GNUnet 0.28.1-dev.5-1-gae1c02d74
 
Loading...
Searching...
No Matches
transport-testing-communicator.h File Reference

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

Include dependency graph for transport-testing-communicator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
 Handle to a transport communicator. More...
 

Typedefs

typedef struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *(* GNUNET_TRANSPORT_TESTING_BackchannelCallback) (void *cls, struct GNUNET_MessageHeader *msg, struct GNUNET_PeerIdentity *pid)
 Function signature for callbacks that are called when new backchannel message arrived.
 
typedef void(* GNUNET_TRANSPORT_TESTING_PeerIdCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const struct GNUNET_PeerIdentity *peer_id)
 Function signature for callbacks that are called once the peer identity of the peer this communicator belongs to is known.
 
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.
 
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.
 
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.
 
typedef void(* GNUNET_TRANSPORT_TESTING_AddQueueCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, size_t mtu)
 Handle opening of queue.
 
typedef void(* GNUNET_TRANSPORT_TESTING_IncomingMessageCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *payload, size_t payload_len)
 Handle an incoming message.
 

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_PeerIdCallback peer_id_cb, 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.
 
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.
 
void GNUNET_TRANSPORT_TESTING_transport_communicator_send (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls, const void *payload, size_t payload_size)
 Instruct communicator to send data.
 

Detailed Description

functions and structures related to testing-tng

Author
Christian Grothoff
Julius Bünger

Definition in file transport-testing-communicator.h.

Typedef Documentation

◆ GNUNET_TRANSPORT_TESTING_BackchannelCallback

typedef struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *(* GNUNET_TRANSPORT_TESTING_BackchannelCallback) (void *cls, struct GNUNET_MessageHeader *msg, struct GNUNET_PeerIdentity *pid)

Function signature for callbacks that are called when new backchannel message arrived.

Parameters
clsClosure
msgBackchannel message
pidTarget peer

Definition at line 1 of file transport-testing-communicator.h.

◆ GNUNET_TRANSPORT_TESTING_PeerIdCallback

typedef void(* GNUNET_TRANSPORT_TESTING_PeerIdCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const struct GNUNET_PeerIdentity *peer_id)

Function signature for callbacks that are called once the peer identity of the peer this communicator belongs to is known.

The peer identity is derived at runtime by PILS, so it is not known when the communicator is started. It may also change later on, in which case this callback is invoked again.

Parameters
clsClosure
tc_hCommunicator handle
peer_idthe (new) peer identity of this peer

Definition at line 72 of file transport-testing-communicator.h.

◆ 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 90 of file transport-testing-communicator.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 111 of file transport-testing-communicator.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 130 of file transport-testing-communicator.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, size_t mtu)

Handle opening of queue.

Parameters
clsClosure
tc_hCommunicator handle
tc_queueHandle to newly opened queue

Definition at line 145 of file transport-testing-communicator.h.

◆ GNUNET_TRANSPORT_TESTING_IncomingMessageCallback

typedef void(* GNUNET_TRANSPORT_TESTING_IncomingMessageCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *payload, size_t payload_len)

Handle an incoming message.

Parameters
clsClosure
tc_hHandle to the receiving communicator
msgReceived message

Definition at line 163 of file transport-testing-communicator.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_PeerIdCallback  peer_id_cb,
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.

Also starts the PILS service of that peer. The peer identity is not known when this function returns; it is reported via peer_id_cb.

Parameters
service_nameName of the service
cfgConfiguration handle
peer_id_cbCallback handling the peer identity assigned by PILS
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
peer_id_cbCallback that is called once PILS assigned a peer identity
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 1034 of file transport-testing-communicator.c.

