aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_validation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r--src/transport/gnunet-service-transport_validation.c123
1 files changed, 47 insertions, 76 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 6ea5394bf..624e3b93c 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -37,6 +37,53 @@
37#include "gnunet_peerinfo_service.h" 37#include "gnunet_peerinfo_service.h"
38#include "gnunet_signatures.h" 38#include "gnunet_signatures.h"
39 39
40/**
41 * Current state of a validation process.
42 *
43 * FIXME: what state is used to indicate that a validation
44 * was successful? If that is clarified/determined, "UGH" in
45 * ~gnunetpeerinfogtk.c:1103 should be resolved.
46 */
47enum GNUNET_TRANSPORT_ValidationState
48{
49 /**
50 * Undefined state
51 *
52 * Used for final callback indicating operation done
53 */
54 GNUNET_TRANSPORT_VS_NONE,
55
56 /**
57 * Fresh validation entry
58 *
59 * Entry was just created, no validation process was executed
60 */
61 GNUNET_TRANSPORT_VS_NEW,
62
63 /**
64 * Updated validation entry
65 *
66 * This is an update for an existing validation entry
67 */
68 GNUNET_TRANSPORT_VS_UPDATE,
69
70 /**
71 * Timeout for validation entry
72 *
73 * A timeout occured during the validation process
74 */
75 GNUNET_TRANSPORT_VS_TIMEOUT,
76
77 /**
78 * Validation entry is removed
79 *
80 * The validation entry is getting removed due to a failed validation
81 */
82 GNUNET_TRANSPORT_VS_REMOVE
83};
84
85
86
40 87
41/** 88/**
42 * How long is a PONG signature valid? We'll recycle a signature until 89 * How long is a PONG signature valid? We'll recycle a signature until
@@ -385,12 +432,6 @@ validation_entry_changed (struct ValidationEntry *ve,
385 enum GNUNET_TRANSPORT_ValidationState state) 432 enum GNUNET_TRANSPORT_ValidationState state)
386{ 433{
387 ve->state = state; 434 ve->state = state;
388 GST_clients_broadcast_validation_notification (&ve->address->peer,
389 ve->address,
390 ve->send_time,
391 ve->valid_until,
392 ve->next_validation,
393 state);
394} 435}
395 436
396 437
@@ -1733,74 +1774,4 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
1733} 1774}
1734 1775
1735 1776
1736/**
1737 * Closure for the validation_entries_iterate function.
1738 */
1739struct ValidationIteratorContext
1740{
1741 /**
1742 * Function to call on each validation entry
1743 */
1744 GST_ValidationChangedCallback cb;
1745
1746 /**
1747 * Closure for @e cb.
1748 */
1749 void *cb_cls;
1750};
1751
1752
1753/**
1754 * Function called on each entry in the validation map.
1755 * Passes the information from the validation entry to
1756 * the callback given in the closure.
1757 *
1758 * @param cls the `struct ValidationIteratorContext`
1759 * @param key peer this is about
1760 * @param value the `struct ValidationEntry`
1761 * @return #GNUNET_OK (continue to iterate)
1762 */
1763static int
1764validation_entries_iterate (void *cls,
1765 const struct GNUNET_PeerIdentity *key,
1766 void *value)
1767{
1768 struct ValidationIteratorContext *ic = cls;
1769 struct ValidationEntry *ve = value;
1770
1771 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1772 "Notifying about validation entry for peer `%s' address `%s' \n",
1773 GNUNET_i2s (&ve->address->peer),
1774 GST_plugins_a2s (ve->address));
1775 ic->cb (ic->cb_cls,
1776 ve->address,
1777 ve->send_time,
1778 ve->valid_until,
1779 ve->next_validation,
1780 ve->state);
1781 return GNUNET_OK;
1782}
1783
1784
1785/**
1786 * Iterate over all iteration entries
1787 *
1788 * @param cb function to call
1789 * @param cb_cls closure for @a cb
1790 */
1791void
1792GST_validation_iterate (GST_ValidationChangedCallback cb,
1793 void *cb_cls)
1794{
1795 struct ValidationIteratorContext ic;
1796
1797 if (NULL == validation_map)
1798 return; /* can happen during shutdown */
1799 ic.cb = cb;
1800 ic.cb_cls = cb_cls;
1801 GNUNET_CONTAINER_multipeermap_iterate (validation_map,
1802 &validation_entries_iterate,
1803 &ic);
1804}
1805
1806/* end of file gnunet-service-transport_validation.c */ 1777/* end of file gnunet-service-transport_validation.c */