diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-20 12:08:55 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-20 12:08:55 -0400 |
commit | a1c40d753ee8faf15aa0dd314bd4249aa3750b2e (patch) | |
tree | fb52c5cffcb897afa709e2d4a9882e89e9c90b5d /core/LAN_discovery.c | |
parent | 9f0efe920170472a4f757f7d8dc84f41e794f945 (diff) |
More refactoring done.
Diffstat (limited to 'core/LAN_discovery.c')
-rw-r--r-- | core/LAN_discovery.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/LAN_discovery.c b/core/LAN_discovery.c index 3045e215..07980d26 100644 --- a/core/LAN_discovery.c +++ b/core/LAN_discovery.c | |||
@@ -123,28 +123,29 @@ static int LAN_ip(IP ip) | |||
123 | 123 | ||
124 | static int handle_LANdiscovery(void * object, IP_Port source, uint8_t *packet, uint32_t length) | 124 | static int handle_LANdiscovery(void * object, IP_Port source, uint8_t *packet, uint32_t length) |
125 | { | 125 | { |
126 | DHT *dht = object; | ||
126 | if (LAN_ip(source.ip) == -1) | 127 | if (LAN_ip(source.ip) == -1) |
127 | return 1; | 128 | return 1; |
128 | 129 | ||
129 | if (length != crypto_box_PUBLICKEYBYTES + 1) | 130 | if (length != crypto_box_PUBLICKEYBYTES + 1) |
130 | return 1; | 131 | return 1; |
131 | 132 | ||
132 | DHT_bootstrap(source, packet + 1); | 133 | DHT_bootstrap(dht, source, packet + 1); |
133 | return 0; | 134 | return 0; |
134 | } | 135 | } |
135 | 136 | ||
136 | 137 | ||
137 | int send_LANdiscovery(uint16_t port) | 138 | int send_LANdiscovery(uint16_t port, Net_Crypto *c) |
138 | { | 139 | { |
139 | uint8_t data[crypto_box_PUBLICKEYBYTES + 1]; | 140 | uint8_t data[crypto_box_PUBLICKEYBYTES + 1]; |
140 | data[0] = 33; | 141 | data[0] = 33; |
141 | memcpy(data + 1, self_public_key, crypto_box_PUBLICKEYBYTES); | 142 | memcpy(data + 1, c->self_public_key, crypto_box_PUBLICKEYBYTES); |
142 | IP_Port ip_port = {broadcast_ip(), port}; | 143 | IP_Port ip_port = {broadcast_ip(), port}; |
143 | return sendpacket(temp_net->sock, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES); | 144 | return sendpacket(c->lossless_udp->net->sock, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES); |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | void LANdiscovery_init(void) | 148 | void LANdiscovery_init(DHT *dht) |
148 | { | 149 | { |
149 | networking_registerhandler(temp_net, 33, &handle_LANdiscovery, NULL); | 150 | networking_registerhandler(dht->c->lossless_udp->net, 33, &handle_LANdiscovery, dht); |
150 | } | 151 | } |