GNUnet  0.11.x
Typedefs | Functions
transport-testing2.h File Reference

functions and structures related to testing-tng More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_ats_transport_service.h"
#include "transport.h"
Include dependency graph for transport-testing2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef 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. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef void(* GNUNET_TRANSPORT_TESTING_IncomingMessageCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const struct GNUNET_MessageHeader *msg)
 Handle an incoming message. More...
 

Functions

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, void *cb_cls)
 Start communicator part of transport service and communicator. More...
 
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...
 
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmissionGNUNET_TRANSPORT_TESTING_transport_communicator_send (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, const void *payload, size_t payload_size)
 Instruct communicator to send data. More...
 

Detailed Description

functions and structures related to testing-tng

Author
Christian Grothoff
Julius Bünger

Definition in file transport-testing2.h.

Typedef Documentation

◆ GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback

typedef 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.

Parameters
clsClosure
tc_hCommunicator handle
ccCharacteristics of communicator
address_prefixPrefix of the address

Definition at line 61 of file transport-testing2.h.

◆ GNUNET_TRANSPORT_TESTING_AddAddressCallback

typedef 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.

Parameters
clsClosure
tc_hCommunicator handle
addressAddress represented as string
expirationExpiration
aidAid
ntNetwork Type

Definition at line 82 of file transport-testing2.h.

◆ GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback

typedef 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.

Parameters
clsClosure
tc_hCommunicator handle
will_tryGNUNET_YES if communicator will try to create queue

Definition at line 101 of file transport-testing2.h.

◆ GNUNET_TRANSPORT_TESTING_AddQueueCallback

typedef 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.

Parameters
clsClosure
tc_hCommunicator handle
tc_queueHandle to newly opened queue

Definition at line 116 of file transport-testing2.h.

◆ GNUNET_TRANSPORT_TESTING_IncomingMessageCallback

typedef void(* GNUNET_TRANSPORT_TESTING_IncomingMessageCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const struct GNUNET_MessageHeader *msg)

Handle an incoming message.

Parameters
clsClosure
tc_hHandle to the receiving communicator
msgReceived message

Definition at line 133 of file transport-testing2.h.

Function Documentation

◆ 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,
void *  cb_cls 
)

Start communicator part of transport service and communicator.

Parameters
service_nameName of the service
cfgConfiguration handle
communicator_availableCallback that is called when a new communicator becomes available
add_address_cbCallback handling new addresses
queue_create_reply_cbCallback handling success of queue requests
add_queue_cbCallback handling freshly created queues
incoming_message_cbCallback handling incoming messages
cb_clsClosure to communicator_available
Returns
Handle to the communicator duo
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 686 of file transport-testing2.c.

References _, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::add_address_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::add_queue_cb, 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_load(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_strdup, GNUNET_SYSERR, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::incoming_msg_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_create_reply_cb, and transport_communicator_start().

697 {
699 
700  tc_h =
703  tc_h->cfg = GNUNET_CONFIGURATION_create ();
705  {
707  _ ("Malformed configuration file `%s', exit ...\n"),
708  cfg_filename);
709  GNUNET_free (tc_h->cfg_filename);
711  GNUNET_free (tc_h);
712  return NULL;
713  }
717  tc_h->add_queue_cb = add_queue_cb;
718  tc_h->incoming_msg_cb = incoming_message_cb;
719  tc_h->cb_cls = cb_cls;
720 
721  /* Start communicator part of service */
723 
724  /* Schedule start communicator */
725  communicator_start (tc_h,
726  binary_name);
727  return tc_h;
728 }
static char * cfg_filename
Name of the configuration file.
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:181
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:76
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.
static void transport_communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start the communicator part of the transport 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 739 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.

743 {
745  static uint32_t idgen;
746  char *prefix;
747  struct GNUNET_TRANSPORT_CreateQueue *msg;
748  struct GNUNET_MQ_Envelope *env;
749  size_t alen;
750 
751  tc_queue =
753  tc_queue->tc_h = tc_h;
755  if (NULL == prefix)
756  {
757  GNUNET_break (0); /* We got an invalid address!? */
758  GNUNET_free (tc_queue);
759  return;
760  }
761  GNUNET_free (prefix);
762  alen = strlen (address) + 1;
763  env =
765  msg->request_id = htonl (idgen++);
766  tc_queue->qid = msg->request_id;
767  msg->receiver = *peer_id;
768  tc_queue->peer_id = *peer_id;
769  memcpy (&msg[1], address, alen);
770  if (NULL != tc_h->c_mq)
771  {
772  GNUNET_MQ_send (tc_h->c_mq, env);
773  }
774  else
775  {
776  tc_queue->open_queue_env = env;
777  }
778  GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
779 }
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:353
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()

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.

Parameters
tc_queueThe queue to use for sending
payloadData to send
payload_sizeSize of the payload
Returns
Handle to the transmission

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

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, env, GNUNET_free, GNUNET_malloc, GNUNET_MESSAGE_TYPE_DUMMY, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), mh, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::mid, msg, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::peer_id, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::qid, and GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::tc_h.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue().

798 {
800  struct GNUNET_MessageHeader *mh;
801  struct GNUNET_TRANSPORT_SendMessageTo *msg;
802  struct GNUNET_MQ_Envelope *env;
803  size_t inbox_size;
804 
805  inbox_size = sizeof(struct GNUNET_MessageHeader) + payload_size;
806  mh = GNUNET_malloc (inbox_size);
807  mh->size = htons (inbox_size);
808  mh->type = GNUNET_MESSAGE_TYPE_DUMMY;
809  memcpy (&mh[1],
810  payload,
811  payload_size);
812  env = GNUNET_MQ_msg_extra (msg,
813  inbox_size,
815  msg->qid = htonl (tc_queue->qid);
816  msg->mid = tc_queue->mid++;
817  msg->receiver = tc_queue->peer_id;
818  memcpy (&msg[1], mh, inbox_size);
819  GNUNET_free (mh);
820  GNUNET_MQ_send (tc_queue->tc_h->c_mq, env);
821  return tc_t;
822 }
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.
#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
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:353
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: