diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-10 10:59:34 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-10 10:59:34 +0000 |
commit | e3e2e5839cc3f7c1efb4bee1826f185169b034fa (patch) | |
tree | 4dd1a750e24025a5763400b77d07ccb0a3b698a6 | |
parent | a0e539e0e1911c2e68df06594624c3f53d569870 (diff) | |
download | gnunet-e3e2e5839cc3f7c1efb4bee1826f185169b034fa.tar.gz gnunet-e3e2e5839cc3f7c1efb4bee1826f185169b034fa.zip |
operation id generation from controller host id and internal counter
-rw-r--r-- | src/testbed/testbed_api.c | 25 | ||||
-rw-r--r-- | src/testbed/testbed_api.h | 13 | ||||
-rw-r--r-- | src/testbed/testbed_api_peers.c | 12 | ||||
-rw-r--r-- | src/testbed/testbed_api_services.c | 2 |
4 files changed, 41 insertions, 11 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 9bed63a97..2dab869dc 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -959,7 +959,7 @@ handle_need_controller_config (struct GNUNET_TESTBED_Controller *c, | |||
959 | uint64_t sub_op_id; | 959 | uint64_t sub_op_id; |
960 | 960 | ||
961 | GNUNET_assert (NULL == oc_data->sub_opc); | 961 | GNUNET_assert (NULL == oc_data->sub_opc); |
962 | sub_op_id = oc_data->p1->controller->operation_counter++; | 962 | sub_op_id = GNUNET_TESTBED_get_next_op_id (oc_data->p1->controller); |
963 | get_cfg_msg = | 963 | get_cfg_msg = |
964 | GNUNET_TESTBED_generate_slavegetconfig_msg_ | 964 | GNUNET_TESTBED_generate_slavegetconfig_msg_ |
965 | (sub_op_id, GNUNET_TESTBED_host_get_id_ (oc_data->p2->host)); | 965 | (sub_op_id, GNUNET_TESTBED_host_get_id_ (oc_data->p2->host)); |
@@ -1873,7 +1873,7 @@ GNUNET_TESTBED_controller_link_2 (void *op_cls, | |||
1873 | opc->c = master; | 1873 | opc->c = master; |
1874 | opc->data = data; | 1874 | opc->data = data; |
1875 | opc->type = OP_LINK_CONTROLLERS; | 1875 | opc->type = OP_LINK_CONTROLLERS; |
1876 | opc->id = master->operation_counter++; | 1876 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
1877 | opc->state = OPC_STATE_INIT; | 1877 | opc->state = OPC_STATE_INIT; |
1878 | msg->operation_id = GNUNET_htonll (opc->id); | 1878 | msg->operation_id = GNUNET_htonll (opc->id); |
1879 | opc->op = | 1879 | opc->op = |
@@ -2003,7 +2003,7 @@ GNUNET_TESTBED_get_slave_config (void *op_cls, | |||
2003 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 2003 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
2004 | opc->state = OPC_STATE_INIT; | 2004 | opc->state = OPC_STATE_INIT; |
2005 | opc->c = master; | 2005 | opc->c = master; |
2006 | opc->id = master->operation_counter++; | 2006 | opc->id = GNUNET_TESTBED_get_next_op_id (master); |
2007 | opc->type = OP_GET_SLAVE_CONFIG; | 2007 | opc->type = OP_GET_SLAVE_CONFIG; |
2008 | opc->data = data; | 2008 | opc->data = data; |
2009 | opc->op = | 2009 | opc->op = |
@@ -2220,4 +2220,23 @@ GNUNET_TESTBED_parse_error_string_ (const struct | |||
2220 | return emsg; | 2220 | return emsg; |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | |||
2224 | /** | ||
2225 | * Function to return the operation id for a controller. The operation id is | ||
2226 | * created from the controllers host id and its internal operation counter. | ||
2227 | * | ||
2228 | * @param controller the handle to the controller whose operation id has to be incremented | ||
2229 | * @return the incremented operation id. | ||
2230 | */ | ||
2231 | uint64_t | ||
2232 | GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller) | ||
2233 | { | ||
2234 | uint64_t op_id; | ||
2235 | |||
2236 | op_id = (uint64_t) GNUNET_TESTBED_host_get_id_ (controller->host); | ||
2237 | op_id = op_id << 32; | ||
2238 | op_id |= (uint64_t) controller->operation_counter++; | ||
2239 | return op_id; | ||
2240 | } | ||
2241 | |||
2223 | /* end of testbed_api.c */ | 2242 | /* end of testbed_api.c */ |
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index 020d951a2..251b8a56a 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -299,7 +299,7 @@ struct GNUNET_TESTBED_Controller | |||
299 | /** | 299 | /** |
300 | * The operation id counter. use current value and increment | 300 | * The operation id counter. use current value and increment |
301 | */ | 301 | */ |
302 | uint64_t operation_counter; | 302 | uint32_t operation_counter; |
303 | 303 | ||
304 | /** | 304 | /** |
305 | * The controller event mask | 305 | * The controller event mask |
@@ -424,5 +424,16 @@ GNUNET_TESTBED_parse_error_string_ (const struct | |||
424 | GNUNET_TESTBED_OperationFailureEventMessage | 424 | GNUNET_TESTBED_OperationFailureEventMessage |
425 | *msg); | 425 | *msg); |
426 | 426 | ||
427 | |||
428 | /** | ||
429 | * Function to return the operation id for a controller. The operation id is | ||
430 | * created from the controllers host id and its internal operation counter. | ||
431 | * | ||
432 | * @param controller the handle to the controller whose operation id has to be incremented | ||
433 | * @return the incremented operation id. | ||
434 | */ | ||
435 | uint64_t | ||
436 | GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller); | ||
437 | |||
427 | #endif | 438 | #endif |
428 | /* end of testbed_api.h */ | 439 | /* end of testbed_api.h */ |
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index ab54cecfa..f9d0929ef 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -439,7 +439,7 @@ GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, | |||
439 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 439 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
440 | opc->c = controller; | 440 | opc->c = controller; |
441 | opc->data = data; | 441 | opc->data = data; |
442 | opc->id = controller->operation_counter++; | 442 | opc->id = GNUNET_TESTBED_get_next_op_id (controller); |
443 | opc->type = OP_PEER_CREATE; | 443 | opc->type = OP_PEER_CREATE; |
444 | opc->op = | 444 | opc->op = |
445 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_create, | 445 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_create, |
@@ -515,7 +515,7 @@ GNUNET_TESTBED_peer_start (struct GNUNET_TESTBED_Peer *peer, | |||
515 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 515 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
516 | opc->c = peer->controller; | 516 | opc->c = peer->controller; |
517 | opc->data = data; | 517 | opc->data = data; |
518 | opc->id = opc->c->operation_counter++; | 518 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
519 | opc->type = OP_PEER_START; | 519 | opc->type = OP_PEER_START; |
520 | opc->op = | 520 | opc->op = |
521 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_start, | 521 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_start, |
@@ -551,7 +551,7 @@ GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer, | |||
551 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 551 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
552 | opc->c = peer->controller; | 552 | opc->c = peer->controller; |
553 | opc->data = data; | 553 | opc->data = data; |
554 | opc->id = opc->c->operation_counter++; | 554 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
555 | opc->type = OP_PEER_STOP; | 555 | opc->type = OP_PEER_STOP; |
556 | opc->op = | 556 | opc->op = |
557 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_stop, | 557 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_stop, |
@@ -595,7 +595,7 @@ GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, | |||
595 | opc->c = peer->controller; | 595 | opc->c = peer->controller; |
596 | opc->data = data; | 596 | opc->data = data; |
597 | opc->type = OP_PEER_INFO; | 597 | opc->type = OP_PEER_INFO; |
598 | opc->id = opc->c->operation_counter++; | 598 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
599 | opc->op = | 599 | opc->op = |
600 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo, | 600 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo, |
601 | &oprelease_peer_getinfo); | 601 | &oprelease_peer_getinfo); |
@@ -641,7 +641,7 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) | |||
641 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 641 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
642 | opc->data = peer; | 642 | opc->data = peer; |
643 | opc->c = peer->controller; | 643 | opc->c = peer->controller; |
644 | opc->id = peer->controller->operation_counter++; | 644 | opc->id = GNUNET_TESTBED_get_next_op_id (peer->controller); |
645 | opc->type = OP_PEER_DESTROY; | 645 | opc->type = OP_PEER_DESTROY; |
646 | opc->op = | 646 | opc->op = |
647 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_destroy, | 647 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_destroy, |
@@ -710,7 +710,7 @@ GNUNET_TESTBED_overlay_connect (void *op_cls, | |||
710 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 710 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
711 | opc->data = data; | 711 | opc->data = data; |
712 | opc->c = p1->controller; | 712 | opc->c = p1->controller; |
713 | opc->id = opc->c->operation_counter++; | 713 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
714 | opc->type = OP_OVERLAY_CONNECT; | 714 | opc->type = OP_OVERLAY_CONNECT; |
715 | opc->op = | 715 | opc->op = |
716 | GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, | 716 | GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, |
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c index 53a2bdc3c..16ea06077 100644 --- a/src/testbed/testbed_api_services.c +++ b/src/testbed/testbed_api_services.c | |||
@@ -190,7 +190,7 @@ opstart_service_connect (void *cls) | |||
190 | GNUNET_assert (NULL != data); | 190 | GNUNET_assert (NULL != data); |
191 | GNUNET_assert (NULL != data->peer); | 191 | GNUNET_assert (NULL != data->peer); |
192 | c = data->peer->controller; | 192 | c = data->peer->controller; |
193 | op_id = c->operation_counter++; | 193 | op_id = GNUNET_TESTBED_get_next_op_id (c); |
194 | msg = | 194 | msg = |
195 | GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, op_id); | 195 | GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, op_id); |
196 | data->opc = | 196 | data->opc = |