summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h65
1 files changed, 59 insertions, 6 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 811e798b..cf5d6b2a 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -26,6 +26,22 @@
26 26
27#include <stdint.h> 27#include <stdint.h>
28 28
29#ifdef WIN32
30#ifndef WINVER
31//Windows XP
32#define WINVER 0x0501
33#endif
34
35#include <winsock2.h>
36#include <windows.h>
37#include <ws2tcpip.h>
38
39#else
40
41#include <netinet/ip.h>
42
43#endif
44
29#ifdef __cplusplus 45#ifdef __cplusplus
30extern "C" { 46extern "C" {
31#endif 47#endif
@@ -36,19 +52,52 @@ extern "C" {
36 52
37#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t)) 53#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
38 54
39
40typedef union { 55typedef union {
41 uint8_t c[4]; 56 uint8_t c[4];
42 uint16_t s[2]; 57 uint16_t s[2];
43 uint32_t i; 58 uint32_t i;
44} tox_IP; 59} tox_IP4;
60
61
62typedef struct in6_addr tox_IP6;
45 63
46typedef struct { 64typedef struct {
47 tox_IP ip; 65 sa_family_t family;
66 union {
67 tox_IP4 ip4;
68 tox_IP6 ip6;
69 };
70} tox_IPAny;
71
72typedef union {
73 struct {
74 tox_IP4 ip;
75 uint16_t port;
76 /* Not used for anything right now. */
77 uint16_t padding;
78 };
79 uint8_t uint8[8];
80} tox_IP4_Port;
81
82/* will replace IP_Port as soon as the complete infrastructure is in place
83 * removed the unused union and padding also */
84typedef struct {
85 tox_IPAny ip;
48 uint16_t port; 86 uint16_t port;
49 /* Not used for anything right now. */ 87} tox_IPAny_Port;
50 uint16_t padding; 88
51} tox_IP_Port; 89#undef TOX_ENABLE_IPV6
90/* #define TOX_ENABLE_IPV6 */
91#ifdef TOX_ENABLE_IPV6
92#define TOX_ENABLE_IPV6_DEFAULT 1
93typedef tox_IPAny tox_IP;
94typedef tox_IPAny_Port tox_IP_Port;
95#else
96#define TOX_ENABLE_IPV6_DEFAULT 0
97typedef tox_IP4 tox_IP;
98typedef tox_IP4_Port tox_IP_Port;
99#endif
100
52 101
53/* Errors for m_addfriend 102/* Errors for m_addfriend
54 * FAERR - Friend Add Error 103 * FAERR - Friend Add Error
@@ -291,8 +340,11 @@ void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uin
291 340
292/* Use this function to bootstrap the client. 341/* Use this function to bootstrap the client.
293 * Sends a get nodes request to the given node with ip port and public_key. 342 * Sends a get nodes request to the given node with ip port and public_key.
343 * tox_bootstrap_ex() returns 1 if the address could be converted, 0 otherwise
294 */ 344 */
295void tox_bootstrap(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key); 345void tox_bootstrap(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key);
346int tox_bootstrap_ex(Tox *tox, const char *address, uint8_t ipv6enabled,
347 uint16_t port, uint8_t *public_key);
296 348
297/* return 0 if we are not connected to the DHT. 349/* return 0 if we are not connected to the DHT.
298 * return 1 if we are. 350 * return 1 if we are.
@@ -305,6 +357,7 @@ int tox_isconnected(Tox *tox);
305 * return 0 if there are problems. 357 * return 0 if there are problems.
306 */ 358 */
307Tox *tox_new(void); 359Tox *tox_new(void);
360Tox *tox_new_ex(uint8_t ipv6enabled);
308 361
309/* Run this before closing shop. 362/* Run this before closing shop.
310 * Free all datastructures. */ 363 * Free all datastructures. */