From f9d82cbcd81da81a3e78bada99f54ccc7c9ac50b Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 13 Oct 2011 08:06:28 +0000 Subject: --- src/transport/plugin_transport_http_server.c | 32 ++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/transport/plugin_transport_http_server.c') diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 68686169e..0eb88fc01 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -352,6 +352,12 @@ server_lookup_session (struct Plugin *plugin, struct ServerConnection *sc = NULL; const union MHD_ConnectionInfo *conn_info; + struct IPv4HttpAddress a4; + struct IPv6HttpAddress a6; + struct sockaddr_in * s4; + struct sockaddr_in6 * s6; + void * a; + size_t a_len; struct GNUNET_PeerIdentity target; size_t addrlen; int check = GNUNET_NO; @@ -485,10 +491,32 @@ create: "Server: Creating new session for peer `%s' \n", GNUNET_i2s (&target)); #endif + switch (conn_info->client_addr->sa_family) + { + case (AF_INET): + s4 = ((struct sockaddr_in * ) conn_info->client_addr); + a4.u4_port = s4->sin_port; + memcpy (&a4.ipv4_addr, &s4->sin_addr, + sizeof (struct in_addr)); + a = &a4; + a_len = sizeof (struct IPv4HttpAddress); + break; + case (AF_INET6): + s6 = ((struct sockaddr_in6 * ) conn_info->client_addr); + a6.u6_port = s6->sin6_port; + memcpy (&a6.ipv6_addr, &s6->sin6_addr, + sizeof (struct in6_addr)); + a = &a6; + a_len = sizeof (struct IPv6HttpAddress); + break; + default: + GNUNET_break (0); + } + s = create_session (plugin, &target, - conn_info->client_addr, - addrlen, + a, + a_len, NULL, NULL); -- cgit v1.2.3