GNUnet  0.20.0
transport-testing2.c File Reference
#include "platform.h"
#include "transport-testing2.h"
Include dependency graph for transport-testing2.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "transport-testing", __VA_ARGS__)
 

Functions

static struct GNUNET_TRANSPORT_TESTING_PeerContextfind_peer_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth, const struct GNUNET_PeerIdentity *peer)
 
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. More...
 
static void set_p1c (void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
 
static void set_mq (void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
 
static void set_p2c (void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
 
static void clear_p1c (void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
 
static void clear_p2c (void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
 
static void * notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 
static void offer_hello (void *cls)
 Offer the current HELLO of P2 to P1. More...
 
static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
 
static void retrieve_hello (void *cls)
 
static void hello_iter_cb (void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 
struct GNUNET_TRANSPORT_TESTING_PeerContextGNUNET_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. More...
 
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. More...
 
void GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
 Shutdown the given peer. More...
 
struct GNUNET_TRANSPORT_TESTING_ConnectRequestGNUNET_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. More...
 
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
 Cancel the request to connect two peers. More...
 
void GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth)
 Clean up the transport testing. More...
 
struct GNUNET_TRANSPORT_TESTING_HandleGNUNET_TRANSPORT_TESTING_init ()
 Initialize the transport testing. More...
 

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "transport-testing", __VA_ARGS__)

Definition at line 30 of file transport-testing2.c.

Function Documentation

◆ find_peer_context()

static struct GNUNET_TRANSPORT_TESTING_PeerContext* find_peer_context ( struct GNUNET_TRANSPORT_TESTING_Handle tth,
const struct GNUNET_PeerIdentity peer 
)
static

Definition at line 34 of file transport-testing2.c.

36 {
38 
39  for (t = tth->p_head; NULL != t; t = t->next)
40  if (0 == memcmp (&t->id,
41  peer,
42  sizeof(struct GNUNET_PeerIdentity)))
43  return t;
44  return NULL;
45 }
static struct GNUNET_SCHEDULER_Task * t
Main task.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_SCHEDULER_Task * next
This is a linked list.
Definition: scheduler.c:140
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_SCHEDULER_Task::next, GNUNET_TRANSPORT_TESTING_Handle::p_head, peer, t, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by notify_connect(), and notify_disconnect().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_find_connecting_context()

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.

Parameters
p1first peer
p2second peer
cbfunction to call
cb_clsclosure for cb

Definition at line 57 of file transport-testing2.c.

66 {
67  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
70 
71  for (cc = tth->cc_head; NULL != cc; cc = ccn)
72  {
73  ccn = cc->next;
74  if ((cc->p1 == p1) &&
75  (cc->p2 == p2))
76  cb (cb_cls,
77  cc);
78  }
79 }
Handle for a request to connect two peers.
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_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts

References GNUNET_TRANSPORT_TESTING_ConnectRequest::cb, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb_cls, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by notify_connect(), and notify_disconnect().

Here is the caller graph for this function:

◆ set_p1c()

static void set_p1c ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest cx 
)
static

Definition at line 83 of file transport-testing2.c.

85 {
86  int *found = cls;
87 
88  if (NULL != found)
89  *found = GNUNET_YES;
90  cx->p1_c = GNUNET_YES;
91 }
@ GNUNET_YES
int p1_c
Set if peer1 says the connection is up to peer2.

References GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c.

Referenced by notify_connect().

Here is the caller graph for this function:

◆ set_mq()

static void set_mq ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest cx 
)
static

Definition at line 95 of file transport-testing2.c.

97 {
98  struct GNUNET_MQ_Handle *mq = cls;
99 
100  cx->mq = mq;
101 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
Handle to a message queue.
Definition: mq.c:87
struct GNUNET_MQ_Handle * mq
Message queue for sending from p1 to p2.

References mq, and GNUNET_TRANSPORT_TESTING_ConnectRequest::mq.

Referenced by notify_connect(), and notify_disconnect().

Here is the caller graph for this function:

◆ set_p2c()

static void set_p2c ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest cx 
)
static

Definition at line 105 of file transport-testing2.c.

107 {
108  int *found = cls;
109 
110  if (NULL != found)
111  *found = GNUNET_YES;
112  cx->p2_c = GNUNET_YES;
113 }
int p2_c
Set if peer2 says the connection is up to peer1.

References GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c.

Referenced by notify_connect().

Here is the caller graph for this function:

◆ clear_p1c()

static void clear_p1c ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest cx 
)
static

Definition at line 117 of file transport-testing2.c.

119 {
120  int *found = cls;
121 
122  if (NULL != found)
123  *found = GNUNET_YES;
124  cx->p1_c = GNUNET_NO;
125 }
@ GNUNET_NO

References GNUNET_NO, GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c.

Referenced by notify_disconnect().

Here is the caller graph for this function:

◆ clear_p2c()

static void clear_p2c ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_ConnectRequest cx 
)
static

