aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-28 13:05:31 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-28 13:05:31 +0000
commit046b26c62c7ebb678be1ffe5c2ea6450d7ae0722 (patch)
treea2374e4175cbf2562053a5d563257bb7e52a4911
parent3e7b2390a6a63f38635108d45d9c293e5a2b25d4 (diff)
downloadgnunet-046b26c62c7ebb678be1ffe5c2ea6450d7ae0722.tar.gz
gnunet-046b26c62c7ebb678be1ffe5c2ea6450d7ae0722.zip
check address function
-rw-r--r--src/transport/plugin_transport_udp.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 7067dc196..1f079801c 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -1406,7 +1406,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
1406 default: 1406 default:
1407#if DEBUG_UDP 1407#if DEBUG_UDP
1408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1409 _("Sending message type %d to transport\n!"), ntohs(currhdr->type)); 1409 _("Sending message type %d to transport!\n"), ntohs(currhdr->type));
1410#endif 1410#endif
1411 plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE, 1411 plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE,
1412 NULL, sender_addr, fromlen); 1412 NULL, sender_addr, fromlen);
@@ -1711,6 +1711,12 @@ udp_check_address (void *cls,
1711 size_t addrlen) 1711 size_t addrlen)
1712{ 1712{
1713 struct Plugin *plugin = cls; 1713 struct Plugin *plugin = cls;
1714 char buf[INET6_ADDRSTRLEN];
1715 const void *sb;
1716 struct in_addr a4;
1717 struct in6_addr a6;
1718 int af;
1719 uint16_t port;
1714 struct IPv4UdpAddress *v4; 1720 struct IPv4UdpAddress *v4;
1715 struct IPv6UdpAddress *v6; 1721 struct IPv6UdpAddress *v6;
1716 1722
@@ -1720,6 +1726,7 @@ udp_check_address (void *cls,
1720 GNUNET_break_op (0); 1726 GNUNET_break_op (0);
1721 return GNUNET_SYSERR; 1727 return GNUNET_SYSERR;
1722 } 1728 }
1729
1723 if (addrlen == sizeof (struct IPv4UdpAddress)) 1730 if (addrlen == sizeof (struct IPv4UdpAddress))
1724 { 1731 {
1725 v4 = (struct IPv4UdpAddress *) addr; 1732 v4 = (struct IPv4UdpAddress *) addr;
@@ -1729,6 +1736,11 @@ udp_check_address (void *cls,
1729 if (GNUNET_OK != 1736 if (GNUNET_OK !=
1730 check_local_addr (plugin, &v4->ipv4_addr, sizeof (uint32_t))) 1737 check_local_addr (plugin, &v4->ipv4_addr, sizeof (uint32_t)))
1731 return GNUNET_SYSERR; 1738 return GNUNET_SYSERR;
1739
1740 af = AF_INET;
1741 port = ntohs (v4->u_port);
1742 memcpy (&a4, &v4->ipv4_addr, sizeof (a4));
1743 sb = &a4;
1732 } 1744 }
1733 else 1745 else
1734 { 1746 {
@@ -1744,12 +1756,21 @@ udp_check_address (void *cls,
1744 if (GNUNET_OK != 1756 if (GNUNET_OK !=
1745 check_local_addr (plugin, &v6->ipv6_addr, sizeof (struct in6_addr))) 1757 check_local_addr (plugin, &v6->ipv6_addr, sizeof (struct in6_addr)))
1746 return GNUNET_SYSERR; 1758 return GNUNET_SYSERR;
1759
1760 af = AF_INET6;
1761 port = ntohs (v6->u6_port);
1762 memcpy (&a6, &v6->ipv6_addr, sizeof (a6));
1763 sb = &a6;
1747 } 1764 }
1765
1766 inet_ntop (af, sb, buf, INET6_ADDRSTRLEN);
1767
1748#if DEBUG_UDP 1768#if DEBUG_UDP
1749 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1769 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1750 "udp", 1770 "udp",
1751 "Informing transport service about my address `%s'.\n", 1771 "Informing transport service about my address `%s:%u'\n",
1752 GNUNET_a2s (addr, addrlen)); 1772 buf,
1773 port);
1753#endif 1774#endif
1754 return GNUNET_OK; 1775 return GNUNET_OK;
1755} 1776}