diff options
-rw-r--r-- | src/testing/testing.c | 22 | ||||
-rw-r--r-- | src/transport/test_transport_nat_icmp_tcp_topo.conf | 7 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 27 |
3 files changed, 44 insertions, 12 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index a1161925b..2a9b0309f 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -63,6 +63,10 @@ | |||
63 | 63 | ||
64 | #define PREFIX_UDP "udp" | 64 | #define PREFIX_UDP "udp" |
65 | 65 | ||
66 | #define PREFIX_TCP_NATTED "tcp_natted" | ||
67 | |||
68 | #define PREFIX_UDP_NATTED "udp_natted" | ||
69 | |||
66 | /** | 70 | /** |
67 | * Lowest port used for GNUnet testing. Should be high enough to not | 71 | * Lowest port used for GNUnet testing. Should be high enough to not |
68 | * conflict with other applications running on the hosts but be low | 72 | * conflict with other applications running on the hosts but be low |
@@ -1914,7 +1918,7 @@ get_value (const char *key, const char *line) | |||
1914 | * Every line in the topology configuration starts with a string indicating which | 1918 | * Every line in the topology configuration starts with a string indicating which |
1915 | * kind of information will be configured with this line. Configuration values following | 1919 | * kind of information will be configured with this line. Configuration values following |
1916 | * this string are seperated by special sequences of characters. A value might be | 1920 | * this string are seperated by special sequences of characters. A value might be |
1917 | * a key value pair. A special key is the 'connect' which can appear more than once. | 1921 | * a key value pair. A special key is the 'connect' key which can appear more than once. |
1918 | * The value is the information about a connection via some protocol to some other node. | 1922 | * The value is the information about a connection via some protocol to some other node. |
1919 | * This function returns the struct GNUNET_TESTING_NodeConnection which holds the information | 1923 | * This function returns the struct GNUNET_TESTING_NodeConnection which holds the information |
1920 | * of the connect value. | 1924 | * of the connect value. |
@@ -2419,7 +2423,8 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, | |||
2419 | unsigned int node_n; | 2423 | unsigned int node_n; |
2420 | 2424 | ||
2421 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2425 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2422 | "node_n: %u\n", | 2426 | "get address prefix: %s node_n: %u\n", |
2427 | prefix, | ||
2423 | connection->node_n); | 2428 | connection->node_n); |
2424 | 2429 | ||
2425 | node = connection->node; | 2430 | node = connection->node; |
@@ -2443,15 +2448,10 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, | |||
2443 | return NULL; | 2448 | return NULL; |
2444 | } | 2449 | } |
2445 | 2450 | ||
2446 | if (0 == strcmp (PREFIX_TCP, prefix)) | 2451 | if (0 == strcmp (PREFIX_TCP, prefix) || |
2447 | { | 2452 | 0 == strcmp (PREFIX_UDP, prefix) || |
2448 | 2453 | 0 == strcmp (PREFIX_UDP_NATTED, prefix) || | |
2449 | GNUNET_asprintf (&addr, | 2454 | 0 == strcmp (PREFIX_TCP_NATTED, prefix)) |
2450 | template, | ||
2451 | prefix, | ||
2452 | node_n); | ||
2453 | } | ||
2454 | else if (0 == strcmp (PREFIX_UDP, prefix)) | ||
2455 | { | 2455 | { |
2456 | GNUNET_asprintf (&addr, | 2456 | GNUNET_asprintf (&addr, |
2457 | template, | 2457 | template, |
diff --git a/src/transport/test_transport_nat_icmp_tcp_topo.conf b/src/transport/test_transport_nat_icmp_tcp_topo.conf new file mode 100644 index 000000000..37738c80f --- /dev/null +++ b/src/transport/test_transport_nat_icmp_tcp_topo.conf | |||
@@ -0,0 +1,7 @@ | |||
1 | M:1 | ||
2 | N:1 | ||
3 | X:1 | ||
4 | T:libgnunet_test_transport_plugin_cmd_nat_upnp | ||
5 | K:1|{connect:{P:1:1:tcp_natted}} | ||
6 | R:1|{tcp_port:0}|{udp_port:0} | ||
7 | P:1:1 \ No newline at end of file | ||
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index d399e9d0a..7feecbcc7 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -97,6 +97,13 @@ connect_peers_run (void *cls, | |||
97 | pos_prefix->address_prefix); | 97 | pos_prefix->address_prefix); |
98 | if (NULL != addr) | 98 | if (NULL != addr) |
99 | { | 99 | { |
100 | char *natted_p = strstr (pos_prefix->address_prefix, "_"); | ||
101 | |||
102 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
103 | "0 validating peer number %s %s %s\n", | ||
104 | natted_p, | ||
105 | pos_prefix->address_prefix, | ||
106 | addr); | ||
100 | if (0 == GNUNET_memcmp (pos_prefix->address_prefix, "udp")) | 107 | if (0 == GNUNET_memcmp (pos_prefix->address_prefix, "udp")) |
101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
102 | "validating memcmp\n"); | 109 | "validating memcmp\n"); |
@@ -108,10 +115,28 @@ connect_peers_run (void *cls, | |||
108 | GNUNET_asprintf (&addr_and_port, | 115 | GNUNET_asprintf (&addr_and_port, |
109 | "%s:2086", | 116 | "%s:2086", |
110 | addr); | 117 | addr); |
111 | else | 118 | else if (NULL == natted_p) |
112 | GNUNET_asprintf (&addr_and_port, | 119 | GNUNET_asprintf (&addr_and_port, |
113 | "%s:60002", | 120 | "%s:60002", |
114 | addr); | 121 | addr); |
122 | else if (NULL != natted_p) | ||
123 | { | ||
124 | char *prefix; | ||
125 | char *rest; | ||
126 | char *rest2; | ||
127 | char *address; | ||
128 | |||
129 | prefix = strtok(addr, "_"); | ||
130 | rest = strtok(NULL, "_"); | ||
131 | rest2 = strtok(rest, "-"); | ||
132 | address = strtok(NULL, "-"); | ||
133 | |||
134 | GNUNET_asprintf (&addr_and_port, | ||
135 | "%s-%s:0", | ||
136 | prefix, | ||
137 | address); | ||
138 | |||
139 | } | ||
115 | peer = GNUNET_TESTING_get_peer (num, tl_system); | 140 | peer = GNUNET_TESTING_get_peer (num, tl_system); |
116 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 141 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
117 | "validating peer number %u with identity %s and address %s %u %s\n", | 142 | "validating peer number %u with identity %s and address %s %u %s\n", |