1 /*
2 * Copyright 2017 gRPC authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /*
18 * Automatically generated by tools/codegen/core/gen_settings_ids.py
19 */
20
21 #include <grpc/support/port_platform.h>
22
23 #include "src/core/ext/transport/chttp2/transport/http2_settings.h"
24
25 #include "src/core/lib/gpr/useful.h"
26 #include "src/core/lib/transport/http2_errors.h"
27
28 const uint16_t grpc_setting_id_to_wire_id[] = {1, 2, 3, 4, 5, 6, 65027};
29
grpc_wire_id_to_setting_id(uint32_t wire_id,grpc_chttp2_setting_id * out)30 bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id* out) {
31 uint32_t i = wire_id - 1;
32 uint32_t x = i % 256;
33 uint32_t y = i / 256;
34 uint32_t h = x;
35 switch (y) {
36 case 254:
37 h += 4;
38 break;
39 }
40 *out = static_cast<grpc_chttp2_setting_id>(h);
41 return h < GPR_ARRAY_SIZE(grpc_setting_id_to_wire_id) &&
42 grpc_setting_id_to_wire_id[h] == wire_id;
43 }
44
45 const grpc_chttp2_setting_parameters
46 grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS] = {
47 {"HEADER_TABLE_SIZE", 4096u, 0u, 4294967295u,
48 GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
49 {"ENABLE_PUSH", 1u, 0u, 1u, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
50 GRPC_HTTP2_PROTOCOL_ERROR},
51 {"MAX_CONCURRENT_STREAMS", 4294967295u, 0u, 4294967295u,
52 GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
53 {"INITIAL_WINDOW_SIZE", 65535u, 0u, 2147483647u,
54 GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
55 GRPC_HTTP2_FLOW_CONTROL_ERROR},
56 {"MAX_FRAME_SIZE", 16384u, 16384u, 16777215u,
57 GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
58 {"MAX_HEADER_LIST_SIZE", 16777216u, 0u, 16777216u,
59 GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
60 {"GRPC_ALLOW_TRUE_BINARY_METADATA", 0u, 0u, 1u,
61 GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
62 };
63