GNUnet  0.11.x
testing.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2008, 2009, 2012 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 
32 #include "platform.h"
33 #include "gnunet_util_lib.h"
34 #include "gnunet_arm_service.h"
35 #include "gnunet_testing_lib.h"
36 #include "gnunet_testing_ng_lib.h"
37 #include "testing_cmds.h"
38 
39 #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
40 
41 
48 #define LOW_PORT 12000
49 
55 #define HIGH_PORT 56000
56 
57 
59 {
60  struct SharedService *ss;
61 
62  char *cfg_fn;
63 
65 
66  char *unix_sock;
67 
68  char *port_str;
69 
70  unsigned int n_refs;
71 };
72 
73 struct SharedService
74 {
75  char *sname;
76 
78 
80 
81  unsigned int n_peers;
82 
83  unsigned int share;
84 
85  unsigned int n_instances;
86 };
87 
88 
94 {
99  char *tmppath;
100 
105  char *trusted_ip;
106 
110  char *hostname;
111 
116 
121 
123 
124  unsigned int n_shared_services;
125 
134  uint32_t reserved_ports[65536 / 32];
135 
144  uint32_t path_counter;
145 
149  uint32_t total_hostkeys;
150 
154  uint16_t lowport;
155 
159  uint16_t highport;
160 };
161 
162 
167 {
172 
176  char *cfgfile;
177 
184  char *main_binary;
185  char *args;
186 
192 
197 
202 
207 
211  void *cb_cls;
212 
218 
220 
226  uint16_t *ports;
227 
231  unsigned int nports;
232 
236  uint32_t key_number;
237 };
238 
239 
247 static int
249 {
250  uint64_t fs;
251  char *data_dir;
252  char *filename;
253  struct GNUNET_DISK_FileHandle *fd;
254 
255  GNUNET_assert (NULL == system->hostkeys_data);
257  GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir);
258  GNUNET_free (data_dir);
259 
261  {
263  _ ("Hostkeys file not found: %s\n"),
264  filename);
266  return GNUNET_SYSERR;
267  }
268  /* Check hostkey file size, read entire thing into memory */
269  if (GNUNET_OK !=
271  fs = 0;
272  if (0 == fs)
273  {
275  return GNUNET_SYSERR; /* File is empty */
276  }
277  if (0 != (fs % GNUNET_TESTING_HOSTKEYFILESIZE))
278  {
280  _ ("Incorrect hostkey file format: %s\n"),
281  filename);
283  return GNUNET_SYSERR;
284  }
288  if (NULL == fd)
289  {
292  return GNUNET_SYSERR;
293  }
295  system->hostkeys_data =
298  if (NULL == system->hostkeys_data)
299  return GNUNET_SYSERR;
301  return GNUNET_OK;
302 }
303 
304 
310 static void
312 {
313  GNUNET_break (NULL != system->hostkeys_data);
314  system->hostkeys_data = NULL;
315  GNUNET_DISK_file_unmap (system->map);
316  system->map = NULL;
317  system->hostkeys_data = NULL;
318  system->total_hostkeys = 0;
319 }
320 
321 
330 static void
331 cfg_copy_iterator (void *cls,
332  const char *section,
333  const char *option,
334  const char *value)
335 {
336  struct GNUNET_CONFIGURATION_Handle *cfg2 = cls;
337 
338  GNUNET_CONFIGURATION_set_value_string (cfg2, section, option, value);
339 }
340 
341 
363 struct GNUNET_TESTING_System *
365  const char *testdir,
366  const char *trusted_ip,
367  const char *hostname,
369  uint16_t lowport,
370  uint16_t highport)
371 {
372  struct GNUNET_TESTING_System *system;
373  struct GNUNET_TESTING_SharedService tss;
374  struct SharedService *ss;
375  unsigned int cnt;
376 
377  GNUNET_assert (NULL != testdir);
378  system = GNUNET_new (struct GNUNET_TESTING_System);
379  if (NULL == (system->tmppath = getenv (GNUNET_TESTING_PREFIX)))
380  system->tmppath = GNUNET_DISK_mkdtemp (testdir);
381  else
382  system->tmppath = GNUNET_strdup (system->tmppath);
383  system->lowport = lowport;
384  system->highport = highport;
385  if (NULL == system->tmppath)
386  {
387  GNUNET_free (system);
388  return NULL;
389  }
390  if (NULL != trusted_ip)
391  system->trusted_ip = GNUNET_strdup (trusted_ip);
392  if (NULL != hostname)
393  system->hostname = GNUNET_strdup (hostname);
394  if (GNUNET_OK != hostkeys_load (system))
395  {
397  return NULL;
398  }
399  if (NULL == shared_services)
400  return system;
401  for (cnt = 0; NULL != shared_services[cnt].service; cnt++)
402  {
403  tss = shared_services[cnt];
404  ss = GNUNET_new (struct SharedService);
405  ss->sname = GNUNET_strdup (tss.service);
408  ss->sname,
410  ss->cfg);
412  "TESTING",
414  ss->cfg);
416  "PATHS",
418  ss->cfg);
419  ss->share = tss.share;
421  system->n_shared_services,
422  ss);
423  }
424  return system;
425 }
426 
427 
448 struct GNUNET_TESTING_System *
450  const char *testdir,
451  const char *trusted_ip,
452  const char *hostname,
454 {
456  trusted_ip,
457  hostname,
459  LOW_PORT,
460  HIGH_PORT);
461 }
462 
463 
464 static void
466 {
467  if (NULL != i->cfg_fn)
468  {
469  (void) unlink (i->cfg_fn);
470  GNUNET_free (i->cfg_fn);
471  }
472  GNUNET_free (i->unix_sock);
473  GNUNET_free (i->port_str);
474  GNUNET_break (NULL == i->proc);
475  GNUNET_break (0 == i->n_refs);
476  GNUNET_free (i);
477 }
478 
479 
480 static int
482 {
483  char *binary;
484  char *libexec_binary;
485 
486  GNUNET_assert (NULL == i->proc);
487  GNUNET_assert (NULL != i->cfg_fn);
488  (void) GNUNET_asprintf (&binary, "gnunet-service-%s", i->ss->sname);
489  libexec_binary = GNUNET_OS_get_libexec_binary_path (binary);
490  GNUNET_free (binary);
492  NULL,
493  NULL,
494  NULL,
495  libexec_binary,
496  libexec_binary,
497  "-c",
498  i->cfg_fn,
499  NULL);
500  GNUNET_free (libexec_binary);
501  if (NULL == i->proc)
502  return GNUNET_SYSERR;
503  return GNUNET_OK;
504 }
505 
506 
507 static void
509 {
510  GNUNET_break (0 == i->n_refs);
513  "Killing shared service instance (%s) failed\n",
514  i->ss->sname);
515  (void) GNUNET_OS_process_wait (i->proc);
517  i->proc = NULL;
518 }
519 
520 
528 void
530  int remove_paths)
531 {
532  struct SharedService *ss;
533  struct SharedServiceInstance *i;
534  unsigned int ss_cnt;
535  unsigned int i_cnt;
536 
537  if (NULL != system->hostkeys_data)
538  hostkeys_unload (system);
539  for (ss_cnt = 0; ss_cnt < system->n_shared_services; ss_cnt++)
540  {
541  ss = system->shared_services[ss_cnt];
542  for (i_cnt = 0; i_cnt < ss->n_instances; i_cnt++)
543  {
544  i = ss->instances[i_cnt];
545  if (NULL != i->proc)
548  }
551  GNUNET_free (ss->sname);
552  GNUNET_free (ss);
553  }
554  GNUNET_free (system->shared_services);
555  if (GNUNET_YES == remove_paths)
557  GNUNET_free (system->tmppath);
558  GNUNET_free (system->trusted_ip);
559  GNUNET_free (system->hostname);
560  GNUNET_free (system);
561 }
562 
563 
570 uint16_t
572 {
573  struct GNUNET_NETWORK_Handle *socket;
574  struct addrinfo hint;
575  struct addrinfo *ret;
576  struct addrinfo *ai;
577  uint32_t *port_buckets;
578  char *open_port_str;
579  int bind_status;
580  uint32_t xor_image;
581  uint16_t index;
582  uint16_t open_port;
583  uint16_t pos;
584 
585  /*
586  FIXME: Instead of using getaddrinfo we should try to determine the port
587  status by the following heurestics.
588 
589  On systems which support both IPv4 and IPv6, only ports open on both
590  address families are considered open.
591  On system with either IPv4 or IPv6. A port is considered open if it's
592  open in the respective address family
593  */hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */
594  hint.ai_socktype = 0;
595  hint.ai_protocol = 0;
596  hint.ai_addrlen = 0;
597  hint.ai_addr = NULL;
598  hint.ai_canonname = NULL;
599  hint.ai_next = NULL;
600  hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */
601  port_buckets = system->reserved_ports;
602  for (index = (system->lowport / 32) + 1; index < (system->highport / 32);
603  index++)
604  {
605  xor_image = (UINT32_MAX ^ port_buckets[index]);
606  if (0 == xor_image) /* Ports in the bucket are full */
607  continue;
608  pos = system->lowport % 32;
609  while (pos < 32)
610  {
611  if (0 == ((xor_image >> pos) & 1U))
612  {
613  pos++;
614  continue;
615  }
616  open_port = (index * 32) + pos;
617  if (open_port >= system->highport)
618  return 0;
619  GNUNET_asprintf (&open_port_str, "%u", (unsigned int) open_port);
620  ret = NULL;
621  GNUNET_assert (0 == getaddrinfo (NULL, open_port_str, &hint, &ret));
622  GNUNET_free (open_port_str);
623  bind_status = GNUNET_NO;
624  for (ai = ret; NULL != ai; ai = ai->ai_next)
625  {
626  socket = GNUNET_NETWORK_socket_create (ai->ai_family, SOCK_STREAM, 0);
627  if (NULL == socket)
628  continue;
629  bind_status =
630  GNUNET_NETWORK_socket_bind (socket, ai->ai_addr, ai->ai_addrlen);
632  if (GNUNET_OK != bind_status)
633  break;
634  socket = GNUNET_NETWORK_socket_create (ai->ai_family, SOCK_DGRAM, 0);
635  if (NULL == socket)
636  continue;
637  bind_status =
638  GNUNET_NETWORK_socket_bind (socket, ai->ai_addr, ai->ai_addrlen);
640  if (GNUNET_OK != bind_status)
641  break;
642  }
643  port_buckets[index] |= (1U << pos); /* Set the port bit */
644  freeaddrinfo (ret);
645  if (GNUNET_OK == bind_status)
646  {
648  "Found a free port %u\n",
649  (unsigned int) open_port);
650  return open_port;
651  }
652  pos++;
653  }
654  }
655  return 0;
656 }
657 
658 
666 void
668  uint16_t port)
669 {
670  uint32_t *port_buckets;
671  uint16_t bucket;
672  uint16_t pos;
673 
674  port_buckets = system->reserved_ports;
675  bucket = port / 32;
676  pos = port % 32;
677  LOG (GNUNET_ERROR_TYPE_DEBUG, "Releasing port %u\n", port);
678  if (0 == (port_buckets[bucket] & (1U << pos)))
679  {
680  GNUNET_break (0); /* Port was not reserved by us using reserve_port() */
681  return;
682  }
683  port_buckets[bucket] &= ~(1U << pos);
684 }
685 
686 
706  uint32_t key_number,
707  struct GNUNET_PeerIdentity *id)
708 {
709  struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
710 
711  if ((NULL == id) || (NULL == system->hostkeys_data))
712  return NULL;
713  if (key_number >= system->total_hostkeys)
714  {
716  _ ("Key number %u does not exist\n"),
717  key_number);
718  return NULL;
719  }
720  private_key = GNUNET_new (struct GNUNET_CRYPTO_EddsaPrivateKey);
721  GNUNET_memcpy (private_key,
722  system->hostkeys_data
723  + (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
725  GNUNET_CRYPTO_eddsa_key_get_public (private_key, &id->public_key);
726  return private_key;
727 }
728 
729 
734 struct UpdateContext
735 {
740 
745 
749  char *gnunet_home;
750 
756  uint16_t *ports;
757 
761  unsigned int nports;
762 
766  int status;
767 };
768 
769 
780 static void
781 update_config (void *cls,
782  const char *section,
783  const char *option,
784  const char *value)
785 {
786  struct UpdateContext *uc = cls;
787  unsigned int ival;
788  char cval[12];
789  char uval[PATH_MAX];
790  char *single_variable;
791  char *per_host_variable;
792  unsigned long long num_per_host;
793  uint16_t new_port;
794 
795  if (GNUNET_OK != uc->status)
796  return;
797  if (! ((0 == strcmp (option, "PORT")) || (0 == strcmp (option, "UNIXPATH")) ||
798  (0 == strcmp (option, "HOSTNAME"))))
799  return;
800  GNUNET_asprintf (&single_variable, "single_%s_per_host", section);
801  GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section);
802  if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
803  {
804  if ((ival != 0) &&
806  "testing",
807  single_variable)))
808  {
809  new_port = GNUNET_TESTING_reserve_port (uc->system);
810  if (0 == new_port)
811  {
812  uc->status = GNUNET_SYSERR;
813  GNUNET_free (single_variable);
814  GNUNET_free (per_host_variable);
815  return;
816  }
817  GNUNET_snprintf (cval, sizeof(cval), "%u", new_port);
818  value = cval;
819  GNUNET_array_append (uc->ports, uc->nports, new_port);
820  }
821  else if ((ival != 0) &&
822  (GNUNET_YES ==
824  "testing",
825  single_variable)) &&
827  "testing",
828  per_host_variable,
829  &num_per_host))
830  {
831  /* GNUNET_snprintf (cval, sizeof (cval), "%u", */
832  /* ival + ctx->fdnum % num_per_host); */
833  /* value = cval; */
834  GNUNET_break (0); /* FIXME */
835  }
836  }
837  if (0 == strcmp (option, "UNIXPATH"))
838  {
840  "testing",
841  single_variable))
842  {
843  GNUNET_snprintf (uval,
844  sizeof(uval),
845  "%s/%s.sock",
846  uc->gnunet_home,
847  section);
848  value = uval;
849  }
850  else if ((GNUNET_YES ==
852  "testing",
853  per_host_variable,
854  &num_per_host)) &&
855  (num_per_host > 0))
856  {
857  GNUNET_break (0); /* FIXME */
858  }
859  }
860  if (0 == strcmp (option, "HOSTNAME"))
861  {
862  value = (NULL == uc->system->hostname) ? "localhost" : uc->system->hostname;
863  }
864  GNUNET_free (single_variable);
865  GNUNET_free (per_host_variable);
866  GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, option, value);
867 }
868 
869 
877 static void
878 update_config_sections (void *cls, const char *section)
879 {
880  struct UpdateContext *uc = cls;
881  char **ikeys;
882  char *val;
883  char *ptr;
884  char *orig_allowed_hosts;
885  char *allowed_hosts;
886  char *ACCEPT_FROM_key;
887  uint16_t ikeys_cnt;
888  uint16_t key;
889 
890  ikeys_cnt = 0;
891  val = NULL;
892  /* Ignore certain options from sections. See
893  https://gnunet.org/bugs/view.php?id=2476 */
894  if (GNUNET_YES ==
895  GNUNET_CONFIGURATION_have_value (uc->cfg, section, "TESTING_IGNORE_KEYS"))
896  {
899  section,
900  "TESTING_IGNORE_KEYS",
901  &val));
902  ptr = val;
903  for (ikeys_cnt = 0; NULL != (ptr = strstr (ptr, ";")); ikeys_cnt++)
904  ptr++;
905  if (0 == ikeys_cnt)
906  GNUNET_break (0);
907  else
908  {
909  ikeys = GNUNET_malloc ((sizeof(char *)) * ikeys_cnt);
910  ptr = val;
911  for (key = 0; key < ikeys_cnt; key++)
912  {
913  ikeys[key] = ptr;
914  ptr = strstr (ptr, ";");
915  GNUNET_assert (NULL != ptr); /* worked just before... */
916  *ptr = '\0';
917  ptr++;
918  }
919  }
920  }
921  if (0 != ikeys_cnt)
922  {
923  for (key = 0; key < ikeys_cnt; key++)
924  {
925  if (NULL != strstr (ikeys[key], "ADVERTISED_PORT"))
926  break;
927  }
928  if ((key == ikeys_cnt) &&
929  (GNUNET_YES ==
930  GNUNET_CONFIGURATION_have_value (uc->cfg, section, "ADVERTISED_PORT")))
931  {
933  section,
934  "PORT",
935  &ptr))
936  {
938  section,
939  "ADVERTISED_PORT",
940  ptr);
941  GNUNET_free (ptr);
942  }
943  }
944  for (key = 0; key < ikeys_cnt; key++)
945  {
946  if (NULL != strstr (ikeys[key], "ACCEPT_FROM"))
947  {
948  GNUNET_free (ikeys);
949  GNUNET_free (val);
950  return;
951  }
952  }
953  GNUNET_free (ikeys);
954  }
955  GNUNET_free (val);
956  ACCEPT_FROM_key = "ACCEPT_FROM";
957  if ((NULL != uc->system->trusted_ip) &&
958  (NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */
959  ACCEPT_FROM_key = "ACCEPT_FROM6";
961  section,
962  ACCEPT_FROM_key,
963  &orig_allowed_hosts))
964  {
965  orig_allowed_hosts = GNUNET_strdup ("127.0.0.1;");
966  }
967  if (NULL == uc->system->trusted_ip)
968  allowed_hosts = GNUNET_strdup (orig_allowed_hosts);
969  else
970  GNUNET_asprintf (&allowed_hosts,
971  "%s%s;",
972  orig_allowed_hosts,
973  uc->system->trusted_ip);
974  GNUNET_free (orig_allowed_hosts);
976  section,
977  ACCEPT_FROM_key,
978  allowed_hosts);
979  GNUNET_free (allowed_hosts);
980 }
981 
982 
983 static struct SharedServiceInstance *
985  struct SharedService *ss,
987 {
988  struct SharedServiceInstance *i;
989  struct GNUNET_CONFIGURATION_Handle *temp;
990  char *gnunet_home;
991  uint32_t port;
992 
993  ss->n_peers++;
994  if (((0 == ss->share) && (NULL == ss->instances)) ||
995  ((0 != ss->share) &&
996  (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share))))
997  {
998  i = GNUNET_new (struct SharedServiceInstance);
999  i->ss = ss;
1000  (void) GNUNET_asprintf (&gnunet_home,
1001  "%s/shared/%s/%u",
1002  system->tmppath,
1003  ss->sname,
1004  ss->n_instances);
1005  (void) GNUNET_asprintf (&i->unix_sock, "%s/sock", gnunet_home);
1006  port = GNUNET_TESTING_reserve_port (system);
1007  if (0 == port)
1008  {
1009  GNUNET_free (gnunet_home);
1011  return NULL;
1012  }
1014  temp = GNUNET_CONFIGURATION_dup (ss->cfg);
1015  (void) GNUNET_asprintf (&i->port_str, "%u", port);
1016  (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", gnunet_home);
1018  "PATHS",
1019  "GNUNET_HOME",
1020  gnunet_home);
1021  GNUNET_free (gnunet_home);
1023  ss->sname,
1024  "UNIXPATH",
1025  i->unix_sock);
1027  ss->sname,
1028  "PORT",
1029  i->port_str);
1031  {
1034  return NULL;
1035  }
1037  }
1038  else
1039  {
1040  GNUNET_assert (NULL != ss->instances);
1041  GNUNET_assert (0 < ss->n_instances);
1042  i = ss->instances[ss->n_instances - 1];
1043  }
1045  ss->sname,
1047  cfg);
1049  ss->sname,
1050  "UNIXPATH",
1051  i->unix_sock);
1053  return i;
1054 }
1055 
1056 
1076 static int
1079  uint16_t **ports,
1080  unsigned int *nports)
1081 {
1082  struct UpdateContext uc;
1083  char *default_config;
1084 
1085  uc.system = system;
1086  uc.cfg = cfg;
1087  uc.status = GNUNET_OK;
1088  uc.ports = NULL;
1089  uc.nports = 0;
1090  GNUNET_asprintf (&uc.gnunet_home,
1091  "%s/%u",
1092  system->tmppath,
1093  system->path_counter++);
1094  GNUNET_asprintf (&default_config, "%s/config", uc.gnunet_home);
1096  "PATHS",
1097  "DEFAULTCONFIG",
1098  default_config);
1099  GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", default_config);
1100  GNUNET_free (default_config);
1102  "PATHS",
1103  "GNUNET_HOME",
1104  uc.gnunet_home);
1105  /* make PORTs and UNIXPATHs unique */
1107  /* allow connections to services from system trusted_ip host */
1109  /* enable loopback-based connections between peers */
1110  GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "USE_LOCALADDR", "YES");
1111  GNUNET_free (uc.gnunet_home);
1112  if ((NULL != ports) && (NULL != nports))
1113  {
1114  *ports = uc.ports;
1115  *nports = uc.nports;
1116  }
1117  else
1118  GNUNET_free (uc.ports);
1119  return uc.status;
1120 }
1121 
1122 
1139 int
1142 {
1143  return GNUNET_TESTING_configuration_create_ (system, cfg, NULL, NULL);
1144 }
1145 
1146 
1160 struct GNUNET_TESTING_Peer *
1163  uint32_t key_number,
1164  struct GNUNET_PeerIdentity *id,
1165  char **emsg)
1166 {
1167  struct GNUNET_TESTING_Peer *peer;
1168  struct GNUNET_DISK_FileHandle *fd;
1169  char *hostkey_filename;
1170  char *config_filename;
1171  char *libexec_binary;
1172  char *emsg_;
1174  uint16_t *ports;
1175  struct SharedService *ss;
1176  struct SharedServiceInstance **ss_instances;
1177  unsigned int cnt;
1178  unsigned int nports;
1179 
1180  ports = NULL;
1181  nports = 0;
1182  ss_instances = NULL;
1183  if (NULL != emsg)
1184  *emsg = NULL;
1185  if (key_number >= system->total_hostkeys)
1186  {
1187  GNUNET_asprintf (
1188  &emsg_,
1189  _ (
1190  "You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"),
1191  (unsigned int) system->total_hostkeys);
1192  goto err_ret;
1193  }
1194  pk = NULL;
1195  if ((NULL != id) &&
1196  (NULL == (pk = GNUNET_TESTING_hostkey_get (system, key_number, id))))
1197  {
1198  GNUNET_asprintf (&emsg_,
1199  _ ("Failed to initialize hostkey for peer %u\n"),
1200  (unsigned int) key_number);
1201  goto err_ret;
1202  }
1203  if (NULL != pk)
1204  GNUNET_free (pk);
1205  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (cfg, "PEER", "PRIVATE_KEY"))
1206  {
1207  GNUNET_asprintf (
1208  &emsg_,
1209  _ ("PRIVATE_KEY option in PEER section missing in configuration\n"));
1210  goto err_ret;
1211  }
1212  /* Remove sections for shared services */
1213  for (cnt = 0; cnt < system->n_shared_services; cnt++)
1214  {
1215  ss = system->shared_services[cnt];
1217  }
1218  if (GNUNET_OK !=
1219  GNUNET_TESTING_configuration_create_ (system, cfg, &ports, &nports))
1220  {
1221  GNUNET_asprintf (&emsg_,
1222  _ ("Failed to create configuration for peer "
1223  "(not enough free ports?)\n"));
1224  goto err_ret;
1225  }
1228  "PEER",
1229  "PRIVATE_KEY",
1230  &hostkey_filename));
1231  fd = GNUNET_DISK_file_open (hostkey_filename,
1235  if (NULL == fd)
1236  {
1237  GNUNET_asprintf (&emsg_,
1238  _ ("Cannot open hostkey file `%s': %s\n"),
1239  hostkey_filename,
1240  strerror (errno));
1241  GNUNET_free (hostkey_filename);
1242  goto err_ret;
1243  }
1244  GNUNET_free (hostkey_filename);
1247  system->hostkeys_data
1248  + (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
1250  {
1251  GNUNET_asprintf (&emsg_,
1252  _ ("Failed to write hostkey file for peer %u: %s\n"),
1253  (unsigned int) key_number,
1254  strerror (errno));
1256  goto err_ret;
1257  }
1259  ss_instances = GNUNET_malloc (sizeof(struct SharedServiceInstance *)
1260  * system->n_shared_services);
1261  for (cnt = 0; cnt < system->n_shared_services; cnt++)
1262  {
1263  ss = system->shared_services[cnt];
1264  ss_instances[cnt] = associate_shared_service (system, ss, cfg);
1265  if (NULL == ss_instances[cnt])
1266  {
1267  emsg_ = GNUNET_strdup ("FIXME");
1268  goto err_ret;
1269  }
1270  }
1273  "PATHS",
1274  "DEFAULTCONFIG",
1275  &config_filename));
1276  if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename))
1277  {
1278  GNUNET_asprintf (&emsg_,
1279  _ (
1280  "Failed to write configuration file `%s' for peer %u: %s\n"),
1281  config_filename,
1282  (unsigned int) key_number,
1283  strerror (errno));
1284  GNUNET_free (config_filename);
1285  goto err_ret;
1286  }
1287  peer = GNUNET_new (struct GNUNET_TESTING_Peer);
1288  peer->ss_instances = ss_instances;
1289  peer->cfgfile = config_filename; /* Free in peer_destroy */
1291  libexec_binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
1292  if (GNUNET_SYSERR ==
1294  "arm",
1295  "PREFIX",
1296  &peer->main_binary))
1297  {
1298  /* No prefix */
1299  GNUNET_asprintf (&peer->main_binary, "%s", libexec_binary);
1300  peer->args = GNUNET_strdup ("");
1301  }
1302  else
1303  {
1304  peer->args = GNUNET_strdup (libexec_binary);
1305  }
1306  peer->system = system;
1307  peer->key_number = key_number;
1308  GNUNET_free (libexec_binary);
1309  peer->ports = ports; /* Free in peer_destroy */
1310  peer->nports = nports;
1311  return peer;
1312 
1313  err_ret:
1314  GNUNET_free (ss_instances);
1315  GNUNET_free (ports);
1316  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_);
1317  if (NULL != emsg)
1318  *emsg = emsg_;
1319  else
1320  GNUNET_free (emsg_);
1321  return NULL;
1322 }
1323 
1324 
1331 void
1333  struct GNUNET_PeerIdentity *id)
1334 {
1335  if (NULL != peer->id)
1336  {
1337  GNUNET_memcpy (id, peer->id, sizeof(struct GNUNET_PeerIdentity));
1338  return;
1339  }
1340  peer->id = GNUNET_new (struct GNUNET_PeerIdentity);
1341  GNUNET_free_nz (
1342  GNUNET_TESTING_hostkey_get (peer->system, peer->key_number, peer->id));
1343  GNUNET_memcpy (id, peer->id, sizeof(struct GNUNET_PeerIdentity));
1344 }
1345 
1346 
1353 int
1355 {
1356  struct SharedServiceInstance *i;
1357  unsigned int cnt;
1358 
1359  if (NULL != peer->main_process)
1360  {
1361  GNUNET_break (0);
1362  return GNUNET_SYSERR;
1363  }
1364  GNUNET_assert (NULL != peer->cfgfile);
1365  for (cnt = 0; cnt < peer->system->n_shared_services; cnt++)
1366  {
1367  i = peer->ss_instances[cnt];
1368  if ((0 == i->n_refs) &&
1370  return GNUNET_SYSERR;
1371  i->n_refs++;
1372  }
1373  peer->main_binary =
1374  GNUNET_CONFIGURATION_expand_dollar (peer->cfg, peer->main_binary);
1375  peer->main_process =
1377  NULL,
1378  peer->main_binary,
1379  peer->args,
1380  "-c",
1381  peer->cfgfile,
1382  NULL);
1383  if (NULL == peer->main_process)
1384  {
1386  _ ("Failed to start `%s': %s\n"),
1387  peer->main_binary,
1388  strerror (errno));
1389  return GNUNET_SYSERR;
1390  }
1391  return GNUNET_OK;
1392 }
1393 
1394 
1402 int
1404 {
1405  struct SharedServiceInstance *i;
1406  unsigned int cnt;
1407 
1408  if (NULL == peer->main_process)
1409  {
1410  GNUNET_break (0);
1411  return GNUNET_SYSERR;
1412  }
1413  if (0 != GNUNET_OS_process_kill (peer->main_process, GNUNET_TERM_SIG))
1414  return GNUNET_SYSERR;
1415  for (cnt = 0; cnt < peer->system->n_shared_services; cnt++)
1416  {
1417  i = peer->ss_instances[cnt];
1418  GNUNET_assert (0 != i->n_refs);
1419  i->n_refs--;
1420  if (0 == i->n_refs)
1422  }
1423  return GNUNET_OK;
1424 }
1425 
1426 
1434 int
1436 {
1437  int ret;
1438 
1439  if (NULL == peer->main_process)
1440  {
1441  GNUNET_break (0);
1442  return GNUNET_SYSERR;
1443  }
1444  ret = GNUNET_OS_process_wait (peer->main_process);
1445  GNUNET_OS_process_destroy (peer->main_process);
1446  peer->main_process = NULL;
1447  return ret;
1448 }
1449 
1450 
1457 int
1459 {
1461  return GNUNET_SYSERR;
1463  return GNUNET_SYSERR;
1464  return GNUNET_OK;
1465 }
1466 
1467 
1475 static void
1476 disconn_status (void *cls, int connected)
1477 {
1478  struct GNUNET_TESTING_Peer *peer = cls;
1479 
1480  if (GNUNET_SYSERR == connected)
1481  {
1482  peer->cb (peer->cb_cls, peer, connected);
1483  return;
1484  }
1485  if (GNUNET_YES == connected)
1486  {
1488  return;
1489  }
1492  peer->ah = NULL;
1493  peer->cb (peer->cb_cls, peer, GNUNET_YES);
1494 }
1495 
1496 
1508 int
1511  void *cb_cls)
1512 {
1513  if (NULL == peer->main_process)
1514  return GNUNET_SYSERR;
1516  if (NULL == peer->ah)
1517  return GNUNET_SYSERR;
1518  peer->cb = cb;
1519  peer->cb_cls = cb_cls;
1520  return GNUNET_OK;
1521 }
1522 
1523 
1533 void
1535 {
1536  GNUNET_assert (NULL != peer->ah);
1538  peer->ah = NULL;
1539 }
1540 
1541 
1549 void
1551 {
1552  unsigned int cnt;
1553 
1554  if (NULL != peer->main_process)
1556  if (NULL != peer->ah)
1558  GNUNET_free (peer->cfgfile);
1559  if (NULL != peer->cfg)
1561  GNUNET_free (peer->main_binary);
1562  GNUNET_free (peer->args);
1563  GNUNET_free (peer->id);
1564  GNUNET_free (peer->ss_instances);
1565  if (NULL != peer->ports)
1566  {
1567  for (cnt = 0; cnt < peer->nports; cnt++)
1568  GNUNET_TESTING_release_port (peer->system, peer->ports[cnt]);
1569  GNUNET_free (peer->ports);
1570  }
1571  GNUNET_free (peer);
1572 }
1573 
1574 
1591 int
1592 GNUNET_TESTING_peer_run (const char *testdir,
1593  const char *cfgfilename,
1595  void *tm_cls)
1596 {
1597  return GNUNET_TESTING_service_run (testdir, "arm", cfgfilename, tm, tm_cls);
1598 }
1599 
1600 
1605 {
1610 
1615 
1620 
1624  void *tm_cls;
1625 };
1626 
1627 
1633 static void
1634 service_run_main (void *cls)
1635 {
1636  struct ServiceContext *sc = cls;
1637 
1638  sc->tm (sc->tm_cls, sc->cfg, sc->peer);
1639 }
1640 
1641 
1663 int
1664 GNUNET_TESTING_service_run (const char *testdir,
1665  const char *service_name,
1666  const char *cfgfilename,
1668  void *tm_cls)
1669 {
1670  struct ServiceContext sc;
1671  struct GNUNET_TESTING_System *system;
1672  struct GNUNET_TESTING_Peer *peer;
1674  char *binary;
1675  char *libexec_binary;
1676 
1677  GNUNET_log_setup (testdir, "WARNING", NULL);
1678  system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL, NULL);
1679  if (NULL == system)
1680  return 1;
1682  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfgfilename))
1683  {
1685  _ ("Failed to load configuration from %s\n"),
1686  cfgfilename);
1689  return 1;
1690  }
1691  peer = GNUNET_TESTING_peer_configure (system, cfg, 0, NULL, NULL);
1692  if (NULL == peer)
1693  {
1695  hostkeys_unload (system);
1697  return 1;
1698  }
1699  GNUNET_free (peer->main_binary);
1700  GNUNET_free (peer->args);
1701  GNUNET_asprintf (&binary, "gnunet-service-%s", service_name);
1702  libexec_binary = GNUNET_OS_get_libexec_binary_path (binary);
1703  if (GNUNET_SYSERR ==
1705  service_name,
1706  "PREFIX",
1707  &peer->main_binary))
1708  {
1709  /* No prefix */
1710  GNUNET_asprintf (&peer->main_binary, "%s", libexec_binary);
1711  peer->args = GNUNET_strdup ("");
1712  }
1713  else
1714  peer->args = GNUNET_strdup (libexec_binary);
1715 
1716  GNUNET_free (libexec_binary);
1717  GNUNET_free (binary);
1719  {
1723  return 1;
1724  }
1725  sc.cfg = cfg;
1726  sc.tm = tm;
1727  sc.tm_cls = tm_cls;
1728  sc.peer = peer;
1729  GNUNET_SCHEDULER_run (&service_run_main, &sc); /* Scheduler loop */
1730  if ((NULL != peer->main_process) &&
1732  {
1736  return 1;
1737  }
1741  return 0;
1742 }
1743 
1744 
1758 char *
1760 {
1761  size_t slen = strlen (argv0) + 1;
1762  char sbuf[slen];
1763  char *ret;
1764  char *dot;
1765 
1766  GNUNET_memcpy (sbuf, argv0, slen);
1767  ret = strrchr (sbuf, '_');
1768  if (NULL == ret)
1769  return NULL;
1770  ret++; /* skip underscore */
1771  dot = strchr (ret, '.');
1772  if (NULL != dot)
1773  *dot = '\0';
1774  return GNUNET_strdup (ret);
1775 }
1776 
1777 
1778 static unsigned int
1780 {
1781  char *copy;
1782  size_t slen;
1783  char *token;
1784  unsigned int ret;
1785  char *rest = NULL;
1786 
1787  slen = strlen (line) + 1;
1788  copy = malloc (slen);
1789  memcpy (copy, line, slen);
1790  token = strtok_r (copy, ":", &rest);
1791  token = strtok_r (NULL, ":", &rest);
1792  sscanf (token, "%u", &ret);
1793  GNUNET_free (copy);
1794  return ret;
1795 }
1796 
1797 
1798 static char *
1799 get_key (char *line)
1800 {
1801  char *copy;
1802  size_t slen;
1803  char *token;
1804  char *ret;
1805  char *rest = NULL;
1806 
1807  slen = strlen (line) + 1;
1808  copy = malloc (slen);
1809  memcpy (copy, line, slen);
1810  token = strtok_r (copy, ":", &rest);
1811  ret = malloc (2);
1812  memcpy (ret, token, 2);
1813  GNUNET_free (copy);
1814  return ret;
1815 }
1816 
1817 
1818 static char *
1820 {
1821  char *copy;
1822  size_t slen, slen_token;
1823  char *token;
1824  char *ret;
1825  char *rest = NULL;
1826 
1827  slen = strlen (line) + 1;
1828  copy = malloc (slen);
1829  memcpy (copy, line, slen);
1830  token = strtok_r (copy, ":", &rest);
1831  token = strtok_r (NULL, ":", &rest);
1833  "first token %s\n",
1834  token);
1835  slen_token = strlen (token);
1836  ret = malloc (slen_token + 1);
1837  memcpy (ret, token, slen_token + 1);
1838  GNUNET_free (copy);
1839  return ret;
1840 }
1841 
1842 
1843 static unsigned int
1845 {
1846  char *copy;
1847  size_t slen;
1848  char *token;
1849  unsigned int ret;
1850  char *rest = NULL;
1851 
1852  slen = strlen (line) + 1;
1853  copy = malloc (slen);
1854  memcpy (copy, line, slen);
1855  token = strtok_r (copy, ":", &rest);
1856  token = strtok_r (NULL, ":", &rest);
1857  token = strtok_r (NULL, ":", &rest);
1858  sscanf (token, "%u", &ret);
1859  GNUNET_free (copy);
1860  return ret;
1861 }
1862 
1863 
1864 static char *
1865 get_value (char *key, char *line)
1866 {
1867  char *copy;
1868  size_t slen, slen_token;
1869  char *token;
1870  char *token2;
1871  char *temp;
1872  char *rest = NULL;
1873  char *ret;
1874 
1875  slen = strlen (line) + 1;
1876  copy = malloc (slen);
1877  memcpy (copy, line, slen);
1878  temp = strstr (copy, key);
1879  if (NULL == temp)
1880  return NULL;
1881  token = strtok_r (temp, ":", &rest);
1882  token = strtok_r (NULL, ":", &rest);
1883  token2 = strtok_r (token, "}", &rest);
1884  slen_token = strlen (token2);
1885  ret = malloc (slen_token + 1);
1886  memcpy (ret, token2, slen_token + 1);
1887  GNUNET_free (copy);
1888  return ret;
1889 }
1890 
1891 
1892 static struct GNUNET_TESTING_NodeConnection *
1894 {
1895  struct GNUNET_TESTING_NodeConnection *node_connection;
1896  char *copy;
1897  size_t slen;
1898  char *token;
1899  char *token2;
1900  unsigned int node_n;
1901  unsigned int namespace_n;
1902  char *rest = NULL;
1903  char *rest2 = NULL;
1905 
1906  node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection);
1907  node_connection->node = node;
1908 
1909  slen = strlen (line) + 1;
1910  copy = malloc (slen);
1911  memcpy (copy, line, slen);
1912  token = strtok_r (copy, ":", &rest);
1913  if (0 == strcmp ("{K", token))
1914  {
1915  node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE;
1916  token = strtok_r (NULL, ":", &rest);
1917  sscanf (token, "%u", &node_n);
1919  "node_n %u\n",
1920  node_n);
1921  node_connection->node_n = node_n;
1922  node_connection->namespace_n = 0;
1923  }
1924  else if (0 == strcmp ("{P", token))
1925  {
1926  node_connection->node_type = GNUNET_TESTING_SUBNET_NODE;
1927  token = strtok_r (NULL, ":", &rest);
1928  sscanf (token, "%u", &node_n);
1929  node_connection->node_n = node_n;
1930  token = strtok_r (NULL, ":", &rest);
1931  sscanf (token, "%u", &namespace_n);
1932  node_connection->namespace_n = namespace_n;
1934  "node_n %u namespace_n %u\n",
1935  node_n,
1936  namespace_n);
1937  }
1938  while (NULL != (token = strtok_r (NULL, ":", &rest)))
1939  {
1941  token2 = strtok_r (token, "}", &rest2);
1942  if (NULL != token2)
1943  {
1944  slen = strlen (token2) + 1;
1945  prefix->address_prefix = malloc (slen);
1946  memcpy (prefix->address_prefix, token2, slen);
1947  }
1948  else
1949  {
1950  slen = strlen (token) + 1;
1951  prefix->address_prefix = malloc (slen);
1952  memcpy (prefix->address_prefix, token, slen);
1953  }
1954 
1956  "address_prefix %s\n",
1957  prefix->address_prefix);
1958 
1960  node_connection->address_prefixes_tail,
1961  prefix);
1962  }
1963 
1964  GNUNET_free (copy);
1965  return node_connection;
1966 }
1967 
1968 
1969 static void
1971 {
1972  char *value, *value2;
1973  char *temp;
1974  char *copy;
1975  size_t slen;
1976  char *rest = NULL;
1977  char *rest2 = NULL;
1978  struct GNUNET_TESTING_NodeConnection *node_connection;
1979 
1980 
1981  temp = strstr (line, "connect");
1982  if (NULL != temp)
1983  {
1984  slen = strlen (temp) + 1;
1985  copy = malloc (slen);
1986  memcpy (copy, temp, slen);
1987  strtok_r (copy, ":", &rest);
1988  value = strtok_r (rest, "|", &rest2);
1989 
1990  while (NULL != value)
1991  {
1992  node_connection = get_connect_value (value, node);
1995  node_connection);
1996  value2 = strstr (value, "}}");
1997  if (NULL != value2)
1998  break;
1999  value = strtok_r (NULL, "|", &rest2);
2000 
2001  }
2002  }
2003 }
2004 
2005 
2012 struct GNUNET_MessageHeader *
2014 {
2015  struct GNUNET_CMDS_LOCAL_FINISHED *reply;
2016  size_t msg_length;
2017 
2019  "Local test exits with status %d\n",
2020  rv);
2021  msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
2022  reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
2024  reply->header.size = htons ((uint16_t) msg_length);
2025  reply->result = htons (rv);
2026 
2027  return (struct GNUNET_MessageHeader *) reply;
2028 }
2029 
2030 
2039 {
2040  uint64_t fs;
2041  char *data;
2042  char *token;
2043  char *key;
2044  unsigned int out;
2045  char *rest = NULL;
2046  char *value;
2047  int ret;
2048  struct GNUNET_TESTING_NetjailTopology *topo = GNUNET_new (struct
2050  struct GNUNET_TESTING_NetjailNode *node;
2051  struct GNUNET_TESTING_NetjailRouter *router;
2052  struct GNUNET_TESTING_NetjailNamespace *namespace;
2053  struct GNUNET_ShortHashCode *hkey;
2054  struct GNUNET_HashCode hc;
2055 
2056  topo->map_namespaces =
2058  topo->map_globals =
2060 
2062  {
2064  _ ("Topology file %s not found\n"),
2065  filename);
2066  return NULL;
2067  }
2068  if (GNUNET_OK !=
2070  {
2072  _ ("Topology file %s has no data\n"),
2073  filename);
2074  return NULL;
2075  }
2076  data = GNUNET_malloc (fs);
2077  if (fs != GNUNET_DISK_fn_read (filename, data, fs))
2078  {
2080  _ ("Topology file %s cannot be read\n"),
2081  filename);
2082  GNUNET_free (data);
2083  return NULL;
2084  }
2085 
2087  "data: %s\n",
2088  data);
2089 
2090  token = strtok_r (data, "\n", &rest);
2091 
2092  while (NULL != token)
2093  {
2094  key = get_key (token);
2096  "In the loop with token: %s beginning with %s\n",
2097  token,
2098  key);
2099  if (0 == strcmp (key, "M"))
2100  {
2102  "Get first Value for M.\n");
2103  out = get_first_value (token);
2105  "M: %u\n",
2106  out);
2107  topo->nodes_m = out;
2108  }
2109  else if (0 == strcmp (key, "N"))
2110  {
2112  "Get first Value for N.\n");
2113  out = get_first_value (token);
2115  "N: %u\n",
2116  out);
2117  topo->namespaces_n = out;
2118  }
2119  else if (0 == strcmp (key, "X"))
2120  {
2122  "Get first Value for X.\n");
2123  out = get_first_value (token);
2125  "X: %u\n",
2126  out);
2127  topo->nodes_x = out;
2128  }
2129  else if (0 == strcmp (key, "T"))
2130  {
2132  "Get first string value for T.\n");
2133  value = get_first_string_value (token);
2135  "value: %s\n",
2136  value);
2137  topo->plugin = value;
2138  }
2139  else if (0 == strcmp (key, "K"))
2140  {
2141  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2142  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2143 
2145  "Get first Value for K.\n");
2146  out = get_first_value (token);
2148  "K: %u\n",
2149  out);
2150  node->node_n = out;
2151  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2152  memcpy (hkey,
2153  &hc,
2154  sizeof (*hkey));
2155  node->is_global = GNUNET_YES;
2156 
2158  topo->map_globals,
2159  hkey))
2160  GNUNET_break (0);
2161  else
2163  hkey,
2164  node,
2167  "Get value for key value on K.\n");
2168  value = get_value ("plugin", token);
2170  "value: %s\n",
2171  value);
2172  node->plugin = value;
2173  node_connections (token, node);
2174  }
2175  else if (0 == strcmp (key, "R"))
2176  {
2177  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2178  router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter);
2179  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2180 
2182  "Get first Value for R.\n");
2183  out = get_first_value (token);
2185  "R: %u\n",
2186  out);
2187  node->node_n = out;
2188  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2189  memcpy (hkey,
2190  &hc,
2191  sizeof (*hkey));
2193  "Get value for key tcp_port on R.\n");
2194  value = get_value ("tcp_port", token);
2196  "tcp_port: %s\n",
2197  value);
2198  ret = sscanf (value, "%u", &(router->tcp_port));
2199 
2200  GNUNET_break (0 != ret && 1 >= router->tcp_port);
2201 
2203  "Get value for key udp_port on R.\n");
2204  value = get_value ("udp_port", token);
2205  ret = sscanf (value, "%u", &(router->udp_port));
2206  GNUNET_break (0 != ret && 1 >= router->udp_port);
2208  "udp_port: %s\n",
2209  value);
2210 
2212  topo->map_namespaces,
2213  hkey))
2214  {
2215  namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
2216  hkey);
2217  }
2218  else
2219  {
2220  namespace = GNUNET_new (struct GNUNET_TESTING_NetjailNamespace);
2221  namespace->namespace_n = out;
2222  namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2224  hkey,
2225  namespace,
2227  }
2228  namespace->router = router;
2229 
2230  }
2231  else if (0 == strcmp (key, "P"))
2232  {
2233  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2234  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2235 
2237  "Get first Value for P.\n");
2238  out = get_first_value (token);
2240  "P: %u\n",
2241  out);
2242  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2243  memcpy (hkey,
2244  &hc,
2245  sizeof (*hkey));
2246 
2248  topo->map_namespaces,
2249  hkey))
2250  {
2251  namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
2252  hkey);
2253  }
2254  else
2255  {
2256  namespace = GNUNET_new (struct GNUNET_TESTING_NetjailNamespace);
2257  namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2258  namespace->namespace_n = out;
2260  hkey,
2261  namespace,
2263  }
2265  "Get second Value for P.\n");
2266  out = get_second_value (token);
2268  "P: %u\n",
2269  out);
2270  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2271  memcpy (hkey,
2272  &hc,
2273  sizeof (*hkey));
2275  namespace->nodes,
2276  hkey))
2277  {
2278  GNUNET_break (0);
2279  }
2280  else
2281  {
2282  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2283  GNUNET_CONTAINER_multishortmap_put (namespace->nodes,
2284  hkey,
2285  node,
2288  "Get value for key plugin on P.\n");
2289  value = get_value ("plugin", token);
2291  "plugin: %s\n",
2292  value);
2293  node->plugin = value;
2294  node->node_n = out;
2295  node->namespace_n = namespace->namespace_n;
2296  }
2297  node_connections (token, node);
2298  }
2299  token = strtok_r (NULL, "\n", &rest);
2300  }
2301 
2302  return topo;
2303 }
2304 
2305 
2306 /* end of testing.c */
char * getenv()
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static uint16_t port
Port number.
Definition: gnunet-bcd.c:83
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:53
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
uint32_t data
The data value.
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
static char * hostname
Our hostname; we give this to all the peers we start.
static struct GNUNET_FS_UnindexContext * uc
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
@ GNUNET_TESTING_SUBNET_NODE
Node in a subnet.
@ GNUNET_TESTING_GLOBAL_NODE
Global known node.
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
Definition: arm_api.c:577
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
Definition: arm_api.c:602
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.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Section_Iterator iter, void *iter_cls)
Iterate over all sections in the configuration.
enum GNUNET_GenericReturnValue 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.
void GNUNET_CONFIGURATION_remove_section(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Remove the given section and all options in it.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
char * GNUNET_CONFIGURATION_expand_dollar(const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig)
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:197
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1235
enum GNUNET_GenericReturnValue 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:482
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:686
enum GNUNET_GenericReturnValue 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:222
void * GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
Map a file into memory.
Definition: disk.c:1378
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1085
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1306
char * GNUNET_DISK_mkdtemp(const char *t)
Create an (empty) temporary directory on disk.
Definition: disk.c:340
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h)
Unmap a file.
Definition: disk.c:1409
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:664
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_MAP_TYPE_READ
Read-only memory map.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
Definition: network.c:907
int GNUNET_NETWORK_socket_bind(struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len)
Bind a socket to a particular address.
Definition: network.c:485
int GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
Definition: network.c:560
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 ...
struct GNUNET_OS_Process * GNUNET_OS_start_process(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,...)
Start a process.
Definition: os_priority.c:678
struct GNUNET_OS_Process * GNUNET_OS_start_process_s(enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename,...)
Start a process.
Definition: os_priority.c:747
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:983
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
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:224
@ GNUNET_OS_INHERIT_STD_OUT_AND_ERR
When these flags are set, the child process will inherit stdout and stderr of the parent.
Definition: gnunet_os_lib.h:97
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:720
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1458
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
Definition: testing.c:449
#define GNUNET_TESTING_PREFIX
The environmental variable, if set, that dictates where testing should place generated peer configura...
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create_with_portrange(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services, uint16_t lowport, uint16_t highport)
Create a system handle.
Definition: testing.c:364
struct GNUNET_TESTING_Peer * GNUNET_TESTING_peer_configure(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t key_number, struct GNUNET_PeerIdentity *id, char **emsg)
Configure a GNUnet peer.
Definition: testing.c:1161
void(* GNUNET_TESTING_PeerStopCallback)(void *cls, struct GNUNET_TESTING_Peer *peer, int success)
Callback to inform whether the peer is running or stopped.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_TESTING_hostkey_get(const struct GNUNET_TESTING_System *system, uint32_t key_number, struct GNUNET_PeerIdentity *id)
Testing includes a number of pre-created hostkeys for faster peer startup.
Definition: testing.c:705
int GNUNET_TESTING_peer_run(const char *testdir, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls)
Start a single peer and run a test using the testing library.
Definition: testing.c:1592
void(* GNUNET_TESTING_TestMain)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
Signature of the 'main' function for a (single-peer) testcase that is run using GNUNET_TESTING_peer_r...
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:529
int GNUNET_TESTING_service_run(const char *testdir, const char *service_name, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls)
Start a single service (no ARM, except of course if the given service name is 'arm') and run a test u...
Definition: testing.c:1664
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1354
uint16_t GNUNET_TESTING_reserve_port(struct GNUNET_TESTING_System *system)
Reserve a TCP or UDP port for a peer.
Definition: testing.c:571
void GNUNET_TESTING_release_port(struct GNUNET_TESTING_System *system, uint16_t port)
Release reservation of a TCP or UDP port for a peer (used during GNUNET_TESTING_peer_destroy()).
Definition: testing.c:667
void GNUNET_TESTING_peer_stop_async_cancel(struct GNUNET_TESTING_Peer *peer)
Cancel a previous asynchronous peer stop request.
Definition: testing.c:1534
int GNUNET_TESTING_peer_stop_async(struct GNUNET_TESTING_Peer *peer, GNUNET_TESTING_PeerStopCallback cb, void *cb_cls)
Stop a peer asynchronously using ARM API.
Definition: testing.c:1509
int GNUNET_TESTING_configuration_create(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new configuration using the given configuration as a template; ports and paths will be modif...
Definition: testing.c:1140
char * GNUNET_TESTING_get_testname_from_underscore(const char *argv0)
Sometimes we use the binary name to determine which specific test to run.
Definition: testing.c:1759
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer's main process.
Definition: testing.c:1403
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1550
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
Definition: testing.c:1435
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1332
#define GNUNET_TESTING_HOSTKEYFILESIZE
Size of each hostkey in the hostkey file (in BYTES).
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
#define AI_NUMERICSERV
AI_NUMERICSERV not defined in windows.
Definition: platform.h:218
#define GNUNET_TERM_SIG
The termination signal.
Definition: platform.h:233
#define PATH_MAX
Assumed maximum path length.
Definition: platform.h:240
Handle for interacting with ARM.
Definition: arm_api.c:103
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED.
Definition: testing_cmds.h:85
enum GNUNET_GenericReturnValue result
Definition: testing_cmds.h:87
Private ECC key encoded for transmission.
Handle used to access files (and pipes).
int fd
File handle on Unix-like systems.
Handle for a memory-mapping operation.
Definition: disk.c:1359
A 512-bit hashcode.
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
handle to a socket
Definition: network.c:53
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
Node in the netjail topology.
unsigned int namespace_n
The number of the namespace this node is running in.
struct GNUNET_TESTING_NodeConnection * node_connections_head
Head of the DLL with the connections which shall be established to other nodes.
unsigned int is_global
Flag indicating if this node is a global known node.
char * plugin
Plugin for the test case to be run on this node.
unsigned int node_n
The number of this node in the namespace.
struct GNUNET_TESTING_NodeConnection * node_connections_tail
Tail of the DLL with the connections which shall be established to other nodes.
Router of a network namespace.
unsigned int tcp_port
Will tcp be forwarded?
unsigned int udp_port
Will udp be forwarded?
Toplogy of our netjail setup.
struct GNUNET_CONTAINER_MultiShortmap * map_globals
Hash map containing the global known nodes which are not natted.
char * plugin
Default plugin for the test case to be run on nodes.
unsigned int nodes_m
Number of nodes per namespace.
unsigned int nodes_x
Number of global known nodes per namespace.
unsigned int namespaces_n
Number of namespaces.
struct GNUNET_CONTAINER_MultiShortmap * map_namespaces
Hash map containing the namespaces (for natted nodes) of the topology.
Connection to another node.
enum GNUNET_TESTING_NODE_TYPE node_type
The type of the node this connection points to.
struct GNUNET_TESTING_ADDRESS_PREFIX * address_prefixes_head
Head of the DLL with the address prefixes for the protocolls this node is reachable.
struct GNUNET_TESTING_ADDRESS_PREFIX * address_prefixes_tail
Tail of the DLL with the address prefixes for the protocolls this node is reachable.
unsigned int node_n
The number of the node this connection points to.
struct GNUNET_TESTING_NetjailNode * node
The node which establish the connection.
unsigned int namespace_n
The number of the subnet of the node this connection points to.
Handle for a GNUnet peer controlled by testing.
Definition: testing.c:167
struct GNUNET_TESTING_System * system
The TESTING system associated with this peer.
Definition: testing.c:171
struct GNUNET_OS_Process * main_process
Handle to the running binary of the service, NULL if the peer/service is currently not running.
Definition: testing.c:191
unsigned int nports
The number of ports in the above array.
Definition: testing.c:231
char * main_binary
Binary to be executed during 'GNUNET_TESTING_peer_start'.
Definition: testing.c:184
struct GNUNET_CONFIGURATION_Handle * cfg
The config of the peer.
Definition: testing.c:201
uint16_t * ports
Array of ports currently allocated to this peer.
Definition: testing.c:226
struct SharedServiceInstance ** ss_instances
Definition: testing.c:219
struct GNUNET_PeerIdentity * id
The cached identity of this peer.
Definition: testing.c:217
struct GNUNET_ARM_Handle * ah
The handle to the peer's ARM service.
Definition: testing.c:196
uint32_t key_number
The keynumber of this peer's hostkey.
Definition: testing.c:236
void * cb_cls
The closure for the above callback.
Definition: testing.c:211
char * cfgfile
Path to the configuration file for this peer.
Definition: testing.c:176
GNUNET_TESTING_PeerStopCallback cb
The callback to call asynchronously when a peer is stopped.
Definition: testing.c:206
Specification of a service that is to be shared among peers.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration template for the service.
unsigned int share
The number of peers which share an instance of the service.
const char * service
The name of the service.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:94
uint16_t highport
Highest port we are allowed to use.
Definition: testing.c:159
char * trusted_ip
The trusted ip.
Definition: testing.c:105
char * tmppath
Prefix (e.g.
Definition: testing.c:99
uint32_t total_hostkeys
The number of hostkeys.
Definition: testing.c:149
unsigned int n_shared_services
Definition: testing.c:124
char * hostname
our hostname
Definition: testing.c:110
uint32_t reserved_ports[65536/32]
Bitmap where each port that has already been reserved for some GNUnet peer is recorded.
Definition: testing.c:134
char * hostkeys_data
Hostkeys data, contains "GNUNET_TESTING_HOSTKEYFILESIZE * total_hostkeys" bytes.
Definition: testing.c:115
uint32_t path_counter
Counter we use to make service home paths unique on this system; the full path consists of the tmppat...
Definition: testing.c:144
struct SharedService ** shared_services
Definition: testing.c:122
struct GNUNET_DISK_MapHandle * map
memory map for hostkeys_data.
Definition: testing.c:120
uint16_t lowport
Lowest port we are allowed to use.
Definition: testing.c:154
Structure for holding service data.
Definition: testing.c:1605
struct GNUNET_TESTING_Peer * peer
The peer in which the service is run.
Definition: testing.c:1619
void * tm_cls
Closure for the above callback.
Definition: testing.c:1624
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the peer in which the service is run.
Definition: testing.c:1609
GNUNET_TESTING_TestMain tm
Callback to signal service startup.
Definition: testing.c:1614
unsigned int n_refs
Definition: testing.c:70
struct SharedService * ss
Definition: testing.c:60
struct GNUNET_OS_Process * proc
Definition: testing.c:64
The structure for identifying a shared service.
unsigned int share
Definition: testing.c:83
struct GNUNET_CONFIGURATION_Handle * cfg
Definition: testing.c:79
unsigned int n_instances
Definition: testing.c:85
struct SharedServiceInstance ** instances
Definition: testing.c:77
unsigned int n_peers
Definition: testing.c:81
char * sname
Definition: testing.c:75
Closure for update_rel_sum() and update_abs_sum().
uint16_t * ports
Array of ports currently allocated to this peer.
Definition: testing.c:756
struct GNUNET_TESTING_System * system
The system for which we are building configurations.
Definition: testing.c:739
char * gnunet_home
The customized service home path for this peer.
Definition: testing.c:749
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration we are building.
Definition: testing.c:744
unsigned int nports
The number of ports in the above array.
Definition: testing.c:761
int status
build status - to signal error while building a configuration
Definition: testing.c:766
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static char * get_value(char *key, char *line)
Definition: testing.c:1865
static void disconn_status(void *cls, int connected)
Function called whenever we connect to or disconnect from ARM.
Definition: testing.c:1476
struct GNUNET_MessageHeader * GNUNET_TESTING_send_local_test_finished_msg(enum GNUNET_GenericReturnValue rv)
Create a GNUNET_CMDS_LOCAL_FINISHED message.
Definition: testing.c:2013
static int start_shared_service_instance(struct SharedServiceInstance *i)
Definition: testing.c:481
static void service_run_main(void *cls)
Callback to be called when SCHEDULER has been started.
Definition: testing.c:1634
#define HIGH_PORT
Highest port used for GNUnet testing.
Definition: testing.c:55
static void node_connections(char *line, struct GNUNET_TESTING_NetjailNode *node)
Definition: testing.c:1970
static void hostkeys_unload(struct GNUNET_TESTING_System *system)
Function to remove the loaded hostkeys.
Definition: testing.c:311
static unsigned int get_second_value(char *line)
Definition: testing.c:1844
static void cleanup_shared_service_instance(struct SharedServiceInstance *i)
Definition: testing.c:465
static unsigned int get_first_value(char *line)
Definition: testing.c:1779
static void update_config(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options.
Definition: testing.c:781
static struct SharedServiceInstance * associate_shared_service(struct GNUNET_TESTING_System *system, struct SharedService *ss, struct GNUNET_CONFIGURATION_Handle *cfg)
Definition: testing.c:984
static char * get_key(char *line)
Definition: testing.c:1799
static void stop_shared_service_instance(struct SharedServiceInstance *i)
Definition: testing.c:508
static char * get_first_string_value(char *line)
Definition: testing.c:1819
static struct GNUNET_TESTING_NodeConnection * get_connect_value(char *line, struct GNUNET_TESTING_NetjailNode *node)
Definition: testing.c:1893
#define LOG(kind,...)
Definition: testing.c:39
static void update_config_sections(void *cls, const char *section)
Section iterator to set ACCEPT_FROM/ACCEPT_FROM6 to include the address of 'trusted_hosts' in all sec...
Definition: testing.c:878
static int GNUNET_TESTING_configuration_create_(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t **ports, unsigned int *nports)
Create a new configuration using the given configuration as a template; ports and paths will be modif...
Definition: testing.c:1077
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
Definition: testing.c:2038
#define LOW_PORT
Lowest port used for GNUnet testing.
Definition: testing.c:48
static void cfg_copy_iterator(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options.
Definition: testing.c:331
static int hostkeys_load(struct GNUNET_TESTING_System *system)
Testing includes a number of pre-created hostkeys for faster peer startup.
Definition: testing.c:248
Message formats for communication between testing cmds helper and testcase plugins.