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/network.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'toxcore/network.h') diff --git a/toxcore/network.h b/toxcore/network.h index 5bc04632..6cdf300d 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -175,25 +175,34 @@ void ipport_copy(IP_Port *target, IP_Port *source); * * input * address: a hostname (or something parseable to an IP address) - * ip: ip.family MUST be initialized, either set to a specific IP version + * to: to.family MUST be initialized, either set to a specific IP version * (AF_INET/AF_INET6) or to the unspecified AF_UNSPEC (= 0), if both * IP versions are acceptable + * extra can be NULL and is only set in special circumstances, see returns * - * returns in ip a valid IPAny (v4/v6), + * returns in *to a valid IPAny (v4/v6), * prefers v6 if ip.family was AF_UNSPEC and both available + * returns in *extra an IPv4 address, if family was AF_UNSPEC and *to is AF_INET6 * returns 0 on failure */ - -int addr_resolve(const char *address, IP *to); +int addr_resolve(const char *address, IP *to, IP *extra); /* * addr_resolve_or_parse_ip * resolves string into an IP address * - * to->family MUST be set (AF_UNSPEC, AF_INET, AF_INET6) - * returns 1 on success, 0 on failure + * address: a hostname (or something parseable to an IP address) + * to: to.family MUST be initialized, either set to a specific IP version + * (AF_INET/AF_INET6) or to the unspecified AF_UNSPEC (= 0), if both + * IP versions are acceptable + * extra can be NULL and is only set in special circumstances, see returns + * + * returns in *tro a matching address (IPv6 or IPv4) + * returns in *extra, if not NULL, an IPv4 address, if to->family was AF_UNSPEC + * returns 1 on success + * returns 0 on failure */ -int addr_resolve_or_parse_ip(const char *address, IP *to); +int addr_resolve_or_parse_ip(const char *address, IP *to, IP *extra); /* Function to receive data, ip and port of sender is put into ip_port. * Packet data is put into data. -- cgit v1.2.3