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