GNUnet 0.22.2
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);
190 tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
191 if (NULL != tc_h->communicator_available_cb)
192 {
193 LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n");
195 tc_h,
196 tc_h->c_characteristics,
197 tc_h->c_addr_prefix);
198 }
200 LOG (GNUNET_ERROR_TYPE_DEBUG, "finished communicator_available_cb()\n");
201
202}
203
204
212static int
214 const struct
216{
217 // struct TransportClient *tc = cls;
218
219 // if (CT_COMMUNICATOR != tc->type)
220 // {
221 // GNUNET_break (0);
222 // return GNUNET_SYSERR;
223 // }
224 // GNUNET_MQ_check_boxed_message (msg);
225 return GNUNET_OK;
226}
227
228
237static void
239 const struct
241 bc_msg)
242{
243 struct MyClient *client = cls;
245 client->tc;
248 struct GNUNET_MQ_Envelope *env;
249 uint16_t isize;
250 const char *target_communicator;
252
253 msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
254 isize = ntohs (msg->size);
255 target_communicator = ((const char *) msg) + isize;
256
258 "Received backchannel message\n");
259 if (tc_h->bc_enabled != GNUNET_YES)
260 {
262 return;
263 }
264 /* Find client providing this communicator */
265 /* Finally, deliver backchannel message to communicator */
267 "Delivering backchannel message of type %u to %s\n",
268 ntohs (msg->type),
269 target_communicator);
270 other_tc_h = tc_h->bc_cb (tc_h, msg, (struct
271 GNUNET_PeerIdentity*) &bc_msg->pid);
273 cbi,
274 isize,
276 cbi->pid = tc_h->peer_id;
277 memcpy (&cbi[1], msg, isize);
278
279
280 GNUNET_MQ_send (other_tc_h->c_mq, env);
282}
283
284
292static int
295{
296 // if (CT_COMMUNICATOR != tc->type)
297 // {
298 // GNUNET_break (0);
299 // return GNUNET_SYSERR;
300 // }
302 return GNUNET_OK;
303}
304
305
314static void
317{
318 struct MyClient *client = cls;
320 client->tc;
321 uint16_t size;
322 size = ntohs (msg->header.size) - sizeof(*msg);
323 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
324 if (0 == size)
325 return; /* receive-only communicator */
326 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
327 GNUNET_free (tc_h->c_address);
328 tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
329 if (NULL != tc_h->add_address_cb)
330 {
331 LOG (GNUNET_ERROR_TYPE_DEBUG, "calling add_address_cb()\n");
332 tc_h->add_address_cb (tc_h->cb_cls,
333 tc_h,
334 tc_h->c_address,
335 GNUNET_TIME_relative_ntoh (msg->expiration),
336 msg->aid,
337 ntohl (msg->nt));
338 }
340}
341
342
350static int
353{
354 // struct TransportClient *tc = cls;
355
356 // if (CT_COMMUNICATOR != tc->type)
357 // {
358 // GNUNET_break (0);
359 // return GNUNET_SYSERR;
360 // }
362 return GNUNET_OK;
363}
364
365
374static void
376 const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
377{
378 struct MyClient *client = cls;
380 client->tc;
382 size_t payload_len;
383 msg = (struct GNUNET_MessageHeader *) &inc_msg[1];
384 payload_len = ntohs (msg->size) - sizeof (struct GNUNET_MessageHeader);
385 if (NULL != tc_h->incoming_msg_cb)
386 {
387 tc_h->incoming_msg_cb (tc_h->cb_cls,
388 tc_h,
389 (char*) &msg[1],
390 payload_len);
391 }
392 else
393 {
395 "Incoming message from communicator but no handler!\n");
396 }
397 if (GNUNET_YES == ntohl (inc_msg->fc_on))
398 {
399 /* send ACK when done to communicator for flow control! */
400 struct GNUNET_MQ_Envelope *env;
402
404 GNUNET_assert (NULL != env);
405 ack->reserved = htonl (0);
406 ack->fc_id = inc_msg->fc_id;
407 ack->sender = inc_msg->sender;
408 GNUNET_MQ_send (tc_h->c_mq, env);
409 }
410
412}
413
414
421static void
424{
425 struct MyClient *client = cls;
427 client->tc;
428
429 if (NULL != tc_h->queue_create_reply_cb)
430 {
431 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
432 }
434}
435
436
446static void
448 void *cls,
450{
451 struct MyClient *client = cls;
453 client->tc;
454
455 if (NULL != tc_h->queue_create_reply_cb)
456 {
457 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
458 }
460}
461
462
469static int
471 const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
472{
474 return GNUNET_OK;
475}
476
477
486static void
489{
490 struct MyClient *client = cls;
492 client->tc;
494
496 "Got queue with ID %u\n", msg->qid);
497 for (tc_queue = tc_h->queue_head; NULL != tc_queue; tc_queue = tc_queue->next)
498 {
499 if (tc_queue->qid == msg->qid)
500 break;
501 }
502 if (NULL == tc_queue)
503 {
504 tc_queue =
506 tc_queue->tc_h = tc_h;
507 tc_queue->qid = msg->qid;
508 tc_queue->peer_id = msg->receiver;
510 }
511 GNUNET_assert (tc_queue->qid == msg->qid);
512 GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
513 tc_queue->nt = msg->nt;
514 tc_queue->mtu = ntohl (msg->mtu);
515 tc_queue->cs = msg->cs;
516 tc_queue->priority = ntohl (msg->priority);
517 tc_queue->q_len = GNUNET_ntohll (msg->q_len);
518 if (NULL != tc_h->add_queue_cb)
519 {
520 tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue, tc_queue->mtu);
521 }
523}
524
525
534static void
536 const struct
538{
539 struct MyClient *client = cls;
541 client->tc;
543
545 "Received queue update message for %u with q_len %" PRIu64 "\n",
546 msg->qid, GNUNET_ntohll (msg->q_len));
547 tc_queue = tc_h->queue_head;
548 if (NULL != tc_queue)
549 {
550 while (tc_queue->qid != msg->qid)
551 {
552 tc_queue = tc_queue->next;
553 }
554 }
555 if (NULL == tc_queue)
556 {
558 return;
559 }
560 GNUNET_assert (tc_queue->qid == msg->qid);
561 GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
562 tc_queue->nt = msg->nt;
563 tc_queue->mtu = ntohl (msg->mtu);
564 tc_queue->cs = msg->cs;
565 tc_queue->priority = ntohl (msg->priority);
566 // Uncomment this for alternative 1 of backchannel functionality
567 tc_queue->q_len += GNUNET_ntohll (msg->q_len);
568 // Until here for alternative 1
569 // Uncomment this for alternative 2 of backchannel functionality
570 // tc_queue->q_len = GNUNET_ntohll (msg->q_len);
571 // Until here for alternative 2
573}
574
575
581static void
583{
584 struct GNUNET_SERVICE_Handle *h = cls;
585
587 "Shutting down service!\n");
588
590}
591
592
602static void *
603connect_cb (void *cls,
604 struct GNUNET_SERVICE_Client *client,
605 struct GNUNET_MQ_Handle *mq)
606{
608 struct MyClient *new_c;
609
610 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected to %p.\n",
611 client, tc_h);
612 new_c = GNUNET_new (struct MyClient);
613 new_c->client = client;
614 new_c->c_mq = mq;
615 new_c->tc = tc_h;
617 tc_h->client_tail,
618 new_c);
619
620 if (NULL == tc_h->queue_head)
621 return new_c;
622 /* Iterate over queues. They are yet to be opened. Request opening. */
623 for (struct
625 tc_h->queue_head;
626 NULL != tc_queue_iter;
627 tc_queue_iter = tc_queue_iter->next)
628 {
629 if (NULL == tc_queue_iter->open_queue_env)
630 continue;
631 /* Send the previously created mq envelope to request the creation of the
632 * queue. */
633 GNUNET_MQ_send (tc_h->c_mq,
634 tc_queue_iter->open_queue_env);
635 tc_queue_iter->open_queue_env = NULL;
636 }
637 return new_c;
638}
639
640
648static void
649disconnect_cb (void *cls,
651 void *internal_cls)
652{
653 struct MyClient *cl = cls;
655
656 for (cl = tc_h->client_head; NULL != cl; cl = cl->next)
657 {
658 if (cl->client != client)
659 continue;
661 tc_h->client_tail,
662 cl);
663 if (cl->c_mq == tc_h->c_mq)
664 tc_h->c_mq = NULL;
665 GNUNET_free (cl);
666 break;
667 }
668 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
669}
670
671
678static void
680 const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
681{
682 struct MyClient *client = cls;
684 client->tc;
685 if (tc_h->cont != NULL)
686 tc_h->cont (tc_h->cont_cls);
688}
689
690
698static void
701{
702 struct GNUNET_MQ_MessageHandler mh[] = {
703 GNUNET_MQ_hd_var_size (communicator_available,
706 tc_h),
707 GNUNET_MQ_hd_var_size (communicator_backchannel,
710 tc_h),
711 GNUNET_MQ_hd_var_size (add_address,
714 tc_h),
715 // GNUNET_MQ_hd_fixed_size (del_address,
716 // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
717 // struct GNUNET_TRANSPORT_DelAddressMessage,
718 // NULL),
719 GNUNET_MQ_hd_var_size (incoming_msg,
722 tc_h),
723 GNUNET_MQ_hd_fixed_size (queue_create_ok,
726 tc_h),
727 GNUNET_MQ_hd_fixed_size (queue_create_fail,
730 tc_h),
731 GNUNET_MQ_hd_var_size (add_queue_message,
734 tc_h),
735 GNUNET_MQ_hd_fixed_size (update_queue_message,
738 tc_h),
739 // GNUNET_MQ_hd_fixed_size (del_queue_message,
740 // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
741 // struct GNUNET_TRANSPORT_DelQueueMessage,
742 // NULL),
743 GNUNET_MQ_hd_fixed_size (send_message_ack,
746 tc_h),
748 };
749
750
752 "transport",
753 tc_h->cfg,
754 &connect_cb,
756 tc_h,
757 mh);
758 GNUNET_assert (NULL != tc_h->sh);
759}
760
761
767static void
769{
770 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
771 {
773 "Error shutting down process with SIGERM, trying SIGKILL\n");
774 if (0 != GNUNET_OS_process_kill (proc, SIGKILL))
775 {
777 "Error shutting down process with SIGERM and SIGKILL\n");
778 }
779 }
782}
783
784
790static void
792{
793 struct GNUNET_OS_Process *proc = cls;
794 shutdown_process (proc);
795}
796
797
803static void
805{
806 struct GNUNET_OS_Process *proc = cls;
807 shutdown_process (proc);
808}
809
810
816static void
818{
819 struct GNUNET_OS_Process *proc = cls;
820 shutdown_process (proc);
821}
822
823
829static void
832 const char *binary_name)
833{
834 char *binary;
835 char *loprefix;
836 char *section_name;
837
838 LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
839
840 section_name = strchr (binary_name, '-');
841 section_name++;
842
845 "PREFIX",
846 &loprefix))
847 loprefix = GNUNET_strdup ("");
848
849
851 binary_name);
853 NULL,
854 loprefix,
855 binary,
856 binary_name,
857 "-c",
858 tc_h->cfg_filename,
859 NULL);
860 GNUNET_free (loprefix);
861 if (NULL == tc_h->c_proc)
862 {
863 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
864 return;
865 }
866 LOG (GNUNET_ERROR_TYPE_INFO, "started communicator\n");
867 GNUNET_free (binary);
868}
869
870
876static void
877shutdown_nat (void *cls)
878{
879 struct GNUNET_OS_Process *proc = cls;
880 shutdown_process (proc);
881}
882
883
889static void
891{
892 struct GNUNET_OS_Process *proc = cls;
893 shutdown_process (proc);
894}
895
896
901static void
904{
905 char *binary;
906
907 LOG (GNUNET_ERROR_TYPE_DEBUG, "resolver_start\n");
909 "gnunet-service-resolver");
913 NULL,
914 NULL,
915 NULL,
916 binary,
917 "gnunet-service-resolver",
918 "-c",
919 tc_h->cfg_filename,
920 NULL);
921 if (NULL == tc_h->resolver_proc)
922 {
923 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start resolver service!");
924 return;
925 }
926 LOG (GNUNET_ERROR_TYPE_INFO, "started resolver service\n");
927 GNUNET_free (binary);
928
929}
930
931
936static void
939{
940 char *binary;
941
943 "gnunet-service-statistics");
945 NULL,
946 NULL,
947 NULL,
948 binary,
949 "gnunet-service-statistics",
950 "-c",
951 tc_h->cfg_filename,
952 NULL);
953 if (NULL == tc_h->stat_proc)
954 {
955 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Statistics!");
956 return;
957 }
958 LOG (GNUNET_ERROR_TYPE_INFO, "started Statistics\n");
959 GNUNET_free (binary);
960}
961
962
967static void
970{
971 char *binary;
972
974 "gnunet-service-peerstore");
976 NULL,
977 NULL,
978 NULL,
979 binary,
980 "gnunet-service-peerstore",
981 "-c",
982 tc_h->cfg_filename,
983 NULL);
984 if (NULL == tc_h->ps_proc)
985 {
986 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Peerstore!");
987 return;
988 }
989 LOG (GNUNET_ERROR_TYPE_INFO, "started Peerstore\n");
990 GNUNET_free (binary);
991}
992
993
998static void
1001{
1002 char *binary;
1003
1004 LOG (GNUNET_ERROR_TYPE_DEBUG, "nat_start\n");
1006 "gnunet-service-nat");
1009 NULL,
1010 NULL,
1011 NULL,
1012 binary,
1013 "gnunet-service-nat",
1014 "-c",
1015 tc_h->cfg_filename,
1016 NULL);
1017 if (NULL == tc_h->nat_proc)
1018 {
1019 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start NAT!");
1020 return;
1021 }
1022 LOG (GNUNET_ERROR_TYPE_INFO, "started NAT\n");
1023 GNUNET_free (binary);
1024}
1025
1026
1041 const char *service_name,
1042 const char *binary_name,
1043 const char *cfg_filename,
1044 const struct GNUNET_PeerIdentity *peer_id,
1052 void *cb_cls)
1053{
1055
1057 "Starting new transport/communicator combo with config %s\n",
1058 cfg_filename);
1059 tc_h =
1063 if ((GNUNET_SYSERR ==
1065 cfg_filename)))
1066 {
1068 _ ("Malformed configuration file `%s', exit ...\n"),
1069 cfg_filename);
1070 GNUNET_free (tc_h->cfg_filename);
1072 GNUNET_free (tc_h);
1073 return NULL;
1074 }
1076 "communicator-test",
1077 "BACKCHANNEL_ENABLED");
1081 tc_h->add_queue_cb = add_queue_cb;
1082 tc_h->incoming_msg_cb = incoming_message_cb;
1083 tc_h->bc_cb = bc_cb;
1084 tc_h->peer_id = *peer_id;
1085 tc_h->cb_cls = cb_cls;
1086
1087 /* Start communicator part of service */
1089 /* Start NAT */
1090 nat_start (tc_h);
1091 /* Start resolver service */
1092 resolver_start (tc_h);
1093 /* Start peerstore service */
1094 peerstore_start (tc_h);
1095 /* Start statistic service */
1096 statistics_start (tc_h);
1097 /* Schedule start communicator */
1098 communicator_start (tc_h,
1099 binary_name);
1100 return tc_h;
1101}
1102
1103
1104void
1107{
1116 while (NULL != (queue = tc_h->queue_head))
1117 {
1120 }
1124 GNUNET_free (tc_h);
1125}
1126
1127
1135void
1138 const struct GNUNET_PeerIdentity *peer_id,
1139 const char *address)
1140{
1142 static uint32_t idgen;
1143 char *prefix;
1145 struct GNUNET_MQ_Envelope *env;
1146 size_t alen;
1147
1148 tc_queue =
1150 tc_queue->tc_h = tc_h;
1152 if (NULL == prefix)
1153 {
1154 GNUNET_break (0); /* We got an invalid address!? */
1155 GNUNET_free (tc_queue);
1156 return;
1157 }
1159 alen = strlen (address) + 1;
1160 env =
1162 msg->request_id = htonl (idgen++);
1163 tc_queue->qid = msg->request_id;
1164 msg->receiver = *peer_id;
1165 tc_queue->peer_id = *peer_id;
1166 memcpy (&msg[1], address, alen);
1167 if (NULL != tc_h->c_mq)
1168 {
1170 "Sending queue create immediately\n");
1171 GNUNET_MQ_send (tc_h->c_mq, env);
1172 }
1173 else
1174 {
1175 tc_queue->open_queue_env = env;
1176 }
1177 GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
1178}
1179
1180
1181void
1185 void *cont_cls,
1186 const void *payload,
1187 size_t payload_size)
1188{
1189 struct GNUNET_MessageHeader *mh;
1191 struct GNUNET_MQ_Envelope *env;
1192 size_t inbox_size;
1196 tc_queue = NULL;
1197
1198 for (tc_queue_tmp = tc_h->queue_head;
1199 NULL != tc_queue_tmp;
1200 tc_queue_tmp = tc_queue_tmp->next)
1201 {
1202 if (tc_queue_tmp->q_len <= 0)
1203 continue;
1204 if (NULL == tc_queue)
1205 {
1207 "Selecting queue with prio %u, len %" PRIu64 " and MTU %u\n",
1208 tc_queue_tmp->priority,
1209 tc_queue_tmp->q_len,
1210 tc_queue_tmp->mtu);
1211 tc_queue = tc_queue_tmp;
1212 continue;
1213 }
1214 if (tc_queue->priority < tc_queue_tmp->priority)
1215 {
1217 "Selecting queue with prio %u, len %" PRIu64 " and MTU %u\n",
1218 tc_queue_tmp->priority,
1219 tc_queue_tmp->q_len,
1220 tc_queue_tmp->mtu);
1221 tc_queue = tc_queue_tmp;
1222 }
1223 }
1224 if (last_queue != tc_queue)
1226 "Selected sending queue changed to %u with length %lu and MTU %u\n",
1227 ntohl (tc_queue->qid), (unsigned long) tc_queue->q_len, tc_queue
1228 ->mtu);
1229 GNUNET_assert (NULL != tc_queue);
1230 last_queue = tc_queue;
1231 // Uncomment this for alternative 1 of backchannel functionality
1233 tc_queue->q_len--;
1234 // Until here for alternative 1
1235 {
1236 static int msg_count = 0;
1237 msg_count++;
1238 if (msg_count % 100 == 0)
1240 "Sending %u-th (%lu-th for queue) message on queue %u\n",
1241 msg_count, (unsigned long) tc_queue->mid, ntohl (tc_queue->qid
1242 ));
1243 }
1244 inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;
1246 inbox_size,
1248 GNUNET_assert (NULL != env);
1249 msg->qid = tc_queue->qid;
1250 msg->mid = tc_queue->mid++;
1251 msg->receiver = tc_queue->peer_id;
1252 mh = (struct GNUNET_MessageHeader *) &msg[1];
1253 mh->size = htons (inbox_size);
1255 memcpy (&mh[1],
1256 payload,
1257 payload_size);
1258 if (NULL != cont)
1260 cont,
1261 cont_cls);
1262 GNUNET_MQ_send (tc_queue->tc_h->c_mq,
1263 env);
1264}
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:98
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:65
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
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
Helper library for handling HELLO URIs.
Constants for network protocols.
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
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.
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-uri.c:1288
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ 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:305
#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:61
#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: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
#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:620
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
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:659
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:871
char * GNUNET_OS_get_libexec_binary_path(const struct GNUNET_OS_ProjectData *pd, const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
@ 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:1958
struct GNUNET_SERVICE_Handle * GNUNET_SERVICE_start(const struct GNUNET_OS_ProjectData *pd, 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:1883
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2389
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:630
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.
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:249
Handle to a service.
Definition: service.c:116
Add address to the list.
Definition: transport.h:287
Add queue to the transport.
Definition: transport.h:401
Message from transport to communicator passing along a backchannel message from the given peer pid.
Definition: transport.h:655
struct GNUNET_PeerIdentity pid
Origin peer.
Definition: transport.h:670
Message from communicator to transport service asking for transmission of a backchannel message with ...
Definition: transport.h:626
struct GNUNET_PeerIdentity pid
Target peer.
Definition: transport.h:640
Communicator tells transport how queue creation went down.
Definition: transport.h:545
Transport tells communicator that it wants a new queue.
Definition: transport.h:521
Transport informs us about being done with an incoming message.
Definition: transport.h:374
struct GNUNET_PeerIdentity sender
Sender identifier of the original message.
Definition: transport.h:393
uint64_t fc_id
Which message is being ACKed?
Definition: transport.h:388
uint32_t reserved
Reserved (0)
Definition: transport.h:383
Inform transport about an incoming message.
Definition: transport.h:333
struct GNUNET_PeerIdentity sender
Sender identifier.
Definition: transport.h:358
uint32_t fc_on
Do we use flow control or not?
Definition: transport.h:342
uint64_t fc_id
64-bit number to identify the matching ACK.
Definition: transport.h:347
Inform transport that message was sent.
Definition: transport.h:592
Inform communicator about transport's desire to send a message.
Definition: transport.h:563
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