GNUnet  0.10.x
testbed_api_peers.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2008--2013 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  */
20 
29 #include "platform.h"
30 #include "testbed_api_peers.h"
31 #include "testbed_api.h"
32 #include "testbed.h"
33 #include "testbed_api_hosts.h"
34 #include "testbed_api_operations.h"
35 
36 
41 
46 
47 
53 void
55 {
56  GNUNET_CONTAINER_DLL_insert_tail (peer_list_head, peer_list_tail, peer);
57 }
58 
59 
65 void
67 {
68  GNUNET_CONTAINER_DLL_remove (peer_list_head, peer_list_tail, peer);
69 }
70 
71 
75 void
77 {
78  struct GNUNET_TESTBED_Peer *peer;
79 
80  while (NULL != (peer = peer_list_head))
81  {
83  GNUNET_free (peer);
84  }
85 }
86 
87 
88 
96 static void
98 {
99  struct OperationContext *opc = cls;
100  struct PeerCreateData *data = opc->data;
102  struct GNUNET_MQ_Envelope *env;
103  char *config;
104  char *xconfig;
105  size_t c_size;
106  size_t xc_size;
107 
109  GNUNET_assert (NULL != data);
110  GNUNET_assert (NULL != data->peer);
111  opc->state = OPC_STATE_STARTED;
112  config = GNUNET_CONFIGURATION_serialize (data->cfg,
113  &c_size);
114  xc_size = GNUNET_TESTBED_compress_config_ (config,
115  c_size,
116  &xconfig);
117  GNUNET_free (config);
118  env = GNUNET_MQ_msg_extra (msg,
119  xc_size,
121  msg->operation_id = GNUNET_htonll (opc->id);
122  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->peer->host));
123  msg->peer_id = htonl (data->peer->unique_id);
124  msg->config_size = htons ((uint16_t) c_size);
125  GNUNET_memcpy (&msg[1],
126  xconfig,
127  xc_size);
128  GNUNET_MQ_send (opc->c->mq,
129  env);
130  GNUNET_free (xconfig);
131  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
132 }
133 
134 
140 static void
142 {
143  struct OperationContext *opc = cls;
144 
145  switch (opc->state)
146  {
147  case OPC_STATE_STARTED:
148  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
149  /* No break we continue flow */
150  case OPC_STATE_INIT:
151  GNUNET_free (((struct PeerCreateData *) opc->data)->peer);
152  GNUNET_free (opc->data);
153  break;
154  case OPC_STATE_FINISHED:
155  break;
156  }
157  GNUNET_free (opc);
158 }
159 
160 
166 static void
168 {
169  struct OperationContext *opc = cls;
170  struct GNUNET_TESTBED_Peer *peer = opc->data;
172  struct GNUNET_MQ_Envelope *env;
173 
175  GNUNET_assert (NULL != peer);
176  opc->state = OPC_STATE_STARTED;
177  env = GNUNET_MQ_msg (msg,
179  msg->peer_id = htonl (peer->unique_id);
180  msg->operation_id = GNUNET_htonll (opc->id);
181  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
182  GNUNET_MQ_send (peer->controller->mq,
183  env);
184 }
185 
186 
192 static void
194 {
195  struct OperationContext *opc = cls;
196 
197  switch (opc->state)
198  {
199  case OPC_STATE_STARTED:
200  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
201  /* no break; continue */
202  case OPC_STATE_INIT:
203  break;
204  case OPC_STATE_FINISHED:
205  break;
206  }
207  GNUNET_free (opc);
208 }
209 
210 
216 static void
218 {
219  struct OperationContext *opc = cls;
221  struct GNUNET_MQ_Envelope *env;
222  struct PeerEventData *data;
223  struct GNUNET_TESTBED_Peer *peer;
224 
225  GNUNET_assert (OP_PEER_START == opc->type);
226  GNUNET_assert (NULL != (data = opc->data));
227  GNUNET_assert (NULL != (peer = data->peer));
229  opc->state = OPC_STATE_STARTED;
230  env = GNUNET_MQ_msg (msg,
232  msg->peer_id = htonl (peer->unique_id);
233  msg->operation_id = GNUNET_htonll (opc->id);
234  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
235  GNUNET_MQ_send (peer->controller->mq,
236  env);
237 }
238 
239 
245 static void
247 {
248  struct OperationContext *opc = cls;
249 
250  switch (opc->state)
251  {
252  case OPC_STATE_STARTED:
253  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
254  /* no break; continue */
255  case OPC_STATE_INIT:
256  GNUNET_free (opc->data);
257  break;
258  case OPC_STATE_FINISHED:
259  break;
260  }
261  GNUNET_free (opc);
262 }
263 
264 
270 static void
271 opstart_peer_stop (void *cls)
272 {
273  struct OperationContext *opc = cls;
275  struct PeerEventData *data;
276  struct GNUNET_TESTBED_Peer *peer;
277  struct GNUNET_MQ_Envelope *env;
278 
279  GNUNET_assert (NULL != (data = opc->data));
280  GNUNET_assert (NULL != (peer = data->peer));
282  opc->state = OPC_STATE_STARTED;
283  env = GNUNET_MQ_msg (msg,
285  msg->peer_id = htonl (peer->unique_id);
286  msg->operation_id = GNUNET_htonll (opc->id);
287  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
288  GNUNET_MQ_send (peer->controller->mq,
289  env);
290 }
291 
292 
298 static void
300 {
301  struct OperationContext *opc = cls;
302 
303  switch (opc->state)
304  {
305  case OPC_STATE_STARTED:
306  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
307  /* no break; continue */
308  case OPC_STATE_INIT:
309  GNUNET_free (opc->data);
310  break;
311  case OPC_STATE_FINISHED:
312  break;
313  }
314  GNUNET_free (opc);
315 }
316 
317 
328  uint64_t operation_id)
329 {
331 
332  msg =
333  GNUNET_malloc (sizeof
335  msg->header.size =
336  htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
338  msg->peer_id = htonl (peer_id);
339  msg->operation_id = GNUNET_htonll (operation_id);
340  return msg;
341 }
342 
343 
349 static void
351 {
352  struct OperationContext *opc = cls;
353  struct PeerInfoData *data = opc->data;
355 
356  GNUNET_assert (NULL != data);
357  opc->state = OPC_STATE_STARTED;
358  msg =
360  opc->id);
361  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
362  GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
363 }
364 
365 
371 static void
373 {
374  struct OperationContext *opc = cls;
376 
377  switch (opc->state)
378  {
379  case OPC_STATE_STARTED:
380  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
381  /* no break; continue */
382  case OPC_STATE_INIT:
383  GNUNET_free (opc->data);
384  break;
385  case OPC_STATE_FINISHED:
386  data = opc->data;
387  GNUNET_assert (NULL != data);
388  switch (data->pit)
389  {
391  if (NULL != data->result.cfg)
393  break;
395  GNUNET_free (data->result.id);
396  break;
397  default:
398  GNUNET_assert (0); /* We should never reach here */
399  }
400  GNUNET_free (data);
401  break;
402  }
403  GNUNET_free (opc);
404 }
405 
406 
412 static void
414 {
415  struct OperationContext *opc = cls;
416  struct GNUNET_MQ_Envelope *env;
418  struct OverlayConnectData *data;
419 
420  opc->state = OPC_STATE_STARTED;
421  data = opc->data;
422  GNUNET_assert (NULL != data);
423  env = GNUNET_MQ_msg (msg,
425  msg->peer1 = htonl (data->p1->unique_id);
426  msg->peer2 = htonl (data->p2->unique_id);
427  msg->operation_id = GNUNET_htonll (opc->id);
428  msg->peer2_host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->p2->host));
430  opc);
431  GNUNET_MQ_send (opc->c->mq,
432  env);
433 }
434 
435 
441 static void
443 {
444  struct OperationContext *opc = cls;
445  struct OverlayConnectData *data;
446 
447  data = opc->data;
448  switch (opc->state)
449  {
450  case OPC_STATE_INIT:
451  break;
452  case OPC_STATE_STARTED:
453  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
454  break;
455  case OPC_STATE_FINISHED:
456  break;
457  }
458  GNUNET_free (data);
459  GNUNET_free (opc);
460 }
461 
462 
468 static void
470 {
471  struct OperationContext *opc = cls;
472  struct PeerReconfigureData *data = opc->data;
473  struct GNUNET_MQ_Envelope *env;
475  char *xconfig;
476  size_t xc_size;
477 
478  opc->state = OPC_STATE_STARTED;
479  GNUNET_assert (NULL != data);
480  xc_size = GNUNET_TESTBED_compress_config_ (data->config,
481  data->cfg_size,
482  &xconfig);
483  GNUNET_free (data->config);
484  data->config = NULL;
485  GNUNET_assert (xc_size < UINT16_MAX - sizeof (*msg));
486  env = GNUNET_MQ_msg_extra (msg,
487  xc_size,
489  msg->peer_id = htonl (data->peer->unique_id);
490  msg->operation_id = GNUNET_htonll (opc->id);
491  msg->config_size = htons (data->cfg_size);
492  GNUNET_memcpy (&msg[1],
493  xconfig,
494  xc_size);
495  GNUNET_free (xconfig);
496  GNUNET_free (data);
497  opc->data = NULL;
498  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
499  GNUNET_MQ_send (opc->c->mq,
500  env);
501 }
502 
503 
509 static void
511 {
512  struct OperationContext *opc = cls;
513  struct PeerReconfigureData *data = opc->data;
514 
515  switch (opc->state)
516  {
517  case OPC_STATE_INIT:
518  GNUNET_free (data->config);
519  GNUNET_free (data);
520  break;
521  case OPC_STATE_STARTED:
522  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
523  break;
524  case OPC_STATE_FINISHED:
525  break;
526  }
527  GNUNET_free (opc);
528 }
529 
530 
537 struct GNUNET_TESTBED_Peer *
539 {
540  GNUNET_break (0);
541  return NULL;
542 }
543 
544 
576  struct GNUNET_TESTBED_Host *host,
577  const struct GNUNET_CONFIGURATION_Handle *cfg,
578  GNUNET_TESTBED_PeerCreateCallback cb, void *cls)
579 {
580 
581  struct GNUNET_TESTBED_Peer *peer;
582  struct PeerCreateData *data;
583  struct OperationContext *opc;
584  static uint32_t id_gen;
585 
586  peer = GNUNET_new (struct GNUNET_TESTBED_Peer);
587  peer->controller = controller;
588  peer->host = host;
589  peer->unique_id = id_gen++;
590  peer->state = TESTBED_PS_INVALID;
591  data = GNUNET_new (struct PeerCreateData);
592  data->host = host;
593  data->cfg = cfg;
594  data->cb = cb;
595  data->cls = cls;
596  data->peer = peer;
597  opc = GNUNET_new (struct OperationContext);
598  opc->c = controller;
599  opc->data = data;
600  opc->id = GNUNET_TESTBED_get_next_op_id (controller);
601  opc->type = OP_PEER_CREATE;
602  opc->op =
606  opc->op);
608  return opc->op;
609 }
610 
611 
624  GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
625 {
626  struct OperationContext *opc;
627  struct PeerEventData *data;
628 
629  data = GNUNET_new (struct PeerEventData);
630  data->peer = peer;
631  data->pcc = pcc;
632  data->pcc_cls = pcc_cls;
633  opc = GNUNET_new (struct OperationContext);
634  opc->c = peer->controller;
635  opc->data = data;
636  opc->op_cls = op_cls;
637  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
638  opc->type = OP_PEER_START;
639  opc->op =
643  opc->op);
645  return opc->op;
646 }
647 
648 
663  struct GNUNET_TESTBED_Peer *peer,
664  GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
665 {
666  struct OperationContext *opc;
667  struct PeerEventData *data;
668 
669  data = GNUNET_new (struct PeerEventData);
670  data->peer = peer;
671  data->pcc = pcc;
672  data->pcc_cls = pcc_cls;
673  opc = GNUNET_new (struct OperationContext);
674  opc->c = peer->controller;
675  opc->data = data;
676  opc->op_cls = op_cls;
677  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
678  opc->type = OP_PEER_STOP;
679  opc->op =
683  opc->op);
685  return opc->op;
686 }
687 
688 
707  void *cb_cls)
708 {
709  struct OperationContext *opc;
710  struct PeerInfoData *data;
711 
713  GNUNET_assert (NULL != cb);
714  data = GNUNET_new (struct PeerInfoData);
715  data->peer = peer;
716  data->pit = pit;
717  data->cb = cb;
718  data->cb_cls = cb_cls;
719  opc = GNUNET_new (struct OperationContext);
720  opc->c = peer->controller;
721  opc->data = data;
722  opc->type = OP_PEER_INFO;
723  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
724  opc->op =
728  opc->op);
730  return opc->op;
731 }
732 
733 
746  const struct
748 {
749  struct OperationContext *opc;
750  struct PeerReconfigureData *data;
751  size_t csize;
752 
753  data = GNUNET_new (struct PeerReconfigureData);
754  data->peer = peer;
755  data->config = GNUNET_CONFIGURATION_serialize (cfg, &csize);
756  if (NULL == data->config)
757  {
758  GNUNET_free (data);
759  return NULL;
760  }
761  if (csize > UINT16_MAX)
762  {
763  GNUNET_break (0);
764  GNUNET_free (data->config);
765  GNUNET_free (data);
766  return NULL;
767  }
768  data->cfg_size = (uint16_t) csize;
769  opc = GNUNET_new (struct OperationContext);
770  opc->c = peer->controller;
771  opc->data = data;
772  opc->type = OP_PEER_RECONFIGURE;
773  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
774  opc->op =
778  opc->op);
780  return opc->op;
781 }
782 
783 
793 {
794  struct OperationContext *opc;
795 
796  opc = GNUNET_new (struct OperationContext);
797  opc->data = peer;
798  opc->c = peer->controller;
800  opc->type = OP_PEER_DESTROY;
801  opc->op =
805  opc->op);
807  return opc->op;
808 }
809 
810 
825  struct GNUNET_TESTBED_Peer *p1,
826  struct GNUNET_TESTBED_Peer *p2,
828  ...)
829 {
830  GNUNET_break (0);
831  return NULL;
832 }
833 
834 
852  void *cb_cls, struct GNUNET_TESTBED_Peer *p1,
853  struct GNUNET_TESTBED_Peer *p2)
854 {
855  struct OperationContext *opc;
856  struct OverlayConnectData *data;
857 
859  data = GNUNET_new (struct OverlayConnectData);
860  data->p1 = p1;
861  data->p2 = p2;
862  data->cb = cb;
863  data->cb_cls = cb_cls;
864  opc = GNUNET_new (struct OperationContext);
865  opc->data = data;
866  opc->c = p1->controller;
867  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
868  opc->type = OP_OVERLAY_CONNECT;
869  opc->op_cls = op_cls;
870  opc->op =
875  return opc->op;
876 }
877 
878 
884 static void
886 {
887  struct OperationContext *opc = cls;
888  struct ManageServiceData *data = opc->data;
889  struct GNUNET_MQ_Envelope *env;
891  size_t xlen;
892 
893  GNUNET_assert (NULL != data);
894  xlen = data->msize - sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage);
895  env = GNUNET_MQ_msg_extra (msg,
896  xlen,
898  msg->peer_id = htonl (data->peer->unique_id);
899  msg->operation_id = GNUNET_htonll (opc->id);
900  msg->start = (uint8_t) data->start;
901  GNUNET_memcpy (&msg[1],
902  data->service_name,
903  xlen);
904  GNUNET_free (data->service_name);
905  data->service_name = NULL;
906  opc->state = OPC_STATE_STARTED;
907  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
908  GNUNET_MQ_send (opc->c->mq,
909  env);
910 }
911 
912 
918 static void
920 {
921  struct OperationContext *opc = cls;
922  struct ManageServiceData *data;
923 
924  data = opc->data;
925  switch (opc->state)
926  {
927  case OPC_STATE_STARTED:
928  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
929  break;
930  case OPC_STATE_INIT:
931  GNUNET_assert (NULL != data);
932  GNUNET_free (data->service_name);
933  break;
934  case OPC_STATE_FINISHED:
935  break;
936  }
937  GNUNET_free_non_null (data);
938  GNUNET_free (opc);
939 }
940 
941 
959  struct GNUNET_TESTBED_Peer *peer,
960  const char *service_name,
962  void *cb_cls,
963  unsigned int start)
964 {
965  struct ManageServiceData *data;
966  struct OperationContext *opc;
967  size_t msize;
968 
969  GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */
970  msize = strlen (service_name) + 1;
971  msize += sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage);
972  if (GNUNET_MAX_MESSAGE_SIZE < msize)
973  return NULL;
974  data = GNUNET_new (struct ManageServiceData);
975  data->cb = cb;
976  data->cb_cls = cb_cls;
977  data->peer = peer;
978  data->service_name = GNUNET_strdup (service_name);
979  data->start = start;
980  data->msize = (uint16_t) msize;
981  opc = GNUNET_new (struct OperationContext);
982  opc->data = data;
983  opc->c = peer->controller;
984  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
985  opc->type = OP_MANAGE_SERVICE;
986  opc->op_cls = op_cls;
987  opc->op =
991  opc->op);
993  return opc->op;
994 }
995 
996 
997 
998 /* end of testbed_api_peers.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void * cb_cls
Closure for callbacks.
Data for the OperationType OP_PEER_INFO.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_stop(void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
Stop the given peer.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
internal API to access the &#39;operations&#39; subsystem
GNUNET_TESTBED_PeerInformationType
Types of information that can be requested about a peer.
void * cb_cls
The closure for the above callback.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:251
static void oprelease_peer_stop(void *cls)
Callback which will be called when peer stop type operation is released.
uint16_t cfg_size
the size of the serialized configuration
union GNUNET_TESTBED_PeerInformation::@64 result
The result of the get information operation; Choose according to the pit.
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
Message sent from client to testing service to stop a peer.
Definition: testbed.h:309
void * cb_cls
The closure for peer info callback.
struct GNUNET_TESTBED_Peer * GNUNET_TESTBED_peer_lookup_by_id_(uint32_t id)
Lookup a peer by ID.
static void oprelease_peer_start(void *cls)
Callback which will be called when peer start type operation is released.
void * op_cls
The operation closure.
Definition: testbed_api.h:152
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:615
The operation has been started.
Definition: testbed_api.h:124
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_overlay_connect(void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2)
Both peers must have been started before calling this function.
void * cls
The closure for the above callback.
Message sent from client to testing service to destroy a (stopped) peer.
Definition: testbed.h:334
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:300
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
#define GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER
Message to stop a peer at a host.
enum GNUNET_TESTBED_PeerInformationType pit
Peer information type; captures which of the types in the &#39;op_result&#39; is actually in use...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_TESTBED_host_queue_oc_(struct GNUNET_TESTBED_Host *h, struct GNUNET_TESTBED_Operation *op)
Queues the given operation in the queue for parallel overlay connects of the given host...
static void opstart_peer_stop(void *cls)
Function called when a peer stop operation is ready.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_start(void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
Start the given peer.
static void oprelease_overlay_connect(void *cls)
Callback which will be called when overlay connect operation is released.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
IPC messages between testing API and service ("controller")
struct GNUNET_TESTBED_Peer * peer
The handle of the peer to start.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:412
GNUNET_TESTBED_PeerCreateCallback cb
The call back to call when we receive peer create success message.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2213
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:626
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_peer_register_(struct GNUNET_TESTBED_Peer *peer)
Adds a peer to the peer list.
static void opstart_peer_reconfigure(void *cls)
Function called when a peer reconfigure operation is ready.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Opaque handle to a host running experiments managed by the testing framework.
struct GNUNET_TESTBED_PeerGetConfigurationMessage * GNUNET_TESTBED_generate_peergetconfig_msg_(uint32_t peer_id, uint64_t operation_id)
Generate PeerGetConfigurationMessage.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE
Message to start/stop a service of a peer.
const struct GNUNET_CONFIGURATION_Handle * cfg
The template configuration of the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Opaque handle to an abstract operation to be executed by the testing framework.
Data for OperationType OP_PEER_START and OP_PEER_STOP.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:262
Reconfigure a peer.
Definition: testbed_api.h:74
Message sent from client to testing service to start a peer.
Definition: testbed.h:284
void GNUNET_TESTBED_cleanup_peers_(void)
Frees all peers.
GNUNET_TESTBED_PeerInfoCallback cb
The Peer info callback to call when this operation has completed.
void(* GNUNET_TESTBED_PeerCreateCallback)(void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
Functions of this signature are called when a peer has been successfully created. ...
uint16_t config_size
The length of the serialized configuration when uncompressed.
Definition: testbed.h:272
struct GNUNET_PeerIdentity * id
The identity of the peer.
uint32_t peer2
Unique ID for the second peer.
Definition: testbed.h:417
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
enum PeerState state
Peer&#39;s state.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint64_t operation_id
Operation ID.
Definition: testbed.h:760
GNUNET_TESTBED_PeerChurnCallback pcc
The Peer churn callback to call when this operation is completed.
static void oprelease_peer_reconfigure(void *cls)
Callback which will be called when a peer reconfigure operation is released.
static unsigned int csize
#define GNUNET_memcpy(dst, src, n)
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:345
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:267
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
Special value (not valid for requesting information) that is used in the event struct if a &#39;generic&#39; ...
uint32_t peer1
Unique ID for the first peer.
Definition: testbed.h:407
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:631
void * pcc_cls
Closure for the above callback.
#define GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER
Message to reconfigure a peer.
static void opstart_peer_getinfo(void *cls)
Function called when a peer get information operation is ready.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:621
uint32_t peer2_host_id
The ID of the host which runs peer2.
Definition: testbed.h:422
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
void(* GNUNET_TESTBED_PeerInfoCallback)(void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
Callback to be called when the requested peer information is available The peer information in the ca...
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
Peer destroy operation.
Definition: testbed_api.h:64
static void opstart_manage_service(void *cls)
Function called when a peer manage service operation is ready.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
#define GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER
Message to destroy a peer.
static const struct GNUNET_CONFIGURATION_Handle * config
What configuration is the peer using? Returns a &#39;const struct GNUNET_CONFIGURATION_Handle *&#39;...
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
Peer start operation.
Definition: testbed_api.h:54
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
static void opstart_peer_start(void *cls)
Function called when a peer start operation is ready.
struct GNUNET_TESTBED_Host * host
Which host does this peer run on?
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call once this operation is done.
void GNUNET_TESTBED_peer_deregister_(struct GNUNET_TESTBED_Peer *peer)
Removes a peer from the peer list.
#define GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT
Message to connect peers in a overlay.
void(* GNUNET_TESTBED_PeerChurnCallback)(void *cls, const char *emsg)
Functions of this signature are called when a peer has been successfully started or stopped...
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the peer.
uint64_t operation_id
Unique operation id.
Definition: testbed.h:229
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
Request information about a peer.
Data structure for OperationType OP_OVERLAY_CONNECT.
Message sent from client to testing service to create (configure, but not start) a peer...
Definition: testbed.h:213
GNUNET_TESTBED_ConnectOption
Options for peer connections.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_underlay_configure_link(void *op_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2, enum GNUNET_TESTBED_ConnectOption co,...)
Manipulate the P2P underlay topology by configuring a link between two peers.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_update_configuration(struct GNUNET_TESTBED_Peer *peer, const struct GNUNET_CONFIGURATION_Handle *cfg)
Change peer configuration.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
The peer is stopped.
GUID host
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1331
struct GNUNET_TESTBED_Peer * p1
Peer A to connect to peer B.
static void opstart_overlay_connect(void *cls)
Function called when a overlay connect operation is ready.
GNUNET_TESTBED_OperationCompletionCallback cb
Overlay connection operation.
Definition: testbed_api.h:79
static void oprelease_peer_destroy(void *cls)
Callback which will be called when peer_create type operation is released.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION
Message to get a peer&#39;s information.
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:118
The operation has finished.
Definition: testbed_api.h:130
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER
Message to create a peer at a host.
static void oprelease_manage_service(void *cls)
Callback which will be called when peer manage server operation is released.
Data for the operations of type OP_PEER_RECONFIGURE.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_destroy(struct GNUNET_TESTBED_Peer *peer)
Destroy the given peer; the peer should have been stopped first (if it was started).
internal API to access the &#39;peers&#39; subsystem
uint8_t start
set this to 1 to start the service; 0 to stop the service
Definition: testbed.h:765
Peer stop operation.
Definition: testbed_api.h:59
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1761
Interface for functions internally exported from testbed_api.c.
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
void(* GNUNET_TESTBED_OperationCompletionCallback)(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback to be called when an operation is completed.
Message sent from client to testing service to connect two peers.
Definition: testbed.h:396
Start/stop service at a peer.
Definition: testbed_api.h:104
uint32_t unique_id
Globally unique ID of the peer.
static void opstart_peer_destroy(void *cls)
Function called when a peer destroy operation is ready.
static struct GNUNET_TESTBED_Peer * peer_list_head
Peer list DLL head.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
What is the identity of the peer? Returns a &#39;const struct GNUNET_PeerIdentity *&#39;. ...
uint32_t peer_id
Unique ID of the peer whose service has to be managed.
Definition: testbed.h:755
struct GNUNET_TESTBED_Peer * peer
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
struct GNUNET_TESTBED_Peer * p2
Peer B.
configuration data
Definition: configuration.c:85
Message to start/stop services of a peer.
Definition: testbed.h:745
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:219
static void oprelease_peer_getinfo(void *cls)
Callback which will be called when peer stop type operation is released.
uint32_t host_id
On which host should the peer be started?
Definition: testbed.h:224
Peer create operation.
Definition: testbed_api.h:49
struct GNUNET_TESTBED_Peer * peer
The peer structure to return when we get success message.
static void oprelease_peer_create(void *cls)
Callback which will be called when peer_create type operation is released.
The peer has been created.
State to signify that this peer is invalid.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:320
void GNUNET_TESTBED_insert_opc_(struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Inserts the given operation context into the operation context map of the given controller.
Definition: testbed_api.c:306
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
The peer is running.
internal API to access the &#39;hosts&#39; subsystem
static void opstart_peer_create(void *cls)
Function to call to start a peer_create type operation once all queues the operation is part of decla...
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:234
enum GNUNET_TESTBED_PeerInformationType pit
The type of peer information requested.
A peer controlled by the testing framework.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_manage_service(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, unsigned int start)
Start or stop given service at a peer.
char * config
The serialized new configuration template.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:325
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_create(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TESTBED_PeerCreateCallback cb, void *cls)
Create the given peer at the specified host using the given controller.
Data for the OperationType OP_PEER_CREATE.
#define GNUNET_MESSAGE_TYPE_TESTBED_START_PEER
Message to start a peer at a host.
static struct GNUNET_TESTBED_Peer * peer_list_tail
Peer list DLL tail.
struct GNUNET_TESTBED_Host * host
The host where the peer has to be created.
Get peer information operation.
Definition: testbed_api.h:69
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:350
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:295
uint16_t config_size
Size of the uncompressed configuration.
Definition: testbed.h:239
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc)
Removes the given operation context from the operation context map of the given controller.
Definition: testbed_api.c:326
Data returned from GNUNET_TESTBED_peer_get_information.