27#ifndef TRANSPORT_TESTING_H
28#define TRANSPORT_TESTING_H
108 struct GNUNET_TESTING_Peer *
peer;
328 void *restart_cb_cls);
689 const char *test_plugin_,
690 const char *test_name_,
710 const char *test_plugin_,
711 const char *test_name_,
742#define GNUNET_TRANSPORT_TESTING_main(num_peers, check, check_cls) \
743 GNUNET_TRANSPORT_TESTING_main_ (argv[0], \
782#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE 12345
787#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 12346
792#define GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE 12347
847#define GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE 2600
926 const char *testname);
struct GNUNET_MQ_MessageHandlers handlers[]
static char * peer_id
Option –peer.
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static struct GNUNET_NotificationContext * nc
Notification context for broadcasting to monitors.
static struct GNUNET_OS_Process * p
Helper process we started.
static unsigned int num_peers
Number of peers.
API to the peerstore service.
Bandwidth allocation API for applications to interact with.
API of the transport service towards the CORE service (TNG version)
void(* GNUNET_TRANSPORT_NotifyDisconnect)(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
Function called to notify transport users that another peer disconnected from us.
void *(* GNUNET_TRANSPORT_NotifyConnect)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void receiver(void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode)
Callback to read from the SOCKS5 proxy.
Handle to a message queue.
Message handler for a specific message type.
Handle to the PEERSTORE service.
Context for a iterate request.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for relative time used by GNUnet, in microseconds.
Handle to the TRANSPORT subsystem for application management.
Handle for TRANSPORT address suggestion requests.
Handle for the transport service (includes all of the state for the transport service).
Closure that must be passed to GNUNET_TRANSPORT_TESTING_connect_check.
GNUNET_TRANSPORT_TESTING_NotifyConnect nc
Notify connect argument to give for peers we start.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration object for the testcase.
unsigned int num_peers
Number of peers involved in the test.
void * shutdown_task_cls
Closure for shutdown_task.
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout.
int global_ret
Result from the main function, set to GNUNET_OK on success.
GNUNET_SCHEDULER_TaskCallback shutdown_task
Custom task to run on shutdown.
void * pre_connect_task_cls
Closure for shutdown_task.
GNUNET_TRANSPORT_TESTING_ReceiveCallback rec
Receiver argument to give for peers we start.
GNUNET_SCHEDULER_TaskCallback connect_continuation
How should we continue after the connect?
const char * config_file
Which configuration file should we pass to the GNUNET_PROGRAM_run() of the testcase?
struct GNUNET_TRANSPORT_TESTING_InternalPeerContext * ip
Array with num_peers entries.
GNUNET_TRANSPORT_TESTING_NotifyDisconnect nd
Notify disconnect argument to give for peers we start.
char ** cfg_files
Configuration files we have, array with num_peers entries.
const char * test_name
Name of the testcase.
GNUNET_SCHEDULER_TaskCallback pre_connect_task
Custom task to run after peers were started but before we try to connect them.
void * connect_continuation_cls
Closure for connect_continuation.
void * cls
Closure for rec, nc and nd.
struct GNUNET_SCHEDULER_Task * connect_task
Task run to connect peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequestList * crl_head
DLL of active connect requests.
int bi_directional
Should we try to create connections in both directions?
unsigned int started
Number of peers that have been started.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Main testing handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext ** p
Array with num_peers entries.
struct GNUNET_TIME_Relative timeout
When should the testcase time out?
uint32_t send_num_gen
Generator for the num field in test messages.
const char * test_plugin
Name of the plugin.
struct GNUNET_TRANSPORT_TESTING_ConnectRequestList * crl_tail
DLL of active connect requests.
Handle for a request to connect two peers.
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
struct GNUNET_MQ_Handle * mq
Message queue for sending from p1 to p2.
int p2_c
Set if peer2 says the connection is up to peer1.
struct GNUNET_TRANSPORT_ApplicationSuggestHandle * ah_sh
Handle by which we ask TNG to facilitate the connection.
void * cb_cls
Closure for cb.
GNUNET_SCHEDULER_TaskCallback cb
Function to call upon completion.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * prev
Kept in a DLL.
int p1_c
Set if peer1 says the connection is up to peer2.
struct GNUNET_TESTBED_System * tl_system
Testing library system handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_tail
tail DLL of peers
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
Context for a single peer.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
void * cb_cls
Closure for the nc and nd callbacks.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
GNUNET_SCHEDULER_TaskCallback start_cb
Startup completed callback.
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
unsigned int no
An unique number to identify the peer.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
GNUNET_TRANSPORT_NotifyConnect nc
Notify connect callback.
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * prev
Previous element in the DLL.
size_t hello_size
Hello size.
struct GNUNET_TRANSPORT_TESTING_PeerContext * next
Next element in the DLL.
struct GNUNET_OS_Process * arm_proc
Handle for the peer's ARM process.
void * start_cb_cls
Closure for start_cb.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
GNUNET_TRANSPORT_NotifyDisconnect nd
Notify disconnect callback.
Type of the closure argument to pass to GNUNET_TRANSPORT_TESTING_simple_send() and GNUNET_TRANSPORT_T...
void * cont_cls
Closure for cont.
unsigned int num_messages
Number of messages to be transmitted in a loop.
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext * ccc
Context for the transmission.
GNUNET_SCHEDULER_TaskCallback cont
Function to call after all transmissions, can be NULL.
size_t(* get_size_cb)(unsigned int n)
Function that returns the desired message size.
uint32_t num
Monotonically increasing counter throughout the test.
struct GNUNET_MessageHeader header
Type is (usually) GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE.
static void start_cb(void *cls)
Function called once we have successfully launched a peer.
int(* GNUNET_TRANSPORT_TESTING_CheckCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_Handle *tth_, const char *test_plugin_, const char *test_name_, unsigned int num_peers, char *cfg_files[])
Main function of a testcase.
struct GNUNET_TRANSPORT_TESTING_PeerContext * GNUNET_TRANSPORT_TESTING_start_peer(struct GNUNET_TRANSPORT_TESTING_Handle *tth, const char *cfgname, int peer_id, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd, void *cb_cls, GNUNET_SCHEDULER_TaskCallback start_cb, void *start_cb_cls)
Start a peer with the given configuration.
void(* GNUNET_TRANSPORT_TESTING_NotifyConnect)(void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
Function called to notify transport users that another peer connected to us.
int GNUNET_TRANSPORT_TESTING_restart_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p, GNUNET_SCHEDULER_TaskCallback restart_cb, void *restart_cb_cls)
Stops and restarts the given peer, sleeping (!) for 5s in between.
void(* GNUNET_TRANSPORT_TESTING_NotifyDisconnect)(void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
Function called to notify transport users that another peer disconnected from us.
void(* GNUNET_TRANSPORT_TESTING_ConnectContinuation)(void *cls, unsigned int num_peers, struct GNUNET_TRANSPORT_TESTING_PeerContext *p[])
Function called once the peers have been launched and connected by GNUNET_TRANSPORT_TESTING_connect_c...
struct GNUNET_TRANSPORT_TESTING_PeerContext * GNUNET_TRANSPORT_TESTING_find_peer(struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc, const struct GNUNET_PeerIdentity *peer)
Find peer by peer ID.
void GNUNET_TRANSPORT_TESTING_large_send(void *cls)
Task that sends a large test message from the first peer to the second peer.
void GNUNET_TRANSPORT_TESTING_log_disconnect(void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
Log a disconnect event.
char * GNUNET_TRANSPORT_TESTING_get_test_source_name(const char *file)
Extracts the filename from an absolute file name and removes the extension.
void GNUNET_TRANSPORT_TESTING_simple_send(void *cls)
Task that sends a minimalistic test message from the first peer to the second peer.
char * GNUNET_TRANSPORT_TESTING_get_test_plugin_name(const char *executable, const char *testname)
Extracts the plugin name from an absolute file name and the test name.
struct GNUNET_TRANSPORT_TESTING_Handle * GNUNET_TRANSPORT_TESTING_init(void)
Initialize the transport testing.
void GNUNET_TRANSPORT_TESTING_find_connecting_context(struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, GNUNET_TRANSPORT_TESTING_ConnectContextCallback cb, void *cb_cls)
Find any connecting context matching the given pair of peers.
void GNUNET_TRANSPORT_TESTING_log_connect(void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
Log a connect event.
int GNUNET_TRANSPORT_TESTING_connect_check(void *cls, struct GNUNET_TRANSPORT_TESTING_Handle *tth_, const char *test_plugin_, const char *test_name_, unsigned int num_peers, char *cfg_files[])
Common implementation of the GNUNET_TRANSPORT_TESTING_CheckCallback.
int GNUNET_TRANSPORT_TESTING_send(struct GNUNET_TRANSPORT_TESTING_PeerContext *sender, struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, uint16_t mtype, uint16_t msize, uint32_t num, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Send a test message of type mtype and size msize from peer sender to peer receiver.
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *pc)
Shutdown the given peer.
char * GNUNET_TRANSPORT_TESTING_get_config_name(const char *file, int count)
This function takes the filename (e.g.
GNUNET_NETWORK_STRUCT_END typedef void(* GNUNET_TRANSPORT_TESTING_ReceiveCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
Function called by the transport for each received message.
void(* GNUNET_TRANSPORT_TESTING_ConnectContextCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Function called on matching connect requests.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * GNUNET_TRANSPORT_TESTING_connect_peers(struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, GNUNET_SCHEDULER_TaskCallback cb, void *cls)
Connect the given peers and call the callback when both peers report the inbound connection.
int GNUNET_TRANSPORT_TESTING_main_(const char *argv0, const char *filename, unsigned int num_peers, GNUNET_TRANSPORT_TESTING_CheckCallback check, void *check_cls)
Setup testcase.
char * GNUNET_TRANSPORT_TESTING_get_test_name(const char *file)
Extracts the test filename from an absolute file name and removes the extension.
void GNUNET_TRANSPORT_TESTING_done(struct GNUNET_TRANSPORT_TESTING_Handle *tth)
Clean up the transport testing.
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers.