GNUnet  0.10.x
gnunet-service-testbed_peers.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2008--2013, 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 */
20 
21 
28 #include "gnunet-service-testbed.h"
29 #include "gnunet_arm_service.h"
30 #include <zlib.h>
31 
32 
37 
41 unsigned int GST_num_local_peers;
42 
43 
48 {
53 
58 
63 
67  struct Peer *peer;
68 
73 
77  char *service;
78 
82  uint64_t op_id;
83 
87  uint8_t start;
88 
93  uint8_t expired;
94 };
95 
96 
101 {
106 
111 
116 
121 
125  uint64_t op_id;
126 
130  uint32_t peer_id;
131 
137  uint8_t stopped;
138 };
139 
144 
149 
150 
151 
156 
161 
162 
168 static void
170 {
171  if (peer->id >= GST_peer_list_size)
172  GST_array_grow_large_enough (GST_peer_list, GST_peer_list_size, peer->id);
173  GNUNET_assert (NULL == GST_peer_list[peer->id]);
174  GST_peer_list[peer->id] = peer;
175  if (GNUNET_NO == peer->is_remote)
177 }
178 
179 
185 static void
187 {
188  unsigned int orig_size;
189  uint32_t id;
190 
191  if (GNUNET_NO == peer->is_remote)
193  GST_peer_list[peer->id] = NULL;
194  orig_size = GST_peer_list_size;
196  {
197  for (id = GST_peer_list_size - 1;
198  (id >= GST_peer_list_size - LIST_GROW_STEP) && (id != UINT32_MAX);
199  id--)
200  if (NULL != GST_peer_list[id])
201  break;
202  if (id != ((GST_peer_list_size - LIST_GROW_STEP) - 1))
203  break;
205  }
206  if (orig_size == GST_peer_list_size)
207  return;
208  GST_peer_list =
209  GNUNET_realloc (GST_peer_list,
210  sizeof (struct Peer *) * GST_peer_list_size);
211 }
212 
213 
220 static void
222 {
223  struct ForwardedOperationContext *fopc = cls;
224 
225  GNUNET_free (fopc->cls);
227 }
228 
229 
237 static void
239 {
240  struct ForwardedOperationContext *fopc = cls;
241  struct Peer *remote_peer;
242 
244  {
245  GNUNET_assert (NULL != fopc->cls);
246  remote_peer = fopc->cls;
247  peer_list_add (remote_peer);
248  }
250  msg);
251 }
252 
253 
259 void
261 {
262  GNUNET_break (0 == peer->reference_cnt);
263  if (GNUNET_YES == peer->is_remote)
264  {
265  peer_list_remove (peer);
266  GNUNET_free (peer);
267  return;
268  }
269  if (GNUNET_YES == peer->details.local.is_running)
270  {
272  peer->details.local.is_running = GNUNET_NO;
273  }
276  peer_list_remove (peer);
277  GNUNET_free (peer);
278 }
279 
280 
286 static void
288 {
289  mctx->expired = GNUNET_YES;
290  GNUNET_CONTAINER_DLL_remove (mctx_head,
291  mctx_tail,
292  mctx);
293  GNUNET_ARM_disconnect (mctx->ah);
294  GNUNET_assert (0 < mctx->peer->reference_cnt);
295  mctx->peer->reference_cnt--;
296  if ( (GNUNET_YES == mctx->peer->destroy_flag) &&
297  (0 == mctx->peer->reference_cnt) )
298  GST_destroy_peer (mctx->peer);
299  GNUNET_free (mctx->service);
300  GNUNET_free (mctx);
301 }
302 
303 
310 static int
311 stop_peer (struct Peer *peer)
312 {
313  GNUNET_assert (GNUNET_NO == peer->is_remote);
314  if (GNUNET_OK != GNUNET_TESTING_peer_kill (peer->details.local.peer))
315  return GNUNET_SYSERR;
316  peer->details.local.is_running = GNUNET_NO;
317  return GNUNET_OK;
318 }
319 
320 
326 static void
328 {
329  struct Peer *peer;
330 
331  if (VALID_PEER_ID (prc->peer_id))
332  {
333  peer = GST_peer_list [prc->peer_id];
334  if (1 != prc->stopped)
335  {
337  stop_peer (peer); /* Stop the peer synchronously */
338  }
339  }
340  if (NULL != prc->cfg)
342  GNUNET_CONTAINER_DLL_remove (prc_head,
343  prc_tail,
344  prc);
345  GNUNET_free (prc);
346 }
347 
348 
354 void
356 {
357  struct ForwardedOperationContext *fopc;
358  struct ForwardedOperationContext *fopcn;
359  struct ManageServiceContext *mctx;
360  struct ManageServiceContext *mctxn;
361  struct PeerReconfigureContext *prc;
362  struct PeerReconfigureContext *prcn;
363 
364  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
365  {
366  fopcn = fopc->next;
367  if (client == fopc->client)
368  {
369  if (OP_PEER_CREATE == fopc->type)
370  GNUNET_free (fopc->cls);
373  }
374  }
375  for (mctx = mctx_head; NULL != mctx; mctx = mctxn)
376  {
377  mctxn = mctx->next;
378  if (client == mctx->client)
379  cleanup_mctx (mctx);
380  }
381  for (prc = prc_head; NULL != prc; prc = prcn)
382  {
383  prcn = prc->next;
384  if (client == prc->client)
385  cleanup_prc (prc);
386  }
387 }
388 
389 
397 static void
399 {
400  struct ForwardedOperationContext *fopc = cls;
401  struct Peer *remote_peer;
402 
404  ntohs (msg->type))
405  {
406  remote_peer = fopc->cls;
407  GNUNET_assert (NULL != remote_peer);
408  remote_peer->destroy_flag = GNUNET_YES;
409  if (0 == remote_peer->reference_cnt)
410  GST_destroy_peer (remote_peer);
411  }
413  msg);
414 }
415 
416 
424 int
425 check_peer_create (void *cls,
427 {
428  return GNUNET_OK; /* checked later */
429 }
430 
431 
438 void
441 {
442  struct GNUNET_SERVICE_Client *client = cls;
443  struct GNUNET_MQ_Envelope *env;
446  struct ForwardedOperationContext *fo_ctxt;
447  struct Route *route;
448  struct Peer *peer;
449  char *emsg;
450  uint32_t host_id;
451  uint32_t peer_id;
452 
453  host_id = ntohl (msg->host_id);
454  peer_id = ntohl (msg->peer_id);
455  if (VALID_PEER_ID (peer_id))
456  {
457  (void) GNUNET_asprintf (&emsg,
458  "Peer with ID %u already exists",
459  peer_id);
462  emsg);
463  GNUNET_free (emsg);
465  return;
466  }
467  if (UINT32_MAX == peer_id)
468  {
471  "Cannot create peer with given ID");
473  return;
474  }
475  if (host_id == GST_context->host_id)
476  {
477  /* We are responsible for this peer */
479  if (NULL == cfg)
480  {
481  GNUNET_break (0);
483  return;
484  }
486  "TESTBED",
487  "PEERID",
488  (unsigned long long) peer_id);
489 
491  "PATHS",
492  "PEERID",
493  (unsigned long long) peer_id);
494  peer = GNUNET_new (struct Peer);
495  peer->is_remote = GNUNET_NO;
496  peer->details.local.cfg = cfg;
497  peer->id = peer_id;
498  LOG_DEBUG ("Creating peer with id: %u\n",
499  (unsigned int) peer->id);
500  peer->details.local.peer =
502  peer->details.local.cfg, peer->id,
503  NULL /* Peer id */ ,
504  &emsg);
505  if (NULL == peer->details.local.peer)
506  {
508  "Configuring peer failed: %s\n",
509  emsg);
510  GNUNET_free (emsg);
511  GNUNET_free (peer);
512  GNUNET_break (0);
514  return;
515  }
516  peer->details.local.is_running = GNUNET_NO;
517  peer_list_add (peer);
518  env = GNUNET_MQ_msg (reply,
520  reply->peer_id = msg->peer_id;
521  reply->operation_id = msg->operation_id;
523  env);
525  return;
526  }
527 
528  /* Forward peer create request */
529  route = GST_find_dest_route (host_id);
530  if (NULL == route)
531  {
532  GNUNET_break (0);
533  GNUNET_SERVICE_client_continue (client); // ?
534  return;
535  }
536  peer = GNUNET_new (struct Peer);
537  peer->is_remote = GNUNET_YES;
538  peer->id = peer_id;
539  peer->details.remote.slave = GST_slave_list[route->dest];
540  peer->details.remote.remote_host_id = host_id;
541  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
542  fo_ctxt->client = client;
543  fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
544  fo_ctxt->cls = peer;
545  fo_ctxt->type = OP_PEER_CREATE;
546  fo_ctxt->opc =
548  [route->dest]->controller,
549  fo_ctxt->operation_id,
550  &msg->header,
552  fo_ctxt);
553  fo_ctxt->timeout_task =
556  fo_ctxt);
558  fopcq_tail,
559  fo_ctxt);
561 }
562 
563 
570 void
573 {
574  struct GNUNET_SERVICE_Client *client = cls;
575  struct ForwardedOperationContext *fopc;
576  struct Peer *peer;
577  uint32_t peer_id;
578 
579  peer_id = ntohl (msg->peer_id);
580  LOG_DEBUG ("Received peer destory on peer: %u and operation id: %llu\n",
581  (unsigned int) peer_id,
582  (unsigned long long) GNUNET_ntohll (msg->operation_id));
583  if (!VALID_PEER_ID (peer_id))
584  {
586  "Asked to destroy a non existent peer with id: %u\n", peer_id);
589  "Peer doesn't exist");
591  return;
592  }
593  peer = GST_peer_list[peer_id];
594  if (GNUNET_YES == peer->is_remote)
595  {
596  /* Forward the destory message to sub controller */
597  fopc = GNUNET_new (struct ForwardedOperationContext);
598  fopc->client = client;
599  fopc->cls = peer;
600  fopc->type = OP_PEER_DESTROY;
601  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
602  fopc->opc =
604  slave->controller,
605  fopc->operation_id,
606  &msg->header,
608  fopc);
609  fopc->timeout_task =
612  fopc);
614  fopcq_tail,
615  fopc);
617  return;
618  }
619  peer->destroy_flag = GNUNET_YES;
620  if (0 == peer->reference_cnt)
621  GST_destroy_peer (peer);
622  else
624  "Delaying peer destroy as peer is currently in use\n");
626  GNUNET_ntohll (msg->operation_id));
628 }
629 
630 
637 static int
639 {
640  GNUNET_assert (GNUNET_NO == peer->is_remote);
641  if (GNUNET_OK != GNUNET_TESTING_peer_start (peer->details.local.peer))
642  return GNUNET_SYSERR;
643  peer->details.local.is_running = GNUNET_YES;
644  return GNUNET_OK;
645 }
646 
647 
654 void
655 handle_peer_start (void *cls,
656  const struct GNUNET_TESTBED_PeerStartMessage *msg)
657 {
658  struct GNUNET_SERVICE_Client *client = cls;
659  struct GNUNET_MQ_Envelope *env;
660  struct GNUNET_TESTBED_PeerEventMessage *reply;
661  struct ForwardedOperationContext *fopc;
662  struct Peer *peer;
663  uint32_t peer_id;
664 
665  peer_id = ntohl (msg->peer_id);
666  if (! VALID_PEER_ID (peer_id))
667  {
668  GNUNET_break (0);
670  "Asked to start a non existent peer with id: %u\n",
671  peer_id);
673  return;
674  }
675  peer = GST_peer_list[peer_id];
676  if (GNUNET_YES == peer->is_remote)
677  {
678  fopc = GNUNET_new (struct ForwardedOperationContext);
679  fopc->client = client;
680  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
681  fopc->type = OP_PEER_START;
682  fopc->opc =
684  slave->controller,
685  fopc->operation_id, &msg->header,
687  fopc);
688  fopc->timeout_task =
691  fopc);
693  fopcq_tail,
694  fopc);
696  return;
697  }
698  if (GNUNET_OK != start_peer (peer))
699  {
701  "Failed to start");
703  return;
704  }
705  env = GNUNET_MQ_msg (reply,
707  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_START);
708  reply->host_id = htonl (GST_context->host_id);
709  reply->peer_id = msg->peer_id;
710  reply->operation_id = msg->operation_id;
712  env);
714 }
715 
716 
723 void
724 handle_peer_stop (void *cls,
725  const struct GNUNET_TESTBED_PeerStopMessage *msg)
726 {
727  struct GNUNET_SERVICE_Client *client = cls;
728  struct GNUNET_MQ_Envelope *env;
729  struct GNUNET_TESTBED_PeerEventMessage *reply;
730  struct ForwardedOperationContext *fopc;
731  struct Peer *peer;
732  uint32_t peer_id;
733 
734  peer_id = ntohl (msg->peer_id);
736  "Received PEER_STOP for peer %u\n",
737  (unsigned int) peer_id);
738  if (! VALID_PEER_ID (peer_id))
739  {
742  "Peer not found");
744  return;
745  }
746  peer = GST_peer_list[peer_id];
747  if (GNUNET_YES == peer->is_remote)
748  {
750  "Forwarding PEER_STOP for peer %u\n",
751  (unsigned int) peer_id);
752  fopc = GNUNET_new (struct ForwardedOperationContext);
753  fopc->client = client;
754  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
755  fopc->type = OP_PEER_STOP;
756  fopc->opc =
758  slave->controller,
759  fopc->operation_id,
760  &msg->header,
762  fopc);
763  fopc->timeout_task =
766  fopc);
768  fopcq_tail,
769  fopc);
771  return;
772  }
773  if (GNUNET_OK != stop_peer (peer))
774  {
776  "Stopping peer %u failed\n",
777  (unsigned int) peer_id);
780  "Peer not running");
782  return;
783  }
785  "Peer %u successfully stopped\n",
786  (unsigned int) peer_id);
787  env = GNUNET_MQ_msg (reply,
789  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_STOP);
790  reply->host_id = htonl (GST_context->host_id);
791  reply->peer_id = msg->peer_id;
792  reply->operation_id = msg->operation_id;
794  env);
797 }
798 
799 
806 void
809 {
810  struct GNUNET_SERVICE_Client *client = cls;
811  struct GNUNET_MQ_Envelope *env;
813  struct ForwardedOperationContext *fopc;
814  struct Peer *peer;
815  char *config;
816  char *xconfig;
817  size_t c_size;
818  size_t xc_size;
819  uint32_t peer_id;
820 
821  peer_id = ntohl (msg->peer_id);
822  LOG_DEBUG ("Received GET_CONFIG for peer %u\n",
823  (unsigned int) peer_id);
824  if (!VALID_PEER_ID (peer_id))
825  {
828  "Peer not found");
830  return;
831  }
832  peer = GST_peer_list[peer_id];
833  if (GNUNET_YES == peer->is_remote)
834  {
835  LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n",
836  (unsigned int) peer_id);
837  fopc = GNUNET_new (struct ForwardedOperationContext);
838  fopc->client = client;
839  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
840  fopc->type = OP_PEER_INFO;
841  fopc->opc =
843  slave->controller,
844  fopc->operation_id,
845  &msg->header,
847  fopc);
848  fopc->timeout_task =
851  fopc);
853  fopcq_tail,
854  fopc);
856  return;
857  }
858  LOG_DEBUG ("Received PEER_GET_CONFIG for peer: %u\n",
859  peer_id);
860  config =
861  GNUNET_CONFIGURATION_serialize (GST_peer_list[peer_id]->details.local.cfg,
862  &c_size);
863  xc_size = GNUNET_TESTBED_compress_config_ (config,
864  c_size,
865  &xconfig);
866  GNUNET_free (config);
867  env = GNUNET_MQ_msg_extra (reply,
868  xc_size,
870  reply->peer_id = msg->peer_id;
871  reply->operation_id = msg->operation_id;
872  GNUNET_TESTING_peer_get_identity (GST_peer_list[peer_id]->details.local.peer,
873  &reply->peer_identity);
874  reply->config_size = htons ((uint16_t) c_size);
875  GNUNET_memcpy (&reply[1],
876  xconfig,
877  xc_size);
878  GNUNET_free (xconfig);
880  env);
882 }
883 
884 
888 void
890 {
891  while (NULL != prc_head)
892  cleanup_prc (prc_head);
893 }
894 
895 
903 static char *
906 {
907  char *emsg;
908 
911  peer->details.local.cfg = cfg;
912  emsg = NULL;
913  peer->details.local.peer
915  peer->details.local.cfg,
916  peer->id,
917  NULL /* Peer id */ ,
918  &emsg);
919  return emsg;
920 }
921 
922 
931 static void
932 prc_stop_cb (void *cls,
933  struct GNUNET_TESTING_Peer *p,
934  int success)
935 {
936  struct PeerReconfigureContext *prc = cls;
937  struct Peer *peer;
938  char *emsg;
939 
941  peer = GST_peer_list [prc->peer_id];
942  GNUNET_assert (GNUNET_NO == peer->is_remote);
943  emsg = update_peer_config (peer, prc->cfg);
944  prc->cfg = NULL;
945  prc->stopped = 1;
946  if (NULL != emsg)
947  {
949  prc->op_id,
950  emsg);
951  goto cleanup;
952  }
953  if (GNUNET_OK != start_peer (peer))
954  {
956  prc->op_id,
957  "Failed to start reconfigured peer");
958  goto cleanup;
959  }
961  prc->op_id);
962 
963  cleanup:
964  cleanup_prc (prc);
965  return;
966 }
967 
968 
976 int
979 {
980  return GNUNET_OK; /* checked later */
981 }
982 
983 
992 void
995 {
996  struct GNUNET_SERVICE_Client *client = cls;
997  struct Peer *peer;
999  struct ForwardedOperationContext *fopc;
1000  struct PeerReconfigureContext *prc;
1001  char *emsg;
1002  uint64_t op_id;
1003  uint32_t peer_id;
1004 
1005  peer_id = ntohl (msg->peer_id);
1006  op_id = GNUNET_ntohll (msg->operation_id);
1007  if (! VALID_PEER_ID (peer_id))
1008  {
1009  GNUNET_break (0);
1011  op_id,
1012  "Peer not found");
1014  return;
1015  }
1016  peer = GST_peer_list[peer_id];
1017  if (GNUNET_YES == peer->is_remote)
1018  {
1019  LOG_DEBUG ("Forwarding PEER_RECONFIGURE for peer: %u\n", peer_id);
1020  fopc = GNUNET_new (struct ForwardedOperationContext);
1021  fopc->client = client;
1022  fopc->operation_id = op_id;
1023  fopc->type = OP_PEER_RECONFIGURE;
1024  fopc->opc =
1026  slave->controller,
1027  fopc->operation_id,
1028  &msg->header,
1030  fopc);
1031  fopc->timeout_task =
1034  fopc);
1036  fopcq_tail,
1037  fopc);
1039  return;
1040  }
1041  LOG_DEBUG ("Received PEER_RECONFIGURE for peer %u\n",
1042  (unsigned int) peer_id);
1043  if (0 < peer->reference_cnt)
1044  {
1045  GNUNET_break (0);
1047  op_id,
1048  "Peer in use");
1050  return;
1051  }
1052  if (GNUNET_YES == peer->destroy_flag)
1053  {
1054  GNUNET_break (0);
1056  op_id,
1057  "Peer is being destroyed");
1059  return;
1060  }
1061  cfg = GNUNET_TESTBED_extract_config_ (&msg->header);
1062  if (NULL == cfg)
1063  {
1064  GNUNET_break (0);
1066  op_id,
1067  "Compression error");
1069  return;
1070  }
1071  if (GNUNET_NO == peer->details.local.is_running)
1072  {
1073  emsg = update_peer_config (peer,
1074  cfg);
1075  if (NULL != emsg)
1077  op_id,
1078  emsg);
1080  op_id);
1082  GNUNET_free_non_null (emsg);
1083  return;
1084  }
1085  prc = GNUNET_new (struct PeerReconfigureContext);
1086  if (GNUNET_OK !=
1088  &prc_stop_cb,
1089  prc))
1090  {
1091  GNUNET_assert (0 < GNUNET_asprintf (&emsg,
1092  "Error trying to stop peer %u asynchronously\n",
1093  peer_id));
1095  "%s\n",
1096  emsg);
1098  op_id,
1099  emsg);
1101  GNUNET_free (prc);
1102  GNUNET_free (emsg);
1103  return;
1104  }
1105  prc->cfg = cfg;
1106  prc->peer_id = peer_id;
1107  prc->op_id = op_id;
1108  prc->client = client;
1110  prc_tail,
1111  prc);
1113 }
1114 
1115 
1119 void
1121 {
1122  while (NULL != mctx_head)
1123  cleanup_mctx (mctx_head);
1124 }
1125 
1126 
1133 static const char *
1135 {
1136  switch (rs)
1137  {
1139  return _("Message was sent successfully");
1141  return _("We disconnected from ARM before we could send a request");
1142  }
1143  return _("Unknown request status");
1144 }
1145 
1146 
1153 static const char *
1155 {
1156  switch (result)
1157  {
1159  return _("%s is stopped");
1161  return _("%s is starting");
1163  return _("%s is stopping");
1165  return _("%s is starting already");
1167  return _("%s is stopping already");
1169  return _("%s is started already");
1171  return _("%s is stopped already");
1173  return _("%s service is not known to ARM");
1175  return _("%s service failed to start");
1177  return _("%s service can't be started because ARM is shutting down");
1178  }
1179  return _("%.s Unknown result code.");
1180 }
1181 
1182 
1193 static void
1195  enum GNUNET_ARM_RequestStatus rs,
1197 {
1198  struct ManageServiceContext *mctx = cls;
1199  char *emsg;
1200 
1201  emsg = NULL;
1202  if (GNUNET_YES == mctx->expired)
1203  return;
1204  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
1205  {
1206  GNUNET_asprintf (&emsg,
1207  "Error communicating with Peer %u's ARM: %s",
1208  mctx->peer->id,
1209  arm_req_string (rs));
1210  goto ret;
1211  }
1212  if (1 == mctx->start)
1213  goto service_start_check;
1214  if (! ((GNUNET_ARM_RESULT_STOPPED == result)
1215  || (GNUNET_ARM_RESULT_STOPPING == result)
1217  || (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY == result)) )
1218  {
1219  /* stopping a service failed */
1220  GNUNET_asprintf (&emsg,
1221  arm_ret_string (result),
1222  mctx->service);
1223  goto ret;
1224  }
1225  /* service stopped successfully */
1226  goto ret;
1227 
1228  service_start_check:
1229  if (! ((GNUNET_ARM_RESULT_STARTING == result)
1231  || (GNUNET_ARM_RESULT_IS_STARTED_ALREADY == result)) )
1232  {
1233  /* starting a service failed */
1234  GNUNET_asprintf (&emsg,
1235  arm_ret_string (result),
1236  mctx->service);
1237  goto ret;
1238  }
1239  /* service started successfully */
1240 
1241  ret:
1242  if (NULL != emsg)
1243  {
1244  LOG_DEBUG ("%s\n", emsg);
1246  mctx->op_id,
1247  emsg);
1248  }
1249  else
1251  mctx->op_id);
1252  GNUNET_free_non_null (emsg);
1253  cleanup_mctx (mctx);
1254 }
1255 
1256 
1264 int
1267 {
1268  uint16_t msize;
1269  const char* service;
1270 
1271  msize = ntohs (msg->header.size);
1272  service = (const char *) &msg[1];
1273  if ('\0' != service[msize - sizeof
1275  {
1276  GNUNET_break_op (0);
1277  return GNUNET_SYSERR;
1278  }
1279  if (1 < msg->start)
1280  {
1281  GNUNET_break_op (0);
1282  return GNUNET_SYSERR;
1283  }
1284  return GNUNET_OK;
1285 }
1286 
1287 
1294 void
1297 {
1298  struct GNUNET_SERVICE_Client *client = cls;
1299  const char* service;
1300  struct Peer *peer;
1301  char *emsg;
1302  struct GNUNET_ARM_Handle *ah;
1303  struct ManageServiceContext *mctx;
1304  struct ForwardedOperationContext *fopc;
1305  uint64_t op_id;
1306  uint32_t peer_id;
1307 
1308  service = (const char *) &msg[1];
1309  peer_id = ntohl (msg->peer_id);
1310  op_id = GNUNET_ntohll (msg->operation_id);
1311  LOG_DEBUG ("Received request to manage service %s on peer %u\n",
1312  service, (unsigned int) peer_id);
1313  if ((GST_peer_list_size <= peer_id)
1314  || (NULL == (peer = GST_peer_list[peer_id])))
1315  {
1316  GNUNET_asprintf (&emsg, "Asked to manage service of a non existent peer "
1317  "with id: %u", peer_id);
1318  goto err_ret;
1319  }
1320  if (0 == strcasecmp ("arm", service))
1321  {
1322  emsg = GNUNET_strdup ("Cannot start/stop peer's ARM service. "
1323  "Use peer start/stop for that");
1324  goto err_ret;
1325  }
1326  if (GNUNET_YES == peer->is_remote)
1327  {
1328  /* Forward the destory message to sub controller */
1329  fopc = GNUNET_new (struct ForwardedOperationContext);
1330  fopc->client = client;
1331  fopc->cls = peer;
1332  fopc->type = OP_MANAGE_SERVICE;
1333  fopc->operation_id = op_id;
1334  fopc->opc =
1336  slave->controller,
1337  fopc->operation_id,
1338  &msg->header,
1340  fopc);
1341  fopc->timeout_task =
1344  fopc);
1346  fopcq_tail,
1347  fopc);
1349  return;
1350  }
1351  if (GNUNET_NO == peer->details.local.is_running)
1352  {
1353  emsg = GNUNET_strdup ("Peer not running\n");
1354  goto err_ret;
1355  }
1356  if ((0 != peer->reference_cnt)
1357  && ( (0 == strcasecmp ("core", service))
1358  || (0 == strcasecmp ("transport", service)) ) )
1359  {
1360  GNUNET_asprintf (&emsg, "Cannot stop %s service of peer with id: %u "
1361  "since it is required by existing operations",
1362  service, peer_id);
1363  goto err_ret;
1364  }
1365  ah = GNUNET_ARM_connect (peer->details.local.cfg, NULL, NULL);
1366  if (NULL == ah)
1367  {
1368  GNUNET_asprintf (&emsg,
1369  "Cannot connect to ARM service of peer with id: %u",
1370  peer_id);
1371  goto err_ret;
1372  }
1373  mctx = GNUNET_new (struct ManageServiceContext);
1374  mctx->peer = peer;
1375  peer->reference_cnt++;
1376  mctx->op_id = op_id;
1377  mctx->ah = ah;
1378  mctx->client = client;
1379  mctx->start = msg->start;
1380  mctx->service = GNUNET_strdup (service);
1382  mctx_tail,
1383  mctx);
1384  if (1 == mctx->start)
1386  service,
1389  mctx);
1390  else
1391  GNUNET_ARM_request_service_stop (mctx->ah, service,
1393  mctx);
1395  return;
1396 
1397  err_ret:
1398  LOG (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1399  GST_send_operation_fail_msg (client, op_id, emsg);
1400  GNUNET_free (emsg);
1402 }
1403 
1404 
1408 void
1410 {
1411  struct Peer *peer;
1412  unsigned int id;
1413 
1414  if (NULL == GST_peer_list)
1415  return;
1416  for (id = 0; id < GST_peer_list_size; id++)
1417  {
1418  peer = GST_peer_list[id];
1419  if (NULL == peer)
1420  continue;
1421  /* If destroy flag is set it means that this peer should have been
1422  * destroyed by a context which we destroy before */
1423  GNUNET_break (GNUNET_NO == peer->destroy_flag);
1424  /* counter should be zero as we free all contexts before */
1425  GNUNET_break (0 == peer->reference_cnt);
1426  if ((GNUNET_NO == peer->is_remote) &&
1427  (GNUNET_YES == peer->details.local.is_running))
1428  GNUNET_TESTING_peer_kill (peer->details.local.peer);
1429  }
1430  for (id = 0; id < GST_peer_list_size; id++)
1431  {
1432  peer = GST_peer_list[id];
1433  if (NULL == peer)
1434  continue;
1435  if (GNUNET_NO == peer->is_remote)
1436  {
1437  if (GNUNET_YES == peer->details.local.is_running)
1438  GNUNET_TESTING_peer_wait (peer->details.local.peer);
1441  }
1442  GNUNET_free (peer);
1443  }
1444  GNUNET_free_non_null (GST_peer_list);
1445  GST_peer_list = NULL;
1446  GST_peer_list_size = 0;
1447 }
1448 
1449 
1458 static void
1460  const struct GNUNET_MessageHeader *msg)
1461 {
1462  struct ForwardedOperationContext *fo_ctxt = cls;
1463  struct HandlerContext_ShutdownPeers *hc;
1464 
1465  hc = fo_ctxt->cls;
1466  GNUNET_assert (0 < hc->nslaves);
1467  hc->nslaves--;
1469  ntohs (msg->type))
1470  hc->timeout = GNUNET_YES;
1471  if (0 == hc->nslaves)
1472  {
1473  if (GNUNET_YES == hc->timeout)
1475  fo_ctxt->operation_id,
1476  "Timeout at a slave controller");
1477  else
1479  fo_ctxt->operation_id);
1480  GNUNET_free (hc);
1481  hc = NULL;
1482  }
1484  fopcq_tail,
1485  fo_ctxt);
1486  GNUNET_free (fo_ctxt);
1487 }
1488 
1489 
1496 void
1499 {
1500  struct GNUNET_SERVICE_Client *client = cls;
1501  struct HandlerContext_ShutdownPeers *hc;
1502  struct Slave *slave;
1503  struct ForwardedOperationContext *fo_ctxt;
1504  uint64_t op_id;
1505  unsigned int cnt;
1506 
1507  LOG_DEBUG ("Received SHUTDOWN_PEERS\n");
1508  /* Stop and destroy all peers */
1509  GST_free_mctxq ();
1510  GST_free_occq ();
1511  GST_free_roccq ();
1512  GST_clear_fopcq ();
1513  /* Forward to all slaves which we have started */
1514  op_id = GNUNET_ntohll (msg->operation_id);
1516  /* FIXME: have a better implementation where we track which slaves are
1517  started by this controller */
1518  for (cnt = 0; cnt < GST_slave_list_size; cnt++)
1519  {
1520  slave = GST_slave_list[cnt];
1521  if (NULL == slave)
1522  continue;
1523  if (NULL == slave->controller_proc) /* We didn't start the slave */
1524  continue;
1525  LOG_DEBUG ("Forwarding SHUTDOWN_PEERS\n");
1526  hc->nslaves++;
1527  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
1528  fo_ctxt->client = client;
1529  fo_ctxt->operation_id = op_id;
1530  fo_ctxt->cls = hc;
1531  fo_ctxt->type = OP_SHUTDOWN_PEERS;
1532  fo_ctxt->opc =
1534  fo_ctxt->operation_id,
1535  &msg->header,
1537  fo_ctxt);
1539  fopcq_tail,
1540  fo_ctxt);
1541  }
1542  LOG_DEBUG ("Shutting down peers\n");
1543  GST_destroy_peers ();
1544  if (0 == hc->nslaves)
1545  {
1547  op_id);
1548  GNUNET_free (hc);
1549  }
1551 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void handle_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
void GST_free_mctxq()
Frees the ManageServiceContext queue.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:493
Event notification from a controller to a client.
Definition: testbed.h:563
ARM stopping was initiated (there&#39;s no "stopped" for ARM itself).
int is_remote
Is this peer locally created?
int GNUNET_TESTING_peer_stop_async(struct GNUNET_TESTING_Peer *peer, GNUNET_TESTING_PeerStopCallback cb, void *cb_cls)
Stop a peer asynchronously using ARM API.
Definition: testing.c:1470
uint32_t peer_id
The id of the peer relevant to this information.
Definition: testbed.h:650
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:92
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct Peer::@69::@71 remote
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER.
Definition: testbed.h:257
int check_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.
Asked to stop it, but it&#39;s already stopping.
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:251
int timeout
Did we observe a timeout with respect to this operation at any of the slaves.
data structures shared amongst components of TESTBED service
Message sent from client to testing service to stop a peer.
Definition: testbed.h:309
void GST_clear_fopcq()
Clears the forwarded operations queue.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1315
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer, we delay the peer destroy to a further time.
Handle for a GNUnet peer controlled by testing.
Definition: testing.c:175
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:615
static void service_manage_result_cb(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
Function called in response to a start/stop request.
static int stop_peer(struct Peer *peer)
Stops a peer.
Shutdown peers message.
Definition: testbed.h:728
Message sent from client to testing service to destroy a (stopped) peer.
Definition: testbed.h:334
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:733
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:300
#define LOG(kind,...)
Definition: arm_api.c:33
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER.
Definition: testbed.h:219
struct ManageServiceContext * next
DLL next ptr.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
static void peer_list_add(struct Peer *peer)
Adds a peer to the peer array.
unsigned int GST_num_local_peers
The current number of peers running locally under this controller.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:639
struct OperationContext * opc
The generated operation context.
We disconnected from ARM, and request was not sent.
Event notification from a controller to a client.
Definition: testbed.h:466
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
Stop and destroy all peers.
Definition: testbed_api.h:99
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
unsigned int GST_peer_list_size
The size of the peer list.
Handle for interacting with ARM.
Definition: arm_api.c:97
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
Context information for peer re-configure operations.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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.
GNUNET_ARM_Result
Replies to ARM requests.
Structure representing a connected(directly-linked) controller.
uint32_t peer_id
Peer identity of the peer that was created.
Definition: testbed.h:574
Context information to manage peers&#39; services.
Asked to start it, but it&#39;s already started.
static void cleanup_prc(struct PeerReconfigureContext *prc)
Cleans up the given PeerReconfigureContext.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:655
uint64_t operation_id
Operation ID.
Definition: testbed.h:738
static int ret
Final status code.
Definition: gnunet-arm.c:89
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
Definition: arm_api.c:507
uint8_t start
1 if the service at the peer has to be started; 0 if it has to be stopped
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
Generates configuration by uncompressing configuration in given message.
Definition: testbed_api.c:2068
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1418
static void peer_create_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer create operation is successfull.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void peer_create_forward_timeout(void *cls)
The task to be executed if the forwarded peer create operation has been timed out.
#define GST_array_grow_large_enough(ptr, size, accommodate_size)
Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call ...
void GST_forwarded_operation_reply_relay(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to relay the reply msg of a forwarded operation back to the client.
uint32_t peer_id
The id of the peer which has to be reconfigured.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:262
Reconfigure a peer.
Definition: testbed_api.h:74
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:1134
uint32_t peer_id
Peer that was started or stopped.
Definition: testbed.h:488
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Message sent from client to testing service to start a peer.
Definition: testbed.h:284
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_ARM_Handle * ah
The ARM handle of the peer.
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:665
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:478
struct Peer * peer
peer whose service has to be managed
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer&#39;s main process.
Definition: testing.c:1363
void GST_destroy_peers()
Stops and destroys all peers.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#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
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
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
struct Peer::@69::@70 local
struct Slave * slave
The slave this peer is started through.
Tried to start a service, but that failed for some reason.
#define GNUNET_memcpy(dst, src, n)
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:345
uint32_t host_id
Our host id according to this context.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
uint32_t host_id
Host where the peer is running.
Definition: testbed.h:483
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:267
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request a service to be stopped.
Definition: arm_api.c:864
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
Service starting was initiated.
void handle_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE messages.
uint64_t op_id
The id of the operation.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:631
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
Message for peer events.
struct PeerReconfigureContext * prev
DLL prev.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:621
enum OperationType type
The type of the operation which is forwarded.
void handle_shutdown_peers(void *cls, const struct GNUNET_TESTBED_ShutdownPeersMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages.
Peer destroy operation.
Definition: testbed_api.h:64
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void handle_peer_get_config(void *cls, const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION messages.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
static const struct GNUNET_CONFIGURATION_Handle * config
A routing entry.
Asked to start it, but it&#39;s already starting.
char * service
Name of the service.
static int result
Global testing status.
Peer start operation.
Definition: testbed_api.h:54
struct ManageServiceContext * prev
DLL prev ptr.
static void peer_list_remove(struct Peer *peer)
Removes a the give peer from the peer array.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer&#39;s information.
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
Definition: arm_api.c:482
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:660
void handle_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
struct Route * GST_find_dest_route(uint32_t host_id)
Finds the route with directly connected host as destination through which the destination host can be...
struct Peer ** GST_peer_list
A list of peers we know about.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
uint64_t operation_id
Unique operation id.
Definition: testbed.h:229
void * cls
Closure pointer.
Message sent from client to testing service to create (configure, but not start) a peer...
Definition: testbed.h:213
static struct PeerReconfigureContext * prc_tail
The DLL tail for the peer reconfigure list.
#define LIST_GROW_STEP
By how much should the arrays lists grow.
Asked to start something, but ARM is shutting down and can&#39;t comply.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint64_t op_id
The operation id of the associated request.
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_start(struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request for a service to be started.
Definition: arm_api.c:789
static char * update_peer_config(struct Peer *peer, struct GNUNET_CONFIGURATION_Handle *cfg)
Update peer configuration.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
void handle_peer_destroy(void *cls, const struct GNUNET_TESTBED_PeerDestroyMessage *msg)
Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.
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.
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:579
struct OperationContext * GNUNET_TESTBED_forward_operation_msg_(struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls)
Sends the given message as an operation.
Definition: testbed_api.c:1368
static void prc_stop_cb(void *cls, struct GNUNET_TESTING_Peer *p, int success)
Callback to inform whether the peer is running or stopped.
static const char * arm_ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
struct GNUNET_SERVICE_Client * client
The client which gave this operation to us.
Asked to stop it, but it&#39;s already stopped.
int check_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
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
Message was sent successfully.
void GNUNET_TESTING_peer_stop_async_cancel(struct GNUNET_TESTING_Peer *peer)
Cancel a previous asynchronous peer stop request.
Definition: testing.c:1495
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
Start/stop service at a peer.
Definition: testbed_api.h:104
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_START_PEER.
Definition: testbed.h:290
GNUNET_ARM_RequestStatus
Statuses of the requests that client can send to ARM.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER.
Definition: testbed.h:315
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
void GST_free_prcq()
Cleans up the Peer reconfigure context list.
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
uint32_t peer_id
Unique ID of the peer whose service has to be managed.
Definition: testbed.h:755
struct GNUNET_SERVICE_Client * client
The client which requested to manage the peer&#39;s service.
union Peer::@69 details
configuration data
Definition: configuration.c:85
void handle_peer_stop(void *cls, const struct GNUNET_TESTBED_PeerStopMessage *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER messages.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct Context * GST_context
The master context; generated with the first INIT message.
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
Message to start/stop services of a peer.
Definition: testbed.h:745
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER.
Definition: testbed.h:340
static int start_peer(struct Peer *peer)
Stats a peer.
uint32_t host_id
On which host should the peer be started?
Definition: testbed.h:224
uint8_t stopped
The the peer stopped? Used while cleaning up this context to decide whether the asynchronous stop req...
Peer create operation.
Definition: testbed_api.h:49
struct ForwardedOperationContext * next
The next pointer for DLL.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle to use as the new template.
void handle_peer_start(void *cls, const struct GNUNET_TESTBED_PeerStartMessage *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_START_PEER messages.
Asked to start or stop a service, but it&#39;s not known.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
uint64_t operation_id
The id of the operation that has been forwarded.
static void peer_destroy_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer destroy operation is successfull.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:320
Header for all communications.
struct PeerReconfigureContext * next
DLL next for inclusoin in peer reconfigure operations list.
#define GNUNET_YES
Definition: gnunet_common.h:80
static const char * arm_req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
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
void GST_notify_client_disconnect_peers(struct GNUNET_SERVICE_Client *client)
Notify peers subsystem that client disconnected.
void GST_send_operation_success_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id)
Function to send generic operation success message to given client.
#define LOG_DEBUG(msg)
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:750
void GST_free_occq(void)
Clears all pending overlay connect contexts in queue.
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:234
A peer has been stopped.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:325
Service was stopped (never sent for ARM itself).
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1511
int check_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
Context information for operations forwarded to subcontrollers.
static struct ManageServiceContext * mctx_tail
DLL tail for queue of manage service requests.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint32_t dest
destination host
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
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
uint8_t expired
Is this context expired? Do not work on this context if it is set to GNUNET_YES.
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
Definition: testing.c:1395
static void cleanup_mctx(struct ManageServiceContext *mctx)
Cleanup the context information created for managing a peer&#39;s service.
static void shutdown_peers_reply_cb(void *cls, const struct GNUNET_MessageHeader *msg)
The reply msg handler forwarded SHUTDOWN_PEERS operation.
void GST_free_roccq(void)
Clears all pending remote overlay connect contexts in queue.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965