1 /*
2  * nghttp2 - HTTP/2 C Library
3  *
4  * Copyright (c) 2014 Tatsuhiro Tsujikawa
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #ifndef NGHTTP2_OPTION_H
26 #define NGHTTP2_OPTION_H
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif /* HAVE_CONFIG_H */
31 
32 #include "nghttp2.h"
33 
34 /**
35  * Configuration options
36  */
37 typedef enum {
38     /**
39      * This option prevents the library from sending WINDOW_UPDATE for a
40      * connection automatically.  If this option is set to nonzero, the
41      * library won't send WINDOW_UPDATE for DATA until application calls
42      * nghttp2_session_consume() to indicate the amount of consumed
43      * DATA.  By default, this option is set to zero.
44      */
45     NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE = 1,
46     /**
47      * This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
48      * remote endpoint as if it is received in SETTINGS frame. Without
49      * specifying this option, before the local endpoint receives
50      * SETTINGS_MAX_CONCURRENT_STREAMS in SETTINGS frame from remote
51      * endpoint, SETTINGS_MAX_CONCURRENT_STREAMS is unlimited. This may
52      * cause problem if local endpoint submits lots of requests
53      * initially and sending them at once to the remote peer may lead to
54      * the rejection of some requests. Specifying this option to the
55      * sensible value, say 100, may avoid this kind of issue. This value
56      * will be overwritten if the local endpoint receives
57      * SETTINGS_MAX_CONCURRENT_STREAMS from the remote endpoint.
58      */
59     NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS = 1 << 1,
60     NGHTTP2_OPT_NO_RECV_CLIENT_MAGIC = 1 << 2,
61     NGHTTP2_OPT_NO_HTTP_MESSAGING = 1 << 3,
62     NGHTTP2_OPT_MAX_RESERVED_REMOTE_STREAMS = 1 << 4,
63     NGHTTP2_OPT_USER_RECV_EXT_TYPES = 1 << 5,
64     NGHTTP2_OPT_NO_AUTO_PING_ACK = 1 << 6,
65     NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES = 1 << 7,
66     NGHTTP2_OPT_MAX_SEND_HEADER_BLOCK_LENGTH = 1 << 8,
67     NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE = 1 << 9,
68     NGHTTP2_OPT_NO_CLOSED_STREAMS = 1 << 10,
69 } nghttp2_option_flag;
70 
71 /**
72  * Struct to store option values for nghttp2_session.
73  */
74 struct nghttp2_option {
75     /**
76      * NGHTTP2_OPT_MAX_SEND_HEADER_BLOCK_LENGTH
77      */
78     size_t max_send_header_block_length;
79     /**
80      * NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE
81      */
82     size_t max_deflate_dynamic_table_size;
83     /**
84      * Bitwise OR of nghttp2_option_flag to determine that which fields
85      * are specified.
86      */
87     uint32_t opt_set_mask;
88     /**
89      * NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS
90      */
91     uint32_t peer_max_concurrent_streams;
92     /**
93      * NGHTTP2_OPT_MAX_RESERVED_REMOTE_STREAMS
94      */
95     uint32_t max_reserved_remote_streams;
96     /**
97      * NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES
98      */
99     uint32_t builtin_recv_ext_types;
100     /**
101      * NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE
102      */
103     int no_auto_window_update;
104     /**
105      * NGHTTP2_OPT_NO_RECV_CLIENT_MAGIC
106      */
107     int no_recv_client_magic;
108     /**
109      * NGHTTP2_OPT_NO_HTTP_MESSAGING
110      */
111     int no_http_messaging;
112     /**
113      * NGHTTP2_OPT_NO_AUTO_PING_ACK
114      */
115     int no_auto_ping_ack;
116     /**
117      * NGHTTP2_OPT_NO_CLOSED_STREAMS
118      */
119     int no_closed_streams;
120     /**
121      * NGHTTP2_OPT_USER_RECV_EXT_TYPES
122      */
123     uint8_t user_recv_ext_types[32];
124 };
125 
126 #endif /* NGHTTP2_OPTION_H */
127