aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/rps_api.c')
-rw-r--r--src/rps/rps_api.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index b7644540d..96660ded6 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -377,6 +377,34 @@ handle_view_update (void *cls,
377 * It calls the callback the caller provided 377 * It calls the callback the caller provided
378 * and disconnects afterwards. 378 * and disconnects afterwards.
379 * 379 *
380 * TODO merge with check_view_update
381 *
382 * @param msg the message
383 */
384static int
385check_stream_input (void *cls,
386 const struct GNUNET_RPS_CS_DEBUG_StreamReply *msg)
387{
388 uint16_t msize = ntohs (msg->header.size);
389 uint32_t num_peers = ntohl (msg->num_peers);
390 (void) cls;
391
392 msize -= sizeof (struct GNUNET_RPS_CS_DEBUG_StreamReply);
393 if ( (msize / sizeof (struct GNUNET_PeerIdentity) != num_peers) ||
394 (msize % sizeof (struct GNUNET_PeerIdentity) != 0) )
395 {
396 GNUNET_break (0);
397 return GNUNET_SYSERR;
398 }
399 return GNUNET_OK;
400}
401
402/**
403 * This function is called, when the service sends another peer from the biased
404 * stream.
405 * It calls the callback the caller provided
406 * and disconnects afterwards.
407 *
380 * @param msg the message 408 * @param msg the message
381 */ 409 */
382static void 410static void
@@ -384,14 +412,17 @@ handle_stream_input (void *cls,
384 const struct GNUNET_RPS_CS_DEBUG_StreamReply *msg) 412 const struct GNUNET_RPS_CS_DEBUG_StreamReply *msg)
385{ 413{
386 struct GNUNET_RPS_Handle *h = cls; 414 struct GNUNET_RPS_Handle *h = cls;
415 const struct GNUNET_PeerIdentity *peers;
387 416
388 /* Give the peers back */ 417 /* Give the peers back */
389 LOG (GNUNET_ERROR_TYPE_DEBUG, 418 LOG (GNUNET_ERROR_TYPE_DEBUG,
390 "New peer of biased input stream\n"); 419 "New peer of %" PRIu64 " biased input stream\n",
420 ntohl (msg->num_peers));
391 421
422 peers = (struct GNUNET_PeerIdentity *) &msg[1];
392 GNUNET_assert (NULL != h); 423 GNUNET_assert (NULL != h);
393 GNUNET_assert (NULL != h->stream_input_cb); 424 GNUNET_assert (NULL != h->stream_input_cb);
394 h->stream_input_cb (h->stream_input_cb, &msg->peer); 425 h->stream_input_cb (h->stream_input_cb, ntohl (msg->num_peers), peers);
395} 426}
396 427
397 428
@@ -444,10 +475,10 @@ reconnect (struct GNUNET_RPS_Handle *h)
444 GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REPLY, 475 GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REPLY,
445 struct GNUNET_RPS_CS_DEBUG_ViewReply, 476 struct GNUNET_RPS_CS_DEBUG_ViewReply,
446 h), 477 h),
447 GNUNET_MQ_hd_fixed_size (stream_input, 478 GNUNET_MQ_hd_var_size (stream_input,
448 GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REPLY, 479 GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REPLY,
449 struct GNUNET_RPS_CS_DEBUG_StreamReply, 480 struct GNUNET_RPS_CS_DEBUG_StreamReply,
450 h), 481 h),
451 GNUNET_MQ_handler_end () 482 GNUNET_MQ_handler_end ()
452 }; 483 };
453 484