GNUnet  0.10.x
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 "gnunet-service-testbed.h"
29 
33 #ifdef LOG
34 #undef LOG
35 #endif
36 #define LOG(kind, ...) \
37  GNUNET_log_from(kind, "testbed-links", __VA_ARGS__)
38 
42 #define EVENT_MASK (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED)
43 
44 
53 
58 
63 
68 };
69 
70 
74 struct LCFContext {
78  struct LCFContext *next;
79 
83  struct LCFContext *prev;
84 
88  struct Slave *gateway;
89 
94 
99 
104 
108  uint64_t operation_id;
109 
114 
119 
124 
128  uint32_t slave_host_id;
129 };
130 
131 
141 
146 
150  struct Neighbour *n;
151 
156 
160  void *cb_cls;
161 };
162 
163 
167 struct Neighbour {
172 
178 
183 
188 
193 
197  unsigned int reference_cnt;
198 
202  unsigned int inactive;
203 
207  uint32_t host_id;
208 };
209 
210 
214 static struct Neighbour **neighbour_list;
215 
219 static unsigned int neighbour_list_size;
220 
221 
231 
236 
240  struct Neighbour *n;
241 
246 
251 
256 
261  uint64_t op_id;
262 };
263 
268 
273 
278 
282 unsigned int GST_slave_list_size;
283 
287 static struct Route **route_list;
288 
292 static struct LCFContext *lcf_head;
293 
297 static struct LCFContext *lcf_tail;
298 
303 
307 static unsigned int route_list_size;
308 
309 
315 static void
316 slave_list_add(struct Slave *slave)
317 {
318  if (slave->host_id >= GST_slave_list_size)
319  GST_array_grow_large_enough(GST_slave_list,
321  slave->host_id);
322  GNUNET_assert(NULL == GST_slave_list[slave->host_id]);
323  GST_slave_list[slave->host_id] = slave;
324 }
325 
326 
336 static int
338  const struct GNUNET_HashCode *key,
339  void *value)
340 {
341  struct GNUNET_SERVICE_Client *client = cls;
342  struct RegisteredHostContext *rhc = value;
343  struct ForwardedOverlayConnectContext *focc;
344  struct ForwardedOverlayConnectContext *foccn;
345 
346  for (focc = rhc->focc_dll_head; NULL != focc; focc = foccn)
347  {
348  foccn = focc->next;
349  if (focc->client == client)
350  GST_cleanup_focc(focc);
351  }
352  return GNUNET_OK;
353 }
354 
355 
361 static void
362 route_list_add(struct Route *route)
363 {
364  if (route->dest >= route_list_size)
365  GST_array_grow_large_enough(route_list, route_list_size, route->dest);
366  GNUNET_assert(NULL == route_list[route->dest]);
367  route_list[route->dest] = route;
368 }
369 
370 
377 static void
379 {
380  if (n->host_id >= neighbour_list_size)
382  GNUNET_assert(NULL == neighbour_list[n->host_id]);
383  neighbour_list[n->host_id] = n;
384 }
385 
386 
390 void
392 {
393  unsigned int id;
394 
395  for (id = 0; id < route_list_size; id++)
396  if (NULL != route_list[id])
397  GNUNET_free(route_list[id]);
398  GNUNET_free_non_null(route_list);
399  route_list = NULL;
400 }
401 
402 
412 static int
414  const struct GNUNET_HashCode *key,
415  void *value)
416 {
417  struct Slave *slave = cls;
418  struct RegisteredHostContext *rhc = value;
419  struct ForwardedOverlayConnectContext *focc;
420 
423  value));
424  while (NULL != (focc = rhc->focc_dll_head))
425  GST_cleanup_focc(focc);
426  GNUNET_free(value);
427  return GNUNET_YES;
428 }
429 
430 
436 static void
437 kill_slave(struct Slave *slave)
438 {
439  struct HostRegistration *hr_entry;
440 
441  while (NULL != (hr_entry = slave->hr_dll_head))
442  {
444  hr_entry);
445  GNUNET_free(hr_entry);
446  }
447  if (NULL != slave->rhandle)
452  slave));
454  if (NULL != slave->controller)
456  if (NULL != slave->controller_proc)
457  {
458  LOG_DEBUG("Stopping a slave\n");
460  }
461 }
462 
463 
469 static void
470 destroy_slave(struct Slave *slave)
471 {
472  if (NULL != slave->controller_proc)
473  {
475  LOG_DEBUG("Slave stopped\n");
476  }
477  GST_slave_list[slave->host_id] = NULL;
478  GNUNET_free(slave);
479 }
480 
481 
485 void
487 {
488  struct Slave *slave;
489  unsigned int id;
490 
491  for (id = 0; id < GST_slave_list_size; id++)
492  {
493  slave = GST_slave_list[id];
494  if (NULL == slave)
495  continue;
496  kill_slave(slave);
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  destroy_slave(slave);
504  }
505  GNUNET_free_non_null(GST_slave_list);
506  GST_slave_list = NULL;
507 }
508 
509 
518 struct Route *
519 GST_find_dest_route(uint32_t host_id)
520 {
521  struct Route *route;
522 
523  if (route_list_size <= host_id)
524  return NULL;
525  while (NULL != (route = route_list[host_id]))
526  {
527  if (route->thru == GST_context->host_id)
528  break;
529  host_id = route->thru;
530  }
531  return route;
532 }
533 
534 
547 static void
549  uint64_t operation_id,
550  const struct GNUNET_CONFIGURATION_Handle *cfg,
551  const char *emsg)
552 {
553  struct GNUNET_MQ_Envelope *env;
555  char *xconfig;
556  size_t config_size;
557  size_t xconfig_size;
558  uint16_t msize;
559 
560  GNUNET_assert((NULL == cfg) || (NULL == emsg));
561  xconfig = NULL;
562  xconfig_size = 0;
563  config_size = 0;
564  msize = 0;
565  if (NULL != cfg)
566  {
567  xconfig = GNUNET_TESTBED_compress_cfg_(cfg,
568  &config_size,
569  &xconfig_size);
570  msize += xconfig_size;
571  }
572  if (NULL != emsg)
573  msize += strlen(emsg);
574  env = GNUNET_MQ_msg_extra(msg,
575  msize,
577  if (NULL == emsg)
578  msg->success = htons(GNUNET_YES);
579  msg->operation_id = GNUNET_htonll(operation_id);
580  msg->config_size = htons((uint16_t)config_size);
581  if (NULL != xconfig)
582  {
583  GNUNET_memcpy(&msg[1],
584  xconfig,
585  xconfig_size);
586  GNUNET_free(xconfig);
587  }
588  if (NULL != emsg)
589  GNUNET_memcpy(&msg[1],
590  emsg,
591  strlen(emsg));
593  env);
594 }
595 
596 
602 static void
603 lcf_proc_task(void *cls);
604 
605 
612 static void
613 lcf_proc_cc(void *cls,
614  const char *emsg)
615 {
616  struct LCFContext *lcf = cls;
617 
618  GNUNET_assert(NULL == lcf_proc_task_id);
619  switch (lcf->state)
620  {
621  case INIT:
622  if (NULL != emsg)
623  goto registration_error;
625  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task, lcf);
626  break;
627 
629  if (NULL != emsg)
630  goto registration_error;
632  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task, lcf);
633  break;
634 
635  default:
636  GNUNET_assert(0); /* Shouldn't reach here */
637  }
638  return;
639 
640 registration_error:
642  "Host registration failed with message: %s\n",
643  emsg);
644  lcf->state = FINISHED;
645  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task,
646  lcf);
647 }
648 
649 
655 static void
656 lcf_proc_task(void *cls);
657 
658 
664 static void
666 {
667  struct LCFContext *lcf = cls;
668 
669  lcf->timeout_task = NULL;
670  // GST_forwarded_operation_timeout (lcf->fopc, tc);
672  "A forwarded controller link operation has timed out\n");
674  lcf->operation_id,
675  NULL,
676  "A forwarded controller link operation has timed out\n");
677  GNUNET_assert(NULL == lcf_proc_task_id);
678  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task,
679  lcf);
680 }
681 
682 
688 static void
689 lcf_proc_task(void *cls)
690 {
691  struct LCFContext *lcf = cls;
692 
693  lcf_proc_task_id = NULL;
694  switch (lcf->state)
695  {
696  case INIT:
697  if (GNUNET_NO ==
699  [lcf->delegated_host_id],
700  lcf->gateway->controller))
701  {
704  }
705  else
706  {
708  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task, lcf);
709  }
710  break;
711 
713  if (GNUNET_NO ==
715  lcf->gateway->controller))
716  {
719  }
720  else
721  {
723  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task, lcf);
724  }
725  break;
726 
729  lcf->gateway->controller,
732  lcf->is_subordinate);
733  lcf->timeout_task =
736  lcf);
737  lcf->state = FINISHED;
738  break;
739 
740  case FINISHED:
741  if (NULL != lcf->op)
744  lcf_tail,
745  lcf);
746  GNUNET_free(lcf);
747  if (NULL != lcf_head)
748  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task,
749  lcf_head);
750  }
751 }
752 
753 
760 static void
761 slave_event_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
762 {
763  struct LCFContext *lcf;
764 
765  /* We currently only get here when working on LCFContexts */
767  lcf = event->op_cls;
768  GNUNET_assert(lcf->op == event->op);
770  lcf->op = NULL;
771  GNUNET_assert(FINISHED == lcf->state);
772  GNUNET_assert(NULL != lcf->timeout_task);
774  if (NULL == event->details.operation_finished.emsg)
778  NULL);
779  else
781  NULL,
782  event->details.operation_finished.emsg);
783  GNUNET_assert(NULL == lcf_proc_task_id);
784  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task, lcf);
785  return;
786 }
787 
788 
798 static void
799 slave_status_cb(void *cls,
800  const struct GNUNET_CONFIGURATION_Handle *cfg,
801  int status)
802 {
803  struct Slave *slave = cls;
804  struct LinkControllersContext *lcc;
805 
806  lcc = slave->lcc;
807  if (GNUNET_SYSERR == status)
808  {
809  slave->controller_proc = NULL;
810  /* Stop all link controller forwarding tasks since we shutdown here anyway
811  and as these tasks they depend on the operation queues which are created
812  through GNUNET_TESTBED_controller_connect() and in kill_slave() we call
813  the destructor function GNUNET_TESTBED_controller_disconnect() */
814  GST_free_lcf();
815  kill_slave(slave);
816  destroy_slave(slave);
817  slave = NULL;
818  LOG(GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n");
819  GNUNET_SCHEDULER_shutdown(); /* We too shutdown */
820  goto clean_lcc;
821  }
822  slave->controller =
825  slave);
826  if (NULL != slave->controller)
827  {
828  send_controller_link_response(lcc->client, lcc->operation_id, cfg, NULL);
829  }
830  else
831  {
833  "Could not connect to delegated controller");
834  kill_slave(slave);
835  destroy_slave(slave);
836  slave = NULL;
837  }
838 
839 clean_lcc:
840  if (NULL != lcc)
841  {
842  if (NULL != lcc->client)
843  {
845  lcc->client = NULL;
846  }
847  GNUNET_free(lcc);
848  }
849  if (NULL != slave)
850  slave->lcc = NULL;
851 }
852 
853 
862 static void
864 
865 
872 static void
874 {
875  struct Neighbour *n = cls;
877 
878  GNUNET_assert(NULL != (h = n->nl_head));
879  GNUNET_assert(NULL != n->notify_task);
880  n->notify_task = NULL;
881  GNUNET_assert(NULL != n->controller);
884  h->cb(h->cb_cls, n->controller);
885  GNUNET_free(h);
886 }
887 
888 
897 static void
899 {
900  GNUNET_assert(NULL != n->conn_op);
901  if (NULL == n->nl_head)
902  return;
903  if (NULL == n->controller)
904  return;
905  if (NULL != n->notify_task)
906  return;
907  if (1 == n->inactive)
908  {
909  GNUNET_assert(0 == n->reference_cnt);
911  n->inactive = 0;
912  }
913  n->reference_cnt++;
914  n->notify_task =
916 }
917 
918 
926 static void
928 {
929  struct Neighbour *n = cls;
930 
931  GNUNET_assert(NULL != n->conn_op);
932  GNUNET_assert(NULL == n->controller);
933  LOG_DEBUG("Opening connection to controller on host %u\n", n->host_id);
935  EVENT_MASK,
937  NULL);
939 }
940 
941 
947 static void
949 {
950  struct Neighbour *n = cls;
951 
952  GNUNET_assert(0 == n->reference_cnt);
953  GNUNET_assert(NULL == n->notify_task);
954  GNUNET_assert(NULL == n->nl_head);
955  if (NULL != n->controller)
956  {
957  LOG_DEBUG("Closing connection to controller on host %u\n", n->host_id);
959  n->controller = NULL;
960  }
961  n->conn_op = NULL;
962  n->inactive = 0;
963 }
964 
965 
980  void *cb_cls)
981 {
983 
984  GNUNET_assert(NULL != cb);
985  LOG_DEBUG("Attempting to get connection to controller on host %u\n",
986  n->host_id);
988  h->n = n;
989  h->cb = cb;
990  h->cb_cls = cb_cls;
992  if (NULL == n->conn_op)
993  {
994  GNUNET_assert(NULL == n->controller);
999  return h;
1000  }
1002  return h;
1003 }
1004 
1005 
1011 void
1013 {
1014  struct Neighbour *n;
1015  int cleanup_task;
1016 
1017  n = h->n;
1018  cleanup_task = (h == n->nl_head) ? GNUNET_YES : GNUNET_NO;
1020  GNUNET_free(h);
1021  if (GNUNET_NO == cleanup_task)
1022  return;
1023  if (NULL == n->notify_task)
1024  return;
1025  GNUNET_assert(0 < n->reference_cnt);
1026  n->reference_cnt--;
1028  n->notify_task = NULL;
1029  if (NULL == n->nl_head)
1030  {
1031  if ((0 == n->reference_cnt) && (0 == n->inactive))
1032  {
1033  n->inactive = 1;
1035  }
1036  return;
1037  }
1039 }
1040 
1041 
1049 void
1051 {
1052  GNUNET_assert(0 == n->inactive);
1053  GNUNET_assert(0 < n->reference_cnt);
1054  n->reference_cnt--;
1055  if (0 == n->reference_cnt)
1056  {
1057  n->inactive = 1;
1059  }
1060 }
1061 
1062 
1068 static void
1070 {
1071  if (NULL != ncc->nh)
1073  if (NULL != ncc->timeout_task)
1075  GNUNET_CONTAINER_DLL_remove(ncc_head,
1076  ncc_tail,
1077  ncc);
1078  GNUNET_free(ncc);
1079 }
1080 
1081 
1085 void
1087 {
1088  struct Neighbour *n;
1089  unsigned int id;
1090 
1091  for (id = 0; id < neighbour_list_size; id++)
1092  {
1093  if (NULL == (n = neighbour_list[id]))
1094  continue;
1095  if (NULL != n->conn_op)
1097  GNUNET_free(n);
1098  neighbour_list[id] = NULL;
1099  }
1100  GNUNET_free_non_null(neighbour_list);
1101 }
1102 
1103 
1111 struct Neighbour *
1112 GST_get_neighbour(uint32_t id)
1113 {
1114  if (neighbour_list_size <= id)
1115  return NULL;
1116  return neighbour_list[id];
1117 }
1118 
1119 
1123 void
1125 {
1126  while (NULL != ncc_head)
1127  cleanup_ncc(ncc_head);
1128 }
1129 
1130 
1136 static void
1138 {
1139  struct NeighbourConnectCtxt *ncc = cls;
1140 
1141  ncc->timeout_task = NULL;
1143  ncc->op_id,
1144  NULL,
1145  "Could not connect to delegated controller");
1146  cleanup_ncc(ncc);
1147 }
1148 
1149 
1156 static void
1158  struct GNUNET_TESTBED_Controller *c)
1159 {
1160  struct NeighbourConnectCtxt *ncc = cls;
1161 
1163  ncc->timeout_task = NULL;
1164  ncc->nh = NULL;
1167  ncc->op_id,
1168  NULL,
1169  NULL);
1170  cleanup_ncc(ncc);
1171 }
1172 
1173 
1179 struct Neighbour *
1181 {
1182  struct Neighbour *n;
1183 
1184  n = GNUNET_new(struct Neighbour);
1186  neighbour_list_add(n); /* just add; connect on-demand */
1187  return n;
1188 }
1189 
1190 
1197 void
1200 {
1201  struct GNUNET_SERVICE_Client *client = cls;
1202  struct LCFContext *lcf;
1203  struct Route *route;
1204  struct Route *new_route;
1205  uint64_t op_id;
1206  uint32_t delegated_host_id;
1207  uint32_t slave_host_id;
1208 
1209  if (NULL == GST_context)
1210  {
1211  GNUNET_break(0);
1213  return;
1214  }
1215  delegated_host_id = ntohl(msg->delegated_host_id);
1216  if (delegated_host_id == GST_context->host_id)
1217  {
1218  GNUNET_break(0);
1220  "Trying to link ourselves\n");
1222  return;
1223  }
1224  if ((delegated_host_id >= GST_host_list_size) ||
1225  (NULL == GST_host_list[delegated_host_id]))
1226  {
1228  "Delegated host %u not registered with us\n",
1229  delegated_host_id);
1231  return;
1232  }
1233  slave_host_id = ntohl(msg->slave_host_id);
1234  if ((slave_host_id >= GST_host_list_size) ||
1235  (NULL == GST_host_list[slave_host_id]))
1236  {
1238  "Slave host %u not registered with us\n",
1239  slave_host_id);
1241  return;
1242  }
1243  if (slave_host_id == delegated_host_id)
1244  {
1246  "Slave and delegated host are same\n");
1248  return;
1249  }
1250  op_id = GNUNET_ntohll(msg->operation_id);
1251  if (slave_host_id == GST_context->host_id) /* Link from us */
1252  {
1253  struct Slave *slave;
1254  struct LinkControllersContext *lcc;
1255 
1256  if (1 != msg->is_subordinate)
1257  {
1258  struct Neighbour *n;
1259  struct NeighbourConnectCtxt *ncc;
1260 
1261  if ((delegated_host_id < neighbour_list_size) &&
1262  (NULL != neighbour_list[delegated_host_id]))
1263  {
1264  GNUNET_break(0);
1266  return;
1267  }
1268  LOG_DEBUG("Received request to establish a link to host %u\n",
1269  delegated_host_id);
1270  n = GST_create_neighbour(GST_host_list[delegated_host_id]);
1271  ncc = GNUNET_new(struct NeighbourConnectCtxt);
1272  ncc->n = n;
1273  ncc->op_id = op_id;
1274  ncc->client = client;
1277  ncc);
1278  ncc->timeout_task
1281  ncc);
1283  ncc_tail,
1284  ncc);
1286  return;
1287  }
1288  if ((delegated_host_id < GST_slave_list_size) &&
1289  (NULL != GST_slave_list[delegated_host_id]))
1290  {
1291  GNUNET_break(0);
1293  return;
1294  }
1295  LOG_DEBUG("Received request to start and establish a link to host %u\n",
1296  delegated_host_id);
1297  slave = GNUNET_new(struct Slave);
1298  slave->host_id = delegated_host_id;
1300  GNUNET_NO);
1301  slave_list_add(slave);
1302  lcc = GNUNET_new(struct LinkControllersContext);
1303  lcc->operation_id = op_id;
1304  lcc->client = client;
1305  slave->lcc = lcc;
1306  slave->controller_proc
1308  GST_host_list[slave->host_id],
1309  &slave_status_cb,
1310  slave);
1311  new_route = GNUNET_new(struct Route);
1312  new_route->dest = delegated_host_id;
1313  new_route->thru = GST_context->host_id;
1314  route_list_add(new_route);
1315  return;
1316  }
1317 
1318  /* Route the request */
1319  if (slave_host_id >= route_list_size)
1320  {
1322  "No route towards slave host");
1324  return;
1325  }
1326  lcf = GNUNET_new(struct LCFContext);
1329  route = GST_find_dest_route(slave_host_id);
1330  GNUNET_assert(NULL != route); /* because we add routes carefully */
1332  GNUNET_assert(NULL != GST_slave_list[route->dest]);
1333  lcf->is_subordinate = msg->is_subordinate;
1334  lcf->state = INIT;
1335  lcf->operation_id = op_id;
1336  lcf->gateway = GST_slave_list[route->dest];
1337  lcf->client = client;
1338  if (NULL == lcf_head)
1339  {
1340  GNUNET_assert(NULL == lcf_proc_task_id);
1342  lcf_tail,
1343  lcf);
1344  lcf_proc_task_id = GNUNET_SCHEDULER_add_now(&lcf_proc_task,
1345  lcf);
1346  }
1347  else
1348  {
1350  lcf_tail,
1351  lcf);
1352  }
1353  /* FIXME: Adding a new route should happen after the controllers are linked
1354  * successfully */
1355  if (1 != msg->is_subordinate)
1356  {
1358  return;
1359  }
1360  if ((delegated_host_id < route_list_size) &&
1361  (NULL != route_list[delegated_host_id]))
1362  {
1363  GNUNET_break_op(0); /* Are you trying to link delegated host twice
1364  * with is subordinate flag set to GNUNET_YES? */
1366  return;
1367  }
1368  new_route = GNUNET_new(struct Route);
1369  new_route->dest = delegated_host_id;
1370  new_route->thru = route->dest;
1371  route_list_add(new_route);
1373 }
1374 
1375 
1382 void
1384 {
1385  struct NeighbourConnectCtxt *ncc;
1386  struct NeighbourConnectCtxt *nccn;
1387  struct LCFContext *lcf;
1388  struct LCFContext *lcfn;
1389 
1390  for (ncc = ncc_head; NULL != ncc; ncc = nccn)
1391  {
1392  nccn = ncc->next;
1393  if (ncc->client == client)
1394  cleanup_ncc(ncc);
1395  }
1396  for (unsigned int i = 0; i < GST_slave_list_size; i++)
1397  {
1398  struct Slave *slave = GST_slave_list[i];
1399  struct LinkControllersContext *lcc;
1400 
1401  if (NULL == slave)
1402  continue;
1405  client);
1406  lcc = slave->lcc;
1407  if (NULL == lcc)
1408  continue;
1409  if (lcc->client == client)
1410  {
1411  slave->lcc = NULL;
1412  GNUNET_free(lcc);
1413  }
1414  }
1415  for (lcf = lcf_head; NULL != lcf; lcf = lcfn)
1416  {
1417  lcfn = lcf->next;
1418  if ((NULL != lcf) &&
1419  (client == lcf->client))
1420  {
1421  if (NULL != lcf->op)
1423  GNUNET_CONTAINER_DLL_remove(lcf_head,
1424  lcf_tail,
1425  lcf);
1426  GNUNET_free(lcf);
1427  }
1428  }
1429 }
1430 
1431 
1435 void
1437 {
1438  struct LCFContext *lcf;
1439 
1440  if (NULL != lcf_head)
1441  {
1442  if (NULL != lcf_proc_task_id)
1443  {
1444  GNUNET_SCHEDULER_cancel(lcf_proc_task_id);
1445  lcf_proc_task_id = NULL;
1446  }
1447  }
1448  GNUNET_assert(NULL == lcf_proc_task_id);
1449  for (lcf = lcf_head; NULL != lcf; lcf = lcf_head)
1450  {
1451  if (NULL != lcf->op)
1453  if (NULL != lcf->timeout_task)
1455  GNUNET_CONTAINER_DLL_remove(lcf_head,
1456  lcf_tail,
1457  lcf);
1458  GNUNET_free(lcf);
1459  }
1460 }
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run upon timeout.
A connected controller which is not our child.
void GNUNET_TESTBED_cancel_registration(struct GNUNET_TESTBED_HostRegistrationHandle *handle)
Cancel the pending registration.
uint64_t operation_id
The id of the operation which created this context.
Context information for establishing a link to neighbour (Used is GST_handle_link_controllers() ...
This context information will be created for each host that is registered at slave controllers during...
uint32_t host_id
The id of the host this controller is running on.
unsigned int GST_host_list_size
The size of the host list.
struct Neighbour * n
The neighbour to whom connection should be made.
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:1713
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:185
Link controllers request forwarding context.
unsigned int inactive
Is the conn_op inactivated?
uint32_t thru
The destination host is reachable thru.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:191
struct NeighbourConnectNotification * nh
The notification handle associated with the neighbour&#39;s connection request.
struct NeighbourConnectNotification * next
DLL next for inclusion in neighbour&#39;s list of notification requests.
data structures shared amongst components of TESTBED service
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2424
struct GNUNET_SERVICE_Client * client
The client handle.
struct LCFContext * prev
The LCFContext.
void GNUNET_TESTBED_controller_kill_(struct GNUNET_TESTBED_ControllerProc *cproc)
Sends termination signal to the controller&#39;s helper process.
static struct GNUNET_SCHEDULER_Task * cleanup_task
Cleanup task.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Notification context to be used to notify when connection to the neighbour&#39;s controller is opened...
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:1824
char * master_ip
The network address of the master controller.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
void GNUNET_TESTBED_operation_release_(struct GNUNET_TESTBED_Operation *op)
An operation is &#39;done&#39; (was cancelled or finished); remove it from the queues and release associated ...
int is_subordinate
should the slave controller start the delegated controller?
void GST_queue_host_registration(struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
Adds a host registration&#39;s request to a slave&#39;s registration queue.
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
enum GNUNET_TESTBED_EventType type
Type of the event.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Structure representing a connected(directly-linked) controller.
struct GNUNET_TESTBED_HostRegistrationHandle * rhandle
The current host registration handle.
Opaque handle to a host running experiments managed by the testing framework.
enum LCFContextState state
The state of this context.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
Context information used while linking controllers.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct Slave * gateway
The gateway which will pass the link message to delegated host.
struct NeighbourConnectNotification * nl_tail
DLL tail for the list of notification requests.
struct OperationQueue * GST_opq_openfds
Operation queue for open file descriptors.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#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 ...
Opaque handle to an abstract operation to be executed by the testing framework.
Response message for ControllerLinkRequest message.
Definition: testbed.h:165
Handle to a client that is connected to a service.
Definition: service.c:246
uint32_t delegated_host_id
For which host should requests be delegated? NBO.
Definition: testbed.h:142
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
Message to signal the result of GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS request.
GST_NeigbourConnectNotifyCallback cb
The notification callback to call when we are connect to neighbour.
#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
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:1777
uint32_t host_id
Our host id according to this context.
struct GNUNET_SERVICE_Client * client
The client which has asked to perform this operation.
static char * value
Value of the record to add/remove.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void * cb_cls
The closure for the above callback.
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:1264
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
Context information to used during operations which forward the overlay connect message.
A DLL of host registrations to be made.
A requested testbed operation has been completed.
uint16_t status
See PRISM_STATUS_*-constants.
int 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.
A routing entry.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
struct HostRegistration * hr_dll_tail
Tail of the host registration DLL.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
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:2037
uint32_t delegated_host_id
The delegated host.
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s configuration template.
struct GNUNET_TESTBED_Operation * conn_op
Operation handle for opening a lateral connection to another controller.
A 512-bit hashcode.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
void GNUNET_TESTBED_controller_destroy_(struct GNUNET_TESTBED_ControllerProc *cproc)
Cleans-up the controller&#39;s helper process handle.
struct HostRegistration * hr_dll_head
Head of the host registration DLL.
struct GNUNET_TESTBED_EventInformation::@58::@63 operation_finished
Details about an operation finished event.
void GNUNET_TESTBED_operation_activate_(struct GNUNET_TESTBED_Operation *op)
Marks and inactive operation as active.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
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.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
uint16_t success
Set to GNUNET_YES to signify SUCCESS; GNUNET_NO to signify failure.
Definition: testbed.h:180
struct NeighbourConnectCtxt * prev
DLL tail.
uint64_t operation_id
The ID of the operation.
struct Neighbour * n
The neighbour.
uint32_t slave_host_id
The slave host.
union GNUNET_TESTBED_EventInformation::@58 details
Details about the event.
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.
unsigned int reference_cnt
How many references are present currently to this neighbour&#39;s connection.
struct LinkControllersContext * lcc
handle to lcc which is associated with this slave startup.
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:1547
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:175
uint64_t op_id
The id of the link-controllers operation responsible for creating this context.
struct NeighbourConnectCtxt * next
DLL next for inclusion in the corresponding context list.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct NeighbourConnectNotification * prev
DLL prev.
struct ForwardedOverlayConnectContext * next
next ForwardedOverlayConnectContext in the DLL
uint32_t slave_host_id
Which host is responsible for managing the delegation? NBO.
Definition: testbed.h:152
uint32_t host_id
The id of the host this controller is running on.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
configuration data
Definition: configuration.c:83
struct Context * GST_context
The master context; generated with the first INIT message.
struct GNUNET_SERVICE_Client * client
The client requesting the connection.
uint8_t is_subordinate
Set to 1 if the receiving controller is the master controller for the slave host (and thus responsibl...
Definition: testbed.h:158
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
Entry in list of pending tasks.
Definition: scheduler.c:131
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:147
#define GNUNET_YES
Definition: gnunet_common.h:77
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 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...
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct LCFContext * next
The LCFContext.
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
#define LOG_DEBUG(...)
Debug logging shorthand.
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.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SERVICE_Client * client
The client which initiated the link controller operation.
struct GNUNET_SCHEDULER_Task * notify_task
Task id for the task to call notifications from the notification list.
Client notifies controller that it should delegate requests for a particular client to a particular s...
Definition: testbed.h:133
struct GNUNET_TESTBED_Operation * op
Handle for the corresponding operation that generated this event.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956