|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifndef __mod_h2__h2__
|
|
Packit |
90a5c9 |
#define __mod_h2__h2__
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The magic PRIamble of RFC 7540 that is always sent when starting
|
|
Packit |
90a5c9 |
* a h2 communication.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
extern const char *H2_MAGIC_TOKEN;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_ERR_NO_ERROR (0x00)
|
|
Packit |
90a5c9 |
#define H2_ERR_PROTOCOL_ERROR (0x01)
|
|
Packit |
90a5c9 |
#define H2_ERR_INTERNAL_ERROR (0x02)
|
|
Packit |
90a5c9 |
#define H2_ERR_FLOW_CONTROL_ERROR (0x03)
|
|
Packit |
90a5c9 |
#define H2_ERR_SETTINGS_TIMEOUT (0x04)
|
|
Packit |
90a5c9 |
#define H2_ERR_STREAM_CLOSED (0x05)
|
|
Packit |
90a5c9 |
#define H2_ERR_FRAME_SIZE_ERROR (0x06)
|
|
Packit |
90a5c9 |
#define H2_ERR_REFUSED_STREAM (0x07)
|
|
Packit |
90a5c9 |
#define H2_ERR_CANCEL (0x08)
|
|
Packit |
90a5c9 |
#define H2_ERR_COMPRESSION_ERROR (0x09)
|
|
Packit |
90a5c9 |
#define H2_ERR_CONNECT_ERROR (0x0a)
|
|
Packit |
90a5c9 |
#define H2_ERR_ENHANCE_YOUR_CALM (0x0b)
|
|
Packit |
90a5c9 |
#define H2_ERR_INADEQUATE_SECURITY (0x0c)
|
|
Packit |
90a5c9 |
#define H2_ERR_HTTP_1_1_REQUIRED (0x0d)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_HEADER_METHOD ":method"
|
|
Packit |
90a5c9 |
#define H2_HEADER_METHOD_LEN 7
|
|
Packit |
90a5c9 |
#define H2_HEADER_SCHEME ":scheme"
|
|
Packit |
90a5c9 |
#define H2_HEADER_SCHEME_LEN 7
|
|
Packit |
90a5c9 |
#define H2_HEADER_AUTH ":authority"
|
|
Packit |
90a5c9 |
#define H2_HEADER_AUTH_LEN 10
|
|
Packit |
90a5c9 |
#define H2_HEADER_PATH ":path"
|
|
Packit |
90a5c9 |
#define H2_HEADER_PATH_LEN 5
|
|
Packit |
90a5c9 |
#define H2_CRLF "\r\n"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Max data size to write so it fits inside a TLS record */
|
|
Packit |
90a5c9 |
#define H2_DATA_CHUNK_SIZE ((16*1024) - 100 - 9)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Size of the frame header itself in HTTP/2 */
|
|
Packit |
90a5c9 |
#define H2_FRAME_HDR_LEN 9
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Maximum number of padding bytes in a frame, rfc7540 */
|
|
Packit |
90a5c9 |
#define H2_MAX_PADLEN 256
|
|
Packit |
90a5c9 |
/* Initial default window size, RFC 7540 ch. 6.5.2 */
|
|
Packit |
90a5c9 |
#define H2_INITIAL_WINDOW_SIZE ((64*1024)-1)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_STREAM_CLIENT_INITIATED(id) (id&0x01)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_ALEN(a) (sizeof(a)/sizeof((a)[0]))
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2MAX(x,y) ((x) > (y) ? (x) : (y))
|
|
Packit |
90a5c9 |
#define H2MIN(x,y) ((x) < (y) ? (x) : (y))
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef enum {
|
|
Packit |
90a5c9 |
H2_DEPENDANT_AFTER,
|
|
Packit |
90a5c9 |
H2_DEPENDANT_INTERLEAVED,
|
|
Packit |
90a5c9 |
H2_DEPENDANT_BEFORE,
|
|
Packit |
90a5c9 |
} h2_dependency;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct h2_priority {
|
|
Packit |
90a5c9 |
h2_dependency dependency;
|
|
Packit |
90a5c9 |
int weight;
|
|
Packit |
90a5c9 |
} h2_priority;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef enum {
|
|
Packit |
90a5c9 |
H2_PUSH_NONE,
|
|
Packit |
90a5c9 |
H2_PUSH_DEFAULT,
|
|
Packit |
90a5c9 |
H2_PUSH_HEAD,
|
|
Packit |
90a5c9 |
H2_PUSH_FAST_LOAD,
|
|
Packit |
90a5c9 |
} h2_push_policy;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef enum {
|
|
Packit |
90a5c9 |
H2_SESSION_ST_INIT, /* send initial SETTINGS, etc. */
|
|
Packit |
90a5c9 |
H2_SESSION_ST_DONE, /* finished, connection close */
|
|
Packit |
90a5c9 |
H2_SESSION_ST_IDLE, /* nothing to write, expecting data inc */
|
|
Packit |
90a5c9 |
H2_SESSION_ST_BUSY, /* read/write without stop */
|
|
Packit |
90a5c9 |
H2_SESSION_ST_WAIT, /* waiting for tasks reporting back */
|
|
Packit |
90a5c9 |
H2_SESSION_ST_CLEANUP, /* pool is being cleaned up */
|
|
Packit |
90a5c9 |
} h2_session_state;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct h2_session_props {
|
|
Packit |
90a5c9 |
int accepted_max; /* the highest remote stream id was/will be handled */
|
|
Packit |
90a5c9 |
int completed_max; /* the highest remote stream completed */
|
|
Packit |
90a5c9 |
int emitted_count; /* the number of local streams sent */
|
|
Packit |
90a5c9 |
int emitted_max; /* the highest local stream id sent */
|
|
Packit |
90a5c9 |
int error; /* the last session error encountered */
|
|
Packit |
90a5c9 |
unsigned int accepting : 1; /* if the session is accepting new streams */
|
|
Packit |
90a5c9 |
unsigned int shutdown : 1; /* if the final GOAWAY has been sent */
|
|
Packit |
90a5c9 |
} h2_session_props;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef enum h2_stream_state_t {
|
|
Packit |
90a5c9 |
H2_SS_IDLE,
|
|
Packit |
90a5c9 |
H2_SS_RSVD_R,
|
|
Packit |
90a5c9 |
H2_SS_RSVD_L,
|
|
Packit |
90a5c9 |
H2_SS_OPEN,
|
|
Packit |
90a5c9 |
H2_SS_CLOSED_R,
|
|
Packit |
90a5c9 |
H2_SS_CLOSED_L,
|
|
Packit |
90a5c9 |
H2_SS_CLOSED,
|
|
Packit |
90a5c9 |
H2_SS_CLEANUP,
|
|
Packit |
90a5c9 |
H2_SS_MAX
|
|
Packit |
90a5c9 |
} h2_stream_state_t;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef enum {
|
|
Packit |
90a5c9 |
H2_SEV_CLOSED_L,
|
|
Packit |
90a5c9 |
H2_SEV_CLOSED_R,
|
|
Packit |
90a5c9 |
H2_SEV_CANCELLED,
|
|
Packit |
90a5c9 |
H2_SEV_EOS_SENT,
|
|
Packit |
90a5c9 |
H2_SEV_IN_DATA_PENDING,
|
|
Packit |
90a5c9 |
} h2_stream_event_t;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* h2_request is the transformer of HTTP2 streams into HTTP/1.1 internal
|
|
Packit |
90a5c9 |
* format that will be fed to various httpd input filters to finally
|
|
Packit |
90a5c9 |
* become a request_rec to be handled by soemone.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
typedef struct h2_request h2_request;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
struct h2_request {
|
|
Packit |
90a5c9 |
const char *method; /* pseudo header values, see ch. 8.1.2.3 */
|
|
Packit |
90a5c9 |
const char *scheme;
|
|
Packit |
90a5c9 |
const char *authority;
|
|
Packit |
90a5c9 |
const char *path;
|
|
Packit |
90a5c9 |
apr_table_t *headers;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_time_t request_time;
|
|
Packit |
90a5c9 |
unsigned int chunked : 1; /* iff requst body needs to be forwarded as chunked */
|
|
Packit |
90a5c9 |
unsigned int serialize : 1; /* iff this request is written in HTTP/1.1 serialization */
|
|
Packit |
90a5c9 |
apr_off_t raw_bytes; /* RAW network bytes that generated this request - if known. */
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct h2_headers h2_headers;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
struct h2_headers {
|
|
Packit |
90a5c9 |
int status;
|
|
Packit |
90a5c9 |
apr_table_t *headers;
|
|
Packit |
90a5c9 |
apr_table_t *notes;
|
|
Packit |
90a5c9 |
apr_off_t raw_bytes; /* RAW network bytes that generated this request - if known. */
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef apr_status_t h2_io_data_cb(void *ctx, const char *data, apr_off_t len);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef int h2_stream_pri_cmp(int stream_id1, int stream_id2, void *ctx);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Note key to attach connection task id to conn_rec/request_rec instances */
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_TASK_ID_NOTE "http2-task-id"
|
|
Packit |
90a5c9 |
#define H2_FILTER_DEBUG_NOTE "http2-debug"
|
|
Packit |
90a5c9 |
#define H2_HDR_CONFORMANCE "http2-hdr-conformance"
|
|
Packit |
90a5c9 |
#define H2_HDR_CONFORMANCE_UNSAFE "unsafe"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#endif /* defined(__mod_h2__h2__) */
|