lsquic_packet_out.h revision a5fa05f9
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * lsquic_packet_out.h -- Structure and routines dealing with packet_out
450aadb33SDmitri Tikhonov */
550aadb33SDmitri Tikhonov
650aadb33SDmitri Tikhonov#ifndef LSQUIC_PACKET_OUT_H
750aadb33SDmitri Tikhonov#define LSQUIC_PACKET_OUT_H 1
850aadb33SDmitri Tikhonov
950aadb33SDmitri Tikhonov#include <sys/queue.h>
1050aadb33SDmitri Tikhonov
1150aadb33SDmitri Tikhonovstruct malo;
129626cfc2SDmitri Tikhonovstruct lsquic_conn;
1350aadb33SDmitri Tikhonovstruct lsquic_engine_public;
1450aadb33SDmitri Tikhonovstruct lsquic_mm;
1550aadb33SDmitri Tikhonovstruct lsquic_stream;
165392f7a3SLiteSpeed Techstruct network_path;
1750aadb33SDmitri Tikhonovstruct parse_funcs;
185392f7a3SLiteSpeed Techstruct bwp_state;
1950aadb33SDmitri Tikhonov
2050aadb33SDmitri Tikhonov/* Each stream_rec is associated with one packet_out.  packet_out can have
2150aadb33SDmitri Tikhonov * zero or more stream_rec structures.  stream_rec keeps a pointer to a stream
224d83f5bdSDmitri Tikhonov * that has STREAM or RST_STREAM frames inside packet_out.  `sr_frame_type'
234d83f5bdSDmitri Tikhonov * specifies the type of the frame; if this value is zero, values of the
244d83f5bdSDmitri Tikhonov * other struct members are not valid.  `sr_off' indicates where inside
254d83f5bdSDmitri Tikhonov * packet_out->po_data the frame begins and `sr_len' is its length.
2650aadb33SDmitri Tikhonov *
27c51ce338SDmitri Tikhonov * We need this information for three reasons:
2850aadb33SDmitri Tikhonov *   1. A stream is not destroyed until all of its STREAM and RST_STREAM
2950aadb33SDmitri Tikhonov *      frames are acknowledged.  This is to make sure that we do not exceed
3050aadb33SDmitri Tikhonov *      maximum allowed number of streams.
3150aadb33SDmitri Tikhonov *   2. When a packet is resubmitted, STREAM frames for a stream that has
3250aadb33SDmitri Tikhonov *      been reset are not to be resubmitted.
33c51ce338SDmitri Tikhonov *   3. A buffered packet may have to be split before it is scheduled (this
34c51ce338SDmitri Tikhonov *      occurs if we guessed incorrectly the number of bytes required to
35c51ce338SDmitri Tikhonov *      encode the packet number and the actual number would make packet
36c51ce338SDmitri Tikhonov *      larger than the max).
37c51ce338SDmitri Tikhonov *
3850aadb33SDmitri Tikhonov */
3950aadb33SDmitri Tikhonovstruct stream_rec {
4050aadb33SDmitri Tikhonov    struct lsquic_stream    *sr_stream;
41c51ce338SDmitri Tikhonov    unsigned short           sr_off,
42c51ce338SDmitri Tikhonov                             sr_len;
436aba801dSDmitri Tikhonov    enum quic_frame_type     sr_frame_type:16;
4450aadb33SDmitri Tikhonov};
4550aadb33SDmitri Tikhonov
464d83f5bdSDmitri Tikhonov#define srec_taken(srec) ((srec)->sr_frame_type)
4750aadb33SDmitri Tikhonov
4850aadb33SDmitri Tikhonovstruct stream_rec_arr {
49c51ce338SDmitri Tikhonov    TAILQ_ENTRY(stream_rec_arr)     next_stream_rec_arr;
5050aadb33SDmitri Tikhonov    struct stream_rec               srecs[
5150aadb33SDmitri Tikhonov      ( 64                              /* Efficient size for malo allocator */
52c51ce338SDmitri Tikhonov      - sizeof(TAILQ_ENTRY(stream_rec)) /* next_stream_rec_arr */
5350aadb33SDmitri Tikhonov      ) / sizeof(struct stream_rec)
5450aadb33SDmitri Tikhonov    ];
5550aadb33SDmitri Tikhonov};
5650aadb33SDmitri Tikhonov
57c51ce338SDmitri TikhonovTAILQ_HEAD(stream_rec_arr_tailq, stream_rec_arr);
58c51ce338SDmitri Tikhonov
595392f7a3SLiteSpeed Tech
6050aadb33SDmitri Tikhonovtypedef struct lsquic_packet_out
6150aadb33SDmitri Tikhonov{
6250aadb33SDmitri Tikhonov    /* `po_next' is used for packets_out, unacked_packets and expired_packets
6350aadb33SDmitri Tikhonov     * lists.
6450aadb33SDmitri Tikhonov     */
6550aadb33SDmitri Tikhonov    TAILQ_ENTRY(lsquic_packet_out)
6650aadb33SDmitri Tikhonov                       po_next;
6750aadb33SDmitri Tikhonov    lsquic_time_t      po_sent;       /* Time sent */
6850aadb33SDmitri Tikhonov    lsquic_packno_t    po_packno;
695392f7a3SLiteSpeed Tech    lsquic_packno_t    po_ack2ed;       /* If packet has ACK frame, value of
705392f7a3SLiteSpeed Tech                                         * largest acked in it.
715392f7a3SLiteSpeed Tech                                         */
725392f7a3SLiteSpeed Tech    struct lsquic_packet_out
735392f7a3SLiteSpeed Tech                      *po_loss_chain;   /* Circular linked list */
7450aadb33SDmitri Tikhonov
755392f7a3SLiteSpeed Tech    enum quic_ft_bit   po_frame_types;  /* Bitmask of QUIC_FRAME_* */
76bfc7bfd8SDmitri Tikhonov    enum packet_out_flags {
775392f7a3SLiteSpeed Tech            /* TODO XXX Phase out PO_MINI in favor of a more specialized flag:
785392f7a3SLiteSpeed Tech             * we only need an indicator that a packet contains STREAM frames
795392f7a3SLiteSpeed Tech             * but no associated srecs.  This type of packets in only created
805392f7a3SLiteSpeed Tech             * by GQUIC mini conn.
815392f7a3SLiteSpeed Tech             */
825392f7a3SLiteSpeed Tech        PO_MINI     = (1 << 0),         /* Allocated by mini connection */
83bfc7bfd8SDmitri Tikhonov        PO_HELLO    = (1 << 1),         /* Packet contains SHLO or CHLO data */
845392f7a3SLiteSpeed Tech        PO_SENT     = (1 << 2),         /* Packet has been sent (mini only) */
85bfc7bfd8SDmitri Tikhonov        PO_ENCRYPTED= (1 << 3),         /* po_enc_data has encrypted data */
86bfc7bfd8SDmitri Tikhonov        PO_SREC_ARR = (1 << 4),
87bfc7bfd8SDmitri Tikhonov#define POBIT_SHIFT 5
88bfc7bfd8SDmitri Tikhonov        PO_BITS_0   = (1 << 5),         /* PO_BITS_0 and PO_BITS_1 encode the */
89bfc7bfd8SDmitri Tikhonov        PO_BITS_1   = (1 << 6),         /*   packet number length.  See macros below. */
90bfc7bfd8SDmitri Tikhonov        PO_NONCE    = (1 << 7),         /* Use value in `po_nonce' to generate header */
91bfc7bfd8SDmitri Tikhonov        PO_VERSION  = (1 << 8),         /* Use value in `po_ver_tag' to generate header */
92bfc7bfd8SDmitri Tikhonov        PO_CONN_ID  = (1 << 9),         /* Include connection ID in public header */
93bfc7bfd8SDmitri Tikhonov        PO_REPACKNO = (1 <<10),         /* Regenerate packet number */
94bfc7bfd8SDmitri Tikhonov        PO_NOENCRYPT= (1 <<11),         /* Do not encrypt data in po_data */
95bfc7bfd8SDmitri Tikhonov        PO_VERNEG   = (1 <<12),         /* Version negotiation packet. */
96bfc7bfd8SDmitri Tikhonov        PO_STREAM_END
97bfc7bfd8SDmitri Tikhonov                    = (1 <<13),         /* STREAM frame reaches the end of the packet: no
98bfc7bfd8SDmitri Tikhonov                                         * further writes are allowed.
99bfc7bfd8SDmitri Tikhonov                                         */
100bfc7bfd8SDmitri Tikhonov        PO_SCHED    = (1 <<14),         /* On scheduled queue */
10116a9b66aSDmitri Tikhonov        PO_SENT_SZ  = (1 <<15),
1027a8b2eceSDmitri Tikhonov        PO_LONGHEAD = (1 <<16),
1031e75f938SDmitri Tikhonov#define POIPv6_SHIFT 20
1041e75f938SDmitri Tikhonov        PO_IPv6     = (1 <<20),         /* Set if pmi_allocate was passed is_ipv6=1,
1051e75f938SDmitri Tikhonov                                         *   otherwise unset.
1061e75f938SDmitri Tikhonov                                         */
1078252b0b9SDmitri Tikhonov        PO_LIMITED  = (1 <<21),         /* Used to credit sc_next_limit if needed. */
1085392f7a3SLiteSpeed Tech#define POPNS_SHIFT 22
1095392f7a3SLiteSpeed Tech        PO_PNS_HSK  = (1 <<22),         /* PNS bits contain the value of the */
1105392f7a3SLiteSpeed Tech        PO_PNS_APP  = (1 <<23),         /*   packet number space. */
1115392f7a3SLiteSpeed Tech        PO_RETRY    = (1 <<24),         /* Retry packet */
1125392f7a3SLiteSpeed Tech        PO_RETX     = (1 <<25),         /* Retransmitted packet: don't append to it */
113de46bf2fSDmitri Tikhonov        PO_POISON   = (1 <<26),         /* Used to detect opt-ACK attack */
1145392f7a3SLiteSpeed Tech        PO_LOSS_REC = (1 <<27),         /* This structure is a loss record */
1155392f7a3SLiteSpeed Tech        /* Only one of PO_SCHED, PO_UNACKED, or PO_LOST can be set.  If pressed
1165392f7a3SLiteSpeed Tech         * for room in the enum, we can switch to using two bits to represent
1175392f7a3SLiteSpeed Tech         * this information.
1185392f7a3SLiteSpeed Tech         */
1195392f7a3SLiteSpeed Tech        PO_UNACKED  = (1 <<28),         /* On unacked queue */
1205392f7a3SLiteSpeed Tech        PO_LOST     = (1 <<29),         /* On lost queue */
1215392f7a3SLiteSpeed Tech#define POSPIN_SHIFT 30
1225392f7a3SLiteSpeed Tech        PO_SPIN_BIT = (1 <<30),         /* Value of the spin bit */
1239626cfc2SDmitri Tikhonov    }                  po_flags;
124bfc7bfd8SDmitri Tikhonov    unsigned short     po_data_sz;      /* Number of usable bytes in data */
125bfc7bfd8SDmitri Tikhonov    unsigned short     po_enc_data_sz;  /* Number of usable bytes in data */
12616a9b66aSDmitri Tikhonov    unsigned short     po_sent_sz;      /* If PO_SENT_SZ is set, real size of sent buffer. */
127bfc7bfd8SDmitri Tikhonov    unsigned short     po_regen_sz;     /* Number of bytes at the beginning
128bfc7bfd8SDmitri Tikhonov                                         * of data containing bytes that are
129bfc7bfd8SDmitri Tikhonov                                         * not to be retransmitted, e.g. ACK
130bfc7bfd8SDmitri Tikhonov                                         * frames.
131bfc7bfd8SDmitri Tikhonov                                         */
132bfc7bfd8SDmitri Tikhonov    unsigned short     po_n_alloc;      /* Total number of bytes allocated in po_data */
1335392f7a3SLiteSpeed Tech    unsigned short     po_token_len;
1349626cfc2SDmitri Tikhonov    enum header_type   po_header_type:8;
1355392f7a3SLiteSpeed Tech    unsigned char      po_path_id;
1365392f7a3SLiteSpeed Tech    enum {
1375392f7a3SLiteSpeed Tech        POL_GQUIC    = 1 << 0,         /* Used for logging */
1385392f7a3SLiteSpeed Tech#define POLEV_SHIFT 1
1395392f7a3SLiteSpeed Tech        POL_ELBIT_0  = 1 << 1,         /* EL bits encode the crypto level. */
1405392f7a3SLiteSpeed Tech        POL_ELBIT_1  = 1 << 2,
1415392f7a3SLiteSpeed Tech#define POKP_SHIFT 3
1429fc12041SDmitri Tikhonov        POL_KEY_PHASE= 1 << 3,
1435392f7a3SLiteSpeed Tech#define POECN_SHIFT 4
1445392f7a3SLiteSpeed Tech        POL_ECNBIT_0 = 1 << 4,
1455392f7a3SLiteSpeed Tech        POL_ECNBIT_1 = 1 << 5,
14602b6086dSDmitri Tikhonov        POL_LOG_QL_BITS = 1 << 6,
14702b6086dSDmitri Tikhonov        POL_SQUARE_BIT = 1 << 7,
14802b6086dSDmitri Tikhonov        POL_LOSS_BIT = 1 << 8,
14902b6086dSDmitri Tikhonov    }                  po_lflags:16;
150bfc7bfd8SDmitri Tikhonov    unsigned char     *po_data;
151bfc7bfd8SDmitri Tikhonov
15250aadb33SDmitri Tikhonov    /* A lot of packets contain data belonging to only one stream.  Thus,
153c51ce338SDmitri Tikhonov     * `one' is used first.  If this is not enough, any number of
15450aadb33SDmitri Tikhonov     * stream_rec_arr structures can be allocated to handle more stream
15550aadb33SDmitri Tikhonov     * records.
15650aadb33SDmitri Tikhonov     */
157c51ce338SDmitri Tikhonov    union {
158c51ce338SDmitri Tikhonov        struct stream_rec               one;
159c51ce338SDmitri Tikhonov        struct stream_rec_arr_tailq     arr;
160c51ce338SDmitri Tikhonov    }                  po_srecs;
16150aadb33SDmitri Tikhonov
16250aadb33SDmitri Tikhonov    /* If PO_ENCRYPTED is set, this points to the buffer that holds encrypted
16350aadb33SDmitri Tikhonov     * data.
16450aadb33SDmitri Tikhonov     */
16550aadb33SDmitri Tikhonov    unsigned char     *po_enc_data;
16650aadb33SDmitri Tikhonov
16750aadb33SDmitri Tikhonov    lsquic_ver_tag_t   po_ver_tag;      /* Set if PO_VERSION is set */
16850aadb33SDmitri Tikhonov    unsigned char     *po_nonce;        /* Use to generate header if PO_NONCE is set */
1695392f7a3SLiteSpeed Tech    const struct network_path
1705392f7a3SLiteSpeed Tech                      *po_path;
1715392f7a3SLiteSpeed Tech#define po_token po_nonce
1725392f7a3SLiteSpeed Tech    struct bwp_state  *po_bwp_state;
17350aadb33SDmitri Tikhonov} lsquic_packet_out_t;
17450aadb33SDmitri Tikhonov
1755392f7a3SLiteSpeed Tech/* This is to make sure these bit names are not used, they are only for
1765392f7a3SLiteSpeed Tech * convenience in gdb output.
1775392f7a3SLiteSpeed Tech */
1785392f7a3SLiteSpeed Tech#define PO_PNS_HSK
1795392f7a3SLiteSpeed Tech#define PO_PNS_APP
1805392f7a3SLiteSpeed Tech
18150aadb33SDmitri Tikhonov/* The size of lsquic_packet_out_t could be further reduced:
18250aadb33SDmitri Tikhonov *
18350aadb33SDmitri Tikhonov * po_ver_tag could be encoded as a few bits representing enum lsquic_version
18450aadb33SDmitri Tikhonov * in po_flags.  The cost is a bit of complexity.  This will save us four bytes.
18550aadb33SDmitri Tikhonov */
18650aadb33SDmitri Tikhonov
18750aadb33SDmitri Tikhonov#define lsquic_packet_out_avail(p) ((unsigned short) \
18850aadb33SDmitri Tikhonov                                        ((p)->po_n_alloc - (p)->po_data_sz))
18950aadb33SDmitri Tikhonov
19050aadb33SDmitri Tikhonov#define lsquic_packet_out_packno_bits(p) (((p)->po_flags >> POBIT_SHIFT) & 0x3)
19150aadb33SDmitri Tikhonov
192bfc7bfd8SDmitri Tikhonov#define lsquic_packet_out_set_packno_bits(p, b) do {                    \
193bfc7bfd8SDmitri Tikhonov    (p)->po_flags &= ~(0x3 << POBIT_SHIFT);                             \
194bfc7bfd8SDmitri Tikhonov    (p)->po_flags |= ((b) & 0x3) << POBIT_SHIFT;                        \
195bfc7bfd8SDmitri Tikhonov} while (0)
196bfc7bfd8SDmitri Tikhonov
1971e75f938SDmitri Tikhonov#define lsquic_packet_out_ipv6(p) ((int)(((p)->po_flags >> POIPv6_SHIFT) & 1))
1981e75f938SDmitri Tikhonov
1991e75f938SDmitri Tikhonov#define lsquic_packet_out_set_ipv6(p, b) do {                           \
2001e75f938SDmitri Tikhonov    (p)->po_flags &= ~(1 << POIPv6_SHIFT);                              \
2011e75f938SDmitri Tikhonov    (p)->po_flags |= ((b) & 1) << POIPv6_SHIFT;                         \
2021e75f938SDmitri Tikhonov} while (0)
2031e75f938SDmitri Tikhonov
2045392f7a3SLiteSpeed Tech#define lsquic_packet_out_spin_bit(p) (((p)->po_flags & PO_SPIN_BIT) > 0)
20502b6086dSDmitri Tikhonov#define lsquic_packet_out_square_bit(p) (((p)->po_lflags & POL_SQUARE_BIT) > 0)
20602b6086dSDmitri Tikhonov#define lsquic_packet_out_loss_bit(p) (((p)->po_lflags & POL_LOSS_BIT) > 0)
2075392f7a3SLiteSpeed Tech
2085392f7a3SLiteSpeed Tech#define lsquic_packet_out_set_spin_bit(p, b) do {                       \
2095392f7a3SLiteSpeed Tech    (p)->po_flags &= ~PO_SPIN_BIT;                                      \
2105392f7a3SLiteSpeed Tech    (p)->po_flags |= ((b) & 1) << POSPIN_SHIFT;                         \
2115392f7a3SLiteSpeed Tech} while (0)
2125392f7a3SLiteSpeed Tech
2135392f7a3SLiteSpeed Tech#define lsquic_po_header_length(lconn, po_flags, dcid_len) ( \
2145392f7a3SLiteSpeed Tech    lconn->cn_pf->pf_packout_max_header_size(lconn, po_flags, dcid_len))
21550aadb33SDmitri Tikhonov
2169626cfc2SDmitri Tikhonov#define lsquic_packet_out_total_sz(lconn, p) (\
2179626cfc2SDmitri Tikhonov    lconn->cn_pf->pf_packout_size(lconn, p))
218bfc7bfd8SDmitri Tikhonov
21916a9b66aSDmitri Tikhonov#if __GNUC__
22016a9b66aSDmitri Tikhonov#if LSQUIC_EXTRA_CHECKS
2219626cfc2SDmitri Tikhonov#define lsquic_packet_out_sent_sz(lconn, p) (                               \
22216a9b66aSDmitri Tikhonov        __builtin_expect(((p)->po_flags & PO_SENT_SZ), 1) ?                 \
2239626cfc2SDmitri Tikhonov        (assert((p)->po_sent_sz == lsquic_packet_out_total_sz(lconn, p)),   \
2249626cfc2SDmitri Tikhonov            (p)->po_sent_sz) : lsquic_packet_out_total_sz(lconn, p))
22516a9b66aSDmitri Tikhonov#   else
2269626cfc2SDmitri Tikhonov#define lsquic_packet_out_sent_sz(lconn, p) (                               \
22716a9b66aSDmitri Tikhonov        __builtin_expect(((p)->po_flags & PO_SENT_SZ), 1) ?                 \
2289626cfc2SDmitri Tikhonov        (p)->po_sent_sz : lsquic_packet_out_total_sz(lconn, p))
22916a9b66aSDmitri Tikhonov#endif
23016a9b66aSDmitri Tikhonov#else
2319626cfc2SDmitri Tikhonov#   define lsquic_packet_out_sent_sz(lconn, p) (                            \
23216a9b66aSDmitri Tikhonov        (p)->po_flags & PO_SENT_SZ ?                                        \
2339626cfc2SDmitri Tikhonov        (p)->po_sent_sz : lsquic_packet_out_total_sz(lconn, p))
23416a9b66aSDmitri Tikhonov#endif
23516a9b66aSDmitri Tikhonov
23650aadb33SDmitri Tikhonov#define lsquic_packet_out_verneg(p) \
2375392f7a3SLiteSpeed Tech    (((p)->po_flags & (PO_NOENCRYPT|PO_VERNEG|PO_RETRY)) == (PO_NOENCRYPT|PO_VERNEG))
23850aadb33SDmitri Tikhonov
23950aadb33SDmitri Tikhonov#define lsquic_packet_out_pubres(p) \
2405392f7a3SLiteSpeed Tech    (((p)->po_flags & (PO_NOENCRYPT|PO_VERNEG|PO_RETRY)) ==  PO_NOENCRYPT           )
2415392f7a3SLiteSpeed Tech
2425392f7a3SLiteSpeed Tech#define lsquic_packet_out_retry(p) \
2435392f7a3SLiteSpeed Tech    (((p)->po_flags & (PO_NOENCRYPT|PO_VERNEG|PO_RETRY)) == (PO_NOENCRYPT|PO_RETRY) )
24450aadb33SDmitri Tikhonov
2459626cfc2SDmitri Tikhonov#define lsquic_packet_out_set_enc_level(p, level) do {                      \
2465392f7a3SLiteSpeed Tech    (p)->po_lflags &= ~(3 << POLEV_SHIFT);                                  \
2475392f7a3SLiteSpeed Tech    (p)->po_lflags |= level << POLEV_SHIFT;                                 \
2485392f7a3SLiteSpeed Tech} while (0)
2495392f7a3SLiteSpeed Tech
2505392f7a3SLiteSpeed Tech#define lsquic_packet_out_enc_level(p)  (((p)->po_lflags >> POLEV_SHIFT) & 3)
2515392f7a3SLiteSpeed Tech
2525392f7a3SLiteSpeed Tech#define lsquic_packet_out_set_kp(p, kp) do {                                \
2535392f7a3SLiteSpeed Tech    (p)->po_lflags &= ~(1 << POKP_SHIFT);                                   \
2545392f7a3SLiteSpeed Tech    (p)->po_lflags |= kp << POKP_SHIFT;                                     \
2555392f7a3SLiteSpeed Tech} while (0)
2565392f7a3SLiteSpeed Tech
2575392f7a3SLiteSpeed Tech#define lsquic_packet_out_kp(p)  (((p)->po_lflags >> POKP_SHIFT) & 1)
2585392f7a3SLiteSpeed Tech
2595392f7a3SLiteSpeed Tech#define lsquic_packet_out_set_pns(p, pns) do {                              \
2605392f7a3SLiteSpeed Tech    (p)->po_flags &= ~(3 << POPNS_SHIFT);                                   \
2615392f7a3SLiteSpeed Tech    (p)->po_flags |= pns << POPNS_SHIFT;                                    \
2625392f7a3SLiteSpeed Tech} while (0)
2635392f7a3SLiteSpeed Tech
2645392f7a3SLiteSpeed Tech#define lsquic_packet_out_pns(p)  (((p)->po_flags >> POPNS_SHIFT) & 3)
2655392f7a3SLiteSpeed Tech
2665392f7a3SLiteSpeed Tech#define lsquic_packet_out_set_ecn(p, ecn) do {                              \
2675392f7a3SLiteSpeed Tech    (p)->po_lflags &= ~(3 << POECN_SHIFT);                                  \
2685392f7a3SLiteSpeed Tech    (p)->po_lflags |= ecn << POECN_SHIFT;                                   \
2699626cfc2SDmitri Tikhonov} while (0)
2709626cfc2SDmitri Tikhonov
2715392f7a3SLiteSpeed Tech#define lsquic_packet_out_ecn(p)  (((p)->po_lflags >> POECN_SHIFT) & 3)
2729626cfc2SDmitri Tikhonov
27350aadb33SDmitri Tikhonovstruct packet_out_srec_iter {
27450aadb33SDmitri Tikhonov    lsquic_packet_out_t         *packet_out;
27550aadb33SDmitri Tikhonov    struct stream_rec_arr       *cur_srec_arr;
27650aadb33SDmitri Tikhonov    unsigned                     srec_idx;
277c51ce338SDmitri Tikhonov    int                          impl_idx;
27850aadb33SDmitri Tikhonov};
27950aadb33SDmitri Tikhonov
2805392f7a3SLiteSpeed Tech
28150aadb33SDmitri Tikhonovstruct stream_rec *
282a5fa05f9SDmitri Tikhonovlsquic_posi_first (struct packet_out_srec_iter *posi, lsquic_packet_out_t *);
28350aadb33SDmitri Tikhonov
28450aadb33SDmitri Tikhonovstruct stream_rec *
285a5fa05f9SDmitri Tikhonovlsquic_posi_next (struct packet_out_srec_iter *posi);
28650aadb33SDmitri Tikhonov
28750aadb33SDmitri Tikhonovlsquic_packet_out_t *
28850aadb33SDmitri Tikhonovlsquic_packet_out_new (struct lsquic_mm *, struct malo *, int use_cid,
289c7d81ce1SDmitri Tikhonov                       const struct lsquic_conn *, enum packno_bits,
2905392f7a3SLiteSpeed Tech                       const lsquic_ver_tag_t *, const unsigned char *nonce,
2915392f7a3SLiteSpeed Tech                       const struct network_path *);
29250aadb33SDmitri Tikhonov
29350aadb33SDmitri Tikhonovvoid
29450aadb33SDmitri Tikhonovlsquic_packet_out_destroy (lsquic_packet_out_t *,
2951e75f938SDmitri Tikhonov                        struct lsquic_engine_public *, void *peer_ctx);
29650aadb33SDmitri Tikhonov
29750aadb33SDmitri Tikhonovint
29850aadb33SDmitri Tikhonovlsquic_packet_out_add_stream (lsquic_packet_out_t *packet_out,
29950aadb33SDmitri Tikhonov                              struct lsquic_mm *mm,
30050aadb33SDmitri Tikhonov                              struct lsquic_stream *new_stream,
3016aba801dSDmitri Tikhonov                              enum quic_frame_type,
302c51ce338SDmitri Tikhonov                              unsigned short off, unsigned short len);
30350aadb33SDmitri Tikhonov
304bfc7bfd8SDmitri Tikhonovunsigned
3055392f7a3SLiteSpeed Techlsquic_packet_out_elide_reset_stream_frames (lsquic_packet_out_t *,
3065392f7a3SLiteSpeed Tech                                                    lsquic_stream_id_t);
307c51ce338SDmitri Tikhonov
308c51ce338SDmitri Tikhonovint
309c51ce338SDmitri Tikhonovlsquic_packet_out_split_in_two (struct lsquic_mm *, lsquic_packet_out_t *,
310c51ce338SDmitri Tikhonov    lsquic_packet_out_t *, const struct parse_funcs *, unsigned excess_bytes);
31150aadb33SDmitri Tikhonov
31250aadb33SDmitri Tikhonovvoid
31350aadb33SDmitri Tikhonovlsquic_packet_out_chop_regen (lsquic_packet_out_t *);
31450aadb33SDmitri Tikhonov
315c51ce338SDmitri Tikhonovvoid
316c51ce338SDmitri Tikhonovlsquic_packet_out_ack_streams (struct lsquic_packet_out *);
317c51ce338SDmitri Tikhonov
318c51ce338SDmitri Tikhonovvoid
319c51ce338SDmitri Tikhonovlsquic_packet_out_zero_pad (struct lsquic_packet_out *);
320c51ce338SDmitri Tikhonov
321c51ce338SDmitri Tikhonovsize_t
322c51ce338SDmitri Tikhonovlsquic_packet_out_mem_used (const struct lsquic_packet_out *);
323c51ce338SDmitri Tikhonov
324c51ce338SDmitri Tikhonovint
325c51ce338SDmitri Tikhonovlsquic_packet_out_turn_on_fin (struct lsquic_packet_out *,
326c51ce338SDmitri Tikhonov                   const struct parse_funcs *, const struct lsquic_stream *);
327c51ce338SDmitri Tikhonov
32850aadb33SDmitri Tikhonov#endif
329