/**
* Public key of the peer.
*/
- struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
+ struct GNUNET_CRYPTO_EccPublicKey public_key;
/**
* The identity of the peer. FIXME: duplicated (also in 'address')
/* FIXME: DEBUGGING */
int last_line_set_to_no;
int last_line_set_to_yes;
+
+ enum GNUNET_ATS_Network_Type network;
};
struct GNUNET_TRANSPORT_PluginFunctions *papi;
struct GNUNET_TIME_Absolute next;
const struct GNUNET_MessageHeader *hello;
+ enum GNUNET_ATS_Network_Type network;
ssize_t ret;
size_t tsize;
size_t slen;
message_buf, tsize,
PING_PRIORITY, ACCEPTABLE_PING_DELAY,
NULL, NULL);
+ network = papi->get_network (ve->address, session);
+ if (GNUNET_ATS_NET_UNSPECIFIED == network)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not obtain a valid network for `%s' %s\n",
+ GNUNET_i2s (pid), GST_plugins_a2s (ve->address));
+ GNUNET_break (0);
+ }
}
else
{
gettext_noop
("# PING without HELLO messages sent"), 1,
GNUNET_NO);
+
+ ve->network = network;
ve->expecting_pong = GNUNET_YES;
validations_running ++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
* if we don't have an existing entry and no public key was given
*/
static struct ValidationEntry *
-find_validation_entry (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded
- *public_key, const struct GNUNET_HELLO_Address *address)
+find_validation_entry (const struct GNUNET_CRYPTO_EccPublicKey *public_key,
+ const struct GNUNET_HELLO_Address *address)
{
struct ValidationEntryMatchContext vemc;
struct ValidationEntry *ve;
const struct GNUNET_HELLO_Message *hello = cls;
struct ValidationEntry *ve;
struct GNUNET_PeerIdentity pid;
- struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
+ struct GNUNET_ATS_Information ats;
+ struct GNUNET_CRYPTO_EccPublicKey public_key;
if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
return GNUNET_OK; /* expired */
if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task)
ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
- GNUNET_ATS_address_add (GST_ats, address, NULL, NULL, 0);
+
+ ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
+ ats.value = htonl (ve->network);
+ GNUNET_ATS_address_add (GST_ats, address, NULL, &ats, 1);
+
return GNUNET_OK;
}
*/
static void
multicast_pong (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded
- *public_key, struct GNUNET_TIME_Absolute valid_until,
+ const struct GNUNET_CRYPTO_EccPublicKey *public_key,
+ struct GNUNET_TIME_Absolute valid_until,
struct GNUNET_TIME_Absolute validation_block,
const struct GNUNET_HELLO_Address *address)
{
struct GNUNET_TIME_Absolute *sig_cache_exp;
const char *addr;
const char *addrend;
+ char *plugin_name;
+ char *pos;
size_t alen;
size_t slen;
ssize_t ret;
sig_cache = NULL;
sig_cache_exp = NULL;
-
+ papi = NULL;
if (alen > 0)
{
addrend = memchr (addr, '\0', alen);
address.transport_name = addr;
address.peer = GST_my_identity;
+ if (NULL == address.transport_name)
+ {
+ GNUNET_break (0);
+ }
+
+ if (0 != strstr (address.transport_name, "_client"))
+ {
+ plugin_name = GNUNET_strdup (address.transport_name);
+ pos = strstr (plugin_name, "_client");
+ GNUNET_assert (NULL != pos);
+ GNUNET_snprintf (pos, strlen ("_server") + 1, "%s", "_server");
+ }
+ else
+ plugin_name = GNUNET_strdup (address.transport_name);
+
+ if (NULL == (papi = GST_plugins_find (plugin_name)))
+ {
+ /* we don't have the plugin for this address */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Plugin `%s' not available, cannot confirm having this address \n",
+ plugin_name);
+ GNUNET_free (plugin_name);
+ return;
+ }
+ GNUNET_free (plugin_name);
+ if (GNUNET_OK != papi->check_address (papi->cls, addrend, alen))
+ {
+ GNUNET_STATISTICS_update (GST_stats,
+ gettext_noop
+ ("# failed address checks during validation"), 1,
+ GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address `%s' is not one of my addresses, not confirming PING\n",
+ GST_plugins_a2s (&address));
+ return;
+ }
+ else
+ {
+ GNUNET_STATISTICS_update (GST_stats,
+ gettext_noop
+ ("# successful address checks during validation"), 1,
+ GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Address `%s' is one of my addresses, confirming PING\n",
+ GST_plugins_a2s (&address));
+ }
if (GNUNET_YES != GST_hello_test_address (&address, &sig_cache, &sig_cache_exp))
{
"Creating PONG signature to indicate ownership.\n");
*sig_cache_exp = GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME);
pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp);
- GNUNET_assert (GNUNET_OK ==
+ if (GNUNET_OK !=
GNUNET_CRYPTO_ecc_sign (GST_my_private_key, &pong->purpose,
- sig_cache));
+ sig_cache))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to create PONG signature for peer `%s'\n"), GNUNET_i2s (sender));
+ }
}
else
{
/* first see if the session we got this PING from can be used to transmit
* a response reliably */
- papi = GST_plugins_find (sender_address->transport_name);
if (papi == NULL)
ret = -1;
else
/**
* Public key of the peer whose address is being validated.
*/
- struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
+ struct GNUNET_CRYPTO_EccPublicKey public_key;
};
ve->pong_sig_valid_until = GNUNET_TIME_absolute_ntoh (pong->expiration);
ve->latency = GNUNET_TIME_absolute_get_duration (ve->send_time);
{
- struct GNUNET_ATS_Information ats;
- ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
- ats.value = htonl ((uint32_t) ve->latency.rel_value);
- GNUNET_ATS_address_add (GST_ats, ve->address, NULL, &ats, 1);
+ struct GNUNET_ATS_Information ats[2];
+ ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
+ ats[0].value = htonl ((uint32_t) ve->latency.rel_value);
+ ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
+ ats[1].value = htonl ((uint32_t) ve->network);
+ GNUNET_ATS_address_add (GST_ats, ve->address, NULL, ats, 2);
}
if (validations_running > 0)
{