gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15014 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r15014 - gnunet/src/mesh
Date: Mon, 18 Apr 2011 12:52:49 +0200

Author: bartpolot
Date: 2011-04-18 12:52:49 +0200 (Mon, 18 Apr 2011)
New Revision: 15014

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
Log:
WiP


Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-04-15 20:13:05 UTC (rev 
15013)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-04-18 10:52:49 UTC (rev 
15014)
@@ -542,6 +542,20 @@
 
/******************************************************************************/
 
 /**
+ * Client exisits
+ * @param client the client to check
+ * @return non-zero if client exists in the global DLL
+ */
+int
+client_exists (struct GNUNET_SERVER_Client *client) {
+    struct Client       *c;
+    for (c = clients_head; c != clients_head; c = c->next) {
+        if(c->handle == client) return 1;
+    }
+    return 0;
+}
+
+/**
  * Handler for client disconnection
  *
  * @param cls closure
@@ -633,16 +647,11 @@
                             struct GNUNET_SERVER_Client *client,
                             const struct GNUNET_MessageHeader *message)
 {
-    struct Client                       *c;
     struct GNUNET_MESH_TunnelMessage    *tunnel_msg;
     struct MESH_tunnel                  *t;
 
     /* Sanity check for client registration */
-    /* TODO: refactor into new function */
-    for (c = clients_head; c != clients_head; c = c->next) {
-        if(c->handle == client) break;
-    }
-    if(c->handle != client) { /* Client hasn't registered, not a good thing */
+    if(!client_exists(client)) {
         GNUNET_break(0);
         GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
         return;
@@ -684,7 +693,7 @@
     t->in_tail = NULL;
     t->out_head = NULL;
     t->out_tail = NULL;
-    
+
     GNUNET_SERVER_receive_done(client, GNUNET_OK);
     return;
 }
@@ -701,6 +710,12 @@
                              struct GNUNET_SERVER_Client *client,
                              const struct GNUNET_MessageHeader *message)
 {
+    /* Sanity check for client registration */
+    if(!client_exists(client)) {
+        GNUNET_break(0);
+        GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
+        return;
+    }
     return;
 }
 
@@ -709,17 +724,56 @@
  * 
  * @param cls closure
  * @param client identification of the client
- * @param message the actual message
+ * @param message the actual message (PeerControl)
  */
 static void
-handle_local_connect (void *cls,
-                         struct GNUNET_SERVER_Client *client,
-                         const struct GNUNET_MessageHeader *message)
+handle_local_connect_add (void *cls,
+                          struct GNUNET_SERVER_Client *client,
+                          const struct GNUNET_MessageHeader *message)
 {
+    /* Sanity check for client registration */
+    if(!client_exists(client)) {
+        GNUNET_break(0);
+        GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
+        return;
+    }
     return;
 }
 
+
 /**
+ * Handler for disconnection requests of peers in a tunnel
+ * 
+ * @param cls closure
+ * @param client identification of the client
+ * @param message the actual message (PeerControl)
+ */
+static void
+handle_local_connect_del (void *cls,
+                          struct GNUNET_SERVER_Client *client,
+                          const struct GNUNET_MessageHeader *message)
+{
+    return;
+}
+
+
+/**
+ * Handler for connection requests to new peers by type
+ * 
+ * @param cls closure
+ * @param client identification of the client
+ * @param message the actual message (ConnectPeerByType)
+ */
+static void
+handle_local_connect_by_type (void *cls,
+                              struct GNUNET_SERVER_Client *client,
+                              const struct GNUNET_MessageHeader *message)
+{
+    return;
+}
+
+
+/**
  * Handler for client traffic
  * 
  * @param cls closure
@@ -743,15 +797,13 @@
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE, 0},
   {&handle_local_tunnel_destroy, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY, 0},
-  {&handle_local_connect, NULL,
+  {&handle_local_connect_add, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0},
-  {&handle_local_connect, NULL,
+  {&handle_local_connect_del, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0},
-  {&handle_local_connect, NULL,
+  {&handle_local_connect_by_type, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE,
    sizeof(struct GNUNET_MESH_ConnectPeerByType)},
-  {&handle_local_connect, NULL,
-   GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL, 0},
   {&handle_local_network_traffic, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, /* FIXME needed? */
   {&handle_local_network_traffic, NULL,




reply via email to

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