GNUnet  0.11.x
Macros | Functions
transport-testing2.c File Reference
#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 Tou MUST cancel the request if you stop the peers before the peers connected successfully. 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__)

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 33 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::id, GNUNET_TRANSPORT_TESTING_PeerContext::next, GNUNET_TRANSPORT_TESTING_Handle::p_head, and t.

Referenced by notify_connect(), and notify_disconnect().

35 {
37 
38  for (t = tth->p_head; NULL != t; t = t->next)
39  if (0 == memcmp (&t->id,
40  peer,
41  sizeof(struct GNUNET_PeerIdentity)))
42  return t;
43  return NULL;
44 }
struct GNUNET_PeerIdentity id
Peer identity.
Context for a single peer.
static struct GNUNET_SCHEDULER_Task * t
Main task.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
struct GNUNET_TRANSPORT_TESTING_PeerContext * next
Next element in the DLL.
The identity of the host (wraps the signing key of the peer).
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 56 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_ConnectRequest::cb, 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().

65 {
66  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
69 
70  for (cc = tth->cc_head; NULL != cc; cc = ccn)
71  {
72  ccn = cc->next;
73  if ((cc->p1 == p1) &&
74  (cc->p2 == p2))
75  cb (cb_cls,
76  cc);
77  }
78 }
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
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.
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 82 of file transport-testing2.c.

References GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c.

Referenced by notify_connect().

84 {
85  int *found = cls;
86 
87  if (NULL != found)
88  *found = GNUNET_YES;
89  cx->p1_c = GNUNET_YES;
90 }
int p1_c
Set if peer1 says the connection is up to peer2.
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 94 of file transport-testing2.c.

References mq, and GNUNET_TRANSPORT_TESTING_ConnectRequest::mq.

Referenced by notify_connect(), and notify_disconnect().

96 {
97  struct GNUNET_MQ_Handle *mq = cls;
98 
99  cx->mq = mq;
100 }
struct GNUNET_MQ_Handle * mq
Message queue for sending from p1 to p2.
Handle to a message queue.
Definition: mq.c:85
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
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 104 of file transport-testing2.c.

References GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c.

Referenced by notify_connect().

106 {
107  int *found = cls;
108 
109  if (NULL != found)
110  *found = GNUNET_YES;
111  cx->p2_c = GNUNET_YES;
112 }
int p2_c
Set if peer2 says the connection is up to peer1.
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 116 of file transport-testing2.c.

References GNUNET_NO, GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c.

Referenced by notify_disconnect().

118 {
119  int *found = cls;
120 
121  if (NULL != found)
122  *found = GNUNET_YES;
123  cx->p1_c = GNUNET_NO;
124 }
int p1_c
Set if peer1 says the connection is up to peer2.
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 128 of file transport-testing2.c.

References GNUNET_NO, GNUNET_YES, and GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c.

Referenced by notify_disconnect().

130 {
131  int *found = cls;
132 
133  if (NULL != found)
134  *found = GNUNET_YES;
135  cx->p2_c = GNUNET_NO;
136 }
int p2_c
Set if peer2 says the connection is up to peer1.
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 140 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb, GNUNET_TRANSPORT_TESTING_PeerContext::cb_cls, 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, GNUNET_TRANSPORT_TESTING_PeerContext::nc, 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, ret, set_mq(), set_p1c(), set_p2c(), GNUNET_TRANSPORT_TESTING_ConnectRequest::tct, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), and GNUNET_TRANSPORT_TESTING_start_peer().

