Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h2_proxy_util.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_proxy_util__
17 #define __mod_h2__h2_proxy_util__
18 
19 /*******************************************************************************
20  * some debugging/format helpers
21  ******************************************************************************/
22 struct h2_proxy_request;
23 struct nghttp2_frame;
24 
25 int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen);
26 
27 /*******************************************************************************
28  * ihash - hash for structs with int identifier
29  ******************************************************************************/
31 typedef int h2_proxy_ihash_iter_t(void *ctx, void *val);
32 
38 h2_proxy_ihash_t *h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int);
39 
42 void *h2_proxy_ihash_get(h2_proxy_ihash_t *ih, int id);
43 
53 
54 void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val);
55 void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id);
56 void h2_proxy_ihash_remove_val(h2_proxy_ihash_t *ih, void *val);
58 
59 size_t h2_proxy_ihash_shift(h2_proxy_ihash_t *ih, void **buffer, size_t max);
60 size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max);
61 
62 /*******************************************************************************
63  * iqueue - sorted list of int with user defined ordering
64  ******************************************************************************/
65 typedef struct h2_proxy_iqueue {
66  int *elts;
67  int head;
68  int nelts;
69  int nalloc;
72 
84 typedef int h2_proxy_iq_cmp(int i1, int i2, void *ctx);
85 
92 
98 
104 
113 void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx);
114 
122 int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid);
123 
128 
137 void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx);
138 
147 
148 /*******************************************************************************
149  * common helpers
150  ******************************************************************************/
151 /* h2_proxy_log2(n) iff n is a power of 2 */
152 unsigned char h2_proxy_log2(int n);
153 
154 /*******************************************************************************
155  * HTTP/2 header helpers
156  ******************************************************************************/
157 void h2_proxy_util_camel_case_header(char *s, size_t len);
158 int h2_proxy_res_ignore_header(const char *name, size_t len);
159 
160 /*******************************************************************************
161  * nghttp2 helpers
162  ******************************************************************************/
163 typedef struct h2_proxy_ngheader {
164  nghttp2_nv *nv;
168  const struct h2_proxy_request *req);
169 
170 /*******************************************************************************
171  * h2_proxy_request helpers
172  ******************************************************************************/
174 
176  const char *method; /* pseudo header values, see ch. 8.1.2.3 */
177  const char *scheme;
178  const char *authority;
179  const char *path;
180 
182 
184 
185  unsigned int chunked : 1; /* iff requst body needs to be forwarded as chunked */
186  unsigned int serialize : 1; /* iff this request is written in HTTP/1.1 serialization */
187 };
188 
189 h2_proxy_request *h2_proxy_req_create(int id, apr_pool_t *pool, int serialize);
191  const char *method, const char *scheme,
192  const char *authority, const char *path,
193  apr_table_t *headers);
194 
195 /*******************************************************************************
196  * reverse mapping for link headers
197  ******************************************************************************/
200  const char *real_server_uri,
201  const char *proxy_server_uri,
202  const char *s);
203 
204 #endif /* defined(__mod_h2__h2_proxy_util__) */
size_t apr_size_t
Definition: apr.h:375
apr_status_t h2_proxy_req_make(h2_proxy_request *req, apr_pool_t *pool, const char *method, const char *scheme, const char *authority, const char *path, apr_table_t *headers)
void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx)
const char * h2_proxy_link_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *real_server_uri, const char *proxy_server_uri, const char *s)
int nelts
Definition: h2_proxy_util.h:68
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:556
h2_proxy_ngheader * h2_proxy_util_nghd_make_req(apr_pool_t *p, const struct h2_proxy_request *req)
size_t h2_proxy_ihash_count(h2_proxy_ihash_t *ih)
h2_proxy_iqueue * h2_proxy_iq_create(apr_pool_t *pool, int capacity)
const char * path
Definition: h2_proxy_util.h:179
size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max)
unsigned int chunked
Definition: h2_proxy_util.h:185
nghttp2_nv * nv
Definition: h2_proxy_util.h:164
int h2_proxy_ihash_iter_t(void *ctx, void *val)
Definition: h2_proxy_util.h:31
void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx)
const char * scheme
Definition: h2_proxy_util.h:177
struct h2_proxy_ihash_t h2_proxy_ihash_t
Definition: h2_proxy_util.h:30
void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val)
struct h2_proxy_iqueue h2_proxy_iqueue
int nalloc
Definition: h2_proxy_util.h:69
apr_int64_t apr_time_t
Definition: apr_time.h:45
int h2_proxy_iq_empty(h2_proxy_iqueue *q)
void h2_proxy_ihash_clear(h2_proxy_ihash_t *ih)
void h2_proxy_util_camel_case_header(char *s, size_t len)
Definition: h2_proxy_util.h:65
apr_time_t request_time
Definition: h2_proxy_util.h:183
int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen)
void h2_proxy_iq_clear(h2_proxy_iqueue *q)
h2_proxy_request * h2_proxy_req_create(int id, apr_pool_t *pool, int serialize)
h2_proxy_ihash_t * h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int)
int h2_proxy_ihash_empty(h2_proxy_ihash_t *ih)
int h2_proxy_res_ignore_header(const char *name, size_t len)
Definition: h2_proxy_util.h:175
void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id)
void h2_proxy_ihash_remove_val(h2_proxy_ihash_t *ih, void *val)
int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid)
void * h2_proxy_ihash_get(h2_proxy_ihash_t *ih, int id)
apr_pool_t * p
int h2_proxy_iq_cmp(int i1, int i2, void *ctx)
Definition: h2_proxy_util.h:84
A structure that represents the current request.
Definition: httpd.h:805
unsigned char h2_proxy_log2(int n)
int * elts
Definition: h2_proxy_util.h:66
const char * method
Definition: h2_proxy_util.h:176
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
struct h2_proxy_ngheader h2_proxy_ngheader
const char * name
Definition: mod_dav.h:730
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_table_t * headers
Definition: h2_proxy_util.h:181
const char * authority
Definition: h2_proxy_util.h:178
int apr_status_t
Definition: apr_errno.h:44
request_rec * r
Definition: mod_dav.h:519
int h2_proxy_iq_shift(h2_proxy_iqueue *q)
Definition: h2_proxy_util.h:163
apr_size_t nvlen
Definition: h2_proxy_util.h:165
unsigned int serialize
Definition: h2_proxy_util.h:186
proxy_worker proxy_server_conf * conf
Definition: mod_proxy.h:602
Definition: mod_proxy.h:205
size_t h2_proxy_ihash_shift(h2_proxy_ihash_t *ih, void **buffer, size_t max)
int h2_proxy_ihash_iter(h2_proxy_ihash_t *ih, h2_proxy_ihash_iter_t *fn, void *ctx)
int h2_proxy_iq_count(h2_proxy_iqueue *q)
int head
Definition: h2_proxy_util.h:67
apr_pool_t * pool
Definition: h2_proxy_util.h:70