5ab2e916356acceb0c2a558a9bf2b59933d283fa
[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
33
34 /**
35  * Start the validation subsystem.
36  */
37 void 
38 GST_validation_start (void);
39
40
41 /**
42  * Stop the validation subsystem.
43  */
44 void
45 GST_validation_stop (void);
46
47
48 /**
49  * We've received a PING.  If appropriate, generate a PONG.
50  *
51  * @param sender peer sending the PING
52  * @param hdr the PING
53  * @param plugin_name name of plugin that received the PING
54  * @param session session we got the PING from
55  * @param sender_address address of the sender as known to the plugin, NULL
56  *                       if we did not initiate the connection
57  * @param sender_address_len number of bytes in sender_address
58  */
59 void
60 GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
61                             const struct GNUNET_MessageHeader *hdr,
62                             const char *plugin_name,
63                             struct Session *session,
64                             const void *sender_address,
65                             size_t sender_address_len);
66
67
68 /**
69  * We've received a PONG.  Check if it matches a pending PING and
70  * mark the respective address as confirmed.
71  *
72  * @param sender peer sending the PONG
73  * @param hdr the PONG
74  * @param plugin_name name of plugin that received the PONG
75  * @param sender_address address of the sender as known to the plugin, NULL
76  *                       if we did not initiate the connection
77  * @param sender_address_len number of bytes in sender_address
78  */
79 void
80 GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
81                             const struct GNUNET_MessageHeader *hdr,
82                             const char *plugin_name,
83                             const void *sender_address,
84                             size_t sender_address_len);
85
86
87 /**
88  * We've received a HELLO, check which addresses are new and trigger
89  * validation.
90  *
91  * @param hello the HELLO we received
92  */
93 void
94 GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
95
96
97 /**
98  * Function called for each address (or address status change) that
99  * the validation module is aware of (for the given target).
100  *
101  * @param cls closure
102  * @param public_key public key for the peer, never NULL
103  * @param target peer this change is about, never NULL
104  * @param valid_until is ZERO if we never validated the address,
105  *                    otherwise a time up to when we consider it (or was) valid
106  * @param validation_block  is FOREVER if the address is for an unsupported plugin (from PEERINFO)
107  *                          is ZERO if the address is considered valid (no validation needed)
108  *                          otherwise a time in the future if we're currently denying re-validation
109  * @param plugin_name name of the plugin
110  * @param plugin_address binary address
111  * @param plugin_address_len length of address
112  */
113 typedef void (*GST_ValidationAddressCallback)(void *cls,
114                                               const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
115                                               const struct GNUNET_PeerIdentity *target,
116                                               struct GNUNET_TIME_Absolute valid_until,
117                                               struct GNUNET_TIME_Absolute validation_block,
118                                               const char *plugin_name,
119                                               const void *plugin_address,
120                                               size_t plugin_address_len);
121
122
123 /**
124  * Call the given function for each address for the given target.
125  *
126  * @param target peer information is requested for
127  * @param cb function to call; will not be called after this function returns
128  *                             if snapshot_only is GNUNET_YES
129  * @param cb_cls closure for 'cb'
130  * @return context to cancel, NULL if 'snapshot_only' is GNUNET_YES
131  */
132 void
133 GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
134                               GST_ValidationAddressCallback cb,
135                               void *cb_cls);
136
137
138 #endif
139 /* end of file gnunet-service-transport_validation.h */