diff options
Diffstat (limited to 'toxcore/network.h')
-rw-r--r-- | toxcore/network.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/toxcore/network.h b/toxcore/network.h index bdf4081f..350ec222 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -111,6 +111,7 @@ typedef enum NET_PACKET_TYPE { | |||
111 | #define TOX_PORT_DEFAULT TOX_PORTRANGE_FROM | 111 | #define TOX_PORT_DEFAULT TOX_PORTRANGE_FROM |
112 | 112 | ||
113 | /* Redefinitions of variables for safe transfer over wire. */ | 113 | /* Redefinitions of variables for safe transfer over wire. */ |
114 | #define TOX_AF_UNSPEC 0 | ||
114 | #define TOX_AF_INET 2 | 115 | #define TOX_AF_INET 2 |
115 | #define TOX_AF_INET6 10 | 116 | #define TOX_AF_INET6 10 |
116 | #define TOX_TCP_INET 130 | 117 | #define TOX_TCP_INET 130 |
@@ -123,10 +124,10 @@ typedef enum NET_PACKET_TYPE { | |||
123 | #define TOX_PROTO_UDP 2 | 124 | #define TOX_PROTO_UDP 2 |
124 | 125 | ||
125 | /* TCP related */ | 126 | /* TCP related */ |
126 | #define TCP_ONION_FAMILY (AF_INET6 + 1) | 127 | #define TCP_ONION_FAMILY (TOX_AF_INET6 + 1) |
127 | #define TCP_INET (AF_INET6 + 2) | 128 | #define TCP_INET (TOX_AF_INET6 + 2) |
128 | #define TCP_INET6 (AF_INET6 + 3) | 129 | #define TCP_INET6 (TOX_AF_INET6 + 3) |
129 | #define TCP_FAMILY (AF_INET6 + 4) | 130 | #define TCP_FAMILY (TOX_AF_INET6 + 4) |
130 | 131 | ||
131 | typedef union { | 132 | typedef union { |
132 | uint8_t uint8[4]; | 133 | uint8_t uint8[4]; |
@@ -174,7 +175,7 @@ uint32_t net_ntohl(uint32_t hostlong); | |||
174 | uint16_t net_ntohs(uint16_t hostshort); | 175 | uint16_t net_ntohs(uint16_t hostshort); |
175 | 176 | ||
176 | /* Does the IP6 struct a contain an IPv4 address in an IPv6 one? */ | 177 | /* Does the IP6 struct a contain an IPv4 address in an IPv6 one? */ |
177 | #define IPV6_IPV4_IN_V6(a) ((a.uint64[0] == 0) && (a.uint32[2] == htonl (0xffff))) | 178 | #define IPV6_IPV4_IN_V6(a) ((a.uint64[0] == 0) && (a.uint32[2] == net_htonl (0xffff))) |
178 | 179 | ||
179 | #define SIZE_IP4 4 | 180 | #define SIZE_IP4 4 |
180 | #define SIZE_IP6 16 | 181 | #define SIZE_IP6 16 |
@@ -206,10 +207,10 @@ const char *ip_ntoa(const IP *ip, char *ip_str, size_t length); | |||
206 | * parses IP structure into an address string | 207 | * parses IP structure into an address string |
207 | * | 208 | * |
208 | * input | 209 | * input |
209 | * ip: ip of AF_INET or AF_INET6 families | 210 | * ip: ip of TOX_AF_INET or TOX_AF_INET6 families |
210 | * length: length of the address buffer | 211 | * length: length of the address buffer |
211 | * Must be at least INET_ADDRSTRLEN for AF_INET | 212 | * Must be at least INET_ADDRSTRLEN for TOX_AF_INET |
212 | * and INET6_ADDRSTRLEN for AF_INET6 | 213 | * and INET6_ADDRSTRLEN for TOX_AF_INET6 |
213 | * | 214 | * |
214 | * output | 215 | * output |
215 | * address: dotted notation (IPv4: quad, IPv6: 16) or colon notation (IPv6) | 216 | * address: dotted notation (IPv4: quad, IPv6: 16) or colon notation (IPv6) |
@@ -270,13 +271,13 @@ void ipport_copy(IP_Port *target, const IP_Port *source); | |||
270 | * input | 271 | * input |
271 | * address: a hostname (or something parseable to an IP address) | 272 | * address: a hostname (or something parseable to an IP address) |
272 | * to: to.family MUST be initialized, either set to a specific IP version | 273 | * to: to.family MUST be initialized, either set to a specific IP version |
273 | * (AF_INET/AF_INET6) or to the unspecified AF_UNSPEC (= 0), if both | 274 | * (TOX_AF_INET/TOX_AF_INET6) or to the unspecified TOX_AF_UNSPEC (= 0), if both |
274 | * IP versions are acceptable | 275 | * IP versions are acceptable |
275 | * extra can be NULL and is only set in special circumstances, see returns | 276 | * extra can be NULL and is only set in special circumstances, see returns |
276 | * | 277 | * |
277 | * returns in *to a valid IPAny (v4/v6), | 278 | * returns in *to a valid IPAny (v4/v6), |
278 | * prefers v6 if ip.family was AF_UNSPEC and both available | 279 | * prefers v6 if ip.family was TOX_AF_UNSPEC and both available |
279 | * returns in *extra an IPv4 address, if family was AF_UNSPEC and *to is AF_INET6 | 280 | * returns in *extra an IPv4 address, if family was TOX_AF_UNSPEC and *to is TOX_AF_INET6 |
280 | * returns 0 on failure | 281 | * returns 0 on failure |
281 | */ | 282 | */ |
282 | int addr_resolve(const char *address, IP *to, IP *extra); | 283 | int addr_resolve(const char *address, IP *to, IP *extra); |
@@ -287,12 +288,12 @@ int addr_resolve(const char *address, IP *to, IP *extra); | |||
287 | * | 288 | * |
288 | * address: a hostname (or something parseable to an IP address) | 289 | * address: a hostname (or something parseable to an IP address) |
289 | * to: to.family MUST be initialized, either set to a specific IP version | 290 | * to: to.family MUST be initialized, either set to a specific IP version |
290 | * (AF_INET/AF_INET6) or to the unspecified AF_UNSPEC (= 0), if both | 291 | * (TOX_AF_INET/TOX_AF_INET6) or to the unspecified TOX_AF_UNSPEC (= 0), if both |
291 | * IP versions are acceptable | 292 | * IP versions are acceptable |
292 | * extra can be NULL and is only set in special circumstances, see returns | 293 | * extra can be NULL and is only set in special circumstances, see returns |
293 | * | 294 | * |
294 | * returns in *tro a matching address (IPv6 or IPv4) | 295 | * returns in *tro a matching address (IPv6 or IPv4) |
295 | * returns in *extra, if not NULL, an IPv4 address, if to->family was AF_UNSPEC | 296 | * returns in *extra, if not NULL, an IPv4 address, if to->family was TOX_AF_UNSPEC |
296 | * returns 1 on success | 297 | * returns 1 on success |
297 | * returns 0 on failure | 298 | * returns 0 on failure |
298 | */ | 299 | */ |
@@ -394,7 +395,7 @@ int net_connect(Socket sock, IP_Port ip_port); | |||
394 | * return number of elements in res array | 395 | * return number of elements in res array |
395 | * and -1 on error. | 396 | * and -1 on error. |
396 | */ | 397 | */ |
397 | int32_t net_getipport(const char *node, IP_Port **res, int type); | 398 | int32_t net_getipport(const char *node, IP_Port **res, int tox_type); |
398 | 399 | ||
399 | /* Deallocates memory allocated by net_getipport | 400 | /* Deallocates memory allocated by net_getipport |
400 | */ | 401 | */ |