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 
52 
57 
62 
66  struct Peer *peer;
67 
72 
76  char *service;
77 
81  uint64_t op_id;
82 
86  uint8_t start;
87 
92  uint8_t expired;
93 };
94 
95 
104 
109 
114 
119 
123  uint64_t op_id;
124 
128  uint32_t peer_id;
129 
135  uint8_t stopped;
136 };
137 
142 
147 
148 
149 
154 
159 
160 
166 static void
168 {
169  if (peer->id >= GST_peer_list_size)
170  GST_array_grow_large_enough(GST_peer_list, GST_peer_list_size, peer->id);
171  GNUNET_assert(NULL == GST_peer_list[peer->id]);
172  GST_peer_list[peer->id] = peer;
173  if (GNUNET_NO == peer->is_remote)
175 }
176 
177 
183 static void
185 {
186  unsigned int orig_size;
187  uint32_t id;
188 
189  if (GNUNET_NO == peer->is_remote)
191  GST_peer_list[peer->id] = NULL;
192  orig_size = GST_peer_list_size;
194  {
195  for (id = GST_peer_list_size - 1;
196  (id >= GST_peer_list_size - LIST_GROW_STEP) && (id != UINT32_MAX);
197  id--)
198  if (NULL != GST_peer_list[id])
199  break;
200  if (id != ((GST_peer_list_size - LIST_GROW_STEP) - 1))
201  break;
203  }
204  if (orig_size == GST_peer_list_size)
205  return;
206  GST_peer_list =
207  GNUNET_realloc(GST_peer_list,
208  sizeof(struct Peer *) * GST_peer_list_size);
209 }
210 
211 
218 static void
220 {
221  struct ForwardedOperationContext *fopc = cls;
222 
223  GNUNET_free(fopc->cls);
225 }
226 
227 
235 static void
237 {
238  struct ForwardedOperationContext *fopc = cls;
239  struct Peer *remote_peer;
240 
242  {
243  GNUNET_assert(NULL != fopc->cls);
244  remote_peer = fopc->cls;
245  peer_list_add(remote_peer);
246  }
248  msg);
249 }
250 
251 
257 void
259 {
260  GNUNET_break(0 == peer->reference_cnt);
261  if (GNUNET_YES == peer->is_remote)
262  {
263  peer_list_remove(peer);
264  GNUNET_free(peer);
265  return;
266  }
267  if (GNUNET_YES == peer->details.local.is_running)
268  {
270  peer->details.local.is_running = GNUNET_NO;
271  }
274  peer_list_remove(peer);
275  GNUNET_free(peer);
276 }
277 
278 
284 static void
286 {
287  mctx->expired = GNUNET_YES;
288  GNUNET_CONTAINER_DLL_remove(mctx_head,
289  mctx_tail,
290  mctx);
291  GNUNET_ARM_disconnect(mctx->ah);
292  GNUNET_assert(0 < mctx->peer->reference_cnt);
293  mctx->peer->reference_cnt--;
294  if ((GNUNET_YES == mctx->peer->destroy_flag) &&
295  (0 == mctx->peer->reference_cnt))
296  GST_destroy_peer(mctx->peer);
297  GNUNET_free(mctx->service);
298  GNUNET_free(mctx);
299 }
300 
301 
308 static int
310 {
312  if (GNUNET_OK != GNUNET_TESTING_peer_kill(peer->details.local.peer))
313  return GNUNET_SYSERR;
314  peer->details.local.is_running = GNUNET_NO;
315  return GNUNET_OK;
316 }
317 
318 
324 static void
326 {
327  struct Peer *peer;
328 
329  if (VALID_PEER_ID(prc->peer_id))
330  {
331  peer = GST_peer_list [prc->peer_id];
332  if (1 != prc->stopped)
333  {
335  stop_peer(peer); /* Stop the peer synchronously */
336  }
337  }
338  if (NULL != prc->cfg)
341  prc_tail,
342  prc);
343  GNUNET_free(prc);
344 }
345 
346 
352 void
354 {
355  struct ForwardedOperationContext *fopc;
356  struct ForwardedOperationContext *fopcn;
357  struct ManageServiceContext *mctx;
358  struct ManageServiceContext *mctxn;
359  struct PeerReconfigureContext *prc;
360  struct PeerReconfigureContext *prcn;
361 
362  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
363  {
364  fopcn = fopc->next;
365  if (client == fopc->client)
366  {
367  if (OP_PEER_CREATE == fopc->type)
368  GNUNET_free(fopc->cls);
371  }
372  }
373  for (mctx = mctx_head; NULL != mctx; mctx = mctxn)
374  {
375  mctxn = mctx->next;
376  if (client == mctx->client)
377  cleanup_mctx(mctx);
378  }
379  for (prc = prc_head; NULL != prc; prc = prcn)
380  {
381  prcn = prc->next;
382  if (client == prc->client)
383  cleanup_prc(prc);
384  }
385 }
386 
387 
395 static void
397 {
398  struct ForwardedOperationContext *fopc = cls;
399  struct Peer *remote_peer;
400 
402  ntohs(msg->type))
403  {
404  remote_peer = fopc->cls;
405  GNUNET_assert(NULL != remote_peer);
406  remote_peer->destroy_flag = GNUNET_YES;
407  if (0 == remote_peer->reference_cnt)
408  GST_destroy_peer(remote_peer);
409  }
411  msg);
412 }
413 
414 
422 int
425 {
426  return GNUNET_OK; /* checked later */
427 }
428 
429 
436 void
439 {
440  struct GNUNET_SERVICE_Client *client = cls;
441  struct GNUNET_MQ_Envelope *env;
444  struct ForwardedOperationContext *fo_ctxt;
445  struct Route *route;
446  struct Peer *peer;
447  char *emsg;
448  uint32_t host_id;
449  uint32_t peer_id;
450 
451  host_id = ntohl(msg->host_id);
452  peer_id = ntohl(msg->peer_id);
453  if (VALID_PEER_ID(peer_id))
454  {
455  (void)GNUNET_asprintf(&emsg,
456  "Peer with ID %u already exists",
457  peer_id);
460  emsg);
461  GNUNET_free(emsg);
463  return;
464  }
465  if (UINT32_MAX == peer_id)
466  {
469  "Cannot create peer with given ID");
471  return;
472  }
473  if (host_id == GST_context->host_id)
474  {
475  /* We are responsible for this peer */
477  if (NULL == cfg)
478  {
479  GNUNET_break(0);
481  return;
482  }
484  "TESTBED",
485  "PEERID",
486  (unsigned long long)peer_id);
487 
489  "PATHS",
490  "PEERID",
491  (unsigned long long)peer_id);
492  peer = GNUNET_new(struct Peer);
493  peer->is_remote = GNUNET_NO;
494  peer->details.local.cfg = cfg;
495  peer->id = peer_id;
496  LOG_DEBUG("Creating peer with id: %u\n",
497  (unsigned int)peer->id);
498  peer->details.local.peer =
500  peer->details.local.cfg, peer->id,
501  NULL /* Peer id */,
502  &emsg);
503  if (NULL == peer->details.local.peer)
504  {
506  "Configuring peer failed: %s\n",
507  emsg);
508  GNUNET_free(emsg);
509  GNUNET_free(peer);
510  GNUNET_break(0);
512  return;
513  }
514  peer->details.local.is_running = GNUNET_NO;
515  peer_list_add(peer);
516  env = GNUNET_MQ_msg(reply,
518  reply->peer_id = msg->peer_id;
519  reply->operation_id = msg->operation_id;
521  env);
523  return;
524  }
525 
526  /* Forward peer create request */
527  route = GST_find_dest_route(host_id);
528  if (NULL == route)
529  {
530  GNUNET_break(0);
531  GNUNET_SERVICE_client_continue(client); // ?
532  return;
533  }
534  peer = GNUNET_new(struct Peer);
535  peer->is_remote = GNUNET_YES;
536  peer->id = peer_id;
537  peer->details.remote.slave = GST_slave_list[route->dest];
538  peer->details.remote.remote_host_id = host_id;
539  fo_ctxt = GNUNET_new(struct ForwardedOperationContext);
540  fo_ctxt->client = client;
541  fo_ctxt->operation_id = GNUNET_ntohll(msg->operation_id);
542  fo_ctxt->cls = peer;
543  fo_ctxt->type = OP_PEER_CREATE;
544  fo_ctxt->opc =
546  [route->dest]->controller,
547  fo_ctxt->operation_id,
548  &msg->header,
550  fo_ctxt);
551  fo_ctxt->timeout_task =
554  fo_ctxt);
556  fopcq_tail,
557  fo_ctxt);
559 }
560 
561 
568 void
571 {
572  struct GNUNET_SERVICE_Client *client = cls;
573  struct ForwardedOperationContext *fopc;
574  struct Peer *peer;
575  uint32_t peer_id;
576 
577  peer_id = ntohl(msg->peer_id);
578  LOG_DEBUG("Received peer destory on peer: %u and operation id: %llu\n",
579  (unsigned int)peer_id,
580  (unsigned long long)GNUNET_ntohll(msg->operation_id));
581  if (!VALID_PEER_ID(peer_id))
582  {
584  "Asked to destroy a non existent peer with id: %u\n", peer_id);
587  "Peer doesn't exist");
589  return;
590  }
591  peer = GST_peer_list[peer_id];
592  if (GNUNET_YES == peer->is_remote)
593  {
594  /* Forward the destory message to sub controller */
595  fopc = GNUNET_new(struct ForwardedOperationContext);
596  fopc->client = client;
597  fopc->cls = peer;
598  fopc->type = OP_PEER_DESTROY;
600  fopc->opc =
602  slave->controller,
603  fopc->operation_id,
604  &msg->header,
606  fopc);
607  fopc->timeout_task =
610  fopc);
612  fopcq_tail,
613  fopc);
615  return;
616  }
617  peer->destroy_flag = GNUNET_YES;
618  if (0 == peer->reference_cnt)
619  GST_destroy_peer(peer);
620  else
622  "Delaying peer destroy as peer is currently in use\n");
626 }
627 
628 
635 static int
637 {
640  return GNUNET_SYSERR;
641  peer->details.local.is_running = GNUNET_YES;
642  return GNUNET_OK;
643 }
644 
645 
652 void
654  const struct GNUNET_TESTBED_PeerStartMessage *msg)
655 {
656  struct GNUNET_SERVICE_Client *client = cls;
657  struct GNUNET_MQ_Envelope *env;
658  struct GNUNET_TESTBED_PeerEventMessage *reply;
659  struct ForwardedOperationContext *fopc;
660  struct Peer *peer;
661  uint32_t peer_id;
662 
663  peer_id = ntohl(msg->peer_id);
664  if (!VALID_PEER_ID(peer_id))
665  {
666  GNUNET_break(0);
668  "Asked to start a non existent peer with id: %u\n",
669  peer_id);
671  return;
672  }
673  peer = GST_peer_list[peer_id];
674  if (GNUNET_YES == peer->is_remote)
675  {
676  fopc = GNUNET_new(struct ForwardedOperationContext);
677  fopc->client = client;
679  fopc->type = OP_PEER_START;
680  fopc->opc =
682  slave->controller,
683  fopc->operation_id, &msg->header,
685  fopc);
686  fopc->timeout_task =
689  fopc);
691  fopcq_tail,
692  fopc);
694  return;
695  }
696  if (GNUNET_OK != start_peer(peer))
697  {
699  "Failed to start");
701  return;
702  }
703  env = GNUNET_MQ_msg(reply,
706  reply->host_id = htonl(GST_context->host_id);
707  reply->peer_id = msg->peer_id;
708  reply->operation_id = msg->operation_id;
710  env);
712 }
713 
714 
721 void
723  const struct GNUNET_TESTBED_PeerStopMessage *msg)
724 {
725  struct GNUNET_SERVICE_Client *client = cls;
726  struct GNUNET_MQ_Envelope *env;
727  struct GNUNET_TESTBED_PeerEventMessage *reply;
728  struct ForwardedOperationContext *fopc;
729  struct Peer *peer;
730  uint32_t peer_id;
731 
732  peer_id = ntohl(msg->peer_id);
734  "Received PEER_STOP for peer %u\n",
735  (unsigned int)peer_id);
736  if (!VALID_PEER_ID(peer_id))
737  {
740  "Peer not found");
742  return;
743  }
744  peer = GST_peer_list[peer_id];
745  if (GNUNET_YES == peer->is_remote)
746  {
748  "Forwarding PEER_STOP for peer %u\n",
749  (unsigned int)peer_id);
750  fopc = GNUNET_new(struct ForwardedOperationContext);
751  fopc->client = client;
753  fopc->type = OP_PEER_STOP;
754  fopc->opc =
756  slave->controller,
757  fopc->operation_id,
758  &msg->header,
760  fopc);
761  fopc->timeout_task =
764  fopc);
766  fopcq_tail,
767  fopc);
769  return;
770  }
771  if (GNUNET_OK != stop_peer(peer))
772  {
774  "Stopping peer %u failed\n",
775  (unsigned int)peer_id);
778  "Peer not running");
780  return;
781  }
783  "Peer %u successfully stopped\n",
784  (unsigned int)peer_id);
785  env = GNUNET_MQ_msg(reply,
787  reply->event_type = htonl(GNUNET_TESTBED_ET_PEER_STOP);
788  reply->host_id = htonl(GST_context->host_id);
789  reply->peer_id = msg->peer_id;
790  reply->operation_id = msg->operation_id;
792  env);
795 }
796 
797 
804 void
807 {
808  struct GNUNET_SERVICE_Client *client = cls;
809  struct GNUNET_MQ_Envelope *env;
811  struct ForwardedOperationContext *fopc;
812  struct Peer *peer;
813  char *config;
814  char *xconfig;
815  size_t c_size;
816  size_t xc_size;
817  uint32_t peer_id;
818 
819  peer_id = ntohl(msg->peer_id);
820  LOG_DEBUG("Received GET_CONFIG for peer %u\n",
821  (unsigned int)peer_id);
822  if (!VALID_PEER_ID(peer_id))
823  {
826  "Peer not found");
828  return;
829  }
830  peer = GST_peer_list[peer_id];
831  if (GNUNET_YES == peer->is_remote)
832  {
833  LOG_DEBUG("Forwarding PEER_GET_CONFIG for peer: %u\n",
834  (unsigned int)peer_id);
835  fopc = GNUNET_new(struct ForwardedOperationContext);
836  fopc->client = client;
838  fopc->type = OP_PEER_INFO;
839  fopc->opc =
841  slave->controller,
842  fopc->operation_id,
843  &msg->header,
845  fopc);
846  fopc->timeout_task =
849  fopc);
851  fopcq_tail,
852  fopc);
854  return;
855  }
856  LOG_DEBUG("Received PEER_GET_CONFIG for peer: %u\n",
857  peer_id);
858  config =
859  GNUNET_CONFIGURATION_serialize(GST_peer_list[peer_id]->details.local.cfg,
860  &c_size);
861  xc_size = GNUNET_TESTBED_compress_config_(config,
862  c_size,
863  &xconfig);
864  GNUNET_free(config);
865  env = GNUNET_MQ_msg_extra(reply,
866  xc_size,
868  reply->peer_id = msg->peer_id;
869  reply->operation_id = msg->operation_id;
870  GNUNET_TESTING_peer_get_identity(GST_peer_list[peer_id]->details.local.peer,
871  &reply->peer_identity);
872  reply->config_size = htons((uint16_t)c_size);
873  GNUNET_memcpy(&reply[1],
874  xconfig,
875  xc_size);
876  GNUNET_free(xconfig);
878  env);
880 }
881 
882 
886 void
888 {
889  while (NULL != prc_head)
890  cleanup_prc(prc_head);
891 }
892 
893 
901 static char *
904 {
905  char *emsg;
906 
909  peer->details.local.cfg = cfg;
910  emsg = NULL;
911  peer->details.local.peer
913  peer->details.local.cfg,
914  peer->id,
915  NULL /* Peer id */,
916  &emsg);
917  return emsg;
918 }
919 
920 
929 static void
930 prc_stop_cb(void *cls,
931  struct GNUNET_TESTING_Peer *p,
932  int success)
933 {
934  struct PeerReconfigureContext *prc = cls;
935  struct Peer *peer;
936  char *emsg;
937 
939  peer = GST_peer_list [prc->peer_id];
941  emsg = update_peer_config(peer, prc->cfg);
942  prc->cfg = NULL;
943  prc->stopped = 1;
944  if (NULL != emsg)
945  {
947  prc->op_id,
948  emsg);
949  goto cleanup;
950  }
951  if (GNUNET_OK != start_peer(peer))
952  {
954  prc->op_id,
955  "Failed to start reconfigured peer");
956  goto cleanup;
957  }
959  prc->op_id);
960 
961 cleanup:
962  cleanup_prc(prc);
963  return;
964 }
965 
966 
974 int
977 {
978  return GNUNET_OK; /* checked later */
979 }
980 
981 
990 void
993 {
994  struct GNUNET_SERVICE_Client *client = cls;
995  struct Peer *peer;
997  struct ForwardedOperationContext *fopc;
998  struct PeerReconfigureContext *prc;
999  char *emsg;
1000  uint64_t op_id;
1001  uint32_t peer_id;
1002 
1003  peer_id = ntohl(msg->peer_id);
1004  op_id = GNUNET_ntohll(msg->operation_id);
1005  if (!VALID_PEER_ID(peer_id))
1006  {
1007  GNUNET_break(0);
1009  op_id,
1010  "Peer not found");
1012  return;
1013  }
1014  peer = GST_peer_list[peer_id];
1015  if (GNUNET_YES == peer->is_remote)
1016  {
1017  LOG_DEBUG("Forwarding PEER_RECONFIGURE for peer: %u\n", peer_id);
1018  fopc = GNUNET_new(struct ForwardedOperationContext);
1019  fopc->client = client;
1020  fopc->operation_id = op_id;
1021  fopc->type = OP_PEER_RECONFIGURE;
1022  fopc->opc =
1024  slave->controller,
1025  fopc->operation_id,
1026  &msg->header,
1028  fopc);
1029  fopc->timeout_task =
1032  fopc);
1034  fopcq_tail,
1035  fopc);
1037  return;
1038  }
1039  LOG_DEBUG("Received PEER_RECONFIGURE for peer %u\n",
1040  (unsigned int)peer_id);
1041  if (0 < peer->reference_cnt)
1042  {
1043  GNUNET_break(0);
1045  op_id,
1046  "Peer in use");
1048  return;
1049  }
1050  if (GNUNET_YES == peer->destroy_flag)
1051  {
1052  GNUNET_break(0);
1054  op_id,
1055  "Peer is being destroyed");
1057  return;
1058  }
1060  if (NULL == cfg)
1061  {
1062  GNUNET_break(0);
1064  op_id,
1065  "Compression error");
1067  return;
1068  }
1069  if (GNUNET_NO == peer->details.local.is_running)
1070  {
1071  emsg = update_peer_config(peer,
1072  cfg);
1073  if (NULL != emsg)
1075  op_id,
1076  emsg);
1078  op_id);
1080  GNUNET_free_non_null(emsg);
1081  return;
1082  }
1083  prc = GNUNET_new(struct PeerReconfigureContext);
1084  if (GNUNET_OK !=
1086  &prc_stop_cb,
1087  prc))
1088  {
1089  GNUNET_assert(0 < GNUNET_asprintf(&emsg,
1090  "Error trying to stop peer %u asynchronously\n",
1091  peer_id));
1093  "%s\n",
1094  emsg);
1096  op_id,
1097  emsg);
1099  GNUNET_free(prc);
1100  GNUNET_free(emsg);
1101  return;
1102  }
1103  prc->cfg = cfg;
1104  prc->peer_id = peer_id;
1105  prc->op_id = op_id;
1106  prc->client = client;
1108  prc_tail,
1109  prc);
1111 }
1112 
1113 
1117 void
1119 {
1120  while (NULL != mctx_head)
1121  cleanup_mctx(mctx_head);
1122 }
1123 
1124 
1131 static const char *
1133 {
1134  switch (rs)
1135  {
1137  return _("Message was sent successfully");
1138 
1140  return _("We disconnected from ARM before we could send a request");
1141  }
1142  return _("Unknown request status");
1143 }
1144 
1145 
1152 static const char *
1154 {
1155  switch (result)
1156  {
1158  return _("%s is stopped");
1159 
1161  return _("%s is starting");
1162 
1164  return _("%s is stopping");
1165 
1167  return _("%s is starting already");
1168 
1170  return _("%s is stopping already");
1171 
1173  return _("%s is started already");
1174 
1176  return _("%s is stopped already");
1177 
1179  return _("%s service is not known to ARM");
1180 
1182  return _("%s service failed to start");
1183 
1185  return _("%s service can't be started because ARM is shutting down");
1186  }
1187  return _("%.s Unknown result code.");
1188 }
1189 
1190 
1201 static void
1203  enum GNUNET_ARM_RequestStatus rs,
1205 {
1206  struct ManageServiceContext *mctx = cls;
1207  char *emsg;
1208 
1209  emsg = NULL;
1210  if (GNUNET_YES == mctx->expired)
1211  return;
1212  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
1213  {
1214  GNUNET_asprintf(&emsg,
1215  "Error communicating with Peer %u's ARM: %s",
1216  mctx->peer->id,
1217  arm_req_string(rs));
1218  goto ret;
1219  }
1220  if (1 == mctx->start)
1221  goto service_start_check;
1222  if (!((GNUNET_ARM_RESULT_STOPPED == result)
1223  || (GNUNET_ARM_RESULT_STOPPING == result)
1225  || (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY == result)))
1226  {
1227  /* stopping a service failed */
1228  GNUNET_asprintf(&emsg,
1229  arm_ret_string(result),
1230  mctx->service);
1231  goto ret;
1232  }
1233  /* service stopped successfully */
1234  goto ret;
1235 
1236 service_start_check:
1237  if (!((GNUNET_ARM_RESULT_STARTING == result)
1239  || (GNUNET_ARM_RESULT_IS_STARTED_ALREADY == result)))
1240  {
1241  /* starting a service failed */
1242  GNUNET_asprintf(&emsg,
1243  arm_ret_string(result),
1244  mctx->service);
1245  goto ret;
1246  }
1247  /* service started successfully */
1248 
1249 ret:
1250  if (NULL != emsg)
1251  {
1252  LOG_DEBUG("%s\n", emsg);
1254  mctx->op_id,
1255  emsg);
1256  }
1257  else
1259  mctx->op_id);
1260  GNUNET_free_non_null(emsg);
1261  cleanup_mctx(mctx);
1262 }
1263 
1264 
1272 int
1275 {
1276  uint16_t msize;
1277  const char* service;
1278 
1279  msize = ntohs(msg->header.size);
1280  service = (const char *)&msg[1];
1281  if ('\0' != service[msize - sizeof
1283  {
1284  GNUNET_break_op(0);
1285  return GNUNET_SYSERR;
1286  }
1287  if (1 < msg->start)
1288  {
1289  GNUNET_break_op(0);
1290  return GNUNET_SYSERR;
1291  }
1292  return GNUNET_OK;
1293 }
1294 
1295 
1302 void
1305 {
1306  struct GNUNET_SERVICE_Client *client = cls;
1307  const char* service;
1308  struct Peer *peer;
1309  char *emsg;
1310  struct GNUNET_ARM_Handle *ah;
1311  struct ManageServiceContext *mctx;
1312  struct ForwardedOperationContext *fopc;
1313  uint64_t op_id;
1314  uint32_t peer_id;
1315 
1316  service = (const char *)&msg[1];
1317  peer_id = ntohl(msg->peer_id);
1318  op_id = GNUNET_ntohll(msg->operation_id);
1319  LOG_DEBUG("Received request to manage service %s on peer %u\n",
1320  service, (unsigned int)peer_id);
1321  if ((GST_peer_list_size <= peer_id)
1322  || (NULL == (peer = GST_peer_list[peer_id])))
1323  {
1324  GNUNET_asprintf(&emsg, "Asked to manage service of a non existent peer "
1325  "with id: %u", peer_id);
1326  goto err_ret;
1327  }
1328  if (0 == strcasecmp("arm", service))
1329  {
1330  emsg = GNUNET_strdup("Cannot start/stop peer's ARM service. "
1331  "Use peer start/stop for that");
1332  goto err_ret;
1333  }
1334  if (GNUNET_YES == peer->is_remote)
1335  {
1336  /* Forward the destory message to sub controller */
1337  fopc = GNUNET_new(struct ForwardedOperationContext);
1338  fopc->client = client;
1339  fopc->cls = peer;
1340  fopc->type = OP_MANAGE_SERVICE;
1341  fopc->operation_id = op_id;
1342  fopc->opc =
1344  slave->controller,
1345  fopc->operation_id,
1346  &msg->header,
1348  fopc);
1349  fopc->timeout_task =
1352  fopc);
1354  fopcq_tail,
1355  fopc);
1357  return;
1358  }
1359  if (GNUNET_NO == peer->details.local.is_running)
1360  {
1361  emsg = GNUNET_strdup("Peer not running\n");
1362  goto err_ret;
1363  }
1364  if ((0 != peer->reference_cnt)
1365  && ((0 == strcasecmp("core", service))
1366  || (0 == strcasecmp("transport", service))))
1367  {
1368  GNUNET_asprintf(&emsg, "Cannot stop %s service of peer with id: %u "
1369  "since it is required by existing operations",
1370  service, peer_id);
1371  goto err_ret;
1372  }
1373  ah = GNUNET_ARM_connect(peer->details.local.cfg, NULL, NULL);
1374  if (NULL == ah)
1375  {
1376  GNUNET_asprintf(&emsg,
1377  "Cannot connect to ARM service of peer with id: %u",
1378  peer_id);
1379  goto err_ret;
1380  }
1381  mctx = GNUNET_new(struct ManageServiceContext);
1382  mctx->peer = peer;
1383  peer->reference_cnt++;
1384  mctx->op_id = op_id;
1385  mctx->ah = ah;
1386  mctx->client = client;
1387  mctx->start = msg->start;
1388  mctx->service = GNUNET_strdup(service);
1390  mctx_tail,
1391  mctx);
1392  if (1 == mctx->start)
1394  service,
1397  mctx);
1398  else
1399  GNUNET_ARM_request_service_stop(mctx->ah, service,
1401  mctx);
1403  return;
1404 
1405 err_ret:
1406  LOG(GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1407  GST_send_operation_fail_msg(client, op_id, emsg);
1408  GNUNET_free(emsg);
1410 }
1411 
1412 
1416 void
1418 {
1419  struct Peer *peer;
1420  unsigned int id;
1421 
1422  if (NULL == GST_peer_list)
1423  return;
1424  for (id = 0; id < GST_peer_list_size; id++)
1425  {
1426  peer = GST_peer_list[id];
1427  if (NULL == peer)
1428  continue;
1429  /* If destroy flag is set it means that this peer should have been
1430  * destroyed by a context which we destroy before */
1432  /* counter should be zero as we free all contexts before */
1433  GNUNET_break(0 == peer->reference_cnt);
1434  if ((GNUNET_NO == peer->is_remote) &&
1435  (GNUNET_YES == peer->details.local.is_running))
1437  }
1438  for (id = 0; id < GST_peer_list_size; id++)
1439  {
1440  peer = GST_peer_list[id];
1441  if (NULL == peer)
1442  continue;
1443  if (GNUNET_NO == peer->is_remote)
1444  {
1445  if (GNUNET_YES == peer->details.local.is_running)
1449  }
1450  GNUNET_free(peer);
1451  }
1452  GNUNET_free_non_null(GST_peer_list);
1453  GST_peer_list = NULL;
1454  GST_peer_list_size = 0;
1455 }
1456 
1457 
1466 static void
1468  const struct GNUNET_MessageHeader *msg)
1469 {
1470  struct ForwardedOperationContext *fo_ctxt = cls;
1471  struct HandlerContext_ShutdownPeers *hc;
1472 
1473  hc = fo_ctxt->cls;
1474  GNUNET_assert(0 < hc->nslaves);
1475  hc->nslaves--;
1477  ntohs(msg->type))
1478  hc->timeout = GNUNET_YES;
1479  if (0 == hc->nslaves)
1480  {
1481  if (GNUNET_YES == hc->timeout)
1483  fo_ctxt->operation_id,
1484  "Timeout at a slave controller");
1485  else
1487  fo_ctxt->operation_id);
1488  GNUNET_free(hc);
1489  hc = NULL;
1490  }
1492  fopcq_tail,
1493  fo_ctxt);
1494  GNUNET_free(fo_ctxt);
1495 }
1496 
1497 
1504 void
1507 {
1508  struct GNUNET_SERVICE_Client *client = cls;
1509  struct HandlerContext_ShutdownPeers *hc;
1510  struct Slave *slave;
1511  struct ForwardedOperationContext *fo_ctxt;
1512  uint64_t op_id;
1513  unsigned int cnt;
1514 
1515  LOG_DEBUG("Received SHUTDOWN_PEERS\n");
1516  /* Stop and destroy all peers */
1517  GST_free_mctxq();
1518  GST_free_occq();
1519  GST_free_roccq();
1520  GST_clear_fopcq();
1521  /* Forward to all slaves which we have started */
1522  op_id = GNUNET_ntohll(msg->operation_id);
1524  /* FIXME: have a better implementation where we track which slaves are
1525  started by this controller */
1526  for (cnt = 0; cnt < GST_slave_list_size; cnt++)
1527  {
1528  slave = GST_slave_list[cnt];
1529  if (NULL == slave)
1530  continue;
1531  if (NULL == slave->controller_proc) /* We didn't start the slave */
1532  continue;
1533  LOG_DEBUG("Forwarding SHUTDOWN_PEERS\n");
1534  hc->nslaves++;
1535  fo_ctxt = GNUNET_new(struct ForwardedOperationContext);
1536  fo_ctxt->client = client;
1537  fo_ctxt->operation_id = op_id;
1538  fo_ctxt->cls = hc;
1539  fo_ctxt->type = OP_SHUTDOWN_PEERS;
1540  fo_ctxt->opc =
1542  fo_ctxt->operation_id,
1543  &msg->header,
1545  fo_ctxt);
1547  fopcq_tail,
1548  fo_ctxt);
1549  }
1550  LOG_DEBUG("Shutting down peers\n");
1552  if (0 == hc->nslaves)
1553  {
1555  op_id);
1556  GNUNET_free(hc);
1557  }
1559 }
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:454
Event notification from a controller to a client.
Definition: testbed.h:517
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:1511
uint32_t peer_id
The id of the peer relevant to this information.
Definition: testbed.h:593
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:90
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:238
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:234
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:286
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:1355
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2424
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:167
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:563
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:666
Message sent from client to testing service to destroy a (stopped) peer.
Definition: testbed.h:308
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:670
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:278
#define LOG(kind,...)
Definition: arm_api.c:33
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER.
Definition: testbed.h:203
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:584
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:429
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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:98
#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:96
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:78
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:75
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:572
#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:526
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:598
uint64_t operation_id
Operation ID.
Definition: testbed.h:675
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:505
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:2059
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1460
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:243
Reconfigure a peer.
Definition: testbed_api.h:73
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:1162
uint32_t peer_id
Peer that was started or stopped.
Definition: testbed.h:449
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Message sent from client to testing service to start a peer.
Definition: testbed.h:264
#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:246
struct GNUNET_ARM_Handle * ah
The ARM handle of the peer.
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:608
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:439
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:1405
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:1237
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:696
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.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:317
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:444
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:248
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:862
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:577
#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:567
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:63
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:53
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:480
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:603
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:2315
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:213
void * cls
Closure pointer.
Message sent from client to testing service to create (configure, but not start) a peer...
Definition: testbed.h:199
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:787
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:76
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:531
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:1362
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:701
Peer stop operation.
Definition: testbed_api.h:58
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1750
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:1536
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:103
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_START_PEER.
Definition: testbed.h:268
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:290
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.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
uint32_t peer_id
Unique ID of the peer whose service has to be managed.
Definition: testbed.h:691
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:83
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:682
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER.
Definition: testbed.h:312
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:208
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:48
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:1333
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:295
Header for all communications.
struct PeerReconfigureContext * next
DLL next for inclusoin in peer reconfigure operations list.
#define GNUNET_YES
Definition: gnunet_common.h:77
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:351
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.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:686
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:218
A peer has been stopped.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:300
Service was stopped (never sent for ARM itself).
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1552
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:2234
uint32_t dest
destination host
Get peer information operation.
Definition: testbed_api.h:68
#define LOG_DEBUG(...)
Debug logging shorthand.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:322
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:273
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:1437
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:956