1// Copyright 2024 The Pigweed Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); you may not 4// use this file except in compliance with the License. You may obtain a copy of 5// the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12// License for the specific language governing permissions and limitations under 13// the License. 14// 15// AUTOGENERATED FILE, DO NOT EDIT 16// 17// To regenerate, run `go run gen/hpack_gen.go > hpack.autogen.inc`. 18// This file should be included in exactly one *.cc file. 19// 20 21// clang-format off 22 23// Huffman decoder table. Decoding starts at index=0. For each bit, we inspect 24// kHuffmanDecoderTable[index][bit] and take an action based on that value: 25// 26// * If the value matches 0b0..._...., set index=value 27// * If the value matches 0b1xxx_xxxx, output byte 32 + xx_xxxx, set index=0 28// * If the value matches 0b1111_1110, fail: unprintable character 29// * If the value matches 0b1111_1111, fail: decoder entered an invalid state 30// 31static constexpr std::array<uint8_t[2], 114> kHuffmanDecoderTable = {{ 32 /*0=*/ {1, 22}, 33 /*1=*/ {2, 9}, 34 /*2=*/ {3, 6}, 35 /*3=*/ {4, 5}, 36 /*4=*/ {144, 145}, 37 /*5=*/ {146, 193}, 38 /*6=*/ {7, 8}, 39 /*7=*/ {195, 197}, 40 /*8=*/ {201, 207}, 41 /*9=*/ {10, 15}, 42 /*10=*/ {11, 12}, 43 /*11=*/ {211, 212}, 44 /*12=*/ {13, 14}, 45 /*13=*/ {128, 133}, 46 /*14=*/ {141, 142}, 47 /*15=*/ {16, 19}, 48 /*16=*/ {17, 18}, 49 /*17=*/ {143, 147}, 50 /*18=*/ {148, 149}, 51 /*19=*/ {20, 21}, 52 /*20=*/ {150, 151}, 53 /*21=*/ {152, 153}, 54 /*22=*/ {23, 40}, 55 /*23=*/ {24, 31}, 56 /*24=*/ {25, 28}, 57 /*25=*/ {26, 27}, 58 /*26=*/ {157, 161}, 59 /*27=*/ {191, 194}, 60 /*28=*/ {29, 30}, 61 /*29=*/ {196, 198}, 62 /*30=*/ {199, 200}, 63 /*31=*/ {32, 35}, 64 /*32=*/ {33, 34}, 65 /*33=*/ {204, 205}, 66 /*34=*/ {206, 208}, 67 /*35=*/ {36, 37}, 68 /*36=*/ {210, 213}, 69 /*37=*/ {38, 39}, 70 /*38=*/ {154, 162}, 71 /*39=*/ {163, 164}, 72 /*40=*/ {41, 56}, 73 /*41=*/ {42, 49}, 74 /*42=*/ {43, 46}, 75 /*43=*/ {44, 45}, 76 /*44=*/ {165, 166}, 77 /*45=*/ {167, 168}, 78 /*46=*/ {47, 48}, 79 /*47=*/ {169, 170}, 80 /*48=*/ {171, 172}, 81 /*49=*/ {50, 53}, 82 /*50=*/ {51, 52}, 83 /*51=*/ {173, 174}, 84 /*52=*/ {175, 176}, 85 /*53=*/ {54, 55}, 86 /*54=*/ {177, 178}, 87 /*55=*/ {179, 180}, 88 /*56=*/ {57, 64}, 89 /*57=*/ {58, 61}, 90 /*58=*/ {59, 60}, 91 /*59=*/ {181, 182}, 92 /*60=*/ {183, 185}, 93 /*61=*/ {62, 63}, 94 /*62=*/ {202, 203}, 95 /*63=*/ {209, 214}, 96 /*64=*/ {65, 68}, 97 /*65=*/ {66, 67}, 98 /*66=*/ {215, 216}, 99 /*67=*/ {217, 218}, 100 /*68=*/ {69, 72}, 101 /*69=*/ {70, 71}, 102 /*70=*/ {134, 138}, 103 /*71=*/ {140, 155}, 104 /*72=*/ {73, 74}, 105 /*73=*/ {184, 186}, 106 /*74=*/ {75, 78}, 107 /*75=*/ {76, 77}, 108 /*76=*/ {129, 130}, 109 /*77=*/ {136, 137}, 110 /*78=*/ {79, 81}, 111 /*79=*/ {159, 80}, 112 /*80=*/ {135, 139}, 113 /*81=*/ {82, 84}, 114 /*82=*/ {220, 83}, 115 /*83=*/ {131, 158}, 116 /*84=*/ {85, 88}, 117 /*85=*/ {86, 87}, 118 /*86=*/ {254, 132}, 119 /*87=*/ {160, 187}, 120 /*88=*/ {89, 90}, 121 /*89=*/ {189, 222}, 122 /*90=*/ {91, 92}, 123 /*91=*/ {190, 221}, 124 /*92=*/ {93, 94}, 125 /*93=*/ {156, 192}, 126 /*94=*/ {219, 95}, 127 /*95=*/ {96, 99}, 128 /*96=*/ {97, 254}, 129 /*97=*/ {98, 254}, 130 /*98=*/ {188, 254}, 131 /*99=*/ {254, 100}, 132 /*100=*/ {254, 101}, 133 /*101=*/ {254, 102}, 134 /*102=*/ {254, 103}, 135 /*103=*/ {254, 104}, 136 /*104=*/ {254, 105}, 137 /*105=*/ {254, 106}, 138 /*106=*/ {254, 107}, 139 /*107=*/ {254, 108}, 140 /*108=*/ {254, 109}, 141 /*109=*/ {110, 111}, 142 /*110=*/ {223, 254}, 143 /*111=*/ {254, 112}, 144 /*112=*/ {254, 113}, 145 /*113=*/ {254, 255}, 146 147}}; 148 149// Decoder table stats: 150// before optimization = {numBranchNodes:256 numOutputNodes:96 numUnprintableNodes:160 numInvalidNodes:1} 151// after optimization = {numBranchNodes:114 numOutputNodes:96 numUnprintableNodes:18 numInvalidNodes:1} 152 153 154// HPACK-encoded header fields which form grpc Response-Headers. 155// These are the same for every response. 156static constexpr std::array<uint8_t, 19> kResponseHeaderFields = { 157 0x88, 0x5f, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63 158}; 159 160// HPACK-encoded header fields which form grpc Trailers. All response Trailers 161// are identical except for the status code. 162// 163// This is indexed by pw::Status::Code, which happens to be identical to grpc's 164// status code. 165struct ResponseTrailerPayload { 166 uint32_t size; 167 std::array<uint8_t, 16> bytes; 168}; 169static constexpr std::array<ResponseTrailerPayload, 17> kResponseTrailerFields = {{ 170 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x30}}, 171 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x31}}, 172 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x32}}, 173 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x33}}, 174 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x34}}, 175 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x35}}, 176 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x36}}, 177 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x37}}, 178 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x38}}, 179 {.size=15, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x39}}, 180 {.size=16, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2, 0x31, 0x30}}, 181 {.size=16, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2, 0x31, 0x31}}, 182 {.size=16, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2, 0x31, 0x32}}, 183 {.size=16, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2, 0x31, 0x33}}, 184 {.size=16, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2, 0x31, 0x34}}, 185 {.size=16, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2, 0x31, 0x35}}, 186 {.size=16, .bytes={0x40, 0xb, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2, 0x31, 0x36}}, 187 188}}; 189