GNUnet  0.11.x
transport-testing2.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "transport-testing2.h"
27 
28 
29 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing", __VA_ARGS__)
30 
31 
34  const struct GNUNET_PeerIdentity *peer)
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 }
45 
46 
55 void
58  *p1,
59  struct
61  *p2,
63  cb,
64  void *cb_cls)
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 }
79 
80 
81 static void
82 set_p1c (void *cls,
84 {
85  int *found = cls;
86 
87  if (NULL != found)
88  *found = GNUNET_YES;
89  cx->p1_c = GNUNET_YES;
90 }
91 
92 
93 static void
94 set_mq (void *cls,
96 {
97  struct GNUNET_MQ_Handle *mq = cls;
98 
99  cx->mq = mq;
100 }
101 
102 
103 static void
104 set_p2c (void *cls,
106 {
107  int *found = cls;
108 
109  if (NULL != found)
110  *found = GNUNET_YES;
111  cx->p2_c = GNUNET_YES;
112 }
113 
114 
115 static void
116 clear_p1c (void *cls,
118 {
119  int *found = cls;
120 
121  if (NULL != found)
122  *found = GNUNET_YES;
123  cx->p1_c = GNUNET_NO;
124 }
125 
126 
127 static void
128 clear_p2c (void *cls,
130 {
131  int *found = cls;
132 
133  if (NULL != found)
134  *found = GNUNET_YES;
135  cx->p2_c = GNUNET_NO;
136 }
137 
138 
139 static void *
140 notify_connect (void *cls,
141  const struct GNUNET_PeerIdentity *peer,
142  struct GNUNET_MQ_Handle *mq)
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 }
247 
248 
254 static void
255 offer_hello (void *cls);
256 
257 
258 static void
259 notify_disconnect (void *cls,
260  const struct GNUNET_PeerIdentity *peer,
261  void *handler_cls)
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 }
330 
331 
332 static void
334  const struct GNUNET_PEERSTORE_Record *record,
335  const char *emsg)
336 {
338  //Check record type et al?
339  p->hello = GNUNET_malloc (record->value_size);
340  memcpy (p->hello, record->value, record->value_size);
341 
343  if (NULL != p->start_cb)
344  {
346  "Peer %u (`%s') successfully started\n",
347  p->no,
348  GNUNET_i2s (&p->id));
349  p->start_cb (p->start_cb_cls);
350  p->start_cb = NULL;
351  }
352 }
353 
354 
371  const char *cfgname,
372  int peer_id,
373  const struct
377  void *cb_cls,
379  void *start_cb_cls)
380 {
381  char *emsg = NULL;
383  struct GNUNET_PeerIdentity dummy;
384  unsigned int i;
385 
386  if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
387  {
389  "File not found: `%s'\n",
390  cfgname);
391  return NULL;
392  }
393 
395  p->tth = tth;
396  p->nc = nc;
397  p->nd = nd;
398  if (NULL != handlers)
399  {
400  for (i = 0; NULL != handlers[i].cb; i++)
401  ;
402  p->handlers = GNUNET_new_array (i + 1,
403  struct GNUNET_MQ_MessageHandler);
405  handlers,
406  i * sizeof(struct GNUNET_MQ_MessageHandler));
407  }
408  if (NULL != cb_cls)
409  p->cb_cls = cb_cls;
410  else
411  p->cb_cls = p;
412  p->start_cb = start_cb;
413  if (NULL != start_cb_cls)
414  p->start_cb_cls = start_cb_cls;
415  else
416  p->start_cb_cls = p;
418  tth->p_tail,
419  p);
420 
421  /* Create configuration and call testing lib to modify it */
424  GNUNET_CONFIGURATION_load (p->cfg, cfgname));
425  if (GNUNET_SYSERR ==
427  p->cfg))
428  {
430  "Testing library failed to create unique configuration based on `%s'\n",
431  cfgname);
433  GNUNET_free (p);
434  return NULL;
435  }
436 
437  p->no = peer_id;
438  /* Configure peer with configuration */
440  p->cfg,
441  p->no,
442  NULL,
443  &emsg);
444  if (NULL == p->peer)
445  {
447  "Testing library failed to create unique configuration based on `%s': `%s'\n",
448  cfgname,
449  emsg);
451  GNUNET_free (emsg);
452  return NULL;
453  }
454  GNUNET_free (emsg);
456  {
458  "Testing library failed to create unique configuration based on `%s'\n",
459  cfgname);
461  return NULL;
462  }
463 
464  memset (&dummy,
465  '\0',
466  sizeof(dummy));
468  &p->id);
469  if (0 == memcmp (&dummy,
470  &p->id,
471  sizeof(struct GNUNET_PeerIdentity)))
472  {
474  "Testing library failed to obtain peer identity for peer %u\n",
475  p->no);
477  return NULL;
478  }
480  "Peer %u configured with identity `%s'\n",
481  p->no,
482  GNUNET_i2s_full (&p->id));
485  NULL,
486  handlers,
487  p,
490  if ((NULL == p->th) ||
491  (NULL == p->tmh))
492  {
494  "Failed to connect to transport service for peer `%s': `%s'\n",
495  cfgname,
496  emsg);
498  return NULL;
499  }
501  if (NULL == p->ats)
502  {
504  "Failed to connect to ATS service for peer `%s': `%s'\n",
505  cfgname,
506  emsg);
508  return NULL;
509  }
511  "transport",
512  &p->id,
515  p);
516  GNUNET_assert (NULL != p->pic);
517 
518  return p;
519 }
520 
521 
530 int
534  void *restart_cb_cls)
535 {
538 
539  /* shutdown */
541  "Stopping peer %u (`%s')\n",
542  p->no,
543  GNUNET_i2s (&p->id));
544  if (NULL != p->pic)
545  {
547  p->pic = NULL;
548  }
549  if (NULL != p->th)
550  {
552  p->th = NULL;
553  }
554  if (NULL != p->tmh)
555  {
557  p->tmh = NULL;
558  }
559  for (cc = p->tth->cc_head; NULL != cc; cc = ccn)
560  {
561  ccn = cc->next;
562  if ((cc->p1 == p) ||
563  (cc->p2 == p))
565  }
566  if (NULL != p->ats)
567  {
569  p->ats = NULL;
570  }
571  if (GNUNET_SYSERR ==
573  {
575  "Failed to stop peer %u (`%s')\n",
576  p->no,
577  GNUNET_i2s (&p->id));
578  return GNUNET_SYSERR;
579  }
580 
581  sleep (5); // YUCK!
582 
584  "Restarting peer %u (`%s')\n",
585  p->no,
586  GNUNET_i2s (&p->id));
587  /* restart */
589  {
591  "Failed to restart peer %u (`%s')\n",
592  p->no,
593  GNUNET_i2s (&p->id));
594  return GNUNET_SYSERR;
595  }
596 
597  GNUNET_assert (NULL == p->start_cb);
598  p->start_cb = restart_cb;
599  p->start_cb_cls = restart_cb_cls;
600 
602  NULL,
603  p->handlers,
604  p,
607  GNUNET_assert (NULL != p->th);
610  "transport",
611  &p->id,
614  p);
615  GNUNET_assert (NULL != p->pic);
616  return GNUNET_OK;
617 }
618 
619 
625 void
628 {
629  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
632 
633  for (cc = tth->cc_head; NULL != cc; cc = ccn)
634  {
635  ccn = cc->next;
636  if ((cc->p1 == p) ||
637  (cc->p2 == p))
639  }
640  if (NULL != p->pic)
641  {
643  p->pic = NULL;
644  }
645  if (NULL != p->tmh)
646  {
648  p->tmh = NULL;
649  }
650  if (NULL != p->th)
651  {
653  p->th = NULL;
654  }
655  if (NULL != p->peer)
656  {
657  if (GNUNET_OK !=
659  {
661  "Testing lib failed to stop peer %u (`%s')\n",
662  p->no,
663  GNUNET_i2s (&p->id));
664  }
666  p->peer = NULL;
667  }
668  if (NULL != p->ats)
669  {
671  p->ats = NULL;
672  }
673  if (NULL != p->hello)
674  {
675  GNUNET_free (p->hello);
676  p->hello = NULL;
677  }
678  if (NULL != p->cfg)
679  {
681  p->cfg = NULL;
682  }
683  if (NULL != p->handlers)
684  {
685  GNUNET_free (p->handlers);
686  p->handlers = NULL;
687  }
689  tth->p_tail,
690  p);
692  "Peer %u (`%s') stopped\n",
693  p->no,
694  GNUNET_i2s (&p->id));
695  GNUNET_free (p);
696 }
697 
698 
704 /*
705 static void
706 hello_offered (void *cls)
707 {
708  struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
709 
710  cc->oh = NULL;
711  cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
712  &offer_hello,
713  cc);
714 }*/
715 
716 
722 static void
723 offer_hello (void *cls)
724 {
726  struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1;
727  struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2;
728  struct GNUNET_TIME_Absolute t;
729  enum GNUNET_NetworkType nt;
730  char *addr;
731 
732  cc->tct = NULL;
733  {
734  char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
735 
737  "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %s\n",
738  p1->no,
739  GNUNET_i2s (&p1->id),
740  p2->no,
741  p2_s,
742  cc->p2->hello);
743  GNUNET_free (p2_s);
744  }
745 
747  cc->p2->hello_size,
748  &cc->p2->id,
749  &nt,
750  &t);
751  GNUNET_assert (NULL == addr);
753  &cc->p2->id,
754  nt,
755  addr);
756  GNUNET_free (addr);
757 }
758 
759 
775  struct
778  void *cls)
779 {
780  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
783 
784  ccn = NULL;
785  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
786  {
787  if ((cc->p1 == p1) &&
788  (cc->p2 == p2))
789  {
790  ccn = cc;
791  break;
792  }
793  }
794 
796  cc->p1 = p1;
797  cc->p2 = p2;
798  cc->cb = cb;
799  if (NULL != cls)
800  cc->cb_cls = cls;
801  else
802  cc->cb_cls = cc;
803  if (NULL != ccn)
804  {
805  cc->p1_c = ccn->p1_c;
806  cc->p2_c = ccn->p2_c;
807  cc->connected = ccn->connected;
808  }
810  tth->cc_tail,
811  cc);
813  cc);
815  &p2->id,
816  1);
818  "New connect request %p\n",
819  cc);
820  return cc;
821 }
822 
823 
831 void
834  *cc)
835 {
836  struct GNUNET_TRANSPORT_TESTING_Handle *tth = cc->p1->tth;
837 
839  "Canceling connect request!\n");
840  if (NULL != cc->tct)
841  {
843  cc->tct = NULL;
844  }
845  if (NULL != cc->ats_sh)
846  {
848  cc->ats_sh = NULL;
849  }
851  tth->cc_tail,
852  cc);
853  GNUNET_free (cc);
854 }
855 
856 
862 void
864 {
869 
870  if (NULL == tth)
871  return;
872  cc = tth->cc_head;
873  while (NULL != cc)
874  {
875  ct = cc->next;
877  "Developer forgot to cancel connect request!\n");
879  cc = ct;
880  }
881  p = tth->p_head;
882  while (NULL != p)
883  {
884  t = p->next;
886  "Developer forgot to stop peer!\n");
888  p = t;
889  }
891  GNUNET_YES);
892 
893  GNUNET_free (tth);
894 }
895 
896 
904 {
906 
908  tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
909  NULL,
910  NULL,
911  NULL);
912  if (NULL == tth->tl_system)
913  {
915  "Failed to initialize testing library!\n");
916  GNUNET_free (tth);
917  return NULL;
918  }
919  return tth;
920 }
921 
922 
923 /* end of transport-testing.c */
#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_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.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
void * start_cb_cls
Closure for start_cb.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer&#39;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&#39;s PEERSTORE Handle.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1352
struct GNUNET_MQ_Handle * mq
Message queue for sending from p1 to p2.
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_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
size_t value_size
Size of value BLOB.
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.
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 int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
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.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
void *(* GNUNET_TRANSPORT_NotifyConnect)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
static struct GNUNET_SCHEDULER_Task * t
Main task.
void * cb_cls
Closure for the nc and nd callbacks.
unsigned int no
An unique number to identify the peer.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1456
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
static void hello_iter_cb(void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a 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_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_TRANSPORT_CoreHandle * th
Peer&#39;s transport service handle.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer&#39;s transport get hello handle to retrieve peer&#39;s HELLO message.
void(* GNUNET_TRANSPORT_NotifyDisconnect)(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
Function called to notify transport users that another peer disconnected from us. ...
static void set_p2c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
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
void * value
Record value BLOB.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
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 * 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&#39;s HELLO message.
static void set_mq(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
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.
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)
void(* GNUNET_TRANSPORT_TESTING_ConnectContextCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Function called on matching connect requests.
struct GNUNET_TRANSPORT_TESTING_PeerContext * next
Next element in the DLL.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been received.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer&#39;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.
Message handler for a specific message type.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
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
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:527
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
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)
GNUNET_SCHEDULER_TaskCallback cb
Function to call upon completion.
GNUNET_TRANSPORT_NotifyConnect nc
Notify connect callback.
void GNUNET_TRANSPORT_TESTING_done(struct GNUNET_TRANSPORT_TESTING_Handle *tth)
Clean up the transport testing.
static void clear_p1c(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
Handle to a message queue.
Definition: mq.c:85
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_TRANSPORT_ManipulationHandle * GNUNET_TRANSPORT_manipulation_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the transport service.
struct GNUNET_HELLO_Message * hello
Peers HELLO Message.
struct GNUNET_TESTING_Peer * peer
Peer&#39;s testing handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
Single PEERSTORE record.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
void GNUNET_TRANSPORT_manipulation_disconnect(struct GNUNET_TRANSPORT_ManipulationHandle *handle)
Disconnect from the transport service.
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
struct GNUNET_TRANSPORT_ManipulationHandle * tmh
Peer&#39;s transport service manipulation handle.
int GNUNET_TRANSPORT_TESTING_restart_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p, GNUNET_SCHEDULER_TaskCallback restart_cb, void *restart_cb_cls)
Stops and restarts the given peer, sleeping (!) for 5s in between.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
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 record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
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
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to faciliate the connection.
int p2_c
Set if peer2 says the connection is up to peer1.
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.
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:107
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).
struct GNUNET_TRANSPORT_TESTING_Handle * GNUNET_TRANSPORT_TESTING_init()
Initialize the transport testing.
#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_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972