summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-15 01:23:08 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-16 20:06:07 +0000
commit643eea60bb9dcf4ecb33d64666b1bc77cbfd7438 (patch)
tree2f98b0c7869fddac03f834be508a182da06f07b4 /testing
parent22db2b9fe581a35300b66126604d12e83c2eafb1 (diff)
Make DHT a module-private type.
Diffstat (limited to 'testing')
-rw-r--r--testing/DHT_test.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 6e65bf3a..c9d34238 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -49,7 +49,7 @@
49 49
50static uint8_t zeroes_cid[CRYPTO_PUBLIC_KEY_SIZE]; 50static uint8_t zeroes_cid[CRYPTO_PUBLIC_KEY_SIZE];
51 51
52static void print_client_id(uint8_t *public_key) 52static void print_client_id(const uint8_t *public_key)
53{ 53{
54 uint32_t j; 54 uint32_t j;
55 55
@@ -58,7 +58,7 @@ static void print_client_id(uint8_t *public_key)
58 } 58 }
59} 59}
60 60
61static void print_hardening(Hardening *h) 61static void print_hardening(const Hardening *h)
62{ 62{
63 printf("Hardening:\n"); 63 printf("Hardening:\n");
64 printf("routes_requests_ok: %hhu\n", h->routes_requests_ok); 64 printf("routes_requests_ok: %hhu\n", h->routes_requests_ok);
@@ -76,9 +76,9 @@ static void print_hardening(Hardening *h)
76 printf("\n\n"); 76 printf("\n\n");
77} 77}
78 78
79static void print_assoc(IPPTsPng *assoc, uint8_t ours) 79static void print_assoc(const IPPTsPng *assoc, uint8_t ours)
80{ 80{
81 IP_Port *ipp = &assoc->ip_port; 81 const IP_Port *ipp = &assoc->ip_port;
82 char ip_str[IP_NTOA_LEN]; 82 char ip_str[IP_NTOA_LEN];
83 printf("\nIP: %s Port: %u", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), net_ntohs(ipp->port)); 83 printf("\nIP: %s Port: %u", ip_ntoa(&ipp->ip, ip_str, sizeof(ip_str)), net_ntohs(ipp->port));
84 printf("\nTimestamp: %llu", (long long unsigned int) assoc->timestamp); 84 printf("\nTimestamp: %llu", (long long unsigned int) assoc->timestamp);
@@ -102,7 +102,7 @@ static void print_clientlist(DHT *dht)
102 printf("___________________CLOSE________________________________\n"); 102 printf("___________________CLOSE________________________________\n");
103 103
104 for (i = 0; i < LCLIENT_LIST; i++) { 104 for (i = 0; i < LCLIENT_LIST; i++) {
105 Client_data *client = &dht->close_clientlist[i]; 105 const Client_data *client = dht_get_close_client(dht, i);
106 106
107 if (public_key_cmp(client->public_key, zeroes_cid) == 0) { 107 if (public_key_cmp(client->public_key, zeroes_cid) == 0) {
108 continue; 108 continue;
@@ -122,20 +122,20 @@ static void print_friendlist(DHT *dht)
122 IP_Port p_ip; 122 IP_Port p_ip;
123 printf("_________________FRIENDS__________________________________\n"); 123 printf("_________________FRIENDS__________________________________\n");
124 124
125 for (k = 0; k < dht->num_friends; k++) { 125 for (k = 0; k < dht_get_num_friends(dht); k++) {
126 printf("FRIEND %u\n", k); 126 printf("FRIEND %u\n", k);
127 printf("ID: "); 127 printf("ID: ");
128 128
129 print_client_id(dht->friends_list[k].public_key); 129 print_client_id(dht_get_friend_public_key(dht, k));
130 130
131 int friendok = DHT_getfriendip(dht, dht->friends_list[k].public_key, &p_ip); 131 int friendok = DHT_getfriendip(dht, dht_get_friend_public_key(dht, k), &p_ip);
132 char ip_str[IP_NTOA_LEN]; 132 char ip_str[IP_NTOA_LEN];
133 printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip, ip_str, sizeof(ip_str)), net_ntohs(p_ip.port), friendok); 133 printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip, ip_str, sizeof(ip_str)), net_ntohs(p_ip.port), friendok);
134 134
135 printf("\nCLIENTS IN LIST:\n\n"); 135 printf("\nCLIENTS IN LIST:\n\n");
136 136
137 for (i = 0; i < MAX_FRIEND_CLIENTS; i++) { 137 for (i = 0; i < MAX_FRIEND_CLIENTS; i++) {
138 Client_data *client = &dht->friends_list[k].client_list[i]; 138 const Client_data *client = &dht_get_friend(dht, k)->client_list[i];
139 139
140 if (public_key_cmp(client->public_key, zeroes_cid) == 0) { 140 if (public_key_cmp(client->public_key, zeroes_cid) == 0) {
141 continue; 141 continue;
@@ -195,11 +195,13 @@ int main(int argc, char *argv[])
195 uint32_t i; 195 uint32_t i;
196 196
197 for (i = 0; i < 32; i++) { 197 for (i = 0; i < 32; i++) {
198 if (dht->self_public_key[i] < 16) { 198 const uint8_t *const self_public_key = dht_get_self_public_key(dht);
199
200 if (self_public_key[i] < 16) {
199 printf("0"); 201 printf("0");
200 } 202 }
201 203
202 printf("%hhX", dht->self_public_key[i]); 204 printf("%hhX", self_public_key[i]);
203 } 205 }
204 206
205 char temp_id[128]; 207 char temp_id[128];
@@ -250,7 +252,7 @@ int main(int argc, char *argv[])
250 } 252 }
251 253
252#endif 254#endif
253 networking_poll(dht->net, NULL); 255 networking_poll(dht_get_net(dht), NULL);
254 256
255 print_clientlist(dht); 257 print_clientlist(dht);
256 print_friendlist(dht); 258 print_friendlist(dht);