GNUnet  0.10.x
gnunet-service-cadet.c
Go to the documentation of this file.
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 it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
35 #include "platform.h"
36 #include "gnunet_util_lib.h"
37 #include "cadet.h"
39 #include "gnunet-service-cadet.h"
48 
49 #define LOG(level, ...) GNUNET_log(level, __VA_ARGS__)
50 
51 
55 struct CadetClient {
59  struct CadetClient *next;
60 
64  struct CadetClient *prev;
65 
71 
76 
81 
87 
93 
97  unsigned int id;
98 };
99 
100 
101 /******************************************************************************/
102 /*********************** GLOBAL VARIABLES ****************************/
103 /******************************************************************************/
104 
105 /****************************** Global variables ******************************/
106 
111 
116 
121 
126 
131 
136 
140 static struct CadetClient *clients_head;
141 
145 static struct CadetClient *clients_tail;
146 
150 static unsigned int next_client_id;
151 
157 
164 
169 
175 
179 unsigned long long ratchet_messages;
180 
185 
190 
194 unsigned long long drop_percent;
195 
196 
203 void
205  struct GNUNET_MQ_Envelope *env)
206 {
207  GNUNET_MQ_send(c->mq,
208  env);
209 }
210 
211 
218 const char *
219 GSC_2s(struct CadetClient *c)
220 {
221  static char buf[32];
222 
223  GNUNET_snprintf(buf,
224  sizeof(buf),
225  "Client(%u)",
226  c->id);
227  return buf;
228 }
229 
230 
238 static struct CadetChannel *
241 {
243  ntohl(ccn.channel_of_client));
244 }
245 
246 
255 {
256  struct GNUNET_CADET_ClientChannelNumber ccn = c->next_ccn;
257 
258  /* increment until we have a free one... */
259  while (NULL !=
260  lookup_channel(c,
261  ccn))
262  {
264  = htonl(1 + (ntohl(ccn.channel_of_client)));
265  if (ntohl(ccn.channel_of_client) >=
267  ccn.channel_of_client = htonl(0);
268  }
269  c->next_ccn.channel_of_client
270  = htonl(1 + (ntohl(ccn.channel_of_client)));
271  return ccn;
272 }
273 
274 
289  struct CadetChannel *ch,
290  struct CadetPeer *dest,
291  const struct GNUNET_HashCode *port,
292  uint32_t options)
293 {
294  struct GNUNET_MQ_Envelope *env;
297 
298  ccn = client_get_next_ccn(c);
301  ntohl(ccn.channel_of_client),
302  ch,
305  "Accepting incoming %s from %s on open port %s (%u), assigning ccn %X\n",
306  GCCH_2s(ch),
307  GCP_2s(dest),
308  GNUNET_h2s(port),
309  (uint32_t)ntohl(options),
310  (uint32_t)ntohl(ccn.channel_of_client));
311  /* notify local client about incoming connection! */
312  env = GNUNET_MQ_msg(cm,
314  cm->ccn = ccn;
315  cm->port = *port;
316  cm->opt = htonl(options);
317  cm->peer = *GCP_get_id(dest);
319  env);
320  return ccn;
321 }
322 
323 
333 static int
335  const struct GNUNET_PeerIdentity *pid,
336  void *value)
337 {
338  struct CadetPeer *cp = value;
339  struct CadetTunnel *t = GCP_get_tunnel(cp,
340  GNUNET_NO);
341 
342  if (NULL != t)
344  return GNUNET_OK;
345 }
346 
347 
357 static int
359  const struct GNUNET_PeerIdentity *pid,
360  void *value)
361 {
362  struct CadetPeer *cp = value;
363 
365  return GNUNET_OK;
366 }
367 
368 
372 static void
374 {
375  if (NULL != stats)
376  {
378  GNUNET_NO);
379  stats = NULL;
380  }
381  /* Destroy tunnels. Note that all channels must be destroyed first! */
383  NULL);
384  /* All tunnels, channels, connections and CORE must be down before this point. */
386  NULL);
387  /* All paths, tunnels, channels, connections and CORE must be down before this point. */
389  if (NULL != open_ports)
390  {
392  open_ports = NULL;
393  }
394  if (NULL != loose_channels)
395  {
397  loose_channels = NULL;
398  }
399  if (NULL != peers)
400  {
402  peers = NULL;
403  }
404  if (NULL != connections)
405  {
407  connections = NULL;
408  }
409  if (NULL != ats_ch)
410  {
412  ats_ch = NULL;
413  }
414  GCD_shutdown();
415  GCH_shutdown();
416  GNUNET_free_non_null(my_private_key);
417  my_private_key = NULL;
418 }
419 
420 
426 static void
427 shutdown_task(void *cls)
428 {
430  "Shutting down\n");
432  GCO_shutdown();
433  if (NULL == clients_head)
434  shutdown_rest();
435 }
436 
437 
447 static int
449  const struct GNUNET_HashCode *port,
450  void *value)
451 {
452  struct OpenPort *op = cls;
453  struct CadetChannel *ch = value;
454 
455  GCCH_bind(ch,
456  op->c,
457  &op->port);
460  &op->h_port,
461  ch));
462  return GNUNET_YES;
463 }
464 
465 
475 static void
477  const struct GNUNET_CADET_PortMessage *pmsg)
478 {
479  struct CadetClient *c = cls;
480  struct OpenPort *op;
481 
483  "Open port %s requested by %s\n",
484  GNUNET_h2s(&pmsg->port),
485  GSC_2s(c));
486  if (NULL == c->ports)
488  GNUNET_NO);
489  op = GNUNET_new(struct OpenPort);
490  op->c = c;
491  op->port = pmsg->port;
492  GCCH_hash_port(&op->h_port,
493  &pmsg->port,
494  &my_full_id);
495  if (GNUNET_OK !=
497  &op->port,
498  op,
500  {
501  GNUNET_break(0);
503  return;
504  }
505  (void)GNUNET_CONTAINER_multihashmap_put(open_ports,
506  &op->h_port,
507  op,
510  &op->h_port,
512  op);
514 }
515 
516 
526 static void
528  const struct GNUNET_CADET_PortMessage *pmsg)
529 {
530  struct CadetClient *c = cls;
531  struct OpenPort *op;
532 
534  "Closing port %s as requested by %s\n",
535  GNUNET_h2s(&pmsg->port),
536  GSC_2s(c));
537  if (NULL == c->ports)
538  {
539  /* Client closed a port despite _never_ having opened one? */
540  GNUNET_break(0);
542  return;
543  }
545  &pmsg->port);
546  if (NULL == op)
547  {
548  GNUNET_break(0);
550  return;
551  }
554  &op->port,
555  op));
558  &op->h_port,
559  op));
560  GNUNET_free(op);
562 }
563 
564 
571 static void
573  const struct GNUNET_CADET_LocalChannelCreateMessage *tcm)
574 {
575  struct CadetClient *c = cls;
576  struct CadetChannel *ch;
577 
579  {
580  /* Channel ID not in allowed range. */
581  GNUNET_break(0);
583  return;
584  }
585  ch = lookup_channel(c,
586  tcm->ccn);
587  if (NULL != ch)
588  {
589  /* Channel ID already in use. Not allowed. */
590  GNUNET_break(0);
592  return;
593  }
595  "New channel to %s at port %s requested by %s\n",
596  GNUNET_i2s(&tcm->peer),
597  GNUNET_h2s(&tcm->port),
598  GSC_2s(c));
599 
600  /* Create channel */
601  ch = GCCH_channel_local_new(c,
602  tcm->ccn,
603  GCP_get(&tcm->peer,
604  GNUNET_YES),
605  &tcm->port,
606  ntohl(tcm->opt));
607  if (NULL == ch)
608  {
609  GNUNET_break(0);
611  return;
612  }
615  ntohl(tcm->ccn.channel_of_client),
616  ch,
618 
620 }
621 
622 
629 static void
632 {
633  struct CadetClient *c = cls;
634  struct CadetChannel *ch;
635 
636  ch = lookup_channel(c,
637  msg->ccn);
638  if (NULL == ch)
639  {
640  /* Client attempted to destroy unknown channel.
641  Can happen if the other side went down at the same time.*/
643  "%s tried to destroy unknown channel %X\n",
644  GSC_2s(c),
645  (uint32_t)ntohl(msg->ccn.channel_of_client));
647  return;
648  }
650  "%s is destroying %s\n",
651  GSC_2s(c),
652  GCCH_2s(ch));
655  ntohl(msg->ccn.channel_of_client),
656  ch));
658  c,
659  msg->ccn);
661 }
662 
663 
671 static int
673  const struct GNUNET_CADET_LocalData *msg)
674 {
675  size_t payload_size;
676  size_t payload_claimed_size;
677  const char *buf;
678  struct GNUNET_MessageHeader pa;
679 
680  /* FIXME: what is the format we shall allow for @a msg?
681  ONE payload item or multiple? Seems current cadet_api
682  at least in theory allows more than one. Next-gen
683  cadet_api will likely no more, so we could then
684  simplify this mess again. */
685  /* Sanity check for message size */
686  payload_size = ntohs(msg->header.size) - sizeof(*msg);
687  buf = (const char *)&msg[1];
688  while (payload_size >= sizeof(struct GNUNET_MessageHeader))
689  {
690  /* need to memcpy() for alignment */
691  GNUNET_memcpy(&pa,
692  buf,
693  sizeof(pa));
694  payload_claimed_size = ntohs(pa.size);
695  if ((payload_size < payload_claimed_size) ||
696  (payload_claimed_size < sizeof(struct GNUNET_MessageHeader)) ||
697  (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size))
698  {
699  GNUNET_break(0);
701  "Local data of %u total size had sub-message %u at %u with %u bytes\n",
702  ntohs(msg->header.size),
703  ntohs(pa.type),
704  (unsigned int)(buf - (const char *)&msg[1]),
705  (unsigned int)payload_claimed_size);
706  return GNUNET_SYSERR;
707  }
708  payload_size -= payload_claimed_size;
709  buf += payload_claimed_size;
710  }
711  if (0 != payload_size)
712  {
713  GNUNET_break_op(0);
714  return GNUNET_SYSERR;
715  }
716  return GNUNET_OK;
717 }
718 
719 
727 static void
729  const struct GNUNET_CADET_LocalData *msg)
730 {
731  struct CadetClient *c = cls;
732  struct CadetChannel *ch;
733  size_t payload_size;
734  const char *buf;
735 
736  ch = lookup_channel(c,
737  msg->ccn);
738  if (NULL == ch)
739  {
740  /* Channel does not exist (anymore) */
742  "Dropping payload for channel %u from client (channel unknown, other endpoint may have disconnected)\n",
743  (unsigned int)ntohl(msg->ccn.channel_of_client));
745  return;
746  }
747  payload_size = ntohs(msg->header.size) - sizeof(*msg);
749  "# payload received from clients",
750  payload_size,
751  GNUNET_NO);
752  buf = (const char *)&msg[1];
754  "Received %u bytes payload from %s for %s\n",
755  (unsigned int)payload_size,
756  GSC_2s(c),
757  GCCH_2s(ch));
758  if (GNUNET_OK !=
760  msg->ccn,
761  buf,
762  payload_size))
763  {
764  GNUNET_break(0);
766  return;
767  }
769 }
770 
771 
778 static void
780  const struct GNUNET_CADET_LocalAck *msg)
781 {
782  struct CadetClient *c = cls;
783  struct CadetChannel *ch;
784 
785  ch = lookup_channel(c,
786  msg->ccn);
787  if (NULL == ch)
788  {
789  /* Channel does not exist (anymore) */
791  "Ignoring local ACK for channel %u from client (channel unknown, other endpoint may have disconnected)\n",
792  (unsigned int)ntohl(msg->ccn.channel_of_client));
794  return;
795  }
797  "Got a local ACK from %s for %s\n",
798  GSC_2s(c),
799  GCCH_2s(ch));
801  msg->ccn);
803 }
804 
805 
814 static int
816  const struct GNUNET_PeerIdentity *peer,
817  void *value)
818 {
819  struct CadetClient *c = cls;
820  struct CadetPeer *p = value;
821  struct GNUNET_MQ_Envelope *env;
823 
824  env = GNUNET_MQ_msg(msg,
826  msg->destination = *peer;
827  msg->paths = htons(GCP_count_paths(p));
828  msg->tunnel = htons(NULL != GCP_get_tunnel(p,
829  GNUNET_NO));
830  msg->best_path_length = htonl(0); // FIXME: get length of shortest known path!
831  GNUNET_MQ_send(c->mq,
832  env);
833  return GNUNET_YES;
834 }
835 
836 
843 static void
845  const struct GNUNET_MessageHeader *message)
846 {
847  struct CadetClient *c = cls;
848  struct GNUNET_MQ_Envelope *env;
849  struct GNUNET_MessageHeader *reply;
850 
852  c);
853  env = GNUNET_MQ_msg(reply,
855  GNUNET_MQ_send(c->mq,
856  env);
858 }
859 
860 
871 static int
873  struct CadetPeerPath *path,
874  unsigned int off)
875 {
876  struct GNUNET_MQ_Handle *mq = cls;
877  struct GNUNET_MQ_Envelope *env;
878  struct GNUNET_CADET_LocalInfoPath *resp;
879  struct GNUNET_PeerIdentity *id;
880  size_t path_size;
881  unsigned int path_length;
882 
883  path_length = GCPP_get_length(path);
884  path_size = sizeof(struct GNUNET_PeerIdentity) * path_length;
885  if (sizeof(*resp) + path_size > UINT16_MAX)
886  {
887  /* try just giving the relevant path */
888  path_length = GNUNET_MIN((UINT16_MAX - sizeof(*resp)) / sizeof(struct GNUNET_PeerIdentity),
889  off);
890  path_size = sizeof(struct GNUNET_PeerIdentity) * path_length;
891  }
892  if (sizeof(*resp) + path_size > UINT16_MAX)
893  {
895  "Path of %u entries is too long for info message\n",
896  path_length);
897  return GNUNET_YES;
898  }
899  env = GNUNET_MQ_msg_extra(resp,
900  path_size,
902  id = (struct GNUNET_PeerIdentity *)&resp[1];
903 
904  /* Don't copy first peer. First peer is always the local one. Last
905  * peer is always the destination (leave as 0, EOL).
906  */
907  for (unsigned int i = 0; i < path_length; i++)
908  id[i] = *GCP_get_id(GCPP_get_peer_at_offset(path,
909  i));
910  resp->off = htonl(off);
911  GNUNET_MQ_send(mq,
912  env);
913  return GNUNET_YES;
914 }
915 
916 
923 static void
926 {
927  struct CadetClient *c = cls;
928  struct CadetPeer *p;
929  struct GNUNET_MQ_Envelope *env;
930  struct GNUNET_MessageHeader *resp;
931 
932  p = GCP_get(&msg->peer,
933  GNUNET_NO);
934  if (NULL != p)
937  c->mq);
938  env = GNUNET_MQ_msg(resp,
940  GNUNET_MQ_send(c->mq,
941  env);
943 }
944 
945 
954 static int
956  const struct GNUNET_PeerIdentity *peer,
957  void *value)
958 {
959  struct CadetClient *c = cls;
960  struct CadetPeer *p = value;
961  struct GNUNET_MQ_Envelope *env;
963  struct CadetTunnel *t;
964 
965  t = GCP_get_tunnel(p,
966  GNUNET_NO);
967  if (NULL == t)
968  return GNUNET_YES;
969  env = GNUNET_MQ_msg(msg,
971  msg->destination = *peer;
972  msg->channels = htonl(GCT_count_channels(t));
973  msg->connections = htonl(GCT_count_any_connections(t));
974  msg->cstate = htons(0);
975  msg->estate = htons((uint16_t)GCT_get_estate(t));
976  GNUNET_MQ_send(c->mq,
977  env);
978  return GNUNET_YES;
979 }
980 
981 
988 static void
990  const struct GNUNET_MessageHeader *message)
991 {
992  struct CadetClient *c = cls;
993  struct GNUNET_MQ_Envelope *env;
994  struct GNUNET_MessageHeader *reply;
995 
997  c);
998  env = GNUNET_MQ_msg(reply,
1000  GNUNET_MQ_send(c->mq,
1001  env);
1003 }
1004 
1005 
1014 static void *
1016  struct GNUNET_SERVICE_Client *client,
1017  struct GNUNET_MQ_Handle *mq)
1018 {
1019  struct CadetClient *c;
1020 
1021  c = GNUNET_new(struct CadetClient);
1022  c->client = client;
1023  c->mq = mq;
1024  c->id = next_client_id++; /* overflow not important: just for debug */
1025  c->channels
1027  GNUNET_CONTAINER_DLL_insert(clients_head,
1028  clients_tail,
1029  c);
1031  "# clients",
1032  +1,
1033  GNUNET_NO);
1035  "%s connected\n",
1036  GSC_2s(c));
1037  return c;
1038 }
1039 
1040 
1048 void
1051  struct CadetChannel *ch)
1052 {
1053  struct GNUNET_MQ_Envelope *env;
1055 
1056  env = GNUNET_MQ_msg(tdm,
1058  tdm->ccn = ccn;
1060  env);
1063  ntohl(ccn.channel_of_client),
1064  ch));
1065 }
1066 
1067 
1075 void
1077  struct CadetChannel *ch)
1078 {
1080  GNUNET_CONTAINER_multihashmap_remove(loose_channels,
1081  h_port,
1082  ch));
1083 }
1084 
1085 
1094 static int
1096  uint32_t key,
1097  void *value)
1098 {
1099  struct CadetClient *c = cls;
1101  struct CadetChannel *ch = value;
1102 
1104  "Destroying %s, due to %s disconnecting.\n",
1105  GCCH_2s(ch),
1106  GSC_2s(c));
1107  ccn.channel_of_client = htonl(key);
1109  c,
1110  ccn);
1113  key,
1114  ch));
1115  return GNUNET_OK;
1116 }
1117 
1118 
1127 static int
1129  const struct GNUNET_HashCode *port,
1130  void *value)
1131 {
1132  struct CadetClient *c = cls;
1133  struct OpenPort *op = value;
1134 
1135  GNUNET_assert(c == op->c);
1137  "Closing port %s due to %s disconnect.\n",
1138  GNUNET_h2s(port),
1139  GSC_2s(c));
1142  &op->h_port,
1143  op));
1146  port,
1147  op));
1148  GNUNET_free(op);
1149  return GNUNET_OK;
1150 }
1151 
1152 
1160 static void
1162  struct GNUNET_SERVICE_Client *client,
1163  void *internal_cls)
1164 {
1165  struct CadetClient *c = internal_cls;
1166 
1167  GNUNET_assert(c->client == client);
1169  "%s is disconnecting.\n",
1170  GSC_2s(c));
1171  if (NULL != c->channels)
1172  {
1175  c);
1178  }
1179  if (NULL != c->ports)
1180  {
1183  c);
1185  }
1186  GNUNET_CONTAINER_DLL_remove(clients_head,
1187  clients_tail,
1188  c);
1190  "# clients",
1191  -1,
1192  GNUNET_NO);
1193  GNUNET_free(c);
1194  if ((NULL == clients_head) &&
1196  shutdown_rest();
1197 }
1198 
1199 
1207 static void
1208 run(void *cls,
1209  const struct GNUNET_CONFIGURATION_Handle *c,
1211 {
1212  cfg = c;
1213  if (GNUNET_OK !=
1215  "CADET",
1216  "RATCHET_MESSAGES",
1217  &ratchet_messages))
1218  {
1220  "CADET",
1221  "RATCHET_MESSAGES",
1222  "needs to be a number");
1223  ratchet_messages = 64;
1224  }
1225  if (GNUNET_OK !=
1227  "CADET",
1228  "RATCHET_TIME",
1229  &ratchet_time))
1230  {
1232  "CADET",
1233  "RATCHET_TIME",
1234  "need delay value");
1236  }
1237  if (GNUNET_OK !=
1239  "CADET",
1240  "REFRESH_CONNECTION_TIME",
1241  &keepalive_period))
1242  {
1244  "CADET",
1245  "REFRESH_CONNECTION_TIME",
1246  "need delay value");
1248  }
1249  if (GNUNET_OK !=
1251  "CADET",
1252  "DROP_PERCENT",
1253  &drop_percent))
1254  {
1255  drop_percent = 0;
1256  }
1257  else
1258  {
1259  LOG(GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
1260  LOG(GNUNET_ERROR_TYPE_WARNING, "Cadet is running with DROP enabled.\n");
1261  LOG(GNUNET_ERROR_TYPE_WARNING, "This is NOT a good idea!\n");
1262  LOG(GNUNET_ERROR_TYPE_WARNING, "Remove DROP_PERCENT from config file.\n");
1263  LOG(GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
1264  }
1266  if (NULL == my_private_key)
1267  {
1268  GNUNET_break(0);
1270  return;
1271  }
1272  GNUNET_CRYPTO_eddsa_key_get_public(my_private_key,
1274  stats = GNUNET_STATISTICS_create("cadet",
1275  c);
1277  NULL);
1278  ats_ch = GNUNET_ATS_connectivity_init(c);
1279  /* FIXME: optimize code to allow GNUNET_YES here! */
1280  open_ports = GNUNET_CONTAINER_multihashmap_create(16,
1281  GNUNET_NO);
1282  loose_channels = GNUNET_CONTAINER_multihashmap_create(16,
1283  GNUNET_NO);
1285  GNUNET_YES);
1286  connections = GNUNET_CONTAINER_multishortmap_create(256,
1287  GNUNET_YES);
1288  GCH_init(c);
1289  GCD_init(c);
1290  GCO_init(c);
1292  "CADET started for peer %s\n",
1294 }
1295 
1296 
1301  ("cadet",
1303  &run,
1306  NULL,
1307  GNUNET_MQ_hd_fixed_size(port_open,
1309  struct GNUNET_CADET_PortMessage,
1310  NULL),
1311  GNUNET_MQ_hd_fixed_size(port_close,
1313  struct GNUNET_CADET_PortMessage,
1314  NULL),
1315  GNUNET_MQ_hd_fixed_size(channel_create,
1318  NULL),
1322  NULL),
1323  GNUNET_MQ_hd_var_size(local_data,
1325  struct GNUNET_CADET_LocalData,
1326  NULL),
1327  GNUNET_MQ_hd_fixed_size(local_ack,
1329  struct GNUNET_CADET_LocalAck,
1330  NULL),
1333  struct GNUNET_MessageHeader,
1334  NULL),
1335  GNUNET_MQ_hd_fixed_size(show_path,
1338  NULL),
1339  GNUNET_MQ_hd_fixed_size(info_tunnels,
1341  struct GNUNET_MessageHeader,
1342  NULL),
1344 
1345 /* end of gnunet-service-cadet-new.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct CadetChannel * lookup_channel(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Lookup channel of client c by ccn.
static void handle_local_data(void *cls, const struct GNUNET_CADET_LocalData *msg)
Handler for client payload traffic to be send on a channel to another peer.
uint16_t cstate
Connection state.
Definition: cadet.h:391
static unsigned int next_client_id
Next ID to assign to a client.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH
Local information of service about a specific path.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:147
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
Peer description.
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
Message to allow the client send more data to the service (always service -> client).
Definition: cadet.h:212
GNUnet CADET service with encryption.
#define GNUNET_TIME_UNIT_HOURS
One hour.
static struct CadetClient * clients_head
DLL with all the clients, head.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
static void channel_destroy(struct CadetChannel *ch)
Destroy the given channel.
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:110
enum CadetTunnelEState GCT_get_estate(struct CadetTunnel *t)
Get the encryption state of a tunnel.
void GCP_drop_owned_paths(struct CadetPeer *cp)
Drop all paths owned by this peer, and do not allow new ones to be added: We are shutting down...
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
struct GNUNET_CONTAINER_MultiPeerMap * peers
Map from PIDs to struct CadetPeer entries.
Message for or to a client to destroy tunnel.
Definition: cadet.h:169
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY
Tell client that a channel was destroyed.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int path_info_iterator(void *cls, struct CadetPeerPath *path, unsigned int off)
Iterator over all paths of a peer to build an InfoPeer message.
static void shutdown_rest()
Shutdown everything once the clients have disconnected.
A connection is a live end-to-end messaging mechanism where the peers are identified by a path and kn...
Handle to a service.
Definition: service.c:114
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct CadetPeer * dest
Destinaton to ping.
static int destroy_tunnels_now(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Callback invoked on all peers to destroy all tunnels that may still exist.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
Message for a client to create and destroy channels.
Definition: cadet.h:117
uint32_t best_path_length
Shortest known path.
Definition: cadet.h:347
static void handle_get_peers(void *cls, const struct GNUNET_MessageHeader *message)
Handler for client&#39;s INFO PEERS request.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GCD_shutdown(void)
Shut down the DHT subsystem.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Callback called when a client disconnected from the service.
struct GNUNET_ATS_ConnectivityHandle * ats_ch
Handle to communicate with ATS.
struct GNUNET_PeerIdentity destination
ID of the destination of the tunnel (can be local peer).
Definition: cadet.h:376
static void handle_port_close(void *cls, const struct GNUNET_CADET_PortMessage *pmsg)
Handler for port close requests.
static void handle_channel_create(void *cls, const struct GNUNET_CADET_LocalChannelCreateMessage *tcm)
Handler for requests for us creating a new channel to another peer and port.
unsigned int GCT_count_any_connections(const struct CadetTunnel *t)
Count all created connections of a tunnel.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
static struct CadetClient * clients_tail
DLL with all the clients, tail.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static void handle_local_ack(void *cls, const struct GNUNET_CADET_LocalAck *msg)
Handler for client&#39;s ACKs for payload traffic.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Tunnels that belong to this client, indexed by local id, value is a struct CadetChannel.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
Information we track per tunnel.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Message to inform the client about channels in the service.
Definition: cadet.h:252
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct CadetChannel * GCCH_channel_local_new(struct CadetClient *owner, struct GNUNET_CADET_ClientChannelNumber ccn, struct CadetPeer *destination, const struct GNUNET_HashCode *port, uint32_t options)
Create a new channel.
void GSC_handle_remote_channel_destroy(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn, struct CadetChannel *ch)
A channel was destroyed by the other peer.
void GCH_shutdown()
Shut down the hello subsystem.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
static struct GNUNET_SCHEDULER_Task * t
Main task.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GCCH_hash_port(struct GNUNET_HashCode *h_port, const struct GNUNET_HashCode *port, const struct GNUNET_PeerIdentity *listener)
Hash the port and initiator and listener to calculate the "challenge" h_port we send to the other pee...
unsigned int id
ID of the client, mainly for debug messages.
uint16_t paths
Number of paths.
Definition: cadet.h:337
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE
Ask the cadet service to create a new channel.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS
Local information about all tunnels of service.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_PeerIdentity peer
ID of the destination of the channel (can be local peer).
Definition: cadet.h:266
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
Handle for the service.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Callback called when a client connects to the service.
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
static struct GNUNET_CADET_ClientChannelNumber client_get_next_ccn(struct CadetClient *c)
Obtain the next LID to use for incoming connections to the given client.
int GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
int16_t tunnel
Do we have a tunnel toward this peer?
Definition: cadet.h:342
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GCCH_handle_local_ack(struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber client_ccn)
Handle ACK from client on local channel.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap * open_ports
All ports clients of this peer have opened.
Handle to a client that is connected to a service.
Definition: service.c:246
struct GNUNET_CONTAINER_MultiHashMap * loose_channels
Map from ports to channels where the ports were closed at the time we got the inbound connection...
void GCP_destroy_all_peers()
Clean up all entries about all peers.
Message to inform the client about one of the paths known to the service.
Definition: cadet.h:312
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_TIME_Relative ratchet_time
How long until we trigger a ratched advance due to time.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK
Local ACK for data.
Information we track per peer.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
static char * value
Value of the record to add/remove.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS_END
End of local information about all peers known to the service.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_HashCode h_port
Port hashed with our PID (matches incoming OPEN messages).
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
Struct containing all information regarding a channel to a remote client.
struct GNUNET_SERVICE_Client * client
Client handle.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:80
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN
Start listening on a port.
#define LOG(level,...)
Message to inform the client about one of the peers in the service.
Definition: cadet.h:328
static void shutdown_task(void *cls)
Task run during shutdown.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
static char buf[2048]
uint32_t off
Offset of the peer that was requested.
Definition: cadet.h:321
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH
Request local information of service about paths to specific peer.
cadet service; dealing with hello messages
static void get_peers(void *cls)
Call CADET&#39;s meta API, get all peers known to a peer.
Definition: gnunet-cadet.c:583
Number uniquely identifying a channel of a client.
Definition: cadet.h:102
struct GNUNET_HashCode port
Port number.
Message to inform the client about one of the tunnels in the service.
Definition: cadet.h:361
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
Minimum value for channel IDs of local clients.
Definition: cadet.h:71
Internal representation of the hash map.
Internal representation of the hash map.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
struct GNUNET_CADET_ClientChannelNumber next_ccn
Channel ID to use for the next incoming channel for this client.
A 512-bit hashcode.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel.
Definition: cadet.h:194
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
GNUNET_SERVICE_MAIN("cadet", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(port_open, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN, struct GNUNET_CADET_PortMessage, NULL), GNUNET_MQ_hd_fixed_size(port_close, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE, struct GNUNET_CADET_PortMessage, NULL), GNUNET_MQ_hd_fixed_size(channel_create, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE, struct GNUNET_CADET_LocalChannelCreateMessage, NULL), GNUNET_MQ_hd_fixed_size(channel_destroy, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY, struct GNUNET_CADET_LocalChannelDestroyMessage, NULL), GNUNET_MQ_hd_var_size(local_data, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, struct GNUNET_CADET_LocalData, NULL), GNUNET_MQ_hd_fixed_size(local_ack, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, struct GNUNET_CADET_LocalAck, NULL), GNUNET_MQ_hd_fixed_size(get_peers, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PEERS, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(show_path, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH, struct GNUNET_CADET_RequestPathInfoMessage, NULL), GNUNET_MQ_hd_fixed_size(info_tunnels, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
struct CadetClient * next
Linked list next.
unsigned long long drop_percent
Set to non-zero values to create random drops to test retransmissions.
#define GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE
Maximum message size that can be sent on CADET.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PEERS
Request local information about all peers known to the service.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
Struct containing all information regarding a tunnel to a peer.
void GCO_shutdown()
Shut down the CORE subsystem.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
Struct containing information about a client of the service.
unsigned long long ratchet_messages
How many messages are needed to trigger an AXOLOTL ratchet advance.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode port
Port to open/close.
Definition: cadet.h:129
struct GNUNET_HashCode key
The key used in the DHT.
Internal representation of the hash map.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Message for a client to create channels.
Definition: cadet.h:136
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END
End of local information about all tunnels of service.
void GCCH_channel_local_destroy(struct CadetChannel *ch, struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Destroy locally created channel.
static int destroy_paths_now(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Callback invoked on all peers to destroy all tunnels that may still exist.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void GCT_destroy_tunnel_now(struct CadetTunnel *t)
Destroys the tunnel t now, without delay.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel allowed to send more data.
Definition: cadet.h:221
uint32_t connections
Number of connections.
Definition: cadet.h:381
static int get_all_peers_iterator(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Iterator over all peers to send a monitoring client info about each peer.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS
Request local information about all tunnels of service.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:272
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports that this client has declared interest in.
uint32_t channels
Number of channels.
Definition: cadet.h:371
int shutting_down
Signal that shutdown is happening: prevent recovery measures.
unsigned int GCP_iterate_indirect_paths(struct CadetPeer *cp, GCP_PathIterator callback, void *callback_cls)
Iterate over the paths to a peer without direct link.
struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Own private key.
Allow multiple values with the same key.
static int get_all_tunnels_iterator(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Iterator over all tunnels to send a monitoring client info about each tunnel.
Handle to a message queue.
Definition: mq.c:84
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
Private ECC key encoded for transmission.
void GCD_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the DHT subsystem.
uint16_t estate
Encryption state.
Definition: cadet.h:386
The identity of the host (wraps the signing key of the peer).
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:178
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
configuration data
Definition: configuration.c:83
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE
Stop listening on a port.
static void handle_port_open(void *cls, const struct GNUNET_CADET_PortMessage *pmsg)
Handle port open request.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS
Local information about all peers known to the service.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA
Payload client <-> service.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END
End of local information of service about a specific path.
unsigned int GCT_count_channels(struct CadetTunnel *t)
Count channels of a tunnel.
#define GNUNET_log(kind,...)
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our configuration.
void GSC_send_to_client(struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
Send a message to a client.
struct CadetClient * prev
Linked list prev.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Setup CADET internals.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
static int client_release_ports(void *cls, const struct GNUNET_HashCode *port, void *value)
Remove client&#39;s ports from the global hashmap on disconnect.
struct GNUNET_PeerIdentity destination
ID of the peer (can be local peer).
Definition: cadet.h:352
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer&#39;s key from the file specified in the configuration...
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
static void handle_channel_destroy(void *cls, const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
Handler for requests of destroying an existing channel.
Header for all communications.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA.
Definition: cadet.h:189
#define GNUNET_YES
Definition: gnunet_common.h:77
void GCO_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the CORE subsystem.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
Message for cadet data traffic.
Definition: cadet.h:185
void GSC_drop_loose_channel(const struct GNUNET_HashCode *h_port, struct CadetChannel *ch)
A client that created a loose channel that was not bound to a port disconnected, drop it from the loo...
cadet service; dealing with DHT requests and results
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
void GCP_iterate_all(GNUNET_CONTAINER_PeerMapIterator iter, void *cls)
Iterate over all known peers.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
cadet service; interaction with CORE service
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
static void handle_info_tunnels(void *cls, const struct GNUNET_MessageHeader *message)
Handler for client&#39;s GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS request.
Information regarding a possible path to reach a peer.
unsigned int GCP_count_paths(const struct CadetPeer *cp)
Count the number of known paths toward the peer.
Handle to the ATS subsystem for connectivity management.
void GCH_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the hello subsystem.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
static int bind_loose_channel(void *cls, const struct GNUNET_HashCode *port, void *value)
We had a remote connection value to port h_port before client cls opened port port.
static int channel_destroy_iterator(void *cls, uint32_t key, void *value)
Iterator for deleting each channel whose client endpoint disconnected.
unsigned int GCPP_get_length(struct CadetPeerPath *path)
Return the length of the path.
struct GNUNET_PeerIdentity peer
Channel&#39;s peer.
Definition: cadet.h:152
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct CadetClient * c
Client that opened the port.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
int GCCH_handle_local_data(struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber sender_ccn, const char *buf, size_t buf_len)
Handle data given by a client.
struct GNUNET_HashCode port
Port of the channel.
Definition: cadet.h:157
Port opened by a client.
static int check_local_data(void *cls, const struct GNUNET_CADET_LocalData *msg)
Check for client traffic data message is well-formed.
struct GNUNET_MQ_Handle * mq
Handle to communicate with the client.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
Time for relative time used by GNUnet, in microseconds.
static void handle_show_path(void *cls, const struct GNUNET_CADET_RequestPathInfoMessage *msg)
Handler for client&#39;s GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH request.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
void GCCH_bind(struct CadetChannel *ch, struct CadetClient *c, const struct GNUNET_HashCode *port)
A client is bound to the port that we have a channel open to.
Information we track per peer.
struct GNUNET_CADET_ClientChannelNumber GSC_bind(struct CadetClient *c, struct CadetChannel *ch, struct CadetPeer *dest, const struct GNUNET_HashCode *port, uint32_t options)
Bind incoming channel to this client, and notify client about incoming connection.