gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37972 - gnunet/src/multicast


From: gnunet
Subject: [GNUnet-SVN] r37972 - gnunet/src/multicast
Date: Thu, 22 Sep 2016 13:35:37 +0200

Author: tg
Date: 2016-09-22 13:35:37 +0200 (Thu, 22 Sep 2016)
New Revision: 37972

Modified:
   gnunet/src/multicast/test_multicast_multipeer.c
Log:
multicast: towards multipeer test

Modified: gnunet/src/multicast/test_multicast_multipeer.c
===================================================================
--- gnunet/src/multicast/test_multicast_multipeer.c     2016-09-22 11:35:35 UTC 
(rev 37971)
+++ gnunet/src/multicast/test_multicast_multipeer.c     2016-09-22 11:35:37 UTC 
(rev 37972)
@@ -36,12 +36,26 @@
 
 #define NUM_PEERS 2
 
-static struct GNUNET_TESTBED_Operation *multicast_peer0;
-static struct GNUNET_TESTBED_Operation *multicast_peer1;
+static struct GNUNET_TESTBED_Operation *peer0;
+static struct GNUNET_TESTBED_Operation *peer1;
 
 static struct GNUNET_SCHEDULER_Task *timeout_tid;
 
+struct GNUNET_CRYPTO_EddsaPrivateKey *group_key;
+struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key;
 
+struct GNUNET_CRYPTO_EcdsaPrivateKey *member1_key;
+struct GNUNET_CRYPTO_EcdsaPublicKey member1_pub_key;
+
+
+enum
+{
+  TEST_INIT          = 0,
+  TEST_ORIGIN_START  = 1,
+  TEST_MEMBER_JOIN   = 2,
+} test;
+
+
 /**
  * Global result for testcase.
  */
@@ -55,10 +69,10 @@
 static void
 shutdown_task (void *cls)
 {
-  if (NULL != multicast_peer0)
+  if (NULL != peer0)
   {
-    GNUNET_TESTBED_operation_done (multicast_peer0); 
-    multicast_peer0 = NULL;
+    GNUNET_TESTBED_operation_done (peer0);
+    peer0 = NULL;
   }
   if (NULL != timeout_tid)
     {
@@ -79,15 +93,89 @@
 }
 
 
-static void 
+static void
+origin_recv_replay_msg (void *cls,
+                        const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key,
+                        uint64_t message_id,
+                        uint64_t fragment_offset,
+                        uint64_t flags,
+                        struct GNUNET_MULTICAST_ReplayHandle *rh)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Test #%u: origin_recv_replay_msg()\n", test);
+  GNUNET_assert (0);
+}
+
+
+static void
+member_recv_replay_msg (void *cls,
+                        const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key,
+                        uint64_t message_id,
+                        uint64_t fragment_offset,
+                        uint64_t flags,
+                        struct GNUNET_MULTICAST_ReplayHandle *rh)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Test #%u: member_recv_replay_msg()\n", test);
+  GNUNET_assert (0);
+}
+
+
+static void
+origin_recv_replay_frag (void *cls,
+                         const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key,
+                         uint64_t fragment_id,
+                         uint64_t flags,
+                         struct GNUNET_MULTICAST_ReplayHandle *rh)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Test #%u: origin_recv_replay_frag()"
+              " - fragment_id=%" PRIu64 " flags=%" PRIu64 "\n",
+              test, fragment_id, flags);
+}
+
+
+/**
+ * Test: origin receives join request
+ */
+static void
+origin_recv_join_request (void *cls,
+                          const struct GNUNET_CRYPTO_EcdsaPublicKey *mem_key,
+                          const struct GNUNET_MessageHeader *join_msg,
+                          struct GNUNET_MULTICAST_JoinHandle *jh)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Test #%u: origin_recv_join_request()\n", test);
+}
+
+
+static void
+origin_recv_request (void *cls,
+                     const struct GNUNET_MULTICAST_RequestHeader *req)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Test #%u: origin_recv_request()\n",
+              test);
+}
+
+
+static void
+origin_recv_message (void *cls,
+                     const struct GNUNET_MULTICAST_MessageHeader *msg)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Test #%u: origin_recv_message()\n",
+              test);
+}
+
+
+static void
 service_close_peer0 (void *cls,
                     void *op_result)
 {
   struct GNUNET_MULTICAST_Origin *orig = op_result;
-  
-  GNUNET_MULTICAST_origin_stop (orig,
-                               NULL,
-                               NULL);
+
+  GNUNET_MULTICAST_origin_stop (orig, NULL, NULL);
 }
 
 
