diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-15 00:48:35 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-16 14:17:05 +0000 |
commit | 0b13936ce8498735e245531c222c035f41fd5e0f (patch) | |
tree | bafaef43863e822bbcb0c05192da0a973b3381a1 /toxcore/LAN_discovery.c | |
parent | b3ec05543acdc0019b545de170720dc32d8f28d3 (diff) |
Use apidsl to generate LAN_discovery.h.
Diffstat (limited to 'toxcore/LAN_discovery.c')
-rw-r--r-- | toxcore/LAN_discovery.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index eeba96bd..b5cf2c52 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -256,7 +256,7 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast) | |||
256 | } | 256 | } |
257 | 257 | ||
258 | /* Is IP a local ip or not. */ | 258 | /* Is IP a local ip or not. */ |
259 | bool Local_ip(IP ip) | 259 | bool ip_is_local(IP ip) |
260 | { | 260 | { |
261 | if (ip.family == TOX_AF_INET) { | 261 | if (ip.family == TOX_AF_INET) { |
262 | IP4 ip4 = ip.ip4; | 262 | IP4 ip4 = ip.ip4; |
@@ -271,7 +271,7 @@ bool Local_ip(IP ip) | |||
271 | IP ip4; | 271 | IP ip4; |
272 | ip4.family = TOX_AF_INET; | 272 | ip4.family = TOX_AF_INET; |
273 | ip4.ip4.uint32 = ip.ip6.uint32[3]; | 273 | ip4.ip4.uint32 = ip.ip6.uint32[3]; |
274 | return Local_ip(ip4); | 274 | return ip_is_local(ip4); |
275 | } | 275 | } |
276 | 276 | ||
277 | /* localhost in IPv6 (::1) */ | 277 | /* localhost in IPv6 (::1) */ |
@@ -286,9 +286,9 @@ bool Local_ip(IP ip) | |||
286 | /* return 0 if ip is a LAN ip. | 286 | /* return 0 if ip is a LAN ip. |
287 | * return -1 if it is not. | 287 | * return -1 if it is not. |
288 | */ | 288 | */ |
289 | int LAN_ip(IP ip) | 289 | int ip_is_lan(IP ip) |
290 | { | 290 | { |
291 | if (Local_ip(ip)) { | 291 | if (ip_is_local(ip)) { |
292 | return 0; | 292 | return 0; |
293 | } | 293 | } |
294 | 294 | ||
@@ -335,7 +335,7 @@ int LAN_ip(IP ip) | |||
335 | IP ip4; | 335 | IP ip4; |
336 | ip4.family = TOX_AF_INET; | 336 | ip4.family = TOX_AF_INET; |
337 | ip4.ip4.uint32 = ip.ip6.uint32[3]; | 337 | ip4.ip4.uint32 = ip.ip6.uint32[3]; |
338 | return LAN_ip(ip4); | 338 | return ip_is_lan(ip4); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
@@ -346,7 +346,7 @@ static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *pack | |||
346 | { | 346 | { |
347 | DHT *dht = (DHT *)object; | 347 | DHT *dht = (DHT *)object; |
348 | 348 | ||
349 | if (LAN_ip(source.ip) == -1) { | 349 | if (ip_is_lan(source.ip) == -1) { |
350 | return 1; | 350 | return 1; |
351 | } | 351 | } |
352 | 352 | ||
@@ -363,7 +363,7 @@ static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *pack | |||
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | int send_LANdiscovery(uint16_t port, DHT *dht) | 366 | int lan_discovery_send(uint16_t port, DHT *dht) |
367 | { | 367 | { |
368 | uint8_t data[CRYPTO_PUBLIC_KEY_SIZE + 1]; | 368 | uint8_t data[CRYPTO_PUBLIC_KEY_SIZE + 1]; |
369 | data[0] = NET_PACKET_LAN_DISCOVERY; | 369 | data[0] = NET_PACKET_LAN_DISCOVERY; |
@@ -399,12 +399,12 @@ int send_LANdiscovery(uint16_t port, DHT *dht) | |||
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void LANdiscovery_init(DHT *dht) | 402 | void lan_discovery_init(DHT *dht) |
403 | { | 403 | { |
404 | networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, &handle_LANdiscovery, dht); | 404 | networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, &handle_LANdiscovery, dht); |
405 | } | 405 | } |
406 | 406 | ||
407 | void LANdiscovery_kill(DHT *dht) | 407 | void lan_discovery_kill(DHT *dht) |
408 | { | 408 | { |
409 | networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, NULL, NULL); | 409 | networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, NULL, NULL); |
410 | } | 410 | } |