-changing exit helper code to automatically do the network configuration for an exit...
[oweals/gnunet.git] / src / transport / gnunet-service-transport_validation.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010,2011 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19 */
20
21 /**
22  * @file transport/gnunet-service-transport_validation.h
23  * @brief address validation API
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H
27 #define GNUNET_SERVICE_TRANSPORT_VALIDATION_H
28
29 #include "gnunet_statistics_service.h"
30 #include "gnunet_transport_plugin.h"
31 #include "gnunet_util_lib.h"
32 #include "gnunet_hello_lib.h"
33
34
35 /**
36  * Start the validation subsystem.
37  */
38 void
39 GST_validation_start (void);
40
41
42 /**
43  * Stop the validation subsystem.
44  */
45 void
46 GST_validation_stop (void);
47
48
49 /**
50  * Update if we are using an address for a connection actively right now.
51  * Based on this, the validation module will measure latency for the
52  * address more or less often.
53  *
54  * @param address the address
55  * @param session session
56  * @param in_use GNUNET_YES if we are now using the address for a connection,
57  *               GNUNET_NO if we are no longer using the address for a connection
58  */
59 void
60 GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
61                                 struct Session *session, int in_use);
62
63
64 /**
65  * Query validation about the latest observed latency on a given
66  * address.
67  *
68  * @param sender peer
69  * @param address the address
70  * @param session session
71  * @return observed latency of the address, FOREVER if the address was
72  *         never successfully validated
73  */
74 struct GNUNET_TIME_Relative
75 GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
76                                     const struct GNUNET_HELLO_Address *address,
77                                     struct Session *session);
78
79
80 /**
81  * We've received a PING.  If appropriate, generate a PONG.
82  *
83  * @param sender peer sending the PING
84  * @param hdr the PING
85  * @param sender_address address of the sender, NULL if we did not initiate
86  * @param session session we got the PING from
87  */
88 void
89 GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
90                             const struct GNUNET_MessageHeader *hdr,
91                             const struct GNUNET_HELLO_Address *sender_address,
92                             struct Session *session);
93
94
95 /**
96  * We've received a PONG.  Check if it matches a pending PING and
97  * mark the respective address as confirmed.
98  *
99  * @param sender peer sending the PONG
100  * @param hdr the PONG
101  */
102 void
103 GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
104                             const struct GNUNET_MessageHeader *hdr);
105
106
107 /**
108  * We've received a HELLO, check which addresses are new and trigger
109  * validation.
110  *
111  * @param hello the HELLO we received
112  */
113 void
114 GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
115
116
117 /**
118  * Function called for each address (or address status change) that
119  * the validation module is aware of (for the given target).
120  *
121  * @param cls closure
122  * @param public_key public key for the peer, never NULL
123  * @param valid_until is ZERO if we never validated the address,
124  *                    otherwise a time up to when we consider it (or was) valid
125  * @param validation_block  is FOREVER if the address is for an unsupported plugin (from PEERINFO)
126  *                          is ZERO if the address is considered valid (no validation needed)
127  *                          otherwise a time in the future if we're currently denying re-validation
128  * @param address the address
129  */
130 typedef void (*GST_ValidationAddressCallback) (void *cls,
131                                                const struct
132                                                GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
133                                                * public_key,
134                                                struct GNUNET_TIME_Absolute
135                                                valid_until,
136                                                struct GNUNET_TIME_Absolute
137                                                validation_block,
138                                                const struct GNUNET_HELLO_Address
139                                                * address);
140
141
142 /**
143  * Call the given function for each address for the given target.
144  *
145  * @param target peer information is requested for
146  * @param cb function to call; will not be called after this function returns
147  * @param cb_cls closure for 'cb'
148  */
149 void
150 GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
151                               GST_ValidationAddressCallback cb, void *cb_cls);
152
153
154 #endif
155 /* end of file gnunet-service-transport_validation.h */