GNUnet 0.21.1
transport-testing-communicator.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 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_protocols.h"
30#include "gnunet_constants.h"
32#include "gnunet_signatures.h"
33#include "transport.h"
35#include <inttypes.h>
36
37#define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
38
40{
41 struct MyClient *prev;
42 struct MyClient *next;
47
52
57
58};
59
64{
69
78
83
87 uint32_t qid;
88
92 uint64_t mid;
93
97 uint32_t nt;
98
102 uint32_t mtu;
103
107 uint64_t q_len;
108
112 uint32_t priority;
113
117 uint32_t cs;
118
123
128};
129
130
135{
136};
137
138
148static int
150 void *cls,
152{
153 uint16_t size;
154
155 size = ntohs (msg->header.size) - sizeof(*msg);
156 if (0 == size)
157 return GNUNET_OK; /* receive-only communicator */
159 return GNUNET_OK;
160}
161
162
171static void
173 void *cls,
175{
176 struct MyClient *client = cls;
178 client->tc;
179 uint16_t size;
180 tc_h->c_mq = client->c_mq;
181
182 size = ntohs (msg->header.size) - sizeof(*msg);
183 if (0 == size)
184 {
186 return; /* receive-only communicator */
187 }
188 tc_h->c_characteristics = ntohl (msg->cc);
189 tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
190 if (NULL != tc_h->communicator_available_cb)
191 {
192 LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n");
194 tc_h,
195 tc_h->c_characteristics,
196 tc_h->c_addr_prefix);
197 }
199 LOG (GNUNET_ERROR_TYPE_DEBUG, "finished communicator_available_cb()\n");
200
201}
202
203
211static int
213 const struct
215{
216 // struct TransportClient *tc = cls;
217
218 // if (CT_COMMUNICATOR != tc->type)
219 // {
220 // GNUNET_break (0);
221 // return GNUNET_SYSERR;
222 // }
223 // GNUNET_MQ_check_boxed_message (msg);
224 return GNUNET_OK;
225}
226
227
236static void
238 const struct
240 bc_msg)
241{
242 struct MyClient *client = cls;
244 client->tc;
247 msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
248 uint16_t isize = ntohs (msg->size);
249 const char *target_communicator = ((const char *) msg) + isize;
251 struct GNUNET_MQ_Envelope *env;
252
254 "Received backchannel message\n");
255 if (tc_h->bc_enabled != GNUNET_YES)
256 {
258 return;
259 }
260 /* Find client providing this communicator */
261 /* Finally, deliver backchannel message to communicator */
263 "Delivering backchannel message of type %u to %s\n",
264 ntohs (msg->type),
265 target_communicator);
266 other_tc_h = tc_h->bc_cb (tc_h, msg, (struct
267 GNUNET_PeerIdentity*) &bc_msg->pid);
269 cbi,
270 isize,
272 cbi->pid = tc_h->peer_id;
273 memcpy (&cbi[1], msg, isize);
274
275
276 GNUNET_MQ_send (other_tc_h->c_mq, env);
278}
279
280
288static int
291{
292 // if (CT_COMMUNICATOR != tc->type)
293 // {
294 // GNUNET_break (0);
295 // return GNUNET_SYSERR;
296 // }
298 return GNUNET_OK;
299}
300
301
310static void
313{
314 struct MyClient *client = cls;
316 client->tc;
317 uint16_t size;
318 size = ntohs (msg->header.size) - sizeof(*msg);
319 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
320 if (0 == size)
321 return; /* receive-only communicator */
322 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
323 tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
324 if (NULL != tc_h->add_address_cb)
325 {
326 LOG (GNUNET_ERROR_TYPE_DEBUG, "calling add_address_cb()\n");
327 tc_h->add_address_cb (tc_h->cb_cls,
328 tc_h,
329 tc_h->c_address,
330 GNUNET_TIME_relative_ntoh (msg->expiration),
331 msg->aid,
332 ntohl (msg->nt));
333 }
335}
336
337
345static int
348{
349 // struct TransportClient *tc = cls;
350
351 // if (CT_COMMUNICATOR != tc->type)
352 // {
353 // GNUNET_break (0);
354 // return GNUNET_SYSERR;
355 // }
357 return GNUNET_OK;
358}
359
360
369static void
371 const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
372{
373 struct MyClient *client = cls;
375 client->tc;
377 msg = (struct GNUNET_MessageHeader *) &inc_msg[1];
378 size_t payload_len = ntohs (msg->size) - sizeof (struct
380 if (NULL != tc_h->incoming_msg_cb)
381 {
382 tc_h->incoming_msg_cb (tc_h->cb_cls,
383 tc_h,
384 (char*) &msg[1],
385 payload_len);
386 }
387 else
388 {
390 "Incoming message from communicator but no handler!\n");
391 }
392 if (GNUNET_YES == ntohl (inc_msg->fc_on))
393 {
394 /* send ACK when done to communicator for flow control! */
395 struct GNUNET_MQ_Envelope *env;
397
399 GNUNET_assert (NULL != env);
400 ack->reserved = htonl (0);
401 ack->fc_id = inc_msg->fc_id;
402 ack->sender = inc_msg->sender;
403 GNUNET_MQ_send (tc_h->c_mq, env);
404 }
405
407}
408
409
416static void
419{
420 struct MyClient *client = cls;
422 client->tc;
423
424 if (NULL != tc_h->queue_create_reply_cb)
425 {
426 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
427 }
429}
430
431
441static void
443 void *cls,
445{
446 struct MyClient *client = cls;
448 client->tc;
449
450 if (NULL != tc_h->queue_create_reply_cb)
451 {
452 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
453 }
455}
456
457
464static int
466 const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
467{
469 return GNUNET_OK;
470}
471
472
481static void
484{
485 struct MyClient *client = cls;
487 client->tc;
489
491 "Got queue with ID %u\n", msg->qid);
492 for (tc_queue = tc_h->queue_head; NULL != tc_queue; tc_queue = tc_queue->next)
493 {
494 if (tc_queue->qid == msg->qid)
495 break;
496 }
497 if (NULL == tc_queue)
498 {
499 tc_queue =
501 tc_queue->tc_h = tc_h;
502 tc_queue->qid = msg->qid;
503 tc_queue->peer_id = msg->receiver;
505 }
506 GNUNET_assert (tc_queue->qid == msg->qid);
507 GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
508 tc_queue->nt = msg->nt;
509 tc_queue->mtu = ntohl (msg->mtu);
510 tc_queue->cs = msg->cs;
511 tc_queue->priority = ntohl (msg->priority);
512 tc_queue->q_len = GNUNET_ntohll (msg->q_len);
513 if (NULL != tc_h->add_queue_cb)
514 {
515 tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue, tc_queue->mtu);
516 }
518}
519
520
529static void
531 const struct
533{
534 struct MyClient *client = cls;
536 client->tc;
538
540 "Received queue update message for %u with q_len %" PRIu64 "\n",
541 msg->qid, GNUNET_ntohll (msg->q_len));
542 tc_queue = tc_h->queue_head;
543 if (NULL != tc_queue)
544 {
545 while (tc_queue->qid != msg->qid)
546 {
547 tc_queue = tc_queue->next;
548 }
549 }
550 if (NULL == tc_queue)
551 {
553 return;
554 }
555 GNUNET_assert (tc_queue->qid == msg->qid);
556 GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
557 tc_queue->nt = msg->nt;
558 tc_queue->mtu = ntohl (msg->mtu);
559 tc_queue->cs = msg->cs;
560 tc_queue->priority = ntohl (msg->priority);
561 // Uncomment this for alternativ 1 of backchannel functionality
562 tc_queue->q_len += GNUNET_ntohll (msg->q_len);
563 // Until here for alternativ 1
564 // Uncomment this for alternativ 2 of backchannel functionality
565 // tc_queue->q_len = GNUNET_ntohll (msg->q_len);
566 // Until here for alternativ 2
568}
569
570
576static void
578{
579 struct GNUNET_SERVICE_Handle *h = cls;
580
582 "Shutting down service!\n");
583
585}
586
587
597static void *
598connect_cb (void *cls,
599 struct GNUNET_SERVICE_Client *client,
600 struct GNUNET_MQ_Handle *mq)
601{
603 struct MyClient *new_c;
604
605 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected to %p.\n",
606 client, tc_h);
607 new_c = GNUNET_new (struct MyClient);
608 new_c->client = client;
609 new_c->c_mq = mq;
610 new_c->tc = tc_h;
612 tc_h->client_tail,
613 new_c);
614
615 if (NULL == tc_h->queue_head)
616 return new_c;
617 /* Iterate over queues. They are yet to be opened. Request opening. */
618 for (struct
620 tc_h->queue_head;
621 NULL != tc_queue_iter;
622 tc_queue_iter = tc_queue_iter->next)
623 {
624 if (NULL == tc_queue_iter->open_queue_env)
625 continue;
626 /* Send the previously created mq envelope to request the creation of the
627 * queue. */
628 GNUNET_MQ_send (tc_h->c_mq,
629 tc_queue_iter->open_queue_env);
630 tc_queue_iter->open_queue_env = NULL;
631 }
632 return new_c;
633}
634
635
643static void
644disconnect_cb (void *cls,
646 void *internal_cls)
647{
648 struct MyClient *cl = cls;
650
651 for (cl = tc_h->client_head; NULL != cl; cl = cl->next)
652 {
653 if (cl->client != client)
654 continue;
656 tc_h->client_tail,
657 cl);
658 if (cl->c_mq == tc_h->c_mq)
659 tc_h->c_mq = NULL;
660 GNUNET_free (cl);
661 break;
662 }
663 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
664}
665
666
673static void
675 const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
676{
677 struct MyClient *client = cls;
679 client->tc;
680 static int mtr = 0;
681 mtr++;
682 if (tc_h->cont != NULL)
683 tc_h->cont (tc_h->cont_cls);
685}
686
687
695static void
698{
699 struct GNUNET_MQ_MessageHandler mh[] = {
700 GNUNET_MQ_hd_var_size (communicator_available,
703 tc_h),
704 GNUNET_MQ_hd_var_size (communicator_backchannel,
707 tc_h),
708 GNUNET_MQ_hd_var_size (add_address,
711 tc_h),
712 // GNUNET_MQ_hd_fixed_size (del_address,
713 // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
714 // struct GNUNET_TRANSPORT_DelAddressMessage,
715 // NULL),
716 GNUNET_MQ_hd_var_size (incoming_msg,
719 tc_h),
720 GNUNET_MQ_hd_fixed_size (queue_create_ok,
723 tc_h),
724 GNUNET_MQ_hd_fixed_size (queue_create_fail,
727 tc_h),
728 GNUNET_MQ_hd_var_size (add_queue_message,
731 tc_h),
732 GNUNET_MQ_hd_fixed_size (update_queue_message,
735 tc_h),
736 // GNUNET_MQ_hd_fixed_size (del_queue_message,
737 // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
738 // struct GNUNET_TRANSPORT_DelQueueMessage,
739 // NULL),
740 GNUNET_MQ_hd_fixed_size (send_message_ack,
743 tc_h),
745 };
746
747
748 tc_h->sh = GNUNET_SERVICE_start ("transport",
749 tc_h->cfg,
750 &connect_cb,
752 tc_h,
753 mh);
754 GNUNET_assert (NULL != tc_h->sh);
755}
756
757
763static void
765{
766 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
767 {
769 "Error shutting down process with SIGERM, trying SIGKILL\n");
770 if (0 != GNUNET_OS_process_kill (proc, SIGKILL))
771 {
773 "Error shutting down process with SIGERM and SIGKILL\n");
774 }
775 }
778}
779
780
786static void
788{
789 struct GNUNET_OS_Process *proc = cls;
790 shutdown_process (proc);
791}
792
793
799static void
801{
802 struct GNUNET_OS_Process *proc = cls;
803 shutdown_process (proc);
804}
805
806
812static void
814{
815 struct GNUNET_OS_Process *proc = cls;
816 shutdown_process (proc);
817}
818
819
825static void
828 const char *binary_name)
829{
830 char *binary;
831 char *loprefix;
832 char *section_name;
833
834 LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
835
836 section_name = strchr (binary_name, '-');
837 section_name++;
838
841 "PREFIX",
842 &loprefix))
843 loprefix = GNUNET_strdup ("");
844
845
846 binary = GNUNET_OS_get_libexec_binary_path (binary_name);
848 NULL,
849 loprefix,
850 binary,
851 binary_name,
852 "-c",
853 tc_h->cfg_filename,
854 NULL);
855 if (NULL == tc_h->c_proc)
856 {
857 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
858 return;
859 }
860 LOG (GNUNET_ERROR_TYPE_INFO, "started communicator\n");
861 GNUNET_free (binary);
862}
863
864
870static void
871shutdown_nat (void *cls)
872{
873 struct GNUNET_OS_Process *proc = cls;
874 shutdown_process (proc);
875}
876
877
883static void
885{
886 struct GNUNET_OS_Process *proc = cls;
887 shutdown_process (proc);
888}
889
890
895static void
898{
899 char *binary;
900
901 LOG (GNUNET_ERROR_TYPE_DEBUG, "resolver_start\n");
902 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
906 NULL,
907 NULL,
908 NULL,
909 binary,
910 "gnunet-service-resolver",
911 "-c",
912 tc_h->cfg_filename,
913 NULL);
914 if (NULL == tc_h->resolver_proc)
915 {
916 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start resolver service!");
917 return;
918 }
919 LOG (GNUNET_ERROR_TYPE_INFO, "started resolver service\n");
920 GNUNET_free (binary);
921
922}
923
924
929static void
932{
933 char *binary;
934
935 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics");
937 NULL,
938 NULL,
939 NULL,
940 binary,
941 "gnunet-service-statistics",
942 "-c",
943 tc_h->cfg_filename,
944 NULL);
945 if (NULL == tc_h->stat_proc)
946 {
947 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Statistics!");
948 return;
949 }
950 LOG (GNUNET_ERROR_TYPE_INFO, "started Statistics\n");
951 GNUNET_free (binary);
952}
953
954
959static void
962{
963 char *binary;
964
965 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore");
967 NULL,
968 NULL,
969 NULL,
970 binary,
971 "gnunet-service-peerstore",
972 "-c",
973 tc_h->cfg_filename,
974 NULL);
975 if (NULL == tc_h->ps_proc)
976 {
977 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Peerstore!");
978 return;
979 }
980 LOG (GNUNET_ERROR_TYPE_INFO, "started Peerstore\n");
981 GNUNET_free (binary);
982}
983
984
989static void
992{
993 char *binary;
994
995 LOG (GNUNET_ERROR_TYPE_DEBUG, "nat_start\n");
996 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-nat");
999 NULL,
1000 NULL,
1001 NULL,
1002 binary,
1003 "gnunet-service-nat",
1004 "-c",
1005 tc_h->cfg_filename,
1006 NULL);
1007 if (NULL == tc_h->nat_proc)
1008 {
1009 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start NAT!");
1010 return;
1011 }
1012 LOG (GNUNET_ERROR_TYPE_INFO, "started NAT\n");
1013 GNUNET_free (binary);
1014}
1015
1016
1031 const char *service_name,
1032 const char *binary_name,
1033 const char *cfg_filename,
1034 const struct GNUNET_PeerIdentity *peer_id,
1042 void *cb_cls)
1043{
1045
1047 "Starting new transport/communicator combo with config %s\n",
1048 cfg_filename);
1049 tc_h =
1054 {
1056 _ ("Malformed configuration file `%s', exit ...\n"),
1057 cfg_filename);
1058 GNUNET_free (tc_h->cfg_filename);
1060 GNUNET_free (tc_h);
1061 return NULL;
1062 }
1064 "communicator-test",
1065 "BACKCHANNEL_ENABLED");
1069 tc_h->add_queue_cb = add_queue_cb;
1070 tc_h->incoming_msg_cb = incoming_message_cb;
1071 tc_h->bc_cb = bc_cb;
1072 tc_h->peer_id = *peer_id;
1073 tc_h->cb_cls = cb_cls;
1074
1075 /* Start communicator part of service */
1077 /* Start NAT */
1078 nat_start (tc_h);
1079 /* Start resolver service */
1080 resolver_start (tc_h);
1081 /* Start peerstore service */
1082 peerstore_start (tc_h);
1083 /* Start statistic service */
1084 statistics_start (tc_h);
1085 /* Schedule start communicator */
1086 communicator_start (tc_h,
1087 binary_name);
1088 return tc_h;
1089}
1090
1091
1092void
1095{
1097 shutdown_service (tc_h->sh);
1098 shutdown_nat (tc_h->nat_proc);
1103 GNUNET_free (tc_h);
1104}
1105
1106
1114void
1117 const struct GNUNET_PeerIdentity *peer_id,
1118 const char *address)
1119{
1121 static uint32_t idgen;
1122 char *prefix;
1124 struct GNUNET_MQ_Envelope *env;
1125 size_t alen;
1126
1127 tc_queue =
1129 tc_queue->tc_h = tc_h;
1131 if (NULL == prefix)
1132 {
1133 GNUNET_break (0); /* We got an invalid address!? */
1134 GNUNET_free (tc_queue);
1135 return;
1136 }
1138 alen = strlen (address) + 1;
1139 env =
1141 msg->request_id = htonl (idgen++);
1142 tc_queue->qid = msg->request_id;
1143 msg->receiver = *peer_id;
1144 tc_queue->peer_id = *peer_id;
1145 memcpy (&msg[1], address, alen);
1146 if (NULL != tc_h->c_mq)
1147 {
1149 "Sending queue create immediately\n");
1150 GNUNET_MQ_send (tc_h->c_mq, env);
1151 }
1152 else
1153 {
1154 tc_queue->open_queue_env = env;
1155 }
1156 GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
1157}
1158
1159
1160void
1164 void *cont_cls,
1165 const void *payload,
1166 size_t payload_size)
1167{
1168 struct GNUNET_MessageHeader *mh;
1170 struct GNUNET_MQ_Envelope *env;
1171 size_t inbox_size;
1175 tc_queue = NULL;
1176
1177 for (tc_queue_tmp = tc_h->queue_head;
1178 NULL != tc_queue_tmp;
1179 tc_queue_tmp = tc_queue_tmp->next)
1180 {
1181 if (tc_queue_tmp->q_len <= 0)
1182 continue;
1183 if (NULL == tc_queue)
1184 {
1186 "Selecting queue with prio %u, len %" PRIu64 " and MTU %u\n",
1187 tc_queue_tmp->priority,
1188 tc_queue_tmp->q_len,
1189 tc_queue_tmp->mtu);
1190 tc_queue = tc_queue_tmp;
1191 continue;
1192 }
1193 if (tc_queue->priority < tc_queue_tmp->priority)
1194 {
1196 "Selecting queue with prio %u, len %" PRIu64 " and MTU %u\n",
1197 tc_queue_tmp->priority,
1198 tc_queue_tmp->q_len,
1199 tc_queue_tmp->mtu);
1200 tc_queue = tc_queue_tmp;
1201 }
1202 }
1203 if (last_queue != tc_queue)
1205 "Selected sending queue changed to %u with length %lu and MTU %u\n",
1206 ntohl (tc_queue->qid), (unsigned long) tc_queue->q_len, tc_queue->mtu);
1207 GNUNET_assert (NULL != tc_queue);
1208 last_queue = tc_queue;
1209 // Uncomment this for alternativ 1 of backchannel functionality
1211 tc_queue->q_len--;
1212 // Until here for alternativ 1
1213 static int msg_count = 0;
1214 msg_count++;
1215 if (msg_count % 100 == 0)
1217 "Sending %u-th (%lu-th for queue) message on queue %u\n",
1218 msg_count, (unsigned long) tc_queue->mid, ntohl (tc_queue->qid));
1219 inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;
1221 inbox_size,
1223 GNUNET_assert (NULL != env);
1224 msg->qid = tc_queue->qid;
1225 msg->mid = tc_queue->mid++;
1226 msg->receiver = tc_queue->peer_id;
1227 mh = (struct GNUNET_MessageHeader *) &msg[1];
1228 mh->size = htons (inbox_size);
1230 memcpy (&mh[1],
1231 payload,
1232 payload_size);
1233 if (NULL != cont)
1235 cont,
1236 cont_cls);
1237 GNUNET_MQ_send (tc_queue->tc_h->c_mq,
1238 env);
1239}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static char * cfg_filename
Name of the configuration file.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:59
static char * address
GNS address for this phone.
static char * section_name
Adapter we are supposed to test.
static unsigned long long payload
How much data are we currently storing in the database?
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:50
Helper library for handling HELLO URIs.
Constants for network protocols.
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
char * GNUNET_HELLO_address_to_prefix(const char *address)
Given an address as a string, extract the prefix that identifies the communicator offering transmissi...
Definition: hello-ng.c:190
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
void * cls
Closure for mv and cb.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#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:63
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#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:638
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_OS_Process * GNUNET_OS_start_process(enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename,...)
Start a process.
Definition: os_priority.c:626
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
struct GNUNET_OS_Process * GNUNET_OS_start_process_s(enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename,...)
Start a process.
Definition: os_priority.c:665
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:260
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:210
enum GNUNET_GenericReturnValue GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:877
@ GNUNET_OS_INHERIT_STD_OUT_AND_ERR
When these flags are set, the child process will inherit stdout and stderr of the parent.
@ GNUNET_OS_USE_PIPE_CONTROL
Should a pipe be used to send signals to the child?
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR
Message sent to indicate to the transport which address prefix is supported by a communicator.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL
Response from communicator: address bogus, will not try to create queue.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
Transport signalling incoming backchannel message to a communicator.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS
inform transport to add an address of this peer
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE
inform transport that a queue was updated
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv)
Stops a service that was started with GNUNET_SERVICE_start().
Definition: service.c:1913
struct GNUNET_SERVICE_Handle * GNUNET_SERVICE_start(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_SERVICE_ConnectHandler connect_cb, GNUNET_SERVICE_DisconnectHandler disconnect_cb, void *cls, const struct GNUNET_MQ_MessageHandler *handlers)
Low-level function to start a service if the scheduler is already running.
Definition: service.c:1880
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2408
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:628
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
The identity of the host (wraps the signing key of the peer).
Handle to a client that is connected to a service.
Definition: service.c:252
Handle to a service.
Definition: service.c:118
Add address to the list.
Definition: transport.h:282
Add queue to the transport.
Definition: transport.h:396
Message from transport to communicator passing along a backchannel message from the given peer pid.
Definition: transport.h:650
struct GNUNET_PeerIdentity pid
Origin peer.
Definition: transport.h:665
Message from communicator to transport service asking for transmission of a backchannel message with ...
Definition: transport.h:621
struct GNUNET_PeerIdentity pid
Target peer.
Definition: transport.h:635
Communicator tells transport how queue creation went down.
Definition: transport.h:540
Transport tells communicator that it wants a new queue.
Definition: transport.h:516
Transport informs us about being done with an incoming message.
Definition: transport.h:369
struct GNUNET_PeerIdentity sender
Sender identifier of the original message.
Definition: transport.h:388
uint64_t fc_id
Which message is being ACKed?
Definition: transport.h:383
uint32_t reserved
Reserved (0)
Definition: transport.h:378
Inform transport about an incoming message.
Definition: transport.h:328
struct GNUNET_PeerIdentity sender
Sender identifier.
Definition: transport.h:353
uint32_t fc_on
Do we use flow control or not?
Definition: transport.h:337
uint64_t fc_id
64-bit number to identify the matching ACK.
Definition: transport.h:342
Inform transport that message was sent.
Definition: transport.h:587
Inform communicator about transport's desire to send a message.
Definition: transport.h:558
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_head
Head of the DLL of queues associated with this communicator.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_tail
Tail of the DLL of queues associated with this communicator.
struct GNUNET_SERVICE_Handle * sh
Our service handle.
struct GNUNET_OS_Process * stat_proc
statistics service process
GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb
Backchannel callback.
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb
Callback called when a new communicator connects.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb
Callback called when a new communicator connects.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the configuration.
struct GNUNET_OS_Process * resolver_proc
resolver service process
struct GNUNET_OS_Process * ps_proc
peerstore service process
struct GNUNET_OS_Process * c_proc
Process of the communicator.
GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb
Callback called when a new communicator connects.
GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb
Callback called when a new communicator connects.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics
Characteristics of the communicator.
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb
Callback called when a new communicator connects.
GNUNET_SCHEDULER_TaskCallback cont
Callback to call when message ack received.
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * prev
Previous element inside a DLL.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * next
Next element inside a DLL.
struct GNUNET_MQ_Envelope * open_queue_env
Envelope to a message that requests the opening of the queue.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
struct GNUNET_PeerIdentity peer_id
Peer ID of the peer on the other side of the queue.
struct GNUNET_SERVICE_Client * client
Handle to the client.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
struct MyClient * prev
struct MyClient * next
void GNUNET_TRANSPORT_TESTING_transport_communicator_send(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls, const void *payload, size_t payload_size)
Instruct communicator to send data.
static void shutdown_peerstore(void *cls)
Task run at shutdown to kill the peerstore process.
static void shutdown_communicator(void *cls)
Task run at shutdown to kill a communicator process.
static void nat_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start NAT.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(const char *service_name, const char *binary_name, const char *cfg_filename, const struct GNUNET_PeerIdentity *peer_id, GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb, GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb, GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb, void *cb_cls)
Start communicator part of transport service and communicator.
static void handle_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
Receive an incoming message.
static void shutdown_statistics(void *cls)
Task run at shutdown to kill the statistics process.
static void resolver_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Resolver.
static int check_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
New queue became available.
static int check_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *msg)
Incoming message.
static int check_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
Address of our peer added.
void GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const struct GNUNET_PeerIdentity *peer_id, const char *address)
Instruct communicator to open a queue.
static void handle_update_queue_message(void *cls, const struct GNUNET_TRANSPORT_UpdateQueueMessage *msg)
Handle new queue.
static void shutdown_resolver(void *cls)
Task run at shutdown to kill the resolver process.
static void handle_queue_create_fail(void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
Communicator informs that it won't try establishing requested queue.
static void handle_queue_create_ok(void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
Communicator informs that it tries to establish requested queue.
static void handle_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *bc_msg)
Receive an incoming message.
static void shutdown_nat(void *cls)
Task run at shutdown to kill communicator and clean up.
static void shutdown_service(void *cls)
Shut down the service.
static void disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Callback called when Client disconnects.
static int check_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *msg)
Incoming message.
static void handle_send_message_ack(void *cls, const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
Message was transmitted.
static void transport_communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start the communicator part of the transport service.
static void handle_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
Handle new queue.
void GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
static void statistics_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Statistics.
static void * connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Callback called when new Client (Communicator) connects.
static void shutdown_process(struct GNUNET_OS_Process *proc)
Task run at shutdown to kill communicator and clean up.
static void communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *binary_name)
Start the communicator.
static void peerstore_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Peerstore.
static void handle_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
The communicator informs about an address.
static int check_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Check whether incoming msg indicating available communicator is correct.
#define LOG(kind,...)
static void handle_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Handle new communicator.
functions and structures related to testing-tng
void(* GNUNET_TRANSPORT_TESTING_IncomingMessageCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *payload, size_t payload_len)
Handle an incoming message.
void(* GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, size_t mtu)
Handle opening of queue.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *(* GNUNET_TRANSPORT_TESTING_BackchannelCallback)(void *cls, struct GNUNET_MessageHeader *msg, struct GNUNET_PeerIdentity *pid)
Function signature for callbacks that are called when new backchannel message arrived.
void(* GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, int will_try)
Get informed about the success of a queue request.
void(* GNUNET_TRANSPORT_TESTING_AddAddressCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *address, struct GNUNET_TIME_Relative expiration, uint32_t aid, enum GNUNET_NetworkType nt)
Receive information about the address of a communicator.
void(* GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, char *address_prefix)
Function signature for callbacks that are called when new communicators become available.
common internal definitions for transport service