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