You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2007/03/29 20:07:38 UTC
svn commit: r523783 - in /webservices/axis2/trunk/c: include/
modules/core/engine/ modules/core/transport/http/common/
modules/core/transport/http/receiver/ util/include/ util/src/
Author: dinesh
Date: Thu Mar 29 11:07:36 2007
New Revision: 523783
URL: http://svn.apache.org/viewvc?view=rev&rev=523783
Log:
fixed:axis2c-418, client ip address append to msg_ctx as a property named AXIS2_SVC_PEER_IP_ADDR
Modified:
webservices/axis2/trunk/c/include/axis2_msg_ctx.h
webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h
webservices/axis2/trunk/c/modules/core/engine/engine.c
webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c
webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
webservices/axis2/trunk/c/util/include/axis2_network_handler.h
webservices/axis2/trunk/c/util/src/network_handler.c
webservices/axis2/trunk/c/util/src/stream.c
Modified: webservices/axis2/trunk/c/include/axis2_msg_ctx.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_msg_ctx.h?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_msg_ctx.h (original)
+++ webservices/axis2/trunk/c/include/axis2_msg_ctx.h Thu Mar 29 11:07:36 2007
@@ -85,6 +85,7 @@
/** Transport URL */
#define AXIS2_TRANSPORT_URL "TransportURL"
+#define AXIS2_SVR_PEER_IP_ADDR "peer_ip_addr"
/* Message flows */
/** In flow */
/*#define AXIS2_IN_FLOW 1*/
Modified: webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h (original)
+++ webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h Thu Mar 29 11:07:36 2007
@@ -167,6 +167,15 @@
/**
* @param svr_conn pointer to server connection struct
* @param env pointer to environment struct
+ */
+ axis2_char_t *(AXIS2_CALL *
+ get_peer_ip)(
+ const axis2_simple_http_svr_conn_t *svr_conn,
+ const axis2_env_t *env);
+
+ /**
+ * @param svr_conn pointer to server connection struct
+ * @param env pointer to environment struct
* @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
*/
void (AXIS2_CALL *
@@ -249,6 +258,11 @@
@sa axis2_simple_http_svr_conn_ops#get_svr_ip */
#define AXIS2_SIMPLE_HTTP_SVR_CONN_GET_SVR_IP(svr_conn, env) \
((svr_conn)->ops->get_svr_ip(svr_conn, env))
+
+/** Get peer ip.
+ @sa axis2_simple_http_svr_conn_ops#get_peer_ip */
+#define AXIS2_SIMPLE_HTTP_SVR_CONN_GET_PEER_IP(svr_conn, env) \
+ ((svr_conn)->ops->get_peer_ip(svr_conn, env))
/** Frees the sime http server connection.
@sa axis2_simple_http_svr_conn_ops#free */
Modified: webservices/axis2/trunk/c/modules/core/engine/engine.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/engine/engine.c?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/modules/core/engine/engine.c (original)
+++ webservices/axis2/trunk/c/modules/core/engine/engine.c Thu Mar 29 11:07:36 2007
@@ -29,7 +29,6 @@
#include <axis2_addr.h>
#include <axis2_uuid_gen.h>
-
struct axis2_engine
{
/** configuration context */
Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c Thu Mar 29 11:07:36 2007
@@ -118,12 +118,14 @@
axis2_char_t *encoding_header_value = NULL;
axis2_op_ctx_t *op_ctx = NULL;
axis2_char_t *svr_ip = NULL;
+ axis2_char_t *peer_ip = NULL;
axis2_url_t *request_url = NULL;
axis2_http_out_transport_info_t *http_out_transport_info = NULL;
axis2_hash_t *headers = NULL;
axis2_char_t *url_external_form = NULL;
axis2_char_t *svc_grp_uuid = NULL;
axis2_char_t *path = NULL;
+ axis2_property_t *peer_property = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, svr_conn, AXIS2_FAILURE);
@@ -187,7 +189,7 @@
(http_worker->conf_ctx, env), env,
AXIS2_TRANSPORT_ENUM_HTTP);
msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
- axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
+ axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
if (0 == axis2_strcasecmp(http_version, AXIS2_HTTP_HEADER_PROTOCOL_11))
@@ -197,6 +199,14 @@
}
svr_ip = AXIS2_SIMPLE_HTTP_SVR_CONN_GET_SVR_IP(svr_conn, env);
+ peer_ip = AXIS2_SIMPLE_HTTP_SVR_CONN_GET_PEER_IP(svr_conn, env);
+
+ if (peer_ip)
+ {
+ peer_property = axis2_property_create (env);
+ axis2_property_set_value (peer_property, env, axis2_strdup (env, peer_ip));
+ axis2_msg_ctx_set_property (msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR, peer_property);
+ }
path = AXIS2_HTTP_REQUEST_LINE_GET_URI(
AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
@@ -369,10 +379,6 @@
status = AXIS2_SIMPLE_HTTP_SVR_CONN_WRITE_RESPONSE(svr_conn, env, response);
AXIS2_FREE(env->allocator, url_external_form);
url_external_form = NULL;
- /* this is freed in the following block of logic, taking it from
- operation context that holds it
- axis2_msg_ctx_free(msg_ctx, env); */
- /* Free message contextx */
op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
if (op_ctx)
{
@@ -386,14 +392,14 @@
if (out_msg_ctx)
{
- axis2_msg_ctx_free(out_msg_ctx, env);
+ axis2_msg_ctx_free(out_msg_ctx, env);
out_msg_ctx = NULL;
msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT] = NULL;
}
if (in_msg_ctx)
{
- axis2_msg_ctx_free(in_msg_ctx, env);
+ axis2_msg_ctx_free(in_msg_ctx, env);
in_msg_ctx = NULL;
msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = NULL;
}
@@ -535,7 +541,7 @@
AXIS2_PARAM_CHECK(env->error, request, AXIS2_FAILURE);
header_list = AXIS2_HTTP_SIMPLE_REQUEST_GET_HEADERS(request, env);
- if (! header_list)
+ if (!header_list)
{
return NULL;
}
@@ -549,14 +555,14 @@
{
axis2_http_header_t *tmp_hdr = NULL;
tmp_hdr = axis2_array_list_get(header_list, env, i);
- if (! tmp_hdr)
+ if (!tmp_hdr)
{
continue;
}
- if (! header_map)
+ if (!header_map)
{
header_map = axis2_hash_make(env);
- if (! header_map)
+ if (!header_map)
{
return NULL;
}
Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c Thu Mar 29 11:07:36 2007
@@ -107,6 +107,11 @@
const axis2_simple_http_svr_conn_t *svr_conn,
const axis2_env_t *env);
+axis2_char_t *AXIS2_CALL
+axis2_simple_http_svr_conn_get_peer_ip(
+ const axis2_simple_http_svr_conn_t *svr_conn,
+ const axis2_env_t *env);
+
void AXIS2_CALL
axis2_simple_http_svr_conn_free(
axis2_simple_http_svr_conn_t *svr_conn,
@@ -174,6 +179,8 @@
axis2_simple_http_svr_conn_set_snd_timeout;
svr_conn_impl->svr_conn.ops->get_svr_ip =
axis2_simple_http_svr_conn_get_svr_ip;
+ svr_conn_impl->svr_conn.ops->get_peer_ip =
+ axis2_simple_http_svr_conn_get_peer_ip;
svr_conn_impl->svr_conn.ops->free = axis2_simple_http_svr_conn_free;
return &(svr_conn_impl->svr_conn);
}
@@ -623,5 +630,15 @@
{
AXIS2_ENV_CHECK(env, NULL);
return axis2_network_handler_get_svr_ip(env,
+ AXIS2_INTF_TO_IMPL(svr_conn)->socket);
+}
+
+axis2_char_t *AXIS2_CALL
+axis2_simple_http_svr_conn_get_peer_ip(
+ const axis2_simple_http_svr_conn_t *svr_conn,
+ const axis2_env_t *env)
+{
+ AXIS2_ENV_CHECK(env, NULL);
+ return axis2_network_handler_get_peer_ip(env,
AXIS2_INTF_TO_IMPL(svr_conn)->socket);
}
Modified: webservices/axis2/trunk/c/util/include/axis2_network_handler.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_network_handler.h?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_network_handler.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_network_handler.h Thu Mar 29 11:07:36 2007
@@ -95,6 +95,11 @@
AXIS2_EXTERN axis2_char_t * AXIS2_CALL
axis2_network_handler_get_svr_ip(const axis2_env_t *env,
axis2_socket_t socket);
+
+ AXIS2_EXTERN axis2_char_t * AXIS2_CALL
+ axis2_network_handler_get_peer_ip(const axis2_env_t *env,
+ axis2_socket_t socket);
+
/** @} */
#ifdef __cplusplus
Modified: webservices/axis2/trunk/c/util/src/network_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/network_handler.c?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/util/src/network_handler.c (original)
+++ webservices/axis2/trunk/c/util/src/network_handler.c Thu Mar 29 11:07:36 2007
@@ -189,7 +189,6 @@
int nodelay = 1;
axis2_socket_len_t cli_len = 0;
axis2_socket_t cli_socket = AXIS2_INVALID_SOCKET;
-
AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
cli_len = sizeof(cli_addr);
@@ -198,7 +197,7 @@
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[Axis2][network_handler] Socket accept \
failed");
- setsockopt(cli_socket, IPPROTO_TCP, TCP_NODELAY, &nodelay,
+ setsockopt(svr_socket, IPPROTO_TCP, TCP_NODELAY, &nodelay,
sizeof(nodelay));
ll.l_onoff = 1;
ll.l_linger = 5;
@@ -254,6 +253,23 @@
char *ret = NULL;
memset(&addr, 0, sizeof(addr));
if (getsockname(socket, (struct sockaddr *)&addr, &len) < 0)
+ {
+ return NULL;
+ }
+ ret = inet_ntoa(addr.sin_addr);
+ return ret;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_network_handler_get_peer_ip(const axis2_env_t *env,
+ axis2_socket_t socket)
+{
+ struct sockaddr_in addr;
+
+ axis2_socket_len_t len = sizeof(addr);
+ char *ret = NULL;
+ memset(&addr, 0, sizeof(addr));
+ if (getpeername(socket, (struct sockaddr *)&addr, &len) < 0)
{
return NULL;
}
Modified: webservices/axis2/trunk/c/util/src/stream.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/stream.c?view=diff&rev=523783&r1=523782&r2=523783
==============================================================================
--- webservices/axis2/trunk/c/util/src/stream.c (original)
+++ webservices/axis2/trunk/c/util/src/stream.c Thu Mar 29 11:07:36 2007
@@ -577,7 +577,6 @@
}
len = recv(stream->socket, buffer, count, 0);
-
#ifdef AXIS2_TCPMON
if (len > 1)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org