paragraph for gnunet devs that don't know how to use the web
[oweals/gnunet.git] / src / transport / gnunet-service-transport_validation.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2010,2011 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14     
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20  * @file transport/gnunet-service-transport_validation.h
21  * @brief address validation API
22  * @author Christian Grothoff
23  */
24 #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H
25 #define GNUNET_SERVICE_TRANSPORT_VALIDATION_H
26
27 #include "gnunet_statistics_service.h"
28 #include "gnunet_transport_plugin.h"
29 #include "gnunet_util_lib.h"
30 #include "gnunet_hello_lib.h"
31
32 /**
33  * Start the validation subsystem.
34  *
35  * @param max_fds maximum number of fds to use
36  */
37 void
38 GST_validation_start (unsigned int max_fds);
39
40
41 /**
42  * Stop the validation subsystem.
43  */
44 void
45 GST_validation_stop (void);
46
47
48 /**
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.
52  *
53  * @param address the address that we are now using (or not)
54  * @param in_use #GNUNET_YES if we are now using the address for a connection,
55  *               #GNUNET_NO if we are no longer using the address for a connection
56  */
57 void
58 GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
59                                 int in_use);
60
61
62 /**
63  * We've received a PING.  If appropriate, generate a PONG.
64  *
65  * @param sender peer sending the PING
66  * @param hdr the PING
67  * @param sender_address address of the sender, NULL if we did not initiate
68  * @param session session we got the PING from
69  * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
70  */
71 int
72 GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
73                             const struct GNUNET_MessageHeader *hdr,
74                             const struct GNUNET_HELLO_Address *sender_address,
75                             struct GNUNET_ATS_Session *session);
76
77
78 /**
79  * We've received a PONG.  Check if it matches a pending PING and
80  * mark the respective address as confirmed.
81  *
82  * @param sender peer sending the PONG
83  * @param hdr the PONG
84  * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
85  */
86 int
87 GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
88                             const struct GNUNET_MessageHeader *hdr);
89
90
91 /**
92  * We've received a HELLO, check which addresses are new and trigger
93  * validation.
94  *
95  * @param hello the HELLO we received
96  * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
97  */
98 int
99 GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
100
101
102 /**
103  * Validate an individual address.
104  *
105  * @param address address we should try to validate
106  */
107 void
108 GST_validation_handle_address (const struct GNUNET_HELLO_Address *address);
109
110
111 /**
112  * Function called for each address (or address status change) that
113  * the validation module is aware of (for the given target).
114  *
115  * @param cls closure
116  * @param public_key public key for the peer, never NULL
117  * @param valid_until is ZERO if we never validated the address,
118  *                    otherwise a time up to when we consider it (or was) valid
119  * @param validation_block  is FOREVER if the address is for an unsupported plugin (from PEERINFO)
120  *                          is ZERO if the address is considered valid (no validation needed)
121  *                          otherwise a time in the future if we're currently denying re-validation
122  * @param address the address
123  */
124 typedef void
125 (*GST_ValidationAddressCallback) (void *cls,
126                                   struct GNUNET_TIME_Absolute valid_until,
127                                   struct GNUNET_TIME_Absolute validation_block,
128                                   const struct GNUNET_HELLO_Address *address);
129
130
131 /**
132  * Call the given function for each address for the given target.
133  *
134  * @param target peer information is requested for
135  * @param cb function to call; will not be called after this function returns
136  * @param cb_cls closure for @a cb
137  */
138 void
139 GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
140                               GST_ValidationAddressCallback cb, void *cb_cls);
141
142
143 #endif
144 /* end of file gnunet-service-transport_validation.h */