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