090681517234f9fcb0579ada54da6603b9c0ac55
[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->t = t;
267   tree->root->t = t;
268
269   return tree;
270 }
271
272
273 /**
274  * Recursively find the given peer in the tree.
275  *
276  * @param t Tunnel where to look for the peer.
277  * @param peer Peer to find
278  *
279  * @return Pointer to the node of the peer. NULL if not found.
280  */
281 struct MeshTunnelTreeNode *
282 tree_find_peer (struct MeshTunnelTreeNode *parent, GNUNET_PEER_Id peer_id)
283 {
284   struct MeshTunnelTreeNode *n;
285   struct MeshTunnelTreeNode *r;
286
287   if (parent->peer == peer_id)
288     return parent;
289   for (n = parent->children_head; NULL != n; n = n->next)
290   {
291     r = tree_find_peer (n, peer_id);
292     if (NULL != r)
293       return r;
294   }
295   return NULL;
296 }
297
298
299 /**
300  * Recusively mark peer and children as disconnected, notify client
301  *
302  * @param tree Tree this node belongs to
303  * @param parent Node to be clean, potentially with children
304  * @param cb Callback to use to notify about disconnected peers.
305  */
306 static void
307 tree_mark_peers_disconnected (struct MeshTunnelTree *tree,
308                               struct MeshTunnelTreeNode *parent,
309                               MeshNodeDisconnectCB cb)
310 {
311   struct GNUNET_PeerIdentity *pi;
312   struct GNUNET_PeerIdentity id;
313   struct MeshTunnelTreeNode *n;
314
315   for (n = parent->children_head; NULL != n; n = n->next)
316   {
317     tree_mark_peers_disconnected (tree, n, cb);
318   }
319   if (MESH_PEER_READY == parent->status && NULL != cb)
320   {
321     cb (parent);
322   }
323   parent->status = MESH_PEER_RECONNECTING;
324
325   /* Remove and free info about first hop */
326   GNUNET_PEER_resolve(parent->peer, &id);
327   pi = GNUNET_CONTAINER_multihashmap_get(tree->first_hops, &id.hashPubKey);
328   GNUNET_CONTAINER_multihashmap_remove_all(tree->first_hops, &id.hashPubKey);
329   if (NULL != pi)
330     GNUNET_free(pi);
331 }
332
333
334 /**
335  * Recusively update the info about what is the first hop to reach the node
336  *
337  * @param tree Tree this nodes belongs to
338  * @param parent Node to be start updating
339  * @param hop If known, ID of the first hop.
340  *            If not known, NULL to find out and pass on children.
341  */
342 void
343 tree_update_first_hops (struct MeshTunnelTree *tree,
344                         struct MeshTunnelTreeNode *parent,
345                         struct GNUNET_PeerIdentity *hop)
346 {
347   struct GNUNET_PeerIdentity pi;
348   struct GNUNET_PeerIdentity *copy;
349   struct GNUNET_PeerIdentity id;
350   struct MeshTunnelTreeNode *n;
351
352   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
353              "tree:   Finding first hop for %u.\n",
354              parent->peer);
355   if (NULL == hop)
356   {
357     struct MeshTunnelTreeNode *aux;
358     struct MeshTunnelTreeNode *old;
359
360     old = parent;
361     aux = old->parent;
362     while (aux != tree->me)
363     {
364       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
365              "tree:   ... its not %u.\n",
366              old->peer);
367       old = aux;
368       aux = aux->parent;
369       GNUNET_assert(NULL != aux);
370     }
371     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
372              "tree:   It's %u!!\n",
373              old->peer);
374     hop = &pi;
375     GNUNET_PEER_resolve(old->peer, hop);
376   }
377   copy = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
378   *copy = *hop;
379   GNUNET_PEER_resolve(parent->peer, &id);
380   GNUNET_CONTAINER_multihashmap_put(tree->first_hops, &id.hashPubKey, copy,
381                                     GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
382
383   for (n = parent->children_head; NULL != n; n = n->next)
384   {
385     tree_update_first_hops (tree, n, hop);
386   }
387 }
388
389
390 /**
391  * Delete the current path to the peer, including all now unused relays.
392  * The destination peer is NOT destroyed, it is returned in order to either set
393  * a new path to it or destroy it explicitly, taking care of it's child nodes.
394  *
395  * @param t Tunnel tree where to delete the path from.
396  * @param peer Destination peer whose path we want to remove.
397  * @param cb Callback to use to notify about disconnected peers.
398  *
399  * @return pointer to the pathless node.
400  *         NULL when not found
401  */
402 struct MeshTunnelTreeNode *
403 tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer_id,
404                  MeshNodeDisconnectCB cb)
405 {
406   struct MeshTunnelTreeNode *parent;
407   struct MeshTunnelTreeNode *node;
408   struct MeshTunnelTreeNode *n;
409
410   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
411              "tree:   Deleting path to %u.\n", peer_id);
412   if (peer_id == t->root->peer)
413     return NULL;
414
415   for (n = t->disconnected_head; NULL != n; n = n->next)
416   {
417     if (n->peer == peer_id)
418     {
419       /* Was already pathless, waiting for reconnection */
420       GNUNET_CONTAINER_DLL_remove (t->disconnected_head,
421                                    t->disconnected_tail,
422                                    n);
423       return n;
424     }
425   }
426   n = tree_find_peer (t->root, peer_id);
427   if (NULL == n)
428     return NULL;
429   node = n;
430
431   parent = n->parent;
432   GNUNET_CONTAINER_DLL_remove(parent->children_head, parent->children_tail, n);
433   n->parent = NULL;
434
435   while (t->root != parent && MESH_PEER_RELAY == parent->status &&
436          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, marking its children as disconnected.
680  *
681  * @param t Tunnel tree to use.
682  * @param peer Short ID of the peer to remove from the tunnel tree.
683  * @param cb Callback to notify client of disconnected peers.
684  *
685  * @return GNUNET_OK or GNUNET_SYSERR
686  */
687 int
688 tree_del_peer (struct MeshTunnelTree *t,
689                GNUNET_PEER_Id peer,
690                MeshNodeDisconnectCB cb)
691 {
692   struct MeshTunnelTreeNode *n;
693   struct MeshTunnelTreeNode *c;
694   struct MeshTunnelTreeNode *aux;
695
696   n = tree_del_path(t, peer, cb);
697   c = n->children_head;
698   while (NULL != c)
699   {
700     aux = c->next;
701     GNUNET_CONTAINER_DLL_remove(n->children_head,
702                                 n->children_tail,
703                                 c);
704     GNUNET_CONTAINER_DLL_insert(t->disconnected_head,
705                                 t->disconnected_tail,
706                                 c);
707     cb (c);
708     c = aux;
709   }
710   tree_node_destroy(n);
711   return GNUNET_OK;
712 }
713
714
715 /**
716  * Print the tree on stderr
717  *
718  * @param t The tree
719  */
720 void
721 tree_debug(struct MeshTunnelTree *t)
722 {
723   tree_node_debug(t->root, 0);
724 }
725
726
727 /**
728  * Iterator over hash map peer entries and frees all data in it.
729  * Used prior to destroying a hashmap. Makes you miss anonymous functions in C.
730  *
731  * @param cls closure
732  * @param key current key code (will no longer contain valid data!!)
733  * @param value value in the hash map (treated as void *)
734  * @return GNUNET_YES if we should continue to iterate, GNUNET_NO if not.
735  */
736 static int
737 iterate_free (void *cls, const GNUNET_HashCode * key, void *value)
738 {
739   GNUNET_free(value);
740   return GNUNET_YES;
741 }
742
743
744 /**
745  * Destroy the whole tree and free all used memory and Peer_Ids
746  * 
747  * @param t Tree to be destroyed
748  */
749 void
750 tree_destroy (struct MeshTunnelTree *t)
751 {
752   tree_node_destroy(t->root);
753   GNUNET_CONTAINER_multihashmap_iterate(t->first_hops, &iterate_free, NULL);
754   GNUNET_CONTAINER_multihashmap_destroy(t->first_hops);
755   GNUNET_free(t);
756 }