diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-04-28 19:32:10 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-04-28 19:32:20 +0200 |
commit | 3f945e6798d8d736ceb104b59ea1269a7abdfe8a (patch) | |
tree | b93e3dc99deda0987e85cb256b3903de8bd74853 /src/include/gnunet_transport_communication_service.h | |
parent | 1227fc30369a55b82e77d35d8d128090e37dd437 (diff) | |
download | gnunet-3f945e6798d8d736ceb104b59ea1269a7abdfe8a.tar.gz gnunet-3f945e6798d8d736ceb104b59ea1269a7abdfe8a.zip |
towards flow control in TNG
Diffstat (limited to 'src/include/gnunet_transport_communication_service.h')
-rw-r--r-- | src/include/gnunet_transport_communication_service.h | 113 |
1 files changed, 61 insertions, 52 deletions
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 |
39 | extern "C" | 39 | extern "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 | */ |
72 | typedef int | 72 | typedef 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 | */ |
90 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics { | 90 | enum 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 | */ |
125 | typedef void | 126 | typedef 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 | */ |
147 | struct GNUNET_TRANSPORT_CommunicatorHandle * | 148 | struct GNUNET_TRANSPORT_CommunicatorHandle * |
148 | GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 149 | GNUNET_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 | */ |
163 | void | 165 | void |
164 | GNUNET_TRANSPORT_communicator_disconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch); | 166 | GNUNET_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 | */ |
177 | typedef void | 181 | typedef 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 | */ |
202 | int | 205 | int |
203 | GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandle *handle, | 206 | GNUNET_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 | */ |
223 | enum GNUNET_TRANSPORT_ConnectionStatus { | 227 | enum 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 | */ |
257 | struct GNUNET_TRANSPORT_QueueHandle * | 262 | struct GNUNET_TRANSPORT_QueueHandle * |
258 | GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, | 263 | GNUNET_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 | */ |
293 | struct GNUNET_TRANSPORT_AddressIdentifier * | 299 | struct GNUNET_TRANSPORT_AddressIdentifier * |
294 | GNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, | 300 | GNUNET_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 | */ |
306 | void | 313 | void |
307 | GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_AddressIdentifier *ai); | 314 | GNUNET_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 | */ |
328 | void | 336 | void |
329 | GNUNET_TRANSPORT_communicator_notify (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, | 337 | GNUNET_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 */ |