diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-07 14:15:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-07 14:15:38 +0000 |
commit | e5bd8fb4aa72717b8707a4652f14c0735acb52c4 (patch) | |
tree | 08398e22b9408cc24b6b9e6cb360fe04b9eeae05 /src/transport/gnunet-service-transport_validation.c | |
parent | 572bab1ace57fb9d7acbd218d6940cb1e9a0797b (diff) | |
download | gnunet-e5bd8fb4aa72717b8707a4652f14c0735acb52c4.tar.gz gnunet-e5bd8fb4aa72717b8707a4652f14c0735acb52c4.zip |
determine network scope for ATS even if we do not yet have a session and only have an address
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 66f9f5409..c7d760199 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -789,7 +789,9 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address) | |||
789 | ve->in_use = GNUNET_SYSERR; /* not defined */ | 789 | ve->in_use = GNUNET_SYSERR; /* not defined */ |
790 | ve->address = GNUNET_HELLO_address_copy (address); | 790 | ve->address = GNUNET_HELLO_address_copy (address); |
791 | ve->pong_sig_valid_until = GNUNET_TIME_UNIT_ZERO_ABS; | 791 | ve->pong_sig_valid_until = GNUNET_TIME_UNIT_ZERO_ABS; |
792 | memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature)); | 792 | memset (&ve->pong_sig_cache, |
793 | '\0', | ||
794 | sizeof (struct GNUNET_CRYPTO_EddsaSignature)); | ||
793 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; | 795 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; |
794 | ve->challenge = | 796 | ve->challenge = |
795 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); | 797 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); |
@@ -828,6 +830,7 @@ add_valid_address (void *cls, | |||
828 | struct ValidationEntry *ve; | 830 | struct ValidationEntry *ve; |
829 | struct GNUNET_PeerIdentity pid; | 831 | struct GNUNET_PeerIdentity pid; |
830 | struct GNUNET_ATS_Properties prop; | 832 | struct GNUNET_ATS_Properties prop; |
833 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | ||
831 | 834 | ||
832 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | 835 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) |
833 | return GNUNET_OK; /* expired */ | 836 | return GNUNET_OK; /* expired */ |
@@ -836,14 +839,26 @@ add_valid_address (void *cls, | |||
836 | GNUNET_break (0); | 839 | GNUNET_break (0); |
837 | return GNUNET_OK; /* invalid HELLO !? */ | 840 | return GNUNET_OK; /* invalid HELLO !? */ |
838 | } | 841 | } |
839 | if (NULL == GST_plugins_find (address->transport_name)) | 842 | if (NULL == (papi = GST_plugins_find (address->transport_name))) |
840 | { | 843 | { |
841 | /* might have been valid in the past, but we don't have that | 844 | /* might have been valid in the past, but we don't have that |
842 | plugin loaded right now */ | 845 | plugin loaded right now */ |
843 | return GNUNET_OK; | 846 | return GNUNET_OK; |
844 | } | 847 | } |
848 | if (NULL == | ||
849 | papi->address_to_string (papi->cls, | ||
850 | address->address, | ||
851 | address->address_length)) | ||
852 | { | ||
853 | /* Why do we try to add an ill-formed address? */ | ||
854 | GNUNET_break (0); | ||
855 | return GNUNET_OK; | ||
856 | } | ||
845 | 857 | ||
846 | ve = find_validation_entry (address); | 858 | ve = find_validation_entry (address); |
859 | ve->network = papi->get_network_for_address (papi->cls, | ||
860 | address); | ||
861 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); | ||
847 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, | 862 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, |
848 | expiration); | 863 | expiration); |
849 | if (NULL == ve->revalidation_task) | 864 | if (NULL == ve->revalidation_task) |
@@ -857,6 +872,7 @@ add_valid_address (void *cls, | |||
857 | validation_entry_changed (ve, | 872 | validation_entry_changed (ve, |
858 | GNUNET_TRANSPORT_VS_UPDATE); | 873 | GNUNET_TRANSPORT_VS_UPDATE); |
859 | memset (&prop, 0, sizeof (prop)); | 874 | memset (&prop, 0, sizeof (prop)); |
875 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); | ||
860 | prop.scope = ve->network; | 876 | prop.scope = ve->network; |
861 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); | 877 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); |
862 | if (GNUNET_YES != ve->known_to_ats) | 878 | if (GNUNET_YES != ve->known_to_ats) |
@@ -1506,6 +1522,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1506 | struct GNUNET_ATS_Properties prop; | 1522 | struct GNUNET_ATS_Properties prop; |
1507 | 1523 | ||
1508 | memset (&prop, 0, sizeof (prop)); | 1524 | memset (&prop, 0, sizeof (prop)); |
1525 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); | ||
1509 | prop.scope = ve->network; | 1526 | prop.scope = ve->network; |
1510 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); | 1527 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); |
1511 | GNUNET_assert (GNUNET_NO == | 1528 | GNUNET_assert (GNUNET_NO == |