aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps_api.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-10-11 14:39:48 +0200
committerJulius Bünger <buenger@mytum.de>2018-10-11 14:40:44 +0200
commitfbbf0db19d08fe54f5b51c82b6cb1c9c7a2d040d (patch)
tree2248e208d0821c4d2c4aac5a4b03309cd0fa6c21 /src/rps/rps_api.c
parent0cdd1af62ca1f17fdca31be6e28ad24dcf3293b1 (diff)
downloadgnunet-fbbf0db19d08fe54f5b51c82b6cb1c9c7a2d040d.tar.gz
gnunet-fbbf0db19d08fe54f5b51c82b6cb1c9c7a2d040d.zip
RPS API: Add creation, deletion of Subs
Diffstat (limited to 'src/rps/rps_api.c')
-rw-r--r--src/rps/rps_api.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 47c4f019d..34b28cd6a 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -588,6 +588,24 @@ mq_error_handler (void *cls,
588 588
589 589
590/** 590/**
591 * @brief Create the hash value from the share value that defines the sub
592 * (-group)
593 *
594 * @param share_val Share value - strings longer than 508 (512 - 4) will be
595 * truncated.
596 * @param hash Pointer to the location in which the hash will be stored.
597 */
598static void
599hash_from_share_val (const char *share_val, struct GNUNET_HashCode *hash)
600{
601 char hash_port_string[512] = "rps";
602
603 (void) strncat (hash_port_string, share_val, 508);
604 GNUNET_CRYPTO_hash (hash_port_string, strlen (hash_port_string), hash);
605}
606
607
608/**
591 * Reconnect to the service 609 * Reconnect to the service
592 */ 610 */
593static void 611static void
@@ -639,6 +657,49 @@ GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
639 657
640 658
641/** 659/**
660 * @brief Start a sub with the given shared value
661 *
662 * @param h Handle to rps
663 * @param shared_value The shared value that defines the members of the sub (-gorup)
664 */
665void
666GNUNET_RPS_sub_start (struct GNUNET_RPS_Handle *h,
667 const char *shared_value)
668{
669 struct GNUNET_RPS_CS_SubStartMessage *msg;
670 struct GNUNET_MQ_Envelope *ev;
671
672 ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START);
673 hash_from_share_val (shared_value, &msg->hash);
674 msg->round_interval = GNUNET_TIME_relative_hton (// TODO read from config!
675 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30));
676 GNUNET_assert (0 != msg->round_interval.rel_value_us__);
677
678 GNUNET_MQ_send (h->mq, ev);
679}
680
681
682/**
683 * @brief Stop a sub with the given shared value
684 *
685 * @param h Handle to rps
686 * @param shared_value The shared value that defines the members of the sub (-gorup)
687 */
688void
689GNUNET_RPS_sub_stop (struct GNUNET_RPS_Handle *h,
690 const char *shared_value)
691{
692 struct GNUNET_RPS_CS_SubStopMessage *msg;
693 struct GNUNET_MQ_Envelope *ev;
694
695 ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP);
696 hash_from_share_val (shared_value, &msg->hash);
697
698 GNUNET_MQ_send (h->mq, ev);
699}
700
701
702/**
642 * Request n random peers. 703 * Request n random peers.
643 * 704 *
644 * @param rps_handle handle to the rps service 705 * @param rps_handle handle to the rps service