gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r21979 - gnunet/src/testbed
Date: Wed, 13 Jun 2012 18:30:48 +0200

Author: harsha
Date: 2012-06-13 18:30:48 +0200 (Wed, 13 Jun 2012)
New Revision: 21979

Modified:
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api_hosts.c
   gnunet/src/testbed/testbed_api_hosts.h
Log:
-Helper handle wrapper

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-06-13 16:14:04 UTC (rev 21978)
+++ gnunet/src/testbed/testbed_api.c    2012-06-13 16:30:48 UTC (rev 21979)
@@ -82,7 +82,7 @@
   /**
    * The helper handle
    */
-  struct GNUNET_HELPER_Handle *helper;
+  struct GNUNET_TESTBED_HelperHandle *helper;
 
   /**
    * The controller callback
@@ -337,7 +337,7 @@
     GNUNET_free (mq_entry);
   }
   GNUNET_CLIENT_disconnect (controller->client);
-  GNUNET_HELPER_stop (controller->helper);
+  GNUNET_TESTBED_host_stop_ (controller->helper);
   GNUNET_CONFIGURATION_destroy (controller->cfg);
   GNUNET_free (controller);
 }

Modified: gnunet/src/testbed/testbed_api_hosts.c
===================================================================
--- gnunet/src/testbed/testbed_api_hosts.c      2012-06-13 16:14:04 UTC (rev 
21978)
+++ gnunet/src/testbed/testbed_api_hosts.c      2012-06-13 16:30:48 UTC (rev 
21979)
@@ -213,11 +213,33 @@
 GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
 {  
   GNUNET_CONTAINER_DLL_remove (host_list_head, host_list_tail, host);
-  GNUNET_free (host);  
+  GNUNET_free (host);
 }
 
 
 /**
+ * Wrapper around GNUNET_HELPER_Handle
+ */
+struct GNUNET_TESTBED_HelperHandle
+{
+  /**
+   * The helper handle
+   */
+  struct GNUNET_HELPER_Handle *handle;
+
+  /**
+   * The port number for ssh; used for helpers starting ssh
+   */
+  char *port;
+
+  /**
+   * The ssh destination string; used for helpers starting ssh
+   */
+  char *dst; 
+};
+
+
+/**
  * Run a given helper process at the given host.  Communication
  * with the helper will be via GNUnet messages on stdin/stdout.
  * Runs the process via 'ssh' at the specified host, or locally.
@@ -229,33 +251,51 @@
  * @param cb_cls closure for cb
  * @return handle to terminate the command, NULL on error
  */
-struct GNUNET_HELPER_Handle *
+struct GNUNET_TESTBED_HelperHandle *
 GNUNET_TESTBED_host_run_ (struct GNUNET_TESTBED_Host *host,
                          char *const binary_argv[],
                          GNUNET_SERVER_MessageTokenizerCallback cb, void 
*cb_cls)
 {
   /* FIXME: decide on the SSH command line, prepend it and
      run GNUNET_HELPER_start with the modified binary_name and binary_argv! */
-  struct GNUNET_HELPER_Handle *h;
-  char *const local_args[] = {NULL};
-  char *port;
-  char *dst;
-  char *remote_args[] = {"ssh", "-p", port, "-q", dst,
-                         "gnunet-service-testbed", NULL};
+  struct GNUNET_TESTBED_HelperHandle *h;
+  char *const local_args[] = {NULL};  
 
+  h = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HelperHandle));
   if (0 == host->unique_id)
-    return GNUNET_HELPER_start ("gnunet-service-testbed", local_args,
-                                cb, cb_cls);
+  {
+    h->handle = GNUNET_HELPER_start ("gnunet-service-testbed", local_args,
+                                     cb, cb_cls);
+  }
   else
+  {    
+    GNUNET_asprintf (&h->port, "%d", host->port);
+    GNUNET_asprintf (&h->dst, "address@hidden", host->hostname, 
host->username);
+    char *remote_args[] = {"ssh", "-p", h->port, "-q", h->dst,
+                           "gnunet-service-testbed", NULL};
+    h->handle = GNUNET_HELPER_start ("ssh", remote_args, cb, cb_cls);
+  }
+  if (NULL == h->handle)
   {
-    GNUNET_asprintf (&port, "%d", host->port);
-    GNUNET_asprintf (&dst, "address@hidden", host->hostname, host->username);
-    h = GNUNET_HELPER_start ("ssh", remote_args, cb, cb_cls);
-    GNUNET_free (port);         /* FIXME: Can we free them? */
-    GNUNET_free (dst);
-    return h;
+    GNUNET_free (h);
+    return NULL;
   }
+  return h;
 }
 
 
+/**
+ * Stops a helper in the HelperHandle using GNUNET_HELPER_stop
+ *
+ * @param handle the handle returned from GNUNET_TESTBED_host_start_
+ */
+void
+GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle)
+{
+  GNUNET_HELPER_stop (handle->handle);
+  GNUNET_free_non_null (handle->port);
+  GNUNET_free_non_null (handle->dst);
+  GNUNET_free (handle);
+}
+
 /* end of testbed_api_hosts.c */

Modified: gnunet/src/testbed/testbed_api_hosts.h
===================================================================
--- gnunet/src/testbed/testbed_api_hosts.h      2012-06-13 16:14:04 UTC (rev 
21978)
+++ gnunet/src/testbed/testbed_api_hosts.h      2012-06-13 16:30:48 UTC (rev 
21979)
@@ -85,6 +85,12 @@
 
 
 /**
+ * Opaque wrapper around GNUNET_HELPER_Handle
+ */
+struct GNUNET_TESTBED_HelperHandle;
+
+
+/**
  * Run a given helper process at the given host.  Communication
  * with the helper will be via GNUnet messages on stdin/stdout.
  * Runs the process via 'ssh' at the specified host, or locally.
@@ -96,10 +102,19 @@
  * @param cb_cls closure for cb
  * @return handle to terminate the command, NULL on error
  */
-struct GNUNET_HELPER_Handle *
+struct GNUNET_TESTBED_HelperHandle *
 GNUNET_TESTBED_host_run_ (struct GNUNET_TESTBED_Host *host,
                          char *const binary_argv[],
                          GNUNET_SERVER_MessageTokenizerCallback cb, void 
*cb_cls);
 
+
+/**
+ * Stops a helper in the HelperHandle using GNUNET_HELPER_stop
+ *
+ * @param handle the handle returned from GNUNET_TESTBED_host_start_
+ */
+void
+GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle);
+
 #endif
 /* end of testbed_api_hosts.h */




reply via email to

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