diff options
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 82 |
1 files changed, 78 insertions, 4 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index aa32e3eb1..6e717470c 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -121,6 +121,16 @@ static GNUNET_SCHEDULER_TaskIdentifier ti_send; | |||
121 | 121 | ||
122 | const struct GNUNET_PeerIdentity * p; | 122 | const struct GNUNET_PeerIdentity * p; |
123 | 123 | ||
124 | |||
125 | /** | ||
126 | * Did the test pass or fail? | ||
127 | */ | ||
128 | static int fail_notify_address; | ||
129 | /** | ||
130 | * Did the test pass or fail? | ||
131 | */ | ||
132 | static int fail_notify_address_count; | ||
133 | |||
124 | /** | 134 | /** |
125 | * Did the test pass or fail? | 135 | * Did the test pass or fail? |
126 | */ | 136 | */ |
@@ -220,6 +230,45 @@ receive (void *cls, | |||
220 | return GNUNET_TIME_UNIT_ZERO; | 230 | return GNUNET_TIME_UNIT_ZERO; |
221 | } | 231 | } |
222 | 232 | ||
233 | |||
234 | /** | ||
235 | * Network format for IPv4 addresses. | ||
236 | */ | ||
237 | struct IPv4HttpAddress | ||
238 | { | ||
239 | /** | ||
240 | * IPv4 address, in network byte order. | ||
241 | */ | ||
242 | uint32_t ipv4_addr; | ||
243 | |||
244 | /** | ||
245 | * Port number, in network byte order. | ||
246 | */ | ||
247 | uint16_t u_port; | ||
248 | |||
249 | }; | ||
250 | |||
251 | |||
252 | /** | ||
253 | * Network format for IPv6 addresses. | ||
254 | */ | ||
255 | struct IPv6HttpAddress | ||
256 | { | ||
257 | /** | ||
258 | * IPv6 address. | ||
259 | */ | ||
260 | struct in6_addr ipv6_addr; | ||
261 | |||
262 | /** | ||
263 | * Port number, in network byte order. | ||
264 | */ | ||
265 | uint16_t u6_port; | ||
266 | |||
267 | }; | ||
268 | |||
269 | /** | ||
270 | * Plugin notifies transport (aka testcase) about its addresses | ||
271 | */ | ||
223 | void | 272 | void |
224 | notify_address (void *cls, | 273 | notify_address (void *cls, |
225 | const char *name, | 274 | const char *name, |
@@ -227,7 +276,27 @@ notify_address (void *cls, | |||
227 | uint16_t addrlen, | 276 | uint16_t addrlen, |
228 | struct GNUNET_TIME_Relative expires) | 277 | struct GNUNET_TIME_Relative expires) |
229 | { | 278 | { |
279 | char * address = NULL; | ||
280 | unsigned int port; | ||
230 | 281 | ||
282 | |||
283 | if (addrlen == (sizeof (struct IPv4HttpAddress))) | ||
284 | { | ||
285 | address = GNUNET_malloc (INET_ADDRSTRLEN); | ||
286 | inet_ntop(AF_INET, (struct in_addr *) addr,address,INET_ADDRSTRLEN); | ||
287 | port = ntohs(((struct IPv4HttpAddress *) addr)->u_port); | ||
288 | } | ||
289 | |||
290 | if (addrlen == (sizeof (struct IPv6HttpAddress))) | ||
291 | { | ||
292 | address = GNUNET_malloc (INET6_ADDRSTRLEN); | ||
293 | inet_ntop(AF_INET6, (struct in6_addr *) addr,address,INET6_ADDRSTRLEN); | ||
294 | port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port); | ||
295 | } | ||
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Transport plugin notification for address: `%s':%u\n"),address,port); | ||
297 | fail_notify_address_count++; | ||
298 | |||
299 | fail_notify_address = GNUNET_NO; | ||
231 | } | 300 | } |
232 | 301 | ||
233 | /** | 302 | /** |
@@ -308,8 +377,7 @@ run (void *cls, | |||
308 | if (my_private_key == NULL) | 377 | if (my_private_key == NULL) |
309 | { | 378 | { |
310 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 379 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
311 | _ | 380 | _("Transport service could not access hostkey. Exiting.\n")); |
312 | ("Transport service could not access hostkey. Exiting.\n")); | ||
313 | GNUNET_SCHEDULER_shutdown (s); | 381 | GNUNET_SCHEDULER_shutdown (s); |
314 | fail = 1; | 382 | fail = 1; |
315 | return; | 383 | return; |
@@ -335,12 +403,18 @@ run (void *cls, | |||
335 | ti_timeout = GNUNET_SCHEDULER_add_delayed (sched, TEST_TIMEOUT, &task_timeout, NULL); | 403 | ti_timeout = GNUNET_SCHEDULER_add_delayed (sched, TEST_TIMEOUT, &task_timeout, NULL); |
336 | 404 | ||
337 | /* testing plugin functionality */ | 405 | /* testing plugin functionality */ |
338 | 406 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transport plugin returned %u addresses to connect to\n"), fail_notify_address_count); | |
339 | 407 | ||
340 | /* testing finished, shutting down */ | 408 | /* testing finished, shutting down */ |
409 | |||
410 | if (fail_notify_address == GNUNET_NO) | ||
411 | fail = 0; | ||
412 | |||
413 | |||
414 | |||
341 | shutdown_clean(); | 415 | shutdown_clean(); |
342 | 416 | ||
343 | fail = 0; | 417 | |
344 | return; | 418 | return; |
345 | } | 419 | } |
346 | 420 | ||