143 {
145  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
146  char *p2_s;
150  int found;
151  void *ret;
152 
153  p2 = find_peer_context (p->tth,
154  peer);
155  if (NULL != p->nc)
156  ret = p->nc (p->cb_cls,
157  peer,
158  mq);
159  else
160  ret = NULL;
161 
162  if (NULL != p2)
163  GNUNET_asprintf (&p2_s,
164  "%u (`%s')",
165  p2->no,
166  GNUNET_i2s (&p2->id));
167  else
168  GNUNET_asprintf (&p2_s,
169  "`%s'",
170  GNUNET_i2s (peer));
172  "Peers %s connected to peer %u (`%s')\n",
173  p2_s,
174  p->no,
175  GNUNET_i2s (&p->id));
176  GNUNET_free (p2_s);
177  /* update flags in connecting contexts */
178  found = GNUNET_NO;
180  p2,
181  &set_p1c,
182  &found);
183  if (GNUNET_NO == found)
184  {
186  cc->p1 = p;
187  cc->p2 = p2;
188  cc->p1_c = GNUNET_YES;
190  tth->cc_tail,
191  cc);
192  }
193  found = GNUNET_NO;
195  p,
196  &set_p2c,
197  &found);
198  if (GNUNET_NO == found)
199  {
201  cc->p1 = p2;
202  cc->p2 = p;
203  cc->p1_c = GNUNET_YES;
205  tth->cc_tail,
206  cc);
207  }
209  p2,
210  &set_mq,
211  mq);
212  /* update set connected flag for all requests */
213  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
214  {
215  if (GNUNET_YES == cc->connected)
216  continue;
217  if ((GNUNET_YES == cc->p1_c) &&
218  (GNUNET_YES == cc->p2_c))
219  {
220  cc->connected = GNUNET_YES;
221  /* stop trying to connect */
222  if (NULL != cc->tct)
223  {
225  cc->tct = NULL;
226  }
227  if (NULL != cc->ats_sh)
228  {
230  cc->ats_sh = NULL;
231  }
232  }
233  }
234  /* then notify application */
235  for (cc = tth->cc_head; NULL != cc; cc = ccn)
236  {
237  ccn = cc->next;
238  if ((GNUNET_YES == cc->connected) &&
239  (NULL != cc->cb))
240  {
241  cc->cb (cc->cb_cls);
242  cc->cb = NULL; /* only notify once! */
243  }
244  }
245  return ret;
246 }
Handle for a request to connect two peers.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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.
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
Context for a single peer.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
void * cb_cls
Closure for the nc and nd callbacks.
unsigned int no
An unique number to identify the peer.
static void set_p2c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static void set_mq(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
int p1_c
Set if peer1 says the connection is up to peer2.
static void set_p1c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
GNUNET_SCHEDULER_TaskCallback cb
Function to call upon completion.
GNUNET_TRANSPORT_NotifyConnect nc
Notify connect callback.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to facilitate the connection.
int p2_c
Set if peer2 says the connection is up to peer1.
static struct GNUNET_TRANSPORT_TESTING_PeerContext * find_peer_context(struct GNUNET_TRANSPORT_TESTING_Handle *tth, const struct GNUNET_PeerIdentity *peer)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define LOG(kind,...)
#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:972
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 Offer the current HELLO of P2 to P1.

Parameters
clsour struct GNUNET_TRANSPORT_TESTING_ConnectRequest

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

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, and GNUNET_TRANSPORT_TESTING_ConnectRequest::tct.

Referenced by GNUNET_TRANSPORT_TESTING_connect_peers(), notify_connect(), and notify_disconnect().

759 {
761  struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1;
762  struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2;
763  struct GNUNET_TIME_Absolute t;
764  enum GNUNET_NetworkType nt = 0;
765  char *addr;
766 
767  cc->tct = NULL;
768  {
769  char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
770 
772  "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %s\n",
773  p1->no,
774  GNUNET_i2s (&p1->id),
775  p2->no,
776  p2_s,
777  p2->hello);
778  GNUNET_free (p2_s);
779  }
780 
782  p2->hello_size,
783  &p2->id,
784  &nt,
785  &t);
786  GNUNET_assert (NULL != addr);
787  GNUNET_assert (NULL != p1->hello);
789  &p2->id,
790  nt,
791  addr);
792  GNUNET_free (addr);
793 }
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
struct GNUNET_PeerIdentity id
Peer identity.
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...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a single peer.
static struct GNUNET_SCHEDULER_Task * t
Main task.
unsigned int no
An unique number to identify the peer.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
struct GNUNET_HELLO_Message * hello
Peers HELLO Message.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
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
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define LOG(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
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 259 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_PeerContext::cb_cls, 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_PeerContext::nd, 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_c, retrieve_hello(), set_mq(), GNUNET_TRANSPORT_TESTING_ConnectRequest::tct, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), and GNUNET_TRANSPORT_TESTING_start_peer().

