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.
16 * @author Christian Grothoff
19 * API of the transport service towards the CORE service.
21 * @defgroup transport TRANSPORT service
22 * Communication with other peers
24 * @see [Documentation](https://gnunet.org/transport-service)
28 #ifndef GNUNET_TRANSPORT_CORE_SERVICE_H
29 #define GNUNET_TRANSPORT_CORE_SERVICE_H
34 #if 0 /* keep Emacsens' auto-indent happy */
39 #include "gnunet_util_lib.h"
42 * Version number of the transport API.
44 #define GNUNET_TRANSPORT_CORE_VERSION 0x00000000
48 * Opaque handle to the service.
50 struct GNUNET_TRANSPORT_CoreHandle;
54 * Function called to notify transport users that another
55 * peer connected to us.
58 * @param peer the identity of the peer that connected; this
59 * pointer will remain valid until the disconnect, hence
60 * applications do not necessarily have to make a copy
61 * of the value if they only need it until disconnect
62 * @param mq message queue to use to transmit to @a peer
63 * @return closure to use in MQ handlers
66 (*GNUNET_TRANSPORT_NotifyConnecT) (void *cls,
67 const struct GNUNET_PeerIdentity *peer,
68 struct GNUNET_MQ_Handle *mq);
72 * Function called to notify transport users that another peer
73 * disconnected from us. The message queue that was given to the
74 * connect notification will be destroyed and must not be used
77 * @param cls closure from #GNUNET_TRANSPORT_core_connect
78 * @param peer the peer that disconnected
79 * @param handlers_cls closure of the handlers, was returned from the
80 * connect notification callback
83 (*GNUNET_TRANSPORT_NotifyDisconnecT) (void *cls,
84 const struct GNUNET_PeerIdentity *peer,
89 * Function called if we have "excess" bandwidth to a peer.
90 * The notification will happen the first time we have excess
91 * bandwidth, and then only again after the client has performed
92 * some transmission to the peer.
94 * Excess bandwidth is defined as being allowed (by ATS) to send
95 * more data, and us reaching the limit of the capacity build-up
96 * (which, if we go past it, means we don't use available bandwidth).
97 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
99 * @param cls the closure
100 * @param neighbour peer that we have excess bandwidth to
101 * @param handlers_cls closure of the handlers, was returned from the
102 * connect notification callback
105 (*GNUNET_TRANSPORT_NotifyExcessBandwidtH)(void *cls,
106 const struct GNUNET_PeerIdentity *neighbour,
112 * Connect to the transport service. Note that the connection may
113 * complete (or fail) asynchronously.
115 * @param cfg configuration to use
116 * @param self our own identity (API should check that it matches
117 * the identity found by transport), or NULL (no check)
118 * @param handlers array of message handlers; note that the
119 * closures provided will be ignored and replaced
120 * with the respective return value from @a nc
121 * @param handlers array with handlers to call when we receive messages, or NULL
122 * @param cls closure for the @a nc, @a nd and @a neb callbacks
123 * @param nc function to call on connect events, or NULL
124 * @param nd function to call on disconnect events, or NULL
125 * @param neb function to call if we have excess bandwidth to a peer, or NULL
126 * @return NULL on error
128 struct GNUNET_TRANSPORT_CoreHandle *
129 GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
130 const struct GNUNET_PeerIdentity *self,
131 const struct GNUNET_MQ_MessageHandler *handlers,
133 GNUNET_TRANSPORT_NotifyConnecT nc,
134 GNUNET_TRANSPORT_NotifyDisconnecT nd,
135 GNUNET_TRANSPORT_NotifyExcessBandwidtH neb);
139 * Disconnect from the transport service.
141 * @param handle handle returned from connect
144 GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle);
148 * Checks if a given peer is connected to us and get the message queue.
150 * @param handle connection to transport service
151 * @param peer the peer to check
152 * @return NULL if disconnected, otherwise message queue for @a peer
154 struct GNUNET_MQ_Handle *
155 GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle,
156 const struct GNUNET_PeerIdentity *peer);
159 #if 0 /* keep Emacsens' auto-indent happy */
166 /* ifndef GNUNET_TRANSPORT_CORE_SERVICE_H */
169 /** @} */ /* end of group */
171 /* end of gnunet_transport_core_service.h */