gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22534 - gnunet/src/testbed
Date: Sat, 7 Jul 2012 00:36:31 +0200

Author: harsha
Date: 2012-07-07 00:36:31 +0200 (Sat, 07 Jul 2012)
New Revision: 22534

Added:
   gnunet/src/testbed/testbed_api.h
Modified:
   gnunet/src/testbed/testbed.h
   gnunet/src/testbed/testbed_api.c
Log:
function exports from testbed_api

Modified: gnunet/src/testbed/testbed.h
===================================================================
--- gnunet/src/testbed/testbed.h        2012-07-06 21:33:21 UTC (rev 22533)
+++ gnunet/src/testbed/testbed.h        2012-07-06 22:36:31 UTC (rev 22534)
@@ -24,8 +24,8 @@
  * @author Christian Grothoff
  */
 
-#ifndef NEW_TESTING_H
-#define NEW_TESTING_H
+#ifndef TESTBED_H
+#define TESTBED_H
 
 #include "gnunet_util_lib.h"
 

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-07-06 21:33:21 UTC (rev 22533)
+++ gnunet/src/testbed/testbed_api.c    2012-07-06 22:36:31 UTC (rev 22534)
@@ -389,9 +389,9 @@
  * @param controller the handle to the controller
  * @param msg the message to queue
  */
-static void
-queue_message (struct GNUNET_TESTBED_Controller *controller,
-               struct GNUNET_MessageHeader *msg)
+void
+GNUNET_TESTBED_queue_message (struct GNUNET_TESTBED_Controller *controller,
+                              struct GNUNET_MessageHeader *msg)
 {
   struct MessageQueue *mq_entry;
   uint16_t type;
@@ -530,7 +530,7 @@
   msg->header.size = htons (sizeof (struct GNUNET_TESTBED_InitMessage));
   msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
   msg->event_mask = GNUNET_htonll (controller->event_mask);
-  queue_message (controller, (struct GNUNET_MessageHeader *) msg);
+  GNUNET_TESTBED_queue_message (controller, (struct GNUNET_MessageHeader *) 
msg);
   return controller;
 }
 
@@ -566,7 +566,7 @@
   msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (controller->host));
   msg->num_peers = htonl (num_peers);
   memcpy (&msg[1], service_name, service_name_size);
-  queue_message (controller, (struct GNUNET_MessageHeader *) msg);
+  GNUNET_TESTBED_queue_message (controller, (struct GNUNET_MessageHeader *) 
msg);
 }
 
 
@@ -662,7 +662,7 @@
   if (NULL != username)
     memcpy (&msg[1], username, user_name_length);
   strcpy (((void *) &msg[1]) + user_name_length, hostname);
-  queue_message (controller, (struct GNUNET_MessageHeader *) msg);
+  GNUNET_TESTBED_queue_message (controller, (struct GNUNET_MessageHeader *) 
msg);
   return rh;
 }
 
@@ -730,11 +730,36 @@
   msg->config_size = htons ((uint16_t) scfg_size);
   msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
   memcpy (&msg[1], sxcfg, sxcfg_size);
-  queue_message (master, (struct GNUNET_MessageHeader *) msg);
+  GNUNET_TESTBED_queue_message (master, (struct GNUNET_MessageHeader *) msg);
 }
 
 
 /**
+ * Compresses given configuration using zlib compress
+ *
+ * @param config the serialized configuration
+ * @param size the size of config
+ * @param xconfig will be set to the compressed configuration (memory is fresly
+ *          allocated) 
+ * @return the size of the xconfig
+ */
+size_t
+GNUNET_TESTBED_compress_config (const char *config, size_t size,
+                                char **xconfig)
+{
+  size_t xsize;
+  
+  xsize = compressBound ((uLong) size);
+  *xconfig = GNUNET_malloc (xsize);
+  GNUNET_assert (Z_OK ==
+                compress2 ((Bytef *)* xconfig, (uLongf *) &xsize,
+                            (const Bytef *) config, (uLongf) size, 
+                            Z_BEST_SPEED));
+  return xsize;
+}
+                                
+
+/**
  * Create a link from slave controller to delegated controller. Whenever the
  * master controller is asked to start a peer at the delegated controller the
  * request will be routed towards slave controller (if a route exists). The
@@ -762,8 +787,8 @@
                                int is_subordinate)
 {
   char *config;
-  Bytef *cconfig;
-  uLongf cc_size;
+  char *cconfig;
+  size_t cc_size;
   size_t config_size;  
   
   GNUNET_assert (GNUNET_YES == 
@@ -772,11 +797,7 @@
     GNUNET_assert (GNUNET_YES == 
                   GNUNET_TESTBED_is_host_registered_ (slave_host, master));
   config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size);
-  cc_size = compressBound ((uLong) config_size);
-  cconfig = GNUNET_malloc (cc_size);
-  GNUNET_assert (Z_OK ==
-                compress2 (cconfig, &cc_size, 
-                           (Bytef *) config, config_size, Z_BEST_SPEED));
+  cc_size = GNUNET_TESTBED_compress_config (config, config_size, &cconfig);
   GNUNET_free (config);
   GNUNET_assert ((UINT16_MAX -
                  sizeof (struct GNUNET_TESTBED_ControllerLinkMessage))

Added: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h                            (rev 0)
+++ gnunet/src/testbed/testbed_api.h    2012-07-06 22:36:31 UTC (rev 22534)
@@ -0,0 +1,54 @@
+/*
+      This file is part of GNUnet
+      (C) 2012 Christian Grothoff (and other contributing authors)
+
+      GNUnet is free software; you can redistribute it and/or modify
+      it under the terms of the GNU General Public License as published
+      by the Free Software Foundation; either version 3, or (at your
+      option) any later version.
+
+      GNUnet is distributed in the hope that it will be useful, but
+      WITHOUT ANY WARRANTY; without even the implied warranty of
+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+      General Public License for more details.
+
+      You should have received a copy of the GNU General Public License
+      along with GNUnet; see the file COPYING.  If not, write to the
+      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+      Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file testbed/testbed_api.h
+ * @brief Interface for functions internally exported from testbed_api.c
+ * @author Sree Harsha Totakura
+ */
+
+#ifndef TESTBED_API_H
+#define TESTBED_API_H
+
+/**
+ * Queues a message in send queue for sending to the service
+ *
+ * @param controller the handle to the controller
+ * @param msg the message to queue
+ */
+void
+GNUNET_TESTBED_queue_message (struct GNUNET_TESTBED_Controller *controller,
+                              struct GNUNET_MessageHeader *msg);
+
+
+/**
+ * Compresses given configuration using zlib compress
+ *
+ * @param config the serialized configuration
+ * @param size the size of config
+ * @param xconfig will be set to the compressed configuration (memory is fresly
+ *          allocated) 
+ * @return the size of the xconfig
+ */
+size_t
+GNUNET_TESTBED_compress_config (const char *config, size_t size,
+                                char **xconfig);
+
+#endif




reply via email to

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