diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 103 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 29 |
2 files changed, 65 insertions, 67 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 323fd042a..8f563de02 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -517,11 +517,11 @@ transmit_ping_if_allowed (void *cls, | |||
517 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 517 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
518 | struct GNUNET_TIME_Absolute next; | 518 | struct GNUNET_TIME_Absolute next; |
519 | const struct GNUNET_MessageHeader *hello; | 519 | const struct GNUNET_MessageHeader *hello; |
520 | enum GNUNET_ATS_Network_Type network; | ||
521 | ssize_t ret; | 520 | ssize_t ret; |
522 | size_t tsize; | 521 | size_t tsize; |
523 | size_t slen; | 522 | size_t slen; |
524 | uint16_t hsize; | 523 | uint16_t hsize; |
524 | struct Session *session; | ||
525 | 525 | ||
526 | ve->bc = NULL; | 526 | ve->bc = NULL; |
527 | if (GNUNET_NO == result) | 527 | if (GNUNET_NO == result) |
@@ -542,17 +542,10 @@ transmit_ping_if_allowed (void *cls, | |||
542 | } | 542 | } |
543 | hello = GST_hello_get (); | 543 | hello = GST_hello_get (); |
544 | GNUNET_assert (NULL != hello); | 544 | GNUNET_assert (NULL != hello); |
545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
546 | "Transmitting plain PING to `%s' `%s' `%s'\n", | ||
547 | GNUNET_i2s (pid), | ||
548 | GST_plugins_a2s (ve->address), | ||
549 | ve->address->transport_name); | ||
550 | |||
551 | slen = strlen (ve->address->transport_name) + 1; | 545 | slen = strlen (ve->address->transport_name) + 1; |
552 | hsize = ntohs (hello->size); | 546 | hsize = ntohs (hello->size); |
553 | tsize = | 547 | tsize = sizeof (struct TransportPingMessage) + |
554 | sizeof (struct TransportPingMessage) + ve->address->address_length + | 548 | ve->address->address_length + slen + hsize; |
555 | slen + hsize; | ||
556 | 549 | ||
557 | ping.header.size = | 550 | ping.header.size = |
558 | htons (sizeof (struct TransportPingMessage) + | 551 | htons (sizeof (struct TransportPingMessage) + |
@@ -570,11 +563,11 @@ transmit_ping_if_allowed (void *cls, | |||
570 | slen + hsize; | 563 | slen + hsize; |
571 | } | 564 | } |
572 | { | 565 | { |
573 | char message_buf[tsize]; | 566 | char message_buf[tsize] GNUNET_ALIGN; |
574 | 567 | ||
575 | /* build message with structure: | 568 | memcpy (message_buf, |
576 | * [HELLO][TransportPingMessage][Transport name][Address] */ | 569 | hello, |
577 | memcpy (message_buf, hello, hsize); | 570 | hsize); |
578 | memcpy (&message_buf[hsize], | 571 | memcpy (&message_buf[hsize], |
579 | &ping, | 572 | &ping, |
580 | sizeof (struct TransportPingMessage)); | 573 | sizeof (struct TransportPingMessage)); |
@@ -585,41 +578,42 @@ transmit_ping_if_allowed (void *cls, | |||
585 | ve->address->address, | 578 | ve->address->address, |
586 | ve->address->address_length); | 579 | ve->address->address_length); |
587 | papi = GST_plugins_find (ve->address->transport_name); | 580 | papi = GST_plugins_find (ve->address->transport_name); |
588 | GNUNET_assert (NULL != papi); | 581 | session = papi->get_session (papi->cls, |
589 | GNUNET_assert (NULL != papi->send); | 582 | ve->address); |
590 | struct Session *session = papi->get_session (papi->cls, | 583 | if (NULL == session) |
591 | ve->address); | ||
592 | |||
593 | if (NULL != session) | ||
594 | { | ||
595 | ret = papi->send (papi->cls, session, | ||
596 | message_buf, tsize, | ||
597 | PING_PRIORITY, | ||
598 | ACCEPTABLE_PING_DELAY, | ||
599 | NULL, NULL); | ||
600 | network = papi->get_network (papi->cls, session); | ||
601 | if (GNUNET_ATS_NET_UNSPECIFIED == network) | ||
602 | { | ||
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
604 | "Could not obtain a valid network for `%s' `%s'\n", | ||
605 | GNUNET_i2s (pid), | ||
606 | GST_plugins_a2s (ve->address)); | ||
607 | GNUNET_break(0); | ||
608 | } | ||
609 | GST_neighbours_notify_data_sent (ve->address, session, tsize); | ||
610 | } | ||
611 | else | ||
612 | { | 584 | { |
613 | /* Could not get a valid session */ | 585 | /* Could not get a valid session */ |
614 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
615 | "Could not get a valid session for `%s' `%s'\n", | 587 | "Failed to get session to send PING to `%s' at `%s'\n", |
616 | GNUNET_i2s (pid), | 588 | GNUNET_i2s (pid), |
617 | GST_plugins_a2s (ve->address)); | 589 | GST_plugins_a2s (ve->address)); |
618 | ret = -1; | 590 | return; |
619 | } | 591 | } |
620 | } | 592 | |
621 | if (-1 != ret) | 593 | ret = papi->send (papi->cls, session, |
622 | { | 594 | message_buf, tsize, |
595 | PING_PRIORITY, | ||
596 | ACCEPTABLE_PING_DELAY, | ||
597 | NULL, NULL); | ||
598 | if (-1 == ret) | ||
599 | { | ||
600 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
601 | "Failed to send PING to `%s' at `%s'\n", | ||
602 | GNUNET_i2s (pid), | ||
603 | GST_plugins_a2s (ve->address)); | ||
604 | return; | ||
605 | } | ||
606 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
607 | "Transmitted plain PING to `%s' `%s' `%s'\n", | ||
608 | GNUNET_i2s (pid), | ||
609 | GST_plugins_a2s (ve->address), | ||
610 | ve->address->transport_name); | ||
611 | ve->network = papi->get_network (papi->cls, | ||
612 | session); | ||
613 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); | ||
614 | GST_neighbours_notify_data_sent (ve->address, | ||
615 | session, | ||
616 | tsize); | ||
623 | next = GNUNET_TIME_relative_to_absolute (validation_delay); | 617 | next = GNUNET_TIME_relative_to_absolute (validation_delay); |
624 | validation_next = GNUNET_TIME_absolute_max (next, | 618 | validation_next = GNUNET_TIME_absolute_max (next, |
625 | validation_next); | 619 | validation_next); |
@@ -628,7 +622,6 @@ transmit_ping_if_allowed (void *cls, | |||
628 | gettext_noop ("# PINGs for address validation sent"), | 622 | gettext_noop ("# PINGs for address validation sent"), |
629 | 1, | 623 | 1, |
630 | GNUNET_NO); | 624 | GNUNET_NO); |
631 | ve->network = network; | ||
632 | ve->expecting_pong = GNUNET_YES; | 625 | ve->expecting_pong = GNUNET_YES; |
633 | validations_running++; | 626 | validations_running++; |
634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -639,7 +632,9 @@ transmit_ping_if_allowed (void *cls, | |||
639 | validations_running, | 632 | validations_running, |
640 | GNUNET_NO); | 633 | GNUNET_NO); |
641 | /* Notify about PING sent */ | 634 | /* Notify about PING sent */ |
642 | validation_entry_changed (ve, GNUNET_TRANSPORT_VS_UPDATE); | 635 | validation_entry_changed (ve, |
636 | GNUNET_TRANSPORT_VS_UPDATE); | ||
637 | |||
643 | } | 638 | } |
644 | } | 639 | } |
645 | 640 | ||
@@ -683,7 +678,7 @@ revalidate_address (void *cls, | |||
683 | { | 678 | { |
684 | /* should wait a bit longer */ | 679 | /* should wait a bit longer */ |
685 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
686 | "Waiting for %s longer before validating address `%s'\n", | 681 | "Waiting for %s longer before (re)validating address `%s'\n", |
687 | GNUNET_STRINGS_relative_time_to_string (delay, | 682 | GNUNET_STRINGS_relative_time_to_string (delay, |
688 | GNUNET_YES), | 683 | GNUNET_YES), |
689 | GST_plugins_a2s (ve->address)); | 684 | GST_plugins_a2s (ve->address)); |
@@ -727,7 +722,8 @@ revalidate_address (void *cls, | |||
727 | 722 | ||
728 | delay = GNUNET_TIME_relative_add (canonical_delay, | 723 | delay = GNUNET_TIME_relative_add (canonical_delay, |
729 | GNUNET_TIME_relative_multiply | 724 | GNUNET_TIME_relative_multiply |
730 | (GNUNET_TIME_UNIT_MICROSECONDS, rdelay)); | 725 | (GNUNET_TIME_UNIT_MICROSECONDS, |
726 | rdelay)); | ||
731 | 727 | ||
732 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 728 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
733 | "Validating now, next scheduled for %s, now validating address `%s'\n", | 729 | "Validating now, next scheduled for %s, now validating address `%s'\n", |
@@ -735,7 +731,9 @@ revalidate_address (void *cls, | |||
735 | GNUNET_YES), | 731 | GNUNET_YES), |
736 | GST_plugins_a2s (ve->address)); | 732 | GST_plugins_a2s (ve->address)); |
737 | ve->revalidation_task = | 733 | ve->revalidation_task = |
738 | GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); | 734 | GNUNET_SCHEDULER_add_delayed (delay, |
735 | &revalidate_address, | ||
736 | ve); | ||
739 | ve->next_validation = GNUNET_TIME_relative_to_absolute (delay); | 737 | ve->next_validation = GNUNET_TIME_relative_to_absolute (delay); |
740 | 738 | ||
741 | /* start PINGing by checking blacklist */ | 739 | /* start PINGing by checking blacklist */ |
@@ -790,7 +788,8 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address) | |||
790 | ve, | 788 | ve, |
791 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 789 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
792 | publish_ve_stat_update (); | 790 | publish_ve_stat_update (); |
793 | validation_entry_changed (ve, GNUNET_TRANSPORT_VS_NEW); | 791 | validation_entry_changed (ve, |
792 | GNUNET_TRANSPORT_VS_NEW); | ||
794 | return ve; | 793 | return ve; |
795 | } | 794 | } |
796 | 795 | ||
@@ -841,7 +840,8 @@ add_valid_address (void *cls, | |||
841 | ve->next_validation = GNUNET_TIME_absolute_get(); | 840 | ve->next_validation = GNUNET_TIME_absolute_get(); |
842 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); | 841 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); |
843 | } | 842 | } |
844 | validation_entry_changed (ve, GNUNET_TRANSPORT_VS_UPDATE); | 843 | validation_entry_changed (ve, |
844 | GNUNET_TRANSPORT_VS_UPDATE); | ||
845 | memset (&prop, 0, sizeof (prop)); | 845 | memset (&prop, 0, sizeof (prop)); |
846 | prop.scope = ve->network; | 846 | prop.scope = ve->network; |
847 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); | 847 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); |
@@ -1508,7 +1508,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1508 | } | 1508 | } |
1509 | 1509 | ||
1510 | /* Notify about new validity */ | 1510 | /* Notify about new validity */ |
1511 | validation_entry_changed (ve, GNUNET_TRANSPORT_VS_UPDATE); | 1511 | validation_entry_changed (ve, |
1512 | GNUNET_TRANSPORT_VS_UPDATE); | ||
1512 | 1513 | ||
1513 | /* build HELLO to store in PEERINFO */ | 1514 | /* build HELLO to store in PEERINFO */ |
1514 | ve->copied = GNUNET_NO; | 1515 | ve->copied = GNUNET_NO; |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 19ce855d8..32bc65047 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -862,9 +862,12 @@ tcp_plugin_disconnect_session (void *cls, | |||
862 | { | 862 | { |
863 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 863 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
864 | (NULL != pm->transmit_cont) | 864 | (NULL != pm->transmit_cont) |
865 | ? "Could not deliver message to `%4s'.\n" | 865 | ? "Could not deliver message to `%s' at %s.\n" |
866 | : "Could not deliver message to `%4s', notifying.\n", | 866 | : "Could not deliver message to `%s' at %s, notifying.\n", |
867 | GNUNET_i2s (&session->target)); | 867 | GNUNET_i2s (&session->target), |
868 | tcp_plugin_address_to_string (session->plugin, | ||
869 | session->address->address, | ||
870 | session->address->address_length)); | ||
868 | GNUNET_STATISTICS_update (session->plugin->env->stats, | 871 | GNUNET_STATISTICS_update (session->plugin->env->stats, |
869 | gettext_noop ("# bytes currently in TCP buffers"), | 872 | gettext_noop ("# bytes currently in TCP buffers"), |
870 | -(int64_t) pm->message_size, GNUNET_NO); | 873 | -(int64_t) pm->message_size, GNUNET_NO); |
@@ -1003,8 +1006,11 @@ create_session (struct Plugin *plugin, | |||
1003 | GNUNET_assert (NULL == client); | 1006 | GNUNET_assert (NULL == client); |
1004 | 1007 | ||
1005 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1008 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1006 | "Creating new session for peer `%4s'\n", | 1009 | "Creating new session for peer `%4s' at address %s\n", |
1007 | GNUNET_i2s (&address->peer)); | 1010 | GNUNET_i2s (&address->peer), |
1011 | tcp_plugin_address_to_string (plugin, | ||
1012 | address->address, | ||
1013 | address->address_length)); | ||
1008 | session = GNUNET_new (struct Session); | 1014 | session = GNUNET_new (struct Session); |
1009 | session->last_activity = GNUNET_TIME_absolute_get (); | 1015 | session->last_activity = GNUNET_TIME_absolute_get (); |
1010 | session->plugin = plugin; | 1016 | session->plugin = plugin; |
@@ -1174,9 +1180,10 @@ do_transmit (void *cls, size_t size, void *buf) | |||
1174 | session->bytes_in_queue -= pos->message_size; | 1180 | session->bytes_in_queue -= pos->message_size; |
1175 | GNUNET_assert(size >= pos->message_size); | 1181 | GNUNET_assert(size >= pos->message_size); |
1176 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1182 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1177 | "Transmitting message of type %u size %u to %s\n", | 1183 | "Transmitting message of type %u size %u to peer %s at %s\n", |
1178 | ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type), | 1184 | ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type), |
1179 | pos->message_size, | 1185 | pos->message_size, |
1186 | GNUNET_i2s (&session->target), | ||
1180 | tcp_plugin_address_to_string (session->plugin, | 1187 | tcp_plugin_address_to_string (session->plugin, |
1181 | session->address->address, | 1188 | session->address->address, |
1182 | session->address->address_length)); | 1189 | session->address->address_length)); |
@@ -1215,9 +1222,6 @@ do_transmit (void *cls, size_t size, void *buf) | |||
1215 | } | 1222 | } |
1216 | GNUNET_assert (NULL == hd); | 1223 | GNUNET_assert (NULL == hd); |
1217 | GNUNET_assert (NULL == tl); | 1224 | GNUNET_assert (NULL == tl); |
1218 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1219 | "Transmitting %u bytes\n", | ||
1220 | ret); | ||
1221 | GNUNET_STATISTICS_update (plugin->env->stats, | 1225 | GNUNET_STATISTICS_update (plugin->env->stats, |
1222 | gettext_noop ("# bytes currently in TCP buffers"), | 1226 | gettext_noop ("# bytes currently in TCP buffers"), |
1223 | - (int64_t) ret, | 1227 | - (int64_t) ret, |
@@ -1767,13 +1771,6 @@ tcp_plugin_get_session (void *cls, | |||
1767 | &session->target, | 1771 | &session->target, |
1768 | session, | 1772 | session, |
1769 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1773 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1770 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1771 | "Creating new session for `%s' address `%s' session %p\n", | ||
1772 | GNUNET_i2s (&address->peer), | ||
1773 | tcp_plugin_address_to_string (plugin, | ||
1774 | address->address, | ||
1775 | address->address_length), | ||
1776 | session); | ||
1777 | /* Send TCP Welcome */ | 1774 | /* Send TCP Welcome */ |
1778 | process_pending_messages (session); | 1775 | process_pending_messages (session); |
1779 | 1776 | ||