From 591d6c70c635406830486deb561343e4dc06af2a Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Thu, 12 Sep 2013 18:39:21 +0200 Subject: network.*: - addr_resolv(_or_parse_ip)(): added an optional parameter to return both an IPv6 and an IPv4 address if requested address family was AF_UNSPEC - logging of unhandled packets DHT.c: - bootstrap_from_address(): use the additional return from addr_resolv_or_parse_ip() to bootstrap in both network types at once Lossless_UDP_testclient.c: - main(): adapt to signature change of addr_resolve() Messenger.c. LAN_discovery.h: - lost a htons(), readded - moved LAN_DISCOVERY_INTERVAL #define into LAN_discovery.h LAN_discovery.c: - added IPv4-in-IPv6 local address test --- toxcore/DHT.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'toxcore/DHT.c') diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 3de7b6ae..a5f0c1ab 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c @@ -982,11 +982,28 @@ void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key) int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) { - IP_Port ip_port; - ip_init(&ip_port.ip, ipv6enabled); - if (addr_resolve_or_parse_ip(address, &ip_port.ip)) { - ip_port.port = port; - DHT_bootstrap(dht, ip_port, public_key); + IP_Port ip_port_v64, ip_port_v4; + IP *ip_extra = NULL; +#ifdef TOX_ENABLE_IPV6 + ip_init(&ip_port_v64.ip, ipv6enabled); + if (ipv6enabled) { + ip_port_v64.ip.family = AF_UNSPEC; + ip_reset(&ip_port_v4.ip); + ip_extra = &ip_port_v4.ip; + } +#else + ip_init(&ip_port_v64.ip, 0); +#endif + + if (addr_resolve_or_parse_ip(address, &ip_port_v64.ip, ip_extra)) { + ip_port_v64.port = port; + DHT_bootstrap(dht, ip_port_v64, public_key); +#ifdef TOX_ENABLE_IPV6 + if ((ip_extra != NULL) && ip_isset(ip_extra)) { + ip_port_v4.port = port; + DHT_bootstrap(dht, ip_port_v4, public_key); + } +#endif return 1; } else -- cgit v1.2.3