aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exit/gnunet-daemon-exit.c44
-rw-r--r--src/exit/gnunet-helper-exit.c2
-rw-r--r--src/vpn/gnunet-helper-vpn.c10
-rw-r--r--src/vpn/gnunet-service-vpn.c134
4 files changed, 140 insertions, 50 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 99dec5ea07..a956bfa1a7 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -2949,6 +2949,31 @@ read_service_conf (void *cls GNUNET_UNUSED, const char *section)
/**
+ * Test if the given AF is supported by this system.
+ *
+ * @param af to test
+ * @return GNUNET_OK if the AF is supported
+ */
+static int
+test_af (int af)
+{
+ int s;
+
+ s = socket (af, SOCK_STREAM, 0);
+ if (-1 == s)
+ {
+ if (EAFNOSUPPORT == errno)
+ return GNUNET_NO;
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
+ "socket");
+ return GNUNET_SYSERR;
+ }
+ close (s);
+ return GNUNET_OK;
+}
+
+
+/**
* @brief Main function that will be run by the scheduler.
*
* @param cls closure
@@ -3000,6 +3025,23 @@ run (void *cls, char *const *args GNUNET_UNUSED,
ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6");
ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4");
ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6");
+
+ if ( (ipv4_exit || ipv4_enabled) &&
+ GNUNET_OK != test_af (AF_INET))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("This system does not support IPv4, will disable IPv4 functions despite them being enabled in the configuration\n"));
+ ipv4_exit = GNUNET_NO;
+ ipv4_enabled = GNUNET_NO;
+ }
+ if ( (ipv6_exit || ipv6_enabled) &&
+ GNUNET_OK != test_af (AF_INET6))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("This system does not support IPv6, will disable IPv6 functions despite them being enabled in the configuration\n"));
+ ipv6_exit = GNUNET_NO;
+ ipv6_enabled = GNUNET_NO;
+ }
if (ipv4_exit && (! ipv4_enabled))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -3063,6 +3105,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
{
exit_argv[2] = GNUNET_strdup ("%");
}
+
+
if (GNUNET_YES == ipv6_enabled)
{
if ( (GNUNET_SYSERR ==
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c
index 518bebfc4f..573bb7a502 100644
--- a/src/exit/gnunet-helper-exit.c
+++ b/src/exit/gnunet-helper-exit.c
@@ -226,7 +226,7 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len)
if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0)))
{
- fprintf (stderr, "Error creating socket: %s\n", strerror (errno));
+ fprintf (stderr, "Error creating socket: %s\n", strerror (errno));
exit (1);
}
diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c
index 5a1b708e24..5903255f88 100644
--- a/src/vpn/gnunet-helper-vpn.c
+++ b/src/vpn/gnunet-helper-vpn.c
@@ -530,10 +530,10 @@ PROCESS_BUFFER:
* @param argc must be 6
* @param argv 0: binary name (gnunet-helper-vpn)
* 1: tunnel interface name (gnunet-vpn)
- * 2: IPv6 address (::1)
- * 3: IPv6 netmask length in bits (64)
- * 4: IPv4 address (1.2.3.4)
- * 5: IPv4 netmask (255.255.0.0)
+ * 2: IPv6 address (::1), "-" to disable
+ * 3: IPv6 netmask length in bits (64), ignored if #2 is "-"
+ * 4: IPv4 address (1.2.3.4), "-" to disable
+ * 5: IPv4 netmask (255.255.0.0), ignored if #4 is "-"
*/
int
main (int argc, char **argv)
@@ -562,6 +562,7 @@ main (int argc, char **argv)
return 1;
}
+ if (0 != strcmp (argv[2], "-"))
{
const char *address = argv[2];
long prefix_len = atol (argv[3]);
@@ -575,6 +576,7 @@ main (int argc, char **argv)
set_address6 (dev, address, prefix_len);
}
+ if (0 != strcmp (argv[4], "-"))
{
const char *address = argv[4];
const char *mask = argv[5];
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 8e6ae655d2..c8ffa8586b 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -2990,6 +2990,31 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
/**
+ * Test if the given AF is supported by this system.
+ *
+ * @param af to test
+ * @return GNUNET_OK if the AF is supported
+ */
+static int
+test_af (int af)
+{
+ int s;
+
+ s = socket (af, SOCK_STREAM, 0);
+ if (-1 == s)
+ {
+ if (EAFNOSUPPORT == errno)
+ return GNUNET_NO;
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
+ "socket");
+ return GNUNET_SYSERR;
+ }
+ close (s);
+ return GNUNET_OK;
+}
+
+
+/**
* Main function that will be run by the scheduler.
*
* @param cls closure
@@ -3062,59 +3087,78 @@ run (void *cls,
return;
}
vpn_argv[1] = ifname;
- if ( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6ADDR",
- &ipv6addr) ||
- (1 != inet_pton (AF_INET6, ipv6addr, &v6))) )
+ if (GNUNET_OK == test_af (AF_INET6))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No valid entry 'IPV6ADDR' in configuration!\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- vpn_argv[2] = ipv6addr;
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6PREFIX",
- &ipv6prefix_s))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No entry 'IPV6PREFIX' in configuration!\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
+ if ( (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6ADDR",
+ &ipv6addr) ||
+ (1 != inet_pton (AF_INET6, ipv6addr, &v6))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No valid entry 'IPV6ADDR' in configuration!\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ vpn_argv[2] = ipv6addr;
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6PREFIX",
+ &ipv6prefix_s))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No entry 'IPV6PREFIX' in configuration!\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ vpn_argv[3] = ipv6prefix_s;
+ if ( (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "vpn",
+ "IPV6PREFIX",
+ &ipv6prefix)) ||
+ (ipv6prefix >= 127) )
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
}
- vpn_argv[3] = ipv6prefix_s;
- if ( (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, "vpn",
- "IPV6PREFIX",
- &ipv6prefix)) ||
- (ipv6prefix >= 127) )
+ else
{
- GNUNET_SCHEDULER_shutdown ();
- return;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("IPv6 support disabled as this system does not support IPv6\n"));
+ vpn_argv[2] = GNUNET_strdup ("-");
+ vpn_argv[3] = GNUNET_strdup ("-");
}
-
- if ( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4ADDR",
- &ipv4addr) ||
- (1 != inet_pton (AF_INET, ipv4addr, &v4))) )
+ if (GNUNET_OK == test_af (AF_INET))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No valid entry for 'IPV4ADDR' in configuration!\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
+ if ( (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4ADDR",
+ &ipv4addr) ||
+ (1 != inet_pton (AF_INET, ipv4addr, &v4))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No valid entry for 'IPV4ADDR' in configuration!\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ vpn_argv[4] = ipv4addr;
+ if ( (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4MASK",
+ &ipv4mask) ||
+ (1 != inet_pton (AF_INET, ipv4mask, &v4))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No valid entry 'IPV4MASK' in configuration!\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ vpn_argv[5] = ipv4mask;
}
- vpn_argv[4] = ipv4addr;
- if ( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4MASK",
- &ipv4mask) ||
- (1 != inet_pton (AF_INET, ipv4mask, &v4))) )
+ else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No valid entry 'IPV4MASK' in configuration!\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("IPv4 support disabled as this system does not support IPv4\n"));
+ vpn_argv[4] = GNUNET_strdup ("-");
+ vpn_argv[5] = GNUNET_strdup ("-");
}
- vpn_argv[5] = ipv4mask;
vpn_argv[6] = NULL;
mesh_handle =