summaryrefslogtreecommitdiff
path: root/toxcore/network.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/network.h')
-rw-r--r--toxcore/network.h32
1 files changed, 8 insertions, 24 deletions
diff --git a/toxcore/network.h b/toxcore/network.h
index 8a0e20dc..1253c07e 100644
--- a/toxcore/network.h
+++ b/toxcore/network.h
@@ -40,14 +40,11 @@
40#include <ws2tcpip.h> 40#include <ws2tcpip.h>
41 41
42typedef unsigned int sock_t; 42typedef unsigned int sock_t;
43typedef INT sa_family_t; 43/* sa_family_t is the sockaddr_in / sockaddr_in6 family field */
44 44typedef short sa_family_t;
45#ifndef IN6_ARE_ADDR_EQUAL 45
46#define IN6_ARE_ADDR_EQUAL(a,b) \ 46#ifndef EWOULDBLOCK
47 ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \ 47#define EWOULDBLOCK WSAEWOULDBLOCK
48 && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \
49 && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \
50 && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
51#endif 48#endif
52 49
53#else // Linux includes 50#else // Linux includes
@@ -103,7 +100,6 @@ typedef int sock_t;
103/* Current time, unix format */ 100/* Current time, unix format */
104#define unix_time() ((uint64_t)time(NULL)) 101#define unix_time() ((uint64_t)time(NULL))
105 102
106
107typedef union { 103typedef union {
108 uint8_t uint8[4]; 104 uint8_t uint8[4];
109 uint16_t uint16[2]; 105 uint16_t uint16[2];
@@ -124,7 +120,7 @@ typedef struct {
124 IP4 ip4; 120 IP4 ip4;
125 IP6 ip6; 121 IP6 ip6;
126 }; 122 };
127} IPAny; 123} IP;
128 124
129typedef union { 125typedef union {
130 struct { 126 struct {
@@ -136,24 +132,12 @@ typedef union {
136 uint8_t uint8[8]; 132 uint8_t uint8[8];
137} IP4_Port; 133} IP4_Port;
138 134
139/* will replace IP_Port as soon as the complete infrastructure is in place
140 * removed the unused union and padding also */
141typedef struct { 135typedef struct {
142 IPAny ip; 136 IP ip;
143 uint16_t port; 137 uint16_t port;
144} IPAny_Port; 138} IP_Port;
145 139
146/* #undef TOX_ENABLE_IPV6 */
147#define TOX_ENABLE_IPV6
148#ifdef TOX_ENABLE_IPV6
149#define TOX_ENABLE_IPV6_DEFAULT 1 140#define TOX_ENABLE_IPV6_DEFAULT 1
150typedef IPAny IP;
151typedef IPAny_Port IP_Port;
152#else
153#define TOX_ENABLE_IPV6_DEFAULT 0
154typedef IP4 IP;
155typedef IP4_Port IP_Port;
156#endif
157 141
158/* ip_ntoa 142/* ip_ntoa
159 * converts ip into a string 143 * converts ip into a string