GNUnet  0.10.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 
93 
98 
103 };
104 
105 
115  const char *hostname;
116 
120  const char *username;
121 
129 
134 
139 
145 
150 
154  int locked;
155 
159  uint32_t id;
160 
164  uint16_t port;
165 };
166 
167 
172 
176 static unsigned int host_list_size;
177 
178 
186 struct GNUNET_TESTBED_Host *
188 {
189  if (host_list_size <= id)
190  return NULL;
191  return host_list[id];
192 }
193 
194 
207 struct GNUNET_TESTBED_Host *
209  uint32_t id,
210  const struct GNUNET_CONFIGURATION_Handle *cfg)
211 {
212  return GNUNET_TESTBED_host_create_with_id(id, NULL, NULL, cfg, 0);
213 }
214 
215 
223 uint32_t
225 {
226  return host->id;
227 }
228 
229 
236 const char *
238 {
239  return host->hostname;
240 }
241 
242 
249 const char *
251 {
252  return host->username;
253 }
254 
255 
262 uint16_t
264 {
265  return host->port;
266 }
267 
268 
275 int
277 {
278  return host->controller_started;
279 }
280 
281 
288 const struct GNUNET_CONFIGURATION_Handle *
290 {
291  return host->cfg;
292 }
293 
294 
301 void
303  struct GNUNET_TESTBED_Host *host,
304  const struct GNUNET_CONFIGURATION_Handle *new_cfg)
305 {
307  host->cfg = GNUNET_CONFIGURATION_dup(new_cfg);
308 }
309 
310 
324 struct GNUNET_TESTBED_Host *
326  uint32_t id,
327  const char *hostname,
328  const char *username,
329  const struct GNUNET_CONFIGURATION_Handle *cfg,
330  uint16_t port)
331 {
332  struct GNUNET_TESTBED_Host *host;
333  unsigned int new_size;
334 
335  if ((id < host_list_size) && (NULL != host_list[id]))
336  {
337  LOG(GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n", id);
338  return NULL;
339  }
340  host = GNUNET_new(struct GNUNET_TESTBED_Host);
341  host->hostname = (NULL != hostname) ? GNUNET_strdup(hostname) : NULL;
342  host->username = (NULL != username) ? GNUNET_strdup(username) : NULL;
343  host->id = id;
344  host->port = (0 == port) ? 22 : port;
345  host->cfg = GNUNET_CONFIGURATION_dup(cfg);
348  UINT_MAX);
349  new_size = host_list_size;
350  while (id >= new_size)
351  new_size += HOST_LIST_GROW_STEP;
352  if (new_size != host_list_size)
353  GNUNET_array_grow(host_list, host_list_size, new_size);
355  LOG(GNUNET_ERROR_TYPE_DEBUG, "Adding host with id: %u\n", host->id);
356  host_list[id] = host;
357  return host;
358 }
359 
360 
372 struct GNUNET_TESTBED_Host *
374  const char *username,
375  const struct GNUNET_CONFIGURATION_Handle *cfg,
376  uint16_t port)
377 {
378  static uint32_t uid_generator;
379 
380  if (NULL == hostname)
382  hostname,
383  username,
384  cfg,
385  port);
386  return GNUNET_TESTBED_host_create_with_id(++uid_generator,
387  hostname,
388  username,
389  cfg,
390  port);
391 }
392 
393 
405 unsigned int
407  const char *filename,
408  const struct GNUNET_CONFIGURATION_Handle *cfg,
409  struct GNUNET_TESTBED_Host ***hosts)
410 {
411  struct GNUNET_TESTBED_Host *starting_host;
412  char *data;
413  char *buf;
414  char *username;
415  char *hostname;
416  regex_t rex;
417  regmatch_t pmatch[6];
418  uint64_t fs;
419  short int port;
420  unsigned int offset;
421  unsigned int count;
422 
423 
424  GNUNET_assert(NULL != filename);
425  if (GNUNET_YES != GNUNET_DISK_file_test(filename))
426  {
427  LOG(GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
428  return 0;
429  }
430  if (GNUNET_OK !=
432  fs = 0;
433  if (0 == fs)
434  {
436  _("Hosts file %s has no data\n"),
437  filename);
438  return 0;
439  }
440  data = GNUNET_malloc(fs);
441  if (fs != GNUNET_DISK_fn_read(filename, data, fs))
442  {
443  GNUNET_free(data);
445  _("Hosts file %s cannot be read\n"),
446  filename);
447  return 0;
448  }
449  buf = data;
450  offset = 0;
451  starting_host = NULL;
452  count = 0;
453  /* refer RFC 952 and RFC 1123 for valid hostnames */
454  GNUNET_assert(0 == regcomp(&rex,
455  "^(([[:alnum:]]+)@)?" /* username */
456  "([[:alnum:]]+[-[:alnum:]_\\.]+)" /* hostname */
457  "(:([[:digit:]]{1,5}))?", /* port */
458  REG_EXTENDED | REG_ICASE));
459  while (offset < (fs - 1))
460  {
461  offset++;
462  if (((data[offset] == '\n')) && (buf != &data[offset]))
463  {
464  unsigned int size;
465 
466  data[offset] = '\0';
467  username = NULL;
468  hostname = NULL;
469  port = 0;
470  if ((REG_NOMATCH == regexec(&rex, buf, 6, pmatch, 0)) ||
471  (-1 == pmatch[3].rm_so))
472  {
474  "Error reading line `%s' in hostfile\n",
475  buf);
476  buf = &data[offset + 1];
477  continue;
478  }
479  if (-1 != pmatch[2].rm_so)
480  {
481  size = pmatch[2].rm_eo - pmatch[2].rm_so;
482  username = GNUNET_malloc(size + 1);
484  0 != GNUNET_strlcpy(username, buf + pmatch[2].rm_so, size + 1));
485  }
486  if (-1 != pmatch[5].rm_so)
487  {
488  (void)sscanf(buf + pmatch[5].rm_so, "%5hd", &port);
489  }
490  size = pmatch[3].rm_eo - pmatch[3].rm_so;
491  hostname = GNUNET_malloc(size + 1);
493  0 != GNUNET_strlcpy(hostname, buf + pmatch[3].rm_so, size + 1));
495  "Successfully read host %s, port %d and user %s from file\n",
496  (NULL == hostname) ? "NULL" : hostname,
497  port,
498  (NULL == username) ? "NULL" : username);
499  /* We store hosts in a static list; hence we only require the starting
500  * host pointer in that list to access the newly created list of hosts */
501  if (NULL == starting_host)
502  starting_host =
503  GNUNET_TESTBED_host_create(hostname, username, cfg, port);
504  else
505  (void)GNUNET_TESTBED_host_create(hostname, username, cfg, port);
506  count++;
507  GNUNET_free_non_null(username);
508  GNUNET_free(hostname);
509  buf = &data[offset + 1];
510  }
511  else if ((data[offset] == '\n') || (data[offset] == '\0'))
512  buf = &data[offset + 1];
513  }
514  regfree(&rex);
515  GNUNET_free(data);
516  if (NULL == starting_host)
517  return 0;
518  *hosts = GNUNET_malloc(sizeof(struct GNUNET_TESTBED_Host *) * count);
519  GNUNET_memcpy(*hosts,
520  &host_list[GNUNET_TESTBED_host_get_id_(starting_host)],
521  sizeof(struct GNUNET_TESTBED_Host *) * count);
522  return count;
523 }
524 
525 
532 const char *
533 simple_resolve(const char *host)
534 {
535  struct addrinfo *res;
536  const struct sockaddr_in *in_addr;
537  char *hostip;
538  struct addrinfo hint;
539  unsigned int rc;
540 
541  hint.ai_family = AF_INET; /* IPv4 */
542  hint.ai_socktype = 0;
543  hint.ai_protocol = 0;
544  hint.ai_addrlen = 0;
545  hint.ai_addr = NULL;
546  hint.ai_canonname = NULL;
547  hint.ai_next = NULL;
548  hint.ai_flags = AI_NUMERICSERV;
549  res = NULL;
550  LOG_DEBUG("Resolving [%s]\n", host);
551  if (0 != (rc = getaddrinfo(host, "22", &hint, &res)))
552  {
553  LOG_GAI(GNUNET_ERROR_TYPE_ERROR, "getaddrinfo", rc);
554  return NULL;
555  }
556  GNUNET_assert(NULL != res);
557  GNUNET_assert(NULL != res->ai_addr);
558  GNUNET_assert(sizeof(struct sockaddr_in) == res->ai_addrlen);
559  in_addr = (const struct sockaddr_in *)res->ai_addr;
560  hostip = inet_ntoa(in_addr->sin_addr);
561  GNUNET_assert(NULL != hostip);
562  freeaddrinfo(res);
563  LOG_DEBUG("Resolved [%s] to [%s]\n", host, hostip);
564  return hostip;
565 }
566 
567 
580 unsigned int
582  const struct GNUNET_CONFIGURATION_Handle *cfg,
583  struct GNUNET_TESTBED_Host ***hosts)
584 {
585 #if !ENABLE_SUPERMUC
587  _("The function %s is only available when compiled with (--with-ll)\n"),
588  __func__);
589  GNUNET_assert(0);
590 #else
591  const char *hostfile;
592 
593  if (NULL == (hostfile = getenv("MP_SAVEHOSTFILE")))
594  {
595  GNUNET_break(0);
596  return 0;
597  }
598  return GNUNET_TESTBED_hosts_load_from_file(hostfile, cfg, hosts);
599 #endif
600 }
601 
602 
609 void
611 {
612  struct RegisteredController *rc;
613  uint32_t id;
614 
616  GNUNET_assert(host_list[host->id] == host);
617  host_list[host->id] = NULL;
618  /* clear registered controllers list */
619  for (rc = host->rc_head; NULL != rc; rc = host->rc_head)
620  {
621  GNUNET_CONTAINER_DLL_remove(host->rc_head, host->rc_tail, rc);
622  GNUNET_free(rc);
623  }
624  GNUNET_free_non_null((char *)host->username);
625  GNUNET_free_non_null((char *)host->hostname);
629  GNUNET_free(host);
631  {
632  for (id = host_list_size - 1; id > host_list_size - HOST_LIST_GROW_STEP;
633  id--)
634  if (NULL != host_list[id])
635  break;
636  if (id != host_list_size - HOST_LIST_GROW_STEP)
637  break;
638  if (NULL != host_list[id])
639  break;
641  }
642  host_list =
643  GNUNET_realloc(host_list,
644  sizeof(struct GNUNET_TESTBED_Host *) * host_list_size);
645 }
646 
647 
654 void
656  struct GNUNET_TESTBED_Host *host,
657  const struct GNUNET_TESTBED_Controller *const controller)
658 {
659  struct RegisteredController *rc;
660 
661  for (rc = host->rc_head; NULL != rc; rc = rc->next)
662  {
663  if (controller == rc->controller) /* already registered at controller */
664  {
665  GNUNET_break(0);
666  return;
667  }
668  }
669  rc = GNUNET_new(struct RegisteredController);
670  rc->controller = controller;
672 }
673 
674 
681 void
683  struct GNUNET_TESTBED_Host *host,
684  const struct GNUNET_TESTBED_Controller *const controller)
685 {
686  struct RegisteredController *rc;
687 
688  for (rc = host->rc_head; NULL != rc; rc = rc->next)
689  if (controller == rc->controller)
690  break;
691  if (NULL == rc)
692  {
693  GNUNET_break(0);
694  return;
695  }
696  GNUNET_CONTAINER_DLL_remove(host->rc_head, host->rc_tail, rc);
697  GNUNET_free(rc);
698 }
699 
700 
708 int
710  const struct GNUNET_TESTBED_Host *host,
711  const struct GNUNET_TESTBED_Controller *const controller)
712 {
713  struct RegisteredController *rc;
714 
715  for (rc = host->rc_head; NULL != rc; rc = rc->next)
716  {
717  if (controller == rc->controller) /* already registered at controller */
718  {
719  return GNUNET_YES;
720  }
721  }
722  return GNUNET_NO;
723 }
724 
725 
734 
738  char **helper_argv;
739 
744 
749 
753  void *cls;
754 
759 
764 };
765 
766 
773 static char **
774 copy_argv(const char *const *argv)
775 {
776  char **argv_dup;
777  unsigned int argp;
778 
779  GNUNET_assert(NULL != argv);
780  for (argp = 0; NULL != argv[argp]; argp++)
781  ;
782  argv_dup = GNUNET_malloc(sizeof(char *) * (argp + 1));
783  for (argp = 0; NULL != argv[argp]; argp++)
784  argv_dup[argp] = GNUNET_strdup(argv[argp]);
785  return argv_dup;
786 }
787 
788 
796 static char **
797 join_argv(const char *const *argv1, const char *const *argv2)
798 {
799  char **argvj;
800  char *argv;
801  unsigned int carg;
802  unsigned int cnt;
803 
804  carg = 0;
805  argvj = NULL;
806  for (cnt = 0; NULL != argv1[cnt]; cnt++)
807  {
808  argv = GNUNET_strdup(argv1[cnt]);
809  GNUNET_array_append(argvj, carg, argv);
810  }
811  for (cnt = 0; NULL != argv2[cnt]; cnt++)
812  {
813  argv = GNUNET_strdup(argv2[cnt]);
814  GNUNET_array_append(argvj, carg, argv);
815  }
816  GNUNET_array_append(argvj, carg, NULL);
817  return argvj;
818 }
819 
820 
826 static void
827 free_argv(char **argv)
828 {
829  unsigned int argp;
830 
831  for (argp = 0; NULL != argv[argp]; argp++)
832  GNUNET_free(argv[argp]);
833  GNUNET_free(argv);
834 }
835 
836 
851 static char **
852 gen_rsh_args(const char *port, const char *hostname, const char *username)
853 {
854  static const char *default_ssh_args[] =
855  { "ssh",
856  "-o",
857  "BatchMode=yes",
858  "-o",
859  "NoHostAuthenticationForLocalhost=yes",
860  "-o",
861  "StrictHostKeyChecking=no",
862  "-o",
863  "PasswordAuthentication=no",
864  "%h",
865  NULL };
866  char **ssh_args;
867  char *ssh_cmd;
868  char *ssh_cmd_cp;
869  char *arg;
870  const char *new_arg;
871  unsigned int size;
872  unsigned int cnt;
873 
874  ssh_args = NULL;
875  if (NULL != (ssh_cmd = getenv("GNUNET_TESTBED_RSH_CMD")))
876  {
877  ssh_cmd = GNUNET_strdup(ssh_cmd);
878  ssh_cmd_cp = ssh_cmd;
879  for (size = 0; NULL != (arg = strtok(ssh_cmd, " ")); ssh_cmd = NULL)
880  GNUNET_array_append(ssh_args, size, GNUNET_strdup(arg));
881  GNUNET_free(ssh_cmd_cp);
882  }
883  else
884  {
885  ssh_args = copy_argv(default_ssh_args);
886  size = (sizeof(default_ssh_args)) / (sizeof(const char *));
887  GNUNET_array_grow(ssh_args, size, size - 1);
888  }
889  for (cnt = 0; cnt < size; cnt++)
890  {
891  arg = ssh_args[cnt];
892  if ('%' != arg[0])
893  continue;
894  switch (arg[1])
895  {
896  case 'p':
897  new_arg = port;
898  break;
899 
900  case 'u':
901  new_arg = username;
902  break;
903 
904  case 'h':
905  new_arg = hostname;
906  break;
907 
908  default:
909  continue;
910  }
911  if (NULL == new_arg)
912  continue;
913  GNUNET_free(arg);
914  ssh_args[cnt] = GNUNET_strdup(new_arg);
915  }
916  GNUNET_array_append(ssh_args, size, NULL);
917  return ssh_args;
918 }
919 
920 
931 static char **
932 gen_rsh_suffix_args(const char *const *append_args)
933 {
934  char **rshell_args;
935  char *rshell_cmd;
936  char *rshell_cmd_cp;
937  char *arg;
938  unsigned int cnt;
939  unsigned int append_cnt;
940 
941  rshell_args = NULL;
942  cnt = 0;
943  if (NULL != (rshell_cmd = getenv("GNUNET_TESTBED_RSH_CMD_SUFFIX")))
944  {
945  rshell_cmd = GNUNET_strdup(rshell_cmd);
946  rshell_cmd_cp = rshell_cmd;
947  for (; NULL != (arg = strtok(rshell_cmd, " ")); rshell_cmd = NULL)
948  GNUNET_array_append(rshell_args, cnt, GNUNET_strdup(arg));
949  GNUNET_free(rshell_cmd_cp);
950  }
951  if (NULL != append_args)
952  {
953  for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++)
954  GNUNET_array_append(rshell_args,
955  cnt,
956  GNUNET_strdup(append_args[append_cnt]));
957  }
958  GNUNET_array_append(rshell_args, cnt, NULL);
959  return rshell_args;
960 }
961 
962 
975 static int
976 helper_mst(void *cls, const struct GNUNET_MessageHeader *message)
977 {
978  struct GNUNET_TESTBED_ControllerProc *cp = cls;
979  const struct GNUNET_TESTBED_HelperReply *msg;
980  const char *hostname;
981  char *config;
982  uLongf config_size;
983  uLongf xconfig_size;
984 
985  msg = (const struct GNUNET_TESTBED_HelperReply *)message;
987  ntohs(msg->header.size));
989  ntohs(msg->header.type));
990  config_size = (uLongf)ntohs(msg->config_size);
991  xconfig_size = (uLongf)(ntohs(msg->header.size) -
992  sizeof(struct GNUNET_TESTBED_HelperReply));
993  config = GNUNET_malloc(config_size);
994  GNUNET_assert(Z_OK == uncompress((Bytef *)config,
995  &config_size,
996  (const Bytef *)&msg[1],
997  xconfig_size));
998  /* Replace the configuration template present in the host with the
999  controller's running configuration */
1003  config,
1004  config_size,
1005  NULL));
1006  GNUNET_free(config);
1007  if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname(cp->host)))
1008  hostname = "localhost";
1009  /* Change the hostname so that we can connect to it */
1011  "testbed",
1012  "hostname",
1013  hostname);
1014  cp->host->locked = GNUNET_NO;
1016  cp->cb(cp->cls, cp->host->cfg, GNUNET_OK);
1017  return GNUNET_OK;
1018 }
1019 
1020 
1029 static void
1030 clear_msg(void *cls, int result)
1031 {
1032  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1033 
1034  GNUNET_assert(NULL != cp->shandle);
1035  cp->shandle = NULL;
1036  GNUNET_free(cp->msg);
1037  cp->msg = NULL;
1038 }
1039 
1040 
1047 static void
1049 {
1050  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1052  void *cb_cls;
1053 
1054  cb = cp->cb;
1055  cb_cls = cp->cls;
1056  cp->helper = NULL;
1058  if (NULL != cb)
1059  cb(cb_cls, NULL, GNUNET_SYSERR);
1060 }
1061 
1062 
1087 GNUNET_TESTBED_controller_start(const char *trusted_ip,
1088  struct GNUNET_TESTBED_Host *host,
1090  void *cls)
1091 {
1092  struct GNUNET_TESTBED_ControllerProc *cp;
1094  const struct GNUNET_CONFIGURATION_Handle *cfg;
1095  const char *hostname;
1096  static char *const binary_argv[] = { HELPER_TESTBED_BINARY, NULL };
1097 
1098  GNUNET_assert(NULL != host);
1099  GNUNET_assert(NULL != (cfg = GNUNET_TESTBED_host_get_cfg_(host)));
1100  hostname = NULL;
1101  API_VIOLATION(
1102  GNUNET_NO == host->locked,
1103  "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
1104  host->locked = GNUNET_YES;
1105  API_VIOLATION(
1106  GNUNET_NO == host->controller_started,
1107  "Attempting to start a controller on a host which is already started a controller");
1109  if (0 == GNUNET_TESTBED_host_get_id_(host))
1110  {
1113  binary_argv,
1114  &helper_mst,
1115  &helper_exp_cb,
1116  cp);
1117  }
1118  else
1119  {
1120  char *helper_binary_path_args[2];
1121  char **rsh_args;
1122  char **rsh_suffix_args;
1123  const char *username;
1124  char *port;
1125  char *argstr;
1126  char *aux;
1127  unsigned int cnt;
1128 
1129  username = host->username;
1130  hostname = host->hostname;
1131  GNUNET_asprintf(&port, "%u", host->port);
1132  LOG_DEBUG("Starting remote connection to destination %s\n", hostname);
1133  if (GNUNET_OK !=
1135  "testbed",
1136  "HELPER_BINARY_PATH",
1137  &helper_binary_path_args[0]))
1138  helper_binary_path_args[0] =
1140  helper_binary_path_args[1] = NULL;
1141  rsh_args = gen_rsh_args(port, hostname, username);
1142  rsh_suffix_args =
1143  gen_rsh_suffix_args((const char **)helper_binary_path_args);
1144  cp->helper_argv =
1145  join_argv((const char **)rsh_args, (const char **)rsh_suffix_args);
1146  free_argv(rsh_args);
1147  free_argv(rsh_suffix_args);
1148  GNUNET_free(port);
1149  argstr = GNUNET_strdup("");
1150  for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
1151  {
1152  aux = argstr;
1153  GNUNET_assert(
1154  0 < GNUNET_asprintf(&argstr, "%s %s", aux, cp->helper_argv[cnt]));
1155  GNUNET_free(aux);
1156  }
1157  LOG_DEBUG("Helper cmd str: %s\n", argstr);
1158  GNUNET_free(argstr);
1160  cp->helper_argv[0],
1161  cp->helper_argv,
1162  &helper_mst,
1163  &helper_exp_cb,
1164  cp);
1165  GNUNET_free(helper_binary_path_args[0]);
1166  }
1167  if (NULL == cp->helper)
1168  {
1169  if (NULL != cp->helper_argv)
1170  free_argv(cp->helper_argv);
1171  GNUNET_free(cp);
1172  return NULL;
1173  }
1174  cp->host = host;
1175  cp->cb = cb;
1176  cp->cls = cls;
1177  msg = GNUNET_TESTBED_create_helper_init_msg_(trusted_ip, hostname, cfg);
1178  cp->msg = &msg->header;
1179  cp->shandle =
1180  GNUNET_HELPER_send(cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
1181  if (NULL == cp->shandle)
1182  {
1183  GNUNET_free(msg);
1185  return NULL;
1186  }
1187  return cp;
1188 }
1189 
1190 
1196 void
1198 {
1199  if (NULL != cproc->shandle)
1201  if (NULL != cproc->helper)
1203 }
1204 
1205 
1211 void
1213 {
1214  if (NULL != cproc->helper)
1215  {
1217  GNUNET_HELPER_destroy(cproc->helper);
1218  }
1219  if (NULL != cproc->helper_argv)
1220  free_argv(cproc->helper_argv);
1221  cproc->host->controller_started = GNUNET_NO;
1222  cproc->host->locked = GNUNET_NO;
1223  GNUNET_free_non_null(cproc->msg);
1224  GNUNET_free(cproc);
1225 }
1226 
1227 
1236 void
1238 {
1241 }
1242 
1243 
1251  const struct GNUNET_TESTBED_Host *host;
1252 
1257 
1261  void *cb_cls;
1262 
1267 
1271  char **helper_argv;
1272 
1277 
1283 };
1284 
1285 
1291 static void
1293 {
1295  void *cb_cls;
1297  const struct GNUNET_TESTBED_Host *host;
1298  unsigned long code;
1300  int ret;
1301 
1302  h->habitability_check_task = NULL;
1303  ret = GNUNET_OS_process_status(h->auxp, &type, &code);
1304  if (GNUNET_SYSERR == ret)
1305  {
1306  GNUNET_break(0);
1307  ret = GNUNET_NO;
1308  goto call_cb;
1309  }
1310  if (GNUNET_NO == ret)
1311  {
1315  return;
1316  }
1318  h->auxp = NULL;
1319  ret = (0 != code) ? GNUNET_NO : GNUNET_YES;
1320 
1321 call_cb:
1322  if (NULL != h->auxp)
1324  cb = h->cb;
1325  cb_cls = h->cb_cls;
1326  host = h->host;
1327  free_argv(h->helper_argv);
1328  GNUNET_free(h);
1329  if (NULL != cb)
1330  cb(cb_cls, host, ret);
1331 }
1332 
1333 
1347  const struct GNUNET_TESTBED_Host *host,
1348  const struct GNUNET_CONFIGURATION_Handle *config,
1350  void *cb_cls)
1351 {
1353  char **rsh_args;
1354  char **rsh_suffix_args;
1355  char *stat_args[3];
1356  const char *hostname;
1357  char *port;
1358 
1360  h->cb = cb;
1361  h->cb_cls = cb_cls;
1362  h->host = host;
1363  hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
1364  if (GNUNET_OK !=
1366  "testbed",
1367  "HELPER_BINARY_PATH",
1368  &stat_args[1]))
1370  GNUNET_asprintf(&port, "%u", host->port);
1371  rsh_args = gen_rsh_args(port, hostname, host->username);
1372  GNUNET_free(port);
1373  port = NULL;
1374  stat_args[0] = "stat";
1375  stat_args[2] = NULL;
1376  rsh_suffix_args = gen_rsh_suffix_args((const char **)stat_args);
1377  GNUNET_free(stat_args[1]);
1378  h->helper_argv =
1379  join_argv((const char **)rsh_args, (const char **)rsh_suffix_args);
1380  free_argv(rsh_suffix_args);
1381  free_argv(rsh_args);
1384  NULL,
1385  NULL,
1386  NULL,
1387  h->helper_argv[0],
1388  h->helper_argv);
1389  if (NULL == h->auxp)
1390  {
1391  GNUNET_break(0); /* Cannot exec SSH? */
1392  GNUNET_free(h);
1393  return NULL;
1394  }
1398  return h;
1399 }
1400 
1401 
1407 void
1410 {
1413  (void)GNUNET_OS_process_wait(handle->auxp);
1415  free_argv(handle->helper_argv);
1416  GNUNET_free(handle);
1417 }
1418 
1419 
1434  struct GNUNET_TESTBED_Host *host,
1436  void *cc_cls)
1437 {
1440  const char *username;
1441  const char *hostname;
1442  char *config;
1443  char *cconfig;
1444  void *ptr;
1445  size_t cc_size;
1446  size_t config_size;
1447  uint16_t msg_size;
1448  uint16_t username_length;
1449  uint16_t hostname_length;
1450 
1451  if (NULL != controller->rh)
1452  return NULL;
1453  hostname = GNUNET_TESTBED_host_get_hostname(host);
1454  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_(host, controller))
1455  {
1457  "Host hostname: %s already registered\n",
1458  (NULL == hostname) ? "localhost" : hostname);
1459  return NULL;
1460  }
1462  rh->host = host;
1463  rh->c = controller;
1464  GNUNET_assert(NULL != cc);
1465  rh->cc = cc;
1466  rh->cc_cls = cc_cls;
1467  controller->rh = rh;
1468  username = GNUNET_TESTBED_host_get_username_(host);
1469  username_length = 0;
1470  if (NULL != username)
1471  username_length = strlen(username);
1472  GNUNET_assert(NULL != hostname); /* Hostname must be present */
1473  hostname_length = strlen(hostname);
1474  GNUNET_assert(NULL != host->cfg);
1475  config = GNUNET_CONFIGURATION_serialize(host->cfg, &config_size);
1476  cc_size = GNUNET_TESTBED_compress_config_(config, config_size, &cconfig);
1477  GNUNET_free(config);
1478  msg_size = (sizeof(struct GNUNET_TESTBED_AddHostMessage));
1479  msg_size += username_length;
1480  msg_size += hostname_length;
1481  msg_size += cc_size;
1482  msg = GNUNET_malloc(msg_size);
1483  msg->header.size = htons(msg_size);
1485  msg->host_id = htonl(GNUNET_TESTBED_host_get_id_(host));
1486  msg->ssh_port = htons(GNUNET_TESTBED_host_get_ssh_port_(host));
1487  ptr = &msg[1];
1488  if (NULL != username)
1489  {
1490  msg->username_length = htons(username_length);
1491  GNUNET_memcpy(ptr, username, username_length);
1492  ptr += username_length;
1493  }
1494  msg->hostname_length = htons(hostname_length);
1495  GNUNET_memcpy(ptr, hostname, hostname_length);
1496  ptr += hostname_length;
1497  msg->config_size = htons(config_size);
1498  GNUNET_memcpy(ptr, cconfig, cc_size);
1499  ptr += cc_size;
1500  GNUNET_assert((ptr - (void *)msg) == msg_size);
1501  GNUNET_free(cconfig);
1502  GNUNET_TESTBED_queue_message_(controller,
1503  (struct GNUNET_MessageHeader *)msg);
1504  return rh;
1505 }
1506 
1507 
1515 void
1518 {
1519  if (handle != handle->c->rh)
1520  {
1521  GNUNET_break(0);
1522  return;
1523  }
1524  handle->c->rh = NULL;
1525  GNUNET_free(handle);
1526 }
1527 
1528 
1537 void
1539  struct GNUNET_TESTBED_Operation *op)
1540 {
1542  op);
1543 }
1544 
1545 
1551 void
1553 {
1554  char *hostname;
1555 
1556  hostname = (char *)host->hostname;
1557  host->hostname = simple_resolve(hostname);
1558  if (NULL == host->hostname)
1559  {
1560  GNUNET_break(0);
1561  host->hostname = hostname;
1562  return;
1563  }
1564  GNUNET_free(hostname);
1565  host->hostname = GNUNET_strdup(host->hostname);
1566 }
1567 
1568 /* 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:175
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:541
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:1973
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:90
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:84
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
#define AI_NUMERICSERV
AI_NUMERICSERV not defined in windows.
Definition: platform.h:226
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:191
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:286
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:77
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:487
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:221
#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:63
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:95
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:90
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.
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.
void(* GNUNET_TESTBED_HostRegistrationCompletion)(void *cls, const char *emsg)
Callback which will be called to after a host registration succeeded or failed.
#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.
static int ret
Final status code.
Definition: gnunet-arm.c:89
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:94
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_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:1237
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:692
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__
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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:72
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:66
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:1328
#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:67
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:254
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:1750
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:526
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:83
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:653
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
int GNUNET_HELPER_wait(struct GNUNET_HELPER_Handle *h)
Reap the helper process.
Definition: helper.c:223
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:139
#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:791
uint16_t ssh_port
SSH port to use, 0 for default (in NBO).
Definition: testbed.h:77
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:224
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
static char ** gen_rsh_suffix_args(const char *const *append_args)
Generates the arguments needed for executing the given binary in a remote shell.