summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostya <kostyarjcnz@gmail.com>2013-08-30 03:28:50 -0400
committerKostya <kostyarjcnz@gmail.com>2013-08-30 03:28:50 -0400
commit25563ac07005448706d294dccdabf14fbe01d100 (patch)
tree2166609dfed18c1e4625c05ac0478220dd842d87
parent790867d984841ba0e28c4100615590870895e7d4 (diff)
Fixed build errors.
-rw-r--r--other/DHT_bootstrap.c4
-rw-r--r--other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c4
-rw-r--r--testing/DHT_test.c14
-rw-r--r--testing/Lossless_UDP_testclient.c6
-rw-r--r--testing/Lossless_UDP_testserver.c2
-rw-r--r--testing/Messenger_test.c2
-rw-r--r--toxcore/DHT.c38
-rw-r--r--toxcore/LAN_discovery.c17
-rw-r--r--toxcore/Lossless_UDP.c2
-rw-r--r--toxcore/Messenger.c4
-rw-r--r--toxcore/friend_requests.c4
-rw-r--r--toxcore/net_crypto.c2
-rw-r--r--toxcore/ping.c4
-rw-r--r--toxcore/util.c2
14 files changed, 52 insertions, 53 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index 229e6593..e3a7397a 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
84 /* Initialize networking - 84 /* Initialize networking -
85 Bind to ip 0.0.0.0:PORT */ 85 Bind to ip 0.0.0.0:PORT */
86 IP ip; 86 IP ip;
87 ip.i = 0; 87 ip.uint32 = 0;
88 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); 88 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT)));
89 manage_keys(dht); 89 manage_keys(dht);
90 printf("Public key: "); 90 printf("Public key: ");
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
111 if (argc > 3) { 111 if (argc > 3) {
112 printf("Trying to bootstrap into the network...\n"); 112 printf("Trying to bootstrap into the network...\n");
113 IP_Port bootstrap_info; 113 IP_Port bootstrap_info;
114 bootstrap_info.ip.i = inet_addr(argv[1]); 114 bootstrap_info.ip.uint32 = inet_addr(argv[1]);
115 bootstrap_info.port = htons(atoi(argv[2])); 115 bootstrap_info.port = htons(atoi(argv[2]));
116 uint8_t *bootstrap_key = hex_string_to_bin(argv[3]); 116 uint8_t *bootstrap_key = hex_string_to_bin(argv[3]);
117 DHT_bootstrap(dht, bootstrap_info, bootstrap_key); 117 DHT_bootstrap(dht, bootstrap_info, bootstrap_key);
diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
index 0f39285b..4e90e345 100644
--- a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
+++ b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
@@ -301,7 +301,7 @@ struct server_conf_s configure_server(char *cfg_file)
301 printf("bootstrap_server %d: Invalid port.\n", i); 301 printf("bootstrap_server %d: Invalid port.\n", i);
302 } 302 }
303 303
304 server_conf.info[i].conn.ip.i = resolve_addr(strcpy(tmp_ip, bs_ip)); 304 server_conf.info[i].conn.ip.uint32 = resolve_addr(strcpy(tmp_ip, bs_ip));
305 server_conf.info[i].conn.port = htons(bs_port); 305 server_conf.info[i].conn.port = htons(bs_port);
306 b16_to_key(strcpy(tmp_pk, bs_pk), bs_pk_p); 306 b16_to_key(strcpy(tmp_pk, bs_pk), bs_pk_p);
307 } 307 }
@@ -340,7 +340,7 @@ int main(int argc, char *argv[])
340 /* Initialize networking 340 /* Initialize networking
341 bind to ip 0.0.0.0:PORT */ 341 bind to ip 0.0.0.0:PORT */
342 IP ip; 342 IP ip;
343 ip.i = 0; 343 ip.uint32 = 0;
344 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, server_conf.port))); 344 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, server_conf.port)));
345 /* Read the config file */ 345 /* Read the config file */
346 printf("PID file: %s\n", server_conf.pid_file); 346 printf("PID file: %s\n", server_conf.pid_file);
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 09e6dfe0..cfb3ec73 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -62,11 +62,11 @@ void print_clientlist(DHT *dht)
62 } 62 }
63 63
64 p_ip = dht->close_clientlist[i].ip_port; 64 p_ip = dht->close_clientlist[i].ip_port;
65 printf("\nIP: %u.%u.%u.%u Port: %u", p_ip.ip.c[0], p_ip.ip.c[1], p_ip.ip.c[2], p_ip.ip.c[3], ntohs(p_ip.port)); 65 printf("\nIP: %u.%u.%u.%u Port: %u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], ntohs(p_ip.port));
66 printf("\nTimestamp: %llu", (long long unsigned int) dht->close_clientlist[i].timestamp); 66 printf("\nTimestamp: %llu", (long long unsigned int) dht->close_clientlist[i].timestamp);
67 printf("\nLast pinged: %llu\n", (long long unsigned int) dht->close_clientlist[i].last_pinged); 67 printf("\nLast pinged: %llu\n", (long long unsigned int) dht->close_clientlist[i].last_pinged);
68 p_ip = dht->close_clientlist[i].ret_ip_port; 68 p_ip = dht->close_clientlist[i].ret_ip_port;
69 printf("OUR IP: %u.%u.%u.%u Port: %u\n", p_ip.ip.c[0], p_ip.ip.c[1], p_ip.ip.c[2], p_ip.ip.c[3], ntohs(p_ip.port)); 69 printf("OUR IP: %u.%u.%u.%u Port: %u\n", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], ntohs(p_ip.port));
70 printf("Timestamp: %llu\n", (long long unsigned int) dht->close_clientlist[i].ret_timestamp); 70 printf("Timestamp: %llu\n", (long long unsigned int) dht->close_clientlist[i].ret_timestamp);
71 } 71 }
72} 72}
@@ -86,7 +86,7 @@ void print_friendlist(DHT *dht)
86 } 86 }
87 87
88 p_ip = DHT_getfriendip(dht, dht->friends_list[k].client_id); 88 p_ip = DHT_getfriendip(dht, dht->friends_list[k].client_id);
89 printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.c[0], p_ip.ip.c[1], p_ip.ip.c[2], p_ip.ip.c[3], ntohs(p_ip.port)); 89 printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], ntohs(p_ip.port));
90 90
91 printf("\nCLIENTS IN LIST:\n\n"); 91 printf("\nCLIENTS IN LIST:\n\n");
92 92
@@ -101,11 +101,11 @@ void print_friendlist(DHT *dht)
101 } 101 }
102 102
103 p_ip = dht->friends_list[k].client_list[i].ip_port; 103 p_ip = dht->friends_list[k].client_list[i].ip_port;
104 printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.c[0], p_ip.ip.c[1], p_ip.ip.c[2], p_ip.ip.c[3], ntohs(p_ip.port)); 104 printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], ntohs(p_ip.port));
105 printf("\nTimestamp: %llu", (long long unsigned int) dht->friends_list[k].client_list[i].timestamp); 105 printf("\nTimestamp: %llu", (long long unsigned int) dht->friends_list[k].client_list[i].timestamp);
106 printf("\nLast pinged: %llu\n", (long long unsigned int) dht->friends_list[k].client_list[i].last_pinged); 106 printf("\nLast pinged: %llu\n", (long long unsigned int) dht->friends_list[k].client_list[i].last_pinged);
107 p_ip = dht->friends_list[k].client_list[i].ret_ip_port; 107 p_ip = dht->friends_list[k].client_list[i].ret_ip_port;
108 printf("ret IP: %u.%u.%u.%u:%u\n", p_ip.ip.c[0], p_ip.ip.c[1], p_ip.ip.c[2], p_ip.ip.c[3], ntohs(p_ip.port)); 108 printf("ret IP: %u.%u.%u.%u:%u\n", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], ntohs(p_ip.port));
109 printf("Timestamp: %llu\n", (long long unsigned int)dht->friends_list[k].client_list[i].ret_timestamp); 109 printf("Timestamp: %llu\n", (long long unsigned int)dht->friends_list[k].client_list[i].ret_timestamp);
110 } 110 }
111 } 111 }
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
133 /* initialize networking */ 133 /* initialize networking */
134 /* bind to ip 0.0.0.0:PORT */ 134 /* bind to ip 0.0.0.0:PORT */
135 IP ip; 135 IP ip;
136 ip.i = 0; 136 ip.uint32 = 0;
137 137
138 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); 138 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT)));
139 139
@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
169 * bootstrap_ip_port.ip.c[1] = 0; 169 * bootstrap_ip_port.ip.c[1] = 0;
170 * bootstrap_ip_port.ip.c[2] = 0; 170 * bootstrap_ip_port.ip.c[2] = 0;
171 * bootstrap_ip_port.ip.c[3] = 1; */ 171 * bootstrap_ip_port.ip.c[3] = 1; */
172 bootstrap_ip_port.ip.i = inet_addr(argv[1]); 172 bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]);
173 DHT_bootstrap(dht, bootstrap_ip_port, hex_string_to_bin(argv[3])); 173 DHT_bootstrap(dht, bootstrap_ip_port, hex_string_to_bin(argv[3]));
174 174
175 /* 175 /*
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c
index af349863..5777f9e7 100644
--- a/testing/Lossless_UDP_testclient.c
+++ b/testing/Lossless_UDP_testclient.c
@@ -62,7 +62,7 @@ void printpacket(uint8_t *data, uint32_t length, IP_Port ip_port)
62 62
63void printip(IP_Port ip_port) 63void printip(IP_Port ip_port)
64{ 64{
65 printf("\nIP: %u.%u.%u.%u Port: %u", ip_port.ip.c[0], ip_port.ip.c[1], ip_port.ip.c[2], ip_port.ip.c[3], 65 printf("\nIP: %u.%u.%u.%u Port: %u", ip_port.ip.uint8[0], ip_port.ip.uint8[1], ip_port.ip.uint8[2], ip_port.ip.uint8[3],
66 ntohs(ip_port.port)); 66 ntohs(ip_port.port));
67} 67}
68/* 68/*
@@ -165,11 +165,11 @@ int main(int argc, char *argv[])
165 /* initialize networking */ 165 /* initialize networking */
166 /* bind to ip 0.0.0.0:PORT */ 166 /* bind to ip 0.0.0.0:PORT */
167 IP ip; 167 IP ip;
168 ip.i = 0; 168 ip.uint32 = 0;
169 Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); 169 Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT));
170 perror("Initialization"); 170 perror("Initialization");
171 IP_Port serverip; 171 IP_Port serverip;
172 serverip.ip.i = inet_addr(argv[1]); 172 serverip.ip.uint32 = inet_addr(argv[1]);
173 serverip.port = htons(atoi(argv[2])); 173 serverip.port = htons(atoi(argv[2]));
174 printip(serverip); 174 printip(serverip);
175 int connection = new_connection(ludp, serverip); 175 int connection = new_connection(ludp, serverip);
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c
index 5c2cabd0..c450c91a 100644
--- a/testing/Lossless_UDP_testserver.c
+++ b/testing/Lossless_UDP_testserver.c
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
160 //initialize networking 160 //initialize networking
161 //bind to ip 0.0.0.0:PORT 161 //bind to ip 0.0.0.0:PORT
162 IP ip; 162 IP ip;
163 ip.i = 0; 163 ip.uint32 = 0;
164 Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); 164 Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT));
165 perror("Initialization"); 165 perror("Initialization");
166 166
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c
index 19fd9ab7..8d9bb715 100644
--- a/testing/Messenger_test.c
+++ b/testing/Messenger_test.c
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
106 if (argc > 3) { 106 if (argc > 3) {
107 IP_Port bootstrap_ip_port; 107 IP_Port bootstrap_ip_port;
108 bootstrap_ip_port.port = htons(atoi(argv[2])); 108 bootstrap_ip_port.port = htons(atoi(argv[2]));
109 bootstrap_ip_port.ip.i = inet_addr(argv[1]); 109 bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]);
110 DHT_bootstrap(m->dht, bootstrap_ip_port, hex_string_to_bin(argv[3])); 110 DHT_bootstrap(m->dht, bootstrap_ip_port, hex_string_to_bin(argv[3]));
111 } else { 111 } else {
112 FILE *file = fopen(argv[1], "rb"); 112 FILE *file = fopen(argv[1], "rb");
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 78ea5b8c..f1cef9f4 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -88,7 +88,7 @@ static int id_closest(uint8_t *id, uint8_t *id1, uint8_t *id2)
88 88
89static int ipport_equal(IP_Port a, IP_Port b) 89static int ipport_equal(IP_Port a, IP_Port b)
90{ 90{
91 return (a.ip.i == b.ip.i) && (a.port == b.port); 91 return (a.ip.uint32 == b.ip.uint32) && (a.port == b.port);
92} 92}
93 93
94static int id_equal(uint8_t *a, uint8_t *b) 94static int id_equal(uint8_t *a, uint8_t *b)
@@ -122,7 +122,7 @@ static int client_in_list(Client_data *list, uint32_t length, uint8_t *client_id
122 if (id_equal(list[i].client_id, client_id)) { 122 if (id_equal(list[i].client_id, client_id)) {
123 /* Refresh the client timestamp. */ 123 /* Refresh the client timestamp. */
124 list[i].timestamp = temp_time; 124 list[i].timestamp = temp_time;
125 list[i].ip_port.ip.i = ip_port.ip.i; 125 list[i].ip_port.ip.uint32 = ip_port.ip.uint32;
126 list[i].ip_port.port = ip_port.port; 126 list[i].ip_port.port = ip_port.port;
127 return 1; 127 return 1;
128 } 128 }
@@ -268,7 +268,7 @@ static int replace_bad( Client_data *list,
268 memcpy(list[i].client_id, client_id, CLIENT_ID_SIZE); 268 memcpy(list[i].client_id, client_id, CLIENT_ID_SIZE);
269 list[i].ip_port = ip_port; 269 list[i].ip_port = ip_port;
270 list[i].timestamp = temp_time; 270 list[i].timestamp = temp_time;
271 list[i].ret_ip_port.ip.i = 0; 271 list[i].ret_ip_port.ip.uint32 = 0;
272 list[i].ret_ip_port.port = 0; 272 list[i].ret_ip_port.port = 0;
273 list[i].ret_timestamp = 0; 273 list[i].ret_timestamp = 0;
274 return 0; 274 return 0;
@@ -320,7 +320,7 @@ static int replace_good( Client_data *list,
320 memcpy(list[i].client_id, client_id, CLIENT_ID_SIZE); 320 memcpy(list[i].client_id, client_id, CLIENT_ID_SIZE);
321 list[i].ip_port = ip_port; 321 list[i].ip_port = ip_port;
322 list[i].timestamp = temp_time; 322 list[i].timestamp = temp_time;
323 list[i].ret_ip_port.ip.i = 0; 323 list[i].ret_ip_port.ip.uint32 = 0;
324 list[i].ret_ip_port.port = 0; 324 list[i].ret_ip_port.port = 0;
325 list[i].ret_timestamp = 0; 325 list[i].ret_timestamp = 0;
326 return 0; 326 return 0;
@@ -418,13 +418,13 @@ static int is_gettingnodes(DHT *dht, IP_Port ip_port, uint64_t ping_id)
418 if (!is_timeout(temp_time, dht->send_nodes[i].timestamp, PING_TIMEOUT)) { 418 if (!is_timeout(temp_time, dht->send_nodes[i].timestamp, PING_TIMEOUT)) {
419 pinging = 0; 419 pinging = 0;
420 420
421 if (ip_port.ip.i != 0 && ipport_equal(dht->send_nodes[i].ip_port, ip_port)) 421 if (ip_port.ip.uint32 != 0 && ipport_equal(dht->send_nodes[i].ip_port, ip_port))
422 ++pinging; 422 ++pinging;
423 423
424 if (ping_id != 0 && dht->send_nodes[i].ping_id == ping_id) 424 if (ping_id != 0 && dht->send_nodes[i].ping_id == ping_id)
425 ++pinging; 425 ++pinging;
426 426
427 if (pinging == (ping_id != 0) + (ip_port.ip.i != 0)) 427 if (pinging == (ping_id != 0) + (ip_port.ip.uint32 != 0))
428 return 1; 428 return 1;
429 } 429 }
430 } 430 }
@@ -690,7 +690,7 @@ IP_Port DHT_getfriendip(DHT *dht, uint8_t *client_id)
690 } 690 }
691 } 691 }
692 692
693 empty.ip.i = 1; 693 empty.ip.uint32 = 1;
694 return empty; 694 return empty;
695} 695}
696 696
@@ -814,7 +814,7 @@ static int friend_iplist(DHT *dht, IP_Port *ip_portlist, uint16_t friend_num)
814 client = &friend->client_list[i]; 814 client = &friend->client_list[i];
815 815
816 /* If ip is not zero and node is good */ 816 /* If ip is not zero and node is good */
817 if (client->ret_ip_port.ip.i != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) { 817 if (client->ret_ip_port.ip.uint32 != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) {
818 818
819 if (id_equal(client->client_id, friend->client_id)) 819 if (id_equal(client->client_id, friend->client_id))
820 return 0; 820 return 0;
@@ -856,7 +856,7 @@ int route_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint32_t lengt
856 client = &friend->client_list[i]; 856 client = &friend->client_list[i];
857 857
858 /* If ip is not zero and node is good */ 858 /* If ip is not zero and node is good */
859 if (client->ret_ip_port.ip.i != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) { 859 if (client->ret_ip_port.ip.uint32 != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) {
860 if (sendpacket(dht->c->lossless_udp->net->sock, client->ip_port, packet, length) == length) 860 if (sendpacket(dht->c->lossless_udp->net->sock, client->ip_port, packet, length) == length)
861 ++sent; 861 ++sent;
862 } 862 }
@@ -887,7 +887,7 @@ static int routeone_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint
887 client = &friend->client_list[i]; 887 client = &friend->client_list[i];
888 888
889 /* If ip is not zero and node is good. */ 889 /* If ip is not zero and node is good. */
890 if (client->ret_ip_port.ip.i != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) { 890 if (client->ret_ip_port.ip.uint32 != 0 && !is_timeout(temp_time, client->ret_timestamp, BAD_NODE_TIMEOUT)) {
891 ip_list[n] = client->ip_port; 891 ip_list[n] = client->ip_port;
892 ++n; 892 ++n;
893 } 893 }
@@ -998,7 +998,7 @@ static IP NAT_commonip(IP_Port *ip_portlist, uint16_t len, uint16_t min_num)
998 998
999 for (i = 0; i < len; ++i) { 999 for (i = 0; i < len; ++i) {
1000 for (j = 0; j < len; ++j) { 1000 for (j = 0; j < len; ++j) {
1001 if (ip_portlist[i].ip.i == ip_portlist[j].ip.i) 1001 if (ip_portlist[i].ip.uint32 == ip_portlist[j].ip.uint32)
1002 ++numbers[i]; 1002 ++numbers[i];
1003 } 1003 }
1004 1004
@@ -1020,7 +1020,7 @@ static uint16_t NAT_getports(uint16_t *portlist, IP_Port *ip_portlist, uint16_t
1020 uint16_t num = 0; 1020 uint16_t num = 0;
1021 1021
1022 for (i = 0; i < len; ++i) { 1022 for (i = 0; i < len; ++i) {
1023 if (ip_portlist[i].ip.i == ip.i) { 1023 if (ip_portlist[i].ip.uint32 == ip.uint32) {
1024 portlist[num] = ntohs(ip_portlist[i].port); 1024 portlist[num] = ntohs(ip_portlist[i].port);
1025 ++num; 1025 ++num;
1026 } 1026 }
@@ -1071,7 +1071,7 @@ static void do_NAT(DHT *dht)
1071 1071
1072 IP ip = NAT_commonip(ip_list, num, MAX_FRIEND_CLIENTS / 2); 1072 IP ip = NAT_commonip(ip_list, num, MAX_FRIEND_CLIENTS / 2);
1073 1073
1074 if (ip.i == 0) 1074 if (ip.uint32 == 0)
1075 continue; 1075 continue;
1076 1076
1077 uint16_t port_list[MAX_FRIEND_CLIENTS]; 1077 uint16_t port_list[MAX_FRIEND_CLIENTS];
@@ -1099,15 +1099,15 @@ static void do_NAT(DHT *dht)
1099 */ 1099 */
1100int add_toping(DHT *dht, uint8_t *client_id, IP_Port ip_port) 1100int add_toping(DHT *dht, uint8_t *client_id, IP_Port ip_port)
1101{ 1101{
1102 if (ip_port.ip.i == 0) 1102 if (ip_port.ip.uint32 == 0)
1103 return -1; 1103 return -1;
1104 1104
1105 uint32_t i; 1105 uint32_t i;
1106 1106
1107 for (i = 0; i < MAX_TOPING; ++i) { 1107 for (i = 0; i < MAX_TOPING; ++i) {
1108 if (dht->toping[i].ip_port.ip.i == 0) { 1108 if (dht->toping[i].ip_port.ip.uint32 == 0) {
1109 memcpy(dht->toping[i].client_id, client_id, CLIENT_ID_SIZE); 1109 memcpy(dht->toping[i].client_id, client_id, CLIENT_ID_SIZE);
1110 dht->toping[i].ip_port.ip.i = ip_port.ip.i; 1110 dht->toping[i].ip_port.ip.uint32 = ip_port.ip.uint32;
1111 dht->toping[i].ip_port.port = ip_port.port; 1111 dht->toping[i].ip_port.port = ip_port.port;
1112 return 0; 1112 return 0;
1113 } 1113 }
@@ -1116,7 +1116,7 @@ int add_toping(DHT *dht, uint8_t *client_id, IP_Port ip_port)
1116 for (i = 0; i < MAX_TOPING; ++i) { 1116 for (i = 0; i < MAX_TOPING; ++i) {
1117 if (id_closest(dht->c->self_public_key, dht->toping[i].client_id, client_id) == 2) { 1117 if (id_closest(dht->c->self_public_key, dht->toping[i].client_id, client_id) == 2) {
1118 memcpy(dht->toping[i].client_id, client_id, CLIENT_ID_SIZE); 1118 memcpy(dht->toping[i].client_id, client_id, CLIENT_ID_SIZE);
1119 dht->toping[i].ip_port.ip.i = ip_port.ip.i; 1119 dht->toping[i].ip_port.ip.uint32 = ip_port.ip.uint32;
1120 dht->toping[i].ip_port.port = ip_port.port; 1120 dht->toping[i].ip_port.port = ip_port.port;
1121 return 0; 1121 return 0;
1122 } 1122 }
@@ -1139,11 +1139,11 @@ static void do_toping(DHT *dht)
1139 uint32_t i; 1139 uint32_t i;
1140 1140
1141 for (i = 0; i < MAX_TOPING; ++i) { 1141 for (i = 0; i < MAX_TOPING; ++i) {
1142 if (dht->toping[i].ip_port.ip.i == 0) 1142 if (dht->toping[i].ip_port.ip.uint32 == 0)
1143 return; 1143 return;
1144 1144
1145 send_ping_request(dht->ping, dht->c, dht->toping[i].ip_port, dht->toping[i].client_id); 1145 send_ping_request(dht->ping, dht->c, dht->toping[i].ip_port, dht->toping[i].client_id);
1146 dht->toping[i].ip_port.ip.i = 0; 1146 dht->toping[i].ip_port.ip.uint32 = 0;
1147 } 1147 }
1148} 1148}
1149 1149
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c
index 736959c5..cb27c024 100644
--- a/toxcore/LAN_discovery.c
+++ b/toxcore/LAN_discovery.c
@@ -89,11 +89,10 @@ static IP broadcast_ip(void)
89{ 89{
90 IP ip; 90 IP ip;
91#ifdef __linux 91#ifdef __linux
92 ip.i = get_broadcast(); 92 ip.uint32 = get_broadcast();
93 93
94 if (ip.i == 0) 94 if (ip.uint32 == 0)
95 /* Error occured, but try anyway? */ 95 ip.uint32 = ~0; /* Error occured, but try anyway? */
96 ip.i = ~0;
97 96
98#else 97#else
99 ip.i = ~0; 98 ip.i = ~0;
@@ -106,19 +105,19 @@ static IP broadcast_ip(void)
106 */ 105 */
107static int LAN_ip(IP ip) 106static int LAN_ip(IP ip)
108{ 107{
109 if (ip.c[0] == 127) /* Loopback. */ 108 if (ip.uint8[0] == 127) /* Loopback. */
110 return 0; 109 return 0;
111 110
112 if (ip.c[0] == 10) /* 10.0.0.0 to 10.255.255.255 range. */ 111 if (ip.uint8[0] == 10) /* 10.0.0.0 to 10.255.255.255 range. */
113 return 0; 112 return 0;
114 113
115 if (ip.c[0] == 172 && ip.c[1] >= 16 && ip.c[1] <= 31) /* 172.16.0.0 to 172.31.255.255 range. */ 114 if (ip.uint8[0] == 172 && ip.uint8[1] >= 16 && ip.uint8[1] <= 31) /* 172.16.0.0 to 172.31.255.255 range. */
116 return 0; 115 return 0;
117 116
118 if (ip.c[0] == 192 && ip.c[1] == 168) /* 192.168.0.0 to 192.168.255.255 range. */ 117 if (ip.uint8[0] == 192 && ip.uint8[1] == 168) /* 192.168.0.0 to 192.168.255.255 range. */
119 return 0; 118 return 0;
120 119
121 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. */ 120 if (ip.uint8[0] == 169 && ip.uint8[1] == 254 && ip.uint8[2] != 0 && ip.uint8[2] != 255)/* 169.254.1.0 to 169.254.254.255 range. */
122 return 0; 121 return 0;
123 122
124 return -1; 123 return -1;
diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c
index 9725e449..3c093661 100644
--- a/toxcore/Lossless_UDP.c
+++ b/toxcore/Lossless_UDP.c
@@ -41,7 +41,7 @@ int getconnection_id(Lossless_UDP *ludp, IP_Port ip_port)
41 uint32_t i; 41 uint32_t i;
42 42
43 for (i = 0; i < ludp->connections_length; ++i) { 43 for (i = 0; i < ludp->connections_length; ++i) {
44 if (ludp->connections[i].ip_port.ip.i == ip_port.ip.i && 44 if (ludp->connections[i].ip_port.ip.uint32 == ip_port.ip.uint32 &&
45 ludp->connections[i].ip_port.port == ip_port.port && 45 ludp->connections[i].ip_port.port == ip_port.port &&
46 ludp->connections[i].status > 0) 46 ludp->connections[i].status > 0)
47 return i; 47 return i;
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 4f1c540a..719988f7 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -643,7 +643,7 @@ Messenger *initMessenger(void)
643 return NULL; 643 return NULL;
644 644
645 IP ip; 645 IP ip;
646 ip.i = 0; 646 ip.uint32 = 0;
647 m->net = new_networking(ip, PORT); 647 m->net = new_networking(ip, PORT);
648 648
649 if (m->net == NULL) { 649 if (m->net == NULL) {
@@ -731,7 +731,7 @@ void doFriends(Messenger *m)
731 731
732 switch (is_cryptoconnected(m->net_crypto, m->friendlist[i].crypt_connection_id)) { 732 switch (is_cryptoconnected(m->net_crypto, m->friendlist[i].crypt_connection_id)) {
733 case 0: 733 case 0:
734 if (friendip.ip.i > 1) 734 if (friendip.ip.uint32 > 1)
735 m->friendlist[i].crypt_connection_id = crypto_connect(m->net_crypto, m->friendlist[i].client_id, friendip); 735 m->friendlist[i].crypt_connection_id = crypto_connect(m->net_crypto, m->friendlist[i].client_id, friendip);
736 736
737 break; 737 break;
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c
index a2827280..152cb188 100644
--- a/toxcore/friend_requests.c
+++ b/toxcore/friend_requests.c
@@ -47,10 +47,10 @@ int send_friendrequest(DHT *dht, uint8_t *public_key, uint32_t nospam_num, uint8
47 47
48 IP_Port ip_port = DHT_getfriendip(dht, public_key); 48 IP_Port ip_port = DHT_getfriendip(dht, public_key);
49 49
50 if (ip_port.ip.i == 1) 50 if (ip_port.ip.uint32 == 1)
51 return -1; 51 return -1;
52 52
53 if (ip_port.ip.i != 0) { 53 if (ip_port.ip.uint32 != 0) {
54 if (sendpacket(dht->c->lossless_udp->net->sock, ip_port, packet, len) != -1) 54 if (sendpacket(dht->c->lossless_udp->net->sock, ip_port, packet, len) != -1)
55 return 0; 55 return 0;
56 56
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index 1f00144a..87c98089 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -422,7 +422,7 @@ int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port)
422 if (id != -1) { 422 if (id != -1) {
423 IP_Port c_ip = connection_ip(c->lossless_udp, c->crypto_connections[id].number); 423 IP_Port c_ip = connection_ip(c->lossless_udp, c->crypto_connections[id].number);
424 424
425 if (c_ip.ip.i == ip_port.ip.i && c_ip.port == ip_port.port) 425 if (c_ip.ip.uint32 == ip_port.ip.uint32 && c_ip.port == ip_port.port)
426 return -1; 426 return -1;
427 } 427 }
428 428
diff --git a/toxcore/ping.c b/toxcore/ping.c
index 384b2036..db7333d3 100644
--- a/toxcore/ping.c
+++ b/toxcore/ping.c
@@ -96,7 +96,7 @@ bool is_pinging(void *ping, IP_Port ipp, uint64_t ping_id) // O(n) TODO: Repl
96{ 96{
97 PING *png = ping; 97 PING *png = ping;
98 98
99 if (ipp.ip.i == 0 && ping_id == 0) 99 if (ipp.ip.uint32 == 0 && ping_id == 0)
100 return false; 100 return false;
101 101
102 size_t i, id; 102 size_t i, id;
@@ -107,7 +107,7 @@ bool is_pinging(void *ping, IP_Port ipp, uint64_t ping_id) // O(n) TODO: Repl
107 id = (png->pos_pings + i) % PING_NUM_MAX; 107 id = (png->pos_pings + i) % PING_NUM_MAX;
108 108
109 /* ping_id = 0 means match any id. */ 109 /* ping_id = 0 means match any id. */
110 if ((ipp_eq(png->pings[id].ipp, ipp) || ipp.ip.i == 0) && (png->pings[id].id == ping_id || ping_id == 0)) { 110 if ((ipp_eq(png->pings[id].ipp, ipp) || ipp.ip.uint32 == 0) && (png->pings[id].id == ping_id || ping_id == 0)) {
111 return true; 111 return true;
112 } 112 }
113 } 113 }
diff --git a/toxcore/util.c b/toxcore/util.c
index 40723eab..59609340 100644
--- a/toxcore/util.c
+++ b/toxcore/util.c
@@ -30,7 +30,7 @@ uint64_t random_64b()
30 30
31bool ipp_eq(IP_Port a, IP_Port b) 31bool ipp_eq(IP_Port a, IP_Port b)
32{ 32{
33 return (a.ip.i == b.ip.i) && (a.port == b.port); 33 return (a.ip.uint32 == b.ip.uint32) && (a.port == b.port);
34} 34}
35 35
36bool id_eq(uint8_t *dest, uint8_t *src) 36bool id_eq(uint8_t *dest, uint8_t *src)