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, ...) \
46  GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);
47 
51 #define LOG_DEBUG(...) \
52  LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
53 
57 #define API_VIOLATION(cond,errstr) \
58  do { \
59  if (cond) \
60  break; \
61  LOG (GNUNET_ERROR_TYPE_ERROR, "API violation detected: %s\n", errstr); \
62  GNUNET_assert (0); \
63  } while (0)
64 
69 #define LOG_GAI(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gai_strerror(rc)); } while(0)
70 
74 #define HOST_LIST_GROW_STEP 10
75 
76 
81 {
86 
91 
96 };
97 
98 
105 {
106 
110  const char *hostname;
111 
115  const char *username;
116 
124 
129 
134 
140 
145 
149  int locked;
150 
154  uint32_t id;
155 
159  uint16_t port;
160 
161 };
162 
163 
168 
172 static unsigned int host_list_size;
173 
174 
182 struct GNUNET_TESTBED_Host *
184 {
185  if (host_list_size <= id)
186  return NULL;
187  return host_list[id];
188 }
189 
190 
203 struct GNUNET_TESTBED_Host *
205  const struct GNUNET_CONFIGURATION_Handle *cfg)
206 {
207  return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0);
208 }
209 
210 
218 uint32_t
220 {
221  return host->id;
222 }
223 
224 
231 const char *
233 {
234  return host->hostname;
235 }
236 
237 
244 const char *
246 {
247  return host->username;
248 }
249 
250 
257 uint16_t
259 {
260  return host->port;
261 }
262 
263 
270 int
272 {
273  return host->controller_started;
274 }
275 
276 
283 const struct GNUNET_CONFIGURATION_Handle *
285 {
286  return host->cfg;
287 }
288 
289 
296 void
298  const struct GNUNET_CONFIGURATION_Handle *new_cfg)
299 {
301  host->cfg = GNUNET_CONFIGURATION_dup (new_cfg);
302 }
303 
304 
318 struct GNUNET_TESTBED_Host *
320  const char *username,
321  const struct GNUNET_CONFIGURATION_Handle
322  *cfg,
323  uint16_t port)
324 {
325  struct GNUNET_TESTBED_Host *host;
326  unsigned int new_size;
327 
328  if ((id < host_list_size) && (NULL != host_list[id]))
329  {
330  LOG (GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n", id);
331  return NULL;
332  }
333  host = GNUNET_new (struct GNUNET_TESTBED_Host);
334  host->hostname = (NULL != hostname) ? GNUNET_strdup (hostname) : NULL;
335  host->username = (NULL != username) ? GNUNET_strdup (username) : NULL;
336  host->id = id;
337  host->port = (0 == port) ? 22 : port;
338  host->cfg = GNUNET_CONFIGURATION_dup (cfg);
341  UINT_MAX);
342  new_size = host_list_size;
343  while (id >= new_size)
344  new_size += HOST_LIST_GROW_STEP;
345  if (new_size != host_list_size)
346  GNUNET_array_grow (host_list, host_list_size, new_size);
348  LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding host with id: %u\n", host->id);
349  host_list[id] = host;
350  return host;
351 }
352 
353 
365 struct GNUNET_TESTBED_Host *
366 GNUNET_TESTBED_host_create (const char *hostname, const char *username,
367  const struct GNUNET_CONFIGURATION_Handle *cfg,
368  uint16_t port)
369 {
370  static uint32_t uid_generator;
371 
372  if (NULL == hostname)
373  return GNUNET_TESTBED_host_create_with_id (0, hostname, username,
374  cfg, port);
375  return GNUNET_TESTBED_host_create_with_id (++uid_generator, hostname,
376  username, cfg, port);
377 }
378 
379 
391 unsigned int
393  const struct GNUNET_CONFIGURATION_Handle
394  *cfg,
395  struct GNUNET_TESTBED_Host ***hosts)
396 {
397  struct GNUNET_TESTBED_Host *starting_host;
398  char *data;
399  char *buf;
400  char *username;
401  char *hostname;
402  regex_t rex;
403  regmatch_t pmatch[6];
404  uint64_t fs;
405  short int port;
406  unsigned int offset;
407  unsigned int count;
408 
409 
410  GNUNET_assert (NULL != filename);
411  if (GNUNET_YES != GNUNET_DISK_file_test (filename))
412  {
413  LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
414  return 0;
415  }
416  if (GNUNET_OK !=
417  GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
418  fs = 0;
419  if (0 == fs)
420  {
421  LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s has no data\n"), filename);
422  return 0;
423  }
424  data = GNUNET_malloc (fs);
425  if (fs != GNUNET_DISK_fn_read (filename, data, fs))
426  {
427  GNUNET_free (data);
428  LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s cannot be read\n"),
429  filename);
430  return 0;
431  }
432  buf = data;
433  offset = 0;
434  starting_host = NULL;
435  count = 0;
436  /* refer RFC 952 and RFC 1123 for valid hostnames */
437  GNUNET_assert (0 == regcomp (&rex,
438  "^(([[:alnum:]]+)@)?" /* username */
439  "([[:alnum:]]+[-[:alnum:]_\\.]+)" /* hostname */
440  "(:([[:digit:]]{1,5}))?", /* port */
441  REG_EXTENDED | REG_ICASE));
442  while (offset < (fs - 1))
443  {
444  offset++;
445  if (((data[offset] == '\n')) && (buf != &data[offset]))
446  {
447  unsigned int size;
448 
449  data[offset] = '\0';
450  username = NULL;
451  hostname = NULL;
452  port = 0;
453  if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0))
454  || (-1 == pmatch[3].rm_so))
455  {
457  "Error reading line `%s' in hostfile\n", buf);
458  buf = &data[offset + 1];
459  continue;
460  }
461  if (-1 != pmatch[2].rm_so)
462  {
463  size = pmatch[2].rm_eo - pmatch[2].rm_so;
464  username = GNUNET_malloc (size + 1);
465  GNUNET_assert(0 != GNUNET_strlcpy (username,
466  buf + pmatch[2].rm_so,
467  size + 1));
468  }
469  if (-1 != pmatch[5].rm_so)
470  {
471  (void) SSCANF (buf + pmatch[5].rm_so, "%5hd", &port);
472  }
473  size = pmatch[3].rm_eo - pmatch[3].rm_so;
474  hostname = GNUNET_malloc (size + 1);
475  GNUNET_assert(0 != GNUNET_strlcpy (hostname,
476  buf + pmatch[3].rm_so,
477  size + 1));
479  "Successfully read host %s, port %d and user %s from file\n",
480  (NULL == hostname) ? "NULL" : hostname,
481  port,
482  (NULL == username) ? "NULL" : username);
483  /* We store hosts in a static list; hence we only require the starting
484  * host pointer in that list to access the newly created list of hosts */
485  if (NULL == starting_host)
486  starting_host = GNUNET_TESTBED_host_create (hostname, username, cfg,
487  port);
488  else
489  (void) GNUNET_TESTBED_host_create (hostname, username, cfg, port);
490  count++;
491  GNUNET_free_non_null (username);
492  GNUNET_free (hostname);
493  buf = &data[offset + 1];
494  }
495  else if ((data[offset] == '\n') || (data[offset] == '\0'))
496  buf = &data[offset + 1];
497  }
498  regfree (&rex);
499  GNUNET_free (data);
500  if (NULL == starting_host)
501  return 0;
502  *hosts = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * count);
503  GNUNET_memcpy (*hosts,
504  &host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
505  sizeof (struct GNUNET_TESTBED_Host *) * count);
506  return count;
507 }
508 
509 
516 const char *
517 simple_resolve (const char *host)
518 {
519  struct addrinfo *res;
520  const struct sockaddr_in *in_addr;
521  char *hostip;
522  struct addrinfo hint;
523  unsigned int rc;
524 
525  hint.ai_family = AF_INET; /* IPv4 */
526  hint.ai_socktype = 0;
527  hint.ai_protocol = 0;
528  hint.ai_addrlen = 0;
529  hint.ai_addr = NULL;
530  hint.ai_canonname = NULL;
531  hint.ai_next = NULL;
532  hint.ai_flags = AI_NUMERICSERV;
533  res = NULL;
534  LOG_DEBUG ("Resolving [%s]\n", host);
535  if (0 != (rc = getaddrinfo (host, "22", &hint, &res)))
536  {
537  LOG_GAI (GNUNET_ERROR_TYPE_ERROR, "getaddrinfo", rc);
538  return NULL;
539  }
540  GNUNET_assert (NULL != res);
541  GNUNET_assert (NULL != res->ai_addr);
542  GNUNET_assert (sizeof (struct sockaddr_in) == res->ai_addrlen);
543  in_addr = (const struct sockaddr_in *) res->ai_addr;
544  hostip = inet_ntoa (in_addr->sin_addr);
545  GNUNET_assert (NULL != hostip);
546  freeaddrinfo (res);
547  LOG_DEBUG ("Resolved [%s] to [%s]\n", host, hostip);
548  return hostip;
549 }
550 
551 
564 unsigned int
567  struct GNUNET_TESTBED_Host ***hosts)
568 {
569 #if !ENABLE_SUPERMUC
571  _("The function %s is only available when compiled with (--with-ll)\n"),
572  __func__);
573  GNUNET_assert (0);
574 #else
575  const char *hostfile;
576 
577  if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE")))
578  {
579  GNUNET_break (0);
580  return 0;
581  }
582  return GNUNET_TESTBED_hosts_load_from_file (hostfile, cfg, hosts);
583 #endif
584 }
585 
586 
593 void
595 {
596  struct RegisteredController *rc;
597  uint32_t id;
598 
599  GNUNET_assert (host->id < host_list_size);
600  GNUNET_assert (host_list[host->id] == host);
601  host_list[host->id] = NULL;
602  /* clear registered controllers list */
603  for (rc = host->rc_head; NULL != rc; rc = host->rc_head)
604  {
605  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
606  GNUNET_free (rc);
607  }
608  GNUNET_free_non_null ((char *) host->username);
609  GNUNET_free_non_null ((char *) host->hostname);
613  GNUNET_free (host);
615  {
616  for (id = host_list_size - 1; id > host_list_size - HOST_LIST_GROW_STEP;
617  id--)
618  if (NULL != host_list[id])
619  break;
620  if (id != host_list_size - HOST_LIST_GROW_STEP)
621  break;
622  if (NULL != host_list[id])
623  break;
625  }
626  host_list =
627  GNUNET_realloc (host_list,
628  sizeof (struct GNUNET_TESTBED_Host *) * host_list_size);
629 }
630 
631 
638 void
640  const struct GNUNET_TESTBED_Controller
641  *const controller)
642 {
643  struct RegisteredController *rc;
644 
645  for (rc = host->rc_head; NULL != rc; rc = rc->next)
646  {
647  if (controller == rc->controller) /* already registered at controller */
648  {
649  GNUNET_break (0);
650  return;
651  }
652  }
653  rc = GNUNET_new (struct RegisteredController);
654  rc->controller = controller;
656 }
657 
658 
665 void
667  const struct GNUNET_TESTBED_Controller
668  *const controller)
669 {
670  struct RegisteredController *rc;
671 
672  for (rc = host->rc_head; NULL != rc; rc=rc->next)
673  if (controller == rc->controller)
674  break;
675  if (NULL == rc)
676  {
677  GNUNET_break (0);
678  return;
679  }
680  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
681  GNUNET_free (rc);
682 }
683 
684 
692 int
694  const struct GNUNET_TESTBED_Controller
695  *const controller)
696 {
697  struct RegisteredController *rc;
698 
699  for (rc = host->rc_head; NULL != rc; rc = rc->next)
700  {
701  if (controller == rc->controller) /* already registered at controller */
702  {
703  return GNUNET_YES;
704  }
705  }
706  return GNUNET_NO;
707 }
708 
709 
714 {
719 
723  char **helper_argv;
724 
729 
734 
738  void *cls;
739 
744 
749 
750 };
751 
752 
759 static char **
760 copy_argv (const char *const *argv)
761 {
762  char **argv_dup;
763  unsigned int argp;
764 
765  GNUNET_assert (NULL != argv);
766  for (argp = 0; NULL != argv[argp]; argp++) ;
767  argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1));
768  for (argp = 0; NULL != argv[argp]; argp++)
769  argv_dup[argp] = GNUNET_strdup (argv[argp]);
770  return argv_dup;
771 }
772 
773 
781 static char **
782 join_argv (const char *const *argv1, const char *const *argv2)
783 {
784  char **argvj;
785  char *argv;
786  unsigned int carg;
787  unsigned int cnt;
788 
789  carg = 0;
790  argvj = NULL;
791  for (cnt = 0; NULL != argv1[cnt]; cnt++)
792  {
793  argv = GNUNET_strdup (argv1[cnt]);
794  GNUNET_array_append (argvj, carg, argv);
795  }
796  for (cnt = 0; NULL != argv2[cnt]; cnt++)
797  {
798  argv = GNUNET_strdup (argv2[cnt]);
799  GNUNET_array_append (argvj, carg, argv);
800  }
801  GNUNET_array_append (argvj, carg, NULL);
802  return argvj;
803 }
804 
805 
811 static void
812 free_argv (char **argv)
813 {
814  unsigned int argp;
815 
816  for (argp = 0; NULL != argv[argp]; argp++)
817  GNUNET_free (argv[argp]);
818  GNUNET_free (argv);
819 }
820 
821 
836 static char **
837 gen_rsh_args (const char *port, const char *hostname, const char *username)
838 {
839  static const char *default_ssh_args[] = {
840  "ssh",
841  "-o",
842  "BatchMode=yes",
843  "-o",
844  "NoHostAuthenticationForLocalhost=yes",
845  "-o",
846  "StrictHostKeyChecking=no",
847  "-o",
848  "PasswordAuthentication=no",
849  "%h",
850  NULL
851  };
852  char **ssh_args;
853  char *ssh_cmd;
854  char *ssh_cmd_cp;
855  char *arg;
856  const char *new_arg;
857  unsigned int size;
858  unsigned int cnt;
859 
860  ssh_args = NULL;
861  if (NULL != (ssh_cmd = getenv ("GNUNET_TESTBED_RSH_CMD")))
862  {
863  ssh_cmd = GNUNET_strdup (ssh_cmd);
864  ssh_cmd_cp = ssh_cmd;
865  for (size = 0; NULL != (arg = strtok (ssh_cmd, " ")); ssh_cmd = NULL)
866  GNUNET_array_append (ssh_args, size, GNUNET_strdup (arg));
867  GNUNET_free (ssh_cmd_cp);
868  }
869  else
870  {
871  ssh_args = copy_argv (default_ssh_args);
872  size = (sizeof (default_ssh_args)) / (sizeof (const char *));
873  GNUNET_array_grow (ssh_args, size, size - 1);
874  }
875  for (cnt = 0; cnt < size; cnt++)
876  {
877  arg = ssh_args[cnt];
878  if ('%' != arg[0])
879  continue;
880  switch (arg[1])
881  {
882  case 'p':
883  new_arg = port;
884  break;
885 
886  case 'u':
887  new_arg = username;
888  break;
889 
890  case 'h':
891  new_arg = hostname;
892  break;
893 
894  default:
895  continue;
896  }
897  if (NULL == new_arg)
898  continue;
899  GNUNET_free (arg);
900  ssh_args[cnt] = GNUNET_strdup (new_arg);
901  }
902  GNUNET_array_append (ssh_args, size, NULL);
903  return ssh_args;
904 }
905 
906 
917 static char **
918 gen_rsh_suffix_args (const char * const *append_args)
919 {
920  char **rshell_args;
921  char *rshell_cmd;
922  char *rshell_cmd_cp;
923  char *arg;
924  unsigned int cnt;
925  unsigned int append_cnt;
926 
927  rshell_args = NULL;
928  cnt = 0;
929  if (NULL != (rshell_cmd = getenv ("GNUNET_TESTBED_RSH_CMD_SUFFIX")))
930  {
931  rshell_cmd = GNUNET_strdup (rshell_cmd);
932  rshell_cmd_cp = rshell_cmd;
933  for (; NULL != (arg = strtok (rshell_cmd, " ")); rshell_cmd = NULL)
934  GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (arg));
935  GNUNET_free (rshell_cmd_cp);
936  }
937  if (NULL != append_args)
938  {
939  for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++)
940  GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (append_args[append_cnt]));
941  }
942  GNUNET_array_append (rshell_args, cnt, NULL);
943  return rshell_args;
944 }
945 
946 
959 static int
960 helper_mst (void *cls,
961  const struct GNUNET_MessageHeader *message)
962 {
963  struct GNUNET_TESTBED_ControllerProc *cp = cls;
964  const struct GNUNET_TESTBED_HelperReply *msg;
965  const char *hostname;
966  char *config;
967  uLongf config_size;
968  uLongf xconfig_size;
969 
970  msg = (const struct GNUNET_TESTBED_HelperReply *) message;
971  GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) <
972  ntohs (msg->header.size));
974  ntohs (msg->header.type));
975  config_size = (uLongf) ntohs (msg->config_size);
976  xconfig_size =
977  (uLongf) (ntohs (msg->header.size) -
978  sizeof (struct GNUNET_TESTBED_HelperReply));
979  config = GNUNET_malloc (config_size);
980  GNUNET_assert (Z_OK ==
981  uncompress ((Bytef *) config, &config_size,
982  (const Bytef *) &msg[1], xconfig_size));
983  /* Replace the configuration template present in the host with the
984  controller's running configuration */
988  (cp->host->cfg,
989  config,
990  config_size,
991  NULL));
992  GNUNET_free (config);
993  if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))
994  hostname = "localhost";
995  /* Change the hostname so that we can connect to it */
996  GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, "testbed", "hostname",
997  hostname);
998  cp->host->locked = GNUNET_NO;
1000  cp->cb (cp->cls, cp->host->cfg, GNUNET_OK);
1001  return GNUNET_OK;
1002 }
1003 
1004 
1013 static void
1014 clear_msg (void *cls, int result)
1015 {
1016  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1017 
1018  GNUNET_assert (NULL != cp->shandle);
1019  cp->shandle = NULL;
1020  GNUNET_free (cp->msg);
1021  cp->msg = NULL;
1022 }
1023 
1024 
1031 static void
1033 {
1034  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1036  void *cb_cls;
1037 
1038  cb = cp->cb;
1039  cb_cls = cp->cls;
1040  cp->helper = NULL;
1042  if (NULL != cb)
1043  cb (cb_cls, NULL, GNUNET_SYSERR);
1044 }
1045 
1046 
1071 GNUNET_TESTBED_controller_start (const char *trusted_ip,
1072  struct GNUNET_TESTBED_Host *host,
1074  void *cls)
1075 {
1076  struct GNUNET_TESTBED_ControllerProc *cp;
1078  const struct GNUNET_CONFIGURATION_Handle *cfg;
1079  const char *hostname;
1080  static char *const binary_argv[] = {
1081  HELPER_TESTBED_BINARY, NULL
1082  };
1083 
1084  GNUNET_assert (NULL != host);
1085  GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1086  hostname = NULL;
1087  API_VIOLATION (GNUNET_NO == host->locked,
1088  "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
1089  host->locked = GNUNET_YES;
1091  "Attempting to start a controller on a host which is already started a controller");
1093  if (0 == GNUNET_TESTBED_host_get_id_ (host))
1094  {
1095  cp->helper =
1097  &helper_mst, &helper_exp_cb, cp);
1098  }
1099  else
1100  {
1101  char *helper_binary_path_args[2];
1102  char **rsh_args;
1103  char **rsh_suffix_args;
1104  const char *username;
1105  char *port;
1106  char *argstr;
1107  char *aux;
1108  unsigned int cnt;
1109 
1110  username = host->username;
1111  hostname = host->hostname;
1112  GNUNET_asprintf (&port, "%u", host->port);
1113  LOG_DEBUG ("Starting remote connection to destination %s\n", hostname);
1114  if (GNUNET_OK !=
1116  "HELPER_BINARY_PATH",
1117  &helper_binary_path_args[0]))
1118  helper_binary_path_args[0] =
1120  helper_binary_path_args[1] = NULL;
1121  rsh_args = gen_rsh_args (port, hostname, username);
1122  rsh_suffix_args = gen_rsh_suffix_args ((const char **) helper_binary_path_args);
1123  cp->helper_argv =
1124  join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
1125  free_argv (rsh_args);
1126  free_argv (rsh_suffix_args);
1127  GNUNET_free (port);
1128  argstr = GNUNET_strdup ("");
1129  for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
1130  {
1131  aux = argstr;
1132  GNUNET_assert (0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
1133  GNUNET_free (aux);
1134  }
1135  LOG_DEBUG ("Helper cmd str: %s\n", argstr);
1136  GNUNET_free (argstr);
1137  cp->helper =
1139  &helper_exp_cb, cp);
1140  GNUNET_free (helper_binary_path_args[0]);
1141  }
1142  if (NULL == cp->helper)
1143  {
1144  if (NULL != cp->helper_argv)
1145  free_argv (cp->helper_argv);
1146  GNUNET_free (cp);
1147  return NULL;
1148  }
1149  cp->host = host;
1150  cp->cb = cb;
1151  cp->cls = cls;
1152  msg = GNUNET_TESTBED_create_helper_init_msg_ (trusted_ip, hostname, cfg);
1153  cp->msg = &msg->header;
1154  cp->shandle =
1155  GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
1156  if (NULL == cp->shandle)
1157  {
1158  GNUNET_free (msg);
1160  return NULL;
1161  }
1162  return cp;
1163 }
1164 
1165 
1171 void
1173 {
1174  if (NULL != cproc->shandle)
1176  if (NULL != cproc->helper)
1178 }
1179 
1180 
1186 void
1188 {
1189  if (NULL != cproc->helper)
1190  {
1192  GNUNET_HELPER_destroy (cproc->helper);
1193  }
1194  if (NULL != cproc->helper_argv)
1195  free_argv (cproc->helper_argv);
1196  cproc->host->controller_started = GNUNET_NO;
1197  cproc->host->locked = GNUNET_NO;
1198  GNUNET_free_non_null (cproc->msg);
1199  GNUNET_free (cproc);
1200 }
1201 
1202 
1211 void
1213 {
1216 }
1217 
1218 
1223 {
1227  const struct GNUNET_TESTBED_Host *host;
1228 
1233 
1237  void *cb_cls;
1238 
1243 
1247  char **helper_argv;
1248 
1253 
1259 
1260 };
1261 
1262 
1268 static void
1270 {
1272  void *cb_cls;
1274  const struct GNUNET_TESTBED_Host *host;
1275  unsigned long code;
1277  int ret;
1278 
1279  h->habitability_check_task = NULL;
1280  ret = GNUNET_OS_process_status (h->auxp, &type, &code);
1281  if (GNUNET_SYSERR == ret)
1282  {
1283  GNUNET_break (0);
1284  ret = GNUNET_NO;
1285  goto call_cb;
1286  }
1287  if (GNUNET_NO == ret)
1288  {
1292  return;
1293  }
1295  h->auxp = NULL;
1296  ret = (0 != code) ? GNUNET_NO : GNUNET_YES;
1297 
1298 call_cb:
1299  if (NULL != h->auxp)
1301  cb = h->cb;
1302  cb_cls = h->cb_cls;
1303  host = h->host;
1304  free_argv (h->helper_argv);
1305  GNUNET_free (h);
1306  if (NULL != cb)
1307  cb (cb_cls, host, ret);
1308 }
1309 
1310 
1324  const struct GNUNET_CONFIGURATION_Handle
1325  *config,
1327  void *cb_cls)
1328 {
1330  char **rsh_args;
1331  char **rsh_suffix_args;
1332  char *stat_args[3];
1333  const char *hostname;
1334  char *port;
1335 
1337  h->cb = cb;
1338  h->cb_cls = cb_cls;
1339  h->host = host;
1340  hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
1341  if (GNUNET_OK !=
1342  GNUNET_CONFIGURATION_get_value_filename (config, "testbed",
1343  "HELPER_BINARY_PATH",
1344  &stat_args[1]))
1345  stat_args[1] =
1347  GNUNET_asprintf (&port, "%u", host->port);
1348  rsh_args = gen_rsh_args (port, hostname, host->username);
1349  GNUNET_free (port);
1350  port = NULL;
1351  stat_args[0] = "stat";
1352  stat_args[2] = NULL;
1353  rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args);
1354  GNUNET_free (stat_args[1]);
1355  h->helper_argv = join_argv ((const char **) rsh_args,
1356  (const char **) rsh_suffix_args);
1357  free_argv (rsh_suffix_args);
1358  free_argv (rsh_args);
1359  h->auxp =
1361  NULL, NULL, h->helper_argv[0], h->helper_argv);
1362  if (NULL == h->auxp)
1363  {
1364  GNUNET_break (0); /* Cannot exec SSH? */
1365  GNUNET_free (h);
1366  return NULL;
1367  }
1371  return h;
1372 }
1373 
1374 
1380 void
1383  *handle)
1384 {
1386  (void) GNUNET_OS_process_kill (handle->auxp, GNUNET_TERM_SIG);
1387  (void) GNUNET_OS_process_wait (handle->auxp);
1388  GNUNET_OS_process_destroy (handle->auxp);
1389  free_argv (handle->helper_argv);
1390  GNUNET_free (handle);
1391 }
1392 
1393 
1408  struct GNUNET_TESTBED_Host *host,
1410  void *cc_cls)
1411 {
1414  const char *username;
1415  const char *hostname;
1416  char *config;
1417  char *cconfig;
1418  void *ptr;
1419  size_t cc_size;
1420  size_t config_size;
1421  uint16_t msg_size;
1422  uint16_t username_length;
1423  uint16_t hostname_length;
1424 
1425  if (NULL != controller->rh)
1426  return NULL;
1427  hostname = GNUNET_TESTBED_host_get_hostname (host);
1428  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
1429  {
1430  LOG (GNUNET_ERROR_TYPE_WARNING, "Host hostname: %s already registered\n",
1431  (NULL == hostname) ? "localhost" : hostname);
1432  return NULL;
1433  }
1435  rh->host = host;
1436  rh->c = controller;
1437  GNUNET_assert (NULL != cc);
1438  rh->cc = cc;
1439  rh->cc_cls = cc_cls;
1440  controller->rh = rh;
1441  username = GNUNET_TESTBED_host_get_username_ (host);
1442  username_length = 0;
1443  if (NULL != username)
1444  username_length = strlen (username);
1445  GNUNET_assert (NULL != hostname); /* Hostname must be present */
1446  hostname_length = strlen (hostname);
1447  GNUNET_assert (NULL != host->cfg);
1448  config = GNUNET_CONFIGURATION_serialize (host->cfg, &config_size);
1449  cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig);
1450  GNUNET_free (config);
1451  msg_size = (sizeof (struct GNUNET_TESTBED_AddHostMessage));
1452  msg_size += username_length;
1453  msg_size += hostname_length;
1454  msg_size += cc_size;
1455  msg = GNUNET_malloc (msg_size);
1456  msg->header.size = htons (msg_size);
1458  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1459  msg->ssh_port = htons (GNUNET_TESTBED_host_get_ssh_port_ (host));
1460  ptr = &msg[1];
1461  if (NULL != username)
1462  {
1463  msg->username_length = htons (username_length);
1464  GNUNET_memcpy (ptr, username, username_length);
1465  ptr += username_length;
1466  }
1467  msg->hostname_length = htons (hostname_length);
1468  GNUNET_memcpy (ptr, hostname, hostname_length);
1469  ptr += hostname_length;
1470  msg->config_size = htons (config_size);
1471  GNUNET_memcpy (ptr, cconfig, cc_size);
1472  ptr += cc_size;
1473  GNUNET_assert ((ptr - (void *) msg) == msg_size);
1474  GNUNET_free (cconfig);
1475  GNUNET_TESTBED_queue_message_ (controller,
1476  (struct GNUNET_MessageHeader *) msg);
1477  return rh;
1478 }
1479 
1480 
1488 void
1490  *handle)
1491 {
1492  if (handle != handle->c->rh)
1493  {
1494  GNUNET_break (0);
1495  return;
1496  }
1497  handle->c->rh = NULL;
1498  GNUNET_free (handle);
1499 }
1500 
1501 
1510 void
1512  struct GNUNET_TESTBED_Operation *op)
1513 {
1516 }
1517 
1518 
1524 void
1526 {
1527  char *hostname;
1528 
1529  hostname = (char *) host->hostname;
1530  host->hostname = simple_resolve (hostname);
1531  if (NULL == host->hostname)
1532  {
1533  GNUNET_break (0);
1534  host->hostname = hostname;
1535  return;
1536  }
1537  GNUNET_free (hostname);
1538  host->hostname = GNUNET_strdup (host->hostname);
1539 }
1540 
1541 /* 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:180
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:669
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:1982
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:92
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:88
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:261
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
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:364
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:1719
The handle to a helper process.
Definition: helper.c:80
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:491
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:225
#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:65
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:99
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:94
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
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:81
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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:208
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:1246
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:701
#define GNUNET_memcpy(dst, src, n)
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:1321
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:76
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:79
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.
GUID host
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:1331
#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:71
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:289
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:1761
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:530
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:1762
#define SSCANF
Definition: plibc.h:691
static unsigned int host_list_size
The size of the available hosts list.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:79
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:660
#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:231
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:80
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:282
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.
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:1019
uint16_t ssh_port
SSH port to use, 0 for default (in NBO).
Definition: testbed.h:81
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:251
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
static char ** gen_rsh_suffix_args(const char *const *append_args)
Generates the arguments needed for executing the given binary in a remote shell.