aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/template_cfg_peer1.conf4
-rw-r--r--src/transport/template_cfg_peer2.conf3
-rw-r--r--src/transport/test_quota_compliance.c11
-rw-r--r--src/transport/test_transport_api.c6
-rw-r--r--src/transport/test_transport_api_bidirectional_connect.c11
-rw-r--r--src/transport/test_transport_api_disconnect.c11
-rw-r--r--src/transport/test_transport_api_reliability.c12
-rw-r--r--src/transport/test_transport_api_timeout.c11
-rw-r--r--src/transport/test_transport_api_unreliability.c11
-rw-r--r--src/transport/test_transport_api_unreliability_constant.c11
-rw-r--r--src/transport/test_transport_testing.c6
-rw-r--r--src/transport/transport-testing.c105
-rw-r--r--src/transport/transport-testing.h6
13 files changed, 168 insertions, 40 deletions
diff --git a/src/transport/template_cfg_peer1.conf b/src/transport/template_cfg_peer1.conf
index fbb4f7c4f..90ad9ab06 100644
--- a/src/transport/template_cfg_peer1.conf
+++ b/src/transport/template_cfg_peer1.conf
@@ -3,6 +3,9 @@
3SERVICEHOME = /tmp/test-transport/api-tcp-p1/ 3SERVICEHOME = /tmp/test-transport/api-tcp-p1/
4DEFAULTCONFIG = template_cfg_peer1.conf 4DEFAULTCONFIG = template_cfg_peer1.conf
5 5
6[gnunetd]
7HOSTKEY = $SERVICEHOME/.hostkey
8
6[nat] 9[nat]
7RETURN_LOCAL_ADDRESSES = YES 10RETURN_LOCAL_ADDRESSES = YES
8DISABLEV6 = NO 11DISABLEV6 = NO
@@ -30,6 +33,7 @@ UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
30 33
31[transport] 34[transport]
32PORT = 12001 35PORT = 12001
36#DEBUG = YES
33UNIXPATH = /tmp/gnunet-p1-service-transport.sock 37UNIXPATH = /tmp/gnunet-p1-service-transport.sock
34 38
35[ats] 39[ats]
diff --git a/src/transport/template_cfg_peer2.conf b/src/transport/template_cfg_peer2.conf
index 7249fc4cc..cb5935f81 100644
--- a/src/transport/template_cfg_peer2.conf
+++ b/src/transport/template_cfg_peer2.conf
@@ -3,6 +3,9 @@
3SERVICEHOME = /tmp/test-transport/api-tcp-p2/ 3SERVICEHOME = /tmp/test-transport/api-tcp-p2/
4DEFAULTCONFIG = template_cfg_peer2.conf 4DEFAULTCONFIG = template_cfg_peer2.conf
5 5
6[gnunetd]
7HOSTKEY = $SERVICEHOME/.hostkey
8
6[nat] 9[nat]
7RETURN_LOCAL_ADDRESSES = YES 10RETURN_LOCAL_ADDRESSES = YES
8DISABLEV6 = NO 11DISABLEV6 = NO
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 7d28820cb..f4bc6fc54 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -587,11 +587,6 @@ main (int argc, char *argv[])
587{ 587{
588 int nat_res; 588 int nat_res;
589 589
590 tth = GNUNET_TRANSPORT_TESTING_init ();
591
592 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
593 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
594 &test_plugin);
595 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 590 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
596 591
597 GNUNET_log_setup (test_name, 592 GNUNET_log_setup (test_name,
@@ -602,6 +597,12 @@ main (int argc, char *argv[])
602#endif 597#endif
603 NULL); 598 NULL);
604 599
600 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
601 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
602 &test_plugin);
603
604 tth = GNUNET_TRANSPORT_TESTING_init ();
605
605 if ((strcmp (test_plugin, "tcp_nat") == 0) || 606 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
606 (strcmp (test_plugin, "udp_nat") == 0)) 607 (strcmp (test_plugin, "udp_nat") == 0))
607 { 608 {
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 47686f8d9..a04017019 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -370,12 +370,10 @@ main (int argc, char *argv[])
370 int ret; 370 int ret;
371 int nat_res; 371 int nat_res;
372 372
373 tth = GNUNET_TRANSPORT_TESTING_init (); 373 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
374
375 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 374 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
376 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 375 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
377 &test_plugin); 376 &test_plugin);
378 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
379 377
380 GNUNET_log_setup (test_name, 378 GNUNET_log_setup (test_name,
381#if VERBOSE 379#if VERBOSE
@@ -385,6 +383,8 @@ main (int argc, char *argv[])
385#endif 383#endif
386 NULL); 384 NULL);
387 385
386 tth = GNUNET_TRANSPORT_TESTING_init ();
387
388 if ((strcmp (test_plugin, "tcp_nat") == 0) || 388 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
389 (strcmp (test_plugin, "udp_nat") == 0)) 389 (strcmp (test_plugin, "udp_nat") == 0))
390 { 390 {
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c
index 06d007c81..bf8de42e9 100644
--- a/src/transport/test_transport_api_bidirectional_connect.c
+++ b/src/transport/test_transport_api_bidirectional_connect.c
@@ -378,11 +378,6 @@ main (int argc, char *argv[])
378 int ret; 378 int ret;
379 int nat_res; 379 int nat_res;
380 380
381 tth = GNUNET_TRANSPORT_TESTING_init ();
382
383 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
384 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
385 &test_plugin);
386 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 381 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
387 382
388 GNUNET_log_setup (test_name, 383 GNUNET_log_setup (test_name,
@@ -393,6 +388,12 @@ main (int argc, char *argv[])
393#endif 388#endif
394 NULL); 389 NULL);
395 390
391 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
392 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
393 &test_plugin);
394
395 tth = GNUNET_TRANSPORT_TESTING_init ();
396
396 if ((strcmp (test_plugin, "tcp_nat") == 0) || 397 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
397 (strcmp (test_plugin, "udp_nat") == 0)) 398 (strcmp (test_plugin, "udp_nat") == 0))
398 { 399 {
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 68881fbe8..703de2a5b 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -401,11 +401,6 @@ main (int argc, char *argv[])
401 int ret; 401 int ret;
402 int nat_res; 402 int nat_res;
403 403
404 tth = GNUNET_TRANSPORT_TESTING_init ();
405
406 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
407 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
408 &test_plugin);
409 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 404 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
410 405
411 GNUNET_log_setup (test_name, 406 GNUNET_log_setup (test_name,
@@ -416,6 +411,12 @@ main (int argc, char *argv[])
416#endif 411#endif
417 NULL); 412 NULL);
418 413
414 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
415 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
416 &test_plugin);
417
418 tth = GNUNET_TRANSPORT_TESTING_init ();
419
419 if ((strcmp (test_plugin, "tcp_nat") == 0) || 420 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
420 (strcmp (test_plugin, "udp_nat") == 0)) 421 (strcmp (test_plugin, "udp_nat") == 0))
421 { 422 {
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 655f6f0a3..7b0b92078 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -437,6 +437,7 @@ start_cb (struct PeerContext *p, void *cls)
437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
438 "Test triest to send from %u (%s) -> peer %u (%s)\n", sender->no, 438 "Test triest to send from %u (%s) -> peer %u (%s)\n", sender->no,
439 sender_c, receiver->no, GNUNET_i2s (&receiver->id)); 439 sender_c, receiver->no, GNUNET_i2s (&receiver->id));
440 GNUNET_free (sender_c);
440 441
441 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 442 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
442 NULL); 443 NULL);
@@ -500,11 +501,6 @@ main (int argc, char *argv[])
500 int ret; 501 int ret;
501 int nat_res; 502 int nat_res;
502 503
503 tth = GNUNET_TRANSPORT_TESTING_init ();
504
505 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
506 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
507 &test_plugin);
508 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 504 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
509 505
510 GNUNET_log_setup (test_name, 506 GNUNET_log_setup (test_name,
@@ -515,6 +511,12 @@ main (int argc, char *argv[])
515#endif 511#endif
516 NULL); 512 NULL);
517 513
514 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
515 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
516 &test_plugin);
517
518 tth = GNUNET_TRANSPORT_TESTING_init ();
519
518 if ((strcmp (test_plugin, "tcp_nat") == 0) || 520 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
519 (strcmp (test_plugin, "udp_nat") == 0)) 521 (strcmp (test_plugin, "udp_nat") == 0))
520 { 522 {
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c
index 79a90ba0e..9a16447f3 100644
--- a/src/transport/test_transport_api_timeout.c
+++ b/src/transport/test_transport_api_timeout.c
@@ -321,11 +321,6 @@ main (int argc, char *argv[])
321 int ret; 321 int ret;
322 int nat_res; 322 int nat_res;
323 323
324 tth = GNUNET_TRANSPORT_TESTING_init ();
325
326 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
327 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
328 &test_plugin);
329 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 324 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
330 325
331 GNUNET_log_setup (test_name, 326 GNUNET_log_setup (test_name,
@@ -336,6 +331,12 @@ main (int argc, char *argv[])
336#endif 331#endif
337 NULL); 332 NULL);
338 333
334 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
335 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
336 &test_plugin);
337
338 tth = GNUNET_TRANSPORT_TESTING_init ();
339
339 if ((strcmp (test_plugin, "tcp_nat") == 0) || 340 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
340 (strcmp (test_plugin, "udp_nat") == 0)) 341 (strcmp (test_plugin, "udp_nat") == 0))
341 { 342 {
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 2336b2bf9..1e93615e7 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -549,11 +549,6 @@ main (int argc, char *argv[])
549 int ret; 549 int ret;
550 int nat_res; 550 int nat_res;
551 551
552 tth = GNUNET_TRANSPORT_TESTING_init ();
553
554 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
555 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
556 &test_plugin);
557 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 552 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
558 553
559 GNUNET_log_setup (test_name, 554 GNUNET_log_setup (test_name,
@@ -564,6 +559,12 @@ main (int argc, char *argv[])
564#endif 559#endif
565 NULL); 560 NULL);
566 561
562 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
563 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
564 &test_plugin);
565
566 tth = GNUNET_TRANSPORT_TESTING_init ();
567
567 if ((strcmp (test_plugin, "tcp_nat") == 0) || 568 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
568 (strcmp (test_plugin, "udp_nat") == 0)) 569 (strcmp (test_plugin, "udp_nat") == 0))
569 { 570 {
diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c
index 3ce256017..feca0c8b7 100644
--- a/src/transport/test_transport_api_unreliability_constant.c
+++ b/src/transport/test_transport_api_unreliability_constant.c
@@ -487,11 +487,6 @@ main (int argc, char *argv[])
487 int ret; 487 int ret;
488 int nat_res; 488 int nat_res;
489 489
490 tth = GNUNET_TRANSPORT_TESTING_init ();
491
492 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
493 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
494 &test_plugin);
495 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 490 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
496 491
497 GNUNET_log_setup (test_name, 492 GNUNET_log_setup (test_name,
@@ -502,6 +497,12 @@ main (int argc, char *argv[])
502#endif 497#endif
503 NULL); 498 NULL);
504 499
500 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
501 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
502 &test_plugin);
503
504 tth = GNUNET_TRANSPORT_TESTING_init ();
505
505 if ((strcmp (test_plugin, "tcp_nat") == 0) || 506 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
506 (strcmp (test_plugin, "udp_nat") == 0)) 507 (strcmp (test_plugin, "udp_nat") == 0))
507 { 508 {
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c
index 996ea0543..7ba78c04e 100644
--- a/src/transport/test_transport_testing.c
+++ b/src/transport/test_transport_testing.c
@@ -145,6 +145,7 @@ start_cb (struct PeerContext *p, void *cls)
145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
146 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", 146 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
147 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 147 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
148 GNUNET_free (sender_c);
148 149
149 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 150 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
150 NULL); 151 NULL);
@@ -165,11 +166,16 @@ run (void *cls, char *const *args, const char *cfgfile,
165 "test_transport_api_tcp_peer1.conf", 166 "test_transport_api_tcp_peer1.conf",
166 1, &notify_receive, &notify_connect, 167 1, &notify_receive, &notify_connect,
167 &notify_disconnect, &start_cb, p1); 168 &notify_disconnect, &start_cb, p1);
169
170 GNUNET_assert (p1->hostkeyfile != NULL);
171
168 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 172 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
169 "test_transport_api_tcp_peer2.conf", 173 "test_transport_api_tcp_peer2.conf",
170 2, &notify_receive, &notify_connect, 174 2, &notify_receive, &notify_connect,
171 &notify_disconnect, &start_cb, p2); 175 &notify_disconnect, &start_cb, p2);
172 176
177 GNUNET_assert (p2->hostkeyfile != NULL);
178
173 if (p1 == NULL) 179 if (p1 == NULL)
174 { 180 {
175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index fb7535750..6892b2556 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -28,7 +28,30 @@
28#include "transport-testing.h" 28#include "transport-testing.h"
29 29
30#define VERBOSE GNUNET_EXTRA_LOGGING 30#define VERBOSE GNUNET_EXTRA_LOGGING
31#define HOSTKEYFILESIZE 914
31 32
33static const char *
34get_host_key (struct GNUNET_TRANSPORT_TESTING_handle *tth)
35{
36 if (tth->hostkey_data == NULL)
37 {
38 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
39 "No precomputed hostkeys available\n");
40 return NULL;
41 }
42 if (tth->hostkeys_total > tth->hostkeys_last)
43 {
44 tth->hostkeys_last++;
45 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
46 "Used hostkey %u of %u available hostkeys\n",
47 tth->hostkeys_last, tth->hostkeys_total);
48 return &tth->hostkey_data[(tth->hostkeys_last - 1) * HOSTKEYFILESIZE];
49 }
50 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
51 "No hostkey available (%u of %u already used)\n",
52 tth->hostkeys_last, tth->hostkeys_total);
53 return NULL;
54}
32 55
33static struct PeerContext * 56static struct PeerContext *
34find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, 57find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
@@ -246,6 +269,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
246 GNUNET_TRANSPORT_TESTING_start_cb start_cb, 269 GNUNET_TRANSPORT_TESTING_start_cb start_cb,
247 void *cb_cls) 270 void *cb_cls)
248{ 271{
272 const char *hostkey = NULL;
273 struct GNUNET_DISK_FileHandle *fn;
274
249 GNUNET_assert (tth != NULL); 275 GNUNET_assert (tth != NULL);
250 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) 276 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
251 { 277 {
@@ -259,13 +285,36 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
259 p->cfg = GNUNET_CONFIGURATION_create (); 285 p->cfg = GNUNET_CONFIGURATION_create ();
260 286
261 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 287 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
288
289
262 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) 290 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
263 GNUNET_assert (GNUNET_OK == 291 GNUNET_assert (GNUNET_OK ==
264 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", 292 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS",
265 "SERVICEHOME", 293 "SERVICEHOME",
266 &p->servicehome)); 294 &p->servicehome));
267 if (NULL != p->servicehome) 295
268 GNUNET_DISK_directory_remove (p->servicehome); 296 if (NULL != p->servicehome)
297 GNUNET_DISK_directory_remove (p->servicehome);
298
299 hostkey = get_host_key(tth);
300 if (hostkey != NULL)
301 {
302
303 GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome);
304 GNUNET_assert(GNUNET_OK == GNUNET_DISK_directory_create_for_file (p->hostkeyfile));
305 fn = GNUNET_DISK_file_open (p->hostkeyfile,
306 GNUNET_DISK_OPEN_READWRITE |
307 GNUNET_DISK_OPEN_CREATE,
308 GNUNET_DISK_PERM_USER_READ |
309 GNUNET_DISK_PERM_USER_WRITE);
310 GNUNET_assert (fn != NULL);
311 GNUNET_assert (HOSTKEYFILESIZE ==
312 GNUNET_DISK_file_write (fn, hostkey, HOSTKEYFILESIZE));
313 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fn));
314 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
315 "Wrote hostkey to file: `%s' \n", p->hostkeyfile);
316 }
317
269 p->arm_proc = 318 p->arm_proc =
270 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 319 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
271 "gnunet-service-arm", "-c", cfgname, 320 "gnunet-service-arm", "-c", cfgname,
@@ -326,6 +375,12 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
326 p->arm_proc = NULL; 375 p->arm_proc = NULL;
327 } 376 }
328 377
378 if (p->hostkeyfile != NULL)
379 {
380 GNUNET_DISK_directory_remove (p->hostkeyfile);
381 GNUNET_free (p->hostkeyfile);
382 }
383
329 if (p->servicehome != NULL) 384 if (p->servicehome != NULL)
330 { 385 {
331 GNUNET_DISK_directory_remove (p->servicehome); 386 GNUNET_DISK_directory_remove (p->servicehome);
@@ -454,6 +509,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
454 p = t; 509 p = t;
455 } 510 }
456 511
512 GNUNET_free_non_null (tth->hostkey_data);
513
457 GNUNET_free (tth); 514 GNUNET_free (tth);
458 tth = NULL; 515 tth = NULL;
459} 516}
@@ -467,6 +524,50 @@ GNUNET_TRANSPORT_TESTING_init ()
467{ 524{
468 struct GNUNET_TRANSPORT_TESTING_handle *tth = 525 struct GNUNET_TRANSPORT_TESTING_handle *tth =
469 GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); 526 GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
527 struct GNUNET_DISK_FileHandle *fd;
528 uint64_t fs;
529 uint64_t total_hostkeys;
530
531
532 /* prepare hostkeys */
533 tth->hostkey_data = NULL;
534 char * hostkeys_file = "../../contrib/testing_hostkeys.dat";
535 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
536 {
537 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
538 _("Could not read hostkeys file!\n"));
539 }
540 else
541 {
542 /* Check hostkey file size, read entire thing into memory */
543 fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ,
544 GNUNET_DISK_PERM_NONE);
545 if (NULL == fd)
546 {
547 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
548 hostkeys_file);
549 return NULL;
550 }
551
552 if (GNUNET_YES != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES))
553 fs = 0;
554
555 if (0 != (fs % HOSTKEYFILESIZE))
556 {
557 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
558 "File size %llu seems incorrect for hostkeys...\n", fs);
559 }
560 else
561 {
562 total_hostkeys = fs / HOSTKEYFILESIZE;
563 tth->hostkey_data = GNUNET_malloc_large (fs);
564 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs));
565 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
566 "Read %llu hostkeys from file\n", total_hostkeys);
567 tth->hostkeys_total = total_hostkeys;
568 }
569 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
570 }
470 571
471 return tth; 572 return tth;
472} 573}
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index 8e5d55dcd..cec7eb724 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -94,6 +94,8 @@ struct PeerContext
94 94
95 char *servicehome; 95 char *servicehome;
96 96
97 char *hostkeyfile;
98
97 unsigned int no; 99 unsigned int no;
98}; 100};
99 101
@@ -118,6 +120,10 @@ struct GNUNET_TRANSPORT_TESTING_handle
118 struct ConnectingContext *cc_head; 120 struct ConnectingContext *cc_head;
119 struct ConnectingContext *cc_tail; 121 struct ConnectingContext *cc_tail;
120 122
123 char *hostkey_data;
124 int hostkeys_total;
125 int hostkeys_last;
126
121 struct PeerContext *p_head; 127 struct PeerContext *p_head;
122 struct PeerContext *p_tail; 128 struct PeerContext *p_tail;
123}; 129};