aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-25 21:26:27 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-25 21:26:27 +0000
commit62947a2d1690f607276aa84c36f269fe188fcb20 (patch)
tree21ee19033fdd544f18daf8efd1cd54df76728ba1 /src/vpn
parent95b2bc87d15ff0f44005081da8b5925839f30cf6 (diff)
downloadgnunet-62947a2d1690f607276aa84c36f269fe188fcb20.tar.gz
gnunet-62947a2d1690f607276aa84c36f269fe188fcb20.zip
-expanding tests to cover 4-to-6, 6-to-4 and 6-over-4 as well
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/Makefile.am31
-rw-r--r--src/vpn/test_gnunet_vpn.c73
2 files changed, 95 insertions, 9 deletions
diff --git a/src/vpn/Makefile.am b/src/vpn/Makefile.am
index fea89724d..2cd798591 100644
--- a/src/vpn/Makefile.am
+++ b/src/vpn/Makefile.am
@@ -34,7 +34,11 @@ bin_PROGRAMS = \
34 34
35 35
36if HAVE_MHD 36if HAVE_MHD
37 VPN_TEST = test_gnunet_vpn 37 VPN_TEST = \
38 test_gnunet_vpn-4_to_6 \
39 test_gnunet_vpn-6_to_4 \
40 test_gnunet_vpn-6_over \
41 test_gnunet_vpn-4_over
38endif 42endif
39 43
40check_PROGRAMS = $(VPN_TEST) 44check_PROGRAMS = $(VPN_TEST)
@@ -75,9 +79,30 @@ libgnunetvpn_la_LDFLAGS = \
75 $(GN_LIB_LDFLAGS) 79 $(GN_LIB_LDFLAGS)
76 80
77 81
78test_gnunet_vpn_SOURCES = \ 82test_gnunet_vpn_4_over_SOURCES = \
79 test_gnunet_vpn.c 83 test_gnunet_vpn.c
80test_gnunet_vpn_LDADD = -lmicrohttpd @LIBCURL@ \ 84test_gnunet_vpn_4_over_LDADD = -lmicrohttpd @LIBCURL@ \
85 $(top_builddir)/src/vpn/libgnunetvpn.la \
86 $(top_builddir)/src/arm/libgnunetarm.la \
87 $(top_builddir)/src/util/libgnunetutil.la
88
89test_gnunet_vpn_6_over_SOURCES = \
90 test_gnunet_vpn.c
91test_gnunet_vpn_6_over_LDADD = -lmicrohttpd @LIBCURL@ \
92 $(top_builddir)/src/vpn/libgnunetvpn.la \
93 $(top_builddir)/src/arm/libgnunetarm.la \
94 $(top_builddir)/src/util/libgnunetutil.la
95
96test_gnunet_vpn_4_to_6_SOURCES = \
97 test_gnunet_vpn.c
98test_gnunet_vpn_4_to_6_LDADD = -lmicrohttpd @LIBCURL@ \
99 $(top_builddir)/src/vpn/libgnunetvpn.la \
100 $(top_builddir)/src/arm/libgnunetarm.la \
101 $(top_builddir)/src/util/libgnunetutil.la
102
103test_gnunet_vpn_6_to_4_SOURCES = \
104 test_gnunet_vpn.c
105test_gnunet_vpn_6_to_4_LDADD = -lmicrohttpd @LIBCURL@ \
81 $(top_builddir)/src/vpn/libgnunetvpn.la \ 106 $(top_builddir)/src/vpn/libgnunetvpn.la \
82 $(top_builddir)/src/arm/libgnunetarm.la \ 107 $(top_builddir)/src/arm/libgnunetarm.la \
83 $(top_builddir)/src/util/libgnunetutil.la 108 $(top_builddir)/src/util/libgnunetutil.la
diff --git a/src/vpn/test_gnunet_vpn.c b/src/vpn/test_gnunet_vpn.c
index 1e4e2044d..781eae5ec 100644
--- a/src/vpn/test_gnunet_vpn.c
+++ b/src/vpn/test_gnunet_vpn.c
@@ -71,6 +71,22 @@ static CURLM *multi;
71 71
72static char *url; 72static char *url;
73 73
74/**
75 * IP address of the ultimate destination.
76 */
77static const char *dest_ip;
78
79/**
80 * Address family of the dest_ip.
81 */
82static int dest_af;
83
84/**
85 * Address family to use by the curl client.
86 */
87static int src_af;
88
89
74struct CBC 90struct CBC
75{ 91{
76 char buf[1024]; 92 char buf[1024];
@@ -267,10 +283,10 @@ allocation_cb (void *cls,
267 int af, 283 int af,
268 const void *address) 284 const void *address)
269{ 285{
270 char ips[INET_ADDRSTRLEN]; 286 char ips[INET6_ADDRSTRLEN];
271 287
272 rr = NULL; 288 rr = NULL;
273 if (AF_INET != af) 289 if (src_af != af)
274 { 290 {
275 fprintf (stderr, 291 fprintf (stderr,
276 "VPN failed to allocate appropriate address\n"); 292 "VPN failed to allocate appropriate address\n");
@@ -371,20 +387,24 @@ run (void *cls, char *const *args, const char *cfgfile,
371 const struct GNUNET_CONFIGURATION_Handle *cfg) 387 const struct GNUNET_CONFIGURATION_Handle *cfg)
372{ 388{
373 struct in_addr v4; 389 struct in_addr v4;
390 enum MHD_FLAG flags;
374 391
375 vpn = GNUNET_VPN_connect (cfg); 392 vpn = GNUNET_VPN_connect (cfg);
376 GNUNET_assert (NULL != vpn); 393 GNUNET_assert (NULL != vpn);
377 mhd = MHD_start_daemon (MHD_USE_DEBUG, 394 flags = MHD_USE_DEBUG;
395 if (AF_INET6 == dest_af)
396 flags |= MHD_USE_IPv6;
397 mhd = MHD_start_daemon (flags,
378 PORT, 398 PORT,
379 NULL, NULL, 399 NULL, NULL,
380 &mhd_ahc, NULL, 400 &mhd_ahc, NULL,
381 MHD_OPTION_END); 401 MHD_OPTION_END);
382 GNUNET_assert (NULL != mhd); 402 GNUNET_assert (NULL != mhd);
383 mhd_main (); 403 mhd_main ();
384 GNUNET_assert (1 == inet_pton (AF_INET, "169.254.86.1", &v4)); 404 GNUNET_assert (1 == inet_pton (dest_af, dest_ip, &v4));
385 rr = GNUNET_VPN_redirect_to_ip (vpn, 405 rr = GNUNET_VPN_redirect_to_ip (vpn,
386 AF_INET, 406 src_af,
387 AF_INET, 407 dest_af,
388 &v4, 408 &v4,
389 GNUNET_YES, 409 GNUNET_YES,
390 GNUNET_TIME_UNIT_FOREVER_ABS, 410 GNUNET_TIME_UNIT_FOREVER_ABS,
@@ -436,6 +456,8 @@ stop_peer (struct PeerContext *p)
436int 456int
437main (int argc, char *const *argv) 457main (int argc, char *const *argv)
438{ 458{
459 const char *type;
460 const char *bin;
439 char *const argvx[] = { 461 char *const argvx[] = {
440 "test_gnunet_vpn", 462 "test_gnunet_vpn",
441 "-c", 463 "-c",
@@ -448,6 +470,45 @@ main (int argc, char *const *argv)
448 struct GNUNET_GETOPT_CommandLineOption options[] = { 470 struct GNUNET_GETOPT_CommandLineOption options[] = {
449 GNUNET_GETOPT_OPTION_END 471 GNUNET_GETOPT_OPTION_END
450 }; 472 };
473 bin = argv[0];
474 if (NULL != strstr (bin, "lt-"))
475 bin = strstr (bin, "lt-") + 4;
476 type = strstr (bin, "-");
477 if (NULL == type)
478 {
479 fprintf (stderr, "invalid binary name\n");
480 return 1;
481 }
482 type++;
483 if (0 == strcmp (type, "4_to_6"))
484 {
485 dest_ip = "FC5A:04E1:C2BA::1";
486 dest_af = AF_INET6;
487 src_af = AF_INET;
488 }
489 else if (0 == strcmp (type, "6_to_4"))
490 {
491 dest_ip = "169.254.86.1";
492 dest_af = AF_INET;
493 src_af = AF_INET6;
494 }
495 else if (0 == strcmp (type, "4_over"))
496 {
497 dest_ip = "169.254.86.1";
498 dest_af = AF_INET;
499 src_af = AF_INET;
500 }
501 else if (0 == strcmp (type, "6_over"))
502 {
503 dest_ip = "FC5A:04E1:C2BA::1";
504 dest_af = AF_INET6;
505 src_af = AF_INET6;
506 }
507 else
508 {
509 fprintf (stderr, "invalid binary suffix `%s'\n", type);
510 return 1;
511 }
451 512
452 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 513 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
453 return 2; 514 return 2;