summaryrefslogtreecommitdiff
path: root/toxcore/LAN_discovery.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-09-15 09:31:27 -0400
committerirungentoo <irungentoo@gmail.com>2013-09-15 09:31:27 -0400
commit8c41244627528ba35dc122ed166cc664fee8c4de (patch)
tree03965770613737b68ac1d8669331a581a1b8ba58 /toxcore/LAN_discovery.c
parentdde98eb34567a274d444893f8c98868ba9d1fa4b (diff)
Fixed portablity problems.
struct in6_addr member names can differ per platform.
Diffstat (limited to 'toxcore/LAN_discovery.c')
-rw-r--r--toxcore/LAN_discovery.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c
index c7afb991..db07755d 100644
--- a/toxcore/LAN_discovery.c
+++ b/toxcore/LAN_discovery.c
@@ -99,15 +99,15 @@ static IP broadcast_ip(sa_family_t family_socket, sa_family_t family_broadcast)
99 /* FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ 99 /* FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */
100 /* FE80::*: MUST be exact, for that we would need to look over all 100 /* FE80::*: MUST be exact, for that we would need to look over all
101 * interfaces and check in which status they are */ 101 * interfaces and check in which status they are */
102 ip.ip6.s6_addr[ 0] = 0xFF; 102 ip.ip6.uint8[ 0] = 0xFF;
103 ip.ip6.s6_addr[ 1] = 0x02; 103 ip.ip6.uint8[ 1] = 0x02;
104 ip.ip6.s6_addr[15] = 0x01; 104 ip.ip6.uint8[15] = 0x01;
105 } else if (family_broadcast == AF_INET) { 105 } else if (family_broadcast == AF_INET) {
106 ip.family = AF_INET6; 106 ip.family = AF_INET6;
107 ip.ip6.s6_addr32[0] = 0; 107 ip.ip6.uint32[0] = 0;
108 ip.ip6.s6_addr32[1] = 0; 108 ip.ip6.uint32[1] = 0;
109 ip.ip6.s6_addr32[2] = htonl(0xFFFF); 109 ip.ip6.uint32[2] = htonl(0xFFFF);
110 ip.ip6.s6_addr32[3] = INADDR_BROADCAST; 110 ip.ip6.uint32[3] = INADDR_BROADCAST;
111 } 111 }
112 } else if (family_socket == AF_INET) { 112 } else if (family_socket == AF_INET) {
113 if (family_broadcast == AF_INET) { 113 if (family_broadcast == AF_INET) {
@@ -166,15 +166,15 @@ static int LAN_ip(IP ip)
166 { 166 {
167 /* autogenerated for each interface: FE80::* (up to FEBF::*) 167 /* autogenerated for each interface: FE80::* (up to FEBF::*)
168 FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */ 168 FF02::1 is - according to RFC 4291 - multicast all-nodes link-local */
169 if (((ip.ip6.s6_addr[0] == 0xFF) && (ip.ip6.s6_addr[1] < 3) && (ip.ip6.s6_addr[15] == 1)) || 169 if (((ip.ip6.uint8[0] == 0xFF) && (ip.ip6.uint8[1] < 3) && (ip.ip6.uint8[15] == 1)) ||
170 ((ip.ip6.s6_addr[0] == 0xFE) && ((ip.ip6.s6_addr[1] & 0xC0) == 0x80))) 170 ((ip.ip6.uint8[0] == 0xFE) && ((ip.ip6.uint8[1] & 0xC0) == 0x80)))
171 return 0; 171 return 0;
172 172
173 /* embedded IPv4-in-IPv6 */ 173 /* embedded IPv4-in-IPv6 */
174 if (IN6_IS_ADDR_V4MAPPED(&ip.ip6)) { 174 if (IN6_IS_ADDR_V4MAPPED(&ip.ip6)) {
175 IP ip4; 175 IP ip4;
176 ip4.family = AF_INET; 176 ip4.family = AF_INET;
177 ip4.ip4.uint32 = ip.ip6.s6_addr32[3]; 177 ip4.ip4.uint32 = ip.ip6.uint32[3];
178 return LAN_ip(ip4); 178 return LAN_ip(ip4);
179 } 179 }
180 } 180 }