initial_settings_frame.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
21 
22 #define PFX_STR "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
23 #define ONE_SETTING_HDR "\x00\x00\x06\x04\x00\x00\x00\x00\x00"
24 
26  void* /*registered_method*/) {
27  while (grpc_core::Server::FromC(server)->HasOpenConnections()) {
31  }
32 }
33 
34 int main(int argc, char** argv) {
36  grpc_init();
37 
38  /* various partial prefixes */
39  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00",
41  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00",
43  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00",
45  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x06",
47  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x06",
49  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x06",
51  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04",
53  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04\x00",
55  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04\x01",
57  GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, PFX_STR "\x00\x00\x00\x04\xff",
60  PFX_STR "\x00\x00\x00\x04\x00\x00",
63  PFX_STR "\x00\x00\x00\x04\x00\x00\x00",
66  PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00",
68  /* must not send frames with stream id != 0 */
70  PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00\x01", 0);
72  PFX_STR "\x00\x00\x00\x04\x00\x40\x00\x00\x00", 0);
73  /* settings frame must be a multiple of six bytes long */
75  PFX_STR "\x00\x00\x01\x04\x00\x00\x00\x00\x00", 0);
77  PFX_STR "\x00\x00\x02\x04\x00\x00\x00\x00\x00", 0);
79  PFX_STR "\x00\x00\x03\x04\x00\x00\x00\x00\x00", 0);
81  PFX_STR "\x00\x00\x04\x04\x00\x00\x00\x00\x00", 0);
83  PFX_STR "\x00\x00\x05\x04\x00\x00\x00\x00\x00", 0);
84  /* some settings values are illegal */
85  /* max frame size = 0 */
87  PFX_STR ONE_SETTING_HDR "\x00\x05\x00\x00\x00\x00",
90  PFX_STR ONE_SETTING_HDR "\x00\x06\xff\xff\xff\xff",
92  /* update intiial window size */
94  PFX_STR ONE_SETTING_HDR "\x00\x04\x00\x01\x00\x00",
96  /* ack with data */
98  PFX_STR
99  "\x00\x00\x00\x04\x00\x00\x00\x00\x00"
100  "\x00\x00\x01\x04\x01\x00\x00\x00\x00",
101  0);
102  /* settings frame with invalid flags */
104  PFX_STR "\x00\x00\x00\x04\x10\x00\x00\x00\x00", 0);
105  /* unknown settings should be ignored */
107  PFX_STR ONE_SETTING_HDR "\x00\x99\x00\x00\x00\x00",
109 
110  grpc_shutdown();
111  return 0;
112 }
generate.env
env
Definition: generate.py:37
ONE_SETTING_HDR
#define ONE_SETTING_HDR
Definition: initial_settings_frame.cc:23
PFX_STR
#define PFX_STR
Definition: initial_settings_frame.cc:22
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_timeout_milliseconds_to_deadline
gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms)
Definition: test/core/util/test_config.cc:89
grpc_completion_queue
Definition: completion_queue.cc:347
grpc_server
struct grpc_server grpc_server
Definition: grpc_types.h:65
verifier
static void verifier(grpc_server *server, grpc_completion_queue *cq, void *)
Definition: initial_settings_frame.cc:25
GRPC_BAD_CLIENT_DISCONNECT
#define GRPC_BAD_CLIENT_DISCONNECT
Definition: bad_client.h:48
server
Definition: examples/python/async_streaming/server.py:1
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
grpc_completion_queue_next
GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved)
Definition: completion_queue.cc:1133
server.h
GRPC_RUN_BAD_CLIENT_TEST
#define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, payload, flags)
Definition: bad_client.h:71
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
grpc_init
GRPCAPI void grpc_init(void)
Definition: init.cc:146
main
int main(int argc, char **argv)
Definition: initial_settings_frame.cc:34
grpc_core::CppImplOf< Server, grpc_server >::FromC
static Server * FromC(grpc_server *c_type)
Definition: cpp_impl_of.h:30
GRPC_QUEUE_TIMEOUT
@ GRPC_QUEUE_TIMEOUT
Definition: grpc_types.h:556
grpc_shutdown
GRPCAPI void grpc_shutdown(void)
Definition: init.cc:209
bad_client.h
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:15