From 55214aa041f2cc0305d290ff7dfd9e3e2f5e0bde Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Mon, 9 Sep 2013 14:53:27 +0200 Subject: network.*: - IP4: changed in_addr_t to struct in_addr for compatibility reasons - IP6: added - IPAny: added - addr_resolve_or_parse_ip(): converts a string into an IPAny --- toxcore/network.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'toxcore/network.h') diff --git a/toxcore/network.h b/toxcore/network.h index 9991c4a4..2a0b5560 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -86,9 +86,19 @@ typedef union { uint8_t uint8[4]; uint16_t uint16[2]; uint32_t uint32; - in_addr_t in_addr; + struct in_addr in_addr; } IP4; +typedef struct in6_addr IP6; + +typedef struct { + sa_family_t family; + union { + IP4 ip4; + IP6 ip6; + }; +} IPAny; + typedef union { struct { IP4 ip; @@ -109,6 +119,15 @@ typedef struct { #endif } ADDR; +/* + * 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 + */ +int addr_resolve_or_parse_ip(const char *address, IPAny *to); + /* Function to receive data, ip and port of sender is put into ip_port. * Packet data is put into data. * Packet length is put into length. @@ -161,5 +180,4 @@ Networking_Core *new_networking(IP4 ip, uint16_t port); /* Function to cleanup networking stuff (doesn't do much right now). */ void kill_networking(Networking_Core *net); - #endif -- cgit v1.2.3