gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r17199 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r17199 - gnunet/src/transport
Date: Wed, 5 Oct 2011 13:51:57 +0200

Author: wachs
Date: 2011-10-05 13:51:57 +0200 (Wed, 05 Oct 2011)
New Revision: 17199

Modified:
   gnunet/src/transport/test_transport_api.c
   gnunet/src/transport/transport-testing.h
Log:
more beautification


Modified: gnunet/src/transport/test_transport_api.c
===================================================================
--- gnunet/src/transport/test_transport_api.c   2011-10-05 11:46:14 UTC (rev 
17198)
+++ gnunet/src/transport/test_transport_api.c   2011-10-05 11:51:57 UTC (rev 
17199)
@@ -37,7 +37,7 @@
 #include "transport.h"
 #include "transport-testing.h"
 
-#define VERBOSE GNUNET_EXTRA_LOGGING
+#define VERBOSE GNUNET_YES
 
 #define VERBOSE_ARM GNUNET_EXTRA_LOGGING
 
@@ -140,9 +140,11 @@
                 const struct GNUNET_TRANSPORT_ATS_Information *ats,
                 uint32_t ats_count)
 {
+  struct PeerContext * p = cls;
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received message of type %d from peer %s!\n",
-              ntohs (message->type), GNUNET_i2s (peer));
+              "Received message of type %d from peer %u (`%4s')!\n",
+              ntohs (message->type), p->no, GNUNET_i2s (peer));
 
   if ((MTYPE == ntohs (message->type)) &&
       (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size)))
@@ -179,8 +181,8 @@
   }
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Transmitting message with %u bytes to peer %s\n",
-              sizeof (struct GNUNET_MessageHeader), GNUNET_i2s (&p->id));
+              "Transmitting message with %u bytes to peer %u (%4s)\n",
+              sizeof (struct GNUNET_MessageHeader), p->no, GNUNET_i2s 
(&p->id));
   GNUNET_assert (size >= 256);
 
   if (buf != NULL)
@@ -198,18 +200,23 @@
                 const struct GNUNET_TRANSPORT_ATS_Information *ats,
                 uint32_t ats_count)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
-              GNUNET_i2s (peer), cls);
+  struct PeerContext *p = cls;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n",
+              p->no, GNUNET_i2s (peer));
 }
 
 
 static void
 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
-              GNUNET_i2s (peer), cls);
+  struct PeerContext *p = cls;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n",
+              p->no, GNUNET_i2s (peer));
 }
 
+struct PeerContext * sender;
+struct PeerContext * receiver;
+
 static void
 sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -217,10 +224,16 @@
 
   if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
     return;
+  char * receiver_s = strdup(GNUNET_i2s (&receiver->id));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
+              sender->no,
+              GNUNET_i2s (&sender->id), receiver->no, receiver_s);
+  GNUNET_free (receiver_s);
 
-  th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0,
+  th = GNUNET_TRANSPORT_notify_transmit_ready (sender->th, &receiver->id, 256, 
0,
                                                TIMEOUT_TRANSMIT, &notify_ready,
-                                               &p1);
+                                               receiver);
 }
 
 static void
@@ -229,8 +242,9 @@
   cc = NULL;
   char *p1_c = strdup (GNUNET_i2s (&p1->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c,
-              GNUNET_i2s (&p2->id));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u 
(%s)\n",
+              p1->no, p1_c,
+              p2->no, GNUNET_i2s (&p2->id));
   GNUNET_free (p1_c);
 
   // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG!
@@ -247,10 +261,11 @@
   p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, &notify_receive,
                                             &notify_connect, 
&notify_disconnect,
                                             NULL);
+  p1->no = 1;
   p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive,
                                             &notify_connect, 
&notify_disconnect,
                                             NULL);
-
+  p2->no = 2;
   if ((p1 == NULL) || (p2 == NULL))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
@@ -260,6 +275,22 @@
     return;
   }
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file 
`%s'\n",
+       p1->no,
+       GNUNET_i2s (&p1->id), cfg_file_p1);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file 
`%s'\n",
+       p2->no,
+       GNUNET_i2s (&p2->id), cfg_file_p2);
+
+  sender = p2;
+  receiver = p1;
+
+  char *sender_c = strdup (GNUNET_i2s (&sender->id));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test triest to send from %u (%s) -> 
peer %u (%s)\n",
+              sender->no, sender_c,
+              receiver->no, GNUNET_i2s (&receiver->id));
+
+
   cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
                                                NULL);
 }

Modified: gnunet/src/transport/transport-testing.h
===================================================================
--- gnunet/src/transport/transport-testing.h    2011-10-05 11:46:14 UTC (rev 
17198)
+++ gnunet/src/transport/transport-testing.h    2011-10-05 11:51:57 UTC (rev 
17199)
@@ -59,6 +59,8 @@
   void *cb_cls;
 
   char *servicehome;
+
+  unsigned int no;
 };
 
 /**




reply via email to

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