From 595fdf819d8c2176be841164508f9bd9985aa304 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 21 May 2010 10:35:50 +0000 Subject: [PATCH] more FBSD fixes --- src/transport/plugin_transport_tcp.c | 18 +++++++++--------- src/transport/plugin_transport_udp.c | 26 ++++++++++++++++++-------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 546bc2066..099e10a1a 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -856,9 +856,9 @@ tcp_plugin_send (void *cls, #endif a6.sin6_family = AF_INET6; a6.sin6_port = t6->t6_port; - memcpy (a6.sin6_addr.s6_addr, + memcpy (&a6.sin6_addr, &t6->ipv6_addr, - 16); + sizeof (struct in6_addr)); sb = &a6; sbs = sizeof (a6); } @@ -1085,9 +1085,9 @@ tcp_plugin_address_pretty_printer (void *cls, memset (&a6, 0, sizeof (a6)); a6.sin6_family = AF_INET6; a6.sin6_port = t6->t6_port; - memcpy (a6.sin6_addr.s6_addr, + memcpy (&a6.sin6_addr, &t6->ipv6_addr, - 16); + sizeof (struct in6_addr)); port = ntohs (t6->t6_port); sb = &a6; sbs = sizeof (a6); @@ -1254,8 +1254,8 @@ handle_tcp_welcome (void *cls, t6 = GNUNET_malloc (sizeof (struct IPv6TcpAddress)); t6->t6_port = s6->sin6_port; memcpy (&t6->ipv6_addr, - s6->sin6_addr.s6_addr, - 16); + &s6->sin6_addr, + sizeof (struct in6_addr)); session->connect_addr = t6; session->connect_alen = sizeof (struct IPv6TcpAddress); } @@ -1451,14 +1451,14 @@ process_interfaces (void *cls, } else if (af == AF_INET6) { - if (IN6_IS_ADDR_LINKLOCAL (((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr)) + if (IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *) addr)->sin6_addr)) { /* skip link local addresses */ return GNUNET_OK; } memcpy (&t6.ipv6_addr, - ((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr, - 16); + &((struct sockaddr_in6 *) addr)->sin6_addr, + sizeof (struct in6_addr)); t6.t6_port = htons (plugin->adv_port); arg = &t6; args = sizeof (t6); diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 322bdd1d0..4de3f2c44 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -295,9 +295,9 @@ udp_plugin_send (void *cls, #endif a6.sin6_family = AF_INET6; a6.sin6_port = t6->u6_port; - memcpy (a6.sin6_addr.s6_addr, + memcpy (&a6.sin6_addr, &t6->ipv6_addr, - 16); + sizeof (struct in6_addr)); sb = &a6; sbs = sizeof (a6); } @@ -380,9 +380,14 @@ process_interfaces (void *cls, } else if (af == AF_INET6) { + if (IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *) addr)->sin6_addr)) + { + /* skip link local addresses */ + return GNUNET_OK; + } memcpy (&t6.ipv6_addr, - ((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr, - 16); + &((struct sockaddr_in6 *) addr)->sin6_addr, + sizeof (struct in6_addr)); t6.u6_port = htons (plugin->adv_port); arg = &t6; args = sizeof (t6); @@ -541,8 +546,8 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) s6 = (const struct sockaddr_in6*) &addr; t6.u6_port = s6->sin6_port; memcpy (&t6.ipv6_addr, - s6->sin6_addr.s6_addr, - 16); + &s6->sin6_addr, + sizeof (struct in6_addr)); ca = &t6; calen = sizeof (struct IPv6UdpAddress); } @@ -714,6 +719,11 @@ udp_check_address (void *cls, void *addr, size_t addrlen) else { v6 = (struct IPv6UdpAddress *) addr; + if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } v6->u6_port = htons (check_port (plugin, ntohs (v6->u6_port))); } return GNUNET_OK; @@ -782,9 +792,9 @@ udp_plugin_address_pretty_printer (void *cls, a6.sin6_family = AF_INET6; a6.sin6_port = t6->u6_port; port = ntohs (t6->u6_port); - memcpy (a6.sin6_addr.s6_addr, + memcpy (&a6.sin6_addr, &t6->ipv6_addr, - 16); + sizeof (struct in6_addr)); sb = &a6; sbs = sizeof (a6); } -- 2.25.1