gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14142 - in gnunet/src: include mesh


From: gnunet
Subject: [GNUnet-SVN] r14142 - in gnunet/src: include mesh
Date: Mon, 10 Jan 2011 22:41:44 +0100

Author: toelke
Date: 2011-01-10 22:41:44 +0100 (Mon, 10 Jan 2011)
New Revision: 14142

Modified:
   gnunet/src/include/gnunet_mesh_service.h
   gnunet/src/mesh/mesh_api.c
Log:
changes to the mesh-api

Modified: gnunet/src/include/gnunet_mesh_service.h
===================================================================
--- gnunet/src/include/gnunet_mesh_service.h    2011-01-10 21:41:42 UTC (rev 
14141)
+++ gnunet/src/include/gnunet_mesh_service.h    2011-01-10 21:41:44 UTC (rev 
14142)
@@ -68,7 +68,7 @@
  */
 typedef int
   (*GNUNET_MESH_MessageCallback) (void *cls,
-                                  const struct GNUNET_MESH_Tunnel *tunnel,
+                                  struct GNUNET_MESH_Tunnel *tunnel,
                                  void **tunnel_ctx,
                                   const struct GNUNET_MessageHeader *message,
                                  const struct GNUNET_TRANSPORT_ATS_Information 
*atsi);
@@ -134,6 +134,16 @@
 
 
 /**
+ * Get the peer on the other side of this tunnel if it is just one. Return 
NULL otherwise
+ * 
+ * @param tunnel the tunnel
+ * @return the peer or NULL
+ */
+const struct GNUNET_PeerIdentity*
+GNUNET_MESH_get_peer(const struct GNUNET_MESH_Tunnel* tunnel);
+
+
+/**
  * Disconnect from the mesh service.
  *
  * @param handle connection to mesh to disconnect

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2011-01-10 21:41:42 UTC (rev 14141)
+++ gnunet/src/mesh/mesh_api.c  2011-01-10 21:41:44 UTC (rev 14142)
@@ -104,6 +104,25 @@
 };
 
 static void
+send_end_connect(void* cls,
+                    const struct GNUNET_SCHEDULER_TaskContext* tc)
+{
+  struct GNUNET_MESH_Tunnel* tunnel = cls;
+
+  tunnel->connect_handler(tunnel->handler_cls, NULL, NULL);
+}
+
+static void
+send_self_connect(void* cls,
+                       const struct GNUNET_SCHEDULER_TaskContext* tc)
+{
+  struct GNUNET_MESH_Tunnel* tunnel = cls;
+
+  tunnel->connect_handler(tunnel->handler_cls, &tunnel->handle->myself, NULL);
+  GNUNET_SCHEDULER_add_now(send_end_connect, tunnel);
+}
+
+static void
 core_startup (void *cls,
              struct GNUNET_CORE_Handle *core,
              const struct GNUNET_PeerIdentity *my_identity,
@@ -160,6 +179,7 @@
                                             tunnel);
          tunnel->tunnel.connect_handler (tunnel->tunnel.handler_cls,
                                          peer, atsi);
+         GNUNET_SCHEDULER_add_now(send_end_connect, tunnel);
          tunnel = next;
        }
       else
@@ -349,7 +369,7 @@
                                         handle->established_tunnels.tail,
                                         handle->established_tunnels.tail,
                                         tunnel);
-      connect_handler (handler_cls, &handle->myself, NULL);
+      GNUNET_SCHEDULER_add_now(send_self_connect, tunnel);
     }
   else
     {
@@ -363,6 +383,12 @@
   return &tunnel->tunnel;
 }
 
+const struct GNUNET_PeerIdentity*
+GNUNET_MESH_get_peer(const struct GNUNET_MESH_Tunnel* tunnel)
+{
+  return &tunnel->peer;
+}
+
 static size_t
 core_notify(void* cls, size_t size, void* buf)
 {




reply via email to

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