diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/DHT_test.c | 31 | ||||
-rw-r--r-- | testing/Lossless_UDP_testclient.c | 14 | ||||
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 6 | ||||
-rw-r--r-- | testing/Messenger_test.c | 10 | ||||
-rw-r--r-- | testing/nTox.c | 19 |
5 files changed, 38 insertions, 42 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index fce9c257..caa0cde2 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -66,13 +66,11 @@ void print_clientlist(DHT *dht) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | p_ip = dht->close_clientlist[i].ip_port; | 68 | p_ip = dht->close_clientlist[i].ip_port; |
69 | printf("\nIP: %u.%u.%u.%u Port: %u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 69 | printf("\nIP: %s Port: %u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
70 | ntohs(p_ip.port)); | ||
71 | printf("\nTimestamp: %llu", (long long unsigned int) dht->close_clientlist[i].timestamp); | 70 | printf("\nTimestamp: %llu", (long long unsigned int) dht->close_clientlist[i].timestamp); |
72 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->close_clientlist[i].last_pinged); | 71 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->close_clientlist[i].last_pinged); |
73 | p_ip = dht->close_clientlist[i].ret_ip_port; | 72 | p_ip = dht->close_clientlist[i].ret_ip_port; |
74 | printf("OUR IP: %u.%u.%u.%u Port: %u\n", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 73 | printf("OUR IP: %s Port: %u\n", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
75 | ntohs(p_ip.port)); | ||
76 | printf("Timestamp: %llu\n", (long long unsigned int) dht->close_clientlist[i].ret_timestamp); | 74 | printf("Timestamp: %llu\n", (long long unsigned int) dht->close_clientlist[i].ret_timestamp); |
77 | } | 75 | } |
78 | } | 76 | } |
@@ -91,9 +89,8 @@ void print_friendlist(DHT *dht) | |||
91 | printf("%c", dht->friends_list[k].client_id[j]); | 89 | printf("%c", dht->friends_list[k].client_id[j]); |
92 | } | 90 | } |
93 | 91 | ||
94 | p_ip = DHT_getfriendip(dht, dht->friends_list[k].client_id); | 92 | int friendok = DHT_getfriendip(dht, dht->friends_list[k].client_id, &p_ip); |
95 | printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 93 | printf("\nIP: %s:%u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
96 | ntohs(p_ip.port)); | ||
97 | 94 | ||
98 | printf("\nCLIENTS IN LIST:\n\n"); | 95 | printf("\nCLIENTS IN LIST:\n\n"); |
99 | 96 | ||
@@ -108,13 +105,11 @@ void print_friendlist(DHT *dht) | |||
108 | } | 105 | } |
109 | 106 | ||
110 | p_ip = dht->friends_list[k].client_list[i].ip_port; | 107 | p_ip = dht->friends_list[k].client_list[i].ip_port; |
111 | printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 108 | printf("\nIP: %s:%u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
112 | ntohs(p_ip.port)); | ||
113 | printf("\nTimestamp: %llu", (long long unsigned int) dht->friends_list[k].client_list[i].timestamp); | 109 | printf("\nTimestamp: %llu", (long long unsigned int) dht->friends_list[k].client_list[i].timestamp); |
114 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->friends_list[k].client_list[i].last_pinged); | 110 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->friends_list[k].client_list[i].last_pinged); |
115 | p_ip = dht->friends_list[k].client_list[i].ret_ip_port; | 111 | p_ip = dht->friends_list[k].client_list[i].ret_ip_port; |
116 | printf("ret IP: %u.%u.%u.%u:%u\n", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 112 | printf("ret IP: %s:%u\n", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
117 | ntohs(p_ip.port)); | ||
118 | printf("Timestamp: %llu\n", (long long unsigned int)dht->friends_list[k].client_list[i].ret_timestamp); | 113 | printf("Timestamp: %llu\n", (long long unsigned int)dht->friends_list[k].client_list[i].ret_timestamp); |
119 | } | 114 | } |
120 | } | 115 | } |
@@ -138,11 +133,14 @@ void printpacket(uint8_t *data, uint32_t length, IP_Port ip_port) | |||
138 | 133 | ||
139 | int main(int argc, char *argv[]) | 134 | int main(int argc, char *argv[]) |
140 | { | 135 | { |
136 | /* let use decide by cmdline: TODO */ | ||
137 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; | ||
138 | |||
141 | //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); | 139 | //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); |
142 | /* initialize networking */ | 140 | /* initialize networking */ |
143 | /* bind to ip 0.0.0.0:PORT */ | 141 | /* bind to ip 0.0.0.0:PORT */ |
144 | IP ip; | 142 | IP ip; |
145 | ip.uint32 = 0; | 143 | ip_init(&ip, ipv6enabled); |
146 | 144 | ||
147 | DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); | 145 | DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); |
148 | 146 | ||
@@ -172,14 +170,7 @@ int main(int argc, char *argv[]) | |||
172 | 170 | ||
173 | 171 | ||
174 | perror("Initialization"); | 172 | perror("Initialization"); |
175 | IP_Port bootstrap_ip_port; | 173 | DHT_bootstrap_ex(dht, argv[1], ipv6enabled, htons(atoi(argv[2])), hex_string_to_bin(argv[3])); |
176 | bootstrap_ip_port.port = htons(atoi(argv[2])); | ||
177 | /* bootstrap_ip_port.ip.c[0] = 127; | ||
178 | * bootstrap_ip_port.ip.c[1] = 0; | ||
179 | * bootstrap_ip_port.ip.c[2] = 0; | ||
180 | * bootstrap_ip_port.ip.c[3] = 1; */ | ||
181 | bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]); | ||
182 | DHT_bootstrap(dht, bootstrap_ip_port, hex_string_to_bin(argv[3])); | ||
183 | 174 | ||
184 | /* | 175 | /* |
185 | IP_Port ip_port; | 176 | IP_Port ip_port; |
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index d5fb1544..564b2ecf 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c | |||
@@ -66,8 +66,7 @@ void printpacket(uint8_t *data, uint32_t length, IP_Port ip_port) | |||
66 | 66 | ||
67 | void printip(IP_Port ip_port) | 67 | void printip(IP_Port ip_port) |
68 | { | 68 | { |
69 | printf("\nIP: %u.%u.%u.%u Port: %u", ip_port.ip.uint8[0], ip_port.ip.uint8[1], ip_port.ip.uint8[2], ip_port.ip.uint8[3], | 69 | printf("\nIP: %s Port: %u", ip_ntoa(&ip_port.ip), ntohs(ip_port.port)); |
70 | ntohs(ip_port.port)); | ||
71 | } | 70 | } |
72 | /* | 71 | /* |
73 | void printpackets(Data test) | 72 | void printpackets(Data test) |
@@ -152,6 +151,9 @@ void printconnection(int connection_id) | |||
152 | 151 | ||
153 | int main(int argc, char *argv[]) | 152 | int main(int argc, char *argv[]) |
154 | { | 153 | { |
154 | /* let use decide by cmdline: TODO */ | ||
155 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; | ||
156 | |||
155 | if (argc < 4) { | 157 | if (argc < 4) { |
156 | printf("usage: %s ip port filename\n", argv[0]); | 158 | printf("usage: %s ip port filename\n", argv[0]); |
157 | exit(0); | 159 | exit(0); |
@@ -169,13 +171,17 @@ int main(int argc, char *argv[]) | |||
169 | /* initialize networking */ | 171 | /* initialize networking */ |
170 | /* bind to ip 0.0.0.0:PORT */ | 172 | /* bind to ip 0.0.0.0:PORT */ |
171 | IP ip; | 173 | IP ip; |
172 | ip.uint32 = 0; | 174 | ip_init(&ip, ipv6enabled); |
175 | |||
173 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); | 176 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); |
174 | perror("Initialization"); | 177 | perror("Initialization"); |
178 | |||
175 | IP_Port serverip; | 179 | IP_Port serverip; |
176 | serverip.ip.uint32 = inet_addr(argv[1]); | 180 | ip_init(&serverip.ip, ipv6enabled); |
181 | addr_resolve(argv[1], &serverip.ip); | ||
177 | serverip.port = htons(atoi(argv[2])); | 182 | serverip.port = htons(atoi(argv[2])); |
178 | printip(serverip); | 183 | printip(serverip); |
184 | |||
179 | int connection = new_connection(ludp, serverip); | 185 | int connection = new_connection(ludp, serverip); |
180 | uint64_t timer = current_time(); | 186 | uint64_t timer = current_time(); |
181 | 187 | ||
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index eb506b3d..3e54e9be 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -147,6 +147,9 @@ void printconnection(int connection_id) | |||
147 | 147 | ||
148 | int main(int argc, char *argv[]) | 148 | int main(int argc, char *argv[]) |
149 | { | 149 | { |
150 | /* let use decide by cmdline: TODO */ | ||
151 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; | ||
152 | |||
150 | if (argc < 2) { | 153 | if (argc < 2) { |
151 | printf("usage: %s filename\n", argv[0]); | 154 | printf("usage: %s filename\n", argv[0]); |
152 | exit(0); | 155 | exit(0); |
@@ -164,7 +167,8 @@ int main(int argc, char *argv[]) | |||
164 | //initialize networking | 167 | //initialize networking |
165 | //bind to ip 0.0.0.0:PORT | 168 | //bind to ip 0.0.0.0:PORT |
166 | IP ip; | 169 | IP ip; |
167 | ip.uint32 = 0; | 170 | ip_init(&ip, ipv6enabled); |
171 | |||
168 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); | 172 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); |
169 | perror("Initialization"); | 173 | perror("Initialization"); |
170 | 174 | ||
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index e85a85a2..73d44efb 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -100,7 +100,9 @@ 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 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; | ||
105 | m = initMessenger(ipv6enabled); | ||
104 | 106 | ||
105 | if ( !m ) { | 107 | if ( !m ) { |
106 | fputs("Failed to allocate messenger datastructure\n", stderr); | 108 | fputs("Failed to allocate messenger datastructure\n", stderr); |
@@ -108,10 +110,8 @@ int main(int argc, char *argv[]) | |||
108 | } | 110 | } |
109 | 111 | ||
110 | if (argc > 3) { | 112 | if (argc > 3) { |
111 | IP_Port bootstrap_ip_port; | 113 | uint16_t port = htons(atoi(argv[2])); |
112 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 114 | DHT_bootstrap_ex(m->dht, argv[1], ipv6enabled, 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 { | 115 | } else { |
116 | FILE *file = fopen(argv[1], "rb"); | 116 | FILE *file = fopen(argv[1], "rb"); |
117 | 117 | ||
diff --git a/testing/nTox.c b/testing/nTox.c index 438468bd..6084aeda 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -537,6 +537,9 @@ void print_help(void) | |||
537 | 537 | ||
538 | int main(int argc, char *argv[]) | 538 | int main(int argc, char *argv[]) |
539 | { | 539 | { |
540 | /* let use decide by cmdline: TODO */ | ||
541 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; | ||
542 | |||
540 | int on = 0; | 543 | int on = 0; |
541 | int c = 0; | 544 | int c = 0; |
542 | int i = 0; | 545 | int i = 0; |
@@ -566,7 +569,7 @@ int main(int argc, char *argv[]) | |||
566 | } | 569 | } |
567 | } | 570 | } |
568 | 571 | ||
569 | m = tox_new(); | 572 | m = tox_new_ex(ipv6enabled); |
570 | 573 | ||
571 | if ( !m ) { | 574 | if ( !m ) { |
572 | fputs("Failed to allocate Messenger datastructure", stderr); | 575 | fputs("Failed to allocate Messenger datastructure", stderr); |
@@ -590,20 +593,12 @@ int main(int argc, char *argv[]) | |||
590 | new_lines(idstring); | 593 | new_lines(idstring); |
591 | strcpy(line, ""); | 594 | strcpy(line, ""); |
592 | 595 | ||
593 | tox_IP_Port bootstrap_ip_port; | 596 | uint16_t port = htons(atoi(argv[2])); |
594 | bootstrap_ip_port.port = htons(atoi(argv[2])); | ||
595 | int resolved_address = resolve_addr(argv[1]); | ||
596 | |||
597 | if (resolved_address != 0) | ||
598 | bootstrap_ip_port.ip.i = resolved_address; | ||
599 | else | ||
600 | exit(1); | ||
601 | |||
602 | unsigned char *binary_string = hex_string_to_bin(argv[3]); | 597 | unsigned char *binary_string = hex_string_to_bin(argv[3]); |
603 | tox_bootstrap(m, bootstrap_ip_port, binary_string); | 598 | tox_bootstrap_ex(m, argv[1], ipv6enabled, port, binary_string); |
604 | free(binary_string); | 599 | free(binary_string); |
605 | nodelay(stdscr, TRUE); | ||
606 | 600 | ||
601 | nodelay(stdscr, TRUE); | ||
607 | while (1) { | 602 | while (1) { |
608 | if (on == 0 && tox_isconnected(m)) { | 603 | if (on == 0 && tox_isconnected(m)) { |
609 | new_lines("[i] connected to DHT\n[i] define username with /n"); | 604 | new_lines("[i] connected to DHT\n[i] define username with /n"); |