262 {
264  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
265  char *p2_s;
266  /* Find PeerContext */
267  int no = 0;
268  struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = NULL;
270 
271  p2 = find_peer_context (p->tth,
272  peer);
273  no = p->no;
274  if (NULL != p2)
275  GNUNET_asprintf (&p2_s,
276  "%u (`%s')",
277  p2->no,
278  GNUNET_i2s (&p2->id));
279  else
280  GNUNET_asprintf (&p2_s,
281  "`%s'",
282  GNUNET_i2s (peer));
284  "Peers %s disconnected from peer %u (`%s')\n",
285  p2_s,
286  no,
287  GNUNET_i2s (&p->id));
288  GNUNET_free (p2_s);
289  /* notify about disconnect */
290  if (NULL != p->nd)
291  p->nd (p->cb_cls,
292  peer,
293  handler_cls);
294  if (NULL == p2)
295  return;
296  /* clear MQ, it is now invalid */
298  p2,
299  &set_mq,
300  NULL);
301  /* update set connected flags for all requests */
303  p2,
304  &clear_p1c,
305  NULL);
307  p,
308  &clear_p2c,
309  NULL);
310  /* resume connectivity requests as necessary */
311  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
312  {
313  if (GNUNET_NO == cc->connected)
314  continue;
315  if ((GNUNET_YES != cc->p1_c) ||
316  (GNUNET_YES != cc->p2_c))
317  {
318  cc->connected = GNUNET_NO;
319  /* start trying to connect */
320  if (NULL == cc->tct)
322  cc);
323  if (NULL == cc->ats_sh)
325  &p2->id,
326  1);
327  }
328  }
329 }
Handle for a request to connect two peers.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
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 clear_p2c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
Context for a single peer.
GNUNET_TRANSPORT_NotifyDisconnect nd
Notify disconnect callback.
void * cb_cls
Closure for the nc and nd callbacks.
unsigned int no
An unique number to identify the peer.
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.
static void offer_hello(void *cls)
Offer the current HELLO of P2 to P1.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
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:1296
static void set_mq(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
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_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
static void clear_p1c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to facilitate the connection.
int p2_c
Set if peer2 says the connection is up to peer1.
static struct GNUNET_TRANSPORT_TESTING_PeerContext * find_peer_context(struct GNUNET_TRANSPORT_TESTING_Handle *tth, const struct GNUNET_PeerIdentity *peer)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define LOG(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
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 368 of file transport-testing2.c.

References GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, hello_iter_cb(), GNUNET_TRANSPORT_TESTING_PeerContext::id, p, GNUNET_TRANSPORT_TESTING_PeerContext::ph, GNUNET_TRANSPORT_TESTING_PeerContext::pic, and GNUNET_TRANSPORT_TESTING_PeerContext::rh_task.

Referenced by GNUNET_TRANSPORT_TESTING_start_peer(), hello_iter_cb(), and notify_disconnect().

369 {
371  p->rh_task = NULL;
373  "transport",
374  &p->id,
377  p);
378 
379 }
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
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_PeerIdentity id
Peer identity.
Context for a single peer.
static void hello_iter_cb(void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY
Key used for storing HELLOs in the peerstore.
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 335 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::cb_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_malloc, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_SCHEDULER_add_now(), GNUNET_TRANSPORT_TESTING_PeerContext::hello, GNUNET_TRANSPORT_TESTING_PeerContext::hello_size, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_PeerContext::no, p, GNUNET_TRANSPORT_TESTING_PeerContext::pic, retrieve_hello(), GNUNET_TRANSPORT_TESTING_PeerContext::rh_task, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb_cls, GNUNET_PEERSTORE_Record::value, and GNUNET_PEERSTORE_Record::value_size.

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), and retrieve_hello().

338 {
340  if (NULL == record)
341  {
342  p->pic = NULL;
343  if (NULL != p->start_cb)
345  return;
346  }
347  // Check record type et al?
348  p->hello_size = record->value_size;
349  p->hello = GNUNET_malloc (p->hello_size);
350  memcpy (p->hello, record->value, p->hello_size);
351  p->hello[p->hello_size - 1] = '\0';
352 
354  p->pic = NULL;
355  if (NULL != p->start_cb)
356  {
358  "Peer %u (`%s') successfully started\n",
359  p->no,
360  GNUNET_i2s (&p->id));
361  p->start_cb (p->start_cb_cls);
362  p->start_cb = NULL;
363  }
364 }
static void retrieve_hello(void *cls)
void * start_cb_cls
Closure for start_cb.
struct GNUNET_PeerIdentity id
Peer identity.
size_t value_size
Size of value BLOB.
Context for a single peer.
void * cb_cls
Closure for the nc and nd callbacks.
unsigned int no
An unique number to identify the peer.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
GNUNET_SCHEDULER_TaskCallback start_cb
Startup completed callback.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void * value
Record value BLOB.
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:1296
struct GNUNET_HELLO_Message * hello
Peers HELLO Message.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define LOG(kind,...)
#define GNUNET_malloc(size)
Wrapper around malloc.
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_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 396 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::ah, GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_MQ_MessageHandler::cb, GNUNET_TRANSPORT_TESTING_PeerContext::cb_cls, GNUNET_TRANSPORT_TESTING_PeerContext::cfg, get_hello(), GNUNET_TRANSPORT_TESTING_PeerContext::ghh, 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_AC_ANY, GNUNET_TRANSPORT_application_init(), GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_hello_get(), GNUNET_TRANSPORT_manipulation_connect(), GNUNET_TRANSPORT_TESTING_stop_peer(), GNUNET_TRANSPORT_TESTING_PeerContext::handlers, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, nc, GNUNET_TRANSPORT_TESTING_PeerContext::nc, GNUNET_TRANSPORT_TESTING_PeerContext::nd, GNUNET_TRANSPORT_TESTING_PeerContext::no, notify_connect(), notify_disconnect(), p, GNUNET_TRANSPORT_TESTING_Handle::p_head, GNUNET_TRANSPORT_TESTING_Handle::p_tail, GNUNET_TRANSPORT_TESTING_PeerContext::peer, peer_id, GNUNET_TRANSPORT_TESTING_PeerContext::ph, retrieve_hello(), GNUNET_TRANSPORT_TESTING_PeerContext::rh_task, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb, start_cb(), GNUNET_TRANSPORT_TESTING_PeerContext::start_cb_cls, GNUNET_TRANSPORT_TESTING_PeerContext::th, GNUNET_TRANSPORT_TESTING_Handle::tl_system, GNUNET_TRANSPORT_TESTING_PeerContext::tmh, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

