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.
17 * @file transport/gnunet-service-transport.h
19 * @author Christian Grothoff
21 #ifndef GNUNET_SERVICE_TRANSPORT_H
22 #define GNUNET_SERVICE_TRANSPORT_H
24 #include "gnunet_util_lib.h"
25 #include "gnunet_statistics_service.h"
26 #include "gnunet_ats_service.h"
27 #include "gnunet_transport_service.h"
29 #define VERBOSE_VALIDATION GNUNET_YES
34 extern struct GNUNET_STATISTICS_Handle *GST_stats;
37 * Configuration handle.
39 extern const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
42 * Configuration handle.
44 extern struct GNUNET_PeerIdentity GST_my_identity;
47 * Handle to peerinfo service.
49 extern struct GNUNET_PEERINFO_Handle *GST_peerinfo;
54 extern struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key;
59 extern struct GNUNET_ATS_SchedulingHandle *GST_ats;
62 * ATS connectivity handle.
64 extern struct GNUNET_ATS_ConnectivityHandle *GST_ats_connect;
67 * Interface scanner determines our LAN address range(s).
69 extern struct GNUNET_ATS_InterfaceScanner *GST_is;
73 * Function to call when a peer's address has changed
76 * @param peer peer this update is about,
77 * @param address address, NULL for disconnect notification
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);
90 * Continuation called from a blacklist test.
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,
98 * #GNUNET_SYSERR if operation was aborted
101 (*GST_BlacklistTestContinuation) (void *cls,
102 const struct GNUNET_PeerIdentity *peer,
103 const struct GNUNET_HELLO_Address *address,
104 struct GNUNET_ATS_Session *session,
109 * Add the given peer to the blacklist (for the given transport).
111 * @param peer peer to blacklist
112 * @param transport_name transport to blacklist for this peer, NULL for all
115 GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
116 const char *transport_name);
120 * Handle to an active blacklist check.
122 struct GST_BlacklistCheck;
127 * Test if a peer/transport combination is blacklisted.
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
138 struct GST_BlacklistCheck *
139 GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
140 const char *transport_name,
141 GST_BlacklistTestContinuation cont,
143 const struct GNUNET_HELLO_Address *address,
144 struct GNUNET_ATS_Session *session);
148 * Abort blacklist if @a address and @a session match.
150 * @param address address used to abort matching checks
151 * @param session session used to abort matching checks
154 GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address,
155 struct GNUNET_ATS_Session *session);
158 * Cancel a blacklist check.
160 * @param bc check to cancel
163 GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc);
167 * Function called by the transport for each received message.
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)
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);
186 * Broadcast the given message to all of our clients.
188 * @param msg message to broadcast
189 * @param may_drop #GNUNET_YES if the message can be dropped / is payload
192 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg,
197 * Broadcast the new active address to all clients monitoring the peer.
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
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);
212 * Notify all clients about a disconnect, and cancel
213 * pending SEND_OK messages for this peer.
215 * @param peer peer that disconnected
218 GST_clients_broadcast_disconnect (const struct GNUNET_PeerIdentity *peer);
224 /* end of file gnunet-service-transport_plugins.h */