30 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing", __VA_ARGS__)
40 if (0 == memcmp (&
t->id,
71 for (cc = tth->
cc_head; NULL != cc; cc = ccn)
157 ret =
p->nc (
p->cb_cls,
173 "Peers %s connected to peer %u (`%s')\n",
236 for (cc = tth->
cc_head; NULL != cc; cc = ccn)
285 "Peers %s disconnected from peer %u (`%s')\n",
345 if (NULL !=
p->start_cb)
350 p->hello_size =
record->value_size;
352 memcpy (
p->hello,
record->value,
p->hello_size);
353 p->hello[
p->hello_size - 1] =
'\0';
357 if (NULL !=
p->start_cb)
360 "Peer %u (`%s') successfully started\n",
363 p->start_cb (
p->start_cb_cls);
405 "File not found: `%s'\n",
416 for (i = 0; NULL !=
handlers[i].cb; i++)
429 if (NULL != start_cb_cls)
430 p->start_cb_cls = start_cb_cls;
446 "Testing library failed to create unique configuration based on `%s'\n",
463 "Testing library failed to create unique configuration based on `%s': `%s'\n",
474 "Testing library failed to create unique configuration based on `%s'\n",
485 if (0 == memcmp (&
dummy,
490 "Testing library failed to obtain peer identity for peer %u\n",
496 "Peer %u configured with identity `%s'\n",
508 "Failed to connect to transport service for peer `%s': `%s'\n",
519 "Failed to connect to ATS service for peer `%s': `%s'\n",
541 void *restart_cb_cls)
548 "Stopping peer %u (`%s')\n",
561 for (cc =
p->tth->cc_head; NULL != cc; cc = ccn)
577 "Failed to stop peer %u (`%s')\n",
586 "Restarting peer %u (`%s')\n",
593 "Failed to restart peer %u (`%s')\n",
600 p->start_cb = restart_cb;
601 p->start_cb_cls = restart_cb_cls;
636 "Stopping peer %u (`%s')\n",
640 for (cc = tth->
cc_head; NULL != cc; cc = ccn)
670 "Disconnecting from PEERSTORE service\n");
681 "Testing lib failed to stop peer %u (`%s')\n",
688 if (NULL !=
p->hello)
698 if (NULL !=
p->handlers)
707 "Peer %u (`%s') stopped\n",
710 if (NULL !=
p->rh_task)
750 "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %s\n",
801 if ((cc->
p1 ==
p1) &&
832 "New connect request %p\n",
846 "Canceling connect request!\n");
884 "Developer forgot to cancel connect request!\n");
893 "Developer forgot to stop peer!\n");
922 "Failed to initialize testing library!\n");
struct GNUNET_MQ_Handle * mq
static int ret
Return value of the commandline.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static char * peer_id
Option –peer.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
static struct GNUNET_OS_Process * p
Helper process we started.
static struct GNUNET_SCHEDULER_Task * t
Main task.
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.
void GNUNET_TRANSPORT_application_done(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Shutdown TRANSPORT application client.
struct GNUNET_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the TRANSPORT application client handle.
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
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_application_validate(struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_NetworkType nt, const char *addr)
An application (or a communicator) has received a HELLO (or other address data of another peer) and w...
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
#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_extract_address(const void *raw, size_t raw_size, const struct GNUNET_PeerIdentity *pid, enum GNUNET_NetworkType *nt, struct GNUNET_TIME_Absolute *mono_time)
Check signature and extract address record.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY
Key used for storing HELLOs in the peerstore.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iterate(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Iterate over records matching supplied key information.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
struct GNUNET_TESTING_Peer * GNUNET_TESTING_peer_configure(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t key_number, struct GNUNET_PeerIdentity *id, char **emsg)
Configure a GNUnet peer.
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
int GNUNET_TESTING_configuration_create(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new configuration using the given configuration as a template; ports and paths will be modif...
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_SCHEDULER_Task * next
This is a linked list.
Time for absolute times used by GNUnet, in microseconds.
Handle for a request to connect two peers.
struct GNUNET_MQ_Handle * mq
Message queue for sending from p1 to p2.
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
int p2_c
Set if peer2 says the connection is up to peer1.
void * cb_cls
Closure for cb.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
GNUNET_SCHEDULER_TaskCallback cb
Function to call upon completion.
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to facilitate the connection.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
int p1_c
Set if peer1 says the connection is up to peer2.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
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
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
Context for a single peer.
void * cb_cls
Closure for the nc and nd callbacks.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
unsigned int no
An unique number to identify the peer.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
struct GNUNET_PeerIdentity id
Peer identity.
void * start_cb_cls
Closure for start_cb.
size_t hello_size
Hello size.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
GNUNET_TRANSPORT_NotifyDisconnect nd
Notify disconnect callback.
struct GNUNET_HELLO_Message * hello
Peers HELLO Message.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static void start_cb(void *cls)
Function called once we have successfully launched a peer.
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.
static void clear_p2c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
static void set_mq(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
static void hello_iter_cb(void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
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.
static void clear_p1c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
static void set_p2c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
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.
static void set_p1c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
static void retrieve_hello(void *cls)
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
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)
Initiate a connection from p1 to p2 by offering p1 p2's HELLO message.
void GNUNET_TRANSPORT_TESTING_done(struct GNUNET_TRANSPORT_TESTING_Handle *tth)
Clean up the transport testing.
struct GNUNET_TRANSPORT_TESTING_Handle * GNUNET_TRANSPORT_TESTING_init()
Initialize the transport testing.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
static struct GNUNET_TRANSPORT_TESTING_PeerContext * find_peer_context(struct GNUNET_TRANSPORT_TESTING_Handle *tth, const struct GNUNET_PeerIdentity *peer)
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers.
static void offer_hello(void *cls)
Offer the current HELLO of P2 to P1.
void(* GNUNET_TRANSPORT_TESTING_ConnectContextCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Function called on matching connect requests.