GNUnet  0.10.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 
100  char *c_address;
101 
106 
111 
112  /* Callbacks + Closures */
118 
123 
128 
133 
138 
142  void *cb_cls;
143 };
144 
145 
150 {
155 
164 
169 
173  uint32_t qid;
174 
178  uint64_t mid;
179 
183  uint32_t nt;
184 
188  uint32_t mtu;
189 
193  uint32_t cs;
194 
199 
204 };
205 
206 
211 {
212 };
213 
214 
224 static int
226  void *cls,
227  const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
228 {
229  uint16_t size;
230 
231  size = ntohs (msg->header.size) - sizeof (*msg);
232  if (0 == size)
233  return GNUNET_OK; /* receive-only communicator */
235  return GNUNET_OK;
236 }
237 
238 
247 static void
249  void *cls,
250  const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
251 {
253  uint16_t size;
254 
255  size = ntohs (msg->header.size) - sizeof (*msg);
256  if (0 == size)
257  return; /* receive-only communicator */
258  tc_h->c_characteristics = ntohl (msg->cc);
259  tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
260  if (NULL != tc_h->communicator_available_cb)
261  {
262  LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n");
263  tc_h->communicator_available_cb (tc_h->cb_cls,
264  tc_h,
265  tc_h->c_characteristics,
266  tc_h->c_addr_prefix);
267  }
269 }
270 
271 
279 static int
280 check_add_address (void *cls,
281  const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
282 {
283  struct TransportClient *tc = cls;
284 
285  //if (CT_COMMUNICATOR != tc->type)
286  //{
287  // GNUNET_break (0);
288  // return GNUNET_SYSERR;
289  //}
291  return GNUNET_OK;
292 }
293 
294 
303 static void
305  const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
306 {
308  uint16_t size;
309 
310  size = ntohs (msg->header.size) - sizeof (*msg);
311  if (0 == size)
312  return; /* receive-only communicator */
313  tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
314  if (NULL != tc_h->add_address_cb)
315  {
316  LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available()\n");
317  tc_h->add_address_cb (tc_h->cb_cls,
318  tc_h,
319  tc_h->c_address,
320  GNUNET_TIME_relative_ntoh (msg->expiration),
321  msg->aid,
322  ntohl (msg->nt));
323  }
325 }
326 
327 
335 static int
337  const struct GNUNET_TRANSPORT_IncomingMessage *msg)
338 {
339  //struct TransportClient *tc = cls;
340 
341  //if (CT_COMMUNICATOR != tc->type)
342  //{
343  // GNUNET_break (0);
344  // return GNUNET_SYSERR;
345  //}
347  return GNUNET_OK;
348 }
349 
350 
359 static void
361  const struct GNUNET_TRANSPORT_IncomingMessage *msg)
362 {
364 
365  if (NULL != tc_h->incoming_msg_cb) {
366  tc_h->incoming_msg_cb (tc_h->cb_cls,
367  tc_h,
368  (const struct GNUNET_MessageHeader *) msg);
369  }
370  else
371  {
373  "Incoming message from communicator but no handler!\n");
374  }
376 }
377 
378 
385 static void
387  const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
388 {
390 
391  if (NULL != tc_h->queue_create_reply_cb)
392  {
393  tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
394  }
396 }
397 
398 
408 static void
410  void *cls,
411  const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
412 {
414 
415  if (NULL != tc_h->queue_create_reply_cb)
416  {
417  tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
418  }
420 }
421 
422 
429 static int
431  const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
432 {
434  return GNUNET_OK;
435 }
436 
437 
446 static void
448  const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
449 {
452 
453  tc_queue = tc_h->queue_head;
454  while (tc_queue->qid != msg->qid)
455  {
456  tc_queue = tc_queue->next;
457  }
458  GNUNET_assert (tc_queue->qid == msg->qid);
459  GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
460  tc_queue->nt = msg->nt;
461  tc_queue->mtu = msg->mtu;
462  tc_queue->cs = msg->cs;
463  if (NULL != tc_h->add_queue_cb)
464  {
465  tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue);
466  }
468 }
469 
470 
476 static void
477 shutdown_service (void *cls)
478 {
479  struct GNUNET_SERVICE_Handle *h = cls;
480 
482 }
483 
484 
494 static void *
495 connect_cb (void *cls,
497  struct GNUNET_MQ_Handle *mq)
498 {
501 
502  LOG (GNUNET_ERROR_TYPE_DEBUG, "Client connected.\n");
503  tc_h->client = client;
504  tc_h->c_mq = mq;
505 
506  if (NULL == tc_h->queue_head)
507  return tc_h;
508  /* Iterate over queues. They are yet to be opened. Request opening. */
509  while (NULL != (tc_queue_iter = tc_h->queue_head))
510  {
511  if (NULL == tc_queue_iter->open_queue_env)
512  continue;
513  /* Send the previously created mq envelope to request the creation of the
514  * queue. */
515  GNUNET_MQ_send (tc_h->c_mq, tc_queue_iter->open_queue_env);
516  tc_queue_iter->open_queue_env = NULL;
517  }
518  return tc_h;
519 }
520 
521 
529 static void
530 disconnect_cb (void *cls,
532  void *internal_cls)
533 {
535 
536  LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
537  tc_h->client = NULL;
538 }
539 
540 
548 static void
551 {
552  struct GNUNET_MQ_MessageHandler mh[] = {
553  GNUNET_MQ_hd_var_size (communicator_available,
555  struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
556  &tc_h),
557  //GNUNET_MQ_hd_var_size (communicator_backchannel,
558  // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
559  // struct GNUNET_TRANSPORT_CommunicatorBackchannel,
560  // NULL),
561  GNUNET_MQ_hd_var_size (add_address,
563  struct GNUNET_TRANSPORT_AddAddressMessage,
564  &tc_h),
565  //GNUNET_MQ_hd_fixed_size (del_address,
566  // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
567  // struct GNUNET_TRANSPORT_DelAddressMessage,
568  // NULL),
569  GNUNET_MQ_hd_var_size (incoming_msg,
571  struct GNUNET_TRANSPORT_IncomingMessage,
572  NULL),
573  GNUNET_MQ_hd_fixed_size (queue_create_ok,
575  struct GNUNET_TRANSPORT_CreateQueueResponse,
576  tc_h),
577  GNUNET_MQ_hd_fixed_size (queue_create_fail,
579  struct GNUNET_TRANSPORT_CreateQueueResponse,
580  tc_h),
581  GNUNET_MQ_hd_var_size (add_queue_message,
583  struct GNUNET_TRANSPORT_AddQueueMessage,
584  NULL),
585  //GNUNET_MQ_hd_fixed_size (del_queue_message,
586  // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
587  // struct GNUNET_TRANSPORT_DelQueueMessage,
588  // NULL),
589  //GNUNET_MQ_hd_fixed_size (send_message_ack,
590  // GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK,
591  // struct GNUNET_TRANSPORT_SendMessageToAck,
592  // NULL),
593  };
594  struct GNUNET_SERVICE_Handle *h;
595 
596  h = GNUNET_SERVICE_start ("transport",
597  tc_h->cfg,
598  &connect_cb,
599  &disconnect_cb,
600  tc_h,
601  mh);
602  if (NULL == h)
603  LOG (GNUNET_ERROR_TYPE_ERROR, "Failed starting service!\n");
604  else
605  {
606  LOG (GNUNET_ERROR_TYPE_DEBUG, "Started service\n");
608  }
609 }
610 
611 
617 static void
619 {
620  struct GNUNET_OS_Process *proc = cls;
621 
622  if (GNUNET_OK != GNUNET_OS_process_kill (proc, SIGTERM))
623  {
625  "Error shutting down communicator with SIGERM, trying SIGKILL\n");
626  if (GNUNET_OK != GNUNET_OS_process_kill (proc, SIGKILL))
627  {
629  "Error shutting down communicator with SIGERM and SIGKILL\n");
630  }
631  }
633 }
634 
635 
641 static void
644  const char *binary_name)
645 {
646  char *binary;
647 
648  LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
649  binary = GNUNET_OS_get_libexec_binary_path (binary_name);
652  NULL,
653  NULL,
654  NULL,
655  binary,
656  binary_name,
657  "-c",
658  tc_h->cfg_filename,
659  NULL);
660  if (NULL == tc_h->c_proc)
661  {
662  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
663  return;
664  }
665  LOG (GNUNET_ERROR_TYPE_DEBUG, "started communicator\n");
666  GNUNET_free (binary);
668  tc_h->c_proc);
669 }
670 
671 
686  const char *service_name,
687  const char *binary_name,
688  const char *cfg_filename,
695  void *cb_cls)
696 {
698 
699  tc_h =
701  tc_h->cfg_filename = GNUNET_strdup (cfg_filename);
702  tc_h->cfg = GNUNET_CONFIGURATION_create ();
703  if ((GNUNET_SYSERR == GNUNET_CONFIGURATION_load (tc_h->cfg, cfg_filename)))
704  {
706  _ ("Malformed configuration file `%s', exit ...\n"),
707  cfg_filename);
708  GNUNET_free (tc_h->cfg_filename);
710  GNUNET_free (tc_h);
711  return NULL;
712  }
716  tc_h->add_queue_cb = add_queue_cb;
717  tc_h->incoming_msg_cb = incoming_message_cb;
718  tc_h->cb_cls = cb_cls;
719 
720  /* Start communicator part of service */
722 
723  /* Schedule start communicator */
724  communicator_start (tc_h,
725  binary_name);
726  return tc_h;
727 }
728 
729 
737 void
740  const struct GNUNET_PeerIdentity *peer_id,
741  const char *address)
742 {
744  static uint32_t idgen;
745  char *prefix;
746  struct GNUNET_TRANSPORT_CreateQueue *msg;
747  struct GNUNET_MQ_Envelope *env;
748  size_t alen;
749 
750  tc_queue =
752  tc_queue->tc_h = tc_h;
753  prefix = GNUNET_HELLO_address_to_prefix (address);
754  if (NULL == prefix)
755  {
756  GNUNET_break (0); /* We got an invalid address!? */
757  GNUNET_free (tc_queue);
758  return;
759  }
760  GNUNET_free (prefix);
761  alen = strlen (address) + 1;
762  env =
764  msg->request_id = htonl (idgen++);
765  tc_queue->qid = msg->request_id;
766  msg->receiver = *peer_id;
767  tc_queue->peer_id = *peer_id;
768  memcpy (&msg[1], address, alen);
769  if (NULL != tc_h->c_mq)
770  {
771  GNUNET_MQ_send (tc_h->c_mq, env);
772  }
773  else
774  {
775  tc_queue->open_queue_env = env;
776  }
777  GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
778 }
779 
780 
793  const void *payload,
794  size_t payload_size/*,
795  GNUNET_TRANSPORT_TESTING_SuccessStatus cb,
796  void *cb_cls*/)
797 {
799  struct GNUNET_MessageHeader *mh;
800  struct GNUNET_TRANSPORT_SendMessageTo *msg;
801  struct GNUNET_MQ_Envelope *env;
802  size_t inbox_size;
803 
804  inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;
805  mh = GNUNET_malloc (inbox_size);
806  mh->size = htons (inbox_size);
807  mh->type = GNUNET_MESSAGE_TYPE_DUMMY;
808  memcpy (&mh[1],
809  payload,
810  payload_size);
811  env = GNUNET_MQ_msg_extra (msg,
812  inbox_size,
814  msg->qid = htonl (tc_queue->qid);
815  msg->mid = tc_queue->mid++;
816  msg->receiver = tc_queue->peer_id;
817  memcpy (&msg[1], mh, inbox_size);
818  GNUNET_free (mh);
819  GNUNET_MQ_send (tc_queue->tc_h->c_mq, env);
820  return tc_t;
821 }
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.
#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
#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:364
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:1293
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)
Task run at shutdown to kill communicator and clean up.
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, void *cb_cls)
Start communicator part of transport service and communicator.
#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:1400
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:417
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.
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
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:2157
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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.
#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:94
GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb
Callback called when a new communicator connects.
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Handle to a client that is connected to a service.
Definition: service.c:249
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
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 ...
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_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
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.
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:2193
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:638
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:98
static int check_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *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:79
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.
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.
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:85
static void handle_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *msg)
Receive an incoming message.
#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
Client connected to the transport service.
#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:80
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.
void(* GNUNET_TRANSPORT_TESTING_IncomingMessageCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const struct GNUNET_MessageHeader *msg)
Handle an incoming message.
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.
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:2533
#define LOG(kind,...)
#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:251
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.