aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_protocols.h8
-rw-r--r--src/include/gnunet_transport_communication_service.h113
-rw-r--r--src/include/gnunet_transport_core_service.h85
-rw-r--r--src/include/gnunet_transport_service.h232
4 files changed, 286 insertions, 152 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 27a7034b0..7a089ad65 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1089,10 +1089,18 @@ extern "C" {
1089 1089
1090/** 1090/**
1091 * Message telling transport to limit its receive rate. 1091 * Message telling transport to limit its receive rate.
1092 * (FIXME: was the above comment ever accurate?)
1093 *
1094 * Note: dead in TNG, replaced by RECV_OK!
1092 */ 1095 */
1093#define GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA 366 1096#define GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA 366
1094 1097
1095/** 1098/**
1099 * Message telling transport to limit its receive rate.
1100 */
1101#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK 366
1102
1103/**
1096 * Request to look addresses of peers in server. 1104 * Request to look addresses of peers in server.
1097 */ 1105 */
1098#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING 367 1106#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING 367
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h
index ca5a86074..ea1ff732e 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2018 GNUnet e.V. 3 Copyright (C) 2009-2019 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -36,9 +36,8 @@
36#define GNUNET_TRANSPORT_COMMUNICATION_SERVICE_H 36#define GNUNET_TRANSPORT_COMMUNICATION_SERVICE_H
37 37
38#ifdef __cplusplus 38#ifdef __cplusplus
39extern "C" 39extern "C" {
40{ 40#if 0 /* keep Emacsens' auto-indent happy */
41#if 0 /* keep Emacsens' auto-indent happy */
42} 41}
43#endif 42#endif
44#endif 43#endif
@@ -67,12 +66,13 @@ extern "C"
67 * @param peer identity of the other peer 66 * @param peer identity of the other peer
68 * @param address where to send the message, human-readable 67 * @param address where to send the message, human-readable
69 * communicator-specific format, 0-terminated, UTF-8 68 * communicator-specific format, 0-terminated, UTF-8
70 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is invalid 69 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is
70 * invalid
71 */ 71 */
72typedef int 72typedef int (*GNUNET_TRANSPORT_CommunicatorMqInit) (
73(*GNUNET_TRANSPORT_CommunicatorMqInit) (void *cls, 73 void *cls,
74 const struct GNUNET_PeerIdentity *peer, 74 const struct GNUNET_PeerIdentity *peer,
75 const char *address); 75 const char *address);
76 76
77 77
78/** 78/**
@@ -87,7 +87,8 @@ struct GNUNET_TRANSPORT_CommunicatorHandle;
87 * FIXME: may want to distinguish bi-directional as well, 87 * FIXME: may want to distinguish bi-directional as well,
88 * should we define a bit for that? Needed in DV logic (handle_dv_learn)! 88 * should we define a bit for that? Needed in DV logic (handle_dv_learn)!
89 */ 89 */
90enum GNUNET_TRANSPORT_CommunicatorCharacteristics { 90enum GNUNET_TRANSPORT_CommunicatorCharacteristics
91{
91 92
92 /** 93 /**
93 * Characteristics are unknown (i.e. DV). 94 * Characteristics are unknown (i.e. DV).
@@ -122,10 +123,10 @@ enum GNUNET_TRANSPORT_CommunicatorCharacteristics {
122 * @param sender which peer sent the notification 123 * @param sender which peer sent the notification
123 * @param msg payload 124 * @param msg payload
124 */ 125 */
125typedef void 126typedef void (*GNUNET_TRANSPORT_CommunicatorNotify) (
126(*GNUNET_TRANSPORT_CommunicatorNotify) (void *cls, 127 void *cls,
127 const struct GNUNET_PeerIdentity *sender, 128 const struct GNUNET_PeerIdentity *sender,
128 const struct GNUNET_MessageHeader *msg); 129 const struct GNUNET_MessageHeader *msg);
129 130
130 131
131/** 132/**
@@ -145,14 +146,15 @@ typedef void
145 * @return NULL on error 146 * @return NULL on error
146 */ 147 */
147struct GNUNET_TRANSPORT_CommunicatorHandle * 148struct GNUNET_TRANSPORT_CommunicatorHandle *
148GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 149GNUNET_TRANSPORT_communicator_connect (
149 const char *config_section_name, 150 const struct GNUNET_CONFIGURATION_Handle *cfg,
150 const char *addr_prefix, 151 const char *config_section_name,
151 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, 152 const char *addr_prefix,
152 GNUNET_TRANSPORT_CommunicatorMqInit mq_init, 153 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc,
153 void *mq_init_cls, 154 GNUNET_TRANSPORT_CommunicatorMqInit mq_init,
154 GNUNET_TRANSPORT_CommunicatorNotify notify_cb, 155 void *mq_init_cls,
155 void *notify_cb_cls); 156 GNUNET_TRANSPORT_CommunicatorNotify notify_cb,
157 void *notify_cb_cls);
156 158
157 159
158/** 160/**
@@ -161,22 +163,23 @@ GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle
161 * @param ch handle returned from connect 163 * @param ch handle returned from connect
162 */ 164 */
163void 165void
164GNUNET_TRANSPORT_communicator_disconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch); 166GNUNET_TRANSPORT_communicator_disconnect (
167 struct GNUNET_TRANSPORT_CommunicatorHandle *ch);
165 168
166 169
167/* ************************* Receiving *************************** */ 170/* ************************* Receiving *************************** */
168 171
169/** 172/**
170 * Function called to notify communicator that we have received 173 * Function called to notify communicator that we have received
171 * and processed the message. 174 * and processed the message. Used for flow control (if supported
175 * by the communicator).
172 * 176 *
173 * @param cls closure 177 * @param cls closure
174 * @param success #GNUNET_SYSERR on failure (try to disconnect/reset connection) 178 * @param success #GNUNET_SYSERR on failure (try to disconnect/reset connection)
175 * #GNUNET_OK on success 179 * #GNUNET_OK on success
176 */ 180 */
177typedef void 181typedef void (*GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls,
178(*GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls, 182 int success);
179 int success);
180 183
181 184
182/** 185/**
@@ -200,12 +203,13 @@ typedef void
200 * the tranport service is not yet up 203 * the tranport service is not yet up
201 */ 204 */
202int 205int
203GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandle *handle, 206GNUNET_TRANSPORT_communicator_receive (
204 const struct GNUNET_PeerIdentity *sender, 207 struct GNUNET_TRANSPORT_CommunicatorHandle *handle,
205 const struct GNUNET_MessageHeader *msg, 208 const struct GNUNET_PeerIdentity *sender,
206 struct GNUNET_TIME_Relative expected_addr_validity, 209 const struct GNUNET_MessageHeader *msg,
207 GNUNET_TRANSPORT_MessageCompletedCallback cb, 210 struct GNUNET_TIME_Relative expected_addr_validity,
208 void *cb_cls); 211 GNUNET_TRANSPORT_MessageCompletedCallback cb,
212 void *cb_cls);
209 213
210 214
211/* ************************* Discovery *************************** */ 215/* ************************* Discovery *************************** */
@@ -220,7 +224,8 @@ struct GNUNET_TRANSPORT_QueueHandle;
220/** 224/**
221 * Possible states of a connection. 225 * Possible states of a connection.
222 */ 226 */
223enum GNUNET_TRANSPORT_ConnectionStatus { 227enum GNUNET_TRANSPORT_ConnectionStatus
228{
224 229
225 /** 230 /**
226 * Connection is down. 231 * Connection is down.
@@ -255,13 +260,14 @@ enum GNUNET_TRANSPORT_ConnectionStatus {
255 * @return API handle identifying the new MQ 260 * @return API handle identifying the new MQ
256 */ 261 */
257struct GNUNET_TRANSPORT_QueueHandle * 262struct GNUNET_TRANSPORT_QueueHandle *
258GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, 263GNUNET_TRANSPORT_communicator_mq_add (
259 const struct GNUNET_PeerIdentity *peer, 264 struct GNUNET_TRANSPORT_CommunicatorHandle *ch,
260 const char *address, 265 const struct GNUNET_PeerIdentity *peer,
261 uint32_t mtu, 266 const char *address,
262 enum GNUNET_NetworkType nt, 267 uint32_t mtu,
263 enum GNUNET_TRANSPORT_ConnectionStatus cs, 268 enum GNUNET_NetworkType nt,
264 struct GNUNET_MQ_Handle *mq); 269 enum GNUNET_TRANSPORT_ConnectionStatus cs,
270 struct GNUNET_MQ_Handle *mq);
265 271
266 272
267/** 273/**
@@ -291,10 +297,11 @@ struct GNUNET_TRANSPORT_AddressIdentifier;
291 * @param expiration when does the communicator forsee this address expiring? 297 * @param expiration when does the communicator forsee this address expiring?
292 */ 298 */
293struct GNUNET_TRANSPORT_AddressIdentifier * 299struct GNUNET_TRANSPORT_AddressIdentifier *
294GNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, 300GNUNET_TRANSPORT_communicator_address_add (
295 const char *address, 301 struct GNUNET_TRANSPORT_CommunicatorHandle *ch,
296 enum GNUNET_NetworkType nt, 302 const char *address,
297 struct GNUNET_TIME_Relative expiration); 303 enum GNUNET_NetworkType nt,
304 struct GNUNET_TIME_Relative expiration);
298 305
299 306
300/** 307/**
@@ -304,7 +311,8 @@ GNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorH
304 * @param ai address that is no longer provided 311 * @param ai address that is no longer provided
305 */ 312 */
306void 313void
307GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_AddressIdentifier *ai); 314GNUNET_TRANSPORT_communicator_address_remove (
315 struct GNUNET_TRANSPORT_AddressIdentifier *ai);
308 316
309 317
310/** 318/**
@@ -326,13 +334,14 @@ GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_AddressIde
326 * notify-API to @a pid's communicator @a comm 334 * notify-API to @a pid's communicator @a comm
327 */ 335 */
328void 336void
329GNUNET_TRANSPORT_communicator_notify (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, 337GNUNET_TRANSPORT_communicator_notify (
330 const struct GNUNET_PeerIdentity *pid, 338 struct GNUNET_TRANSPORT_CommunicatorHandle *ch,
331 const char *comm, 339 const struct GNUNET_PeerIdentity *pid,
332 const struct GNUNET_MessageHeader *header); 340 const char *comm,
341 const struct GNUNET_MessageHeader *header);
333 342
334 343
335#if 0 /* keep Emacsens' auto-indent happy */ 344#if 0 /* keep Emacsens' auto-indent happy */
336{ 345{
337#endif 346#endif
338#ifdef __cplusplus 347#ifdef __cplusplus
@@ -342,6 +351,6 @@ GNUNET_TRANSPORT_communicator_notify (struct GNUNET_TRANSPORT_CommunicatorHandle
342/* ifndef GNUNET_TRANSPORT_COMMUNICATOR_SERVICE_H */ 351/* ifndef GNUNET_TRANSPORT_COMMUNICATOR_SERVICE_H */
343#endif 352#endif
344 353
345/** @} */ /* end of group */ 354/** @} */ /* end of group */
346 355
347/* end of gnunet_transport_communicator_service.h */ 356/* end of gnunet_transport_communicator_service.h */
diff --git a/src/include/gnunet_transport_core_service.h b/src/include/gnunet_transport_core_service.h
index f442b53c0..076514779 100644
--- a/src/include/gnunet_transport_core_service.h
+++ b/src/include/gnunet_transport_core_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2016 GNUnet e.V. 3 Copyright (C) 2009-2019 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -21,7 +21,7 @@
21 * @author Christian Grothoff 21 * @author Christian Grothoff
22 * 22 *
23 * @file 23 * @file
24 * API of the transport service towards the CORE service. 24 * API of the transport service towards the CORE service (TNG version)
25 * 25 *
26 * @defgroup transport TRANSPORT service 26 * @defgroup transport TRANSPORT service
27 * Communication with other peers 27 * Communication with other peers
@@ -34,9 +34,8 @@
34#define GNUNET_TRANSPORT_CORE_SERVICE_H 34#define GNUNET_TRANSPORT_CORE_SERVICE_H
35 35
36#ifdef __cplusplus 36#ifdef __cplusplus
37extern "C" 37extern "C" {
38{ 38#if 0 /* keep Emacsens' auto-indent happy */
39#if 0 /* keep Emacsens' auto-indent happy */
40} 39}
41#endif 40#endif
42#endif 41#endif
@@ -62,15 +61,15 @@ struct GNUNET_TRANSPORT_CoreHandle;
62 * @param cls closure 61 * @param cls closure
63 * @param peer the identity of the peer that connected; this 62 * @param peer the identity of the peer that connected; this
64 * pointer will remain valid until the disconnect, hence 63 * pointer will remain valid until the disconnect, hence
65 * applications do not necessarily have to make a copy 64 * applications do not necessarily have to make a copy
66 * of the value if they only need it until disconnect 65 * of the value if they only need it until disconnect
67 * @param mq message queue to use to transmit to @a peer 66 * @param mq message queue to use to transmit to @a peer
68 * @return closure to use in MQ handlers 67 * @return closure to use in MQ handlers
69 */ 68 */
70typedef void * 69typedef void *(*GNUNET_TRANSPORT_NotifyConnect) (
71(*GNUNET_TRANSPORT_NotifyConnect) (void *cls, 70 void *cls,
72 const struct GNUNET_PeerIdentity *peer, 71 const struct GNUNET_PeerIdentity *peer,
73 struct GNUNET_MQ_Handle *mq); 72 struct GNUNET_MQ_Handle *mq);
74 73
75 74
76/** 75/**
@@ -84,33 +83,10 @@ typedef void *
84 * @param handlers_cls closure of the handlers, was returned from the 83 * @param handlers_cls closure of the handlers, was returned from the
85 * connect notification callback 84 * connect notification callback
86 */ 85 */
87typedef void 86typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (
88(*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, 87 void *cls,
89 const struct GNUNET_PeerIdentity *peer, 88 const struct GNUNET_PeerIdentity *peer,
90 void *handler_cls); 89 void *handler_cls);
91
92
93/**
94 * Function called if we have "excess" bandwidth to a peer.
95 * The notification will happen the first time we have excess
96 * bandwidth, and then only again after the client has performed
97 * some transmission to the peer.
98 *
99 * Excess bandwidth is defined as being allowed (by ATS) to send
100 * more data, and us reaching the limit of the capacity build-up
101 * (which, if we go past it, means we don't use available bandwidth).
102 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
103 *
104 * @param cls the closure
105 * @param neighbour peer that we have excess bandwidth to
106 * @param handlers_cls closure of the handlers, was returned from the
107 * connect notification callback
108 */
109typedef void
110(*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls,
111 const struct GNUNET_PeerIdentity *neighbour,
112 void *handlers_cls);
113
114 90
115 91
116/** 92/**
@@ -136,8 +112,7 @@ GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
136 const struct GNUNET_MQ_MessageHandler *handlers, 112 const struct GNUNET_MQ_MessageHandler *handlers,
137 void *cls, 113 void *cls,
138 GNUNET_TRANSPORT_NotifyConnect nc, 114 GNUNET_TRANSPORT_NotifyConnect nc,
139 GNUNET_TRANSPORT_NotifyDisconnect nd, 115 GNUNET_TRANSPORT_NotifyDisconnect nd);
140 GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
141 116
142 117
143/** 118/**
@@ -150,7 +125,33 @@ GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle);
150 125
151 126
152/** 127/**
128 * Notification from the CORE service to the TRANSPORT service
129 * that the CORE service has finished processing a message from
130 * TRANSPORT (via the @code{handlers} of #GNUNET_TRANSPORT_core_connect())
131 * and that it is thus now OK for TRANSPORT to send more messages
132 * for @a pid.
133 *
134 * Used to provide flow control, this is our equivalent to
135 * #GNUNET_SERVICE_client_continue() of an ordinary service.
136 *
137 * Note that due to the use of a window, TRANSPORT may send multiple
138 * messages destined for the same peer even without an intermediate
139 * call to this function. However, CORE must still call this function
140 * once per message received, as otherwise eventually the window will
141 * be full and TRANSPORT will stop providing messages to CORE for @a
142 * pid.
143 *
144 * @param ch core handle
145 * @param pid which peer was the message from that was fully processed by CORE
146 */
147void
148GNUNET_TRANSPORT_core_receive_continue (struct GNUNET_TRANSPORT_CoreHandle *ch,
149 const struct GNUNET_PeerIdentity *pid);
150
151
152/**
153 * Checks if a given peer is connected to us and get the message queue. 153 * Checks if a given peer is connected to us and get the message queue.
154 * Convenience function.
154 * 155 *
155 * @param handle connection to transport service 156 * @param handle connection to transport service
156 * @param peer the peer to check 157 * @param peer the peer to check
@@ -161,7 +162,7 @@ GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle,
161 const struct GNUNET_PeerIdentity *peer); 162 const struct GNUNET_PeerIdentity *peer);
162 163
163 164
164#if 0 /* keep Emacsens' auto-indent happy */ 165#if 0 /* keep Emacsens' auto-indent happy */
165{ 166{
166#endif 167#endif
167#ifdef __cplusplus 168#ifdef __cplusplus
@@ -171,6 +172,6 @@ GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle,
171/* ifndef GNUNET_TRANSPORT_CORE_SERVICE_H */ 172/* ifndef GNUNET_TRANSPORT_CORE_SERVICE_H */
172#endif 173#endif
173 174
174/** @} */ /* end of group */ 175/** @} */ /* end of group */
175 176
176/* end of gnunet_transport_core_service.h */ 177/* end of gnunet_transport_core_service.h */
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index c5cb10ad8..80949b417 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -36,9 +36,8 @@
36#define GNUNET_TRANSPORT_SERVICE_H 36#define GNUNET_TRANSPORT_SERVICE_H
37 37
38#ifdef __cplusplus 38#ifdef __cplusplus
39extern "C" 39extern "C" {
40{ 40#if 0 /* keep Emacsens' auto-indent happy */
41#if 0 /* keep Emacsens' auto-indent happy */
42} 41}
43#endif 42#endif
44#endif 43#endif
@@ -71,8 +70,8 @@ struct GNUNET_TRANSPORT_OfferHelloHandle;
71 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail 70 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
72 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success 71 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
73 * @param cont_cls closure for @a cont 72 * @param cont_cls closure for @a cont
74 * @return a `struct GNUNET_TRANSPORT_OfferHelloHandle` handle or NULL on failure, 73 * @return a `struct GNUNET_TRANSPORT_OfferHelloHandle` handle or NULL on
75 * in case of failure @a cont will not be called 74 * failure, in case of failure @a cont will not be called
76 * 75 *
77 */ 76 */
78struct GNUNET_TRANSPORT_OfferHelloHandle * 77struct GNUNET_TRANSPORT_OfferHelloHandle *
@@ -88,7 +87,8 @@ GNUNET_TRANSPORT_offer_hello (const struct GNUNET_CONFIGURATION_Handle *cfg,
88 * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel 87 * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel
89 */ 88 */
90void 89void
91GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh); 90GNUNET_TRANSPORT_offer_hello_cancel (
91 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh);
92 92
93 93
94/* *********************** Address to String ******************* */ 94/* *********************** Address to String ******************* */
@@ -115,10 +115,9 @@ struct GNUNET_TRANSPORT_AddressToStringContext;
115 * if #GNUNET_NO: address was invalid (or not supported) 115 * if #GNUNET_NO: address was invalid (or not supported)
116 * if #GNUNET_SYSERR: communication error (IPC error) 116 * if #GNUNET_SYSERR: communication error (IPC error)
117 */ 117 */
118typedef void 118typedef void (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
119(*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls, 119 const char *address,
120 const char *address, 120 int res);
121 int res);
122 121
123 122
124/** 123/**
@@ -134,12 +133,13 @@ typedef void
134 * @return handle to cancel the operation, NULL on error 133 * @return handle to cancel the operation, NULL on error
135 */ 134 */
136struct GNUNET_TRANSPORT_AddressToStringContext * 135struct GNUNET_TRANSPORT_AddressToStringContext *
137GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg, 136GNUNET_TRANSPORT_address_to_string (
138 const struct GNUNET_HELLO_Address *address, 137 const struct GNUNET_CONFIGURATION_Handle *cfg,
139 int numeric, 138 const struct GNUNET_HELLO_Address *address,
140 struct GNUNET_TIME_Relative timeout, 139 int numeric,
141 GNUNET_TRANSPORT_AddressToStringCallback aluc, 140 struct GNUNET_TIME_Relative timeout,
142 void *aluc_cls); 141 GNUNET_TRANSPORT_AddressToStringCallback aluc,
142 void *aluc_cls);
143 143
144 144
145/** 145/**
@@ -148,14 +148,16 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
148 * @param alc the context handle 148 * @param alc the context handle
149 */ 149 */
150void 150void
151GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStringContext *alc); 151GNUNET_TRANSPORT_address_to_string_cancel (
152 struct GNUNET_TRANSPORT_AddressToStringContext *alc);
152 153
153 154
154/* *********************** Monitoring ************************** */ 155/* *********************** Monitoring ************************** */
155 156
156 157
157/** 158/**
158 * Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_NOT_CONNECTED. 159 * Possible state of a neighbour. Initially, we are
160 * #GNUNET_TRANSPORT_PS_NOT_CONNECTED.
159 * 161 *
160 * Then, there are two main paths. If we receive a SYN message, we give 162 * Then, there are two main paths. If we receive a SYN message, we give
161 * the inbound address to ATS. After the check we ask ATS for a suggestion 163 * the inbound address to ATS. After the check we ask ATS for a suggestion
@@ -174,14 +176,14 @@ GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStri
174 * #GNUNET_TRANSPORT_PS_DISCONNECT. 176 * #GNUNET_TRANSPORT_PS_DISCONNECT.
175 * 177 *
176 * If the session is in trouble (i.e. transport-level disconnect or 178 * If the session is in trouble (i.e. transport-level disconnect or
177 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new 179 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a
178 * address (we don't notify anyone about the disconnect yet). Once we 180 * new address (we don't notify anyone about the disconnect yet). Once we have
179 * have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a 181 * a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a SYN
180 * SYN message. If we receive a 182 * message. If we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
181 * SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had 183 * and nobody noticed that we had trouble; we also send a ACK at this time just
182 * trouble; we also send a ACK at this time just in case. If 184 * in case. If the operation times out, we go to
183 * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone 185 * #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone about the lost
184 * about the lost connection). 186 * connection).
185 * 187 *
186 * If ATS decides to switch addresses while we have a normal 188 * If ATS decides to switch addresses while we have a normal
187 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT 189 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT
@@ -189,13 +191,14 @@ GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStri
189 * primary connection to the suggested alternative from ATS, go back 191 * primary connection to the suggested alternative from ATS, go back
190 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be 192 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be
191 * sure. If the operation times out 193 * sure. If the operation times out
192 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative 194 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given
193 * address is "invalid"). 195 * alternative address is "invalid").
194 * 196 *
195 * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and then goes 197 * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and
196 * to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explicit disconnect 198 * then goes to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an
197 * request, we can go from any state to #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after 199 * explicit disconnect request, we can go from any state to
198 * generating disconnect notifications. 200 * #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after generating disconnect
201 * notifications.
199 * 202 *
200 * Note that it is quite possible that while we are in any of these 203 * Note that it is quite possible that while we are in any of these
201 * states, we could receive a 'SYN' request from the other peer. 204 * states, we could receive a 'SYN' request from the other peer.
@@ -323,12 +326,12 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext;
323 * @param state current state this peer is in 326 * @param state current state this peer is in
324 * @param state_timeout timeout for the current state of the peer 327 * @param state_timeout timeout for the current state of the peer
325 */ 328 */
326typedef void 329typedef void (*GNUNET_TRANSPORT_PeerIterateCallback) (
327(*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls, 330 void *cls,
328 const struct GNUNET_PeerIdentity *peer, 331 const struct GNUNET_PeerIdentity *peer,
329 const struct GNUNET_HELLO_Address *address, 332 const struct GNUNET_HELLO_Address *address,
330 enum GNUNET_TRANSPORT_PeerState state, 333 enum GNUNET_TRANSPORT_PeerState state,
331 struct GNUNET_TIME_Absolute state_timeout); 334 struct GNUNET_TIME_Absolute state_timeout);
332 335
333 336
334/** 337/**
@@ -352,17 +355,18 @@ typedef void
352 * @param cfg configuration to use 355 * @param cfg configuration to use
353 * @param peer a specific peer identity to obtain information for, 356 * @param peer a specific peer identity to obtain information for,
354 * NULL for all peers 357 * NULL for all peers
355 * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL), 358 * @param one_shot #GNUNET_YES to return the current state and then end (with
356 * #GNUNET_NO to monitor peers continuously 359 * NULL+NULL), #GNUNET_NO to monitor peers continuously
357 * @param peer_callback function to call with the results 360 * @param peer_callback function to call with the results
358 * @param peer_callback_cls closure for @a peer_callback 361 * @param peer_callback_cls closure for @a peer_callback
359 */ 362 */
360struct GNUNET_TRANSPORT_PeerMonitoringContext * 363struct GNUNET_TRANSPORT_PeerMonitoringContext *
361GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, 364GNUNET_TRANSPORT_monitor_peers (
362 const struct GNUNET_PeerIdentity *peer, 365 const struct GNUNET_CONFIGURATION_Handle *cfg,
363 int one_shot, 366 const struct GNUNET_PeerIdentity *peer,
364 GNUNET_TRANSPORT_PeerIterateCallback peer_callback, 367 int one_shot,
365 void *peer_callback_cls); 368 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
369 void *peer_callback_cls);
366 370
367 371
368/** 372/**
@@ -371,7 +375,8 @@ GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
371 * @param pic handle for the request to cancel 375 * @param pic handle for the request to cancel
372 */ 376 */
373void 377void
374GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic); 378GNUNET_TRANSPORT_monitor_peers_cancel (
379 struct GNUNET_TRANSPORT_PeerMonitoringContext *pic);
375 380
376 381
377/* *********************** Blacklisting ************************ */ 382/* *********************** Blacklisting ************************ */
@@ -389,9 +394,9 @@ struct GNUNET_TRANSPORT_Blacklist;
389 * @param pid peer to approve or disapproave 394 * @param pid peer to approve or disapproave
390 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not 395 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
391 */ 396 */
392typedef int 397typedef int (*GNUNET_TRANSPORT_BlacklistCallback) (
393(*GNUNET_TRANSPORT_BlacklistCallback) (void *cls, 398 void *cls,
394 const struct GNUNET_PeerIdentity *pid); 399 const struct GNUNET_PeerIdentity *pid);
395 400
396 401
397/** 402/**
@@ -539,11 +544,11 @@ struct GNUNET_TRANSPORT_SessionInfo
539 * NULL with @a session being non-NULL if the monitor 544 * NULL with @a session being non-NULL if the monitor
540 * was being cancelled while sessions were active 545 * was being cancelled while sessions were active
541 */ 546 */
542typedef void 547typedef void (*GNUNET_TRANSPORT_SessionMonitorCallback) (
543(*GNUNET_TRANSPORT_SessionMonitorCallback) (void *cls, 548 void *cls,
544 struct GNUNET_TRANSPORT_PluginSession *session, 549 struct GNUNET_TRANSPORT_PluginSession *session,
545 void **session_ctx, 550 void **session_ctx,
546 const struct GNUNET_TRANSPORT_SessionInfo *info); 551 const struct GNUNET_TRANSPORT_SessionInfo *info);
547 552
548 553
549/** 554/**
@@ -569,11 +574,122 @@ GNUNET_TRANSPORT_monitor_plugins (const struct GNUNET_CONFIGURATION_Handle *cfg,
569 * @param pm handle of the request that is to be cancelled 574 * @param pm handle of the request that is to be cancelled
570 */ 575 */
571void 576void
572GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor *pm); 577GNUNET_TRANSPORT_monitor_plugins_cancel (
578 struct GNUNET_TRANSPORT_PluginMonitor *pm);
579
580
581/**
582 * Opaque handle to the service.
583 */
584struct GNUNET_TRANSPORT_CoreHandle;
585
586
587/**
588 * Function called to notify transport users that another
589 * peer connected to us.
590 *
591 * @param cls closure
592 * @param peer the identity of the peer that connected; this
593 * pointer will remain valid until the disconnect, hence
594 * applications do not necessarily have to make a copy
595 * of the value if they only need it until disconnect
596 * @param mq message queue to use to transmit to @a peer
597 * @return closure to use in MQ handlers
598 */
599typedef void *(*GNUNET_TRANSPORT_NotifyConnect) (
600 void *cls,
601 const struct GNUNET_PeerIdentity *peer,
602 struct GNUNET_MQ_Handle *mq);
603
604
605/**
606 * Function called to notify transport users that another peer
607 * disconnected from us. The message queue that was given to the
608 * connect notification will be destroyed and must not be used
609 * henceforth.
610 *
611 * @param cls closure from #GNUNET_TRANSPORT_core_connect
612 * @param peer the peer that disconnected
613 * @param handlers_cls closure of the handlers, was returned from the
614 * connect notification callback
615 */
616typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (
617 void *cls,
618 const struct GNUNET_PeerIdentity *peer,
619 void *handler_cls);
620
621
622/**
623 * Function called if we have "excess" bandwidth to a peer.
624 * The notification will happen the first time we have excess
625 * bandwidth, and then only again after the client has performed
626 * some transmission to the peer.
627 *
628 * Excess bandwidth is defined as being allowed (by ATS) to send
629 * more data, and us reaching the limit of the capacity build-up
630 * (which, if we go past it, means we don't use available bandwidth).
631 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
632 *
633 * @param cls the closure
634 * @param neighbour peer that we have excess bandwidth to
635 * @param handlers_cls closure of the handlers, was returned from the
636 * connect notification callback
637 */
638typedef void (*GNUNET_TRANSPORT_NotifyExcessBandwidth) (
639 void *cls,
640 const struct GNUNET_PeerIdentity *neighbour,
641 void *handlers_cls);
642
643
644/**
645 * Connect to the transport service. Note that the connection may
646 * complete (or fail) asynchronously.
647 *
648 * @param cfg configuration to use
649 * @param self our own identity (API should check that it matches
650 * the identity found by transport), or NULL (no check)
651 * @param handlers array of message handlers; note that the
652 * closures provided will be ignored and replaced
653 * with the respective return value from @a nc
654 * @param handlers array with handlers to call when we receive messages, or NULL
655 * @param cls closure for the @a nc, @a nd and @a neb callbacks
656 * @param nc function to call on connect events, or NULL
657 * @param nd function to call on disconnect events, or NULL
658 * @param neb function to call if we have excess bandwidth to a peer, or NULL
659 * @return NULL on error
660 */
661struct GNUNET_TRANSPORT_CoreHandle *
662GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
663 const struct GNUNET_PeerIdentity *self,
664 const struct GNUNET_MQ_MessageHandler *handlers,
665 void *cls,
666 GNUNET_TRANSPORT_NotifyConnect nc,
667 GNUNET_TRANSPORT_NotifyDisconnect nd,
668 GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
669
670
671/**
672 * Disconnect from the transport service.
673 *
674 * @param handle handle returned from connect
675 */
676void
677GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle);
573 678
574 679
680/**
681 * Checks if a given peer is connected to us and get the message queue.
682 *
683 * @param handle connection to transport service
684 * @param peer the peer to check
685 * @return NULL if disconnected, otherwise message queue for @a peer
686 */
687struct GNUNET_MQ_Handle *
688GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle,
689 const struct GNUNET_PeerIdentity *peer);
690
575 691
576#if 0 /* keep Emacsens' auto-indent happy */ 692#if 0 /* keep Emacsens' auto-indent happy */
577{ 693{
578#endif 694#endif
579#ifdef __cplusplus 695#ifdef __cplusplus
@@ -583,6 +699,6 @@ GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor *
583/* ifndef GNUNET_TRANSPORT_SERVICE_H */ 699/* ifndef GNUNET_TRANSPORT_SERVICE_H */
584#endif 700#endif
585 701
586/** @} */ /* end of group */ 702/** @} */ /* end of group */
587 703
588/* end of gnunet_transport_service.h */ 704/* end of gnunet_transport_service.h */