diff options
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r-- | src/transport/test_transport_api.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 817077f58..7ce02c757 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -40,7 +40,7 @@ | |||
40 | /** | 40 | /** |
41 | * How long until we give up on transmitting the message? | 41 | * How long until we give up on transmitting the message? |
42 | */ | 42 | */ |
43 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | 43 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
44 | 44 | ||
45 | #define MTYPE 12345 | 45 | #define MTYPE 12345 |
46 | 46 | ||
@@ -159,6 +159,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
159 | "-c", cfgname, NULL); | 159 | "-c", cfgname, NULL); |
160 | #endif | 160 | #endif |
161 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 161 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
162 | |||
162 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, | 163 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, |
163 | p, | 164 | p, |
164 | ¬ify_receive, | 165 | ¬ify_receive, |
@@ -230,6 +231,31 @@ exchange_hello (void *cls, | |||
230 | GNUNET_TRANSPORT_get_hello (p2.th, TIMEOUT, &exchange_hello_last, &p2); | 231 | GNUNET_TRANSPORT_get_hello (p2.th, TIMEOUT, &exchange_hello_last, &p2); |
231 | } | 232 | } |
232 | 233 | ||
234 | static void | ||
235 | setTransportOptions(char * filename) | ||
236 | { | ||
237 | struct GNUNET_CONFIGURATION_Handle * tempcfg; | ||
238 | |||
239 | tempcfg = GNUNET_CONFIGURATION_create(); | ||
240 | GNUNET_CONFIGURATION_load (tempcfg, filename); | ||
241 | |||
242 | unsigned long long curr_port; | ||
243 | GNUNET_CONFIGURATION_get_value_number(tempcfg, "transport", "port", &curr_port); | ||
244 | |||
245 | if (is_udp) | ||
246 | { | ||
247 | fprintf(stderr, "setting transport udp plugins\n"); | ||
248 | GNUNET_CONFIGURATION_set_value_string(tempcfg, "transport", "plugins", "udp"); | ||
249 | GNUNET_CONFIGURATION_set_value_number(tempcfg, "transport-udp", "PORT", curr_port + 3); | ||
250 | } | ||
251 | else if (is_tcp) | ||
252 | { | ||
253 | GNUNET_CONFIGURATION_set_value_string(tempcfg, "transport", "plugins", "tcp"); | ||
254 | GNUNET_CONFIGURATION_set_value_number(tempcfg, "transport-tcp", "port", curr_port + 3); | ||
255 | } | ||
256 | GNUNET_CONFIGURATION_write(tempcfg, filename); | ||
257 | return; | ||
258 | } | ||
233 | 259 | ||
234 | static void | 260 | static void |
235 | run (void *cls, | 261 | run (void *cls, |
@@ -240,6 +266,10 @@ run (void *cls, | |||
240 | GNUNET_assert (ok == 1); | 266 | GNUNET_assert (ok == 1); |
241 | OKPP; | 267 | OKPP; |
242 | sched = s; | 268 | sched = s; |
269 | |||
270 | setTransportOptions("test_transport_api_peer1.conf"); | ||
271 | setTransportOptions("test_transport_api_peer2.conf"); | ||
272 | |||
243 | setup_peer (&p1, "test_transport_api_peer1.conf"); | 273 | setup_peer (&p1, "test_transport_api_peer1.conf"); |
244 | setup_peer (&p2, "test_transport_api_peer2.conf"); | 274 | setup_peer (&p2, "test_transport_api_peer2.conf"); |
245 | GNUNET_TRANSPORT_get_hello (p1.th, TIMEOUT, &exchange_hello, &p1); | 275 | GNUNET_TRANSPORT_get_hello (p1.th, TIMEOUT, &exchange_hello, &p1); |
@@ -257,10 +287,10 @@ stop_arm (struct PeerContext *p) | |||
257 | GNUNET_CONFIGURATION_destroy (p->cfg); | 287 | GNUNET_CONFIGURATION_destroy (p->cfg); |
258 | } | 288 | } |
259 | 289 | ||
260 | |||
261 | static int | 290 | static int |
262 | check () | 291 | check () |
263 | { | 292 | { |
293 | |||
264 | char *const argv[] = { "test-transport-api", | 294 | char *const argv[] = { "test-transport-api", |
265 | "-c", | 295 | "-c", |
266 | "test_transport_api_data.conf", | 296 | "test_transport_api_data.conf", |
@@ -269,6 +299,9 @@ check () | |||
269 | #endif | 299 | #endif |
270 | NULL | 300 | NULL |
271 | }; | 301 | }; |
302 | |||
303 | setTransportOptions("test_transport_api_data.conf"); | ||
304 | |||
272 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 305 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
273 | GNUNET_GETOPT_OPTION_END | 306 | GNUNET_GETOPT_OPTION_END |
274 | }; | 307 | }; |
@@ -287,13 +320,13 @@ main (int argc, char *argv[]) | |||
287 | { | 320 | { |
288 | int ret; | 321 | int ret; |
289 | 322 | ||
290 | if (strstr(argv[0], "test_transport_api_tcp") == 0) | 323 | if (strstr(argv[0], "tcp") != NULL) |
291 | { | 324 | { |
292 | is_tcp = GNUNET_YES; | 325 | is_tcp = GNUNET_YES; |
293 | } | 326 | } |
294 | else if (strstr(argv[0], "test_transport_api_udp") == 0) | 327 | else if (strstr(argv[0], "udp") != NULL) |
295 | { | 328 | { |
296 | is_udp = GNUNET_NO; | 329 | is_udp = GNUNET_YES; |
297 | } | 330 | } |
298 | 331 | ||
299 | 332 | ||