GNUnet  0.11.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 
49 {
54 
59 
64 
69 };
70 
71 
75 struct LCFContext
76 {
80  struct LCFContext *next;
81 
85  struct LCFContext *prev;
86 
90  struct Slave *gateway;
91 
96 
101 
106 
110  uint64_t operation_id;
111 
116 
121 
126 
130  uint32_t slave_host_id;
131 };
132 
133 
139 {
144 
149 
153  struct Neighbour *n;
154 
159 
163  void *cb_cls;
164 };
165 
166 
170 struct Neighbour
171 {
176 
182 
187 
192 
197 
201  unsigned int reference_cnt;
202 
206  unsigned int inactive;
207 
211  uint32_t host_id;
212 };
213 
214 
218 static struct Neighbour **neighbour_list;
219 
223 static unsigned int neighbour_list_size;
224 
225 
231 {
236 
241 
245  struct Neighbour *n;
246 
251 
256 
261 
266  uint64_t op_id;
267 };
268 
273 
278 
283 
287 unsigned int GST_slave_list_size;
288 
292 static struct Route **route_list;
293 
297 static struct LCFContext *lcf_head;
298 
302 static struct LCFContext *lcf_tail;
303 
308 
312 static unsigned int route_list_size;
313 
314 
320 static void
321 slave_list_add (struct Slave *slave)
322 {
323  if (slave->host_id >= GST_slave_list_size)
324  GST_array_grow_large_enough (GST_slave_list,
326  slave->host_id);
327  GNUNET_assert (NULL == GST_slave_list[slave->host_id]);
328  GST_slave_list[slave->host_id] = slave;
329 }
330 
331 
341 static int
343  const struct GNUNET_HashCode *key,
344  void *value)
345 {
346  struct GNUNET_SERVICE_Client *client = cls;
347  struct RegisteredHostContext *rhc = value;
348  struct ForwardedOverlayConnectContext *focc;
349  struct ForwardedOverlayConnectContext *foccn;
350 
351  for (focc = rhc->focc_dll_head; NULL != focc; focc = foccn)
352  {
353  foccn = focc->next;
354  if (focc->client == client)
355  GST_cleanup_focc (focc);
356  }
357  return GNUNET_OK;
358 }
359 
360 
366 static void
367 route_list_add (struct Route *route)
368 {
369  if (route->dest >= route_list_size)
370  GST_array_grow_large_enough (route_list, route_list_size, route->dest);
371  GNUNET_assert (NULL == route_list[route->dest]);
372  route_list[route->dest] = route;
373 }
374 
375 
382 static void
384 {
385  if (n->host_id >= neighbour_list_size)
387  n->host_id);
388  GNUNET_assert (NULL == neighbour_list[n->host_id]);
389  neighbour_list[n->host_id] = n;
390 }
391 
392 
396 void
398 {
399  unsigned int id;
400 
401  for (id = 0; id < route_list_size; id++)
402  if (NULL != route_list[id])
403  GNUNET_free (route_list[id]);
404  GNUNET_free_non_null (route_list);
405  route_list = NULL;
406 }
407 
408 
418 static int
420  const struct GNUNET_HashCode *key,
421  void *value)
422 {
423  struct Slave *slave = cls;
424  struct RegisteredHostContext *rhc = value;
425  struct ForwardedOverlayConnectContext *focc;
426 
429  value));
430  while (NULL != (focc = rhc->focc_dll_head))
431  GST_cleanup_focc (focc);
432  GNUNET_free (value);
433  return GNUNET_YES;
434 }
435 
436 
442 static void
443 kill_slave (struct Slave *slave)
444 {
445  struct HostRegistration *hr_entry;
446 
447  while (NULL != (hr_entry = slave->hr_dll_head))
448  {
450  hr_entry);
451  GNUNET_free (hr_entry);
452  }
453  if (NULL != slave->rhandle)
458  slave));
460  if (NULL != slave->controller)
462  if (NULL != slave->controller_proc)
463  {
464  LOG_DEBUG ("Stopping a slave\n");
466  }
467 }
468 
469 
475 static void
476 destroy_slave (struct Slave *slave)
477 {
478  if (NULL != slave->controller_proc)
479  {
481  LOG_DEBUG ("Slave stopped\n");
482  }
483  GST_slave_list[slave->host_id] = NULL;
484  GNUNET_free (slave);
485 }
486 
487 
491 void
493 {
494  struct Slave *slave;
495  unsigned int id;
496 
497  for (id = 0; id < GST_slave_list_size; id++)
498  {
499  slave = GST_slave_list[id];
500  if (NULL == slave)
501  continue;
502  kill_slave (slave);
503  }
504  for (id = 0; id < GST_slave_list_size; id++)
505  {
506  slave = GST_slave_list[id];
507  if (NULL == slave)
508  continue;
509  destroy_slave (slave);
510  }
511  GNUNET_free_non_null (GST_slave_list);
512  GST_slave_list = NULL;
513 }
514 
515 
524 struct Route *
525 GST_find_dest_route (uint32_t host_id)
526 {
527  struct Route *route;
528 
529  if (route_list_size <= host_id)
530  return NULL;
531  while (NULL != (route = route_list[host_id]))
532  {
533  if (route->thru == GST_context->host_id)
534  break;
535  host_id = route->thru;
536  }
537  return route;
538 }
539 
540 
553 static void
555  uint64_t operation_id,
556  const struct GNUNET_CONFIGURATION_Handle *cfg,
557  const char *emsg)
558 {
559  struct GNUNET_MQ_Envelope *env;
561  char *xconfig;
562  size_t config_size;
563  size_t xconfig_size;
564  uint16_t msize;
565 
566  GNUNET_assert ((NULL == cfg) || (NULL == emsg));
567  xconfig = NULL;
568  xconfig_size = 0;
569  config_size = 0;
570  msize = 0;
571  if (NULL != cfg)
572  {
573  xconfig = GNUNET_TESTBED_compress_cfg_ (cfg,
574  &config_size,
575  &xconfig_size);
576  msize += xconfig_size;
577  }
578  if (NULL != emsg)
579  msize += strlen (emsg);
580  env = GNUNET_MQ_msg_extra (msg,
581  msize,
583  if (NULL == emsg)
584  msg->success = htons (GNUNET_YES);
585  msg->operation_id = GNUNET_htonll (operation_id);
586  msg->config_size = htons ((uint16_t) config_size);
587  if (NULL != xconfig)
588  {
589  GNUNET_memcpy (&msg[1],
590  xconfig,
591  xconfig_size);
592  GNUNET_free (xconfig);
593  }
594  if (NULL != emsg)
595  GNUNET_memcpy (&msg[1],
596  emsg,
597  strlen (emsg));
599  env);
600 }
601 
602 
608 static void
609 lcf_proc_task (void *cls);
610 
611 
618 static void
619 lcf_proc_cc (void *cls,
620  const char *emsg)
621 {
622  struct LCFContext *lcf = cls;
623 
624  GNUNET_assert (NULL == lcf_proc_task_id);
625  switch (lcf->state)
626  {
627  case INIT:
628  if (NULL != emsg)
629  goto registration_error;
631  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
632  break;
633 
635  if (NULL != emsg)
636  goto registration_error;
638  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
639  break;
640 
641  default:
642  GNUNET_assert (0); /* Shouldn't reach here */
643  }
644  return;
645 
646 registration_error:
648  "Host registration failed with message: %s\n",
649  emsg);
650  lcf->state = FINISHED;
651  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task,
652  lcf);
653 }
654 
655 
661 static void
662 lcf_proc_task (void *cls);
663 
664 
670 static void
672 {
673  struct LCFContext *lcf = cls;
674 
675  lcf->timeout_task = NULL;
676  // GST_forwarded_operation_timeout (lcf->fopc, tc);
678  "A forwarded controller link operation has timed out\n");
680  lcf->operation_id,
681  NULL,
682  "A forwarded controller link operation has timed out\n");
683  GNUNET_assert (NULL == lcf_proc_task_id);
684  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task,
685  lcf);
686 }
687 
688 
694 static void
695 lcf_proc_task (void *cls)
696 {
697  struct LCFContext *lcf = cls;
698 
699  lcf_proc_task_id = NULL;
700  switch (lcf->state)
701  {
702  case INIT:
703  if (GNUNET_NO ==
705  [lcf->delegated_host_id],
706  lcf->gateway->controller))
707  {
710  }
711  else
712  {
714  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
715  }
716  break;
717 
719  if (GNUNET_NO ==
721  lcf->gateway->controller))
722  {
725  }
726  else
727  {
729  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
730  }
731  break;
732 
735  lcf->gateway->controller,
736  GST_host_list[lcf->
739  lcf->is_subordinate);
740  lcf->timeout_task =
743  lcf);
744  lcf->state = FINISHED;
745  break;
746 
747  case FINISHED:
748  if (NULL != lcf->op)
750  GNUNET_CONTAINER_DLL_remove (lcf_head,
751  lcf_tail,
752  lcf);
753  GNUNET_free (lcf);
754  if (NULL != lcf_head)
755  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task,
756  lcf_head);
757  }
758 }
759 
760 
767 static void
768 slave_event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
769 {
770  struct LCFContext *lcf;
771 
772  /* We currently only get here when working on LCFContexts */
774  lcf = event->op_cls;
775  GNUNET_assert (lcf->op == event->op);
777  lcf->op = NULL;
778  GNUNET_assert (FINISHED == lcf->state);
779  GNUNET_assert (NULL != lcf->timeout_task);
781  if (NULL == event->details.operation_finished.emsg)
785  NULL);
786  else
788  NULL,
789  event->details.operation_finished.emsg);
790  GNUNET_assert (NULL == lcf_proc_task_id);
791  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
792  return;
793 }
794 
795 
805 static void
806 slave_status_cb (void *cls,
807  const struct GNUNET_CONFIGURATION_Handle *cfg,
808  int status)
809 {
810  struct Slave *slave = cls;
811  struct LinkControllersContext *lcc;
812 
813  lcc = slave->lcc;
814  if (GNUNET_SYSERR == status)
815  {
816  slave->controller_proc = NULL;
817  /* Stop all link controller forwarding tasks since we shutdown here anyway
818  and as these tasks they depend on the operation queues which are created
819  through GNUNET_TESTBED_controller_connect() and in kill_slave() we call
820  the destructor function GNUNET_TESTBED_controller_disconnect() */
821  GST_free_lcf ();
822  kill_slave (slave);
823  destroy_slave (slave);
824  slave = NULL;
825  LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n");
826  GNUNET_SCHEDULER_shutdown (); /* We too shutdown */
827  goto clean_lcc;
828  }
829  slave->controller =
832  slave);
833  if (NULL != slave->controller)
834  {
835  send_controller_link_response (lcc->client, lcc->operation_id, cfg, NULL);
836  }
837  else
838  {
840  "Could not connect to delegated controller");
841  kill_slave (slave);
842  destroy_slave (slave);
843  slave = NULL;
844  }
845 
846 clean_lcc:
847  if (NULL != lcc)
848  {
849  if (NULL != lcc->client)
850  {
852  lcc->client = NULL;
853  }
854  GNUNET_free (lcc);
855  }
856  if (NULL != slave)
857  slave->lcc = NULL;
858 }
859 
860 
869 static void
870 trigger_notifications (struct Neighbour *n);
871 
872 
879 static void
881 {
882  struct Neighbour *n = cls;
884 
885  GNUNET_assert (NULL != (h = n->nl_head));
886  GNUNET_assert (NULL != n->notify_task);
887  n->notify_task = NULL;
888  GNUNET_assert (NULL != n->controller);
891  h->cb (h->cb_cls, n->controller);
892  GNUNET_free (h);
893 }
894 
895 
904 static void
906 {
907  GNUNET_assert (NULL != n->conn_op);
908  if (NULL == n->nl_head)
909  return;
910  if (NULL == n->controller)
911  return;
912  if (NULL != n->notify_task)
913  return;
914  if (1 == n->inactive)
915  {
916  GNUNET_assert (0 == n->reference_cnt);
918  n->inactive = 0;
919  }
920  n->reference_cnt++;
921  n->notify_task =
923 }
924 
925 
933 static void
935 {
936  struct Neighbour *n = cls;
937 
938  GNUNET_assert (NULL != n->conn_op);
939  GNUNET_assert (NULL == n->controller);
940  LOG_DEBUG ("Opening connection to controller on host %u\n", n->host_id);
942  EVENT_MASK,
944  NULL);
946 }
947 
948 
954 static void
956 {
957  struct Neighbour *n = cls;
958 
959  GNUNET_assert (0 == n->reference_cnt);
960  GNUNET_assert (NULL == n->notify_task);
961  GNUNET_assert (NULL == n->nl_head);
962  if (NULL != n->controller)
963  {
964  LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id);
966  n->controller = NULL;
967  }
968  n->conn_op = NULL;
969  n->inactive = 0;
970 }
971 
972 
987  void *cb_cls)
988 {
990 
991  GNUNET_assert (NULL != cb);
992  LOG_DEBUG ("Attempting to get connection to controller on host %u\n",
993  n->host_id);
995  h->n = n;
996  h->cb = cb;
997  h->cb_cls = cb_cls;
999  if (NULL == n->conn_op)
1000  {
1001  GNUNET_assert (NULL == n->controller);
1006  return h;
1007  }
1009  return h;
1010 }
1011 
1012 
1018 void
1020 {
1021  struct Neighbour *n;
1022  int cleanup_task;
1023 
1024  n = h->n;
1025  cleanup_task = (h == n->nl_head) ? GNUNET_YES : GNUNET_NO;
1027  GNUNET_free (h);
1028  if (GNUNET_NO == cleanup_task)
1029  return;
1030  if (NULL == n->notify_task)
1031  return;
1032  GNUNET_assert (0 < n->reference_cnt);
1033  n->reference_cnt--;
1035  n->notify_task = NULL;
1036  if (NULL == n->nl_head)
1037  {
1038  if ((0 == n->reference_cnt) && (0 == n->inactive))
1039  {
1040  n->inactive = 1;
1042  }
1043  return;
1044  }
1046 }
1047 
1048 
1056 void
1058 {
1059  GNUNET_assert (0 == n->inactive);
1060  GNUNET_assert (0 < n->reference_cnt);
1061  n->reference_cnt--;
1062  if (0 == n->reference_cnt)
1063  {
1064  n->inactive = 1;
1066  }
1067 }
1068 
1069 
1075 static void
1077 {
1078  if (NULL != ncc->nh)
1080  if (NULL != ncc->timeout_task)
1082  GNUNET_CONTAINER_DLL_remove (ncc_head,
1083  ncc_tail,
1084  ncc);
1085  GNUNET_free (ncc);
1086 }
1087 
1088 
1092 void
1094 {
1095  struct Neighbour *n;
1096  unsigned int id;
1097 
1098  for (id = 0; id < neighbour_list_size; id++)
1099  {
1100  if (NULL == (n = neighbour_list[id]))
1101  continue;
1102  if (NULL != n->conn_op)
1104  GNUNET_free (n);
1105  neighbour_list[id] = NULL;
1106  }
1107  GNUNET_free_non_null (neighbour_list);
1108 }
1109 
1110 
1118 struct Neighbour *
1119 GST_get_neighbour (uint32_t id)
1120 {
1121  if (neighbour_list_size <= id)
1122  return NULL;
1123  return neighbour_list[id];
1124 }
1125 
1126 
1130 void
1132 {
1133  while (NULL != ncc_head)
1134  cleanup_ncc (ncc_head);
1135 }
1136 
1137 
1143 static void
1145 {
1146  struct NeighbourConnectCtxt *ncc = cls;
1147 
1148  ncc->timeout_task = NULL;
1150  ncc->op_id,
1151  NULL,
1152  "Could not connect to delegated controller");
1153  cleanup_ncc (ncc);
1154 }
1155 
1156 
1163 static void
1165  struct GNUNET_TESTBED_Controller *c)
1166 {
1167  struct NeighbourConnectCtxt *ncc = cls;
1168 
1170  ncc->timeout_task = NULL;
1171  ncc->nh = NULL;
1174  ncc->op_id,
1175  NULL,
1176  NULL);
1177  cleanup_ncc (ncc);
1178 }
1179 
1180 
1186 struct Neighbour *
1188 {
1189  struct Neighbour *n;
1190 
1191  n = GNUNET_new (struct Neighbour);
1193  neighbour_list_add (n); /* just add; connect on-demand */
1194  return n;
1195 }
1196 
1197 
1204 void
1207 {
1208  struct GNUNET_SERVICE_Client *client = cls;
1209  struct LCFContext *lcf;
1210  struct Route *route;
1211  struct Route *new_route;
1212  uint64_t op_id;
1213  uint32_t delegated_host_id;
1214  uint32_t slave_host_id;
1215 
1216  if (NULL == GST_context)
1217  {
1218  GNUNET_break (0);
1219  GNUNET_SERVICE_client_drop (client);
1220  return;
1221  }
1222  delegated_host_id = ntohl (msg->delegated_host_id);
1223  if (delegated_host_id == GST_context->host_id)
1224  {
1225  GNUNET_break (0);
1227  "Trying to link ourselves\n");
1228  GNUNET_SERVICE_client_drop (client);
1229  return;
1230  }
1231  if ((delegated_host_id >= GST_host_list_size) ||
1232  (NULL == GST_host_list[delegated_host_id]))
1233  {
1235  "Delegated host %u not registered with us\n",
1236  delegated_host_id);
1237  GNUNET_SERVICE_client_drop (client);
1238  return;
1239  }
1240  slave_host_id = ntohl (msg->slave_host_id);
1241  if ((slave_host_id >= GST_host_list_size) ||
1242  (NULL == GST_host_list[slave_host_id]))
1243  {
1245  "Slave host %u not registered with us\n",
1246  slave_host_id);
1247  GNUNET_SERVICE_client_drop (client);
1248  return;
1249  }
1250  if (slave_host_id == delegated_host_id)
1251  {
1253  "Slave and delegated host are same\n");
1254  GNUNET_SERVICE_client_drop (client);
1255  return;
1256  }
1257  op_id = GNUNET_ntohll (msg->operation_id);
1258  if (slave_host_id == GST_context->host_id) /* Link from us */
1259  {
1260  struct Slave *slave;
1261  struct LinkControllersContext *lcc;
1262 
1263  if (1 != msg->is_subordinate)
1264  {
1265  struct Neighbour *n;
1266  struct NeighbourConnectCtxt *ncc;
1267 
1268  if ((delegated_host_id < neighbour_list_size) &&
1269  (NULL != neighbour_list[delegated_host_id]))
1270  {
1271  GNUNET_break (0);
1272  GNUNET_SERVICE_client_drop (client);
1273  return;
1274  }
1275  LOG_DEBUG ("Received request to establish a link to host %u\n",
1276  delegated_host_id);
1277  n = GST_create_neighbour (GST_host_list[delegated_host_id]);
1278  ncc = GNUNET_new (struct NeighbourConnectCtxt);
1279  ncc->n = n;
1280  ncc->op_id = op_id;
1281  ncc->client = client;
1282  ncc->nh = GST_neighbour_get_connection (n,
1284  ncc);
1285  ncc->timeout_task
1288  ncc);
1290  ncc_tail,
1291  ncc);
1293  return;
1294  }
1295  if ((delegated_host_id < GST_slave_list_size) &&
1296  (NULL != GST_slave_list[delegated_host_id]))
1297  {
1298  GNUNET_break (0);
1299  GNUNET_SERVICE_client_drop (client);
1300  return;
1301  }
1302  LOG_DEBUG ("Received request to start and establish a link to host %u\n",
1303  delegated_host_id);
1304  slave = GNUNET_new (struct Slave);
1305  slave->host_id = delegated_host_id;
1307  GNUNET_NO);
1308  slave_list_add (slave);
1309  lcc = GNUNET_new (struct LinkControllersContext);
1310  lcc->operation_id = op_id;
1311  lcc->client = client;
1312  slave->lcc = lcc;
1313  slave->controller_proc
1315  GST_host_list[slave->host_id],
1316  &slave_status_cb,
1317  slave);
1318  new_route = GNUNET_new (struct Route);
1319  new_route->dest = delegated_host_id;
1320  new_route->thru = GST_context->host_id;
1321  route_list_add (new_route);
1322  return;
1323  }
1324 
1325  /* Route the request */
1326  if (slave_host_id >= route_list_size)
1327  {
1329  "No route towards slave host");
1330  GNUNET_SERVICE_client_drop (client);
1331  return;
1332  }
1333  lcf = GNUNET_new (struct LCFContext);
1336  route = GST_find_dest_route (slave_host_id);
1337  GNUNET_assert (NULL != route); /* because we add routes carefully */
1339  GNUNET_assert (NULL != GST_slave_list[route->dest]);
1340  lcf->is_subordinate = msg->is_subordinate;
1341  lcf->state = INIT;
1342  lcf->operation_id = op_id;
1343  lcf->gateway = GST_slave_list[route->dest];
1344  lcf->client = client;
1345  if (NULL == lcf_head)
1346  {
1347  GNUNET_assert (NULL == lcf_proc_task_id);
1349  lcf_tail,
1350  lcf);
1351  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task,
1352  lcf);
1353  }
1354  else
1355  {
1357  lcf_tail,
1358  lcf);
1359  }
1360  /* FIXME: Adding a new route should happen after the controllers are linked
1361  * successfully */
1362  if (1 != msg->is_subordinate)
1363  {
1365  return;
1366  }
1367  if ((delegated_host_id < route_list_size) &&
1368  (NULL != route_list[delegated_host_id]))
1369  {
1370  GNUNET_break_op (0); /* Are you trying to link delegated host twice
1371  * with is subordinate flag set to GNUNET_YES? */
1372  GNUNET_SERVICE_client_drop (client);
1373  return;
1374  }
1375  new_route = GNUNET_new (struct Route);
1376  new_route->dest = delegated_host_id;
1377  new_route->thru = route->dest;
1378  route_list_add (new_route);
1380 }
1381 
1382 
1389 void
1391 {
1392  struct NeighbourConnectCtxt *ncc;
1393  struct NeighbourConnectCtxt *nccn;
1394  struct LCFContext *lcf;
1395  struct LCFContext *lcfn;
1396 
1397  for (ncc = ncc_head; NULL != ncc; ncc = nccn)
1398  {
1399  nccn = ncc->next;
1400  if (ncc->client == client)
1401  cleanup_ncc (ncc);
1402  }
1403  for (unsigned int i = 0; i < GST_slave_list_size; i++)
1404  {
1405  struct Slave *slave = GST_slave_list[i];
1406  struct LinkControllersContext *lcc;
1407 
1408  if (NULL == slave)
1409  continue;
1412  client);
1413  lcc = slave->lcc;
1414  if (NULL == lcc)
1415  continue;
1416  if (lcc->client == client)
1417  {
1418  slave->lcc = NULL;
1419  GNUNET_free (lcc);
1420  }
1421  }
1422  for (lcf = lcf_head; NULL != lcf; lcf = lcfn)
1423  {
1424  lcfn = lcf->next;
1425  if ((NULL != lcf) &&
1426  (client == lcf->client))
1427  {
1428  if (NULL != lcf->op)
1430  GNUNET_CONTAINER_DLL_remove (lcf_head,
1431  lcf_tail,
1432  lcf);
1433  GNUNET_free (lcf);
1434  }
1435  }
1436 }
1437 
1438 
1442 void
1444 {
1445  struct LCFContext *lcf;
1446 
1447  if (NULL != lcf_head)
1448  {
1449  if (NULL != lcf_proc_task_id)
1450  {
1451  GNUNET_SCHEDULER_cancel (lcf_proc_task_id);
1452  lcf_proc_task_id = NULL;
1453  }
1454  }
1455  GNUNET_assert (NULL == lcf_proc_task_id);
1456  for (lcf = lcf_head; NULL != lcf; lcf = lcf_head)
1457  {
1458  if (NULL != lcf->op)
1460  if (NULL != lcf->timeout_task)
1462  GNUNET_CONTAINER_DLL_remove (lcf_head,
1463  lcf_tail,
1464  lcf);
1465  GNUNET_free (lcf);
1466  }
1467 }
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:1720
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:190
Link controllers request forwarding context.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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:193
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:2437
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:1831
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.
struct GNUNET_TESTBED_EventInformation::@55::@60 operation_finished
Details about an operation finished event.
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:526
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:99
#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:169
Handle to a client that is connected to a service.
Definition: service.c:250
uint32_t delegated_host_id
For which host should requests be delegated? NBO.
Definition: testbed.h:146
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:1253
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:1784
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:1280
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:2044
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:2324
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.
void GNUNET_TESTBED_operation_activate_(struct GNUNET_TESTBED_Operation *op)
Marks and inactive operation as active.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
union GNUNET_TESTBED_EventInformation::@55 details
Details about the event.
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:185
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.
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:1554
uint16_t config_size
The size of the compressed configuration.
Definition: testbed.h:180
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:156
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:85
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:162
struct NeighbourConnectNotification * nl_head
DLL head for the list of notification requests.
Entry in list of pending tasks.
Definition: scheduler.c:134
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:151
#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:353
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:2243
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:136
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:966