aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_api_iterate_peers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/core_api_iterate_peers.c')
-rw-r--r--src/core/core_api_iterate_peers.c56
1 files changed, 6 insertions, 50 deletions
diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c
index 7b28842..7db9486 100644
--- a/src/core/core_api_iterate_peers.c
+++ b/src/core/core_api_iterate_peers.c
@@ -80,7 +80,7 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg)
{
if (request_context->peer_cb != NULL)
request_context->peer_cb (request_context->cb_cls, NULL, NULL, 0);
- GNUNET_CLIENT_disconnect (request_context->client, GNUNET_NO);
+ GNUNET_CLIENT_disconnect (request_context->client);
GNUNET_free (request_context);
return;
}
@@ -93,7 +93,7 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg)
GNUNET_break (0);
if (request_context->peer_cb != NULL)
request_context->peer_cb (request_context->cb_cls, NULL, NULL, 0);
- GNUNET_CLIENT_disconnect (request_context->client, GNUNET_NO);
+ GNUNET_CLIENT_disconnect (request_context->client);
GNUNET_free (request_context);
return;
}
@@ -106,7 +106,7 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg)
GNUNET_break (0);
if (request_context->peer_cb != NULL)
request_context->peer_cb (request_context->cb_cls, NULL, NULL, 0);
- GNUNET_CLIENT_disconnect (request_context->client, GNUNET_NO);
+ GNUNET_CLIENT_disconnect (request_context->client);
GNUNET_free (request_context);
return;
}
@@ -119,6 +119,7 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg)
request_context, GNUNET_TIME_UNIT_FOREVER_REL);
}
+
/**
* Function called to notify a client about the socket
* begin ready to queue more data. "buf" will be
@@ -143,10 +144,8 @@ transmit_request (void *cls, size_t size, void *buf)
msize =
sizeof (struct GNUNET_MessageHeader) +
sizeof (struct GNUNET_PeerIdentity);
-
if ((size < msize) || (buf == NULL))
return 0;
-
msg = (struct GNUNET_MessageHeader *) buf;
msg->size = htons (msize);
if (peer != NULL)
@@ -160,50 +159,7 @@ transmit_request (void *cls, size_t size, void *buf)
return msize;
}
-/**
- * Iterate over all currently connected peers.
- * Calls peer_cb with each connected peer, and then
- * once with NULL to indicate that all peers have
- * been handled.
- *
- * @param cfg configuration to use
- * @param peer the specific peer to check for
- * @param peer_cb function to call with the peer information
- * @param cb_cls closure for peer_cb
- *
- * @return GNUNET_OK if iterating, GNUNET_SYSERR on error
- */
-int
-GNUNET_CORE_is_peer_connected (const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_PeerIdentity *peer,
- GNUNET_CORE_ConnectEventHandler peer_cb,
- void *cb_cls)
-{
- struct GNUNET_CORE_RequestContext *request_context;
- struct GNUNET_CLIENT_Connection *client;
-
- client = GNUNET_CLIENT_connect ("core", cfg);
- if (client == NULL)
- return GNUNET_SYSERR;
- GNUNET_assert (peer != NULL);
- request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext));
- request_context->client = client;
- request_context->peer_cb = peer_cb;
- request_context->cb_cls = cb_cls;
- request_context->peer = peer;
- request_context->th =
- GNUNET_CLIENT_notify_transmit_ready (client,
- sizeof (struct GNUNET_MessageHeader)
- +
- sizeof (struct GNUNET_PeerIdentity),
- GNUNET_TIME_relative_get_forever (),
- GNUNET_YES, &transmit_request, peer);
- GNUNET_assert (request_context->th != NULL);
- GNUNET_CLIENT_receive (client, &receive_info, request_context,
- GNUNET_TIME_relative_get_forever ());
- return GNUNET_OK;
-}
/**
* Iterate over all currently connected peers.
@@ -236,11 +192,11 @@ GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
request_context->th =
GNUNET_CLIENT_notify_transmit_ready (client,
sizeof (struct GNUNET_MessageHeader),
- GNUNET_TIME_relative_get_forever (),
+ GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_YES, &transmit_request, NULL);
GNUNET_CLIENT_receive (client, &receive_info, request_context,
- GNUNET_TIME_relative_get_forever ());
+ GNUNET_TIME_UNIT_FOREVER_REL);
return GNUNET_OK;
}