2 This file is part of GNUnet.
3 Copyright (C) 2009-2016 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/>.
19 * @author Christian Grothoff
22 * API of the transport service towards the CORE service.
24 * @defgroup transport TRANSPORT service
25 * Communication with other peers
27 * @see [Documentation](https://gnunet.org/transport-service)
31 #ifndef GNUNET_TRANSPORT_CORE_SERVICE_H
32 #define GNUNET_TRANSPORT_CORE_SERVICE_H
37 #if 0 /* keep Emacsens' auto-indent happy */
42 #include "gnunet_util_lib.h"
45 * Version number of the transport API.
47 #define GNUNET_TRANSPORT_CORE_VERSION 0x00000000
51 * Opaque handle to the service.
53 struct GNUNET_TRANSPORT_CoreHandle;
57 * Function called to notify transport users that another
58 * peer connected to us.
61 * @param peer the identity of the peer that connected; this
62 * pointer will remain valid until the disconnect, hence
63 * applications do not necessarily have to make a copy
64 * of the value if they only need it until disconnect
65 * @param mq message queue to use to transmit to @a peer
66 * @return closure to use in MQ handlers
69 (*GNUNET_TRANSPORT_NotifyConnecT) (void *cls,
70 const struct GNUNET_PeerIdentity *peer,
71 struct GNUNET_MQ_Handle *mq);
75 * Function called to notify transport users that another peer
76 * disconnected from us. The message queue that was given to the
77 * connect notification will be destroyed and must not be used
80 * @param cls closure from #GNUNET_TRANSPORT_core_connect
81 * @param peer the peer that disconnected
82 * @param handlers_cls closure of the handlers, was returned from the
83 * connect notification callback
86 (*GNUNET_TRANSPORT_NotifyDisconnecT) (void *cls,
87 const struct GNUNET_PeerIdentity *peer,
92 * Function called if we have "excess" bandwidth to a peer.
93 * The notification will happen the first time we have excess
94 * bandwidth, and then only again after the client has performed
95 * some transmission to the peer.
97 * Excess bandwidth is defined as being allowed (by ATS) to send
98 * more data, and us reaching the limit of the capacity build-up
99 * (which, if we go past it, means we don't use available bandwidth).
100 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
102 * @param cls the closure
103 * @param neighbour peer that we have excess bandwidth to
104 * @param handlers_cls closure of the handlers, was returned from the
105 * connect notification callback
108 (*GNUNET_TRANSPORT_NotifyExcessBandwidtH)(void *cls,
109 const struct GNUNET_PeerIdentity *neighbour,
115 * Connect to the transport service. Note that the connection may
116 * complete (or fail) asynchronously.
118 * @param cfg configuration to use
119 * @param self our own identity (API should check that it matches
120 * the identity found by transport), or NULL (no check)
121 * @param handlers array of message handlers; note that the
122 * closures provided will be ignored and replaced
123 * with the respective return value from @a nc
124 * @param handlers array with handlers to call when we receive messages, or NULL
125 * @param cls closure for the @a nc, @a nd and @a neb callbacks
126 * @param nc function to call on connect events, or NULL
127 * @param nd function to call on disconnect events, or NULL
128 * @param neb function to call if we have excess bandwidth to a peer, or NULL
129 * @return NULL on error
131 struct GNUNET_TRANSPORT_CoreHandle *
132 GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
133 const struct GNUNET_PeerIdentity *self,
134 const struct GNUNET_MQ_MessageHandler *handlers,
136 GNUNET_TRANSPORT_NotifyConnecT nc,
137 GNUNET_TRANSPORT_NotifyDisconnecT nd,
138 GNUNET_TRANSPORT_NotifyExcessBandwidtH neb);
142 * Disconnect from the transport service.
144 * @param handle handle returned from connect
147 GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle);
151 * Checks if a given peer is connected to us and get the message queue.
153 * @param handle connection to transport service
154 * @param peer the peer to check
155 * @return NULL if disconnected, otherwise message queue for @a peer
157 struct GNUNET_MQ_Handle *
158 GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle,
159 const struct GNUNET_PeerIdentity *peer);
162 #if 0 /* keep Emacsens' auto-indent happy */
169 /* ifndef GNUNET_TRANSPORT_CORE_SERVICE_H */
172 /** @} */ /* end of group */
174 /* end of gnunet_transport_core_service.h */