aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_validation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-02 22:25:48 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-02 22:25:48 +0000
commit69c3a52cfa679175da8f06bdcb8e2e4195465e44 (patch)
tree73109126cfcf1a807c5dc1e778f40b955fc959c5 /src/transport/gnunet-service-transport_validation.c
parentc42deb089faffd654e27bf661ce85d5c1bb38b7a (diff)
downloadgnunet-69c3a52cfa679175da8f06bdcb8e2e4195465e44.tar.gz
gnunet-69c3a52cfa679175da8f06bdcb8e2e4195465e44.zip
avoid passing both PeerIdentity and Address (which contains PeerIdentity) if address is always present as then this is redundant
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r--src/transport/gnunet-service-transport_validation.c150
1 files changed, 49 insertions, 101 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 59b99b8fc..d0a731789 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -190,11 +190,6 @@ struct ValidationEntry
190 struct GST_BlacklistCheck *bc; 190 struct GST_BlacklistCheck *bc;
191 191
192 /** 192 /**
193 * Public key of the peer.
194 */
195 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
196
197 /**
198 * Cached PONG signature 193 * Cached PONG signature
199 */ 194 */
200 struct GNUNET_CRYPTO_EddsaSignature pong_sig_cache; 195 struct GNUNET_CRYPTO_EddsaSignature pong_sig_cache;
@@ -388,7 +383,7 @@ validation_entry_match (void *cls,
388 struct ValidationEntryMatchContext *vemc = cls; 383 struct ValidationEntryMatchContext *vemc = cls;
389 struct ValidationEntry *ve = value; 384 struct ValidationEntry *ve = value;
390 385
391 if (0 == GNUNET_HELLO_address_cmp (ve->address, 386 if (0 == GNUNET_HELLO_address_cmp (ve->address,
392 vemc->address)) 387 vemc->address))
393 { 388 {
394 vemc->ve = ve; 389 vemc->ve = ve;
@@ -447,7 +442,7 @@ cleanup_validation_entry (void *cls,
447 } 442 }
448 GNUNET_break (GNUNET_OK == 443 GNUNET_break (GNUNET_OK ==
449 GNUNET_CONTAINER_multipeermap_remove (validation_map, 444 GNUNET_CONTAINER_multipeermap_remove (validation_map,
450 &ve->address->peer, 445 &ve->address->peer,
451 ve)); 446 ve));
452 if (GNUNET_YES == ve->known_to_ats) 447 if (GNUNET_YES == ve->known_to_ats)
453 { 448 {
@@ -585,10 +580,10 @@ transmit_ping_if_allowed (void *cls,
585 * [HELLO][TransportPingMessage][Transport name][Address] */ 580 * [HELLO][TransportPingMessage][Transport name][Address] */
586 memcpy (message_buf, hello, hsize); 581 memcpy (message_buf, hello, hsize);
587 memcpy (&message_buf[hsize], 582 memcpy (&message_buf[hsize],
588 &ping, 583 &ping,
589 sizeof (struct TransportPingMessage)); 584 sizeof (struct TransportPingMessage));
590 memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], 585 memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize],
591 ve->address->transport_name, 586 ve->address->transport_name,
592 slen); 587 slen);
593 memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], 588 memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize],
594 ve->address->address, 589 ve->address->address,
@@ -624,7 +619,7 @@ transmit_ping_if_allowed (void *cls,
624 GST_plugins_a2s (ve->address)); 619 GST_plugins_a2s (ve->address));
625 GNUNET_break(0); 620 GNUNET_break(0);
626 } 621 }
627 GST_neighbours_notify_data_sent (pid, ve->address, session, tsize); 622 GST_neighbours_notify_data_sent (ve->address, session, tsize);
628 } 623 }
629 else 624 else
630 { 625 {
@@ -709,7 +704,7 @@ revalidate_address (void *cls,
709 ve->revalidation_task = 704 ve->revalidation_task =
710 GNUNET_SCHEDULER_add_delayed (delay, 705 GNUNET_SCHEDULER_add_delayed (delay,
711 &revalidate_address, ve); 706 &revalidate_address, ve);
712 ve->next_validation = GNUNET_TIME_relative_to_absolute (delay); 707 ve->next_validation = GNUNET_TIME_relative_to_absolute (delay);
713 return; 708 return;
714 } 709 }
715 /* check if globally we have too many active validations at a 710 /* check if globally we have too many active validations at a
@@ -726,7 +721,7 @@ revalidate_address (void *cls,
726 GST_plugins_a2s (ve->address)); 721 GST_plugins_a2s (ve->address));
727 ve->revalidation_task = 722 ve->revalidation_task =
728 GNUNET_SCHEDULER_add_delayed (blocked_for, &revalidate_address, ve); 723 GNUNET_SCHEDULER_add_delayed (blocked_for, &revalidate_address, ve);
729 ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for); 724 ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for);
730 return; 725 return;
731 } 726 }
732 727
@@ -769,14 +764,12 @@ revalidate_address (void *cls,
769 * the given address and transport. If none exists, create one (but 764 * the given address and transport. If none exists, create one (but
770 * without starting any validation). 765 * without starting any validation).
771 * 766 *
772 * @param public_key public key of the peer, NULL for unknown
773 * @param address address to find 767 * @param address address to find
774 * @return validation entry matching the given specifications, NULL 768 * @return validation entry matching the given specifications, NULL
775 * if we don't have an existing entry and no public key was given 769 * if we don't have an existing entry and no public key was given
776 */ 770 */
777static struct ValidationEntry * 771static struct ValidationEntry *
778find_validation_entry (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, 772find_validation_entry (const struct GNUNET_HELLO_Address *address)
779 const struct GNUNET_HELLO_Address *address)
780{ 773{
781 struct ValidationEntryMatchContext vemc; 774 struct ValidationEntryMatchContext vemc;
782 struct ValidationEntry *ve; 775 struct ValidationEntry *ve;
@@ -788,12 +781,9 @@ find_validation_entry (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
788 &validation_entry_match, &vemc); 781 &validation_entry_match, &vemc);
789 if (NULL != (ve = vemc.ve)) 782 if (NULL != (ve = vemc.ve))
790 return ve; 783 return ve;
791 if (NULL == public_key)
792 return NULL;
793 ve = GNUNET_new (struct ValidationEntry); 784 ve = GNUNET_new (struct ValidationEntry);
794 ve->in_use = GNUNET_SYSERR; /* not defined */ 785 ve->in_use = GNUNET_SYSERR; /* not defined */
795 ve->address = GNUNET_HELLO_address_copy (address); 786 ve->address = GNUNET_HELLO_address_copy (address);
796 ve->public_key = *public_key;
797 ve->pong_sig_valid_until = GNUNET_TIME_absolute_get_zero_(); 787 ve->pong_sig_valid_until = GNUNET_TIME_absolute_get_zero_();
798 memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature)); 788 memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature));
799 ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; 789 ve->latency = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -828,12 +818,10 @@ add_valid_address (void *cls,
828 struct ValidationEntry *ve; 818 struct ValidationEntry *ve;
829 struct GNUNET_PeerIdentity pid; 819 struct GNUNET_PeerIdentity pid;
830 struct GNUNET_ATS_Information ats; 820 struct GNUNET_ATS_Information ats;
831 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
832 821
833 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) 822 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
834 return GNUNET_OK; /* expired */ 823 return GNUNET_OK; /* expired */
835 if ((GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) || 824 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
836 (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key)))
837 { 825 {
838 GNUNET_break (0); 826 GNUNET_break (0);
839 return GNUNET_OK; /* invalid HELLO !? */ 827 return GNUNET_OK; /* invalid HELLO !? */
@@ -852,7 +840,7 @@ add_valid_address (void *cls,
852 return GNUNET_OK; 840 return GNUNET_OK;
853 } 841 }
854 842
855 ve = find_validation_entry (&public_key, address); 843 ve = find_validation_entry (address);
856 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, 844 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until,
857 expiration); 845 expiration);
858 if (NULL == ve->revalidation_task) 846 if (NULL == ve->revalidation_task)
@@ -967,7 +955,6 @@ GST_validation_stop ()
967 * Send the given PONG to the given address. 955 * Send the given PONG to the given address.
968 * 956 *
969 * @param cls the PONG message 957 * @param cls the PONG message
970 * @param public_key public key for the peer, never NULL
971 * @param valid_until is ZERO if we never validated the address, 958 * @param valid_until is ZERO if we never validated the address,
972 * otherwise a time up to when we consider it (or was) valid 959 * otherwise a time up to when we consider it (or was) valid
973 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) 960 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
@@ -977,7 +964,6 @@ GST_validation_stop ()
977 */ 964 */
978static void 965static void
979multicast_pong (void *cls, 966multicast_pong (void *cls,
980 const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
981 struct GNUNET_TIME_Absolute valid_until, 967 struct GNUNET_TIME_Absolute valid_until,
982 struct GNUNET_TIME_Absolute validation_block, 968 struct GNUNET_TIME_Absolute validation_block,
983 const struct GNUNET_HELLO_Address *address) 969 const struct GNUNET_HELLO_Address *address)
@@ -1005,8 +991,7 @@ multicast_pong (void *cls,
1005 PONG_PRIORITY, 991 PONG_PRIORITY,
1006 ACCEPTABLE_PING_DELAY, 992 ACCEPTABLE_PING_DELAY,
1007 NULL, NULL); 993 NULL, NULL);
1008 GST_neighbours_notify_data_sent (&address->peer, 994 GST_neighbours_notify_data_sent (address,
1009 address,
1010 session, 995 session,
1011 pong->header.size); 996 pong->header.size);
1012 997
@@ -1234,12 +1219,13 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1234 else 1219 else
1235 { 1220 {
1236 ret = papi->send (papi->cls, session, 1221 ret = papi->send (papi->cls, session,
1237 (const char *) pong, ntohs (pong->header.size), 1222 (const char *) pong,
1223 ntohs (pong->header.size),
1238 PONG_PRIORITY, ACCEPTABLE_PING_DELAY, 1224 PONG_PRIORITY, ACCEPTABLE_PING_DELAY,
1239 NULL, NULL); 1225 NULL, NULL);
1240 if (-1 != ret) 1226 if (-1 != ret)
1241 GST_neighbours_notify_data_sent (sender, 1227 GST_neighbours_notify_data_sent (sender_address,
1242 sender_address, session, 1228 session,
1243 pong->header.size); 1229 pong->header.size);
1244 } 1230 }
1245 } 1231 }
@@ -1270,28 +1256,10 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1270 1256
1271 1257
1272/** 1258/**
1273 * Context for the #validate_address_iterator() function
1274 */
1275struct ValidateAddressContext
1276{
1277 /**
1278 * Hash of the public key of the peer whose address is being validated.
1279 */
1280 struct GNUNET_PeerIdentity pid;
1281
1282 /**
1283 * Public key of the peer whose address is being validated.
1284 */
1285 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
1286
1287};
1288
1289
1290/**
1291 * Iterator callback to go over all addresses and try to validate them 1259 * Iterator callback to go over all addresses and try to validate them
1292 * (unless blocked or already validated). 1260 * (unless blocked or already validated).
1293 * 1261 *
1294 * @param cls pointer to a `struct ValidateAddressContext *` 1262 * @param cls NULL
1295 * @param address the address 1263 * @param address the address
1296 * @param expiration expiration time 1264 * @param expiration expiration time
1297 * @return #GNUNET_OK (keep the address) 1265 * @return #GNUNET_OK (keep the address)
@@ -1301,10 +1269,8 @@ validate_address_iterator (void *cls,
1301 const struct GNUNET_HELLO_Address *address, 1269 const struct GNUNET_HELLO_Address *address,
1302 struct GNUNET_TIME_Absolute expiration) 1270 struct GNUNET_TIME_Absolute expiration)
1303{ 1271{
1304 const struct ValidateAddressContext *vac = cls;
1305 struct GNUNET_TRANSPORT_PluginFunctions * papi; 1272 struct GNUNET_TRANSPORT_PluginFunctions * papi;
1306 struct ValidationEntry *ve; 1273 struct ValidationEntry *ve;
1307 struct GNUNET_TIME_Relative canonical_delay;
1308 1274
1309 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) 1275 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
1310 { 1276 {
@@ -1312,34 +1278,13 @@ validate_address_iterator (void *cls,
1312 "Skipping expired address from HELLO\n"); 1278 "Skipping expired address from HELLO\n");
1313 return GNUNET_OK; /* expired */ 1279 return GNUNET_OK; /* expired */
1314 } 1280 }
1315 ve = find_validation_entry (&vac->public_key, address); 1281 papi = GST_plugins_find (address->transport_name);
1316 1282 if (NULL == papi)
1317 papi = GST_plugins_find (ve->address->transport_name);
1318 if (papi == NULL)
1319 { 1283 {
1320 /* This plugin is currently unvailable ... retry later */ 1284 /* This plugin is currently unvailable ... ignore */
1321 if (NULL == ve->revalidation_task)
1322 {
1323 if (GNUNET_YES == ve->in_use)
1324 canonical_delay = CONNECTED_PING_FREQUENCY;
1325 else if (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value_us > 0)
1326 canonical_delay = VALIDATED_PING_FREQUENCY;
1327 else
1328 canonical_delay = UNVALIDATED_PING_KEEPALIVE;
1329
1330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1331 "Plugin `%s' unavailable, validation process for peer `%s' delayed for %llu ms\n",
1332 ve->address->transport_name,
1333 GNUNET_i2s (&ve->address->peer),
1334 (long long unsigned) canonical_delay.rel_value_us / 1000);
1335
1336 ve->revalidation_task = GNUNET_SCHEDULER_add_delayed (canonical_delay,
1337 &revalidate_address, ve);
1338 }
1339 return GNUNET_OK; 1285 return GNUNET_OK;
1340 } 1286 }
1341 1287 ve = find_validation_entry (address);
1342
1343 if (NULL == ve->revalidation_task) 1288 if (NULL == ve->revalidation_task)
1344 { 1289 {
1345 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1290 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1427,7 +1372,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1427 address.address_length = addrlen; 1372 address.address_length = addrlen;
1428 address.transport_name = tname; 1373 address.transport_name = tname;
1429 address.local_info = GNUNET_HELLO_ADDRESS_INFO_NONE; 1374 address.local_info = GNUNET_HELLO_ADDRESS_INFO_NONE;
1430 ve = find_validation_entry (NULL, &address); 1375 ve = find_validation_entry (&address);
1431 if ((NULL == ve) || (GNUNET_NO == ve->expecting_pong)) 1376 if ((NULL == ve) || (GNUNET_NO == ve->expecting_pong))
1432 { 1377 {
1433 GNUNET_STATISTICS_update (GST_stats, 1378 GNUNET_STATISTICS_update (GST_stats,
@@ -1437,8 +1382,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1437 return GNUNET_OK; 1382 return GNUNET_OK;
1438 } 1383 }
1439 /* now check that PONG is well-formed */ 1384 /* now check that PONG is well-formed */
1440 if (0 != memcmp (&ve->address->peer, 1385 if (0 != memcmp (&ve->address->peer,
1441 sender, 1386 sender,
1442 sizeof (struct GNUNET_PeerIdentity))) 1387 sizeof (struct GNUNET_PeerIdentity)))
1443 { 1388 {
1444 GNUNET_break_op (0); 1389 GNUNET_break_op (0);
@@ -1479,7 +1424,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1479 /* Do expensive verification */ 1424 /* Do expensive verification */
1480 sig_res = GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, 1425 sig_res = GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
1481 &pong->purpose, &pong->signature, 1426 &pong->purpose, &pong->signature,
1482 &ve->public_key); 1427 &ve->address->peer.public_key);
1483 if (sig_res == GNUNET_SYSERR) 1428 if (sig_res == GNUNET_SYSERR)
1484 { 1429 {
1485 GNUNET_break_op (0); 1430 GNUNET_break_op (0);
@@ -1549,7 +1494,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1549 1494
1550 /* build HELLO to store in PEERINFO */ 1495 /* build HELLO to store in PEERINFO */
1551 ve->copied = GNUNET_NO; 1496 ve->copied = GNUNET_NO;
1552 hello = GNUNET_HELLO_create (&ve->public_key, 1497 hello = GNUNET_HELLO_create (&ve->address->peer.public_key,
1553 &add_valid_peer_address, ve, 1498 &add_valid_peer_address, ve,
1554 GNUNET_NO); 1499 GNUNET_NO);
1555 GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL); 1500 GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL);
@@ -1570,41 +1515,43 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1570{ 1515{
1571 const struct GNUNET_HELLO_Message *hm = 1516 const struct GNUNET_HELLO_Message *hm =
1572 (const struct GNUNET_HELLO_Message *) hello; 1517 (const struct GNUNET_HELLO_Message *) hello;
1573 struct ValidateAddressContext vac; 1518 struct GNUNET_PeerIdentity pid;
1574 struct GNUNET_HELLO_Message *h; 1519 struct GNUNET_HELLO_Message *h;
1575 int friend; 1520 int friend;
1576 1521
1577 friend = GNUNET_HELLO_is_friend_only (hm); 1522 friend = GNUNET_HELLO_is_friend_only (hm);
1578 if ( ( (GNUNET_YES != friend) && 1523 if ( ( (GNUNET_YES != friend) &&
1579 (GNUNET_NO != friend) ) || 1524 (GNUNET_NO != friend) ) ||
1580 (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) || 1525 (GNUNET_OK != GNUNET_HELLO_get_id (hm, &pid)) )
1581 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
1582 { 1526 {
1583 /* malformed HELLO */ 1527 /* malformed HELLO */
1584 GNUNET_break_op (0); 1528 GNUNET_break_op (0);
1585 return GNUNET_SYSERR; 1529 return GNUNET_SYSERR;
1586 } 1530 }
1587 if (0 == 1531 if (0 ==
1588 memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity))) 1532 memcmp (&GST_my_identity,
1533 &pid,
1534 sizeof (struct GNUNET_PeerIdentity)))
1589 return GNUNET_OK; 1535 return GNUNET_OK;
1590 /* Add peer identity without addresses to peerinfo service */ 1536 /* Add peer identity without addresses to peerinfo service */
1591 h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend); 1537 h = GNUNET_HELLO_create (&pid.public_key, NULL, NULL, friend);
1592 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1538 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1593 _("Validation received new %s message for peer `%s' with size %u\n"), 1539 _("Validation received new %s message for peer `%s' with size %u\n"),
1594 "HELLO", 1540 "HELLO",
1595 GNUNET_i2s (&vac.pid), 1541 GNUNET_i2s (&pid),
1596 ntohs (hello->size)); 1542 ntohs (hello->size));
1597 GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL); 1543 GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
1598 1544
1599 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1600 _("Adding `%s' without addresses for peer `%s'\n"), "HELLO", 1546 _("Adding `%s' without addresses for peer `%s'\n"), "HELLO",
1601 GNUNET_i2s (&vac.pid)); 1547 GNUNET_i2s (&pid));
1602 1548
1603 GNUNET_free (h); 1549 GNUNET_free (h);
1604 GNUNET_assert (NULL == 1550 GNUNET_assert (NULL ==
1605 GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO, 1551 GNUNET_HELLO_iterate_addresses (hm,
1552 GNUNET_NO,
1606 &validate_address_iterator, 1553 &validate_address_iterator,
1607 &vac)); 1554 NULL));
1608 return GNUNET_OK; 1555 return GNUNET_OK;
1609} 1556}
1610 1557
@@ -1644,7 +1591,6 @@ iterate_addresses (void *cls,
1644 struct ValidationEntry *ve = value; 1591 struct ValidationEntry *ve = value;
1645 1592
1646 ic->cb (ic->cb_cls, 1593 ic->cb (ic->cb_cls,
1647 &ve->public_key,
1648 ve->valid_until, 1594 ve->valid_until,
1649 ve->revalidation_block, 1595 ve->revalidation_block,
1650 ve->address); 1596 ve->address);
@@ -1662,7 +1608,8 @@ iterate_addresses (void *cls,
1662 */ 1608 */
1663void 1609void
1664GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, 1610GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
1665 GST_ValidationAddressCallback cb, void *cb_cls) 1611 GST_ValidationAddressCallback cb,
1612 void *cb_cls)
1666{ 1613{
1667 struct IteratorContext ic; 1614 struct IteratorContext ic;
1668 1615
@@ -1691,8 +1638,11 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
1691{ 1638{
1692 struct ValidationEntry *ve; 1639 struct ValidationEntry *ve;
1693 1640
1641 if (GNUNET_HELLO_address_check_option (address,
1642 GNUNET_HELLO_ADDRESS_INFO_INBOUND))
1643 return; /* ignore inbound for validation */
1694 if (NULL != address) 1644 if (NULL != address)
1695 ve = find_validation_entry (NULL, address); 1645 ve = find_validation_entry (address);
1696 else 1646 else
1697 ve = NULL; /* FIXME: lookup based on session... */ 1647 ve = NULL; /* FIXME: lookup based on session... */
1698 if (NULL == ve) 1648 if (NULL == ve)
@@ -1721,7 +1671,8 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
1721 if (in_use == GNUNET_YES) 1671 if (in_use == GNUNET_YES)
1722 { 1672 {
1723 /* from now on, higher frequeny, so reschedule now */ 1673 /* from now on, higher frequeny, so reschedule now */
1724 GNUNET_SCHEDULER_cancel (ve->revalidation_task); 1674 if (NULL != ve->revalidation_task)
1675 GNUNET_SCHEDULER_cancel (ve->revalidation_task);
1725 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); 1676 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
1726 } 1677 }
1727} 1678}
@@ -1731,15 +1682,13 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
1731 * Query validation about the latest observed latency on a given 1682 * Query validation about the latest observed latency on a given
1732 * address. 1683 * address.
1733 * 1684 *
1734 * @param sender peer
1735 * @param address the address 1685 * @param address the address
1736 * @param session session 1686 * @param session session
1737 * @return observed latency of the address, FOREVER if the address was 1687 * @return observed latency of the address, FOREVER if the address was
1738 * never successfully validated 1688 * never successfully validated
1739 */ 1689 */
1740struct GNUNET_TIME_Relative 1690struct GNUNET_TIME_Relative
1741GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, 1691GST_validation_get_address_latency (const struct GNUNET_HELLO_Address *address,
1742 const struct GNUNET_HELLO_Address *address,
1743 struct Session *session) 1692 struct Session *session)
1744{ 1693{
1745 struct ValidationEntry *ve; 1694 struct ValidationEntry *ve;
@@ -1749,7 +1698,7 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
1749 GNUNET_break (0); // FIXME: support having latency only with session... 1698 GNUNET_break (0); // FIXME: support having latency only with session...
1750 return GNUNET_TIME_UNIT_FOREVER_REL; 1699 return GNUNET_TIME_UNIT_FOREVER_REL;
1751 } 1700 }
1752 ve = find_validation_entry (NULL, address); 1701 ve = find_validation_entry (address);
1753 if (NULL == ve) 1702 if (NULL == ve)
1754 return GNUNET_TIME_UNIT_FOREVER_REL; 1703 return GNUNET_TIME_UNIT_FOREVER_REL;
1755 return ve->latency; 1704 return ve->latency;
@@ -1790,13 +1739,12 @@ validation_entries_iterate (void *cls,
1790 struct ValidationIteratorContext *ic = cls; 1739 struct ValidationIteratorContext *ic = cls;
1791 struct ValidationEntry *ve = value; 1740 struct ValidationEntry *ve = value;
1792 1741
1793 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1794 "Notifying about validation entry for peer `%s' address `%s' \n", 1743 "Notifying about validation entry for peer `%s' address `%s' \n",
1795 GNUNET_i2s (&ve->address->peer), 1744 GNUNET_i2s (&ve->address->peer),
1796 GST_plugins_a2s (ve->address)); 1745 GST_plugins_a2s (ve->address));
1797 ic->cb (ic->cb_cls, 1746 ic->cb (ic->cb_cls,
1798 &ve->address->peer, 1747 ve->address,
1799 ve->address,
1800 ve->send_time, 1748 ve->send_time,
1801 ve->valid_until, 1749 ve->valid_until,
1802 ve->next_validation, 1750 ve->next_validation,