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