diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-30 13:38:49 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-30 13:38:49 +0000 |
commit | f3b225f570302afef710c58e22b75efd81e71e56 (patch) | |
tree | 9fcfbca8decfa22a7ddf58ff928dd05fa55a0e7b | |
parent | c58e7239c70925b7045d109fa1c7eaf8e2659604 (diff) | |
download | gnunet-f3b225f570302afef710c58e22b75efd81e71e56.tar.gz gnunet-f3b225f570302afef710c58e22b75efd81e71e56.zip |
function to synchronously check if a peer is connected at CORE level
-rw-r--r-- | src/core/core_api.c | 25 | ||||
-rw-r--r-- | src/include/gnunet_core_service.h | 20 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index ffddc73b2..2b1291d08 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -1369,4 +1369,29 @@ GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle *th) | |||
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | /** | ||
1373 | * Check if the given peer is currently connected. This function is for special | ||
1374 | * cirumstances (GNUNET_TESTBED uses it), normal users of the CORE API are | ||
1375 | * expected to track which peers are connected based on the connect/disconnect | ||
1376 | * callbacks from GNUNET_CORE_connect. This function is NOT part of the | ||
1377 | * 'versioned', 'official' API. The difference between this function and the | ||
1378 | * function GNUNET_CORE_is_peer_connected() is that this one returns | ||
1379 | * synchronously after looking in the CORE API cache. The function | ||
1380 | * GNUNET_CORE_is_peer_connected() sends a message to the CORE service and hence | ||
1381 | * its response is given asynchronously. | ||
1382 | * | ||
1383 | * @param h the core handle | ||
1384 | * @param pid the identity of the peer to check if it has been connected to us | ||
1385 | * @return GNUNET_YES if the peer is connected to us; GNUNET_NO if not | ||
1386 | */ | ||
1387 | int | ||
1388 | GNUNET_CORE_is_peer_connected_sync (const struct GNUNET_CORE_Handle *h, | ||
1389 | const struct GNUNET_PeerIdentity *pid) | ||
1390 | { | ||
1391 | GNUNET_assert (NULL != h); | ||
1392 | GNUNET_assert (NULL != pid); | ||
1393 | return GNUNET_CONTAINER_multihashmap_contains (h->peers, &pid->hashPubKey); | ||
1394 | } | ||
1395 | |||
1396 | |||
1372 | /* end of core_api.c */ | 1397 | /* end of core_api.c */ |
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index ca4048b52..4af8ef2cf 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h | |||
@@ -326,6 +326,26 @@ void | |||
326 | GNUNET_CORE_is_peer_connected_cancel (struct GNUNET_CORE_ConnectTestHandle *cth); | 326 | GNUNET_CORE_is_peer_connected_cancel (struct GNUNET_CORE_ConnectTestHandle *cth); |
327 | 327 | ||
328 | 328 | ||
329 | /** | ||
330 | * Check if the given peer is currently connected. This function is for special | ||
331 | * cirumstances (GNUNET_TESTBED uses it), normal users of the CORE API are | ||
332 | * expected to track which peers are connected based on the connect/disconnect | ||
333 | * callbacks from GNUNET_CORE_connect. This function is NOT part of the | ||
334 | * 'versioned', 'official' API. The difference between this function and the | ||
335 | * function GNUNET_CORE_is_peer_connected() is that this one returns | ||
336 | * synchronously after looking in the CORE API cache. The function | ||
337 | * GNUNET_CORE_is_peer_connected() sends a message to the CORE service and hence | ||
338 | * its response is given asynchronously. | ||
339 | * | ||
340 | * @param h the core handle | ||
341 | * @param pid the identity of the peer to check if it has been connected to us | ||
342 | * @return GNUNET_YES if the peer is connected to us; GNUNET_NO if not | ||
343 | */ | ||
344 | int | ||
345 | GNUNET_CORE_is_peer_connected_sync (const struct GNUNET_CORE_Handle *h, | ||
346 | const struct GNUNET_PeerIdentity *pid); | ||
347 | |||
348 | |||
329 | #if 0 /* keep Emacsens' auto-indent happy */ | 349 | #if 0 /* keep Emacsens' auto-indent happy */ |
330 | { | 350 | { |
331 | #endif | 351 | #endif |