2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors)
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/gnunet-service-transport_validation.h
23 * @brief address validation API
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H
27 #define GNUNET_SERVICE_TRANSPORT_VALIDATION_H
29 #include "gnunet_statistics_service.h"
30 #include "gnunet_transport_plugin.h"
31 #include "gnunet_util_lib.h"
35 * Start the validation subsystem.
38 GST_validation_start (void);
42 * Stop the validation subsystem.
45 GST_validation_stop (void);
49 * Update if we are using an address for a connection actively right now.
50 * Based on this, the validation module will measure latency for the
51 * address more or less often.
53 * @param sender peer sending the PING
55 * @param plugin_name name of plugin that received the PING
56 * @param session session we got the PING from
57 * @param sender_address address of the sender as known to the plugin, NULL
58 * if we did not initiate the connection
59 * @param sender_address_len number of bytes in sender_address
60 * @param in_use GNUNET_YES if we are now using the address for a connection,
61 * GNUNET_NO if we are no longer using the address for a connection
64 GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
65 const struct GNUNET_MessageHeader *hdr,
66 const char *plugin_name, struct Session *session,
67 const void *sender_address,
68 size_t sender_address_len,
73 * Query validation about the latest observed latency on a given
76 * @param sender peer sending the PING
78 * @param plugin_name name of plugin that received the PING
79 * @param session session we got the PING from
80 * @param sender_address address of the sender as known to the plugin, NULL
81 * if we did not initiate the connection
82 * @param sender_address_len number of bytes in sender_address
83 * @return observed latency of the address, FOREVER if the address was
84 * never successfully validated
86 struct GNUNET_TIME_Relative
87 GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
88 const struct GNUNET_MessageHeader *hdr,
89 const char *plugin_name, struct Session *session,
90 const void *sender_address,
91 size_t sender_address_len);
95 * We've received a PING. If appropriate, generate a PONG.
97 * @param sender peer sending the PING
99 * @param plugin_name name of plugin that received the PING
100 * @param session session we got the PING from
101 * @param sender_address address of the sender as known to the plugin, NULL
102 * if we did not initiate the connection
103 * @param sender_address_len number of bytes in sender_address
106 GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
107 const struct GNUNET_MessageHeader *hdr,
108 const char *plugin_name, struct Session *session,
109 const void *sender_address,
110 size_t sender_address_len);
114 * We've received a PONG. Check if it matches a pending PING and
115 * mark the respective address as confirmed.
117 * @param sender peer sending the PONG
118 * @param hdr the PONG
121 GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
122 const struct GNUNET_MessageHeader *hdr);
126 * We've received a HELLO, check which addresses are new and trigger
129 * @param hello the HELLO we received
132 GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
136 * Function called for each address (or address status change) that
137 * the validation module is aware of (for the given target).
140 * @param public_key public key for the peer, never NULL
141 * @param target peer this change is about, never NULL
142 * @param valid_until is ZERO if we never validated the address,
143 * otherwise a time up to when we consider it (or was) valid
144 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
145 * is ZERO if the address is considered valid (no validation needed)
146 * otherwise a time in the future if we're currently denying re-validation
147 * @param plugin_name name of the plugin
148 * @param plugin_address binary address
149 * @param plugin_address_len length of address
151 typedef void (*GST_ValidationAddressCallback) (void *cls,
153 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
155 const struct GNUNET_PeerIdentity
157 struct GNUNET_TIME_Absolute
159 struct GNUNET_TIME_Absolute
161 const char *plugin_name,
162 const void *plugin_address,
163 size_t plugin_address_len);
167 * Call the given function for each address for the given target.
169 * @param target peer information is requested for
170 * @param cb function to call; will not be called after this function returns
171 * @param cb_cls closure for 'cb'
174 GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
175 GST_ValidationAddressCallback cb, void *cb_cls);
179 /* end of file gnunet-service-transport_validation.h */