refactor DHT for new service API
[oweals/gnunet.git] / src / cadet / cadet_common.c
index 360fbcee65cbb74dba6b121f94cfebfe1fc4021e..c24bc5c4b6b97a3b0c6f1be5a355e23917f3f66c 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2012 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -47,7 +47,7 @@ GC_f2s (int fwd)
   else
   {
     /* Not an error, can happen with CONNECTION_BROKEN messages. */
-    return "";
+    return "\???";
   }
 }
 
@@ -81,7 +81,7 @@ const struct GNUNET_HashCode *
 GC_h2hc (const struct GNUNET_CADET_Hash *id)
 {
   static struct GNUNET_HashCode hc;
-  memcpy (&hc, id, sizeof (*id));
+  GNUNET_memcpy (&hc, id, sizeof (*id));
 
   return &hc;
 }
@@ -92,7 +92,7 @@ GC_h2s (const struct GNUNET_CADET_Hash *id)
 {
   static char s[53];
 
-  memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52);
+  GNUNET_memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52);
   s[52] = '\0';
 
   return s;
@@ -146,7 +146,7 @@ GC_m2s (uint16_t m)
      * Used to mark the "payload" of a non-payload message.
      */
     case 0:
-      s = "retrnsmit";
+      s = "retransmit";
       break;
 
       /**
@@ -205,20 +205,6 @@ GC_m2s (uint16_t m)
       s = "AX_KX";
       break;
 
-      /**
-       * New ephemeral key.
-       */
-    case GNUNET_MESSAGE_TYPE_CADET_KX_EPHEMERAL:
-      s = "KX_EPHM";
-      break;
-
-      /**
-       * Answer to session key challenge.
-       */
-    case GNUNET_MESSAGE_TYPE_CADET_KX_PONG:
-      s = "KX_PONG";
-      break;
-
       /**
        * Request the destuction of a path
        */
@@ -247,11 +233,18 @@ GC_m2s (uint16_t m)
       s = "KEEPALIVE";
       break;
 
-    /**
-       * Connect to the cadet service, specifying subscriptions
+      /**
+       * Open port
        */
-    case GNUNET_MESSAGE_TYPE_CADET_LOCAL_CONNECT:
-      s = "LOC_CONNCT";
+    case GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN:
+      s = "OPEN_PORT";
+      break;
+
+      /**
+       * Close port
+       */
+    case GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE:
+      s = "CLOSE_PORT";
       break;
 
       /**
@@ -282,13 +275,6 @@ GC_m2s (uint16_t m)
       s = "CHAN_NACK";
       break;
 
-      /**
-       * OTR encrypted payload.
-       */
-    case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
-      s = "OTR";
-      break;
-
       /**
        * Axolotl encrypted payload.
        */
@@ -380,8 +366,16 @@ GC_m2s (uint16_t m)
       s = "INFO_DUMP";
       break;
 
+      /**
+       * Used to mark the "payload" of a non-payload message.
+       */
+    case UINT16_MAX:
+      s = "      N/A";
+      break;
+
+
     default:
-      SPRINTF (buf[idx], "%u (UNKNOWN)", m);
+      SPRINTF (buf[idx], "{UNK: %5u}", m);
       return buf[idx];
   }
   SPRINTF (buf[idx], "{%10s}", s);