1047{
1049
1051 "Starting new transport/communicator combo with config %s\n",
1052 cfg_filename);
1053 tc_h =
1057 if ((GNUNET_SYSERR ==
1059 cfg_filename)))
1060 {
1062 _ ("Malformed configuration file `%s', exit ...\n"),
1063 cfg_filename);
1064 GNUNET_free (tc_h->cfg_filename);
1066 GNUNET_free (tc_h);
1067 return NULL;
1068 }
1070 "communicator-test",
1071 "BACKCHANNEL_ENABLED");
1072 tc_h->peer_id_cb = peer_id_cb;
1076 tc_h->add_queue_cb = add_queue_cb;
1077 tc_h->incoming_msg_cb = incoming_message_cb;
1078 tc_h->bc_cb = bc_cb;
1079 tc_h->have_peer_id = GNUNET_NO;
1080 tc_h->cb_cls = cb_cls;
1081
1082 /* Start communicator part of service */
1084 /* Start NAT */
1085 tc_h->nat_proc = service_start (tc_h,
1086 "gnunet-service-nat");
1087 tc_h->resolver_proc = service_start (tc_h,
1088 "gnunet-service-resolver");
1089 tc_h->ps_proc = service_start (tc_h,
1090 "gnunet-service-peerstore");
1091 tc_h->stat_proc = service_start (tc_h,
1092 "gnunet-service-statistics");
1093 /* The peer identity is derived by PILS at runtime, so we have to run
1094 PILS for this peer and wait for it to tell us who we are. */
1095 tc_h->pils_proc = service_start (tc_h,
1096 "gnunet-service-pils");
1097 tc_h->pils = GNUNET_PILS_connect (tc_h->cfg,
1099 tc_h);
1100 if (NULL == tc_h->pils)
1101 {
1103 "Failed to connect to PILS!\n");
1104 GNUNET_break (0);
1105 }
1106 /* Schedule start communicator */
1107 communicator_start (tc_h,
1108 binary_name);
1109 return tc_h;
1110}
static char * cfg_filename
Name of the configuration file.
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition pils_api.c:624
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define GNUNET_log(kind,...)
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define _(String)
GNU gettext support macro.
Definition platform.h:179
struct GNUNET_Process * stat_proc
statistics service process
struct GNUNET_Process * resolver_proc
resolver service process
GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb
Backchannel callback.
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb
Callback called when a new communicator connects.
struct GNUNET_PILS_Handle * pils
Handle to the PILS service of this peer.
GNUNET_TRANSPORT_TESTING_PeerIdCallback peer_id_cb
Callback called when PILS assigned us a peer identity.
GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb
Callback called when a new communicator connects.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the configuration.
GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb
Callback called when a new communicator connects.
GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb
Callback called when a new communicator connects.
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb
Callback called when a new communicator connects.
struct GNUNET_Process * ps_proc
peerstore service process
static void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
Handler called by PILS once our peer identity is known or changed.
static void transport_communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start the communicator part of the transport service.
static void communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *binary_name)
Start the communicator.
#define LOG(kind,...)
static struct GNUNET_Process * service_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *service_name)
Start service.

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, cfg_filename, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg_filename, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::communicator_available_cb, communicator_start(), GNUNET_break, 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_NO, GNUNET_OS_project_data_gnunet(), GNUNET_PILS_connect(), GNUNET_strdup, GNUNET_SYSERR, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::have_peer_id, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::incoming_msg_cb, LOG, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::nat_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::peer_id_cb, pid_change_cb(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::pils, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::pils_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::ps_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_create_reply_cb, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::resolver_proc, service_start(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::stat_proc, and transport_communicator_start().

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 1114 of file transport-testing-communicator.c.

1116{
1120 if (NULL != tc_h->pils)
1121 {
1123 tc_h->pils = NULL;
1124 }
1131 while (NULL != (queue = tc_h->queue_head))
1132 {
1135 }
1139 GNUNET_free (tc_h);
1140}
static void queue(const char *label, uint32_t rd_count, struct GNUNET_GNSRECORD_Data *rd, const struct Zone *zone)
Add hostname to the list of requests to be made.
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:647
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_head
Head of the DLL of queues associated with this communicator.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_tail
Tail of the DLL of queues associated with this communicator.
struct GNUNET_SERVICE_Handle * sh
Our service handle.
struct GNUNET_Process * c_proc
Process of the communicator.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
static void shutdown_peerstore(void *cls)
Task run at shutdown to kill the peerstore process.
static void shutdown_communicator(void *cls)
Task run at shutdown to kill a communicator process.
static void shutdown_statistics(void *cls)
Task run at shutdown to kill the statistics process.
static void shutdown_resolver(void *cls)
Task run at shutdown to kill the resolver process.
static void shutdown_pils(void *cls)
Task run at shutdown to kill the PILS process.
static void shutdown_nat(void *cls)
Task run at shutdown to kill communicator and clean up.
static void shutdown_service(void *cls)
Shut down the service.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_addr_prefix, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_address, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::cfg_filename, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PILS_disconnect(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::nat_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::pils, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::pils_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::ps_proc, queue(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_head, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_tail, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::resolver_proc, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::sh, shutdown_communicator(), shutdown_nat(), shutdown_peerstore(), shutdown_pils(), shutdown_resolver(), shutdown_service(), shutdown_statistics(), GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::stat_proc, and GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::tc_h.

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 1151 of file transport-testing-communicator.c.

1155{
1157 static uint32_t idgen;
1158 char *prefix;
1160 struct GNUNET_MQ_Envelope *env;
1161 size_t alen;
1162
1163 tc_queue =
1165 tc_queue->tc_h = tc_h;
1167 if (NULL == prefix)
1168 {
1169 GNUNET_break (0); /* We got an invalid address!? */
1170 GNUNET_free (tc_queue);
1171 return;
1172 }
1174 alen = strlen (address) + 1;
1175 env =
1177 msg->request_id = htonl (idgen++);
1178 tc_queue->qid = msg->request_id;
1179 msg->receiver = *peer_id;
1180 tc_queue->peer_id = *peer_id;
1181 memcpy (&msg[1], address, alen);
1182 if (NULL != tc_h->c_mq)
1183 {
1185 "Sending queue create immediately\n");
1186 GNUNET_MQ_send (tc_h->c_mq, env);
1187 }
1188 else
1189 {
1190 tc_queue->open_queue_env = env;
1191 }
1192 GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
1193}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static char * peer_id
Option –peer.
static int prefix
If printing the value of PREFIX has been requested.
static char * address
GNS address for this phone.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
char * GNUNET_HELLO_address_to_prefix(const char *address)
Given an address as a string, extract the prefix that identifies the communicator offering transmissi...
Definition hello-uri.c:1139
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:337
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
Transport tells communicator that it wants a new queue.
Definition transport.h:523
struct GNUNET_MQ_Envelope * open_queue_env
Envelope to a message that requests the opening of the queue.
struct GNUNET_PeerIdentity peer_id
Peer ID of the peer on the other side of the queue.

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

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_TransportCommunicatorHandle tc_h,
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 1197 of file transport-testing-communicator.c.

1203{
1204 struct GNUNET_MessageHeader *mh;
1206 struct GNUNET_MQ_Envelope *env;
1207 size_t inbox_size;
1211 tc_queue = NULL;
1212
1213 for (tc_queue_tmp = tc_h->queue_head;
1214 NULL != tc_queue_tmp;
1215 tc_queue_tmp = tc_queue_tmp->next)
1216 {
1217 if (tc_queue_tmp->q_len <= 0)
1218 continue;
1219 if (NULL == tc_queue)
1220 {
1222 "Selecting queue with prio %u, len %" PRIu64 " and MTU %u\n",
1223 tc_queue_tmp->priority,
1224 tc_queue_tmp->q_len,
1225 tc_queue_tmp->mtu);
1226 tc_queue = tc_queue_tmp;
1227 continue;
1228 }
1229 if (tc_queue->priority < tc_queue_tmp->priority)
1230 {
1232 "Selecting queue with prio %u, len %" PRIu64 " and MTU %u\n",
1233 tc_queue_tmp->priority,
1234 tc_queue_tmp->q_len,
1235 tc_queue_tmp->mtu);
1236 tc_queue = tc_queue_tmp;
1237 }
1238 }
1239 if (last_queue != tc_queue)
1241 "Selected sending queue changed to %u with length %lu and MTU %u\n",
1242 ntohl (tc_queue->qid), (unsigned long) tc_queue->q_len, tc_queue
1243 ->mtu);
1244 GNUNET_assert (NULL != tc_queue);
1245 last_queue = tc_queue;
1246 // Uncomment this for alternative 1 of backchannel functionality
1248 tc_queue->q_len--;
1249 // Until here for alternative 1
1250 {
1251 static int msg_count = 0;
1252 msg_count++;
1253 if (msg_count % 100 == 0)
1255 "Sending %u-th (%lu-th for queue) message on queue %u\n",
1256 msg_count, (unsigned long) tc_queue->mid, ntohl (tc_queue->qid
1257 ));
1258 }
1259 inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;
1261 inbox_size,
1263 GNUNET_assert (NULL != env);
1264 msg->qid = tc_queue->qid;
1265 msg->mid = tc_queue->mid++;
1266 msg->receiver = tc_queue->peer_id;
1267 mh = (struct GNUNET_MessageHeader *) &msg[1];
1268 mh->size = htons (inbox_size);
1270 memcpy (&mh[1],
1271 payload,
1272 payload_size);
1273 if (NULL != cont)
1275 cont,
1276 cont_cls);
1277 GNUNET_MQ_send (tc_queue->tc_h->c_mq,
1278 env);
1279}
static struct GNUNET_CADET_Handle * mh
Cadet handle.
static unsigned long long payload
How much data are we currently storing in the database?
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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:687
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
Header for all communications.
Inform communicator about transport's desire to send a message.
Definition transport.h:565
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * next
Next element inside a DLL.

References GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::c_mq, env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_DUMMY, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, LOG, mh, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::mid, msg, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::mtu, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::next, payload, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::peer_id, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::priority, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::q_len, GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::qid, GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle::queue_head, and GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue::tc_h.

Here is the call graph for this function: