diff options
author | Coren[m] <Break@Ocean> | 2013-09-11 20:50:15 +0200 |
---|---|---|
committer | Coren[m] <Break@Ocean> | 2013-09-11 20:50:15 +0200 |
commit | 513e37815db8319dd015bf03b588380a4e3c61d3 (patch) | |
tree | 809738c8ff2370936638565ff096d387d7222f85 /toxcore/LAN_discovery.c | |
parent | d0f5ad34ae2cb88e921cf6f6d829d611b5ea2152 (diff) |
tox.h, DHT.h:
- tox_bootstrap_ex(), DHT_bootstrap_ex() renamed to tox_bootstrap_from_address(), DHT_bootstrap_from_address()
- (handle_)sendnodes_ex() renamed to (handle_)sendnodes_ipv6()
- only sending sendnodes_ipv6() if we're actually IPv6 enabled
- changed comments to conform better
nTox.c, Messenger_text.c, DHT_test.c, DHT_bootstrap.c:
- fallout from *_ex() to *_from_address()
DHT_bootstrap.c:
- corrected a potentially wrong info message
util.c:
- fixed logfile name: now (funcptr) => now() (number)
network.c:
- addead comment about the necessity of bind() to succeed
auto_test/messenger_test.c:
- defaulting ipv6enabled to TOX_ENABLE_IPV6_DEFAULT
LAN_discovery.c:
- slight cleanup and comments for clarity
Diffstat (limited to 'toxcore/LAN_discovery.c')
-rw-r--r-- | toxcore/LAN_discovery.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index 933c2402..b429ea6e 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -112,7 +112,9 @@ static IP broadcast_ip(sa_family_t family_socket, sa_family_t family_broadcast) | |||
112 | } | 112 | } |
113 | } | 113 | } |
114 | #else | 114 | #else |
115 | ip.uint32 = INADDR_BROADCAST; | 115 | if (family_socket == AF_INET) |
116 | if (family_broadcast == AF_INET) | ||
117 | ip.uint32 = INADDR_BROADCAST; | ||
116 | #endif | 118 | #endif |
117 | 119 | ||
118 | return ip; | 120 | return ip; |
@@ -193,23 +195,22 @@ int send_LANdiscovery(uint16_t port, Net_Crypto *c) | |||
193 | ip_port.port = port; | 195 | ip_port.port = port; |
194 | 196 | ||
195 | #ifdef TOX_ENABLE_IPV6 | 197 | #ifdef TOX_ENABLE_IPV6 |
198 | /* IPv6 multicast */ | ||
196 | if (c->lossless_udp->net->family == AF_INET6) { | 199 | if (c->lossless_udp->net->family == AF_INET6) { |
197 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET6); | 200 | ip_port.ip = broadcast_ip(AF_INET6, AF_INET6); |
198 | if (ip_isset(&ip_port.ip)) | 201 | if (ip_isset(&ip_port.ip)) |
199 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES) > 0) | 202 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES) > 0) |
200 | res = 1; | 203 | res = 1; |
201 | } | 204 | } |
202 | 205 | ||
206 | /* IPv4 broadcast (has to be IPv4-in-IPv6 mapping if socket is AF_INET6 */ | ||
203 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET); | 207 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET); |
204 | if (ip_isset(&ip_port.ip)) | ||
205 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES)) | ||
206 | res = 1; | ||
207 | #else | 208 | #else |
208 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET); | 209 | ip_port.ip = broadcast_ip(AF_INET, AF_INET); |
210 | #endif | ||
209 | if (ip_isset(&ip_port.ip)) | 211 | if (ip_isset(&ip_port.ip)) |
210 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES)) | 212 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES)) |
211 | res = 1; | 213 | res = 1; |
212 | #endif | ||
213 | 214 | ||
214 | return res; | 215 | return res; |
215 | } | 216 | } |