407 {
408  char *emsg = NULL;
410  struct GNUNET_PeerIdentity dummy;
411  unsigned int i;
412 
413  if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
414  {
416  "File not found: `%s'\n",
417  cfgname);
418  return NULL;
419  }
420 
422  p->tth = tth;
423  p->nc = nc;
424  p->nd = nd;
425  if (NULL != handlers)
426  {
427  for (i = 0; NULL != handlers[i].cb; i++)
428  ;
429  p->handlers = GNUNET_new_array (i + 1,
430  struct GNUNET_MQ_MessageHandler);
432  handlers,
433  i * sizeof(struct GNUNET_MQ_MessageHandler));
434  }
435  if (NULL != cb_cls)
436  p->cb_cls = cb_cls;
437  else
438  p->cb_cls = p;
439  p->start_cb = start_cb;
440  if (NULL != start_cb_cls)
441  p->start_cb_cls = start_cb_cls;
442  else
443  p->start_cb_cls = p;
445  tth->p_tail,
446  p);
447 
448  /* Create configuration and call testing lib to modify it */
451  GNUNET_CONFIGURATION_load (p->cfg, cfgname));
452  if (GNUNET_SYSERR ==
454  p->cfg))
455  {
457  "Testing library failed to create unique configuration based on `%s'\n",
458  cfgname);
460  GNUNET_free (p);
461  return NULL;
462  }
463 
464  p->no = peer_id;
465  /* Configure peer with configuration */
467  p->cfg,
468  p->no,
469  NULL,
470  &emsg);
471  if (NULL == p->peer)
472  {
474  "Testing library failed to create unique configuration based on `%s': `%s'\n",
475  cfgname,
476  emsg);
478  GNUNET_free (emsg);
479  return NULL;
480  }
481  GNUNET_free (emsg);
483  {
485  "Testing library failed to create unique configuration based on `%s'\n",
486  cfgname);
488  return NULL;
489  }
490 
491  memset (&dummy,
492  '\0',
493  sizeof(dummy));
495  &p->id);
496  if (0 == memcmp (&dummy,
497  &p->id,
498  sizeof(struct GNUNET_PeerIdentity)))
499  {
501  "Testing library failed to obtain peer identity for peer %u\n",
502  p->no);
504  return NULL;
505  }
507  "Peer %u configured with identity `%s'\n",
508  p->no,
509  GNUNET_i2s_full (&p->id));
511  NULL,
512  handlers,
513  p,
516  if (NULL == p->th)
517  {
519  "Failed to connect to transport service for peer `%s': `%s'\n",
520  cfgname,
521  emsg);
523  return NULL;
524  }
526  if (NULL == p->ats)
527  {
529  "Failed to connect to ATS service for peer `%s': `%s'\n",
530  cfgname,
531  emsg);
533  return NULL;
534  }
535  p->ph = GNUNET_PEERSTORE_connect (p->cfg);
536  // FIXME Error handling
538  GNUNET_assert (NULL != p->ah);
539  // FIXME Error handling
541 
542  return p;
543 }
static void retrieve_hello(void *cls)
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
void * start_cb_cls
Closure for start_cb.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1352
struct GNUNET_PeerIdentity id
Peer identity.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
Context for a single peer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_TRANSPORT_NotifyDisconnect nd
Notify disconnect callback.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#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.
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 * cb_cls
Closure for the nc and nd callbacks.
unsigned int no
An unique number to identify 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...
Definition: testing.c:1138
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
GNUNET_SCHEDULER_TaskCallback start_cb
Startup completed callback.
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:1159
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
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:1296
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been received.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
Message handler for a specific message type.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
GNUNET_TRANSPORT_NotifyConnect nc
Notify connect callback.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
struct GNUNET_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the TRANSPORT application client handle.
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
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:1330
static void start_cb(void *cls)
Function called once we have successfully launched a peer.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_tail
tail DLL of peers
#define LOG(kind,...)
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:437
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
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_cbcallback to call when restarted
restart_cb_clscallback closure
Returns
GNUNET_OK in success otherwise GNUNET_SYSERR

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

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_PeerContext::cfg, get_hello(), GNUNET_TRANSPORT_TESTING_PeerContext::ghh, 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_AC_ANY, GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_hello_get(), GNUNET_TRANSPORT_hello_get_cancel(), GNUNET_TRANSPORT_manipulation_disconnect(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), GNUNET_TRANSPORT_TESTING_PeerContext::handlers, hello_iter_cb(), GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_PeerContext::no, notify_connect(), notify_disconnect(), GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_PeerContext::peer, GNUNET_TRANSPORT_TESTING_PeerContext::ph, GNUNET_TRANSPORT_TESTING_PeerContext::pic, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb_cls, GNUNET_TRANSPORT_TESTING_PeerContext::th, GNUNET_TRANSPORT_TESTING_PeerContext::tmh, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

