- more info API
[oweals/gnunet.git] / src / cadet / cadet_api.c
index aa5c67329689adb6cac3ba6c83e5afe998f96b6d..c65475b10f74d66755c71d53850a5ddcccd576bc 100644 (file)
@@ -865,7 +865,7 @@ process_incoming_data (struct GNUNET_CADET_Handle *h,
 
   payload = (struct GNUNET_MessageHeader *) &dmsg[1];
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  %s data on channel %s [%X]\n",
-       GM_f2s (ch->chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV),
+       GC_f2s (ch->chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV),
        GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)), ntohl (dmsg->id));
 
   size = ntohs (message->size);
@@ -879,7 +879,7 @@ process_incoming_data (struct GNUNET_CADET_Handle *h,
   }
   type = ntohs (payload->type);
   size = ntohs (payload->size);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "  payload type %s\n", GM_m2s (type));
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "  payload type %s\n", GC_m2s (type));
   for (i = 0; i < h->n_handlers; i++)
   {
     handler = &h->message_handlers[i];
@@ -1078,13 +1078,9 @@ process_get_peer (struct GNUNET_CADET_Handle *h,
   struct GNUNET_CADET_LocalInfoTunnel *msg;
   size_t esize;
   size_t msize;
-  unsigned int ch_n;
-  unsigned int c_n;
-  struct GNUNET_CADET_Hash *conns;
-  CADET_ChannelNumber *chns;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnel messasge received\n");
-  if (NULL == h->info_cb.tunnel_cb)
+  if (NULL == h->info_cb.peer_cb)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  ignored\n");
     return;
@@ -1093,38 +1089,28 @@ process_get_peer (struct GNUNET_CADET_Handle *h,
   /* Verify message sanity */
   msg = (struct GNUNET_CADET_LocalInfoTunnel *) message;
   msize = ntohs (message->size);
-  esize = sizeof (struct GNUNET_CADET_LocalInfoTunnel);
+  esize = sizeof (struct GNUNET_CADET_LocalInfoPeer);
   if (esize > msize)
   {
     GNUNET_break_op (0);
-    h->info_cb.tunnel_cb (h->info_cls, NULL, 0, 0, NULL, NULL, 0, 0);
+    h->info_cb.peer_cb (h->info_cls, NULL, 0, 0, 0, NULL);
     goto clean_cls;
   }
-  ch_n = ntohl (msg->channels);
-  c_n = ntohl (msg->connections);
-  esize += ch_n * sizeof (CADET_ChannelNumber);
-  esize += c_n * sizeof (struct GNUNET_CADET_Hash);
+//   esize += ch_n * sizeof (CADET_ChannelNumber);
+//   esize += c_n * sizeof (struct GNUNET_CADET_Hash);
   if (msize != esize)
   {
     GNUNET_break_op (0);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "m:%u, e: %u (%u ch, %u conn)\n",
-                msize, esize, ch_n, c_n);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u (%u ch, %u conn)\n",
-                sizeof (struct GNUNET_CADET_LocalInfoTunnel),
-                sizeof (CADET_ChannelNumber), sizeof (struct GNUNET_HashCode));
-    h->info_cb.tunnel_cb (h->info_cls, NULL, 0, 0, NULL, NULL, 0, 0);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "m:%u, e: %u\n", msize, esize);
+    h->info_cb.peer_cb (h->info_cls, NULL, 0, 0, 0, NULL);
     goto clean_cls;
   }
 
   /* Call Callback with tunnel info. */
-  conns = (struct GNUNET_CADET_Hash *) &msg[1];
-  chns = (CADET_ChannelNumber *) &conns[c_n];
-  h->info_cb.tunnel_cb (h->info_cls, &msg->destination,
-                        ch_n, c_n, chns, conns,
-                        ntohs (msg->estate), ntohs (msg->cstate));
+  h->info_cb.peer_cb (h->info_cls, &msg->destination, 0, 0, 0, NULL);
 
   clean_cls:
-  h->info_cb.tunnel_cb = NULL;
+  h->info_cb.peer_cb = NULL;
   h->info_cls = NULL;
 }
 
@@ -1253,7 +1239,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
   type = ntohs (msg->type);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a message: %s\n",
-       GM_m2s (type));
+       GC_m2s (type));
   switch (type)
   {
     /* Notify of a new incoming channel */
@@ -1296,7 +1282,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
     /* We shouldn't get any other packages, log and ignore */
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "unsolicited message form service (type %s)\n",
-         GM_m2s (ntohs (msg->type)));
+         GC_m2s (ntohs (msg->type)));
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n");
   if (GNUNET_YES == h->in_receive)
@@ -1380,7 +1366,7 @@ send_callback (void *cls, size_t size, void *buf)
         dmsg->id = htonl (ch->chid);
         dmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
         LOG (GNUNET_ERROR_TYPE_DEBUG, "#  payload type %s\n",
-             GM_m2s (ntohs (mh->type)));
+             GC_m2s (ntohs (mh->type)));
                 ch->allow_send = GNUNET_NO;
       }
       else
@@ -1395,7 +1381,7 @@ send_callback (void *cls, size_t size, void *buf)
       struct GNUNET_MessageHeader *mh = (struct GNUNET_MessageHeader *) &th[1];
 
       LOG (GNUNET_ERROR_TYPE_DEBUG, "#  cadet internal traffic, type %s\n",
-           GM_m2s (ntohs (mh->type)));
+           GC_m2s (ntohs (mh->type)));
       memcpy (cbuf, &th[1], th->size);
       psize = th->size;
     }
@@ -1457,7 +1443,7 @@ send_packet (struct GNUNET_CADET_Handle *h,
   size_t msize;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, " Sending message to service: %s\n",
-       GM_m2s(ntohs(msg->type)));
+       GC_m2s(ntohs(msg->type)));
   msize = ntohs (msg->size);
   th = GNUNET_malloc (sizeof (struct GNUNET_CADET_TransmitHandle) + msize);
   th->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
@@ -1809,6 +1795,21 @@ send_info_request (struct GNUNET_CADET_Handle *h, uint16_t type)
 }
 
 
+/**
+ * Request a debug dump on the service's STDERR.
+ *
+ * WARNING: unstable API, likely to change in the future!
+ *
+ * @param h cadet handle
+ */
+void
+GNUNET_CADET_request_dump (struct GNUNET_CADET_Handle *h)
+{
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "requesting dump\n");
+  send_info_request (h, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP);
+}
+
+
 /**
  * Request information about peers known to the running cadet service.
  * The callback will be called for every peer known to the service.