32#include "gnunet_signatures.h"
37#define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
250 const char *target_communicator;
255 target_communicator = ((
const char *)
msg) + isize;
258 "Received backchannel message\n");
267 "Delivering backchannel message of type %u to %s\n",
269 target_communicator);
270 other_tc_h = tc_h->
bc_cb (tc_h,
msg, (
struct
277 memcpy (&cbi[1],
msg, isize);
395 "Incoming message from communicator but no handler!\n");
496 "Got queue with ID %u\n",
msg->qid);
499 if (tc_queue->
qid ==
msg->qid)
502 if (NULL == tc_queue)
513 tc_queue->
nt =
msg->nt;
514 tc_queue->
mtu = ntohl (
msg->mtu);
515 tc_queue->
cs =
msg->cs;
545 "Received queue update message for %u with q_len %" PRIu64
"\n",
548 if (NULL != tc_queue)
550 while (tc_queue->
qid !=
msg->qid)
552 tc_queue = tc_queue->
next;
555 if (NULL == tc_queue)
562 tc_queue->
nt =
msg->nt;
563 tc_queue->
mtu = ntohl (
msg->mtu);
564 tc_queue->
cs =
msg->cs;
587 "Shutting down service!\n");
626 NULL != tc_queue_iter;
627 tc_queue_iter = tc_queue_iter->
next)
629 if (NULL == tc_queue_iter->open_queue_env)
634 tc_queue_iter->open_queue_env);
635 tc_queue_iter->open_queue_env = NULL;
685 if (tc_h->
cont != NULL)
773 "Error shutting down process with SIGERM, trying SIGKILL\n");
777 "Error shutting down process with SIGERM and SIGKILL\n");
832 const char *binary_name)
909 "gnunet-service-resolver");
917 "gnunet-service-resolver",
943 "gnunet-service-statistics");
949 "gnunet-service-statistics",
974 "gnunet-service-peerstore");
980 "gnunet-service-peerstore",
1006 "gnunet-service-nat");
1013 "gnunet-service-nat",
1042 const char *binary_name,
1057 "Starting new transport/communicator combo with config %s\n",
1068 _ (
"Malformed configuration file `%s', exit ...\n"),
1076 "communicator-test",
1077 "BACKCHANNEL_ENABLED");
1142 static uint32_t idgen;
1150 tc_queue->
tc_h = tc_h;
1162 msg->request_id = htonl (idgen++);
1163 tc_queue->
qid =
msg->request_id;
1167 if (NULL != tc_h->
c_mq)
1170 "Sending queue create immediately\n");
1187 size_t payload_size)
1199 NULL != tc_queue_tmp;
1200 tc_queue_tmp = tc_queue_tmp->
next)
1202 if (tc_queue_tmp->
q_len <= 0)
1204 if (NULL == tc_queue)
1207 "Selecting queue with prio %u, len %" PRIu64
" and MTU %u\n",
1209 tc_queue_tmp->
q_len,
1211 tc_queue = tc_queue_tmp;
1217 "Selecting queue with prio %u, len %" PRIu64
" and MTU %u\n",
1219 tc_queue_tmp->
q_len,
1221 tc_queue = tc_queue_tmp;
1224 if (last_queue != tc_queue)
1226 "Selected sending queue changed to %u with length %lu and MTU %u\n",
1227 ntohl (tc_queue->
qid), (
unsigned long) tc_queue->
q_len, tc_queue
1230 last_queue = tc_queue;
1236 static int msg_count = 0;
1238 if (msg_count % 100 == 0)
1240 "Sending %u-th (%lu-th for queue) message on queue %u\n",
1241 msg_count, (
unsigned long) tc_queue->
mid, ntohl (tc_queue->
qid
1249 msg->qid = tc_queue->
qid;
1250 msg->mid = tc_queue->
mid++;
1253 mh->size = htons (inbox_size);
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static char * cfg_filename
Name of the configuration file.
static char * peer_id
Option –peer.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
static int prefix
If printing the value of PREFIX has been requested.
static char * address
GNS address for this phone.
static char * section_name
Adapter we are supposed to test.
static unsigned long long payload
How much data are we currently storing in the database?
static char * service_name
Option -s: service name (hash to get service descriptor)
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
Helper library for handling HELLO URIs.
Constants for network protocols.
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED
Queue length.
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_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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#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...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
void * cls
Closure for mv and cb.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ 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.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#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_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
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.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
struct GNUNET_OS_Process * GNUNET_OS_start_process_s(enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename,...)
Start a process.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
enum GNUNET_GenericReturnValue GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
char * GNUNET_OS_get_libexec_binary_path(const struct GNUNET_OS_ProjectData *pd, const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
@ GNUNET_OS_INHERIT_STD_OUT_AND_ERR
When these flags are set, the child process will inherit stdout and stderr of the parent.
@ GNUNET_OS_USE_PIPE_CONTROL
Should a pipe be used to send signals to the child?
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
#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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
Transport signalling incoming backchannel message to a communicator.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS
inform transport to add an address of this peer
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE
inform transport that a queue was updated
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv)
Stops a service that was started with GNUNET_SERVICE_start().
struct GNUNET_SERVICE_Handle * GNUNET_SERVICE_start(const struct GNUNET_OS_ProjectData *pd, 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.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
static unsigned int size
Size of the "table".
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Handle to a client that is connected to a service.
Add queue to the transport.
Communicator goes online.
Message from transport to communicator passing along a backchannel message from the given peer pid.
struct GNUNET_PeerIdentity pid
Origin peer.
Message from communicator to transport service asking for transmission of a backchannel message with ...
struct GNUNET_PeerIdentity pid
Target peer.
Communicator tells transport how queue creation went down.
Transport tells communicator that it wants a new queue.
Transport informs us about being done with an incoming message.
struct GNUNET_PeerIdentity sender
Sender identifier of the original message.
uint64_t fc_id
Which message is being ACKed?
uint32_t reserved
Reserved (0)
Inform transport about an incoming message.
struct GNUNET_PeerIdentity sender
Sender identifier.
uint32_t fc_on
Do we use flow control or not?
uint64_t fc_id
64-bit number to identify the matching ACK.
Inform transport that message was sent.
Inform communicator about transport's desire to send a message.
Handle to a transport communicator.
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_OS_Process * nat_proc
NAT process.
void * cb_cls
Closure to the callback.
struct GNUNET_SERVICE_Handle * sh
Our service handle.
struct GNUNET_OS_Process * stat_proc
statistics service process
char * cfg_filename
File name of configuration file.
GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb
Backchannel callback.
int bc_enabled
Backchannel supported.
struct GNUNET_PeerIdentity peer_id
GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb
Callback called when a new communicator connects.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb
Callback called when a new communicator connects.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to the configuration.
struct MyClient * client_tail
struct GNUNET_OS_Process * resolver_proc
resolver service process
struct GNUNET_OS_Process * ps_proc
peerstore service process
struct GNUNET_OS_Process * c_proc
Process of the communicator.
char * c_addr_prefix
Specifies supported addresses.
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.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics
Characteristics of the communicator.
GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb
Callback called when a new communicator connects.
GNUNET_SCHEDULER_TaskCallback cont
Callback to call when message ack received.
char * c_address
Specifies supported addresses.
void * cont_cls
Closure for cont.
struct MyClient * client_head
Clients.
Queue of a communicator and some context.
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * prev
Previous element inside a DLL.
uint32_t mtu
Maximum transmission unit.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * next
Next element inside a DLL.
uint64_t q_len
Queue length.
uint32_t priority
Queue prio.
struct GNUNET_MQ_Envelope * open_queue_env
Envelope to a message that requests the opening of the queue.
uint64_t mid
Current message id.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc_h
Handle to the TransportCommunicator.
struct GNUNET_PeerIdentity peer_id
Peer ID of the peer on the other side of the queue.
uint32_t nt
An enum GNUNET_NetworkType in NBO.
Handle/Context to a single transmission.
struct GNUNET_SERVICE_Client * client
Handle to the client.
struct GNUNET_MQ_Handle * c_mq
Handle to the client.
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * tc
The TCH.
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.
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 nat_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start NAT.
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.
static void handle_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
Receive an incoming message.
static void shutdown_statistics(void *cls)
Task run at shutdown to kill the statistics process.
static void resolver_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Resolver.
static int check_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
New queue became available.
static int check_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *msg)
Incoming message.
static int check_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
Address of our peer added.
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.
static void handle_update_queue_message(void *cls, const struct GNUNET_TRANSPORT_UpdateQueueMessage *msg)
Handle new queue.
static void shutdown_resolver(void *cls)
Task run at shutdown to kill the resolver process.
static void handle_queue_create_fail(void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
Communicator informs that it won't try establishing requested queue.
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_communicator_backchannel(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *bc_msg)
Receive an incoming message.
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.
static void disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Callback called when Client disconnects.
static int check_incoming_msg(void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *msg)
Incoming message.
static void handle_send_message_ack(void *cls, const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
Message was transmitted.
static void transport_communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start the communicator part of the transport service.
static void handle_add_queue_message(void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
Handle new queue.
void GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
static void statistics_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Statistics.
static void * connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Callback called when new Client (Communicator) connects.
static void shutdown_process(struct GNUNET_OS_Process *proc)
Task run at shutdown to kill communicator and clean up.
static void communicator_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, const char *binary_name)
Start the communicator.
static void peerstore_start(struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
Start Peerstore.
static void handle_add_address(void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
The communicator informs about an address.
static int check_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Check whether incoming msg indicating available communicator is correct.
static void handle_communicator_available(void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
Handle new communicator.
functions and structures related to testing-tng
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.
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.
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.
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.
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.
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.
common internal definitions for transport service