559 {
562 
563  /* shutdown */
565  "Stopping peer %u (`%s')\n",
566  p->no,
567  GNUNET_i2s (&p->id));
568  if (NULL != p->pic)
569  {
571  p->pic = NULL;
572  }
573  if (NULL != p->th)
574  {
576  p->th = NULL;
577  }
578  for (cc = p->tth->cc_head; NULL != cc; cc = ccn)
579  {
580  ccn = cc->next;
581  if ((cc->p1 == p) ||
582  (cc->p2 == p))
584  }
585  if (NULL != p->ats)
586  {
588  p->ats = NULL;
589  }
590  if (GNUNET_SYSERR ==
592  {
594  "Failed to stop peer %u (`%s')\n",
595  p->no,
596  GNUNET_i2s (&p->id));
597  return GNUNET_SYSERR;
598  }
599 
600  sleep (5); // YUCK!
601 
603  "Restarting peer %u (`%s')\n",
604  p->no,
605  GNUNET_i2s (&p->id));
606  /* restart */
608  {
610  "Failed to restart peer %u (`%s')\n",
611  p->no,
612  GNUNET_i2s (&p->id));
613  return GNUNET_SYSERR;
614  }
615 
616  GNUNET_assert (NULL == p->start_cb);
617  p->start_cb = restart_cb;
618  p->start_cb_cls = restart_cb_cls;
619 
621  NULL,
622  p->handlers,
623  p,
626  GNUNET_assert (NULL != p->th);
629  "transport",
630  &p->id,
633  p);
634  GNUNET_assert (NULL != p->pic);
635  return GNUNET_OK;
636 }
Handle for a request to connect two peers.
void * start_cb_cls
Closure for start_cb.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1352
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_PeerIdentity id
Peer identity.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
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.
unsigned int no
An unique number to identify the peer.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1456
static void hello_iter_cb(void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
GNUNET_SCHEDULER_TaskCallback start_cb
Startup completed callback.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY
Key used for storing HELLOs in the peerstore.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport 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.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers Tou MUST cancel the request if you stop the peers before the ...
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define LOG(kind,...)
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 645 of file transport-testing2.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::ah, GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_PeerContext::cfg, GNUNET_TRANSPORT_TESTING_PeerContext::ghh, 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_hello_get_cancel(), GNUNET_TRANSPORT_manipulation_disconnect(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), GNUNET_TRANSPORT_TESTING_PeerContext::handlers, GNUNET_TRANSPORT_TESTING_PeerContext::hello, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_PeerContext::no, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_Handle::p_head, GNUNET_TRANSPORT_TESTING_Handle::p_tail, GNUNET_TRANSPORT_TESTING_PeerContext::peer, GNUNET_TRANSPORT_TESTING_PeerContext::ph, GNUNET_TRANSPORT_TESTING_PeerContext::pic, GNUNET_TRANSPORT_TESTING_PeerContext::rh_task, GNUNET_TRANSPORT_TESTING_PeerContext::th, GNUNET_TRANSPORT_TESTING_PeerContext::tmh, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by GNUNET_TRANSPORT_TESTING_done(), and GNUNET_TRANSPORT_TESTING_start_peer().

647 {
648  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
651  /* shutdown */
653  "Stopping peer %u (`%s')\n",
654  p->no,
655  GNUNET_i2s (&p->id));
656 
657  for (cc = tth->cc_head; NULL != cc; cc = ccn)
658  {
659  ccn = cc->next;
660  if ((cc->p1 == p) ||
661  (cc->p2 == p))
663  }
664  if (NULL != p->pic)
665  {
667  p->pic = NULL;
668  }
669  if (NULL != p->th)
670  {
672  p->th = NULL;
673  }
674  if (NULL != p->ats)
675  {
677  p->ats = NULL;
678  }
679  if (NULL != p->ah)
680  {
682  p->ah = NULL;
683  }
684  if (NULL != p->ph)
685  {
687  "Disconnecting from PEERSTORE service\n");
689  p->ph = NULL;
690  }
691 
692  if (NULL != p->peer)
693  {
694  if (GNUNET_OK !=
696  {
698  "Testing lib failed to stop peer %u (`%s')\n",
699  p->no,
700  GNUNET_i2s (&p->id));
701  }
703  p->peer = NULL;
704  }
705  if (NULL != p->hello)
706  {
707  GNUNET_free (p->hello);
708  p->hello = NULL;
709  }
710  if (NULL != p->cfg)
711  {
713  p->cfg = NULL;
714  }
715  if (NULL != p->handlers)
716  {
717  GNUNET_free (p->handlers);
718  p->handlers = NULL;
719  }
721  tth->p_tail,
722  p);
724  "Peer %u (`%s') stopped\n",
725  p->no,
726  GNUNET_i2s (&p->id));
727  if (NULL != p->rh_task)
729  p->rh_task = NULL;
730  GNUNET_free (p);
731 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
unsigned int no
An unique number to identify the peer.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1456
void GNUNET_TRANSPORT_application_done(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Shutdown TRANSPORT application client.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_HELLO_Message * hello
Peers HELLO Message.
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
#define GNUNET_log(kind,...)
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_tail
tail DLL of peers
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers Tou MUST cancel the request if you stop the peers before the ...
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1548
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define LOG(kind,...)
#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:972
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 809 of file transport-testing2.c.

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.

815 {
816  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
819 
820  ccn = NULL;
821  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
822  {
823  if ((cc->p1 == p1) &&
824  (cc->p2 == p2))
825  {
826  ccn = cc;
827  break;
828  }
829  }
830 
832  cc->p1 = p1;
833  cc->p2 = p2;
834  cc->cb = cb;
835  if (NULL != cls)
836  cc->cb_cls = cls;
837  else
838  cc->cb_cls = cc;
839  if (NULL != ccn)
840  {
841  cc->p1_c = ccn->p1_c;
842  cc->p2_c = ccn->p2_c;
843  cc->connected = ccn->connected;
844  }
846  tth->cc_tail,
847  cc);
849  cc);
851  &p2->id,
852  1);
854  "New connect request %p\n",
855  cc);
856  return cc;
857 }
Handle for a request to connect two peers.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
static void offer_hello(void *cls)
Offer the current HELLO of P2 to P1.
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:1296
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
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_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
GNUNET_SCHEDULER_TaskCallback cb
Function to call upon completion.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to facilitate the connection.
int p2_c
Set if peer2 says the connection is up to peer1.
#define LOG(kind,...)
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 Tou MUST cancel the request if you stop the peers before the peers connected successfully.

