gnunet-service-cadet.c 39 KB

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