aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_core_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_core_service.h')
-rw-r--r--src/include/gnunet_core_service.h78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index 9c102988b..abfcd1d3b 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -37,6 +37,7 @@ extern "C"
37#endif 37#endif
38 38
39#include "gnunet_util_lib.h" 39#include "gnunet_util_lib.h"
40#include "gnunet_transport_service.h"
40 41
41/** 42/**
42 * Version number of GNUnet-core API. 43 * Version number of GNUnet-core API.
@@ -55,35 +56,32 @@ struct GNUNET_CORE_Handle;
55 * 56 *
56 * @param cls closure 57 * @param cls closure
57 * @param peer peer identity this notification is about 58 * @param peer peer identity this notification is about
58 * @param latency reported latency of the connection with 'other' 59 * @param atsi performance data for the connection
59 * @param distance reported distance (DV) to 'other'
60 */ 60 */
61typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls, 61typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls,
62 const struct 62 const struct
63 GNUNET_PeerIdentity * peer, 63 GNUNET_PeerIdentity *peer,
64 struct GNUNET_TIME_Relative latency, 64 const struct GNUNET_TRANSPORT_ATS_Information *atsi);
65 uint32_t distance); 65
66 66
67/** 67/**
68 * Method called whenever a given peer has a status change. 68 * Method called whenever a given peer has a status change.
69 * 69 *
70 * @param cls closure 70 * @param cls closure
71 * @param peer peer identity this notification is about 71 * @param peer peer identity this notification is about
72 * @param latency reported latency of the connection with 'other'
73 * @param distance reported distance (DV) to 'other'
74 * @param bandwidth_in available amount of inbound bandwidth
75 * @param bandwidth_out available amount of outbound bandwidth
76 * @param timeout absolute time when this peer will time out 72 * @param timeout absolute time when this peer will time out
77 * unless we see some further activity from it 73 * unless we see some further activity from it
74 * @param bandwidth_in available amount of inbound bandwidth
75 * @param bandwidth_out available amount of outbound bandwidth
76 * @param atsi performance data for the connection
78 */ 77 */
79typedef void (*GNUNET_CORE_PeerStatusEventHandler) (void *cls, 78typedef void (*GNUNET_CORE_PeerStatusEventHandler) (void *cls,
80 const struct 79 const struct
81 GNUNET_PeerIdentity * peer, 80 GNUNET_PeerIdentity * peer,
82 struct GNUNET_TIME_Relative latency,
83 uint32_t distance,
84 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 81 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
85 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 82 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
86 struct GNUNET_TIME_Absolute timeout); 83 struct GNUNET_TIME_Absolute timeout,
84 const struct GNUNET_TRANSPORT_ATS_Information *atsi);
87 85
88 86
89/** 87/**
@@ -94,29 +92,26 @@ typedef void (*GNUNET_CORE_PeerStatusEventHandler) (void *cls,
94 */ 92 */
95typedef void (*GNUNET_CORE_DisconnectEventHandler) (void *cls, 93typedef void (*GNUNET_CORE_DisconnectEventHandler) (void *cls,
96 const struct 94 const struct
97 GNUNET_PeerIdentity * peer); 95 GNUNET_PeerIdentity *peer);
98 96
99 97
100/** 98/**
101 * Functions with this signature are called whenever a message is 99 * Functions with this signature are called whenever a message is
102 * received or transmitted. 100 * received or transmitted.
103 * 101 *
104 * @param cls closure 102 * @param cls closure (set from GNUNET_CORE_connect)
105 * @param peer the other peer involved (sender or receiver, NULL 103 * @param peer the other peer involved (sender or receiver, NULL
106 * for loopback messages where we are both sender and receiver) 104 * for loopback messages where we are both sender and receiver)
107 * @param message the actual message 105 * @param message the actual message
108 * @param latency reported latency of the connection with 'other' 106 * @param atsi performance data for the connection
109 * @param distance reported distance (DV) to 'other'
110 * @return GNUNET_OK to keep the connection open, 107 * @return GNUNET_OK to keep the connection open,
111 * GNUNET_SYSERR to close it (signal serious error) 108 * GNUNET_SYSERR to close it (signal serious error)
112 */ 109 */
113typedef int 110typedef int
114 (*GNUNET_CORE_MessageCallback) (void *cls, 111 (*GNUNET_CORE_MessageCallback) (void *cls,
115 const struct GNUNET_PeerIdentity * other, 112 const struct GNUNET_PeerIdentity *other,
116 const struct GNUNET_MessageHeader * 113 const struct GNUNET_MessageHeader *message,
117 message, 114 const struct GNUNET_TRANSPORT_ATS_Information *atsi);
118 struct GNUNET_TIME_Relative latency,
119 uint32_t distance);
120 115
121 116
122/** 117/**
@@ -180,7 +175,6 @@ typedef void
180 * 175 *
181 * @param cfg configuration to use 176 * @param cfg configuration to use
182 * @param queue_size size of the per-peer message queue 177 * @param queue_size size of the per-peer message queue
183 * @param timeout after how long should we give up trying to connect to the core service?
184 * @param cls closure for the various callbacks that follow (including handlers in the handlers array) 178 * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
185 * @param init callback to call on timeout or once we have successfully 179 * @param init callback to call on timeout or once we have successfully
186 * connected to the core service; note that timeout is only meaningful if init is not NULL 180 * connected to the core service; note that timeout is only meaningful if init is not NULL
@@ -217,7 +211,6 @@ typedef void
217struct GNUNET_CORE_Handle * 211struct GNUNET_CORE_Handle *
218GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 212GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
219 unsigned int queue_size, 213 unsigned int queue_size,
220 struct GNUNET_TIME_Relative timeout,
221 void *cls, 214 void *cls,
222 GNUNET_CORE_StartupCallback init, 215 GNUNET_CORE_StartupCallback init,
223 GNUNET_CORE_ConnectEventHandler connects, 216 GNUNET_CORE_ConnectEventHandler connects,
@@ -231,7 +224,9 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
231 224
232 225
233/** 226/**
234 * Disconnect from the core service. 227 * Disconnect from the core service. This function can only
228 * be called *after* all pending 'GNUNET_CORE_notify_transmit_ready'
229 * requests have been explicitly cancelled.
235 * 230 *
236 * @param handle connection to core to disconnect 231 * @param handle connection to core to disconnect
237 */ 232 */
@@ -257,7 +252,7 @@ struct GNUNET_CORE_PeerRequestHandle;
257 * to our connection attempt within the given time frame, 'cont' will 252 * to our connection attempt within the given time frame, 'cont' will
258 * be called with the TIMEOUT reason code. 253 * be called with the TIMEOUT reason code.
259 * 254 *
260 * @param cfg configuration to use 255 * @param h core handle
261 * @param timeout how long to try to talk to core 256 * @param timeout how long to try to talk to core
262 * @param peer who should we connect to 257 * @param peer who should we connect to
263 * @param cont function to call once the request has been completed (or timed out) 258 * @param cont function to call once the request has been completed (or timed out)
@@ -265,7 +260,7 @@ struct GNUNET_CORE_PeerRequestHandle;
265 * @return NULL on error (cont will not be called), otherwise handle for cancellation 260 * @return NULL on error (cont will not be called), otherwise handle for cancellation
266 */ 261 */
267struct GNUNET_CORE_PeerRequestHandle * 262struct GNUNET_CORE_PeerRequestHandle *
268GNUNET_CORE_peer_request_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 263GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h,
269 struct GNUNET_TIME_Relative timeout, 264 struct GNUNET_TIME_Relative timeout,
270 const struct GNUNET_PeerIdentity * peer, 265 const struct GNUNET_PeerIdentity * peer,
271 GNUNET_SCHEDULER_Task cont, 266 GNUNET_SCHEDULER_Task cont,
@@ -283,14 +278,11 @@ GNUNET_CORE_peer_request_connect_cancel (struct GNUNET_CORE_PeerRequestHandle *r
283 278
284 279
285/** 280/**
286 * Function called with statistics about the given peer. 281 * Function called with perference change information about the given peer.
287 * 282 *
288 * @param cls closure 283 * @param cls closure
289 * @param peer identifies the peer 284 * @param peer identifies the peer
290 * @param bpm_in set to the current bandwidth limit (receiving) for this peer 285 * @param bandwidth_out available amount of outbound bandwidth
291 * @param bpm_out set to the current bandwidth limit (sending) for this peer
292 * @param latency current latency estimate, "FOREVER" if we have been
293 * disconnected
294 * @param amount set to the amount that was actually reserved or unreserved; 286 * @param amount set to the amount that was actually reserved or unreserved;
295 * either the full requested amount or zero (no partial reservations) 287 * either the full requested amount or zero (no partial reservations)
296 * @param preference current traffic preference for the given peer 288 * @param preference current traffic preference for the given peer
@@ -299,8 +291,7 @@ typedef void
299 (*GNUNET_CORE_PeerConfigurationInfoCallback) (void *cls, 291 (*GNUNET_CORE_PeerConfigurationInfoCallback) (void *cls,
300 const struct 292 const struct
301 GNUNET_PeerIdentity * peer, 293 GNUNET_PeerIdentity * peer,
302 struct GNUNET_BANDWIDTH_Value32NBO bpm_in, 294 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
303 struct GNUNET_BANDWIDTH_Value32NBO bpm_out,
304 int amount, 295 int amount,
305 uint64_t preference); 296 uint64_t preference);
306 297
@@ -314,8 +305,9 @@ struct GNUNET_CORE_InformationRequestContext;
314 305
315/** 306/**
316 * Obtain statistics and/or change preferences for the given peer. 307 * Obtain statistics and/or change preferences for the given peer.
308 * You can only have one such pending request per peer.
317 * 309 *
318 * @param cfg configuration to use 310 * @param h core handle
319 * @param peer identifies the peer 311 * @param peer identifies the peer
320 * @param timeout after how long should we give up (and call "info" with NULL 312 * @param timeout after how long should we give up (and call "info" with NULL
321 * for "peer" to signal an error)? 313 * for "peer" to signal an error)?
@@ -337,7 +329,7 @@ struct GNUNET_CORE_InformationRequestContext;
337 * @return NULL on error 329 * @return NULL on error
338 */ 330 */
339struct GNUNET_CORE_InformationRequestContext * 331struct GNUNET_CORE_InformationRequestContext *
340GNUNET_CORE_peer_change_preference (const struct GNUNET_CONFIGURATION_Handle *cfg, 332GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
341 const struct GNUNET_PeerIdentity *peer, 333 const struct GNUNET_PeerIdentity *peer,
342 struct GNUNET_TIME_Relative timeout, 334 struct GNUNET_TIME_Relative timeout,
343 struct GNUNET_BANDWIDTH_Value32NBO bw_out, 335 struct GNUNET_BANDWIDTH_Value32NBO bw_out,
@@ -349,25 +341,33 @@ GNUNET_CORE_peer_change_preference (const struct GNUNET_CONFIGURATION_Handle *cf
349 341
350/** 342/**
351 * Cancel request for getting information about a peer. 343 * Cancel request for getting information about a peer.
344 * Note that an eventual change in preference, trust or bandwidth
345 * assignment MAY have already been committed at the time,
346 * so cancelling a request is NOT sure to undo the original
347 * request. The original request may or may not still commit.
348 * The only thing cancellation ensures is that the callback
349 * from the original request will no longer be called.
352 * 350 *
353 * @param irc context returned by the original GNUNET_CORE_peer_get_info call 351 * @param irc context returned by the original GNUNET_CORE_peer_get_info call
354 */ 352 */
355void 353void
356GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequestContext *irc); 354GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequestContext *irc);
357 355
356
358/** 357/**
359 * Obtain statistics and/or change preferences for the given peer. 358 * Iterate over all connected peers.
360 * 359 *
361 * @param cfg configuration to use 360 * @param h core handle
362 * @param peer_cb function to call with the peer information 361 * @param peer_cb function to call with the peer information
363 * @param cb_cls closure for peer_cb 362 * @param cb_cls closure for peer_cb
364 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error 363 * @return GNUNET_OK on success, GNUNET_SYSERR on errors
365 */ 364 */
366int 365int
367GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, 366GNUNET_CORE_iterate_peers (struct GNUNET_CORE_Handle *h,
368 GNUNET_CORE_ConnectEventHandler peer_cb, 367 GNUNET_CORE_ConnectEventHandler peer_cb,
369 void *cb_cls); 368 void *cb_cls);
370 369
370
371/** 371/**
372 * Handle for a transmission request. 372 * Handle for a transmission request.
373 */ 373 */