diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-02 22:44:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-02 22:44:16 +0000 |
commit | 17aa8594c3970f4921146fa5ec3a8e81926e30f6 (patch) | |
tree | d5ea0432bc5449362c5d030e6c3ef0bf4ce051e9 /src/transport/gnunet-service-transport_validation.c | |
parent | e47cd2126ede0336453b1abc42d68e7d68977bd4 (diff) | |
download | gnunet-17aa8594c3970f4921146fa5ec3a8e81926e30f6.tar.gz gnunet-17aa8594c3970f4921146fa5ec3a8e81926e30f6.zip |
check that we support the specified plugin early, not late
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 89 |
1 files changed, 53 insertions, 36 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 5c85c1680..eff7570b0 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -571,47 +571,37 @@ transmit_ping_if_allowed (void *cls, | |||
571 | ve->address->address, | 571 | ve->address->address, |
572 | ve->address->address_length); | 572 | ve->address->address_length); |
573 | papi = GST_plugins_find (ve->address->transport_name); | 573 | papi = GST_plugins_find (ve->address->transport_name); |
574 | if (NULL == papi) | 574 | GNUNET_assert (NULL != papi); |
575 | { | 575 | GNUNET_assert (NULL != papi->send); |
576 | ret = -1; | 576 | struct Session *session = papi->get_session (papi->cls, |
577 | GNUNET_STATISTICS_update (GST_stats, | 577 | ve->address); |
578 | gettext_noop ("# validations not attempted (no plugin)"), | ||
579 | 1, | ||
580 | GNUNET_NO); | ||
581 | } | ||
582 | else | ||
583 | { | ||
584 | GNUNET_assert (NULL != papi->send); | ||
585 | struct Session *session = papi->get_session (papi->cls, | ||
586 | ve->address); | ||
587 | 578 | ||
588 | if (NULL != session) | 579 | if (NULL != session) |
589 | { | 580 | { |
590 | ret = papi->send (papi->cls, session, | 581 | ret = papi->send (papi->cls, session, |
591 | message_buf, tsize, | 582 | message_buf, tsize, |
592 | PING_PRIORITY, | 583 | PING_PRIORITY, |
593 | ACCEPTABLE_PING_DELAY, | 584 | ACCEPTABLE_PING_DELAY, |
594 | NULL, NULL); | 585 | NULL, NULL); |
595 | network = papi->get_network (papi->cls, session); | 586 | network = papi->get_network (papi->cls, session); |
596 | if (GNUNET_ATS_NET_UNSPECIFIED == network) | 587 | if (GNUNET_ATS_NET_UNSPECIFIED == network) |
597 | { | ||
598 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
599 | "Could not obtain a valid network for `%s' `%s'\n", | ||
600 | GNUNET_i2s (pid), | ||
601 | GST_plugins_a2s (ve->address)); | ||
602 | GNUNET_break(0); | ||
603 | } | ||
604 | GST_neighbours_notify_data_sent (ve->address, session, tsize); | ||
605 | } | ||
606 | else | ||
607 | { | 588 | { |
608 | /* Could not get a valid session */ | ||
609 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
610 | "Could not get a valid session for `%s' `%s'\n", | 590 | "Could not obtain a valid network for `%s' `%s'\n", |
611 | GNUNET_i2s (pid), | 591 | GNUNET_i2s (pid), |
612 | GST_plugins_a2s (ve->address)); | 592 | GST_plugins_a2s (ve->address)); |
613 | ret = -1; | 593 | GNUNET_break(0); |
614 | } | 594 | } |
595 | GST_neighbours_notify_data_sent (ve->address, session, tsize); | ||
596 | } | ||
597 | else | ||
598 | { | ||
599 | /* Could not get a valid session */ | ||
600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
601 | "Could not get a valid session for `%s' `%s'\n", | ||
602 | GNUNET_i2s (pid), | ||
603 | GST_plugins_a2s (ve->address)); | ||
604 | ret = -1; | ||
615 | } | 605 | } |
616 | } | 606 | } |
617 | if (-1 != ret) | 607 | if (-1 != ret) |
@@ -950,7 +940,12 @@ multicast_pong (void *cls, | |||
950 | 940 | ||
951 | papi = GST_plugins_find (address->transport_name); | 941 | papi = GST_plugins_find (address->transport_name); |
952 | if (NULL == papi) | 942 | if (NULL == papi) |
943 | { | ||
944 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
945 | "Plugin %s not supported, cannot send PONG\n", | ||
946 | address->transport_name); | ||
953 | return; | 947 | return; |
948 | } | ||
954 | 949 | ||
955 | GNUNET_assert (NULL != papi->send); | 950 | GNUNET_assert (NULL != papi->send); |
956 | GNUNET_assert (NULL != papi->get_session); | 951 | GNUNET_assert (NULL != papi->get_session); |
@@ -1343,6 +1338,16 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1343 | addr++; | 1338 | addr++; |
1344 | slen = strlen (tname) + 1; | 1339 | slen = strlen (tname) + 1; |
1345 | addrlen = size - slen; | 1340 | addrlen = size - slen; |
1341 | |||
1342 | if (NULL == GST_plugins_find (tname)) | ||
1343 | { | ||
1344 | /* we got the PONG, but the transport plugin specified in it | ||
1345 | is not supported by this peer, so this cannot be a good | ||
1346 | PONG for us. */ | ||
1347 | GNUNET_break_op (0); | ||
1348 | return GNUNET_OK; | ||
1349 | } | ||
1350 | |||
1346 | address.peer = *sender; | 1351 | address.peer = *sender; |
1347 | address.address = addr; | 1352 | address.address = addr; |
1348 | address.address_length = addrlen; | 1353 | address.address_length = addrlen; |
@@ -1617,6 +1622,12 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, | |||
1617 | if (GNUNET_HELLO_address_check_option (address, | 1622 | if (GNUNET_HELLO_address_check_option (address, |
1618 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | 1623 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) |
1619 | return; /* ignore inbound for validation */ | 1624 | return; /* ignore inbound for validation */ |
1625 | if (NULL == GST_plugins_find (address->transport_name)) | ||
1626 | { | ||
1627 | /* How can we use an address for which we don't have the plugin? */ | ||
1628 | GNUNET_break (0); | ||
1629 | return; | ||
1630 | } | ||
1620 | if (NULL != address) | 1631 | if (NULL != address) |
1621 | ve = find_validation_entry (address); | 1632 | ve = find_validation_entry (address); |
1622 | else | 1633 | else |
@@ -1671,9 +1682,15 @@ GST_validation_get_address_latency (const struct GNUNET_HELLO_Address *address, | |||
1671 | 1682 | ||
1672 | if (NULL == address) | 1683 | if (NULL == address) |
1673 | { | 1684 | { |
1674 | GNUNET_break (0); // FIXME: support having latency only with session... | 1685 | GNUNET_break (0); |
1675 | return GNUNET_TIME_UNIT_FOREVER_REL; | 1686 | return GNUNET_TIME_UNIT_FOREVER_REL; |
1676 | } | 1687 | } |
1688 | if (NULL == GST_plugins_find (address->transport_name)) | ||
1689 | { | ||
1690 | GNUNET_break (0); /* but we don't have the plugin! */ | ||
1691 | return GNUNET_TIME_UNIT_FOREVER_REL; | ||
1692 | } | ||
1693 | |||
1677 | ve = find_validation_entry (address); | 1694 | ve = find_validation_entry (address); |
1678 | if (NULL == ve) | 1695 | if (NULL == ve) |
1679 | return GNUNET_TIME_UNIT_FOREVER_REL; | 1696 | return GNUNET_TIME_UNIT_FOREVER_REL; |