diff options
-rw-r--r-- | src/transport/plugin_transport_http.c | 30 | ||||
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 153 |
2 files changed, 104 insertions, 79 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index f71acf4b0..2ece30433 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -568,26 +568,21 @@ int mhd_send_callback (void *cls, uint64_t pos, char *buf, int max) | |||
568 | 568 | ||
569 | if (msg!=NULL) | 569 | if (msg!=NULL) |
570 | { | 570 | { |
571 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"mhd_send_callback %X: queue msg size: %u, max %u pos %u msg->pos %u\n",ps,msg->size,max,pos,msg->pos); | ||
572 | if ((msg->size-msg->pos) <= max) | 571 | if ((msg->size-msg->pos) <= max) |
573 | { | 572 | { |
574 | memcpy(buf,&msg->buf[msg->pos],(msg->size-msg->pos)); | 573 | memcpy(buf,&msg->buf[msg->pos],(msg->size-msg->pos)); |
575 | bytes_read = msg->size-msg->pos; | 574 | bytes_read = msg->size-msg->pos; |
576 | msg->pos+=(msg->size-msg->pos); | 575 | msg->pos+=(msg->size-msg->pos); |
577 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"mhd_send_callback %X: complete: size %u pos %u bytes read %u \n",ps,msg->size,msg->pos,bytes_read); | ||
578 | } | 576 | } |
579 | else | 577 | else |
580 | { | 578 | { |
581 | memcpy(buf,&msg->buf[msg->pos],max); | 579 | memcpy(buf,&msg->buf[msg->pos],max); |
582 | msg->pos+=max; | 580 | msg->pos+=max; |
583 | bytes_read = max; | 581 | bytes_read = max; |
584 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"mhd_send_callback %X: partial: size %u pos %u bytes read %u \n",ps,msg->size,msg->pos,bytes_read); | ||
585 | } | 582 | } |
586 | 583 | ||
587 | if (msg->pos==msg->size) | 584 | if (msg->pos==msg->size) |
588 | { | 585 | { |
589 | struct GNUNET_MessageHeader * tmp = (struct GNUNET_MessageHeader *) msg->buf; | ||
590 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MHD SENT MESSAGE %u bytes msg->type %u msg->size %u\n", bytes_read, ntohs(tmp->type), ntohs(tmp->size)); | ||
591 | if (NULL!=msg->transmit_cont) | 586 | if (NULL!=msg->transmit_cont) |
592 | msg->transmit_cont (msg->transmit_cont_cls,&pc->identity,GNUNET_OK); | 587 | msg->transmit_cont (msg->transmit_cont_cls,&pc->identity,GNUNET_OK); |
593 | res = remove_http_message(ps,msg); | 588 | res = remove_http_message(ps,msg); |
@@ -1143,11 +1138,7 @@ static size_t curl_receive_cb( void *stream, size_t size, size_t nmemb, void *pt | |||
1143 | #if DEBUG_CONNECTIONS | 1138 | #if DEBUG_CONNECTIONS |
1144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes received\n",ps, size*nmemb); | 1139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes received\n",ps, size*nmemb); |
1145 | #endif | 1140 | #endif |
1146 | 1141 | GNUNET_SERVER_mst_receive(ps->msgtok, ps, stream, size*nmemb, GNUNET_NO, GNUNET_NO); | |
1147 | struct GNUNET_MessageHeader * msg = stream; | ||
1148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes msg->type %u msg->size %u\n",ps, size*nmemb, ntohs(msg->type), ntohs(msg->size)); | ||
1149 | |||
1150 | // GNUNET_SERVER_mst_receive(ps->msgtok, ps, stream, size*nmemb, GNUNET_NO, GNUNET_NO); | ||
1151 | return (size * nmemb); | 1142 | return (size * nmemb); |
1152 | 1143 | ||
1153 | } | 1144 | } |
@@ -1712,37 +1703,41 @@ http_plugin_disconnect (void *cls, | |||
1712 | struct Plugin *plugin = cls; | 1703 | struct Plugin *plugin = cls; |
1713 | struct HTTP_PeerContext *pc = NULL; | 1704 | struct HTTP_PeerContext *pc = NULL; |
1714 | struct Session *ps = NULL; | 1705 | struct Session *ps = NULL; |
1706 | //struct Session *tmp = NULL; | ||
1715 | 1707 | ||
1716 | pc = GNUNET_CONTAINER_multihashmap_get (plugin->peers, &target->hashPubKey); | 1708 | pc = GNUNET_CONTAINER_multihashmap_get (plugin->peers, &target->hashPubKey); |
1717 | if (pc==NULL) | 1709 | if (pc==NULL) |
1718 | return; | 1710 | return; |
1719 | |||
1720 | ps = pc->head; | 1711 | ps = pc->head; |
1721 | 1712 | ||
1722 | while (ps!=NULL) | 1713 | while (ps!=NULL) |
1723 | { | 1714 | { |
1715 | |||
1724 | if (ps->direction==OUTBOUND) | 1716 | if (ps->direction==OUTBOUND) |
1725 | { | 1717 | { |
1718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"connections %X\n", ps, GNUNET_i2s(target)); | ||
1726 | if (ps->send_endpoint!=NULL) | 1719 | if (ps->send_endpoint!=NULL) |
1727 | { | 1720 | { |
1728 | curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint); | 1721 | //curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint); |
1729 | curl_easy_cleanup(ps->send_endpoint); | 1722 | //curl_easy_cleanup(ps->send_endpoint); |
1730 | ps->send_endpoint=NULL; | 1723 | //ps->send_endpoint=NULL; |
1731 | ps->send_force_disconnect = GNUNET_YES; | 1724 | ps->send_force_disconnect = GNUNET_YES; |
1732 | } | 1725 | } |
1733 | if (ps->recv_endpoint!=NULL) | 1726 | if (ps->recv_endpoint!=NULL) |
1734 | { | 1727 | { |
1735 | curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint); | 1728 | //curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint); |
1736 | curl_easy_cleanup(ps->recv_endpoint); | 1729 | //curl_easy_cleanup(ps->recv_endpoint); |
1737 | ps->recv_endpoint=NULL; | 1730 | //ps->recv_endpoint=NULL; |
1738 | ps->recv_force_disconnect = GNUNET_YES; | 1731 | ps->recv_force_disconnect = GNUNET_YES; |
1739 | } | 1732 | } |
1740 | } | 1733 | } |
1734 | |||
1741 | if (ps->direction==INBOUND) | 1735 | if (ps->direction==INBOUND) |
1742 | { | 1736 | { |
1743 | ps->recv_force_disconnect = GNUNET_YES; | 1737 | ps->recv_force_disconnect = GNUNET_YES; |
1744 | ps->send_force_disconnect = GNUNET_YES; | 1738 | ps->send_force_disconnect = GNUNET_YES; |
1745 | } | 1739 | } |
1740 | |||
1746 | while (ps->pending_msgs_head!=NULL) | 1741 | while (ps->pending_msgs_head!=NULL) |
1747 | { | 1742 | { |
1748 | remove_http_message(ps, ps->pending_msgs_head); | 1743 | remove_http_message(ps, ps->pending_msgs_head); |
@@ -1751,7 +1746,6 @@ http_plugin_disconnect (void *cls, | |||
1751 | ps->send_active = GNUNET_NO; | 1746 | ps->send_active = GNUNET_NO; |
1752 | ps=ps->next; | 1747 | ps=ps->next; |
1753 | } | 1748 | } |
1754 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"All connections to peer `%s' terminated\n", GNUNET_i2s(target)); | ||
1755 | } | 1749 | } |
1756 | 1750 | ||
1757 | 1751 | ||
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 699ca3582..52121d3cf 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -57,7 +57,7 @@ | |||
57 | /** | 57 | /** |
58 | * How long until we give up on transmitting the message? | 58 | * How long until we give up on transmitting the message? |
59 | */ | 59 | */ |
60 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 60 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * How long between recieve and send? | 63 | * How long between recieve and send? |
@@ -343,6 +343,16 @@ static struct HTTP_Transfer test_valid_ident; | |||
343 | */ | 343 | */ |
344 | static int fail_session_selection_any; | 344 | static int fail_session_selection_any; |
345 | 345 | ||
346 | /** | ||
347 | * Test: session selection, use existing inbound session | ||
348 | */ | ||
349 | static int fail_session_selection_session; | ||
350 | |||
351 | /** | ||
352 | * Test: session selection, use existing inbound session | ||
353 | * max message, not fitting in send & recv buffers at one time | ||
354 | */ | ||
355 | static int fail_session_selection_session_big; | ||
346 | 356 | ||
347 | /** | 357 | /** |
348 | * Test: session selection, use reliable existing | 358 | * Test: session selection, use reliable existing |
@@ -384,17 +394,22 @@ shutdown_clean () | |||
384 | fail = 0; | 394 | fail = 0; |
385 | if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES)) | 395 | if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES)) |
386 | { | 396 | { |
387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test plugin functions failed\n"); | 397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 0: Test plugin functions failed\n"); |
388 | fail = 1; | 398 | fail = 1; |
389 | } | 399 | } |
390 | if ((test_no_ident.test_failed == GNUNET_YES) || (test_too_short_ident.test_failed == GNUNET_YES) || (test_too_long_ident.test_failed == GNUNET_YES) || (test_valid_ident.test_failed == GNUNET_YES)) | 400 | if ((test_no_ident.test_failed == GNUNET_YES) || (test_too_short_ident.test_failed == GNUNET_YES) || (test_too_long_ident.test_failed == GNUNET_YES) || (test_valid_ident.test_failed == GNUNET_YES)) |
391 | { | 401 | { |
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test connect with wrong data failed\n"); | 402 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 1: Test connect with wrong data failed\n"); |
403 | fail = 1; | ||
404 | } | ||
405 | if ((fail_session_selection_any != GNUNET_NO) || (fail_session_selection_reliable != GNUNET_NO) || (fail_session_selection_session != GNUNET_NO) || (fail_session_selection_session_big != GNUNET_NO)) | ||
406 | { | ||
407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 2: Test session selection failed\n"); | ||
393 | fail = 1; | 408 | fail = 1; |
394 | } | 409 | } |
395 | if ((fail_msgs_transmited_to_local_addrs != count_str_addr) || (fail_multiple_msgs_in_transmission != 2) || (fail_msg_transmited_max_size == GNUNET_YES)) | 410 | if ((fail_msgs_transmited_to_local_addrs != count_str_addr) || (fail_multiple_msgs_in_transmission != 2) || (fail_msg_transmited_max_size == GNUNET_YES)) |
396 | { | 411 | { |
397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test sending with plugin failed\n"); | 412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: Test sending with plugin failed\n"); |
398 | fail = 1; | 413 | fail = 1; |
399 | } | 414 | } |
400 | if (fail != 1) | 415 | if (fail != 1) |
@@ -479,7 +494,7 @@ static void task_send_cont (void *cls, | |||
479 | } | 494 | } |
480 | 495 | ||
481 | 496 | ||
482 | static void run_connection_tests( int ); | 497 | static void run_connection_tests( int phase , void * cls); |
483 | 498 | ||
484 | /** | 499 | /** |
485 | * Recieves messages from plugin, in real world transport | 500 | * Recieves messages from plugin, in real world transport |
@@ -493,33 +508,42 @@ receive (void *cls, | |||
493 | const char *sender_address, | 508 | const char *sender_address, |
494 | uint16_t sender_address_len) | 509 | uint16_t sender_address_len) |
495 | { | 510 | { |
496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size)); | 511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); |
497 | 512 | ||
498 | if ((ntohs(message->type)>=10) && (ntohs(message->type)<=20)) | 513 | if ((ntohs(message->type)>=10) && (ntohs(message->type)<20)) |
499 | { | 514 | { |
500 | fail_msgs_transmited_to_local_addrs++; | 515 | fail_msgs_transmited_to_local_addrs++; |
501 | if (fail_msgs_transmited_to_local_addrs == count_str_addr) | 516 | if (fail_msgs_transmited_to_local_addrs == count_str_addr) |
502 | run_connection_tests(2); | 517 | run_connection_tests(2, session); |
503 | } | 518 | } |
504 | 519 | ||
505 | 520 | ||
506 | if ((ntohs(message->type)==60)) | 521 | if ((ntohs(message->type)==20)) |
507 | { | 522 | { |
508 | fail_session_selection_reliable = GNUNET_NO; | 523 | fail_session_selection_reliable = GNUNET_NO; |
509 | } | 524 | } |
510 | 525 | ||
511 | if ((ntohs(message->type)==61)) | 526 | if ((ntohs(message->type)==21)) |
512 | { | 527 | { |
513 | fail_session_selection_any = GNUNET_NO; | 528 | fail_session_selection_any = GNUNET_NO; |
514 | run_connection_tests(3); | 529 | } |
530 | if ((ntohs(message->type)==22)) | ||
531 | { | ||
532 | fail_session_selection_session = GNUNET_NO; | ||
515 | } | 533 | } |
516 | 534 | ||
517 | if ((ntohs(message->type)==40) || (ntohs(message->type)==41)) | 535 | if ((ntohs(message->type)==23)) |
536 | { | ||
537 | fail_session_selection_session_big = GNUNET_NO; | ||
538 | run_connection_tests(3, NULL); | ||
539 | } | ||
540 | |||
541 | if ((ntohs(message->type)==30) || (ntohs(message->type)==31)) | ||
518 | { | 542 | { |
519 | fail_multiple_msgs_in_transmission ++; | 543 | fail_multiple_msgs_in_transmission ++; |
520 | } | 544 | } |
521 | 545 | ||
522 | if (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1) | 546 | if ((ntohs(message->type)==32) && (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1)) |
523 | { | 547 | { |
524 | fail_msg_transmited_max_size = GNUNET_NO; | 548 | fail_msg_transmited_max_size = GNUNET_NO; |
525 | shutdown_clean(); | 549 | shutdown_clean(); |
@@ -595,7 +619,7 @@ static size_t header_function( void *ptr, size_t size, size_t nmemb, void *strea | |||
595 | 619 | ||
596 | static size_t send_prepare( struct HTTP_Transfer * result); | 620 | static size_t send_prepare( struct HTTP_Transfer * result); |
597 | 621 | ||
598 | static void run_connection_tests( ); | 622 | |
599 | 623 | ||
600 | static void send_execute (void *cls, | 624 | static void send_execute (void *cls, |
601 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 625 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -644,7 +668,7 @@ static void send_execute (void *cls, | |||
644 | curl_easy_cleanup(curl_handle); | 668 | curl_easy_cleanup(curl_handle); |
645 | curl_handle=NULL; | 669 | curl_handle=NULL; |
646 | 670 | ||
647 | run_connection_tests(0); | 671 | run_connection_tests(0, NULL); |
648 | } | 672 | } |
649 | if (res == &test_no_ident) | 673 | if (res == &test_no_ident) |
650 | { | 674 | { |
@@ -689,8 +713,8 @@ static void send_execute (void *cls, | |||
689 | curl_easy_cleanup(curl_handle); | 713 | curl_easy_cleanup(curl_handle); |
690 | curl_handle=NULL; | 714 | curl_handle=NULL; |
691 | if ((res == &test_valid_ident) && (res->test_failed == GNUNET_NO)) | 715 | if ((res == &test_valid_ident) && (res->test_failed == GNUNET_NO)) |
692 | run_connection_tests(1); | 716 | run_connection_tests(1, NULL); |
693 | run_connection_tests(0); | 717 | run_connection_tests(0, NULL); |
694 | return; | 718 | return; |
695 | default: | 719 | default: |
696 | break; | 720 | break; |
@@ -899,8 +923,11 @@ static void pretty_printer_cb (void *cls, | |||
899 | /** | 923 | /** |
900 | * Runs every single test to test the plugin | 924 | * Runs every single test to test the plugin |
901 | */ | 925 | */ |
902 | static void run_connection_tests( int phase ) | 926 | static void run_connection_tests( int phase , void * cls) |
903 | { | 927 | { |
928 | struct GNUNET_MessageHeader * msg; | ||
929 | unsigned int size; | ||
930 | |||
904 | if (phase==0) | 931 | if (phase==0) |
905 | { | 932 | { |
906 | char * host_str = NULL; | 933 | char * host_str = NULL; |
@@ -1000,66 +1027,68 @@ static void run_connection_tests( int phase ) | |||
1000 | count ++; | 1027 | count ++; |
1001 | type ++; | 1028 | type ++; |
1002 | } | 1029 | } |
1003 | |||
1004 | msg.type = htons(60); | ||
1005 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | ||
1006 | api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, &fail_msgs_transmited_to_local_addrs); | ||
1007 | |||
1008 | msg.type = htons(61); | ||
1009 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | ||
1010 | api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, &fail_msgs_transmited_to_local_addrs); | ||
1011 | return; | 1030 | return; |
1012 | } | 1031 | } |
1013 | 1032 | ||
1014 | if (phase==2) | 1033 | if (phase==2) |
1015 | { | 1034 | { |
1016 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("\nPhase 2: session selection\n\n")); | 1035 | struct Session * session = cls; |
1036 | msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader)); | ||
1017 | 1037 | ||
1018 | struct GNUNET_MessageHeader msg; | 1038 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("\nPhase 2: session selection\n\n")); |
1019 | msg.size=htons(sizeof(struct GNUNET_MessageHeader)); | 1039 | size = sizeof(struct GNUNET_MessageHeader); |
1020 | msg.type = htons(60); | 1040 | msg->size=htons(size); |
1021 | api->send(api->cls, &my_identity, (const char *) &msg, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL); | 1041 | msg->type = htons(20); |
1022 | 1042 | api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL); | |
1023 | msg.type = htons(61); | 1043 | |
1024 | api->send(api->cls, &my_identity, (const char *) &msg, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); | 1044 | msg->type = htons(21); |
1045 | api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); | ||
1046 | |||
1047 | /* answer on session*/ | ||
1048 | size = sizeof( struct GNUNET_MessageHeader); | ||
1049 | msg->size = htons(size); | ||
1050 | msg->type = htons(22); | ||
1051 | api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); | ||
1052 | |||
1053 | GNUNET_free(msg); | ||
1054 | |||
1055 | /* answer on session with big message not fitting in mhd send buffer*/ | ||
1056 | size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1; | ||
1057 | msg = GNUNET_malloc (size); | ||
1058 | msg->size=htons(size); | ||
1059 | msg->type = htons(23); | ||
1060 | api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_NO, &task_send_cont, NULL); | ||
1061 | GNUNET_free(msg); | ||
1062 | return; | ||
1025 | } | 1063 | } |
1026 | 1064 | ||
1027 | if (phase==3) | 1065 | if (phase==3) |
1028 | { | 1066 | { |
1067 | |||
1029 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("\nPhase 3: send multiple or big messages after disconnect\n\n")); | 1068 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("\nPhase 3: send multiple or big messages after disconnect\n\n")); |
1030 | /* disconnect from peer, so new connections are created */ | 1069 | /* disconnect from peer, so new connections are created */ |
1031 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity)); | 1070 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity)); |
1032 | api->disconnect(api->cls, &my_identity); | 1071 | api->disconnect(api->cls, &my_identity); |
1033 | 1072 | ||
1034 | struct GNUNET_MessageHeader msg; | ||
1035 | char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)); | ||
1036 | /* send a multiple GNUNET_messages at a time*/ | 1073 | /* send a multiple GNUNET_messages at a time*/ |
1037 | GNUNET_free(tmp); | ||
1038 | tmp = GNUNET_malloc(4 * sizeof(struct GNUNET_MessageHeader)); | ||
1039 | struct GNUNET_MessageHeader * msg1 = (struct GNUNET_MessageHeader *) tmp; | ||
1040 | msg1->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); | ||
1041 | msg1->type = htons(40); | ||
1042 | struct GNUNET_MessageHeader * msg2 = &msg1[2]; | ||
1043 | msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); | ||
1044 | msg2->type = htons(41); | ||
1045 | api->send(api->cls, &my_identity, tmp, 4 * sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_multiple_msgs_in_transmission); | ||
1046 | 1074 | ||
1075 | size = 2 * sizeof(struct GNUNET_MessageHeader); | ||
1076 | msg = GNUNET_malloc( 2* size); | ||
1077 | msg->size = htons(size); | ||
1078 | msg->type = htons(30); | ||
1079 | struct GNUNET_MessageHeader * msg2 = &msg[2]; | ||
1080 | msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); | ||
1081 | msg2->type = htons(31); | ||
1082 | api->send(api->cls, &my_identity, (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_multiple_msgs_in_transmission); | ||
1083 | GNUNET_free(msg); | ||
1047 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ | 1084 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ |
1048 | GNUNET_free(tmp); | 1085 | |
1049 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE-1); | 1086 | size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1; |
1050 | uint16_t t = (uint16_t)GNUNET_SERVER_MAX_MESSAGE_SIZE-1; | 1087 | msg = GNUNET_malloc(size); |
1051 | msg.size = htons(t); | 1088 | msg->size = htons(size); |
1052 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | 1089 | msg->type = htons(32); |
1053 | api->send(api->cls, &my_identity, tmp, GNUNET_SERVER_MAX_MESSAGE_SIZE-1, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size); | 1090 | api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size); |
1054 | GNUNET_free(tmp); | 1091 | GNUNET_free(msg); |
1055 | /* send a message without address, use existing session */ | ||
1056 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE-1); | ||
1057 | t = (uint16_t)GNUNET_SERVER_MAX_MESSAGE_SIZE-1; | ||
1058 | msg.size = htons(t); | ||
1059 | msg.type = htons(50); | ||
1060 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | ||
1061 | api->send(api->cls, &my_identity, tmp, GNUNET_SERVER_MAX_MESSAGE_SIZE-1, 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size); | ||
1062 | GNUNET_free(tmp); | ||
1063 | } | 1092 | } |
1064 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n"); | 1093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n"); |
1065 | } | 1094 | } |
@@ -1097,6 +1126,8 @@ run (void *cls, | |||
1097 | fail_multiple_msgs_in_transmission = 0; | 1126 | fail_multiple_msgs_in_transmission = 0; |
1098 | fail_session_selection_reliable = GNUNET_YES; | 1127 | fail_session_selection_reliable = GNUNET_YES; |
1099 | fail_session_selection_reliable = GNUNET_YES; | 1128 | fail_session_selection_reliable = GNUNET_YES; |
1129 | fail_session_selection_session = GNUNET_YES; | ||
1130 | fail_session_selection_session_big = GNUNET_YES; | ||
1100 | 1131 | ||
1101 | addr_head = NULL; | 1132 | addr_head = NULL; |
1102 | count_str_addr = 0; | 1133 | count_str_addr = 0; |
@@ -1246,7 +1277,7 @@ run (void *cls, | |||
1246 | test_addr = (char *) api->address_to_string (api->cls,addr_head->addr,addr_head->addrlen); | 1277 | test_addr = (char *) api->address_to_string (api->cls,addr_head->addr,addr_head->addrlen); |
1247 | 1278 | ||
1248 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("\nPhase 0\n\n")); | 1279 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("\nPhase 0\n\n")); |
1249 | run_connection_tests(0); | 1280 | run_connection_tests(0, NULL); |
1250 | 1281 | ||
1251 | /* testing finished */ | 1282 | /* testing finished */ |
1252 | 1283 | ||