summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-09-09 20:14:24 +0200
committerCoren[m] <Break@Ocean>2013-09-09 21:03:31 +0200
commit05d7b157c6560d4545f815b60b8c43aca6981227 (patch)
tree06d110716cd2c1605b3bee97894092f8472fb134 /toxcore
parenta77253c79b9c2acaa73164dcbd0694cb7b19db91 (diff)
tox.*, Messenger.*:
- initialisation: argument added to enable/disable ipv6 as socket Messenger_test.c: - initialisation: ipv4 hardcoded for now - delegating IP resolution to DHT_bootstrap_ex()
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/Messenger.c8
-rw-r--r--toxcore/Messenger.h2
-rw-r--r--toxcore/tox.c6
-rw-r--r--toxcore/tox.h3
4 files changed, 16 insertions, 3 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index e18e9efc..48d40f43 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -650,15 +650,21 @@ static void LANdiscovery(Messenger *m)
650} 650}
651 651
652/* Run this at startup. */ 652/* Run this at startup. */
653Messenger *initMessenger(void) 653Messenger *initMessenger(uint8_t ipv6enabled)
654{ 654{
655 Messenger *m = calloc(1, sizeof(Messenger)); 655 Messenger *m = calloc(1, sizeof(Messenger));
656 656
657 if ( ! m ) 657 if ( ! m )
658 return NULL; 658 return NULL;
659 659
660#ifdef NETWORK_IP_PORT_IS_IPV6
661 IPAny ip;
662 memset(&ip, 0, sizeof(ip));
663 ip.family = ipv6enabled ? AF_INET6 : AF_INET;
664#else
660 IP4 ip; 665 IP4 ip;
661 ip.uint32 = 0; 666 ip.uint32 = 0;
667#endif
662 m->net = new_networking(ip, PORT); 668 m->net = new_networking(ip, PORT);
663 669
664 if (m->net == NULL) { 670 if (m->net == NULL) {
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index c512245c..34131a20 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -367,7 +367,7 @@ void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, in
367 * return allocated instance of Messenger on success. 367 * return allocated instance of Messenger on success.
368 * return 0 if there are problems. 368 * return 0 if there are problems.
369 */ 369 */
370Messenger *initMessenger(void); 370Messenger *initMessenger(uint8_t ipv6enabled);
371 371
372/* Run this before closing shop 372/* Run this before closing shop
373 * Free all datastructures. 373 * Free all datastructures.
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 1507b2c5..d48de0d8 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -394,9 +394,13 @@ int tox_isconnected(void *tox)
394 * return allocated instance of tox on success. 394 * return allocated instance of tox on success.
395 * return 0 if there are problems. 395 * return 0 if there are problems.
396 */ 396 */
397void *tox_new_ex(uint8_t ipv6enabled)
398{
399 return initMessenger(ipv6enabled);
400}
397void *tox_new(void) 401void *tox_new(void)
398{ 402{
399 return initMessenger(); 403 return tox_new_ex(0);
400} 404}
401 405
402/* Run this before closing shop. 406/* Run this before closing shop.
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 77f0be7f..f8d7975f 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -50,6 +50,8 @@ typedef struct {
50 uint16_t padding; 50 uint16_t padding;
51} tox_IP_Port; 51} tox_IP_Port;
52 52
53#define TOX_IP_IS_IPV6 0
54
53/* Errors for m_addfriend 55/* Errors for m_addfriend
54 * FAERR - Friend Add Error 56 * FAERR - Friend Add Error
55 */ 57 */
@@ -307,6 +309,7 @@ int tox_isconnected(Tox *tox);
307 * return 0 if there are problems. 309 * return 0 if there are problems.
308 */ 310 */
309Tox *tox_new(void); 311Tox *tox_new(void);
312Tox *tox_new_ex(uint8_t ipv6enabled);
310 313
311/* Run this before closing shop. 314/* Run this before closing shop.
312 * Free all datastructures. */ 315 * Free all datastructures. */