83ce893dc891df1a4a028b4b332044a53e0b72e9
[oweals/gnunet.git] / src / mesh / mesh_tunnel_tree.c
1 /*
2      This file is part of GNUnet.
3      (C) 2001 - 2011 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file mesh/mesh_tunnel_tree.c
23  * @brief Tunnel tree handling functions
24  * @author Bartlomiej Polot
25  */
26
27 #include "mesh.h"
28 #include "mesh_tunnel_tree.h"
29
30
31 /**
32  * Create a new path
33  *
34  * @param lenght How many hops will the path have.
35  *
36  * @return A newly allocated path with a peer array of the specified length.
37  */
38 struct MeshPeerPath *
39 path_new (unsigned int length)
40 {
41   struct MeshPeerPath *p;
42
43   p = GNUNET_malloc (sizeof(struct MeshPeerPath));
44   if (length > 0)
45   {
46     p->length = length;
47     p->peers = GNUNET_malloc (length * sizeof(GNUNET_PEER_Id));
48   }
49   return p;
50 }
51
52
53 /**
54  * Invert the path
55  *
56  * @param p the path to invert
57  */
58 void
59 path_invert (struct MeshPeerPath *path)
60 {
61   GNUNET_PEER_Id aux;
62   unsigned int i;
63
64   for (i = 0; i < path->length / 2; i++)
65   {
66     aux = path->peers[i];
67     path->peers[i] = path->peers[path->length - i - 1];
68     path->peers[path->length - i - 1] = aux;
69   }
70 }
71
72
73 /**
74  * Duplicate a path, incrementing short peer's rc.
75  *
76  * @param p The path to duplicate.
77  */
78 struct MeshPeerPath *
79 path_duplicate (struct MeshPeerPath *path)
80 {
81   struct MeshPeerPath *aux;
82   unsigned int i;
83
84   aux = path_new(path->length);
85   memcpy (aux->peers, path->peers, path->length * sizeof(GNUNET_PEER_Id));
86   for (i = 0; i < path->length; i++)
87     GNUNET_PEER_change_rc(path->peers[i], 1);
88   return aux;
89 }
90
91
92 /**
93  * Find the first peer whom to send a packet to go down this path
94  *
95  * @param t The tunnel tree to use
96  * @param peer The peerinfo of the peer we are trying to reach
97  *
98  * @return peerinfo of the peer who is the first hop in the tunnel
99  *         NULL on error
100  */
101 struct GNUNET_PeerIdentity *
102 path_get_first_hop (struct MeshTunnelTree *t, GNUNET_PEER_Id peer)
103 {
104   struct GNUNET_PeerIdentity id;
105   struct GNUNET_PeerIdentity *r;
106
107   GNUNET_PEER_resolve (peer, &id);
108   r = GNUNET_CONTAINER_multihashmap_get (t->first_hops, &id.hashPubKey);
109   GNUNET_break (NULL != r);
110
111   return r;
112 }
113
114
115 /**
116  * Get the length of a path
117  *
118  * @param path The path to measure, with the local peer at any point of it
119  *
120  * @return Number of hops to reach destination
121  *         UINT_MAX in case the peer is not in the path
122  */
123 unsigned int
124 path_get_length (struct MeshPeerPath *path)
125 {
126   if (NULL == path)
127     return UINT_MAX;
128   return path->length;
129 }
130
131
132 /**
133  * Get the cost of the path relative to the already built tunnel tree
134  *
135  * @param t The tunnel tree to which compare
136  * @param path The individual path to reach a peer
137  *
138  * @return Number of hops to reach destination, UINT_MAX in case the peer is not
139  * in the path
140  *
141  * TODO: remove dummy implementation, look into the tunnel tree
142  */
143 unsigned int
144 path_get_cost (struct MeshTunnelTree *t, struct MeshPeerPath *path)
145 {
146   return path_get_length (path);
147 }
148
149
150 /**
151  * Destroy the path and free any allocated resources linked to it
152  *
153  * @param p the path to destroy
154  *
155  * @return GNUNET_OK on success
156  */
157 int
158 path_destroy (struct MeshPeerPath *p)
159 {
160   GNUNET_PEER_decrement_rcs (p->peers, p->length);
161   GNUNET_free (p->peers);
162   GNUNET_free (p);
163   return GNUNET_OK;
164 }
165
166
167
168 /**
169  * Allocates and initializes a new node.
170  * Sets ID and parent of the new node and inserts it in the DLL of the parent
171  *
172  * @param parent Node that will be the parent from the new node, NULL for root
173  * @param peer Short Id of the new node
174  *
175  * @return Newly allocated node
176  */
177 static struct MeshTunnelTreeNode *
178 tree_node_new(struct MeshTunnelTreeNode *parent, GNUNET_PEER_Id peer)
179 {
180   struct MeshTunnelTreeNode *node;
181
182   node = GNUNET_malloc(sizeof(struct MeshTunnelTreeNode));
183   node->peer = peer;
184   GNUNET_PEER_change_rc(peer, 1);
185   node->parent = parent;
186   if (NULL != parent)
187     GNUNET_CONTAINER_DLL_insert(parent->children_head,
188                                 parent->children_tail,
189                                 node);
190
191   return node;
192 }
193
194
195 static void
196 tree_node_debug(struct MeshTunnelTreeNode *n, uint16_t level)
197 {
198   struct MeshTunnelTreeNode *c;
199   uint16_t i;
200
201   for (i = 0; i < level; i++)
202     fprintf(stderr, "  ");
203   if (n->status == MESH_PEER_READY)
204     fprintf(stderr, "#");
205   if (n->status == MESH_PEER_SEARCHING)
206     fprintf(stderr, "+");
207   if (n->status == MESH_PEER_RELAY)
208     fprintf(stderr, "-");
209   if (n->status == MESH_PEER_RECONNECTING)
210     fprintf(stderr, "*");
211
212   fprintf(stderr, "%u [%p] ", n->peer, n);
213   if (NULL != n->parent)
214     fprintf(stderr, "(-> %u)\n", n->parent->peer);
215   else
216     fprintf(stderr, "(root)\n");
217   for (c = n->children_head; NULL != c; c = c->next)
218     tree_node_debug(c, level + 1);
219 }
220
221
222 /**
223  * Destroys and frees the node and all children
224  *
225  * @param n Parent node to be destroyed
226  */
227 static void
228 tree_node_destroy (struct MeshTunnelTreeNode *parent)
229 {
230   struct MeshTunnelTreeNode *n;
231   struct MeshTunnelTreeNode *next;
232
233   n = parent->children_head;
234   while (NULL != n)
235   {
236     next = n->next;
237     tree_node_destroy(n);
238     n = next;
239   }
240   GNUNET_PEER_change_rc(parent->peer, -1);
241   if (NULL != parent->parent)
242     GNUNET_CONTAINER_DLL_remove(parent->parent->children_head,
243                                 parent->parent->children_tail,
244                                 parent);
245   GNUNET_free(parent);
246 }
247
248
249
250 /**
251  * Create a new tunnel tree associated to a tunnel
252  *
253  * @param t Tunnel this tree will represent
254  * @param peer A short peer id of the root of the tree
255  *
256  * @return A newly allocated and initialized tunnel tree
257  */
258 struct MeshTunnelTree *
259 tree_new (struct MeshTunnel *t, GNUNET_PEER_Id peer)
260 {
261   struct MeshTunnelTree *tree;
262
263   tree = GNUNET_malloc(sizeof (struct MeshTunnelTree));
264   tree->first_hops = GNUNET_CONTAINER_multihashmap_create(32);
265   tree->root = tree_node_new(NULL, peer);
266   tree->root->status = MESH_PEER_ROOT;
267   tree->t = t;
268   tree->root->t = t;
269
270   return tree;
271 }
272
273
274 /**
275  * Recursively find the given peer in the tree.
276  *
277  * @param t Tunnel where to look for the peer.
278  * @param peer Peer to find
279  *
280  * @return Pointer to the node of the peer. NULL if not found.
281  */
282 struct MeshTunnelTreeNode *
283 tree_find_peer (struct MeshTunnelTreeNode *parent, GNUNET_PEER_Id peer_id)
284 {
285   struct MeshTunnelTreeNode *n;
286   struct MeshTunnelTreeNode *r;
287
288   if (parent->peer == peer_id)
289     return parent;
290   for (n = parent->children_head; NULL != n; n = n->next)
291   {
292     r = tree_find_peer (n, peer_id);
293     if (NULL != r)
294       return r;
295   }
296   return NULL;
297 }
298
299
300 /**
301  * Recusively mark peer and children as disconnected, notify client
302  *
303  * @param tree Tree this node belongs to
304  * @param parent Node to be clean, potentially with children
305  * @param cb Callback to use to notify about disconnected peers.
306  */
307 static void
308 tree_mark_peers_disconnected (struct MeshTunnelTree *tree,
309                               struct MeshTunnelTreeNode *parent,
310                               MeshNodeDisconnectCB cb)
311 {
312   struct GNUNET_PeerIdentity *pi;
313   struct GNUNET_PeerIdentity id;
314   struct MeshTunnelTreeNode *n;
315
316   for (n = parent->children_head; NULL != n; n = n->next)
317   {
318     tree_mark_peers_disconnected (tree, n, cb);
319   }
320   if (MESH_PEER_READY == parent->status && NULL != cb)
321   {
322     cb (parent);
323   }
324   parent->status = MESH_PEER_RECONNECTING;
325
326   /* Remove and free info about first hop */
327   GNUNET_PEER_resolve(parent->peer, &id);
328   pi = GNUNET_CONTAINER_multihashmap_get(tree->first_hops, &id.hashPubKey);
329   GNUNET_CONTAINER_multihashmap_remove_all(tree->first_hops, &id.hashPubKey);
330   if (NULL != pi)
331     GNUNET_free(pi);
332 }
333
334
335 /**
336  * Recusively update the info about what is the first hop to reach the node
337  *
338  * @param tree Tree this nodes belongs to
339  * @param parent Node to be start updating
340  * @param hop If known, ID of the first hop.
341  *            If not known, NULL to find out and pass on children.
342  */
343 void
344 tree_update_first_hops (struct MeshTunnelTree *tree,
345                         struct MeshTunnelTreeNode *parent,
346                         struct GNUNET_PeerIdentity *hop)
347 {
348   struct GNUNET_PeerIdentity pi;
349   struct GNUNET_PeerIdentity *copy;
350   struct GNUNET_PeerIdentity id;
351   struct MeshTunnelTreeNode *n;
352
353   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
354              "tree:   Finding first hop for %u.\n",
355              parent->peer);
356   if (NULL == hop)
357   {
358     struct MeshTunnelTreeNode *aux;
359     struct MeshTunnelTreeNode *old;
360
361     old = parent;
362     aux = old->parent;
363     while (aux != tree->me)
364     {
365       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
366              "tree:   ... its not %u.\n",
367              old->peer);
368       old = aux;
369       aux = aux->parent;
370       GNUNET_assert(NULL != aux);
371     }
372     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
373              "tree:   It's %u!!\n",
374              old->peer);
375     hop = &pi;
376     GNUNET_PEER_resolve(old->peer, hop);
377   }
378   copy = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
379   *copy = *hop;
380   GNUNET_PEER_resolve(parent->peer, &id);
381   GNUNET_CONTAINER_multihashmap_put(tree->first_hops, &id.hashPubKey, copy,
382                                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
383
384   for (n = parent->children_head; NULL != n; n = n->next)
385   {
386     tree_update_first_hops (tree, n, hop);
387   }
388 }
389
390
391 /**
392  * Delete the current path to the peer, including all now unused relays.
393  * The destination peer is NOT destroyed, it is returned in order to either set
394  * a new path to it or destroy it explicitly, taking care of it's child nodes.
395  *
396  * @param t Tunnel tree where to delete the path from.
397  * @param peer Destination peer whose path we want to remove.
398  * @param cb Callback to use to notify about disconnected peers.
399  *
400  * @return pointer to the pathless node.
401  *         NULL when not found
402  */
403 struct MeshTunnelTreeNode *
404 tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer_id,
405                  MeshNodeDisconnectCB cb)
406 {
407   struct MeshTunnelTreeNode *parent;
408   struct MeshTunnelTreeNode *node;
409   struct MeshTunnelTreeNode *n;
410
411   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
412              "tree:   Deleting path to %u.\n", peer_id);
413   if (peer_id == t->root->peer)
414     return NULL;
415
416   for (n = t->disconnected_head; NULL != n; n = n->next)
417   {
418     if (n->peer == peer_id)
419     {
420       /* Was already pathless, waiting for reconnection */
421       GNUNET_CONTAINER_DLL_remove (t->disconnected_head,
422                                    t->disconnected_tail,
423                                    n);
424       return n;
425     }
426   }
427   n = tree_find_peer (t->root, peer_id);
428   if (NULL == n)
429     return NULL;
430   node = n;
431
432   parent = n->parent;
433   GNUNET_CONTAINER_DLL_remove(parent->children_head, parent->children_tail, n);
434   n->parent = NULL;
435
436   while (MESH_PEER_RELAY == parent->status && NULL == parent->children_head)
437   {
438     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
439                "tree:   Deleting node %u.\n",
440                parent->peer);
441     n = parent->parent;
442     tree_node_destroy(parent);
443     parent = n;
444   }
445   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
446              "tree:   Not deleted peer %u.\n",
447              parent->peer);
448
449   tree_mark_peers_disconnected (t, node, cb);
450
451   return node;
452 }
453
454
455 /**
456  * Return a newly allocated individual path to reach a peer from the local peer,
457  * according to the path tree of some tunnel.
458  *
459  * @param t Tunnel from which to read the path tree
460  * @param peer_info Destination peer to whom we want a path
461  *
462  * @return A newly allocated individual path to reach the destination peer.
463  *         Path must be destroyed afterwards.
464  */
465 struct MeshPeerPath *
466 tree_get_path_to_peer(struct MeshTunnelTree *t, GNUNET_PEER_Id peer)
467 {
468   struct MeshTunnelTreeNode *n;
469   struct MeshPeerPath *p;
470   GNUNET_PEER_Id myid = t->me->peer;
471
472   n = tree_find_peer(t->me, peer);
473   p = path_new(0);
474
475   /* Building the path (inverted!) */
476   while (n->peer != myid)
477   {
478     GNUNET_array_append(p->peers, p->length, n->peer);
479     GNUNET_PEER_change_rc(n->peer, 1);
480     n = n->parent;
481     GNUNET_assert(NULL != n);
482   }
483   GNUNET_array_append(p->peers, p->length, myid);
484   GNUNET_PEER_change_rc(myid, 1);
485
486   path_invert(p);
487
488   return p;
489 }
490
491
492
493 /**
494  * Integrate a stand alone path into the tunnel tree.
495  * If the peer toward which the new path is already in the tree, the peer
496  * and its children will be maked as disconnected and the callback
497  * will be called on each one of them. They will be maked as online only after
498  * receiving a PATH ACK for the new path for each one of them, so the caller
499  * should take care of sending a new CREATE PATH message for each disconnected
500  * peer.
501  *
502  * @param t Tunnel where to add the new path.
503  * @param p Path to be integrated.
504  * @param cb Callback to use to notify about peers temporarily disconnecting
505  *
506  * @return GNUNET_OK in case of success.
507  *         GNUNET_SYSERR in case of error.
508  *
509  * TODO: optimize
510  * - go backwards on path looking for each peer in the present tree
511  * - do not disconnect peers until new path is created & connected
512  */
513 int
514 tree_add_path (struct MeshTunnelTree *t,
515                const struct MeshPeerPath *p,
516                MeshNodeDisconnectCB cb)
517 {
518   struct MeshTunnelTreeNode *parent;
519   struct MeshTunnelTreeNode *oldnode;
520   struct MeshTunnelTreeNode *n;
521   struct MeshTunnelTreeNode *c;
522   struct GNUNET_PeerIdentity id;
523   GNUNET_PEER_Id myid;
524   int me;
525   unsigned int i;
526
527   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
528              "tree:   Adding path [%u] towards peer %u.\n",
529              p->length,
530              p->peers[p->length - 1]);
531
532   if (NULL != t->me)
533     myid = t->me->peer;
534   else
535     myid = 0;
536   GNUNET_assert(0 != p->length);
537   parent = n = t->root;
538   if (n->peer != p->peers[0])
539   {
540     GNUNET_break (0);
541     return GNUNET_SYSERR;
542   }
543   if (1 == p->length)
544     return GNUNET_OK;
545   oldnode = tree_del_path (t, p->peers[p->length - 1], cb);
546   /* Look for the first node that is not already present in the tree
547    *
548    * Assuming that the tree is somewhat balanced, O(log n * log N).
549    * - Length of the path is expected to be log N (size of whole network).
550    * - Each level of the tree is expected to have log n children (size of tree).
551    */
552   me = t->root->peer == myid ? 0 : -1;
553   for (i = 1; i < p->length; i++)
554   {
555     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
556              "tree:   Looking for peer %u.\n",
557              p->peers[i]);
558     parent = n;
559     if (p->peers[i] == myid)
560       me = i;
561     for (c = n->children_head; NULL != c; c = c->next)
562     {
563       if (c->peer == p->peers[i])
564       {
565         GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
566              "tree:   Found in children of %u.\n",
567              parent->peer);
568         n = c;
569         break;
570       }
571     }
572     /*  If we couldn't find a child equal to path[i], we have reached the end
573      * of the common path. */
574     if (parent == n)
575       break;
576   }
577   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
578              "tree:   All childen visited.\n");
579   /* Add the rest of the path as a branch from parent. */
580   while (i < p->length)
581   {
582     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
583                "tree:   Adding  peer %u, to %u.\n",
584                p->peers[i],
585                parent->peer);
586
587     if (i == p->length - 1 && NULL != oldnode)
588     {
589       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
590                  "tree:   Putting old node into place.\n");
591       oldnode->parent = parent;
592       GNUNET_CONTAINER_DLL_insert(parent->children_head,
593                                   parent->children_tail,
594                                   oldnode);
595       tree_update_first_hops (t, oldnode, NULL);
596       n = oldnode;
597     }
598     else
599     {
600       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "tree:   Creating new node.\n");
601       n = tree_node_new(parent, p->peers[i]);
602       n->t = t->t;
603       n->status = MESH_PEER_RELAY;
604     }
605     i++;
606     parent = n;
607   }
608   n->status = MESH_PEER_SEARCHING;
609
610   /* Add info about first hop into hashmap. */
611   if (-1 != me && me < p->length - 1)
612   {
613     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
614                 "MESH:   finding first hop (own pos %d/%u)\n",
615                 me, p->length - 1);
616     GNUNET_PEER_resolve (p->peers[me + 1], &id);
617     tree_update_first_hops(t,
618                            tree_find_peer(t->root, p->peers[p->length - 1]),
619                            &id);
620   }
621   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "tree:   New node added.\n");
622   return GNUNET_OK;
623 }
624
625
626 /**
627  * Notifies a tree that a connection it might be using is broken.
628  * Marks all peers down the paths as disconnected and notifies the client.
629  *
630  * @param t Tree to use.
631  * @param p1 Short id of one of the peers (order unimportant)
632  * @param p2 Short id of one of the peers (order unimportant)
633  * @param cb Function to call for every peer that is marked as disconnected.
634  *
635  * @return Short ID of the first disconnected peer in the tree.
636  */
637 GNUNET_PEER_Id
638 tree_notify_connection_broken (struct MeshTunnelTree *t,
639                                GNUNET_PEER_Id p1,
640                                GNUNET_PEER_Id p2,
641                                MeshNodeDisconnectCB cb)
642 {
643   struct MeshTunnelTreeNode *n;
644   struct MeshTunnelTreeNode *c;
645
646   n = tree_find_peer(t->me, p1);
647   if (NULL == n)
648     return 0;
649   if (NULL != n->parent && n->parent->peer == p2)
650   {
651     tree_mark_peers_disconnected(t, n, cb);
652     GNUNET_CONTAINER_DLL_remove(n->parent->children_head,
653                                 n->parent->children_tail,
654                                 n);
655     GNUNET_CONTAINER_DLL_insert(t->disconnected_head,
656                                 t->disconnected_tail,
657                                 n);
658     return p1;
659   }
660   for (c = n->children_head; NULL != c; c = c->next)
661   {
662     if (c->peer == p2)
663     {
664       tree_mark_peers_disconnected(t, c, cb);
665       GNUNET_CONTAINER_DLL_remove(n->children_head,
666                                   n->children_tail,
667                                   c);
668       GNUNET_CONTAINER_DLL_insert(t->disconnected_head,
669                                   t->disconnected_tail,
670                                   c);
671       return p2;
672     }
673   }
674   return 0;
675 }
676
677
678 /**
679  * Deletes a peer from a tunnel, liberating all unused resources on the path to
680  * it. It shouldn't have children, if it has they will be destroyed as well.
681  * If the tree is not local and no longer has any paths, the root node will be
682  * destroyed and marked as NULL.
683  *
684  * @param t Tunnel tree to use.
685  * @param peer Short ID of the peer to remove from the tunnel tree.
686  * @param cb Callback to notify client of disconnected peers.
687  *
688  * @return GNUNET_OK or GNUNET_SYSERR
689  */
690 int
691 tree_del_peer (struct MeshTunnelTree *t,
692                GNUNET_PEER_Id peer,
693                MeshNodeDisconnectCB cb)
694 {
695   struct MeshTunnelTreeNode *n;
696
697   n = tree_del_path(t, peer, cb);
698   if (NULL == n)
699     return GNUNET_SYSERR;
700   GNUNET_break_op (NULL == n->children_head);
701   tree_node_destroy(n);
702   if (NULL == t->root->children_head && t->me != t->root)
703   {
704     tree_node_destroy (t->root);
705     t->root = NULL;
706   }
707   return GNUNET_OK;
708 }
709
710
711 /**
712  * Print the tree on stderr
713  *
714  * @param t The tree
715  */
716 void
717 tree_debug(struct MeshTunnelTree *t)
718 {
719   tree_node_debug(t->root, 0);
720 }
721
722
723 /**
724  * Iterator over hash map peer entries and frees all data in it.
725  * Used prior to destroying a hashmap. Makes you miss anonymous functions in C.
726  *
727  * @param cls closure
728  * @param key current key code (will no longer contain valid data!!)
729  * @param value value in the hash map (treated as void *)
730  * @return GNUNET_YES if we should continue to iterate, GNUNET_NO if not.
731  */
732 static int
733 iterate_free (void *cls, const GNUNET_HashCode * key, void *value)
734 {
735   GNUNET_free(value);
736   return GNUNET_YES;
737 }
738
739
740 /**
741  * Destroy the whole tree and free all used memory and Peer_Ids
742  * 
743  * @param t Tree to be destroyed
744  */
745 void
746 tree_destroy (struct MeshTunnelTree *t)
747 {
748   tree_node_destroy(t->root);
749   GNUNET_CONTAINER_multihashmap_iterate(t->first_hops, &iterate_free, NULL);
750   GNUNET_CONTAINER_multihashmap_destroy(t->first_hops);
751   GNUNET_free(t);
752 }