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.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/LAN_discovery.c b/core/LAN_discovery.c
index 3cfcb067..1ac13c33 100644
--- a/core/LAN_discovery.c
+++ b/core/LAN_discovery.c
@@ -37,24 +37,24 @@ IP broadcast_ip()
37 return -1 if it is not */ 37 return -1 if it is not */
38int LAN_ip(IP ip) 38int LAN_ip(IP ip)
39{ 39{
40 if(ip.c[0] == 127)/* Loopback */ 40 if (ip.c[0] == 127)/* Loopback */
41 return 0; 41 return 0;
42 if(ip.c[0] == 10)/* 10.0.0.0 to 10.255.255.255 range */ 42 if (ip.c[0] == 10)/* 10.0.0.0 to 10.255.255.255 range */
43 return 0; 43 return 0;
44 if(ip.c[0] == 172 && ip.c[1] >= 16 && ip.c[1] <= 31)/* 172.16.0.0 to 172.31.255.255 range */ 44 if (ip.c[0] == 172 && ip.c[1] >= 16 && ip.c[1] <= 31)/* 172.16.0.0 to 172.31.255.255 range */
45 return 0; 45 return 0;
46 if(ip.c[0] == 192 && ip.c[1] == 168) /* 192.168.0.0 to 192.168.255.255 range */ 46 if (ip.c[0] == 192 && ip.c[1] == 168) /* 192.168.0.0 to 192.168.255.255 range */
47 return 0; 47 return 0;
48 if(ip.c[0] == 169 && ip.c[1] == 254 && ip.c[2] != 0 && ip.c[2] != 255)/* 169.254.1.0 to 169.254.254.255 range */ 48 if (ip.c[0] == 169 && ip.c[1] == 254 && ip.c[2] != 0 && ip.c[2] != 255)/* 169.254.1.0 to 169.254.254.255 range */
49 return 0; 49 return 0;
50 return -1; 50 return -1;
51} 51}
52 52
53int handle_LANdiscovery(uint8_t * packet, uint32_t length, IP_Port source) 53int handle_LANdiscovery(uint8_t *packet, uint32_t length, IP_Port source)
54{ 54{
55 if(LAN_ip(source.ip) == -1) 55 if (LAN_ip(source.ip) == -1)
56 return 1; 56 return 1;
57 if(length != crypto_box_PUBLICKEYBYTES + 1) 57 if (length != crypto_box_PUBLICKEYBYTES + 1)
58 return 1; 58 return 1;
59 DHT_bootstrap(source, packet + 1); 59 DHT_bootstrap(source, packet + 1);
60 return 0; 60 return 0;
@@ -71,9 +71,9 @@ int send_LANdiscovery(uint16_t port)
71} 71}
72 72
73 73
74int LANdiscovery_handlepacket(uint8_t * packet, uint32_t length, IP_Port source) 74int LANdiscovery_handlepacket(uint8_t *packet, uint32_t length, IP_Port source)
75{ 75{
76 if(packet[0] == 32) 76 if (packet[0] == 32)
77 return handle_LANdiscovery(packet, length, source); 77 return handle_LANdiscovery(packet, length, source);
78 return 1; 78 return 1;
79} 79}