GNUnet 0.22.2
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"
30#include "../../service/cadet/cadet.h" // FIXME Smell: this should not be shared like this.
31
32#define STREAM_BUFFER_SIZE 1024 // Packets
33
37static int request_peers;
38
42static char *peer_id;
43
47static int request_tunnels;
48
52static char *conn_id;
53
57static char *channel_id;
58
62static char *listen_port;
63
67static int echo;
68
73
78
82static char *target_id;
83
87static const char *target_port = "default";
88
92static struct GNUNET_CADET_Handle *mh;
93
98
103
108
113
118
123
128
133
138
139static unsigned int sent_pkt;
140
141
145static void
146listen_stdio (void);
147
148
156static const char *
157enc_2s (uint16_t status)
158{
159 switch (status)
160 {
161 case 0:
162 return "NULL ";
163
164 case 1:
165 return "KSENT";
166
167 case 2:
168 return "KRECV";
169
170 case 3:
171 return "READY";
172
173 default:
174 return "";
175 }
176}
177
178
186static const char *
187conn_2s (uint16_t status)
188{
189 switch (status)
190 {
191 case 0:
192 return "NEW ";
193
194 case 1:
195 return "SRCH ";
196
197 case 2:
198 return "WAIT ";
199
200 case 3:
201 return "READY";
202
203 case 4:
204 return "SHUTD";
205
206 default:
207 return "";
208 }
209}
210
211
217static void
218shutdown_task (void *cls)
219{
220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
221 if (NULL != lp)
222 {
224 lp = NULL;
225 }
226 if (NULL != ch)
227 {
229 ch = NULL;
230 }
231 if (NULL != gpo)
232 {
234 gpo = NULL;
235 }
236 if (NULL != plo)
237 {
239 plo = NULL;
240 }
241 if (NULL != tio)
242 {
244 tio = NULL;
245 }
246 if (NULL != mh)
247 {
249 mh = NULL;
250 }
251 if (NULL != rd_task)
252 {
254 rd_task = NULL;
255 }
256 if (NULL != echo_task)
257 {
259 echo_task = NULL;
260 }
261 if (NULL != job)
262 {
264 job = NULL;
265 }
266}
267
268
269static void
270mq_cb (void *cls)
271{
272 listen_stdio ();
273}
274
275
281static void
282read_stdio (void *cls)
283{
284 struct GNUNET_MQ_Envelope *env;
286 char buf[60000];
287 ssize_t data_size;
288
289 rd_task = NULL;
290 data_size = read (0, buf, 60000);
291 if (data_size < 1)
292 {
294 "read() returned %s\n",
295 strerror (errno));
297 return;
298 }
300 "Read %u bytes from stdio\n",
301 (unsigned int) data_size);
303 GNUNET_memcpy (&msg[1], buf, data_size);
305
306 sent_pkt++;
307
308 if (GNUNET_NO == echo)
309 {
310 // Use MQ's notification if too much data of stdin is pooring in too fast.
312 {
314 sent_pkt = 0;
315 }
316 else
317 {
318 listen_stdio ();
319 }
320 }
321 else
322 {
324 }
325}
326
327
331static void
333{
334 struct GNUNET_NETWORK_FDSet *rs;
335
336 /* FIXME: why use 'rs' here, seems overly complicated... */
338 GNUNET_NETWORK_fdset_set_native (rs, 0); /* STDIN */
341 rs,
342 NULL,
343 &read_stdio,
344 NULL);
346}
347
348
358static void
359channel_ended (void *cls, const struct GNUNET_CADET_Channel *channel)
360{
361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel ended!\n");
362 GNUNET_assert (channel == ch);
363 ch = NULL;
365}
366
367
382static void *
384 struct GNUNET_CADET_Channel *channel,
385 const struct GNUNET_PeerIdentity *initiator)
386{
388 "Incoming connection from %s\n",
389 GNUNET_i2s_full (initiator));
390 GNUNET_assert (NULL == ch);
391 GNUNET_assert (NULL != lp);
393 lp = NULL;
394 ch = channel;
395 if (GNUNET_NO == echo)
396 listen_stdio ();
397 return channel;
398}
399
400
406static void
407send_echo (void *cls)
408{
409 struct GNUNET_MQ_Envelope *env;
411
412 echo_task = NULL;
413 if (NULL == ch)
414 return;
417}
418
419
428static int
429check_data (void *cls, const struct GNUNET_MessageHeader *message)
430{
431 return GNUNET_OK; /* all is well-formed */
432}
433
434
445static void
446handle_data (void *cls, const struct GNUNET_MessageHeader *message)
447{
448 size_t payload_size = ntohs (message->size) - sizeof(*message);
449 uint16_t len;
450 ssize_t done;
451 uint16_t off;
452 const char *buf;
453
455 if (GNUNET_YES == echo)
456 {
457 if (NULL != listen_port)
458 {
459 struct GNUNET_MQ_Envelope *env;
461
462 env =
464 GNUNET_memcpy (&msg[1], &message[1], payload_size);
466 return;
467 }
468 else
469 {
470 struct GNUNET_TIME_Relative latency;
471
475 "time: %s\n",
478 &send_echo,
479 NULL);
480 }
481 }
482
483 len = ntohs (message->size) - sizeof(*message);
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got %u bytes\n", len);
485 buf = (const char *) &message[1];
486 off = 0;
487 while (off < len)
488 {
489 done = write (1, &buf[off], len - off);
490 if (done <= 0)
491 {
492 if (-1 == done)
495 return;
496 }
497 off += done;
498 }
499}
500
501
511static void
512peers_callback (void *cls, const struct GNUNET_CADET_PeerListEntry *ple)
513{
514 if (NULL == ple)
515 {
516 plo = NULL;
518 return;
519 }
520 fprintf (stdout,
521 "%s tunnel: %c, paths: %u\n",
522 GNUNET_i2s_full (&ple->peer),
523 ple->have_tunnel ? 'Y' : 'N',
524 ple->n_paths);
525}
526
527
535static void
536path_callback (void *cls, const struct GNUNET_CADET_PeerPathDetail *ppd)
537{
538 if (NULL == ppd)
539 {
540 gpo = NULL;
542 return;
543 }
544 fprintf (stdout, "Path of length %u: ", ppd->path_length);
545 for (unsigned int i = 0; i < ppd->path_length; i++)
546 fprintf (stdout,
547 (i == ppd->target_offset) ? "*%s* " : "%s ",
548 GNUNET_i2s (&ppd->path[i]));
549 fprintf (stdout, "\n");
550}
551
552
559static void
560tunnels_callback (void *cls, const struct GNUNET_CADET_TunnelDetails *td)
561{
562 if (NULL == td)
563 {
564 tio = NULL;
566 return;
567 }
568 fprintf (stdout,
569 "%s [ENC: %s, CON: %s] CHs: %u, CONNs: %u\n",
570 GNUNET_i2s_full (&td->peer),
571 enc_2s (td->estate),
572 conn_2s (td->cstate),
573 td->channels,
574 td->connections);
575}
576
577
583static void
584get_peers (void *cls)
585{
586 job = NULL;
588}
589
590
596static void
597show_peer (void *cls)
598{
600
601 job = NULL;
603 strlen (peer_id),
604 &pid.public_key))
605 {
606 fprintf (stderr, _ ("Invalid peer ID `%s'\n"), peer_id);
608 return;
609 }
611}
612
613
619static void
620get_tunnels (void *cls)
621{
622 job = NULL;
624}
625
626
632static void
633show_channel (void *cls)
634{
635 job = NULL;
636 GNUNET_break (0);
637}
638
639
645static void
647{
648 job = NULL;
649 GNUNET_break (0);
650}
651
652
661static void
662run (void *cls,
663 char *const *args,
664 const char *cfgfile,
665 const struct GNUNET_CONFIGURATION_Handle *cfg)
666{
671 NULL),
673
674 /* FIXME add option to monitor apps */
675 my_cfg = cfg;
676 target_id = args[0];
677 if (target_id && args[1])
678 target_port = args[1];
679
680 if (((0 != (request_peers | request_tunnels)) || (NULL != conn_id) ||
681 (NULL != channel_id) ) &&
682 (target_id != NULL) )
683 {
684 fprintf (stderr,
685 _ ("Extra arguments are not applicable "
686 "in combination with this option.\n"));
687 return;
688 }
689
690 if (NULL != peer_id)
691 {
692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show peer\n");
694 }
695 else if (NULL != channel_id)
696 {
697 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show channel\n");
699 }
700 else if (NULL != conn_id)
701 {
702 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show connection\n");
704 }
705 else if (GNUNET_YES == request_peers)
706 {
707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all peers\n");
709 }
710 else if (GNUNET_YES == request_tunnels)
711 {
712 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n");
714 }
715
716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CADET service\n");
719 if (NULL == mh)
720 {
722 return;
723 }
724 if (NULL != listen_port)
725 {
726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening CADET listen port\n");
729 &porthash,
731 NULL,
732 NULL /* window changes */,
734 handlers);
735 }
736 if (NULL != target_id)
737 {
739
740 if (GNUNET_OK !=
742 strlen (target_id),
743 &pid.public_key))
744 {
746 _ ("Invalid target `%s'\n"),
747 target_id);
749 return;
750 }
752 "Connecting to `%s:%s'\n",
753 target_id,
757 NULL,
758 &pid,
759 &porthash,
760 NULL /* window changes */,
762 handlers);
763 if (GNUNET_YES == echo)
764 {
766 }
767 else
768 {
769 listen_stdio ();
770 }
771 }
772
773 if ((NULL == lp) && (NULL == job) && (NULL == ch))
774 {
775 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, _ ("No action requested\n"));
777 return;
778 }
779}
780
781
789int
790main (int argc, char *const *argv)
791{
792 int res;
793 const char helpstr[] =
794 "Create tunnels and retrieve info about CADET's status.";
795 struct GNUNET_GETOPT_CommandLineOption options[] = { /* I would use the terminology 'circuit' here... --lynX */
797 'C',
798 "connection",
799 "CONNECTION_ID",
800 gettext_noop ("Provide information about a particular connection"),
801 &conn_id),
803 "echo",
804 gettext_noop ("Activate echo mode"),
805 &echo),
807 'o',
808 "open-port",
809 "SHARED_SECRET",
811 "Listen for connections using a shared secret among sender and recipient"),
812 &listen_port),
814 "peer",
815 "PEER_ID",
817 "Provide information about a patricular peer"),
818 &peer_id),
820 "peers",
822 "Provide information about all peers"),
825 "tunnels",
827 "Provide information about all tunnels"),
830 };
831
833 argc,
834 argv,
835 "gnunet-cadet (OPTIONS | PEER_ID SHARED_SECRET)",
836 gettext_noop (helpstr),
837 options,
838 &run,
839 NULL);
840
841 if (GNUNET_OK == res)
842 return 0;
843 return 1;
844}
845
846
847/* end of gnunet-cadet.c */
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define gettext_noop(String)
Definition: gettext.h:74
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
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:512
static struct GNUNET_HashCode porthash
HashCode of the given port string.
Definition: gnunet-cadet.c:122
#define STREAM_BUFFER_SIZE
Definition: gnunet-cadet.c:32
static struct GNUNET_SCHEDULER_Task * echo_task
Task for next echo request.
Definition: gnunet-cadet.c:77
static void listen_stdio(void)
Wait for input on STDIO and send it out over the ch.
Definition: gnunet-cadet.c:332
static int check_data(void *cls, const struct GNUNET_MessageHeader *message)
Check data message sanity.
Definition: gnunet-cadet.c:429
static char * channel_id
Option –channel.
Definition: gnunet-cadet.c:57
static const char * conn_2s(uint16_t status)
Convert connection status to human readable string.
Definition: gnunet-cadet.c:187
static struct GNUNET_SCHEDULER_Task * job
Task for main job.
Definition: gnunet-cadet.c:137
static char * listen_port
Port to listen on (-o).
Definition: gnunet-cadet.c:62
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:536
struct GNUNET_CADET_Port * lp
Data structure for ongoing reception of incoming virtual circuits.
Definition: gnunet-cadet.c:127
static void get_peers(void *cls)
Call CADET's meta API, get all peers known to a peer.
Definition: gnunet-cadet.c:584
static struct GNUNET_SCHEDULER_Task * rd_task
Task for reading from stdin.
Definition: gnunet-cadet.c:132
static void show_connection(void *cls)
Call CADET's monitor API, get info of one connection.
Definition: gnunet-cadet.c:646
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
static void channel_ended(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called whenever a channel is destroyed.
Definition: gnunet-cadet.c:359
static void read_stdio(void *cls)
Task run in stdio mode, after some data is available at stdin.
Definition: gnunet-cadet.c:282
static const struct GNUNET_CONFIGURATION_Handle * my_cfg
Our configuration.
Definition: gnunet-cadet.c:97
static struct GNUNET_TIME_Absolute echo_time
Time of last echo request.
Definition: gnunet-cadet.c:72
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static struct GNUNET_CADET_GetPath * gpo
Active get path operation.
Definition: gnunet-cadet.c:102
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static void shutdown_task(void *cls)
Task to shut down this application.
Definition: gnunet-cadet.c:218
static void mq_cb(void *cls)
Definition: gnunet-cadet.c:270
static int request_peers
Option -P.
Definition: gnunet-cadet.c:37
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:383
static void get_tunnels(void *cls)
Call CADET's meta API, get all tunnels known to a peer.
Definition: gnunet-cadet.c:620
static char * target_id
Peer to connect to.
Definition: gnunet-cadet.c:82
static char * conn_id
Option –connection.
Definition: gnunet-cadet.c:52
static void show_peer(void *cls)
Call CADET's monitor API, get info of one peer.
Definition: gnunet-cadet.c:597
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:560
static const char * target_port
Port to connect to.
Definition: gnunet-cadet.c:87
static int request_tunnels
Option -T.
Definition: gnunet-cadet.c:47
static void show_channel(void *cls)
Call CADET's monitor API, get info of one channel.
Definition: gnunet-cadet.c:633
static int echo
Request echo service.
Definition: gnunet-cadet.c:67
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:662
static void handle_data(void *cls, const struct GNUNET_MessageHeader *message)
Function called whenever a message is received.
Definition: gnunet-cadet.c:446
int main(int argc, char *const *argv)
The main function to obtain peer information.
Definition: gnunet-cadet.c:790
static void send_echo(void *cls)
Send an echo request to the remote peer.
Definition: gnunet-cadet.c:407
static const char * enc_2s(uint16_t status)
Convert encryption status to human readable string.
Definition: gnunet-cadet.c:157
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
static unsigned int sent_pkt
Definition: gnunet-cadet.c:139
static struct GNUNET_CADET_PeersLister * plo
Active peer listing operation.
Definition: gnunet-cadet.c:107
static char * data
The data to insert into the dht.
static char * res
Currently read line or NULL on EOF.
static size_t data_size
Number of bytes in data.
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:39
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
CADET service; establish channels to distant peers.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
Definition: cadet_api.c:897
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
Definition: cadet_api.c:875
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_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:833
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.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected channel.
Definition: cadet_api.c:1081
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 incoming MQ-based channels.
Definition: cadet_api.c:966
void * GNUNET_CADET_list_tunnels_cancel(struct GNUNET_CADET_ListTunnels *lt)
Cancel a monitor request.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:777
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
Definition: cadet_api.c:804
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, 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:1030
void * GNUNET_CADET_get_path_cancel(struct GNUNET_CADET_GetPath *gp)
Cancel gp operation.
void * GNUNET_CADET_list_peers_cancel(struct GNUNET_CADET_PeersLister *pl)
Cancel a peer info request.
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 a peer known to the running cadet 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.
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.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue 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:361
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SCHEDULER_PRIORITY_DEFAULT
Run with the default priority (normal P2P operations).
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_MESSAGE
@ GNUNET_ERROR_TYPE_DEBUG
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:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#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:61
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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:655
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
Definition: network.c:1185
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
Definition: network.c:1169
void GNUNET_NETWORK_fdset_set_native(struct GNUNET_NETWORK_FDSet *to, int nfd)
Set a native fd in a set.
Definition: network.c:1058
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, 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,...
Definition: program.c:407
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
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:1835
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,...
Definition: scheduler.c:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
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:1304
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:1277
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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:438
#define GNUNET_TIME_UNIT_SECONDS
One second.
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:579
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Opaque handle to a channel.
Definition: cadet.h:116
Operation handle.
Opaque handle to the service.
Definition: cadet_api.c:39
Information we return per peer.
unsigned int n_paths
Number of disjoint known paths to peer.
struct GNUNET_PeerIdentity peer
Which peer is the information about?
int have_tunnel
Do we have a tunnel to this peer?
Detailed information we return per peer.
unsigned int path_length
Number of entries on the path.
const struct GNUNET_PeerIdentity * path
Array of PEER_IDs representing all paths to reach the peer.
unsigned int target_offset
Offset of the target peer on the path.
Opaque handle to a port.
Definition: cadet_api.c:80
Details about a tunnel managed by CADET.
uint16_t cstate
What is our connectivity state?
uint32_t channels
How many channels use the tunnel.
uint16_t estate
What is our encryption state?
struct GNUNET_PeerIdentity peer
Target of the tunnel.
uint32_t connections
How many connections support the tunnel.
Definition of a command line option.
A 512-bit hashcode.
Message handler for a specific message type.
Header for all communications.
collection of IO descriptors
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.