GNUnet  0.11.x
transport-testing2.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"
31 #include "transport-testing2.h"
33 #include "gnunet_hello_lib.h"
34 #include "gnunet_signatures.h"
35 #include "transport.h"
36 
37 
38 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
39 
40 
45 {
50 
54  char *cfg_filename;
55 
60 
66 
71 
76 
81 
86 
91 
96 
101 
105  char *c_address;
106 
111 
116 
117  /* Callbacks + Closures */
123 
128 
133 
138 
143 
148 
153 
157  void *cb_cls;
158 
163 };
164 
165 
170 {
175 
184 
189 
193  uint32_t qid;
194 
198  uint64_t mid;
199 
203  uint32_t nt;
204 
208  uint32_t mtu;
209 
213  uint32_t cs;
214 
219 
224 };
225 
226 
231 {
232 };
233 
234 
244 static int
246  void *cls,
247  const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
248 {
249  uint16_t size;
250 
251  size = ntohs (msg->header.size) - sizeof(*msg);
252  if (0 == size)
253  return GNUNET_OK; /* receive-only communicator */
255  return GNUNET_OK;
256 }
257 
258 
267 static void
269  void *cls,
270  const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
271 {
273  uint16_t size;
274 
275  size = ntohs (msg->header.size) - sizeof(*msg);
276  if (0 == size)
277  return; /* receive-only communicator */
278  tc_h->c_characteristics = ntohl (msg->cc);
279  tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
280  if (NULL != tc_h->communicator_available_cb)
281  {
282  LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n");
283  tc_h->communicator_available_cb (tc_h->cb_cls,
284  tc_h,
285  tc_h->c_characteristics,
286  tc_h->c_addr_prefix);
287  }
289 }
290 
291 
299 static int
301  const struct
302  GNUNET_TRANSPORT_CommunicatorBackchannel *msg)
303 {
304  // struct TransportClient *tc = cls;
305 
306  // if (CT_COMMUNICATOR != tc->type)
307  // {
308  // GNUNET_break (0);
309  // return GNUNET_SYSERR;
310  // }
311  // GNUNET_MQ_check_boxed_message (msg);
312  return GNUNET_OK;
313 }
314 
315 
324 static void
326  const struct
327  GNUNET_TRANSPORT_CommunicatorBackchannel *
328  bc_msg)
329 {
332  struct GNUNET_MessageHeader *msg;
333  msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
334  uint16_t isize = ntohs (msg->size);
335  const char *target_communicator = ((const char *) msg) + isize;
336  struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
337  struct GNUNET_MQ_Envelope *env;
338 
339 
340  if (tc_h->bc_enabled != GNUNET_YES)
341  {
343  return;
344  }
345  /* Find client providing this communicator */
346  /* Finally, deliver backchannel message to communicator */
348  "Delivering backchannel message of type %u to %s\n",
349  ntohs (msg->type),
350  target_communicator);
351  other_tc_h = tc_h->bc_cb (tc_h, msg, (struct
352  GNUNET_PeerIdentity*) &bc_msg->pid);
353  env = GNUNET_MQ_msg_extra (
354  cbi,
355  isize,
357  cbi->pid = bc_msg->pid;
358  memcpy (&cbi[1], msg, isize);
359 
360 
361  GNUNET_MQ_send (other_tc_h->c_mq, env);
363 }
364 
365 
373 static int
374 check_add_address (void *cls,
375  const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
376 {
377  // if (CT_COMMUNICATOR != tc->type)
378  // {
379  // GNUNET_break (0);
380  // return GNUNET_SYSERR;
381  // }
383  return GNUNET_OK;
384 }
385 
386 
395 static void
397  const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
398 {
400  uint16_t size;
401  size = ntohs (msg->header.size) - sizeof(*msg);
402  if (0 == size)
403  return; /* receive-only communicator */
404  LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
405  tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
406  if (NULL != tc_h->add_address_cb)
407  {
408  LOG (GNUNET_ERROR_TYPE_DEBUG, "calling add_address_cb()\n");
409  tc_h->add_address_cb (tc_h->cb_cls,
410  tc_h,
411  tc_h->c_address,
412  GNUNET_TIME_relative_ntoh (msg->expiration),
413  msg->aid,
414  ntohl (msg->nt));
415  }
417 }
418 
419 
427 static int
429  const struct GNUNET_TRANSPORT_IncomingMessage *msg)
430 {
431  // struct TransportClient *tc = cls;
432 
433  // if (CT_COMMUNICATOR != tc->type)
434  // {
435  // GNUNET_break (0);
436  // return GNUNET_SYSERR;
437  // }
439  return GNUNET_OK;
440 }
441 
442 
451 static void
453  const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
454 {
456  struct GNUNET_MessageHeader *msg;
457  msg = (struct GNUNET_MessageHeader *) &inc_msg[1];
458  size_t payload_len = ntohs (msg->size) - sizeof (struct
461  "Incoming message from communicator!\n");
462 
463  if (NULL != tc_h->incoming_msg_cb)
464  {
465  tc_h->incoming_msg_cb (tc_h->cb_cls,
466  tc_h,
467  (char*) &msg[1],
468  payload_len);
469  }
470  else
471  {
473  "Incoming message from communicator but no handler!\n");
474  }
475  if (GNUNET_YES == ntohl (inc_msg->fc_on))
476  {
477  /* send ACK when done to communicator for flow control! */
478  struct GNUNET_MQ_Envelope *env;
479  struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
480 
482  ack->reserved = htonl (0);
483  ack->fc_id = inc_msg->fc_id;
484  ack->sender = inc_msg->sender;
485  GNUNET_MQ_send (tc_h->c_mq, env);
486  }
487 
489 }
490 
491 
498 static void
500  const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
501 {
503 
504  if (NULL != tc_h->queue_create_reply_cb)
505  {
506  tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
507  }
509 }
510 
511 
521 static void
523  void *cls,
524  const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
525 {
527 
528  if (NULL != tc_h->queue_create_reply_cb)
529  {
530  tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
531  }
533 }
534 
535 
542 static int
544  const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
545 {
547  return GNUNET_OK;
548 }
549 
550 
559 static void
561  const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
562 {
565 
566  tc_queue = tc_h->queue_head;
567  if (NULL != tc_queue)
568  {
569  while (tc_queue->qid != msg->qid)
570  {
571  tc_queue = tc_queue->next;
572  }
573  }
574  else
575  {
576  tc_queue =
578  tc_queue->tc_h = tc_h;
579  tc_queue->qid = msg->qid;
580  tc_queue->peer_id = msg->receiver;
581  GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
582  }
583  GNUNET_assert (tc_queue->qid == msg->qid);
584  GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
585  tc_queue->nt = msg->nt;
586  tc_queue->mtu = msg->mtu;
587  tc_queue->cs = msg->cs;
588  if (NULL != tc_h->add_queue_cb)
589  {
590  tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue);
591  }
593 }
594 
595 
601 static void
602 shutdown_service (void *cls)
603 {
604  struct GNUNET_SERVICE_Handle *h = cls;
605 
607 }
608 
609 
619 static void *
620 connect_cb (void *cls,
622  struct GNUNET_MQ_Handle *mq)
623 {
625 
626  LOG (GNUNET_ERROR_TYPE_DEBUG, "Client connected.\n");
627  tc_h->client = client;
628  tc_h->c_mq = mq;
629 
630  if (NULL == tc_h->queue_head)
631  return tc_h;
632  /* Iterate over queues. They are yet to be opened. Request opening. */
633  for (struct
635  tc_h->queue_head;
636  NULL != tc_queue_iter;
637  tc_queue_iter = tc_queue_iter->next)
638  {
639  if (NULL == tc_queue_iter->open_queue_env)
640  continue;
641  /* Send the previously created mq envelope to request the creation of the
642  * queue. */
643  GNUNET_MQ_send (tc_h->c_mq,
644  tc_queue_iter->open_queue_env);
645  tc_queue_iter->open_queue_env = NULL;
646  }
647  return tc_h;
648 }
649 
650 
658 static void
659 disconnect_cb (void *cls,
661  void *internal_cls)
662 {
664 
665  LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
666  tc_h->client = NULL;
667 }
668 
669 
676 static void
678  const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
679 {
682  // NOP
683 }
684 
685 
693 static void
696 {
697  struct GNUNET_MQ_MessageHandler mh[] = {
698  GNUNET_MQ_hd_var_size (communicator_available,
700  struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
701  tc_h),
702  GNUNET_MQ_hd_var_size (communicator_backchannel,
704  struct GNUNET_TRANSPORT_CommunicatorBackchannel,
705  tc_h),
706  GNUNET_MQ_hd_var_size (add_address,
708  struct GNUNET_TRANSPORT_AddAddressMessage,
709  tc_h),
710  // GNUNET_MQ_hd_fixed_size (del_address,
711  // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
712  // struct GNUNET_TRANSPORT_DelAddressMessage,
713  // NULL),
714  GNUNET_MQ_hd_var_size (incoming_msg,
716  struct GNUNET_TRANSPORT_IncomingMessage,
717  tc_h),
718  GNUNET_MQ_hd_fixed_size (queue_create_ok,
720  struct GNUNET_TRANSPORT_CreateQueueResponse,
721  tc_h),
722  GNUNET_MQ_hd_fixed_size (queue_create_fail,
724  struct GNUNET_TRANSPORT_CreateQueueResponse,
725  tc_h),
726  GNUNET_MQ_hd_var_size (add_queue_message,
728  struct GNUNET_TRANSPORT_AddQueueMessage,
729  tc_h),
730  // GNUNET_MQ_hd_fixed_size (del_queue_message,
731  // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
732  // struct GNUNET_TRANSPORT_DelQueueMessage,
733  // NULL),
734  GNUNET_MQ_hd_fixed_size (send_message_ack,
736  struct GNUNET_TRANSPORT_SendMessageToAck,
737  tc_h),
739  };
740 
741 
742  tc_h->sh = GNUNET_SERVICE_start ("transport",
743  tc_h->cfg,
744  &connect_cb,
745  &disconnect_cb,
746  tc_h,
747  mh);
748  GNUNET_assert (NULL != tc_h->sh);
749 }
750 
751 
757 static void
759 {
760  if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
761  {
763  "Error shutting down communicator with SIGERM, trying SIGKILL\n");
764  if (0 != GNUNET_OS_process_kill (proc, SIGKILL))
765  {
767  "Error shutting down communicator with SIGERM and SIGKILL\n");
768  }
769  }
771 }
772 
773 
774 static void
776 {
777  struct GNUNET_OS_Process *proc = cls;
778  shutdown_process (proc);
779 }
780 
781 
787 static void
790  const char *binary_name)
791 {
792  char *binary;
793 
794  LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
795  binary = GNUNET_OS_get_libexec_binary_path (binary_name);
798  NULL,
799  NULL,
800  NULL,
801  binary,
802  binary_name,
803  "-c",
804  tc_h->cfg_filename,
805  NULL);
806  if (NULL == tc_h->c_proc)
807  {
808  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
809  return;
810  }
811  LOG (GNUNET_ERROR_TYPE_INFO, "started communicator\n");
812  GNUNET_free (binary);
813 }
814 
815 
821 static void
822 shutdown_nat (void *cls)
823 {
824  struct GNUNET_OS_Process *proc = cls;
825  shutdown_process (proc);
826 }
827 
828 
833 static void
836 {
837  char *binary;
838 
839  LOG (GNUNET_ERROR_TYPE_DEBUG, "nat_start\n");
840  binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-nat");
843  NULL,
844  NULL,
845  NULL,
846  binary,
847  "gnunet-service-nat",
848  "-c",
849  tc_h->cfg_filename,
850  NULL);
851  if (NULL == tc_h->nat_proc)
852  {
853  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start NAT!");
854  return;
855  }
856  LOG (GNUNET_ERROR_TYPE_INFO, "started NAT\n");
857  GNUNET_free (binary);
858 }
859 
860 
861 static void
862 do_shutdown (void *cls)
863 {
866  shutdown_service (tc_h->sh);
867  shutdown_nat (tc_h->nat_proc);
868 }
869 
870 
885  const char *service_name,
886  const char *binary_name,
887  const char *cfg_filename,
895  void *cb_cls)
896 {
898 
899  tc_h =
901  tc_h->cfg_filename = GNUNET_strdup (cfg_filename);
902  tc_h->cfg = GNUNET_CONFIGURATION_create ();
903  if ((GNUNET_SYSERR == GNUNET_CONFIGURATION_load (tc_h->cfg, cfg_filename)))
904  {
906  _ ("Malformed configuration file `%s', exit ...\n"),
907  cfg_filename);
908  GNUNET_free (tc_h->cfg_filename);
910  GNUNET_free (tc_h);
911  return NULL;
912  }
914  "communicator-test",
915  "BACKCHANNEL_ENABLED");
919  tc_h->add_queue_cb = add_queue_cb;
920  tc_h->incoming_msg_cb = incoming_message_cb;
921  tc_h->bc_cb = bc_cb;
922  tc_h->cb_cls = cb_cls;
923 
924  /* Start communicator part of service */
926  /* Start NAT */
927  nat_start (tc_h);
928  /* Schedule start communicator */
929  communicator_start (tc_h,
930  binary_name);
932  return tc_h;
933 }
934 
935 
943 void
946  const struct GNUNET_PeerIdentity *peer_id,
947  const char *address)
948 {
950  static uint32_t idgen;
951  char *prefix;
952  struct GNUNET_TRANSPORT_CreateQueue *msg;
953  struct GNUNET_MQ_Envelope *env;
954  size_t alen;
955 
956  tc_queue =
958  tc_queue->tc_h = tc_h;
959  prefix = GNUNET_HELLO_address_to_prefix (address);
960  if (NULL == prefix)
961  {
962  GNUNET_break (0); /* We got an invalid address!? */
963  GNUNET_free (tc_queue);
964  return;
965  }
966  GNUNET_free (prefix);
967  alen = strlen (address) + 1;
968  env =
970  msg->request_id = htonl (idgen++);
971  tc_queue->qid = msg->request_id;
972  msg->receiver = *peer_id;
973  tc_queue->peer_id = *peer_id;
974  memcpy (&msg[1], address, alen);
975  if (NULL != tc_h->c_mq)
976  {
977  GNUNET_MQ_send (tc_h->c_mq, env);
978  }
979  else
980  {
981  tc_queue->open_queue_env = env;
982  }
983  GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
984 }
985 
986 
999  const void *payload,
1000  size_t payload_size)
1001 {
1003  struct GNUNET_MessageHeader *mh;
1004  struct GNUNET_TRANSPORT_SendMessageTo *msg;
1005  struct GNUNET_MQ_Envelope *env;
1006  size_t inbox_size;
1007 
1008  inbox_size = sizeof(struct GNUNET_MessageHeader) + payload_size;
1009  mh = GNUNET_malloc (inbox_size);
1010  mh->size = htons (inbox_size);
1011  mh->type = GNUNET_MESSAGE_TYPE_DUMMY;
1012  memcpy (&mh[1],
1013  payload,
1014  payload_size);
1015  env = GNUNET_MQ_msg_extra (msg,
1016  inbox_size,
1018  msg->qid = htonl (tc_queue->qid);
1019  msg->mid = tc_queue->mid++;
1020  msg->receiver = tc_queue->peer_id;
1021  memcpy (&msg[1], mh, inbox_size);
1022  GNUNET_free (mh);
1023  GNUNET_MQ_send (tc_queue->tc_h->c_mq, env);
1024  // GNUNET_assert (0); // FIXME: not iplemented!
1025  return tc_t;
1026 }
GNUNET_TRANSPORT_CommunicatorCharacteristics
What characteristics does this communicator have?
functions and structures related to testing-tng
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * next
Next element inside a DLL.
struct GNUNET_PeerIdentity peer_id
Peer ID of the peer on the other side of the queue.
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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
static void handle_queue_create_fail(void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
Communicator informs that it wont try establishing requested queue.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
static void nat_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start NAT.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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.
common internal definitions for transport service
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:287
Handle to a service.
Definition: service.c:116
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
char * cfg_filename
File name of configuration file.
static void handle_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Handle new communicator.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
void(* GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue)
Handle opening of queue.
struct GNUNET_SCHEDULER_Task * ts_shutdown_task
Task that will be run on shutdown to stop and clean transport service.
static void shutdown_communicator(void *cls)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
struct GNUNET_OS_Process * GNUNET_OS_start_process(int pipe_control, 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:687
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_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
Receive an incoming message.
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
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:1878
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:86
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(const char *service_name, const char *binary_name, const char *cfg_filename, 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.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics
Characteristics of the communicator.
static void shutdown_nat(void *cls)
Task run at shutdown to kill communicator and clean up.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
Transport signalling incoming backchannel message to a communicator.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_SERVICE_Handle * sh
Our service handle.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb
Callback called when a new communicator connects.
struct GNUNET_OS_Process * nat_proc
NAT process.
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define _(String)
GNU gettext support macro.
Definition: platform.h:180
Handle to a client that is connected to a service.
Definition: service.c:250
char * c_addr_prefix
Specifies supported addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
static void handle_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
The communicator informs about an address.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static int check_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
New queue became available.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
void * cls
Closure for mv and cb.
static int check_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Check whether incoming msg indicating available communicator is correct.
static int check_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
Address of our peer added.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
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.
static void shutdown_process(struct GNUNET_OS_Process *proc)
Task run at shutdown to kill communicator and clean up.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb
Callback called when a new communicator connects.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission * GNUNET_TRANSPORT_TESTING_transport_communicator_send(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, const void *payload, size_t payload_size)
Instruct communicator to send data.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
static void handle_queue_create_ok(void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
Communicator informs that it tries to establish requested queue.
void GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv)
Stops a service that was started with GNUNET_SERVICE_start().
Definition: service.c:1911
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:641
Message handler for a specific message type.
When these flags are set, the child process will inherit stdout and stderr of the parent...
Definition: gnunet_os_lib.h:97
static int check_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *msg)
Incoming message.
static int check_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *msg)
Incoming message.
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.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the configuration.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:191
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * prev
Previous element inside a DLL.
static void do_shutdown(void *cls)
static void handle_send_message_ack(void *cls, const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
Message was transmitted.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb
Callback called when a new communicator connects.
static void communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *binary_name)
Start the communicator.
static unsigned long long payload
How much data are we currently storing in the database?
uint32_t nt
An enum GNUNET_NetworkType in NBO.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_SERVICE_Handle * tsh
Handle to the transport service.
Handle to a message queue.
Definition: mq.c:85
uint32_t mtu
Maximum transmission unit, in NBO.
static void handle_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *bc_msg)
Receive an incoming message.
The identity of the host (wraps the signing key of the peer).
static void handle_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
Handle new queue.
configuration data
Definition: configuration.c:84
#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.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_tail
Tail of the DLL of queues associated with this communicator.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
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 ...
static void disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Callback called when Client disconnects.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS
inform transport to add an address of this peer
struct GNUNET_MQ_Envelope * open_queue_env
Envelope to a message that requests the opening of the queue.
struct GNUNET_OS_Process * c_proc
Process of the communicator.
Header for all communications.
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.
GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb
Callback called when a new communicator connects.
#define GNUNET_YES
Definition: gnunet_common.h:85
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb
Callback called when a new communicator connects.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_head
Head of the DLL of queues associated with this communicator.
struct GNUNET_SCHEDULER_Task * c_shutdown_task
Task that will be run on shutdown to stop and clean communicator.
GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb
Backchannel callback.
struct GNUNET_SERVICE_Client * client
Handle to the client.
static void shutdown_service(void *cls)
Shut down the service.
static void transport_communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start the communicator part of the transport service.
int 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".
static char * address
GNS address for this phone.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define LOG(kind,...)
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
char * c_address
Specifies supported addresses.
#define GNUNET_free(ptr)
Wrapper around free.
Queue of a communicator and some context.
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:225
static void * connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Callback called when new Client (Communicator) connects.
Bandwidth allocation API for the transport service.