diff options
author | Coren[m] <Break@Ocean> | 2013-09-27 03:27:52 +0200 |
---|---|---|
committer | Coren[m] <Break@Ocean> | 2013-09-27 03:27:52 +0200 |
commit | 9de295374decd78fd676574bd38243479dfd6054 (patch) | |
tree | a614006e1919e1c16f67fe0c90b16114d0b47aab /testing | |
parent | beff2b6de659a708ed366a9ae925eab8c4ca0ddd (diff) |
expanded Client_data to hold two addresses (IPv4, IPv6) instead of one
Compilerflag: CLIENT_ONETOONE_IP (to define in DHT.h, default unset i.e. NEW case: two addresses)
Every function in DHT{_test}.c working on Client_data has been rewritten to store IPv4 addresses in assoc4, IPv6 addresses in assoc6.
Loading/Storing of states defined with other compiler switch is transparently adjusting to the differences.
DHT.h, DHT.c:
- introduction and handling of the structure changes
DHT_test.c, Messenger.c:
- logging adapted to new structures
util.h:
- LOGGING isn't undefined per default anymore
Diffstat (limited to 'testing')
-rw-r--r-- | testing/DHT_test.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 3cd1bce6..492586fc 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -52,26 +52,40 @@ | |||
52 | 52 | ||
53 | #define PORT 33445 | 53 | #define PORT 33445 |
54 | 54 | ||
55 | void print_assoc(IPPTsPng *assoc, uint8_t ours) | ||
56 | { | ||
57 | IP_Port *ipp = &assoc->ip_port; | ||
58 | printf("\nIP: %s Port: %u", ip_ntoa(&ipp->ip), ntohs(ipp->port)); | ||
59 | printf("\nTimestamp: %llu", (long long unsigned int) assoc->timestamp); | ||
60 | printf("\nLast pinged: %llu\n", (long long unsigned int) assoc->last_pinged); | ||
61 | |||
62 | ipp = &assoc->ret_ip_port; | ||
63 | if (ours) | ||
64 | printf("OUR IP: %s Port: %u\n", ip_ntoa(&ipp->ip), ntohs(ipp->port)); | ||
65 | else | ||
66 | printf("RET IP: %s Port: %u\n", ip_ntoa(&ipp->ip), ntohs(ipp->port)); | ||
67 | printf("Timestamp: %llu\n", (long long unsigned int) assoc->ret_timestamp); | ||
68 | } | ||
69 | |||
55 | void print_clientlist(DHT *dht) | 70 | void print_clientlist(DHT *dht) |
56 | { | 71 | { |
57 | uint32_t i, j; | 72 | uint32_t i, j; |
58 | IP_Port p_ip; | ||
59 | printf("___________________CLOSE________________________________\n"); | 73 | printf("___________________CLOSE________________________________\n"); |
60 | 74 | ||
61 | for (i = 0; i < LCLIENT_LIST; i++) { | 75 | for (i = 0; i < LCLIENT_LIST; i++) { |
76 | Client_data *client = &dht->close_clientlist[i]; | ||
62 | printf("ClientID: "); | 77 | printf("ClientID: "); |
63 | 78 | ||
64 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | 79 | for (j = 0; j < CLIENT_ID_SIZE; j++) { |
65 | printf("%02hhX", dht->close_clientlist[i].client_id[j]); | 80 | printf("%02hhX", client->client_id[j]); |
66 | } | 81 | } |
67 | 82 | ||
68 | p_ip = dht->close_clientlist[i].ip_port; | 83 | #ifdef CLIENT_ONETOONE_IP |
69 | printf("\nIP: %s Port: %u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); | 84 | print_assoc(&client->assoc, 1); |
70 | printf("\nTimestamp: %llu", (long long unsigned int) dht->close_clientlist[i].timestamp); | 85 | #else |
71 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->close_clientlist[i].last_pinged); | 86 | print_assoc(&client->assoc4, 1); |
72 | p_ip = dht->close_clientlist[i].ret_ip_port; | 87 | print_assoc(&client->assoc6, 1); |
73 | printf("OUR IP: %s Port: %u\n", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); | 88 | #endif |
74 | printf("Timestamp: %llu\n", (long long unsigned int) dht->close_clientlist[i].ret_timestamp); | ||
75 | } | 89 | } |
76 | } | 90 | } |
77 | 91 | ||
@@ -95,22 +109,22 @@ void print_friendlist(DHT *dht) | |||
95 | printf("\nCLIENTS IN LIST:\n\n"); | 109 | printf("\nCLIENTS IN LIST:\n\n"); |
96 | 110 | ||
97 | for (i = 0; i < MAX_FRIEND_CLIENTS; i++) { | 111 | for (i = 0; i < MAX_FRIEND_CLIENTS; i++) { |
112 | Client_data *client = &dht->friends_list[k].client_list[i]; | ||
98 | printf("ClientID: "); | 113 | printf("ClientID: "); |
99 | 114 | ||
100 | for (j = 0; j < CLIENT_ID_SIZE; j++) { | 115 | for (j = 0; j < CLIENT_ID_SIZE; j++) { |
101 | if (dht->friends_list[k].client_list[i].client_id[j] < 16) | 116 | if (client->client_id[j] < 16) |
102 | printf("0"); | 117 | printf("0"); |
103 | 118 | ||
104 | printf("%hhX", dht->friends_list[k].client_list[i].client_id[j]); | 119 | printf("%hhX", client->client_id[j]); |
105 | } | 120 | } |
106 | 121 | ||
107 | p_ip = dht->friends_list[k].client_list[i].ip_port; | 122 | #ifdef CLIENT_ONETOONE_IP |
108 | printf("\nIP: %s:%u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); | 123 | print_assoc(&client->assoc, 0); |
109 | printf("\nTimestamp: %llu", (long long unsigned int) dht->friends_list[k].client_list[i].timestamp); | 124 | #else |
110 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->friends_list[k].client_list[i].last_pinged); | 125 | print_assoc(&client->assoc4, 0); |
111 | p_ip = dht->friends_list[k].client_list[i].ret_ip_port; | 126 | print_assoc(&client->assoc6, 0); |
112 | printf("ret IP: %s:%u\n", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); | 127 | #endif |
113 | printf("Timestamp: %llu\n", (long long unsigned int)dht->friends_list[k].client_list[i].ret_timestamp); | ||
114 | } | 128 | } |
115 | } | 129 | } |
116 | } | 130 | } |