From 62973b2dea9b0c53f59570c0060a6436871373b9 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 15 Jun 2010 13:44:45 +0000 Subject: [PATCH] --- src/transport/plugin_transport_http.c | 28 +++++++++++++++------- src/transport/test_plugin_transport_http.c | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index a1fe426b3..e88a2d581 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -39,7 +39,7 @@ #include -#define DEBUG_CURL GNUNET_CURL +#define DEBUG_CURL GNUNET_NO #define DEBUG_HTTP GNUNET_NO /** @@ -382,7 +382,6 @@ static struct Session * create_session (struct sockaddr_in *addr_in, struct sock { memcpy(ses->addr_outbound, addr_out, sizeof (struct sockaddr_in)); } - memcpy(&ses->sender, peer, sizeof (struct GNUNET_PeerIdentity)); GNUNET_CRYPTO_hash_to_enc(&ses->sender.hashPubKey,&(ses->hash)); ses->is_active = GNUNET_NO; @@ -449,7 +448,7 @@ accessHandlerCallback (void *cls, const union MHD_ConnectionInfo * conn_info; struct sockaddr_in *addrin; struct sockaddr_in6 *addrin6; - char * address = NULL; + char address[INET6_ADDRSTRLEN+14]; struct GNUNET_PeerIdentity pi_in; int res = GNUNET_NO; struct GNUNET_MessageHeader *gn_msg; @@ -475,14 +474,12 @@ accessHandlerCallback (void *cls, /* Incoming IPv4 connection */ if ( AF_INET == conn_info->client_addr->sin_family) { - address = GNUNET_malloc (INET_ADDRSTRLEN); addrin = conn_info->client_addr; inet_ntop(addrin->sin_family, &(addrin->sin_addr),address,INET_ADDRSTRLEN); } /* Incoming IPv6 connection */ if ( AF_INET6 == conn_info->client_addr->sin_family) { - address = GNUNET_malloc (INET6_ADDRSTRLEN); addrin6 = (struct sockaddr_in6 *) conn_info->client_addr; inet_ntop(addrin6->sin6_family, &(addrin6->sin6_addr),address,INET6_ADDRSTRLEN); } @@ -534,7 +531,7 @@ accessHandlerCallback (void *cls, cs_temp->next = cs; plugin->session_count++; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New Session `%s' inserted, count %u \n", address, plugin->session_count); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New Session `%s' inserted, count %u \n", GNUNET_i2s(&cs->sender), plugin->session_count); } /* Set closure */ @@ -544,7 +541,7 @@ accessHandlerCallback (void *cls, /* Updating session */ memcpy(cs->addr_inbound,conn_info->client_addr, sizeof(struct sockaddr_in)); } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s' (`[%s]:%u')\n",method, GNUNET_i2s(&cs->sender),address,cs->addr_inbound->sin_port); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s' (`[%s]:%u')\n",method, GNUNET_i2s(&cs->sender),address,ntohs(cs->addr_inbound->sin_port)); } else { @@ -620,7 +617,22 @@ accessHandlerCallback (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Recieved GNUnet message type %u size %u and payload %u \n",ntohs (gn_msg->type), ntohs (gn_msg->size), ntohs (gn_msg->size)-sizeof(struct GNUNET_MessageHeader)); /* forwarding message to transport */ - //plugin->env->receive(plugin->env, &(cs->sender), gn_msg, 1, cs , cs->ip, strlen(cs->ip) ); + char * tmp = NULL; + if ( AF_INET == cs->addr_inbound->sin_family) + { + tmp = GNUNET_malloc (INET_ADDRSTRLEN + 14); + inet_ntop(AF_INET, &(cs->addr_inbound)->sin_addr,address,INET_ADDRSTRLEN); + GNUNET_asprintf(&tmp,"%s:%u",address,ntohs(cs->addr_inbound->sin_port)); + } + /* Incoming IPv6 connection */ + if ( AF_INET6 == cs->addr_inbound->sin_family) + { + tmp = GNUNET_malloc (INET6_ADDRSTRLEN + 14); + inet_ntop(AF_INET6, &((struct sockaddr_in6 *) cs->addr_inbound)->sin6_addr,address,INET6_ADDRSTRLEN); + GNUNET_asprintf(&tmp,"[%s]:%u",address,ntohs(cs->addr_inbound->sin_port)); + } + plugin->env->receive(plugin->env, &(cs->sender), gn_msg, 1, cs , tmp, strlen(tmp)); + GNUNET_free(tmp); send_error_to_client = GNUNET_NO; } } diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 373e5f9c8..d1c1da120 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -481,7 +481,7 @@ receive (void *cls, const char *sender_address, uint16_t sender_address_len) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u\n", GNUNET_i2s(peer),ntohs(message->type),ntohs(message->size)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' (`%s') with type %u and length %u\n", GNUNET_i2s(peer), sender_address, ntohs(message->type), ntohs(message->size)); return GNUNET_TIME_UNIT_ZERO; } -- 2.25.1