GNUnet  0.19.4
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 "platform.h"
29 #include "gnunet-service-testbed.h"
30 #include "gnunet_arm_service.h"
31 #include <zlib.h>
32 
33 
38 
42 unsigned int GST_num_local_peers;
43 
44 
49 {
54 
59 
64 
68  struct Peer *peer;
69 
74 
78  char *service;
79 
83  uint64_t op_id;
84 
88  uint8_t start;
89 
94  uint8_t expired;
95 };
96 
97 
102 {
107 
112 
117 
122 
126  uint64_t op_id;
127 
131  uint32_t peer_id;
132 
138  uint8_t stopped;
139 };
140 
145 
150 
151 
156 
161 
162 
168 static void
170 {
171  if (peer->id >= GST_peer_list_size)
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 =
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  {
266  GNUNET_free (peer);
267  return;
268  }
269  if (GNUNET_YES == peer->details.local.is_running)
270  {
271  GNUNET_TESTING_peer_stop (peer->details.local.peer);
272  peer->details.local.is_running = GNUNET_NO;
273  }
274  GNUNET_TESTING_peer_destroy (peer->details.local.peer);
275  GNUNET_CONFIGURATION_destroy (peer->details.local.cfg);
277  GNUNET_free (peer);
278 }
279 
280 
286 static void
288 {
289  mctx->expired = GNUNET_YES;
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  {
336  GNUNET_TESTING_peer_stop_async_cancel (peer->details.local.peer);
337  stop_peer (peer); /* Stop the peer synchronously */
338  }
339  }
340  if (NULL != prc->cfg)
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 
432 void
435 {
436  struct GNUNET_SERVICE_Client *client = cls;
437  struct GNUNET_MQ_Envelope *env;
440  struct ForwardedOperationContext *fo_ctxt;
441  struct Route *route;
442  struct Peer *peer;
443  char *emsg;
444  uint32_t host_id;
445  uint32_t peer_id;
446 
447  host_id = ntohl (msg->host_id);
448  peer_id = ntohl (msg->peer_id);
449  if (VALID_PEER_ID (peer_id))
450  {
451  (void) GNUNET_asprintf (&emsg,
452  "Peer with ID %u already exists",
453  peer_id);
455  GNUNET_ntohll (msg->operation_id),
456  emsg);
457  GNUNET_free (emsg);
459  return;
460  }
461  if (UINT32_MAX == peer_id)
462  {
464  GNUNET_ntohll (msg->operation_id),
465  "Cannot create peer with given ID");
467  return;
468  }
469  if (host_id == GST_context->host_id)
470  {
471  /* We are responsible for this peer */
473  if (NULL == cfg)
474  {
475  GNUNET_break (0);
477  return;
478  }
480  "TESTBED",
481  "PEERID",
482  (unsigned long long) peer_id);
483 
485  "PATHS",
486  "PEERID",
487  (unsigned long long) peer_id);
488  peer = GNUNET_new (struct Peer);
489  peer->is_remote = GNUNET_NO;
490  peer->details.local.cfg = cfg;
491  peer->id = peer_id;
492  LOG_DEBUG ("Creating peer with id: %u\n",
493  (unsigned int) peer->id);
494  peer->details.local.peer =
496  peer->details.local.cfg, peer->id,
497  NULL /* Peer id */,
498  &emsg);
499  if (NULL == peer->details.local.peer)
500  {
502  "Configuring peer failed: %s\n",
503  emsg);
504  GNUNET_free (emsg);
505  GNUNET_free (peer);
506  GNUNET_break (0);
508  return;
509  }
510  peer->details.local.is_running = GNUNET_NO;
512  env = GNUNET_MQ_msg (reply,
514  reply->peer_id = msg->peer_id;
515  reply->operation_id = msg->operation_id;
517  env);
519  return;
520  }
521 
522  /* Forward peer create request */
523  route = GST_find_dest_route (host_id);
524  if (NULL == route)
525  {
526  GNUNET_break (0);
527  GNUNET_SERVICE_client_continue (client); // ?
528  return;
529  }
530  peer = GNUNET_new (struct Peer);
531  peer->is_remote = GNUNET_YES;
532  peer->id = peer_id;
533  peer->details.remote.slave = GST_slave_list[route->dest];
534  peer->details.remote.remote_host_id = host_id;
535  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
536  fo_ctxt->client = client;
537  fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
538  fo_ctxt->cls = peer;
539  fo_ctxt->type = OP_PEER_CREATE;
540  fo_ctxt->opc =
542  [route->dest]->controller,
543  fo_ctxt->operation_id,
544  &msg->header,
546  fo_ctxt);
547  fo_ctxt->timeout_task =
550  fo_ctxt);
552  fopcq_tail,
553  fo_ctxt);
555 }
556 
557 
564 void
567 {
568  struct GNUNET_SERVICE_Client *client = cls;
569  struct ForwardedOperationContext *fopc;
570  struct Peer *peer;
571  uint32_t peer_id;
572 
573  peer_id = ntohl (msg->peer_id);
574  LOG_DEBUG ("Received peer destroy on peer: %u and operation id: %llu\n",
575  (unsigned int) peer_id,
576  (unsigned long long) GNUNET_ntohll (msg->operation_id));
577  if (! VALID_PEER_ID (peer_id))
578  {
580  "Asked to destroy a non existent peer with id: %u\n", peer_id);
582  GNUNET_ntohll (msg->operation_id),
583  "Peer doesn't exist");
585  return;
586  }
588  if (GNUNET_YES == peer->is_remote)
589  {
590  /* Forward the destroy message to sub controller */
591  fopc = GNUNET_new (struct ForwardedOperationContext);
592  fopc->client = client;
593  fopc->cls = peer;
594  fopc->type = OP_PEER_DESTROY;
595  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
596  fopc->opc =
598  slave->controller,
599  fopc->operation_id,
600  &msg->header,
602  fopc);
603  fopc->timeout_task =
606  fopc);
608  fopcq_tail,
609  fopc);
611  return;
612  }
613  peer->destroy_flag = GNUNET_YES;
614  if (0 == peer->reference_cnt)
616  else
618  "Delaying peer destroy as peer is currently in use\n");
620  GNUNET_ntohll (msg->operation_id));
622 }
623 
624 
631 static int
633 {
634  GNUNET_assert (GNUNET_NO == peer->is_remote);
635  if (GNUNET_OK != GNUNET_TESTING_peer_start (peer->details.local.peer))
636  return GNUNET_SYSERR;
637  peer->details.local.is_running = GNUNET_YES;
638  return GNUNET_OK;
639 }
640 
641 
642 void
643 handle_peer_start (void *cls,
644  const struct GNUNET_TESTBED_PeerStartMessage *msg)
645 {
646  struct GNUNET_SERVICE_Client *client = cls;
647  struct GNUNET_MQ_Envelope *env;
648  struct GNUNET_TESTBED_PeerEventMessage *reply;
649  struct ForwardedOperationContext *fopc;
650  struct Peer *peer;
651  uint32_t peer_id;
652 
653  peer_id = ntohl (msg->peer_id);
654  if (! VALID_PEER_ID (peer_id))
655  {
656  GNUNET_break (0);
658  "Asked to start a non existent peer with id: %u\n",
659  peer_id);
661  return;
662  }
664  if (GNUNET_YES == peer->is_remote)
665  {
666  fopc = GNUNET_new (struct ForwardedOperationContext);
667  fopc->client = client;
668  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
669  fopc->type = OP_PEER_START;
670  fopc->opc =
672  slave->controller,
673  fopc->operation_id, &msg->header,
674  &
676  fopc);
677  fopc->timeout_task =
680  fopc);
682  fopcq_tail,
683  fopc);
685  return;
686  }
687  if (GNUNET_OK != start_peer (peer))
688  {
689  GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
690  "Failed to start");
692  return;
693  }
694  env = GNUNET_MQ_msg (reply,
696  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_START);
697  reply->host_id = htonl (GST_context->host_id);
698  reply->peer_id = msg->peer_id;
699  reply->operation_id = msg->operation_id;
701  env);
703 }
704 
705 
712 void
713 handle_peer_stop (void *cls,
714  const struct GNUNET_TESTBED_PeerStopMessage *msg)
715 {
716  struct GNUNET_SERVICE_Client *client = cls;
717  struct GNUNET_MQ_Envelope *env;
718  struct GNUNET_TESTBED_PeerEventMessage *reply;
719  struct ForwardedOperationContext *fopc;
720  struct Peer *peer;
721  uint32_t peer_id;
722 
723  peer_id = ntohl (msg->peer_id);
725  "Received PEER_STOP for peer %u\n",
726  (unsigned int) peer_id);
727  if (! VALID_PEER_ID (peer_id))
728  {
730  GNUNET_ntohll (msg->operation_id),
731  "Peer not found");
733  return;
734  }
736  if (GNUNET_YES == peer->is_remote)
737  {
739  "Forwarding PEER_STOP for peer %u\n",
740  (unsigned int) peer_id);
741  fopc = GNUNET_new (struct ForwardedOperationContext);
742  fopc->client = client;
743  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
744  fopc->type = OP_PEER_STOP;
745  fopc->opc =
747  slave->controller,
748  fopc->operation_id,
749  &msg->header,
750  &
752  fopc);
753  fopc->timeout_task =
756  fopc);
758  fopcq_tail,
759  fopc);
761  return;
762  }
763  if (GNUNET_OK != stop_peer (peer))
764  {
766  "Stopping peer %u failed\n",
767  (unsigned int) peer_id);
769  GNUNET_ntohll (msg->operation_id),
770  "Peer not running");
772  return;
773  }
775  "Peer %u successfully stopped\n",
776  (unsigned int) peer_id);
777  env = GNUNET_MQ_msg (reply,
779  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_STOP);
780  reply->host_id = htonl (GST_context->host_id);
781  reply->peer_id = msg->peer_id;
782  reply->operation_id = msg->operation_id;
784  env);
786  GNUNET_TESTING_peer_wait (peer->details.local.peer);
787 }
788 
789 
796 void
798  const struct
800 {
801  struct GNUNET_SERVICE_Client *client = cls;
802  struct GNUNET_MQ_Envelope *env;
804  struct ForwardedOperationContext *fopc;
805  struct Peer *peer;
806  char *config;
807  char *xconfig;
808  size_t c_size;
809  size_t xc_size;
810  uint32_t peer_id;
811 
812  peer_id = ntohl (msg->peer_id);
813  LOG_DEBUG ("Received GET_CONFIG for peer %u\n",
814  (unsigned int) peer_id);
815  if (! VALID_PEER_ID (peer_id))
816  {
818  GNUNET_ntohll (msg->operation_id),
819  "Peer not found");
821  return;
822  }
824  if (GNUNET_YES == peer->is_remote)
825  {
826  LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n",
827  (unsigned int) peer_id);
828  fopc = GNUNET_new (struct ForwardedOperationContext);
829  fopc->client = client;
830  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
831  fopc->type = OP_PEER_INFO;
832  fopc->opc =
834  slave->controller,
835  fopc->operation_id,
836  &msg->header,
837  &
839  fopc);
840  fopc->timeout_task =
843  fopc);
845  fopcq_tail,
846  fopc);
848  return;
849  }
850  LOG_DEBUG ("Received PEER_GET_CONFIG for peer: %u\n",
851  peer_id);
852  config =
854  &c_size);
856  c_size,
857  &xconfig);
859  env = GNUNET_MQ_msg_extra (reply,
860  xc_size,
862  reply->peer_id = msg->peer_id;
863  reply->operation_id = msg->operation_id;
865  &reply->peer_identity);
866  reply->config_size = htons ((uint16_t) c_size);
867  GNUNET_memcpy (&reply[1],
868  xconfig,
869  xc_size);
870  GNUNET_free (xconfig);
872  env);
874 }
875 
876 
880 void
882 {
883  while (NULL != prc_head)
885 }
886 
887 
895 static char *
898 {
899  char *emsg;
900 
901  GNUNET_TESTING_peer_destroy (peer->details.local.peer);
902  GNUNET_CONFIGURATION_destroy (peer->details.local.cfg);
903  peer->details.local.cfg = cfg;
904  emsg = NULL;
905  peer->details.local.peer
907  peer->details.local.cfg,
908  peer->id,
909  NULL /* Peer id */,
910  &emsg);
911  return emsg;
912 }
913 
914 
923 static void
924 prc_stop_cb (void *cls,
925  struct GNUNET_TESTING_Peer *p,
926  int success)
927 {
928  struct PeerReconfigureContext *prc = cls;
929  struct Peer *peer;
930  char *emsg;
931 
933  peer = GST_peer_list [prc->peer_id];
934  GNUNET_assert (GNUNET_NO == peer->is_remote);
935  emsg = update_peer_config (peer, prc->cfg);
936  prc->cfg = NULL;
937  prc->stopped = 1;
938  if (NULL != emsg)
939  {
941  prc->op_id,
942  emsg);
943  goto cleanup;
944  }
945  if (GNUNET_OK != start_peer (peer))
946  {
948  prc->op_id,
949  "Failed to start reconfigured peer");
950  goto cleanup;
951  }
953  prc->op_id);
954 
955 cleanup:
956  cleanup_prc (prc);
957  return;
958 }
959 
960 
968 int
971 {
972  return GNUNET_OK; /* checked later */
973 }
974 
975 
984 void
986  const struct
988 {
989  struct GNUNET_SERVICE_Client *client = cls;
990  struct Peer *peer;
992  struct ForwardedOperationContext *fopc;
993  struct PeerReconfigureContext *prc;
994  char *emsg;
995  uint64_t op_id;
996  uint32_t peer_id;
997 
998  peer_id = ntohl (msg->peer_id);
999  op_id = GNUNET_ntohll (msg->operation_id);
1000  if (! VALID_PEER_ID (peer_id))
1001  {
1002  GNUNET_break (0);
1004  op_id,
1005  "Peer not found");
1007  return;
1008  }
1010  if (GNUNET_YES == peer->is_remote)
1011  {
1012  LOG_DEBUG ("Forwarding PEER_RECONFIGURE for peer: %u\n", peer_id);
1013  fopc = GNUNET_new (struct ForwardedOperationContext);
1014  fopc->client = client;
1015  fopc->operation_id = op_id;
1016  fopc->type = OP_PEER_RECONFIGURE;
1017  fopc->opc =
1019  slave->controller,
1020  fopc->operation_id,
1021  &msg->header,
1022  &
1024  fopc);
1025  fopc->timeout_task =
1028  fopc);
1030  fopcq_tail,
1031  fopc);
1033  return;
1034  }
1035  LOG_DEBUG ("Received PEER_RECONFIGURE for peer %u\n",
1036  (unsigned int) peer_id);
1037  if (0 < peer->reference_cnt)
1038  {
1039  GNUNET_break (0);
1041  op_id,
1042  "Peer in use");
1044  return;
1045  }
1046  if (GNUNET_YES == peer->destroy_flag)
1047  {
1048  GNUNET_break (0);
1050  op_id,
1051  "Peer is being destroyed");
1053  return;
1054  }
1055  cfg = GNUNET_TESTBED_extract_config_ (&msg->header);
1056  if (NULL == cfg)
1057  {
1058  GNUNET_break (0);
1060  op_id,
1061  "Compression error");
1063  return;
1064  }
1065  if (GNUNET_NO == peer->details.local.is_running)
1066  {
1067  emsg = update_peer_config (peer,
1068  cfg);
1069  if (NULL != emsg)
1071  op_id,
1072  emsg);
1074  op_id);
1076  GNUNET_free (emsg);
1077  return;
1078  }
1079  prc = GNUNET_new (struct PeerReconfigureContext);
1080  if (GNUNET_OK !=
1081  GNUNET_TESTING_peer_stop_async (peer->details.local.peer,
1082  &prc_stop_cb,
1083  prc))
1084  {
1085  GNUNET_assert (0 < GNUNET_asprintf (&emsg,
1086  "Error trying to stop peer %u asynchronously\n",
1087  peer_id));
1089  "%s\n",
1090  emsg);
1092  op_id,
1093  emsg);
1095  GNUNET_free (prc);
1096  GNUNET_free (emsg);
1097  return;
1098  }
1099  prc->cfg = cfg;
1100  prc->peer_id = peer_id;
1101  prc->op_id = op_id;
1102  prc->client = client;
1104  prc_tail,
1105  prc);
1107 }
1108 
1109 
1113 void
1115 {
1116  while (NULL != mctx_head)
1118 }
1119 
1120 
1127 static const char *
1129 {
1130  switch (rs)
1131  {
1133  return _ ("Message was sent successfully");
1134 
1136  return _ ("We disconnected from ARM before we could send a request");
1137  }
1138  return _ ("Unknown request status");
1139 }
1140 
1141 
1148 static const char *
1150 {
1151  switch (result)
1152  {
1154  return _ ("%s is stopped");
1155 
1157  return _ ("%s is starting");
1158 
1160  return _ ("%s is stopping");
1161 
1163  return _ ("%s is starting already");
1164 
1166  return _ ("%s is stopping already");
1167 
1169  return _ ("%s is started already");
1170 
1172  return _ ("%s is stopped already");
1173 
1175  return _ ("%s service is not known to ARM");
1176 
1178  return _ ("%s service failed to start");
1179 
1181  return _ ("%s service can't be started because ARM is shutting down");
1182  }
1183  return _ ("%.s Unknown result code.");
1184 }
1185 
1186 
1197 static void
1199  enum GNUNET_ARM_RequestStatus rs,
1201 {
1202  struct ManageServiceContext *mctx = cls;
1203  char *emsg;
1204 
1205  emsg = NULL;
1206  if (GNUNET_YES == mctx->expired)
1207  return;
1208  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
1209  {
1210  GNUNET_asprintf (&emsg,
1211  "Error communicating with Peer %u's ARM: %s",
1212  mctx->peer->id,
1213  arm_req_string (rs));
1214  goto ret;
1215  }
1216  if (1 == mctx->start)
1217  goto service_start_check;
1218  if (! ((GNUNET_ARM_RESULT_STOPPED == result)
1222  {
1223  /* stopping a service failed */
1224  GNUNET_asprintf (&emsg,
1226  mctx->service);
1227  goto ret;
1228  }
1229  /* service stopped successfully */
1230  goto ret;
1231 
1232 service_start_check:
1236  {
1237  /* starting a service failed */
1238  GNUNET_asprintf (&emsg,
1240  mctx->service);
1241  goto ret;
1242  }
1243  /* service started successfully */
1244 
1245 ret:
1246  if (NULL != emsg)
1247  {
1248  LOG_DEBUG ("%s\n", emsg);
1250  mctx->op_id,
1251  emsg);
1252  }
1253  else
1255  mctx->op_id);
1256  GNUNET_free (emsg);
1257  cleanup_mctx (mctx);
1258 }
1259 
1260 
1268 int
1270  const struct
1272 {
1273  uint16_t msize;
1274  const char*service;
1275 
1276  msize = ntohs (msg->header.size);
1277  service = (const char *) &msg[1];
1278  if ('\0' != service[msize - sizeof
1280  {
1281  GNUNET_break_op (0);
1282  return GNUNET_SYSERR;
1283  }
1284  if (1 < msg->start)
1285  {
1286  GNUNET_break_op (0);
1287  return GNUNET_SYSERR;
1288  }
1289  return GNUNET_OK;
1290 }
1291 
1292 
1293 void
1295  const struct
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 destroy 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,
1339  &
1341  fopc);
1342  fopc->timeout_task =
1345  fopc);
1347  fopcq_tail,
1348  fopc);
1350  return;
1351  }
1352  if (GNUNET_NO == peer->details.local.is_running)
1353  {
1354  emsg = GNUNET_strdup ("Peer not running\n");
1355  goto err_ret;
1356  }
1357  if ((0 != peer->reference_cnt)
1358  && ((0 == strcasecmp ("core", service))
1359  || (0 == strcasecmp ("transport", service))))
1360  {
1361  GNUNET_asprintf (&emsg, "Cannot stop %s service of peer with id: %u "
1362  "since it is required by existing operations",
1363  service, peer_id);
1364  goto err_ret;
1365  }
1366  ah = GNUNET_ARM_connect (peer->details.local.cfg, NULL, NULL);
1367  if (NULL == ah)
1368  {
1369  GNUNET_asprintf (&emsg,
1370  "Cannot connect to ARM service of peer with id: %u",
1371  peer_id);
1372  goto err_ret;
1373  }
1374  mctx = GNUNET_new (struct ManageServiceContext);
1375  mctx->peer = peer;
1376  peer->reference_cnt++;
1377  mctx->op_id = op_id;
1378  mctx->ah = ah;
1379  mctx->client = client;
1380  mctx->start = msg->start;
1381  mctx->service = GNUNET_strdup (service);
1383  mctx_tail,
1384  mctx);
1385  if (1 == mctx->start)
1387  service,
1390  mctx);
1391  else
1394  mctx);
1396  return;
1397 
1398 err_ret:
1399  LOG (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1400  GST_send_operation_fail_msg (client, op_id, emsg);
1401  GNUNET_free (emsg);
1403 }
1404 
1405 
1409 void
1411 {
1412  struct Peer *peer;
1413  unsigned int id;
1414 
1415  if (NULL == GST_peer_list)
1416  return;
1417  for (id = 0; id < GST_peer_list_size; id++)
1418  {
1419  peer = GST_peer_list[id];
1420  if (NULL == peer)
1421  continue;
1422  /* If destroy flag is set it means that this peer should have been
1423  * destroyed by a context which we destroy before */
1424  GNUNET_break (GNUNET_NO == peer->destroy_flag);
1425  /* counter should be zero as we free all contexts before */
1426  GNUNET_break (0 == peer->reference_cnt);
1427  if ((GNUNET_NO == peer->is_remote) &&
1428  (GNUNET_YES == peer->details.local.is_running))
1429  GNUNET_TESTING_peer_kill (peer->details.local.peer);
1430  }
1431  for (id = 0; id < GST_peer_list_size; id++)
1432  {
1433  peer = GST_peer_list[id];
1434  if (NULL == peer)
1435  continue;
1436  if (GNUNET_NO == peer->is_remote)
1437  {
1438  if (GNUNET_YES == peer->details.local.is_running)
1439  GNUNET_TESTING_peer_wait (peer->details.local.peer);
1440  GNUNET_TESTING_peer_destroy (peer->details.local.peer);
1441  GNUNET_CONFIGURATION_destroy (peer->details.local.cfg);
1442  }
1443  GNUNET_free (peer);
1444  }
1446  GST_peer_list = NULL;
1447  GST_peer_list_size = 0;
1448 }
1449 
1450 
1459 static void
1461  const struct GNUNET_MessageHeader *msg)
1462 {
1463  struct ForwardedOperationContext *fo_ctxt = cls;
1464  struct HandlerContext_ShutdownPeers *hc;
1465 
1466  hc = fo_ctxt->cls;
1467  GNUNET_assert (0 < hc->nslaves);
1468  hc->nslaves--;
1470  ntohs (msg->type))
1471  hc->timeout = GNUNET_YES;
1472  if (0 == hc->nslaves)
1473  {
1474  if (GNUNET_YES == hc->timeout)
1476  fo_ctxt->operation_id,
1477  "Timeout at a slave controller");
1478  else
1480  fo_ctxt->operation_id);
1481  GNUNET_free (hc);
1482  hc = NULL;
1483  }
1485  fopcq_tail,
1486  fo_ctxt);
1487  GNUNET_free (fo_ctxt);
1488 }
1489 
1490 
1497 void
1500 {
1501  struct GNUNET_SERVICE_Client *client = cls;
1502  struct HandlerContext_ShutdownPeers *hc;
1503  struct Slave *slave;
1504  struct ForwardedOperationContext *fo_ctxt;
1505  uint64_t op_id;
1506  unsigned int cnt;
1507 
1508  LOG_DEBUG ("Received SHUTDOWN_PEERS\n");
1509  /* Stop and destroy all peers */
1510  GST_free_mctxq ();
1511  GST_free_occq ();
1512  GST_free_roccq ();
1513  GST_clear_fopcq ();
1514  /* Forward to all slaves which we have started */
1515  op_id = GNUNET_ntohll (msg->operation_id);
1517  /* FIXME: have a better implementation where we track which slaves are
1518  started by this controller */
1519  for (cnt = 0; cnt < GST_slave_list_size; cnt++)
1520  {
1521  slave = GST_slave_list[cnt];
1522  if (NULL == slave)
1523  continue;
1524  if (NULL == slave->controller_proc) /* We didn't start the slave */
1525  continue;
1526  LOG_DEBUG ("Forwarding SHUTDOWN_PEERS\n");
1527  hc->nslaves++;
1528  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
1529  fo_ctxt->client = client;
1530  fo_ctxt->operation_id = op_id;
1531  fo_ctxt->cls = hc;
1532  fo_ctxt->type = OP_SHUTDOWN_PEERS;
1533  fo_ctxt->opc =
1535  fo_ctxt->operation_id,
1536  &msg->header,
1538  fo_ctxt);
1540  fopcq_tail,
1541  fo_ctxt);
1542  }
1543  LOG_DEBUG ("Shutting down peers\n");
1544  GST_destroy_peers ();
1545  if (0 == hc->nslaves)
1546  {
1548  op_id);
1549  GNUNET_free (hc);
1550  }
1552 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define LOG(kind,...)
Definition: abd_api.c:38
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
#define LOG_DEBUG(...)
Debug logging shorthand.
static int result
Global testing status.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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.
void GST_clear_fopcq()
Clears the forwarded operations queue.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
struct Context * GST_context
The master context; generated with the first INIT message.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
unsigned int GST_peer_list_size
The size of the peer list.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
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.
data structures shared amongst components of TESTBED service
#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 ...
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
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...
#define LIST_GROW_STEP
By how much should the arrays lists grow.
void GST_free_roccq(void)
Clears all pending remote overlay connect contexts in queue.
void GST_free_occq(void)
Clears all pending overlay connect contexts in queue.
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 start_peer(struct Peer *peer)
Stats a peer.
static char * update_peer_config(struct Peer *peer, struct GNUNET_CONFIGURATION_Handle *cfg)
Update peer configuration.
int check_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
void GST_free_prcq()
Cleans up the Peer reconfigure context list.
unsigned int GST_num_local_peers
The current number of peers running locally under this controller.
void handle_peer_destroy(void *cls, const struct GNUNET_TESTBED_PeerDestroyMessage *msg)
Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.
static struct ManageServiceContext * mctx_tail
DLL tail for queue of manage service requests.
static void shutdown_peers_reply_cb(void *cls, const struct GNUNET_MessageHeader *msg)
The reply msg handler forwarded SHUTDOWN_PEERS operation.
void GST_notify_client_disconnect_peers(struct GNUNET_SERVICE_Client *client)
Notify peers subsystem that client disconnected.
static void peer_list_remove(struct Peer *peer)
Removes a the give peer from the peer array.
static const char * arm_req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
static const char * arm_ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
static void prc_stop_cb(void *cls, struct GNUNET_TESTING_Peer *p, int success)
Callback to inform whether the peer is running or stopped.
void handle_shutdown_peers(void *cls, const struct GNUNET_TESTBED_ShutdownPeersMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages.
static void peer_create_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer create operation is successful.
static void cleanup_prc(struct PeerReconfigureContext *prc)
Cleans up the given PeerReconfigureContext.
void GST_free_mctxq()
Frees the ManageServiceContext queue.
static void cleanup_mctx(struct ManageServiceContext *mctx)
Cleanup the context information created for managing a peer's service.
static int stop_peer(struct Peer *peer)
Stops a peer.
void handle_peer_get_config(void *cls, const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION messages.
void handle_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE messages.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
void handle_peer_start(void *cls, const struct GNUNET_TESTBED_PeerStartMessage *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_START_PEER messages.
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
static void peer_list_add(struct Peer *peer)
Adds a peer to the peer array.
void handle_peer_stop(void *cls, const struct GNUNET_TESTBED_PeerStopMessage *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER messages.
void GST_destroy_peers()
Stops and destroys all peers.
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
static void peer_destroy_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer destroy operation is successful.
void handle_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
int check_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
struct Peer ** GST_peer_list
A list of peers we know about.
static struct PeerReconfigureContext * prc_tail
The DLL tail for the peer reconfigure list.
void handle_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
static void peer_create_forward_timeout(void *cls)
The task to be executed if the forwarded peer create operation has been timed out.
int check_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.
static const struct GNUNET_CONFIGURATION_Handle * config
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
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:926
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:577
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:1038
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
Definition: arm_api.c:602
GNUNET_ARM_Result
Replies to ARM requests.
GNUNET_ARM_RequestStatus
Statuses of the requests that client can send to ARM.
@ GNUNET_ARM_RESULT_IS_NOT_KNOWN
Asked to start or stop a service, but it's not known.
@ GNUNET_ARM_RESULT_IS_STARTING_ALREADY
Asked to start it, but it's already starting.
@ GNUNET_ARM_RESULT_IS_STOPPED_ALREADY
Asked to stop it, but it's already stopped.
@ GNUNET_ARM_RESULT_STARTING
Service starting was initiated.
@ GNUNET_ARM_RESULT_IS_STARTED_ALREADY
Asked to start it, but it's already started.
@ GNUNET_ARM_RESULT_STOPPING
ARM stopping was initiated (there's no "stopped" for ARM itself).
@ GNUNET_ARM_RESULT_IS_STOPPING_ALREADY
Asked to stop it, but it's already stopping.
@ GNUNET_ARM_RESULT_STOPPED
Service was stopped (never sent for ARM itself).
@ GNUNET_ARM_RESULT_START_FAILED
Tried to start a service, but that failed for some reason.
@ GNUNET_ARM_RESULT_IN_SHUTDOWN
Asked to start something, but ARM is shutting down and can't comply.
@ GNUNET_ARM_REQUEST_DISCONNECTED
We disconnected from ARM, and request was not sent.
@ GNUNET_ARM_REQUEST_SENT_OK
Message was sent successfully.
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
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.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_free(ptr)
Wrapper around free.
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:304
#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:62
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:77
@ GNUNET_OS_INHERIT_STD_ERR
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:95
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
Message for peer events.
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer's information.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
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:1272
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2330
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2443
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2249
@ GNUNET_TESTBED_ET_PEER_START
A peer has been started.
@ GNUNET_TESTBED_ET_PEER_STOP
A peer has been stopped.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1485
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:1188
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1381
void GNUNET_TESTING_peer_stop_async_cancel(struct GNUNET_TESTING_Peer *peer)
Cancel a previous asynchronous peer stop request.
Definition: testing.c:1550
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:1525
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer's main process.
Definition: testing.c:1430
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1566
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
Definition: testing.c:1462
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:1359
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
uint32_t host_id
Our host id according to this context.
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
Context information for operations forwarded to subcontrollers.
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
enum OperationType type
The type of the operation which is forwarded.
struct OperationContext * opc
The generated operation context.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
struct ForwardedOperationContext * next
The next pointer for DLL.
uint64_t operation_id
The id of the operation that has been forwarded.
Handle for interacting with ARM.
Definition: arm_api.c:103
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Handle to a client that is connected to a service.
Definition: service.c:252
Message to start/stop services of a peer.
Definition: testbed.h:706
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:604
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:618
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:623
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:628
uint32_t peer_id
The id of the peer relevant to this information.
Definition: testbed.h:613
Message sent from client to testing service to create (configure, but not start) a peer.
Definition: testbed.h:205
Event notification from a controller to a client.
Definition: testbed.h:534
uint32_t peer_id
Peer identity of the peer that was created.
Definition: testbed.h:543
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:548
Message sent from client to testing service to destroy a (stopped) peer.
Definition: testbed.h:318
Event notification from a controller to a client.
Definition: testbed.h:443
uint32_t peer_id
Peer that was started or stopped.
Definition: testbed.h:463
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:468
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:453
uint32_t host_id
Host where the peer is running.
Definition: testbed.h:458
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:582
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:241
Message sent from client to testing service to start a peer.
Definition: testbed.h:272
Message sent from client to testing service to stop a peer.
Definition: testbed.h:295
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
Shutdown peers message.
Definition: testbed.h:689
Handle for a GNUnet peer controlled by testing.
Definition: testing.c:195
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
int timeout
Did we observe a timeout with respect to this operation at any of the slaves.
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
Context information to manage peers' services.
uint64_t op_id
The operation id of the associated request.
struct ManageServiceContext * next
DLL next ptr.
struct GNUNET_ARM_Handle * ah
The ARM handle of the peer.
uint8_t start
1 if the service at the peer has to be started; 0 if it has to be stopped
struct GNUNET_SERVICE_Client * client
The client which requested to manage the peer's service.
char * service
Name of the service.
struct ManageServiceContext * prev
DLL prev ptr.
struct Peer * peer
peer whose service has to be managed
uint8_t expired
Is this context expired? Do not work on this context if it is set to GNUNET_YES.
Context information for peer re-configure operations.
uint8_t stopped
The the peer stopped? Used while cleaning up this context to decide whether the asynchronous stop req...
struct GNUNET_SERVICE_Client * client
The client which gave this operation to us.
uint64_t op_id
The id of the operation.
struct PeerReconfigureContext * prev
DLL prev.
uint32_t peer_id
The id of the peer which has to be reconfigured.
struct PeerReconfigureContext * next
DLL next for inclusoin in peer reconfigure operations list.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle to use as the new template.
struct Slave * slave
The slave this peer is started through.
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer,...
union Peer::@57 details
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts.
uint32_t id
Our local reference id for this peer.
A routing entry.
uint32_t dest
destination host
Structure representing a connected(directly-linked) controller.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
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:2043
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:1370
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1758
@ OP_PEER_RECONFIGURE
Reconfigure a peer.
Definition: testbed_api.h:74
@ OP_PEER_START
Peer start operation.
Definition: testbed_api.h:54
@ OP_PEER_INFO
Get peer information operation.
Definition: testbed_api.h:69
@ OP_SHUTDOWN_PEERS
Stop and destroy all peers.
Definition: testbed_api.h:99
@ OP_MANAGE_SERVICE
Start/stop service at a peer.
Definition: testbed_api.h:104
@ OP_PEER_DESTROY
Peer destroy operation.
Definition: testbed_api.h:64
@ OP_PEER_STOP
Peer stop operation.
Definition: testbed_api.h:59
@ OP_PEER_CREATE
Peer create operation.
Definition: testbed_api.h:49
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.