proxygen
HPACKConstants.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <stdint.h>
13 #include <iosfwd>
14 
15 namespace proxygen {
16 
17 namespace HPACK {
18 
19 struct Instruction {
22 };
23 
24 const Instruction INDEX_REF { 0x80, 7 };
25 const Instruction LITERAL_INC_INDEX { 0x40, 6 };
26 const Instruction LITERAL { 0x00, 4 };
27 const Instruction LITERAL_NEV_INDEX { 0x10, 4 };
28 const Instruction TABLE_SIZE_UPDATE { 0x20, 5 };
29 
30 // Encoder Stream
31 const Instruction Q_INSERT_NAME_REF { 0x80, 6 };
33 const Instruction Q_TABLE_SIZE_UPDATE { 0x20, 5 };
34 const Instruction Q_DUPLICATE { 0x00, 5 };
35 
36 // Decoder Stream
37 const Instruction Q_HEADER_ACK { 0x80, 7 };
38 const Instruction Q_CANCEL_STREAM { 0x40, 6 };
39 const Instruction Q_TABLE_STATE_SYNC { 0x00, 6 };
40 
41 // Request/Push Streams
42 
43 // Prefix
46 
47 const Instruction Q_DELTA_BASE { 0x00, 7 };
48 
49 // Instructions
50 const Instruction Q_INDEXED { 0x80, 6 };
51 const Instruction Q_INDEXED_POST { 0x10, 4 };
52 const Instruction Q_LITERAL_NAME_REF { 0x40, 4 };
54 const Instruction Q_LITERAL { 0x20, 3 };
55 
59 
61 
62 const uint32_t kTableSize = 4096;
63 
64 const uint8_t NBIT_MASKS[9] = {
65  0x00, // 00000000, unused
66  0x01, // 00000001
67  0x03, // 00000011
68  0x07, // 00000111
69  0x0F, // 00001111
70  0x1F, // 00011111
71  0x3F, // 00111111
72  0x7F, // 01111111
73  0xFF, // 11111111
74 };
75 
77  PLAIN = 0x00,
78  HUFFMAN = 0x80
79 };
80 
81 enum class DecodeError : uint8_t {
82  NONE = 0,
83  INVALID_INDEX = 1,
85  INVALID_ENCODING = 3,
86  INTEGER_OVERFLOW = 4,
89  BUFFER_UNDERFLOW = 7,
91  TIMEOUT = 9,
92  CANCELLED = 10,
94  INVALID_ACK = 12,
96 };
97 
98 std::ostream& operator<<(std::ostream& os, DecodeError err);
99 }
100 
101 }
const uint32_t kTableSize
const Instruction Q_TABLE_STATE_SYNC
const Instruction Q_INSERT_NO_NAME_REF
const Instruction INDEX_REF
const uint8_t Q_DELTA_BASE_POS
const Instruction Q_DUPLICATE
const Instruction Q_INDEXED_POST
const Instruction Q_LITERAL_NAME_REF_POST
const Instruction Q_LITERAL
const Instruction TABLE_SIZE_UPDATE
const Instruction LITERAL_INC_INDEX
const Instruction Q_TABLE_SIZE_UPDATE
const Instruction LITERAL_NEV_INDEX
const uint8_t Q_LITERAL_STATIC
const uint8_t Q_INSERT_NAME_REF_STATIC
const Instruction Q_HEADER_ACK
const Instruction Q_INSERT_NAME_REF
const Instruction Q_DELTA_BASE
std::ostream & operator<<(std::ostream &os, DecodeError err)
const uint8_t Q_INDEXED_STATIC
const Instruction LITERAL
const uint8_t Q_DELTA_BASE_NEG
const uint8_t NBIT_MASKS[9]
const Instruction Q_INDEXED
const Instruction Q_LITERAL_NAME_REF
const uint32_t kDefaultBlocking
const Instruction Q_CANCEL_STREAM