Definition at line 129 of file transport-testing2.c.

131 {
132  int *found = cls;
133 
134  if (NULL != found)
135  *found = GNUNET_YES;
136  cx->p2_c = GNUNET_NO;
137 }

References GNUNET_NO, GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c.

Referenced by notify_disconnect().

Here is the caller graph for this function:

◆ notify_connect()

static void* notify_connect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 
)
static

Definition at line 141 of file transport-testing2.c.

144 {
146  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
147  char *p2_s;
151  int found;
152  void *ret;
153 
154  p2 = find_peer_context (p->tth,
155  peer);
156  if (NULL != p->nc)
157  ret = p->nc (p->cb_cls,
158  peer,
159  mq);
160  else
161  ret = NULL;
162 
163  if (NULL != p2)
164  GNUNET_asprintf (&p2_s,
165  "%u (`%s')",
166  p2->no,
167  GNUNET_i2s (&p2->id));
168  else
169  GNUNET_asprintf (&p2_s,
170  "`%s'",
171  GNUNET_i2s (peer));
173  "Peers %s connected to peer %u (`%s')\n",
174  p2_s,
175  p->no,
176  GNUNET_i2s (&p->id));
177  GNUNET_free (p2_s);
178  /* update flags in connecting contexts */
179  found = GNUNET_NO;
181  p2,
182  &set_p1c,
183  &found);
184  if (GNUNET_NO == found)
185  {
187  cc->p1 = p;
188  cc->p2 = p2;
189  cc->p1_c = GNUNET_YES;
191  tth->cc_tail,
192  cc);
193  }
194  found = GNUNET_NO;
196  p,
197  &set_p2c,
198  &found);
199  if (GNUNET_NO == found)
200  {
202  cc->p1 = p2;
203  cc->p2 = p;
204  cc->p1_c = GNUNET_YES;
206  tth->cc_tail,
207  cc);
208  }
210  p2,
211  &set_mq,
212  mq);
213  /* update set connected flag for all requests */
214  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
215  {
216  if (GNUNET_YES == cc->connected)
217  continue;
218  if ((GNUNET_YES == cc->p1_c) &&
219  (GNUNET_YES == cc->p2_c))
220  {
221  cc->connected = GNUNET_YES;
222  /* stop trying to connect */
223  if (NULL != cc->tct)
224  {
226  cc->tct = NULL;
227  }
228  if (NULL != cc->ats_sh)
229  {
231  cc->ats_sh = NULL;
232  }
233  }
234  }
235  /* then notify application */
236  for (cc = tth->cc_head; NULL != cc; cc = ccn)
237  {
238  ccn = cc->next;
239  if ((GNUNET_YES == cc->connected) &&
240  (NULL != cc->cb))
241  {
242  cc->cb (cc->cb_cls);
243  cc->cb = NULL; /* only notify once! */
244  }
245  }
246  return ret;
247 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
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.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
unsigned int no
An unique number to identify the peer.
struct GNUNET_PeerIdentity id
Peer identity.
static void set_mq(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)
#define LOG(kind,...)
static struct GNUNET_TRANSPORT_TESTING_PeerContext * find_peer_context(struct GNUNET_TRANSPORT_TESTING_Handle *tth, const struct GNUNET_PeerIdentity *peer)

References GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb_cls, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_Handle::cc_tail, GNUNET_TRANSPORT_TESTING_ConnectRequest::connected, find_peer_context(), GNUNET_asprintf(), GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_TESTING_find_connecting_context(), GNUNET_YES, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, mq, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_PeerContext::no, p, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c, peer, ret, set_mq(), set_p1c(), set_p2c(), and GNUNET_TRANSPORT_TESTING_ConnectRequest::tct.

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), and GNUNET_TRANSPORT_TESTING_start_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ offer_hello()

