aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_validation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-19 01:08:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-19 01:08:03 +0000
commitf735158d94616b75ade351a3cce226483b8af55e (patch)
tree1cd9732b99cc6437fec7751b8f3c9ef28f0371c9 /src/transport/gnunet-service-transport_validation.c
parentd769049a7db56037ea4aff3d9d8a8d42a373ec9c (diff)
downloadgnunet-f735158d94616b75ade351a3cce226483b8af55e.tar.gz
gnunet-f735158d94616b75ade351a3cce226483b8af55e.zip
-towards improved ATS API, adding return value with address record when adding address, adding new subsystem with peer-to-address map to transport; causes various new assertions to fail, but no major regression -- not finished
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r--src/transport/gnunet-service-transport_validation.c56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index b02c90009..03b125dc5 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010-2014 Christian Grothoff (and other contributing authors) 3 (C) 2010-2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -24,12 +24,13 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet-service-transport_ats.h"
28#include "gnunet-service-transport_blacklist.h"
27#include "gnunet-service-transport_clients.h" 29#include "gnunet-service-transport_clients.h"
28#include "gnunet-service-transport_validation.h"
29#include "gnunet-service-transport_plugins.h"
30#include "gnunet-service-transport_hello.h" 30#include "gnunet-service-transport_hello.h"
31#include "gnunet-service-transport_blacklist.h"
32#include "gnunet-service-transport_neighbours.h" 31#include "gnunet-service-transport_neighbours.h"
32#include "gnunet-service-transport_plugins.h"
33#include "gnunet-service-transport_validation.h"
33#include "gnunet-service-transport.h" 34#include "gnunet-service-transport.h"
34#include "gnunet_hello_lib.h" 35#include "gnunet_hello_lib.h"
35#include "gnunet_ats_service.h" 36#include "gnunet_ats_service.h"
@@ -253,6 +254,7 @@ struct ValidationEntry
253 * Current state of this validation entry 254 * Current state of this validation entry
254 */ 255 */
255 enum GNUNET_TRANSPORT_ValidationState state; 256 enum GNUNET_TRANSPORT_ValidationState state;
257
256 /** 258 /**
257 * Challenge number we used. 259 * Challenge number we used.
258 */ 260 */
@@ -275,6 +277,11 @@ struct ValidationEntry
275 int expecting_pong; 277 int expecting_pong;
276 278
277 /** 279 /**
280 * Is this address known to ATS as valid right now?
281 */
282 int known_to_ats;
283
284 /**
278 * Which network type does our address belong to? 285 * Which network type does our address belong to?
279 */ 286 */
280 enum GNUNET_ATS_Network_Type network; 287 enum GNUNET_ATS_Network_Type network;
@@ -445,6 +452,11 @@ cleanup_validation_entry (void *cls,
445 GNUNET_break (GNUNET_OK == 452 GNUNET_break (GNUNET_OK ==
446 GNUNET_CONTAINER_multipeermap_remove (validation_map, 453 GNUNET_CONTAINER_multipeermap_remove (validation_map,
447 &ve->pid, ve)); 454 &ve->pid, ve));
455 if (GNUNET_YES == ve->known_to_ats)
456 {
457 GST_ats_expire_address (ve->address);
458 ve->known_to_ats = GNUNET_NO;
459 }
448 GNUNET_HELLO_address_free (ve->address); 460 GNUNET_HELLO_address_free (ve->address);
449 if (NULL != ve->timeout_task) 461 if (NULL != ve->timeout_task)
450 { 462 {
@@ -593,7 +605,8 @@ transmit_ping_if_allowed (void *cls,
593 { 605 {
594 GNUNET_assert (NULL != papi->send); 606 GNUNET_assert (NULL != papi->send);
595 GNUNET_assert (NULL != papi->get_session); 607 GNUNET_assert (NULL != papi->get_session);
596 struct Session * session = papi->get_session(papi->cls, ve->address); 608 struct Session *session = papi->get_session (papi->cls,
609 ve->address);
597 610
598 if (NULL != session) 611 if (NULL != session)
599 { 612 {
@@ -847,8 +860,11 @@ add_valid_address (void *cls,
847 860
848 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 861 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
849 ats.value = htonl (ve->network); 862 ats.value = htonl (ve->network);
850 GNUNET_ATS_address_add (GST_ats, address, NULL, &ats, 1); 863 if (GNUNET_YES != ve->known_to_ats)
851 864 {
865 ve->known_to_ats = GNUNET_YES;
866 GST_ats_add_address (address, NULL, &ats, 1);
867 }
852 return GNUNET_OK; 868 return GNUNET_OK;
853} 869}
854 870
@@ -975,6 +991,7 @@ multicast_pong (void *cls,
975 GNUNET_break (0); 991 GNUNET_break (0);
976 return; 992 return;
977 } 993 }
994 GST_ats_new_session (address, session);
978 papi->send (papi->cls, session, 995 papi->send (papi->cls, session,
979 (const char *) pong, 996 (const char *) pong,
980 ntohs (pong->header.size), 997 ntohs (pong->header.size),
@@ -1190,18 +1207,19 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1190 1207
1191 /* first see if the session we got this PING from can be used to transmit 1208 /* first see if the session we got this PING from can be used to transmit
1192 * a response reliably */ 1209 * a response reliably */
1193 if (papi == NULL) 1210 if (NULL == papi)
1211 {
1194 ret = -1; 1212 ret = -1;
1213 }
1195 else 1214 else
1196 { 1215 {
1197 GNUNET_assert (papi->send != NULL); 1216 GNUNET_assert (NULL != papi->send);
1198 GNUNET_assert (papi->get_session != NULL); 1217 GNUNET_assert (NULL != papi->get_session);
1199 1218 if (NULL == session)
1200 if (session == NULL)
1201 { 1219 {
1202 session = papi->get_session (papi->cls, sender_address); 1220 session = papi->get_session (papi->cls, sender_address);
1203 } 1221 }
1204 if (session == NULL) 1222 if (NULL == session)
1205 { 1223 {
1206 GNUNET_break (0); 1224 GNUNET_break (0);
1207 ret = -1; 1225 ret = -1;
@@ -1491,8 +1509,15 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1491 ats[0].value = htonl ((uint32_t) ve->latency.rel_value_us); 1509 ats[0].value = htonl ((uint32_t) ve->latency.rel_value_us);
1492 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); 1510 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
1493 ats[1].value = htonl ((uint32_t) ve->network); 1511 ats[1].value = htonl ((uint32_t) ve->network);
1494 // FIXME: add vs. update! 1512 if (GNUNET_YES == ve->known_to_ats)
1495 GNUNET_ATS_address_add (GST_ats, ve->address, NULL, ats, 2); 1513 {
1514 GST_ats_update_metrics (ve->address, NULL, ats, 2);
1515 }
1516 else
1517 {
1518 ve->known_to_ats = GNUNET_YES;
1519 GST_ats_add_address (ve->address, NULL, ats, 2);
1520 }
1496 } 1521 }
1497 if (validations_running > 0) 1522 if (validations_running > 0)
1498 { 1523 {
@@ -1668,7 +1693,6 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
1668 } 1693 }
1669 if (ve->in_use == in_use) 1694 if (ve->in_use == in_use)
1670 { 1695 {
1671
1672 if (GNUNET_YES == in_use) 1696 if (GNUNET_YES == in_use)
1673 { 1697 {
1674 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1698 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,