summaryrefslogtreecommitdiff
path: root/core/LAN_discovery.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/LAN_discovery.c')
-rw-r--r--core/LAN_discovery.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/core/LAN_discovery.c b/core/LAN_discovery.c
index 26b3930c..67dc656b 100644
--- a/core/LAN_discovery.c
+++ b/core/LAN_discovery.c
@@ -111,7 +111,7 @@ static int LAN_ip(IP ip)
111 return -1; 111 return -1;
112} 112}
113 113
114static int handle_LANdiscovery(uint8_t *packet, uint32_t length, IP_Port source) 114static int handle_LANdiscovery(IP_Port source, uint8_t *packet, uint32_t length)
115{ 115{
116 if (LAN_ip(source.ip) == -1) 116 if (LAN_ip(source.ip) == -1)
117 return 1; 117 return 1;
@@ -125,16 +125,14 @@ static int handle_LANdiscovery(uint8_t *packet, uint32_t length, IP_Port source)
125int send_LANdiscovery(uint16_t port) 125int send_LANdiscovery(uint16_t port)
126{ 126{
127 uint8_t data[crypto_box_PUBLICKEYBYTES + 1]; 127 uint8_t data[crypto_box_PUBLICKEYBYTES + 1];
128 data[0] = 32; 128 data[0] = 33;
129 memcpy(data + 1, self_public_key, crypto_box_PUBLICKEYBYTES); 129 memcpy(data + 1, self_public_key, crypto_box_PUBLICKEYBYTES);
130 IP_Port ip_port = {broadcast_ip(), port}; 130 IP_Port ip_port = {broadcast_ip(), port};
131 return sendpacket(ip_port, data, 1 + crypto_box_PUBLICKEYBYTES); 131 return sendpacket(ip_port, data, 1 + crypto_box_PUBLICKEYBYTES);
132} 132}
133 133
134 134
135int LANdiscovery_handlepacket(uint8_t *packet, uint32_t length, IP_Port source) 135void LANdiscovery_init(void)
136{ 136{
137 if (packet[0] == 32) 137 networking_registerhandler(33, &handle_LANdiscovery);
138 return handle_LANdiscovery(packet, length, source);
139 return 1;
140} 138}