38 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__) 152 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *
msg)
156 size = ntohs (msg->header.size) -
sizeof(*msg);
175 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *
msg)
183 size = ntohs (msg->header.size) -
sizeof(*msg);
215 GNUNET_TRANSPORT_CommunicatorBackchannel *
msg)
240 GNUNET_TRANSPORT_CommunicatorBackchannel *
249 uint16_t isize = ntohs (msg->
size);
250 const char *target_communicator = ((
const char *) msg) + isize;
251 struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
255 "Received backchannel message\n");
264 "Delivering backchannel message of type %u to %s\n",
266 target_communicator);
267 other_tc_h = tc_h->
bc_cb (tc_h, msg, (
struct 274 memcpy (&cbi[1], msg, isize);
291 const struct GNUNET_TRANSPORT_AddAddressMessage *
msg)
313 const struct GNUNET_TRANSPORT_AddAddressMessage *
msg)
319 size = ntohs (msg->header.size) -
sizeof(*msg);
348 const struct GNUNET_TRANSPORT_IncomingMessage *
msg)
372 const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
379 size_t payload_len = ntohs (msg->
size) -
sizeof (
struct 391 "Incoming message from communicator but no handler!\n");
397 struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
401 ack->reserved = htonl (0);
402 ack->fc_id = inc_msg->fc_id;
403 ack->sender = inc_msg->sender;
419 const struct GNUNET_TRANSPORT_CreateQueueResponse *
msg)
445 const struct GNUNET_TRANSPORT_CreateQueueResponse *
msg)
467 const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
484 const struct GNUNET_TRANSPORT_AddQueueMessage *
msg)
492 "Got queue with ID %u\n", msg->qid);
493 for (tc_queue = tc_h->
queue_head; NULL != tc_queue; tc_queue = tc_queue->
next)
495 if (tc_queue->
qid == msg->qid)
498 if (NULL == tc_queue)
503 tc_queue->
qid = msg->qid;
504 tc_queue->
peer_id = msg->receiver;
509 tc_queue->
nt = msg->nt;
510 tc_queue->
mtu = ntohl (msg->mtu);
511 tc_queue->
cs = msg->cs;
512 tc_queue->
priority = ntohl (msg->priority);
533 GNUNET_TRANSPORT_UpdateQueueMessage *
msg)
541 "Received queue update message for %u with q_len %" PRIu64
"\n",
544 if (NULL != tc_queue)
546 while (tc_queue->
qid != msg->qid)
548 tc_queue = tc_queue->
next;
553 tc_queue->
nt = msg->nt;
554 tc_queue->
mtu = ntohl (msg->mtu);
555 tc_queue->
cs = msg->cs;
556 tc_queue->
priority = ntohl (msg->priority);
578 "Shutting down service!\n");
617 NULL != tc_queue_iter;
618 tc_queue_iter = tc_queue_iter->
next)
620 if (NULL == tc_queue_iter->open_queue_env)
625 tc_queue_iter->open_queue_env);
626 tc_queue_iter->open_queue_env = NULL;
671 const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
693 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
697 struct GNUNET_TRANSPORT_CommunicatorBackchannel,
701 struct GNUNET_TRANSPORT_AddAddressMessage,
709 struct GNUNET_TRANSPORT_IncomingMessage,
713 struct GNUNET_TRANSPORT_CreateQueueResponse,
717 struct GNUNET_TRANSPORT_CreateQueueResponse,
721 struct GNUNET_TRANSPORT_AddQueueMessage,
725 struct GNUNET_TRANSPORT_UpdateQueueMessage,
733 struct GNUNET_TRANSPORT_SendMessageToAck,
760 "Error shutting down process with SIGERM, trying SIGKILL\n");
764 "Error shutting down process with SIGERM and SIGKILL\n");
815 const char *binary_name)
823 section_name = strchr (binary_name,
'-');
897 "gnunet-service-resolver",
927 "gnunet-service-statistics",
956 "gnunet-service-peerstore",
987 "gnunet-service-nat",
1016 const char *binary_name,
1031 "Starting new transport/communicator combo with config %s\n",
1040 _ (
"Malformed configuration file `%s', exit ...\n"),
1048 "communicator-test",
1049 "BACKCHANNEL_ENABLED");
1105 static uint32_t idgen;
1107 struct GNUNET_TRANSPORT_CreateQueue *
msg;
1113 tc_queue->
tc_h = tc_h;
1122 alen = strlen (address) + 1;
1125 msg->request_id = htonl (idgen++);
1126 tc_queue->
qid = msg->request_id;
1129 memcpy (&msg[1], address, alen);
1130 if (NULL != tc_h->
c_mq)
1133 "Sending queue create immediately\n");
1159 size_t payload_size)
1162 struct GNUNET_TRANSPORT_SendMessageTo *
msg;
1170 NULL != tc_queue_tmp;
1171 tc_queue_tmp = tc_queue_tmp->
next)
1173 if (tc_queue_tmp->
q_len <= 0)
1175 if (NULL == tc_queue)
1178 "Selecting queue with prio %u, len %" PRIu64
" and MTU %u\n",
1180 tc_queue_tmp->
q_len,
1182 tc_queue = tc_queue_tmp;
1188 "Selecting queue with prio %u, len %" PRIu64
" and MTU %u\n",
1190 tc_queue_tmp->
q_len,
1192 tc_queue = tc_queue_tmp;
1201 "Sending message\n");
1207 msg->qid = htonl (tc_queue->
qid);
1208 msg->mid = tc_queue->
mid++;
1209 msg->receiver = tc_queue->
peer_id;
1211 mh->
size = htons (inbox_size);
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void shutdown_process(struct GNUNET_OS_Process *proc)
Task run at shutdown to kill communicator and clean up.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * next
Next element inside a DLL.
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.
struct GNUNET_PeerIdentity peer_id
Peer ID of the peer on the other side of the queue.
static char * cfg_filename
Name of the configuration file.
struct GNUNET_OS_Process * GNUNET_OS_start_process_s(enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename,...)
Start a process.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
struct GNUNET_MessageHeader * msg
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
struct GNUNET_OS_Process * GNUNET_OS_start_process(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.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
static void handle_send_message_ack(void *cls, const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
Message was transmitted.
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
common internal definitions for transport service
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
struct GNUNET_OS_Process * stat_proc
statistics service process
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
char * cfg_filename
File name of configuration file.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *(* GNUNET_TRANSPORT_TESTING_BackchannelCallback)(void *cls, struct GNUNET_MessageHeader *msg, struct GNUNET_PeerIdentity *pid)
Function signature for callbacks that are called when new backchannel message arrived.
static void disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Callback called when Client disconnects.
static void peerstore_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Peerstore.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Handle/Context to a single transmission.
static int check_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
Address of our peer added.
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE
inform transport that a queue was updated
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
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.
struct GNUNET_PeerIdentity peer_id
static char * peer_id
Option –peer.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics
Characteristics of the communicator.
uint64_t mid
Current message id.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
Transport signalling incoming backchannel message to a communicator.
static void handle_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
Handle new queue.
struct GNUNET_SERVICE_Handle * sh
Our service handle.
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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb
Callback called when a new communicator connects.
struct GNUNET_OS_Process * nat_proc
NAT process.
static void shutdown_resolver(void *cls)
Task run at shutdown to kill the resolver process.
Handle to a client that is connected to a service.
char * c_addr_prefix
Specifies supported addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
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.
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
struct GNUNET_OS_Process * ps_proc
peerstore service process
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
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.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
void * cls
Closure for mv and cb.
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...
struct MyClient * client_tail
struct MyClient * client_head
Clients.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
static void resolver_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Resolver.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(const char *service_name, const char *binary_name, const char *cfg_filename, const struct GNUNET_PeerIdentity *peer_id, 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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
static void handle_queue_create_ok(void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
Communicator informs that it tries to establish requested queue.
static void handle_queue_create_fail(void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
Communicator informs that it wont try establishing requested queue.
functions and structures related to testing-tng
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
struct GNUNET_OS_Process * resolver_proc
resolver service process
static void shutdown_statistics(void *cls)
Task run at shutdown to kill the statistics process.
static char * service_name
Option -s: service name (hash to get service descriptor)
static void handle_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
Receive an incoming message.
struct GNUNET_SERVICE_Client * client
Handle to the client.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static int check_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *msg)
Incoming message.
static void shutdown_communicator(void *cls)
Task run at shutdown to kill a communicator process.
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.
GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb
Callback called when a new communicator connects.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
void GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv)
Stops a service that was started with GNUNET_SERVICE_start().
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
static void transport_communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start the communicator part of the transport service.
Message handler for a specific message type.
static void * connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Callback called when new Client (Communicator) connects.
When these flags are set, the child process will inherit stdout and stderr of the parent...
static void handle_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *bc_msg)
Receive an incoming message.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the configuration.
static void shutdown_peerstore(void *cls)
Task run at shutdown to kill the peerstore process.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
static unsigned int size
Size of the "table".
uint64_t q_len
Queue length.
char * GNUNET_HELLO_address_to_prefix(const char *address)
Given an address as a string, extract the prefix that identifies the communicator offering transmissi...
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * prev
Previous element inside a DLL.
struct GNUNET_MQ_Envelope * env
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb
Callback called when a new communicator connects.
static int check_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *msg)
Incoming message.
static void handle_update_queue_message(void *cls, const struct GNUNET_TRANSPORT_UpdateQueueMessage *msg)
Handle new queue.
static unsigned long long payload
How much data are we currently storing in the database?
uint32_t priority
Queue prio.
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.
static void handle_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Handle new communicator.
Handle to a message queue.
uint32_t mtu
Maximum transmission unit.
static void statistics_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Statistics.
The identity of the host (wraps the signing key of the peer).
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
static int check_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
New queue became available.
static char * section_name
Name of section in configuration file to use for additional options.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR
Message sent to indicate to the transport which address prefix is supported by a communicator.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL
Response from communicator: address bogus, will not try to create queue.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_tail
Tail of the DLL of queues associated with this communicator.
struct GNUNET_MQ_Handle * mq
static void communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *binary_name)
Start the communicator.
#define GNUNET_log(kind,...)
static void nat_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start NAT.
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 ...
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".
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS
inform transport to add an address of this peer
struct GNUNET_MQ_Envelope * open_queue_env
Envelope to a message that requests the opening of the queue.
struct GNUNET_OS_Process * c_proc
Process of the communicator.
static void shutdown_service(void *cls)
Shut down the service.
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.
Handle to a transport communicator.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * queue_head
Head of the DLL of queues associated with this communicator.
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.
GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb
Backchannel callback.
void * cb_cls
Closure to the callback.
static void handle_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
The communicator informs about an address.
static char * address
GNS address for this phone.
static void shutdown_nat(void *cls)
Task run at shutdown to kill communicator and clean up.
Should a pipe be used to send signals to the child?
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
int bc_enabled
Backchannel supported.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
char * c_address
Specifies supported addresses.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_free(ptr)
Wrapper around free.
Queue of a communicator and some context.
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Bandwidth allocation API for the transport service.
static int check_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Check whether incoming msg indicating available communicator is correct.