aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-22 19:57:22 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-22 19:57:22 +0000
commit658f44879747d23c92e30ca004b04e2dddac73d8 (patch)
treec3e225cc738cc9588393c6de2b908b4f6e4b9f04
parent58121840c21ad0a64d6e2b11dd01f50064ca1773 (diff)
downloadgnunet-658f44879747d23c92e30ca004b04e2dddac73d8.tar.gz
gnunet-658f44879747d23c92e30ca004b04e2dddac73d8.zip
-simplify logic a bit, doxygen, indentation
-rw-r--r--src/transport/gnunet-service-transport.c32
-rw-r--r--src/transport/gnunet-service-transport_clients.c46
-rw-r--r--src/transport/gnunet-service-transport_validation.c102
-rw-r--r--src/transport/gnunet-service-transport_validation.h72
-rw-r--r--src/transport/gnunet-transport.c18
-rw-r--r--src/transport/transport.h9
-rw-r--r--src/transport/transport_api_monitoring.c42
7 files changed, 158 insertions, 163 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 936742e7b..a41aa7f65 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -1009,35 +1009,6 @@ neighbours_changed_notification (void *cls,
1009 GST_clients_broadcast_peer_notification (peer, address, state, state_timeout); 1009 GST_clients_broadcast_peer_notification (peer, address, state, state_timeout);
1010} 1010}
1011 1011
1012/**
1013 * Function called to notify transport users that a neighbour peer changed its
1014 * active address.
1015 *
1016 * @param cls closure
1017 * @param peer peer this update is about (never NULL)
1018 * @param address address (never NULL)
1019 * @param last_validation point in time when last validation was performed
1020 * @param valid_until point in time how long address is valid
1021 * @param next_validation point in time when next validation will be performed
1022 * @param state state of validation notification
1023 */
1024static void
1025validation_changed_notification (void *cls,
1026 const struct GNUNET_PeerIdentity *peer,
1027 const struct GNUNET_HELLO_Address *address,
1028 struct GNUNET_TIME_Absolute last_validation,
1029 struct GNUNET_TIME_Absolute valid_until,
1030 struct GNUNET_TIME_Absolute next_validation,
1031 enum GNUNET_TRANSPORT_ValidationState state)
1032{
1033 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1034 "Notifying about change for for validation entry for peer `%s' with address `%s'\n",
1035 GNUNET_i2s (peer),
1036 (NULL != address) ? GST_plugins_a2s (address) : "<none>");
1037
1038 GST_clients_broadcast_validation_notification (peer, address,
1039 last_validation, valid_until, next_validation, state);
1040}
1041 1012
1042/** 1013/**
1043 * Function called when the service shuts down. Unloads our plugins 1014 * Function called when the service shuts down. Unloads our plugins
@@ -1191,9 +1162,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1191 &neighbours_changed_notification, 1162 &neighbours_changed_notification,
1192 (max_fd / 3) * 2); 1163 (max_fd / 3) * 2);
1193 GST_clients_start (GST_server); 1164 GST_clients_start (GST_server);
1194 GST_validation_start (&validation_changed_notification, NULL, (max_fd / 3)); 1165 GST_validation_start ((max_fd / 3));
1195} 1166}
1196 1167
1168
1197/** 1169/**
1198 * The main function for the transport service. 1170 * The main function for the transport service.
1199 * 1171 *
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index fc3abdd1a..29d506ab3 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -1115,10 +1115,11 @@ struct IterationContext
1115 int all; 1115 int all;
1116}; 1116};
1117 1117
1118
1118/** 1119/**
1119 * Output information of validation entries to the given client. 1120 * Output information of validation entries to the given client.
1120 * 1121 *
1121 * @param cls the 'struct IterationContext' 1122 * @param cls the `struct IterationContext *`
1122 * @param peer identity of the neighbour 1123 * @param peer identity of the neighbour
1123 * @param address the address 1124 * @param address the address
1124 * @param last_validation point in time when last validation was performed 1125 * @param last_validation point in time when last validation was performed
@@ -1128,12 +1129,12 @@ struct IterationContext
1128 */ 1129 */
1129static void 1130static void
1130send_validation_information (void *cls, 1131send_validation_information (void *cls,
1131 const struct GNUNET_PeerIdentity *peer, 1132 const struct GNUNET_PeerIdentity *peer,
1132 const struct GNUNET_HELLO_Address *address, 1133 const struct GNUNET_HELLO_Address *address,
1133 struct GNUNET_TIME_Absolute last_validation, 1134 struct GNUNET_TIME_Absolute last_validation,
1134 struct GNUNET_TIME_Absolute valid_until, 1135 struct GNUNET_TIME_Absolute valid_until,
1135 struct GNUNET_TIME_Absolute next_validation, 1136 struct GNUNET_TIME_Absolute next_validation,
1136 enum GNUNET_TRANSPORT_ValidationState state) 1137 enum GNUNET_TRANSPORT_ValidationState state)
1137{ 1138{
1138 struct IterationContext *pc = cls; 1139 struct IterationContext *pc = cls;
1139 struct ValidationIterateResponseMessage *msg; 1140 struct ValidationIterateResponseMessage *msg;
@@ -1158,7 +1159,7 @@ send_validation_information (void *cls,
1158/** 1159/**
1159 * Output information of neighbours to the given client. 1160 * Output information of neighbours to the given client.
1160 * 1161 *
1161 * @param cls the 'struct PeerIterationContext' 1162 * @param cls the `struct PeerIterationContext *`
1162 * @param peer identity of the neighbour 1163 * @param peer identity of the neighbour
1163 * @param address the address 1164 * @param address the address
1164 * @param state current state this peer is in 1165 * @param state current state this peer is in
@@ -1168,12 +1169,12 @@ send_validation_information (void *cls,
1168 */ 1169 */
1169static void 1170static void
1170send_peer_information (void *cls, 1171send_peer_information (void *cls,
1171 const struct GNUNET_PeerIdentity *peer, 1172 const struct GNUNET_PeerIdentity *peer,
1172 const struct GNUNET_HELLO_Address *address, 1173 const struct GNUNET_HELLO_Address *address,
1173 enum GNUNET_TRANSPORT_PeerState state, 1174 enum GNUNET_TRANSPORT_PeerState state,
1174 struct GNUNET_TIME_Absolute state_timeout, 1175 struct GNUNET_TIME_Absolute state_timeout,
1175 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 1176 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1176 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) 1177 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
1177{ 1178{
1178 struct IterationContext *pc = cls; 1179 struct IterationContext *pc = cls;
1179 struct PeerIterateResponseMessage *msg; 1180 struct PeerIterateResponseMessage *msg;
@@ -1498,21 +1499,20 @@ GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer,
1498 * @param state state of validation notification 1499 * @param state state of validation notification
1499 */ 1500 */
1500void 1501void
1501GST_clients_broadcast_validation_notification ( 1502GST_clients_broadcast_validation_notification (const struct GNUNET_PeerIdentity *peer,
1502 const struct GNUNET_PeerIdentity *peer, 1503 const struct GNUNET_HELLO_Address *address,
1503 const struct GNUNET_HELLO_Address *address, 1504 struct GNUNET_TIME_Absolute last_validation,
1504 struct GNUNET_TIME_Absolute last_validation, 1505 struct GNUNET_TIME_Absolute valid_until,
1505 struct GNUNET_TIME_Absolute valid_until, 1506 struct GNUNET_TIME_Absolute next_validation,
1506 struct GNUNET_TIME_Absolute next_validation, 1507 enum GNUNET_TRANSPORT_ValidationState state)
1507 enum GNUNET_TRANSPORT_ValidationState state)
1508{ 1508{
1509 struct ValidationIterateResponseMessage *msg; 1509 struct ValidationIterateResponseMessage *msg;
1510 struct MonitoringClient *mc; 1510 struct MonitoringClient *mc;
1511 static struct GNUNET_PeerIdentity all_zeros; 1511 static struct GNUNET_PeerIdentity all_zeros;
1512 1512
1513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1514 "Sending information about for validation entry for peer `%s' using address `%s'\n", 1514 "Sending information about for validation entry for peer `%s' using address `%s'\n",
1515 GNUNET_i2s(peer), (address != NULL) ? GST_plugins_a2s (address) : "<none>"); 1515 GNUNET_i2s(peer), (address != NULL) ? GST_plugins_a2s (address) : "<none>");
1516 1516
1517 msg = compose_validation_iterate_response_message (peer, address); 1517 msg = compose_validation_iterate_response_message (peer, address);
1518 msg->last_validation = GNUNET_TIME_absolute_hton(last_validation); 1518 msg->last_validation = GNUNET_TIME_absolute_hton(last_validation);
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 7c2675df3..6621ecc67 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-2013 Christian Grothoff (and other contributing authors) 3 (C) 2010-2014 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,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet-service-transport_clients.h"
27#include "gnunet-service-transport_validation.h" 28#include "gnunet-service-transport_validation.h"
28#include "gnunet-service-transport_plugins.h" 29#include "gnunet-service-transport_plugins.h"
29#include "gnunet-service-transport_hello.h" 30#include "gnunet-service-transport_hello.h"
@@ -324,7 +325,6 @@ static struct GNUNET_CONTAINER_MultiPeerMap *validation_map;
324 */ 325 */
325static struct GNUNET_PEERINFO_NotifyContext *pnc; 326static struct GNUNET_PEERINFO_NotifyContext *pnc;
326 327
327
328/** 328/**
329 * Minimum delay between to validations 329 * Minimum delay between to validations
330 */ 330 */
@@ -345,8 +345,6 @@ static unsigned int validations_fast_start_threshold;
345 */ 345 */
346static struct GNUNET_TIME_Absolute validation_next; 346static struct GNUNET_TIME_Absolute validation_next;
347 347
348static GST_ValidationChangedCallback validation_entry_changed_cb;
349static void *validation_entry_changed_cb_cls;
350 348
351/** 349/**
352 * Context for the validation entry match function. 350 * Context for the validation entry match function.
@@ -369,14 +367,16 @@ struct ValidationEntryMatchContext
369/** 367/**
370 * Iterate over validation entries until a matching one is found. 368 * Iterate over validation entries until a matching one is found.
371 * 369 *
372 * @param cls the 'struct ValidationEntryMatchContext' 370 * @param cls the `struct ValidationEntryMatchContext *`
373 * @param key peer identity (unused) 371 * @param key peer identity (unused)
374 * @param value a 'struct ValidationEntry' to match 372 * @param value a `struct ValidationEntry *` to match
375 * @return GNUNET_YES if the entry does not match, 373 * @return #GNUNET_YES if the entry does not match,
376 * GNUNET_NO if the entry does match 374 * #GNUNET_NO if the entry does match
377 */ 375 */
378static int 376static int
379validation_entry_match (void *cls, const struct GNUNET_PeerIdentity * key, void *value) 377validation_entry_match (void *cls,
378 const struct GNUNET_PeerIdentity *key,
379 void *value)
380{ 380{
381 struct ValidationEntryMatchContext *vemc = cls; 381 struct ValidationEntryMatchContext *vemc = cls;
382 struct ValidationEntry *ve = value; 382 struct ValidationEntry *ve = value;
@@ -389,22 +389,25 @@ validation_entry_match (void *cls, const struct GNUNET_PeerIdentity * key, void
389 return GNUNET_YES; 389 return GNUNET_YES;
390} 390}
391 391
392
393/**
394 * A validation entry changed. Update the state and notify
395 * monitors.
396 *
397 * @param ve validation entry that changed
398 * @param state new state
399 */
392static void 400static void
393validation_entry_changed (struct ValidationEntry *ve, enum GNUNET_TRANSPORT_ValidationState state) 401validation_entry_changed (struct ValidationEntry *ve,
402 enum GNUNET_TRANSPORT_ValidationState state)
394{ 403{
395 char *t_sent = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string(ve->send_time));
396 char *t_valid = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string(ve->valid_until));
397 char *t_next = GNUNET_strdup(GNUNET_STRINGS_absolute_time_to_string(ve->next_validation));
398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validation entry changed for peer `%s' address `%s':\n\tSent: %s\n\tValid: %s\n\tNext: %s\n",
399 GNUNET_i2s(&ve->pid), GST_plugins_a2s(ve->address),
400 t_sent, t_valid, t_next);
401 ve->state = state; 404 ve->state = state;
402 405 GST_clients_broadcast_validation_notification (&ve->pid,
403 GNUNET_free (t_sent); 406 ve->address,
404 GNUNET_free (t_valid); 407 ve->send_time,
405 GNUNET_free (t_next); 408 ve->valid_until,
406 validation_entry_changed_cb (validation_entry_changed_cb_cls, &ve->pid, 409 ve->next_validation,
407 ve->address, ve->send_time, ve->valid_until, ve->next_validation, state); 410 state);
408} 411}
409 412
410 413
@@ -413,11 +416,13 @@ validation_entry_changed (struct ValidationEntry *ve, enum GNUNET_TRANSPORT_Vali
413 * 416 *
414 * @param cls (unused) 417 * @param cls (unused)
415 * @param key peer identity (unused) 418 * @param key peer identity (unused)
416 * @param value a 'struct ValidationEntry' to clean up 419 * @param value a `struct ValidationEntry *` to clean up
417 * @return GNUNET_YES (continue to iterate) 420 * @return #GNUNET_YES (continue to iterate)
418 */ 421 */
419static int 422static int
420cleanup_validation_entry (void *cls, const struct GNUNET_PeerIdentity * key, void *value) 423cleanup_validation_entry (void *cls,
424 const struct GNUNET_PeerIdentity *key,
425 void *value)
421{ 426{
422 struct ValidationEntry *ve = value; 427 struct ValidationEntry *ve = value;
423 428
@@ -579,8 +584,8 @@ transmit_ping_if_allowed (void *cls,
579 ret = -1; 584 ret = -1;
580 else 585 else
581 { 586 {
582 GNUNET_assert (papi->send != NULL); 587 GNUNET_assert (NULL != papi->send);
583 GNUNET_assert (papi->get_session != NULL); 588 GNUNET_assert (NULL != papi->get_session);
584 struct Session * session = papi->get_session(papi->cls, ve->address); 589 struct Session * session = papi->get_session(papi->cls, ve->address);
585 590
586 if (session != NULL) 591 if (session != NULL)
@@ -863,12 +868,10 @@ process_peerinfo_hello (void *cls, const struct GNUNET_PeerIdentity *peer,
863/** 868/**
864 * Start the validation subsystem. 869 * Start the validation subsystem.
865 * 870 *
866 * @param cb callback to call with changes to valdidation entries
867 * @param cb_cls cls for the callback
868 * @param max_fds maximum number of fds to use 871 * @param max_fds maximum number of fds to use
869 */ 872 */
870void 873void
871GST_validation_start (GST_ValidationChangedCallback cb, void *cb_cls, unsigned int max_fds) 874GST_validation_start (unsigned int max_fds)
872{ 875{
873 /** 876 /**
874 * Initialization for validation throttling 877 * Initialization for validation throttling
@@ -886,9 +889,8 @@ GST_validation_start (GST_ValidationChangedCallback cb, void *cb_cls, unsigned i
886 validation_delay.rel_value_us = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value_us) / (max_fds / 2); 889 validation_delay.rel_value_us = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value_us) / (max_fds / 2);
887 validations_fast_start_threshold = (max_fds / 2); 890 validations_fast_start_threshold = (max_fds / 2);
888 validations_running = 0; 891 validations_running = 0;
889 validation_entry_changed_cb = cb; 892 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
890 validation_entry_changed_cb_cls = cb_cls; 893 "Validation uses a fast start threshold of %u connections and a delay between of %s\n ",
891 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validation uses a fast start threshold of %u connections and a delay between of %s\n ",
892 validations_fast_start_threshold, 894 validations_fast_start_threshold,
893 GNUNET_STRINGS_relative_time_to_string (validation_delay, 895 GNUNET_STRINGS_relative_time_to_string (validation_delay,
894 GNUNET_YES)); 896 GNUNET_YES));
@@ -1243,7 +1245,7 @@ struct ValidateAddressContext
1243 * Iterator callback to go over all addresses and try to validate them 1245 * Iterator callback to go over all addresses and try to validate them
1244 * (unless blocked or already validated). 1246 * (unless blocked or already validated).
1245 * 1247 *
1246 * @param cls pointer to a `struct ValidateAddressContext` 1248 * @param cls pointer to a `struct ValidateAddressContext *`
1247 * @param address the address 1249 * @param address the address
1248 * @param expiration expiration time 1250 * @param expiration expiration time
1249 * @return #GNUNET_OK (keep the address) 1251 * @return #GNUNET_OK (keep the address)
@@ -1277,14 +1279,16 @@ validate_address_iterator (void *cls,
1277/** 1279/**
1278 * Add the validated peer address to the HELLO. 1280 * Add the validated peer address to the HELLO.
1279 * 1281 *
1280 * @param cls the 'struct ValidationEntry' with the validated address 1282 * @param cls the `struct ValidationEntry *` with the validated address
1281 * @param max space in buf 1283 * @param max space in @a buf
1282 * @param buf where to add the address 1284 * @param buf where to add the address
1283 * @return number of bytes written, GNUNET_SYSERR to signal the 1285 * @return number of bytes written, #GNUNET_SYSERR to signal the
1284 * end of the iteration. 1286 * end of the iteration.
1285 */ 1287 */
1286static ssize_t 1288static ssize_t
1287add_valid_peer_address (void *cls, size_t max, void *buf) 1289add_valid_peer_address (void *cls,
1290 size_t max,
1291 void *buf)
1288{ 1292{
1289 struct ValidationEntry *ve = cls; 1293 struct ValidationEntry *ve = cls;
1290 1294
@@ -1375,7 +1379,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1375 1379
1376 sig_res = GNUNET_SYSERR; 1380 sig_res = GNUNET_SYSERR;
1377 do_verify = GNUNET_YES; 1381 do_verify = GNUNET_YES;
1378 if (0 != GNUNET_TIME_absolute_get_remaining(ve->pong_sig_valid_until).rel_value_us) 1382 if (0 != GNUNET_TIME_absolute_get_remaining (ve->pong_sig_valid_until).rel_value_us)
1379 { 1383 {
1380 /* We have a cached and valid signature for this peer, 1384 /* We have a cached and valid signature for this peer,
1381 * try to compare instead of verify */ 1385 * try to compare instead of verify */
@@ -1416,7 +1420,9 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1416 1420
1417 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1421 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1418 "Validation process successful for peer `%s' with plugin `%s' address `%s'\n", 1422 "Validation process successful for peer `%s' with plugin `%s' address `%s'\n",
1419 GNUNET_i2s (sender), tname, GST_plugins_a2s (ve->address)); 1423 GNUNET_i2s (sender),
1424 tname,
1425 GST_plugins_a2s (ve->address));
1420 /* validity achieved, remember it! */ 1426 /* validity achieved, remember it! */
1421 ve->expecting_pong = GNUNET_NO; 1427 ve->expecting_pong = GNUNET_NO;
1422 ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); 1428 ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
@@ -1536,7 +1542,9 @@ struct IteratorContext
1536 * @return #GNUNET_OK (continue to iterate) 1542 * @return #GNUNET_OK (continue to iterate)
1537 */ 1543 */
1538static int 1544static int
1539iterate_addresses (void *cls, const struct GNUNET_PeerIdentity *key, void *value) 1545iterate_addresses (void *cls,
1546 const struct GNUNET_PeerIdentity *key,
1547 void *value)
1540{ 1548{
1541 struct IteratorContext *ic = cls; 1549 struct IteratorContext *ic = cls;
1542 struct ValidationEntry *ve = value; 1550 struct ValidationEntry *ve = value;
@@ -1553,7 +1561,7 @@ iterate_addresses (void *cls, const struct GNUNET_PeerIdentity *key, void *value
1553 * 1561 *
1554 * @param target peer information is requested for 1562 * @param target peer information is requested for
1555 * @param cb function to call; will not be called after this function returns 1563 * @param cb function to call; will not be called after this function returns
1556 * @param cb_cls closure for 'cb' 1564 * @param cb_cls closure for @a cb
1557 */ 1565 */
1558void 1566void
1559GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, 1567GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
@@ -1662,11 +1670,12 @@ struct ValidationIteratorContext
1662 GST_ValidationChangedCallback cb; 1670 GST_ValidationChangedCallback cb;
1663 1671
1664 /** 1672 /**
1665 * Closure for 'cb'. 1673 * Closure for @e cb.
1666 */ 1674 */
1667 void *cb_cls; 1675 void *cb_cls;
1668}; 1676};
1669 1677
1678
1670static int 1679static int
1671validation_entries_iterate (void *cls, 1680validation_entries_iterate (void *cls,
1672 const struct GNUNET_PeerIdentity *key, 1681 const struct GNUNET_PeerIdentity *key,
@@ -1690,7 +1699,8 @@ validation_entries_iterate (void *cls,
1690 * @param cb_cls closure for cb 1699 * @param cb_cls closure for cb
1691 */ 1700 */
1692void 1701void
1693GST_validation_iterate (GST_ValidationChangedCallback cb, void *cb_cls) 1702GST_validation_iterate (GST_ValidationChangedCallback cb,
1703 void *cb_cls)
1694{ 1704{
1695 struct ValidationIteratorContext ic; 1705 struct ValidationIteratorContext ic;
1696 1706
@@ -1698,7 +1708,9 @@ GST_validation_iterate (GST_ValidationChangedCallback cb, void *cb_cls)
1698 return; /* can happen during shutdown */ 1708 return; /* can happen during shutdown */
1699 ic.cb = cb; 1709 ic.cb = cb;
1700 ic.cb_cls = cb_cls; 1710 ic.cb_cls = cb_cls;
1701 GNUNET_CONTAINER_multipeermap_iterate (validation_map, &validation_entries_iterate, &ic); 1711 GNUNET_CONTAINER_multipeermap_iterate (validation_map,
1712 &validation_entries_iterate,
1713 &ic);
1702} 1714}
1703 1715
1704/* end of file gnunet-service-transport_validation.c */ 1716/* end of file gnunet-service-transport_validation.c */
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index 71c095c1b..df2ef0ee8 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -32,35 +32,12 @@
32#include "gnunet_hello_lib.h" 32#include "gnunet_hello_lib.h"
33 33
34/** 34/**
35 * Function called to notify transport users that a neighbour peer changed its
36 * active address.
37 *
38 * @param cls closure
39 * @param peer peer this update is about (never NULL)
40 * @param address address (never NULL)
41 * @param last_validation point in time when last validation was performed
42 * @param valid_until point in time how long address is valid
43 * @param next_validation point in time when next validation will be performed
44 * @param state state of validation notification
45 */
46typedef void (*GST_ValidationChangedCallback) (void *cls,
47 const struct GNUNET_PeerIdentity *peer,
48 const struct GNUNET_HELLO_Address *address,
49 struct GNUNET_TIME_Absolute last_validation,
50 struct GNUNET_TIME_Absolute valid_until,
51 struct GNUNET_TIME_Absolute next_validation,
52 enum GNUNET_TRANSPORT_ValidationState state);
53
54
55/**
56 * Start the validation subsystem. 35 * Start the validation subsystem.
57 * 36 *
58 * @param cb callback to call with changes to valdidation entries
59 * @param cb_cls cls for the callback
60 * @param max_fds maximum number of fds to use 37 * @param max_fds maximum number of fds to use
61 */ 38 */
62void 39void
63GST_validation_start (GST_ValidationChangedCallback cb, void *cb_cls, unsigned int max_fds); 40GST_validation_start (unsigned int max_fds);
64 41
65 42
66/** 43/**
@@ -77,8 +54,8 @@ GST_validation_stop (void);
77 * 54 *
78 * @param address the address 55 * @param address the address
79 * @param session the session 56 * @param session the session
80 * @param in_use GNUNET_YES if we are now using the address for a connection, 57 * @param in_use #GNUNET_YES if we are now using the address for a connection,
81 * GNUNET_NO if we are no longer using the address for a connection 58 * #GNUNET_NO if we are no longer using the address for a connection
82 */ 59 */
83void 60void
84GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, 61GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
@@ -101,15 +78,39 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
101 const struct GNUNET_HELLO_Address *address, 78 const struct GNUNET_HELLO_Address *address,
102 struct Session *session); 79 struct Session *session);
103 80
81
82/**
83 * Function called to notify transport users that a neighbour peer changed its
84 * active address.
85 *
86 * @param cls closure
87 * @param peer peer this update is about (never NULL)
88 * @param address address (never NULL)
89 * @param last_validation point in time when last validation was performed
90 * @param valid_until point in time how long address is valid
91 * @param next_validation point in time when next validation will be performed
92 * @param state state of validation notification
93 */
94typedef void
95(*GST_ValidationChangedCallback) (void *cls,
96 const struct GNUNET_PeerIdentity *peer,
97 const struct GNUNET_HELLO_Address *address,
98 struct GNUNET_TIME_Absolute last_validation,
99 struct GNUNET_TIME_Absolute valid_until,
100 struct GNUNET_TIME_Absolute next_validation,
101 enum GNUNET_TRANSPORT_ValidationState state);
102
103
104/** 104/**
105 * Iterate over all iteration entries 105 * Iterate over all iteration entries
106 * 106 *
107 * @param cb function to call 107 * @param cb function to call
108 * @param cb_cls closure for cb 108 * @param cb_cls closure for @a cb
109 */ 109 */
110void 110void
111GST_validation_iterate (GST_ValidationChangedCallback cb, void *cb_cls); 111GST_validation_iterate (GST_ValidationChangedCallback cb, void *cb_cls);
112 112
113
113/** 114/**
114 * We've received a PING. If appropriate, generate a PONG. 115 * We've received a PING. If appropriate, generate a PONG.
115 * 116 *
@@ -163,15 +164,12 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
163 * otherwise a time in the future if we're currently denying re-validation 164 * otherwise a time in the future if we're currently denying re-validation
164 * @param address the address 165 * @param address the address
165 */ 166 */
166typedef void (*GST_ValidationAddressCallback) (void *cls, 167typedef void
167 const struct 168(*GST_ValidationAddressCallback) (void *cls,
168 GNUNET_CRYPTO_EddsaPublicKey *public_key, 169 const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
169 struct GNUNET_TIME_Absolute 170 struct GNUNET_TIME_Absolute valid_until,
170 valid_until, 171 struct GNUNET_TIME_Absolute validation_block,
171 struct GNUNET_TIME_Absolute 172 const struct GNUNET_HELLO_Address *address);
172 validation_block,
173 const struct GNUNET_HELLO_Address
174 * address);
175 173
176 174
177/** 175/**
@@ -179,7 +177,7 @@ typedef void (*GST_ValidationAddressCallback) (void *cls,
179 * 177 *
180 * @param target peer information is requested for 178 * @param target peer information is requested for
181 * @param cb function to call; will not be called after this function returns 179 * @param cb function to call; will not be called after this function returns
182 * @param cb_cls closure for 'cb' 180 * @param cb_cls closure for @a cb
183 */ 181 */
184void 182void
185GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, 183GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 80a3e2d15..0fef7784e 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -1684,19 +1684,22 @@ testservice_task (void *cls, int result)
1684 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 1684 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1685 address_resolution_in_progress = GNUNET_YES; 1685 address_resolution_in_progress = GNUNET_YES;
1686 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid, 1686 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
1687 GNUNET_NO, TIMEOUT, &process_peer_monitoring_cb, (void *) cfg); 1687 GNUNET_NO, TIMEOUT,
1688 &process_peer_monitoring_cb, (void *) cfg);
1688 } 1689 }
1689 else if (iterate_validation) /* -d: Print information about validations */ 1690 else if (iterate_validation) /* -d: Print information about validations */
1690 { 1691 {
1691 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg, 1692 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
1692 (NULL == cpid) ? NULL : &pid, 1693 (NULL == cpid) ? NULL : &pid,
1693 GNUNET_YES, TIMEOUT, &process_validation_cb, (void *) cfg); 1694 GNUNET_YES, TIMEOUT,
1695 &process_validation_cb, (void *) cfg);
1694 } 1696 }
1695 else if (monitor_validation) /* -f: Print information about validations continuously */ 1697 else if (monitor_validation) /* -f: Print information about validations continuously */
1696 { 1698 {
1697 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg, 1699 vic = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
1698 (NULL == cpid) ? NULL : &pid, 1700 (NULL == cpid) ? NULL : &pid,
1699 GNUNET_NO, TIMEOUT, &process_validation_cb, (void *) cfg); 1701 GNUNET_NO, TIMEOUT,
1702 &process_validation_cb, (void *) cfg);
1700 } 1703 }
1701 else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */ 1704 else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */
1702 { 1705 {
@@ -1706,7 +1709,9 @@ testservice_task (void *cls, int result)
1706 &monitor_notify_disconnect); 1709 &monitor_notify_disconnect);
1707 if (NULL == handle) 1710 if (NULL == handle)
1708 { 1711 {
1709 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n")); 1712 FPRINTF (stderr,
1713 "%s",
1714 _("Failed to connect to transport service\n"));
1710 ret = 1; 1715 ret = 1;
1711 return; 1716 return;
1712 } 1717 }
@@ -1721,7 +1726,6 @@ testservice_task (void *cls, int result)
1721 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 1726 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1722 &shutdown_task, 1727 &shutdown_task,
1723 NULL); 1728 NULL);
1724
1725} 1729}
1726 1730
1727 1731
diff --git a/src/transport/transport.h b/src/transport/transport.h
index cbbefb7e1..ceeaf9c0d 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -416,17 +416,20 @@ struct ValidationIterateResponseMessage
416 uint32_t state GNUNET_PACKED; 416 uint32_t state GNUNET_PACKED;
417 417
418 /** 418 /**
419 * FIXME 419 * At what time did we successfully validate the address last.
420 * Will be NEVER if the address failed validation.
420 */ 421 */
421 struct GNUNET_TIME_AbsoluteNBO last_validation; 422 struct GNUNET_TIME_AbsoluteNBO last_validation;
422 423
423 /** 424 /**
424 * FIXME 425 * Until when is the address believed to be valid.
426 * Will be ZERO if the address is not belived to be valid.
425 */ 427 */
426 struct GNUNET_TIME_AbsoluteNBO valid_until; 428 struct GNUNET_TIME_AbsoluteNBO valid_until;
427 429
428 /** 430 /**
429 * FIXME 431 * When will we next try to validate the address (typically
432 * done before @e valid_until happens).
430 */ 433 */
431 struct GNUNET_TIME_AbsoluteNBO next_validation; 434 struct GNUNET_TIME_AbsoluteNBO next_validation;
432}; 435};
diff --git a/src/transport/transport_api_monitoring.c b/src/transport/transport_api_monitoring.c
index 31f3d4f90..b44bf51b8 100644
--- a/src/transport/transport_api_monitoring.c
+++ b/src/transport/transport_api_monitoring.c
@@ -516,9 +516,12 @@ val_response_processor (void *cls,
516 GNUNET_break (0); 516 GNUNET_break (0);
517 if (val_ctx->one_shot) 517 if (val_ctx->one_shot)
518 { 518 {
519 val_ctx->cb (val_ctx->cb_cls, NULL, NULL, 519 val_ctx->cb (val_ctx->cb_cls,
520 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, 520 NULL, NULL,
521 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); 521 GNUNET_TIME_UNIT_ZERO_ABS,
522 GNUNET_TIME_UNIT_ZERO_ABS,
523 GNUNET_TIME_UNIT_ZERO_ABS,
524 GNUNET_TRANSPORT_VS_NONE);
522 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); 525 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
523 } 526 }
524 else 527 else
@@ -530,12 +533,16 @@ val_response_processor (void *cls,
530 533
531 /* notify client */ 534 /* notify client */
532 address = GNUNET_HELLO_address_allocate (&vr_msg->peer, 535 address = GNUNET_HELLO_address_allocate (&vr_msg->peer,
533 transport_name, addr, alen, ntohl(vr_msg->local_address_info)); 536 transport_name,
534 val_ctx->cb (val_ctx->cb_cls, &vr_msg->peer, address, 537 addr, alen,
535 GNUNET_TIME_absolute_ntoh(vr_msg->last_validation), 538 ntohl (vr_msg->local_address_info));
536 GNUNET_TIME_absolute_ntoh(vr_msg->valid_until), 539 val_ctx->cb (val_ctx->cb_cls,
537 GNUNET_TIME_absolute_ntoh(vr_msg->next_validation), 540 &vr_msg->peer,
538 ntohl(vr_msg->state)); 541 address,
542 GNUNET_TIME_absolute_ntoh (vr_msg->last_validation),
543 GNUNET_TIME_absolute_ntoh (vr_msg->valid_until),
544 GNUNET_TIME_absolute_ntoh (vr_msg->next_validation),
545 ntohl(vr_msg->state));
539 GNUNET_HELLO_address_free (address); 546 GNUNET_HELLO_address_free (address);
540 } 547 }
541 /* expect more replies */ 548 /* expect more replies */
@@ -777,20 +784,19 @@ GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringCon
777 * @param cfg configuration to use 784 * @param cfg configuration to use
778 * @param peer a specific peer identity to obtain validation entries for, 785 * @param peer a specific peer identity to obtain validation entries for,
779 * NULL for all peers 786 * NULL for all peers
780 * @param one_shot GNUNET_YES to return all entries and then end (with NULL+NULL), 787 * @param one_shot #GNUNET_YES to return all entries and then end (with NULL+NULL),
781 * GNUNET_NO to monitor validation entries continuously 788 * #GNUNET_NO to monitor validation entries continuously
782 * @param timeout how long is the lookup allowed to take at most 789 * @param timeout how long is the lookup allowed to take at most
783 * @param validation_callback function to call with the results 790 * @param validation_callback function to call with the results
784 * @param validation_callback_cls closure for peer_address_callback 791 * @param validation_callback_cls closure for peer_address_callback
785 */ 792 */
786struct GNUNET_TRANSPORT_ValidationMonitoringContext * 793struct GNUNET_TRANSPORT_ValidationMonitoringContext *
787GNUNET_TRANSPORT_monitor_validation_entries (const struct 794GNUNET_TRANSPORT_monitor_validation_entries (const struct GNUNET_CONFIGURATION_Handle *cfg,
788 GNUNET_CONFIGURATION_Handle *cfg, 795 const struct GNUNET_PeerIdentity *peer,
789 const struct GNUNET_PeerIdentity *peer, 796 int one_shot,
790 int one_shot, 797 struct GNUNET_TIME_Relative timeout,
791 struct GNUNET_TIME_Relative timeout, 798 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
792 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback, 799 void *validation_callback_cls)
793 void *validation_callback_cls)
794{ 800{
795 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx; 801 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx;
796 struct GNUNET_CLIENT_Connection *client; 802 struct GNUNET_CLIENT_Connection *client;