static void offer_hello ( void *  cls)
static

Offer the current HELLO of P2 to P1.

Function called after the HELLO was passed to the transport service.

Parameters
clsour struct GNUNET_TRANSPORT_TESTING_ConnectRequest

FIXME maybe schedule the application_validate somehow

Definition at line 736 of file transport-testing2.c.

737 {
739  struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1;
740  struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2;
741  struct GNUNET_TIME_Absolute t;
742  enum GNUNET_NetworkType nt = 0;
743  char *addr;
744 
745  cc->tct = NULL;
746  {
747  char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
748 
750  "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %s\n",
751  p1->no,
752  GNUNET_i2s (&p1->id),
753  p2->no,
754  p2_s,
755  p2->hello);
756  GNUNET_free (p2_s);
757  }
758 
760  p2->hello_size,
761  &p2->id,
762  &nt,
763  &t);
764  GNUNET_assert (NULL != addr);
765  GNUNET_assert (NULL != p1->hello);
767  &p2->id,
768  nt,
769  addr);
770  GNUNET_free (addr);
771 }
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
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...
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.
Definition: hello-ng.c:108
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:39
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
struct GNUNET_HELLO_Message * hello
Peers HELLO Message.

References GNUNET_TRANSPORT_TESTING_PeerContext::ah, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_extract_address(), GNUNET_i2s(), GNUNET_strdup, GNUNET_TRANSPORT_application_validate(), GNUNET_TRANSPORT_TESTING_PeerContext::hello, GNUNET_TRANSPORT_TESTING_PeerContext::hello_size, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_PeerContext::no, nt, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, t, and GNUNET_TRANSPORT_TESTING_ConnectRequest::tct.

Referenced by GNUNET_TRANSPORT_TESTING_connect_peers(), and notify_disconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_disconnect()

static void notify_disconnect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  handler_cls 
)
static

Definition at line 260 of file transport-testing2.c.

263 {
265  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
266  char *p2_s;
267  /* Find PeerContext */
268  int no = 0;
269  struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = NULL;
271 
272  p2 = find_peer_context (p->tth,
273  peer);
274  no = p->no;
275  if (NULL != p2)
276  GNUNET_asprintf (&p2_s,
277  "%u (`%s')",
278  p2->no,
279  GNUNET_i2s (&p2->id));
280  else
281  GNUNET_asprintf (&p2_s,
282  "`%s'",
283  GNUNET_i2s (peer));
285  "Peers %s disconnected from peer %u (`%s')\n",
286  p2_s,
287  no,
288  GNUNET_i2s (&p->id));
289  GNUNET_free (p2_s);
290  /* notify about disconnect */
291  if (NULL != p->nd)
292  p->nd (p->cb_cls,
293  peer,
294  handler_cls);
295  if (NULL == p2)
296  return;
297  /* clear MQ, it is now invalid */
299  p2,
300  &set_mq,
301  NULL);
302  /* update set connected flags for all requests */
304  p2,
305  &clear_p1c,
306  NULL);
308  p,
309  &clear_p2c,
310  NULL);
311  /* resume connectivity requests as necessary */
312  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
313  {
314  if (GNUNET_NO == cc->connected)
315  continue;
316  if ((GNUNET_YES != cc->p1_c) ||
317  (GNUNET_YES != cc->p2_c))
318  {
319  cc->connected = GNUNET_NO;
320  /* start trying to connect */
321  if (NULL == cc->tct)
323  cc);
324  if (NULL == cc->ats_sh)
326  &p2->id,
327  1);
328  }
329  }
330 }
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.
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.
Definition: scheduler.c:1299
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
static void clear_p2c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
static void clear_p1c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
static void offer_hello(void *cls)
Offer the current HELLO of P2 to P1.

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_Handle::cc_head, clear_p1c(), clear_p2c(), GNUNET_TRANSPORT_TESTING_ConnectRequest::connected, find_peer_context(), GNUNET_asprintf(), GNUNET_ATS_connectivity_suggest(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_TRANSPORT_TESTING_find_connecting_context(), GNUNET_YES, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_PeerContext::no, offer_hello(), p, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c, peer, set_mq(), and GNUNET_TRANSPORT_TESTING_ConnectRequest::tct.

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), and GNUNET_TRANSPORT_TESTING_start_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ retrieve_hello()

