GNUnet  0.11.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 
95 static void
97 {
98  struct OperationContext *opc = cls;
99  struct PeerCreateData *data = opc->data;
101  struct GNUNET_MQ_Envelope *env;
102  char *config;
103  char *xconfig;
104  size_t c_size;
105  size_t xc_size;
106 
108  GNUNET_assert (NULL != data);
109  GNUNET_assert (NULL != data->peer);
110  opc->state = OPC_STATE_STARTED;
111  config = GNUNET_CONFIGURATION_serialize (data->cfg,
112  &c_size);
113  xc_size = GNUNET_TESTBED_compress_config_ (config,
114  c_size,
115  &xconfig);
116  GNUNET_free (config);
117  env = GNUNET_MQ_msg_extra (msg,
118  xc_size,
120  msg->operation_id = GNUNET_htonll (opc->id);
121  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->peer->host));
122  msg->peer_id = htonl (data->peer->unique_id);
123  msg->config_size = htons ((uint16_t) c_size);
124  GNUNET_memcpy (&msg[1],
125  xconfig,
126  xc_size);
127  GNUNET_MQ_send (opc->c->mq,
128  env);
129  GNUNET_free (xconfig);
130  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
131 }
132 
133 
139 static void
141 {
142  struct OperationContext *opc = cls;
143 
144  switch (opc->state)
145  {
146  case OPC_STATE_STARTED:
147  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
148 
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 
155  case OPC_STATE_FINISHED:
156  break;
157  }
158  GNUNET_free (opc);
159 }
160 
161 
167 static void
169 {
170  struct OperationContext *opc = cls;
171  struct GNUNET_TESTBED_Peer *peer = opc->data;
173  struct GNUNET_MQ_Envelope *env;
174 
176  GNUNET_assert (NULL != peer);
177  opc->state = OPC_STATE_STARTED;
178  env = GNUNET_MQ_msg (msg,
180  msg->peer_id = htonl (peer->unique_id);
181  msg->operation_id = GNUNET_htonll (opc->id);
182  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
183  GNUNET_MQ_send (peer->controller->mq,
184  env);
185 }
186 
187 
193 static void
195 {
196  struct OperationContext *opc = cls;
197 
198  switch (opc->state)
199  {
200  case OPC_STATE_STARTED:
201  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
202 
203  /* no break; continue */
204  case OPC_STATE_INIT:
205  break;
206 
207  case OPC_STATE_FINISHED:
208  break;
209  }
210  GNUNET_free (opc);
211 }
212 
213 
219 static void
221 {
222  struct OperationContext *opc = cls;
224  struct GNUNET_MQ_Envelope *env;
225  struct PeerEventData *data;
226  struct GNUNET_TESTBED_Peer *peer;
227 
228  GNUNET_assert (OP_PEER_START == opc->type);
229  GNUNET_assert (NULL != (data = opc->data));
230  GNUNET_assert (NULL != (peer = data->peer));
232  peer->state));
233  opc->state = OPC_STATE_STARTED;
234  env = GNUNET_MQ_msg (msg,
236  msg->peer_id = htonl (peer->unique_id);
237  msg->operation_id = GNUNET_htonll (opc->id);
238  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
239  GNUNET_MQ_send (peer->controller->mq,
240  env);
241 }
242 
243 
249 static void
251 {
252  struct OperationContext *opc = cls;
253 
254  switch (opc->state)
255  {
256  case OPC_STATE_STARTED:
257  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
258 
259  /* no break; continue */
260  case OPC_STATE_INIT:
261  GNUNET_free (opc->data);
262  break;
263 
264  case OPC_STATE_FINISHED:
265  break;
266  }
267  GNUNET_free (opc);
268 }
269 
270 
276 static void
277 opstart_peer_stop (void *cls)
278 {
279  struct OperationContext *opc = cls;
281  struct PeerEventData *data;
282  struct GNUNET_TESTBED_Peer *peer;
283  struct GNUNET_MQ_Envelope *env;
284 
285  GNUNET_assert (NULL != (data = opc->data));
286  GNUNET_assert (NULL != (peer = data->peer));
288  opc->state = OPC_STATE_STARTED;
289  env = GNUNET_MQ_msg (msg,
291  msg->peer_id = htonl (peer->unique_id);
292  msg->operation_id = GNUNET_htonll (opc->id);
293  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
294  GNUNET_MQ_send (peer->controller->mq,
295  env);
296 }
297 
298 
304 static void
306 {
307  struct OperationContext *opc = cls;
308 
309  switch (opc->state)
310  {
311  case OPC_STATE_STARTED:
312  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
313 
314  /* no break; continue */
315  case OPC_STATE_INIT:
316  GNUNET_free (opc->data);
317  break;
318 
319  case OPC_STATE_FINISHED:
320  break;
321  }
322  GNUNET_free (opc);
323 }
324 
325 
336  uint64_t operation_id)
337 {
339 
340  msg =
341  GNUNET_malloc (sizeof
343  msg->header.size =
344  htons (sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage));
346  msg->peer_id = htonl (peer_id);
347  msg->operation_id = GNUNET_htonll (operation_id);
348  return msg;
349 }
350 
351 
357 static void
359 {
360  struct OperationContext *opc = cls;
361  struct PeerInfoData *data = opc->data;
363 
364  GNUNET_assert (NULL != data);
365  opc->state = OPC_STATE_STARTED;
366  msg =
368  opc->id);
369  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
370  GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
371 }
372 
373 
379 static void
381 {
382  struct OperationContext *opc = cls;
384 
385  switch (opc->state)
386  {
387  case OPC_STATE_STARTED:
388  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
389 
390  /* no break; continue */
391  case OPC_STATE_INIT:
392  GNUNET_free (opc->data);
393  break;
394 
395  case OPC_STATE_FINISHED:
396  data = opc->data;
397  GNUNET_assert (NULL != data);
398  switch (data->pit)
399  {
401  if (NULL != data->result.cfg)
403  break;
404 
406  GNUNET_free (data->result.id);
407  break;
408 
409  default:
410  GNUNET_assert (0); /* We should never reach here */
411  }
412  GNUNET_free (data);
413  break;
414  }
415  GNUNET_free (opc);
416 }
417 
418 
424 static void
426 {
427  struct OperationContext *opc = cls;
428  struct GNUNET_MQ_Envelope *env;
430  struct OverlayConnectData *data;
431 
432  opc->state = OPC_STATE_STARTED;
433  data = opc->data;
434  GNUNET_assert (NULL != data);
435  env = GNUNET_MQ_msg (msg,
437  msg->peer1 = htonl (data->p1->unique_id);
438  msg->peer2 = htonl (data->p2->unique_id);
439  msg->operation_id = GNUNET_htonll (opc->id);
440  msg->peer2_host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->p2->host));
442  opc);
443  GNUNET_MQ_send (opc->c->mq,
444  env);
445 }
446 
447 
453 static void
455 {
456  struct OperationContext *opc = cls;
457  struct OverlayConnectData *data;
458 
459  data = opc->data;
460  switch (opc->state)
461  {
462  case OPC_STATE_INIT:
463  break;
464 
465  case OPC_STATE_STARTED:
466  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
467  break;
468 
469  case OPC_STATE_FINISHED:
470  break;
471  }
472  GNUNET_free (data);
473  GNUNET_free (opc);
474 }
475 
476 
482 static void
484 {
485  struct OperationContext *opc = cls;
486  struct PeerReconfigureData *data = opc->data;
487  struct GNUNET_MQ_Envelope *env;
489  char *xconfig;
490  size_t xc_size;
491 
492  opc->state = OPC_STATE_STARTED;
493  GNUNET_assert (NULL != data);
494  xc_size = GNUNET_TESTBED_compress_config_ (data->config,
495  data->cfg_size,
496  &xconfig);
497  GNUNET_free (data->config);
498  data->config = NULL;
499  GNUNET_assert (xc_size < UINT16_MAX - sizeof(*msg));
500  env = GNUNET_MQ_msg_extra (msg,
501  xc_size,
503  msg->peer_id = htonl (data->peer->unique_id);
504  msg->operation_id = GNUNET_htonll (opc->id);
505  msg->config_size = htons (data->cfg_size);
506  GNUNET_memcpy (&msg[1],
507  xconfig,
508  xc_size);
509  GNUNET_free (xconfig);
510  GNUNET_free (data);
511  opc->data = NULL;
512  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
513  GNUNET_MQ_send (opc->c->mq,
514  env);
515 }
516 
517 
523 static void
525 {
526  struct OperationContext *opc = cls;
527  struct PeerReconfigureData *data = opc->data;
528 
529  switch (opc->state)
530  {
531  case OPC_STATE_INIT:
532  GNUNET_free (data->config);
533  GNUNET_free (data);
534  break;
535 
536  case OPC_STATE_STARTED:
537  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
538  break;
539 
540  case OPC_STATE_FINISHED:
541  break;
542  }
543  GNUNET_free (opc);
544 }
545 
546 
553 struct GNUNET_TESTBED_Peer *
555 {
556  GNUNET_break (0);
557  return NULL;
558 }
559 
560 
592  struct GNUNET_TESTBED_Host *host,
593  const struct GNUNET_CONFIGURATION_Handle *cfg,
594  GNUNET_TESTBED_PeerCreateCallback cb, void *cls)
595 {
596  struct GNUNET_TESTBED_Peer *peer;
597  struct PeerCreateData *data;
598  struct OperationContext *opc;
599  static uint32_t id_gen;
600 
601  peer = GNUNET_new (struct GNUNET_TESTBED_Peer);
602  peer->controller = controller;
603  peer->host = host;
604  peer->unique_id = id_gen++;
605  peer->state = TESTBED_PS_INVALID;
606  data = GNUNET_new (struct PeerCreateData);
607  data->host = host;
608  data->cfg = cfg;
609  data->cb = cb;
610  data->cls = cls;
611  data->peer = peer;
612  opc = GNUNET_new (struct OperationContext);
613  opc->c = controller;
614  opc->data = data;
615  opc->id = GNUNET_TESTBED_get_next_op_id (controller);
616  opc->type = OP_PEER_CREATE;
617  opc->op =
621  opc->op);
623  return opc->op;
624 }
625 
626 
639  GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
640 {
641  struct OperationContext *opc;
642  struct PeerEventData *data;
643 
644  data = GNUNET_new (struct PeerEventData);
645  data->peer = peer;
646  data->pcc = pcc;
647  data->pcc_cls = pcc_cls;
648  opc = GNUNET_new (struct OperationContext);
649  opc->c = peer->controller;
650  opc->data = data;
651  opc->op_cls = op_cls;
652  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
653  opc->type = OP_PEER_START;
654  opc->op =
658  opc->op);
660  return opc->op;
661 }
662 
663 
678  struct GNUNET_TESTBED_Peer *peer,
679  GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
680 {
681  struct OperationContext *opc;
682  struct PeerEventData *data;
683 
684  data = GNUNET_new (struct PeerEventData);
685  data->peer = peer;
686  data->pcc = pcc;
687  data->pcc_cls = pcc_cls;
688  opc = GNUNET_new (struct OperationContext);
689  opc->c = peer->controller;
690  opc->data = data;
691  opc->op_cls = op_cls;
692  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
693  opc->type = OP_PEER_STOP;
694  opc->op =
698  opc->op);
700  return opc->op;
701 }
702 
703 
722  void *cb_cls)
723 {
724  struct OperationContext *opc;
725  struct PeerInfoData *data;
726 
728  GNUNET_assert (NULL != cb);
729  data = GNUNET_new (struct PeerInfoData);
730  data->peer = peer;
731  data->pit = pit;
732  data->cb = cb;
733  data->cb_cls = cb_cls;
734  opc = GNUNET_new (struct OperationContext);
735  opc->c = peer->controller;
736  opc->data = data;
737  opc->type = OP_PEER_INFO;
738  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
739  opc->op =
743  opc->op);
745  return opc->op;
746 }
747 
748 
761  const struct
763 {
764  struct OperationContext *opc;
765  struct PeerReconfigureData *data;
766  size_t csize;
767 
768  data = GNUNET_new (struct PeerReconfigureData);
769  data->peer = peer;
770  data->config = GNUNET_CONFIGURATION_serialize (cfg, &csize);
771  if (NULL == data->config)
772  {
773  GNUNET_free (data);
774  return NULL;
775  }
776  if (csize > UINT16_MAX)
777  {
778  GNUNET_break (0);
779  GNUNET_free (data->config);
780  GNUNET_free (data);
781  return NULL;
782  }
783  data->cfg_size = (uint16_t) csize;
784  opc = GNUNET_new (struct OperationContext);
785  opc->c = peer->controller;
786  opc->data = data;
787  opc->type = OP_PEER_RECONFIGURE;
788  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
789  opc->op =
793  opc->op);
795  return opc->op;
796 }
797 
798 
808 {
809  struct OperationContext *opc;
810 
811  opc = GNUNET_new (struct OperationContext);
812  opc->data = peer;
813  opc->c = peer->controller;
815  opc->type = OP_PEER_DESTROY;
816  opc->op =
820  opc->op);
822  return opc->op;
823 }
824 
825 
840  struct GNUNET_TESTBED_Peer *p1,
841  struct GNUNET_TESTBED_Peer *p2,
843  ...)
844 {
845  GNUNET_break (0);
846  return NULL;
847 }
848 
849 
867  void *cb_cls, struct GNUNET_TESTBED_Peer *p1,
868  struct GNUNET_TESTBED_Peer *p2)
869 {
870  struct OperationContext *opc;
871  struct OverlayConnectData *data;
872 
874  p2->state));
875  data = GNUNET_new (struct OverlayConnectData);
876  data->p1 = p1;
877  data->p2 = p2;
878  data->cb = cb;
879  data->cb_cls = cb_cls;
880  opc = GNUNET_new (struct OperationContext);
881  opc->data = data;
882  opc->c = p1->controller;
883  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
884  opc->type = OP_OVERLAY_CONNECT;
885  opc->op_cls = op_cls;
886  opc->op =
891  return opc->op;
892 }
893 
894 
900 static void
902 {
903  struct OperationContext *opc = cls;
904  struct ManageServiceData *data = opc->data;
905  struct GNUNET_MQ_Envelope *env;
907  size_t xlen;
908 
909  GNUNET_assert (NULL != data);
910  xlen = data->msize - sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage);
911  env = GNUNET_MQ_msg_extra (msg,
912  xlen,
914  msg->peer_id = htonl (data->peer->unique_id);
915  msg->operation_id = GNUNET_htonll (opc->id);
916  msg->start = (uint8_t) data->start;
917  GNUNET_memcpy (&msg[1],
918  data->service_name,
919  xlen);
920  GNUNET_free (data->service_name);
921  data->service_name = NULL;
922  opc->state = OPC_STATE_STARTED;
923  GNUNET_TESTBED_insert_opc_ (opc->c, opc);
924  GNUNET_MQ_send (opc->c->mq,
925  env);
926 }
927 
928 
934 static void
936 {
937  struct OperationContext *opc = cls;
938  struct ManageServiceData *data;
939 
940  data = opc->data;
941  switch (opc->state)
942  {
943  case OPC_STATE_STARTED:
944  GNUNET_TESTBED_remove_opc_ (opc->c, opc);
945  break;
946 
947  case OPC_STATE_INIT:
948  GNUNET_assert (NULL != data);
949  GNUNET_free (data->service_name);
950  break;
951 
952  case OPC_STATE_FINISHED:
953  break;
954  }
955  GNUNET_free_non_null (data);
956  GNUNET_free (opc);
957 }
958 
959 
977  struct GNUNET_TESTBED_Peer *peer,
978  const char *service_name,
980  cb,
981  void *cb_cls,
982  unsigned int start)
983 {
984  struct ManageServiceData *data;
985  struct OperationContext *opc;
986  size_t msize;
987 
988  GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */
989  msize = strlen (service_name) + 1;
990  msize += sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage);
991  if (GNUNET_MAX_MESSAGE_SIZE < msize)
992  return NULL;
993  data = GNUNET_new (struct ManageServiceData);
994  data->cb = cb;
995  data->cb_cls = cb_cls;
996  data->peer = peer;
997  data->service_name = GNUNET_strdup (service_name);
998  data->start = start;
999  data->msize = (uint16_t) msize;
1000  opc = GNUNET_new (struct OperationContext);
1001  opc->data = data;
1002  opc->c = peer->controller;
1003  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
1004  opc->type = OP_MANAGE_SERVICE;
1005  opc->op_cls = op_cls;
1006  opc->op =
1010  opc->op);
1012  return opc->op;
1013 }
1014 
1015 
1016 /* 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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
void * cb_cls
The closure for the above callback.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:193
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:240
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
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:146
Message sent from client to testing service to stop a peer.
Definition: testbed.h:294
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:151
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:581
The operation has been started.
Definition: testbed_api.h:123
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:317
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:286
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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:390
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:2208
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:591
#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:250
Reconfigure a peer.
Definition: testbed_api.h:74
Message sent from client to testing service to start a peer.
Definition: testbed.h:271
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:260
struct GNUNET_PeerIdentity * id
The identity of the peer.
uint32_t peer2
Unique ID for the second peer.
Definition: testbed.h:395
#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:720
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
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:327
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:255
uint64_t id
The id of the opearation.
Definition: testbed_api.h:161
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:385
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:596
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:586
uint32_t peer2_host_id
The ID of the host which runs peer2.
Definition: testbed.h:400
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
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:166
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:219
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:204
GNUNET_TESTBED_ConnectOption
Options for peer connections.
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.
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:1335
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:117
The operation has finished.
Definition: testbed_api.h:129
#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:725
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:1757
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:375
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:244
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:715
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:705
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
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:214
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:304
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:298
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:224
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:309
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
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.
union GNUNET_TESTBED_PeerInformation::@61 result
The result of the get information operation; Choose according to the pit.
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:332
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:281
uint16_t config_size
Size of the uncompressed configuration.
Definition: testbed.h:229
#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:136
#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:319
Data returned from GNUNET_TESTBED_peer_get_information.