1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
|
/* ========================================================================= *
* *
* The Apache Software License, Version 1.1 *
* *
* Copyright (c) 1999-2001 The Apache Software Foundation. *
* All rights reserved. *
* *
* ========================================================================= *
* *
* Redistribution and use in source and binary forms, with or without modi- *
* fication, are permitted provided that the following conditions are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. The end-user documentation included with the redistribution, if any, *
* must include the following acknowlegement: *
* *
* "This product includes software developed by the Apache Software *
* Foundation <http://www.apache.org/>." *
* *
* Alternately, this acknowlegement may appear in the software itself, if *
* and wherever such third-party acknowlegements normally appear. *
* *
* 4. The names "The Jakarta Project", "Jk", and "Apache Software *
* Foundation" must not be used to endorse or promote products derived *
* from this software without prior written permission. For written *
* permission, please contact <apache@apache.org>. *
* *
* 5. Products derived from this software may not be called "Apache" nor may *
* "Apache" appear in their names without prior written permission of the *
* Apache Software Foundation. *
* *
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY *
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY *
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= *
* *
* This software consists of voluntary contributions made by many indivi- *
* duals on behalf of the Apache Software Foundation. For more information *
* on the Apache Software Foundation, please see <http://www.apache.org/>. *
* *
* ========================================================================= */
/***************************************************************************
* Description: Next generation bi-directional protocol handler. *
* Author: Henri Gomez <hgomez@slib.fr> *
* Version: $Revision: 1.9 $ *
***************************************************************************/
#ifndef JK_AJP14_H
#define JK_AJP14_H
#include "jk_ajp_common.h"
#include "jk_context.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define AJP14_PROTO 14
#define AJP14_WS_HEADER 0x1235
#define AJP14_SW_HEADER 0x1235 /* AJP14 use now the same header in both directions */
#define AJP14_DEF_HOST ("localhost")
#define AJP14_DEF_PORT (8011)
#define AJP14_READ_BUF_SIZE (8*1024)
#define AJP14_DEF_RETRY_ATTEMPTS (1)
#define AJP14_DEF_CACHE_SZ (1)
#define AJP14_MAX_SEND_BODY_SZ (DEF_BUFFER_SZ - 6)
#define AJP14_HEADER_LEN (4)
#define AJP14_HEADER_SZ_LEN (2)
/*
* Initial Login Phase (web server -> servlet engine)
*/
#define AJP14_LOGINIT_CMD (unsigned char)0x10
/*
* Second Login Phase (servlet engine -> web server), md5 seed is received
*/
#define AJP14_LOGSEED_CMD (unsigned char)0x11
/*
* Third Login Phase (web server -> servlet engine), md5 of seed + secret is sent
*/
#define AJP14_LOGCOMP_CMD (unsigned char)0x12
/*
* Login Accepted (servlet engine -> web server)
*/
#define AJP14_LOGOK_CMD (unsigned char)0x13
/*
* Login Rejected (servlet engine -> web server), will be logged
*/
#define AJP14_LOGNOK_CMD (unsigned char)0x14
/*
* Context Query (web server -> servlet engine), which URI are handled by servlet engine ?
*/
#define AJP14_CONTEXT_QRY_CMD (unsigned char)0x15
/*
* Context Info (servlet engine -> web server), URI handled response
*/
#define AJP14_CONTEXT_INFO_CMD (unsigned char)0x16
/*
* Context Update (servlet engine -> web server), status of context changed
*/
#define AJP14_CONTEXT_UPDATE_CMD (unsigned char)0x17
/*
* Servlet Engine Status (web server -> servlet engine), what's the status of the servlet engine ?
*/
#define AJP14_STATUS_CMD (unsigned char)0x18
/*
* Secure Shutdown command (web server -> servlet engine), please servlet stop yourself.
*/
#define AJP14_SHUTDOWN_CMD (unsigned char)0x19
/*
* Secure Shutdown command Accepted (servlet engine -> web server)
*/
#define AJP14_SHUTOK_CMD (unsigned char)0x1A
/*
* Secure Shutdown Rejected (servlet engine -> web server)
*/
#define AJP14_SHUTNOK_CMD (unsigned char)0x1B
/*
* Context Status (web server -> servlet engine), what's the status of the context ?
*/
#define AJP14_CONTEXT_STATE_CMD (unsigned char)0x1C
/*
* Context Status Reply (servlet engine -> web server), status of context
*/
#define AJP14_CONTEXT_STATE_REP_CMD (unsigned char)0x1D
/*
* Unknown Packet Reply (web server <-> servlet engine), when a packet couldn't be decoded
*/
#define AJP14_UNKNOW_PACKET_CMD (unsigned char)0x1E
/*
* Negociation flags
*/
/*
* web-server want context info after login
*/
#define AJP14_CONTEXT_INFO_NEG 0x80000000
/*
* web-server want context updates
*/
#define AJP14_CONTEXT_UPDATE_NEG 0x40000000
/*
* web-server want compressed stream
*/
#define AJP14_GZIP_STREAM_NEG 0x20000000
/*
* web-server want crypted DES56 stream with secret key
*/
#define AJP14_DES56_STREAM_NEG 0x10000000
/*
* Extended info on server SSL vars
*/
#define AJP14_SSL_VSERVER_NEG 0x08000000
/*
*Extended info on client SSL vars
*/
#define AJP14_SSL_VCLIENT_NEG 0x04000000
/*
* Extended info on crypto SSL vars
*/
#define AJP14_SSL_VCRYPTO_NEG 0x02000000
/*
* Extended info on misc SSL vars
*/
#define AJP14_SSL_VMISC_NEG 0x01000000
/*
* mask of protocol supported
*/
#define AJP14_PROTO_SUPPORT_AJPXX_NEG 0x00FF0000
/*
* communication could use AJP14
*/
#define AJP14_PROTO_SUPPORT_AJP14_NEG 0x00010000
/*
* communication could use AJP15
*/
#define AJP14_PROTO_SUPPORT_AJP15_NEG 0x00020000
/*
* communication could use AJP16
*/
#define AJP14_PROTO_SUPPORT_AJP16_NEG 0x00040000
/*
* Some failure codes
*/
#define AJP14_BAD_KEY_ERR 0xFFFFFFFF
#define AJP14_ENGINE_DOWN_ERR 0xFFFFFFFE
#define AJP14_RETRY_LATER_ERR 0xFFFFFFFD
#define AJP14_SHUT_AUTHOR_FAILED_ERR 0xFFFFFFFC
/*
* Some status codes
*/
#define AJP14_CONTEXT_DOWN 0x01
#define AJP14_CONTEXT_UP 0x02
#define AJP14_CONTEXT_OK 0x03
/*
* Misc defines
*/
#define AJP14_ENTROPY_SEED_LEN 32 /* we're using MD5 => 32 chars */
#define AJP14_COMPUTED_KEY_LEN 32 /* we're using MD5 also */
/*
* The login structure
*/
typedef struct jk_login_service jk_login_service_t;
struct jk_login_service {
/*
* Pointer to web-server name
*/
char * web_server_name;
/*
* Pointer to servlet-engine name
*/
char * servlet_engine_name;
/*
* Pointer to secret key
*/
char * secret_key;
/*
* Received entropy seed
*/
char entropy[AJP14_ENTROPY_SEED_LEN + 1];
/*
* Computed key
*/
char computed_key[AJP14_COMPUTED_KEY_LEN + 1];
/*
* What we want to negociate
*/
unsigned long negociation;
/*
* What we received from servlet engine
*/
unsigned long negociated;
};
/*
* functions defined here
*/
void ajp14_compute_md5(jk_login_service_t *s,
jk_logger_t *l);
int ajp14_marshal_login_init_into_msgb(jk_msg_buf_t *msg,
jk_login_service_t *s,
jk_logger_t *l);
int ajp14_unmarshal_login_seed(jk_msg_buf_t *msg,
jk_login_service_t *s,
jk_logger_t *l);
int ajp14_marshal_login_comp_into_msgb(jk_msg_buf_t *msg,
jk_login_service_t *s,
jk_logger_t *l);
int ajp14_unmarshal_log_ok(jk_msg_buf_t *msg,
jk_login_service_t *s,
jk_logger_t *l);
int ajp14_unmarshal_log_nok(jk_msg_buf_t *msg,
jk_logger_t *l);
int ajp14_marshal_shutdown_into_msgb(jk_msg_buf_t *msg,
jk_login_service_t *s,
jk_logger_t *l);
int ajp14_unmarshal_shutdown_nok(jk_msg_buf_t *msg,
jk_logger_t *l);
int ajp14_marshal_unknown_packet_into_msgb(jk_msg_buf_t *msg,
jk_msg_buf_t *unk,
jk_logger_t *l);
int ajp14_marshal_context_query_into_msgb(jk_msg_buf_t *msg,
char *virtual,
jk_logger_t *l);
int ajp14_unmarshal_context_info(jk_msg_buf_t *msg,
jk_context_t *context,
jk_logger_t *l);
int ajp14_marshal_context_state_into_msgb(jk_msg_buf_t *msg,
jk_context_t *context,
char *cname,
jk_logger_t *l);
int ajp14_unmarshal_context_state_reply(jk_msg_buf_t *msg,
jk_context_t *context,
jk_logger_t *l);
int ajp14_unmarshal_context_update_cmd(jk_msg_buf_t *msg,
jk_context_t *context,
jk_logger_t *l);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* JK_AJP14_H */
|