summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-09-10 16:36:20 +0200
committerCoren[m] <Break@Ocean>2013-09-10 16:36:20 +0200
commitbcb283cf4512f36b189ce2d49eb040c205cbc778 (patch)
treeb0678f9acf245e5620d21c046265a7b3ad98c561 /toxcore/tox.h
parentbcf251ac3190db4230d42be97b539e4df3af736f (diff)
big push, putting all the infrastructure in place behind TOX_ENABLE_IPV6
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h47
1 files changed, 39 insertions, 8 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index f8d7975f..44eba081 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -36,21 +36,51 @@ extern "C" {
36 36
37#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t)) 37#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
38 38
39
40typedef union { 39typedef union {
41 uint8_t c[4]; 40 uint8_t c[4];
42 uint16_t s[2]; 41 uint16_t s[2];
43 uint32_t i; 42 uint32_t i;
44} tox_IP; 43} tox_IP4;
44
45
46typedef struct in6_addr tox_IP6;
45 47
46typedef struct { 48typedef struct {
47 tox_IP ip; 49 sa_family_t family;
50 union {
51 tox_IP4 ip4;
52 tox_IP6 ip6;
53 };
54} tox_IPAny;
55
56typedef union {
57 struct {
58 tox_IP4 ip;
59 uint16_t port;
60 /* Not used for anything right now. */
61 uint16_t padding;
62 };
63 uint8_t uint8[8];
64} tox_IP4_Port;
65
66/* will replace IP_Port as soon as the complete infrastructure is in place
67 * removed the unused union and padding also */
68typedef struct {
69 tox_IPAny ip;
48 uint16_t port; 70 uint16_t port;
49 /* Not used for anything right now. */ 71} tox_IPAny_Port;
50 uint16_t padding; 72
51} tox_IP_Port; 73#undef TOX_ENABLE_IPV6
74#ifdef TOX_ENABLE_IPV6
75#define TOX_ENABLE_IPV6_DEFAULT 1
76typedef tox_IPAny tox_IP;
77typedef tox_IPAny_Port tox_IP_Port;
78#else
79#define TOX_ENABLE_IPV6_DEFAULT 0
80typedef tox_IP4 tox_IP;
81typedef tox_IP4_Port tox_IP_Port;
82#endif
52 83
53#define TOX_IP_IS_IPV6 0
54 84
55/* Errors for m_addfriend 85/* Errors for m_addfriend
56 * FAERR - Friend Add Error 86 * FAERR - Friend Add Error
@@ -296,7 +326,8 @@ void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uin
296 * tox_bootstrap_ex converts the address into an IP_Port structure internally 326 * tox_bootstrap_ex converts the address into an IP_Port structure internally
297 */ 327 */
298void tox_bootstrap(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key); 328void tox_bootstrap(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key);
299void tox_bootstrap_ex(Tox *tox, const char *address, uint16_t port, uint8_t *public_key); 329void tox_bootstrap_ex(Tox *tox, const char *address, uint8_t ipv6enabled,
330 uint16_t port, uint8_t *public_key);
300 331
301/* return 0 if we are not connected to the DHT. 332/* return 0 if we are not connected to the DHT.
302 * return 1 if we are. 333 * return 1 if we are.