gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r19413 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r19413 - gnunet/src/vpn
Date: Wed, 25 Jan 2012 22:26:27 +0100

Author: grothoff
Date: 2012-01-25 22:26:27 +0100 (Wed, 25 Jan 2012)
New Revision: 19413

Modified:
   gnunet/src/vpn/Makefile.am
   gnunet/src/vpn/test_gnunet_vpn.c
Log:
-expanding tests to cover 4-to-6, 6-to-4 and 6-over-4 as well

Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am  2012-01-25 21:08:59 UTC (rev 19412)
+++ gnunet/src/vpn/Makefile.am  2012-01-25 21:26:27 UTC (rev 19413)
@@ -34,7 +34,11 @@
 
 
 if HAVE_MHD
- VPN_TEST = test_gnunet_vpn
+ VPN_TEST = \
+ test_gnunet_vpn-4_to_6 \
+ test_gnunet_vpn-6_to_4 \
+ test_gnunet_vpn-6_over \
+ test_gnunet_vpn-4_over
 endif
 
 check_PROGRAMS = $(VPN_TEST)
@@ -75,9 +79,30 @@
   $(GN_LIB_LDFLAGS)
 
 
-test_gnunet_vpn_SOURCES = \
+test_gnunet_vpn_4_over_SOURCES = \
  test_gnunet_vpn.c
-test_gnunet_vpn_LDADD = -lmicrohttpd @LIBCURL@ \
+test_gnunet_vpn_4_over_LDADD = -lmicrohttpd @LIBCURL@ \
  $(top_builddir)/src/vpn/libgnunetvpn.la \
  $(top_builddir)/src/arm/libgnunetarm.la \
  $(top_builddir)/src/util/libgnunetutil.la 
+
+test_gnunet_vpn_6_over_SOURCES = \
+ test_gnunet_vpn.c
+test_gnunet_vpn_6_over_LDADD = -lmicrohttpd @LIBCURL@ \
+ $(top_builddir)/src/vpn/libgnunetvpn.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
+
+test_gnunet_vpn_4_to_6_SOURCES = \
+ test_gnunet_vpn.c
+test_gnunet_vpn_4_to_6_LDADD = -lmicrohttpd @LIBCURL@ \
+ $(top_builddir)/src/vpn/libgnunetvpn.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
+
+test_gnunet_vpn_6_to_4_SOURCES = \
+ test_gnunet_vpn.c
+test_gnunet_vpn_6_to_4_LDADD = -lmicrohttpd @LIBCURL@ \
+ $(top_builddir)/src/vpn/libgnunetvpn.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la 

Modified: gnunet/src/vpn/test_gnunet_vpn.c
===================================================================
--- gnunet/src/vpn/test_gnunet_vpn.c    2012-01-25 21:08:59 UTC (rev 19412)
+++ gnunet/src/vpn/test_gnunet_vpn.c    2012-01-25 21:26:27 UTC (rev 19413)
@@ -71,6 +71,22 @@
 
 static char *url;
 
+/**
+ * IP address of the ultimate destination.
+ */
+static const char *dest_ip;
+
+/**
+ * Address family of the dest_ip.
+ */
+static int dest_af;
+
+/**
+ * Address family to use by the curl client.
+ */
+static int src_af;
+
+
 struct CBC
 {
   char buf[1024];
@@ -267,10 +283,10 @@
               int af,
               const void *address)
 {
-  char ips[INET_ADDRSTRLEN];
+  char ips[INET6_ADDRSTRLEN];
 
   rr = NULL;
-  if (AF_INET != af)
+  if (src_af != af)
   {
     fprintf (stderr, 
             "VPN failed to allocate appropriate address\n");
@@ -371,20 +387,24 @@
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct in_addr v4;
+  enum MHD_FLAG flags;
 
   vpn = GNUNET_VPN_connect (cfg);
   GNUNET_assert (NULL != vpn); 
-  mhd = MHD_start_daemon (MHD_USE_DEBUG,
+  flags = MHD_USE_DEBUG;
+  if (AF_INET6 == dest_af)
+    flags |= MHD_USE_IPv6;
+  mhd = MHD_start_daemon (flags,
                          PORT,
                          NULL, NULL,
                          &mhd_ahc, NULL,
                          MHD_OPTION_END);
   GNUNET_assert (NULL != mhd);
   mhd_main ();
-  GNUNET_assert (1 == inet_pton (AF_INET, "169.254.86.1", &v4));
+  GNUNET_assert (1 == inet_pton (dest_af, dest_ip, &v4));
   rr = GNUNET_VPN_redirect_to_ip (vpn,
-                                 AF_INET,
-                                 AF_INET,
+                                 src_af,
+                                 dest_af,
                                  &v4,
                                  GNUNET_YES,
                                  GNUNET_TIME_UNIT_FOREVER_ABS,
@@ -436,6 +456,8 @@
 int
 main (int argc, char *const *argv)
 {
+  const char *type;
+  const char *bin;
   char *const argvx[] = {
     "test_gnunet_vpn",
     "-c",
@@ -448,6 +470,45 @@
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
+  bin = argv[0];
+  if (NULL != strstr (bin, "lt-"))
+    bin = strstr (bin, "lt-") + 4;
+  type = strstr (bin, "-");
+  if (NULL == type)
+  {
+    fprintf (stderr, "invalid binary name\n");
+    return 1;
+  }
+  type++;
+  if (0 == strcmp (type, "4_to_6"))
+  {
+    dest_ip = "FC5A:04E1:C2BA::1";
+    dest_af = AF_INET6;
+    src_af = AF_INET;
+  } 
+  else if (0 == strcmp (type, "6_to_4"))
+  {
+    dest_ip = "169.254.86.1";
+    dest_af = AF_INET;
+    src_af = AF_INET6;
+  } 
+  else if (0 == strcmp (type, "4_over"))
+  {
+    dest_ip = "169.254.86.1";
+    dest_af = AF_INET;
+    src_af = AF_INET;
+  } 
+  else if (0 == strcmp (type, "6_over"))
+  {
+    dest_ip = "FC5A:04E1:C2BA::1";
+    dest_af = AF_INET6;
+    src_af = AF_INET6;
+  }
+  else
+  {
+    fprintf (stderr, "invalid binary suffix `%s'\n", type);
+    return 1;
+  }
 
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
     return 2;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]