gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r24252 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r24252 - gnunet/src/testbed
Date: Wed, 10 Oct 2012 12:59:34 +0200

Author: harsha
Date: 2012-10-10 12:59:34 +0200 (Wed, 10 Oct 2012)
New Revision: 24252

Modified:
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api.h
   gnunet/src/testbed/testbed_api_peers.c
   gnunet/src/testbed/testbed_api_services.c
Log:
operation id generation from controller host id and internal counter

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-10-10 10:26:08 UTC (rev 24251)
+++ gnunet/src/testbed/testbed_api.c    2012-10-10 10:59:34 UTC (rev 24252)
@@ -959,7 +959,7 @@
       uint64_t sub_op_id;
       
       GNUNET_assert (NULL == oc_data->sub_opc);
-      sub_op_id = oc_data->p1->controller->operation_counter++;
+      sub_op_id = GNUNET_TESTBED_get_next_op_id (oc_data->p1->controller);
       get_cfg_msg = 
           GNUNET_TESTBED_generate_slavegetconfig_msg_ 
           (sub_op_id, GNUNET_TESTBED_host_get_id_ (oc_data->p2->host));
@@ -1873,7 +1873,7 @@
   opc->c = master;
   opc->data = data;
   opc->type = OP_LINK_CONTROLLERS;
-  opc->id = master->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
   opc->state = OPC_STATE_INIT;
   msg->operation_id = GNUNET_htonll (opc->id);
   opc->op =
@@ -2003,7 +2003,7 @@
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->state = OPC_STATE_INIT;
   opc->c = master;
-  opc->id = master->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (master);
   opc->type = OP_GET_SLAVE_CONFIG;
   opc->data = data;
   opc->op =
@@ -2220,4 +2220,23 @@
   return emsg;
 }
 
+
+/**
+ * Function to return the operation id for a controller. The operation id is
+ * created from the controllers host id and its internal operation counter.
+ *
+ * @param controller the handle to the controller whose operation id has to be 
incremented
+ * @return the incremented operation id.
+ */
+uint64_t
+GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller)
+{
+  uint64_t op_id;  
+
+  op_id = (uint64_t) GNUNET_TESTBED_host_get_id_ (controller->host);
+  op_id = op_id <<  32;
+  op_id |= (uint64_t) controller->operation_counter++;
+  return op_id;
+}
+
 /* end of testbed_api.c */

Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h    2012-10-10 10:26:08 UTC (rev 24251)
+++ gnunet/src/testbed/testbed_api.h    2012-10-10 10:59:34 UTC (rev 24252)
@@ -299,7 +299,7 @@
   /**
    * The operation id counter. use current value and increment
    */
-  uint64_t operation_counter;
+  uint32_t operation_counter;
 
   /**
    * The controller event mask
@@ -424,5 +424,16 @@
                                     GNUNET_TESTBED_OperationFailureEventMessage
                                     *msg);
 
+
+/**
+ * Function to return the operation id for a controller. The operation id is
+ * created from the controllers host id and its internal operation counter.
+ *
+ * @param controller the handle to the controller whose operation id has to be 
incremented
+ * @return the incremented operation id.
+ */
+uint64_t
+GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller);
+
 #endif
 /* end of testbed_api.h */

Modified: gnunet/src/testbed/testbed_api_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2012-10-10 10:26:08 UTC (rev 
24251)
+++ gnunet/src/testbed/testbed_api_peers.c      2012-10-10 10:59:34 UTC (rev 
24252)
@@ -439,7 +439,7 @@
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->c = controller;
   opc->data = data;
-  opc->id = controller->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (controller);
   opc->type = OP_PEER_CREATE;
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_create,
@@ -515,7 +515,7 @@
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->c = peer->controller;
   opc->data = data;
-  opc->id = opc->c->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
   opc->type = OP_PEER_START;
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_start,
@@ -551,7 +551,7 @@
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->c = peer->controller;
   opc->data = data;
-  opc->id = opc->c->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
   opc->type = OP_PEER_STOP;
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_stop,
@@ -595,7 +595,7 @@
   opc->c = peer->controller;
   opc->data = data;
   opc->type = OP_PEER_INFO;
-  opc->id = opc->c->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo,
                                         &oprelease_peer_getinfo);
@@ -641,7 +641,7 @@
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->data = peer;
   opc->c = peer->controller;
-  opc->id = peer->controller->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (peer->controller);
   opc->type = OP_PEER_DESTROY;
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_destroy,
@@ -710,7 +710,7 @@
   opc = GNUNET_malloc (sizeof (struct OperationContext));
   opc->data = data;
   opc->c = p1->controller;
-  opc->id = opc->c->operation_counter++;
+  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
   opc->type = OP_OVERLAY_CONNECT;
   opc->op =
       GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect,

Modified: gnunet/src/testbed/testbed_api_services.c
===================================================================
--- gnunet/src/testbed/testbed_api_services.c   2012-10-10 10:26:08 UTC (rev 
24251)
+++ gnunet/src/testbed/testbed_api_services.c   2012-10-10 10:59:34 UTC (rev 
24252)
@@ -190,7 +190,7 @@
   GNUNET_assert (NULL != data);
   GNUNET_assert (NULL != data->peer);
   c = data->peer->controller;
-  op_id = c->operation_counter++;
+  op_id = GNUNET_TESTBED_get_next_op_id (c);
   msg =
       GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, 
op_id);
   data->opc =




reply via email to

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