gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r32602 - gnunet/src/mesh
Date: Mon, 10 Mar 2014 10:52:46 +0100

Author: bartpolot
Date: 2014-03-10 10:52:45 +0100 (Mon, 10 Mar 2014)
New Revision: 32602

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_connection.h
Log:
- use MeshHash in connection code

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-03-10 09:52:45 UTC 
(rev 32601)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-03-10 09:52:45 UTC 
(rev 32602)
@@ -839,7 +839,7 @@
  * @param peer Peer to notify (neighbor who sent the connection).
  */
 static void
-send_broken2 (struct GNUNET_HashCode *connection_id,
+send_broken2 (struct GNUNET_MeshHash *connection_id,
              const struct GNUNET_PeerIdentity *id1,
              const struct GNUNET_PeerIdentity *id2,
              GNUNET_PEER_Id peer_id)
@@ -847,8 +847,8 @@
   struct GNUNET_MESH_ConnectionBroken *msg;
   struct MeshPeer *neighbor;
 
-  LOG (GNUNET_ERROR_TYPE_INFO,
-       "Send BROKEN on unknown connection %s\n", GNUNET_h2s (connection_id));
+  LOG (GNUNET_ERROR_TYPE_INFO, "=> BROKEN on unknown connection %s\n",
+       GNUNET_h2s (GM_h2hc (connection_id)));
 
   msg = GNUNET_new (struct GNUNET_MESH_ConnectionBroken);
   msg->header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken));
@@ -1480,10 +1480,11 @@
 static void
 log_message (const struct GNUNET_MessageHeader *message,
              const struct GNUNET_PeerIdentity *peer,
-             const struct GNUNET_HashCode *hash)
+             const struct GNUNET_MeshHash *hash)
 {
   LOG (GNUNET_ERROR_TYPE_INFO, "<- %s on connection %s from %s\n",
-       GM_m2s (ntohs (message->type)), GNUNET_h2s (hash), GNUNET_i2s (peer));
+       GM_m2s (ntohs (message->type)), GNUNET_h2s (GM_h2hc (hash)),
+       GNUNET_i2s (peer));
 }
 
 
/******************************************************************************/
@@ -1506,7 +1507,7 @@
 {
   struct GNUNET_MESH_ConnectionCreate *msg;
   struct GNUNET_PeerIdentity *id;
-  struct GNUNET_HashCode *cid;
+  struct GNUNET_MeshHash *cid;
   struct MeshPeerPath *path;
   struct MeshPeer *dest_peer;
   struct MeshPeer *orig_peer;
@@ -1891,8 +1892,8 @@
   if (NULL == c)
   {
     GNUNET_STATISTICS_update (stats, "# unknown connection", 1, GNUNET_NO);
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING enc on unknown connection %s\n",
-         GNUNET_h2s (&msg->cid));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "enc on unknown connection %s\n",
+         GNUNET_h2s (GM_h2hc (&msg->cid)));
     return GNUNET_OK;
   }
 
@@ -2016,7 +2017,7 @@
   {
     GNUNET_STATISTICS_update (stats, "# unknown connection", 1, GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG, "kx on unknown connection %s\n",
-         GNUNET_h2s (&msg->cid));
+         GNUNET_h2s (GM_h2hc (&msg->cid)));
     return GNUNET_OK;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, " on connection %s\n", GMC_2s (c));
@@ -2219,7 +2220,7 @@
                               GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "WARNING POLL message on unknown connection %s!\n",
-         GNUNET_h2s (&msg->cid));
+         GNUNET_h2s (GM_h2hc (&msg->cid)));
     return GNUNET_OK;
   }
 
@@ -2391,7 +2392,7 @@
 
 
 struct MeshConnection *
-GMC_new (const struct GNUNET_HashCode *cid,
+GMC_new (const struct GNUNET_MeshHash *cid,
          struct MeshTunnel3 *t,
          struct MeshPeerPath *p,
          unsigned int own_pos)
@@ -2402,7 +2403,7 @@
   c->id = *cid;
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONTAINER_multihashmap_put (connections,
-                                                    &c->id, c,
+                                                    GMC_get_h (c), c,
                                                     
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   fc_init (&c->fwd_fc);
   fc_init (&c->bck_fc);
@@ -2494,7 +2495,8 @@
   }
 
   GNUNET_break (GNUNET_YES ==
-                GNUNET_CONTAINER_multihashmap_remove (connections, &c->id, c));
+                GNUNET_CONTAINER_multihashmap_remove (connections,
+                                                      GMC_get_h (c), c));
 
   GNUNET_STATISTICS_update (stats, "# connections", -1, GNUNET_NO);
   GNUNET_free (c);
@@ -2515,6 +2517,20 @@
 
 
 /**
+ * Get the connection ID.
+ *
+ * @param c Connection to get the ID from.
+ *
+ * @return ID of the connection.
+ */
+const struct GNUNET_HashCode *
+GMC_get_h (const struct MeshConnection *c)
+{
+  return GM_h2hc (&c->id);
+}
+
+
+/**
  * Get the connection path.
  *
  * @param c Connection to get the path from.
@@ -3048,8 +3064,8 @@
   {
     static char buf[128];
 
-    sprintf (buf, "%s (->%s)", GNUNET_h2s (&c->id), GMT_2s (c->t));
+    sprintf (buf, "%s (->%s)", GNUNET_h2s (GM_h2hc (GMC_get_id(c))), GMT_2s 
(c->t));
     return buf;
   }
-  return GNUNET_h2s (&c->id);
+  return GNUNET_h2s (GM_h2hc (&c->id));
 }

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.h    2014-03-10 09:52:45 UTC 
(rev 32601)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.h    2014-03-10 09:52:45 UTC 
(rev 32602)
@@ -266,7 +266,7 @@
  * @return Newly created connection, NULL in case of error (own id not in 
path).
  */
 struct MeshConnection *
-GMC_new (const struct GNUNET_HashCode *cid,
+GMC_new (const struct GNUNET_MeshHash *cid,
          struct MeshTunnel3 *t,
          struct MeshPeerPath *p,
          unsigned int own_pos);
@@ -292,7 +292,19 @@
 const struct GNUNET_MeshHash *
 GMC_get_id (const struct MeshConnection *c);
 
+
 /**
+ * Get a hash for the connection ID.
+ *
+ * @param c Connection to get the hash.
+ *
+ * @return Hash expanded from the ID of the connection.
+ */
+const struct GNUNET_HashCode *
+GMC_get_h (const struct MeshConnection *c);
+
+
+/**
  * Get the connection path.
  *
  * @param c Connection to get the path from.




reply via email to

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