static struct MeshConnection *
connection_get (const struct GNUNET_MeshHash *cid)
{
- struct GNUNET_HashCode hash;
- struct GNUNET_MeshHash *aux;
-
- memcpy (&hash, cid, sizeof (cid));
- aux = (struct GNUNET_MeshHash *) &hash;
- memset (&aux[1], 0, sizeof (hash) - sizeof (*cid));
-
- return GNUNET_CONTAINER_multihashmap_get (connections, &hash);
+ return GNUNET_CONTAINER_multihashmap_get (connections, GM_h2hc (cid));
}
GM_min_pid (uint32_t a, uint32_t b);
+/**
+ * Convert a 256 bit MeshHash into a 512 HashCode to use in GNUNET_h2s,
+ * multihashmap, and other HashCode-based functions.
+ *
+ * @param id A 256 bit hash to expand.
+ *
+ * @return A HashCode containing the original 256 bit hash right-padded with 0.
+ */
+struct GNUNET_HashCode *
+GM_h2hc (const struct GNUNET_MeshHash *id);
+
/**
* Convert a message type into a string to help debug
* Generated with:
}
+struct GNUNET_HashCode *
+GM_h2hc (const struct GNUNET_MeshHash *id)
+{
+ static struct GNUNET_HashCode hc;
+ memcpy (&hc, id, sizeof (*id));
+
+ return &hc;
+}
+
+
#if !defined(GNUNET_CULL_LOGGING)
const char *
GM_m2s (uint16_t m)