GNUnet  0.10.x
gnunet-cadet.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012, 2017, 2019 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 
27 #include "platform.h"
28 #include "gnunet_util_lib.h"
29 #include "gnunet_cadet_service.h"
30 #include "cadet.h"
31 
32 #define STREAM_BUFFER_SIZE 1024 // Pakets
33 
37 static int request_peers;
38 
42 static char *peer_id;
43 
47 static int request_tunnels;
48 
52 static char *conn_id;
53 
57 static char *channel_id;
58 
62 static char *listen_port;
63 
67 static int echo;
68 
73 
78 
82 static char *target_id;
83 
87 static char *target_port = "default";
88 
92 static struct GNUNET_CADET_Handle *mh;
93 
97 static const struct GNUNET_CONFIGURATION_Handle *my_cfg;
98 
102 static struct GNUNET_CADET_GetPath *gpo;
103 
108 
113 
117 static struct GNUNET_CADET_Channel *ch;
118 
122 static struct GNUNET_HashCode porthash;
123 
128 
133 
137 static struct GNUNET_SCHEDULER_Task *job;
138 
139 static unsigned int sent_pkt;
140 
141 
145 static void
146 listen_stdio (void);
147 
148 
156 static const char *
157 enc_2s (uint16_t status)
158 {
159  switch (status)
160  {
161  case 0:
162  return "NULL ";
163  case 1:
164  return "KSENT";
165  case 2:
166  return "KRECV";
167  case 3:
168  return "READY";
169  default:
170  return "";
171  }
172 }
173 
174 
182 static const char *
183 conn_2s (uint16_t status)
184 {
185  switch (status)
186  {
187  case 0:
188  return "NEW ";
189  case 1:
190  return "SRCH ";
191  case 2:
192  return "WAIT ";
193  case 3:
194  return "READY";
195  case 4:
196  return "SHUTD";
197  default:
198  return "";
199  }
200 }
201 
202 
203 
209 static void
210 shutdown_task (void *cls)
211 {
213  "Shutdown\n");
214  if (NULL != lp)
215  {
217  lp = NULL;
218  }
219  if (NULL != ch)
220  {
222  ch = NULL;
223  }
224  if (NULL != gpo)
225  {
227  gpo = NULL;
228  }
229  if (NULL != plo)
230  {
232  plo = NULL;
233  }
234  if (NULL != tio)
235  {
237  tio = NULL;
238  }
239  if (NULL != mh)
240  {
242  mh = NULL;
243  }
244  if (NULL != rd_task)
245  {
246  GNUNET_SCHEDULER_cancel (rd_task);
247  rd_task = NULL;
248  }
249  if (NULL != echo_task)
250  {
251  GNUNET_SCHEDULER_cancel (echo_task);
252  echo_task = NULL;
253  }
254  if (NULL != job)
255  {
257  job = NULL;
258  }
259 }
260 
261 void
262 mq_cb(void *cls)
263 {
264  listen_stdio ();
265 }
266 
267 
273 static void
274 read_stdio (void *cls)
275 {
276  struct GNUNET_MQ_Envelope *env;
277  struct GNUNET_MessageHeader *msg;
278  char buf[60000];
279  ssize_t data_size;
280 
281  rd_task = NULL;
282  data_size = read (0,
283  buf,
284  60000);
285  if (data_size < 1)
286  {
288  "read() returned %s\n", strerror(errno));
290  return;
291  }
293  "Read %u bytes from stdio\n",
294  (unsigned int) data_size);
295  env = GNUNET_MQ_msg_extra (msg,
296  data_size,
298  GNUNET_memcpy (&msg[1],
299  buf,
300  data_size);
302  env);
303 
304  sent_pkt++;
305 
306  if (GNUNET_NO == echo)
307  {
308  // Use MQ's notification if too much data of stdin is pooring in too fast.
310  {
311  GNUNET_MQ_notify_sent (env, mq_cb, cls);
312  sent_pkt = 0;
313  }
314  else
315  {
316  listen_stdio ();
317  }
318  }
319  else
320  {
322  }
323 }
324 
325 
329 static void
331 {
332  struct GNUNET_NETWORK_FDSet *rs;
333 
334  /* FIXME: why use 'rs' here, seems overly complicated... */
337  0); /* STDIN */
340  rs,
341  NULL,
342  &read_stdio,
343  NULL);
345 }
346 
347 
357 static void
358 channel_ended (void *cls,
359  const struct GNUNET_CADET_Channel *channel)
360 {
362  "Channel ended!\n");
363  GNUNET_assert (channel == ch);
364  ch = NULL;
366 }
367 
368 
383 static void *
384 channel_incoming (void *cls,
385  struct GNUNET_CADET_Channel *channel,
386  const struct GNUNET_PeerIdentity *initiator)
387 {
389  "Incoming connection from %s\n",
390  GNUNET_i2s_full (initiator));
391  GNUNET_assert (NULL == ch);
392  GNUNET_assert (NULL != lp);
394  lp = NULL;
395  ch = channel;
396  if (GNUNET_NO == echo)
397  listen_stdio ();
398  return channel;
399 }
400 
401 
407 static void
408 send_echo (void *cls)
409 {
410  struct GNUNET_MQ_Envelope *env;
411  struct GNUNET_MessageHeader *msg;
412 
413  echo_task = NULL;
414  if (NULL == ch)
415  return;
416  env = GNUNET_MQ_msg (msg,
419  env);
420 }
421 
422 
431 static int
432 check_data (void *cls,
433  const struct GNUNET_MessageHeader *message)
434 {
435  return GNUNET_OK; /* all is well-formed */
436 }
437 
438 
449 static void
450 handle_data (void *cls,
451  const struct GNUNET_MessageHeader *message)
452 {
453  size_t payload_size = ntohs (message->size) - sizeof (*message);
454  uint16_t len;
455  ssize_t done;
456  uint16_t off;
457  const char *buf;
458 
460  if (GNUNET_YES == echo)
461  {
462  if (NULL != listen_port)
463  {
464  struct GNUNET_MQ_Envelope *env;
465  struct GNUNET_MessageHeader *msg;
466 
467  env = GNUNET_MQ_msg_extra (msg,
468  payload_size,
470  GNUNET_memcpy (&msg[1],
471  &message[1],
472  payload_size);
474  env);
475  return;
476  }
477  else
478  {
479  struct GNUNET_TIME_Relative latency;
480 
484  "time: %s\n",
486  GNUNET_NO));
488  &send_echo,
489  NULL);
490  }
491  }
492 
493  len = ntohs (message->size) - sizeof (*message);
495  "Got %u bytes\n",
496  len);
497  buf = (const char *) &message[1];
498  off = 0;
499  while (off < len)
500  {
501  done = write (1,
502  &buf[off],
503  len - off);
504  if (done <= 0)
505  {
506  if (-1 == done)
508  "write");
510  return;
511  }
512  off += done;
513  }
514 }
515 
516 
526 static void
527 peers_callback (void *cls,
528  const struct GNUNET_CADET_PeerListEntry *ple)
529 {
530  if (NULL == ple)
531  {
532  plo = NULL;
534  return;
535  }
536  FPRINTF (stdout,
537  "%s tunnel: %c, paths: %u\n",
538  GNUNET_i2s_full (&ple->peer),
539  ple->have_tunnel ? 'Y' : 'N',
540  ple->n_paths);
541 }
542 
543 
551 static void
552 path_callback (void *cls,
553  const struct GNUNET_CADET_PeerPathDetail *ppd)
554 {
555  if (NULL == ppd)
556  {
557  gpo = NULL;
559  return;
560  }
561  FPRINTF (stdout,
562  "Path of length %u: ",
563  ppd->path_length);
564  for (unsigned int i = 0; i < ppd->path_length; i++)
565  FPRINTF (stdout,
566  (i == ppd->target_offset) ? "*%s* " : "%s ",
567  GNUNET_i2s (&ppd->path[i]));
568  FPRINTF (stdout,
569  "\n");
570 }
571 
572 
579 static void
580 tunnels_callback (void *cls,
581  const struct GNUNET_CADET_TunnelDetails *td)
582 {
583  if (NULL == td)
584  {
585  tio = NULL;
587  return;
588  }
589  FPRINTF (stdout,
590  "%s [ENC: %s, CON: %s] CHs: %u, CONNs: %u\n",
591  GNUNET_i2s_full (&td->peer),
592  enc_2s (td->estate),
593  conn_2s (td->cstate),
594  td->channels,
595  td->connections);
596 }
597 
598 
604 static void
605 get_peers (void *cls)
606 {
607  job = NULL;
608  plo = GNUNET_CADET_list_peers (my_cfg,
610  NULL);
611 }
612 
613 
619 static void
620 show_peer (void *cls)
621 {
622  struct GNUNET_PeerIdentity pid;
623 
624  job = NULL;
625  if (GNUNET_OK !=
627  strlen (peer_id),
628  &pid.public_key))
629  {
630  fprintf (stderr,
631  _("Invalid peer ID `%s'\n"),
632  peer_id);
634  return;
635  }
636  gpo = GNUNET_CADET_get_path (my_cfg,
637  &pid,
638  &path_callback,
639  NULL);
640 }
641 
642 
648 static void
649 get_tunnels (void *cls)
650 {
651  job = NULL;
652  tio = GNUNET_CADET_list_tunnels (my_cfg,
654  NULL);
655 }
656 
657 
663 static void
664 show_channel (void *cls)
665 {
666  job = NULL;
667  GNUNET_break (0);
668 }
669 
670 
676 static void
677 show_connection (void *cls)
678 {
679  job = NULL;
680  GNUNET_break (0);
681 }
682 
683 
692 static void
693 run (void *cls,
694  char *const *args,
695  const char *cfgfile,
696  const struct GNUNET_CONFIGURATION_Handle *cfg)
697 {
698  struct GNUNET_MQ_MessageHandler handlers[] = {
701  struct GNUNET_MessageHeader,
702  NULL),
704  };
705 
706  /* FIXME add option to monitor apps */
707  my_cfg = cfg;
708  target_id = args[0];
709  if (target_id && args[1])
710  target_port = args[1];
711 
712  if ( (0 != (request_peers | request_tunnels)
713  || NULL != conn_id
714  || NULL != channel_id)
715  && target_id != NULL)
716  {
717  FPRINTF (stderr,
718  _("Extra arguments are not applicable "
719  "in combination with this option.\n"));
720  return;
721  }
722 
723  if (NULL != peer_id)
724  {
726  "Show peer\n");
728  NULL);
729  }
730  else if (NULL != channel_id)
731  {
733  "Show channel\n");
735  NULL);
736  }
737  else if (NULL != conn_id)
738  {
740  "Show connection\n");
742  NULL);
743  }
744  else if (GNUNET_YES == request_peers)
745  {
747  "Show all peers\n");
749  NULL);
750  }
751  else if (GNUNET_YES == request_tunnels)
752  {
754  "Show all tunnels\n");
756  NULL);
757  }
758 
760  "Connecting to CADET service\n");
761  mh = GNUNET_CADET_connect (cfg);
763  NULL);
764  if (NULL == mh)
765  {
767  return;
768  }
769  if (NULL != listen_port)
770  {
772  "Opening CADET listen port\n");
774  strlen (listen_port),
775  &porthash);
776  lp = GNUNET_CADET_open_port (mh,
777  &porthash,
779  NULL,
780  NULL /* window changes */,
781  &channel_ended,
782  handlers);
783  }
784  if (NULL != target_id)
785  {
786  struct GNUNET_PeerIdentity pid;
788 
789  if (GNUNET_OK !=
791  strlen (target_id),
792  &pid.public_key))
793  {
795  _("Invalid target `%s'\n"),
796  target_id);
798  return;
799  }
801  "Connecting to `%s:%s'\n",
802  target_id,
803  target_port);
806  strlen(target_port),
807  &porthash);
809  NULL,
810  &pid,
811  &porthash,
812  opt,
813  NULL /* window changes */,
814  &channel_ended,
815  handlers);
816  if (GNUNET_YES == echo)
817  {
818  echo_task = GNUNET_SCHEDULER_add_now (&send_echo,
819  NULL);
820  }
821  else
822  {
823  listen_stdio ();
824  }
825  }
826 
827  if ( (NULL == lp) &&
828  (NULL == job) &&
829  (NULL == ch) )
830  {
832  _("No action requested\n"));
834  return;
835  }
836 }
837 
838 
846 int
847 main (int argc,
848  char *const *argv)
849 {
850  int res;
851  const char helpstr[] = "Create tunnels and retrieve info about CADET's status.";
852  struct GNUNET_GETOPT_CommandLineOption options[] = {
853  /* I would use the terminology 'circuit' here... --lynX */
855  "connection",
856  "CONNECTION_ID",
857  gettext_noop ("Provide information about a particular connection"),
858  &conn_id),
860  "echo",
861  gettext_noop ("Activate echo mode"),
862  &echo),
864  "open-port",
865  "SHARED_SECRET",
866  gettext_noop ("Listen for connections using a shared secret among sender and recipient"),
867  &listen_port),
869  "peer",
870  "PEER_ID",
871  gettext_noop ("Provide information about a patricular peer"),
872  &peer_id),
874  "peers",
875  gettext_noop ("Provide information about all peers"),
876  &request_peers),
878  "tunnels",
879  gettext_noop ("Provide information about all tunnels"),
880  &request_tunnels),
882  };
883 
884  if (GNUNET_OK !=
885  GNUNET_STRINGS_get_utf8_args (argc, argv,
886  &argc, &argv))
887  return 2;
888 
889  res = GNUNET_PROGRAM_run (argc, argv,
890  "gnunet-cadet (OPTIONS | PEER_ID SHARED_SECRET)",
891  gettext_noop (helpstr),
892  options, &run, NULL);
893 
894  GNUNET_free ((void *) argv);
895 
896  if (GNUNET_OK == res)
897  return 0;
898  return 1;
899 }
900 
901 /* end of gnunet-cadet.c */
static void read_stdio(void *cls)
Task run in stdio mode, after some data is available at stdin.
Definition: gnunet-cadet.c:274
static char * listen_port
Port to listen on (-o).
Definition: gnunet-cadet.c:62
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:849
static void done()
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static void handle_data(void *cls, const struct GNUNET_MessageHeader *message)
Function called whenever a message is received.
Definition: gnunet-cadet.c:450
void * GNUNET_CADET_list_tunnels_cancel(struct GNUNET_CADET_ListTunnels *lt)
Cancel a monitor request.
Opaque handle to the service.
Definition: cadet_api.c:38
static void shutdown_task(void *cls)
Task to shut down this application.
Definition: gnunet-cadet.c:210
#define FPRINTF
Definition: plibc.h:683
void GNUNET_NETWORK_fdset_set_native(struct GNUNET_NETWORK_FDSet *to, int nfd)
Set a native fd in a set.
Definition: network.c:1325
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:1293
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1521
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void get_tunnels(void *cls)
Call CADET&#39;s meta API, get all tunnels known to a peer.
Definition: gnunet-cadet.c:649
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
static int echo
Request echo service.
Definition: gnunet-cadet.c:67
#define GNUNET_TIME_UNIT_SECONDS
One second.
static int request_tunnels
Option -T.
Definition: gnunet-cadet.c:47
uint16_t cstate
What is our connectivity state?
Enable channel reliability, lost messages will be retransmitted.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Opaque handle to a channel.
Definition: cadet_api.c:80
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
unsigned int path_length
Number of entries on the path.
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
static const struct GNUNET_CONFIGURATION_Handle * my_cfg
Our configuration.
Definition: gnunet-cadet.c:97
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_CADET_PeersLister * GNUNET_CADET_list_peers(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CADET_PeersCB callback, void *callback_cls)
Request information about peers known to the running cadet service.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static int check_data(void *cls, const struct GNUNET_MessageHeader *message)
Check data message sanity.
Definition: gnunet-cadet.c:432
void * GNUNET_CADET_list_peers_cancel(struct GNUNET_CADET_PeersLister *pl)
Cancel a peer info request.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
Definition: cadet_api.c:995
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
struct GNUNET_CADET_Port * lp
Data structure for ongoing reception of incoming virtual circuits.
Definition: gnunet-cadet.c:127
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct GNUNET_PeerIdentity peer
Target of the tunnel.
static struct GNUNET_TIME_Absolute echo_time
Time of last echo request.
Definition: gnunet-cadet.c:72
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
Definition: network.c:1554
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
Definition: gnunet-cadet.c:693
static char * conn_id
Option –connection.
Definition: gnunet-cadet.c:52
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
Details about a tunnel managed by CADET.
static const char * enc_2s(uint16_t status)
Convert encryption status to human readable string.
Definition: gnunet-cadet.c:157
static void channel_ended(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called whenever a channel is destroyed.
Definition: gnunet-cadet.c:358
#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_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
Definition: network.c:1538
static void * channel_incoming(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Method called whenever another peer has added us to a channel the other peer initiated.
Definition: gnunet-cadet.c:384
static char * target_port
Port to connect to.
Definition: gnunet-cadet.c:87
struct GNUNET_CADET_GetPath * GNUNET_CADET_get_path(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *id, GNUNET_CADET_PathCB callback, void *callback_cls)
Request information about paths known to the running cadet peer.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incomming MQ-based channels.
Definition: cadet_api.c:1029
#define GNUNET_memcpy(dst, src, n)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:774
static char * channel_id
Option –channel.
Definition: gnunet-cadet.c:57
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
static void peers_callback(void *cls, const struct GNUNET_CADET_PeerListEntry *ple)
Method called to retrieve information about all peers in CADET, called once per peer.
Definition: gnunet-cadet.c:527
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
#define STREAM_BUFFER_SIZE
Definition: gnunet-cadet.c:32
static struct GNUNET_HashCode porthash
HashCode of the given port string.
Definition: gnunet-cadet.c:122
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
static void show_peer(void *cls)
Call CADET&#39;s monitor API, get info of one peer.
Definition: gnunet-cadet.c:620
collection of IO descriptors
uint16_t status
See PRISM_STATUS_*-constants.
static char buf[2048]
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_select(enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when any of the specified file descriptor set...
Definition: scheduler.c:1829
uint32_t channels
How many channels use the tunnel.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
Default options: unreliable, default buffering, not out of order.
static void path_callback(void *cls, const struct GNUNET_CADET_PeerPathDetail *ppd)
Method called to retrieve information about paths to a specific peer known to the service...
Definition: gnunet-cadet.c:552
static void get_peers(void *cls)
Call CADET&#39;s meta API, get all peers known to a peer.
Definition: gnunet-cadet.c:605
static void show_channel(void *cls)
Call CADET&#39;s monitor API, get info of one channel.
Definition: gnunet-cadet.c:664
void * GNUNET_CADET_get_path_cancel(struct GNUNET_CADET_GetPath *gp)
Cancel gp operation.
struct GNUNET_PeerIdentity peer
Which peer is the information about?
static struct GNUNET_CADET_PeersLister * plo
Active peer listing operation.
Definition: gnunet-cadet.c:107
A 512-bit hashcode.
unsigned int target_offset
Offset of the target peer on the path.
Message handler for a specific message type.
static int res
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Operation handle.
static struct GNUNET_SCHEDULER_Task * echo_task
Task for next echo request.
Definition: gnunet-cadet.c:77
int have_tunnel
Do we have a tunnel to this peer?
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_SCHEDULER_Task * rd_task
Task for reading from stdin.
Definition: gnunet-cadet.c:132
static void send_echo(void *cls)
Send an echo request to the remote peer.
Definition: gnunet-cadet.c:408
const struct GNUNET_PeerIdentity * path
Array of PEER_IDs representing all paths to reach the peer.
static struct GNUNET_SCHEDULER_Task * job
Task for main job.
Definition: gnunet-cadet.c:137
uint16_t estate
What is our encryption state?
struct GNUNET_CADET_ListTunnels * GNUNET_CADET_list_tunnels(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CADET_TunnelsCB callback, void *callback_cls)
Request information about tunnels of the running cadet peer.
int GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:501
The identity of the host (wraps the signing key of the peer).
Detailed information we return per peer.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
Definition: cadet_api.c:973
void mq_cb(void *cls)
Definition: gnunet-cadet.c:262
static void listen_stdio(void)
Wait for input on STDIO and send it out over the ch.
Definition: gnunet-cadet.c:330
configuration data
Definition: configuration.c:85
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
static unsigned int sent_pkt
Definition: gnunet-cadet.c:139
Information we return per peer.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
int main(int argc, char *const *argv)
The main function to obtain peer information.
Definition: gnunet-cadet.c:847
static const char * conn_2s(uint16_t status)
Convert connection status to human readable string.
Definition: gnunet-cadet.c:183
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
Opaque handle to a port.
Definition: cadet_api.c:151
static int request_peers
Option -P.
Definition: gnunet-cadet.c:37
unsigned int n_paths
Number of disjoint known paths to peer.
uint32_t connections
How many connections support the tunnel.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:361
static char * target_id
Peer to connect to.
Definition: gnunet-cadet.c:82
Header for all communications.
static struct GNUNET_CADET_GetPath * gpo
Active get path operation.
Definition: gnunet-cadet.c:102
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
Definition: cadet_api.c:882
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
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:353
Run with the default priority (normal P2P operations).
uint32_t data
The data value.
static void tunnels_callback(void *cls, const struct GNUNET_CADET_TunnelDetails *td)
Method called to retrieve information about all tunnels in CADET.
Definition: gnunet-cadet.c:580
GNUNET_CADET_ChannelOption
Channel options.
static size_t data_size
Number of bytes in data.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:911
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static void show_connection(void *cls)
Call CADET&#39;s monitor API, get info of one connection.
Definition: gnunet-cadet.c:677
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, enum GNUNET_CADET_ChannelOption options, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
Definition: cadet_api.c:1088
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
#define gettext_noop(String)
Definition: gettext.h:69
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
Definition: cadet_api.c:1142
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965