GNUnet 0.21.2
testing_api_topology.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_testing_lib.h"
36#include "testing_cmds.h"
37
38#define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
39
40#define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u"
41
42#define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u"
43
44#define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u"
45
46#define PREFIX_TCP "tcp"
47
48#define PREFIX_UDP "udp"
49
50#define PREFIX_TCP_NATTED "tcp_natted"
51
52#define PREFIX_UDP_NATTED "udp_natted"
53
54
64static unsigned int
65get_first_value (const char *line)
66{
67 const char *colon = strchr (line, ':');
68 char dummy;
69 int ret;
70
71 GNUNET_assert (NULL != colon);
72 ret = sscanf (colon + 1,
73 "%u%c",
74 &ret,
75 &dummy);
76 if (2 == ret)
77 GNUNET_assert (':' == dummy);
78 else
79 GNUNET_assert (1 == ret);
80 return ret;
81}
82
83
92static char *
93get_key (const char *line)
94{
95 const char *colon = strchr (line, ':');
96
97 GNUNET_assert (NULL != colon);
98 return GNUNET_strndup (line,
99 colon - line);
100}
101
102
112// FIXME: avoid strdup, return const?
113static char *
115{
116 const char *colon = strchr (line, ':');
117
118 GNUNET_assert (NULL != colon);
119 return GNUNET_strdup (colon + 1);
120}
121
122
133static unsigned int
135{
136 const char *colon;
137 char dummy;
138 int ret;
139
140 colon = strchr (line, ':');
141 GNUNET_assert (NULL != colon);
142 colon = strchr (colon + 1, ':');
143 GNUNET_assert (NULL != colon);
144 GNUNET_assert (1 ==
145 sscanf (colon + 1,
146 "%u%c",
147 &ret,
148 &dummy));
149 return ret;
150}
151
152
163static char *
164get_value (const char *key, const char *line)
165{
166 char copy[strlen (line) + 1];
167 size_t slen;
168 char *token;
169 char *token2;
170 char *temp;
171 char *rest = NULL;
172
173 slen = strlen (line) + 1;
174 memcpy (copy, line, slen);
175 temp = strstr (copy, key);
176 if (NULL == temp)
177 return NULL;
178 token = strtok_r (temp, ":", &rest);
179 if (NULL == token)
180 return NULL;
181 token = strtok_r (NULL, ":", &rest);
182 if (NULL == token)
183 return NULL;
184 token2 = strtok_r (token, "}", &rest);
185 if (NULL == token2)
186 return NULL;
187 return GNUNET_strdup (token2);
188}
189
190
203static struct GNUNET_TESTING_NodeConnection *
206{
207 struct GNUNET_TESTING_NodeConnection *node_connection;
208 char *copy;
209 char *token;
210 char *token2;
211 unsigned int node_n;
212 unsigned int namespace_n;
213 char *rest = NULL;
214 char *rest2 = NULL;
216 unsigned int sscanf_ret;
217
218 node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection);
219 node_connection->node = node;
220
221 copy = GNUNET_strdup (line);
222 token = strtok_r (copy, ":", &rest);
223 if (0 == strcmp ("{K", token))
224 {
225 node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE;
226 token = strtok_r (NULL, ":", &rest);
227 GNUNET_assert (1 == sscanf (token, "%u", &node_n));
229 "node_n %u\n",
230 node_n);
231 node_connection->node_n = node_n;
232 node_connection->namespace_n = 0;
233 }
234 else if (0 == strcmp ("{P", token))
235 {
236 node_connection->node_type = GNUNET_TESTING_SUBNET_NODE;
237 token = strtok_r (NULL, ":", &rest);
238 errno = 0;
239 sscanf_ret = sscanf (token, "%u", &namespace_n);
240 if (errno != 0)
241 {
243 }
244 GNUNET_assert (0 < sscanf_ret);
245 node_connection->namespace_n = namespace_n;
246 token = strtok_r (NULL, ":", &rest);
247 errno = 0;
248 sscanf_ret = sscanf (token, "%u", &node_n);
249 if (errno != 0)
250 {
252 }
253 GNUNET_assert (0 < sscanf_ret);
254 node_connection->node_n = node_n;
256 "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n",
257 node_n,
258 namespace_n,
259 node->node_n,
260 node->namespace_n);
261 }
262 else
263 {
264 GNUNET_break (0);
265 GNUNET_free (node_connection);
266 GNUNET_free (copy);
267 return NULL;
268 }
269
270 while (NULL != (token = strtok_r (NULL, ":", &rest)))
271 {
273 token2 = strtok_r (token, "}", &rest2);
274 if (NULL != token2)
275 prefix->address_prefix = GNUNET_strdup (token2);
276 else
277 prefix->address_prefix = GNUNET_strdup (token);
278
280 "address_prefix %s\n",
281 prefix->address_prefix);
282
284 node_connection->address_prefixes_tail,
285 prefix);
287 "address_prefix %s\n",
288 prefix->address_prefix);
289 }
290
291 GNUNET_free (copy);
292 return node_connection;
293}
294
295
312static void
314 struct GNUNET_TESTING_NetjailNode *node)
315{
316 char *value, *value2;
317 char *temp;
318 char *copy;
319 char *rest = NULL;
320 char *rest2 = NULL;
321 struct GNUNET_TESTING_NodeConnection *node_connection;
322
323 temp = strstr (line, "connect");
324 if (NULL != temp)
325 {
326 copy = GNUNET_strdup (temp);
327 strtok_r (copy, ":", &rest);
328 value = strtok_r (rest, "|", &rest2);
329
330 while (NULL != value)
331 {
333 "node_connections value %s\n",
334 value);
335 node_connection = get_connect_value (value, node);
336 if (NULL == node_connection)
337 {
339 "connect key was not expected in this configuration line: %s\n",
340 line);
341 break;
342 }
345 node_connection);
346 value2 = strstr (value, "}}");
347 if (NULL != value2)
348 break;
349 value = strtok_r (NULL, "|", &rest2);
350
351 }
352 GNUNET_free (copy);
353 }
354}
355
356
365static int
366log_nodes (void *cls,
367 const struct GNUNET_ShortHashCode *id,
368 void *value)
369{
370 struct GNUNET_TESTING_NetjailNode *node = value;
371 struct GNUNET_TESTING_NodeConnection *pos_connection;
372 struct GNUNET_TESTING_AddressPrefix *pos_prefix;
373
375 "plugin: %s space: %u node: %u global: %u\n",
376 node->plugin,
377 node->namespace_n,
378 node->node_n,
379 node->is_global);
380
381 for (pos_connection = node->node_connections_head; NULL != pos_connection;
382 pos_connection = pos_connection->next)
383 {
384
386 "namespace_n: %u node_n: %u node_type: %u\n",
387 pos_connection->namespace_n,
388 pos_connection->node_n,
389 pos_connection->node_type);
390
391 for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix;
392 pos_prefix =
393 pos_prefix->next)
394 {
396 "prefix: %s\n",
397 pos_prefix->address_prefix);
398 }
399 }
400 return GNUNET_YES;
401}
402
403
412static int
413log_namespaces (void *cls,
414 const struct GNUNET_ShortHashCode *id,
415 void *value)
416{
417 struct GNUNET_TESTING_NetjailNamespace *namespace = value;
418
420 &log_nodes,
421 NULL);
422 return GNUNET_YES;
423}
424
425
431static int
433{
435 "plugin: %s spaces: %u nodes: %u known: %u\n",
436 topology->plugin,
437 topology->namespaces_n,
438 topology->nodes_m,
439 topology->nodes_x);
440
442 log_namespaces, NULL);
444 NULL);
445 return GNUNET_YES;
446}
447
448
459static void
460get_node_info (unsigned int num,
461 const struct GNUNET_TESTING_NetjailTopology *topology,
462 struct GNUNET_TESTING_NetjailNode **node_ex,
463 struct GNUNET_TESTING_NetjailNamespace **namespace_ex,
464 struct GNUNET_TESTING_NodeConnection **node_connections_ex)
465{
466 struct GNUNET_ShortHashCode hkey;
467 struct GNUNET_HashCode hc;
468 unsigned int namespace_n;
469 unsigned int node_m;
470 struct GNUNET_TESTING_NetjailNode *node;
471 struct GNUNET_TESTING_NetjailNamespace *namespace;
473
474 log_topo (topology);
476 "num: %u \n",
477 num);
478 if (topology->nodes_x >= num)
479 {
480
481 GNUNET_CRYPTO_hash (&num, sizeof(num), &hc);
482 memcpy (&hkey,
483 &hc,
484 sizeof (hkey));
486 &hkey);
487 if (NULL != node)
488 {
489 *node_ex = node;
490 *node_connections_ex = node->node_connections_head;
491 }
492 }
493 else
494 {
495 namespace_n = (unsigned int) ceil ((double) (num - topology->nodes_x)
496 / topology->nodes_m);
498 "ceil num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n",
499 num,
500 topology->nodes_x,
501 topology->nodes_m,
504 memcpy (&hkey,
505 &hc,
506 sizeof (hkey));
507 namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
508 &hkey);
509 if (NULL != namespace)
510 {
511 node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1);
512 GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc);
513 memcpy (&hkey,
514 &hc,
515 sizeof (hkey));
516 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
517 &hkey);
518 if (NULL != node)
519 {
521 "node additional_connects: %u %p\n",
523 node);
525 }
526 *node_ex = node;
527 *namespace_ex = namespace;
528 *node_connections_ex = node_connections;
529 }
530 }
531}
532
533
542GNUNET_TESTING_get_node (unsigned int num,
543 struct GNUNET_TESTING_NetjailTopology *topology)
544{
545 struct GNUNET_TESTING_NetjailNode *node;
546 struct GNUNET_TESTING_NetjailNamespace *namespace;
548
549 get_node_info (num, topology, &node, &namespace, &node_connections);
550
551 return node;
552
553}
554
555
565 const struct
567{
568 struct GNUNET_TESTING_NetjailNode *node;
569 struct GNUNET_TESTING_NetjailNamespace *namespace;
571
573 "get_connections\n");
574
575 get_node_info (num, topology, &node, &namespace, &node_connections);
576
577 return node_connections;
578}
579
580
581int
582free_nodes_cb (void *cls,
583 const struct GNUNET_ShortHashCode *key,
584 void *value)
585{
586 (void) cls;
587 struct GNUNET_TESTING_NetjailNode *node = value;
588 struct GNUNET_TESTING_NodeConnection *pos_connection;
589 struct GNUNET_TESTING_AddressPrefix *pos_prefix;
590
591 while (NULL != (pos_connection = node->node_connections_head))
592 {
593 while (NULL != (pos_prefix = pos_connection->address_prefixes_head))
594 {
596 pos_connection->address_prefixes_tail,
597 pos_prefix);
598 GNUNET_free (pos_prefix->address_prefix);
599 GNUNET_free (pos_prefix);
600 }
603 pos_connection);
604 GNUNET_free (pos_connection);
605 }
606
607 GNUNET_free (node->plugin);
608 GNUNET_free (node);
609 return GNUNET_OK;
610}
611
612
613int
615 const struct GNUNET_ShortHashCode *key,
616 void *value)
617{
618 (void) cls;
619 struct GNUNET_TESTING_NetjailNamespace *namespace = value;
620
621 GNUNET_free (namespace->router);
623 namespace->nodes);
624 return GNUNET_OK;
625
626}
627
628
629static int
630free_value_cb (void *cls,
631 const struct GNUNET_ShortHashCode *key,
632 void *value)
633{
634 (void) cls;
635
637
638 return GNUNET_OK;
639}
640
641
642static int
644 const struct GNUNET_ShortHashCode *key,
645 void *value)
646{
647 (void) cls;
648 struct GNUNET_TESTING_NetjailSubnet *subnet = value;
649
652 NULL);
653
654 GNUNET_free (subnet);
655
656 return GNUNET_OK;
657}
658
659
660static int
662 const struct GNUNET_ShortHashCode *key,
663 void *value)
664{
665 (void) cls;
666 struct GNUNET_TESTING_NetjailCarrier *carrier = value;
667
670 NULL);
673 NULL);
674
675 GNUNET_free (carrier);
676
677 return GNUNET_OK;
678}
679
680
686void
688{
691 NULL);
694 NULL);
695 GNUNET_free (topology->plugin);
696 GNUNET_free (topology);
697}
698
699
721unsigned int
723 struct GNUNET_TESTING_NodeConnection *node_connection,
724 struct GNUNET_TESTING_NetjailTopology *topology)
725{
726 unsigned int n, m, num;
727
728 n = node_connection->namespace_n;
729 m = node_connection->node_n;
730
731 if (0 == n)
732 num = m;
733 else
734 num = (n - 1) * topology->nodes_m + m + topology->nodes_x;
735
736 return num;
737}
738
739
747char *
749 const char *prefix)
750{
751 struct GNUNET_TESTING_NetjailNode *node;
752 char *addr;
753 char *template;
754 unsigned int node_n;
755
757 "get address prefix: %s node_n: %u\n",
758 prefix,
759 connection->node_n);
760
761 node = connection->node;
762 if (connection->namespace_n == node->namespace_n)
763 {
764 template = CONNECT_ADDRESS_TEMPLATE;
765 node_n = connection->node_n;
766 }
767 else if (0 == connection->namespace_n)
768 {
770 node_n = connection->node_n;
771 }
772 else if (1 == connection->node_n)
773 {
775 node_n = connection->namespace_n;
776 }
777 else
778 {
779 return NULL;
780 }
781
782 if (0 == strcmp (PREFIX_TCP, prefix) ||
783 0 == strcmp (PREFIX_UDP, prefix) ||
784 0 == strcmp (PREFIX_UDP_NATTED, prefix) ||
785 0 == strcmp (PREFIX_TCP_NATTED, prefix))
786 {
787 GNUNET_asprintf (&addr,
788 template,
789 prefix,
790 node_n);
791 }
792 else
793 {
794 GNUNET_assert (0);
795 }
796
797 return addr;
798}
799
800
807unsigned int
810 topology)
811{
812 struct GNUNET_TESTING_NetjailNode *node;
813 struct GNUNET_TESTING_NetjailNamespace *namespace;
815
817 "get_additional_connects\n");
818
819 get_node_info (num, topology, &node, &namespace, &node_connections);
820
821 if (NULL == node)
822 {
824 "No info found for node %d\n", num);
825 return 0;
826 }
828 "node additional_connects for node %p\n",
829 node);
831 "node additional_connects: %u\n",
832 node->additional_connects);
833
834 return node->additional_connects;
835}
836
837char *
840 const char *my_node_id)
841{
842 return njt->plugin;
843}
844
845
846static void
848 struct GNUNET_TESTING_NetjailTopology *topology,
849 struct GNUNET_TESTING_NetjailSubnet *subnet)
850{
851 struct GNUNET_HashCode hc;
853
854 for (int i = 1; i < subnet->number_peers; i++)
855 {
856 struct GNUNET_ShortHashCode hkey;
858
859 topology->total++;
860 GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
861 memcpy (&hkey,
862 &hc,
863 sizeof (hkey));
865 &hkey,
866 subnet_peer,
868 }
869}
870
871
872static void
874 struct GNUNET_TESTING_NetjailTopology *topology,
875 struct GNUNET_TESTING_NetjailCarrier *carrier)
876{
877 struct GNUNET_HashCode hc;
879
880 for (int i = 1; i < carrier->number_subnets; i++)
881 {
882 struct GNUNET_ShortHashCode hkey;
884 char *section;
885
886 topology->total++;
887 subnet->number = topology->total;
888 subnet->index = i;
889 GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
890 memcpy (&hkey,
891 &hc,
892 sizeof (hkey));
894 &hkey,
895 subnet,
897 GNUNET_asprintf (&section, "CARRIER-%u-SUBNET-%u", carrier->index, i);
899 section,
900 "SUBNET_PEERS",
901 (unsigned long long *) &subnet->number_peers))
902 {
903 subnet->number_peers = topology->default_subnet_peers;
904 }
905
906 create_subnet_peers (cfg, topology, subnet);
907
908 GNUNET_free (section);
909 }
910}
911
912
913static void
915 struct GNUNET_TESTING_NetjailTopology *topology,
916 struct GNUNET_TESTING_NetjailCarrier *carrier)
917{
918 struct GNUNET_HashCode hc;
920
921 for (int i = 1; i < carrier->number_peers; i++)
922 {
923 struct GNUNET_ShortHashCode hkey;
925
926 topology->total++;
927 peer->number = topology->total;
928 GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
929 memcpy (&hkey,
930 &hc,
931 sizeof (hkey));
933 &hkey,
934 peer,
936 //GNUNET_asprintf (&section, "CARRIER-%u-PEER-%u", carrier->index, i);
937 }
938}
939
940
943{
948 struct GNUNET_HashCode hc;
949
951 GNUNET_assert (NULL != topology->carriers);
952
953 if (GNUNET_OK !=
955 input,
956 strlen (input),
957 NULL))
958 {
960 _ ("Failed to parse configuration.\n"));
962 return NULL;
963 }
965 "DEFAULTS",
966 "SUBNETS",
967 &(topology->default_subnets)))
968 {
970 "Missing default SUBNETS!\n");
971 return NULL;
972 }
974 "DEFAULTS",
975 "TESTBED_PLUGIN",
976 &topology->plugin))
977 {
979 "Missing default TESTBED_PLUGIN!\n");
980 return NULL;
981 }
983 "DEFAULTS",
984 "CARRIER_PEERS",
985 &(topology->default_carrier_peers)))
986 {
988 "Missing default CARRIER_PEERS!\n");
989 return NULL;
990 }
992 "DEFAULTS",
993 "SUBNET_PEERS",
994 &(topology->default_subnet_peers)))
995 {
997 "Missing default SUBNET_PEERS!\n");
998 return NULL;
999 }
1001 "BACKBONE",
1002 "CARRIERS",
1003 &(topology->num_carriers)))
1004 {
1006 "No carrier configured!\n");
1007 return NULL;
1008 }
1010 "BACKBONE",
1011 "BACKBONE_PEERS",
1012 &(topology->num_backbone_peers)))
1013 {
1015 "No backbone peers configured!\n");
1016 return NULL;
1017 }
1018 for (int i = 0;i < topology->num_backbone_peers; i++)
1019 {
1021 struct GNUNET_ShortHashCode hkey;
1022
1023 topology->total++;
1024 peer->number = topology->total;
1025 GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
1026 memcpy (&hkey,
1027 &hc,
1028 sizeof (hkey));
1030 &hkey,
1031 peer,
1033 }
1034 GNUNET_assert (NULL != topology->carriers);
1035 for (int i = 0;i < topology->num_carriers; i++)
1036 {
1038 struct GNUNET_ShortHashCode hkey;
1039 char *section;
1040
1041 topology->total++;
1042 carrier->number = topology->total;
1043 GNUNET_CRYPTO_hash (&topology->total, sizeof(topology->total), &hc);
1044 memcpy (&hkey,
1045 &hc,
1046 sizeof (hkey));
1047 GNUNET_assert (NULL != topology->carriers);
1049 &hkey,
1050 carrier,
1052 GNUNET_asprintf (&section, "CARRIER-%u", i);
1054 section,
1055 "SUBNETS",
1056 (unsigned long long *) &carrier->number_subnets))
1057 {
1058 carrier->number_subnets = topology->default_subnets;
1059 }
1061 section,
1062 "CARRIER_PEERS",
1063 (unsigned long long *) &carrier->number_peers))
1064 {
1065 carrier->number_peers = topology->default_carrier_peers;
1066 }
1067 create_peers (cfg, topology, carrier);
1068 create_subnets (cfg, topology, carrier);
1069
1070 GNUNET_free (section);
1071 }
1072
1073 GNUNET_free (cfg);
1074
1075 return topology;
1076}
1077
1078
1352 GNUNET_TESTING)
1353
1354
1355/* end of netjail.c */
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static int ret
Final status code.
Definition: gnunet-arm.c:94
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
struct GNUNET_TESTING_NetjailTopology * njt
The loaded topology.
static const char * my_node_id
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:66
static char * line
Desired phone line (string to be converted to a hash).
struct GNUNET_HashCode key
The key used in the DHT.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * value
Value of the record to add/remove.
#define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(prefix, name, type)
Create C implementation for a trait with name name for statically allocated data of type type.
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.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename)
De-serializes configuration.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#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).
enum GNUNET_GenericReturnValue 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_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#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(level, cmd)
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
@ GNUNET_ERROR_TYPE_INFO
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
A 512-bit hashcode.
A 256-bit hashcode.
Protocol address prefix für a connection between nodes.
struct GNUNET_TESTING_AddressPrefix * next
Pointer to the next prefix in the DLL.
char * address_prefix
The address prefix.
unsigned int number
Unique identifier this part of the topology can be identified.
unsigned int number
Unique identifier this part of the topology can be identified.
unsigned int number_peers
Number of carrier peers.
struct GNUNET_CONTAINER_MultiShortmap * subnets
Hash map containing subnets.
unsigned int number_subnets
Number of carrier subnets.
unsigned int index
Of all carriers this has index.
unsigned int number
Unique identifier this part of the topology can be identified.
struct GNUNET_CONTAINER_MultiShortmap * peers
Hash map containing peers.
Node in the netjail topology.
unsigned int namespace_n
The number of the subnet 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 additional_connects
The number of unintentional additional connections this node waits for.
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 subnet.
struct GNUNET_TESTING_NodeConnection * node_connections_tail
Tail of the DLL with the connections which shall be established to other nodes.
unsigned int number_peers
Number of subnet peers.
unsigned int number
Unique identifier this part of the topology can be identified.
struct GNUNET_CONTAINER_MultiShortmap * peers
Hash map containing peers.
unsigned int index
Of all subnets this has index.
Toplogy of our netjail setup.
unsigned long long default_subnets
Default number of subnets per carrier.
struct GNUNET_CONTAINER_MultiShortmap * map_globals
Hash map containing the global known nodes which are not natted.
struct GNUNET_CONTAINER_MultiShortmap * carriers
Hash map containing the carriers.
unsigned long long default_subnet_peers
Default number of peers per subnet.
char * plugin
Default plugin for the test case to be run on nodes.
unsigned int nodes_m
Number of nodes per subnet.
unsigned int nodes_x
Number of global known nodes.
unsigned long long num_carriers
Number of carriers.
unsigned int namespaces_n
Number of subnets.
unsigned long long default_carrier_peers
Default number of peers per carrier.
unsigned int total
Total number of namespaces in the topology.
struct GNUNET_CONTAINER_MultiShortmap * backbone_peers
Hash map containing the carriers.
struct GNUNET_CONTAINER_MultiShortmap * map_namespaces
Hash map containing the subnets (for natted nodes) of the topology.
unsigned long long num_backbone_peers
Default number of backbone peers.
Connection to another node.
struct GNUNET_TESTING_AddressPrefix * address_prefixes_tail
Tail of the DLL with the address prefixes for the protocols this node is reachable.
struct GNUNET_TESTING_NodeConnection * next
Pointer to the next connection in the DLL.
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.
struct GNUNET_TESTING_AddressPrefix * address_prefixes_head
Head of the DLL with the address prefixes for the protocols this node is reachable.
enum GNUNET_TESTING_NodeType node_type
The type of the node this connection points to.
int free_nodes_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static unsigned int get_first_value(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
#define PREFIX_UDP_NATTED
static int free_subnets_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static void node_connections(const char *line, struct GNUNET_TESTING_NetjailNode *node)
Every line in the topology configuration starts with a string indicating which kind of information wi...
static int free_value_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
unsigned int GNUNET_TESTING_get_additional_connects(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get the number of unintentional additional connections the node waits for.
#define PREFIX_TCP
static struct GNUNET_TESTING_NodeConnection * get_connect_value(const char *line, struct GNUNET_TESTING_NetjailNode *node)
Every line in the topology configuration starts with a string indicating which kind of information wi...
static char * get_key(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
static int free_carriers_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
struct GNUNET_TESTING_NodeConnection * GNUNET_TESTING_get_connections(unsigned int num, const struct GNUNET_TESTING_NetjailTopology *topology)
Get the connections to other nodes for a specific node.
static char * get_value(const char *key, const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
char * GNUNET_TESTING_get_plugin_from_topo(struct GNUNET_TESTING_NetjailTopology *njt, const char *my_node_id)
Get the global plugin name form the topology file.
static void create_peers(struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailCarrier *carrier)
int free_namespaces_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
#define PREFIX_TCP_NATTED
static unsigned int get_second_value(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
static void create_subnets(struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailCarrier *carrier)
struct GNUNET_TESTING_NetjailNode * GNUNET_TESTING_get_node(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get a node from the topology.
static void get_node_info(unsigned int num, const struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailNode **node_ex, struct GNUNET_TESTING_NetjailNamespace **namespace_ex, struct GNUNET_TESTING_NodeConnection **node_connections_ex)
This function extracts information about a specific node from the topology.
static char * get_first_string_value(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
unsigned int GNUNET_TESTING_calculate_num(struct GNUNET_TESTING_NodeConnection *node_connection, struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
#define LOG(kind,...)
#define CONNECT_ADDRESS_TEMPLATE
#define PREFIX_UDP
static int log_topo(const struct GNUNET_TESTING_NetjailTopology *topology)
Helper function to log the configuration in case of a problem with configuration.
static int log_nodes(void *cls, const struct GNUNET_ShortHashCode *id, void *value)
A helper function to log information about individual nodes.
#define KNOWN_CONNECT_ADDRESS_TEMPLATE
static void create_subnet_peers(struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailSubnet *subnet)
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
#define ROUTER_CONNECT_ADDRESS_TEMPLATE
static int log_namespaces(void *cls, const struct GNUNET_ShortHashCode *id, void *value)
Helper function to log information about namespaces.
char * GNUNET_TESTING_get_address(struct GNUNET_TESTING_NodeConnection *connection, const char *prefix)
Get the address for a specific communicator from a connection.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string_(const char *input)
Parse the topology data.
@ GNUNET_TESTING_SUBNET_NODE
Node in a subnet.
@ GNUNET_TESTING_GLOBAL_NODE
Global known node.
#define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op, prefix)
Call op on all simple traits.
Message formats for communication between testing cmds helper and testcase plugins.