glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / transport / gnunet-service-transport.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
16 /**
17  * @file transport/gnunet-service-transport.h
18  * @brief globals
19  * @author Christian Grothoff
20  */
21 #ifndef GNUNET_SERVICE_TRANSPORT_H
22 #define GNUNET_SERVICE_TRANSPORT_H
23
24 #include "gnunet_util_lib.h"
25 #include "gnunet_statistics_service.h"
26 #include "gnunet_ats_service.h"
27 #include "gnunet_transport_service.h"
28
29 #define VERBOSE_VALIDATION GNUNET_YES
30
31 /**
32  * Statistics handle.
33  */
34 extern struct GNUNET_STATISTICS_Handle *GST_stats;
35
36 /**
37  * Configuration handle.
38  */
39 extern const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
40
41 /**
42  * Configuration handle.
43  */
44 extern struct GNUNET_PeerIdentity GST_my_identity;
45
46 /**
47  * Handle to peerinfo service.
48  */
49 extern struct GNUNET_PEERINFO_Handle *GST_peerinfo;
50
51 /**
52  * Our private key.
53  */
54 extern struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key;
55
56 /**
57  * ATS handle.
58  */
59 extern struct GNUNET_ATS_SchedulingHandle *GST_ats;
60
61 /**
62  * ATS connectivity handle.
63  */
64 extern struct GNUNET_ATS_ConnectivityHandle *GST_ats_connect;
65
66 /**
67  * Interface scanner determines our LAN address range(s).
68  */
69 extern struct GNUNET_ATS_InterfaceScanner *GST_is;
70
71
72 /**
73  * Function to call when a peer's address has changed
74  *
75  * @param cls closure
76  * @param peer peer this update is about,
77  * @param address address, NULL for disconnect notification
78  */
79 typedef void
80 (*GNUNET_TRANSPORT_NeighbourChangeCallback) (void *cls,
81     const struct GNUNET_PeerIdentity *peer,
82     const struct GNUNET_HELLO_Address *address,
83     enum GNUNET_TRANSPORT_PeerState state,
84     struct GNUNET_TIME_Absolute state_timeout,
85     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
86     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
87
88
89 /**
90  * Continuation called from a blacklist test.
91  *
92  * @param cls closure
93  * @param peer identity of peer that was tested
94  * @param address address associated with the request
95  * @param session session associated with the request
96  * @param result #GNUNET_OK if the connection is allowed,
97  *               #GNUNET_NO if not,
98  *               #GNUNET_SYSERR if operation was aborted
99  */
100 typedef void
101 (*GST_BlacklistTestContinuation) (void *cls,
102                                   const struct GNUNET_PeerIdentity *peer,
103                                   const struct GNUNET_HELLO_Address *address,
104                                   struct GNUNET_ATS_Session *session,
105                                   int result);
106
107
108 /**
109  * Add the given peer to the blacklist (for the given transport).
110  *
111  * @param peer peer to blacklist
112  * @param transport_name transport to blacklist for this peer, NULL for all
113  */
114 void
115 GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
116                         const char *transport_name);
117
118
119 /**
120  * Handle to an active blacklist check.
121  */
122 struct GST_BlacklistCheck;
123
124
125
126 /**
127  * Test if a peer/transport combination is blacklisted.
128  *
129  * @param peer the identity of the peer to test
130  * @param transport_name name of the transport to test, never NULL
131  * @param cont function to call with result
132  * @param cont_cls closure for @a cont
133  * @param address address to pass back to @a cont, can be NULL
134  * @param session session to pass back to @a cont, can be NULL
135  * @return handle to the blacklist check, NULL if the decision
136  *        was made instantly and @a cont was already called
137  */
138 struct GST_BlacklistCheck *
139 GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
140                             const char *transport_name,
141                             GST_BlacklistTestContinuation cont, 
142                             void *cont_cls,
143                             const struct GNUNET_HELLO_Address *address,
144                             struct GNUNET_ATS_Session *session);
145
146
147 /**
148  * Abort blacklist if @a address and @a session match.
149  *
150  * @param address address used to abort matching checks
151  * @param session session used to abort matching checks
152  */
153 void
154 GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address,
155                               struct GNUNET_ATS_Session *session);
156
157 /**
158  * Cancel a blacklist check.
159  *
160  * @param bc check to cancel
161  */
162 void
163 GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc);
164
165
166 /**
167  * Function called by the transport for each received message.
168  *
169  * @param cls closure, const char* with the name of the plugin we received the message from
170  * @param address address and (claimed) identity of the other peer
171  * @param session identifier used for this session (NULL for plugins
172  *                that do not offer bi-directional communication to the sender
173  *                using the same "connection")
174  * @param message the message, NULL if we only care about
175  *                learning about the delay until we should receive again
176  * @return how long the plugin should wait until receiving more data
177  *         (plugins that do not support this, can ignore the return value)
178  */
179 struct GNUNET_TIME_Relative
180 GST_receive_callback (void *cls,
181                       const struct GNUNET_HELLO_Address *address,
182                       struct GNUNET_ATS_Session *session,
183                       const struct GNUNET_MessageHeader *message);
184
185 /**
186  * Broadcast the given message to all of our clients.
187  *
188  * @param msg message to broadcast
189  * @param may_drop #GNUNET_YES if the message can be dropped / is payload
190  */
191 void
192 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg,
193                        int may_drop);
194
195
196 /**
197  * Broadcast the new active address to all clients monitoring the peer.
198  *
199  * @param peer peer this update is about (never NULL)
200  * @param address address, NULL on disconnect
201  * @param state the current state of the peer
202  * @param state_timeout the time out for the state
203  */
204 void
205 GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer,
206                                          const struct GNUNET_HELLO_Address *address,
207                                          enum GNUNET_TRANSPORT_PeerState state,
208                                          struct GNUNET_TIME_Absolute state_timeout);
209
210
211 /**
212  * Notify all clients about a disconnect, and cancel
213  * pending SEND_OK messages for this peer.
214  *
215  * @param peer peer that disconnected
216  */
217 void
218 GST_clients_broadcast_disconnect (const struct GNUNET_PeerIdentity *peer);
219
220
221
222
223 #endif
224 /* end of file gnunet-service-transport_plugins.h */