diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-05 09:36:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-05 09:36:02 +0000 |
commit | fb567582ca24ac7450336782365e86a177d8a472 (patch) | |
tree | 053b29071811155a328bf8dec1f1c922997fe02f /src/transport/gnunet-service-transport_validation.h | |
parent | ec057166095a225d45be16e66671e0f7f74cbef2 (diff) | |
download | gnunet-fb567582ca24ac7450336782365e86a177d8a472.tar.gz gnunet-fb567582ca24ac7450336782365e86a177d8a472.zip |
more refactoring
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.h')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.h | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h index 9768c425e..0d6e0ef5a 100644 --- a/src/transport/gnunet-service-transport_validation.h +++ b/src/transport/gnunet-service-transport_validation.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/gnunet-service-transport_validation.h | 22 | * @file transport/gnunet-service-transport_validation.h |
23 | * @brief plugin management API | 23 | * @brief address validation API |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H | 26 | #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H |
@@ -31,33 +31,49 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /** | 33 | /** |
34 | * | 34 | * Start the validation subsystem. |
35 | */ | 35 | */ |
36 | void | 36 | void |
37 | GST_validation_start (void); | 37 | GST_validation_start (void); |
38 | 38 | ||
39 | 39 | ||
40 | /** | 40 | /** |
41 | * | 41 | * Stop the validation subsystem. |
42 | */ | 42 | */ |
43 | void | 43 | void |
44 | GST_validation_stop (void); | 44 | GST_validation_stop (void); |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
48 | * We've received a PING. If appropriate, generate a PONG. | ||
48 | * | 49 | * |
50 | * @param sender peer sending the PING | ||
51 | * @param hdr the PING | ||
52 | * @param plugin_name name of plugin that received the PING | ||
53 | * @param sender_address address of the sender as known to the plugin, NULL | ||
54 | * if we did not initiate the connection | ||
55 | * @param sender_address_len number of bytes in sender_address | ||
49 | */ | 56 | */ |
50 | int | 57 | void |
51 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | 58 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, |
52 | const struct GNUNET_MessageHeader *hdr, | 59 | const struct GNUNET_MessageHeader *hdr, |
53 | const char *plugin_name, | 60 | const char *plugin_name, |
54 | const void *sender_address, | 61 | const void *sender_address, |
55 | size_t sender_address_len); | 62 | size_t sender_address_len); |
56 | 63 | ||
64 | |||
57 | /** | 65 | /** |
66 | * We've received a PONG. Check if it matches a pending PING and | ||
67 | * mark the respective address as confirmed. | ||
58 | * | 68 | * |
69 | * @param sender peer sending the PONG | ||
70 | * @param hdr the PONG | ||
71 | * @param plugin_name name of plugin that received the PONG | ||
72 | * @param sender_address address of the sender as known to the plugin, NULL | ||
73 | * if we did not initiate the connection | ||
74 | * @param sender_address_len number of bytes in sender_address | ||
59 | */ | 75 | */ |
60 | int | 76 | void |
61 | GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | 77 | GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, |
62 | const struct GNUNET_MessageHeader *hdr, | 78 | const struct GNUNET_MessageHeader *hdr, |
63 | const char *plugin_name, | 79 | const char *plugin_name, |
@@ -66,21 +82,36 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
66 | 82 | ||
67 | 83 | ||
68 | /** | 84 | /** |
85 | * We've received a HELLO, check which addresses are new and trigger | ||
86 | * validation. | ||
69 | * | 87 | * |
88 | * @param hello the HELLO we received | ||
70 | */ | 89 | */ |
71 | void | 90 | void |
72 | GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello); | 91 | GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello); |
73 | 92 | ||
74 | 93 | ||
94 | /** | ||
95 | * Opaque handle to stop incremental validation address callbacks. | ||
96 | */ | ||
75 | struct GST_ValidationIteratorContext; | 97 | struct GST_ValidationIteratorContext; |
76 | 98 | ||
99 | |||
77 | /** | 100 | /** |
101 | * Function called for each address (or address status change) that | ||
102 | * the validation module is aware of (for the given target). | ||
103 | * | ||
104 | * @param cls closure | ||
105 | * @param target peer this change is about, never NULL | ||
78 | * @param last_validated_at is FOREVER if the address has not been validated (we're currently checking) | 106 | * @param last_validated_at is FOREVER if the address has not been validated (we're currently checking) |
79 | * is ZERO if the address was validated a long time ago (from PEERINFO) | 107 | * is ZERO if the address was validated a long time ago (from PEERINFO) |
80 | * is a time in the past if this process validated the address | 108 | * is a time in the past if this process validated the address |
81 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) | 109 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) |
82 | * is ZERO if the address is considered valid (no validation needed) | 110 | * is ZERO if the address is considered valid (no validation needed) |
83 | * is a time in the future if we're currently denying re-validation | 111 | * is a time in the future if we're currently denying re-validation |
112 | * @param plugin_name name of the plugin | ||
113 | * @param plugin_address binary address | ||
114 | * @param plugin_address_len length of address | ||
84 | */ | 115 | */ |
85 | typedef void (*GST_ValidationAddressCallback)(void *cls, | 116 | typedef void (*GST_ValidationAddressCallback)(void *cls, |
86 | const struct GNUNET_PeerIdentity *target, | 117 | const struct GNUNET_PeerIdentity *target, |
@@ -90,13 +121,31 @@ typedef void (*GST_ValidationAddressCallback)(void *cls, | |||
90 | const void *plugin_address, | 121 | const void *plugin_address, |
91 | size_t plugin_address_len); | 122 | size_t plugin_address_len); |
92 | 123 | ||
124 | |||
125 | /** | ||
126 | * Call the given function for each address for the given target. | ||
127 | * Can either give a snapshot (synchronous API) or be continuous. | ||
128 | * | ||
129 | * @param target peer information is requested for | ||
130 | * @param snapshot_only GNUNET_YES to iterate over addresses once, GNUNET_NO to | ||
131 | * continue to give information about addresses as it evolves | ||
132 | * @param cb function to call; will not be called after this function returns | ||
133 | * if snapshot_only is GNUNET_YES | ||
134 | * @param cb_cls closure for 'cb' | ||
135 | * @return context to cancel, NULL if 'snapshot_only' is GNUNET_YES | ||
136 | */ | ||
93 | struct GST_ValidationIteratorContext * | 137 | struct GST_ValidationIteratorContext * |
94 | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | 138 | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, |
139 | int snapshot_only, | ||
95 | GST_ValidationAddressCallback cb, | 140 | GST_ValidationAddressCallback cb, |
96 | void *cb_cls); | 141 | void *cb_cls); |
97 | 142 | ||
98 | 143 | ||
99 | 144 | /** | |
145 | * Cancel an active validation address iteration. | ||
146 | * | ||
147 | * @param ctx the context of the operation that is cancelled | ||
148 | */ | ||
100 | void | 149 | void |
101 | GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx); | 150 | GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx); |
102 | 151 | ||