From 5f04609b906a435465dc09ff31173aafb0353e9b Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 14 Jun 2010 09:31:57 +0000 Subject: [PATCH] --- src/transport/plugin_transport_http.c | 19 ++++++++---------- src/transport/test_plugin_transport_http.c | 23 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index fc49cf287..c20e30c91 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -395,14 +395,12 @@ static struct Session * create_session (struct sockaddr_in *addr_in, struct sock { ses->ip = GNUNET_malloc (INET_ADDRSTRLEN); addrin = addr_in; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Port %u \n", addrin->sin_port); inet_ntop(addrin->sin_family,&(addrin->sin_addr),ses->ip,INET_ADDRSTRLEN); } if ( AF_INET6 == addr_in->sin_family) { ses->ip = GNUNET_malloc (INET6_ADDRSTRLEN); addrin6 = (struct sockaddr_in6 *) addr_in; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Port %u \n", addrin6->sin6_port); inet_ntop(addrin6->sin6_family, &(addrin6->sin6_addr) ,ses->ip,INET6_ADDRSTRLEN); } } @@ -1194,13 +1192,12 @@ http_plugin_send (void *cls, unsigned int port; if (addrlen == (sizeof (struct IPv4HttpAddress))) { - inet_ntop(AF_INET, (struct in_addr *) addr,address,INET_ADDRSTRLEN); - port = ((struct IPv4HttpAddress *) addr)->u_port; - //port = ntohs(((struct in_addr *) addr)->); + inet_ntop(AF_INET,&((struct IPv4HttpAddress *) addr)->ipv4_addr,address,INET_ADDRSTRLEN); + port = ntohs(((struct IPv4HttpAddress *) addr)->u_port); } else if (addrlen == (sizeof (struct IPv6HttpAddress))) { - inet_ntop(AF_INET6, (struct in6_addr *) addr,address,INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, &((struct IPv6HttpAddress *) addr)->ipv6_addr,address,INET6_ADDRSTRLEN); port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port); } else @@ -1208,7 +1205,6 @@ http_plugin_send (void *cls, GNUNET_break (0); return -1; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"ADDR `%s':%u \n",address,port); ses->transmit_cont = cont; ses->transmit_cont_cls = cont_cls; @@ -1346,6 +1342,7 @@ http_plugin_address_suggested (void *cls, { struct IPv4HttpAddress *v4; struct IPv6HttpAddress *v6; + unsigned int port; if ((addrlen != sizeof (struct IPv4HttpAddress)) && (addrlen != sizeof (struct IPv6HttpAddress))) @@ -1357,8 +1354,8 @@ http_plugin_address_suggested (void *cls, { v4 = (struct IPv4HttpAddress *) addr; - v4->u_port = ntohs (v4->u_port); - if (v4->u_port != plugin->port_inbound) + port = ntohs (v4->u_port); + if (port != plugin->port_inbound) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -1372,8 +1369,8 @@ http_plugin_address_suggested (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - v6->u6_port = ntohs (v6->u6_port); - if (v6->u6_port != plugin->port_inbound) + port = ntohs (v6->u6_port); + if (port != plugin->port_inbound) { GNUNET_break_op (0); return GNUNET_SYSERR; diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index fd598a685..ed501be42 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -902,6 +902,9 @@ static void run_connection_tests( void ) struct Plugin_Address * tmp_addr; struct GNUNET_MessageHeader msg; char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)); + char address[INET6_ADDRSTRLEN]; + unsigned int port; + msg.size=htons(sizeof(struct GNUNET_MessageHeader)); msg.type=htons(13); memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); @@ -912,7 +915,25 @@ static void run_connection_tests( void ) while (tmp_addr != NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u\n", count); + + + if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) + { + inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN); + port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address, port); + } + else if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) + { + inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN); + port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address,port); + } + else + { + GNUNET_break (0); + return; + } api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, NULL); tmp_addr = tmp_addr->next; count ++; -- 2.25.1