GNUnet  0.19.5
gnunet-service-testbed_links.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2008--2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
28 #include "platform.h"
29 #include "gnunet-service-testbed.h"
30 
34 #ifdef LOG
35 #undef LOG
36 #endif
37 #define LOG(kind, ...) \
38  GNUNET_log_from (kind, "testbed-links", __VA_ARGS__)
39 
43 #define EVENT_MASK (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED)
44 
45 
50 {
55 
60 
65 
69  FINISHED
70 };
71 
72 
76 struct LCFContext
77 {
81  struct LCFContext *next;
82 
86  struct LCFContext *prev;
87 
91  struct Slave *gateway;
92 
97 
102 
107 
111  uint64_t operation_id;
112 
117 
121  enum LCFContextState state;
122 
127 
131  uint32_t slave_host_id;
132 };
133 
134 
140 {
145 
150 
154  struct Neighbour *n;
155 
160 
164  void *cb_cls;
165 };
166 
167 
171 struct Neighbour
172 {
177 
183 
188 
193 
198 
202  unsigned int reference_cnt;
203 
207  unsigned int inactive;
208 
212  uint32_t host_id;
213 };
214 
215 
219 static struct Neighbour **neighbour_list;
220 
224 static unsigned int neighbour_list_size;
225 
226 
232 {
237 
242 
246  struct Neighbour *n;
247 
252 
257 
262 
267  uint64_t op_id;
268 };
269 
274 
279 
284 
288 unsigned int GST_slave_list_size;
289 
293 static struct Route **route_list;
294 
298 static struct LCFContext *lcf_head;
299 
303 static struct LCFContext *lcf_tail;
304 
309 
313 static unsigned int route_list_size;
314 
315 
321 static void
322 slave_list_add (struct Slave *slave)
323 {
324  if (slave->host_id >= GST_slave_list_size)
327  slave->host_id);
328  GNUNET_assert (NULL == GST_slave_list[slave->host_id]);
329  GST_slave_list[slave->host_id] = slave;
330 }
331 
332 
342 static int
344  const struct GNUNET_HashCode *key,
345  void *value)
346 {
347  struct GNUNET_SERVICE_Client *client = cls;
348  struct RegisteredHostContext *rhc = value;
349  struct ForwardedOverlayConnectContext *focc;
350  struct ForwardedOverlayConnectContext *foccn;
351 
352  for (focc = rhc->focc_dll_head; NULL != focc; focc = foccn)
353  {
354  foccn = focc->next;
355  if (focc->client == client)
356  GST_cleanup_focc (focc);
357  }
358  return GNUNET_OK;
359 }
360 
361 
367 static void
368 route_list_add (struct Route *route)
369 {
370  if (route->dest >= route_list_size)
372  GNUNET_assert (NULL == route_list[route->dest]);
373  route_list[route->dest] = route;
374 }
375 
376 
383 static void
385 {
386  if (n->host_id >= neighbour_list_size)
388  n->host_id);
389  GNUNET_assert (NULL == neighbour_list[n->host_id]);
390  neighbour_list[n->host_id] = n;
391 }
392 
393 
397 void
399 {
400  unsigned int id;
401 
402  for (id = 0; id < route_list_size; id++)
403  if (NULL != route_list[id])
404  GNUNET_free (route_list[id]);
406  route_list = NULL;
407 }
408 
409 
419 static int
421  const struct GNUNET_HashCode *key,
422  void *value)
423 {
424  struct Slave *slave = cls;
425  struct RegisteredHostContext *rhc = value;
426  struct ForwardedOverlayConnectContext *focc;
427 
430  value));
431  while (NULL != (focc = rhc->focc_dll_head))
432  GST_cleanup_focc (focc);
433  GNUNET_free (value);
434  return GNUNET_YES;
435 }
436 
437 
443 static void
444 kill_slave (struct Slave *slave)
445 {
446  struct HostRegistration *hr_entry;
447 
448  while (NULL != (hr_entry = slave->hr_dll_head))
449  {
451  hr_entry);
452  GNUNET_free (hr_entry);
453  }
454  if (NULL != slave->rhandle)
459  slave));
461  if (NULL != slave->controller)
463  if (NULL != slave->controller_proc)
464  {
465  LOG_DEBUG ("Stopping a slave\n");
467  }
468 }
469 
470 
476 static void
477 destroy_slave (struct Slave *slave)
478 {
479  if (NULL != slave->controller_proc)
480  {
482  LOG_DEBUG ("Slave stopped\n");
483  }
484  GST_slave_list[slave->host_id] = NULL;
485  GNUNET_free (slave);
486 }
487 
488 
492 void
494 {
495  struct Slave *slave;
496  unsigned int id;
497 
498  for (id = 0; id < GST_slave_list_size; id++)
499  {
500  slave = GST_slave_list[id];
501  if (NULL == slave)
502  continue;
503  kill_slave (slave);
504  }
505  for (id = 0; id < GST_slave_list_size; id++)
506  {
507  slave = GST_slave_list[id];
508  if (NULL == slave)
509  continue;
510  destroy_slave (slave);
511  }
513  GST_slave_list = NULL;
514 }
515 
516 
525 struct Route *
526 GST_find_dest_route (uint32_t host_id)
527 {
528  struct Route *route;
529 
530  if (route_list_size <= host_id)
531  return NULL;
532  while (NULL != (route = route_list[host_id]))
533  {
534  if (route->thru == GST_context->host_id)
535  break;
536  host_id = route->thru;
537  }
538  return route;
539 }
540 
541 
554 static void
556  uint64_t operation_id,
557  const struct GNUNET_CONFIGURATION_Handle *cfg,
558  const char *emsg)
559 {
560  struct GNUNET_MQ_Envelope *env;
562  char *xconfig;
563  size_t config_size;
564  size_t xconfig_size;
565  uint16_t msize;
566 
567  GNUNET_assert ((NULL == cfg) || (NULL == emsg));
568  xconfig = NULL;
569  xconfig_size = 0;
570  config_size = 0;
571  msize = 0;
572  if (NULL != cfg)
573  {
575  &config_size,
576  &xconfig_size);
577  msize += xconfig_size;
578  }
579  if (NULL != emsg)
580  msize += strlen (emsg);
582  msize,
584  if (NULL == emsg)
585  msg->success = htons (GNUNET_YES);
586  msg->operation_id = GNUNET_htonll (operation_id);
587  msg->config_size = htons ((uint16_t) config_size);
588  if (NULL != xconfig)
589  {
590  GNUNET_memcpy (&msg[1],
591  xconfig,
592  xconfig_size);
593  GNUNET_free (xconfig);
594  }
595  if (NULL != emsg)
596  GNUNET_memcpy (&msg[1],
597  emsg,
598  strlen (emsg));
600  env);
601 }
602 
603 
609 static void
610 lcf_proc_task (void *cls);
611 
612 
619 static void
620 lcf_proc_cc (void *cls,
621  const char *emsg)
622 {
623  struct LCFContext *lcf = cls;
624 
626  switch (lcf->state)
627  {
628  case INIT:
629  if (NULL != emsg)
630  goto registration_error;
633  break;
634 
636  if (NULL != emsg)
637  goto registration_error;
640  break;
641 
642  default:
643  GNUNET_assert (0); /* Shouldn't reach here */
644  }
645  return;
646 
647 registration_error:
649  "Host registration failed with message: %s\n",
650  emsg);
651  lcf->state = FINISHED;
653  lcf);
654 }
655 
656 
662 static void
663 lcf_proc_task (void *cls);
664 
665 
671 static void
673 {
674  struct LCFContext *lcf = cls;
675 
676  lcf->timeout_task = NULL;
677  // GST_forwarded_operation_timeout (lcf->fopc, tc);
679  "A forwarded controller link operation has timed out\n");
681  lcf->operation_id,
682  NULL,
683  "A forwarded controller link operation has timed out\n");
686  lcf);
687 }
688 
689 
695 static void
696 lcf_proc_task (void *cls)
697 {
698  struct LCFContext *lcf = cls;
699 
700  lcf_proc_task_id = NULL;
701  switch (lcf->state)
702  {
703  case INIT:
704  if (GNUNET_NO ==
706  [lcf->delegated_host_id],
707  lcf->gateway->controller))
708  {
711  }
712  else
713  {
716  }
717  break;
718 
720  if (GNUNET_NO ==
722  lcf->gateway->controller))
723  {
726  }
727  else
728  {
731  }
732  break;
733 
736  lcf->gateway->controller,
737  GST_host_list[lcf->
740  lcf->is_subordinate);
741  lcf->timeout_task =
744  lcf);
745  lcf->state = FINISHED;
746  break;
747 
748  case FINISHED:
749  if (NULL != lcf->op)
752  lcf_tail,
753  lcf);
754  GNUNET_free (lcf);
755  if (NULL != lcf_head)
757  lcf_head);
758  }
759 }
760 
761 
768 static void
769 slave_event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
770 {
771  struct LCFContext *lcf;
772 
773  /* We currently only get here when working on LCFContexts */
775  lcf = event->op_cls;
776  GNUNET_assert (lcf->op == event->op);
778  lcf->op = NULL;
779  GNUNET_assert (FINISHED == lcf->state);
780  GNUNET_assert (NULL != lcf->timeout_task);
782  if (NULL == event->details.operation_finished.emsg)
786  NULL);
787  else
789  NULL,
790  event->details.operation_finished.emsg);
793  return;
794 }
795 
796 
806 static void
807 slave_status_cb (void *cls,
808  const struct GNUNET_CONFIGURATION_Handle *cfg,
809  int status)
810 {
811  struct Slave *slave = cls;
812  struct LinkControllersContext *lcc;
813 
814  lcc = slave->lcc;
815  if (GNUNET_SYSERR == status)
816  {
817  slave->controller_proc = NULL;
818  /* Stop all link controller forwarding tasks since we shutdown here anyway
819  and as these tasks they depend on the operation queues which are created
820  through GNUNET_TESTBED_controller_connect() and in kill_slave() we call
821  the destructor function GNUNET_TESTBED_controller_disconnect() */
822  GST_free_lcf ();
823  kill_slave (slave);
824  destroy_slave (slave);
825  slave = NULL;
826  LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n");
827  GNUNET_SCHEDULER_shutdown (); /* We too shutdown */
828  goto clean_lcc;
829  }
830  slave->controller =
833  slave);
834  if (NULL != slave->controller)
835  {
837  }
838  else
839  {
841  "Could not connect to delegated controller");
842  kill_slave (slave);
843  destroy_slave (slave);
844  slave = NULL;
845  }
846 
847 clean_lcc:
848  if (NULL != lcc)
849  {
850  if (NULL != lcc->client)
851  {
853  lcc->client = NULL;
854  }
855  GNUNET_free (lcc);
856  }
857  if (NULL != slave)
858  slave->lcc = NULL;
859 }
860 
861 
870 static void
871 trigger_notifications (struct Neighbour *n);
872 
873 
880 static void
882 {
883  struct Neighbour *n = cls;
885 
886  GNUNET_assert (NULL != (h = n->nl_head));
887  GNUNET_assert (NULL != n->notify_task);
888  n->notify_task = NULL;
889  GNUNET_assert (NULL != n->controller);
892  h->cb (h->cb_cls, n->controller);
893  GNUNET_free (h);
894 }
895 
896 
905 static void
907 {
908  GNUNET_assert (NULL != n->conn_op);
909  if (NULL == n->nl_head)
910  return;
911  if (NULL == n->controller)
912  return;
913  if (NULL != n->notify_task)
914  return;
915  if (1 == n->inactive)
916  {
917  GNUNET_assert (0 == n->reference_cnt);
919  n->inactive = 0;
920  }
921  n->reference_cnt++;
922  n->notify_task =
924 }
925 
926 
934 static void
936 {
937  struct Neighbour *n = cls;
938 
939  GNUNET_assert (NULL != n->conn_op);
940  GNUNET_assert (NULL == n->controller);
941  LOG_DEBUG ("Opening connection to controller on host %u\n", n->host_id);
943  EVENT_MASK,
945  NULL);
947 }
948 
949 
955 static void
957 {
958  struct Neighbour *n = cls;
959 
960  GNUNET_assert (0 == n->reference_cnt);
961  GNUNET_assert (NULL == n->notify_task);
962  GNUNET_assert (NULL == n->nl_head);
963  if (NULL != n->controller)
964  {
965  LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id);
967  n->controller = NULL;
968  }
969  n->conn_op = NULL;
970  n->inactive = 0;
971 }
972 
973 
988  void *cb_cls)
989 {
991 
992  GNUNET_assert (NULL != cb);
993  LOG_DEBUG ("Attempting to get connection to controller on host %u\n",
994  n->host_id);
996  h->n = n;
997  h->cb = cb;
998  h->cb_cls = cb_cls;
1000  if (NULL == n->conn_op)
1001  {
1002  GNUNET_assert (NULL == n->controller);
1007  return h;
1008  }
1010  return h;
1011 }
1012 
1013 
1019 void
1021 {
1022  struct Neighbour *n;
1023  int cleanup_task;
1024 
1025  n = h->n;
1026  cleanup_task = (h == n->nl_head) ? GNUNET_YES : GNUNET_NO;
1028  GNUNET_free (h);
1029  if (GNUNET_NO == cleanup_task)
1030  return;
1031  if (NULL == n->notify_task)
1032  return;
1033  GNUNET_assert (0 < n->reference_cnt);
1034  n->reference_cnt--;
1036  n->notify_task = NULL;
1037  if (NULL == n->nl_head)
1038  {
1039  if ((0 == n->reference_cnt) && (0 == n->inactive))
1040  {
1041  n->inactive = 1;
1043  }
1044  return;
1045  }
1047 }
1048 
1049 
1057 void
1059 {
1060  GNUNET_assert (0 == n->inactive);
1061  GNUNET_assert (0 < n->reference_cnt);
1062  n->reference_cnt--;
1063  if (0 == n->reference_cnt)
1064  {
1065  n->inactive = 1;
1067  }
1068 }
1069 
1070 
1076 static void
1078 {
1079  if (NULL != ncc->nh)
1081  if (NULL != ncc->timeout_task)
1084  ncc_tail,
1085  ncc);
1086  GNUNET_free (ncc);
1087 }
1088 
1089 
1093 void
1095 {
1096  struct Neighbour *n;
1097  unsigned int id;
1098 
1099  for (id = 0; id < neighbour_list_size; id++)
1100  {
1101  if (NULL == (n = neighbour_list[id]))
1102  continue;
1103  if (NULL != n->conn_op)
1105  GNUNET_free (n);
1106  neighbour_list[id] = NULL;
1107  }
1109 }
1110 
1111 
1119 struct Neighbour *
1120 GST_get_neighbour (uint32_t id)
1121 {
1122  if (neighbour_list_size <= id)
1123  return NULL;
1124  return neighbour_list[id];
1125 }
1126 
1127 
1131 void
1133 {
1134  while (NULL != ncc_head)
1136 }
1137 
1138 
1144 static void
1146 {
1147  struct NeighbourConnectCtxt *ncc = cls;
1148 
1149  ncc->timeout_task = NULL;
1151  ncc->op_id,
1152  NULL,
1153  "Could not connect to delegated controller");
1154  cleanup_ncc (ncc);
1155 }
1156 
1157 
1164 static void
1166  struct GNUNET_TESTBED_Controller *c)
1167 {
1168  struct NeighbourConnectCtxt *ncc = cls;
1169 
1171  ncc->timeout_task = NULL;
1172  ncc->nh = NULL;
1175  ncc->op_id,
1176  NULL,
1177  NULL);
1178  cleanup_ncc (ncc);
1179 }
1180 
1181 
1187 struct Neighbour *
1189 {
1190  struct Neighbour *n;
1191 
1192  n = GNUNET_new (struct Neighbour);
1194  neighbour_list_add (n); /* just add; connect on-demand */
1195  return n;
1196 }
1197 
1198 
1205 void
1208 {
1209  struct GNUNET_SERVICE_Client *client = cls;
1210  struct LCFContext *lcf;
1211  struct Route *route;
1212  struct Route *new_route;
1213  uint64_t op_id;
1214  uint32_t delegated_host_id;
1215  uint32_t slave_host_id;
1216 
1217  if (NULL == GST_context)
1218  {
1219  GNUNET_break (0);
1220  GNUNET_SERVICE_client_drop (client);
1221  return;
1222  }
1223  delegated_host_id = ntohl (msg->delegated_host_id);
1224  if (delegated_host_id == GST_context->host_id)
1225  {
1226  GNUNET_break (0);
1228  "Trying to link ourselves\n");
1229  GNUNET_SERVICE_client_drop (client);
1230  return;
1231  }
1232  if ((delegated_host_id >= GST_host_list_size) ||
1233  (NULL == GST_host_list[delegated_host_id]))
1234  {
1236  "Delegated host %u not registered with us\n",
1237  delegated_host_id);
1238  GNUNET_SERVICE_client_drop (client);
1239  return;
1240  }
1241  slave_host_id = ntohl (msg->slave_host_id);
1242  if ((slave_host_id >= GST_host_list_size) ||
1243  (NULL == GST_host_list[slave_host_id]))
1244  {
1246  "Slave host %u not registered with us\n",
1247  slave_host_id);
1248  GNUNET_SERVICE_client_drop (client);
1249  return;
1250  }
1251  if (slave_host_id == delegated_host_id)
1252  {
1254  "Slave and delegated host are same\n");
1255  GNUNET_SERVICE_client_drop (client);
1256  return;
1257  }
1258  op_id = GNUNET_ntohll (msg->operation_id);
1259  if (slave_host_id == GST_context->host_id) /* Link from us */
1260  {
1261  struct Slave *slave;
1262  struct LinkControllersContext *lcc;
1263 
1264  if (1 != msg->is_subordinate)
1265  {
1266  struct Neighbour *n;
1267  struct NeighbourConnectCtxt *ncc;
1268 
1269  if ((delegated_host_id < neighbour_list_size) &&
1270  (NULL != neighbour_list[delegated_host_id]))
1271  {
1272  GNUNET_break (0);
1274  return;
1275  }
1276  LOG_DEBUG ("Received request to establish a link to host %u\n",
1277  delegated_host_id);
1278  n = GST_create_neighbour (GST_host_list[delegated_host_id]);
1279  ncc = GNUNET_new (struct NeighbourConnectCtxt);
1280  ncc->n = n;
1281  ncc->op_id = op_id;
1282  ncc->client = client;
1285  ncc);
1286  ncc->timeout_task
1289  ncc);
1291  ncc_tail,
1292  ncc);
1294  return;
1295  }
1296  if ((delegated_host_id < GST_slave_list_size) &&
1297  (NULL != GST_slave_list[delegated_host_id]))
1298  {
1299  GNUNET_break (0);
1301  return;
1302  }
1303  LOG_DEBUG ("Received request to start and establish a link to host %u\n",
1304  delegated_host_id);
1305  slave = GNUNET_new (struct Slave);
1306  slave->host_id = delegated_host_id;
1308  GNUNET_NO);
1309  slave_list_add (slave);
1310  lcc = GNUNET_new (struct LinkControllersContext);
1311  lcc->operation_id = op_id;
1312  lcc->client = client;
1313  slave->lcc = lcc;
1314  slave->controller_proc
1316  GST_host_list[slave->host_id],
1317  &slave_status_cb,
1318  slave);
1319  new_route = GNUNET_new (struct Route);
1320  new_route->dest = delegated_host_id;
1321  new_route->thru = GST_context->host_id;
1322  route_list_add (new_route);
1323  return;
1324  }
1325 
1326  /* Route the request */
1327  if (slave_host_id >= route_list_size)
1328  {
1330  "No route towards slave host");
1332  return;
1333  }
1334  lcf = GNUNET_new (struct LCFContext);
1335  lcf->delegated_host_id = delegated_host_id;
1336  lcf->slave_host_id = slave_host_id;
1337  route = GST_find_dest_route (slave_host_id);
1338  GNUNET_assert (NULL != route); /* because we add routes carefully */
1340  GNUNET_assert (NULL != GST_slave_list[route->dest]);
1341  lcf->is_subordinate = msg->is_subordinate;
1342  lcf->state = INIT;
1343  lcf->operation_id = op_id;
1344  lcf->gateway = GST_slave_list[route->dest];
1345  lcf->client = client;
1346  if (NULL == lcf_head)
1347  {
1348  GNUNET_assert (NULL == lcf_proc_task_id);
1350  lcf_tail,
1351  lcf);
1353  lcf);
1354  }
1355  else
1356  {
1358  lcf_tail,
1359  lcf);
1360  }
1361  /* FIXME: Adding a new route should happen after the controllers are linked
1362  * successfully */
1363  if (1 != msg->is_subordinate)
1364  {
1366  return;
1367  }
1368  if ((delegated_host_id < route_list_size) &&
1369  (NULL != route_list[delegated_host_id]))
1370  {
1371  GNUNET_break_op (0); /* Are you trying to link delegated host twice
1372  * with is subordinate flag set to GNUNET_YES? */
1374  return;
1375  }
1376  new_route = GNUNET_new (struct Route);
1377  new_route->dest = delegated_host_id;
1378  new_route->thru = route->dest;
1379  route_list_add (new_route);
1381 }
1382 
1383 
1390 void
1392 {
1393  struct NeighbourConnectCtxt *ncc;
1394  struct NeighbourConnectCtxt *nccn;
1395  struct LCFContext *lcf;
1396  struct LCFContext *lcfn;
1397 
1398  for (ncc = ncc_head; NULL != ncc; ncc = nccn)
1399  {
1400  nccn = ncc->next;
1401  if (ncc->client == client)
1402  cleanup_ncc (ncc);
1403  }
1404  for (unsigned int i = 0; i < GST_slave_list_size; i++)
1405  {
1406  struct Slave *slave = GST_slave_list[i];
1407  struct LinkControllersContext *lcc;
1408 
1409  if (NULL == slave)
1410  continue;
1413  client);
1414  lcc = slave->lcc;
1415  if (NULL == lcc)
1416  continue;
1417  if (lcc->client == client)
1418  {
1419  slave->lcc = NULL;
1420  GNUNET_free (lcc);
1421  }
1422  }
1423  for (lcf = lcf_head; NULL != lcf; lcf = lcfn)
1424  {
1425  lcfn = lcf->next;
1426  if ((NULL != lcf) &&
1427  (client == lcf->client))
1428  {
1429  if (NULL != lcf->op)
1432  lcf_tail,
1433  lcf);
1434  GNUNET_free (lcf);
1435  }
1436  }
1437 }
1438 
1439 
1443 void
1445 {
1446  struct LCFContext *lcf;
1447 
1448  if (NULL != lcf_head)
1449  {
1450  if (NULL != lcf_proc_task_id)
1451  {
1453  lcf_proc_task_id = NULL;
1454  }
1455  }
1456  GNUNET_assert (NULL == lcf_proc_task_id);
1457  for (lcf = lcf_head; NULL != lcf; lcf = lcf_head)
1458  {
1459  if (NULL != lcf->op)
1461  if (NULL != lcf->timeout_task)
1464  lcf_tail,
1465  lcf);
1466  GNUNET_free (lcf);
1467  }
1468 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct GNUNET_HashCode key
The key used in the DHT.
uint16_t status
See PRISM_STATUS_*-constants.
static char * value
Value of the record to add/remove.
#define LOG_DEBUG(...)
Debug logging shorthand.
static struct GNUNET_SCHEDULER_Task * cleanup_task
Cleanup task.
struct OperationQueue * GST_opq_openfds
Operation queue for open file descriptors.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
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.
unsigned int GST_host_list_size
The size of the host list.
void GST_queue_host_registration(struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
Adds a host registration's request to a slave's registration queue.
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 ...
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
#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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#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
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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:63
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
Message to signal the result of GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS request.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1299
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
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2021
void GNUNET_TESTBED_cancel_registration(struct GNUNET_TESTBED_HostRegistrationHandle *handle)
Cancel the pending registration.
void GNUNET_TESTBED_controller_disconnect(struct GNUNET_TESTBED_Controller *c)
Stop the given controller (also will terminate all peers and controllers dependent on this controller...
Definition: testbed_api.c:1721
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_controller_link(void *op_cls, struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Host *delegated_host, struct GNUNET_TESTBED_Host *slave_host, int is_subordinate)
Create a link from slave controller to delegated controller.
Definition: testbed_api.c:1832
struct GNUNET_TESTBED_Controller * GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
Connect to a controller process.
Definition: testbed_api.c:1555
struct GNUNET_TESTBED_ControllerProc * GNUNET_TESTBED_controller_start(const char *trusted_ip, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_ControllerStatusCallback cb, void *cls)
Starts a controller process at the given host.
@ GNUNET_TESTBED_ET_OPERATION_FINISHED
A requested testbed operation has been completed.
char * master_ip
The network address of the master controller.
uint32_t host_id
Our host id according to this context.
Context information to used during operations which forward the overlay connect message.
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
struct ForwardedOverlayConnectContext * next
next ForwardedOverlayConnectContext in the DLL
struct GNUNET_SERVICE_Client * client
The client handle.
A 512-bit hashcode.
Entry in list of pending tasks.
Definition: scheduler.c:136
Handle to a client that is connected to a service.
Definition: service.c:252
Client notifies controller that it should delegate requests for a particular client to a particular s...
Definition: testbed.h:137
Response message for ControllerLinkRequest message.
Definition: testbed.h:170
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:190
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:180
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
enum GNUNET_TESTBED_EventType type
Type of the event.
struct GNUNET_TESTBED_Operation * op
Handle for the corresponding operation that generated this event.
union GNUNET_TESTBED_EventInformation::@43 details
Details about the event.
struct GNUNET_TESTBED_EventInformation::@43::@48 operation_finished
Details about an operation finished event.
Opaque handle to a host running experiments managed by the testing framework.
Opaque handle to an abstract operation to be executed by the testing framework.
A DLL of host registrations to be made.
Link controllers request forwarding context.
enum LCFContextState state
The state of this context.
uint32_t delegated_host_id
The delegated host.
struct GNUNET_SERVICE_Client * client
The client which has asked to perform this operation.
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
uint32_t slave_host_id
The slave host.
uint64_t operation_id
The id of the operation which created this context.
struct LCFContext * prev
The LCFContext.
struct Slave * gateway
The gateway which will pass the link message to delegated host.
int is_subordinate
should the slave controller start the delegated controller?
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.
struct LCFContext * next
The LCFContext.
Context information used while linking controllers.
uint64_t operation_id
The ID of the operation.
struct GNUNET_SERVICE_Client * client
The client which initiated the link controller operation.
Context information for establishing a link to neighbour (Used is GST_handle_link_controllers()
struct NeighbourConnectNotification * nh
The notification handle associated with the neighbour's connection request.
uint64_t op_id
The id of the link-controllers operation responsible for creating this context.
struct NeighbourConnectCtxt * prev
DLL tail.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run upon timeout.
struct Neighbour * n
The neighbour to whom connection should be made.
struct NeighbourConnectCtxt * next
DLL next for inclusion in the corresponding context list.
struct GNUNET_SERVICE_Client * client
The client requesting the connection.
Notification context to be used to notify when connection to the neighbour's controller is opened.
GST_NeighbourConnectNotifyCallback cb
The notification callback to call when we are connect to neighbour.
struct NeighbourConnectNotification * prev
DLL prev.
struct Neighbour * n
The neighbour.
void * cb_cls
The closure for the above callback.
struct NeighbourConnectNotification * next
DLL next for inclusion in neighbour's list of notification requests.
A connected controller which is not our child.
struct NeighbourConnectNotification * nl_tail
DLL tail for the list of notification requests.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
unsigned int reference_cnt
How many references are present currently to this neighbour's connection.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
unsigned int inactive
Is the conn_op inactivated?
struct GNUNET_SCHEDULER_Task * notify_task
Task id for the task to call notifications from the notification list.
uint32_t host_id
The id of the host this controller is running on.
This context information will be created for each host that is registered at slave controllers during...
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
A routing entry.
uint32_t thru
The destination host is reachable thru.
uint32_t dest
destination host
Structure representing a connected(directly-linked) controller.
uint32_t host_id
The id of the host this controller is running on.
struct HostRegistration * hr_dll_tail
Tail of the host registration DLL.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct HostRegistration * hr_dll_head
Head of the host registration DLL.
struct GNUNET_TESTBED_HostRegistrationHandle * rhandle
The current host registration handle.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
struct LinkControllersContext * lcc
handle to lcc which is associated with this slave startup.
char * GNUNET_TESTBED_compress_cfg_(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size, size_t *xsize)
Function to serialize and compress using zlib a configuration through a configuration handle.
Definition: testbed_api.c:1785
int GNUNET_TESTBED_is_host_registered_(const struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
Checks whether a host has been registered.
void GNUNET_TESTBED_controller_kill_(struct GNUNET_TESTBED_ControllerProc *cproc)
Sends termination signal to the controller's helper process.
void GNUNET_TESTBED_controller_destroy_(struct GNUNET_TESTBED_ControllerProc *cproc)
Cleans-up the controller's helper process handle.
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's configuration template.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain a host's unique global ID.
void GNUNET_TESTBED_operation_activate_(struct GNUNET_TESTBED_Operation *op)
Marks and inactive operation as active.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an 'operation' to be performed.
void GNUNET_TESTBED_operation_release_(struct GNUNET_TESTBED_Operation *op)
An operation is 'done' (was cancelled or finished); remove it from the queues and release associated ...
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
void GNUNET_TESTBED_operation_inactivate_(struct GNUNET_TESTBED_Operation *op)
Marks an active operation as inactive - the operation will be kept in a ready-to-be-released state an...
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.