gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r23198 - gnunet/src/testbed
Date: Fri, 10 Aug 2012 22:03:22 +0200

Author: harsha
Date: 2012-08-10 22:03:22 +0200 (Fri, 10 Aug 2012)
New Revision: 23198

Modified:
   gnunet/src/testbed/gnunet-service-testbed.c
   gnunet/src/testbed/testbed_api.h
Log:
towards peer create forwarding

Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-08-10 19:22:14 UTC (rev 
23197)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-08-10 20:03:22 UTC (rev 
23198)
@@ -406,6 +406,29 @@
 
 
 /**
+ * Context data to be used when forwarding peer create messages
+ */
+struct PeerCreateContext
+{
+  /**
+   * The operation handle to peer create
+   */
+  struct GNUNET_TESTBED_operation *operation;
+
+  /**
+   * The ID of the operation which created this context
+   */
+  uint64_t operation_id;
+
+  /**
+   * The peer create timeout task id
+   */
+  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+
+};
+
+
+/**
  * The master context; generated with the first INIT message
  */
 static struct Context *master_context;
@@ -713,6 +736,29 @@
 
 
 /**
+ * Finds the route with directly connected host as destination through which
+ * the destination host can be reached
+ *
+ * @param host_id the id of the destination host
+ * @return the route with directly connected destination host; NULL if no route
+ *           is found
+ */
+static struct Route *
+find_dest_route (uint32_t host_id)
+{
+  struct Route *route;
+  
+  while(NULL != (route = route_list[host_id]))
+  {
+    if (route->thru == master_context->host_id)
+      break;
+    host_id = route->thru;
+  }
+  return route;
+}
+
+
+/**
  * Routes message to a host given its host_id
  *
  * @param host_id the id of the destination host
@@ -1287,12 +1333,7 @@
   lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
   lcfq->lcf->delegated_host_id = delegated_host_id;
   lcfq->lcf->slave_host_id = slave_host_id;
-  while (NULL != (route = route_list[slave_host_id]))
-  {
-    if (route->thru == master_context->host_id)
-      break;
-    slave_host_id = route->thru;
-  }
+  route = find_dest_route (slave_host_id);
   GNUNET_assert (NULL != route); /* because we add routes carefully */
   GNUNET_assert (route->dest < slave_list_size);
   GNUNET_assert (NULL != slave_list[route->dest]);  
@@ -1335,10 +1376,13 @@
   const struct GNUNET_TESTBED_PeerCreateMessage *msg;
   struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *reply;
   struct GNUNET_CONFIGURATION_Handle *cfg;
+  struct PeerCreateContext *pc_ctxt;
+  struct Route *route;
   char *config;
   size_t dest_size;
   int ret;
   uint32_t config_size;
+  uint32_t host_id;
   uint16_t msize;
   
 
@@ -1350,7 +1394,8 @@
     return;
   }
   msg = (const struct GNUNET_TESTBED_PeerCreateMessage *) message;
-  if (ntohl (msg->host_id) == master_context->host_id)
+  host_id = ntohl (msg->host_id);
+  if (host_id == master_context->host_id)
   {
     struct Peer *peer;
     char *emsg;
@@ -1411,10 +1456,18 @@
     GNUNET_SERVER_receive_done (client, GNUNET_OK);
     return;
   }
-
-  /* FIXME: Forward the peer to other host */
-  GNUNET_break (0);
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+  
+  /* Forward peer create request */
+  route = find_dest_route (host_id);
+  if (NULL == route)
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
+  pc_ctxt = GNUNET_malloc (sizeof (struct PeerCreateContext));
+  pc_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
+  /* To be continued .. :) */
 }
 
 

Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h    2012-08-10 19:22:14 UTC (rev 23197)
+++ gnunet/src/testbed/testbed_api.h    2012-08-10 20:03:22 UTC (rev 23198)
@@ -345,6 +345,8 @@
  */
 struct GNUNET_TESTBED_HelperInit *
 GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
-                                       const struct 
GNUNET_CONFIGURATION_Handle *cfg);
+                                       const struct
+                                        GNUNET_CONFIGURATION_Handle *cfg);
 
+
 #endif




reply via email to

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