2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 /***************************************************************************
19 * Description: URI to worker mapper header file *
20 * Author: Gal Shachor <shachor@il.ibm.com> *
21 * Version: $Revision: 705283 $ *
22 ***************************************************************************/
24 #ifndef JK_URI_WORKER_MAP_H
25 #define JK_URI_WORKER_MAP_H
31 #endif /* __cplusplus */
33 #include "jk_global.h"
35 #include "jk_logger.h"
38 #define MATCH_TYPE_EXACT 0x0001
40 #define MATCH_TYPE_CONTEXT 0x0002
42 /* match all context path URIs with a path component suffix */
44 #define MATCH_TYPE_CONTEXT_PATH 0x0004
47 #define MATCH_TYPE_SUFFIX 0x0010
49 /* match all URIs of the form *ext */
51 #define MATCH_TYPE_GENERAL_SUFFIX 0x0020
53 /* match multiple wild characters (*) and (?) */
54 #define MATCH_TYPE_WILDCHAR_PATH 0x0040
55 #define MATCH_TYPE_NO_MATCH 0x1000
56 #define MATCH_TYPE_DISABLED 0x2000
58 #define MATCH_TYPE_STOPPED 0x4000
61 #define SOURCE_TYPE_WORKERDEF 0x0001
62 #define SOURCE_TYPE_JKMOUNT 0x0002
63 #define SOURCE_TYPE_URIMAP 0x0003
64 #define SOURCE_TYPE_DISCOVER 0x0004
65 #define SOURCE_TYPE_TEXT_WORKERDEF ("worker definition")
66 #define SOURCE_TYPE_TEXT_JKMOUNT ("JkMount")
67 #define SOURCE_TYPE_TEXT_URIMAP ("uriworkermap")
68 #define SOURCE_TYPE_TEXT_DISCOVER ("ajp14")
70 #define JK_MAX_URI_LEN 4095
74 /* reply_timeout overwrite */
76 /* activation state overwrites for load balancers */
77 /* Number of elements in the array activations. */
79 /* Dynamically allocated array with one entry per lb member. */
81 /* Temporary storage for the original extension strings. */
85 /* fail_on_status overwrites */
86 /* Number of elements in the array fail_on_status. */
87 int fail_on_status_size;
88 /* Dynamically allocated array with one entry per status. */
90 /* Temporary storage for the original extension strings. */
91 char *fail_on_status_str;
92 /* Use server error pages for responses >= 400. */
93 int use_server_error_pages;
95 typedef struct rule_extension rule_extension_t;
97 struct uri_worker_record
99 /* Original uri for logging */
102 /* Name of worker mapped */
103 const char *worker_name;
109 unsigned int match_type;
111 /* Definition source type */
112 unsigned int source_type;
114 /* char length of the context */
117 /* extended mapping properties */
118 rule_extension_t extensions;
120 typedef struct uri_worker_record uri_worker_record_t;
122 struct jk_uri_worker_map
126 jk_pool_atom_t buf[BIG_POOL_SIZE];
128 /* Index 0 or 1, which map instance do we use */
129 /* Needed to make map reload more atomically */
132 /* Memory Pool - cleared when doing reload */
133 /* Use this pool to allocate objects, that are deleted */
134 /* when the map gets dynamically reloaded from uriworkermap.properties. */
136 jk_pool_atom_t buf_dyn[2][BIG_POOL_SIZE];
138 /* map URI->WORKER */
139 uri_worker_record_t **maps[2];
142 unsigned int size[2];
145 unsigned int capacity[2];
148 unsigned int nosize[2];
150 /* Dynamic config support */
153 /* should we forward potentially unsafe URLs */
155 /* uriworkermap filename */
157 /* uriworkermap reload check interval */
159 /* Last modified time */
161 /* Last checked time */
164 typedef struct jk_uri_worker_map jk_uri_worker_map_t;
166 const char *uri_worker_map_get_source(uri_worker_record_t *uwr, jk_logger_t *l);
168 char *uri_worker_map_get_match(uri_worker_record_t *uwr, char *buf, jk_logger_t *l);
170 int uri_worker_map_alloc(jk_uri_worker_map_t **uw_map,
171 jk_map_t *init_data, jk_logger_t *l);
173 int uri_worker_map_free(jk_uri_worker_map_t **uw_map, jk_logger_t *l);
175 int uri_worker_map_open(jk_uri_worker_map_t *uw_map,
176 jk_map_t *init_data, jk_logger_t *l);
178 void uri_worker_map_switch(jk_uri_worker_map_t *uw_map, jk_logger_t *l);
180 void uri_worker_map_ext(jk_uri_worker_map_t *uw_map, jk_logger_t *l);
182 int uri_worker_map_add(jk_uri_worker_map_t *uw_map,
183 const char *puri, const char *worker,
184 unsigned int source_type, jk_logger_t *l);
186 const char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
187 const char *uri, const char *vhost,
190 const char *map_uri_to_worker_ext(jk_uri_worker_map_t *uw_map,
191 const char *uri, const char *vhost,
192 rule_extension_t **extensions,
196 rule_extension_t *get_uri_to_worker_ext(jk_uri_worker_map_t *uw_map,
199 int uri_worker_map_load(jk_uri_worker_map_t *uw_map,
202 int uri_worker_map_update(jk_uri_worker_map_t *uw_map,
203 int force, jk_logger_t *l);
207 #endif /* __cplusplus */
208 #endif /* JK_URI_WORKER_MAP_H */