lsquic_packet_resize.h revision b8fa6195
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_packet_resize.h -- functions to resize packets 4 */ 5 6#ifndef LSQUIC_PACKET_RESIZE_H 7#define LSQUIC_PACKET_RESIZE_H 1 8 9struct lsquic_packet_out; 10struct lsquic_conn; 11struct frame_rec; 12struct lsquic_engine_public; 13 14struct packet_resize_if 15{ 16 /* Get next packet to convert */ 17 struct lsquic_packet_out * 18 (*pri_next_packet)(void *ctx); 19 /* Discard packet after it was converted */ 20 void (*pri_discard_packet)(void *ctx, struct lsquic_packet_out *); 21 /* Get new packet to write frames to */ 22 struct lsquic_packet_out * 23 (*pri_new_packet)(void *ctx); 24}; 25 26struct packet_resize_ctx 27{ 28 const struct lsquic_conn *prc_conn; 29 void *prc_data; /* First arg to prc_pri */ 30 const struct packet_resize_if *prc_pri; 31 struct lsquic_engine_public *prc_enpub; 32 const struct frame_rec *prc_cur_frec; 33 struct lsquic_packet_out *prc_cur_packet; 34 struct data_frame prc_data_frame; 35 struct packet_out_frec_iter prc_pofi; 36 enum { 37 PRC_ERROR = 1 << 0, 38 PRC_NEW_FREC = 1 << 1, 39 } prc_flags; 40}; 41 42void 43lsquic_packet_resize_init (struct packet_resize_ctx *, 44 struct lsquic_engine_public *, struct lsquic_conn *, void *ctx, 45 const struct packet_resize_if *); 46 47struct lsquic_packet_out * 48lsquic_packet_resize_next (struct packet_resize_ctx *); 49 50#define lsquic_packet_resize_is_error(prctx_) \ 51 (!!((prctx_)->prc_flags & PRC_ERROR)) 52 53#endif 54