Cancel the request to connect two peers.

Parameters
tthtransport testing handle
cca connect request handle

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

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(), GNUNET_TRANSPORT_offer_hello_cancel(), LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::oh, 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().

871 {
872  struct GNUNET_TRANSPORT_TESTING_Handle *tth = cc->p1->tth;
873 
875  "Canceling connect request!\n");
876  if (NULL != cc->tct)
877  {
879  cc->tct = NULL;
880  }
881  if (NULL != cc->ats_sh)
882  {
884  cc->ats_sh = NULL;
885  }
887  tth->cc_tail,
888  cc);
889  GNUNET_free (cc);
890 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to facilitate the connection.
#define LOG(kind,...)
#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:972
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 899 of file transport-testing2.c.

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_PeerContext::next, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, p, GNUNET_TRANSPORT_TESTING_Handle::p_head, t, and GNUNET_TRANSPORT_TESTING_Handle::tl_system.

900 {
905 
906  if (NULL == tth)
907  return;
908  cc = tth->cc_head;
909  while (NULL != cc)
910  {
911  ct = cc->next;
913  "Developer forgot to cancel connect request!\n");
915  cc = ct;
916  }
917  p = tth->p_head;
918  while (NULL != p)
919  {
920  t = p->next;
922  "Developer forgot to stop peer!\n");
924  p = t;
925  }
927  GNUNET_YES);
928 
929  GNUNET_free (tth);
930 }
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
Context for a single peer.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
struct GNUNET_TRANSPORT_TESTING_PeerContext * next
Next element in the DLL.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:527
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers Tou MUST cancel the request if you stop the peers before the ...
#define LOG(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
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 939 of file transport-testing2.c.

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

940 {
942 
944  tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
945  NULL,
946  NULL,
947  NULL);
948  if (NULL == tth->tl_system)
949  {
951  "Failed to initialize testing library!\n");
952  GNUNET_free (tth);
953  return NULL;
954  }
955  return tth;
956 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:447
#define GNUNET_log(kind,...)
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function: