aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-07-08 20:28:46 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-07-08 20:28:46 +0000
commit8fa1a818df4f8466dbaeece10f2a1bdecc396595 (patch)
tree249afe774b316e755b4d1d7de5045bb2b8107c17
parent216d130e277fee333b243faefd3c4e3aec2b22a0 (diff)
downloadgnunet-8fa1a818df4f8466dbaeece10f2a1bdecc396595.tar.gz
gnunet-8fa1a818df4f8466dbaeece10f2a1bdecc396595.zip
operation and peer_destroy
-rw-r--r--src/testbed/testbed_api.c32
-rw-r--r--src/testbed/testbed_api.h60
-rw-r--r--src/testbed/testbed_api_peers.c32
-rw-r--r--src/testbed/testbed_api_peers.h9
4 files changed, 133 insertions, 0 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 159b43daf..b290e748c 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -24,7 +24,10 @@
24 * This library is supposed to make it easier to write 24 * This library is supposed to make it easier to write
25 * testcases and script large-scale benchmarks. 25 * testcases and script large-scale benchmarks.
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 * @author Sree Harsha Totakura
27 */ 28 */
29
30
28#include "platform.h" 31#include "platform.h"
29#include "gnunet_testbed_service.h" 32#include "gnunet_testbed_service.h"
30#include "gnunet_core_service.h" 33#include "gnunet_core_service.h"
@@ -34,6 +37,7 @@
34#include <zlib.h> 37#include <zlib.h>
35 38
36#include "testbed.h" 39#include "testbed.h"
40#include "testbed_api.h"
37#include "testbed_api_hosts.h" 41#include "testbed_api_hosts.h"
38 42
39/** 43/**
@@ -235,6 +239,34 @@ struct GNUNET_TESTBED_HostRegistrationHandle
235 239
236 240
237/** 241/**
242 * The global operation id counter
243 */
244uint64_t GNUNET_TESTBED_operation_id;
245
246/**
247 * The head of the operation queue
248 */
249struct GNUNET_TESTBED_Operation *op_head;
250
251/**
252 * The tail of the operation queue
253 */
254struct GNUNET_TESTBED_Operation *op_tail;
255
256
257/**
258 * Adds an operation to the queue of operations
259 *
260 * @param op the operation to add
261 */
262void
263GNUNET_TESTBED_operation_add (struct GNUNET_TESTBED_Operation *op)
264{
265 GNUNET_CONTAINER_DLL_insert_tail (op_head, op_tail, op);
266}
267
268
269/**
238 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from 270 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
239 * controller (testbed service) 271 * controller (testbed service)
240 * 272 *
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index aee284c40..53e4607ff 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -27,6 +27,57 @@
27#ifndef TESTBED_API_H 27#ifndef TESTBED_API_H
28#define TESTBED_API_H 28#define TESTBED_API_H
29 29
30
31/**
32 * Enumeration of operations
33 */
34enum OperationType
35 {
36 /**
37 * Peer destroy operation
38 */
39 OP_PEER_DESTROY
40 };
41
42
43/**
44 * The counter for generating unique operation ids. Use its current value and
45 * increment it (defined in testbed_api.c)
46 */
47extern uint64_t GNUNET_TESTBED_operation_id;
48
49/**
50 * Testbed operation structure
51 */
52struct GNUNET_TESTBED_Operation
53{
54 /**
55 * next pointer for DLL
56 */
57 struct GNUNET_TESTBED_Operation *next;
58
59 /**
60 * prev pointer for DLL
61 */
62 struct GNUNET_TESTBED_Operation *prev;
63
64 /**
65 * The ID for the operation;
66 */
67 uint64_t operation_id;
68
69 /**
70 * The type of operation
71 */
72 enum OperationType type;
73
74 /**
75 * Data specific to OperationType
76 */
77 void *data;
78};
79
80
30/** 81/**
31 * Queues a message in send queue for sending to the service 82 * Queues a message in send queue for sending to the service
32 * 83 *
@@ -51,4 +102,13 @@ size_t
51GNUNET_TESTBED_compress_config (const char *config, size_t size, 102GNUNET_TESTBED_compress_config (const char *config, size_t size,
52 char **xconfig); 103 char **xconfig);
53 104
105
106/**
107 * Adds an operation to the queue of operations
108 *
109 * @param op the operation to add
110 */
111void
112GNUNET_TESTBED_operation_add (struct GNUNET_TESTBED_Operation *op);
113
54#endif 114#endif
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c
index 844510cda..c225c7d12 100644
--- a/src/testbed/testbed_api_peers.c
+++ b/src/testbed/testbed_api_peers.c
@@ -273,6 +273,38 @@ GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
273 273
274 274
275/** 275/**
276 * Destroy the given peer; the peer should have been
277 * stopped first (if it was started).
278 *
279 * @param peer peer to stop
280 * @return handle to the operation
281 */
282struct GNUNET_TESTBED_Operation *
283GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer)
284{
285 struct GNUNET_TESTBED_Operation *op;
286 struct PeerDestroyData *data;
287 struct GNUNET_TESTBED_PeerDestroyMessage *msg;
288
289 data = GNUNET_malloc (sizeof (struct PeerDestroyData));
290 data->peer = peer;
291 op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation));
292 op->operation_id = GNUNET_TESTBED_operation_id++;
293 op->type = OP_PEER_DESTROY;
294 op->data = data;
295 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage));
296 msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage));
297 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER);
298 msg->peer_id = peer->unique_id;
299 msg->operation_id = GNUNET_htonll (op->operation_id);
300 GNUNET_TESTBED_operation_add (op);
301 GNUNET_TESTBED_queue_message (peer->controller,
302 (struct GNUNET_MessageHeader *) msg);
303 return op;
304}
305
306
307/**
276 * Manipulate the P2P underlay topology by configuring a link 308 * Manipulate the P2P underlay topology by configuring a link
277 * between two peers. 309 * between two peers.
278 * 310 *
diff --git a/src/testbed/testbed_api_peers.h b/src/testbed/testbed_api_peers.h
index ea42c9810..3a9244fc2 100644
--- a/src/testbed/testbed_api_peers.h
+++ b/src/testbed/testbed_api_peers.h
@@ -31,6 +31,15 @@
31 31
32 32
33/** 33/**
34 * Data for the OperationType OP_PEER_DESTROY;
35 */
36struct PeerDestroyData
37{
38 struct GNUNET_TESTBED_Peer *peer;
39};
40
41
42/**
34 * Create the given peer at the specified host using the given 43 * Create the given peer at the specified host using the given
35 * controller. If the given controller is not running on the target 44 * controller. If the given controller is not running on the target
36 * host, it should find or create a controller at the target host and 45 * host, it should find or create a controller at the target host and