diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-15 01:23:08 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-16 20:06:07 +0000 |
commit | 643eea60bb9dcf4ecb33d64666b1bc77cbfd7438 (patch) | |
tree | 2f98b0c7869fddac03f834be508a182da06f07b4 /toxcore/LAN_discovery.c | |
parent | 22db2b9fe581a35300b66126604d12e83c2eafb1 (diff) |
Make DHT a module-private type.
Diffstat (limited to 'toxcore/LAN_discovery.c')
-rw-r--r-- | toxcore/LAN_discovery.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index b5cf2c52..c0724ad9 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -356,7 +356,6 @@ static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *pack | |||
356 | 356 | ||
357 | char ip_str[IP_NTOA_LEN] = { 0 }; | 357 | char ip_str[IP_NTOA_LEN] = { 0 }; |
358 | ip_ntoa(&source.ip, ip_str, sizeof(ip_str)); | 358 | ip_ntoa(&source.ip, ip_str, sizeof(ip_str)); |
359 | LOGGER_DEBUG(dht->log, "Found node in LAN: %s", ip_str); | ||
360 | 359 | ||
361 | DHT_bootstrap(dht, source, packet + 1); | 360 | DHT_bootstrap(dht, source, packet + 1); |
362 | return 0; | 361 | return 0; |
@@ -367,30 +366,30 @@ int lan_discovery_send(uint16_t port, DHT *dht) | |||
367 | { | 366 | { |
368 | uint8_t data[CRYPTO_PUBLIC_KEY_SIZE + 1]; | 367 | uint8_t data[CRYPTO_PUBLIC_KEY_SIZE + 1]; |
369 | data[0] = NET_PACKET_LAN_DISCOVERY; | 368 | data[0] = NET_PACKET_LAN_DISCOVERY; |
370 | id_copy(data + 1, dht->self_public_key); | 369 | id_copy(data + 1, dht_get_self_public_key(dht)); |
371 | 370 | ||
372 | send_broadcasts(dht->net, port, data, 1 + CRYPTO_PUBLIC_KEY_SIZE); | 371 | send_broadcasts(dht_get_net(dht), port, data, 1 + CRYPTO_PUBLIC_KEY_SIZE); |
373 | 372 | ||
374 | int res = -1; | 373 | int res = -1; |
375 | IP_Port ip_port; | 374 | IP_Port ip_port; |
376 | ip_port.port = port; | 375 | ip_port.port = port; |
377 | 376 | ||
378 | /* IPv6 multicast */ | 377 | /* IPv6 multicast */ |
379 | if (net_family(dht->net) == TOX_AF_INET6) { | 378 | if (net_family(dht_get_net(dht)) == TOX_AF_INET6) { |
380 | ip_port.ip = broadcast_ip(TOX_AF_INET6, TOX_AF_INET6); | 379 | ip_port.ip = broadcast_ip(TOX_AF_INET6, TOX_AF_INET6); |
381 | 380 | ||
382 | if (ip_isset(&ip_port.ip)) { | 381 | if (ip_isset(&ip_port.ip)) { |
383 | if (sendpacket(dht->net, ip_port, data, 1 + CRYPTO_PUBLIC_KEY_SIZE) > 0) { | 382 | if (sendpacket(dht_get_net(dht), ip_port, data, 1 + CRYPTO_PUBLIC_KEY_SIZE) > 0) { |
384 | res = 1; | 383 | res = 1; |
385 | } | 384 | } |
386 | } | 385 | } |
387 | } | 386 | } |
388 | 387 | ||
389 | /* IPv4 broadcast (has to be IPv4-in-IPv6 mapping if socket is TOX_AF_INET6 */ | 388 | /* IPv4 broadcast (has to be IPv4-in-IPv6 mapping if socket is TOX_AF_INET6 */ |
390 | ip_port.ip = broadcast_ip(net_family(dht->net), TOX_AF_INET); | 389 | ip_port.ip = broadcast_ip(net_family(dht_get_net(dht)), TOX_AF_INET); |
391 | 390 | ||
392 | if (ip_isset(&ip_port.ip)) { | 391 | if (ip_isset(&ip_port.ip)) { |
393 | if (sendpacket(dht->net, ip_port, data, 1 + CRYPTO_PUBLIC_KEY_SIZE)) { | 392 | if (sendpacket(dht_get_net(dht), ip_port, data, 1 + CRYPTO_PUBLIC_KEY_SIZE)) { |
394 | res = 1; | 393 | res = 1; |
395 | } | 394 | } |
396 | } | 395 | } |
@@ -401,10 +400,10 @@ int lan_discovery_send(uint16_t port, DHT *dht) | |||
401 | 400 | ||
402 | void lan_discovery_init(DHT *dht) | 401 | void lan_discovery_init(DHT *dht) |
403 | { | 402 | { |
404 | networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, &handle_LANdiscovery, dht); | 403 | networking_registerhandler(dht_get_net(dht), NET_PACKET_LAN_DISCOVERY, &handle_LANdiscovery, dht); |
405 | } | 404 | } |
406 | 405 | ||
407 | void lan_discovery_kill(DHT *dht) | 406 | void lan_discovery_kill(DHT *dht) |
408 | { | 407 | { |
409 | networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, NULL, NULL); | 408 | networking_registerhandler(dht_get_net(dht), NET_PACKET_LAN_DISCOVERY, NULL, NULL); |
410 | } | 409 | } |