documentation
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 12 Aug 2011 04:28:53 +0000 (04:28 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 12 Aug 2011 04:28:53 +0000 (04:28 +0000)
src/transport/transport-testing.c
src/transport/transport-testing.h

index 24e4e8797d27a4adb3e731bbf89f999e414ab9ec..16e7a1e250d28a5de44b935318cf1ecbbcf1cc80 100644 (file)
@@ -41,10 +41,10 @@ struct ConnectingContext
 };
 
 static void
-exchange_hello_last (void *cls,
+exchange_hello_last (void *cb_cls,
                      const struct GNUNET_MessageHeader *message);
 static void
-exchange_hello (void *cls,
+exchange_hello (void *cb_cls,
                      const struct GNUNET_MessageHeader *message);
 
 static void
@@ -120,10 +120,10 @@ notify_receive (void *cls,
 
 
 static void
-exchange_hello_last (void *cls,
+exchange_hello_last (void *cb_cls,
                      const struct GNUNET_MessageHeader *message)
 {
-  struct ConnectingContext * cc = cls;
+  struct ConnectingContext * cc = cb_cls;
   struct PeerContext *me = cc->p2;
   //struct PeerContext *p1 = cc->p1;
 
@@ -140,10 +140,10 @@ exchange_hello_last (void *cls,
 
 
 static void
-exchange_hello (void *cls,
+exchange_hello (void *cb_cls,
                 const struct GNUNET_MessageHeader *message)
 {
-  struct ConnectingContext * cc = cls;
+  struct ConnectingContext * cc = cb_cls;
   struct PeerContext *me = cc->p1;
   //struct PeerContext *p2 = cc->p2;
 
@@ -183,6 +183,15 @@ try_connect (void *cls,
                                       cc);
 }
 
+
+/**
+ * Start a peer with the given configuration
+ * @param rec receive callback
+ * @param nc connect callback
+ * @param nd disconnect callback
+ * @param cb_cls closure for callback
+ * @return the peer context
+ */
 struct PeerContext *
 GNUNET_TRANSPORT_TESTING_start_peer (const char * cfgname,
     GNUNET_TRANSPORT_ReceiveCallback rec,
@@ -222,6 +231,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (const char * cfgname,
   return p;
 }
 
+/**
+ * shutdown the given peer
+ * @param p the peer
+ */
 void
 GNUNET_TRANSPORT_TESTING_stop_peer (struct PeerContext * p)
 {
@@ -245,11 +258,20 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct PeerContext * p)
   GNUNET_free (p);
 }
 
+/**
+ * Connect the two given peers and call the callback when both peers report the
+ * inbound connect. Remarks: start_peer's notify_connect callback can be called
+ * before.
+ * @param p1 peer 1
+ * @param p2 peer 2
+ * @param cb the callback to call
+ * @param cb_cls callback cls
+ */
 void
 GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext * p1,
                                         struct PeerContext * p2,
                                         GNUNET_TRANSPORT_TESTING_connect_cb cb,
-                                        void * cls)
+                                        void * cb_cls)
 {
   struct ConnectingContext * cc = GNUNET_malloc (sizeof (struct ConnectingContext));
 
@@ -260,7 +282,7 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext * p1,
   cc->p2 = p2;
 
   cc->cb = cb;
-  cc->cb_cls = cls;
+  cc->cb_cls = cb_cls;
 
   cc->th_p1 = GNUNET_TRANSPORT_connect(cc->p1->cfg, NULL,
                             cc,
index cfcffaff6c4cc30f9adfbd6a89b7aecec5af862a..25a7720013d22121103267a3180e149e30d813ea 100644 (file)
 
 #include "platform.h"
 #include "gnunet_common.h"
-#include "gnunet_hello_lib.h"
 #include "gnunet_getopt_lib.h"
 #include "gnunet_os_lib.h"
 #include "gnunet_program_lib.h"
 #include "gnunet_transport_service.h"
-#include "transport.h"
 
 
+/**
+ * Context for a single peer
+ */
 struct PeerContext
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
+
   struct GNUNET_TRANSPORT_Handle *th;
+
   struct GNUNET_PeerIdentity id;
+
   struct GNUNET_OS_Process *arm_proc;
 
   GNUNET_TRANSPORT_ReceiveCallback rec;
+
   GNUNET_TRANSPORT_NotifyConnect nc;
+
   GNUNET_TRANSPORT_NotifyDisconnect nd;
+
   void * cb_cls;
 
   char * servicehome;
 };
 
+/**
+ * Callback when two peers are connected and both have called the connect callback
+ * to notify clients about a new peer
+ */
 typedef void (*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext * p1, struct PeerContext * p2, void *cls);
 
+
+/**
+ * Start a peer with the given configuration
+ * @param rec receive callback
+ * @param nc connect callback
+ * @param nd disconnect callback
+ * @param cb_cls closure for callback
+ * @return the peer context
+ */
 struct PeerContext *
 GNUNET_TRANSPORT_TESTING_start_peer (const char * cfgname,
     GNUNET_TRANSPORT_ReceiveCallback rec,
@@ -59,9 +79,25 @@ GNUNET_TRANSPORT_TESTING_start_peer (const char * cfgname,
     GNUNET_TRANSPORT_NotifyDisconnect nd,
     void * cb_cls);
 
+
+/**
+ * shutdown the given peer
+ * @param p the peer
+ */
+
 void
 GNUNET_TRANSPORT_TESTING_stop_peer (struct PeerContext * pc);
 
+
+/**
+ * Connect the given peers and call the callback when both peers report the
+ * inbound connection. Remarks: start_peer's notify_connect callback can be called
+ * before.
+ * @param p1 peer 1
+ * @param p2 peer 2
+ * @param cb the callback to call
+ * @param cb_cls callback cls
+ */
 void
 GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext * p1,
     struct PeerContext * p2,