/* Copyright 2006 - Chris Josephes * * Licensed under the General Public License, version 2.0 * You may not use this file except in compliance with this license. * Full text of the license is at http://www.gnu.org/copyleft/gpl.html * * */ /* * Written by Chris Josephes * * This module adds the following logging directives to Apache * * %...S: remote port of client connection * */ #include "apr_strings.h" #include "apr_lib.h" #include "apr_hash.h" #include "apr_optional.h" #include "ap_config.h" #include "mod_log_config.h" #include "httpd.h" #include "http_core.h" #include "http_config.h" #include "http_connection.h" #include "http_protocol.h" module AP_MODULE_DECLARE_DATA log_remote_port_module; static const char remote_port_filer_name[] = "LOG_REMOTE_PORT"; /* * Format handler */ static const char *log_rp(request_rec *r, char *a) { return apr_itoa(r->pool, r->connection->remote_addr->port); } /* * Pre-configuration handler */ static int log_rp_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) { static APR_OPTIONAL_FN_TYPE(ap_register_log_handler) *log_pfn_register; log_pfn_register = APR_RETRIEVE_OPTIONAL_FN(ap_register_log_handler); if (log_pfn_register) { log_pfn_register(p, "S", log_rp, 0); } return OK; } /* * Register Hooks */ static void register_hooks(apr_pool_t *p) { static const char *pre[] = { "mod_log_config.c", NULL }; ap_hook_pre_config(log_rp_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); } module AP_MODULE_DECLARE_DATA log_remote_port_module= { STANDARD20_MODULE_STUFF, NULL, /* create per-dir config */ NULL, /* merge per-dir config */ NULL, /* server config */ NULL, /* merge server config */ NULL, /* command apr_table_t */ register_hooks /* register_hooks */ };