static void retrieve_hello ( void *  cls)
static

Definition at line 370 of file transport-testing2.c.

371 {
373  p->rh_task = NULL;
374  p->pic = GNUNET_PEERSTORE_iterate (p->ph,
375  "transport",
376  &p->id,
379  p);
380 
381 }
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY
Key used for storing HELLOs in the peerstore.
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.
static void hello_iter_cb(void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)

References GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, hello_iter_cb(), and p.

Referenced by GNUNET_TRANSPORT_TESTING_start_peer(), and hello_iter_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hello_iter_cb()

static void hello_iter_cb ( void *  cb_cls,
const struct GNUNET_PEERSTORE_Record record,
const char *  emsg 
)
static

Definition at line 337 of file transport-testing2.c.

340 {
342  if (NULL == record)
343  {
344  p->pic = NULL;
345  if (NULL != p->start_cb)
347  return;
348  }
349  // Check record type et al?
350  p->hello_size = record->value_size;
351  p->hello = GNUNET_malloc (p->hello_size);
352  memcpy (p->hello, record->value, p->hello_size);
353  p->hello[p->hello_size - 1] = '\0';
354 
356  p->pic = NULL;
357  if (NULL != p->start_cb)
358  {
360  "Peer %u (`%s') successfully started\n",
361  p->no,
362  GNUNET_i2s (&p->id));
363  p->start_cb (p->start_cb_cls);
364  p->start_cb = NULL;
365  }
366 }
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
#define GNUNET_malloc(size)
Wrapper around malloc.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
void * cb_cls
Closure for the nc and nd callbacks.
static void retrieve_hello(void *cls)

References GNUNET_TRANSPORT_TESTING_PeerContext::cb_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_malloc, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_SCHEDULER_add_now(), LOG, p, record(), and retrieve_hello().

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), and retrieve_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_start_peer()

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.

Parameters
tththe testing handle
cfgnameconfiguration file
peer_idthe peer_id
handlersfunctions for receiving messages
ncconnect callback
nddisconnect callback
cb_clsclosure for nc and nd callback
start_cbstart callback
start_cb_clsclosure for start_cb
Returns
the peer context
Parameters
tththe testing handle
cfgnameconfiguration file
peer_ida unique number to identify the peer
handlersfunctions for receiving messages
ncconnect callback
nddisconnect callback
cb_clsclosure for callback
start_cbstart callback
start_cb_clsclosure for callback
Returns
the peer context

Definition at line 385 of file transport-testing2.c.

396 {
397  char *emsg = NULL;
399  struct GNUNET_PeerIdentity dummy;
400  unsigned int i;
401 
402  if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
403  {
405  "File not found: `%s'\n",
406  cfgname);
407  return NULL;
408  }
409 
411  p->tth = tth;
412  p->nc = nc;
413  p->nd = nd;
414  if (NULL != handlers)
415  {
416  for (i = 0; NULL != handlers[i].cb; i++)
417  ;
418  p->handlers = GNUNET_new_array (i + 1,
419  struct GNUNET_MQ_MessageHandler);
420  GNUNET_memcpy (p->handlers,
421  handlers,
422  i * sizeof(struct GNUNET_MQ_MessageHandler));
423  }
424  if (NULL != cb_cls)
425  p->cb_cls = cb_cls;
426  else
427  p->cb_cls = p;
428  p->start_cb = start_cb;
429  if (NULL != start_cb_cls)
430  p->start_cb_cls = start_cb_cls;
431  else
432  p->start_cb_cls = p;
434  tth->p_tail,
435  p);
436 
437  /* Create configuration and call testing lib to modify it */
438  p->cfg = GNUNET_CONFIGURATION_create ();
440  GNUNET_CONFIGURATION_load (p->cfg, cfgname));
441  if (GNUNET_SYSERR ==
443  p->cfg))
444  {
446  "Testing library failed to create unique configuration based on `%s'\n",
447  cfgname);
449  GNUNET_free (p);
450  return NULL;
451  }
452 
453  p->no = peer_id;
454  /* Configure peer with configuration */
456  p->cfg,
457  p->no,
458  NULL,
459  &emsg);
460  if (NULL == p->peer)
461  {
463  "Testing library failed to create unique configuration based on `%s': `%s'\n",
464  cfgname,
465  emsg);
467  GNUNET_free (emsg);
468  return NULL;
469  }
470 
471  if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer))
472  {
474  "Testing library failed to create unique configuration based on `%s'\n",
475  cfgname);
477  return NULL;
478  }
479 
480  memset (&dummy,
481  '\0',
482  sizeof(dummy));
484  &p->id);
485  if (0 == memcmp (&dummy,
486  &p->id,
487  sizeof(struct GNUNET_PeerIdentity)))
488  {
490  "Testing library failed to obtain peer identity for peer %u\n",
491  p->no);
493  return NULL;
494  }
496  "Peer %u configured with identity `%s'\n",
497  p->no,
498  GNUNET_i2s_full (&p->id));
499  p->th = GNUNET_TRANSPORT_core_connect (p->cfg,
500  NULL,
501  handlers,
502  p,
505  if (NULL == p->th)
506  {
508  "Failed to connect to transport service for peer `%s': `%s'\n",
509  cfgname,
510  emsg);
512  GNUNET_free (emsg);
513  return NULL;
514  }
515  p->ats = GNUNET_ATS_connectivity_init (p->cfg);
516  if (NULL == p->ats)
517  {
519  "Failed to connect to ATS service for peer `%s': `%s'\n",
520  cfgname,
521  emsg);
523  GNUNET_free (emsg);
524  return NULL;
525  }
526  p->ph = GNUNET_PEERSTORE_connect (p->cfg);
527  // FIXME Error handling
529  GNUNET_assert (NULL != p->ah);
530  // FIXME Error handling
532 
533  return p;
534 }
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
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.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
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).
Definition: disk.c:482
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
@ GNUNET_SYSERR
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
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
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.
Definition: testing.c:1188
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1381
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...
Definition: testing.c:1167
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1359
Message handler for a specific message type.
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_tail
tail DLL of peers
static void start_cb(void *cls)
Function called once we have successfully launched a peer.
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)

References dummy, GNUNET_assert, GNUNET_ATS_connectivity_init(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_load(), GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s_full(), GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_PEERSTORE_connect(), GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, GNUNET_TESTING_configuration_create(), GNUNET_TESTING_peer_configure(), GNUNET_TESTING_peer_get_identity(), GNUNET_TESTING_peer_start(), GNUNET_TRANSPORT_application_init(), GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_TESTING_stop_peer(), handlers, LOG, nc, notify_connect(), notify_disconnect(), p, GNUNET_TRANSPORT_TESTING_Handle::p_head, GNUNET_TRANSPORT_TESTING_Handle::p_tail, peer_id, retrieve_hello(), start_cb(), and GNUNET_TRANSPORT_TESTING_Handle::tl_system.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_restart_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.

Parameters
pthe peer
restart_cbrestart callback
restart_cb_clscallback closure
Returns
GNUNET_OK in success otherwise GNUNET_SYSERR
Parameters
pthe peer
restart_cbcallback to call when restarted
restart_cb_clscallback closure
Returns
GNUNET_OK in success otherwise GNUNET_SYSERR

Definition at line 538 of file transport-testing2.c.

542 {
545 
546  /* shutdown */
548  "Stopping peer %u (`%s')\n",
549  p->no,
550  GNUNET_i2s (&p->id));
551  if (NULL != p->pic)
552  {
554  p->pic = NULL;
555  }
556  if (NULL != p->th)
557  {
559  p->th = NULL;
560  }
561  for (cc = p->tth->cc_head; NULL != cc; cc = ccn)
562  {
563  ccn = cc->next;
564  if ((cc->p1 == p) ||
565  (cc->p2 == p))
567  }
568  if (NULL != p->ats)
569  {
571  p->ats = NULL;
572  }
573  if (GNUNET_SYSERR ==
574  GNUNET_TESTING_peer_stop (p->peer))
575  {
577  "Failed to stop peer %u (`%s')\n",
578  p->no,
579  GNUNET_i2s (&p->id));
580  return GNUNET_SYSERR;
581  }
582 
583  sleep (5); // YUCK!
584 
586  "Restarting peer %u (`%s')\n",
587  p->no,
588  GNUNET_i2s (&p->id));
589  /* restart */
591  {
593  "Failed to restart peer %u (`%s')\n",
594  p->no,
595  GNUNET_i2s (&p->id));
596  return GNUNET_SYSERR;
597  }
598 
599  GNUNET_assert (NULL == p->start_cb);
600  p->start_cb = restart_cb;
601  p->start_cb_cls = restart_cb_cls;
602 
603  p->th = GNUNET_TRANSPORT_core_connect (p->cfg,
604  NULL,
605  p->handlers,
606  p,
609  GNUNET_assert (NULL != p->th);
610  p->ats = GNUNET_ATS_connectivity_init (p->cfg);
611  p->pic = GNUNET_PEERSTORE_iterate (p->ph,
612  "transport",
613  &p->id,
616  p);
617  GNUNET_assert (NULL != p->pic);
618  return GNUNET_OK;
619 }
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1485
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers.

References GNUNET_assert, GNUNET_ATS_connectivity_done(), GNUNET_ATS_connectivity_init(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_OK, GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_iterate_cancel(), GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, GNUNET_SYSERR, GNUNET_TESTING_peer_start(), GNUNET_TESTING_peer_stop(), GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), hello_iter_cb(), LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, notify_connect(), notify_disconnect(), p, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p2.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_stop_peer()

void GNUNET_TRANSPORT_TESTING_stop_peer ( struct GNUNET_TRANSPORT_TESTING_PeerContext p)

Shutdown the given peer.

Parameters
pthe peer

Definition at line 628 of file transport-testing2.c.

630 {
631  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
634  /* shutdown */
636  "Stopping peer %u (`%s')\n",
637  p->no,
638  GNUNET_i2s (&p->id));
639 
640  for (cc = tth->cc_head; NULL != cc; cc = ccn)
641  {
642  ccn = cc->next;
643  if ((cc->p1 == p) ||
644  (cc->p2 == p))
646  }
647  if (NULL != p->pic)
648  {
650  p->pic = NULL;
651  }
652  if (NULL != p->th)
653  {
655  p->th = NULL;
656  }
657  if (NULL != p->ats)
658  {
660  p->ats = NULL;
661  }
662  if (NULL != p->ah)
663  {
665  p->ah = NULL;
666  }
667  if (NULL != p->ph)
668  {
670  "Disconnecting from PEERSTORE service\n");
672  p->ph = NULL;
673  }
674 
675  if (NULL != p->peer)
676  {
677  if (GNUNET_OK !=
678  GNUNET_TESTING_peer_stop (p->peer))
679  {
681  "Testing lib failed to stop peer %u (`%s')\n",
682  p->no,
683  GNUNET_i2s (&p->id));
684  }
686  p->peer = NULL;
687  }
688  if (NULL != p->hello)
689  {
690  GNUNET_free (p->hello);
691  p->hello = NULL;
692  }
693  if (NULL != p->cfg)
694  {
696  p->cfg = NULL;
697  }
698  if (NULL != p->handlers)
699  {
700  GNUNET_free (p->handlers);
701  p->handlers = NULL;
702  }
704  tth->p_tail,
705  p);
707  "Peer %u (`%s') stopped\n",
708  p->no,
709  GNUNET_i2s (&p->id));
710  if (NULL != p->rh_task)
711  GNUNET_SCHEDULER_cancel (p->rh_task);
712  p->rh_task = NULL;
713  GNUNET_free (p);
714 }
void GNUNET_TRANSPORT_application_done(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Shutdown TRANSPORT application client.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_log(kind,...)
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1566

References GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_ATS_connectivity_done(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_iterate_cancel(), GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_peer_stop(), GNUNET_TRANSPORT_application_done(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, p, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_Handle::p_head, and GNUNET_TRANSPORT_TESTING_Handle::p_tail.

Referenced by GNUNET_TRANSPORT_TESTING_done(), and GNUNET_TRANSPORT_TESTING_start_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_connect_peers()

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.

Connect the given peers and call the callback when both peers report the inbound connection.

Remarks: start_peer's notify_connect callback can be called before.

Parameters
tthtransport testing handle
p1peer 1
p2peer 2
cbthe callback to call when both peers notified that they are connected
clscallback cls
Returns
a connect request handle

Definition at line 787 of file transport-testing2.c.

793 {
794  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
797 
798  ccn = NULL;
799  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
800  {
801  if ((cc->p1 == p1) &&
802  (cc->p2 == p2))
803  {
804  ccn = cc;
805  break;
806  }
807  }
808 
810  cc->p1 = p1;
811  cc->p2 = p2;
812  cc->cb = cb;
813  if (NULL != cls)
814  cc->cb_cls = cls;
815  else
816  cc->cb_cls = cc;
817  if (NULL != ccn)
818  {
819  cc->p1_c = ccn->p1_c;
820  cc->p2_c = ccn->p2_c;
821  cc->connected = ccn->connected;
822  }
824  tth->cc_tail,
825  cc);
827  cc);
829  &p2->id,
830  1);
832  "New connect request %p\n",
833  cc);
834  return cc;
835 }

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb_cls, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_Handle::cc_tail, GNUNET_TRANSPORT_TESTING_ConnectRequest::connected, GNUNET_ATS_connectivity_suggest(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, offer_hello(), GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c, GNUNET_TRANSPORT_TESTING_ConnectRequest::tct, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_connect_peers_cancel()

void GNUNET_TRANSPORT_TESTING_connect_peers_cancel ( struct GNUNET_TRANSPORT_TESTING_ConnectRequest cc)

Cancel the request to connect two peers.

You MUST cancel the request if you stop the peers before the peers connected successfully.

Parameters
cca connect request handle

Cancel the request to connect two peers.

Parameters
tthtransport testing handle
cca connect request handle

Definition at line 839 of file transport-testing2.c.

842 {
843  struct GNUNET_TRANSPORT_TESTING_Handle *tth = cc->p1->tth;
844 
846  "Canceling connect request!\n");
847  if (NULL != cc->tct)
848  {
850  cc->tct = NULL;
851  }
852  if (NULL != cc->ats_sh)
853  {
855  cc->ats_sh = NULL;
856  }
858  tth->cc_tail,
859  cc);
860  GNUNET_free (cc);
861 }

References GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_Handle::cc_tail, GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SCHEDULER_cancel(), LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::tct, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by GNUNET_TRANSPORT_TESTING_done(), GNUNET_TRANSPORT_TESTING_restart_peer(), and GNUNET_TRANSPORT_TESTING_stop_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_done()

void GNUNET_TRANSPORT_TESTING_done ( struct GNUNET_TRANSPORT_TESTING_Handle tth)

Clean up the transport testing.

Parameters
tthtransport testing handle

Definition at line 870 of file transport-testing2.c.

871 {
876 
877  if (NULL == tth)
878  return;
879  cc = tth->cc_head;
880  while (NULL != cc)
881  {
882  ct = cc->next;
884  "Developer forgot to cancel connect request!\n");
886  cc = ct;
887  }
888  p = tth->p_head;
889  while (NULL != p)
890  {
891  t = p->next;
893  "Developer forgot to stop peer!\n");
895  p = t;
896  }
898  GNUNET_YES);
899 
900  GNUNET_free (tth);
901 }
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:557

References GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_TESTING_system_destroy(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), GNUNET_TRANSPORT_TESTING_stop_peer(), GNUNET_YES, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, p, GNUNET_TRANSPORT_TESTING_Handle::p_head, t, GNUNET_TRANSPORT_TESTING_Handle::tl_system, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_init()

struct GNUNET_TRANSPORT_TESTING_Handle* GNUNET_TRANSPORT_TESTING_init ( void  )

Initialize the transport testing.

Returns
transport testing handle

Definition at line 910 of file transport-testing2.c.

911 {
913 
915  tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
916  NULL,
917  NULL,
918  NULL);
919  if (NULL == tth->tl_system)
920  {
922  "Failed to initialize testing library!\n");
923  GNUNET_free (tth);
924  return NULL;
925  }
926  return tth;
927 }
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.
Definition: testing.c:477

References GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_TESTING_system_create(), and GNUNET_TRANSPORT_TESTING_Handle::tl_system.

Here is the call graph for this function: