Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h2.h
Go to the documentation of this file.
1 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://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,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __mod_h2__h2__
17 #define __mod_h2__h2__
18 
23 extern const char *H2_MAGIC_TOKEN;
24 
25 #define H2_ERR_NO_ERROR (0x00)
26 #define H2_ERR_PROTOCOL_ERROR (0x01)
27 #define H2_ERR_INTERNAL_ERROR (0x02)
28 #define H2_ERR_FLOW_CONTROL_ERROR (0x03)
29 #define H2_ERR_SETTINGS_TIMEOUT (0x04)
30 #define H2_ERR_STREAM_CLOSED (0x05)
31 #define H2_ERR_FRAME_SIZE_ERROR (0x06)
32 #define H2_ERR_REFUSED_STREAM (0x07)
33 #define H2_ERR_CANCEL (0x08)
34 #define H2_ERR_COMPRESSION_ERROR (0x09)
35 #define H2_ERR_CONNECT_ERROR (0x0a)
36 #define H2_ERR_ENHANCE_YOUR_CALM (0x0b)
37 #define H2_ERR_INADEQUATE_SECURITY (0x0c)
38 #define H2_ERR_HTTP_1_1_REQUIRED (0x0d)
39 
40 #define H2_HEADER_METHOD ":method"
41 #define H2_HEADER_METHOD_LEN 7
42 #define H2_HEADER_SCHEME ":scheme"
43 #define H2_HEADER_SCHEME_LEN 7
44 #define H2_HEADER_AUTH ":authority"
45 #define H2_HEADER_AUTH_LEN 10
46 #define H2_HEADER_PATH ":path"
47 #define H2_HEADER_PATH_LEN 5
48 #define H2_CRLF "\r\n"
49 
50 /* Max data size to write so it fits inside a TLS record */
51 #define H2_DATA_CHUNK_SIZE ((16*1024) - 100 - 9)
52 
53 /* Maximum number of padding bytes in a frame, rfc7540 */
54 #define H2_MAX_PADLEN 256
55 /* Initial default window size, RFC 7540 ch. 6.5.2 */
56 #define H2_INITIAL_WINDOW_SIZE ((64*1024)-1)
57 
58 #define H2_STREAM_CLIENT_INITIATED(id) (id&0x01)
59 
60 #define H2_ALEN(a) (sizeof(a)/sizeof((a)[0]))
61 
62 #define H2MAX(x,y) ((x) > (y) ? (x) : (y))
63 #define H2MIN(x,y) ((x) < (y) ? (x) : (y))
64 
65 typedef enum {
70 
71 typedef struct h2_priority {
73  int weight;
74 } h2_priority;
75 
76 typedef enum {
82 
83 typedef enum {
92 
93 typedef enum {
94  H2_SESSION_ST_INIT, /* send initial SETTINGS, etc. */
95  H2_SESSION_ST_DONE, /* finished, connection close */
96  H2_SESSION_ST_IDLE, /* nothing to write, expecting data inc */
97  H2_SESSION_ST_BUSY, /* read/write without stop */
98  H2_SESSION_ST_WAIT, /* waiting for tasks reporting back */
100 
101 typedef struct h2_session_props {
102  int accepted_max; /* the highest remote stream id was/will be handled */
103  int completed_max; /* the highest remote stream completed */
104  int emitted_count; /* the number of local streams sent */
105  int emitted_max; /* the highest local stream id sent */
106  int error; /* the last session error encountered */
107  unsigned int accepting : 1; /* if the session is accepting new streams */
108  unsigned int shutdown : 1; /* if the final GOAWAY has been sent */
110 
111 
112 /* h2_request is the transformer of HTTP2 streams into HTTP/1.1 internal
113  * format that will be fed to various httpd input filters to finally
114  * become a request_rec to be handled by soemone.
115  */
116 typedef struct h2_request h2_request;
117 
118 struct h2_request {
119  const char *method; /* pseudo header values, see ch. 8.1.2.3 */
120  const char *scheme;
121  const char *authority;
122  const char *path;
124 
126  unsigned int chunked : 1; /* iff requst body needs to be forwarded as chunked */
127  unsigned int serialize : 1; /* iff this request is written in HTTP/1.1 serialization */
128 };
129 
130 typedef struct h2_headers h2_headers;
131 
132 struct h2_headers {
133  int status;
136 };
137 
138 typedef apr_status_t h2_io_data_cb(void *ctx, const char *data, apr_off_t len);
139 
140 typedef int h2_stream_pri_cmp(int stream_id1, int stream_id2, void *ctx);
141 
142 /* Note key to attach connection task id to conn_rec/request_rec instances */
143 
144 #define H2_TASK_ID_NOTE "http2-task-id"
145 #define H2_FILTER_DEBUG_NOTE "http2-debug"
146 
147 #endif /* defined(__mod_h2__h2__) */
unsigned int shutdown
Definition: h2.h:108
h2_dependency dependency
Definition: h2.h:72
Definition: h2.h:77
struct h2_session_props h2_session_props
Definition: h2.h:68
Definition: h2.h:87
unsigned int chunked
Definition: h2.h:126
Definition: h2.h:71
Definition: h2.h:66
h2_push_policy
Definition: h2.h:76
Definition: h2.h:118
Definition: h2.h:95
apr_table_t * notes
Definition: h2.h:135
int error
Definition: h2.h:106
int status
Definition: h2.h:133
unsigned int accepting
Definition: h2.h:107
Definition: h2.h:67
int emitted_count
Definition: h2.h:104
Definition: h2.h:88
Definition: h2.h:89
int completed_max
Definition: h2.h:103
Definition: h2.h:85
h2_dependency
Definition: h2.h:65
Definition: h2.h:90
apr_int64_t apr_time_t
Definition: apr_time.h:45
Definition: h2.h:101
const char * method
Definition: h2.h:119
Definition: h2.h:94
Definition: h2.h:98
unsigned int serialize
Definition: h2.h:127
const char * scheme
Definition: h2.h:120
apr_status_t h2_io_data_cb(void *ctx, const char *data, apr_off_t len)
Definition: h2.h:138
Definition: h2.h:79
int emitted_max
Definition: h2.h:105
struct h2_priority h2_priority
h2_stream_state_t
Definition: h2.h:83
apr_time_t request_time
Definition: h2.h:125
const char * path
Definition: h2.h:122
int h2_stream_pri_cmp(int stream_id1, int stream_id2, void *ctx)
Definition: h2.h:140
Definition: h2.h:84
apr_table_t * headers
Definition: h2.h:134
Definition: h2.h:132
Definition: h2.h:97
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
h2_session_state
Definition: h2.h:93
Definition: h2.h:86
Definition: h2.h:96
int weight
Definition: h2.h:73
int apr_status_t
Definition: apr_errno.h:44
Definition: h2.h:80
const char * authority
Definition: h2.h:121
apr_table_t * headers
Definition: h2.h:123
int accepted_max
Definition: h2.h:102
Definition: h2.h:78
off_t apr_off_t
Definition: apr.h:377
const char * H2_MAGIC_TOKEN