* This library is supposed to make it easier to write
* testcases and script large-scale benchmarks.
* @author Christian Grothoff
+ * @author Sree Harsha Totakura
*/
+
+
#include "platform.h"
#include "gnunet_testbed_service.h"
#include "gnunet_core_service.h"
#include <zlib.h>
#include "testbed.h"
+#include "testbed_api.h"
#include "testbed_api_hosts.h"
/**
};
+/**
+ * The global operation id counter
+ */
+uint64_t GNUNET_TESTBED_operation_id;
+
+/**
+ * The head of the operation queue
+ */
+struct GNUNET_TESTBED_Operation *op_head;
+
+/**
+ * The tail of the operation queue
+ */
+struct GNUNET_TESTBED_Operation *op_tail;
+
+
+/**
+ * Adds an operation to the queue of operations
+ *
+ * @param op the operation to add
+ */
+void
+GNUNET_TESTBED_operation_add (struct GNUNET_TESTBED_Operation *op)
+{
+ GNUNET_CONTAINER_DLL_insert_tail (op_head, op_tail, op);
+}
+
+
/**
* Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
* controller (testbed service)
#ifndef TESTBED_API_H
#define TESTBED_API_H
+
+/**
+ * Enumeration of operations
+ */
+enum OperationType
+ {
+ /**
+ * Peer destroy operation
+ */
+ OP_PEER_DESTROY
+ };
+
+
+/**
+ * The counter for generating unique operation ids. Use its current value and
+ * increment it (defined in testbed_api.c)
+ */
+extern uint64_t GNUNET_TESTBED_operation_id;
+
+/**
+ * Testbed operation structure
+ */
+struct GNUNET_TESTBED_Operation
+{
+ /**
+ * next pointer for DLL
+ */
+ struct GNUNET_TESTBED_Operation *next;
+
+ /**
+ * prev pointer for DLL
+ */
+ struct GNUNET_TESTBED_Operation *prev;
+
+ /**
+ * The ID for the operation;
+ */
+ uint64_t operation_id;
+
+ /**
+ * The type of operation
+ */
+ enum OperationType type;
+
+ /**
+ * Data specific to OperationType
+ */
+ void *data;
+};
+
+
/**
* Queues a message in send queue for sending to the service
*
GNUNET_TESTBED_compress_config (const char *config, size_t size,
char **xconfig);
+
+/**
+ * Adds an operation to the queue of operations
+ *
+ * @param op the operation to add
+ */
+void
+GNUNET_TESTBED_operation_add (struct GNUNET_TESTBED_Operation *op);
+
#endif
}
+/**
+ * Destroy the given peer; the peer should have been
+ * stopped first (if it was started).
+ *
+ * @param peer peer to stop
+ * @return handle to the operation
+ */
+struct GNUNET_TESTBED_Operation *
+GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer)
+{
+ struct GNUNET_TESTBED_Operation *op;
+ struct PeerDestroyData *data;
+ struct GNUNET_TESTBED_PeerDestroyMessage *msg;
+
+ data = GNUNET_malloc (sizeof (struct PeerDestroyData));
+ data->peer = peer;
+ op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation));
+ op->operation_id = GNUNET_TESTBED_operation_id++;
+ op->type = OP_PEER_DESTROY;
+ op->data = data;
+ msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage));
+ msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage));
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER);
+ msg->peer_id = peer->unique_id;
+ msg->operation_id = GNUNET_htonll (op->operation_id);
+ GNUNET_TESTBED_operation_add (op);
+ GNUNET_TESTBED_queue_message (peer->controller,
+ (struct GNUNET_MessageHeader *) msg);
+ return op;
+}
+
+
/**
* Manipulate the P2P underlay topology by configuring a link
* between two peers.
#include "gnunet_helper_lib.h"
+/**
+ * Data for the OperationType OP_PEER_DESTROY;
+ */
+struct PeerDestroyData
+{
+ struct GNUNET_TESTBED_Peer *peer;
+};
+
+
/**
* Create the given peer at the specified host using the given
* controller. If the given controller is not running on the target