GNUnet  0.11.x
testbed_api_hosts.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_util_lib.h"
30 #include "gnunet_testbed_service.h"
31 #include "gnunet_core_service.h"
33 
34 #include "testbed_api.h"
35 #include "testbed_api_hosts.h"
36 #include "testbed_helper.h"
37 #include "testbed_api_operations.h"
38 
39 #include <zlib.h>
40 #include <regex.h>
41 
45 #define LOG(kind, ...) GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);
46 
50 #define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
51 
55 #define API_VIOLATION(cond, errstr) \
56  do \
57  { \
58  if (cond) \
59  break; \
60  LOG (GNUNET_ERROR_TYPE_ERROR, "API violation detected: %s\n", errstr); \
61  GNUNET_assert (0); \
62  } while (0)
63 
68 #define LOG_GAI(level, cmd, rc) \
69  do \
70  { \
71  LOG (level, \
72  _ ("`%s' failed at %s:%d with error: %s\n"), \
73  cmd, \
74  __FILE__, \
75  __LINE__, \
76  gai_strerror (rc)); \
77  } while (0)
78 
82 #define HOST_LIST_GROW_STEP 10
83 
84 
89 {
94 
99 
104 };
105 
106 
113 {
117  const char *hostname;
118 
122  const char *username;
123 
131 
136 
141 
147 
152 
156  int locked;
157 
161  uint32_t id;
162 
166  uint16_t port;
167 };
168 
169 
174 
178 static unsigned int host_list_size;
179 
180 
188 struct GNUNET_TESTBED_Host *
190 {
191  if (host_list_size <= id)
192  return NULL;
193  return host_list[id];
194 }
195 
196 
209 struct GNUNET_TESTBED_Host *
211  uint32_t id,
212  const struct GNUNET_CONFIGURATION_Handle *cfg)
213 {
214  return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0);
215 }
216 
217 
225 uint32_t
227 {
228  return host->id;
229 }
230 
231 
238 const char *
240 {
241  return host->hostname;
242 }
243 
244 
251 const char *
253 {
254  return host->username;
255 }
256 
257 
264 uint16_t
266 {
267  return host->port;
268 }
269 
270 
277 int
279 {
280  return host->controller_started;
281 }
282 
283 
290 const struct GNUNET_CONFIGURATION_Handle *
292 {
293  return host->cfg;
294 }
295 
296 
303 void
305  struct GNUNET_TESTBED_Host *host,
306  const struct GNUNET_CONFIGURATION_Handle *new_cfg)
307 {
309  host->cfg = GNUNET_CONFIGURATION_dup (new_cfg);
310 }
311 
312 
326 struct GNUNET_TESTBED_Host *
328  uint32_t id,
329  const char *hostname,
330  const char *username,
331  const struct GNUNET_CONFIGURATION_Handle *cfg,
332  uint16_t port)
333 {
334  struct GNUNET_TESTBED_Host *host;
335  unsigned int new_size;
336 
337  if ((id < host_list_size) && (NULL != host_list[id]))
338  {
339  LOG (GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n", id);
340  return NULL;
341  }
342  host = GNUNET_new (struct GNUNET_TESTBED_Host);
343  host->hostname = (NULL != hostname) ? GNUNET_strdup (hostname) : NULL;
344  host->username = (NULL != username) ? GNUNET_strdup (username) : NULL;
345  host->id = id;
346  host->port = (0 == port) ? 22 : port;
347  host->cfg = GNUNET_CONFIGURATION_dup (cfg);
350  UINT_MAX);
351  new_size = host_list_size;
352  while (id >= new_size)
353  new_size += HOST_LIST_GROW_STEP;
354  if (new_size != host_list_size)
355  GNUNET_array_grow (host_list, host_list_size, new_size);
357  LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding host with id: %u\n", host->id);
358  host_list[id] = host;
359  return host;
360 }
361 
362 
374 struct GNUNET_TESTBED_Host *
376  const char *username,
377  const struct GNUNET_CONFIGURATION_Handle *cfg,
378  uint16_t port)
379 {
380  static uint32_t uid_generator;
381 
382  if (NULL == hostname)
384  hostname,
385  username,
386  cfg,
387  port);
388  return GNUNET_TESTBED_host_create_with_id (++uid_generator,
389  hostname,
390  username,
391  cfg,
392  port);
393 }
394 
395 
407 unsigned int
409  const char *filename,
410  const struct GNUNET_CONFIGURATION_Handle *cfg,
411  struct GNUNET_TESTBED_Host ***hosts)
412 {
413  struct GNUNET_TESTBED_Host *starting_host;
414  char *data;
415  char *buf;
416  char *username;
417  char *hostname;
418  regex_t rex;
419  regmatch_t pmatch[6];
420  uint64_t fs;
421  short int port;
422  unsigned int offset;
423  unsigned int count;
424 
425 
426  GNUNET_assert (NULL != filename);
427  if (GNUNET_YES != GNUNET_DISK_file_test (filename))
428  {
429  LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Hosts file %s not found\n"), filename);
430  return 0;
431  }
432  if (GNUNET_OK !=
433  GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
434  fs = 0;
435  if (0 == fs)
436  {
438  _ ("Hosts file %s has no data\n"),
439  filename);
440  return 0;
441  }
442  data = GNUNET_malloc (fs);
443  if (fs != GNUNET_DISK_fn_read (filename, data, fs))
444  {
445  GNUNET_free (data);
447  _ ("Hosts file %s cannot be read\n"),
448  filename);
449  return 0;
450  }
451  buf = data;
452  offset = 0;
453  starting_host = NULL;
454  count = 0;
455  /* refer RFC 952 and RFC 1123 for valid hostnames */
456  GNUNET_assert (0 == regcomp (&rex,
457  "^(([[:alnum:]]+)@)?" /* username */
458  "([[:alnum:]]+[-[:alnum:]_\\.]+)" /* hostname */
459  "(:([[:digit:]]{1,5}))?", /* port */
460  REG_EXTENDED | REG_ICASE));
461  while (offset < (fs - 1))
462  {
463  offset++;
464  if (((data[offset] == '\n')) && (buf != &data[offset]))
465  {
466  unsigned int size;
467 
468  data[offset] = '\0';
469  username = NULL;
470  hostname = NULL;
471  port = 0;
472  if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0)) ||
473  (-1 == pmatch[3].rm_so))
474  {
476  "Error reading line `%s' in hostfile\n",
477  buf);
478  buf = &data[offset + 1];
479  continue;
480  }
481  if (-1 != pmatch[2].rm_so)
482  {
483  size = pmatch[2].rm_eo - pmatch[2].rm_so;
484  username = GNUNET_malloc (size + 1);
485  GNUNET_assert (
486  0 != GNUNET_strlcpy (username, buf + pmatch[2].rm_so, size + 1));
487  }
488  if (-1 != pmatch[5].rm_so)
489  {
490  (void) sscanf (buf + pmatch[5].rm_so, "%5hd", &port);
491  }
492  size = pmatch[3].rm_eo - pmatch[3].rm_so;
493  hostname = GNUNET_malloc (size + 1);
494  GNUNET_assert (
495  0 != GNUNET_strlcpy (hostname, buf + pmatch[3].rm_so, size + 1));
497  "Successfully read host %s, port %d and user %s from file\n",
498  (NULL == hostname) ? "NULL" : hostname,
499  port,
500  (NULL == username) ? "NULL" : username);
501  /* We store hosts in a static list; hence we only require the starting
502  * host pointer in that list to access the newly created list of hosts */
503  if (NULL == starting_host)
504  starting_host =
505  GNUNET_TESTBED_host_create (hostname, username, cfg, port);
506  else
507  (void) GNUNET_TESTBED_host_create (hostname, username, cfg, port);
508  count++;
509  GNUNET_free_non_null (username);
510  GNUNET_free (hostname);
511  buf = &data[offset + 1];
512  }
513  else if ((data[offset] == '\n') || (data[offset] == '\0'))
514  buf = &data[offset + 1];
515  }
516  regfree (&rex);
517  GNUNET_free (data);
518  if (NULL == starting_host)
519  return 0;
520  *hosts = GNUNET_malloc (sizeof(struct GNUNET_TESTBED_Host *) * count);
521  GNUNET_memcpy (*hosts,
522  &host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
523  sizeof(struct GNUNET_TESTBED_Host *) * count);
524  return count;
525 }
526 
527 
534 const char *
535 simple_resolve (const char *host)
536 {
537  struct addrinfo *res;
538  const struct sockaddr_in *in_addr;
539  char *hostip;
540  struct addrinfo hint;
541  unsigned int rc;
542 
543  hint.ai_family = AF_INET; /* IPv4 */
544  hint.ai_socktype = 0;
545  hint.ai_protocol = 0;
546  hint.ai_addrlen = 0;
547  hint.ai_addr = NULL;
548  hint.ai_canonname = NULL;
549  hint.ai_next = NULL;
550  hint.ai_flags = AI_NUMERICSERV;
551  res = NULL;
552  LOG_DEBUG ("Resolving [%s]\n", host);
553  if (0 != (rc = getaddrinfo (host, "22", &hint, &res)))
554  {
555  LOG_GAI (GNUNET_ERROR_TYPE_ERROR, "getaddrinfo", rc);
556  return NULL;
557  }
558  GNUNET_assert (NULL != res);
559  GNUNET_assert (NULL != res->ai_addr);
560  GNUNET_assert (sizeof(struct sockaddr_in) == res->ai_addrlen);
561  in_addr = (const struct sockaddr_in *) res->ai_addr;
562  hostip = inet_ntoa (in_addr->sin_addr);
563  GNUNET_assert (NULL != hostip);
564  freeaddrinfo (res);
565  LOG_DEBUG ("Resolved [%s] to [%s]\n", host, hostip);
566  return hostip;
567 }
568 
569 
582 unsigned int
584  const struct GNUNET_CONFIGURATION_Handle *cfg,
585  struct GNUNET_TESTBED_Host ***hosts)
586 {
587 #if ! ENABLE_SUPERMUC
589  _ ("The function %s is only available when compiled with (--with-ll)\n"),
590  __func__);
591  GNUNET_assert (0);
592 #else
593  const char *hostfile;
594 
595  if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE")))
596  {
597  GNUNET_break (0);
598  return 0;
599  }
600  return GNUNET_TESTBED_hosts_load_from_file (hostfile, cfg, hosts);
601 #endif
602 }
603 
604 
611 void
613 {
614  struct RegisteredController *rc;
615  uint32_t id;
616 
617  GNUNET_assert (host->id < host_list_size);
618  GNUNET_assert (host_list[host->id] == host);
619  host_list[host->id] = NULL;
620  /* clear registered controllers list */
621  for (rc = host->rc_head; NULL != rc; rc = host->rc_head)
622  {
623  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
624  GNUNET_free (rc);
625  }
626  GNUNET_free_non_null ((char *) host->username);
627  GNUNET_free_non_null ((char *) host->hostname);
631  GNUNET_free (host);
633  {
634  for (id = host_list_size - 1; id > host_list_size - HOST_LIST_GROW_STEP;
635  id--)
636  if (NULL != host_list[id])
637  break;
638  if (id != host_list_size - HOST_LIST_GROW_STEP)
639  break;
640  if (NULL != host_list[id])
641  break;
643  }
644  host_list =
645  GNUNET_realloc (host_list,
646  sizeof(struct GNUNET_TESTBED_Host *) * host_list_size);
647 }
648 
649 
656 void
658  struct GNUNET_TESTBED_Host *host,
659  const struct GNUNET_TESTBED_Controller *const controller)
660 {
661  struct RegisteredController *rc;
662 
663  for (rc = host->rc_head; NULL != rc; rc = rc->next)
664  {
665  if (controller == rc->controller) /* already registered at controller */
666  {
667  GNUNET_break (0);
668  return;
669  }
670  }
671  rc = GNUNET_new (struct RegisteredController);
672  rc->controller = controller;
674 }
675 
676 
683 void
685  struct GNUNET_TESTBED_Host *host,
686  const struct GNUNET_TESTBED_Controller *const controller)
687 {
688  struct RegisteredController *rc;
689 
690  for (rc = host->rc_head; NULL != rc; rc = rc->next)
691  if (controller == rc->controller)
692  break;
693  if (NULL == rc)
694  {
695  GNUNET_break (0);
696  return;
697  }
698  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
699  GNUNET_free (rc);
700 }
701 
702 
710 int
712  const struct GNUNET_TESTBED_Host *host,
713  const struct GNUNET_TESTBED_Controller *const controller)
714 {
715  struct RegisteredController *rc;
716 
717  for (rc = host->rc_head; NULL != rc; rc = rc->next)
718  {
719  if (controller == rc->controller) /* already registered at controller */
720  {
721  return GNUNET_YES;
722  }
723  }
724  return GNUNET_NO;
725 }
726 
727 
732 {
737 
741  char **helper_argv;
742 
747 
752 
756  void *cls;
757 
762 
767 };
768 
769 
776 static char **
777 copy_argv (const char *const *argv)
778 {
779  char **argv_dup;
780  unsigned int argp;
781 
782  GNUNET_assert (NULL != argv);
783  for (argp = 0; NULL != argv[argp]; argp++)
784  ;
785  argv_dup = GNUNET_malloc (sizeof(char *) * (argp + 1));
786  for (argp = 0; NULL != argv[argp]; argp++)
787  argv_dup[argp] = GNUNET_strdup (argv[argp]);
788  return argv_dup;
789 }
790 
791 
799 static char **
800 join_argv (const char *const *argv1, const char *const *argv2)
801 {
802  char **argvj;
803  char *argv;
804  unsigned int carg;
805  unsigned int cnt;
806 
807  carg = 0;
808  argvj = NULL;
809  for (cnt = 0; NULL != argv1[cnt]; cnt++)
810  {
811  argv = GNUNET_strdup (argv1[cnt]);
812  GNUNET_array_append (argvj, carg, argv);
813  }
814  for (cnt = 0; NULL != argv2[cnt]; cnt++)
815  {
816  argv = GNUNET_strdup (argv2[cnt]);
817  GNUNET_array_append (argvj, carg, argv);
818  }
819  GNUNET_array_append (argvj, carg, NULL);
820  return argvj;
821 }
822 
823 
829 static void
830 free_argv (char **argv)
831 {
832  unsigned int argp;
833 
834  for (argp = 0; NULL != argv[argp]; argp++)
835  GNUNET_free (argv[argp]);
836  GNUNET_free (argv);
837 }
838 
839 
854 static char **
855 gen_rsh_args (const char *port, const char *hostname, const char *username)
856 {
857  static const char *default_ssh_args[] =
858  { "ssh",
859  "-o",
860  "BatchMode=yes",
861  "-o",
862  "NoHostAuthenticationForLocalhost=yes",
863  "-o",
864  "StrictHostKeyChecking=no",
865  "-o",
866  "PasswordAuthentication=no",
867  "%h",
868  NULL };
869  char **ssh_args;
870  char *ssh_cmd;
871  char *ssh_cmd_cp;
872  char *arg;
873  const char *new_arg;
874  unsigned int size;
875  unsigned int cnt;
876 
877  ssh_args = NULL;
878  if (NULL != (ssh_cmd = getenv ("GNUNET_TESTBED_RSH_CMD")))
879  {
880  ssh_cmd = GNUNET_strdup (ssh_cmd);
881  ssh_cmd_cp = ssh_cmd;
882  for (size = 0; NULL != (arg = strtok (ssh_cmd, " ")); ssh_cmd = NULL)
883  GNUNET_array_append (ssh_args, size, GNUNET_strdup (arg));
884  GNUNET_free (ssh_cmd_cp);
885  }
886  else
887  {
888  ssh_args = copy_argv (default_ssh_args);
889  size = (sizeof(default_ssh_args)) / (sizeof(const char *));
890  GNUNET_array_grow (ssh_args, size, size - 1);
891  }
892  for (cnt = 0; cnt < size; cnt++)
893  {
894  arg = ssh_args[cnt];
895  if ('%' != arg[0])
896  continue;
897  switch (arg[1])
898  {
899  case 'p':
900  new_arg = port;
901  break;
902 
903  case 'u':
904  new_arg = username;
905  break;
906 
907  case 'h':
908  new_arg = hostname;
909  break;
910 
911  default:
912  continue;
913  }
914  if (NULL == new_arg)
915  continue;
916  GNUNET_free (arg);
917  ssh_args[cnt] = GNUNET_strdup (new_arg);
918  }
919  GNUNET_array_append (ssh_args, size, NULL);
920  return ssh_args;
921 }
922 
923 
934 static char **
935 gen_rsh_suffix_args (const char *const *append_args)
936 {
937  char **rshell_args;
938  char *rshell_cmd;
939  char *rshell_cmd_cp;
940  char *arg;
941  unsigned int cnt;
942  unsigned int append_cnt;
943 
944  rshell_args = NULL;
945  cnt = 0;
946  if (NULL != (rshell_cmd = getenv ("GNUNET_TESTBED_RSH_CMD_SUFFIX")))
947  {
948  rshell_cmd = GNUNET_strdup (rshell_cmd);
949  rshell_cmd_cp = rshell_cmd;
950  for (; NULL != (arg = strtok (rshell_cmd, " ")); rshell_cmd = NULL)
951  GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (arg));
952  GNUNET_free (rshell_cmd_cp);
953  }
954  if (NULL != append_args)
955  {
956  for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++)
957  GNUNET_array_append (rshell_args,
958  cnt,
959  GNUNET_strdup (append_args[append_cnt]));
960  }
961  GNUNET_array_append (rshell_args, cnt, NULL);
962  return rshell_args;
963 }
964 
965 
978 static int
979 helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
980 {
981  struct GNUNET_TESTBED_ControllerProc *cp = cls;
982  const struct GNUNET_TESTBED_HelperReply *msg;
983  const char *hostname;
984  char *config;
985  uLongf config_size;
986  uLongf xconfig_size;
987 
988  msg = (const struct GNUNET_TESTBED_HelperReply *) message;
989  GNUNET_assert (sizeof(struct GNUNET_TESTBED_HelperReply) <
990  ntohs (msg->header.size));
992  ntohs (msg->header.type));
993  config_size = (uLongf) ntohs (msg->config_size);
994  xconfig_size = (uLongf) (ntohs (msg->header.size)
995  - sizeof(struct GNUNET_TESTBED_HelperReply));
996  config = GNUNET_malloc (config_size);
997  GNUNET_assert (Z_OK == uncompress ((Bytef *) config,
998  &config_size,
999  (const Bytef *) &msg[1],
1000  xconfig_size));
1001  /* Replace the configuration template present in the host with the
1002  controller's running configuration */
1006  config,
1007  config_size,
1008  NULL));
1009  GNUNET_free (config);
1010  if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))
1011  hostname = "localhost";
1012  /* Change the hostname so that we can connect to it */
1014  "testbed",
1015  "hostname",
1016  hostname);
1017  cp->host->locked = GNUNET_NO;
1019  cp->cb (cp->cls, cp->host->cfg, GNUNET_OK);
1020  return GNUNET_OK;
1021 }
1022 
1023 
1032 static void
1033 clear_msg (void *cls, int result)
1034 {
1035  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1036 
1037  GNUNET_assert (NULL != cp->shandle);
1038  cp->shandle = NULL;
1039  GNUNET_free (cp->msg);
1040  cp->msg = NULL;
1041 }
1042 
1043 
1050 static void
1052 {
1053  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1055  void *cb_cls;
1056 
1057  cb = cp->cb;
1058  cb_cls = cp->cls;
1059  cp->helper = NULL;
1061  if (NULL != cb)
1062  cb (cb_cls, NULL, GNUNET_SYSERR);
1063 }
1064 
1065 
1090 GNUNET_TESTBED_controller_start (const char *trusted_ip,
1091  struct GNUNET_TESTBED_Host *host,
1093  void *cls)
1094 {
1095  struct GNUNET_TESTBED_ControllerProc *cp;
1097  const struct GNUNET_CONFIGURATION_Handle *cfg;
1098  const char *hostname;
1099  static char *const binary_argv[] = { HELPER_TESTBED_BINARY, NULL };
1100 
1101  GNUNET_assert (NULL != host);
1102  GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1103  hostname = NULL;
1104  API_VIOLATION (
1105  GNUNET_NO == host->locked,
1106  "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
1107  host->locked = GNUNET_YES;
1108  API_VIOLATION (
1109  GNUNET_NO == host->controller_started,
1110  "Attempting to start a controller on a host which is already started a controller");
1112  if (0 == GNUNET_TESTBED_host_get_id_ (host))
1113  {
1116  binary_argv,
1117  &helper_mst,
1118  &helper_exp_cb,
1119  cp);
1120  }
1121  else
1122  {
1123  char *helper_binary_path_args[2];
1124  char **rsh_args;
1125  char **rsh_suffix_args;
1126  const char *username;
1127  char *port;
1128  char *argstr;
1129  char *aux;
1130  unsigned int cnt;
1131 
1132  username = host->username;
1133  hostname = host->hostname;
1134  GNUNET_asprintf (&port, "%u", host->port);
1135  LOG_DEBUG ("Starting remote connection to destination %s\n", hostname);
1136  if (GNUNET_OK !=
1138  "testbed",
1139  "HELPER_BINARY_PATH",
1140  &helper_binary_path_args[0]))
1141  helper_binary_path_args[0] =
1143  helper_binary_path_args[1] = NULL;
1144  rsh_args = gen_rsh_args (port, hostname, username);
1145  rsh_suffix_args =
1146  gen_rsh_suffix_args ((const char **) helper_binary_path_args);
1147  cp->helper_argv =
1148  join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
1149  free_argv (rsh_args);
1150  free_argv (rsh_suffix_args);
1151  GNUNET_free (port);
1152  argstr = GNUNET_strdup ("");
1153  for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
1154  {
1155  aux = argstr;
1156  GNUNET_assert (
1157  0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
1158  GNUNET_free (aux);
1159  }
1160  LOG_DEBUG ("Helper cmd str: %s\n", argstr);
1161  GNUNET_free (argstr);
1163  cp->helper_argv[0],
1164  cp->helper_argv,
1165  &helper_mst,
1166  &helper_exp_cb,
1167  cp);
1168  GNUNET_free (helper_binary_path_args[0]);
1169  }
1170  if (NULL == cp->helper)
1171  {
1172  if (NULL != cp->helper_argv)
1173  free_argv (cp->helper_argv);
1174  GNUNET_free (cp);
1175  return NULL;
1176  }
1177  cp->host = host;
1178  cp->cb = cb;
1179  cp->cls = cls;
1180  msg = GNUNET_TESTBED_create_helper_init_msg_ (trusted_ip, hostname, cfg);
1181  cp->msg = &msg->header;
1182  cp->shandle =
1183  GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
1184  if (NULL == cp->shandle)
1185  {
1186  GNUNET_free (msg);
1188  return NULL;
1189  }
1190  return cp;
1191 }
1192 
1193 
1199 void
1201 {
1202  if (NULL != cproc->shandle)
1204  if (NULL != cproc->helper)
1206 }
1207 
1208 
1214 void
1216 {
1217  if (NULL != cproc->helper)
1218  {
1220  GNUNET_HELPER_destroy (cproc->helper);
1221  }
1222  if (NULL != cproc->helper_argv)
1223  free_argv (cproc->helper_argv);
1224  cproc->host->controller_started = GNUNET_NO;
1225  cproc->host->locked = GNUNET_NO;
1226  GNUNET_free_non_null (cproc->msg);
1227  GNUNET_free (cproc);
1228 }
1229 
1230 
1239 void
1241 {
1244 }
1245 
1246 
1251 {
1255  const struct GNUNET_TESTBED_Host *host;
1256 
1261 
1265  void *cb_cls;
1266 
1271 
1275  char **helper_argv;
1276 
1281 
1287 };
1288 
1289 
1295 static void
1297 {
1299  void *cb_cls;
1301  const struct GNUNET_TESTBED_Host *host;
1302  unsigned long code;
1304  int ret;
1305 
1306  h->habitability_check_task = NULL;
1307  ret = GNUNET_OS_process_status (h->auxp, &type, &code);
1308  if (GNUNET_SYSERR == ret)
1309  {
1310  GNUNET_break (0);
1311  ret = GNUNET_NO;
1312  goto call_cb;
1313  }
1314  if (GNUNET_NO == ret)
1315  {
1319  return;
1320  }
1322  h->auxp = NULL;
1323  ret = (0 != code) ? GNUNET_NO : GNUNET_YES;
1324 
1325 call_cb:
1326  if (NULL != h->auxp)
1328  cb = h->cb;
1329  cb_cls = h->cb_cls;
1330  host = h->host;
1331  free_argv (h->helper_argv);
1332  GNUNET_free (h);
1333  if (NULL != cb)
1334  cb (cb_cls, host, ret);
1335 }
1336 
1337 
1351  const struct GNUNET_TESTBED_Host *host,
1352  const struct GNUNET_CONFIGURATION_Handle *config,
1354  void *cb_cls)
1355 {
1357  char **rsh_args;
1358  char **rsh_suffix_args;
1359  char *stat_args[3];
1360  const char *hostname;
1361  char *port;
1362 
1364  h->cb = cb;
1365  h->cb_cls = cb_cls;
1366  h->host = host;
1367  hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
1368  if (GNUNET_OK !=
1370  "testbed",
1371  "HELPER_BINARY_PATH",
1372  &stat_args[1]))
1374  GNUNET_asprintf (&port, "%u", host->port);
1375  rsh_args = gen_rsh_args (port, hostname, host->username);
1376  GNUNET_free (port);
1377  port = NULL;
1378  stat_args[0] = "stat";
1379  stat_args[2] = NULL;
1380  rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args);
1381  GNUNET_free (stat_args[1]);
1382  h->helper_argv =
1383  join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
1384  free_argv (rsh_suffix_args);
1385  free_argv (rsh_args);
1388  NULL,
1389  NULL,
1390  NULL,
1391  h->helper_argv[0],
1392  h->helper_argv);
1393  if (NULL == h->auxp)
1394  {
1395  GNUNET_break (0); /* Cannot exec SSH? */
1396  GNUNET_free (h);
1397  return NULL;
1398  }
1402  return h;
1403 }
1404 
1405 
1411 void
1414 {
1416  (void) GNUNET_OS_process_kill (handle->auxp, GNUNET_TERM_SIG);
1417  (void) GNUNET_OS_process_wait (handle->auxp);
1418  GNUNET_OS_process_destroy (handle->auxp);
1419  free_argv (handle->helper_argv);
1420  GNUNET_free (handle);
1421 }
1422 
1423 
1438  struct GNUNET_TESTBED_Host *host,
1440  void *cc_cls)
1441 {
1444  const char *username;
1445  const char *hostname;
1446  char *config;
1447  char *cconfig;
1448  void *ptr;
1449  size_t cc_size;
1450  size_t config_size;
1451  uint16_t msg_size;
1452  uint16_t username_length;
1453  uint16_t hostname_length;
1454 
1455  if (NULL != controller->rh)
1456  return NULL;
1457  hostname = GNUNET_TESTBED_host_get_hostname (host);
1458  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
1459  {
1461  "Host hostname: %s already registered\n",
1462  (NULL == hostname) ? "localhost" : hostname);
1463  return NULL;
1464  }
1466  rh->host = host;
1467  rh->c = controller;
1468  GNUNET_assert (NULL != cc);
1469  rh->cc = cc;
1470  rh->cc_cls = cc_cls;
1471  controller->rh = rh;
1472  username = GNUNET_TESTBED_host_get_username_ (host);
1473  username_length = 0;
1474  if (NULL != username)
1475  username_length = strlen (username);
1476  GNUNET_assert (NULL != hostname); /* Hostname must be present */
1477  hostname_length = strlen (hostname);
1478  GNUNET_assert (NULL != host->cfg);
1479  config = GNUNET_CONFIGURATION_serialize (host->cfg, &config_size);
1480  cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig);
1481  GNUNET_free (config);
1482  msg_size = (sizeof(struct GNUNET_TESTBED_AddHostMessage));
1483  msg_size += username_length;
1484  msg_size += hostname_length;
1485  msg_size += cc_size;
1486  msg = GNUNET_malloc (msg_size);
1487  msg->header.size = htons (msg_size);
1489  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1490  msg->ssh_port = htons (GNUNET_TESTBED_host_get_ssh_port_ (host));
1491  ptr = &msg[1];
1492  if (NULL != username)
1493  {
1494  msg->username_length = htons (username_length);
1495  GNUNET_memcpy (ptr, username, username_length);
1496  ptr += username_length;
1497  }
1498  msg->hostname_length = htons (hostname_length);
1499  GNUNET_memcpy (ptr, hostname, hostname_length);
1500  ptr += hostname_length;
1501  msg->config_size = htons (config_size);
1502  GNUNET_memcpy (ptr, cconfig, cc_size);
1503  ptr += cc_size;
1504  GNUNET_assert ((ptr - (void *) msg) == msg_size);
1505  GNUNET_free (cconfig);
1506  GNUNET_TESTBED_queue_message_ (controller,
1507  (struct GNUNET_MessageHeader *) msg);
1508  return rh;
1509 }
1510 
1511 
1519 void
1522 {
1523  if (handle != handle->c->rh)
1524  {
1525  GNUNET_break (0);
1526  return;
1527  }
1528  handle->c->rh = NULL;
1529  GNUNET_free (handle);
1530 }
1531 
1532 
1541 void
1543  struct GNUNET_TESTBED_Operation *op)
1544 {
1547  op);
1548 }
1549 
1550 
1556 void
1558 {
1559  char *hostname;
1560 
1561  hostname = (char *) host->hostname;
1562  host->hostname = simple_resolve (hostname);
1563  if (NULL == host->hostname)
1564  {
1565  GNUNET_break (0);
1566  host->hostname = hostname;
1567  return;
1568  }
1569  GNUNET_free (hostname);
1570  host->hostname = GNUNET_strdup (host->hostname);
1571 }
1572 
1573 
1574 /* end of testbed_api_hosts.c */
struct GNUNET_OS_Process * auxp
The process handle for the SSH process.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_HELPER_kill(struct GNUNET_HELPER_Handle *h, int soft_kill)
Sends termination signal to the helper process.
Definition: helper.c:177
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:544
void GNUNET_TESTBED_cancel_registration(struct GNUNET_TESTBED_HostRegistrationHandle *handle)
Cancel the pending registration.
struct GNUNET_TESTBED_HelperInit * GNUNET_TESTBED_create_helper_init_msg_(const char *trusted_ip, const char *hostname, const struct GNUNET_CONFIGURATION_Handle *cfg)
Creates a helper initialization message.
Definition: testbed_api.c:1980
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:91
uint16_t username_length
Number of bytes in the user name that follows; 0 to use no user name; otherwise &#39;strlen (username)&#39;...
Definition: testbed.h:86
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
char ** helper_argv
The arguments used to start the helper.
struct GNUNET_TESTBED_HostHabitableCheckHandle * GNUNET_TESTBED_is_host_habitable(const struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *config, GNUNET_TESTBED_HostHabitableCallback cb, void *cb_cls)
Checks whether a host can be used to start testbed service.
internal API to access the &#39;operations&#39; subsystem
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define AI_NUMERICSERV
AI_NUMERICSERV not defined in windows.
Definition: platform.h:227
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:193
int locked
Is this host locked by GNUNET_TESTBED_controller_start()?
void GNUNET_TESTBED_mark_host_registered_at_(struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
Marks a host as registered with a controller.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:287
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_create_by_id_(uint32_t id, const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a host by ID; given this host handle, we could not run peers at the host, but we can talk abou...
void GNUNET_TESTBED_is_host_habitable_cancel(struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
Function to cancel a request started using GNUNET_TESTBED_is_host_habitable()
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_create_with_id(uint32_t id, const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
Create a host to run peers and controllers on.
int GNUNET_OS_process_status(struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code)
Retrieve the status of a process, waiting on it if dead.
Definition: os_priority.c:963
The handle to a helper process.
Definition: helper.c:78
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
Definition: helper.c:489
struct GNUNET_TESTBED_Host * host
The host being registered.
const struct GNUNET_TESTBED_Host * host
The host to check.
void GNUNET_TESTBED_controller_kill_(struct GNUNET_TESTBED_ControllerProc *cproc)
Sends termination signal to the controller&#39;s helper process.
#define HELPER_TESTBED_BINARY
Testbed Helper binary name.
Definition: testbed_api.h:38
struct GNUNET_HELPER_Handle * helper
The process handle.
struct GNUNET_TESTBED_HostRegistrationHandle * rh
The host registration handle; NULL if no current registration requests are present.
Definition: testbed_api.h:224
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_TESTBED_host_queue_oc_(struct GNUNET_TESTBED_Host *h, struct GNUNET_TESTBED_Operation *op)
Queues the given operation in the queue for parallel overlay connects of the given host...
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
Notify the service about a host that we intend to use.
Definition: testbed.h:64
struct GNUNET_SCHEDULER_Task * habitability_check_task
Task id for the habitability check task.
uint16_t config_size
The length of the uncompressed configuration.
Definition: testbed.h:97
struct OperationQueue * opq_parallel_overlay_connect_operations
Operation queue for simultaneous overlay connect operations target at this host.
void GNUNET_TESTBED_controller_stop(struct GNUNET_TESTBED_ControllerProc *cproc)
Stop the controller process (also will terminate all peers and controllers dependent on this controll...
static char ** gen_rsh_args(const char *port, const char *hostname, const char *username)
Generates arguments for opening a remote shell.
uint16_t hostname_length
Number of bytes in the host name (excluding 0-termination) that follows the user name; cannot be 0...
Definition: testbed.h:92
int controller_started
Is a controller started on this host? FIXME: Is this needed?
Entry in the queue of messages we need to transmit to the helper.
Definition: helper.c:36
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
void GNUNET_TESTBED_deregister_host_at_(struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
Unmarks a host registered at a controller.
A list entry for registered controllers list.
#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
#define LOG(kind,...)
Generic logging shorthand.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_TESTBED_host_replace_cfg_(struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *new_cfg)
Function to replace host&#39;s configuration.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Opaque handle to a host running experiments managed by the testing framework.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
Initialization message for gnunet-helper-testbed to start testbed service.
Handle for controller process.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct OperationQueue * GNUNET_TESTBED_operation_queue_create_(enum OperationQueueType type, unsigned int max_active)
Create an operation queue.
void * cc_cls
The closure for above callback.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
Opaque handle to an abstract operation to be executed by the testing framework.
GNUNET_TESTBED_HostHabitableCallback cb
The callback to call once we have the status.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
void(* GNUNET_TESTBED_HostRegistrationCompletion)(void *cls, const char *emsg)
Callback which will be called to after a host registration succeeded or failed.
void(* GNUNET_TESTBED_ControllerStatusCallback)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
Callback to signal successfull startup of the controller process.
struct RegisteredController * rc_head
The head for the list of controllers where this host is registered.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static void clear_msg(void *cls, int result)
Continuation function from GNUNET_HELPER_send()
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
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:695
const char * GNUNET_TESTBED_host_get_username_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s username.
struct RegisteredController * next
The next ptr for DLL.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
struct RegisteredController * rc_tail
The tail for the list of controllers where this host is registered.
static void free_argv(char **argv)
Frees the given NULL terminated arguments.
const char * simple_resolve(const char *host)
Resolves a hostname using getaddrinfo.
GNUNET_OS_ProcessStatusType
Process status types.
void GNUNET_TESTBED_host_resolve_(struct GNUNET_TESTBED_Host *host)
Resolves the hostname of the host to an ip address.
void(* GNUNET_TESTBED_HostHabitableCallback)(void *cls, const struct GNUNET_TESTBED_Host *host, int status)
Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to inform whether the given hos...
The handle for whether a host is habitable or not.
struct GNUNET_OS_Process * GNUNET_OS_start_process_vap(int pipe_control, enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, char *const argv[])
Start a process.
Definition: os_priority.c:607
static void helper_exp_cb(void *cls)
Callback that will be called when the helper process dies.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static char buf[2048]
static char * filename
static const struct GNUNET_CONFIGURATION_Handle * config
static char ** copy_argv(const char *const *argv)
Function to copy NULL terminated list of arguments.
#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST
Message to add host.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static int result
Global testing status.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
uint32_t id
Global ID we use to refer to a host on the network.
static struct GNUNET_TIME_Relative wait_time
How long to wait before triggering next round? Default: 60 s.
struct GNUNET_TIME_Relative wait_time
How long we wait before checking the process status.
struct RegisteredController * prev
The prev ptr for DLL.
#define LOG_GAI(level, cmd, rc)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char ** argv2
The arguments including the binary to spawn.
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s configuration template.
void GNUNET_TESTBED_controller_destroy_(struct GNUNET_TESTBED_ControllerProc *cproc)
Cleans-up the controller&#39;s helper process handle.
static int res
uint16_t port
The port which is to be used for SSH.
Reply message from helper process.
#define __func__
void GNUNET_TESTBED_operation_queue_destroy_(struct OperationQueue *queue)
Destroys an operation queue.
#define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY
The reply message from gnunet-testbed-helper.
#define LOG_DEBUG(...)
Debug logging shorthand.
static char ** join_argv(const char *const *argv1, const char *const *argv2)
Function to join NULL terminated list of arguments.
uint32_t host_id
Unique ID for the host (in NBO).
Definition: testbed.h:74
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_create(const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
Create a host to run peers and controllers on.
int GNUNET_TESTBED_host_controller_started(const struct GNUNET_TESTBED_Host *host)
Check whether a controller is already started on the given host.
const char * username
The username to be used for SSH login.
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_host_destroy(struct GNUNET_TESTBED_Host *host)
Destroy a host handle.
GNUNET_TESTBED_ControllerStatusCallback cb
The controller error callback.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
const struct GNUNET_TESTBED_Controller * controller
The controller at which this host is registered.
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1335
#define API_VIOLATION(cond, errstr)
Prints API violation message.
#define HOST_LIST_GROW_STEP
Number of extra elements we create space for when we grow host list.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST.
Definition: testbed.h:69
char * getenv()
struct GNUNET_TESTBED_Controller * c
The controller at which this host is being registered.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
const char * hostname
The hostname of the host; NULL for localhost.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
int GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:257
GNUNET_TESTBED_HostRegistrationCompletion cc
The Registartion completion callback.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1757
Interface for functions internally exported from testbed_api.c.
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
Queue of operations where we can only support a certain number of concurrent operations of a particul...
const char * GNUNET_TESTBED_host_get_hostname(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s hostname.
static char * hostname
Our hostname; we give this to all the peers we start.
struct GNUNET_TESTBED_Host * host
The host where the helper is run.
void GNUNET_HELPER_destroy(struct GNUNET_HELPER_Handle *h)
Free&#39;s the resources occupied by the helper handle.
Definition: helper.c:528
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:1000
static unsigned int host_list_size
The size of the available hosts list.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
configuration data
Definition: configuration.c:85
void * cls
The closure for the above callback.
static void habitability_check(void *cls)
Task for checking whether a host is habitable or not.
unsigned int GNUNET_TESTBED_hosts_load_from_loadleveler(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts)
Loads the set of host allocated by the LoadLeveler Job Scheduler.
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
Definition: helper.c:655
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
int GNUNET_HELPER_wait(struct GNUNET_HELPER_Handle *h)
Reap the helper process.
Definition: helper.c:225
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
handle for host registration
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
uint16_t GNUNET_TESTBED_host_get_ssh_port_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s ssh port.
static int helper_mst(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer...
internal API to access the &#39;hosts&#39; subsystem
Message formats for communication between testbed api and gnunet-helper-testbed process.
char ** helper_argv
The arguments used to start the helper.
int GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
De-serializes configuration.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
#define GNUNET_TERM_SIG
The termination signal.
Definition: platform.h:242
uint32_t data
The data value.
Operation queue which adapts the number of operations to be active based on the operation completion ...
struct GNUNET_TESTBED_HostRegistrationHandle * GNUNET_TESTBED_register_host(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_HostRegistrationCompletion cc, void *cc_cls)
Register a host with the controller.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
Definition: strings.c:219
uint16_t config_size
Size of the uncompressed configuration.
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.
#define GNUNET_malloc(size)
Wrapper around malloc.
unsigned int GNUNET_TESTBED_hosts_load_from_file(const char *filename, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts)
Load a set of hosts from a configuration file.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:794
uint16_t ssh_port
SSH port to use, 0 for default (in NBO).
Definition: testbed.h:79
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TESTBED_Host ** host_list
Array of available hosts.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_lookup_by_id_(uint32_t id)
Lookup a host by ID.
struct GNUNET_MessageHeader * msg
The message corresponding to send handle.
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:225
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
static char ** gen_rsh_suffix_args(const char *const *append_args)
Generates the arguments needed for executing the given binary in a remote shell.