diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-17 17:18:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-17 17:18:53 +0100 |
commit | f9b01d9c8eeac932db6357426f8a70bf525a4e07 (patch) | |
tree | f3023b6cfe959a38ed5d9ab131fc8e1c62d136ea /src | |
parent | 100e16ba31dac7138413bda3389d30b3575a8b8e (diff) | |
download | gnunet-f9b01d9c8eeac932db6357426f8a70bf525a4e07.tar.gz gnunet-f9b01d9c8eeac932db6357426f8a70bf525a4e07.zip |
use new shortmap to simplify CADET logic a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/cadet.h | 25 | ||||
-rw-r--r-- | src/cadet/cadet_common.c | 22 | ||||
-rw-r--r-- | src/cadet/cadet_protocol.h | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-cadet.c | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new.c | 15 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new.h | 5 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_connection.c | 49 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_connection.h | 22 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_core.c | 62 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_peer.c | 28 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_tunnels.c | 6 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 80 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.h | 11 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_local.c | 4 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.c | 53 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnel.c | 8 | ||||
-rw-r--r-- | src/include/gnunet_cadet_service.h | 14 | ||||
-rw-r--r-- | src/include/gnunet_common.h | 15 | ||||
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 23 | ||||
-rw-r--r-- | src/util/common_logging.c | 23 |
20 files changed, 187 insertions, 282 deletions
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h index 163734c06..df8803662 100644 --- a/src/cadet/cadet.h +++ b/src/cadet/cadet.h | |||
@@ -376,26 +376,6 @@ GC_min_pid (uint32_t a, uint32_t b); | |||
376 | 376 | ||
377 | 377 | ||
378 | /** | 378 | /** |
379 | * Convert a 256 bit CadetHash into a 512 HashCode to use in GNUNET_h2s, | ||
380 | * multihashmap, and other HashCode-based functions. | ||
381 | * | ||
382 | * @param id A 256 bit hash to expand. | ||
383 | * | ||
384 | * @return A HashCode containing the original 256 bit hash right-padded with 0. | ||
385 | */ | ||
386 | const struct GNUNET_HashCode * | ||
387 | GC_h2hc (const struct GNUNET_CADET_Hash *id); | ||
388 | |||
389 | |||
390 | /** | ||
391 | * Get a string from a Cadet Hash (256 bits). | ||
392 | * WARNING: Not reentrant (based on GNUNET_h2s). | ||
393 | */ | ||
394 | const char * | ||
395 | GC_h2s (const struct GNUNET_CADET_Hash *id); | ||
396 | |||
397 | |||
398 | /** | ||
399 | * Allocate a string with a hexdump of any binary data. | 379 | * Allocate a string with a hexdump of any binary data. |
400 | * | 380 | * |
401 | * @param bin Arbitrary binary data. | 381 | * @param bin Arbitrary binary data. |
@@ -405,7 +385,10 @@ GC_h2s (const struct GNUNET_CADET_Hash *id); | |||
405 | * @return The size of the output. | 385 | * @return The size of the output. |
406 | */ | 386 | */ |
407 | size_t | 387 | size_t |
408 | GC_bin2s (void *bin, unsigned int len, char **output); | 388 | GC_bin2s (void *bin, |
389 | unsigned int len, | ||
390 | char **output); | ||
391 | |||
409 | 392 | ||
410 | /** | 393 | /** |
411 | * Convert a message type into a string to help debug | 394 | * Convert a message type into a string to help debug |
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c index 20ee7e5c9..9a0c58d48 100644 --- a/src/cadet/cadet_common.c +++ b/src/cadet/cadet_common.c | |||
@@ -86,28 +86,6 @@ GC_min_pid (uint32_t a, uint32_t b) | |||
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
89 | const struct GNUNET_HashCode * | ||
90 | GC_h2hc (const struct GNUNET_CADET_Hash *id) | ||
91 | { | ||
92 | static struct GNUNET_HashCode hc; | ||
93 | GNUNET_memcpy (&hc, id, sizeof (*id)); | ||
94 | |||
95 | return &hc; | ||
96 | } | ||
97 | |||
98 | |||
99 | const char * | ||
100 | GC_h2s (const struct GNUNET_CADET_Hash *id) | ||
101 | { | ||
102 | static char s[53]; | ||
103 | |||
104 | GNUNET_memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52); | ||
105 | s[52] = '\0'; | ||
106 | |||
107 | return s; | ||
108 | } | ||
109 | |||
110 | |||
111 | /** | 89 | /** |
112 | * Allocate a string with a hexdump of any binary data. | 90 | * Allocate a string with a hexdump of any binary data. |
113 | * | 91 | * |
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index e1f768ab7..c63337c95 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h | |||
@@ -290,7 +290,7 @@ struct GNUNET_CADET_Encrypted | |||
290 | * Everything after this value will be encrypted with the header key | 290 | * Everything after this value will be encrypted with the header key |
291 | * and authenticated. | 291 | * and authenticated. |
292 | */ | 292 | */ |
293 | struct GNUNET_CADET_Hash hmac; | 293 | struct GNUNET_ShortHashCode hmac; |
294 | 294 | ||
295 | /**************** AX_HEADER start ****************/ | 295 | /**************** AX_HEADER start ****************/ |
296 | 296 | ||
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index eeef2ff89..72d7bf8a9 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -742,7 +742,7 @@ tunnel_callback (void *cls, | |||
742 | FPRINTF (stdout, "\t\t%X\n", ntohl (channels[i].cn)); | 742 | FPRINTF (stdout, "\t\t%X\n", ntohl (channels[i].cn)); |
743 | FPRINTF (stdout, "\t%u connections\n", n_connections); | 743 | FPRINTF (stdout, "\t%u connections\n", n_connections); |
744 | for (i = 0; i < n_connections; i++) | 744 | for (i = 0; i < n_connections; i++) |
745 | FPRINTF (stdout, "\t\t%s\n", GC_h2s (&connections[i].connection_of_tunnel)); | 745 | FPRINTF (stdout, "\t\t%s\n", GNUNET_sh2s (&connections[i].connection_of_tunnel)); |
746 | FPRINTF (stdout, "\tencryption state: %s\n", enc_2s (estate)); | 746 | FPRINTF (stdout, "\tencryption state: %s\n", enc_2s (estate)); |
747 | FPRINTF (stdout, "\tconnection state: %s\n", conn_2s (cstate)); | 747 | FPRINTF (stdout, "\tconnection state: %s\n", conn_2s (cstate)); |
748 | } | 748 | } |
diff --git a/src/cadet/gnunet-service-cadet-new.c b/src/cadet/gnunet-service-cadet-new.c index ad68f09b1..c8cd2fc63 100644 --- a/src/cadet/gnunet-service-cadet-new.c +++ b/src/cadet/gnunet-service-cadet-new.c | |||
@@ -172,9 +172,10 @@ struct GNUNET_CONTAINER_MultiHashMap *loose_channels; | |||
172 | struct GNUNET_CONTAINER_MultiPeerMap *peers; | 172 | struct GNUNET_CONTAINER_MultiPeerMap *peers; |
173 | 173 | ||
174 | /** | 174 | /** |
175 | * Map from expanded connection hash codes to `struct CadetConnection` objects. | 175 | * Map from `struct GNUNET_CADET_ConnectionTunnelIdentifier` |
176 | * hash codes to `struct CadetConnection` objects. | ||
176 | */ | 177 | */ |
177 | struct GNUNET_CONTAINER_MultiHashMap *connections; | 178 | struct GNUNET_CONTAINER_MultiShortmap *connections; |
178 | 179 | ||
179 | /** | 180 | /** |
180 | * How many messages are needed to trigger an AXOLOTL ratchet advance. | 181 | * How many messages are needed to trigger an AXOLOTL ratchet advance. |
@@ -335,7 +336,7 @@ shutdown_task (void *cls) | |||
335 | } | 336 | } |
336 | if (NULL != connections) | 337 | if (NULL != connections) |
337 | { | 338 | { |
338 | GNUNET_CONTAINER_multihashmap_destroy (connections); | 339 | GNUNET_CONTAINER_multishortmap_destroy (connections); |
339 | connections = NULL; | 340 | connections = NULL; |
340 | } | 341 | } |
341 | if (NULL != ats_ch) | 342 | if (NULL != ats_ch) |
@@ -909,7 +910,7 @@ iter_channel (void *cls, | |||
909 | struct CadetChannel *ch) | 910 | struct CadetChannel *ch) |
910 | { | 911 | { |
911 | struct GNUNET_CADET_LocalInfoTunnel *msg = cls; | 912 | struct GNUNET_CADET_LocalInfoTunnel *msg = cls; |
912 | struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1]; | 913 | struct GNUNET_CADET_ConnectionTunnelIdentifier *h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1]; |
913 | struct GCT_ChannelTunnelNumber *chn | 914 | struct GCT_ChannelTunnelNumber *chn |
914 | = (struct GCT_ChannelTunnelNumber *) &h[msg->connections]; | 915 | = (struct GCT_ChannelTunnelNumber *) &h[msg->connections]; |
915 | 916 | ||
@@ -961,7 +962,7 @@ handle_show_tunnel (void *cls, | |||
961 | ch_n = GCT_count_channels (t); | 962 | ch_n = GCT_count_channels (t); |
962 | c_n = GCT_count_any_connections (t); | 963 | c_n = GCT_count_any_connections (t); |
963 | env = GNUNET_MQ_msg_extra (resp, | 964 | env = GNUNET_MQ_msg_extra (resp, |
964 | c_n * sizeof (struct GNUNET_CADET_Hash) + | 965 | c_n * sizeof (struct GNUNET_CADET_ConnectionTunnelIdentifier) + |
965 | ch_n * sizeof (struct GCT_ChannelTunnelNumber), | 966 | ch_n * sizeof (struct GCT_ChannelTunnelNumber), |
966 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); | 967 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); |
967 | resp->destination = msg->peer; | 968 | resp->destination = msg->peer; |
@@ -1278,8 +1279,8 @@ run (void *cls, | |||
1278 | GNUNET_NO); | 1279 | GNUNET_NO); |
1279 | peers = GNUNET_CONTAINER_multipeermap_create (16, | 1280 | peers = GNUNET_CONTAINER_multipeermap_create (16, |
1280 | GNUNET_YES); | 1281 | GNUNET_YES); |
1281 | connections = GNUNET_CONTAINER_multihashmap_create (256, | 1282 | connections = GNUNET_CONTAINER_multishortmap_create (256, |
1282 | GNUNET_YES); | 1283 | GNUNET_YES); |
1283 | GCH_init (c); | 1284 | GCH_init (c); |
1284 | GCD_init (c); | 1285 | GCD_init (c); |
1285 | GCO_init (c); | 1286 | GCO_init (c); |
diff --git a/src/cadet/gnunet-service-cadet-new.h b/src/cadet/gnunet-service-cadet-new.h index 903ceed94..3258a6666 100644 --- a/src/cadet/gnunet-service-cadet-new.h +++ b/src/cadet/gnunet-service-cadet-new.h | |||
@@ -144,9 +144,10 @@ extern struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; | |||
144 | extern struct GNUNET_CONTAINER_MultiHashMap *open_ports; | 144 | extern struct GNUNET_CONTAINER_MultiHashMap *open_ports; |
145 | 145 | ||
146 | /** | 146 | /** |
147 | * Map from expanded connection hash codes to `struct CadetConnection` objects. | 147 | * Map from `struct GNUNET_CADET_ConnectionTunnelIdentifier` |
148 | * hash codes to `struct CadetConnection` objects. | ||
148 | */ | 149 | */ |
149 | extern struct GNUNET_CONTAINER_MultiHashMap *connections; | 150 | extern struct GNUNET_CONTAINER_MultiShortmap *connections; |
150 | 151 | ||
151 | /** | 152 | /** |
152 | * Map from ports to channels where the ports were closed at the | 153 | * Map from ports to channels where the ports were closed at the |
diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index 761bc403a..6b802b69a 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c | |||
@@ -196,48 +196,15 @@ GCC_destroy (struct CadetConnection *cc) | |||
196 | GCPP_del_connection (cc->path, | 196 | GCPP_del_connection (cc->path, |
197 | cc->off, | 197 | cc->off, |
198 | cc); | 198 | cc); |
199 | GNUNET_assert (GNUNET_YES == | ||
200 | GNUNET_CONTAINER_multishortmap_remove (connections, | ||
201 | &GCC_get_id (cc)->connection_of_tunnel, | ||
202 | cc)); | ||
199 | GNUNET_free (cc); | 203 | GNUNET_free (cc); |
200 | } | 204 | } |
201 | 205 | ||
202 | 206 | ||
203 | /** | 207 | /** |
204 | * Expand the shorter CADET hash to a full GNUnet hash. | ||
205 | * | ||
206 | * @param id hash to expand | ||
207 | * @return expanded hash | ||
208 | * @param deprecated | ||
209 | */ | ||
210 | const struct GNUNET_HashCode * | ||
211 | GCC_h2hc (const struct GNUNET_CADET_Hash *id) | ||
212 | { | ||
213 | static struct GNUNET_HashCode hc; | ||
214 | char *ptr = (char *) &hc; | ||
215 | |||
216 | GNUNET_assert (sizeof (hc) == 2 * sizeof (*id)); | ||
217 | GNUNET_memcpy (ptr, | ||
218 | id, | ||
219 | sizeof (*id)); | ||
220 | GNUNET_memcpy (&ptr[sizeof (*id)], | ||
221 | id, | ||
222 | sizeof (*id)); | ||
223 | return &hc; | ||
224 | } | ||
225 | |||
226 | |||
227 | /** | ||
228 | * Get the connection ID as a full hash. | ||
229 | * | ||
230 | * @param cc Connection to get the ID from. | ||
231 | * @return full hash ID of the connection. | ||
232 | */ | ||
233 | const struct GNUNET_HashCode * | ||
234 | GCC_get_h (const struct CadetConnection *cc) | ||
235 | { | ||
236 | return GCC_h2hc (&cc->cid.connection_of_tunnel); | ||
237 | } | ||
238 | |||
239 | |||
240 | /** | ||
241 | * Return the tunnel associated with this connection. | 208 | * Return the tunnel associated with this connection. |
242 | * | 209 | * |
243 | * @param cc connection to query | 210 | * @param cc connection to query |
@@ -429,10 +396,10 @@ GCC_create (struct CadetPeer *destination, | |||
429 | &cc->cid, | 396 | &cc->cid, |
430 | sizeof (cc->cid)); | 397 | sizeof (cc->cid)); |
431 | GNUNET_assert (GNUNET_OK == | 398 | GNUNET_assert (GNUNET_OK == |
432 | GNUNET_CONTAINER_multihashmap_put (connections, | 399 | GNUNET_CONTAINER_multishortmap_put (connections, |
433 | GCC_get_h (cc), | 400 | &GCC_get_id (cc)->connection_of_tunnel, |
434 | cc, | 401 | cc, |
435 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 402 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
436 | cc->ready_cb = ready_cb; | 403 | cc->ready_cb = ready_cb; |
437 | cc->ready_cb_cls = ready_cb_cls; | 404 | cc->ready_cb_cls = ready_cb_cls; |
438 | cc->path = path; | 405 | cc->path = path; |
diff --git a/src/cadet/gnunet-service-cadet-new_connection.h b/src/cadet/gnunet-service-cadet-new_connection.h index 6ed83575f..515863aad 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.h +++ b/src/cadet/gnunet-service-cadet-new_connection.h | |||
@@ -152,28 +152,6 @@ GCC_get_id (struct CadetConnection *cc); | |||
152 | 152 | ||
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Get the connection ID as a full hash. | ||
156 | * | ||
157 | * @param cc Connection to get the ID from. | ||
158 | * @return full hash ID of the connection. | ||
159 | * @deprecated try to replace use of full hash codes eventually... | ||
160 | */ | ||
161 | const struct GNUNET_HashCode * | ||
162 | GCC_get_h (const struct CadetConnection *cc); | ||
163 | |||
164 | |||
165 | /** | ||
166 | * Expand the shorter CADET hash to a full GNUnet hash. | ||
167 | * | ||
168 | * @param id hash to expand | ||
169 | * @return expanded hash | ||
170 | * @param deprecated | ||
171 | */ | ||
172 | const struct GNUNET_HashCode * | ||
173 | GCC_h2hc (const struct GNUNET_CADET_Hash *id); | ||
174 | |||
175 | |||
176 | /** | ||
177 | * Log connection info. | 155 | * Log connection info. |
178 | * | 156 | * |
179 | * @param cc connection | 157 | * @param cc connection |
diff --git a/src/cadet/gnunet-service-cadet-new_core.c b/src/cadet/gnunet-service-cadet-new_core.c index 8cc6c843e..3980f2e2d 100644 --- a/src/cadet/gnunet-service-cadet-new_core.c +++ b/src/cadet/gnunet-service-cadet-new_core.c | |||
@@ -77,7 +77,7 @@ static struct GNUNET_CORE_Handle *core; | |||
77 | /** | 77 | /** |
78 | * Routes on which this peer is an intermediate. | 78 | * Routes on which this peer is an intermediate. |
79 | */ | 79 | */ |
80 | static struct GNUNET_CONTAINER_MultiHashMap *routes; | 80 | static struct GNUNET_CONTAINER_MultiShortmap *routes; |
81 | 81 | ||
82 | 82 | ||
83 | /** | 83 | /** |
@@ -86,10 +86,10 @@ static struct GNUNET_CONTAINER_MultiHashMap *routes; | |||
86 | * @param cid hash generated from the connection identifier | 86 | * @param cid hash generated from the connection identifier |
87 | */ | 87 | */ |
88 | static struct CadetRoute * | 88 | static struct CadetRoute * |
89 | get_route (const struct GNUNET_HashCode *cid) | 89 | get_route (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) |
90 | { | 90 | { |
91 | return GNUNET_CONTAINER_multihashmap_get (routes, | 91 | return GNUNET_CONTAINER_multishortmap_get (routes, |
92 | cid); | 92 | &cid->connection_of_tunnel); |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
@@ -104,7 +104,7 @@ get_route (const struct GNUNET_HashCode *cid) | |||
104 | */ | 104 | */ |
105 | static void | 105 | static void |
106 | route_message (struct CadetPeer *prev, | 106 | route_message (struct CadetPeer *prev, |
107 | const struct GNUNET_HashCode *cid, /* FIXME: bad type... */ | 107 | const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, |
108 | const struct GNUNET_MessageHeader *msg) | 108 | const struct GNUNET_MessageHeader *msg) |
109 | { | 109 | { |
110 | struct CadetRoute *route; | 110 | struct CadetRoute *route; |
@@ -117,10 +117,7 @@ route_message (struct CadetPeer *prev, | |||
117 | 117 | ||
118 | env = GNUNET_MQ_msg (bm, | 118 | env = GNUNET_MQ_msg (bm, |
119 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); | 119 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); |
120 | /* FIXME: ugly */ | 120 | bm->cid = *cid; |
121 | memcpy (&bm->cid, | ||
122 | cid, | ||
123 | sizeof (bm->cid)); | ||
124 | bm->peer1 = my_full_id; | 121 | bm->peer1 = my_full_id; |
125 | GCP_send (prev, | 122 | GCP_send (prev, |
126 | env); | 123 | env); |
@@ -201,12 +198,11 @@ handle_connection_ack (void *cls, | |||
201 | const struct GNUNET_CADET_ConnectionACK *msg) | 198 | const struct GNUNET_CADET_ConnectionACK *msg) |
202 | { | 199 | { |
203 | struct CadetPeer *peer = cls; | 200 | struct CadetPeer *peer = cls; |
204 | const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel); | ||
205 | struct CadetConnection *cc; | 201 | struct CadetConnection *cc; |
206 | 202 | ||
207 | /* First, check if ACK belongs to a connection that ends here. */ | 203 | /* First, check if ACK belongs to a connection that ends here. */ |
208 | cc = GNUNET_CONTAINER_multihashmap_get (connections, | 204 | cc = GNUNET_CONTAINER_multishortmap_get (connections, |
209 | cid); | 205 | &msg->cid.connection_of_tunnel); |
210 | if (NULL != cc) | 206 | if (NULL != cc) |
211 | { | 207 | { |
212 | /* verify ACK came from the right direction */ | 208 | /* verify ACK came from the right direction */ |
@@ -226,7 +222,7 @@ handle_connection_ack (void *cls, | |||
226 | 222 | ||
227 | /* We're just an intermediary peer, route the message along its path */ | 223 | /* We're just an intermediary peer, route the message along its path */ |
228 | route_message (peer, | 224 | route_message (peer, |
229 | cid, | 225 | &msg->cid, |
230 | &msg->header); | 226 | &msg->header); |
231 | } | 227 | } |
232 | 228 | ||
@@ -243,13 +239,12 @@ handle_broken (void *cls, | |||
243 | const struct GNUNET_CADET_ConnectionBroken *msg) | 239 | const struct GNUNET_CADET_ConnectionBroken *msg) |
244 | { | 240 | { |
245 | struct CadetPeer *peer = cls; | 241 | struct CadetPeer *peer = cls; |
246 | const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel); | ||
247 | struct CadetConnection *cc; | 242 | struct CadetConnection *cc; |
248 | struct CadetRoute *route; | 243 | struct CadetRoute *route; |
249 | 244 | ||
250 | /* First, check if message belongs to a connection that ends here. */ | 245 | /* First, check if message belongs to a connection that ends here. */ |
251 | cc = GNUNET_CONTAINER_multihashmap_get (connections, | 246 | cc = GNUNET_CONTAINER_multishortmap_get (connections, |
252 | cid); | 247 | &msg->cid.connection_of_tunnel); |
253 | if (NULL != cc) | 248 | if (NULL != cc) |
254 | { | 249 | { |
255 | /* verify message came from the right direction */ | 250 | /* verify message came from the right direction */ |
@@ -268,9 +263,9 @@ handle_broken (void *cls, | |||
268 | } | 263 | } |
269 | 264 | ||
270 | /* We're just an intermediary peer, route the message along its path */ | 265 | /* We're just an intermediary peer, route the message along its path */ |
271 | route = get_route (cid); | 266 | route = get_route (&msg->cid); |
272 | route_message (peer, | 267 | route_message (peer, |
273 | cid, | 268 | &msg->cid, |
274 | &msg->header); | 269 | &msg->header); |
275 | destroy_route (route); | 270 | destroy_route (route); |
276 | } | 271 | } |
@@ -287,13 +282,12 @@ handle_destroy (void *cls, | |||
287 | const struct GNUNET_CADET_ConnectionDestroy *msg) | 282 | const struct GNUNET_CADET_ConnectionDestroy *msg) |
288 | { | 283 | { |
289 | struct CadetPeer *peer = cls; | 284 | struct CadetPeer *peer = cls; |
290 | const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel); | ||
291 | struct CadetConnection *cc; | 285 | struct CadetConnection *cc; |
292 | struct CadetRoute *route; | 286 | struct CadetRoute *route; |
293 | 287 | ||
294 | /* First, check if message belongs to a connection that ends here. */ | 288 | /* First, check if message belongs to a connection that ends here. */ |
295 | cc = GNUNET_CONTAINER_multihashmap_get (connections, | 289 | cc = GNUNET_CONTAINER_multishortmap_get (connections, |
296 | cid); | 290 | &msg->cid.connection_of_tunnel); |
297 | if (NULL != cc) | 291 | if (NULL != cc) |
298 | { | 292 | { |
299 | /* verify message came from the right direction */ | 293 | /* verify message came from the right direction */ |
@@ -312,9 +306,9 @@ handle_destroy (void *cls, | |||
312 | } | 306 | } |
313 | 307 | ||
314 | /* We're just an intermediary peer, route the message along its path */ | 308 | /* We're just an intermediary peer, route the message along its path */ |
315 | route = get_route (cid); | 309 | route = get_route (&msg->cid); |
316 | route_message (peer, | 310 | route_message (peer, |
317 | cid, | 311 | &msg->cid, |
318 | &msg->header); | 312 | &msg->header); |
319 | destroy_route (route); | 313 | destroy_route (route); |
320 | } | 314 | } |
@@ -369,12 +363,11 @@ handle_kx (void *cls, | |||
369 | const struct GNUNET_CADET_KX *msg) | 363 | const struct GNUNET_CADET_KX *msg) |
370 | { | 364 | { |
371 | struct CadetPeer *peer = cls; | 365 | struct CadetPeer *peer = cls; |
372 | const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel); | ||
373 | struct CadetConnection *cc; | 366 | struct CadetConnection *cc; |
374 | 367 | ||
375 | /* First, check if message belongs to a connection that ends here. */ | 368 | /* First, check if message belongs to a connection that ends here. */ |
376 | cc = GNUNET_CONTAINER_multihashmap_get (connections, | 369 | cc = GNUNET_CONTAINER_multishortmap_get (connections, |
377 | cid); | 370 | &msg->cid.connection_of_tunnel); |
378 | if (NULL != cc) | 371 | if (NULL != cc) |
379 | { | 372 | { |
380 | /* verify message came from the right direction */ | 373 | /* verify message came from the right direction */ |
@@ -395,7 +388,7 @@ handle_kx (void *cls, | |||
395 | 388 | ||
396 | /* We're just an intermediary peer, route the message along its path */ | 389 | /* We're just an intermediary peer, route the message along its path */ |
397 | route_message (peer, | 390 | route_message (peer, |
398 | cid, | 391 | &msg->cid, |
399 | &msg->header); | 392 | &msg->header); |
400 | } | 393 | } |
401 | 394 | ||
@@ -427,12 +420,11 @@ handle_encrypted (void *cls, | |||
427 | const struct GNUNET_CADET_Encrypted *msg) | 420 | const struct GNUNET_CADET_Encrypted *msg) |
428 | { | 421 | { |
429 | struct CadetPeer *peer = cls; | 422 | struct CadetPeer *peer = cls; |
430 | const struct GNUNET_HashCode *cid = GCC_h2hc (&msg->cid.connection_of_tunnel); | ||
431 | struct CadetConnection *cc; | 423 | struct CadetConnection *cc; |
432 | 424 | ||
433 | /* First, check if message belongs to a connection that ends here. */ | 425 | /* First, check if message belongs to a connection that ends here. */ |
434 | cc = GNUNET_CONTAINER_multihashmap_get (connections, | 426 | cc = GNUNET_CONTAINER_multishortmap_get (connections, |
435 | cid); | 427 | &msg->cid.connection_of_tunnel); |
436 | if (NULL != cc) | 428 | if (NULL != cc) |
437 | { | 429 | { |
438 | /* verify message came from the right direction */ | 430 | /* verify message came from the right direction */ |
@@ -453,7 +445,7 @@ handle_encrypted (void *cls, | |||
453 | 445 | ||
454 | /* We're just an intermediary peer, route the message along its path */ | 446 | /* We're just an intermediary peer, route the message along its path */ |
455 | route_message (peer, | 447 | route_message (peer, |
456 | cid, | 448 | &msg->cid, |
457 | &msg->header); | 449 | &msg->header); |
458 | } | 450 | } |
459 | 451 | ||
@@ -572,8 +564,8 @@ GCO_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
572 | GNUNET_MQ_handler_end () | 564 | GNUNET_MQ_handler_end () |
573 | }; | 565 | }; |
574 | 566 | ||
575 | routes = GNUNET_CONTAINER_multihashmap_create (1024, | 567 | routes = GNUNET_CONTAINER_multishortmap_create (1024, |
576 | GNUNET_NO); | 568 | GNUNET_NO); |
577 | core = GNUNET_CORE_connect (c, | 569 | core = GNUNET_CORE_connect (c, |
578 | NULL, | 570 | NULL, |
579 | &core_init_cb, | 571 | &core_init_cb, |
@@ -594,8 +586,8 @@ GCO_shutdown () | |||
594 | GNUNET_CORE_disconnect (core); | 586 | GNUNET_CORE_disconnect (core); |
595 | core = NULL; | 587 | core = NULL; |
596 | } | 588 | } |
597 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (routes)); | 589 | GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (routes)); |
598 | GNUNET_CONTAINER_multihashmap_destroy (routes); | 590 | GNUNET_CONTAINER_multishortmap_destroy (routes); |
599 | } | 591 | } |
600 | 592 | ||
601 | /* end of gnunet-cadet-service_core.c */ | 593 | /* end of gnunet-cadet-service_core.c */ |
diff --git a/src/cadet/gnunet-service-cadet-new_peer.c b/src/cadet/gnunet-service-cadet-new_peer.c index 5c3e6cf17..55a03a206 100644 --- a/src/cadet/gnunet-service-cadet-new_peer.c +++ b/src/cadet/gnunet-service-cadet-new_peer.c | |||
@@ -155,7 +155,7 @@ struct CadetPeer | |||
155 | /** | 155 | /** |
156 | * Connections that go through this peer; indexed by tid. | 156 | * Connections that go through this peer; indexed by tid. |
157 | */ | 157 | */ |
158 | struct GNUNET_CONTAINER_MultiHashMap *connections; | 158 | struct GNUNET_CONTAINER_MultiShortmap *connections; |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * Handle for core transmissions. | 161 | * Handle for core transmissions. |
@@ -227,7 +227,7 @@ destroy_peer (void *cls) | |||
227 | GNUNET_assert (NULL == cp->t); | 227 | GNUNET_assert (NULL == cp->t); |
228 | GNUNET_assert (NULL == cp->core_mq); | 228 | GNUNET_assert (NULL == cp->core_mq); |
229 | GNUNET_assert (0 == cp->path_dll_length); | 229 | GNUNET_assert (0 == cp->path_dll_length); |
230 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (cp->connections)); | 230 | GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections)); |
231 | GNUNET_assert (GNUNET_YES == | 231 | GNUNET_assert (GNUNET_YES == |
232 | GNUNET_CONTAINER_multipeermap_remove (peers, | 232 | GNUNET_CONTAINER_multipeermap_remove (peers, |
233 | &cp->pid, | 233 | &cp->pid, |
@@ -252,7 +252,7 @@ destroy_peer (void *cls) | |||
252 | GNUNET_ATS_connectivity_suggest_cancel (cp->connectivity_suggestion); | 252 | GNUNET_ATS_connectivity_suggest_cancel (cp->connectivity_suggestion); |
253 | cp->connectivity_suggestion = NULL; | 253 | cp->connectivity_suggestion = NULL; |
254 | } | 254 | } |
255 | GNUNET_CONTAINER_multihashmap_destroy (cp->connections); | 255 | GNUNET_CONTAINER_multishortmap_destroy (cp->connections); |
256 | GNUNET_CONTAINER_heap_destroy (cp->path_heap); | 256 | GNUNET_CONTAINER_heap_destroy (cp->path_heap); |
257 | GNUNET_free_non_null (cp->hello); | 257 | GNUNET_free_non_null (cp->hello); |
258 | /* Peer should not be freed if paths exist; if there are no paths, | 258 | /* Peer should not be freed if paths exist; if there are no paths, |
@@ -385,7 +385,7 @@ consider_peer_destroy (struct CadetPeer *cp) | |||
385 | return; /* still relevant! */ | 385 | return; /* still relevant! */ |
386 | if (NULL != cp->core_mq) | 386 | if (NULL != cp->core_mq) |
387 | return; /* still relevant! */ | 387 | return; /* still relevant! */ |
388 | if (0 != GNUNET_CONTAINER_multihashmap_size (cp->connections)) | 388 | if (0 != GNUNET_CONTAINER_multishortmap_size (cp->connections)) |
389 | return; /* still relevant! */ | 389 | return; /* still relevant! */ |
390 | if (0 < GNUNET_CONTAINER_heap_get_size (cp->path_heap)) | 390 | if (0 < GNUNET_CONTAINER_heap_get_size (cp->path_heap)) |
391 | { | 391 | { |
@@ -563,10 +563,10 @@ GCP_add_connection (struct CadetPeer *cp, | |||
563 | struct CadetConnection *cc) | 563 | struct CadetConnection *cc) |
564 | { | 564 | { |
565 | GNUNET_assert (GNUNET_OK == | 565 | GNUNET_assert (GNUNET_OK == |
566 | GNUNET_CONTAINER_multihashmap_put (cp->connections, | 566 | GNUNET_CONTAINER_multishortmap_put (cp->connections, |
567 | GCC_get_h (cc), | 567 | &GCC_get_id (cc)->connection_of_tunnel, |
568 | cc, | 568 | cc, |
569 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 569 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
570 | } | 570 | } |
571 | 571 | ||
572 | 572 | ||
@@ -581,9 +581,9 @@ GCP_remove_connection (struct CadetPeer *cp, | |||
581 | struct CadetConnection *cc) | 581 | struct CadetConnection *cc) |
582 | { | 582 | { |
583 | GNUNET_assert (GNUNET_YES == | 583 | GNUNET_assert (GNUNET_YES == |
584 | GNUNET_CONTAINER_multihashmap_remove (cp->connections, | 584 | GNUNET_CONTAINER_multishortmap_remove (cp->connections, |
585 | GCC_get_h (cc), | 585 | &GCC_get_id (cc)->connection_of_tunnel, |
586 | cc)); | 586 | cc)); |
587 | } | 587 | } |
588 | 588 | ||
589 | 589 | ||
@@ -603,7 +603,7 @@ consider_peer_activate (struct CadetPeer *cp) | |||
603 | GNUNET_SCHEDULER_cancel (cp->destroy_task); | 603 | GNUNET_SCHEDULER_cancel (cp->destroy_task); |
604 | cp->destroy_task = NULL; | 604 | cp->destroy_task = NULL; |
605 | } | 605 | } |
606 | if ( (0 == GNUNET_CONTAINER_multihashmap_size (cp->connections)) && | 606 | if ( (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections)) && |
607 | (NULL == cp->t) ) | 607 | (NULL == cp->t) ) |
608 | { | 608 | { |
609 | /* We're just on a path or directly connected; don't bother too much */ | 609 | /* We're just on a path or directly connected; don't bother too much */ |
@@ -673,8 +673,8 @@ GCP_get (const struct GNUNET_PeerIdentity *peer_id, | |||
673 | return NULL; | 673 | return NULL; |
674 | cp = GNUNET_new (struct CadetPeer); | 674 | cp = GNUNET_new (struct CadetPeer); |
675 | cp->pid = *peer_id; | 675 | cp->pid = *peer_id; |
676 | cp->connections = GNUNET_CONTAINER_multihashmap_create (32, | 676 | cp->connections = GNUNET_CONTAINER_multishortmap_create (32, |
677 | GNUNET_YES); | 677 | GNUNET_YES); |
678 | cp->path_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 678 | cp->path_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
679 | GNUNET_assert (GNUNET_YES == | 679 | GNUNET_assert (GNUNET_YES == |
680 | GNUNET_CONTAINER_multipeermap_put (peers, | 680 | GNUNET_CONTAINER_multipeermap_put (peers, |
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c index b5a4e0112..01511d65e 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.c +++ b/src/cadet/gnunet-service-cadet-new_tunnels.c | |||
@@ -534,7 +534,7 @@ t_hmac (const void *plaintext, | |||
534 | size_t size, | 534 | size_t size, |
535 | uint32_t iv, | 535 | uint32_t iv, |
536 | const struct GNUNET_CRYPTO_SymmetricSessionKey *key, | 536 | const struct GNUNET_CRYPTO_SymmetricSessionKey *key, |
537 | struct GNUNET_CADET_Hash *hmac) | 537 | struct GNUNET_ShortHashCode *hmac) |
538 | { | 538 | { |
539 | static const char ctx[] = "cadet authentication key"; | 539 | static const char ctx[] = "cadet authentication key"; |
540 | struct GNUNET_CRYPTO_AuthKey auth_key; | 540 | struct GNUNET_CRYPTO_AuthKey auth_key; |
@@ -834,7 +834,7 @@ try_old_ax_keys (struct CadetTunnel *t, | |||
834 | size_t size) | 834 | size_t size) |
835 | { | 835 | { |
836 | struct CadetTunnelSkippedKey *key; | 836 | struct CadetTunnelSkippedKey *key; |
837 | struct GNUNET_CADET_Hash *hmac; | 837 | struct GNUNET_ShortHashCode *hmac; |
838 | struct GNUNET_CRYPTO_SymmetricInitializationVector iv; | 838 | struct GNUNET_CRYPTO_SymmetricInitializationVector iv; |
839 | struct GNUNET_CADET_Encrypted plaintext_header; | 839 | struct GNUNET_CADET_Encrypted plaintext_header; |
840 | struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK; | 840 | struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK; |
@@ -1012,7 +1012,7 @@ t_ax_decrypt_and_validate (struct CadetTunnel *t, | |||
1012 | size_t size) | 1012 | size_t size) |
1013 | { | 1013 | { |
1014 | struct CadetTunnelAxolotl *ax; | 1014 | struct CadetTunnelAxolotl *ax; |
1015 | struct GNUNET_CADET_Hash msg_hmac; | 1015 | struct GNUNET_ShortHashCode msg_hmac; |
1016 | struct GNUNET_HashCode hmac; | 1016 | struct GNUNET_HashCode hmac; |
1017 | struct GNUNET_CADET_Encrypted plaintext_header; | 1017 | struct GNUNET_CADET_Encrypted plaintext_header; |
1018 | uint32_t Np; | 1018 | uint32_t Np; |
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 2c21a1686..500511ce4 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -322,7 +322,7 @@ extern struct GNUNET_PeerIdentity my_full_id; | |||
322 | /** | 322 | /** |
323 | * Connections known, indexed by cid (CadetConnection). | 323 | * Connections known, indexed by cid (CadetConnection). |
324 | */ | 324 | */ |
325 | static struct GNUNET_CONTAINER_MultiHashMap *connections; | 325 | static struct GNUNET_CONTAINER_MultiShortmap *connections; |
326 | 326 | ||
327 | /** | 327 | /** |
328 | * How many connections are we willing to maintain. | 328 | * How many connections are we willing to maintain. |
@@ -475,7 +475,8 @@ fc_init (struct CadetFlowControl *fc) | |||
475 | static struct CadetConnection * | 475 | static struct CadetConnection * |
476 | connection_get (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) | 476 | connection_get (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) |
477 | { | 477 | { |
478 | return GNUNET_CONTAINER_multihashmap_get (connections, GC_h2hc (&cid->connection_of_tunnel)); | 478 | return GNUNET_CONTAINER_multishortmap_get (connections, |
479 | &cid->connection_of_tunnel); | ||
479 | } | 480 | } |
480 | 481 | ||
481 | 482 | ||
@@ -912,7 +913,7 @@ check_neighbours (const struct CadetConnection *c) | |||
912 | */ | 913 | */ |
913 | static int | 914 | static int |
914 | check_connection (void *cls, | 915 | check_connection (void *cls, |
915 | const struct GNUNET_HashCode *key, | 916 | const struct GNUNET_ShortHashCode *key, |
916 | void *value) | 917 | void *value) |
917 | { | 918 | { |
918 | struct CadetConnection *c = value; | 919 | struct CadetConnection *c = value; |
@@ -932,9 +933,9 @@ GCC_check_connections () | |||
932 | return; | 933 | return; |
933 | if (NULL == connections) | 934 | if (NULL == connections) |
934 | return; | 935 | return; |
935 | GNUNET_CONTAINER_multihashmap_iterate (connections, | 936 | GNUNET_CONTAINER_multishortmap_iterate (connections, |
936 | &check_connection, | 937 | &check_connection, |
937 | NULL); | 938 | NULL); |
938 | } | 939 | } |
939 | 940 | ||
940 | 941 | ||
@@ -1109,7 +1110,7 @@ send_broken_unknown (const struct GNUNET_CADET_ConnectionTunnelIdentifier *conne | |||
1109 | 1110 | ||
1110 | GCC_check_connections (); | 1111 | GCC_check_connections (); |
1111 | LOG (GNUNET_ERROR_TYPE_INFO, "--> BROKEN on unknown connection %s\n", | 1112 | LOG (GNUNET_ERROR_TYPE_INFO, "--> BROKEN on unknown connection %s\n", |
1112 | GNUNET_h2s (GC_h2hc (&connection_id->connection_of_tunnel))); | 1113 | GNUNET_sh2s (&connection_id->connection_of_tunnel)); |
1113 | 1114 | ||
1114 | msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken)); | 1115 | msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken)); |
1115 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); | 1116 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); |
@@ -1855,9 +1856,13 @@ log_message (const struct GNUNET_MessageHeader *message, | |||
1855 | default: | 1856 | default: |
1856 | arrow = "--"; | 1857 | arrow = "--"; |
1857 | } | 1858 | } |
1858 | LOG (GNUNET_ERROR_TYPE_INFO, "<%s %s on conn %s from %s, %6u bytes\n", | 1859 | LOG (GNUNET_ERROR_TYPE_INFO, |
1859 | arrow, GC_m2s (type), GNUNET_h2s (GC_h2hc (&conn_id->connection_of_tunnel)), | 1860 | "<%s %s on conn %s from %s, %6u bytes\n", |
1860 | GCP_2s(peer), (unsigned int) size); | 1861 | arrow, |
1862 | GC_m2s (type), | ||
1863 | GNUNET_sh2s (&conn_id->connection_of_tunnel), | ||
1864 | GCP_2s(peer), | ||
1865 | (unsigned int) size); | ||
1861 | } | 1866 | } |
1862 | 1867 | ||
1863 | /******************************************************************************/ | 1868 | /******************************************************************************/ |
@@ -2354,7 +2359,7 @@ GCC_handle_poll (struct CadetPeer *peer, | |||
2354 | GNUNET_NO); | 2359 | GNUNET_NO); |
2355 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2360 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2356 | "POLL message on unknown connection %s!\n", | 2361 | "POLL message on unknown connection %s!\n", |
2357 | GNUNET_h2s (GC_h2hc (&msg->cid.connection_of_tunnel))); | 2362 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
2358 | send_broken_unknown (&msg->cid, | 2363 | send_broken_unknown (&msg->cid, |
2359 | &my_full_id, | 2364 | &my_full_id, |
2360 | NULL, | 2365 | NULL, |
@@ -2428,7 +2433,7 @@ check_message (const struct GNUNET_MessageHeader *message, | |||
2428 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2433 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2429 | "%s on unknown connection %s\n", | 2434 | "%s on unknown connection %s\n", |
2430 | GC_m2s (ntohs (message->type)), | 2435 | GC_m2s (ntohs (message->type)), |
2431 | GNUNET_h2s (GC_h2hc (&cid->connection_of_tunnel))); | 2436 | GNUNET_sh2s (&cid->connection_of_tunnel)); |
2432 | GNUNET_break_op (0); | 2437 | GNUNET_break_op (0); |
2433 | send_broken_unknown (cid, | 2438 | send_broken_unknown (cid, |
2434 | &my_full_id, | 2439 | &my_full_id, |
@@ -2680,7 +2685,8 @@ GCC_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
2680 | } | 2685 | } |
2681 | create_connection_time = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, | 2686 | create_connection_time = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, |
2682 | refresh_connection_time); | 2687 | refresh_connection_time); |
2683 | connections = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO); | 2688 | connections = GNUNET_CONTAINER_multishortmap_create (1024, |
2689 | GNUNET_YES); | ||
2684 | } | 2690 | } |
2685 | 2691 | ||
2686 | 2692 | ||
@@ -2695,7 +2701,7 @@ GCC_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
2695 | */ | 2701 | */ |
2696 | static int | 2702 | static int |
2697 | shutdown_iterator (void *cls, | 2703 | shutdown_iterator (void *cls, |
2698 | const struct GNUNET_HashCode *key, | 2704 | const struct GNUNET_ShortHashCode *key, |
2699 | void *value) | 2705 | void *value) |
2700 | { | 2706 | { |
2701 | struct CadetConnection *c = value; | 2707 | struct CadetConnection *c = value; |
@@ -2714,10 +2720,10 @@ GCC_shutdown (void) | |||
2714 | { | 2720 | { |
2715 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connections\n"); | 2721 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connections\n"); |
2716 | GCC_check_connections (); | 2722 | GCC_check_connections (); |
2717 | GNUNET_CONTAINER_multihashmap_iterate (connections, | 2723 | GNUNET_CONTAINER_multishortmap_iterate (connections, |
2718 | &shutdown_iterator, | 2724 | &shutdown_iterator, |
2719 | NULL); | 2725 | NULL); |
2720 | GNUNET_CONTAINER_multihashmap_destroy (connections); | 2726 | GNUNET_CONTAINER_multishortmap_destroy (connections); |
2721 | connections = NULL; | 2727 | connections = NULL; |
2722 | } | 2728 | } |
2723 | 2729 | ||
@@ -2748,9 +2754,10 @@ GCC_new (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, | |||
2748 | c = GNUNET_new (struct CadetConnection); | 2754 | c = GNUNET_new (struct CadetConnection); |
2749 | c->id = *cid; | 2755 | c->id = *cid; |
2750 | GNUNET_assert (GNUNET_OK == | 2756 | GNUNET_assert (GNUNET_OK == |
2751 | GNUNET_CONTAINER_multihashmap_put (connections, | 2757 | GNUNET_CONTAINER_multishortmap_put (connections, |
2752 | GCC_get_h (c), c, | 2758 | &c->id.connection_of_tunnel, |
2753 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 2759 | c, |
2760 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
2754 | fc_init (&c->fwd_fc); | 2761 | fc_init (&c->fwd_fc); |
2755 | fc_init (&c->bck_fc); | 2762 | fc_init (&c->bck_fc); |
2756 | c->fwd_fc.c = c; | 2763 | c->fwd_fc.c = c; |
@@ -2851,9 +2858,9 @@ GCC_destroy (struct CadetConnection *c) | |||
2851 | if (GNUNET_NO == c->was_removed) | 2858 | if (GNUNET_NO == c->was_removed) |
2852 | { | 2859 | { |
2853 | GNUNET_break (GNUNET_YES == | 2860 | GNUNET_break (GNUNET_YES == |
2854 | GNUNET_CONTAINER_multihashmap_remove (connections, | 2861 | GNUNET_CONTAINER_multishortmap_remove (connections, |
2855 | GCC_get_h (c), | 2862 | &c->id.connection_of_tunnel, |
2856 | c)); | 2863 | c)); |
2857 | } | 2864 | } |
2858 | GNUNET_STATISTICS_update (stats, | 2865 | GNUNET_STATISTICS_update (stats, |
2859 | "# connections", | 2866 | "# connections", |
@@ -2879,20 +2886,6 @@ GCC_get_id (const struct CadetConnection *c) | |||
2879 | 2886 | ||
2880 | 2887 | ||
2881 | /** | 2888 | /** |
2882 | * Get the connection ID. | ||
2883 | * | ||
2884 | * @param c Connection to get the ID from. | ||
2885 | * | ||
2886 | * @return ID of the connection. | ||
2887 | */ | ||
2888 | const struct GNUNET_HashCode * | ||
2889 | GCC_get_h (const struct CadetConnection *c) | ||
2890 | { | ||
2891 | return GC_h2hc (&c->id.connection_of_tunnel); | ||
2892 | } | ||
2893 | |||
2894 | |||
2895 | /** | ||
2896 | * Get the connection path. | 2889 | * Get the connection path. |
2897 | * | 2890 | * |
2898 | * @param c Connection to get the path from. | 2891 | * @param c Connection to get the path from. |
@@ -3092,9 +3085,9 @@ GCC_neighbor_disconnected (struct CadetConnection *c, struct CadetPeer *peer) | |||
3092 | GNUNET_assert (GNUNET_NO == c->was_removed); | 3085 | GNUNET_assert (GNUNET_NO == c->was_removed); |
3093 | c->was_removed = GNUNET_YES; | 3086 | c->was_removed = GNUNET_YES; |
3094 | GNUNET_break (GNUNET_YES == | 3087 | GNUNET_break (GNUNET_YES == |
3095 | GNUNET_CONTAINER_multihashmap_remove (connections, | 3088 | GNUNET_CONTAINER_multishortmap_remove (connections, |
3096 | GCC_get_h (c), | 3089 | &c->id.connection_of_tunnel, |
3097 | c)); | 3090 | c)); |
3098 | /* Cancel queue in the direction that just died. */ | 3091 | /* Cancel queue in the direction that just died. */ |
3099 | connection_cancel_queues (c, ! fwd); | 3092 | connection_cancel_queues (c, ! fwd); |
3100 | GCC_stop_poll (c, ! fwd); | 3093 | GCC_stop_poll (c, ! fwd); |
@@ -3559,10 +3552,11 @@ GCC_2s (const struct CadetConnection *c) | |||
3559 | static char buf[128]; | 3552 | static char buf[128]; |
3560 | 3553 | ||
3561 | SPRINTF (buf, "%s (->%s)", | 3554 | SPRINTF (buf, "%s (->%s)", |
3562 | GNUNET_h2s (GC_h2hc (&GCC_get_id (c)->connection_of_tunnel)), GCT_2s (c->t)); | 3555 | GNUNET_sh2s (&GCC_get_id (c)->connection_of_tunnel), |
3556 | GCT_2s (c->t)); | ||
3563 | return buf; | 3557 | return buf; |
3564 | } | 3558 | } |
3565 | return GNUNET_h2s (GC_h2hc (&c->id.connection_of_tunnel)); | 3559 | return GNUNET_sh2s (&c->id.connection_of_tunnel); |
3566 | } | 3560 | } |
3567 | 3561 | ||
3568 | 3562 | ||
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h index f1eb4d59c..3d3e8adbe 100644 --- a/src/cadet/gnunet-service-cadet_connection.h +++ b/src/cadet/gnunet-service-cadet_connection.h | |||
@@ -305,17 +305,6 @@ GCC_get_id (const struct CadetConnection *c); | |||
305 | 305 | ||
306 | 306 | ||
307 | /** | 307 | /** |
308 | * Get a hash for the connection ID. | ||
309 | * | ||
310 | * @param c Connection to get the hash. | ||
311 | * | ||
312 | * @return Hash expanded from the ID of the connection. | ||
313 | */ | ||
314 | const struct GNUNET_HashCode * | ||
315 | GCC_get_h (const struct CadetConnection *c); | ||
316 | |||
317 | |||
318 | /** | ||
319 | * Get the connection path. | 308 | * Get the connection path. |
320 | * | 309 | * |
321 | * @param c Connection to get the path from. | 310 | * @param c Connection to get the path from. |
diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c index 6e6313902..cea28bcd2 100644 --- a/src/cadet/gnunet-service-cadet_local.c +++ b/src/cadet/gnunet-service-cadet_local.c | |||
@@ -976,7 +976,7 @@ static void | |||
976 | iter_channel (void *cls, struct CadetChannel *ch) | 976 | iter_channel (void *cls, struct CadetChannel *ch) |
977 | { | 977 | { |
978 | struct GNUNET_CADET_LocalInfoTunnel *msg = cls; | 978 | struct GNUNET_CADET_LocalInfoTunnel *msg = cls; |
979 | struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1]; | 979 | struct GNUNET_CADET_ConnectionTunnelIdentifier *h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1]; |
980 | struct GNUNET_CADET_ChannelNumber *chn = (struct GNUNET_CADET_ChannelNumber *) &h[msg->connections]; | 980 | struct GNUNET_CADET_ChannelNumber *chn = (struct GNUNET_CADET_ChannelNumber *) &h[msg->connections]; |
981 | 981 | ||
982 | chn[msg->channels] = GCCH_get_id (ch); | 982 | chn[msg->channels] = GCCH_get_id (ch); |
@@ -1044,7 +1044,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | |||
1044 | c_n = GCT_count_any_connections (t); | 1044 | c_n = GCT_count_any_connections (t); |
1045 | 1045 | ||
1046 | size = sizeof (struct GNUNET_CADET_LocalInfoTunnel); | 1046 | size = sizeof (struct GNUNET_CADET_LocalInfoTunnel); |
1047 | size += c_n * sizeof (struct GNUNET_CADET_Hash); | 1047 | size += c_n * sizeof (struct GNUNET_CADET_ConnectionTunnelIdentifier); |
1048 | size += ch_n * sizeof (struct GNUNET_CADET_ChannelNumber); | 1048 | size += ch_n * sizeof (struct GNUNET_CADET_ChannelNumber); |
1049 | 1049 | ||
1050 | resp = GNUNET_malloc (size); | 1050 | resp = GNUNET_malloc (size); |
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index b2ad1124c..a3defb87e 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -165,7 +165,7 @@ struct CadetPeer | |||
165 | /** | 165 | /** |
166 | * Connections that go through this peer; indexed by tid. | 166 | * Connections that go through this peer; indexed by tid. |
167 | */ | 167 | */ |
168 | struct GNUNET_CONTAINER_MultiHashMap *connections; | 168 | struct GNUNET_CONTAINER_MultiShortmap *connections; |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Handle for core transmissions. | 171 | * Handle for core transmissions. |
@@ -268,7 +268,7 @@ static int in_shutdown; | |||
268 | */ | 268 | */ |
269 | static int | 269 | static int |
270 | notify_broken (void *cls, | 270 | notify_broken (void *cls, |
271 | const struct GNUNET_HashCode *key, | 271 | const struct GNUNET_ShortHashCode *key, |
272 | void *value) | 272 | void *value) |
273 | { | 273 | { |
274 | struct CadetPeer *peer = cls; | 274 | struct CadetPeer *peer = cls; |
@@ -373,7 +373,8 @@ core_connect_handler (void *cls, | |||
373 | 373 | ||
374 | /* Create the connections hashmap */ | 374 | /* Create the connections hashmap */ |
375 | GNUNET_assert (NULL == neighbor->connections); | 375 | GNUNET_assert (NULL == neighbor->connections); |
376 | neighbor->connections = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); | 376 | neighbor->connections = GNUNET_CONTAINER_multishortmap_create (16, |
377 | GNUNET_YES); | ||
377 | GNUNET_STATISTICS_update (stats, | 378 | GNUNET_STATISTICS_update (stats, |
378 | "# peers", | 379 | "# peers", |
379 | 1, | 380 | 1, |
@@ -425,11 +426,11 @@ core_disconnect_handler (void *cls, | |||
425 | direct_path = pop_direct_path (p); | 426 | direct_path = pop_direct_path (p); |
426 | if (NULL != p->connections) | 427 | if (NULL != p->connections) |
427 | { | 428 | { |
428 | GNUNET_CONTAINER_multihashmap_iterate (p->connections, | 429 | GNUNET_CONTAINER_multishortmap_iterate (p->connections, |
429 | ¬ify_broken, | 430 | ¬ify_broken, |
430 | p); | 431 | p); |
431 | GNUNET_CONTAINER_multihashmap_destroy (p->connections); | 432 | GNUNET_CONTAINER_multishortmap_destroy (p->connections); |
432 | p->connections = NULL; | 433 | p->connections = NULL; |
433 | } | 434 | } |
434 | GNUNET_STATISTICS_update (stats, | 435 | GNUNET_STATISTICS_update (stats, |
435 | "# peers", | 436 | "# peers", |
@@ -800,8 +801,8 @@ peer_destroy (struct CadetPeer *peer) | |||
800 | GCT_destroy_empty (peer->tunnel); | 801 | GCT_destroy_empty (peer->tunnel); |
801 | if (NULL != peer->connections) | 802 | if (NULL != peer->connections) |
802 | { | 803 | { |
803 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 804 | GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (peer->connections)); |
804 | GNUNET_CONTAINER_multihashmap_destroy (peer->connections); | 805 | GNUNET_CONTAINER_multishortmap_destroy (peer->connections); |
805 | peer->connections = NULL; | 806 | peer->connections = NULL; |
806 | } | 807 | } |
807 | if (NULL != peer->hello_offer) | 808 | if (NULL != peer->hello_offer) |
@@ -1574,14 +1575,14 @@ GCP_add_connection (struct CadetPeer *peer, | |||
1574 | GCP_2s (peer)); | 1575 | GCP_2s (peer)); |
1575 | GNUNET_assert (NULL != peer->connections); | 1576 | GNUNET_assert (NULL != peer->connections); |
1576 | GNUNET_assert (GNUNET_OK == | 1577 | GNUNET_assert (GNUNET_OK == |
1577 | GNUNET_CONTAINER_multihashmap_put (peer->connections, | 1578 | GNUNET_CONTAINER_multishortmap_put (peer->connections, |
1578 | GCC_get_h (c), | 1579 | &GCC_get_id (c)->connection_of_tunnel, |
1579 | c, | 1580 | c, |
1580 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1581 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1581 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1582 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1582 | "Peer %s has now %u connections.\n", | 1583 | "Peer %s has now %u connections.\n", |
1583 | GCP_2s (peer), | 1584 | GCP_2s (peer), |
1584 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 1585 | GNUNET_CONTAINER_multishortmap_size (peer->connections)); |
1585 | } | 1586 | } |
1586 | 1587 | ||
1587 | 1588 | ||
@@ -1792,13 +1793,13 @@ void | |||
1792 | GCP_check_connection (const struct CadetPeer *peer, | 1793 | GCP_check_connection (const struct CadetPeer *peer, |
1793 | const struct CadetConnection *c) | 1794 | const struct CadetConnection *c) |
1794 | { | 1795 | { |
1795 | GNUNET_assert (NULL != peer); | 1796 | GNUNET_assert (NULL != peer); |
1796 | GNUNET_assert (NULL != peer->connections); | 1797 | GNUNET_assert (NULL != peer->connections); |
1797 | return; | 1798 | return; // ???? |
1798 | GNUNET_assert (GNUNET_YES == | 1799 | GNUNET_assert (GNUNET_YES == |
1799 | GNUNET_CONTAINER_multihashmap_contains_value (peer->connections, | 1800 | GNUNET_CONTAINER_multishortmap_contains_value (peer->connections, |
1800 | GCC_get_h (c), | 1801 | &GCC_get_id (c)->connection_of_tunnel, |
1801 | c)); | 1802 | c)); |
1802 | } | 1803 | } |
1803 | 1804 | ||
1804 | 1805 | ||
@@ -1822,13 +1823,13 @@ GCP_remove_connection (struct CadetPeer *peer, | |||
1822 | (NULL == peer->connections) ) | 1823 | (NULL == peer->connections) ) |
1823 | return; | 1824 | return; |
1824 | GNUNET_assert (GNUNET_YES == | 1825 | GNUNET_assert (GNUNET_YES == |
1825 | GNUNET_CONTAINER_multihashmap_remove (peer->connections, | 1826 | GNUNET_CONTAINER_multishortmap_remove (peer->connections, |
1826 | GCC_get_h (c), | 1827 | &GCC_get_id (c)->connection_of_tunnel, |
1827 | c)); | 1828 | c)); |
1828 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1829 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1829 | "Peer %s remains with %u connections.\n", | 1830 | "Peer %s remains with %u connections.\n", |
1830 | GCP_2s (peer), | 1831 | GCP_2s (peer), |
1831 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 1832 | GNUNET_CONTAINER_multishortmap_size (peer->connections)); |
1832 | } | 1833 | } |
1833 | 1834 | ||
1834 | 1835 | ||
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index 29087dba4..09e91386e 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c | |||
@@ -649,7 +649,7 @@ new_ephemeral (struct CadetTunnel *t) | |||
649 | static void | 649 | static void |
650 | t_hmac (const void *plaintext, size_t size, | 650 | t_hmac (const void *plaintext, size_t size, |
651 | uint32_t iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *key, | 651 | uint32_t iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *key, |
652 | struct GNUNET_CADET_Hash *hmac) | 652 | struct GNUNET_ShortHashCode *hmac) |
653 | { | 653 | { |
654 | static const char ctx[] = "cadet authentication key"; | 654 | static const char ctx[] = "cadet authentication key"; |
655 | struct GNUNET_CRYPTO_AuthKey auth_key; | 655 | struct GNUNET_CRYPTO_AuthKey auth_key; |
@@ -916,7 +916,7 @@ try_old_ax_keys (struct CadetTunnel *t, void *dst, | |||
916 | const struct GNUNET_CADET_Encrypted *src, size_t size) | 916 | const struct GNUNET_CADET_Encrypted *src, size_t size) |
917 | { | 917 | { |
918 | struct CadetTunnelSkippedKey *key; | 918 | struct CadetTunnelSkippedKey *key; |
919 | struct GNUNET_CADET_Hash *hmac; | 919 | struct GNUNET_ShortHashCode *hmac; |
920 | struct GNUNET_CRYPTO_SymmetricInitializationVector iv; | 920 | struct GNUNET_CRYPTO_SymmetricInitializationVector iv; |
921 | struct GNUNET_CADET_Encrypted plaintext_header; | 921 | struct GNUNET_CADET_Encrypted plaintext_header; |
922 | struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK; | 922 | struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK; |
@@ -1096,7 +1096,7 @@ t_ax_decrypt_and_validate (struct CadetTunnel *t, void *dst, | |||
1096 | size_t size) | 1096 | size_t size) |
1097 | { | 1097 | { |
1098 | struct CadetTunnelAxolotl *ax; | 1098 | struct CadetTunnelAxolotl *ax; |
1099 | struct GNUNET_CADET_Hash msg_hmac; | 1099 | struct GNUNET_ShortHashCode msg_hmac; |
1100 | struct GNUNET_HashCode hmac; | 1100 | struct GNUNET_HashCode hmac; |
1101 | struct GNUNET_CADET_Encrypted plaintext_header; | 1101 | struct GNUNET_CADET_Encrypted plaintext_header; |
1102 | uint32_t Np; | 1102 | uint32_t Np; |
@@ -1406,7 +1406,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
1406 | "Sending message of type %s with PID %u and CID %s\n", | 1406 | "Sending message of type %s with PID %u and CID %s\n", |
1407 | GC_m2s (type), | 1407 | GC_m2s (type), |
1408 | htonl (ax_msg->pid), | 1408 | htonl (ax_msg->pid), |
1409 | GC_h2s (&ax_msg->cid.connection_of_tunnel)); | 1409 | GNUNET_sh2s (&ax_msg->cid.connection_of_tunnel)); |
1410 | 1410 | ||
1411 | if (NULL == cont) | 1411 | if (NULL == cont) |
1412 | { | 1412 | { |
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h index c6b683370..c17cb983c 100644 --- a/src/include/gnunet_cadet_service.h +++ b/src/include/gnunet_cadet_service.h | |||
@@ -67,15 +67,6 @@ struct GNUNET_CADET_Channel; | |||
67 | */ | 67 | */ |
68 | struct GNUNET_CADET_Port; | 68 | struct GNUNET_CADET_Port; |
69 | 69 | ||
70 | /** | ||
71 | * Hash to be used in Cadet communication. Only 256 bits needed, | ||
72 | * instead of the 512 from `struct GNUNET_HashCode`. | ||
73 | */ | ||
74 | struct GNUNET_CADET_Hash | ||
75 | { | ||
76 | unsigned char bits[256 / 8]; | ||
77 | }; | ||
78 | |||
79 | 70 | ||
80 | /** | 71 | /** |
81 | * Channel options. Second line indicates filed in the | 72 | * Channel options. Second line indicates filed in the |
@@ -255,8 +246,7 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle); | |||
255 | struct GNUNET_CADET_Port * | 246 | struct GNUNET_CADET_Port * |
256 | GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h, | 247 | GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h, |
257 | const struct GNUNET_HashCode *port, | 248 | const struct GNUNET_HashCode *port, |
258 | GNUNET_CADET_InboundChannelNotificationHandler | 249 | GNUNET_CADET_InboundChannelNotificationHandler new_channel, |
259 | new_channel, | ||
260 | void *new_channel_cls); | 250 | void *new_channel_cls); |
261 | 251 | ||
262 | /** | 252 | /** |
@@ -496,7 +486,7 @@ typedef void | |||
496 | */ | 486 | */ |
497 | struct GNUNET_CADET_ConnectionTunnelIdentifier | 487 | struct GNUNET_CADET_ConnectionTunnelIdentifier |
498 | { | 488 | { |
499 | struct GNUNET_CADET_Hash connection_of_tunnel; | 489 | struct GNUNET_ShortHashCode connection_of_tunnel; |
500 | }; | 490 | }; |
501 | 491 | ||
502 | 492 | ||
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 62ae499e2..9ad604711 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -558,6 +558,19 @@ GNUNET_logger_remove (GNUNET_Logger logger, | |||
558 | 558 | ||
559 | /** | 559 | /** |
560 | * @ingroup logging | 560 | * @ingroup logging |
561 | * Convert a short hash value to a string (for printing debug messages). | ||
562 | * This is one of the very few calls in the entire API that is | ||
563 | * NOT reentrant! | ||
564 | * | ||
565 | * @param shc the hash code | ||
566 | * @return string | ||
567 | */ | ||
568 | const char * | ||
569 | GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc); | ||
570 | |||
571 | |||
572 | /** | ||
573 | * @ingroup logging | ||
561 | * Convert a hash value to a string (for printing debug messages). | 574 | * Convert a hash value to a string (for printing debug messages). |
562 | * This is one of the very few calls in the entire API that is | 575 | * This is one of the very few calls in the entire API that is |
563 | * NOT reentrant! | 576 | * NOT reentrant! |
@@ -655,7 +668,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
655 | /** | 668 | /** |
656 | * @ingroup logging | 669 | * @ingroup logging |
657 | * Use this for fatal errors that cannot be handled | 670 | * Use this for fatal errors that cannot be handled |
658 | * | 671 | * |
659 | * @param cond Condition to evaluate | 672 | * @param cond Condition to evaluate |
660 | * @param comp Component string to use for logging | 673 | * @param comp Component string to use for logging |
661 | */ | 674 | */ |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index b6875c5cf..43fd32a58 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -52,20 +52,6 @@ extern "C" | |||
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * @brief A 512-bit hashcode | ||
56 | */ | ||
57 | struct GNUNET_HashCode; | ||
58 | |||
59 | /** | ||
60 | * The identity of the host (wraps the signing key of the peer). | ||
61 | */ | ||
62 | struct GNUNET_PeerIdentity; | ||
63 | |||
64 | #include "gnunet_common.h" | ||
65 | #include <gcrypt.h> | ||
66 | |||
67 | |||
68 | /** | ||
69 | * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512. | 55 | * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512. |
70 | */ | 56 | */ |
71 | struct GNUNET_HashCode | 57 | struct GNUNET_HashCode |
@@ -86,6 +72,15 @@ struct GNUNET_ShortHashCode | |||
86 | 72 | ||
87 | 73 | ||
88 | /** | 74 | /** |
75 | * The identity of the host (wraps the signing key of the peer). | ||
76 | */ | ||
77 | struct GNUNET_PeerIdentity; | ||
78 | |||
79 | #include "gnunet_common.h" | ||
80 | #include <gcrypt.h> | ||
81 | |||
82 | |||
83 | /** | ||
89 | * Maximum length of an ECC signature. | 84 | * Maximum length of an ECC signature. |
90 | * Note: round up to multiple of 8 minus 2 for alignment. | 85 | * Note: round up to multiple of 8 minus 2 for alignment. |
91 | */ | 86 | */ |
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 5989db00c..ce229826e 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -1153,6 +1153,29 @@ GNUNET_h2s (const struct GNUNET_HashCode * hc) | |||
1153 | 1153 | ||
1154 | 1154 | ||
1155 | /** | 1155 | /** |
1156 | * @ingroup logging | ||
1157 | * Convert a short hash value to a string (for printing debug messages). | ||
1158 | * This is one of the very few calls in the entire API that is | ||
1159 | * NOT reentrant! | ||
1160 | * | ||
1161 | * @param shc the hash code | ||
1162 | * @return string | ||
1163 | */ | ||
1164 | const char * | ||
1165 | GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc) | ||
1166 | { | ||
1167 | static char buf[32]; | ||
1168 | |||
1169 | GNUNET_STRINGS_data_to_string (shc, | ||
1170 | sizeof (*shc), | ||
1171 | buf, | ||
1172 | sizeof (buf)); | ||
1173 | buf[6] = '\0'; | ||
1174 | return (const char *) buf; | ||
1175 | } | ||
1176 | |||
1177 | |||
1178 | /** | ||
1156 | * Convert a hash to a string (for printing debug messages). | 1179 | * Convert a hash to a string (for printing debug messages). |
1157 | * This is one of the very few calls in the entire API that is | 1180 | * This is one of the very few calls in the entire API that is |
1158 | * NOT reentrant! | 1181 | * NOT reentrant! |