rename configs to match
[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      SPDX-License-Identifier: AGPL3.0-or-later
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  * Start the validation subsystem.
36  *
37  * @param max_fds maximum number of fds to use
38  */
39 void
40 GST_validation_start (unsigned int max_fds);
41
42
43 /**
44  * Stop the validation subsystem.
45  */
46 void
47 GST_validation_stop (void);
48
49
50 /**
51  * Update if we are using an address for a connection actively right now.
52  * Based on this, the validation module will measure latency for the
53  * address more or less often.
54  *
55  * @param address the address that we are now using (or not)
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                                 int in_use);
62
63
64 /**
65  * We've received a PING.  If appropriate, generate a PONG.
66  *
67  * @param sender peer sending the PING
68  * @param hdr the PING
69  * @param sender_address address of the sender, NULL if we did not initiate
70  * @param session session we got the PING from
71  * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
72  */
73 int
74 GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
75                             const struct GNUNET_MessageHeader *hdr,
76                             const struct GNUNET_HELLO_Address *sender_address,
77                             struct GNUNET_ATS_Session *session);
78
79
80 /**
81  * We've received a PONG.  Check if it matches a pending PING and
82  * mark the respective address as confirmed.
83  *
84  * @param sender peer sending the PONG
85  * @param hdr the PONG
86  * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
87  */
88 int
89 GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
90                             const struct GNUNET_MessageHeader *hdr);
91
92
93 /**
94  * We've received a HELLO, check which addresses are new and trigger
95  * validation.
96  *
97  * @param hello the HELLO we received
98  * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
99  */
100 int
101 GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
102
103
104 /**
105  * Validate an individual address.
106  *
107  * @param address address we should try to validate
108  */
109 void
110 GST_validation_handle_address (const struct GNUNET_HELLO_Address *address);
111
112
113 /**
114  * Function called for each address (or address status change) that
115  * the validation module is aware of (for the given target).
116  *
117  * @param cls closure
118  * @param public_key public key for the peer, never NULL
119  * @param valid_until is ZERO if we never validated the address,
120  *                    otherwise a time up to when we consider it (or was) valid
121  * @param validation_block  is FOREVER if the address is for an unsupported plugin (from PEERINFO)
122  *                          is ZERO if the address is considered valid (no validation needed)
123  *                          otherwise a time in the future if we're currently denying re-validation
124  * @param address the address
125  */
126 typedef void
127 (*GST_ValidationAddressCallback) (void *cls,
128                                   struct GNUNET_TIME_Absolute valid_until,
129                                   struct GNUNET_TIME_Absolute validation_block,
130                                   const struct GNUNET_HELLO_Address *address);
131
132
133 /**
134  * Call the given function for each address for the given target.
135  *
136  * @param target peer information is requested for
137  * @param cb function to call; will not be called after this function returns
138  * @param cb_cls closure for @a cb
139  */
140 void
141 GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
142                               GST_ValidationAddressCallback cb, void *cb_cls);
143
144
145 #endif
146 /* end of file gnunet-service-transport_validation.h */