@@ -94,30 +182,26 @@
 /**
  * Function run when service multicast has started and is providing us
  * with a configuration file.
- */ 
+ */
 static void *
 service_conf_peer0 (void *cls,
                    const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  #if 0
-  return GNUNET_MULTICAST_origin_start (cfg,
-                                       priv_key,
-                                       42,
-                                       &join_rcb,
-                                       &reply_fcb,
-                                       &reply_mcb,
-                                       &request_cb,
-                                       &message_cb,
+  group_key = GNUNET_CRYPTO_eddsa_key_create ();
+  GNUNET_CRYPTO_eddsa_key_get_public (group_key, &group_pub_key);
+
+  return GNUNET_MULTICAST_origin_start (cfg, group_key, 0,
+                                        origin_recv_join_request,
+                                        origin_recv_replay_frag,
+                                        origin_recv_replay_msg,
+                                        origin_recv_request,
+                                        origin_recv_message,
                                        NULL);
-#else
-  return NULL;
-
-#endif
 }
 
 
 /**
- * Test logic of peer "0" being origin starts here. 
+ * Test logic of peer "0" being origin starts here.
  *
  * @param cls closure, for the example: NULL
  * @param op should be equal to "dht_op"
@@ -134,7 +218,7 @@
 {
   struct GNUNET_MULTICAST_Origin *orig = ca_result;
 
-  /* Connection to service successful. Here we'd usually do something with 
+  /* Connection to service successful. Here we'd usually do something with
    * the service. */
   result = GNUNET_OK;
   GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */
@@ -147,8 +231,8 @@
  * just to the multicast service of peer 0 and 1.
  * Peer 0 is going to be origin.
  * Peer 1 is going to be one member.
- * Origin will start a multicast group and the member will try to join it. 
- * After that we execute some multicast test. 
+ * Origin will start a multicast group and the member will try to join it.
+ * After that we execute some multicast test.
  *
  * @param cls closure
  * @param h the run handle
@@ -158,18 +242,18 @@
  * @param links_failed number of links testbed was unable to establish
  */
 static void
-test_master (void *cls,
-             struct GNUNET_TESTBED_RunHandle *h,
-             unsigned int num_peers,
-             struct GNUNET_TESTBED_Peer **peers,
-             unsigned int links_succeeded,
-             unsigned int links_failed)
+run (void *cls,
+     struct GNUNET_TESTBED_RunHandle *h,
+     unsigned int num_peers,
+     struct GNUNET_TESTBED_Peer **peers,
+     unsigned int links_succeeded,
+     unsigned int links_failed)
 {
   /* Testbed is ready with peers running and connected in a pre-defined overlay
      topology (FIXME)  */
 
   /* connect to a peers service */
-  multicast_peer0 = GNUNET_TESTBED_service_connect
+  peer0 = GNUNET_TESTBED_service_connect
       (NULL,                    /* Closure for operation */
        peers[0],                /* The peer whose service to connect to */
        "multicast",             /* The name of the service */
@@ -200,8 +284,7 @@
        0LL, /* Event mask - set to 0 for no event notifications */
        NULL, /* Controller event callback */
        NULL, /* Closure for controller event callback */
-       &test_master, /* continuation callback to be called when testbed setup 
is
-                        complete */
+       run, /* continuation callback to be called when testbed setup is 
complete */
        NULL); /* Closure for the test_master callback */
   if ( (GNUNET_OK != ret) || (GNUNET_OK != result) )
     return 1;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]