diff options
author | irungentoo <irungentoo@gmail.com> | 2013-06-26 07:40:07 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-06-26 07:40:07 -0400 |
commit | d1837342e027d4587221f7a68b387d14f39cdd59 (patch) | |
tree | 292b4ae5575247a40c83ae30cb97f75ec551a46a /testing | |
parent | 68d2995bce43bc1f52ac25ca52e0897baef8d111 (diff) |
Couple fixes.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/DHT_test.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 6bf4e4f2..53712e6e 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Compile with: gcc -Wall -o test ../core/DHT.c DHT_test.c | 4 | * Compile with: gcc -Wall -o test ../core/DHT.c DHT_test.c |
5 | * | 5 | * |
6 | * Command line arguments are the ip and port of a node and the client_id of the friend you want to find the ip_port of | 6 | * Command line arguments are the ip and port of a node and the client_id (32 bytes) of the friend you want to find the ip_port of |
7 | * EX: ./test 127.0.0.1 33445 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef | 7 | * EX: ./test 127.0.0.1 33445 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef |
8 | */ | 8 | */ |
9 | 9 | ||
@@ -60,14 +60,16 @@ void print_friendlist() | |||
60 | p_ip = getfriendip(friends_list[k].client_id); | 60 | p_ip = getfriendip(friends_list[k].client_id); |
61 | printf("\nIP: %u.%u.%u.%u:%u",p_ip.ip.c[0],p_ip.ip.c[1],p_ip.ip.c[2],p_ip.ip.c[3],ntohs(p_ip.port)); | 61 | printf("\nIP: %u.%u.%u.%u:%u",p_ip.ip.c[0],p_ip.ip.c[1],p_ip.ip.c[2],p_ip.ip.c[3],ntohs(p_ip.port)); |
62 | 62 | ||
63 | printf("\nCLIENTS IN LIST:\n\n "); | 63 | printf("\nCLIENTS IN LIST:\n\n"); |
64 | 64 | ||
65 | for(i = 0; i < 4; i++) | 65 | for(i = 0; i < 4; i++) |
66 | { | 66 | { |
67 | printf("ClientID: "); | 67 | printf("ClientID: "); |
68 | for(j = 0; j < 32; j++) | 68 | for(j = 0; j < 32; j++) |
69 | { | 69 | { |
70 | printf("%X", friends_list[k].client_list[i].client_id[j]); | 70 | if(0 <= friends_list[k].client_list[i].client_id[j] && friends_list[k].client_list[i].client_id[j] < 16) |
71 | printf("0"); | ||
72 | printf("%hhX", friends_list[k].client_list[i].client_id[j]); | ||
71 | } | 73 | } |
72 | p_ip = friends_list[k].client_list[i].ip_port; | 74 | p_ip = friends_list[k].client_list[i].ip_port; |
73 | printf("\nIP: %u.%u.%u.%u:%u",p_ip.ip.c[0],p_ip.ip.c[1],p_ip.ip.c[2],p_ip.ip.c[3],ntohs(p_ip.port)); | 75 | printf("\nIP: %u.%u.%u.%u:%u",p_ip.ip.c[0],p_ip.ip.c[1],p_ip.ip.c[2],p_ip.ip.c[3],ntohs(p_ip.port)); |
@@ -83,6 +85,7 @@ int main(int argc, char *argv[]) | |||
83 | srand(time(NULL)); | 85 | srand(time(NULL)); |
84 | int randdomnum = rand(); | 86 | int randdomnum = rand(); |
85 | memcpy(self_client_id, &randdomnum, 4); | 87 | memcpy(self_client_id, &randdomnum, 4); |
88 | //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); | ||
86 | 89 | ||
87 | #ifdef WIN32 | 90 | #ifdef WIN32 |
88 | WSADATA wsaData; | 91 | WSADATA wsaData; |
@@ -144,7 +147,7 @@ int main(int argc, char *argv[]) | |||
144 | { | 147 | { |
145 | if(data[i] < 16) | 148 | if(data[i] < 16) |
146 | printf("0"); | 149 | printf("0"); |
147 | printf("%X",data[i]); | 150 | printf("%hhX",data[i]); |
148 | } | 151 | } |
149 | printf("\n--------------------END-----------------------------\n\n\n"); | 152 | printf("\n--------------------END-----------------------------\n\n\n"); |
150 | } | 153 | } |