diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-30 21:21:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-30 21:21:49 +0000 |
commit | 77c03065a39f869a188b4e2e8cd6a88dc7a02fc8 (patch) | |
tree | cdce3e214df170eaa8106459a44fc2a82b70a629 /src/exit | |
parent | 84dc557dc24e981d8c9a85b1bb087a4d803225a4 (diff) | |
download | gnunet-77c03065a39f869a188b4e2e8cd6a88dc7a02fc8.tar.gz gnunet-77c03065a39f869a188b4e2e8cd6a88dc7a02fc8.zip |
-also run if system does not support IPv4 or IPv6 at all - #2123
Diffstat (limited to 'src/exit')
-rw-r--r-- | src/exit/gnunet-daemon-exit.c | 44 | ||||
-rw-r--r-- | src/exit/gnunet-helper-exit.c | 2 |
2 files changed, 45 insertions, 1 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 99dec5ea0..a956bfa1a 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) | |||
2949 | 2949 | ||
2950 | 2950 | ||
2951 | /** | 2951 | /** |
2952 | * Test if the given AF is supported by this system. | ||
2953 | * | ||
2954 | * @param af to test | ||
2955 | * @return GNUNET_OK if the AF is supported | ||
2956 | */ | ||
2957 | static int | ||
2958 | test_af (int af) | ||
2959 | { | ||
2960 | int s; | ||
2961 | |||
2962 | s = socket (af, SOCK_STREAM, 0); | ||
2963 | if (-1 == s) | ||
2964 | { | ||
2965 | if (EAFNOSUPPORT == errno) | ||
2966 | return GNUNET_NO; | ||
2967 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
2968 | "socket"); | ||
2969 | return GNUNET_SYSERR; | ||
2970 | } | ||
2971 | close (s); | ||
2972 | return GNUNET_OK; | ||
2973 | } | ||
2974 | |||
2975 | |||
2976 | /** | ||
2952 | * @brief Main function that will be run by the scheduler. | 2977 | * @brief Main function that will be run by the scheduler. |
2953 | * | 2978 | * |
2954 | * @param cls closure | 2979 | * @param cls closure |
@@ -3000,6 +3025,23 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
3000 | ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6"); | 3025 | ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6"); |
3001 | ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4"); | 3026 | ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4"); |
3002 | ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6"); | 3027 | ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6"); |
3028 | |||
3029 | if ( (ipv4_exit || ipv4_enabled) && | ||
3030 | GNUNET_OK != test_af (AF_INET)) | ||
3031 | { | ||
3032 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
3033 | _("This system does not support IPv4, will disable IPv4 functions despite them being enabled in the configuration\n")); | ||
3034 | ipv4_exit = GNUNET_NO; | ||
3035 | ipv4_enabled = GNUNET_NO; | ||
3036 | } | ||
3037 | if ( (ipv6_exit || ipv6_enabled) && | ||
3038 | GNUNET_OK != test_af (AF_INET6)) | ||
3039 | { | ||
3040 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
3041 | _("This system does not support IPv6, will disable IPv6 functions despite them being enabled in the configuration\n")); | ||
3042 | ipv6_exit = GNUNET_NO; | ||
3043 | ipv6_enabled = GNUNET_NO; | ||
3044 | } | ||
3003 | if (ipv4_exit && (! ipv4_enabled)) | 3045 | if (ipv4_exit && (! ipv4_enabled)) |
3004 | { | 3046 | { |
3005 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3047 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -3063,6 +3105,8 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
3063 | { | 3105 | { |
3064 | exit_argv[2] = GNUNET_strdup ("%"); | 3106 | exit_argv[2] = GNUNET_strdup ("%"); |
3065 | } | 3107 | } |
3108 | |||
3109 | |||
3066 | if (GNUNET_YES == ipv6_enabled) | 3110 | if (GNUNET_YES == ipv6_enabled) |
3067 | { | 3111 | { |
3068 | if ( (GNUNET_SYSERR == | 3112 | if ( (GNUNET_SYSERR == |
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c index 518bebfc4..573bb7a50 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) | |||
226 | 226 | ||
227 | if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0))) | 227 | if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0))) |
228 | { | 228 | { |
229 | fprintf (stderr, "Error creating socket: %s\n", strerror (errno)); | 229 | fprintf (stderr, "Error creating socket: %s\n", strerror (errno)); |
230 | exit (1); | 230 | exit (1); |
231 | } | 231 | } |
232 | 232 | ||