diff options
Diffstat (limited to 'toxcore/LAN_discovery.c')
-rw-r--r-- | toxcore/LAN_discovery.c | 36 |
1 files changed, 18 insertions, 18 deletions
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) | |||
79 | if (gateway.family == TOX_AF_INET && subnet_mask.family == TOX_AF_INET) { | 79 | if (gateway.family == TOX_AF_INET && subnet_mask.family == TOX_AF_INET) { |
80 | IP_Port *ip_port = &ip_ports[count]; | 80 | IP_Port *ip_port = &ip_ports[count]; |
81 | ip_port->ip.family = TOX_AF_INET; | 81 | ip_port->ip.family = TOX_AF_INET; |
82 | uint32_t gateway_ip = net_ntohl(gateway.ip4.uint32), subnet_ip = net_ntohl(subnet_mask.ip4.uint32); | 82 | uint32_t gateway_ip = net_ntohl(gateway.ip.v4.uint32), subnet_ip = net_ntohl(subnet_mask.ip.v4.uint32); |
83 | uint32_t broadcast_ip = gateway_ip + ~subnet_ip - 1; | 83 | uint32_t broadcast_ip = gateway_ip + ~subnet_ip - 1; |
84 | ip_port->ip.ip4.uint32 = net_htonl(broadcast_ip); | 84 | ip_port->ip.ip.v4.uint32 = net_htonl(broadcast_ip); |
85 | ip_port->port = port; | 85 | ip_port->port = port; |
86 | count++; | 86 | count++; |
87 | 87 | ||
@@ -177,9 +177,9 @@ static void fetch_broadcast_info(uint16_t port) | |||
177 | 177 | ||
178 | IP_Port *ip_port = &ip_ports[count]; | 178 | IP_Port *ip_port = &ip_ports[count]; |
179 | ip_port->ip.family = TOX_AF_INET; | 179 | ip_port->ip.family = TOX_AF_INET; |
180 | ip_port->ip.ip4.uint32 = sock4->sin_addr.s_addr; | 180 | ip_port->ip.ip.v4.uint32 = sock4->sin_addr.s_addr; |
181 | 181 | ||
182 | if (ip_port->ip.ip4.uint32 == 0) { | 182 | if (ip_port->ip.ip.v4.uint32 == 0) { |
183 | continue; | 183 | continue; |
184 | } | 184 | } |
185 | 185 | ||
@@ -240,17 +240,17 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast) | |||
240 | /* FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ | 240 | /* FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ |
241 | /* FE80::*: MUST be exact, for that we would need to look over all | 241 | /* FE80::*: MUST be exact, for that we would need to look over all |
242 | * interfaces and check in which status they are */ | 242 | * interfaces and check in which status they are */ |
243 | ip.ip6.uint8[ 0] = 0xFF; | 243 | ip.ip.v6.uint8[ 0] = 0xFF; |
244 | ip.ip6.uint8[ 1] = 0x02; | 244 | ip.ip.v6.uint8[ 1] = 0x02; |
245 | ip.ip6.uint8[15] = 0x01; | 245 | ip.ip.v6.uint8[15] = 0x01; |
246 | } else if (family_broadcast == TOX_AF_INET) { | 246 | } else if (family_broadcast == TOX_AF_INET) { |
247 | ip.family = TOX_AF_INET6; | 247 | ip.family = TOX_AF_INET6; |
248 | ip.ip6 = IP6_BROADCAST; | 248 | ip.ip.v6 = IP6_BROADCAST; |
249 | } | 249 | } |
250 | } else if (family_socket == TOX_AF_INET) { | 250 | } else if (family_socket == TOX_AF_INET) { |
251 | if (family_broadcast == TOX_AF_INET) { | 251 | if (family_broadcast == TOX_AF_INET) { |
252 | ip.family = TOX_AF_INET; | 252 | ip.family = TOX_AF_INET; |
253 | ip.ip4 = IP4_BROADCAST; | 253 | ip.ip.v4 = IP4_BROADCAST; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
@@ -261,7 +261,7 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast) | |||
261 | bool ip_is_local(IP ip) | 261 | bool ip_is_local(IP ip) |
262 | { | 262 | { |
263 | if (ip.family == TOX_AF_INET) { | 263 | if (ip.family == TOX_AF_INET) { |
264 | IP4 ip4 = ip.ip4; | 264 | IP4 ip4 = ip.ip.v4; |
265 | 265 | ||
266 | /* Loopback. */ | 266 | /* Loopback. */ |
267 | if (ip4.uint8[0] == 127) { | 267 | if (ip4.uint8[0] == 127) { |
@@ -269,15 +269,15 @@ bool ip_is_local(IP ip) | |||
269 | } | 269 | } |
270 | } else { | 270 | } else { |
271 | /* embedded IPv4-in-IPv6 */ | 271 | /* embedded IPv4-in-IPv6 */ |
272 | if (IPV6_IPV4_IN_V6(ip.ip6)) { | 272 | if (IPV6_IPV4_IN_V6(ip.ip.v6)) { |
273 | IP ip4; | 273 | IP ip4; |
274 | ip4.family = TOX_AF_INET; | 274 | ip4.family = TOX_AF_INET; |
275 | ip4.ip4.uint32 = ip.ip6.uint32[3]; | 275 | ip4.ip.v4.uint32 = ip.ip.v6.uint32[3]; |
276 | return ip_is_local(ip4); | 276 | return ip_is_local(ip4); |
277 | } | 277 | } |
278 | 278 | ||
279 | /* localhost in IPv6 (::1) */ | 279 | /* localhost in IPv6 (::1) */ |
280 | if (ip.ip6.uint64[0] == 0 && ip.ip6.uint32[2] == 0 && ip.ip6.uint32[3] == net_htonl(1)) { | 280 | if (ip.ip.v6.uint64[0] == 0 && ip.ip.v6.uint32[2] == 0 && ip.ip.v6.uint32[3] == net_htonl(1)) { |
281 | return 1; | 281 | return 1; |
282 | } | 282 | } |
283 | } | 283 | } |
@@ -295,7 +295,7 @@ int ip_is_lan(IP ip) | |||
295 | } | 295 | } |
296 | 296 | ||
297 | if (ip.family == TOX_AF_INET) { | 297 | if (ip.family == TOX_AF_INET) { |
298 | IP4 ip4 = ip.ip4; | 298 | IP4 ip4 = ip.ip.v4; |
299 | 299 | ||
300 | /* 10.0.0.0 to 10.255.255.255 range. */ | 300 | /* 10.0.0.0 to 10.255.255.255 range. */ |
301 | if (ip4.uint8[0] == 10) { | 301 | if (ip4.uint8[0] == 10) { |
@@ -327,16 +327,16 @@ int ip_is_lan(IP ip) | |||
327 | 327 | ||
328 | /* autogenerated for each interface: FE80::* (up to FEBF::*) | 328 | /* autogenerated for each interface: FE80::* (up to FEBF::*) |
329 | FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ | 329 | FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ |
330 | if (((ip.ip6.uint8[0] == 0xFF) && (ip.ip6.uint8[1] < 3) && (ip.ip6.uint8[15] == 1)) || | 330 | if (((ip.ip.v6.uint8[0] == 0xFF) && (ip.ip.v6.uint8[1] < 3) && (ip.ip.v6.uint8[15] == 1)) || |
331 | ((ip.ip6.uint8[0] == 0xFE) && ((ip.ip6.uint8[1] & 0xC0) == 0x80))) { | 331 | ((ip.ip.v6.uint8[0] == 0xFE) && ((ip.ip.v6.uint8[1] & 0xC0) == 0x80))) { |
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | /* embedded IPv4-in-IPv6 */ | 335 | /* embedded IPv4-in-IPv6 */ |
336 | if (IPV6_IPV4_IN_V6(ip.ip6)) { | 336 | if (IPV6_IPV4_IN_V6(ip.ip.v6)) { |
337 | IP ip4; | 337 | IP ip4; |
338 | ip4.family = TOX_AF_INET; | 338 | ip4.family = TOX_AF_INET; |
339 | ip4.ip4.uint32 = ip.ip6.uint32[3]; | 339 | ip4.ip.v4.uint32 = ip.ip.v6.uint32[3]; |
340 | return ip_is_lan(ip4); | 340 | return ip_is_lan(ip4); |
341 | } | 341 | } |
342 | } | 342 | } |