summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toxcore/Lossless_UDP.c3
-rw-r--r--toxcore/misc_tools.h16
-rw-r--r--toxcore/network.c25
-rw-r--r--toxcore/ping.h2
-rw-r--r--toxcore/util.c2
-rw-r--r--toxcore/util.h2
6 files changed, 28 insertions, 22 deletions
diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c
index e291340d..04533a3b 100644
--- a/toxcore/Lossless_UDP.c
+++ b/toxcore/Lossless_UDP.c
@@ -455,8 +455,9 @@ uint32_t sendqueue_total(Lossless_UDP *ludp)
455{ 455{
456 uint32_t i, total = 0; 456 uint32_t i, total = 0;
457 457
458 for(i = 0; i < ludp->connections.len; i++) { 458 for (i = 0; i < ludp->connections.len; i++) {
459 Connection *connection = &tox_array_get(&ludp->connections, i, Connection); 459 Connection *connection = &tox_array_get(&ludp->connections, i, Connection);
460
460 if (connection->status != 0) 461 if (connection->status != 0)
461 total += connection->sendbuff_packetnum - connection->successful_sent; 462 total += connection->sendbuff_packetnum - connection->successful_sent;
462 } 463 }
diff --git a/toxcore/misc_tools.h b/toxcore/misc_tools.h
index 5fd0cb7a..4bf28ac7 100644
--- a/toxcore/misc_tools.h
+++ b/toxcore/misc_tools.h
@@ -89,7 +89,7 @@ int main()
89{ 89{
90 tox_list_t head; 90 tox_list_t head;
91 tox_list_new(&head); //initialize head 91 tox_list_new(&head); //initialize head
92 92
93 //input a new character, until user enters q or e 93 //input a new character, until user enters q or e
94 char c = '\0'; 94 char c = '\0';
95 while (c != 'q' && c != 'e') { 95 while (c != 'q' && c != 'e') {
@@ -98,16 +98,16 @@ int main()
98 tmp->c = c; 98 tmp->c = c;
99 tox_list_add(&head, &tmp->tox_lst); //add it to the list 99 tox_list_add(&head, &tmp->tox_lst); //add it to the list
100 } 100 }
101 101
102TOX_LIST_FOR_EACH() takes a struct tox_list and a name for a temporary pointer to use in the loop. 102TOX_LIST_FOR_EACH() takes a struct tox_list and a name for a temporary pointer to use in the loop.
103 103
104TOX_LIST_GET_VALUE() uses magic to return an instance of a structure that contains tox_list_t. 104TOX_LIST_GET_VALUE() uses magic to return an instance of a structure that contains tox_list_t.
105You have to give it a temporary tox_string_t, name of tox_list_t member inside our structure (tox_lst), 105You have to give it a temporary tox_string_t, name of tox_list_t member inside our structure (tox_lst),
106and the type of structure to return. 106and the type of structure to return.
107 107
108 TOX_LIST_FOR_EACH(head, tmp) 108 TOX_LIST_FOR_EACH(head, tmp)
109 printf("%c", TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c); 109 printf("%c", TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c);
110 110
111 TOX_LIST_FOR_EACH(head, tmp) { 111 TOX_LIST_FOR_EACH(head, tmp) {
112 if (TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c == 'z') { 112 if (TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c == 'z') {
113 //If you delete tmp, you have to quit the loop, or it will go on infinitly. 113 //If you delete tmp, you have to quit the loop, or it will go on infinitly.
@@ -116,12 +116,12 @@ and the type of structure to return.
116 break; 116 break;
117 } 117 }
118 } 118 }
119 119
120 printf("\n"); 120 printf("\n");
121 TOX_LIST_FOR_EACH(head, tmp) 121 TOX_LIST_FOR_EACH(head, tmp)
122 printf("%c", TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c); 122 printf("%c", TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c);
123 123
124 124
125 return 0; 125 return 0;
126} 126}
127*/ 127*/
diff --git a/toxcore/network.c b/toxcore/network.c
index 53511df6..640311b3 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -20,10 +20,10 @@
20 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 20 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
21 * 21 *
22 */ 22 */
23 23
24#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) 24#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
25#define _WIN32_WINNT 0x501 25#define _WIN32_WINNT 0x501
26#endif 26#endif
27 27
28#ifdef HAVE_CONFIG_H 28#ifdef HAVE_CONFIG_H
29#include "config.h" 29#include "config.h"
@@ -371,13 +371,15 @@ int networking_wait_execute(uint8_t *data, uint16_t len, uint16_t milliseconds)
371 /* returns -1 on error, 0 on timeout, the socket on activity */ 371 /* returns -1 on error, 0 on timeout, the socket on activity */
372 int res = select(nfds, &readfds, &writefds, &exceptfds, &timeout); 372 int res = select(nfds, &readfds, &writefds, &exceptfds, &timeout);
373#ifdef LOGGING 373#ifdef LOGGING
374
374 /* only dump if not timeout */ 375 /* only dump if not timeout */
375 if (res) { 376 if (res) {
376 sprintf(logbuffer, "select(%d): %d (%d, %s) - %d %d %d\n", milliseconds, res, errno, 377 sprintf(logbuffer, "select(%d): %d (%d, %s) - %d %d %d\n", milliseconds, res, errno,
377 strerror(errno), FD_ISSET(s->sock, &readfds), FD_ISSET(s->sock, &writefds), 378 strerror(errno), FD_ISSET(s->sock, &readfds), FD_ISSET(s->sock, &writefds),
378 FD_ISSET(s->sock, &exceptfds)); 379 FD_ISSET(s->sock, &exceptfds));
379 loglog(logbuffer); 380 loglog(logbuffer);
380 } 381 }
382
381#endif 383#endif
382 384
383 if (FD_ISSET(s->sock, &writefds)) 385 if (FD_ISSET(s->sock, &writefds))
@@ -525,14 +527,14 @@ Networking_Core *new_networking(IP ip, uint16_t port)
525 } else 527 } else
526 return NULL; 528 return NULL;
527 529
528 if (ip.family == AF_INET6) 530 if (ip.family == AF_INET6) {
529 {
530 char ipv6only = 0; 531 char ipv6only = 0;
531 socklen_t optsize = sizeof(ipv6only); 532 socklen_t optsize = sizeof(ipv6only);
532#ifdef LOGGING 533#ifdef LOGGING
533 errno = 0; 534 errno = 0;
534#endif 535#endif
535 int res = getsockopt(temp->sock, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6only, &optsize); 536 int res = getsockopt(temp->sock, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6only, &optsize);
537
536 if ((res == 0) && (ipv6only == 0)) { 538 if ((res == 0) && (ipv6only == 0)) {
537#ifdef LOGGING 539#ifdef LOGGING
538 loglog("Dual-stack socket: enabled per default.\n"); 540 loglog("Dual-stack socket: enabled per default.\n");
@@ -540,6 +542,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
540 } else { 542 } else {
541 ipv6only = 0; 543 ipv6only = 0;
542#ifdef LOGGING 544#ifdef LOGGING
545
543 if (res < 0) { 546 if (res < 0) {
544 sprintf(logbuffer, "Dual-stack socket: Failed to query default. (%d, %s)\n", 547 sprintf(logbuffer, "Dual-stack socket: Failed to query default. (%d, %s)\n",
545 errno, strerror(errno)); 548 errno, strerror(errno));
@@ -549,8 +552,9 @@ Networking_Core *new_networking(IP ip, uint16_t port)
549 errno = 0; 552 errno = 0;
550 res = 553 res =
551#endif 554#endif
552 setsockopt(temp->sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, sizeof(ipv6only)); 555 setsockopt(temp->sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, sizeof(ipv6only));
553#ifdef LOGGING 556#ifdef LOGGING
557
554 if (res < 0) { 558 if (res < 0) {
555 sprintf(logbuffer, 559 sprintf(logbuffer,
556 "Dual-stack socket: Failed to enable, won't be able to receive from/send to IPv4 addresses. (%u, %s)\n", 560 "Dual-stack socket: Failed to enable, won't be able to receive from/send to IPv4 addresses. (%u, %s)\n",
@@ -558,6 +562,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
558 loglog(logbuffer); 562 loglog(logbuffer);
559 } else 563 } else
560 loglog("Dual-stack socket: Enabled successfully.\n"); 564 loglog("Dual-stack socket: Enabled successfully.\n");
565
561#endif 566#endif
562 } 567 }
563 568
@@ -605,8 +610,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
605 *portptr = htons(port_to_try); 610 *portptr = htons(port_to_try);
606 int tries, res; 611 int tries, res;
607 612
608 for (tries = TOX_PORTRANGE_FROM; tries <= TOX_PORTRANGE_TO; tries++) 613 for (tries = TOX_PORTRANGE_FROM; tries <= TOX_PORTRANGE_TO; tries++) {
609 {
610 res = bind(temp->sock, (struct sockaddr *)&addr, addrsize); 614 res = bind(temp->sock, (struct sockaddr *)&addr, addrsize);
611 615
612 if (!res) { 616 if (!res) {
@@ -674,6 +678,7 @@ int ip_equal(IP *a, IP *b)
674 else if (a->family == AF_INET6) 678 else if (a->family == AF_INET6)
675#ifdef WIN32 679#ifdef WIN32
676 return IN6_ADDR_EQUAL(&a->ip6.in6_addr, &b->ip6.in6_addr); 680 return IN6_ADDR_EQUAL(&a->ip6.in6_addr, &b->ip6.in6_addr);
681
677#else 682#else
678 return IN6_ARE_ADDR_EQUAL(&a->ip6.in6_addr, &b->ip6.in6_addr); 683 return IN6_ARE_ADDR_EQUAL(&a->ip6.in6_addr, &b->ip6.in6_addr);
679#endif 684#endif
diff --git a/toxcore/ping.h b/toxcore/ping.h
index 32742401..c2437e1b 100644
--- a/toxcore/ping.h
+++ b/toxcore/ping.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * This file is donated to the Tox Project. 4 * This file is donated to the Tox Project.
5 * Copyright 2013 plutooo 5 * Copyright 2013 plutooo
6 * 6 *
7 * Copyright (C) 2013 Tox project All Rights Reserved. 7 * Copyright (C) 2013 Tox project All Rights Reserved.
8 * 8 *
9 * This file is part of Tox. 9 * This file is part of Tox.
diff --git a/toxcore/util.c b/toxcore/util.c
index 576972b4..620d1f4f 100644
--- a/toxcore/util.c
+++ b/toxcore/util.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * This file is donated to the Tox Project. 4 * This file is donated to the Tox Project.
5 * Copyright 2013 plutooo 5 * Copyright 2013 plutooo
6 * 6 *
7 * Copyright (C) 2013 Tox project All Rights Reserved. 7 * Copyright (C) 2013 Tox project All Rights Reserved.
8 * 8 *
9 * This file is part of Tox. 9 * This file is part of Tox.
diff --git a/toxcore/util.h b/toxcore/util.h
index f7b30693..97f82f60 100644
--- a/toxcore/util.h
+++ b/toxcore/util.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * This file is donated to the Tox Project. 4 * This file is donated to the Tox Project.
5 * Copyright 2013 plutooo 5 * Copyright 2013 plutooo
6 * 6 *
7 * Copyright (C) 2013 Tox project All Rights Reserved. 7 * Copyright (C) 2013 Tox project All Rights Reserved.
8 * 8 *
9 * This file is part of Tox. 9 * This file is part of Tox.