From 35f13ef51dbf99c3d45d04f572e9e88795df7ae6 Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 14 Feb 2018 20:51:55 +0000 Subject: Get rid of the only GNU extension we used. --- toxcore/LAN_discovery.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'toxcore/LAN_discovery.c') diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index 2f43ea11..f5883060 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c @@ -79,9 +79,9 @@ static void fetch_broadcast_info(uint16_t port) if (gateway.family == TOX_AF_INET && subnet_mask.family == TOX_AF_INET) { IP_Port *ip_port = &ip_ports[count]; ip_port->ip.family = TOX_AF_INET; - uint32_t gateway_ip = net_ntohl(gateway.ip4.uint32), subnet_ip = net_ntohl(subnet_mask.ip4.uint32); + uint32_t gateway_ip = net_ntohl(gateway.ip.v4.uint32), subnet_ip = net_ntohl(subnet_mask.ip.v4.uint32); uint32_t broadcast_ip = gateway_ip + ~subnet_ip - 1; - ip_port->ip.ip4.uint32 = net_htonl(broadcast_ip); + ip_port->ip.ip.v4.uint32 = net_htonl(broadcast_ip); ip_port->port = port; count++; @@ -177,9 +177,9 @@ static void fetch_broadcast_info(uint16_t port) IP_Port *ip_port = &ip_ports[count]; ip_port->ip.family = TOX_AF_INET; - ip_port->ip.ip4.uint32 = sock4->sin_addr.s_addr; + ip_port->ip.ip.v4.uint32 = sock4->sin_addr.s_addr; - if (ip_port->ip.ip4.uint32 == 0) { + if (ip_port->ip.ip.v4.uint32 == 0) { continue; } @@ -240,17 +240,17 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast) /* FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ /* FE80::*: MUST be exact, for that we would need to look over all * interfaces and check in which status they are */ - ip.ip6.uint8[ 0] = 0xFF; - ip.ip6.uint8[ 1] = 0x02; - ip.ip6.uint8[15] = 0x01; + ip.ip.v6.uint8[ 0] = 0xFF; + ip.ip.v6.uint8[ 1] = 0x02; + ip.ip.v6.uint8[15] = 0x01; } else if (family_broadcast == TOX_AF_INET) { ip.family = TOX_AF_INET6; - ip.ip6 = IP6_BROADCAST; + ip.ip.v6 = IP6_BROADCAST; } } else if (family_socket == TOX_AF_INET) { if (family_broadcast == TOX_AF_INET) { ip.family = TOX_AF_INET; - ip.ip4 = IP4_BROADCAST; + ip.ip.v4 = IP4_BROADCAST; } } @@ -261,7 +261,7 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast) bool ip_is_local(IP ip) { if (ip.family == TOX_AF_INET) { - IP4 ip4 = ip.ip4; + IP4 ip4 = ip.ip.v4; /* Loopback. */ if (ip4.uint8[0] == 127) { @@ -269,15 +269,15 @@ bool ip_is_local(IP ip) } } else { /* embedded IPv4-in-IPv6 */ - if (IPV6_IPV4_IN_V6(ip.ip6)) { + if (IPV6_IPV4_IN_V6(ip.ip.v6)) { IP ip4; ip4.family = TOX_AF_INET; - ip4.ip4.uint32 = ip.ip6.uint32[3]; + ip4.ip.v4.uint32 = ip.ip.v6.uint32[3]; return ip_is_local(ip4); } /* localhost in IPv6 (::1) */ - if (ip.ip6.uint64[0] == 0 && ip.ip6.uint32[2] == 0 && ip.ip6.uint32[3] == net_htonl(1)) { + if (ip.ip.v6.uint64[0] == 0 && ip.ip.v6.uint32[2] == 0 && ip.ip.v6.uint32[3] == net_htonl(1)) { return 1; } } @@ -295,7 +295,7 @@ int ip_is_lan(IP ip) } if (ip.family == TOX_AF_INET) { - IP4 ip4 = ip.ip4; + IP4 ip4 = ip.ip.v4; /* 10.0.0.0 to 10.255.255.255 range. */ if (ip4.uint8[0] == 10) { @@ -327,16 +327,16 @@ int ip_is_lan(IP ip) /* autogenerated for each interface: FE80::* (up to FEBF::*) FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ - if (((ip.ip6.uint8[0] == 0xFF) && (ip.ip6.uint8[1] < 3) && (ip.ip6.uint8[15] == 1)) || - ((ip.ip6.uint8[0] == 0xFE) && ((ip.ip6.uint8[1] & 0xC0) == 0x80))) { + if (((ip.ip.v6.uint8[0] == 0xFF) && (ip.ip.v6.uint8[1] < 3) && (ip.ip.v6.uint8[15] == 1)) || + ((ip.ip.v6.uint8[0] == 0xFE) && ((ip.ip.v6.uint8[1] & 0xC0) == 0x80))) { return 0; } /* embedded IPv4-in-IPv6 */ - if (IPV6_IPV4_IN_V6(ip.ip6)) { + if (IPV6_IPV4_IN_V6(ip.ip.v6)) { IP ip4; ip4.family = TOX_AF_INET; - ip4.ip4.uint32 = ip.ip6.uint32[3]; + ip4.ip.v4.uint32 = ip.ip.v6.uint32[3]; return ip_is_lan(ip4); } } -- cgit v1.2.3