diff options
-rw-r--r-- | auto_tests/messenger_test.c | 3 | ||||
-rw-r--r-- | testing/Messenger_test.c | 9 | ||||
-rw-r--r-- | toxcore/Messenger.c | 8 | ||||
-rw-r--r-- | toxcore/Messenger.h | 2 | ||||
-rw-r--r-- | toxcore/tox.c | 6 | ||||
-rw-r--r-- | toxcore/tox.h | 3 |
6 files changed, 22 insertions, 9 deletions
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index d067a014..cba509ba 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -274,7 +274,8 @@ int main(int argc, char *argv[]) | |||
274 | good_id_b = hex_string_to_bin(good_id_b_str); | 274 | good_id_b = hex_string_to_bin(good_id_b_str); |
275 | bad_id = hex_string_to_bin(bad_id_str); | 275 | bad_id = hex_string_to_bin(bad_id_str); |
276 | 276 | ||
277 | m = initMessenger(); | 277 | /* no IPv6 enabled yet */ |
278 | m = initMessenger(0); | ||
278 | 279 | ||
279 | /* setup a default friend and friendnum */ | 280 | /* setup a default friend and friendnum */ |
280 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) | 281 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) |
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index e85a85a2..04d3bc14 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -100,7 +100,8 @@ int main(int argc, char *argv[]) | |||
100 | exit(0); | 100 | exit(0); |
101 | } | 101 | } |
102 | 102 | ||
103 | m = initMessenger(); | 103 | /* IPv6: maybe allow from cmdline --ipv6? sticking to IPv4 for now */ |
104 | m = initMessenger(0); | ||
104 | 105 | ||
105 | if ( !m ) { | 106 | if ( !m ) { |
106 | fputs("Failed to allocate messenger datastructure\n", stderr); | 107 | fputs("Failed to allocate messenger datastructure\n", stderr); |
@@ -108,10 +109,8 @@ int main(int argc, char *argv[]) | |||
108 | } | 109 | } |
109 | 110 | ||
110 | if (argc > 3) { | 111 | if (argc > 3) { |
111 | IP_Port bootstrap_ip_port; | 112 | uint16_t port = htons(atoi(argv[2])); |
112 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 113 | DHT_bootstrap_ex(m->dht, argv[1], port, hex_string_to_bin(argv[3])); |
113 | bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]); | ||
114 | DHT_bootstrap(m->dht, bootstrap_ip_port, hex_string_to_bin(argv[3])); | ||
115 | } else { | 114 | } else { |
116 | FILE *file = fopen(argv[1], "rb"); | 115 | FILE *file = fopen(argv[1], "rb"); |
117 | 116 | ||
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. */ |
653 | Messenger *initMessenger(void) | 653 | Messenger *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 | */ |
370 | Messenger *initMessenger(void); | 370 | Messenger *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 | */ |
397 | void *tox_new_ex(uint8_t ipv6enabled) | ||
398 | { | ||
399 | return initMessenger(ipv6enabled); | ||
400 | } | ||
397 | void *tox_new(void) | 401 | void *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 | */ |
309 | Tox *tox_new(void); | 311 | Tox *tox_new(void); |
312 | Tox *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. */ |