GC_min_pid (uint32_t a, uint32_t b);
-/**
- * Convert a 256 bit CadetHash 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.
- */
-const struct GNUNET_HashCode *
-GC_h2hc (const struct GNUNET_CADET_Hash *id);
-
-
-/**
- * Get a string from a Cadet Hash (256 bits).
- * WARNING: Not reentrant (based on GNUNET_h2s).
- */
-const char *
-GC_h2s (const struct GNUNET_CADET_Hash *id);
-
-
/**
* Allocate a string with a hexdump of any binary data.
*
* @return The size of the output.
*/
size_t
-GC_bin2s (void *bin, unsigned int len, char **output);
+GC_bin2s (void *bin,
+ unsigned int len,
+ char **output);
+
/**
* Convert a message type into a string to help debug
}
-const struct GNUNET_HashCode *
-GC_h2hc (const struct GNUNET_CADET_Hash *id)
-{
- static struct GNUNET_HashCode hc;
- GNUNET_memcpy (&hc, id, sizeof (*id));
-
- return &hc;
-}
-
-
-const char *
-GC_h2s (const struct GNUNET_CADET_Hash *id)
-{
- static char s[53];
-
- GNUNET_memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52);
- s[52] = '\0';
-
- return s;
-}
-
-
/**
* Allocate a string with a hexdump of any binary data.
*
* Everything after this value will be encrypted with the header key
* and authenticated.
*/
- struct GNUNET_CADET_Hash hmac;
+ struct GNUNET_ShortHashCode hmac;
/**************** AX_HEADER start ****************/
FPRINTF (stdout, "\t\t%X\n", ntohl (channels[i].cn));
FPRINTF (stdout, "\t%u connections\n", n_connections);
for (i = 0; i < n_connections; i++)
- FPRINTF (stdout, "\t\t%s\n", GC_h2s (&connections[i].connection_of_tunnel));
+ FPRINTF (stdout, "\t\t%s\n", GNUNET_sh2s (&connections[i].connection_of_tunnel));
FPRINTF (stdout, "\tencryption state: %s\n", enc_2s (estate));
FPRINTF (stdout, "\tconnection state: %s\n", conn_2s (cstate));
}
struct GNUNET_CONTAINER_MultiPeerMap *peers;
/**
- * Map from expanded connection hash codes to `struct CadetConnection` objects.
+ * Map from `struct GNUNET_CADET_ConnectionTunnelIdentifier`
+ * hash codes to `struct CadetConnection` objects.
*/
-struct GNUNET_CONTAINER_MultiHashMap *connections;
+struct GNUNET_CONTAINER_MultiShortmap *connections;
/**
* How many messages are needed to trigger an AXOLOTL ratchet advance.
}
if (NULL != connections)
{
- GNUNET_CONTAINER_multihashmap_destroy (connections);
+ GNUNET_CONTAINER_multishortmap_destroy (connections);
connections = NULL;
}
if (NULL != ats_ch)
struct CadetChannel *ch)
{
struct GNUNET_CADET_LocalInfoTunnel *msg = cls;
- struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1];
+ struct GNUNET_CADET_ConnectionTunnelIdentifier *h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1];
struct GCT_ChannelTunnelNumber *chn
= (struct GCT_ChannelTunnelNumber *) &h[msg->connections];
ch_n = GCT_count_channels (t);
c_n = GCT_count_any_connections (t);
env = GNUNET_MQ_msg_extra (resp,
- c_n * sizeof (struct GNUNET_CADET_Hash) +
+ c_n * sizeof (struct GNUNET_CADET_ConnectionTunnelIdentifier) +
ch_n * sizeof (struct GCT_ChannelTunnelNumber),
GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL);
resp->destination = msg->peer;
GNUNET_NO);
peers = GNUNET_CONTAINER_multipeermap_create (16,
GNUNET_YES);
- connections = GNUNET_CONTAINER_multihashmap_create (256,
- GNUNET_YES);
+ connections = GNUNET_CONTAINER_multishortmap_create (256,
+ GNUNET_YES);
GCH_init (c);
GCD_init (c);
GCO_init (c);
extern struct GNUNET_CONTAINER_MultiHashMap *open_ports;
/**
- * Map from expanded connection hash codes to `struct CadetConnection` objects.
+ * Map from `struct GNUNET_CADET_ConnectionTunnelIdentifier`
+ * hash codes to `struct CadetConnection` objects.
*/
-extern struct GNUNET_CONTAINER_MultiHashMap *connections;
+extern struct GNUNET_CONTAINER_MultiShortmap *connections;
/**
* Map from ports to channels where the ports were closed at the
GCPP_del_connection (cc->path,
cc->off,
cc);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multishortmap_remove (connections,
+ &GCC_get_id (cc)->connection_of_tunnel,
+ cc));
GNUNET_free (cc);
}
-/**
- * Expand the shorter CADET hash to a full GNUnet hash.
- *
- * @param id hash to expand
- * @return expanded hash
- * @param deprecated
- */
-const struct GNUNET_HashCode *
-GCC_h2hc (const struct GNUNET_CADET_Hash *id)
-{
- static struct GNUNET_HashCode hc;
- char *ptr = (char *) &hc;
-
- GNUNET_assert (sizeof (hc) == 2 * sizeof (*id));
- GNUNET_memcpy (ptr,
- id,
- sizeof (*id));
- GNUNET_memcpy (&ptr[sizeof (*id)],
- id,
- sizeof (*id));
- return &hc;
-}
-
-
-/**
- * Get the connection ID as a full hash.
- *
- * @param cc Connection to get the ID from.
- * @return full hash ID of the connection.
- */
-const struct GNUNET_HashCode *
-GCC_get_h (const struct CadetConnection *cc)
-{
- return GCC_h2hc (&cc->cid.connection_of_tunnel);
-}
-
-
/**
* Return the tunnel associated with this connection.
*
&cc->cid,
sizeof (cc->cid));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (connections,
- GCC_get_h (cc),
- cc,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multishortmap_put (connections,
+ &GCC_get_id (cc)->connection_of_tunnel,
+ cc,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
cc->ready_cb = ready_cb;
cc->ready_cb_cls = ready_cb_cls;
cc->path = path;
GCC_get_id (struct CadetConnection *cc);
-/**
- * Get the connection ID as a full hash.
- *
- * @param cc Connection to get the ID from.
- * @return full hash ID of the connection.
- * @deprecated try to replace use of full hash codes eventually...
- */
-const struct GNUNET_HashCode *
-GCC_get_h (const struct CadetConnection *cc);
-
-
-/**
- * Expand the shorter CADET hash to a full GNUnet hash.
- *
- * @param id hash to expand
- * @return expanded hash
- * @param deprecated
- */
-const struct GNUNET_HashCode *
-GCC_h2hc (const struct GNUNET_CADET_Hash *id);
-
-
/**
* Log connection info.
*
/**
* Routes on which this peer is an intermediate.
*/
-static struct GNUNET_CONTAINER_MultiHashMap *routes;
+static struct GNUNET_CONTAINER_MultiShortmap *routes;
/**
* @param cid hash generated from the connection identifier
*/
static struct CadetRoute *
-get_route (const struct GNUNET_HashCode *cid)
+get_route (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
{
- return GNUNET_CONTAINER_multihashmap_get (routes,
- cid);
+ return GNUNET_CONTAINER_multishortmap_get (routes,
+ &cid->connection_of_tunnel);
}
*/
static void
route_message (struct CadetPeer *prev,
- const struct GNUNET_HashCode *cid, /* FIXME: bad type... */
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
const struct GNUNET_MessageHeader *msg)
{
struct CadetRoute *route;
env = GNUNET_MQ_msg (bm,
GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN);
- /* FIXME: ugly */
- memcpy (&bm->cid,
- cid,
- sizeof (bm->cid));
+ bm->cid = *cid;
bm->peer1 = my_full_id;
GCP_send (prev,
env);
const struct GNUNET_CADET_ConnectionACK *msg)
{
struct CadetPeer *peer = cls;
- const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel);
struct CadetConnection *cc;
/* First, check if ACK belongs to a connection that ends here. */
- cc = GNUNET_CONTAINER_multihashmap_get (connections,
- cid);
+ cc = GNUNET_CONTAINER_multishortmap_get (connections,
+ &msg->cid.connection_of_tunnel);
if (NULL != cc)
{
/* verify ACK came from the right direction */
/* We're just an intermediary peer, route the message along its path */
route_message (peer,
- cid,
+ &msg->cid,
&msg->header);
}
const struct GNUNET_CADET_ConnectionBroken *msg)
{
struct CadetPeer *peer = cls;
- const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel);
struct CadetConnection *cc;
struct CadetRoute *route;
/* First, check if message belongs to a connection that ends here. */
- cc = GNUNET_CONTAINER_multihashmap_get (connections,
- cid);
+ cc = GNUNET_CONTAINER_multishortmap_get (connections,
+ &msg->cid.connection_of_tunnel);
if (NULL != cc)
{
/* verify message came from the right direction */
}
/* We're just an intermediary peer, route the message along its path */
- route = get_route (cid);
+ route = get_route (&msg->cid);
route_message (peer,
- cid,
+ &msg->cid,
&msg->header);
destroy_route (route);
}
const struct GNUNET_CADET_ConnectionDestroy *msg)
{
struct CadetPeer *peer = cls;
- const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel);
struct CadetConnection *cc;
struct CadetRoute *route;
/* First, check if message belongs to a connection that ends here. */
- cc = GNUNET_CONTAINER_multihashmap_get (connections,
- cid);
+ cc = GNUNET_CONTAINER_multishortmap_get (connections,
+ &msg->cid.connection_of_tunnel);
if (NULL != cc)
{
/* verify message came from the right direction */
}
/* We're just an intermediary peer, route the message along its path */
- route = get_route (cid);
+ route = get_route (&msg->cid);
route_message (peer,
- cid,
+ &msg->cid,
&msg->header);
destroy_route (route);
}
const struct GNUNET_CADET_KX *msg)
{
struct CadetPeer *peer = cls;
- const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel);
struct CadetConnection *cc;
/* First, check if message belongs to a connection that ends here. */
- cc = GNUNET_CONTAINER_multihashmap_get (connections,
- cid);
+ cc = GNUNET_CONTAINER_multishortmap_get (connections,
+ &msg->cid.connection_of_tunnel);
if (NULL != cc)
{
/* verify message came from the right direction */
/* We're just an intermediary peer, route the message along its path */
route_message (peer,
- cid,
+ &msg->cid,
&msg->header);
}
const struct GNUNET_CADET_Encrypted *msg)
{
struct CadetPeer *peer = cls;
- const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel);
struct CadetConnection *cc;
/* First, check if message belongs to a connection that ends here. */
- cc = GNUNET_CONTAINER_multihashmap_get (connections,
- cid);
+ cc = GNUNET_CONTAINER_multishortmap_get (connections,
+ &msg->cid.connection_of_tunnel);
if (NULL != cc)
{
/* verify message came from the right direction */
/* We're just an intermediary peer, route the message along its path */
route_message (peer,
- cid,
+ &msg->cid,
&msg->header);
}
GNUNET_MQ_handler_end ()
};
- routes = GNUNET_CONTAINER_multihashmap_create (1024,
- GNUNET_NO);
+ routes = GNUNET_CONTAINER_multishortmap_create (1024,
+ GNUNET_NO);
core = GNUNET_CORE_connect (c,
NULL,
&core_init_cb,
GNUNET_CORE_disconnect (core);
core = NULL;
}
- GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (routes));
- GNUNET_CONTAINER_multihashmap_destroy (routes);
+ GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (routes));
+ GNUNET_CONTAINER_multishortmap_destroy (routes);
}
/* end of gnunet-cadet-service_core.c */
/**
* Connections that go through this peer; indexed by tid.
*/
- struct GNUNET_CONTAINER_MultiHashMap *connections;
+ struct GNUNET_CONTAINER_MultiShortmap *connections;
/**
* Handle for core transmissions.
GNUNET_assert (NULL == cp->t);
GNUNET_assert (NULL == cp->core_mq);
GNUNET_assert (0 == cp->path_dll_length);
- GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (cp->connections));
+ GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections));
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (peers,
&cp->pid,
GNUNET_ATS_connectivity_suggest_cancel (cp->connectivity_suggestion);
cp->connectivity_suggestion = NULL;
}
- GNUNET_CONTAINER_multihashmap_destroy (cp->connections);
+ GNUNET_CONTAINER_multishortmap_destroy (cp->connections);
GNUNET_CONTAINER_heap_destroy (cp->path_heap);
GNUNET_free_non_null (cp->hello);
/* Peer should not be freed if paths exist; if there are no paths,
return; /* still relevant! */
if (NULL != cp->core_mq)
return; /* still relevant! */
- if (0 != GNUNET_CONTAINER_multihashmap_size (cp->connections))
+ if (0 != GNUNET_CONTAINER_multishortmap_size (cp->connections))
return; /* still relevant! */
if (0 < GNUNET_CONTAINER_heap_get_size (cp->path_heap))
{
struct CadetConnection *cc)
{
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (cp->connections,
- GCC_get_h (cc),
- cc,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multishortmap_put (cp->connections,
+ &GCC_get_id (cc)->connection_of_tunnel,
+ cc,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
struct CadetConnection *cc)
{
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (cp->connections,
- GCC_get_h (cc),
- cc));
+ GNUNET_CONTAINER_multishortmap_remove (cp->connections,
+ &GCC_get_id (cc)->connection_of_tunnel,
+ cc));
}
GNUNET_SCHEDULER_cancel (cp->destroy_task);
cp->destroy_task = NULL;
}
- if ( (0 == GNUNET_CONTAINER_multihashmap_size (cp->connections)) &&
+ if ( (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections)) &&
(NULL == cp->t) )
{
/* We're just on a path or directly connected; don't bother too much */
return NULL;
cp = GNUNET_new (struct CadetPeer);
cp->pid = *peer_id;
- cp->connections = GNUNET_CONTAINER_multihashmap_create (32,
- GNUNET_YES);
+ cp->connections = GNUNET_CONTAINER_multishortmap_create (32,
+ GNUNET_YES);
cp->path_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_put (peers,
size_t size,
uint32_t iv,
const struct GNUNET_CRYPTO_SymmetricSessionKey *key,
- struct GNUNET_CADET_Hash *hmac)
+ struct GNUNET_ShortHashCode *hmac)
{
static const char ctx[] = "cadet authentication key";
struct GNUNET_CRYPTO_AuthKey auth_key;
size_t size)
{
struct CadetTunnelSkippedKey *key;
- struct GNUNET_CADET_Hash *hmac;
+ struct GNUNET_ShortHashCode *hmac;
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
struct GNUNET_CADET_Encrypted plaintext_header;
struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK;
size_t size)
{
struct CadetTunnelAxolotl *ax;
- struct GNUNET_CADET_Hash msg_hmac;
+ struct GNUNET_ShortHashCode msg_hmac;
struct GNUNET_HashCode hmac;
struct GNUNET_CADET_Encrypted plaintext_header;
uint32_t Np;
/**
* Connections known, indexed by cid (CadetConnection).
*/
-static struct GNUNET_CONTAINER_MultiHashMap *connections;
+static struct GNUNET_CONTAINER_MultiShortmap *connections;
/**
* How many connections are we willing to maintain.
static struct CadetConnection *
connection_get (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
{
- return GNUNET_CONTAINER_multihashmap_get (connections, GC_h2hc (&cid->connection_of_tunnel));
+ return GNUNET_CONTAINER_multishortmap_get (connections,
+ &cid->connection_of_tunnel);
}
*/
static int
check_connection (void *cls,
- const struct GNUNET_HashCode *key,
+ const struct GNUNET_ShortHashCode *key,
void *value)
{
struct CadetConnection *c = value;
return;
if (NULL == connections)
return;
- GNUNET_CONTAINER_multihashmap_iterate (connections,
- &check_connection,
- NULL);
+ GNUNET_CONTAINER_multishortmap_iterate (connections,
+ &check_connection,
+ NULL);
}
GCC_check_connections ();
LOG (GNUNET_ERROR_TYPE_INFO, "--> BROKEN on unknown connection %s\n",
- GNUNET_h2s (GC_h2hc (&connection_id->connection_of_tunnel)));
+ GNUNET_sh2s (&connection_id->connection_of_tunnel));
msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN);
default:
arrow = "--";
}
- LOG (GNUNET_ERROR_TYPE_INFO, "<%s %s on conn %s from %s, %6u bytes\n",
- arrow, GC_m2s (type), GNUNET_h2s (GC_h2hc (&conn_id->connection_of_tunnel)),
- GCP_2s(peer), (unsigned int) size);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "<%s %s on conn %s from %s, %6u bytes\n",
+ arrow,
+ GC_m2s (type),
+ GNUNET_sh2s (&conn_id->connection_of_tunnel),
+ GCP_2s(peer),
+ (unsigned int) size);
}
/******************************************************************************/
GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"POLL message on unknown connection %s!\n",
- GNUNET_h2s (GC_h2hc (&msg->cid.connection_of_tunnel)));
+ GNUNET_sh2s (&msg->cid.connection_of_tunnel));
send_broken_unknown (&msg->cid,
&my_full_id,
NULL,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"%s on unknown connection %s\n",
GC_m2s (ntohs (message->type)),
- GNUNET_h2s (GC_h2hc (&cid->connection_of_tunnel)));
+ GNUNET_sh2s (&cid->connection_of_tunnel));
GNUNET_break_op (0);
send_broken_unknown (cid,
&my_full_id,
}
create_connection_time = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS,
refresh_connection_time);
- connections = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
+ connections = GNUNET_CONTAINER_multishortmap_create (1024,
+ GNUNET_YES);
}
*/
static int
shutdown_iterator (void *cls,
- const struct GNUNET_HashCode *key,
+ const struct GNUNET_ShortHashCode *key,
void *value)
{
struct CadetConnection *c = value;
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connections\n");
GCC_check_connections ();
- GNUNET_CONTAINER_multihashmap_iterate (connections,
- &shutdown_iterator,
- NULL);
- GNUNET_CONTAINER_multihashmap_destroy (connections);
+ GNUNET_CONTAINER_multishortmap_iterate (connections,
+ &shutdown_iterator,
+ NULL);
+ GNUNET_CONTAINER_multishortmap_destroy (connections);
connections = NULL;
}
c = GNUNET_new (struct CadetConnection);
c->id = *cid;
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (connections,
- GCC_get_h (c), c,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multishortmap_put (connections,
+ &c->id.connection_of_tunnel,
+ c,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
fc_init (&c->fwd_fc);
fc_init (&c->bck_fc);
c->fwd_fc.c = c;
if (GNUNET_NO == c->was_removed)
{
GNUNET_break (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (connections,
- GCC_get_h (c),
- c));
+ GNUNET_CONTAINER_multishortmap_remove (connections,
+ &c->id.connection_of_tunnel,
+ c));
}
GNUNET_STATISTICS_update (stats,
"# connections",
}
-/**
- * Get the connection ID.
- *
- * @param c Connection to get the ID from.
- *
- * @return ID of the connection.
- */
-const struct GNUNET_HashCode *
-GCC_get_h (const struct CadetConnection *c)
-{
- return GC_h2hc (&c->id.connection_of_tunnel);
-}
-
-
/**
* Get the connection path.
*
GNUNET_assert (GNUNET_NO == c->was_removed);
c->was_removed = GNUNET_YES;
GNUNET_break (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (connections,
- GCC_get_h (c),
- c));
+ GNUNET_CONTAINER_multishortmap_remove (connections,
+ &c->id.connection_of_tunnel,
+ c));
/* Cancel queue in the direction that just died. */
connection_cancel_queues (c, ! fwd);
GCC_stop_poll (c, ! fwd);
static char buf[128];
SPRINTF (buf, "%s (->%s)",
- GNUNET_h2s (GC_h2hc (&GCC_get_id (c)->connection_of_tunnel)), GCT_2s (c->t));
+ GNUNET_sh2s (&GCC_get_id (c)->connection_of_tunnel),
+ GCT_2s (c->t));
return buf;
}
- return GNUNET_h2s (GC_h2hc (&c->id.connection_of_tunnel));
+ return GNUNET_sh2s (&c->id.connection_of_tunnel);
}
GCC_get_id (const struct CadetConnection *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 *
-GCC_get_h (const struct CadetConnection *c);
-
-
/**
* Get the connection path.
*
iter_channel (void *cls, struct CadetChannel *ch)
{
struct GNUNET_CADET_LocalInfoTunnel *msg = cls;
- struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1];
+ struct GNUNET_CADET_ConnectionTunnelIdentifier *h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1];
struct GNUNET_CADET_ChannelNumber *chn = (struct GNUNET_CADET_ChannelNumber *) &h[msg->connections];
chn[msg->channels] = GCCH_get_id (ch);
c_n = GCT_count_any_connections (t);
size = sizeof (struct GNUNET_CADET_LocalInfoTunnel);
- size += c_n * sizeof (struct GNUNET_CADET_Hash);
+ size += c_n * sizeof (struct GNUNET_CADET_ConnectionTunnelIdentifier);
size += ch_n * sizeof (struct GNUNET_CADET_ChannelNumber);
resp = GNUNET_malloc (size);
/**
* Connections that go through this peer; indexed by tid.
*/
- struct GNUNET_CONTAINER_MultiHashMap *connections;
+ struct GNUNET_CONTAINER_MultiShortmap *connections;
/**
* Handle for core transmissions.
*/
static int
notify_broken (void *cls,
- const struct GNUNET_HashCode *key,
+ const struct GNUNET_ShortHashCode *key,
void *value)
{
struct CadetPeer *peer = cls;
/* Create the connections hashmap */
GNUNET_assert (NULL == neighbor->connections);
- neighbor->connections = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO);
+ neighbor->connections = GNUNET_CONTAINER_multishortmap_create (16,
+ GNUNET_YES);
GNUNET_STATISTICS_update (stats,
"# peers",
1,
direct_path = pop_direct_path (p);
if (NULL != p->connections)
{
- GNUNET_CONTAINER_multihashmap_iterate (p->connections,
- ¬ify_broken,
- p);
- GNUNET_CONTAINER_multihashmap_destroy (p->connections);
- p->connections = NULL;
+ GNUNET_CONTAINER_multishortmap_iterate (p->connections,
+ ¬ify_broken,
+ p);
+ GNUNET_CONTAINER_multishortmap_destroy (p->connections);
+ p->connections = NULL;
}
GNUNET_STATISTICS_update (stats,
"# peers",
GCT_destroy_empty (peer->tunnel);
if (NULL != peer->connections)
{
- GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (peer->connections));
- GNUNET_CONTAINER_multihashmap_destroy (peer->connections);
+ GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (peer->connections));
+ GNUNET_CONTAINER_multishortmap_destroy (peer->connections);
peer->connections = NULL;
}
if (NULL != peer->hello_offer)
GCP_2s (peer));
GNUNET_assert (NULL != peer->connections);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (peer->connections,
- GCC_get_h (c),
- c,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multishortmap_put (peer->connections,
+ &GCC_get_id (c)->connection_of_tunnel,
+ c,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Peer %s has now %u connections.\n",
GCP_2s (peer),
- GNUNET_CONTAINER_multihashmap_size (peer->connections));
+ GNUNET_CONTAINER_multishortmap_size (peer->connections));
}
GCP_check_connection (const struct CadetPeer *peer,
const struct CadetConnection *c)
{
- GNUNET_assert (NULL != peer);
- GNUNET_assert (NULL != peer->connections);
- return;
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_contains_value (peer->connections,
- GCC_get_h (c),
- c));
+ GNUNET_assert (NULL != peer);
+ GNUNET_assert (NULL != peer->connections);
+ return; // ????
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multishortmap_contains_value (peer->connections,
+ &GCC_get_id (c)->connection_of_tunnel,
+ c));
}
(NULL == peer->connections) )
return;
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (peer->connections,
- GCC_get_h (c),
- c));
+ GNUNET_CONTAINER_multishortmap_remove (peer->connections,
+ &GCC_get_id (c)->connection_of_tunnel,
+ c));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Peer %s remains with %u connections.\n",
GCP_2s (peer),
- GNUNET_CONTAINER_multihashmap_size (peer->connections));
+ GNUNET_CONTAINER_multishortmap_size (peer->connections));
}
static void
t_hmac (const void *plaintext, size_t size,
uint32_t iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *key,
- struct GNUNET_CADET_Hash *hmac)
+ struct GNUNET_ShortHashCode *hmac)
{
static const char ctx[] = "cadet authentication key";
struct GNUNET_CRYPTO_AuthKey auth_key;
const struct GNUNET_CADET_Encrypted *src, size_t size)
{
struct CadetTunnelSkippedKey *key;
- struct GNUNET_CADET_Hash *hmac;
+ struct GNUNET_ShortHashCode *hmac;
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
struct GNUNET_CADET_Encrypted plaintext_header;
struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK;
size_t size)
{
struct CadetTunnelAxolotl *ax;
- struct GNUNET_CADET_Hash msg_hmac;
+ struct GNUNET_ShortHashCode msg_hmac;
struct GNUNET_HashCode hmac;
struct GNUNET_CADET_Encrypted plaintext_header;
uint32_t Np;
"Sending message of type %s with PID %u and CID %s\n",
GC_m2s (type),
htonl (ax_msg->pid),
- GC_h2s (&ax_msg->cid.connection_of_tunnel));
+ GNUNET_sh2s (&ax_msg->cid.connection_of_tunnel));
if (NULL == cont)
{
*/
struct GNUNET_CADET_Port;
-/**
- * Hash to be used in Cadet communication. Only 256 bits needed,
- * instead of the 512 from `struct GNUNET_HashCode`.
- */
-struct GNUNET_CADET_Hash
-{
- unsigned char bits[256 / 8];
-};
-
/**
* Channel options. Second line indicates filed in the
struct GNUNET_CADET_Port *
GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
const struct GNUNET_HashCode *port,
- GNUNET_CADET_InboundChannelNotificationHandler
- new_channel,
+ GNUNET_CADET_InboundChannelNotificationHandler new_channel,
void *new_channel_cls);
/**
*/
struct GNUNET_CADET_ConnectionTunnelIdentifier
{
- struct GNUNET_CADET_Hash connection_of_tunnel;
+ struct GNUNET_ShortHashCode connection_of_tunnel;
};
void *logger_cls);
+/**
+ * @ingroup logging
+ * Convert a short hash value to a string (for printing debug messages).
+ * This is one of the very few calls in the entire API that is
+ * NOT reentrant!
+ *
+ * @param shc the hash code
+ * @return string
+ */
+const char *
+GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc);
+
+
/**
* @ingroup logging
* Convert a hash value to a string (for printing debug messages).
/**
* @ingroup logging
* Use this for fatal errors that cannot be handled
- *
+ *
* @param cond Condition to evaluate
* @param comp Component string to use for logging
*/
#endif
#endif
-/**
- * @brief A 512-bit hashcode
- */
-struct GNUNET_HashCode;
-
-/**
- * The identity of the host (wraps the signing key of the peer).
- */
-struct GNUNET_PeerIdentity;
-
-#include "gnunet_common.h"
-#include <gcrypt.h>
-
-
/**
* @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512.
*/
};
+/**
+ * The identity of the host (wraps the signing key of the peer).
+ */
+struct GNUNET_PeerIdentity;
+
+#include "gnunet_common.h"
+#include <gcrypt.h>
+
+
/**
* Maximum length of an ECC signature.
* Note: round up to multiple of 8 minus 2 for alignment.
}
+/**
+ * @ingroup logging
+ * Convert a short hash value to a string (for printing debug messages).
+ * This is one of the very few calls in the entire API that is
+ * NOT reentrant!
+ *
+ * @param shc the hash code
+ * @return string
+ */
+const char *
+GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc)
+{
+ static char buf[32];
+
+ GNUNET_STRINGS_data_to_string (shc,
+ sizeof (*shc),
+ buf,
+ sizeof (buf));
+ buf[6] = '\0';
+ return (const char *) buf;
+}
+
+
/**
* Convert a hash to a string (for printing debug messages).
* This is one of the very few calls in the entire API that is