Apache2
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  ******************************************************************************/
31 typedef struct h2_proxy_ihash_t h2_proxy_ihash_t;
32 typedef int h2_proxy_ihash_iter_t(void *ctx, void *val);
33 
40 
44 
54 
55 void h2_proxy_ihash_add(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 
124 
129 
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 
172 
173 /*******************************************************************************
174  * h2_proxy_request helpers
175  ******************************************************************************/
176 typedef struct h2_proxy_request h2_proxy_request;
177 
179  const char *method; /* pseudo header values, see ch. 8.1.2.3 */
180  const char *scheme;
181  const char *authority;
182  const char *path;
183 
185 
187 
188  int chunked; /* iff request body needs to be forwarded as chunked */
189 };
190 
193  const char *method, const char *scheme,
194  const char *authority, const char *path,
196 
197 /*******************************************************************************
198  * reverse mapping for link headers
199  ******************************************************************************/
202  const char *real_server_uri,
203  const char *proxy_server_uri,
204  const char *s);
205 
206 /*******************************************************************************
207  * FIFO queue
208  ******************************************************************************/
209 
214 typedef struct h2_proxy_fifo h2_proxy_fifo;
215 
221 
228 
231 
234 
245 
248 
255 
256 
257 #endif /* defined(__mod_h2__h2_proxy_util__) */
request_rec * r
Definition: mod_dav.h:518
const char * s
Definition: mod_dav.h:1327
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:557
const char * name
Definition: mod_dav.h:805
apr_table_t * headers
Definition: mod_proxy.h:1484
proxy_worker proxy_server_conf * conf
Definition: mod_proxy.h:657
int apr_status_t
Definition: apr_errno.h:44
size_t apr_size_t
Definition: apr.h:394
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
apr_int64_t apr_time_t
Definition: apr_time.h:45
apr_status_t h2_proxy_fifo_try_push(h2_proxy_fifo *fifo, void *elem)
apr_status_t h2_proxy_fifo_try_pull(h2_proxy_fifo *fifo, void **pelem)
int h2_proxy_iq_remove(h2_proxy_iqueue *q, int sid)
h2_proxy_request * h2_proxy_req_create(int id, apr_pool_t *pool)
void * h2_proxy_ihash_get(h2_proxy_ihash_t *ih, int id)
int h2_proxy_ihash_iter(h2_proxy_ihash_t *ih, h2_proxy_ihash_iter_t *fn, void *ctx)
void h2_proxy_ihash_remove_val(h2_proxy_ihash_t *ih, void *val)
apr_status_t h2_proxy_fifo_remove(h2_proxy_fifo *fifo, void *elem)
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)
apr_status_t h2_proxy_fifo_set_create(h2_proxy_fifo **pfifo, apr_pool_t *pool, int capacity)
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_clear(h2_proxy_iqueue *q)
int h2_proxy_iq_shift(h2_proxy_iqueue *q)
int h2_proxy_fifo_count(h2_proxy_fifo *fifo)
apr_status_t h2_proxy_fifo_pull(h2_proxy_fifo *fifo, void **pelem)
int h2_proxy_iq_cmp(int i1, int i2, void *ctx)
Definition: h2_proxy_util.h:85
struct h2_proxy_iqueue h2_proxy_iqueue
unsigned char h2_proxy_log2(int n)
int h2_proxy_util_frame_print(const nghttp2_frame *frame, char *buffer, size_t maxlen)
apr_status_t h2_proxy_fifo_interrupt(h2_proxy_fifo *fifo)
struct h2_proxy_ihash_t h2_proxy_ihash_t
Definition: h2_proxy_util.h:31
void h2_proxy_ihash_remove(h2_proxy_ihash_t *ih, int id)
int h2_proxy_fifo_capacity(h2_proxy_fifo *fifo)
struct h2_proxy_fifo h2_proxy_fifo
Definition: h2_proxy_util.h:214
struct h2_proxy_ngheader h2_proxy_ngheader
size_t h2_proxy_ihash_shift(h2_proxy_ihash_t *ih, void **buffer, size_t max)
void h2_proxy_iq_add(h2_proxy_iqueue *q, int sid, h2_proxy_iq_cmp *cmp, void *ctx)
int h2_proxy_iq_empty(h2_proxy_iqueue *q)
h2_proxy_ngheader * h2_proxy_util_nghd_make(apr_pool_t *p, apr_table_t *headers)
size_t h2_proxy_ihash_ishift(h2_proxy_ihash_t *ih, int *buffer, size_t max)
h2_proxy_ihash_t * h2_proxy_ihash_create(apr_pool_t *pool, size_t offset_of_int)
void h2_proxy_ihash_clear(h2_proxy_ihash_t *ih)
void h2_proxy_util_camel_case_header(char *s, size_t len)
int h2_proxy_iq_count(h2_proxy_iqueue *q)
apr_status_t h2_proxy_fifo_term(h2_proxy_fifo *fifo)
int h2_proxy_ihash_iter_t(void *ctx, void *val)
Definition: h2_proxy_util.h:32
size_t h2_proxy_ihash_count(h2_proxy_ihash_t *ih)
void h2_proxy_ihash_add(h2_proxy_ihash_t *ih, void *val)
void h2_proxy_iq_sort(h2_proxy_iqueue *q, h2_proxy_iq_cmp *cmp, void *ctx)
int h2_proxy_res_ignore_header(const char *name, size_t len)
apr_status_t h2_proxy_fifo_push(h2_proxy_fifo *fifo, void *elem)
h2_proxy_ngheader * h2_proxy_util_nghd_make_req(apr_pool_t *p, const struct h2_proxy_request *req)
h2_proxy_iqueue * h2_proxy_iq_create(apr_pool_t *pool, int capacity)
int h2_proxy_ihash_empty(h2_proxy_ihash_t *ih)
apr_status_t h2_proxy_fifo_create(h2_proxy_fifo **pfifo, apr_pool_t *pool, int capacity)
Definition: h2_proxy_util.h:66
int * elts
Definition: h2_proxy_util.h:67
int head
Definition: h2_proxy_util.h:68
apr_pool_t * pool
Definition: h2_proxy_util.h:71
int nalloc
Definition: h2_proxy_util.h:70
int nelts
Definition: h2_proxy_util.h:69
Definition: h2_proxy_util.h:164
nghttp2_nv * nv
Definition: h2_proxy_util.h:165
apr_size_t nvlen
Definition: h2_proxy_util.h:166
Definition: h2_proxy_util.h:178
const char * scheme
Definition: h2_proxy_util.h:180
const char * authority
Definition: h2_proxy_util.h:181
apr_table_t * headers
Definition: h2_proxy_util.h:184
apr_time_t request_time
Definition: h2_proxy_util.h:186
const char * path
Definition: h2_proxy_util.h:182
int chunked
Definition: h2_proxy_util.h:188
const char * method
Definition: h2_proxy_util.h:179
Definition: mod_proxy.h:214
A structure that represents the current request.
Definition: httpd.h:856
apr_pool_t * p