gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22546 - gnunet/src/testbed
Date: Sun, 8 Jul 2012 22:28:46 +0200

Author: harsha
Date: 2012-07-08 22:28:46 +0200 (Sun, 08 Jul 2012)
New Revision: 22546

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_peers.h
Log:
operation and peer_destroy

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-07-08 17:46:26 UTC (rev 22545)
+++ gnunet/src/testbed/testbed_api.c    2012-07-08 20:28:46 UTC (rev 22546)
@@ -24,7 +24,10 @@
  *        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"
@@ -34,6 +37,7 @@
 #include <zlib.h>
 
 #include "testbed.h"
+#include "testbed_api.h"
 #include "testbed_api_hosts.h"
 
 /**
@@ -235,6 +239,34 @@
 
 
 /**
+ * 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)
  *

Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h    2012-07-08 17:46:26 UTC (rev 22545)
+++ gnunet/src/testbed/testbed_api.h    2012-07-08 20:28:46 UTC (rev 22546)
@@ -27,7 +27,58 @@
 #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
  *
  * @param controller the handle to the controller
@@ -51,4 +102,13 @@
 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

Modified: gnunet/src/testbed/testbed_api_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2012-07-08 17:46:26 UTC (rev 
22545)
+++ gnunet/src/testbed/testbed_api_peers.c      2012-07-08 20:28:46 UTC (rev 
22546)
@@ -273,6 +273,38 @@
 
 
 /**
+ * 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.  
  *

Modified: gnunet/src/testbed/testbed_api_peers.h
===================================================================
--- gnunet/src/testbed/testbed_api_peers.h      2012-07-08 17:46:26 UTC (rev 
22545)
+++ gnunet/src/testbed/testbed_api_peers.h      2012-07-08 20:28:46 UTC (rev 
22546)
@@ -31,6 +31,15 @@
 
 
 /**
+ * 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
  * host, it should find or create a controller at the target host and




reply via email to

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