gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r17347 - gnunet/src/mesh
Date: Mon, 10 Oct 2011 15:47:33 +0200

Author: grothoff
Date: 2011-10-10 15:47:33 +0200 (Mon, 10 Oct 2011)
New Revision: 17347

Modified:
   gnunet/src/mesh/mesh_api.c
   gnunet/src/mesh/mesh_api_new.c
Log:
use LOG macro in mesh_api.c

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2011-10-10 13:46:01 UTC (rev 17346)
+++ gnunet/src/mesh/mesh_api.c  2011-10-10 13:47:33 UTC (rev 17347)
@@ -32,6 +32,8 @@
 #include <gnunet_container_lib.h>
 #include <gnunet_applications.h>
 
+#define LOG(kind,...) GNUNET_log_from (kind, "mesh-api",__VA_ARGS__)
+
 struct tunnel_id
 {
   uint32_t id GNUNET_PACKED;
@@ -196,7 +198,7 @@
   if (cls == NULL)
     return 0;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending hello\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending hello\n");
 
   struct peer_list_element *element = cls;
   struct GNUNET_MESH_Handle *handle = element->handle;
@@ -256,8 +258,8 @@
 {
   struct GNUNET_MESH_Handle *handle = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Core tells us we are connected to peer %s\n", GNUNET_i2s 
(peer));
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Core tells us we are connected to peer %s\n",
+       GNUNET_i2s (peer));
 
   /* put the new peer into the list of connected peers */
   struct peer_list_element *element =
@@ -312,9 +314,9 @@
 {
   struct GNUNET_MESH_Handle *handle = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Core tells us we are no longer connected to peer %s\n",
-              GNUNET_i2s (peer));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Core tells us we are no longer connected to peer %s\n",
+       GNUNET_i2s (peer));
 
   struct peer_list_element *element = handle->connected_peers.head;
 
@@ -389,9 +391,9 @@
       (GNUNET_MESH_ApplicationType *) (num + 1);
   unsigned int i;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "The peer %s tells us he supports %d application-types.\n",
-              GNUNET_i2s (other), ntohs (*num));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "The peer %s tells us he supports %d application-types.\n",
+       GNUNET_i2s (other), ntohs (*num));
 
   struct peer_list_element *element = handle->connected_peers.head;
 
@@ -407,9 +409,9 @@
 
   for (i = 0; i < ntohs (*num); i++)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "The peer %s newly supports the application-type %d\n",
-                GNUNET_i2s (other), ntohs (ports[i]));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "The peer %s newly supports the application-type %d\n",
+         GNUNET_i2s (other), ntohs (ports[i]));
     if (GNUNET_APPLICATION_TYPE_END == ntohs (ports[i]))
       continue;
     struct type_list_element *new_type = GNUNET_malloc (sizeof *new_type);
@@ -423,9 +425,9 @@
 
   for (type = element->type_head; type != NULL; type = type->next)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "The peer %s supports the application-type %d\n",
-                GNUNET_i2s (other), type->type);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "The peer %s supports the application-type %d\n", GNUNET_i2s (other),
+         type->type);
   }
 
   struct tunnel_list_element *tunnel = handle->pending_by_type_tunnels.head;
@@ -491,9 +493,9 @@
   /* If no handler was found, drop the message but keep the channel open */
   if (handler->callback == NULL)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Received message of type %d from peer %s; dropping it.\n",
-                ntohs (rmessage->type), GNUNET_i2s (other));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Received message of type %d from peer %s; dropping it.\n",
+         ntohs (rmessage->type), GNUNET_i2s (other));
     return GNUNET_OK;
   }
 
@@ -515,9 +517,9 @@
   /* if no tunnel was found: create a new inbound tunnel */
   if (tunnel == NULL)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "New inbound tunnel from peer %s; first message has type 
%d.\n",
-                GNUNET_i2s (other), ntohs (rmessage->type));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "New inbound tunnel from peer %s; first message has type %d.\n",
+         GNUNET_i2s (other), ntohs (rmessage->type));
     tunnel = GNUNET_malloc (sizeof (struct tunnel_list_element));
     tunnel->tunnel.connect_handler = NULL;
     tunnel->tunnel.disconnect_handler = NULL;
@@ -533,9 +535,8 @@
                                        tunnel);
   }
   else
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Inbound message from peer %s; type %d.\n", GNUNET_i2s (other),
-                ntohs (rmessage->type));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Inbound message from peer %s; type %d.\n",
+         GNUNET_i2s (other), ntohs (rmessage->type));
 
   return handler->callback (handle->cls, &tunnel->tunnel, &tunnel->tunnel.ctx,
                             other, rmessage, atsi);
