aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_core_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-04-11 11:49:51 +0000
committerChristian Grothoff <christian@grothoff.org>2014-04-11 11:49:51 +0000
commit24712c94e185b72c30da25ea1b3a1784bde0defa (patch)
tree1ca399a023e0cdf48dbf9b411bb4b245081a1100 /src/include/gnunet_core_service.h
parenta61a4e0ffd7d563f3ae4d758f06a894edee71f58 (diff)
downloadgnunet-24712c94e185b72c30da25ea1b3a1784bde0defa.tar.gz
gnunet-24712c94e185b72c30da25ea1b3a1784bde0defa.zip
towards fixing #3363: replacing old iteration API with new monitoring API for core (needs testing, gnunet-core incomplete)
Diffstat (limited to 'src/include/gnunet_core_service.h')
-rw-r--r--src/include/gnunet_core_service.h137
1 files changed, 119 insertions, 18 deletions
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index b0248323a..c4acd3564 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009-2013 Christian Grothoff (and other contributing authors) 3 (C) 2009-2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -280,31 +280,132 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
280 * @param th handle that was returned by "notify_transmit_ready". 280 * @param th handle that was returned by "notify_transmit_ready".
281 */ 281 */
282void 282void
283GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle 283GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle *th);
284 *th);
285 284
286 285
287/** 286/**
288 * Iterate over all connected peers. Calls @a peer_cb with each 287 * Handle to a CORE monitoring operation.
289 * connected peer, and then once with NULL to indicate that all peers 288 */
290 * have been handled. Normal users of the CORE API are not expected 289struct GNUNET_CORE_MonitorHandle;
291 * to use this function. It is different in that it truly lists 290
292 * all connections, not just those relevant to the application. This 291
293 * function is used by special applications for diagnostics. This 292/**
294 * function is NOT part of the 'versioned', 'official' API. 293 * State machine for our P2P encryption handshake. Everyone starts in
294 * #GNUNET_CORE_KX_STATE_DOWN, if we receive the other peer's key
295 * (other peer initiated) we start in state
296 * #GNUNET_CORE_KX_STATE_KEY_RECEIVED (since we will immediately send
297 * our own); otherwise we start in #GNUNET_CORE_KX_STATE_KEY_SENT. If
298 * we get back a PONG from within either state, we move up to
299 * #GNUNET_CORE_KX_STATE_UP (the PONG will always be sent back
300 * encrypted with the key we sent to the other peer). Eventually,
301 * we will try to rekey, for this we will enter
302 * #GNUNET_CORE_KX_STATE_REKEY_SENT until the rekey operation is
303 * confirmed by a PONG from the other peer.
304 */
305enum GNUNET_CORE_KxState
306{
307 /**
308 * No handshake yet.
309 */
310 GNUNET_CORE_KX_STATE_DOWN,
311
312 /**
313 * We've sent our session key.
314 */
315 GNUNET_CORE_KX_STATE_KEY_SENT,
316
317 /**
318 * We've received the other peers session key.
319 */
320 GNUNET_CORE_KX_STATE_KEY_RECEIVED,
321
322 /**
323 * The other peer has confirmed our session key + PING with a PONG
324 * message encrypted with his session key (which we got). Key
325 * exchange is done.
326 */
327 GNUNET_CORE_KX_STATE_UP,
328
329 /**
330 * We're rekeying (or had a timeout), so we have sent the other peer
331 * our new ephemeral key, but we did not get a matching PONG yet.
332 * This is equivalent to being #GNUNET_CORE_KX_STATE_KEY_RECEIVED,
333 * except that the session is marked as 'up' with sessions (as we
334 * don't want to drop and re-establish P2P connections simply due to
335 * rekeying).
336 */
337 GNUNET_CORE_KX_STATE_REKEY_SENT,
338
339 /**
340 * Last state of a KX (when it is being terminated). Set
341 * just before CORE frees the internal state for this peer.
342 */
343 GNUNET_CORE_KX_PEER_DISCONNECT,
344
345 /**
346 * This is not a state in a peer's state machine, but a special
347 * value used with the #GNUNET_CORE_MonitorCallback to indicate
348 * that we finished the initial iteration over the peers.
349 */
350 GNUNET_CORE_KX_ITERATION_FINISHED,
351
352 /**
353 * This is not a state in a peer's state machine, but a special
354 * value used with the #GNUNET_CORE_MonitorCallback to indicate
355 * that we lost the connection to the CORE service (and will try
356 * to reconnect). If this happens, most likely the CORE service
357 * crashed and thus all connection state should be assumed lost.
358 */
359 GNUNET_CORE_KX_CORE_DISCONNECT
360
361};
362
363
364/**
365 * Function called by the monitor callback whenever
366 * a peer's connection status changes.
295 * 367 *
296 * FIXME: we should probably make it possible to 'cancel' the 368 * @param cls closure
297 * operation... 369 * @param pid identity of the peer this update is about
370 * @param state current key exchange state of the peer
371 * @param timeout when does the current state expire
372 */
373typedef void
374(*GNUNET_CORE_MonitorCallback)(void *cls,
375 const struct GNUNET_PeerIdentity *pid,
376 enum GNUNET_CORE_KxState state,
377 struct GNUNET_TIME_Absolute timeout);
378
379
380/**
381 * Monitor connectivity and KX status of all peers known to CORE.
382 * Calls @a peer_cb with the current status for each connected peer,
383 * and then once with NULL to indicate that all peers that are
384 * currently active have been handled. After that, the iteration
385 * continues until it is cancelled. Normal users of the CORE API are
386 * not expected to use this function. It is different in that it
387 * truly lists all connections (including those where the KX is in
388 * progress), not just those relevant to the application. This
389 * function is used by special applications for diagnostics.
298 * 390 *
299 * @param cfg configuration handle 391 * @param cfg configuration handle
300 * @param peer_cb function to call with the peer information 392 * @param peer_cb function to call with the peer information
301 * @param cb_cls closure for @a peer_cb 393 * @param peer_cb_cls closure for @a peer_cb
302 * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors 394 * @return NULL on error
303 */ 395 */
304int 396struct GNUNET_CORE_MonitorHandle *
305GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, 397GNUNET_CORE_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
306 GNUNET_CORE_ConnectEventHandler peer_cb, 398 GNUNET_CORE_MonitorCallback peer_cb,
307 void *cb_cls); 399 void *peer_cb_cls);
400
401
402/**
403 * Stop monitoring CORE activity.
404 *
405 * @param mh monitor to stop
406 */
407void
408GNUNET_CORE_monitor_stop (struct GNUNET_CORE_MonitorHandle *mh);
308 409
309 410
310/** 411/**