mturk 2004/07/28 09:09:05 Modified: ajp/ajplib/test httpd_wrap.h httpd_wrap.c Log: Added ap_get_remote_host and ap_get_server_name Revision Changes Path 1.5 +63 -0 jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.h Index: httpd_wrap.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- httpd_wrap.h 28 Jul 2004 05:38:04 -0000 1.4 +++ httpd_wrap.h 28 Jul 2004 16:09:04 -0000 1.5 @@ -163,6 +163,30 @@ */ #define DEFAULT_VHOST_ADDR 0xfffffffful +/* options for get_remote_host() */ +/* REMOTE_HOST returns the hostname, or NULL if the hostname + * lookup fails. It will force a DNS lookup according to the + * HostnameLookups setting. + */ +#define REMOTE_HOST (0) + +/* REMOTE_NAME returns the hostname, or the dotted quad if the + * hostname lookup fails. It will force a DNS lookup according + * to the HostnameLookups setting. + */ +#define REMOTE_NAME (1) + +/* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is + * never forced. + */ +#define REMOTE_NOLOOKUP (2) + +/* REMOTE_DOUBLE_REV will always force a DNS lookup, and also force + * a double reverse lookup, regardless of the HostnameLookups + * setting. The result is the (double reverse checked) hostname, + * or NULL if any of the lookups fail. + */ +#define REMOTE_DOUBLE_REV (3) /** @} */ /** @@ -328,6 +352,11 @@ apr_finfo_t finfo; /** A struct containing the components of URI */ apr_uri_t parsed_uri; + /** Options set in config files, etc. */ + void *per_dir_config; + /** Notes on *this* request */ + void *request_config; + }; /** Structure to store things which are per connection */ @@ -547,6 +576,40 @@ server_rec *server, apr_socket_t *csd, long id, void *sbh, apr_bucket_alloc_t *alloc); + +/** + * Get the current server name from the request + * @param r The current request + * @return the server name + * @deffunc const char *ap_get_server_name(request_rec *r) + */ +AP_DECLARE(const char *) ap_get_server_name(request_rec *r); + +/** + * Lookup the remote client's DNS name or IP address + * @param conn The current connection + * @param dir_config The directory config vector from the request + * @param type The type of lookup to perform. One of: + * <pre> + * REMOTE_HOST returns the hostname, or NULL if the hostname + * lookup fails. It will force a DNS lookup according to the + * HostnameLookups setting. + * REMOTE_NAME returns the hostname, or the dotted quad if the + * hostname lookup fails. It will force a DNS lookup according + * to the HostnameLookups setting. + * REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is + * never forced. + * REMOTE_DOUBLE_REV will always force a DNS lookup, and also force + * a double reverse lookup, regardless of the HostnameLookups + * setting. The result is the (double reverse checked) + * hostname, or NULL if any of the lookups fail. + * </pre> + * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address + * string is returned + * @return The remote hostname + * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip) + */ +AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip); /** 1.7 +35 -0 jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.c Index: httpd_wrap.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- httpd_wrap.c 28 Jul 2004 05:38:04 -0000 1.6 +++ httpd_wrap.c 28 Jul 2004 16:09:04 -0000 1.7 @@ -282,3 +282,38 @@ return c; } + +AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, + int type, int *str_is_ip) +{ + int ignored_str_is_ip; + + if (!str_is_ip) { /* caller doesn't want to know */ + str_is_ip = &ignored_str_is_ip; + } + *str_is_ip = 0; + + /* + * Return the desired information; either the remote DNS name, if found, + * or either NULL (if the hostname was requested) or the IP address + * (if any identifier was requested). + */ + if (conn->remote_host != NULL && conn->remote_host[0] != '\0') { + return conn->remote_host; + } + else { + if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) { + return NULL; + } + else { + *str_is_ip = 1; + return conn->remote_ip; + } + } +} + +AP_DECLARE(const char *) ap_get_server_name(request_rec *r) +{ + /* default */ + return r->server->server_hostname; +}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]