Added more data structures and functions to build the skeleton of mesh
authorBart Polot <bart@net.in.tum.de>
Fri, 11 Mar 2011 03:39:47 +0000 (03:39 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 11 Mar 2011 03:39:47 +0000 (03:39 +0000)
src/include/gnunet_mesh_service.h
src/mesh/gnunet-service-mesh.c
src/mesh/mesh.h
src/mesh/mesh_api.c

index 36dbafb86ba1ab57d3473a5ce865eaf66caafaa6..1677c714cc0676bac78ebee1f9b8ae1fe819e516 100644 (file)
@@ -213,7 +213,7 @@ GNUNET_MESH_peer_request_connect_any (struct GNUNET_MESH_Handle *h,
  *
  * @param h mesh handle
  * @param timeout how long to try to establish a connection
- * @param num_peers length of the peers arrray
+ * @param num_peers length of the peers array
  * @param peers list of candidates to connect to
  * @param connect_handler function to call on successful connect (or timeout);
  *                will be called for EACH of the peers in the list and
index bdfd1a3ac260b7f14ab55b6c7f7baabdf649581a..449b8984cde79ec928bb8a41edb58ac7eb74e392 100644 (file)
  */
 
 #include <stdint.h>
+#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_core_service.h"
+#include <netinet/in.h>
 
 /**
  * All the states a peer participating in a tunnel can be in.
@@ -135,6 +139,11 @@ struct MESH_tunnel
      */
     uint32_t speed_max;
 
+    /**
+     * Last time the tunnel was used
+     */
+    struct GNUNET_TIME_Absolute timestamp;
+
     /**
      * Peers in the tunnel, for future optimizations
      */
@@ -172,7 +181,76 @@ struct Clients
     int fixme;
 };
 
+/**
+ * Handler for requests of creating new path
+ *
+ * @param cls closure
+ * @param client the client this message is from
+ * @param message the message received
+ */
+static void
+handle_mesh_path_create (void *cls,
+                         struct GNUNET_SERVER_Client *client,
+                         const struct GNUNET_MessageHeader *message)
+{
+    return;
+}
 
+/**
+ * Handler for client disconnection
+ *
+ * @param cls closure
+ * @param client identification of the client; NULL
+ *        for the last call when the server is destroyed
+ */
+static void
+handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
+{
+    /* Remove client from list, delete all timers and queues associated */
+    return;
+}
+
+/**
+ * Core handler for mesh network traffic
+ *
+ * @param cls closure
+ * @param message message
+ * @param peer peer identity this notification is about
+ * @param atsi performance data
+ *
+ */
+static int
+handle_mesh_network_traffic (void *cls,
+                              const struct GNUNET_PeerIdentity *peer,
+                              const struct GNUNET_MessageHeader *message,
+                              const struct GNUNET_TRANSPORT_ATS_Information
+                              *atsi)
+{
+    if(GNUNET_MESSAGE_TYPE_MESH_DATA_GO == ntohs(message->type)) {
+        /* Retransmit to next in path of tunnel identified by message */
+        return 0;
+    } else { /* GNUNET_MESSAGE_TYPE_MESH_DATA_BACK */
+        /* Retransmit to previous in path of tunnel identified by message */
+        return 0;
+    }
+}
+
+/**
+ * Functions to handle messages from core
+ */
+static struct GNUNET_CORE_MessageHandler core_handlers[] = {
+  {&handle_mesh_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_GO, 0},
+  {&handle_mesh_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_BACK, 0},
+  {NULL, 0, 0}
+};
+
+/**
+ * Functions to handle messages from clients
+ */
+static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
+  {&handle_mesh_path_create, NULL, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0},
+  {NULL, NULL, 0, 0}
+};
 
 /**
  * Process mesh requests. FIXME NON FUNCTIONAL, COPIED FROM DHT!!
@@ -189,17 +267,16 @@ run (void *cls,
   struct GNUNET_TIME_Relative next_send_time;
   unsigned long long temp_config_num;
   char *converge_modifier_buf;
+  GNUNET_CORE_Handle *coreAPI;
 
-  cfg = c;
-  datacache = GNUNET_DATACACHE_create (cfg, "dhtcache");
   GNUNET_SERVER_add_handlers (server, plugin_handlers);
   GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
-  coreAPI = GNUNET_CORE_connect (cfg,   /* Main configuration */
-                                 DEFAULT_CORE_QUEUE_SIZE,       /* queue size */
+  coreAPI = GNUNET_CORE_connect (c,   /* Main configuration */
+                                 32,       /* queue size */
                                  NULL,  /* Closure passed to DHT functions */
-                                 &core_init,    /* Call core_init once connected */
-                                 &handle_core_connect,  /* Handle connects */
-                                 &handle_core_disconnect,       /* remove peers on disconnects */
+                                 NULL,    /* Call core_init once connected */
+                                 NULL,  /* Handle connects */
+                                 NULL,       /* remove peers on disconnects */
                                  NULL,  /* Do we care about "status" updates? */
                                  NULL,  /* Don't want notified about all incoming messages */
                                  GNUNET_NO,     /* For header only inbound notification */
index 57778a3527eb6240fa314db591207313774d6fac..085f3ef4d63c6f5f0ff4308148e89117ba8a5a1c 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef MESH_H_
 #define MESH_H_
 #include <stdint.h>
+#include "gnunet_common.h"
 
 /**
  * Message for mesh path management
@@ -80,6 +81,11 @@ struct GNUNET_MESH_Data
      */
     uint32_t tid;
 
+    /**
+     * FIXME Some form of authentication
+     */
+    uint32_t token;
+
     /**
      * Size of payload
      * FIXME uint16 enough?
index 3421e2c6f7ad39b4756ed3ef8735e20e0f49b085..f714d32bb2f91c6ad6606fb0ed91f5a09afe0cd3 100644 (file)
@@ -469,7 +469,7 @@ GNUNET_MESH_connect (const struct
   ret->connected_peers.tail = NULL;
   ret->cleaner = cleaner;
   ret->cls = cls;
-    
+
   const struct GNUNET_MESH_MessageHandler *it;
   unsigned int len = 1;
   for (it = handlers; it->callback != NULL; it++)