implement keepalives
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet-new.c
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2001-2013, 2017 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file cadet/gnunet-service-cadet-new.c
23  * @brief GNUnet CADET service with encryption
24  * @author Bartlomiej Polot
25  * @author Christian Grothoff
26  *
27  * Dictionary:
28  * - peer: other cadet instance. If there is direct connection it's a neighbor.
29  * - path: series of directly connected peer from one peer to another.
30  * - connection: path which is being used in a tunnel.
31  * - tunnel: encrypted connection to a peer, neighbor or not.
32  * - channel: logical link between two clients, on the same or different peers.
33  *            have properties like reliability.
34  */
35
36 #include "platform.h"
37 #include "gnunet_util_lib.h"
38 #include "cadet.h"
39 #include "gnunet_statistics_service.h"
40 #include "gnunet-service-cadet-new.h"
41 #include "gnunet-service-cadet-new_channel.h"
42 #include "gnunet-service-cadet-new_connection.h"
43 #include "gnunet-service-cadet-new_core.h"
44 #include "gnunet-service-cadet-new_dht.h"
45 #include "gnunet-service-cadet-new_hello.h"
46 #include "gnunet-service-cadet-new_tunnels.h"
47 #include "gnunet-service-cadet-new_peer.h"
48 #include "gnunet-service-cadet-new_paths.h"
49
50 #define LOG(level, ...) GNUNET_log (level,__VA_ARGS__)
51
52
53 /**
54  * Struct containing information about a client of the service
55  */
56 struct CadetClient
57 {
58   /**
59    * Linked list next
60    */
61   struct CadetClient *next;
62
63   /**
64    * Linked list prev
65    */
66   struct CadetClient *prev;
67
68   /**
69    * Tunnels that belong to this client, indexed by local id,
70    * value is a `struct CadetChannel`.
71    */
72   struct GNUNET_CONTAINER_MultiHashMap32 *channels;
73
74   /**
75    * Handle to communicate with the client
76    */
77   struct GNUNET_MQ_Handle *mq;
78
79   /**
80    * Client handle.
81    */
82   struct GNUNET_SERVICE_Client *client;
83
84   /**
85    * Ports that this client has declared interest in.
86    * Indexed by port, contains *Client.
87    */
88   struct GNUNET_CONTAINER_MultiHashMap *ports;
89
90   /**
91    * Channel ID to use for the next incoming channel for this client.
92    * Wraps around (in theory).
93    */
94   struct GNUNET_CADET_ClientChannelNumber next_ccn;
95
96   /**
97    * ID of the client, mainly for debug messages. Purely internal to this file.
98    */
99   unsigned int id;
100 };
101
102 /******************************************************************************/
103 /***********************      GLOBAL VARIABLES     ****************************/
104 /******************************************************************************/
105
106 /****************************** Global variables ******************************/
107
108 /**
109  * Handle to our configuration.
110  */
111 const struct GNUNET_CONFIGURATION_Handle *cfg;
112
113 /**
114  * Handle to the statistics service.
115  */
116 struct GNUNET_STATISTICS_Handle *stats;
117
118 /**
119  * Handle to communicate with ATS.
120  */
121 struct GNUNET_ATS_ConnectivityHandle *ats_ch;
122
123 /**
124  * Local peer own ID.
125  */
126 struct GNUNET_PeerIdentity my_full_id;
127
128 /**
129  * Own private key.
130  */
131 struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
132
133 /**
134  * Signal that shutdown is happening: prevent recovery measures.
135  */
136 int shutting_down;
137
138 /**
139  * DLL with all the clients, head.
140  */
141 static struct CadetClient *clients_head;
142
143 /**
144  * DLL with all the clients, tail.
145  */
146 static struct CadetClient *clients_tail;
147
148 /**
149  * Next ID to assign to a client.
150  */
151 static unsigned int next_client_id;
152
153 /**
154  * All ports clients of this peer have opened.
155  */
156 struct GNUNET_CONTAINER_MultiHashMap *open_ports;
157
158 /**
159  * Map from ports to channels where the ports were closed at the
160  * time we got the inbound connection.
161  * Indexed by port, contains `struct CadetChannel`.
162  */
163 struct GNUNET_CONTAINER_MultiHashMap *loose_channels;
164
165 /**
166  * Map from PIDs to `struct CadetPeer` entries.
167  */
168 struct GNUNET_CONTAINER_MultiPeerMap *peers;
169
170 /**
171  * Map from `struct GNUNET_CADET_ConnectionTunnelIdentifier`
172  * hash codes to `struct CadetConnection` objects.
173  */
174 struct GNUNET_CONTAINER_MultiShortmap *connections;
175
176 /**
177  * How many messages are needed to trigger an AXOLOTL ratchet advance.
178  */
179 unsigned long long ratchet_messages;
180
181 /**
182  * How long until we trigger a ratched advance due to time.
183  */
184 struct GNUNET_TIME_Relative ratchet_time;
185
186 /**
187  * How frequently do we send KEEPALIVE messages on idle connections?
188  */
189 struct GNUNET_TIME_Relative keepalive_period;
190
191
192 /**
193  * Send a message to a client.
194  *
195  * @param c client to get the message
196  * @param env envelope with the message
197  */
198 void
199 GSC_send_to_client (struct CadetClient *c,
200                     struct GNUNET_MQ_Envelope *env)
201 {
202   GNUNET_MQ_send (c->mq,
203                   env);
204 }
205
206
207 /**
208  * Return identifier for a client as a string.
209  *
210  * @param c client to identify
211  * @return string for debugging
212  */
213 const char *
214 GSC_2s (struct CadetClient *c)
215 {
216   static char buf[32];
217
218   GNUNET_snprintf (buf,
219                    sizeof (buf),
220                    "Client(%u)",
221                    c->id);
222   return buf;
223 }
224
225
226 /**
227  * Lookup channel of client @a c by @a ccn.
228  *
229  * @param c client to look in
230  * @param ccn channel ID to look up
231  * @return NULL if no such channel exists
232  */
233 static struct CadetChannel *
234 lookup_channel (struct CadetClient *c,
235                 struct GNUNET_CADET_ClientChannelNumber ccn)
236 {
237   return GNUNET_CONTAINER_multihashmap32_get (c->channels,
238                                               ntohl (ccn.channel_of_client));
239 }
240
241
242 /**
243  * Obtain the next LID to use for incoming connections to
244  * the given client.
245  *
246  * @param c client handle
247  */
248 static struct GNUNET_CADET_ClientChannelNumber
249 client_get_next_ccn (struct CadetClient *c)
250 {
251   struct GNUNET_CADET_ClientChannelNumber ccn = c->next_ccn;
252
253   /* increment until we have a free one... */
254   while (NULL !=
255          lookup_channel (c,
256                          ccn))
257   {
258     ccn.channel_of_client
259       = htonl (1 + (ntohl (ccn.channel_of_client)));
260     if (ntohl (ccn.channel_of_client) >=
261         GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
262       ccn.channel_of_client = htonl (0);
263   }
264   c->next_ccn.channel_of_client
265     = htonl (1 + (ntohl (ccn.channel_of_client)));
266   return ccn;
267 }
268
269
270 /**
271  * Bind incoming channel to this client, and notify client about
272  * incoming connection.  Caller is responsible for notifying the other
273  * peer about our acceptance of the channel.
274  *
275  * @param c client to bind to
276  * @param ch channel to be bound
277  * @param dest peer that establishes the connection
278  * @param port port number
279  * @param options options
280  * @return local channel number assigned to the new client
281  */
282 struct GNUNET_CADET_ClientChannelNumber
283 GSC_bind (struct CadetClient *c,
284           struct CadetChannel *ch,
285           struct CadetPeer *dest,
286           const struct GNUNET_HashCode *port,
287           uint32_t options)
288 {
289   struct GNUNET_MQ_Envelope *env;
290   struct GNUNET_CADET_LocalChannelCreateMessage *cm;
291   struct GNUNET_CADET_ClientChannelNumber ccn;
292
293   ccn = client_get_next_ccn (c);
294   GNUNET_assert (GNUNET_YES ==
295                  GNUNET_CONTAINER_multihashmap32_put (c->channels,
296                                                       ntohl (ccn.channel_of_client),
297                                                       ch,
298                                                       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
299   LOG (GNUNET_ERROR_TYPE_DEBUG,
300        "Accepting incoming %s from %s on open port %s (%u), assigning ccn %X\n",
301        GCCH_2s (ch),
302        GCP_2s (dest),
303        GNUNET_h2s (port),
304        ntohl (options),
305        ntohl (ccn.channel_of_client));
306   /* notify local client about incoming connection! */
307   env = GNUNET_MQ_msg (cm,
308                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
309   cm->ccn = ccn;
310   cm->port = *port;
311   cm->opt = htonl (options);
312   cm->peer = *GCP_get_id (dest);
313   GSC_send_to_client (c,
314                       env);
315   return ccn;
316 }
317
318
319 /**
320  * Callback invoked on all peers to destroy all tunnels
321  * that may still exist.
322  *
323  * @param cls NULL
324  * @param pid identify of a peer
325  * @param value a `struct CadetPeer` that may still have a tunnel
326  * @return #GNUNET_OK (iterate over all entries)
327  */
328 static int
329 destroy_tunnels_now (void *cls,
330                      const struct GNUNET_PeerIdentity *pid,
331                      void *value)
332 {
333   struct CadetPeer *cp = value;
334   struct CadetTunnel *t = GCP_get_tunnel (cp,
335                                           GNUNET_NO);
336
337   if (NULL != t)
338     GCT_destroy_tunnel_now (t);
339   return GNUNET_OK;
340 }
341
342
343 /**
344  * Callback invoked on all peers to destroy all tunnels
345  * that may still exist.
346  *
347  * @param cls NULL
348  * @param pid identify of a peer
349  * @param value a `struct CadetPeer` that may still have a tunnel
350  * @return #GNUNET_OK (iterate over all entries)
351  */
352 static int
353 destroy_paths_now (void *cls,
354                    const struct GNUNET_PeerIdentity *pid,
355                    void *value)
356 {
357   struct CadetPeer *cp = value;
358
359   GCP_drop_owned_paths (cp);
360   return GNUNET_OK;
361 }
362
363
364 /**
365  * Shutdown everything once the clients have disconnected.
366  */
367 static void
368 shutdown_rest ()
369 {
370   if (NULL != stats)
371   {
372     GNUNET_STATISTICS_destroy (stats,
373                                GNUNET_NO);
374     stats = NULL;
375   }
376   if (NULL != open_ports)
377   {
378     GNUNET_CONTAINER_multihashmap_destroy (open_ports);
379     open_ports = NULL;
380   }
381   if (NULL != loose_channels)
382   {
383     GNUNET_CONTAINER_multihashmap_destroy (loose_channels);
384     loose_channels = NULL;
385   }
386   /* Destroy tunnels.  Note that all channels must be destroyed first! */
387   GCP_iterate_all (&destroy_tunnels_now,
388                    NULL);
389   /* All tunnels, channels, connections and CORE must be down before this point. */
390   GCP_iterate_all (&destroy_paths_now,
391                    NULL);
392   /* All paths, tunnels, channels, connections and CORE must be down before this point. */
393   GCP_destroy_all_peers ();
394   if (NULL != peers)
395   {
396     GNUNET_CONTAINER_multipeermap_destroy (peers);
397     peers = NULL;
398   }
399   if (NULL != connections)
400   {
401     GNUNET_CONTAINER_multishortmap_destroy (connections);
402     connections = NULL;
403   }
404   if (NULL != ats_ch)
405   {
406     GNUNET_ATS_connectivity_done (ats_ch);
407     ats_ch = NULL;
408   }
409   GCD_shutdown ();
410   GCH_shutdown ();
411   GNUNET_free_non_null (my_private_key);
412   my_private_key = NULL;
413 }
414
415
416 /**
417  * Task run during shutdown.
418  *
419  * @param cls unused
420  */
421 static void
422 shutdown_task (void *cls)
423 {
424   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
425               "Shutting down\n");
426   shutting_down = GNUNET_YES;
427   GCO_shutdown ();
428   if (NULL == clients_head)
429     shutdown_rest ();
430 }
431
432
433 /**
434  * We had a remote connection @a value to port @a port before
435  * client @a cls opened port @a port.  Bind them now.
436  *
437  * @param cls the `struct CadetClient`
438  * @param port the port
439  * @param value the `struct CadetChannel`
440  * @return #GNUNET_YES (iterate over all such channels)
441  */
442 static int
443 bind_loose_channel (void *cls,
444                     const struct GNUNET_HashCode *port,
445                     void *value)
446 {
447   struct CadetClient *c = cls;
448   struct CadetChannel *ch = value;
449
450   GCCH_bind (ch,
451              c);
452   GNUNET_assert (GNUNET_YES ==
453                  GNUNET_CONTAINER_multihashmap_remove (loose_channels,
454                                                        port,
455                                                        value));
456   return GNUNET_YES;
457 }
458
459
460 /**
461  * Handle port open request.  Creates a mapping from the
462  * port to the respective client and checks whether we have
463  * loose channels trying to bind to the port.  If so, those
464  * are bound.
465  *
466  * @param cls Identification of the client.
467  * @param pmsg The actual message.
468  */
469 static void
470 handle_port_open (void *cls,
471                   const struct GNUNET_CADET_PortMessage *pmsg)
472 {
473   struct CadetClient *c = cls;
474
475   LOG (GNUNET_ERROR_TYPE_DEBUG,
476        "Open port %s requested by %s\n",
477        GNUNET_h2s (&pmsg->port),
478        GSC_2s (c));
479   if (NULL == c->ports)
480     c->ports = GNUNET_CONTAINER_multihashmap_create (4,
481                                                       GNUNET_NO);
482   if (GNUNET_OK !=
483       GNUNET_CONTAINER_multihashmap_put (c->ports,
484                                          &pmsg->port,
485                                          c,
486                                          GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
487   {
488     GNUNET_break (0);
489     GNUNET_SERVICE_client_drop (c->client);
490     return;
491   }
492   (void) GNUNET_CONTAINER_multihashmap_put (open_ports,
493                                             &pmsg->port,
494                                             c,
495                                             GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
496   GNUNET_CONTAINER_multihashmap_get_multiple (loose_channels,
497                                               &pmsg->port,
498                                               &bind_loose_channel,
499                                               c);
500   GNUNET_SERVICE_client_continue (c->client);
501 }
502
503
504 /**
505  * Handler for port close requests.  Marks this port as closed
506  * (unless of course we have another client with the same port
507  * open).  Note that existing channels accepted on the port are
508  * not affected.
509  *
510  * @param cls Identification of the client.
511  * @param pmsg The actual message.
512  */
513 static void
514 handle_port_close (void *cls,
515                    const struct GNUNET_CADET_PortMessage *pmsg)
516 {
517   struct CadetClient *c = cls;
518
519   LOG (GNUNET_ERROR_TYPE_DEBUG,
520        "Closing port %s as requested by %s\n",
521        GNUNET_h2s (&pmsg->port),
522        GSC_2s (c));
523   if (GNUNET_YES !=
524       GNUNET_CONTAINER_multihashmap_remove (c->ports,
525                                             &pmsg->port,
526                                             c))
527   {
528     GNUNET_break (0);
529     GNUNET_SERVICE_client_drop (c->client);
530     return;
531   }
532   GNUNET_assert (GNUNET_YES ==
533                  GNUNET_CONTAINER_multihashmap_remove (open_ports,
534                                                        &pmsg->port,
535                                                        c));
536   GNUNET_SERVICE_client_continue (c->client);
537 }
538
539
540 /**
541  * Handler for requests for us creating a new channel to another peer and port.
542  *
543  * @param cls Identification of the client.
544  * @param tcm The actual message.
545  */
546 static void
547 handle_channel_create (void *cls,
548                        const struct GNUNET_CADET_LocalChannelCreateMessage *tcm)
549 {
550   struct CadetClient *c = cls;
551   struct CadetChannel *ch;
552
553   if (ntohl (tcm->ccn.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
554   {
555     /* Channel ID not in allowed range. */
556     GNUNET_break (0);
557     GNUNET_SERVICE_client_drop (c->client);
558     return;
559   }
560   ch = lookup_channel (c,
561                        tcm->ccn);
562   if (NULL != ch)
563   {
564     /* Channel ID already in use. Not allowed. */
565     GNUNET_break (0);
566     GNUNET_SERVICE_client_drop (c->client);
567     return;
568   }
569   LOG (GNUNET_ERROR_TYPE_DEBUG,
570        "New channel to %s at port %s requested by %s\n",
571        GNUNET_i2s (&tcm->peer),
572        GNUNET_h2s (&tcm->port),
573        GSC_2s (c));
574
575   /* Create channel */
576   ch = GCCH_channel_local_new (c,
577                                tcm->ccn,
578                                GCP_get (&tcm->peer,
579                                         GNUNET_YES),
580                                &tcm->port,
581                                ntohl (tcm->opt));
582   if (NULL == ch)
583   {
584     GNUNET_break (0);
585     GNUNET_SERVICE_client_drop (c->client);
586     return;
587   }
588   GNUNET_assert (GNUNET_YES ==
589                  GNUNET_CONTAINER_multihashmap32_put (c->channels,
590                                                       ntohl (tcm->ccn.channel_of_client),
591                                                       ch,
592                                                       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
593
594   GNUNET_SERVICE_client_continue (c->client);
595 }
596
597
598 /**
599  * Handler for requests of destroying an existing channel.
600  *
601  * @param cls client identification of the client
602  * @param msg the actual message
603  */
604 static void
605 handle_channel_destroy (void *cls,
606                         const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
607 {
608   struct CadetClient *c = cls;
609   struct CadetChannel *ch;
610
611   ch = lookup_channel (c,
612                        msg->ccn);
613   if (NULL == ch)
614   {
615     /* Client attempted to destroy unknown channel */
616     GNUNET_break (0);
617     GNUNET_SERVICE_client_drop (c->client);
618     return;
619   }
620   LOG (GNUNET_ERROR_TYPE_INFO,
621        "%s is destroying %s\n",
622        GSC_2s(c),
623        GCCH_2s (ch));
624   GNUNET_assert (GNUNET_YES ==
625                  GNUNET_CONTAINER_multihashmap32_remove (c->channels,
626                                                          ntohl (msg->ccn.channel_of_client),
627                                                          ch));
628   GCCH_channel_local_destroy (ch,
629                               c,
630                               msg->ccn);
631   GNUNET_SERVICE_client_continue (c->client);
632 }
633
634
635 /**
636  * Check for client traffic data message is well-formed.
637  *
638  * @param cls identification of the client
639  * @param msg the actual message
640  * @return #GNUNET_OK if @a msg is OK, #GNUNET_SYSERR if not
641  */
642 static int
643 check_local_data (void *cls,
644                   const struct GNUNET_CADET_LocalData *msg)
645 {
646   size_t payload_size;
647   size_t payload_claimed_size;
648   const char *buf;
649   struct GNUNET_MessageHeader pa;
650
651   /* FIXME: what is the format we shall allow for @a msg?
652      ONE payload item or multiple? Seems current cadet_api
653      at least in theory allows more than one. Next-gen
654      cadet_api will likely no more, so we could then
655      simplify this mess again. */
656   /* Sanity check for message size */
657   payload_size = ntohs (msg->header.size) - sizeof (*msg);
658   buf = (const char *) &msg[1];
659   while (payload_size >= sizeof (struct GNUNET_MessageHeader))
660   {
661     /* need to memcpy() for alignment */
662     GNUNET_memcpy (&pa,
663                    buf,
664                    sizeof (pa));
665     payload_claimed_size = ntohs (pa.size);
666     if ( (payload_size < payload_claimed_size) ||
667          (payload_claimed_size < sizeof (struct GNUNET_MessageHeader)) ||
668          (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size) )
669     {
670       GNUNET_break (0);
671       LOG (GNUNET_ERROR_TYPE_DEBUG,
672            "Local data of %u total size had sub-message %u at %u with %u bytes\n",
673            ntohs (msg->header.size),
674            ntohs (pa.type),
675            (unsigned int) (buf - (const char *) &msg[1]),
676            (unsigned int) payload_claimed_size);
677       return GNUNET_SYSERR;
678     }
679     payload_size -= payload_claimed_size;
680     buf += payload_claimed_size;
681   }
682   if (0 != payload_size)
683   {
684     GNUNET_break_op (0);
685     return GNUNET_SYSERR;
686   }
687   return GNUNET_OK;
688 }
689
690
691 /**
692  * Handler for client payload traffic to be send on a channel to
693  * another peer.
694  *
695  * @param cls identification of the client
696  * @param msg the actual message
697  */
698 static void
699 handle_local_data (void *cls,
700                    const struct GNUNET_CADET_LocalData *msg)
701 {
702   struct CadetClient *c = cls;
703   struct CadetChannel *ch;
704   size_t payload_size;
705   const char *buf;
706
707   ch = lookup_channel (c,
708                        msg->ccn);
709   if (NULL == ch)
710   {
711     /* Channel does not exist! */
712     GNUNET_break (0);
713     GNUNET_SERVICE_client_drop (c->client);
714     return;
715   }
716   payload_size = ntohs (msg->header.size) - sizeof (*msg);
717   buf = (const char *) &msg[1];
718   LOG (GNUNET_ERROR_TYPE_DEBUG,
719        "Received %u bytes payload from %s for %s\n",
720        (unsigned int) payload_size,
721        GSC_2s (c),
722        GCCH_2s (ch));
723   if (GNUNET_OK !=
724       GCCH_handle_local_data (ch,
725                               msg->ccn,
726                               buf,
727                               payload_size))
728   {
729     GNUNET_SERVICE_client_drop (c->client);
730     return;
731   }
732   GNUNET_SERVICE_client_continue (c->client);
733 }
734
735
736 /**
737  * Handler for client's ACKs for payload traffic.
738  *
739  * @param cls identification of the client.
740  * @param msg The actual message.
741  */
742 static void
743 handle_local_ack (void *cls,
744                   const struct GNUNET_CADET_LocalAck *msg)
745 {
746   struct CadetClient *c = cls;
747   struct CadetChannel *ch;
748
749   ch = lookup_channel (c,
750                        msg->ccn);
751   if (NULL == ch)
752   {
753     /* Channel does not exist! */
754     GNUNET_break (0);
755     GNUNET_SERVICE_client_drop (c->client);
756     return;
757   }
758   LOG (GNUNET_ERROR_TYPE_DEBUG,
759        "Got a local ACK from %s for %s\n",
760        GSC_2s(c),
761        GCCH_2s (ch));
762   GCCH_handle_local_ack (ch,
763                          msg->ccn);
764   GNUNET_SERVICE_client_continue (c->client);
765 }
766
767
768 /**
769  * Iterator over all peers to send a monitoring client info about each peer.
770  *
771  * @param cls Closure ().
772  * @param peer Peer ID (tunnel remote peer).
773  * @param value Peer info.
774  * @return #GNUNET_YES, to keep iterating.
775  */
776 static int
777 get_all_peers_iterator (void *cls,
778                         const struct GNUNET_PeerIdentity *peer,
779                         void *value)
780 {
781   struct CadetClient *c = cls;
782   struct CadetPeer *p = value;
783   struct GNUNET_MQ_Envelope *env;
784   struct GNUNET_CADET_LocalInfoPeer *msg;
785
786   env = GNUNET_MQ_msg (msg,
787                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS);
788   msg->destination = *peer;
789   msg->paths = htons (GCP_count_paths (p));
790   msg->tunnel = htons (NULL != GCP_get_tunnel (p,
791                                                GNUNET_NO));
792   GNUNET_MQ_send (c->mq,
793                   env);
794   return GNUNET_YES;
795 }
796
797
798 /**
799  * Handler for client's INFO PEERS request.
800  *
801  * @param cls Identification of the client.
802  * @param message The actual message.
803  */
804 static void
805 handle_get_peers (void *cls,
806                   const struct GNUNET_MessageHeader *message)
807 {
808   struct CadetClient *c = cls;
809   struct GNUNET_MQ_Envelope *env;
810   struct GNUNET_MessageHeader *reply;
811
812   GCP_iterate_all (&get_all_peers_iterator,
813                    c);
814   env = GNUNET_MQ_msg (reply,
815                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS);
816   GNUNET_MQ_send (c->mq,
817                   env);
818   GNUNET_SERVICE_client_continue (c->client);
819 }
820
821
822 /**
823  * Iterator over all paths of a peer to build an InfoPeer message.
824  * Message contains blocks of peers, first not included.
825  *
826  * @param cls message queue for transmission
827  * @param path Path itself
828  * @param off offset of the peer on @a path
829  * @return #GNUNET_YES if should keep iterating.
830  *         #GNUNET_NO otherwise.
831  */
832 static int
833 path_info_iterator (void *cls,
834                     struct CadetPeerPath *path,
835                     unsigned int off)
836 {
837   struct GNUNET_MQ_Handle *mq = cls;
838   struct GNUNET_MQ_Envelope *env;
839   struct GNUNET_MessageHeader *resp;
840   struct GNUNET_PeerIdentity *id;
841   uint16_t path_size;
842   unsigned int i;
843   unsigned int path_length;
844
845   path_length = GCPP_get_length (path);
846   path_size = sizeof (struct GNUNET_PeerIdentity) * (path_length - 1);
847   if (sizeof (*resp) + path_size > UINT16_MAX)
848   {
849     LOG (GNUNET_ERROR_TYPE_WARNING,
850          "Path of %u entries is too long for info message\n",
851          path_length);
852     return GNUNET_YES;
853   }
854   env = GNUNET_MQ_msg_extra (resp,
855                              path_size,
856                              GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER);
857   id = (struct GNUNET_PeerIdentity *) &resp[1];
858
859   /* Don't copy first peer.  First peer is always the local one.  Last
860    * peer is always the destination (leave as 0, EOL).
861    */
862   for (i = 0; i < off; i++)
863     id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path,
864                                                   i + 1));
865   GNUNET_MQ_send (mq,
866                   env);
867   return GNUNET_YES;
868 }
869
870
871 /**
872  * Handler for client's SHOW_PEER request.
873  *
874  * @param cls Identification of the client.
875  * @param msg The actual message.
876  */
877 static void
878 handle_show_peer (void *cls,
879                   const struct GNUNET_CADET_LocalInfo *msg)
880 {
881   struct CadetClient *c = cls;
882   struct CadetPeer *p;
883   struct GNUNET_MQ_Envelope *env;
884   struct GNUNET_MessageHeader *resp;
885
886   p = GCP_get (&msg->peer,
887                GNUNET_NO);
888   if (NULL != p)
889     GCP_iterate_paths (p,
890                        &path_info_iterator,
891                        c->mq);
892   /* Send message with 0/0 to indicate the end */
893   env = GNUNET_MQ_msg (resp,
894                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER_END);
895   GNUNET_MQ_send (c->mq,
896                   env);
897   GNUNET_SERVICE_client_continue (c->client);
898 }
899
900
901 /**
902  * Iterator over all tunnels to send a monitoring client info about each tunnel.
903  *
904  * @param cls Closure ().
905  * @param peer Peer ID (tunnel remote peer).
906  * @param value a `struct CadetPeer`
907  * @return #GNUNET_YES, to keep iterating.
908  */
909 static int
910 get_all_tunnels_iterator (void *cls,
911                           const struct GNUNET_PeerIdentity *peer,
912                           void *value)
913 {
914   struct CadetClient *c = cls;
915   struct CadetPeer *p = value;
916   struct GNUNET_MQ_Envelope *env;
917   struct GNUNET_CADET_LocalInfoTunnel *msg;
918   struct CadetTunnel *t;
919
920   t = GCP_get_tunnel (p,
921                       GNUNET_NO);
922   if (NULL == t)
923     return GNUNET_YES;
924   env = GNUNET_MQ_msg (msg,
925                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
926   msg->destination = *peer;
927   msg->channels = htonl (GCT_count_channels (t));
928   msg->connections = htonl (GCT_count_any_connections (t));
929   msg->cstate = htons (0);
930   msg->estate = htons ((uint16_t) GCT_get_estate (t));
931   GNUNET_MQ_send (c->mq,
932                   env);
933   return GNUNET_YES;
934 }
935
936
937 /**
938  * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS request.
939  *
940  * @param cls client Identification of the client.
941  * @param message The actual message.
942  */
943 static void
944 handle_info_tunnels (void *cls,
945                      const struct GNUNET_MessageHeader *message)
946 {
947   struct CadetClient *c = cls;
948   struct GNUNET_MQ_Envelope *env;
949   struct GNUNET_MessageHeader *reply;
950
951   GCP_iterate_all (&get_all_tunnels_iterator,
952                    c);
953   env = GNUNET_MQ_msg (reply,
954                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
955   GNUNET_MQ_send (c->mq,
956                   env);
957   GNUNET_SERVICE_client_continue (c->client);
958 }
959
960
961 /**
962  * Update the message with information about the connection.
963  *
964  * @param cls a `struct GNUNET_CADET_LocalInfoTunnel` message to update
965  * @param c a connection about which we should store information in @a cls
966  */
967 static void
968 iter_connection (void *cls,
969                  struct CadetConnection *c)
970 {
971   struct GNUNET_CADET_LocalInfoTunnel *msg = cls;
972   struct GNUNET_CADET_ConnectionTunnelIdentifier *h;
973
974   h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1];
975   h[msg->connections++] = *(GCC_get_id (c));
976 }
977
978
979 /**
980  * Update the message with information about the channel.
981  *
982  * @param cls a `struct GNUNET_CADET_LocalInfoTunnel` message to update
983  * @param ch a channel about which we should store information in @a cls
984  */
985 static void
986 iter_channel (void *cls,
987               struct CadetChannel *ch)
988 {
989   struct GNUNET_CADET_LocalInfoTunnel *msg = cls;
990   struct GNUNET_CADET_ConnectionTunnelIdentifier *h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1];
991   struct GNUNET_CADET_ChannelTunnelNumber *chn
992     = (struct GNUNET_CADET_ChannelTunnelNumber *) &h[msg->connections];
993
994   chn[msg->channels++] = GCCH_get_id (ch);
995 }
996
997
998 /**
999  * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL request.
1000  *
1001  * @param cls Identification of the client.
1002  * @param msg The actual message.
1003  */
1004 static void
1005 handle_info_tunnel (void *cls,
1006                     const struct GNUNET_CADET_LocalInfo *msg)
1007 {
1008   struct CadetClient *c = cls;
1009   struct GNUNET_MQ_Envelope *env;
1010   struct GNUNET_CADET_LocalInfoTunnel *resp;
1011   struct CadetTunnel *t;
1012   struct CadetPeer *p;
1013   unsigned int ch_n;
1014   unsigned int c_n;
1015
1016   p = GCP_get (&msg->peer,
1017                GNUNET_NO);
1018   t = GCP_get_tunnel (p,
1019                       GNUNET_NO);
1020   if (NULL == t)
1021   {
1022     /* We don't know the tunnel */
1023     struct GNUNET_MQ_Envelope *env;
1024     struct GNUNET_CADET_LocalInfoTunnel *warn;
1025
1026     LOG (GNUNET_ERROR_TYPE_INFO,
1027          "Tunnel to %s unknown\n",
1028          GNUNET_i2s_full (&msg->peer));
1029     env = GNUNET_MQ_msg (warn,
1030                          GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL);
1031     warn->destination = msg->peer;
1032     GNUNET_MQ_send (c->mq,
1033                     env);
1034     GNUNET_SERVICE_client_continue (c->client);
1035     return;
1036   }
1037
1038   /* Initialize context */
1039   ch_n = GCT_count_channels (t);
1040   c_n = GCT_count_any_connections (t);
1041   env = GNUNET_MQ_msg_extra (resp,
1042                              c_n * sizeof (struct GNUNET_CADET_ConnectionTunnelIdentifier) +
1043                              ch_n * sizeof (struct GNUNET_CADET_ChannelTunnelNumber),
1044                              GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL);
1045   resp->destination = msg->peer;
1046   /* Do not reorder! #iter_channel needs counters in HBO! */
1047   GCT_iterate_connections (t,
1048                            &iter_connection,
1049                            resp);
1050   GCT_iterate_channels (t,
1051                         &iter_channel,
1052                         resp);
1053   resp->connections = htonl (resp->connections);
1054   resp->channels = htonl (resp->channels);
1055   resp->cstate = htons (0);
1056   resp->estate = htons (GCT_get_estate (t));
1057   GNUNET_MQ_send (c->mq,
1058                   env);
1059   GNUNET_SERVICE_client_continue (c->client);
1060 }
1061
1062
1063 /**
1064  * Iterator over all peers to dump info for each peer.
1065  *
1066  * @param cls Closure (unused).
1067  * @param peer Peer ID (tunnel remote peer).
1068  * @param value Peer info.
1069  *
1070  * @return #GNUNET_YES, to keep iterating.
1071  */
1072 static int
1073 show_peer_iterator (void *cls,
1074                     const struct GNUNET_PeerIdentity *peer,
1075                     void *value)
1076 {
1077   struct CadetPeer *p = value;
1078   struct CadetTunnel *t;
1079
1080   t = GCP_get_tunnel (p,
1081                       GNUNET_NO);
1082   if (NULL != t)
1083     GCT_debug (t,
1084                GNUNET_ERROR_TYPE_ERROR);
1085   LOG (GNUNET_ERROR_TYPE_ERROR, "\n");
1086   return GNUNET_YES;
1087 }
1088
1089
1090 /**
1091  * Handler for client's INFO_DUMP request.
1092  *
1093  * @param cls Identification of the client.
1094  * @param message The actual message.
1095  */
1096 static void
1097 handle_info_dump (void *cls,
1098                   const struct GNUNET_MessageHeader *message)
1099 {
1100   struct CadetClient *c = cls;
1101
1102   LOG (GNUNET_ERROR_TYPE_INFO,
1103        "Received dump info request from client %u\n",
1104        c->id);
1105
1106   LOG (GNUNET_ERROR_TYPE_ERROR,
1107        "*************************** DUMP START ***************************\n");
1108   for (struct CadetClient *ci = clients_head;
1109        NULL != ci;
1110        ci = ci->next)
1111   {
1112     LOG (GNUNET_ERROR_TYPE_ERROR,
1113          "Client %u (%p), handle: %p, ports: %u, channels: %u\n",
1114          ci->id,
1115          ci,
1116          ci->client,
1117          (NULL != c->ports)
1118          ? GNUNET_CONTAINER_multihashmap_size (ci->ports)
1119          : 0,
1120          GNUNET_CONTAINER_multihashmap32_size (ci->channels));
1121   }
1122   LOG (GNUNET_ERROR_TYPE_ERROR, "***************************\n");
1123   GCP_iterate_all (&show_peer_iterator,
1124                    NULL);
1125
1126   LOG (GNUNET_ERROR_TYPE_ERROR,
1127        "**************************** DUMP END ****************************\n");
1128
1129   GNUNET_SERVICE_client_continue (c->client);
1130 }
1131
1132
1133
1134 /**
1135  * Callback called when a client connects to the service.
1136  *
1137  * @param cls closure for the service
1138  * @param client the new client that connected to the service
1139  * @param mq the message queue used to send messages to the client
1140  * @return @a c
1141  */
1142 static void *
1143 client_connect_cb (void *cls,
1144                    struct GNUNET_SERVICE_Client *client,
1145                    struct GNUNET_MQ_Handle *mq)
1146 {
1147   struct CadetClient *c;
1148
1149   c = GNUNET_new (struct CadetClient);
1150   c->client = client;
1151   c->mq = mq;
1152   c->id = next_client_id++; /* overflow not important: just for debug */
1153   c->channels
1154     = GNUNET_CONTAINER_multihashmap32_create (32);
1155   GNUNET_CONTAINER_DLL_insert (clients_head,
1156                                clients_tail,
1157                                c);
1158   GNUNET_STATISTICS_update (stats,
1159                             "# clients",
1160                             +1,
1161                             GNUNET_NO);
1162   LOG (GNUNET_ERROR_TYPE_DEBUG,
1163        "%s connected\n",
1164        GSC_2s (c));
1165   return c;
1166 }
1167
1168
1169 /**
1170  * A channel was destroyed by the other peer. Tell our client.
1171  *
1172  * @param c client that lost a channel
1173  * @param ccn channel identification number for the client
1174  * @param ch the channel object
1175  */
1176 void
1177 GSC_handle_remote_channel_destroy (struct CadetClient *c,
1178                                    struct GNUNET_CADET_ClientChannelNumber ccn,
1179                                    struct CadetChannel *ch)
1180 {
1181   struct GNUNET_MQ_Envelope *env;
1182   struct GNUNET_CADET_LocalChannelDestroyMessage *tdm;
1183
1184   env = GNUNET_MQ_msg (tdm,
1185                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
1186   tdm->ccn = ccn;
1187   GSC_send_to_client (c,
1188                       env);
1189   GNUNET_assert (GNUNET_YES ==
1190                  GNUNET_CONTAINER_multihashmap32_remove (c->channels,
1191                                                          ntohl (ccn.channel_of_client),
1192                                                          ch));
1193 }
1194
1195
1196 /**
1197  * Iterator for deleting each channel whose client endpoint disconnected.
1198  *
1199  * @param cls Closure (client that has disconnected).
1200  * @param key The local channel id in host byte order
1201  * @param value The value stored at the key (channel to destroy).
1202  * @return #GNUNET_OK, keep iterating.
1203  */
1204 static int
1205 channel_destroy_iterator (void *cls,
1206                           uint32_t key,
1207                           void *value)
1208 {
1209   struct CadetClient *c = cls;
1210   struct GNUNET_CADET_ClientChannelNumber ccn;
1211   struct CadetChannel *ch = value;
1212
1213   LOG (GNUNET_ERROR_TYPE_DEBUG,
1214        "Destroying %s, due to %s disconnecting.\n",
1215        GCCH_2s (ch),
1216        GSC_2s (c));
1217   GNUNET_assert (GNUNET_YES ==
1218                  GNUNET_CONTAINER_multihashmap32_remove (c->channels,
1219                                                          key,
1220                                                          ch));
1221   ccn.channel_of_client = htonl (key);
1222   GCCH_channel_local_destroy (ch,
1223                               c,
1224                               ccn);
1225   return GNUNET_OK;
1226 }
1227
1228
1229 /**
1230  * Remove client's ports from the global hashmap on disconnect.
1231  *
1232  * @param cls Closure (unused).
1233  * @param key the port.
1234  * @param value the `struct CadetClient` to remove
1235  * @return #GNUNET_OK, keep iterating.
1236  */
1237 static int
1238 client_release_ports (void *cls,
1239                       const struct GNUNET_HashCode *key,
1240                       void *value)
1241 {
1242   struct CadetClient *c = value;
1243
1244   LOG (GNUNET_ERROR_TYPE_DEBUG,
1245        "Closing port %s due to %s disconnect.\n",
1246        GNUNET_h2s (key),
1247        GSC_2s (c));
1248   GNUNET_assert (GNUNET_YES ==
1249                  GNUNET_CONTAINER_multihashmap_remove (open_ports,
1250                                                        key,
1251                                                        value));
1252   GNUNET_assert (GNUNET_YES ==
1253                  GNUNET_CONTAINER_multihashmap_remove (c->ports,
1254                                                        key,
1255                                                        value));
1256   return GNUNET_OK;
1257 }
1258
1259
1260 /**
1261  * Callback called when a client disconnected from the service
1262  *
1263  * @param cls closure for the service
1264  * @param client the client that disconnected
1265  * @param internal_cls should be equal to @a c
1266  */
1267 static void
1268 client_disconnect_cb (void *cls,
1269                       struct GNUNET_SERVICE_Client *client,
1270                       void *internal_cls)
1271 {
1272   struct CadetClient *c = internal_cls;
1273
1274   GNUNET_assert (c->client == client);
1275   LOG (GNUNET_ERROR_TYPE_DEBUG,
1276        "%s is disconnecting.\n",
1277        GSC_2s (c));
1278   if (NULL != c->channels)
1279   {
1280     GNUNET_CONTAINER_multihashmap32_iterate (c->channels,
1281                                              &channel_destroy_iterator,
1282                                              c);
1283     GNUNET_CONTAINER_multihashmap32_destroy (c->channels);
1284   }
1285   if (NULL != c->ports)
1286   {
1287     GNUNET_CONTAINER_multihashmap_iterate (c->ports,
1288                                            &client_release_ports,
1289                                            c);
1290     GNUNET_CONTAINER_multihashmap_destroy (c->ports);
1291   }
1292   GNUNET_CONTAINER_DLL_remove (clients_head,
1293                                clients_tail,
1294                                c);
1295   GNUNET_STATISTICS_update (stats,
1296                             "# clients",
1297                             -1,
1298                             GNUNET_NO);
1299   GNUNET_free (c);
1300   if ( (NULL == clients_head) &&
1301        (GNUNET_YES == shutting_down) )
1302     shutdown_rest ();
1303 }
1304
1305
1306 /**
1307  * Setup CADET internals.
1308  *
1309  * @param cls closure
1310  * @param server the initialized server
1311  * @param c configuration to use
1312  */
1313 static void
1314 run (void *cls,
1315      const struct GNUNET_CONFIGURATION_Handle *c,
1316      struct GNUNET_SERVICE_Handle *service)
1317 {
1318   cfg = c;
1319   if (GNUNET_OK !=
1320       GNUNET_CONFIGURATION_get_value_number (c,
1321                                              "CADET",
1322                                              "RATCHET_MESSAGES",
1323                                              &ratchet_messages))
1324   {
1325     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
1326                                "CADET",
1327                                "RATCHET_MESSAGES",
1328                                "needs to be a number");
1329     ratchet_messages = 64;
1330   }
1331   if (GNUNET_OK !=
1332       GNUNET_CONFIGURATION_get_value_time (c,
1333                                            "CADET",
1334                                            "RATCHET_TIME",
1335                                            &ratchet_time))
1336   {
1337     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
1338                                "CADET",
1339                                "RATCHET_TIME",
1340                                "need delay value");
1341     ratchet_time = GNUNET_TIME_UNIT_HOURS;
1342   }
1343   if (GNUNET_OK !=
1344       GNUNET_CONFIGURATION_get_value_time (c,
1345                                            "CADET",
1346                                            "REFRESH_CONNECTION_TIME",
1347                                            &keepalive_period))
1348   {
1349     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
1350                                "CADET",
1351                                "REFRESH_CONNECTION_TIME",
1352                                "need delay value");
1353     keepalive_period = GNUNET_TIME_UNIT_MINUTES;
1354   }
1355
1356   my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (c);
1357   if (NULL == my_private_key)
1358   {
1359     GNUNET_break (0);
1360     GNUNET_SCHEDULER_shutdown ();
1361     return;
1362   }
1363   GNUNET_CRYPTO_eddsa_key_get_public (my_private_key,
1364                                       &my_full_id.public_key);
1365   stats = GNUNET_STATISTICS_create ("cadet",
1366                                     c);
1367   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
1368                                  NULL);
1369   ats_ch = GNUNET_ATS_connectivity_init (c);
1370   /* FIXME: optimize code to allow GNUNET_YES here! */
1371   open_ports = GNUNET_CONTAINER_multihashmap_create (16,
1372                                                      GNUNET_NO);
1373   loose_channels = GNUNET_CONTAINER_multihashmap_create (16,
1374                                                          GNUNET_NO);
1375   peers = GNUNET_CONTAINER_multipeermap_create (16,
1376                                                 GNUNET_YES);
1377   connections = GNUNET_CONTAINER_multishortmap_create (256,
1378                                                        GNUNET_YES);
1379   GCH_init (c);
1380   GCD_init (c);
1381   GCO_init (c);
1382   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1383               "CADET started for peer %s\n",
1384               GNUNET_i2s (&my_full_id));
1385
1386 }
1387
1388
1389 /**
1390  * Define "main" method using service macro.
1391  */
1392 GNUNET_SERVICE_MAIN
1393 ("cadet",
1394  GNUNET_SERVICE_OPTION_NONE,
1395  &run,
1396  &client_connect_cb,
1397  &client_disconnect_cb,
1398  NULL,
1399  GNUNET_MQ_hd_fixed_size (port_open,
1400                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN,
1401                           struct GNUNET_CADET_PortMessage,
1402                           NULL),
1403  GNUNET_MQ_hd_fixed_size (port_close,
1404                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE,
1405                           struct GNUNET_CADET_PortMessage,
1406                           NULL),
1407  GNUNET_MQ_hd_fixed_size (channel_create,
1408                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE,
1409                           struct GNUNET_CADET_LocalChannelCreateMessage,
1410                           NULL),
1411  GNUNET_MQ_hd_fixed_size (channel_destroy,
1412                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY,
1413                           struct GNUNET_CADET_LocalChannelDestroyMessage,
1414                           NULL),
1415  GNUNET_MQ_hd_var_size (local_data,
1416                         GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
1417                         struct GNUNET_CADET_LocalData,
1418                         NULL),
1419  GNUNET_MQ_hd_fixed_size (local_ack,
1420                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK,
1421                           struct GNUNET_CADET_LocalAck,
1422                           NULL),
1423  GNUNET_MQ_hd_fixed_size (get_peers,
1424                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS,
1425                           struct GNUNET_MessageHeader,
1426                           NULL),
1427  GNUNET_MQ_hd_fixed_size (show_peer,
1428                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER,
1429                           struct GNUNET_CADET_LocalInfo,
1430                           NULL),
1431  GNUNET_MQ_hd_fixed_size (info_tunnels,
1432                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS,
1433                           struct GNUNET_MessageHeader,
1434                           NULL),
1435  GNUNET_MQ_hd_fixed_size (info_tunnel,
1436                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL,
1437                           struct GNUNET_CADET_LocalInfo,
1438                           NULL),
1439  GNUNET_MQ_hd_fixed_size (info_dump,
1440                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP,
1441                           struct GNUNET_MessageHeader,
1442                           NULL),
1443  GNUNET_MQ_handler_end ());
1444
1445 /* end of gnunet-service-cadet-new.c */