lsquic_parse_gquic_common.c revision 1b97e4af
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * lsquic_parse_gquic_common.c -- Parsing functions common to GQUIC
450aadb33SDmitri Tikhonov */
550aadb33SDmitri Tikhonov
650aadb33SDmitri Tikhonov#include <assert.h>
750aadb33SDmitri Tikhonov#include <errno.h>
850aadb33SDmitri Tikhonov#include <inttypes.h>
950aadb33SDmitri Tikhonov#include <string.h>
1050aadb33SDmitri Tikhonov#include <stdlib.h>
1150aadb33SDmitri Tikhonov#include <sys/types.h>
1250aadb33SDmitri Tikhonov
1350aadb33SDmitri Tikhonov#include "lsquic_types.h"
1450aadb33SDmitri Tikhonov#include "lsquic_packet_common.h"
1550aadb33SDmitri Tikhonov#include "lsquic_packet_in.h"
1650aadb33SDmitri Tikhonov#include "lsquic_parse.h"
1750aadb33SDmitri Tikhonov#include "lsquic.h"
1850aadb33SDmitri Tikhonov
1950aadb33SDmitri Tikhonov#define LSQUIC_LOGGER_MODULE LSQLM_PARSE
2050aadb33SDmitri Tikhonov#include "lsquic_logger.h"
2150aadb33SDmitri Tikhonov
2250aadb33SDmitri Tikhonov#define CHECK_SPACE(need, pstart, pend)  \
2350aadb33SDmitri Tikhonov    do { if ((intptr_t) (need) > ((pend) - (pstart))) { return -1; } } while (0)
2450aadb33SDmitri Tikhonov
2550aadb33SDmitri Tikhonov/* This partially parses `packet_in' and returns 0 if in case it succeeded and
2650aadb33SDmitri Tikhonov * -1 on failure.
2750aadb33SDmitri Tikhonov *
2850aadb33SDmitri Tikhonov * After this function returns 0, connection ID, nonce, and version fields can
2950aadb33SDmitri Tikhonov * be examined.  To finsh parsing the packet, call version-specific
3050aadb33SDmitri Tikhonov * pf_parse_packet_in_finish() routine.
3150aadb33SDmitri Tikhonov */
3250aadb33SDmitri Tikhonovint
3350aadb33SDmitri Tikhonovparse_packet_in_begin (lsquic_packet_in_t *packet_in, size_t length,
3450aadb33SDmitri Tikhonov                            int is_server, struct packin_parse_state *state)
3550aadb33SDmitri Tikhonov{
3650aadb33SDmitri Tikhonov    int nbytes;
3750aadb33SDmitri Tikhonov    enum PACKET_PUBLIC_FLAGS public_flags;
3850aadb33SDmitri Tikhonov    const unsigned char *p = packet_in->pi_data;
3950aadb33SDmitri Tikhonov    const unsigned char *const pend = packet_in->pi_data + length;
4050aadb33SDmitri Tikhonov
4150aadb33SDmitri Tikhonov    CHECK_SPACE(1, p, pend);
4250aadb33SDmitri Tikhonov
4350aadb33SDmitri Tikhonov    public_flags = *p++;
4450aadb33SDmitri Tikhonov
4550aadb33SDmitri Tikhonov    if (public_flags & PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID)
4650aadb33SDmitri Tikhonov    {
4750aadb33SDmitri Tikhonov        CHECK_SPACE(8, p, pend);
4850aadb33SDmitri Tikhonov        memcpy(&packet_in->pi_conn_id, p, 8);
4950aadb33SDmitri Tikhonov        packet_in->pi_flags |= PI_CONN_ID;
5050aadb33SDmitri Tikhonov        p += 8;
5150aadb33SDmitri Tikhonov    }
5250aadb33SDmitri Tikhonov
5350aadb33SDmitri Tikhonov    if (public_flags & PACKET_PUBLIC_FLAGS_VERSION)
5450aadb33SDmitri Tikhonov    {
5550aadb33SDmitri Tikhonov        /* It seems that version negotiation packets sent by Google may have
5650aadb33SDmitri Tikhonov         * NONCE bit set.  Ignore it:
5750aadb33SDmitri Tikhonov         */
5850aadb33SDmitri Tikhonov        public_flags &= ~PACKET_PUBLIC_FLAGS_NONCE;
5950aadb33SDmitri Tikhonov
6050aadb33SDmitri Tikhonov        if (is_server)
6150aadb33SDmitri Tikhonov        {
6250aadb33SDmitri Tikhonov            CHECK_SPACE(4, p, pend);
6350aadb33SDmitri Tikhonov            packet_in->pi_quic_ver = p - packet_in->pi_data;
6450aadb33SDmitri Tikhonov            p += 4;
6550aadb33SDmitri Tikhonov        }
6650aadb33SDmitri Tikhonov        else
6750aadb33SDmitri Tikhonov        {   /* OK, we have a version negotiation packet.  We need to verify
6850aadb33SDmitri Tikhonov             * that it has correct structure.  See Section 4.3 of
6950aadb33SDmitri Tikhonov             * [draft-ietf-quic-transport-00].
7050aadb33SDmitri Tikhonov             */
7150aadb33SDmitri Tikhonov            if ((public_flags & ~(PACKET_PUBLIC_FLAGS_VERSION|
7250aadb33SDmitri Tikhonov                                  PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID))
7350aadb33SDmitri Tikhonov                || ((pend - p) & 3))
7450aadb33SDmitri Tikhonov                return -1;
7550aadb33SDmitri Tikhonov            CHECK_SPACE(4, p, pend);
7650aadb33SDmitri Tikhonov            packet_in->pi_quic_ver = p - packet_in->pi_data;
7750aadb33SDmitri Tikhonov            p = pend;
7850aadb33SDmitri Tikhonov        }
7950aadb33SDmitri Tikhonov    }
8050aadb33SDmitri Tikhonov    else
8150aadb33SDmitri Tikhonov    {
8250aadb33SDmitri Tikhonov        /* From [draft-hamilton-quic-transport-protocol-01]:
8350aadb33SDmitri Tikhonov         *    0x40 = MULTIPATH. This bit is reserved for multipath use.
8450aadb33SDmitri Tikhonov         *    0x80 is currently unused, and must be set to 0.
8550aadb33SDmitri Tikhonov         *
8650aadb33SDmitri Tikhonov         * The reference implementation checks that two high bits are not set
8750aadb33SDmitri Tikhonov         * if version flag is not set or if the version is the same.  For our
8850aadb33SDmitri Tikhonov         * purposes, all GQUIC version we support so far have these bits set
8950aadb33SDmitri Tikhonov         * to zero.
9050aadb33SDmitri Tikhonov         */
9150aadb33SDmitri Tikhonov        if (public_flags & (0x80|0x40))
9250aadb33SDmitri Tikhonov            return -1;
9350aadb33SDmitri Tikhonov        packet_in->pi_quic_ver = 0;
9450aadb33SDmitri Tikhonov    }
9550aadb33SDmitri Tikhonov
9650aadb33SDmitri Tikhonov    if (!is_server && (public_flags & PACKET_PUBLIC_FLAGS_NONCE) ==
9750aadb33SDmitri Tikhonov                                            PACKET_PUBLIC_FLAGS_NONCE)
9850aadb33SDmitri Tikhonov    {
9950aadb33SDmitri Tikhonov        CHECK_SPACE(32, p, pend);
10050aadb33SDmitri Tikhonov        packet_in->pi_nonce = p - packet_in->pi_data;
10150aadb33SDmitri Tikhonov        p += 32;
10250aadb33SDmitri Tikhonov    }
10350aadb33SDmitri Tikhonov    else
10450aadb33SDmitri Tikhonov        packet_in->pi_nonce = 0;
10550aadb33SDmitri Tikhonov
10650aadb33SDmitri Tikhonov    state->pps_p = p;
10750aadb33SDmitri Tikhonov
10850aadb33SDmitri Tikhonov    packet_in->pi_packno = 0;
10950aadb33SDmitri Tikhonov    if (0 == (public_flags & (PACKET_PUBLIC_FLAGS_VERSION|PACKET_PUBLIC_FLAGS_RST))
11050aadb33SDmitri Tikhonov        || ((public_flags & PACKET_PUBLIC_FLAGS_VERSION) && is_server))
11150aadb33SDmitri Tikhonov    {
11250aadb33SDmitri Tikhonov        nbytes = twobit_to_1246((public_flags >> 4) & 3);
11350aadb33SDmitri Tikhonov        CHECK_SPACE(nbytes, p, pend);
11450aadb33SDmitri Tikhonov        p += nbytes;
11550aadb33SDmitri Tikhonov        state->pps_nbytes = nbytes;
11650aadb33SDmitri Tikhonov    }
11750aadb33SDmitri Tikhonov    else
11850aadb33SDmitri Tikhonov        state->pps_nbytes = 0;
11950aadb33SDmitri Tikhonov
12050aadb33SDmitri Tikhonov    packet_in->pi_header_sz    = p - packet_in->pi_data;
12150aadb33SDmitri Tikhonov    packet_in->pi_frame_types  = 0;
12250aadb33SDmitri Tikhonov    memset(&packet_in->pi_next, 0, sizeof(packet_in->pi_next));
12350aadb33SDmitri Tikhonov    packet_in->pi_data_sz      = length;
12450aadb33SDmitri Tikhonov    packet_in->pi_refcnt       = 0;
12550aadb33SDmitri Tikhonov    packet_in->pi_received     = 0;
12650aadb33SDmitri Tikhonov
12750aadb33SDmitri Tikhonov    return 0;
12850aadb33SDmitri Tikhonov}
12950aadb33SDmitri Tikhonov
13050aadb33SDmitri Tikhonov
13150aadb33SDmitri Tikhonovstatic const enum QUIC_FRAME_TYPE byte2frame_type_Q035_thru_Q039[0x100] =
13250aadb33SDmitri Tikhonov{
13350aadb33SDmitri Tikhonov    [0x00] = QUIC_FRAME_PADDING,
13450aadb33SDmitri Tikhonov    [0x01] = QUIC_FRAME_RST_STREAM,
13550aadb33SDmitri Tikhonov    [0x02] = QUIC_FRAME_CONNECTION_CLOSE,
13650aadb33SDmitri Tikhonov    [0x03] = QUIC_FRAME_GOAWAY,
13750aadb33SDmitri Tikhonov    [0x04] = QUIC_FRAME_WINDOW_UPDATE,
13850aadb33SDmitri Tikhonov    [0x05] = QUIC_FRAME_BLOCKED,
13950aadb33SDmitri Tikhonov    [0x06] = QUIC_FRAME_STOP_WAITING,
14050aadb33SDmitri Tikhonov    [0x07] = QUIC_FRAME_PING,
14150aadb33SDmitri Tikhonov    [0x08] = QUIC_FRAME_INVALID,
14250aadb33SDmitri Tikhonov    [0x09] = QUIC_FRAME_INVALID,
14350aadb33SDmitri Tikhonov    [0x0A] = QUIC_FRAME_INVALID,
14450aadb33SDmitri Tikhonov    [0x0B] = QUIC_FRAME_INVALID,
14550aadb33SDmitri Tikhonov    [0x0C] = QUIC_FRAME_INVALID,
14650aadb33SDmitri Tikhonov    [0x0D] = QUIC_FRAME_INVALID,
14750aadb33SDmitri Tikhonov    [0x0E] = QUIC_FRAME_INVALID,
14850aadb33SDmitri Tikhonov    [0x0F] = QUIC_FRAME_INVALID,
14950aadb33SDmitri Tikhonov    [0x10] = QUIC_FRAME_INVALID,
15050aadb33SDmitri Tikhonov    [0x11] = QUIC_FRAME_INVALID,
15150aadb33SDmitri Tikhonov    [0x12] = QUIC_FRAME_INVALID,
15250aadb33SDmitri Tikhonov    [0x13] = QUIC_FRAME_INVALID,
15350aadb33SDmitri Tikhonov    [0x14] = QUIC_FRAME_INVALID,
15450aadb33SDmitri Tikhonov    [0x15] = QUIC_FRAME_INVALID,
15550aadb33SDmitri Tikhonov    [0x16] = QUIC_FRAME_INVALID,
15650aadb33SDmitri Tikhonov    [0x17] = QUIC_FRAME_INVALID,
15750aadb33SDmitri Tikhonov    [0x18] = QUIC_FRAME_INVALID,
15850aadb33SDmitri Tikhonov    [0x19] = QUIC_FRAME_INVALID,
15950aadb33SDmitri Tikhonov    [0x1A] = QUIC_FRAME_INVALID,
16050aadb33SDmitri Tikhonov    [0x1B] = QUIC_FRAME_INVALID,
16150aadb33SDmitri Tikhonov    [0x1C] = QUIC_FRAME_INVALID,
16250aadb33SDmitri Tikhonov    [0x1D] = QUIC_FRAME_INVALID,
16350aadb33SDmitri Tikhonov    [0x1E] = QUIC_FRAME_INVALID,
16450aadb33SDmitri Tikhonov    [0x1F] = QUIC_FRAME_INVALID,
16550aadb33SDmitri Tikhonov    [0x20] = QUIC_FRAME_INVALID,
16650aadb33SDmitri Tikhonov    [0x21] = QUIC_FRAME_INVALID,
16750aadb33SDmitri Tikhonov    [0x22] = QUIC_FRAME_INVALID,
16850aadb33SDmitri Tikhonov    [0x23] = QUIC_FRAME_INVALID,
16950aadb33SDmitri Tikhonov    [0x24] = QUIC_FRAME_INVALID,
17050aadb33SDmitri Tikhonov    [0x25] = QUIC_FRAME_INVALID,
17150aadb33SDmitri Tikhonov    [0x26] = QUIC_FRAME_INVALID,
17250aadb33SDmitri Tikhonov    [0x27] = QUIC_FRAME_INVALID,
17350aadb33SDmitri Tikhonov    [0x28] = QUIC_FRAME_INVALID,
17450aadb33SDmitri Tikhonov    [0x29] = QUIC_FRAME_INVALID,
17550aadb33SDmitri Tikhonov    [0x2A] = QUIC_FRAME_INVALID,
17650aadb33SDmitri Tikhonov    [0x2B] = QUIC_FRAME_INVALID,
17750aadb33SDmitri Tikhonov    [0x2C] = QUIC_FRAME_INVALID,
17850aadb33SDmitri Tikhonov    [0x2D] = QUIC_FRAME_INVALID,
17950aadb33SDmitri Tikhonov    [0x2E] = QUIC_FRAME_INVALID,
18050aadb33SDmitri Tikhonov    [0x2F] = QUIC_FRAME_INVALID,
18150aadb33SDmitri Tikhonov    [0x30] = QUIC_FRAME_INVALID,
18250aadb33SDmitri Tikhonov    [0x31] = QUIC_FRAME_INVALID,
18350aadb33SDmitri Tikhonov    [0x32] = QUIC_FRAME_INVALID,
18450aadb33SDmitri Tikhonov    [0x33] = QUIC_FRAME_INVALID,
18550aadb33SDmitri Tikhonov    [0x34] = QUIC_FRAME_INVALID,
18650aadb33SDmitri Tikhonov    [0x35] = QUIC_FRAME_INVALID,
18750aadb33SDmitri Tikhonov    [0x36] = QUIC_FRAME_INVALID,
18850aadb33SDmitri Tikhonov    [0x37] = QUIC_FRAME_INVALID,
18950aadb33SDmitri Tikhonov    [0x38] = QUIC_FRAME_INVALID,
19050aadb33SDmitri Tikhonov    [0x39] = QUIC_FRAME_INVALID,
19150aadb33SDmitri Tikhonov    [0x3A] = QUIC_FRAME_INVALID,
19250aadb33SDmitri Tikhonov    [0x3B] = QUIC_FRAME_INVALID,
19350aadb33SDmitri Tikhonov    [0x3C] = QUIC_FRAME_INVALID,
19450aadb33SDmitri Tikhonov    [0x3D] = QUIC_FRAME_INVALID,
19550aadb33SDmitri Tikhonov    [0x3E] = QUIC_FRAME_INVALID,
19650aadb33SDmitri Tikhonov    [0x3F] = QUIC_FRAME_INVALID,
19750aadb33SDmitri Tikhonov    [0x40] = QUIC_FRAME_ACK,
19850aadb33SDmitri Tikhonov    [0x41] = QUIC_FRAME_ACK,
19950aadb33SDmitri Tikhonov    [0x42] = QUIC_FRAME_ACK,
20050aadb33SDmitri Tikhonov    [0x43] = QUIC_FRAME_ACK,
20150aadb33SDmitri Tikhonov    [0x44] = QUIC_FRAME_ACK,
20250aadb33SDmitri Tikhonov    [0x45] = QUIC_FRAME_ACK,
20350aadb33SDmitri Tikhonov    [0x46] = QUIC_FRAME_ACK,
20450aadb33SDmitri Tikhonov    [0x47] = QUIC_FRAME_ACK,
20550aadb33SDmitri Tikhonov    [0x48] = QUIC_FRAME_ACK,
20650aadb33SDmitri Tikhonov    [0x49] = QUIC_FRAME_ACK,
20750aadb33SDmitri Tikhonov    [0x4A] = QUIC_FRAME_ACK,
20850aadb33SDmitri Tikhonov    [0x4B] = QUIC_FRAME_ACK,
20950aadb33SDmitri Tikhonov    [0x4C] = QUIC_FRAME_ACK,
21050aadb33SDmitri Tikhonov    [0x4D] = QUIC_FRAME_ACK,
21150aadb33SDmitri Tikhonov    [0x4E] = QUIC_FRAME_ACK,
21250aadb33SDmitri Tikhonov    [0x4F] = QUIC_FRAME_ACK,
21350aadb33SDmitri Tikhonov    [0x50] = QUIC_FRAME_ACK,
21450aadb33SDmitri Tikhonov    [0x51] = QUIC_FRAME_ACK,
21550aadb33SDmitri Tikhonov    [0x52] = QUIC_FRAME_ACK,
21650aadb33SDmitri Tikhonov    [0x53] = QUIC_FRAME_ACK,
21750aadb33SDmitri Tikhonov    [0x54] = QUIC_FRAME_ACK,
21850aadb33SDmitri Tikhonov    [0x55] = QUIC_FRAME_ACK,
21950aadb33SDmitri Tikhonov    [0x56] = QUIC_FRAME_ACK,
22050aadb33SDmitri Tikhonov    [0x57] = QUIC_FRAME_ACK,
22150aadb33SDmitri Tikhonov    [0x58] = QUIC_FRAME_ACK,
22250aadb33SDmitri Tikhonov    [0x59] = QUIC_FRAME_ACK,
22350aadb33SDmitri Tikhonov    [0x5A] = QUIC_FRAME_ACK,
22450aadb33SDmitri Tikhonov    [0x5B] = QUIC_FRAME_ACK,
22550aadb33SDmitri Tikhonov    [0x5C] = QUIC_FRAME_ACK,
22650aadb33SDmitri Tikhonov    [0x5D] = QUIC_FRAME_ACK,
22750aadb33SDmitri Tikhonov    [0x5E] = QUIC_FRAME_ACK,
22850aadb33SDmitri Tikhonov    [0x5F] = QUIC_FRAME_ACK,
22950aadb33SDmitri Tikhonov    [0x60] = QUIC_FRAME_ACK,
23050aadb33SDmitri Tikhonov    [0x61] = QUIC_FRAME_ACK,
23150aadb33SDmitri Tikhonov    [0x62] = QUIC_FRAME_ACK,
23250aadb33SDmitri Tikhonov    [0x63] = QUIC_FRAME_ACK,
23350aadb33SDmitri Tikhonov    [0x64] = QUIC_FRAME_ACK,
23450aadb33SDmitri Tikhonov    [0x65] = QUIC_FRAME_ACK,
23550aadb33SDmitri Tikhonov    [0x66] = QUIC_FRAME_ACK,
23650aadb33SDmitri Tikhonov    [0x67] = QUIC_FRAME_ACK,
23750aadb33SDmitri Tikhonov    [0x68] = QUIC_FRAME_ACK,
23850aadb33SDmitri Tikhonov    [0x69] = QUIC_FRAME_ACK,
23950aadb33SDmitri Tikhonov    [0x6A] = QUIC_FRAME_ACK,
24050aadb33SDmitri Tikhonov    [0x6B] = QUIC_FRAME_ACK,
24150aadb33SDmitri Tikhonov    [0x6C] = QUIC_FRAME_ACK,
24250aadb33SDmitri Tikhonov    [0x6D] = QUIC_FRAME_ACK,
24350aadb33SDmitri Tikhonov    [0x6E] = QUIC_FRAME_ACK,
24450aadb33SDmitri Tikhonov    [0x6F] = QUIC_FRAME_ACK,
24550aadb33SDmitri Tikhonov    [0x70] = QUIC_FRAME_ACK,
24650aadb33SDmitri Tikhonov    [0x71] = QUIC_FRAME_ACK,
24750aadb33SDmitri Tikhonov    [0x72] = QUIC_FRAME_ACK,
24850aadb33SDmitri Tikhonov    [0x73] = QUIC_FRAME_ACK,
24950aadb33SDmitri Tikhonov    [0x74] = QUIC_FRAME_ACK,
25050aadb33SDmitri Tikhonov    [0x75] = QUIC_FRAME_ACK,
25150aadb33SDmitri Tikhonov    [0x76] = QUIC_FRAME_ACK,
25250aadb33SDmitri Tikhonov    [0x77] = QUIC_FRAME_ACK,
25350aadb33SDmitri Tikhonov    [0x78] = QUIC_FRAME_ACK,
25450aadb33SDmitri Tikhonov    [0x79] = QUIC_FRAME_ACK,
25550aadb33SDmitri Tikhonov    [0x7A] = QUIC_FRAME_ACK,
25650aadb33SDmitri Tikhonov    [0x7B] = QUIC_FRAME_ACK,
25750aadb33SDmitri Tikhonov    [0x7C] = QUIC_FRAME_ACK,
25850aadb33SDmitri Tikhonov    [0x7D] = QUIC_FRAME_ACK,
25950aadb33SDmitri Tikhonov    [0x7E] = QUIC_FRAME_ACK,
26050aadb33SDmitri Tikhonov    [0x7F] = QUIC_FRAME_ACK,
26150aadb33SDmitri Tikhonov    [0x80] = QUIC_FRAME_STREAM,
26250aadb33SDmitri Tikhonov    [0x81] = QUIC_FRAME_STREAM,
26350aadb33SDmitri Tikhonov    [0x82] = QUIC_FRAME_STREAM,
26450aadb33SDmitri Tikhonov    [0x83] = QUIC_FRAME_STREAM,
26550aadb33SDmitri Tikhonov    [0x84] = QUIC_FRAME_STREAM,
26650aadb33SDmitri Tikhonov    [0x85] = QUIC_FRAME_STREAM,
26750aadb33SDmitri Tikhonov    [0x86] = QUIC_FRAME_STREAM,
26850aadb33SDmitri Tikhonov    [0x87] = QUIC_FRAME_STREAM,
26950aadb33SDmitri Tikhonov    [0x88] = QUIC_FRAME_STREAM,
27050aadb33SDmitri Tikhonov    [0x89] = QUIC_FRAME_STREAM,
27150aadb33SDmitri Tikhonov    [0x8A] = QUIC_FRAME_STREAM,
27250aadb33SDmitri Tikhonov    [0x8B] = QUIC_FRAME_STREAM,
27350aadb33SDmitri Tikhonov    [0x8C] = QUIC_FRAME_STREAM,
27450aadb33SDmitri Tikhonov    [0x8D] = QUIC_FRAME_STREAM,
27550aadb33SDmitri Tikhonov    [0x8E] = QUIC_FRAME_STREAM,
27650aadb33SDmitri Tikhonov    [0x8F] = QUIC_FRAME_STREAM,
27750aadb33SDmitri Tikhonov    [0x90] = QUIC_FRAME_STREAM,
27850aadb33SDmitri Tikhonov    [0x91] = QUIC_FRAME_STREAM,
27950aadb33SDmitri Tikhonov    [0x92] = QUIC_FRAME_STREAM,
28050aadb33SDmitri Tikhonov    [0x93] = QUIC_FRAME_STREAM,
28150aadb33SDmitri Tikhonov    [0x94] = QUIC_FRAME_STREAM,
28250aadb33SDmitri Tikhonov    [0x95] = QUIC_FRAME_STREAM,
28350aadb33SDmitri Tikhonov    [0x96] = QUIC_FRAME_STREAM,
28450aadb33SDmitri Tikhonov    [0x97] = QUIC_FRAME_STREAM,
28550aadb33SDmitri Tikhonov    [0x98] = QUIC_FRAME_STREAM,
28650aadb33SDmitri Tikhonov    [0x99] = QUIC_FRAME_STREAM,
28750aadb33SDmitri Tikhonov    [0x9A] = QUIC_FRAME_STREAM,
28850aadb33SDmitri Tikhonov    [0x9B] = QUIC_FRAME_STREAM,
28950aadb33SDmitri Tikhonov    [0x9C] = QUIC_FRAME_STREAM,
29050aadb33SDmitri Tikhonov    [0x9D] = QUIC_FRAME_STREAM,
29150aadb33SDmitri Tikhonov    [0x9E] = QUIC_FRAME_STREAM,
29250aadb33SDmitri Tikhonov    [0x9F] = QUIC_FRAME_STREAM,
29350aadb33SDmitri Tikhonov    [0xA0] = QUIC_FRAME_STREAM,
29450aadb33SDmitri Tikhonov    [0xA1] = QUIC_FRAME_STREAM,
29550aadb33SDmitri Tikhonov    [0xA2] = QUIC_FRAME_STREAM,
29650aadb33SDmitri Tikhonov    [0xA3] = QUIC_FRAME_STREAM,
29750aadb33SDmitri Tikhonov    [0xA4] = QUIC_FRAME_STREAM,
29850aadb33SDmitri Tikhonov    [0xA5] = QUIC_FRAME_STREAM,
29950aadb33SDmitri Tikhonov    [0xA6] = QUIC_FRAME_STREAM,
30050aadb33SDmitri Tikhonov    [0xA7] = QUIC_FRAME_STREAM,
30150aadb33SDmitri Tikhonov    [0xA8] = QUIC_FRAME_STREAM,
30250aadb33SDmitri Tikhonov    [0xA9] = QUIC_FRAME_STREAM,
30350aadb33SDmitri Tikhonov    [0xAA] = QUIC_FRAME_STREAM,
30450aadb33SDmitri Tikhonov    [0xAB] = QUIC_FRAME_STREAM,
30550aadb33SDmitri Tikhonov    [0xAC] = QUIC_FRAME_STREAM,
30650aadb33SDmitri Tikhonov    [0xAD] = QUIC_FRAME_STREAM,
30750aadb33SDmitri Tikhonov    [0xAE] = QUIC_FRAME_STREAM,
30850aadb33SDmitri Tikhonov    [0xAF] = QUIC_FRAME_STREAM,
30950aadb33SDmitri Tikhonov    [0xB0] = QUIC_FRAME_STREAM,
31050aadb33SDmitri Tikhonov    [0xB1] = QUIC_FRAME_STREAM,
31150aadb33SDmitri Tikhonov    [0xB2] = QUIC_FRAME_STREAM,
31250aadb33SDmitri Tikhonov    [0xB3] = QUIC_FRAME_STREAM,
31350aadb33SDmitri Tikhonov    [0xB4] = QUIC_FRAME_STREAM,
31450aadb33SDmitri Tikhonov    [0xB5] = QUIC_FRAME_STREAM,
31550aadb33SDmitri Tikhonov    [0xB6] = QUIC_FRAME_STREAM,
31650aadb33SDmitri Tikhonov    [0xB7] = QUIC_FRAME_STREAM,
31750aadb33SDmitri Tikhonov    [0xB8] = QUIC_FRAME_STREAM,
31850aadb33SDmitri Tikhonov    [0xB9] = QUIC_FRAME_STREAM,
31950aadb33SDmitri Tikhonov    [0xBA] = QUIC_FRAME_STREAM,
32050aadb33SDmitri Tikhonov    [0xBB] = QUIC_FRAME_STREAM,
32150aadb33SDmitri Tikhonov    [0xBC] = QUIC_FRAME_STREAM,
32250aadb33SDmitri Tikhonov    [0xBD] = QUIC_FRAME_STREAM,
32350aadb33SDmitri Tikhonov    [0xBE] = QUIC_FRAME_STREAM,
32450aadb33SDmitri Tikhonov    [0xBF] = QUIC_FRAME_STREAM,
32550aadb33SDmitri Tikhonov    [0xC0] = QUIC_FRAME_STREAM,
32650aadb33SDmitri Tikhonov    [0xC1] = QUIC_FRAME_STREAM,
32750aadb33SDmitri Tikhonov    [0xC2] = QUIC_FRAME_STREAM,
32850aadb33SDmitri Tikhonov    [0xC3] = QUIC_FRAME_STREAM,
32950aadb33SDmitri Tikhonov    [0xC4] = QUIC_FRAME_STREAM,
33050aadb33SDmitri Tikhonov    [0xC5] = QUIC_FRAME_STREAM,
33150aadb33SDmitri Tikhonov    [0xC6] = QUIC_FRAME_STREAM,
33250aadb33SDmitri Tikhonov    [0xC7] = QUIC_FRAME_STREAM,
33350aadb33SDmitri Tikhonov    [0xC8] = QUIC_FRAME_STREAM,
33450aadb33SDmitri Tikhonov    [0xC9] = QUIC_FRAME_STREAM,
33550aadb33SDmitri Tikhonov    [0xCA] = QUIC_FRAME_STREAM,
33650aadb33SDmitri Tikhonov    [0xCB] = QUIC_FRAME_STREAM,
33750aadb33SDmitri Tikhonov    [0xCC] = QUIC_FRAME_STREAM,
33850aadb33SDmitri Tikhonov    [0xCD] = QUIC_FRAME_STREAM,
33950aadb33SDmitri Tikhonov    [0xCE] = QUIC_FRAME_STREAM,
34050aadb33SDmitri Tikhonov    [0xCF] = QUIC_FRAME_STREAM,
34150aadb33SDmitri Tikhonov    [0xD0] = QUIC_FRAME_STREAM,
34250aadb33SDmitri Tikhonov    [0xD1] = QUIC_FRAME_STREAM,
34350aadb33SDmitri Tikhonov    [0xD2] = QUIC_FRAME_STREAM,
34450aadb33SDmitri Tikhonov    [0xD3] = QUIC_FRAME_STREAM,
34550aadb33SDmitri Tikhonov    [0xD4] = QUIC_FRAME_STREAM,
34650aadb33SDmitri Tikhonov    [0xD5] = QUIC_FRAME_STREAM,
34750aadb33SDmitri Tikhonov    [0xD6] = QUIC_FRAME_STREAM,
34850aadb33SDmitri Tikhonov    [0xD7] = QUIC_FRAME_STREAM,
34950aadb33SDmitri Tikhonov    [0xD8] = QUIC_FRAME_STREAM,
35050aadb33SDmitri Tikhonov    [0xD9] = QUIC_FRAME_STREAM,
35150aadb33SDmitri Tikhonov    [0xDA] = QUIC_FRAME_STREAM,
35250aadb33SDmitri Tikhonov    [0xDB] = QUIC_FRAME_STREAM,
35350aadb33SDmitri Tikhonov    [0xDC] = QUIC_FRAME_STREAM,
35450aadb33SDmitri Tikhonov    [0xDD] = QUIC_FRAME_STREAM,
35550aadb33SDmitri Tikhonov    [0xDE] = QUIC_FRAME_STREAM,
35650aadb33SDmitri Tikhonov    [0xDF] = QUIC_FRAME_STREAM,
35750aadb33SDmitri Tikhonov    [0xE0] = QUIC_FRAME_STREAM,
35850aadb33SDmitri Tikhonov    [0xE1] = QUIC_FRAME_STREAM,
35950aadb33SDmitri Tikhonov    [0xE2] = QUIC_FRAME_STREAM,
36050aadb33SDmitri Tikhonov    [0xE3] = QUIC_FRAME_STREAM,
36150aadb33SDmitri Tikhonov    [0xE4] = QUIC_FRAME_STREAM,
36250aadb33SDmitri Tikhonov    [0xE5] = QUIC_FRAME_STREAM,
36350aadb33SDmitri Tikhonov    [0xE6] = QUIC_FRAME_STREAM,
36450aadb33SDmitri Tikhonov    [0xE7] = QUIC_FRAME_STREAM,
36550aadb33SDmitri Tikhonov    [0xE8] = QUIC_FRAME_STREAM,
36650aadb33SDmitri Tikhonov    [0xE9] = QUIC_FRAME_STREAM,
36750aadb33SDmitri Tikhonov    [0xEA] = QUIC_FRAME_STREAM,
36850aadb33SDmitri Tikhonov    [0xEB] = QUIC_FRAME_STREAM,
36950aadb33SDmitri Tikhonov    [0xEC] = QUIC_FRAME_STREAM,
37050aadb33SDmitri Tikhonov    [0xED] = QUIC_FRAME_STREAM,
37150aadb33SDmitri Tikhonov    [0xEE] = QUIC_FRAME_STREAM,
37250aadb33SDmitri Tikhonov    [0xEF] = QUIC_FRAME_STREAM,
37350aadb33SDmitri Tikhonov    [0xF0] = QUIC_FRAME_STREAM,
37450aadb33SDmitri Tikhonov    [0xF1] = QUIC_FRAME_STREAM,
37550aadb33SDmitri Tikhonov    [0xF2] = QUIC_FRAME_STREAM,
37650aadb33SDmitri Tikhonov    [0xF3] = QUIC_FRAME_STREAM,
37750aadb33SDmitri Tikhonov    [0xF4] = QUIC_FRAME_STREAM,
37850aadb33SDmitri Tikhonov    [0xF5] = QUIC_FRAME_STREAM,
37950aadb33SDmitri Tikhonov    [0xF6] = QUIC_FRAME_STREAM,
38050aadb33SDmitri Tikhonov    [0xF7] = QUIC_FRAME_STREAM,
38150aadb33SDmitri Tikhonov    [0xF8] = QUIC_FRAME_STREAM,
38250aadb33SDmitri Tikhonov    [0xF9] = QUIC_FRAME_STREAM,
38350aadb33SDmitri Tikhonov    [0xFA] = QUIC_FRAME_STREAM,
38450aadb33SDmitri Tikhonov    [0xFB] = QUIC_FRAME_STREAM,
38550aadb33SDmitri Tikhonov    [0xFC] = QUIC_FRAME_STREAM,
38650aadb33SDmitri Tikhonov    [0xFD] = QUIC_FRAME_STREAM,
38750aadb33SDmitri Tikhonov    [0xFE] = QUIC_FRAME_STREAM,
38850aadb33SDmitri Tikhonov    [0xFF] = QUIC_FRAME_STREAM,
38950aadb33SDmitri Tikhonov};
39050aadb33SDmitri Tikhonov
39150aadb33SDmitri Tikhonov
3921b97e4afSDmitri Tikhonovstatic const enum QUIC_FRAME_TYPE byte2frame_type_Q041[0x100] =
39350aadb33SDmitri Tikhonov{
39450aadb33SDmitri Tikhonov    [0x00] = QUIC_FRAME_PADDING,
39550aadb33SDmitri Tikhonov    [0x01] = QUIC_FRAME_RST_STREAM,
39650aadb33SDmitri Tikhonov    [0x02] = QUIC_FRAME_CONNECTION_CLOSE,
39750aadb33SDmitri Tikhonov    [0x03] = QUIC_FRAME_GOAWAY,
39850aadb33SDmitri Tikhonov    [0x04] = QUIC_FRAME_WINDOW_UPDATE,
39950aadb33SDmitri Tikhonov    [0x05] = QUIC_FRAME_BLOCKED,
40050aadb33SDmitri Tikhonov    [0x06] = QUIC_FRAME_STOP_WAITING,
40150aadb33SDmitri Tikhonov    [0x07] = QUIC_FRAME_PING,
40250aadb33SDmitri Tikhonov    [0x08] = QUIC_FRAME_INVALID,
40350aadb33SDmitri Tikhonov    [0x09] = QUIC_FRAME_INVALID,
40450aadb33SDmitri Tikhonov    [0x0A] = QUIC_FRAME_INVALID,
40550aadb33SDmitri Tikhonov    [0x0B] = QUIC_FRAME_INVALID,
40650aadb33SDmitri Tikhonov    [0x0C] = QUIC_FRAME_INVALID,
40750aadb33SDmitri Tikhonov    [0x0D] = QUIC_FRAME_INVALID,
40850aadb33SDmitri Tikhonov    [0x0E] = QUIC_FRAME_INVALID,
40950aadb33SDmitri Tikhonov    [0x0F] = QUIC_FRAME_INVALID,
41050aadb33SDmitri Tikhonov    [0x10] = QUIC_FRAME_INVALID,
41150aadb33SDmitri Tikhonov    [0x11] = QUIC_FRAME_INVALID,
41250aadb33SDmitri Tikhonov    [0x12] = QUIC_FRAME_INVALID,
41350aadb33SDmitri Tikhonov    [0x13] = QUIC_FRAME_INVALID,
41450aadb33SDmitri Tikhonov    [0x14] = QUIC_FRAME_INVALID,
41550aadb33SDmitri Tikhonov    [0x15] = QUIC_FRAME_INVALID,
41650aadb33SDmitri Tikhonov    [0x16] = QUIC_FRAME_INVALID,
41750aadb33SDmitri Tikhonov    [0x17] = QUIC_FRAME_INVALID,
41850aadb33SDmitri Tikhonov    [0x18] = QUIC_FRAME_INVALID,
41950aadb33SDmitri Tikhonov    [0x19] = QUIC_FRAME_INVALID,
42050aadb33SDmitri Tikhonov    [0x1A] = QUIC_FRAME_INVALID,
42150aadb33SDmitri Tikhonov    [0x1B] = QUIC_FRAME_INVALID,
42250aadb33SDmitri Tikhonov    [0x1C] = QUIC_FRAME_INVALID,
42350aadb33SDmitri Tikhonov    [0x1D] = QUIC_FRAME_INVALID,
42450aadb33SDmitri Tikhonov    [0x1E] = QUIC_FRAME_INVALID,
42550aadb33SDmitri Tikhonov    [0x1F] = QUIC_FRAME_INVALID,
42650aadb33SDmitri Tikhonov    [0x20] = QUIC_FRAME_INVALID,
42750aadb33SDmitri Tikhonov    [0x21] = QUIC_FRAME_INVALID,
42850aadb33SDmitri Tikhonov    [0x22] = QUIC_FRAME_INVALID,
42950aadb33SDmitri Tikhonov    [0x23] = QUIC_FRAME_INVALID,
43050aadb33SDmitri Tikhonov    [0x24] = QUIC_FRAME_INVALID,
43150aadb33SDmitri Tikhonov    [0x25] = QUIC_FRAME_INVALID,
43250aadb33SDmitri Tikhonov    [0x26] = QUIC_FRAME_INVALID,
43350aadb33SDmitri Tikhonov    [0x27] = QUIC_FRAME_INVALID,
43450aadb33SDmitri Tikhonov    [0x28] = QUIC_FRAME_INVALID,
43550aadb33SDmitri Tikhonov    [0x29] = QUIC_FRAME_INVALID,
43650aadb33SDmitri Tikhonov    [0x2A] = QUIC_FRAME_INVALID,
43750aadb33SDmitri Tikhonov    [0x2B] = QUIC_FRAME_INVALID,
43850aadb33SDmitri Tikhonov    [0x2C] = QUIC_FRAME_INVALID,
43950aadb33SDmitri Tikhonov    [0x2D] = QUIC_FRAME_INVALID,
44050aadb33SDmitri Tikhonov    [0x2E] = QUIC_FRAME_INVALID,
44150aadb33SDmitri Tikhonov    [0x2F] = QUIC_FRAME_INVALID,
44250aadb33SDmitri Tikhonov    [0x30] = QUIC_FRAME_INVALID,
44350aadb33SDmitri Tikhonov    [0x31] = QUIC_FRAME_INVALID,
44450aadb33SDmitri Tikhonov    [0x32] = QUIC_FRAME_INVALID,
44550aadb33SDmitri Tikhonov    [0x33] = QUIC_FRAME_INVALID,
44650aadb33SDmitri Tikhonov    [0x34] = QUIC_FRAME_INVALID,
44750aadb33SDmitri Tikhonov    [0x35] = QUIC_FRAME_INVALID,
44850aadb33SDmitri Tikhonov    [0x36] = QUIC_FRAME_INVALID,
44950aadb33SDmitri Tikhonov    [0x37] = QUIC_FRAME_INVALID,
45050aadb33SDmitri Tikhonov    [0x38] = QUIC_FRAME_INVALID,
45150aadb33SDmitri Tikhonov    [0x39] = QUIC_FRAME_INVALID,
45250aadb33SDmitri Tikhonov    [0x3A] = QUIC_FRAME_INVALID,
45350aadb33SDmitri Tikhonov    [0x3B] = QUIC_FRAME_INVALID,
45450aadb33SDmitri Tikhonov    [0x3C] = QUIC_FRAME_INVALID,
45550aadb33SDmitri Tikhonov    [0x3D] = QUIC_FRAME_INVALID,
45650aadb33SDmitri Tikhonov    [0x3E] = QUIC_FRAME_INVALID,
45750aadb33SDmitri Tikhonov    [0x3F] = QUIC_FRAME_INVALID,
45850aadb33SDmitri Tikhonov    [0x40] = QUIC_FRAME_INVALID,
45950aadb33SDmitri Tikhonov    [0x41] = QUIC_FRAME_INVALID,
46050aadb33SDmitri Tikhonov    [0x42] = QUIC_FRAME_INVALID,
46150aadb33SDmitri Tikhonov    [0x43] = QUIC_FRAME_INVALID,
46250aadb33SDmitri Tikhonov    [0x44] = QUIC_FRAME_INVALID,
46350aadb33SDmitri Tikhonov    [0x45] = QUIC_FRAME_INVALID,
46450aadb33SDmitri Tikhonov    [0x46] = QUIC_FRAME_INVALID,
46550aadb33SDmitri Tikhonov    [0x47] = QUIC_FRAME_INVALID,
46650aadb33SDmitri Tikhonov    [0x48] = QUIC_FRAME_INVALID,
46750aadb33SDmitri Tikhonov    [0x49] = QUIC_FRAME_INVALID,
46850aadb33SDmitri Tikhonov    [0x4A] = QUIC_FRAME_INVALID,
46950aadb33SDmitri Tikhonov    [0x4B] = QUIC_FRAME_INVALID,
47050aadb33SDmitri Tikhonov    [0x4C] = QUIC_FRAME_INVALID,
47150aadb33SDmitri Tikhonov    [0x4D] = QUIC_FRAME_INVALID,
47250aadb33SDmitri Tikhonov    [0x4E] = QUIC_FRAME_INVALID,
47350aadb33SDmitri Tikhonov    [0x4F] = QUIC_FRAME_INVALID,
47450aadb33SDmitri Tikhonov    [0x50] = QUIC_FRAME_INVALID,
47550aadb33SDmitri Tikhonov    [0x51] = QUIC_FRAME_INVALID,
47650aadb33SDmitri Tikhonov    [0x52] = QUIC_FRAME_INVALID,
47750aadb33SDmitri Tikhonov    [0x53] = QUIC_FRAME_INVALID,
47850aadb33SDmitri Tikhonov    [0x54] = QUIC_FRAME_INVALID,
47950aadb33SDmitri Tikhonov    [0x55] = QUIC_FRAME_INVALID,
48050aadb33SDmitri Tikhonov    [0x56] = QUIC_FRAME_INVALID,
48150aadb33SDmitri Tikhonov    [0x57] = QUIC_FRAME_INVALID,
48250aadb33SDmitri Tikhonov    [0x58] = QUIC_FRAME_INVALID,
48350aadb33SDmitri Tikhonov    [0x59] = QUIC_FRAME_INVALID,
48450aadb33SDmitri Tikhonov    [0x5A] = QUIC_FRAME_INVALID,
48550aadb33SDmitri Tikhonov    [0x5B] = QUIC_FRAME_INVALID,
48650aadb33SDmitri Tikhonov    [0x5C] = QUIC_FRAME_INVALID,
48750aadb33SDmitri Tikhonov    [0x5D] = QUIC_FRAME_INVALID,
48850aadb33SDmitri Tikhonov    [0x5E] = QUIC_FRAME_INVALID,
48950aadb33SDmitri Tikhonov    [0x5F] = QUIC_FRAME_INVALID,
49050aadb33SDmitri Tikhonov    [0x60] = QUIC_FRAME_INVALID,
49150aadb33SDmitri Tikhonov    [0x61] = QUIC_FRAME_INVALID,
49250aadb33SDmitri Tikhonov    [0x62] = QUIC_FRAME_INVALID,
49350aadb33SDmitri Tikhonov    [0x63] = QUIC_FRAME_INVALID,
49450aadb33SDmitri Tikhonov    [0x64] = QUIC_FRAME_INVALID,
49550aadb33SDmitri Tikhonov    [0x65] = QUIC_FRAME_INVALID,
49650aadb33SDmitri Tikhonov    [0x66] = QUIC_FRAME_INVALID,
49750aadb33SDmitri Tikhonov    [0x67] = QUIC_FRAME_INVALID,
49850aadb33SDmitri Tikhonov    [0x68] = QUIC_FRAME_INVALID,
49950aadb33SDmitri Tikhonov    [0x69] = QUIC_FRAME_INVALID,
50050aadb33SDmitri Tikhonov    [0x6A] = QUIC_FRAME_INVALID,
50150aadb33SDmitri Tikhonov    [0x6B] = QUIC_FRAME_INVALID,
50250aadb33SDmitri Tikhonov    [0x6C] = QUIC_FRAME_INVALID,
50350aadb33SDmitri Tikhonov    [0x6D] = QUIC_FRAME_INVALID,
50450aadb33SDmitri Tikhonov    [0x6E] = QUIC_FRAME_INVALID,
50550aadb33SDmitri Tikhonov    [0x6F] = QUIC_FRAME_INVALID,
50650aadb33SDmitri Tikhonov    [0x70] = QUIC_FRAME_INVALID,
50750aadb33SDmitri Tikhonov    [0x71] = QUIC_FRAME_INVALID,
50850aadb33SDmitri Tikhonov    [0x72] = QUIC_FRAME_INVALID,
50950aadb33SDmitri Tikhonov    [0x73] = QUIC_FRAME_INVALID,
51050aadb33SDmitri Tikhonov    [0x74] = QUIC_FRAME_INVALID,
51150aadb33SDmitri Tikhonov    [0x75] = QUIC_FRAME_INVALID,
51250aadb33SDmitri Tikhonov    [0x76] = QUIC_FRAME_INVALID,
51350aadb33SDmitri Tikhonov    [0x77] = QUIC_FRAME_INVALID,
51450aadb33SDmitri Tikhonov    [0x78] = QUIC_FRAME_INVALID,
51550aadb33SDmitri Tikhonov    [0x79] = QUIC_FRAME_INVALID,
51650aadb33SDmitri Tikhonov    [0x7A] = QUIC_FRAME_INVALID,
51750aadb33SDmitri Tikhonov    [0x7B] = QUIC_FRAME_INVALID,
51850aadb33SDmitri Tikhonov    [0x7C] = QUIC_FRAME_INVALID,
51950aadb33SDmitri Tikhonov    [0x7D] = QUIC_FRAME_INVALID,
52050aadb33SDmitri Tikhonov    [0x7E] = QUIC_FRAME_INVALID,
52150aadb33SDmitri Tikhonov    [0x7F] = QUIC_FRAME_INVALID,
52250aadb33SDmitri Tikhonov    [0x80] = QUIC_FRAME_INVALID,
52350aadb33SDmitri Tikhonov    [0x81] = QUIC_FRAME_INVALID,
52450aadb33SDmitri Tikhonov    [0x82] = QUIC_FRAME_INVALID,
52550aadb33SDmitri Tikhonov    [0x83] = QUIC_FRAME_INVALID,
52650aadb33SDmitri Tikhonov    [0x84] = QUIC_FRAME_INVALID,
52750aadb33SDmitri Tikhonov    [0x85] = QUIC_FRAME_INVALID,
52850aadb33SDmitri Tikhonov    [0x86] = QUIC_FRAME_INVALID,
52950aadb33SDmitri Tikhonov    [0x87] = QUIC_FRAME_INVALID,
53050aadb33SDmitri Tikhonov    [0x88] = QUIC_FRAME_INVALID,
53150aadb33SDmitri Tikhonov    [0x89] = QUIC_FRAME_INVALID,
53250aadb33SDmitri Tikhonov    [0x8A] = QUIC_FRAME_INVALID,
53350aadb33SDmitri Tikhonov    [0x8B] = QUIC_FRAME_INVALID,
53450aadb33SDmitri Tikhonov    [0x8C] = QUIC_FRAME_INVALID,
53550aadb33SDmitri Tikhonov    [0x8D] = QUIC_FRAME_INVALID,
53650aadb33SDmitri Tikhonov    [0x8E] = QUIC_FRAME_INVALID,
53750aadb33SDmitri Tikhonov    [0x8F] = QUIC_FRAME_INVALID,
53850aadb33SDmitri Tikhonov    [0x90] = QUIC_FRAME_INVALID,
53950aadb33SDmitri Tikhonov    [0x91] = QUIC_FRAME_INVALID,
54050aadb33SDmitri Tikhonov    [0x92] = QUIC_FRAME_INVALID,
54150aadb33SDmitri Tikhonov    [0x93] = QUIC_FRAME_INVALID,
54250aadb33SDmitri Tikhonov    [0x94] = QUIC_FRAME_INVALID,
54350aadb33SDmitri Tikhonov    [0x95] = QUIC_FRAME_INVALID,
54450aadb33SDmitri Tikhonov    [0x96] = QUIC_FRAME_INVALID,
54550aadb33SDmitri Tikhonov    [0x97] = QUIC_FRAME_INVALID,
54650aadb33SDmitri Tikhonov    [0x98] = QUIC_FRAME_INVALID,
54750aadb33SDmitri Tikhonov    [0x99] = QUIC_FRAME_INVALID,
54850aadb33SDmitri Tikhonov    [0x9A] = QUIC_FRAME_INVALID,
54950aadb33SDmitri Tikhonov    [0x9B] = QUIC_FRAME_INVALID,
55050aadb33SDmitri Tikhonov    [0x9C] = QUIC_FRAME_INVALID,
55150aadb33SDmitri Tikhonov    [0x9D] = QUIC_FRAME_INVALID,
55250aadb33SDmitri Tikhonov    [0x9E] = QUIC_FRAME_INVALID,
55350aadb33SDmitri Tikhonov    [0x9F] = QUIC_FRAME_INVALID,
55450aadb33SDmitri Tikhonov    [0xA0] = QUIC_FRAME_ACK,
55550aadb33SDmitri Tikhonov    [0xA1] = QUIC_FRAME_ACK,
55650aadb33SDmitri Tikhonov    [0xA2] = QUIC_FRAME_ACK,
55750aadb33SDmitri Tikhonov    [0xA3] = QUIC_FRAME_ACK,
55850aadb33SDmitri Tikhonov    [0xA4] = QUIC_FRAME_ACK,
55950aadb33SDmitri Tikhonov    [0xA5] = QUIC_FRAME_ACK,
56050aadb33SDmitri Tikhonov    [0xA6] = QUIC_FRAME_ACK,
56150aadb33SDmitri Tikhonov    [0xA7] = QUIC_FRAME_ACK,
56250aadb33SDmitri Tikhonov    [0xA8] = QUIC_FRAME_ACK,
56350aadb33SDmitri Tikhonov    [0xA9] = QUIC_FRAME_ACK,
56450aadb33SDmitri Tikhonov    [0xAA] = QUIC_FRAME_ACK,
56550aadb33SDmitri Tikhonov    [0xAB] = QUIC_FRAME_ACK,
56650aadb33SDmitri Tikhonov    [0xAC] = QUIC_FRAME_ACK,
56750aadb33SDmitri Tikhonov    [0xAD] = QUIC_FRAME_ACK,
56850aadb33SDmitri Tikhonov    [0xAE] = QUIC_FRAME_ACK,
56950aadb33SDmitri Tikhonov    [0xAF] = QUIC_FRAME_ACK,
57050aadb33SDmitri Tikhonov    [0xB0] = QUIC_FRAME_ACK,
57150aadb33SDmitri Tikhonov    [0xB1] = QUIC_FRAME_ACK,
57250aadb33SDmitri Tikhonov    [0xB2] = QUIC_FRAME_ACK,
57350aadb33SDmitri Tikhonov    [0xB3] = QUIC_FRAME_ACK,
57450aadb33SDmitri Tikhonov    [0xB4] = QUIC_FRAME_ACK,
57550aadb33SDmitri Tikhonov    [0xB5] = QUIC_FRAME_ACK,
57650aadb33SDmitri Tikhonov    [0xB6] = QUIC_FRAME_ACK,
57750aadb33SDmitri Tikhonov    [0xB7] = QUIC_FRAME_ACK,
57850aadb33SDmitri Tikhonov    [0xB8] = QUIC_FRAME_ACK,
57950aadb33SDmitri Tikhonov    [0xB9] = QUIC_FRAME_ACK,
58050aadb33SDmitri Tikhonov    [0xBA] = QUIC_FRAME_ACK,
58150aadb33SDmitri Tikhonov    [0xBB] = QUIC_FRAME_ACK,
58250aadb33SDmitri Tikhonov    [0xBC] = QUIC_FRAME_ACK,
58350aadb33SDmitri Tikhonov    [0xBD] = QUIC_FRAME_ACK,
58450aadb33SDmitri Tikhonov    [0xBE] = QUIC_FRAME_ACK,
58550aadb33SDmitri Tikhonov    [0xBF] = QUIC_FRAME_ACK,
58650aadb33SDmitri Tikhonov    [0xC0] = QUIC_FRAME_STREAM,
58750aadb33SDmitri Tikhonov    [0xC1] = QUIC_FRAME_STREAM,
58850aadb33SDmitri Tikhonov    [0xC2] = QUIC_FRAME_STREAM,
58950aadb33SDmitri Tikhonov    [0xC3] = QUIC_FRAME_STREAM,
59050aadb33SDmitri Tikhonov    [0xC4] = QUIC_FRAME_STREAM,
59150aadb33SDmitri Tikhonov    [0xC5] = QUIC_FRAME_STREAM,
59250aadb33SDmitri Tikhonov    [0xC6] = QUIC_FRAME_STREAM,
59350aadb33SDmitri Tikhonov    [0xC7] = QUIC_FRAME_STREAM,
59450aadb33SDmitri Tikhonov    [0xC8] = QUIC_FRAME_STREAM,
59550aadb33SDmitri Tikhonov    [0xC9] = QUIC_FRAME_STREAM,
59650aadb33SDmitri Tikhonov    [0xCA] = QUIC_FRAME_STREAM,
59750aadb33SDmitri Tikhonov    [0xCB] = QUIC_FRAME_STREAM,
59850aadb33SDmitri Tikhonov    [0xCC] = QUIC_FRAME_STREAM,
59950aadb33SDmitri Tikhonov    [0xCD] = QUIC_FRAME_STREAM,
60050aadb33SDmitri Tikhonov    [0xCE] = QUIC_FRAME_STREAM,
60150aadb33SDmitri Tikhonov    [0xCF] = QUIC_FRAME_STREAM,
60250aadb33SDmitri Tikhonov    [0xD0] = QUIC_FRAME_STREAM,
60350aadb33SDmitri Tikhonov    [0xD1] = QUIC_FRAME_STREAM,
60450aadb33SDmitri Tikhonov    [0xD2] = QUIC_FRAME_STREAM,
60550aadb33SDmitri Tikhonov    [0xD3] = QUIC_FRAME_STREAM,
60650aadb33SDmitri Tikhonov    [0xD4] = QUIC_FRAME_STREAM,
60750aadb33SDmitri Tikhonov    [0xD5] = QUIC_FRAME_STREAM,
60850aadb33SDmitri Tikhonov    [0xD6] = QUIC_FRAME_STREAM,
60950aadb33SDmitri Tikhonov    [0xD7] = QUIC_FRAME_STREAM,
61050aadb33SDmitri Tikhonov    [0xD8] = QUIC_FRAME_STREAM,
61150aadb33SDmitri Tikhonov    [0xD9] = QUIC_FRAME_STREAM,
61250aadb33SDmitri Tikhonov    [0xDA] = QUIC_FRAME_STREAM,
61350aadb33SDmitri Tikhonov    [0xDB] = QUIC_FRAME_STREAM,
61450aadb33SDmitri Tikhonov    [0xDC] = QUIC_FRAME_STREAM,
61550aadb33SDmitri Tikhonov    [0xDD] = QUIC_FRAME_STREAM,
61650aadb33SDmitri Tikhonov    [0xDE] = QUIC_FRAME_STREAM,
61750aadb33SDmitri Tikhonov    [0xDF] = QUIC_FRAME_STREAM,
61850aadb33SDmitri Tikhonov    [0xE0] = QUIC_FRAME_STREAM,
61950aadb33SDmitri Tikhonov    [0xE1] = QUIC_FRAME_STREAM,
62050aadb33SDmitri Tikhonov    [0xE2] = QUIC_FRAME_STREAM,
62150aadb33SDmitri Tikhonov    [0xE3] = QUIC_FRAME_STREAM,
62250aadb33SDmitri Tikhonov    [0xE4] = QUIC_FRAME_STREAM,
62350aadb33SDmitri Tikhonov    [0xE5] = QUIC_FRAME_STREAM,
62450aadb33SDmitri Tikhonov    [0xE6] = QUIC_FRAME_STREAM,
62550aadb33SDmitri Tikhonov    [0xE7] = QUIC_FRAME_STREAM,
62650aadb33SDmitri Tikhonov    [0xE8] = QUIC_FRAME_STREAM,
62750aadb33SDmitri Tikhonov    [0xE9] = QUIC_FRAME_STREAM,
62850aadb33SDmitri Tikhonov    [0xEA] = QUIC_FRAME_STREAM,
62950aadb33SDmitri Tikhonov    [0xEB] = QUIC_FRAME_STREAM,
63050aadb33SDmitri Tikhonov    [0xEC] = QUIC_FRAME_STREAM,
63150aadb33SDmitri Tikhonov    [0xED] = QUIC_FRAME_STREAM,
63250aadb33SDmitri Tikhonov    [0xEE] = QUIC_FRAME_STREAM,
63350aadb33SDmitri Tikhonov    [0xEF] = QUIC_FRAME_STREAM,
63450aadb33SDmitri Tikhonov    [0xF0] = QUIC_FRAME_STREAM,
63550aadb33SDmitri Tikhonov    [0xF1] = QUIC_FRAME_STREAM,
63650aadb33SDmitri Tikhonov    [0xF2] = QUIC_FRAME_STREAM,
63750aadb33SDmitri Tikhonov    [0xF3] = QUIC_FRAME_STREAM,
63850aadb33SDmitri Tikhonov    [0xF4] = QUIC_FRAME_STREAM,
63950aadb33SDmitri Tikhonov    [0xF5] = QUIC_FRAME_STREAM,
64050aadb33SDmitri Tikhonov    [0xF6] = QUIC_FRAME_STREAM,
64150aadb33SDmitri Tikhonov    [0xF7] = QUIC_FRAME_STREAM,
64250aadb33SDmitri Tikhonov    [0xF8] = QUIC_FRAME_STREAM,
64350aadb33SDmitri Tikhonov    [0xF9] = QUIC_FRAME_STREAM,
64450aadb33SDmitri Tikhonov    [0xFA] = QUIC_FRAME_STREAM,
64550aadb33SDmitri Tikhonov    [0xFB] = QUIC_FRAME_STREAM,
64650aadb33SDmitri Tikhonov    [0xFC] = QUIC_FRAME_STREAM,
64750aadb33SDmitri Tikhonov    [0xFD] = QUIC_FRAME_STREAM,
64850aadb33SDmitri Tikhonov    [0xFE] = QUIC_FRAME_STREAM,
64950aadb33SDmitri Tikhonov    [0xFF] = QUIC_FRAME_STREAM,
65050aadb33SDmitri Tikhonov};
65150aadb33SDmitri Tikhonov
65250aadb33SDmitri Tikhonov
65350aadb33SDmitri Tikhonovenum QUIC_FRAME_TYPE
65450aadb33SDmitri Tikhonovparse_frame_type_gquic_Q035_thru_Q039 (unsigned char b)
65550aadb33SDmitri Tikhonov{
65650aadb33SDmitri Tikhonov    return byte2frame_type_Q035_thru_Q039[b];
65750aadb33SDmitri Tikhonov}
65850aadb33SDmitri Tikhonov
65950aadb33SDmitri Tikhonov
66050aadb33SDmitri Tikhonovenum QUIC_FRAME_TYPE
6611b97e4afSDmitri Tikhonovparse_frame_type_gquic_Q041 (unsigned char b)
66250aadb33SDmitri Tikhonov{
6631b97e4afSDmitri Tikhonov    return byte2frame_type_Q041[b];
66450aadb33SDmitri Tikhonov}
66550aadb33SDmitri Tikhonov
66650aadb33SDmitri Tikhonov
66750aadb33SDmitri Tikhonovunsigned
66850aadb33SDmitri Tikhonovparse_stream_frame_header_sz_gquic (unsigned char type)
66950aadb33SDmitri Tikhonov{
67050aadb33SDmitri Tikhonov    const unsigned data_len      = (type >> 4) & 2;
67150aadb33SDmitri Tikhonov    const unsigned offset_len    = ((type >> 2) & 7) + 1 - !((type >> 2) & 7);
67250aadb33SDmitri Tikhonov    const unsigned stream_id_len = 1 + (type & 3);
67350aadb33SDmitri Tikhonov    return 1 + data_len + offset_len + stream_id_len;
67450aadb33SDmitri Tikhonov}
67550aadb33SDmitri Tikhonov
67650aadb33SDmitri Tikhonov
67750aadb33SDmitri Tikhonovsize_t
67850aadb33SDmitri Tikhonovcalc_stream_frame_header_sz_gquic (uint32_t stream_id, uint64_t offset)
67950aadb33SDmitri Tikhonov{
68050aadb33SDmitri Tikhonov    return
68150aadb33SDmitri Tikhonov        /* Type */
68250aadb33SDmitri Tikhonov        1
68350aadb33SDmitri Tikhonov        /* Stream ID length */
68450aadb33SDmitri Tikhonov      + ((stream_id) > 0x0000FF)
68550aadb33SDmitri Tikhonov      + ((stream_id) > 0x00FFFF)
68650aadb33SDmitri Tikhonov      + ((stream_id) > 0xFFFFFF)
68750aadb33SDmitri Tikhonov      + 1
68850aadb33SDmitri Tikhonov        /* Offset length */
68950aadb33SDmitri Tikhonov      + ((offset) >= (1ULL << 56))
69050aadb33SDmitri Tikhonov      + ((offset) >= (1ULL << 48))
69150aadb33SDmitri Tikhonov      + ((offset) >= (1ULL << 40))
69250aadb33SDmitri Tikhonov      + ((offset) >= (1ULL << 32))
69350aadb33SDmitri Tikhonov      + ((offset) >= (1ULL << 24))
69450aadb33SDmitri Tikhonov      + ((offset) >= (1ULL << 16))
69550aadb33SDmitri Tikhonov      + (((offset) > 0) << 1)
69650aadb33SDmitri Tikhonov        /* Add data length (2) yourself, if necessary */
69750aadb33SDmitri Tikhonov    ;
69850aadb33SDmitri Tikhonov}
69950aadb33SDmitri Tikhonov
70050aadb33SDmitri Tikhonov
70150aadb33SDmitri Tikhonovchar *
70250aadb33SDmitri Tikhonovacki2str (const struct ack_info *acki, size_t *sz)
70350aadb33SDmitri Tikhonov{
70450aadb33SDmitri Tikhonov    size_t off, bufsz, nw;
70550aadb33SDmitri Tikhonov    unsigned n;
70650aadb33SDmitri Tikhonov    char *buf;
70750aadb33SDmitri Tikhonov
70850aadb33SDmitri Tikhonov    bufsz = acki->n_ranges * (3 /* [-] */ + 20 /* ~0ULL */ * 2);
70950aadb33SDmitri Tikhonov    buf = malloc(bufsz);
71050aadb33SDmitri Tikhonov    if (!buf)
71150aadb33SDmitri Tikhonov    {
71250aadb33SDmitri Tikhonov        LSQ_WARN("%s: malloc(%zd) failure: %s", __func__, bufsz,
71350aadb33SDmitri Tikhonov                                                        strerror(errno));
71450aadb33SDmitri Tikhonov        return NULL;
71550aadb33SDmitri Tikhonov    }
71650aadb33SDmitri Tikhonov
71750aadb33SDmitri Tikhonov    off = 0;
71850aadb33SDmitri Tikhonov    for (n = 0; n < acki->n_ranges; ++n)
71950aadb33SDmitri Tikhonov    {
72050aadb33SDmitri Tikhonov        nw = snprintf(buf + off, bufsz - off, "[%"PRIu64"-%"PRIu64"]",
72150aadb33SDmitri Tikhonov                acki->ranges[n].high, acki->ranges[n].low);
72250aadb33SDmitri Tikhonov        if (nw > bufsz - off)
72350aadb33SDmitri Tikhonov            break;
72450aadb33SDmitri Tikhonov        off += nw;
72550aadb33SDmitri Tikhonov    }
72650aadb33SDmitri Tikhonov
72750aadb33SDmitri Tikhonov    *sz = off;
72850aadb33SDmitri Tikhonov    return buf;
72950aadb33SDmitri Tikhonov}
73050aadb33SDmitri Tikhonov
73150aadb33SDmitri Tikhonov
732