@@ -568,8 +569,8 @@
     element = element->next;
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect by tupe %d.\n",
-              application_type);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect by tupe %d.\n",
+       application_type);
 
   /* Put into pending list */
   struct tunnel_list_element *tunnel =
@@ -809,7 +810,7 @@
 
   for (t = stypes; *t != GNUNET_APPLICATION_TYPE_END; t++, num++) ;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I can handle %d app-types.\n", num);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "I can handle %d app-types.\n", num);
 
   handle->hello_message_size = sizeof (uint16_t) +      /* For the number of 
types */
       num * sizeof (GNUNET_MESH_ApplicationType);       /* For the types */
@@ -824,8 +825,7 @@
 
   for (i = 0; i < num; i++)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I can handle the app-type %d\n",
-                stypes[i]);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "I can handle the app-type %d\n", stypes[i]);
     types[i] = htons (stypes[i]);
   }
 
@@ -872,10 +872,9 @@
 
   ret->core =
       GNUNET_CORE_connect (cfg, 42, ret, &core_startup, &core_connect,
-                           &core_disconnect, NULL, GNUNET_NO, NULL,
-                           GNUNET_NO, core_handlers);
-  ret->transport =
-    GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL);
+                           &core_disconnect, NULL, GNUNET_NO, NULL, GNUNET_NO,
+                           core_handlers);
+  ret->transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, 
NULL);
   return ret;
 }
 

Modified: gnunet/src/mesh/mesh_api_new.c
===================================================================
--- gnunet/src/mesh/mesh_api_new.c      2011-10-10 13:46:01 UTC (rev 17346)
+++ gnunet/src/mesh/mesh_api_new.c      2011-10-10 13:47:33 UTC (rev 17347)
@@ -47,6 +47,8 @@
 
 #define DEBUG GNUNET_YES
 
+#define LOG(kind,...) GNUNET_log_from (kind, "mesh-api",__VA_ARGS__)
+
 
/******************************************************************************/
 /************************      DATA STRUCTURES     
****************************/
 
/******************************************************************************/
@@ -581,9 +583,9 @@
 /**
  * Send a connect packet to the service with the applications and types
  * requested by the user.
- * 
+ *
  * @param h The mesh handle.
- * 
+ *
  */
 static void
 send_connect (struct GNUNET_MESH_Handle *h)
@@ -609,8 +611,7 @@
     for (napps = 0; napps < h->n_applications; napps++)
     {
       apps[napps] = htonl (h->applications[napps]);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh:  app %u\n",
-                  h->applications[napps]);
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh:  app %u\n", h->applications[napps]);
     }
     types = (uint16_t *) & apps[napps];
     for (ntypes = 0; ntypes < h->n_handlers; ntypes++)
@@ -618,9 +619,9 @@
     msg->applications = htons (napps);
     msg->types = htons (ntypes);
 #if DEBUG
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "mesh: Sending %lu bytes long message %d types and %d apps\n",
-                ntohs (msg->header.size), ntypes, napps);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "mesh: Sending %lu bytes long message %d types and %d apps\n",
+         ntohs (msg->header.size), ntypes, napps);
 #endif
     send_packet (h, &msg->header);
   }
@@ -642,9 +643,9 @@
   unsigned int i;
 
 #if DEBUG
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: 
*****************************\n");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: *******   RECONNECT   
*******\n");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: 
*****************************\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *******   RECONNECT   *******\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n");
 #endif
   h->in_receive = GNUNET_NO;
   /* disconnect */
@@ -666,9 +667,8 @@
         GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_HOURS,
                                   GNUNET_TIME_relative_multiply
                                   (h->reconnect_time, 2));
-    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "mesh:   Next retry in %sms\n",
-               GNUNET_TIME_relative_to_string(h->reconnect_time));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh:   Next retry in %sms\n",
+         GNUNET_TIME_relative_to_string (h->reconnect_time));
     GNUNET_break (0);
     return GNUNET_NO;
   }
@@ -676,7 +676,7 @@
   {
     h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS;
   }
