gRPC  0.6.0
 All Classes Namespaces Functions Variables Enumerations Properties Pages
frame_settings.h
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H
35 #define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H
36 
37 #include <grpc/support/port_platform.h>
38 #include <grpc/support/slice.h>
39 #include "src/core/transport/chttp2/frame.h"
40 
41 typedef enum {
42  GRPC_CHTTP2_SPS_ID0,
43  GRPC_CHTTP2_SPS_ID1,
44  GRPC_CHTTP2_SPS_VAL0,
45  GRPC_CHTTP2_SPS_VAL1,
46  GRPC_CHTTP2_SPS_VAL2,
47  GRPC_CHTTP2_SPS_VAL3
48 } grpc_chttp2_settings_parse_state;
49 
50 /* The things HTTP/2 defines as connection level settings */
51 typedef enum {
52  GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE = 1,
53  GRPC_CHTTP2_SETTINGS_ENABLE_PUSH = 2,
54  GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS = 3,
55  GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE = 4,
56  GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE = 5,
57  GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 6,
58  GRPC_CHTTP2_NUM_SETTINGS
59 } grpc_chttp2_setting_id;
60 
61 typedef struct {
62  grpc_chttp2_settings_parse_state state;
63  gpr_uint32 *target_settings;
64  gpr_uint8 is_ack;
65  gpr_uint16 id;
66  gpr_uint32 value;
67  gpr_uint32 incoming_settings[GRPC_CHTTP2_NUM_SETTINGS];
69 
70 typedef enum {
71  GRPC_CHTTP2_CLAMP_INVALID_VALUE,
72  GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE
73 } grpc_chttp2_invalid_value_behavior;
74 
75 typedef struct {
76  const char *name;
77  gpr_uint32 default_value;
78  gpr_uint32 min_value;
79  gpr_uint32 max_value;
80  grpc_chttp2_invalid_value_behavior invalid_value_behavior;
82 
83 /* HTTP/2 mandated connection setting parameters */
85  grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS];
86 
87 /* Create a settings frame by diffing old & new, and updating old to be new */
88 gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
89  gpr_uint32 force_mask, size_t count);
90 /* Create an ack settings frame */
91 gpr_slice grpc_chttp2_settings_ack_create(void);
92 
93 grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
94  grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags,
95  gpr_uint32 *settings);
96 grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
97  void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last);
98 
99 #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H */
Definition: frame.h:48
Definition: frame_settings.h:75
Definition: frame_settings.h:61
Definition: slice.h:79