diff options
author | Diadlo <polsha3@gmail.com> | 2017-01-07 11:28:53 +0300 |
---|---|---|
committer | Diadlo <polsha3@gmail.com> | 2017-02-26 23:16:16 +0300 |
commit | b19a9e54643eceaa52e71c0f38fa2ecae5a6809e (patch) | |
tree | 4c6fff0a086988ab21636e88dbf65c2e40a76a67 /testing/DHT_test.c | |
parent | b2d04eae9d9b76523b877a9e5efd5989f83b143d (diff) |
Add part of platform-independent network API implementation
socket -> net_socket
htons -> net_htons
htonl -> net_htonl
connect -> net_connect
sendto -> net_sendto_ip4
getaddrinfo -> net_getipport
sa_family_t -> Family
Diffstat (limited to 'testing/DHT_test.c')
-rw-r--r-- | testing/DHT_test.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index c42dc053..536217fe 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -88,16 +88,16 @@ static void print_assoc(IPPTsPng *assoc, uint8_t ours) | |||
88 | { | 88 | { |
89 | IP_Port *ipp = &assoc->ip_port; | 89 | IP_Port *ipp = &assoc->ip_port; |
90 | char ip_str[IP_NTOA_LEN]; | 90 | char ip_str[IP_NTOA_LEN]; |
91 | printf("\nIP: %s Port: %u", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), ntohs(ipp->port)); | 91 | printf("\nIP: %s Port: %u", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), net_ntohs(ipp->port)); |
92 | printf("\nTimestamp: %llu", (long long unsigned int) assoc->timestamp); | 92 | printf("\nTimestamp: %llu", (long long unsigned int) assoc->timestamp); |
93 | printf("\nLast pinged: %llu\n", (long long unsigned int) assoc->last_pinged); | 93 | printf("\nLast pinged: %llu\n", (long long unsigned int) assoc->last_pinged); |
94 | 94 | ||
95 | ipp = &assoc->ret_ip_port; | 95 | ipp = &assoc->ret_ip_port; |
96 | 96 | ||
97 | if (ours) { | 97 | if (ours) { |
98 | printf("OUR IP: %s Port: %u\n", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), ntohs(ipp->port)); | 98 | printf("OUR IP: %s Port: %u\n", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), net_ntohs(ipp->port)); |
99 | } else { | 99 | } else { |
100 | printf("RET IP: %s Port: %u\n", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), ntohs(ipp->port)); | 100 | printf("RET IP: %s Port: %u\n", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), net_ntohs(ipp->port)); |
101 | } | 101 | } |
102 | 102 | ||
103 | printf("Timestamp: %llu\n", (long long unsigned int) assoc->ret_timestamp); | 103 | printf("Timestamp: %llu\n", (long long unsigned int) assoc->ret_timestamp); |
@@ -138,7 +138,7 @@ static void print_friendlist(DHT *dht) | |||
138 | 138 | ||
139 | int friendok = DHT_getfriendip(dht, dht->friends_list[k].public_key, &p_ip); | 139 | int friendok = DHT_getfriendip(dht, dht->friends_list[k].public_key, &p_ip); |
140 | char ip_str[IP_NTOA_LEN]; | 140 | char ip_str[IP_NTOA_LEN]; |
141 | printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip, ip_str, sizeof(ip_str)), ntohs(p_ip.port), friendok); | 141 | printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip, ip_str, sizeof(ip_str)), net_ntohs(p_ip.port), friendok); |
142 | 142 | ||
143 | printf("\nCLIENTS IN LIST:\n\n"); | 143 | printf("\nCLIENTS IN LIST:\n\n"); |
144 | 144 | ||
@@ -227,7 +227,7 @@ int main(int argc, char *argv[]) | |||
227 | 227 | ||
228 | perror("Initialization"); | 228 | perror("Initialization"); |
229 | 229 | ||
230 | uint16_t port = htons(atoi(argv[argvoffset + 2])); | 230 | uint16_t port = net_htons(atoi(argv[argvoffset + 2])); |
231 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); | 231 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
232 | int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], ipv6enabled, port, binary_string); | 232 | int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], ipv6enabled, port, binary_string); |
233 | free(binary_string); | 233 | free(binary_string); |