aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-30 21:21:49 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-30 21:21:49 +0000
commit77c03065a39f869a188b4e2e8cd6a88dc7a02fc8 (patch)
treecdce3e214df170eaa8106459a44fc2a82b70a629
parent84dc557dc24e981d8c9a85b1bb087a4d803225a4 (diff)
downloadgnunet-77c03065a39f869a188b4e2e8cd6a88dc7a02fc8.tar.gz
gnunet-77c03065a39f869a188b4e2e8cd6a88dc7a02fc8.zip
-also run if system does not support IPv4 or IPv6 at all - #2123
-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 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 */
2957static int
2958test_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
diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c
index 5a1b708e2..5903255f8 100644
--- a/src/vpn/gnunet-helper-vpn.c
+++ b/src/vpn/gnunet-helper-vpn.c
@@ -530,10 +530,10 @@ PROCESS_BUFFER:
530 * @param argc must be 6 530 * @param argc must be 6
531 * @param argv 0: binary name (gnunet-helper-vpn) 531 * @param argv 0: binary name (gnunet-helper-vpn)
532 * 1: tunnel interface name (gnunet-vpn) 532 * 1: tunnel interface name (gnunet-vpn)
533 * 2: IPv6 address (::1) 533 * 2: IPv6 address (::1), "-" to disable
534 * 3: IPv6 netmask length in bits (64) 534 * 3: IPv6 netmask length in bits (64), ignored if #2 is "-"
535 * 4: IPv4 address (1.2.3.4) 535 * 4: IPv4 address (1.2.3.4), "-" to disable
536 * 5: IPv4 netmask (255.255.0.0) 536 * 5: IPv4 netmask (255.255.0.0), ignored if #4 is "-"
537 */ 537 */
538int 538int
539main (int argc, char **argv) 539main (int argc, char **argv)
@@ -562,6 +562,7 @@ main (int argc, char **argv)
562 return 1; 562 return 1;
563 } 563 }
564 564
565 if (0 != strcmp (argv[2], "-"))
565 { 566 {
566 const char *address = argv[2]; 567 const char *address = argv[2];
567 long prefix_len = atol (argv[3]); 568 long prefix_len = atol (argv[3]);
@@ -575,6 +576,7 @@ main (int argc, char **argv)
575 set_address6 (dev, address, prefix_len); 576 set_address6 (dev, address, prefix_len);
576 } 577 }
577 578
579 if (0 != strcmp (argv[4], "-"))
578 { 580 {
579 const char *address = argv[4]; 581 const char *address = argv[4];
580 const char *mask = argv[5]; 582 const char *mask = argv[5];
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 8e6ae655d..c8ffa8586 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)
2990 2990
2991 2991
2992/** 2992/**
2993 * Test if the given AF is supported by this system.
2994 *
2995 * @param af to test
2996 * @return GNUNET_OK if the AF is supported
2997 */
2998static int
2999test_af (int af)
3000{
3001 int s;
3002
3003 s = socket (af, SOCK_STREAM, 0);
3004 if (-1 == s)
3005 {
3006 if (EAFNOSUPPORT == errno)
3007 return GNUNET_NO;
3008 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
3009 "socket");
3010 return GNUNET_SYSERR;
3011 }
3012 close (s);
3013 return GNUNET_OK;
3014}
3015
3016
3017/**
2993 * Main function that will be run by the scheduler. 3018 * Main function that will be run by the scheduler.
2994 * 3019 *
2995 * @param cls closure 3020 * @param cls closure
@@ -3062,59 +3087,78 @@ run (void *cls,
3062 return; 3087 return;
3063 } 3088 }
3064 vpn_argv[1] = ifname; 3089 vpn_argv[1] = ifname;
3065 if ( (GNUNET_SYSERR == 3090 if (GNUNET_OK == test_af (AF_INET6))
3066 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6ADDR",
3067 &ipv6addr) ||
3068 (1 != inet_pton (AF_INET6, ipv6addr, &v6))) )
3069 { 3091 {
3070 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3092 if ( (GNUNET_SYSERR ==
3071 "No valid entry 'IPV6ADDR' in configuration!\n"); 3093 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6ADDR",
3072 GNUNET_SCHEDULER_shutdown (); 3094 &ipv6addr) ||
3073 return; 3095 (1 != inet_pton (AF_INET6, ipv6addr, &v6))) )
3074 } 3096 {
3075 vpn_argv[2] = ipv6addr; 3097 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3076 if (GNUNET_SYSERR == 3098 "No valid entry 'IPV6ADDR' in configuration!\n");
3077 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6PREFIX", 3099 GNUNET_SCHEDULER_shutdown ();
3078 &ipv6prefix_s)) 3100 return;
3079 { 3101 }
3080 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3102 vpn_argv[2] = ipv6addr;
3081 "No entry 'IPV6PREFIX' in configuration!\n"); 3103 if (GNUNET_SYSERR ==
3082 GNUNET_SCHEDULER_shutdown (); 3104 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6PREFIX",
3083 return; 3105 &ipv6prefix_s))
3106 {
3107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3108 "No entry 'IPV6PREFIX' in configuration!\n");
3109 GNUNET_SCHEDULER_shutdown ();
3110 return;
3111 }
3112 vpn_argv[3] = ipv6prefix_s;
3113 if ( (GNUNET_OK !=
3114 GNUNET_CONFIGURATION_get_value_number (cfg, "vpn",
3115 "IPV6PREFIX",
3116 &ipv6prefix)) ||
3117 (ipv6prefix >= 127) )
3118 {
3119 GNUNET_SCHEDULER_shutdown ();
3120 return;
3121 }
3084 } 3122 }
3085 vpn_argv[3] = ipv6prefix_s; 3123 else
3086 if ( (GNUNET_OK !=
3087 GNUNET_CONFIGURATION_get_value_number (cfg, "vpn",
3088 "IPV6PREFIX",
3089 &ipv6prefix)) ||
3090 (ipv6prefix >= 127) )
3091 { 3124 {
3092 GNUNET_SCHEDULER_shutdown (); 3125 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3093 return; 3126 _("IPv6 support disabled as this system does not support IPv6\n"));
3127 vpn_argv[2] = GNUNET_strdup ("-");
3128 vpn_argv[3] = GNUNET_strdup ("-");
3094 } 3129 }
3095 3130 if (GNUNET_OK == test_af (AF_INET))
3096 if ( (GNUNET_SYSERR ==
3097 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4ADDR",
3098 &ipv4addr) ||
3099 (1 != inet_pton (AF_INET, ipv4addr, &v4))) )
3100 { 3131 {
3101 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3132 if ( (GNUNET_SYSERR ==
3102 "No valid entry for 'IPV4ADDR' in configuration!\n"); 3133 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4ADDR",
3103 GNUNET_SCHEDULER_shutdown (); 3134 &ipv4addr) ||
3104 return; 3135 (1 != inet_pton (AF_INET, ipv4addr, &v4))) )
3136 {
3137 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3138 "No valid entry for 'IPV4ADDR' in configuration!\n");
3139 GNUNET_SCHEDULER_shutdown ();
3140 return;
3141 }
3142 vpn_argv[4] = ipv4addr;
3143 if ( (GNUNET_SYSERR ==
3144 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4MASK",
3145 &ipv4mask) ||
3146 (1 != inet_pton (AF_INET, ipv4mask, &v4))) )
3147 {
3148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3149 "No valid entry 'IPV4MASK' in configuration!\n");
3150 GNUNET_SCHEDULER_shutdown ();
3151 return;
3152 }
3153 vpn_argv[5] = ipv4mask;
3105 } 3154 }
3106 vpn_argv[4] = ipv4addr; 3155 else
3107 if ( (GNUNET_SYSERR ==
3108 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4MASK",
3109 &ipv4mask) ||
3110 (1 != inet_pton (AF_INET, ipv4mask, &v4))) )
3111 { 3156 {
3112 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3157 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3113 "No valid entry 'IPV4MASK' in configuration!\n"); 3158 _("IPv4 support disabled as this system does not support IPv4\n"));
3114 GNUNET_SCHEDULER_shutdown (); 3159 vpn_argv[4] = GNUNET_strdup ("-");
3115 return; 3160 vpn_argv[5] = GNUNET_strdup ("-");
3116 } 3161 }
3117 vpn_argv[5] = ipv4mask;
3118 vpn_argv[6] = NULL; 3162 vpn_argv[6] = NULL;
3119 3163
3120 mesh_handle = 3164 mesh_handle =