GNUnet  0.11.x
Data Structures | Macros | Functions
transport-testing2.c File Reference

functions related to testing-tng More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_constants.h"
#include "transport-testing2.h"
#include "gnunet_ats_transport_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_signatures.h"
#include "transport.h"
Include dependency graph for transport-testing2.c:

Go to the source code of this file.

Data Structures

struct  MyClient
 
struct  GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
 Handle to a transport communicator. More...
 
struct  GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
 Queue of a communicator and some context. More...
 
struct  GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission
 Handle/Context to a single transmission. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
 

Functions

static int check_communicator_available (void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
 Check whether incoming msg indicating available communicator is correct. More...
 
static void handle_communicator_available (void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
 Handle new communicator. More...
 
static int check_communicator_backchannel (void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *msg)
 Incoming message. More...
 
static void handle_communicator_backchannel (void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *bc_msg)
 Receive an incoming message. More...
 
static int check_add_address (void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
 Address of our peer added. More...
 
static void handle_add_address (void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
 The communicator informs about an address. More...
 
static int check_incoming_msg (void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *msg)
 Incoming message. More...
 
static void handle_incoming_msg (void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
 Receive an incoming message. More...
 
static void handle_queue_create_ok (void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
 Communicator informs that it tries to establish requested queue. More...
 
static void handle_queue_create_fail (void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
 Communicator informs that it wont try establishing requested queue. More...
 
static int check_add_queue_message (void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
 New queue became available. More...
 
static void handle_add_queue_message (void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
 Handle new queue. More...
 
static void shutdown_service (void *cls)
 Shut down the service. More...
 
static void * connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Callback called when new Client (Communicator) connects. More...
 
static void disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
 Callback called when Client disconnects. More...
 
static void handle_send_message_ack (void *cls, const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
 Message was transmitted. More...
 
static void transport_communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
 Start the communicator part of the transport service. More...
 
static void shutdown_process (struct GNUNET_OS_Process *proc)
 Task run at shutdown to kill communicator and clean up. More...
 
static void shutdown_communicator (void *cls)
 
static void communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *binary_name)
 Start the communicator. More...
 
static void shutdown_nat (void *cls)
 Task run at shutdown to kill communicator and clean up. More...
 
static void nat_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
 Start NAT. More...
 
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandleGNUNET_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. More...
 
void GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
 
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. More...
 
void GNUNET_TRANSPORT_TESTING_transport_communicator_send (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls, const void *payload, size_t payload_size)
 Instruct communicator to send data. More...
 

Detailed Description

functions related to testing-tng

Author
Christian Grothoff
Julius Bünger

Definition in file transport-testing2.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)

Function Documentation

◆ check_communicator_available()

static int check_communicator_available ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *  msg 
)
static

Check whether incoming msg indicating available communicator is correct.

Parameters
clsClosure
msgMessage struct
Returns
GNUNET_YES in case message is correct

Definition at line 267 of file transport-testing2.c.

References GNUNET_MQ_check_zero_termination, GNUNET_OK, and size.

270 {
271  uint16_t size;
272 
273  size = ntohs (msg->header.size) - sizeof(*msg);
274  if (0 == size)
275  return GNUNET_OK; /* receive-only communicator */
277  return GNUNET_OK;
278 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ handle_communicator_available()

static void handle_communicator_available ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *  msg 
)
static

Handle new communicator.

Store characteristics of communicator, call respective client callback.

Parameters
clsClosure - communicator handle
msgMessage struct

Definition at line 290 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_addr_prefix, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_characteristics, MyClient::c_mq, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cb_cls, MyClient::client, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::communicator_available_cb, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SERVICE_client_continue(), GNUNET_strdup, LOG, size, and MyClient::tc.

293 {
294  struct MyClient *client = cls;
296  client->tc;
297  uint16_t size;
298  tc_h->c_mq = client->c_mq;
299 
300  size = ntohs (msg->header.size) - sizeof(*msg);
301  if (0 == size)
302  {
304  return; /* receive-only communicator */
305  }
306  tc_h->c_characteristics = ntohl (msg->cc);
307  tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
308  if (NULL != tc_h->communicator_available_cb)
309  {
310  LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n");
311  tc_h->communicator_available_cb (tc_h->cb_cls,
312  tc_h,
313  tc_h->c_characteristics,
314  tc_h->c_addr_prefix);
315  }
317  LOG (GNUNET_ERROR_TYPE_DEBUG, "finished communicator_available_cb()\n");
318 
319 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics
Characteristics of the communicator.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb
Callback called when a new communicator connects.
char * c_addr_prefix
Specifies supported addresses.
struct GNUNET_SERVICE_Client * client
Handle to the client.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
static unsigned int size
Size of the "table".
Definition: peer.c:67
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
#define LOG(kind,...)
Here is the call graph for this function:

◆ check_communicator_backchannel()

static int check_communicator_backchannel ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorBackchannel *  msg 
)
static

Incoming message.

Test message is well-formed.

Parameters
clsthe client
msgthe send message that was sent
Returns
GNUNET_OK if message is well-formed

Definition at line 330 of file transport-testing2.c.

References GNUNET_OK.

333 {
334  // struct TransportClient *tc = cls;
335 
336  // if (CT_COMMUNICATOR != tc->type)
337  // {
338  // GNUNET_break (0);
339  // return GNUNET_SYSERR;
340  // }
341  // GNUNET_MQ_check_boxed_message (msg);
342  return GNUNET_OK;
343 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83

◆ handle_communicator_backchannel()

static void handle_communicator_backchannel ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorBackchannel *  bc_msg 
)
static

Receive an incoming message.

Pass the message to the client.

Parameters
clsClosure - communicator handle
msgMessage

Definition at line 355 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::bc_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::bc_enabled, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, MyClient::client, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_YES, msg, GNUNET_MessageHeader::size, MyClient::tc, and GNUNET_MessageHeader::type.

359 {
360  struct MyClient *client = cls;
362  client->tc;
364  struct GNUNET_MessageHeader *msg;
365  msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
366  uint16_t isize = ntohs (msg->size);
367  const char *target_communicator = ((const char *) msg) + isize;
368  struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
369  struct GNUNET_MQ_Envelope *env;
370 
371 
372  if (tc_h->bc_enabled != GNUNET_YES)
373  {
375  return;
376  }
377  /* Find client providing this communicator */
378  /* Finally, deliver backchannel message to communicator */
380  "Delivering backchannel message of type %u to %s\n",
381  ntohs (msg->type),
382  target_communicator);
383  other_tc_h = tc_h->bc_cb (tc_h, msg, (struct
384  GNUNET_PeerIdentity*) &bc_msg->pid);
385  env = GNUNET_MQ_msg_extra (
386  cbi,
387  isize,
389  cbi->pid = bc_msg->pid;
390  memcpy (&cbi[1], msg, isize);
391 
392 
393  GNUNET_MQ_send (other_tc_h->c_mq, env);
395 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
#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...
#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.
struct GNUNET_SERVICE_Client * client
Handle to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
The identity of the host (wraps the signing key of the peer).
#define GNUNET_log(kind,...)
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:85
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:355
GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb
Backchannel callback.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
Here is the call graph for this function:

◆ check_add_address()

static int check_add_address ( void *  cls,
const struct GNUNET_TRANSPORT_AddAddressMessage *  msg 
)
static

Address of our peer added.

Test message is well-formed.

Parameters
clsthe client
aamthe send message that was sent
Returns
GNUNET_OK if message is well-formed

Definition at line 406 of file transport-testing2.c.

References GNUNET_MQ_check_zero_termination, and GNUNET_OK.

408 {
409  // if (CT_COMMUNICATOR != tc->type)
410  // {
411  // GNUNET_break (0);
412  // return GNUNET_SYSERR;
413  // }
415  return GNUNET_OK;
416 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_add_address()

static void handle_add_address ( void *  cls,
const struct GNUNET_TRANSPORT_AddAddressMessage *  msg 
)
static

The communicator informs about an address.

Store address and call client callback.

Parameters
clsClosure - communicator handle
msgMessage

Definition at line 428 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::add_address_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_address, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cb_cls, MyClient::client, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_TIME_relative_ntoh(), LOG, size, and MyClient::tc.

430 {
431  struct MyClient *client = cls;
433  client->tc;
434  uint16_t size;
435  size = ntohs (msg->header.size) - sizeof(*msg);
436  if (0 == size)
437  return; /* receive-only communicator */
438  LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
439  tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
440  if (NULL != tc_h->add_address_cb)
441  {
442  LOG (GNUNET_ERROR_TYPE_DEBUG, "calling add_address_cb()\n");
443  tc_h->add_address_cb (tc_h->cb_cls,
444  tc_h,
445  tc_h->c_address,
446  GNUNET_TIME_relative_ntoh (msg->expiration),
447  msg->aid,
448  ntohl (msg->nt));
449  }
451 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_SERVICE_Client * client
Handle to the client.
GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb
Callback called when a new communicator connects.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:641
static unsigned int size
Size of the "table".
Definition: peer.c:67
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
#define LOG(kind,...)
char * c_address
Specifies supported addresses.
Here is the call graph for this function:

◆ check_incoming_msg()

static int check_incoming_msg ( void *  cls,
const struct GNUNET_TRANSPORT_IncomingMessage *  msg 
)
static

Incoming message.

Test message is well-formed.

Parameters
clsthe client
msgthe send message that was sent
Returns
GNUNET_OK if message is well-formed

Definition at line 462 of file transport-testing2.c.

References GNUNET_MQ_check_boxed_message, and GNUNET_OK.

464 {
465  // struct TransportClient *tc = cls;
466 
467  // if (CT_COMMUNICATOR != tc->type)
468  // {
469  // GNUNET_break (0);
470  // return GNUNET_SYSERR;
471  // }
473  return GNUNET_OK;
474 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_incoming_msg()

static void handle_incoming_msg ( void *  cls,
const struct GNUNET_TRANSPORT_IncomingMessage *  inc_msg 
)
static

Receive an incoming message.

Pass the message to the client.

Parameters
clsClosure - communicator handle
msgMessage

Definition at line 486 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cb_cls, MyClient::client, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_YES, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::incoming_msg_cb, LOG, msg, GNUNET_MessageHeader::size, and MyClient::tc.

488 {
489  struct MyClient *client = cls;
491  client->tc;
492  struct GNUNET_MessageHeader *msg;
493  msg = (struct GNUNET_MessageHeader *) &inc_msg[1];
494  size_t payload_len = ntohs (msg->size) - sizeof (struct
497  "Incoming message from communicator!\n");
498 
499  if (NULL != tc_h->incoming_msg_cb)
500  {
501  tc_h->incoming_msg_cb (tc_h->cb_cls,
502  tc_h,
503  (char*) &msg[1],
504  payload_len);
505  }
506  else
507  {
509  "Incoming message from communicator but no handler!\n");
510  }
511  if (GNUNET_YES == ntohl (inc_msg->fc_on))
512  {
513  /* send ACK when done to communicator for flow control! */
514  struct GNUNET_MQ_Envelope *env;
515  struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
516 
518  ack->reserved = htonl (0);
519  ack->fc_id = inc_msg->fc_id;
520  ack->sender = inc_msg->sender;
521  GNUNET_MQ_send (tc_h->c_mq, env);
522  }
523 
525 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
struct GNUNET_SERVICE_Client * client
Handle to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb
Callback called when a new communicator connects.
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:85
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:355
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
#define LOG(kind,...)
Here is the call graph for this function:

◆ handle_queue_create_ok()

static void handle_queue_create_ok ( void *  cls,
const struct GNUNET_TRANSPORT_CreateQueueResponse *  msg 
)
static

Communicator informs that it tries to establish requested queue.

Parameters
clsClosure - communicator handle
msgMessage

Definition at line 535 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cb_cls, MyClient::client, GNUNET_SERVICE_client_continue(), GNUNET_YES, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_create_reply_cb, and MyClient::tc.

537 {
538  struct MyClient *client = cls;
540  client->tc;
541 
542  if (NULL != tc_h->queue_create_reply_cb)
543  {
544  tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
545  }
547 }
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
struct GNUNET_SERVICE_Client * client
Handle to the client.
#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_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
Here is the call graph for this function:

◆ handle_queue_create_fail()

static void handle_queue_create_fail ( void *  cls,
const struct GNUNET_TRANSPORT_CreateQueueResponse *  msg 
)
static

Communicator informs that it wont try establishing requested queue.

It will not do so probably because the address is bougus (see comment to GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL)

Parameters
clsClosure - communicator handle
msgMessage

Definition at line 560 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cb_cls, MyClient::client, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_create_reply_cb, and MyClient::tc.

563 {
564  struct MyClient *client = cls;
566  client->tc;
567 
568  if (NULL != tc_h->queue_create_reply_cb)
569  {
570  tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
571  }
573 }
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
#define GNUNET_NO
Definition: gnunet_common.h:86
struct GNUNET_SERVICE_Client * client
Handle to the client.
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb
Callback called when a new communicator connects.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
Here is the call graph for this function:

◆ check_add_queue_message()

static int check_add_queue_message ( void *  cls,
const struct GNUNET_TRANSPORT_AddQueueMessage *  aqm 
)
static

New queue became available.

Check message.

Parameters
clsthe client
aqmthe send message that was sent

Definition at line 583 of file transport-testing2.c.

References GNUNET_MQ_check_zero_termination, and GNUNET_OK.

585 {
587  return GNUNET_OK;
588 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_add_queue_message()

static void handle_add_queue_message ( void *  cls,
const struct GNUNET_TRANSPORT_AddQueueMessage *  msg 
)
static

Handle new queue.

Store context and call client callback.

Parameters
clsClosure - communicator handle
msgMessage struct

Definition at line 600 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::add_queue_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cb_cls, MyClient::client, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::cs, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_memcmp, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::mtu, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::next, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::nt, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::peer_id, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::qid, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_head, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_tail, MyClient::tc, and GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::tc_h.

602 {
603  struct MyClient *client = cls;
605  client->tc;
607 
608  tc_queue = tc_h->queue_head;
609  if (NULL != tc_queue)
610  {
611  while (tc_queue->qid != msg->qid)
612  {
613  tc_queue = tc_queue->next;
614  }
615  }
616  else
617  {
618  tc_queue =
620  tc_queue->tc_h = tc_h;
621  tc_queue->qid = msg->qid;
622  tc_queue->peer_id = msg->receiver;
623  GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
624  }
625  GNUNET_assert (tc_queue->qid == msg->qid);
626  GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
627  tc_queue->nt = msg->nt;
628  tc_queue->mtu = msg->mtu;
629  tc_queue->cs = msg->cs;
630  if (NULL != tc_h->add_queue_cb)
631  {
632  tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue);
633  }
635 }
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.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
struct GNUNET_SERVICE_Client * client
Handle to the client.
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.
uint32_t mtu
Maximum transmission unit, in NBO.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_tail
Tail of the DLL of queues associated with this communicator.
GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb
Callback called when a new communicator connects.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_head
Head of the DLL of queues associated with this communicator.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
Queue of a communicator and some context.
Here is the call graph for this function:

◆ shutdown_service()

static void shutdown_service ( void *  cls)
static

Shut down the service.

Parameters
clsClosure - Handle to the service

Definition at line 644 of file transport-testing2.c.

References GNUNET_SERVICE_stop(), and h.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop().

645 {
646  struct GNUNET_SERVICE_Handle *h = cls;
647 
649 }
Handle to a service.
Definition: service.c:116
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
void GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv)
Stops a service that was started with GNUNET_SERVICE_start().
Definition: service.c:1907
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_cb()

static void* connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Callback called when new Client (Communicator) connects.

Parameters
clsClosure - TransporCommmunicator Handle
clientClient
mqMessagequeue
Returns
TransportCommunicator Handle

Definition at line 662 of file transport-testing2.c.

References MyClient::c_mq, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, MyClient::client, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::client_head, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::client_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_send(), GNUNET_new, LOG, mq, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::next, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_head, and MyClient::tc.

Referenced by transport_communicator_start().

665 {
667  struct MyClient *new_c;
668 
669  LOG (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected to %p.\n",
670  client, tc_h);
671  new_c = GNUNET_new (struct MyClient);
672  new_c->client = client;
673  new_c->c_mq = mq;
674  new_c->tc = tc_h;
676  tc_h->client_tail,
677  new_c);
678 
679  if (NULL == tc_h->queue_head)
680  return new_c;
681  /* Iterate over queues. They are yet to be opened. Request opening. */
682  for (struct
684  tc_h->queue_head;
685  NULL != tc_queue_iter;
686  tc_queue_iter = tc_queue_iter->next)
687  {
688  if (NULL == tc_queue_iter->open_queue_env)
689  continue;
690  /* Send the previously created mq envelope to request the creation of the
691  * queue. */
692  GNUNET_MQ_send (tc_h->c_mq,
693  tc_queue_iter->open_queue_env);
694  tc_queue_iter->open_queue_env = NULL;
695  }
696  return new_c;
697 }
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * next
Next element inside a DLL.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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_SERVICE_Client * client
Handle to the client.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
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:355
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_head
Head of the DLL of queues associated with this communicator.
#define LOG(kind,...)
Queue of a communicator and some context.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect_cb()

static void disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  internal_cls 
)
static

Callback called when Client disconnects.

Parameters
clsClosure - TransportCommunicator Handle
clientClient
internal_clsTransporCommmunicator Handle

Definition at line 708 of file transport-testing2.c.

References MyClient::client, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::client_head, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::client_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, LOG, and MyClient::next.

Referenced by transport_communicator_start().

711 {
712  struct MyClient *cl = cls;
714 
715  for (cl = tc_h->client_head; NULL != cl; cl = cl->next)
716  {
717  if (cl->client != client)
718  continue;
720  tc_h->client_tail,
721  cl);
722  GNUNET_free (cl);
723  break;
724  }
725  LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
726 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct MyClient * next
struct GNUNET_SERVICE_Client * client
Handle to the client.
#define LOG(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ handle_send_message_ack()

static void handle_send_message_ack ( void *  cls,
const struct GNUNET_TRANSPORT_SendMessageToAck *  sma 
)
static

Message was transmitted.

Process the request.

Parameters
clsthe client
smathe send message that was sent

Definition at line 736 of file transport-testing2.c.

References MyClient::client, and GNUNET_SERVICE_client_continue().

738 {
739  struct MyClient *client = cls;
741  // NOP
742 }
struct GNUNET_SERVICE_Client * client
Handle to the client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2239
Here is the call graph for this function:

◆ transport_communicator_start()

static void transport_communicator_start ( struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle tc_h)
static

Start the communicator part of the transport service.

Parameters
communicator_availableCallback to be called when a new communicator becomes available
cfgConfiguration

Definition at line 753 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg, connect_cb(), disconnect_cb(), GNUNET_assert, GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_SERVICE_start(), and GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::sh.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_service_start().

755 {
756  struct GNUNET_MQ_MessageHandler mh[] = {
757  GNUNET_MQ_hd_var_size (communicator_available,
759  struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
760  tc_h),
761  GNUNET_MQ_hd_var_size (communicator_backchannel,
763  struct GNUNET_TRANSPORT_CommunicatorBackchannel,
764  tc_h),
765  GNUNET_MQ_hd_var_size (add_address,
767  struct GNUNET_TRANSPORT_AddAddressMessage,
768  tc_h),
769  // GNUNET_MQ_hd_fixed_size (del_address,
770  // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
771  // struct GNUNET_TRANSPORT_DelAddressMessage,
772  // NULL),
773  GNUNET_MQ_hd_var_size (incoming_msg,
775  struct GNUNET_TRANSPORT_IncomingMessage,
776  tc_h),
777  GNUNET_MQ_hd_fixed_size (queue_create_ok,
779  struct GNUNET_TRANSPORT_CreateQueueResponse,
780  tc_h),
781  GNUNET_MQ_hd_fixed_size (queue_create_fail,
783  struct GNUNET_TRANSPORT_CreateQueueResponse,
784  tc_h),
785  GNUNET_MQ_hd_var_size (add_queue_message,
787  struct GNUNET_TRANSPORT_AddQueueMessage,
788  tc_h),
789  // GNUNET_MQ_hd_fixed_size (del_queue_message,
790  // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
791  // struct GNUNET_TRANSPORT_DelQueueMessage,
792  // NULL),
793  GNUNET_MQ_hd_fixed_size (send_message_ack,
795  struct GNUNET_TRANSPORT_SendMessageToAck,
796  tc_h),
798  };
799 
800 
801  tc_h->sh = GNUNET_SERVICE_start ("transport",
802  tc_h->cfg,
803  &connect_cb,
804  &disconnect_cb,
805  tc_h,
806  mh);
807  GNUNET_assert (NULL != tc_h->sh);
808 }
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
#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
#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:1874
struct GNUNET_SERVICE_Handle * sh
Our service handle.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
#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
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
Message handler for a specific message type.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the configuration.
#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.
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
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static void * connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Callback called when new Client (Communicator) connects.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_process()

static void shutdown_process ( struct GNUNET_OS_Process proc)
static

Task run at shutdown to kill communicator and clean up.

Parameters
clsClosure - Process of communicator

Definition at line 817 of file transport-testing2.c.

References GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_OS_process_destroy(), GNUNET_OS_process_kill(), and LOG.

Referenced by shutdown_communicator(), and shutdown_nat().

818 {
819  if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
820  {
822  "Error shutting down communicator with SIGERM, trying SIGKILL\n");
823  if (0 != GNUNET_OS_process_kill (proc, SIGKILL))
824  {
826  "Error shutting down communicator with SIGERM and SIGKILL\n");
827  }
828  }
830 }
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
#define LOG(kind,...)
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:225
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_communicator()

static void shutdown_communicator ( void *  cls)
static

Definition at line 834 of file transport-testing2.c.

References shutdown_process().

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop().

835 {
836  struct GNUNET_OS_Process *proc = cls;
837  shutdown_process (proc);
838 }
static void shutdown_process(struct GNUNET_OS_Process *proc)
Task run at shutdown to kill communicator and clean up.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ communicator_start()

static void communicator_start ( struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle tc_h,
const char *  binary_name 
)
static

Start the communicator.

Parameters
cfgnameName of the communicator

Definition at line 847 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg_filename, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_INHERIT_STD_OUT_AND_ERR, GNUNET_OS_start_process(), GNUNET_YES, and LOG.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_service_start().

850 {
851  char *binary;
852 
853  LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
854  binary = GNUNET_OS_get_libexec_binary_path (binary_name);
857  NULL,
858  NULL,
859  NULL,
860  binary,
861  binary_name,
862  "-c",
863  tc_h->cfg_filename,
864  NULL);
865  if (NULL == tc_h->c_proc)
866  {
867  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
868  return;
869  }
870  LOG (GNUNET_ERROR_TYPE_INFO, "started communicator\n");
871  GNUNET_free (binary);
872 }
char * cfg_filename
File name of configuration file.
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
When these flags are set, the child process will inherit stdout and stderr of the parent...
Definition: gnunet_os_lib.h:97
#define GNUNET_log(kind,...)
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
struct GNUNET_OS_Process * c_proc
Process of the communicator.
#define GNUNET_YES
Definition: gnunet_common.h:85
#define LOG(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_nat()

static void shutdown_nat ( void *  cls)
static

Task run at shutdown to kill communicator and clean up.

Parameters
clsClosure - Process of communicator

Definition at line 881 of file transport-testing2.c.

References shutdown_process().

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop().

882 {
883  struct GNUNET_OS_Process *proc = cls;
884  shutdown_process (proc);
885 }
static void shutdown_process(struct GNUNET_OS_Process *proc)
Task run at shutdown to kill communicator and clean up.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nat_start()

static void nat_start ( struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle tc_h)
static

Start NAT.

Definition at line 893 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg_filename, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_INHERIT_STD_OUT_AND_ERR, GNUNET_OS_start_process(), GNUNET_YES, LOG, and GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::nat_proc.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_service_start().

895 {
896  char *binary;
897 
898  LOG (GNUNET_ERROR_TYPE_DEBUG, "nat_start\n");
899  binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-nat");
902  NULL,
903  NULL,
904  NULL,
905  binary,
906  "gnunet-service-nat",
907  "-c",
908  tc_h->cfg_filename,
909  NULL);
910  if (NULL == tc_h->nat_proc)
911  {
912  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start NAT!");
913  return;
914  }
915  LOG (GNUNET_ERROR_TYPE_INFO, "started NAT\n");
916  GNUNET_free (binary);
917 }
char * cfg_filename
File name of configuration file.
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
struct GNUNET_OS_Process * nat_proc
NAT process.
When these flags are set, the child process will inherit stdout and stderr of the parent...
Definition: gnunet_os_lib.h:97
#define GNUNET_log(kind,...)
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 ...
#define GNUNET_YES
Definition: gnunet_common.h:85
#define LOG(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start()

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.

Parameters
service_nameName of the service
cfgConfiguration handle
communicator_available_cbCallback that is called when a new
add_address_cbCallback that is called when a new communicator becomes available
cb_clsClosure to communicator_available_cb and
Returns
Handle to the communicator duo

Definition at line 933 of file transport-testing2.c.

References _, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::add_address_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::add_queue_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::bc_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::bc_enabled, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cb_cls, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg_filename, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::communicator_available_cb, communicator_start(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_load(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_strdup, GNUNET_SYSERR, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::incoming_msg_cb, LOG, nat_start(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_create_reply_cb, and transport_communicator_start().

945 {
947 
949  "Starting new transport/communicator combo with config %s\n",
950  cfg_filename);
951  tc_h =
954  tc_h->cfg = GNUNET_CONFIGURATION_create ();
956  {
958  _ ("Malformed configuration file `%s', exit ...\n"),
959  cfg_filename);
960  GNUNET_free (tc_h->cfg_filename);
962  GNUNET_free (tc_h);
963  return NULL;
964  }
966  "communicator-test",
967  "BACKCHANNEL_ENABLED");
971  tc_h->add_queue_cb = add_queue_cb;
972  tc_h->incoming_msg_cb = incoming_message_cb;
973  tc_h->bc_cb = bc_cb;
974  tc_h->cb_cls = cb_cls;
975 
976  /* Start communicator part of service */
978  /* Start NAT */
979  nat_start (tc_h);
980  /* Schedule start communicator */
981  communicator_start (tc_h,
982  binary_name);
983  return tc_h;
984 }
static char * cfg_filename
Name of the configuration file.
static void nat_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start NAT.
char * cfg_filename
File name of configuration file.
#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.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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:180
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_CONFIGURATION_Handle * cfg
Handle to the configuration.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
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.
#define GNUNET_log(kind,...)
GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb
Callback called when a new communicator connects.
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb
Callback called when a new communicator connects.
GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb
Backchannel callback.
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".
#define LOG(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop()

void GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop ( struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle tc_h)

Definition at line 988 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::nat_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::sh, shutdown_communicator(), shutdown_nat(), and shutdown_service().

990 {
992  shutdown_service (tc_h->sh);
993  shutdown_nat (tc_h->nat_proc);
995  GNUNET_free (tc_h);
996 }
static void shutdown_communicator(void *cls)
static void shutdown_nat(void *cls)
Task run at shutdown to kill communicator and clean up.
struct GNUNET_SERVICE_Handle * sh
Our service handle.
struct GNUNET_OS_Process * nat_proc
NAT process.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the configuration.
struct GNUNET_OS_Process * c_proc
Process of the communicator.
static void shutdown_service(void *cls)
Shut down the service.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue()

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.

Parameters
tc_hHandle to communicator which shall open queue
peer_idTowards which peer
addressFor which address

Definition at line 1007 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, env, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_HELLO_address_to_prefix(), GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_TRANSPORT_TESTING_transport_communicator_send(), msg, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::open_queue_env, peer_id, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::peer_id, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::qid, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_head, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_tail, and GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::tc_h.

1011 {
1013  static uint32_t idgen;
1014  char *prefix;
1015  struct GNUNET_TRANSPORT_CreateQueue *msg;
1016  struct GNUNET_MQ_Envelope *env;
1017  size_t alen;
1018 
1019  tc_queue =
1021  tc_queue->tc_h = tc_h;
1023  if (NULL == prefix)
1024  {
1025  GNUNET_break (0); /* We got an invalid address!? */
1026  GNUNET_free (tc_queue);
1027  return;
1028  }
1029  GNUNET_free (prefix);
1030  alen = strlen (address) + 1;
1031  env =
1033  msg->request_id = htonl (idgen++);
1034  tc_queue->qid = msg->request_id;
1035  msg->receiver = *peer_id;
1036  tc_queue->peer_id = *peer_id;
1037  memcpy (&msg[1], address, alen);
1038  if (NULL != tc_h->c_mq)
1039  {
1040  GNUNET_MQ_send (tc_h->c_mq, env);
1041  }
1042  else
1043  {
1044  tc_queue->open_queue_env = env;
1045  }
1046  GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
1047 }
struct GNUNET_PeerIdentity peer_id
Peer ID of the peer on the other side of the 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.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#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
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_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_tail
Tail of the DLL of queues associated with this communicator.
struct GNUNET_MQ_Envelope * open_queue_env
Envelope to a message that requests the opening of the queue.
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:355
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_head
Head of the DLL of queues associated with this communicator.
static char * address
GNS address for this phone.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
#define GNUNET_free(ptr)
Wrapper around free.
Queue of a communicator and some context.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_transport_communicator_send()

void GNUNET_TRANSPORT_TESTING_transport_communicator_send ( struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue tc_queue,
GNUNET_SCHEDULER_TaskCallback  cont,
void *  cont_cls,
const void *  payload,
size_t  payload_size 
)

Instruct communicator to send data.

Parameters
tc_queueThe queue to use for sending
contfunction to call when done sending
cont_clsclosure for cont
payloadData to send
payload_sizeSize of the payload

Definition at line 1061 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, env, GNUNET_MESSAGE_TYPE_DUMMY, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), mh, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::mid, msg, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::peer_id, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::qid, GNUNET_MessageHeader::size, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::tc_h, and GNUNET_MessageHeader::type.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue().

1066 {
1067  struct GNUNET_MessageHeader *mh;
1068  struct GNUNET_TRANSPORT_SendMessageTo *msg;
1069  struct GNUNET_MQ_Envelope *env;
1070  size_t inbox_size;
1071 
1072  inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;
1073  env = GNUNET_MQ_msg_extra (msg,
1074  inbox_size,
1076  msg->qid = htonl (tc_queue->qid);
1077  msg->mid = tc_queue->mid++;
1078  msg->receiver = tc_queue->peer_id;
1079  mh = (struct GNUNET_MessageHeader *) &msg[1];
1080  mh->size = htons (inbox_size);
1082  memcpy (&mh[1],
1083  payload,
1084  payload_size);
1085  if (NULL != cont)
1086  GNUNET_MQ_notify_sent (env,
1087  cont,
1088  cont_cls);
1089  GNUNET_MQ_send (tc_queue->tc_h->c_mq,
1090  env);
1091 }
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
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#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.
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:783
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static unsigned long long payload
How much data are we currently storing in the database?
Header for all communications.
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:355
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
Here is the call graph for this function:
Here is the caller graph for this function: