2 This file is part of GNUnet.
3 Copyright (C) 2010,2011 GNUnet e.V.
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.
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.
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/>.
20 * @file transport/gnunet-service-transport.h
22 * @author Christian Grothoff
24 #ifndef GNUNET_SERVICE_TRANSPORT_H
25 #define GNUNET_SERVICE_TRANSPORT_H
27 #include "gnunet_util_lib.h"
28 #include "gnunet_statistics_service.h"
29 #include "gnunet_ats_service.h"
30 #include "gnunet_transport_service.h"
32 #define VERBOSE_VALIDATION GNUNET_YES
37 extern struct GNUNET_STATISTICS_Handle *GST_stats;
40 * Configuration handle.
42 extern const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
45 * Configuration handle.
47 extern struct GNUNET_PeerIdentity GST_my_identity;
50 * Handle to peerinfo service.
52 extern struct GNUNET_PEERINFO_Handle *GST_peerinfo;
57 extern struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key;
62 extern struct GNUNET_ATS_SchedulingHandle *GST_ats;
65 * ATS connectivity handle.
67 extern struct GNUNET_ATS_ConnectivityHandle *GST_ats_connect;
70 * Interface scanner determines our LAN address range(s).
72 extern struct GNUNET_ATS_InterfaceScanner *GST_is;
76 * Function to call when a peer's address has changed
79 * @param peer peer this update is about,
80 * @param address address, NULL for disconnect notification
83 (*GNUNET_TRANSPORT_NeighbourChangeCallback) (void *cls,
84 const struct GNUNET_PeerIdentity *peer,
85 const struct GNUNET_HELLO_Address *address,
86 enum GNUNET_TRANSPORT_PeerState state,
87 struct GNUNET_TIME_Absolute state_timeout,
88 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
89 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
93 * Continuation called from a blacklist test.
96 * @param peer identity of peer that was tested
97 * @param address address associated with the request
98 * @param session session associated with the request
99 * @param result #GNUNET_OK if the connection is allowed,
101 * #GNUNET_SYSERR if operation was aborted
104 (*GST_BlacklistTestContinuation) (void *cls,
105 const struct GNUNET_PeerIdentity *peer,
106 const struct GNUNET_HELLO_Address *address,
107 struct GNUNET_ATS_Session *session,
112 * Add the given peer to the blacklist (for the given transport).
114 * @param peer peer to blacklist
115 * @param transport_name transport to blacklist for this peer, NULL for all
118 GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
119 const char *transport_name);
123 * Handle to an active blacklist check.
125 struct GST_BlacklistCheck;
130 * Test if a peer/transport combination is blacklisted.
132 * @param peer the identity of the peer to test
133 * @param transport_name name of the transport to test, never NULL
134 * @param cont function to call with result
135 * @param cont_cls closure for @a cont
136 * @param address address to pass back to @a cont, can be NULL
137 * @param session session to pass back to @a cont, can be NULL
138 * @return handle to the blacklist check, NULL if the decision
139 * was made instantly and @a cont was already called
141 struct GST_BlacklistCheck *
142 GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
143 const char *transport_name,
144 GST_BlacklistTestContinuation cont,
146 const struct GNUNET_HELLO_Address *address,
147 struct GNUNET_ATS_Session *session);
151 * Abort blacklist if @a address and @a session match.
153 * @param address address used to abort matching checks
154 * @param session session used to abort matching checks
157 GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address,
158 struct GNUNET_ATS_Session *session);
161 * Cancel a blacklist check.
163 * @param bc check to cancel
166 GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc);
170 * Function called by the transport for each received message.
172 * @param cls closure, const char* with the name of the plugin we received the message from
173 * @param address address and (claimed) identity of the other peer
174 * @param session identifier used for this session (NULL for plugins
175 * that do not offer bi-directional communication to the sender
176 * using the same "connection")
177 * @param message the message, NULL if we only care about
178 * learning about the delay until we should receive again
179 * @return how long the plugin should wait until receiving more data
180 * (plugins that do not support this, can ignore the return value)
182 struct GNUNET_TIME_Relative
183 GST_receive_callback (void *cls,
184 const struct GNUNET_HELLO_Address *address,
185 struct GNUNET_ATS_Session *session,
186 const struct GNUNET_MessageHeader *message);
189 * Broadcast the given message to all of our clients.
191 * @param msg message to broadcast
192 * @param may_drop #GNUNET_YES if the message can be dropped / is payload
195 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg,
200 * Broadcast the new active address to all clients monitoring the peer.
202 * @param peer peer this update is about (never NULL)
203 * @param address address, NULL on disconnect
204 * @param state the current state of the peer
205 * @param state_timeout the time out for the state
208 GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer,
209 const struct GNUNET_HELLO_Address *address,
210 enum GNUNET_TRANSPORT_PeerState state,
211 struct GNUNET_TIME_Absolute state_timeout);
215 * Notify all clients about a disconnect, and cancel
216 * pending SEND_OK messages for this peer.
218 * @param peer peer that disconnected
221 GST_clients_broadcast_disconnect (const struct GNUNET_PeerIdentity *peer);
227 /* end of file gnunet-service-transport_plugins.h */