-  send_connect(h);
+  send_connect (h);
   /* Rebuild all tunnels */
   for (t = h->tunnels_head; NULL != t; t = t->next)
   {
@@ -825,7 +825,7 @@
   GNUNET_PEER_Id id;
   uint16_t size;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: processig peer event\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: processig peer event\n");
   size = ntohs (msg->header.size);
   if (size != sizeof (struct GNUNET_MESH_PeerControl))
   {
@@ -843,7 +843,7 @@
     p = add_peer_to_tunnel (t, &msg->peer);
   if (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD == ntohs (msg->header.type))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: adding peer\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: adding peer\n");
     if (NULL != t->connect_handler)
     {
       atsi.type = 0;
@@ -854,7 +854,7 @@
   }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: removing peer\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: removing peer\n");
     if (NULL != t->disconnect_handler && p->connected)
     {
       t->disconnect_handler (t->cls, &msg->peer);
@@ -862,7 +862,7 @@
     remove_peer_from_tunnel (p);
     GNUNET_free (p);
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: processing peer event END\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: processing peer event END\n");
 }
 
 
@@ -930,16 +930,15 @@
       if (GNUNET_OK !=
           handler->callback (h->cls, t, &t->ctx, peer, payload, &atsi))
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "MESH: callback caused disconnection\n");
+        LOG (GNUNET_ERROR_TYPE_DEBUG, "MESH: callback caused disconnection\n");
         GNUNET_MESH_disconnect (h);
         return;
       }
 #if DEBUG
       else
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "MESH: callback completed successfully\n");
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "MESH: callback completed successfully\n");
 
       }
 #endif
@@ -964,9 +963,8 @@
     reconnect (h);
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "mesh: received a message type %hu from MESH\n",
-              ntohs (msg->type));
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: received a message type %hu from 
MESH\n",
+       ntohs (msg->type));
   switch (ntohs (msg->type))
   {
     /* Notify of a new incoming tunnel */
@@ -990,11 +988,11 @@
     break;
     /* We shouldn't get any other packages, log and ignore */
   default:
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "MESH: unsolicited message form service (type %d)\n",
-                ntohs (msg->type));
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "MESH: unsolicited message form service (type %d)\n",
+         ntohs (msg->type));
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: message processed\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: message processed\n");
   GNUNET_CLIENT_receive (h->client, &msg_received, h,
                          GNUNET_TIME_UNIT_FOREVER_REL);
 }
@@ -1023,7 +1021,7 @@
   size_t tsize;
   size_t psize;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Send packet() Buffer %u\n", 
size);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: Send packet() Buffer %u\n", size);
   h->th = NULL;
   if ((0 == size) || (NULL == buf))
   {
@@ -1034,10 +1032,10 @@
   while ((NULL != (th = h->th_head)) && (size >= th->size))
   {
 #if DEBUG
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh:     type: %u\n",
-                ntohs (((struct GNUNET_MessageHeader *) &th[1])->type));
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh:     size: %u\n",
-                ntohs (((struct GNUNET_MessageHeader *) &th[1])->size));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh:     type: %u\n",
+         ntohs (((struct GNUNET_MessageHeader *) &th[1])->type));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh:     size: %u\n",
+         ntohs (((struct GNUNET_MessageHeader *) &th[1])->size));
 #endif
     if (NULL != th->notify)
     {
@@ -1092,16 +1090,16 @@
     size -= psize;
     tsize += psize;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh:   total size: %u\n", tsize);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh:   total size: %u\n", tsize);
   if (NULL != (th = h->th_head))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh:   next size: %u\n", th->size);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh:   next size: %u\n", th->size);
     h->th =
         GNUNET_CLIENT_notify_transmit_ready (h->client, th->size,
                                              GNUNET_TIME_UNIT_FOREVER_REL,
                                              GNUNET_YES, &send_callback, h);
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Send packet() END\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: Send packet() END\n");
   if (GNUNET_NO == h->in_receive)
   {
     h->in_receive = GNUNET_YES;
@@ -1175,7 +1173,7 @@
 {
   struct GNUNET_MESH_Handle *h;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: GNUNET_MESH_connect()\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: GNUNET_MESH_connect()\n");
   h = GNUNET_malloc (sizeof (struct GNUNET_MESH_Handle));
   h->cfg = cfg;
   h->max_queue_size = queue_size;
@@ -1198,8 +1196,8 @@
   /* count handlers and apps, calculate size */
   for (h->n_applications = 0; stypes[h->n_applications]; h->n_applications++) ;
   for (h->n_handlers = 0; handlers[h->n_handlers].type; h->n_handlers++) ;
-  send_connect(h);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: GNUNET_MESH_connect() END\n");
+  send_connect (h);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: GNUNET_MESH_connect() END\n");
   return h;
 }
 
@@ -1253,7 +1251,7 @@
   struct GNUNET_MESH_Tunnel *t;
   struct GNUNET_MESH_TunnelMessage msg;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Creating new tunnel\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: Creating new tunnel\n");
   t = create_tunnel (h, 0);
   t->connect_handler = connect_handler;
   t->disconnect_handler = disconnect_handler;
@@ -1278,7 +1276,7 @@
   struct GNUNET_MESH_Handle *h;
   struct GNUNET_MESH_TunnelMessage msg;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Destroying tunnel\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: Destroying tunnel\n");
   h = tunnel->mesh;
 
   if (0 != tunnel->owner)




reply via email to

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