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 /* 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_proxy_util__
18 #define __mod_h2__h2_proxy_util__
19 
20 /*******************************************************************************
21  * some debugging/format helpers
22  ******************************************************************************/
23 struct h2_proxy_request;
24 struct nghttp2_frame;
25 
26 int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen);
27 
28 /*******************************************************************************
29  * ihash - hash for structs with int identifier
30  ******************************************************************************/
32 typedef int h2_proxy_ihash_iter_t(void *ctx, void *val);
33 
39 h2_proxy_ihash_t *h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int);
40 
43 void *h2_proxy_ihash_get(h2_proxy_ihash_t *ih, int id);
44 
54 
55 void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val);
56 void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id);
57 void h2_proxy_ihash_remove_val(h2_proxy_ihash_t *ih, void *val);
59 
60 size_t h2_proxy_ihash_shift(h2_proxy_ihash_t *ih, void **buffer, size_t max);
61 size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max);
62 
63 /*******************************************************************************
64  * iqueue - sorted list of int with user defined ordering
65  ******************************************************************************/
66 typedef struct h2_proxy_iqueue {
67  int *elts;
68  int head;
69  int nelts;
70  int nalloc;
73 
85 typedef int h2_proxy_iq_cmp(int i1, int i2, void *ctx);
86 
93 
99 
105 
114 void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx);
115 
123 int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid);
124 
129 
138 void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx);
139 
148 
149 /*******************************************************************************
150  * common helpers
151  ******************************************************************************/
152 /* h2_proxy_log2(n) iff n is a power of 2 */
153 unsigned char h2_proxy_log2(int n);
154 
155 /*******************************************************************************
156  * HTTP/2 header helpers
157  ******************************************************************************/
158 void h2_proxy_util_camel_case_header(char *s, size_t len);
159 int h2_proxy_res_ignore_header(const char *name, size_t len);
160 
161 /*******************************************************************************
162  * nghttp2 helpers
163  ******************************************************************************/
164 typedef struct h2_proxy_ngheader {
165  nghttp2_nv *nv;
169  const struct h2_proxy_request *req);
170 
171 /*******************************************************************************
172  * h2_proxy_request helpers
173  ******************************************************************************/
175 
177  const char *method; /* pseudo header values, see ch. 8.1.2.3 */
178  const char *scheme;
179  const char *authority;
180  const char *path;
181 
183 
185 
186  unsigned int chunked : 1; /* iff requst body needs to be forwarded as chunked */
187  unsigned int serialize : 1; /* iff this request is written in HTTP/1.1 serialization */
188 };
189 
190 h2_proxy_request *h2_proxy_req_create(int id, apr_pool_t *pool, int serialize);
192  const char *method, const char *scheme,
193  const char *authority, const char *path,
194  apr_table_t *headers);
195 
196 /*******************************************************************************
197  * reverse mapping for link headers
198  ******************************************************************************/
201  const char *real_server_uri,
202  const char *proxy_server_uri,
203  const char *s);
204 
205 /*******************************************************************************
206  * FIFO queue
207  ******************************************************************************/
208 
214 
220 
227 
230 
233 
244 
245 apr_status_t h2_proxy_fifo_pull(h2_proxy_fifo *fifo, void **pelem);
247 
254 
255 
256 #endif /* defined(__mod_h2__h2_proxy_util__) */
size_t apr_size_t
Definition: apr.h:375
apr_status_t h2_proxy_fifo_pull(h2_proxy_fifo *fifo, void **pelem)
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:69
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
h2_proxy_ngheader * h2_proxy_util_nghd_make_req(apr_pool_t *p, const struct h2_proxy_request *req)
struct h2_proxy_fifo h2_proxy_fifo
Definition: h2_proxy_util.h:213
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:180
size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max)
apr_status_t h2_proxy_fifo_try_push(h2_proxy_fifo *fifo, void *elem)
unsigned int chunked
Definition: h2_proxy_util.h:186
nghttp2_nv * nv
Definition: h2_proxy_util.h:165
int h2_proxy_ihash_iter_t(void *ctx, void *val)
Definition: h2_proxy_util.h:32
void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx)
const char * scheme
Definition: h2_proxy_util.h:178
apr_status_t h2_proxy_fifo_term(h2_proxy_fifo *fifo)
struct h2_proxy_ihash_t h2_proxy_ihash_t
Definition: h2_proxy_util.h:31
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:70
int h2_proxy_fifo_count(h2_proxy_fifo *fifo)
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:66
apr_time_t request_time
Definition: h2_proxy_util.h:184
apr_status_t h2_proxy_fifo_remove(h2_proxy_fifo *fifo, void *elem)
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)
apr_status_t h2_proxy_fifo_set_create(h2_proxy_fifo **pfifo, apr_pool_t *pool, int capacity)
apr_status_t h2_proxy_fifo_try_pull(h2_proxy_fifo *fifo, void **pelem)
h2_proxy_ihash_t * h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int)
apr_status_t h2_proxy_fifo_create(h2_proxy_fifo **pfifo, apr_pool_t *pool, int capacity)
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:176
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:85
apr_status_t h2_proxy_fifo_interrupt(h2_proxy_fifo *fifo)
A structure that represents the current request.
Definition: httpd.h:811
unsigned char h2_proxy_log2(int n)
int * elts
Definition: h2_proxy_util.h:67
const char * method
Definition: h2_proxy_util.h:177
apr_status_t h2_proxy_fifo_push(h2_proxy_fifo *fifo, void *elem)
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:726
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_table_t * headers
Definition: h2_proxy_util.h:182
const char * authority
Definition: h2_proxy_util.h:179
int apr_status_t
Definition: apr_errno.h:44
request_rec * r
Definition: mod_dav.h:515
int h2_proxy_iq_shift(h2_proxy_iqueue *q)
int h2_proxy_fifo_capacity(h2_proxy_fifo *fifo)
Definition: h2_proxy_util.h:164
apr_size_t nvlen
Definition: h2_proxy_util.h:166
unsigned int serialize
Definition: h2_proxy_util.h:187
proxy_worker proxy_server_conf * conf
Definition: mod_proxy.h:611
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:68
apr_pool_t * pool
Definition: h2_proxy_util.h:71