diff options
Diffstat (limited to 'testing/DHT_test.c')
-rw-r--r-- | testing/DHT_test.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 1eae74a0..799d31ad 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -80,7 +80,19 @@ void print_friendlist() | |||
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | void printpacket(char * data, uint32_t length, IP_Port ip_port) | |
84 | { | ||
85 | uint32_t i; | ||
86 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); | ||
87 | printf("--------------------BEGIN-----------------------------\n"); | ||
88 | for(i = 0; i < length; i++) | ||
89 | { | ||
90 | if(data[i] < 16) | ||
91 | printf("0"); | ||
92 | printf("%hhX",data[i]); | ||
93 | } | ||
94 | printf("\n--------------------END-----------------------------\n\n\n"); | ||
95 | } | ||
84 | 96 | ||
85 | int main(int argc, char *argv[]) | 97 | int main(int argc, char *argv[]) |
86 | { | 98 | { |
@@ -116,8 +128,6 @@ int main(int argc, char *argv[]) | |||
116 | char data[MAX_UDP_PACKET_SIZE]; | 128 | char data[MAX_UDP_PACKET_SIZE]; |
117 | uint32_t length; | 129 | uint32_t length; |
118 | 130 | ||
119 | uint32_t i; | ||
120 | |||
121 | while(1) | 131 | while(1) |
122 | { | 132 | { |
123 | 133 | ||
@@ -127,15 +137,8 @@ int main(int argc, char *argv[]) | |||
127 | { | 137 | { |
128 | if(DHT_handlepacket(data, length, ip_port)) | 138 | if(DHT_handlepacket(data, length, ip_port)) |
129 | { | 139 | { |
130 | printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length); | 140 | //unhandled packet |
131 | printf("--------------------BEGIN-----------------------------\n"); | 141 | printpacket(data, length, ip_port); |
132 | for(i = 0; i < length; i++) | ||
133 | { | ||
134 | if(data[i] < 16) | ||
135 | printf("0"); | ||
136 | printf("%hhX",data[i]); | ||
137 | } | ||
138 | printf("\n--------------------END-----------------------------\n\n\n"); | ||
139 | } | 142 | } |
140 | else | 143 | else |
141 | { | 144 | { |
@@ -147,8 +150,6 @@ int main(int argc, char *argv[]) | |||
147 | c_sleep(300); | 150 | c_sleep(300); |
148 | } | 151 | } |
149 | 152 | ||
150 | #ifdef WIN32 | 153 | shutdown_networking(); |
151 | WSACleanup(); | ||
152 | #endif | ||
153 | return 0; | 154 | return 0; |
154 | } \ No newline at end of file | 155 | } \ No newline at end of file |