summaryrefslogtreecommitdiff
path: root/toxcore/network.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/network.c')
-rw-r--r--toxcore/network.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/toxcore/network.c b/toxcore/network.c
index 62bb4c34..619248d8 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -36,28 +36,27 @@
36 36
37static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t bufsize) 37static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t bufsize)
38{ 38{
39 if(family == AF_INET) 39 if (family == AF_INET) {
40 {
41 struct sockaddr_in saddr = { 0 }; 40 struct sockaddr_in saddr = { 0 };
42 saddr.sin_family = AF_INET; 41 saddr.sin_family = AF_INET;
43 saddr.sin_addr = *(struct in_addr*)addr; 42 saddr.sin_addr = *(struct in_addr *)addr;
44 43
45 DWORD len = bufsize; 44 DWORD len = bufsize;
46 if(WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len)) 45
46 if (WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len))
47 return NULL; 47 return NULL;
48 48
49 return buf; 49 return buf;
50 } 50 } else if (family == AF_INET6) {
51 else if(family == AF_INET6)
52 {
53 struct sockaddr_in6 saddr = { 0 }; 51 struct sockaddr_in6 saddr = { 0 };
54 saddr.sin6_family = AF_INET6; 52 saddr.sin6_family = AF_INET6;
55 saddr.sin6_addr = *(struct in6_addr*)addr; 53 saddr.sin6_addr = *(struct in6_addr *)addr;
56 54
57 DWORD len = bufsize; 55 DWORD len = bufsize;
58 if(WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len)) 56
57 if (WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len))
59 return NULL; 58 return NULL;
60 59
61 return buf; 60 return buf;
62 } 61 }
63 62
@@ -66,30 +65,27 @@ static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t b
66 65
67static int inet_pton(sa_family_t family, const char *addrString, void *addrbuf) 66static int inet_pton(sa_family_t family, const char *addrString, void *addrbuf)
68{ 67{
69 if(family == AF_INET) 68 if (family == AF_INET) {
70 {
71 struct sockaddr_in saddr = { 0 }; 69 struct sockaddr_in saddr = { 0 };
72 70
73 INT len = sizeof(saddr); 71 INT len = sizeof(saddr);
74 72
75 if(WSAStringToAddress((LPTSTR)addrString, AF_INET, NULL, (LPSOCKADDR)&saddr, &len)) 73 if (WSAStringToAddress((LPTSTR)addrString, AF_INET, NULL, (LPSOCKADDR)&saddr, &len))
76 return 0; 74 return 0;
77 75
78 *(struct in_addr*)addrbuf = saddr.sin_addr; 76 *(struct in_addr *)addrbuf = saddr.sin_addr;
79 77
80 return 1; 78 return 1;
81 } 79 } else if (family == AF_INET6) {
82 else if(family == AF_INET6)
83 {
84 struct sockaddr_in6 saddr = { 0 }; 80 struct sockaddr_in6 saddr = { 0 };
85 81
86 INT len = sizeof(saddr); 82 INT len = sizeof(saddr);
87 83
88 if(WSAStringToAddress((LPTSTR)addrString, AF_INET6, NULL, (LPSOCKADDR)&saddr, &len)) 84 if (WSAStringToAddress((LPTSTR)addrString, AF_INET6, NULL, (LPSOCKADDR)&saddr, &len))
89 return 0; 85 return 0;
90 86
91 *(struct in6_addr*)addrbuf = saddr.sin6_addr; 87 *(struct in6_addr *)addrbuf = saddr.sin6_addr;
92 88
93 return 1; 89 return 1;
94 } 90 }
95 91
@@ -477,7 +473,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
477#ifdef LOGGING 473#ifdef LOGGING
478 res = 474 res =
479#endif 475#endif
480 setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char*)&mreq, sizeof(mreq)); 476 setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq));
481#ifdef LOGGING 477#ifdef LOGGING
482 478
483 if (res < 0) { 479 if (res < 0) {