aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_plugin_transport_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r--src/transport/test_plugin_transport_http.c1163
1 files changed, 577 insertions, 586 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c
index 5ba8c573a..921f9ec32 100644
--- a/src/transport/test_plugin_transport_http.c
+++ b/src/transport/test_plugin_transport_http.c
@@ -75,12 +75,12 @@ struct Plugin_Address
75 /** 75 /**
76 * Next field for linked list 76 * Next field for linked list
77 */ 77 */
78 struct Plugin_Address * next; 78 struct Plugin_Address *next;
79 79
80 /** 80 /**
81 * buffer containing data to send 81 * buffer containing data to send
82 */ 82 */
83 void * addr; 83 void *addr;
84 84
85 /** 85 /**
86 * amount of data to sent 86 * amount of data to sent
@@ -162,9 +162,9 @@ struct HTTP_Transfer
162 */ 162 */
163struct IPv4HttpAddress 163struct IPv4HttpAddress
164{ 164{
165 struct IPv4HttpAddress * next; 165 struct IPv4HttpAddress *next;
166 166
167 struct IPv4HttpAddress * prev; 167 struct IPv4HttpAddress *prev;
168 168
169 /** 169 /**
170 * IPv4 address, in network byte order. 170 * IPv4 address, in network byte order.
@@ -184,9 +184,9 @@ struct IPv4HttpAddress
184 */ 184 */
185struct IPv6HttpAddress 185struct IPv6HttpAddress
186{ 186{
187 struct IPv6HttpAddress * next; 187 struct IPv6HttpAddress *next;
188 188
189 struct IPv6HttpAddress * prev; 189 struct IPv6HttpAddress *prev;
190 190
191 /** 191 /**
192 * IPv6 address. 192 * IPv6 address.
@@ -229,7 +229,7 @@ static long long unsigned int port;
229/** 229/**
230 * Peer's addr 230 * Peer's addr
231 */ 231 */
232static char * test_addr; 232static char *test_addr;
233 233
234/** 234/**
235 * Our statistics handle. 235 * Our statistics handle.
@@ -277,12 +277,13 @@ static struct HTTP_Message buffer_out;
277static struct HTTP_Message buffer_in; 277static struct HTTP_Message buffer_in;
278 278
279 279
280struct Plugin_Address * addr_head; 280struct Plugin_Address *addr_head;
281 281
282/** 282/**
283 * Did the test pass or fail? 283 * Did the test pass or fail?
284 */ 284 */
285static int fail_notify_address; 285static int fail_notify_address;
286
286/** 287/**
287 * Did the test pass or fail? 288 * Did the test pass or fail?
288 */ 289 */
@@ -386,7 +387,7 @@ static CURLM *multi_handle;
386 */ 387 */
387static GNUNET_SCHEDULER_TaskIdentifier http_task_send; 388static GNUNET_SCHEDULER_TaskIdentifier http_task_send;
388 389
389static char * servicehome; 390static char *servicehome;
390 391
391/** 392/**
392 * Shutdown testcase 393 * Shutdown testcase
@@ -394,53 +395,51 @@ static char * servicehome;
394static void 395static void
395shutdown_clean () 396shutdown_clean ()
396{ 397{
397 struct Plugin_Address * tmp; 398 struct Plugin_Address *tmp;
398 399
399 /* Evaluate results */ 400 /* Evaluate results */
400 fail = 0; 401 fail = 0;
401 if ( (fail_notify_address == GNUNET_YES) || 402 if ((fail_notify_address == GNUNET_YES) ||
402 (fail_pretty_printer == GNUNET_YES) || 403 (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES))
403 (fail_addr_to_str == GNUNET_YES)) 404 {
404 { 405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 406 "Phase 0: Test plugin functions failed\n");
406 "Phase 0: Test plugin functions failed\n"); 407 fail = 1;
407 fail = 1; 408 }
408 } 409 if ((test_no_ident.test_failed == GNUNET_YES) ||
409 if ( (test_no_ident.test_failed == GNUNET_YES) || 410 (test_too_short_ident.test_failed == GNUNET_YES) ||
410 (test_too_short_ident.test_failed == GNUNET_YES) || 411 (test_too_long_ident.test_failed == GNUNET_YES) ||
411 (test_too_long_ident.test_failed == GNUNET_YES) || 412 (test_valid_ident.test_failed == GNUNET_YES))
412 (test_valid_ident.test_failed == GNUNET_YES) )
413 { 413 {
414 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 414 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
415 "Phase 1: Test connect with wrong data failed\n"); 415 "Phase 1: Test connect with wrong data failed\n");
416 fail = 1; 416 fail = 1;
417 } 417 }
418 if ( (fail_session_selection_any != GNUNET_NO) || 418 if ((fail_session_selection_any != GNUNET_NO) ||
419 (fail_session_selection_reliable != GNUNET_NO) || 419 (fail_session_selection_reliable != GNUNET_NO) ||
420 (fail_session_selection_session != GNUNET_NO) || 420 (fail_session_selection_session != GNUNET_NO) ||
421 (fail_session_selection_session_big != GNUNET_NO) ) 421 (fail_session_selection_session_big != GNUNET_NO))
422 { 422 {
423 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 423 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
424 "Phase 2: Test session selection failed\n"); 424 "Phase 2: Test session selection failed\n");
425 fail = 1; 425 fail = 1;
426 } 426 }
427 if ( (fail_msgs_transmited_to_local_addrs != count_str_addr) || 427 if ((fail_msgs_transmited_to_local_addrs != count_str_addr) ||
428 (fail_multiple_msgs_in_transmission != 2) || 428 (fail_multiple_msgs_in_transmission != 2) ||
429 (fail_msg_transmited_max_size == GNUNET_YES) ) 429 (fail_msg_transmited_max_size == GNUNET_YES))
430 { 430 {
431 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 431 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
432 "Phase 3: Test sending with plugin failed\n"); 432 "Phase 3: Test sending with plugin failed\n");
433 fail = 1; 433 fail = 1;
434 } 434 }
435 if (fail != 1) 435 if (fail != 1)
436 { 436 {
437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All tests successful\n");
438 "All tests successful\n"); 438 }
439 } 439
440 440 api->disconnect (api->cls, &my_identity);
441 api->disconnect(api->cls,&my_identity);
442 441
443 curl_multi_cleanup(multi_handle); 442 curl_multi_cleanup (multi_handle);
444 443
445 if (NULL != curl_handle) 444 if (NULL != curl_handle)
446 curl_easy_cleanup (curl_handle); 445 curl_easy_cleanup (curl_handle);
@@ -451,37 +450,37 @@ shutdown_clean ()
451 tmp = addr_head->next; 450 tmp = addr_head->next;
452 GNUNET_free (addr_head->addr); 451 GNUNET_free (addr_head->addr);
453 GNUNET_free (addr_head); 452 GNUNET_free (addr_head);
454 addr_head=tmp; 453 addr_head = tmp;
455 } 454 }
456 455
457 if (ti_send != GNUNET_SCHEDULER_NO_TASK) 456 if (ti_send != GNUNET_SCHEDULER_NO_TASK)
458 { 457 {
459 GNUNET_SCHEDULER_cancel(ti_send); 458 GNUNET_SCHEDULER_cancel (ti_send);
460 ti_send = GNUNET_SCHEDULER_NO_TASK; 459 ti_send = GNUNET_SCHEDULER_NO_TASK;
461 } 460 }
462 461
463 if (http_task_send != GNUNET_SCHEDULER_NO_TASK) 462 if (http_task_send != GNUNET_SCHEDULER_NO_TASK)
464 { 463 {
465 GNUNET_SCHEDULER_cancel(http_task_send); 464 GNUNET_SCHEDULER_cancel (http_task_send);
466 http_task_send = GNUNET_SCHEDULER_NO_TASK; 465 http_task_send = GNUNET_SCHEDULER_NO_TASK;
467 } 466 }
468 467
469 if (ti_timeout != GNUNET_SCHEDULER_NO_TASK) 468 if (ti_timeout != GNUNET_SCHEDULER_NO_TASK)
470 { 469 {
471 GNUNET_SCHEDULER_cancel(ti_timeout); 470 GNUNET_SCHEDULER_cancel (ti_timeout);
472 ti_timeout = GNUNET_SCHEDULER_NO_TASK; 471 ti_timeout = GNUNET_SCHEDULER_NO_TASK;
473 } 472 }
474 473
475 GNUNET_free(test_addr); 474 GNUNET_free (test_addr);
476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n");
477 "Unloading http plugin\n"); 476 GNUNET_assert (NULL ==
478 GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api)); 477 GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http",
478 api));
479 479
480 GNUNET_SCHEDULER_shutdown(); 480 GNUNET_SCHEDULER_shutdown ();
481 GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http"); 481 GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http");
482 482
483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n");
484 "Exiting testcase\n");
485 484
486 if (servicehome != NULL) 485 if (servicehome != NULL)
487 { 486 {
@@ -489,7 +488,7 @@ shutdown_clean ()
489 GNUNET_free (servicehome); 488 GNUNET_free (servicehome);
490 } 489 }
491 490
492 exit(fail); 491 exit (fail);
493 return; 492 return;
494} 493}
495 494
@@ -502,102 +501,98 @@ shutdown_clean ()
502 */ 501 */
503 502
504static void 503static void
505task_send_cont (void *cls, 504task_send_cont (void *cls, const struct GNUNET_PeerIdentity *target, int result)
506 const struct GNUNET_PeerIdentity * target,
507 int result)
508{ 505{
509 if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR)) 506 if ((cls == &fail_msg_transmited_bigger_max_size) &&
510 { 507 (result == GNUNET_SYSERR))
511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 508 {
512 "Message bigger max msg size was not sent!\n"); 509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
513 fail_msg_transmited_bigger_max_size = GNUNET_NO; 510 "Message bigger max msg size was not sent!\n");
514 return; 511 fail_msg_transmited_bigger_max_size = GNUNET_NO;
515 } 512 return;
513 }
516 514
517 if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK)) 515 if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK))
518 { 516 {
519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
520 "Message with max msg size succesfully sent!\n", 518 "Message with max msg size succesfully sent!\n",
521 fail_msgs_transmited_to_local_addrs); 519 fail_msgs_transmited_to_local_addrs);
522 fail_msg_transmited_max_size = GNUNET_NO; 520 fail_msg_transmited_max_size = GNUNET_NO;
523 } 521 }
524} 522}
525 523
526 524
527static void run_connection_tests( int phase , void * cls); 525static void run_connection_tests (int phase, void *cls);
528 526
529/** 527/**
530 * Recieves messages from plugin, in real world transport 528 * Recieves messages from plugin, in real world transport
531 */ 529 */
532static struct GNUNET_TIME_Relative 530static struct GNUNET_TIME_Relative
533receive (void *cls, const struct GNUNET_PeerIdentity *peer, 531receive (void *cls, const struct GNUNET_PeerIdentity *peer,
534 const struct GNUNET_MessageHeader *message, 532 const struct GNUNET_MessageHeader *message,
535 const struct GNUNET_TRANSPORT_ATS_Information *ats, 533 const struct GNUNET_TRANSPORT_ATS_Information *ats,
536 uint32_t ats_count, 534 uint32_t ats_count,
537 struct Session *session, 535 struct Session *session,
538 const char *sender_address, 536 const char *sender_address, uint16_t sender_address_len)
539 uint16_t sender_address_len)
540{ 537{
541 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
542 "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", 539 "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n",
543 GNUNET_i2s(peer), 540 GNUNET_i2s (peer),
544 ntohs(message->type), 541 ntohs (message->type), ntohs (message->size), session);
545 ntohs(message->size),
546 session);
547 542
548 if ( (ntohs(message->type)>=10) && 543 if ((ntohs (message->type) >= 10) && (ntohs (message->type) < 20))
549 (ntohs(message->type)<20) ) 544 {
550 { 545 fail_msgs_transmited_to_local_addrs++;
551 fail_msgs_transmited_to_local_addrs++; 546 if (fail_msgs_transmited_to_local_addrs == count_str_addr)
552 if (fail_msgs_transmited_to_local_addrs == count_str_addr) 547 run_connection_tests (2, session);
553 run_connection_tests(2, session); 548 }
554 } 549 if ((ntohs (message->type) == 20))
555 if ((ntohs(message->type)==20)) 550 {
556 { 551 fail_session_selection_reliable = GNUNET_NO;
557 fail_session_selection_reliable = GNUNET_NO; 552 }
558 } 553 if ((ntohs (message->type) == 21))
559 if ((ntohs(message->type)==21)) 554 {
560 { 555 fail_session_selection_any = GNUNET_NO;
561 fail_session_selection_any = GNUNET_NO; 556 }
562 } 557 if ((ntohs (message->type) == 22))
563 if ((ntohs(message->type)==22)) 558 {
564 { 559 fail_session_selection_session = GNUNET_NO;
565 fail_session_selection_session = GNUNET_NO; 560 }
566 } 561 if ((ntohs (message->type) == 23))
567 if ((ntohs(message->type)==23)) 562 {
568 { 563 fail_session_selection_session_big = GNUNET_NO;
569 fail_session_selection_session_big = GNUNET_NO; 564 run_connection_tests (3, NULL);
570 run_connection_tests(3, NULL); 565 }
571 } 566 if ((ntohs (message->type) == 30) || (ntohs (message->type) == 31))
572 if ((ntohs(message->type)==30) || (ntohs(message->type)==31)) 567 {
573 { 568 fail_multiple_msgs_in_transmission++;
574 fail_multiple_msgs_in_transmission ++; 569 }
575 } 570 if ((ntohs (message->type) == 32) &&
576 if ((ntohs(message->type)==32) && (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1)) 571 (ntohs (message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE - 1))
577 { 572 {
578 fail_msg_transmited_max_size = GNUNET_NO; 573 fail_msg_transmited_max_size = GNUNET_NO;
579 shutdown_clean(); 574 shutdown_clean ();
580 } 575 }
581 return GNUNET_TIME_UNIT_ZERO; 576 return GNUNET_TIME_UNIT_ZERO;
582} 577}
583 578
584 579
585static size_t 580static size_t
586send_function (void *stream, size_t size, size_t nmemb, void *ptr) 581send_function (void *stream, size_t size, size_t nmemb, void *ptr)
587{ 582{
588 unsigned int len; 583 unsigned int len;
589 584
590 len = buffer_out.len; 585 len = buffer_out.len;
591 586
592 if (( buffer_out.pos == len) || (len > (size * nmemb))) 587 if ((buffer_out.pos == len) || (len > (size * nmemb)))
593 return 0; 588 return 0;
594 memcpy(stream, buffer_out.buf, len); 589 memcpy (stream, buffer_out.buf, len);
595 buffer_out.pos = len; 590 buffer_out.pos = len;
596 return len; 591 return len;
597 592
598} 593}
599 594
600static size_t 595static size_t
601recv_function (void *ptr, size_t size, size_t nmemb, void *ctx) 596recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
602{ 597{
603 598
@@ -613,54 +608,50 @@ recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
613} 608}
614 609
615static size_t 610static size_t
616header_function( void *ptr, size_t size, size_t nmemb, void *stream) 611header_function (void *ptr, size_t size, size_t nmemb, void *stream)
617{ 612{
618 struct HTTP_Transfer * res = stream; 613 struct HTTP_Transfer *res = stream;
619 char * tmp; 614 char *tmp;
620 unsigned int len = size * nmemb; 615 unsigned int len = size * nmemb;
621 616
622 tmp = GNUNET_malloc ( len+1 ); 617 tmp = GNUNET_malloc (len + 1);
623 memcpy(tmp,ptr,len); 618 memcpy (tmp, ptr, len);
624 if (tmp[len-2] == 13) 619 if (tmp[len - 2] == 13)
625 tmp[len-2]= '\0'; 620 tmp[len - 2] = '\0';
626#if DEBUG_CURL 621#if DEBUG_CURL
627 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Header: `%s'\n", tmp);
628 "Header: `%s'\n",
629 tmp);
630#endif 623#endif
631 if (0==strcmp (tmp,"HTTP/1.1 100 Continue")) 624 if (0 == strcmp (tmp, "HTTP/1.1 100 Continue"))
632 { 625 {
633 res->http_result_code=100; 626 res->http_result_code = 100;
634 } 627 }
635 if (0==strcmp (tmp,"HTTP/1.1 200 OK")) 628 if (0 == strcmp (tmp, "HTTP/1.1 200 OK"))
636 { 629 {
637 res->http_result_code=200; 630 res->http_result_code = 200;
638 } 631 }
639 if (0==strcmp (tmp,"HTTP/1.1 400 Bad Request")) 632 if (0 == strcmp (tmp, "HTTP/1.1 400 Bad Request"))
640 { 633 {
641 res->http_result_code=400; 634 res->http_result_code = 400;
642 } 635 }
643 if (0==strcmp (tmp,"HTTP/1.1 404 Not Found")) 636 if (0 == strcmp (tmp, "HTTP/1.1 404 Not Found"))
644 { 637 {
645 res->http_result_code=404; 638 res->http_result_code = 404;
646 } 639 }
647 if (0==strcmp (tmp,"HTTP/1.1 413 Request entity too large")) 640 if (0 == strcmp (tmp, "HTTP/1.1 413 Request entity too large"))
648 { 641 {
649 res->http_result_code=413; 642 res->http_result_code = 413;
650 } 643 }
651 644
652 GNUNET_free (tmp); 645 GNUNET_free (tmp);
653 return size * nmemb; 646 return size * nmemb;
654} 647}
655 648
656 649
657static size_t 650static size_t send_prepare (struct HTTP_Transfer *result);
658send_prepare( struct HTTP_Transfer * result);
659 651
660 652
661static void 653static void
662send_execute (void *cls, 654send_execute (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
663 const struct GNUNET_SCHEDULER_TaskContext *tc)
664{ 655{
665 struct HTTP_Transfer *res; 656 struct HTTP_Transfer *res;
666 657
@@ -674,104 +665,106 @@ send_execute (void *cls,
674 return; 665 return;
675 666
676 do 667 do
668 {
669 running = 0;
670 mret = curl_multi_perform (multi_handle, &running);
671 if (running == 0)
677 { 672 {
678 running = 0; 673 do
679 mret = curl_multi_perform (multi_handle, &running); 674 {
680 if (running == 0)
681 {
682 do
683 {
684 675
685 msg = curl_multi_info_read (multi_handle, &running); 676 msg = curl_multi_info_read (multi_handle, &running);
686 if (msg == NULL) 677 if (msg == NULL)
687 break; 678 break;
688 /* get session for affected curl handle */ 679 /* get session for affected curl handle */
689 //cs = find_session_by_curlhandle (msg->easy_handle); 680 //cs = find_session_by_curlhandle (msg->easy_handle);
690 //GNUNET_assert ( cs != NULL ); 681 //GNUNET_assert ( cs != NULL );
691 switch (msg->msg) 682 switch (msg->msg)
692 { 683 {
693
694 case CURLMSG_DONE:
695 if ( (msg->data.result != CURLE_OK) &&
696 (msg->data.result != CURLE_GOT_NOTHING) )
697 {
698
699 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
700 _("curl failed for `%s' at %s:%d: `%s'\n"),
701 "curl_multi_perform",
702 __FILE__,
703 __LINE__,
704 curl_easy_strerror (msg->data.result));
705 /* sending msg failed*/
706 curl_easy_cleanup(curl_handle);
707 curl_handle=NULL;
708
709 run_connection_tests(0, NULL);
710 }
711 if (res == &test_no_ident)
712 {
713 if ((res->http_result_code==404) && (buffer_in.len==208))
714 {
715 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
716 "Connecting to peer without any peer identification: test passed\n");
717 res->test_failed = GNUNET_NO;
718 }
719 else
720 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
721 _("Connecting to peer without any peer identification: test failed\n"));
722 }
723 if (res == &test_too_short_ident)
724 {
725 if ((res->http_result_code==404) && (buffer_in.len==208))
726 {
727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
728 "Connecting to peer with too short peer identification: test passed\n");
729 res->test_failed = GNUNET_NO;
730 }
731 else
732 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
733 _("Connecting to peer with too short peer identification: test failed\n"));
734 }
735 if (res == &test_too_long_ident)
736 {
737 if ((res->http_result_code==404) && (buffer_in.len==208))
738 {
739 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
740 "Connecting to peer with too long peer identification: test passed\n");
741 res->test_failed = GNUNET_NO;
742 }
743 else
744 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
745 _("Connecting to peer with too long peer identification: test failed\n"));
746 }
747 if (res == &test_valid_ident)
748 {
749 if ((res->http_result_code==200))
750 {
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
752 "Connecting to peer with valid peer identification: test passed\n");
753 res->test_failed = GNUNET_NO;
754 }
755 else
756 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
757 "Connecting to peer with valid peer identification: test failed\n");
758 }
759 curl_easy_cleanup(curl_handle);
760 curl_handle=NULL;
761 if ((res == &test_valid_ident) && (res->test_failed == GNUNET_NO))
762 run_connection_tests(1, NULL);
763 run_connection_tests(0, NULL);
764 return;
765 default:
766 break;
767 }
768 684
685 case CURLMSG_DONE:
686 if ((msg->data.result != CURLE_OK) &&
687 (msg->data.result != CURLE_GOT_NOTHING))
688 {
689
690 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
691 _("curl failed for `%s' at %s:%d: `%s'\n"),
692 "curl_multi_perform",
693 __FILE__,
694 __LINE__, curl_easy_strerror (msg->data.result));
695 /* sending msg failed */
696 curl_easy_cleanup (curl_handle);
697 curl_handle = NULL;
698
699 run_connection_tests (0, NULL);
700 }
701 if (res == &test_no_ident)
702 {
703 if ((res->http_result_code == 404) && (buffer_in.len == 208))
704 {
705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
706 "Connecting to peer without any peer identification: test passed\n");
707 res->test_failed = GNUNET_NO;
708 }
709 else
710 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
711 _
712 ("Connecting to peer without any peer identification: test failed\n"));
713 }
714 if (res == &test_too_short_ident)
715 {
716 if ((res->http_result_code == 404) && (buffer_in.len == 208))
717 {
718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
719 "Connecting to peer with too short peer identification: test passed\n");
720 res->test_failed = GNUNET_NO;
721 }
722 else
723 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
724 _
725 ("Connecting to peer with too short peer identification: test failed\n"));
726 }
727 if (res == &test_too_long_ident)
728 {
729 if ((res->http_result_code == 404) && (buffer_in.len == 208))
730 {
731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
732 "Connecting to peer with too long peer identification: test passed\n");
733 res->test_failed = GNUNET_NO;
769 } 734 }
770 while ( (running > 0) ); 735 else
736 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
737 _
738 ("Connecting to peer with too long peer identification: test failed\n"));
739 }
740 if (res == &test_valid_ident)
741 {
742 if ((res->http_result_code == 200))
743 {
744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
745 "Connecting to peer with valid peer identification: test passed\n");
746 res->test_failed = GNUNET_NO;
747 }
748 else
749 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
750 "Connecting to peer with valid peer identification: test failed\n");
751 }
752 curl_easy_cleanup (curl_handle);
753 curl_handle = NULL;
754 if ((res == &test_valid_ident) && (res->test_failed == GNUNET_NO))
755 run_connection_tests (1, NULL);
756 run_connection_tests (0, NULL);
757 return;
758 default:
759 break;
771 } 760 }
761
762 }
763 while ((running > 0));
772 } 764 }
765 }
773 while (mret == CURLM_CALL_MULTI_PERFORM); 766 while (mret == CURLM_CALL_MULTI_PERFORM);
774 send_prepare(cls); 767 send_prepare (cls);
775} 768}
776 769
777 770
@@ -781,7 +774,7 @@ send_execute (void *cls,
781 * @return bytes sent to peer 774 * @return bytes sent to peer
782 */ 775 */
783static size_t 776static size_t
784send_prepare( struct HTTP_Transfer * result) 777send_prepare (struct HTTP_Transfer *result)
785{ 778{
786 fd_set rs; 779 fd_set rs;
787 fd_set ws; 780 fd_set ws;
@@ -798,34 +791,33 @@ send_prepare( struct HTTP_Transfer * result)
798 FD_ZERO (&es); 791 FD_ZERO (&es);
799 mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max); 792 mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max);
800 if (mret != CURLM_OK) 793 if (mret != CURLM_OK)
801 { 794 {
802 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 795 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
803 _("%s failed at %s:%d: `%s'\n"), 796 _("%s failed at %s:%d: `%s'\n"),
804 "curl_multi_fdset", __FILE__, __LINE__, 797 "curl_multi_fdset", __FILE__, __LINE__,
805 curl_multi_strerror (mret)); 798 curl_multi_strerror (mret));
806 return -1; 799 return -1;
807 } 800 }
808 mret = curl_multi_timeout (multi_handle, &to); 801 mret = curl_multi_timeout (multi_handle, &to);
809 if (mret != CURLM_OK) 802 if (mret != CURLM_OK)
810 { 803 {
811 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 804 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
812 _("%s failed at %s:%d: `%s'\n"), 805 _("%s failed at %s:%d: `%s'\n"),
813 "curl_multi_timeout", __FILE__, __LINE__, 806 "curl_multi_timeout", __FILE__, __LINE__,
814 curl_multi_strerror (mret)); 807 curl_multi_strerror (mret));
815 return -1; 808 return -1;
816 } 809 }
817 810
818 grs = GNUNET_NETWORK_fdset_create (); 811 grs = GNUNET_NETWORK_fdset_create ();
819 gws = GNUNET_NETWORK_fdset_create (); 812 gws = GNUNET_NETWORK_fdset_create ();
820 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); 813 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
821 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); 814 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
822 http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 815 http_task_send =
823 GNUNET_SCHEDULER_NO_TASK, 816 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
824 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), 817 GNUNET_SCHEDULER_NO_TASK,
825 grs, 818 GNUNET_TIME_relative_multiply
826 gws, 819 (GNUNET_TIME_UNIT_SECONDS, 0), grs, gws,
827 &send_execute, 820 &send_execute, result);
828 result);
829 GNUNET_NETWORK_fdset_destroy (gws); 821 GNUNET_NETWORK_fdset_destroy (gws);
830 GNUNET_NETWORK_fdset_destroy (grs); 822 GNUNET_NETWORK_fdset_destroy (grs);
831 823
@@ -836,35 +828,35 @@ send_prepare( struct HTTP_Transfer * result)
836/** 828/**
837 * function to send data to server 829 * function to send data to server
838 */ 830 */
839static int 831static int
840send_data(struct HTTP_Transfer * result, 832send_data (struct HTTP_Transfer *result, char *url)
841 char * url)
842{ 833{
843 834
844 curl_handle = curl_easy_init(); 835 curl_handle = curl_easy_init ();
845 if( NULL == curl_handle) 836 if (NULL == curl_handle)
846 { 837 {
847 printf("easy_init failed \n"); 838 printf ("easy_init failed \n");
848 return GNUNET_SYSERR; 839 return GNUNET_SYSERR;
849 } 840 }
850#if DEBUG_CURL 841#if DEBUG_CURL
851 curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); 842 curl_easy_setopt (curl_handle, CURLOPT_VERBOSE, 1L);
852#endif 843#endif
853 curl_easy_setopt(curl_handle, CURLOPT_URL, url); 844 curl_easy_setopt (curl_handle, CURLOPT_URL, url);
854 curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L); 845 curl_easy_setopt (curl_handle, CURLOPT_PUT, 1L);
855 curl_easy_setopt (curl_handle, CURLOPT_HEADERFUNCTION, &header_function); 846 curl_easy_setopt (curl_handle, CURLOPT_HEADERFUNCTION, &header_function);
856 curl_easy_setopt (curl_handle, CURLOPT_WRITEHEADER, result); 847 curl_easy_setopt (curl_handle, CURLOPT_WRITEHEADER, result);
857 curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, &recv_function); 848 curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, &recv_function);
858 curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, result); 849 curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, result);
859 curl_easy_setopt (curl_handle, CURLOPT_READFUNCTION, &send_function); 850 curl_easy_setopt (curl_handle, CURLOPT_READFUNCTION, &send_function);
860 curl_easy_setopt (curl_handle, CURLOPT_READDATA, result); 851 curl_easy_setopt (curl_handle, CURLOPT_READDATA, result);
861 curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t) buffer_out.len); 852 curl_easy_setopt (curl_handle, CURLOPT_INFILESIZE_LARGE,
862 curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 30); 853 (curl_off_t) buffer_out.len);
863 curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 20); 854 curl_easy_setopt (curl_handle, CURLOPT_TIMEOUT, 30);
855 curl_easy_setopt (curl_handle, CURLOPT_CONNECTTIMEOUT, 20);
864 856
865 curl_multi_add_handle(multi_handle, curl_handle); 857 curl_multi_add_handle (multi_handle, curl_handle);
866 858
867 send_prepare(result); 859 send_prepare (result);
868 860
869 return GNUNET_OK; 861 return GNUNET_OK;
870} 862}
@@ -873,58 +865,54 @@ send_data(struct HTTP_Transfer * result,
873 * Plugin notifies transport (aka testcase) about its addresses 865 * Plugin notifies transport (aka testcase) about its addresses
874 */ 866 */
875static void 867static void
876notify_address (void *cls, 868notify_address (void *cls, int add_remove, const void *addr, size_t addrlen)
877 int add_remove,
878 const void *addr,
879 size_t addrlen)
880{ 869{
881 char address[INET6_ADDRSTRLEN]; 870 char address[INET6_ADDRSTRLEN];
882 unsigned int port; 871 unsigned int port;
883 struct Plugin_Address * pl_addr; 872 struct Plugin_Address *pl_addr;
884 struct Plugin_Address * cur; 873 struct Plugin_Address *cur;
885 874
886 if (addrlen == (sizeof (struct IPv4HttpAddress))) 875 if (addrlen == (sizeof (struct IPv4HttpAddress)))
887 { 876 {
888 inet_ntop(AF_INET, (struct in_addr *) addr,address,INET_ADDRSTRLEN); 877 inet_ntop (AF_INET, (struct in_addr *) addr, address, INET_ADDRSTRLEN);
889 port = ntohs(((struct IPv4HttpAddress *) addr)->u_port); 878 port = ntohs (((struct IPv4HttpAddress *) addr)->u_port);
890 } 879 }
891 else if (addrlen == (sizeof (struct IPv6HttpAddress))) 880 else if (addrlen == (sizeof (struct IPv6HttpAddress)))
892 { 881 {
893 inet_ntop(AF_INET6, (struct in6_addr *) addr,address,INET6_ADDRSTRLEN); 882 inet_ntop (AF_INET6, (struct in6_addr *) addr, address, INET6_ADDRSTRLEN);
894 port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port); 883 port = ntohs (((struct IPv6HttpAddress *) addr)->u6_port);
895 } 884 }
896 else 885 else
897 { 886 {
898 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
899 _("Unknown address size: ipv6 has %u ipv4 has %u but this has %u\n"), 888 _
889 ("Unknown address size: ipv6 has %u ipv4 has %u but this has %u\n"),
900 sizeof (struct IPv6HttpAddress), 890 sizeof (struct IPv6HttpAddress),
901 sizeof (struct IPv4HttpAddress), 891 sizeof (struct IPv4HttpAddress), addrlen);
902 addrlen); 892 return;
903 return; 893 }
904 }
905 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
906 _("Transport plugin notification for address: `%s':%u\n"), 895 _("Transport plugin notification for address: `%s':%u\n"),
907 address, 896 address, port);
908 port); 897 pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address));
909 pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address) );
910 pl_addr->addrlen = addrlen; 898 pl_addr->addrlen = addrlen;
911 pl_addr->addr = GNUNET_malloc(addrlen); 899 pl_addr->addr = GNUNET_malloc (addrlen);
912 memcpy(pl_addr->addr,addr,addrlen); 900 memcpy (pl_addr->addr, addr, addrlen);
913 pl_addr->next = NULL; 901 pl_addr->next = NULL;
914 902
915 if ( NULL == addr_head) 903 if (NULL == addr_head)
916 { 904 {
917 addr_head = pl_addr; 905 addr_head = pl_addr;
918 } 906 }
919 else 907 else
908 {
909 cur = addr_head;
910 while (NULL != cur->next)
920 { 911 {
921 cur = addr_head; 912 cur = cur->next;
922 while (NULL != cur->next)
923 {
924 cur = cur->next;
925 }
926 cur->next = pl_addr;
927 } 913 }
914 cur->next = pl_addr;
915 }
928 fail_notify_address_count++; 916 fail_notify_address_count++;
929 fail_notify_address = GNUNET_NO; 917 fail_notify_address = GNUNET_NO;
930} 918}
@@ -936,8 +924,7 @@ plugin_env_session_end (void *cls,
936{ 924{
937 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
938 "Pluging tells me: session %X to peer `%s' ended\n", 926 "Pluging tells me: session %X to peer `%s' ended\n",
939 session, 927 session, GNUNET_i2s (peer));
940 GNUNET_i2s(peer));
941} 928}
942 929
943 930
@@ -962,8 +949,7 @@ setup_plugin_environment ()
962 * Task shutting down testcase if it a timeout occurs 949 * Task shutting down testcase if it a timeout occurs
963 */ 950 */
964static void 951static void
965task_timeout (void *cls, 952task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
966 const struct GNUNET_SCHEDULER_TaskContext *tc)
967{ 953{
968 ti_timeout = GNUNET_SCHEDULER_NO_TASK; 954 ti_timeout = GNUNET_SCHEDULER_NO_TASK;
969 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 955 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
@@ -971,35 +957,34 @@ task_timeout (void *cls,
971 957
972 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase timeout\n"); 958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase timeout\n");
973 fail = GNUNET_YES; 959 fail = GNUNET_YES;
974 shutdown_clean(); 960 shutdown_clean ();
975 return; 961 return;
976} 962}
977 963
978 964
979static void 965static void
980pretty_printer_cb (void *cls, 966pretty_printer_cb (void *cls, const char *address)
981 const char *address)
982{ 967{
983 if (NULL==address) 968 if (NULL == address)
984 return; 969 return;
985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
986 "Plugin returned pretty address: `%s'\n", 971 "Plugin returned pretty address: `%s'\n", address);
987 address);
988 fail_pretty_printer_count++; 972 fail_pretty_printer_count++;
989} 973}
990 974
991/** 975/**
992 * Runs every single test to test the plugin 976 * Runs every single test to test the plugin
993 */ 977 */
994static void 978static void
995run_connection_tests( int phase , void * cls) 979run_connection_tests (int phase, void *cls)
996{ 980{
997 struct GNUNET_MessageHeader * msg; 981 struct GNUNET_MessageHeader *msg;
998 unsigned int size; 982 unsigned int size;
999 983
1000 if (phase==0) 984 if (phase == 0)
1001 { 985 {
1002 char * host_str = NULL; 986 char *host_str = NULL;
987
1003 /* resetting buffers */ 988 /* resetting buffers */
1004 buffer_in.size = HTTP_BUFFER_SIZE; 989 buffer_in.size = HTTP_BUFFER_SIZE;
1005 buffer_in.pos = 0; 990 buffer_in.pos = 0;
@@ -1010,217 +995,210 @@ run_connection_tests( int phase , void * cls)
1010 buffer_out.len = 0; 995 buffer_out.len = 0;
1011 996
1012 if (test_no_ident.test_executed == GNUNET_NO) 997 if (test_no_ident.test_executed == GNUNET_NO)
1013 { 998 {
1014 /* Connecting to peer without identification */ 999 /* Connecting to peer without identification */
1015 const char * ident = ""; 1000 const char *ident = "";
1016 GNUNET_asprintf (&host_str, 1001
1017 "%s://%s/%s", 1002 GNUNET_asprintf (&host_str,
1018 PROTOCOL_PREFIX, 1003 "%s://%s/%s", PROTOCOL_PREFIX, test_addr, ident);
1019 test_addr,ident); 1004 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1020 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1005 _("Connecting to peer without any peer identification.\n"));
1021 _("Connecting to peer without any peer identification.\n")); 1006 test_no_ident.test_executed = GNUNET_YES;
1022 test_no_ident.test_executed = GNUNET_YES; 1007 send_data (&test_no_ident, host_str);
1023 send_data ( &test_no_ident, host_str); 1008 GNUNET_free (host_str);
1024 GNUNET_free (host_str); 1009 return;
1025 return; 1010 }
1026 }
1027 if (test_too_short_ident.test_executed == GNUNET_NO) 1011 if (test_too_short_ident.test_executed == GNUNET_NO)
1028 { 1012 {
1029 const char * ident = "AAAAAAAAAA"; 1013 const char *ident = "AAAAAAAAAA";
1030 /* Connecting to peer with too short identification */ 1014
1031 GNUNET_asprintf (&host_str, 1015 /* Connecting to peer with too short identification */
1032 "%s://%s/%s", 1016 GNUNET_asprintf (&host_str,
1033 PROTOCOL_PREFIX, 1017 "%s://%s/%s", PROTOCOL_PREFIX, test_addr, ident);
1034 test_addr, 1018 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1035 ident); 1019 _
1036 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1020 ("Connecting to peer with too short peer identification.\n"));
1037 _("Connecting to peer with too short peer identification.\n")); 1021 test_too_short_ident.test_executed = GNUNET_YES;
1038 test_too_short_ident.test_executed = GNUNET_YES; 1022 send_data (&test_too_short_ident, host_str);
1039 send_data ( &test_too_short_ident, host_str); 1023 GNUNET_free (host_str);
1040 GNUNET_free (host_str); 1024 return;
1041 return; 1025 }
1042 }
1043 1026
1044 if (test_too_long_ident.test_executed == GNUNET_NO) 1027 if (test_too_long_ident.test_executed == GNUNET_NO)
1045 { 1028 {
1046 const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; 1029 const char *ident =
1030 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1047 1031
1048 /* Connecting to peer with too long identification */ 1032 /* Connecting to peer with too long identification */
1049 GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident); 1033 GNUNET_asprintf (&host_str, "%s://%s/%s", PROTOCOL_PREFIX, test_addr,
1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1034 ident);
1051 _("Connecting to peer with too long peer identification.\n")); 1035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1052 test_too_long_ident.test_executed = GNUNET_YES; 1036 _("Connecting to peer with too long peer identification.\n"));
1053 send_data ( &test_too_long_ident, host_str); 1037 test_too_long_ident.test_executed = GNUNET_YES;
1054 GNUNET_free (host_str); 1038 send_data (&test_too_long_ident, host_str);
1055 return; 1039 GNUNET_free (host_str);
1040 return;
1056 } 1041 }
1057 if (test_valid_ident.test_executed == GNUNET_NO) 1042 if (test_valid_ident.test_executed == GNUNET_NO)
1058 {
1059 struct GNUNET_CRYPTO_HashAsciiEncoded ident;
1060 GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident);
1061 GNUNET_asprintf (&host_str,
1062 "%s://%s/%s%s",
1063 PROTOCOL_PREFIX,
1064 test_addr,
1065 (char *) &ident,
1066 ";0");
1067 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1068 _("Connecting to peer with valid peer identification.\n"));
1069 test_valid_ident.test_executed = GNUNET_YES;
1070 send_data ( &test_valid_ident, host_str);
1071 GNUNET_free (host_str);
1072 return;
1073 }
1074 }
1075 if (phase==1)
1076 { 1043 {
1044 struct GNUNET_CRYPTO_HashAsciiEncoded ident;
1045
1046 GNUNET_CRYPTO_hash_to_enc (&my_identity.hashPubKey, &ident);
1047 GNUNET_asprintf (&host_str,
1048 "%s://%s/%s%s",
1049 PROTOCOL_PREFIX, test_addr, (char *) &ident, ";0");
1077 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1078 "\nPhase 1: transmit data to all suggested addresses\n\n"); 1051 _("Connecting to peer with valid peer identification.\n"));
1079 /* Using one of the addresses the plugin proposed */ 1052 test_valid_ident.test_executed = GNUNET_YES;
1080 GNUNET_assert (addr_head->addr != NULL); 1053 send_data (&test_valid_ident, host_str);
1081 1054 GNUNET_free (host_str);
1082 struct Plugin_Address * tmp_addr;
1083 struct GNUNET_MessageHeader msg;
1084 char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
1085 char address[INET6_ADDRSTRLEN];
1086 unsigned int port;
1087 unsigned int type = 10;
1088
1089 msg.size=htons(sizeof(struct GNUNET_MessageHeader));
1090 tmp_addr = addr_head;
1091 /* send a message to all addresses advertised by plugin */
1092
1093 int count = 0;
1094 while (tmp_addr != NULL)
1095 {
1096 if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
1097 {
1098 inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN);
1099 port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
1100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1101 "Sending message to addres no. %u: `%s':%u\n",
1102 count,
1103 address,
1104 port);
1105 }
1106 if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
1107 {
1108 inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN);
1109 port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
1110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1111 "Sending message to addres no. %u: `%s':%u\n",
1112 count,
1113 address,
1114 port);
1115 }
1116 msg.type=htons(type);
1117 memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
1118 api->send(api->cls,
1119 &my_identity,
1120 tmp, sizeof(struct GNUNET_MessageHeader),
1121 0, TIMEOUT,
1122 NULL,
1123 tmp_addr->addr, tmp_addr->addrlen,
1124 GNUNET_YES,
1125 &task_send_cont, &fail_msgs_transmited_to_local_addrs);
1126 tmp_addr = tmp_addr->next;
1127 count++;
1128 type++;
1129 }
1130 GNUNET_free(tmp);
1131 return; 1055 return;
1132 } 1056 }
1057 }
1058 if (phase == 1)
1059 {
1060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1061 "\nPhase 1: transmit data to all suggested addresses\n\n");
1062 /* Using one of the addresses the plugin proposed */
1063 GNUNET_assert (addr_head->addr != NULL);
1064
1065 struct Plugin_Address *tmp_addr;
1066 struct GNUNET_MessageHeader msg;
1067 char *tmp = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader));
1068 char address[INET6_ADDRSTRLEN];
1069 unsigned int port;
1070 unsigned int type = 10;
1071
1072 msg.size = htons (sizeof (struct GNUNET_MessageHeader));
1073 tmp_addr = addr_head;
1074 /* send a message to all addresses advertised by plugin */
1133 1075
1134 if (phase==2) 1076 int count = 0;
1077
1078 while (tmp_addr != NULL)
1135 { 1079 {
1136 struct Session * session = cls; 1080 if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
1137 msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader)); 1081 {
1138 1082 inet_ntop (AF_INET, (struct in_addr *) tmp_addr->addr, address,
1139 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1083 INET_ADDRSTRLEN);
1140 "Phase 2: session selection\n\n"); 1084 port = ntohs (((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
1141 size = sizeof(struct GNUNET_MessageHeader); 1085 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1142 msg->size=htons(size); 1086 "Sending message to addres no. %u: `%s':%u\n",
1143 msg->type = htons(20); 1087 count, address, port);
1144 api->send(api->cls, 1088 }
1145 &my_identity, 1089 if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
1146 (const char *) msg, size, 1090 {
1147 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, 1091 inet_ntop (AF_INET6, (struct in6_addr *) tmp_addr->addr, address,
1148 &task_send_cont, NULL); 1092 INET6_ADDRSTRLEN);
1149 1093 port = ntohs (((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
1150 msg->type = htons(21); 1094 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1151 api->send(api->cls, 1095 "Sending message to addres no. %u: `%s':%u\n",
1152 &my_identity, 1096 count, address, port);
1153 (const char *) msg, size, 1097 }
1154 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, 1098 msg.type = htons (type);
1155 &task_send_cont, NULL); 1099 memcpy (tmp, &msg, sizeof (struct GNUNET_MessageHeader));
1156 1100 api->send (api->cls,
1157 /* answer on session*/ 1101 &my_identity,
1158 size = sizeof( struct GNUNET_MessageHeader); 1102 tmp, sizeof (struct GNUNET_MessageHeader),
1159 msg->size = htons(size); 1103 0, TIMEOUT,
1160 msg->type = htons(22); 1104 NULL,
1161 api->send(api->cls, 1105 tmp_addr->addr, tmp_addr->addrlen,
1162 &my_identity, 1106 GNUNET_YES,
1163 (const char *) msg, size, 1107 &task_send_cont, &fail_msgs_transmited_to_local_addrs);
1164 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, 1108 tmp_addr = tmp_addr->next;
1165 &task_send_cont, NULL); 1109 count++;
1166 GNUNET_free(msg); 1110 type++;
1167
1168 /* answer on session with big message not fitting in mhd send buffer*/
1169 size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
1170 msg = GNUNET_malloc (size);
1171 msg->size=htons(size);
1172 msg->type = htons(23);
1173 api->send(api->cls,
1174 &my_identity,
1175 (const char *) msg, size,
1176 0, TIMEOUT, session, NULL, 0, GNUNET_NO,
1177 &task_send_cont, NULL);
1178 GNUNET_free(msg);
1179 return;
1180 } 1111 }
1181 1112 GNUNET_free (tmp);
1182 if (phase==3) 1113 return;
1183 { 1114 }
1184 1115
1185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1116 if (phase == 2)
1117 {
1118 struct Session *session = cls;
1119
1120 msg = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader));
1121
1122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 2: session selection\n\n");
1123 size = sizeof (struct GNUNET_MessageHeader);
1124 msg->size = htons (size);
1125 msg->type = htons (20);
1126 api->send (api->cls,
1127 &my_identity,
1128 (const char *) msg, size,
1129 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1130
1131 msg->type = htons (21);
1132 api->send (api->cls,
1133 &my_identity,
1134 (const char *) msg, size,
1135 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
1136
1137 /* answer on session */
1138 size = sizeof (struct GNUNET_MessageHeader);
1139 msg->size = htons (size);
1140 msg->type = htons (22);
1141 api->send (api->cls,
1142 &my_identity,
1143 (const char *) msg, size,
1144 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR,
1145 &task_send_cont, NULL);
1146 GNUNET_free (msg);
1147
1148 /* answer on session with big message not fitting in mhd send buffer */
1149 size = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1;
1150 msg = GNUNET_malloc (size);
1151 msg->size = htons (size);
1152 msg->type = htons (23);
1153 api->send (api->cls,
1154 &my_identity,
1155 (const char *) msg, size,
1156 0, TIMEOUT, session, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1157 GNUNET_free (msg);
1158 return;
1159 }
1160
1161 if (phase == 3)
1162 {
1163
1164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1186 "Phase 3: send multiple or big messages after disconnect\n\n"); 1165 "Phase 3: send multiple or big messages after disconnect\n\n");
1187 /* disconnect from peer, so new connections are created */ 1166 /* disconnect from peer, so new connections are created */
1188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity)); 1167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect from peer: `%s'\n",
1189 api->disconnect(api->cls, &my_identity); 1168 GNUNET_i2s (&my_identity));
1190 1169 api->disconnect (api->cls, &my_identity);
1170
1191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: sending messages\n"); 1171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: sending messages\n");
1192 /* send a multiple GNUNET_messages at a time*/ 1172 /* send a multiple GNUNET_messages at a time */
1193 size = 2 * sizeof(struct GNUNET_MessageHeader); 1173 size = 2 * sizeof (struct GNUNET_MessageHeader);
1194 msg = GNUNET_malloc( 2* size); 1174 msg = GNUNET_malloc (2 * size);
1195 msg->size = htons(size); 1175 msg->size = htons (size);
1196 msg->type = htons(30); 1176 msg->type = htons (30);
1197 struct GNUNET_MessageHeader * msg2 = &msg[2]; 1177 struct GNUNET_MessageHeader *msg2 = &msg[2];
1198 msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); 1178
1199 msg2->type = htons(31); 1179 msg2->size = htons (2 * sizeof (struct GNUNET_MessageHeader));
1200 api->send(api->cls, 1180 msg2->type = htons (31);
1201 &my_identity, 1181 api->send (api->cls,
1202 (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), 1182 &my_identity,
1203 0, TIMEOUT, NULL, 1183 (const char *) msg, 4 * sizeof (struct GNUNET_MessageHeader),
1204 addr_head->addr, addr_head->addrlen, 1184 0, TIMEOUT, NULL,
1205 GNUNET_NO, 1185 addr_head->addr, addr_head->addrlen,
1206 &task_send_cont, &fail_multiple_msgs_in_transmission); 1186 GNUNET_NO, &task_send_cont, &fail_multiple_msgs_in_transmission);
1207 GNUNET_free(msg); 1187 GNUNET_free (msg);
1208 /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ 1188 /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */
1209 1189
1210 size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1; 1190 size = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1;
1211 msg = GNUNET_malloc(size); 1191 msg = GNUNET_malloc (size);
1212 msg->size = htons(size); 1192 msg->size = htons (size);
1213 msg->type = htons(32); 1193 msg->type = htons (32);
1214 api->send(api->cls, 1194 api->send (api->cls,
1215 &my_identity, 1195 &my_identity,
1216 (const char *) msg, size, 1196 (const char *) msg, size,
1217 0, TIMEOUT, NULL, 1197 0, TIMEOUT, NULL,
1218 addr_head->addr, addr_head->addrlen, 1198 addr_head->addr, addr_head->addrlen,
1219 GNUNET_NO, 1199 GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size);
1220 &task_send_cont, &fail_msg_transmited_max_size); 1200 GNUNET_free (msg);
1221 GNUNET_free(msg); 1201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more tests to run\n");
1222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1223 "No more tests to run\n");
1224 } 1202 }
1225} 1203}
1226 1204
@@ -1236,12 +1214,13 @@ run (void *cls,
1236 char *const *args, 1214 char *const *args,
1237 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) 1215 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
1238{ 1216{
1239 char * libname; 1217 char *libname;
1218
1240 cfg = c; 1219 cfg = c;
1241 char *keyfile; 1220 char *keyfile;
1242 unsigned long long tneigh; 1221 unsigned long long tneigh;
1243 struct Plugin_Address * cur; 1222 struct Plugin_Address *cur;
1244 const char * addr_str; 1223 const char *addr_str;
1245 1224
1246 1225
1247 unsigned int suggest_res; 1226 unsigned int suggest_res;
@@ -1260,8 +1239,9 @@ run (void *cls,
1260 addr_head = NULL; 1239 addr_head = NULL;
1261 count_str_addr = 0; 1240 count_str_addr = 0;
1262 /* parse configuration */ 1241 /* parse configuration */
1263 if (GNUNET_CONFIGURATION_have_value (c,"PATHS", "SERVICEHOME")) 1242 if (GNUNET_CONFIGURATION_have_value (c, "PATHS", "SERVICEHOME"))
1264 GNUNET_CONFIGURATION_get_value_string (c, "PATHS", "SERVICEHOME", &servicehome); 1243 GNUNET_CONFIGURATION_get_value_string (c, "PATHS", "SERVICEHOME",
1244 &servicehome);
1265 1245
1266 if ((GNUNET_OK != 1246 if ((GNUNET_OK !=
1267 GNUNET_CONFIGURATION_get_value_number (c, 1247 GNUNET_CONFIGURATION_get_value_number (c,
@@ -1272,20 +1252,21 @@ run (void *cls,
1272 GNUNET_CONFIGURATION_get_value_filename (c, 1252 GNUNET_CONFIGURATION_get_value_filename (c,
1273 "GNUNETD", 1253 "GNUNETD",
1274 "HOSTKEY", &keyfile))) 1254 "HOSTKEY", &keyfile)))
1275 { 1255 {
1276 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1277 _("Transport service is lacking key configuration settings. Exiting.\n")); 1257 _
1278 GNUNET_SCHEDULER_shutdown (); 1258 ("Transport service is lacking key configuration settings. Exiting.\n"));
1279 fail = 1; 1259 GNUNET_SCHEDULER_shutdown ();
1280 return; 1260 fail = 1;
1281 } 1261 return;
1262 }
1282 1263
1283 if ((GNUNET_OK != 1264 if ((GNUNET_OK !=
1284 GNUNET_CONFIGURATION_get_value_number (cfg, 1265 GNUNET_CONFIGURATION_get_value_number (cfg,
1285 "transport-http", 1266 "transport-http",
1286 "PORT", 1267 "PORT",
1287 &port)) || 1268 &port)) ||
1288 (port > 65535) || (port == 0)) 1269 (port > 65535) || (port == 0))
1289 { 1270 {
1290 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 1271 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
1291 "http", 1272 "http",
@@ -1298,16 +1279,17 @@ run (void *cls,
1298 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 1279 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
1299 GNUNET_free (keyfile); 1280 GNUNET_free (keyfile);
1300 if (my_private_key == NULL) 1281 if (my_private_key == NULL)
1301 { 1282 {
1302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1303 _("Transport service could not access hostkey. Exiting.\n")); 1284 _("Transport service could not access hostkey. Exiting.\n"));
1304 GNUNET_SCHEDULER_shutdown (); 1285 GNUNET_SCHEDULER_shutdown ();
1305 fail = 1; 1286 fail = 1;
1306 return; 1287 return;
1307 } 1288 }
1308 1289
1309 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); 1290 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
1310 GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), &my_identity.hashPubKey); 1291 GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
1292 &my_identity.hashPubKey);
1311 1293
1312 /* assertions before start */ 1294 /* assertions before start */
1313 GNUNET_assert ((port > 0) && (port <= 65535)); 1295 GNUNET_assert ((port > 0) && (port <= 65535));
@@ -1315,9 +1297,8 @@ run (void *cls,
1315 /* load plugins... */ 1297 /* load plugins... */
1316 setup_plugin_environment (); 1298 setup_plugin_environment ();
1317 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http"); 1299 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http");
1318 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1300 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1319 _("Loading HTTP transport plugin `%s'\n"), 1301 _("Loading HTTP transport plugin `%s'\n"), libname);
1320 libname);
1321 api = GNUNET_PLUGIN_load (libname, &env); 1302 api = GNUNET_PLUGIN_load (libname, &env);
1322 GNUNET_free (libname); 1303 GNUNET_free (libname);
1323 if (api == NULL) 1304 if (api == NULL)
@@ -1332,49 +1313,51 @@ run (void *cls,
1332 ti_timeout = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &task_timeout, NULL); 1313 ti_timeout = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &task_timeout, NULL);
1333 1314
1334 /* testing plugin functionality */ 1315 /* testing plugin functionality */
1335 GNUNET_assert (0!=fail_notify_address_count); 1316 GNUNET_assert (0 != fail_notify_address_count);
1336 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1337 "Transport plugin returned %u addresses to connect to\n", 1318 "Transport plugin returned %u addresses to connect to\n",
1338 fail_notify_address_count); 1319 fail_notify_address_count);
1339 1320
1340 /* testing pretty printer with all addresses obtained from the plugin*/ 1321 /* testing pretty printer with all addresses obtained from the plugin */
1341 cur = addr_head; 1322 cur = addr_head;
1342 while (cur != NULL) 1323 while (cur != NULL)
1343 { 1324 {
1344 api->address_pretty_printer (api->cls, "http", 1325 api->address_pretty_printer (api->cls, "http",
1345 cur->addr,cur->addrlen, GNUNET_NO,TEST_TIMEOUT, 1326 cur->addr, cur->addrlen, GNUNET_NO,
1346 &pretty_printer_cb, NULL); 1327 TEST_TIMEOUT, &pretty_printer_cb, NULL);
1347 addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen); 1328 addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen);
1348 suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen); 1329 suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen);
1349 1330
1350 GNUNET_assert (GNUNET_OK == suggest_res); 1331 GNUNET_assert (GNUNET_OK == suggest_res);
1351 GNUNET_assert (NULL != addr_str); 1332 GNUNET_assert (NULL != addr_str);
1352 count_str_addr++; 1333 count_str_addr++;
1353 GNUNET_free ( (char *) addr_str); 1334 GNUNET_free ((char *) addr_str);
1354 cur = cur->next; 1335 cur = cur->next;
1355 } 1336 }
1356 GNUNET_assert (fail_pretty_printer_count > 0); 1337 GNUNET_assert (fail_pretty_printer_count > 0);
1357 GNUNET_assert (fail_pretty_printer_count==fail_notify_address_count); 1338 GNUNET_assert (fail_pretty_printer_count == fail_notify_address_count);
1358 GNUNET_assert (fail_pretty_printer_count==count_str_addr); 1339 GNUNET_assert (fail_pretty_printer_count == count_str_addr);
1359 fail_pretty_printer=GNUNET_NO; 1340 fail_pretty_printer = GNUNET_NO;
1360 fail_addr_to_str=GNUNET_NO; 1341 fail_addr_to_str = GNUNET_NO;
1361 1342
1362 struct IPv4HttpAddress failing_addr; 1343 struct IPv4HttpAddress failing_addr;
1363 1344
1364 /* Suggesting addresses with wrong size*/ 1345 /* Suggesting addresses with wrong size */
1365 failing_addr.ipv4_addr = htonl(INADDR_LOOPBACK); 1346 failing_addr.ipv4_addr = htonl (INADDR_LOOPBACK);
1366 failing_addr.u_port = htons(0); 1347 failing_addr.u_port = htons (0);
1367 suggest_res = api->check_address (api->cls,&failing_addr,sizeof (struct IPv6HttpAddress)); 1348 suggest_res =
1349 api->check_address (api->cls, &failing_addr,
1350 sizeof (struct IPv6HttpAddress));
1368 GNUNET_assert (GNUNET_SYSERR == suggest_res); 1351 GNUNET_assert (GNUNET_SYSERR == suggest_res);
1369 1352
1370 /* Suggesting addresses with wrong address*/ 1353 /* Suggesting addresses with wrong address */
1371 failing_addr.ipv4_addr = htonl(0xffc00000); 1354 failing_addr.ipv4_addr = htonl (0xffc00000);
1372 failing_addr.u_port = htons(12389); 1355 failing_addr.u_port = htons (12389);
1373 suggest_res = api->check_address (api->cls,&failing_addr,100); 1356 suggest_res = api->check_address (api->cls, &failing_addr, 100);
1374 GNUNET_assert (GNUNET_SYSERR == suggest_res); 1357 GNUNET_assert (GNUNET_SYSERR == suggest_res);
1375 1358
1376 /* test sending to client */ 1359 /* test sending to client */
1377 multi_handle = curl_multi_init(); 1360 multi_handle = curl_multi_init ();
1378 1361
1379 /* Setting up buffers */ 1362 /* Setting up buffers */
1380 buffer_in.size = HTTP_BUFFER_SIZE; 1363 buffer_in.size = HTTP_BUFFER_SIZE;
@@ -1403,10 +1386,12 @@ run (void *cls,
1403 test_valid_ident.test_executed = GNUNET_NO; 1386 test_valid_ident.test_executed = GNUNET_NO;
1404 test_valid_ident.test_failed = GNUNET_YES; 1387 test_valid_ident.test_failed = GNUNET_YES;
1405 1388
1406 test_addr = (char *) api->address_to_string (api->cls,addr_head->addr,addr_head->addrlen); 1389 test_addr =
1390 (char *) api->address_to_string (api->cls, addr_head->addr,
1391 addr_head->addrlen);
1407 1392
1408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Phase 0\n\n")); 1393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Phase 0\n\n"));
1409 run_connection_tests(0, NULL); 1394 run_connection_tests (0, NULL);
1410 /* testing finished */ 1395 /* testing finished */
1411} 1396}
1412 1397
@@ -1425,6 +1410,7 @@ main (int argc, char *const *argv)
1425 GNUNET_GETOPT_OPTION_END 1410 GNUNET_GETOPT_OPTION_END
1426 }; 1411 };
1427 int ret; 1412 int ret;
1413
1428 char *const argv_prog[] = { 1414 char *const argv_prog[] = {
1429 "test_gnunet_transport_plugin_http", 1415 "test_gnunet_transport_plugin_http",
1430 "-c", 1416 "-c",
@@ -1446,11 +1432,15 @@ main (int argc, char *const *argv)
1446 NULL); 1432 NULL);
1447 1433
1448 struct GNUNET_CONFIGURATION_Handle *cfg; 1434 struct GNUNET_CONFIGURATION_Handle *cfg;
1435
1449 cfg = GNUNET_CONFIGURATION_create (); 1436 cfg = GNUNET_CONFIGURATION_create ();
1450 1437
1451 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, "test_plugin_transport_data_http.conf")); 1438 GNUNET_assert (GNUNET_OK ==
1452 if (GNUNET_CONFIGURATION_have_value (cfg,"PATHS", "SERVICEHOME")) 1439 GNUNET_CONFIGURATION_load (cfg,
1453 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &servicehome); 1440 "test_plugin_transport_data_http.conf"));
1441 if (GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "SERVICEHOME"))
1442 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME",
1443 &servicehome);
1454 GNUNET_DISK_directory_remove (servicehome); 1444 GNUNET_DISK_directory_remove (servicehome);
1455 GNUNET_CONFIGURATION_destroy (cfg); 1445 GNUNET_CONFIGURATION_destroy (cfg);
1456 1446
@@ -1458,7 +1448,8 @@ main (int argc, char *const *argv)
1458 GNUNET_PROGRAM_run (5, 1448 GNUNET_PROGRAM_run (5,
1459 argv_prog, 1449 argv_prog,
1460 "test_gnunet_transport_plugin_http", 1450 "test_gnunet_transport_plugin_http",
1461 "testcase", options, &run, NULL)) ? GNUNET_NO : GNUNET_YES; 1451 "testcase", options, &run,
1452 NULL)) ? GNUNET_NO : GNUNET_YES;
1462 1453
1463 if (servicehome != NULL) 1454 if (servicehome != NULL)
1464 { 1455 {