ajp.h revision ab51ff5abc1f007ff150975ccd09072bae1be0b4
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file ajp.h
* @brief Apache Jserv Protocol
*
* @defgroup AJP_defines AJP definitions
* @ingroup MOD_PROXY
* @{
*/
#ifndef AJP_H
#define AJP_H
#include "apr_version.h"
#include "apr.h"
#include "apr_hooks.h"
#include "apr_lib.h"
#include "apr_strings.h"
#include "apr_buckets.h"
#include "apr_md5.h"
#include "apr_network_io.h"
#include "apr_poll.h"
#include "apr_pools.h"
#include "apr_strings.h"
#include "apr_uri.h"
#include "apr_date.h"
#include "apr_fnmatch.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#endif
#endif
#define AJP13_DEF_HOST "127.0.0.1"
#ifdef NETWARE
#else
#define AJP13_DEF_PORT 8009
#endif
/* The following environment variables match mod_ssl! */
#define AJP13_HTTPS_INDICATOR "HTTPS"
#define AJP13_SSL_CLIENT_CERT_INDICATOR "SSL_CLIENT_CERT"
#define AJP13_SSL_CIPHER_INDICATOR "SSL_CIPHER"
#define AJP13_SSL_SESSION_INDICATOR "SSL_SESSION_ID"
#define AJP13_SSL_KEY_SIZE_INDICATOR "SSL_CIPHER_USEKEYSIZE"
#ifdef AJP_USE_HTTPD_WRAP
#include "httpd_wrap.h"
#else
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_main.h"
#include "http_log.h"
#endif
#include "mod_proxy.h"
#include "util_ebcdic.h"
/** AJP Specific error codes
*/
/** Buffer overflow exception */
/** Destination Buffer is to small */
/** Invalid input parameters */
/** Bad message signature */
/** Incoming message too bg */
/** Missing message header */
/** Bad message header */
/** Bad message */
/** Cant log via AJP14 */
/** Bad request method */
/** A structure that represents ajp message */
/** A structure that represents ajp message */
struct ajp_msg
{
/** The buffer holding a AJP message */
/** The length of AJP message header (defaults to AJP_HEADER_LEN) */
/** The length of AJP message */
/** The current read position */
/** Flag indicating the origing of the message */
int server_side;
/** The size of the buffer */
};
/**
* Signature for the messages sent from Apache to tomcat
*/
#define AJP13_WS_HEADER 0x1234
#define AJP_HEADER_LEN 4
#define AJP_HEADER_SZ_LEN 2
#define AJP_HEADER_SZ 6
#define AJP_MSG_BUFFER_SZ 8192
#define AJP_MAX_BUFFER_SZ 65536
#define AJP_PING_PONG_SZ 128
/** Send a request from web server to container*/
#define CMD_AJP13_FORWARD_REQUEST (unsigned char)2
/** Write a body chunk from the servlet container to the web server */
#define CMD_AJP13_SEND_BODY_CHUNK (unsigned char)3
/** Send response headers from the servlet container to the web server. */
#define CMD_AJP13_SEND_HEADERS (unsigned char)4
/** Marks the end of response. */
#define CMD_AJP13_END_RESPONSE (unsigned char)5
/** Get further data from the web server if it hasn't all been transferred yet. */
#define CMD_AJP13_GET_BODY_CHUNK (unsigned char)6
/** The web server asks the container to shut itself down. */
#define CMD_AJP13_SHUTDOWN (unsigned char)7
/** Webserver ask container to take control (logon phase) */
#define CMD_AJP13_PING (unsigned char)8
/** Container response to cping request */
#define CMD_AJP13_CPONG (unsigned char)9
/** Webserver check if container is alive, since container should respond by cpong */
#define CMD_AJP13_CPING (unsigned char)10
/** @} */
/**
* @defgroup AJP_api AJP API functions
* @ingroup MOD_PROXY
* @{
*/
/**
* Check a new AJP Message by looking at signature and return its size
*
* @param msg AJP Message to check
* @param len Pointer to returned len
* @return APR_SUCCESS or error
*/
/**
* Reset an AJP Message
*
* @param msg AJP Message to reset
* @return APR_SUCCESS or error
*/
/**
* Reuse an AJP Message
*
* @param msg AJP Message to reuse
* @return APR_SUCCESS or error
*/
/**
* Mark the end of an AJP Message
*
* @param msg AJP Message to end
* @return APR_SUCCESS or error
*/
/**
* Add an unsigned 32bits value to AJP Message
*
* @param msg AJP Message to get value from
* @param value value to add to AJP Message
* @return APR_SUCCESS or error
*/
/**
* Add an unsigned 16bits value to AJP Message
*
* @param msg AJP Message to get value from
* @param value value to add to AJP Message
* @return APR_SUCCESS or error
*/
/**
* Add an unsigned 8bits value to AJP Message
*
* @param msg AJP Message to get value from
* @param value value to add to AJP Message
* @return APR_SUCCESS or error
*/
/**
* Add a String in AJP message, and transform the String in ASCII
* if convert is set and we're on an EBCDIC machine
*
* @param msg AJP Message to get value from
* @param value Pointer to String
* @param convert When set told to convert String to ASCII
* @return APR_SUCCESS or error
*/
int convert);
/**
* Add a String in AJP message, and transform
* the String in ASCII if we're on an EBCDIC machine
*/
/**
* Add a String in AJP message.
*/
#define ajp_msg_append_string_ascii(m, v) ajp_msg_append_string_ex(m, v, 0)
/**
* Add a Byte array to AJP Message
*
* @param msg AJP Message to get value from
* @param value Pointer to Byte array
* @param valuelen Byte array len
* @return APR_SUCCESS or error
*/
/**
* Get a 32bits unsigned value from AJP Message
*
* @param msg AJP Message to get value from
* @param rvalue Pointer where value will be returned
* @return APR_SUCCESS or error
*/
/**
* Get a 16bits unsigned value from AJP Message
*
* @param msg AJP Message to get value from
* @param rvalue Pointer where value will be returned
* @return APR_SUCCESS or error
*/
/**
* Peek a 16bits unsigned value from AJP Message, position in message
* is not updated
*
* @param msg AJP Message to get value from
* @param rvalue Pointer where value will be returned
* @return APR_SUCCESS or error
*/
/**
* Get a 8bits unsigned value from AJP Message
*
* @param msg AJP Message to get value from
* @param rvalue Pointer where value will be returned
* @return APR_SUCCESS or error
*/
/**
* Peek a 8bits unsigned value from AJP Message, position in message
* is not updated
*
* @param msg AJP Message to get value from
* @param rvalue Pointer where value will be returned
* @return APR_SUCCESS or error
*/
/**
* Get a String value from AJP Message
*
* @param msg AJP Message to get value from
* @param rvalue Pointer where value will be returned
* @return APR_SUCCESS or error
*/
/**
* Get a Byte array from AJP Message
*
* @param msg AJP Message to get value from
* @param rvalue Pointer where value will be returned
* @param rvalue_len Pointer where Byte array len will be returned
* @return APR_SUCCESS or error
*/
/**
* Create an AJP Message from pool
*
* @param pool memory pool to allocate AJP message from
* @param size size of the buffer to create
* @param rmsg Pointer to newly created AJP message
* @return APR_SUCCESS or error
*/
/**
* Recopy an AJP Message to another
*
* @param smsg source AJP message
* @param dmsg destination AJP message
* @return APR_SUCCESS or error
*/
/**
* Serialize in an AJP Message a PING command
*
* +-----------------------+
* | PING CMD (1 byte) |
* +-----------------------+
*
* @param msg AJP message to put serialized message
* @return APR_SUCCESS or error
*/
/**
* Serialize in an AJP Message a CPING command
*
* +-----------------------+
* | CPING CMD (1 byte) |
* +-----------------------+
*
* @param msg AJP message to put serialized message
* @return APR_SUCCESS or error
*/
/**
* Dump up to the first 1024 bytes on an AJP Message
*
* @param pool pool to allocate from
* @param msg AJP Message to dump
* @param err error string to display
* @param count the number of bytes to dump
* @param buf buffer pointer for dump message
* @return APR_SUCCESS or error
*/
/**
* Log an AJP message
*
* @param request The current request
* @param msg AJP Message to dump
* @param err error string to display
* @return APR_SUCCESS or error
*/
/**
* Send an AJP message to backend
*
* @param sock backend socket
* @param msg AJP message to put serialized message
* @return APR_SUCCESS or error
*/
/**
* Receive an AJP message from backend
*
* @param sock backend socket
* @param msg AJP message to put serialized message
* @return APR_SUCCESS or error
*/
/**
* Build the ajp header message and send it
* @param sock backend socket
* @param r current request
* @param buffsize max size of the AJP packet.
* @param uri requested uri
* @return APR_SUCCESS or error
*/
/**
* Read the ajp message and return the type of the message.
* @param sock backend socket
* @param r current request
* @param buffsize size of the buffer.
* @param msg returned AJP message
* @return APR_SUCCESS or error
*/
request_rec *r,
/**
* Allocate a msg to send data
* @param pool pool to allocate from
* @param ptr data buffer
* @param len the length of allocated data buffer
* @param msg returned AJP message
* @return APR_SUCCESS or error
*/
/**
* Send the data message
* @param sock backend socket
* @param msg AJP message to send
* @param len AJP message length
* @return APR_SUCCESS or error
*/
/**
* Parse the message type
* @param r current request
* @param msg AJP message
* @return AJP message type.
*/
/**
* Parse the header message from container
* @param r current request
* @param conf proxy config
* @param msg AJP message
* @return APR_SUCCESS or error
*/
/**
* Parse the message body and return data address and length
* @param r current request
* @param msg AJP message
* @param len returned AJP message length
* @param ptr returned data
* @return APR_SUCCESS or error
*/
/**
* Check the reuse flag in CMD_AJP13_END_RESPONSE
* @param r current request
* @param msg AJP message
* @param reuse returned reuse flag
* @return APR_SUCCESS or error
*/
apr_byte_t *reuse);
/**
* @param sock backend socket
* @param r current request
* @param timeout time window for receiving cpong reply
* @return APR_SUCCESS or error
*/
request_rec *r,
/**
* Convert numeric message type into string
* @param type AJP message type
* @return AJP message type as a string
*/
const char *ajp_type_str(int type);
/** @} */
#endif /* AJP_H */