aboutsummaryrefslogtreecommitdiff
path: root/src/exit/gnunet-daemon-exit.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-19 21:53:15 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-19 21:53:15 +0000
commit1f74c14aa117afe2395e3ab0d7e53498504d0bc3 (patch)
tree900427f19f66a4d8346ab9ebf76ad397943b6efc /src/exit/gnunet-daemon-exit.c
parent657ca4de06f6c8d4e48b766f03264ac39f55c817 (diff)
downloadgnunet-1f74c14aa117afe2395e3ab0d7e53498504d0bc3.tar.gz
gnunet-1f74c14aa117afe2395e3ab0d7e53498504d0bc3.zip
-fix renumbering crash
Diffstat (limited to 'src/exit/gnunet-daemon-exit.c')
-rw-r--r--src/exit/gnunet-daemon-exit.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index b4edcad91..c437afac2 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -235,11 +235,27 @@ static struct GNUNET_HELPER_Handle *helper_handle;
235static char *exit_argv[7]; 235static char *exit_argv[7];
236 236
237/** 237/**
238 * IPv6 address of our TUN interface.
239 */
240static struct in6_addr exit_ipv6addr;
241
242/**
238 * IPv6 prefix (0..127) from configuration file. 243 * IPv6 prefix (0..127) from configuration file.
239 */ 244 */
240static unsigned long long ipv6prefix; 245static unsigned long long ipv6prefix;
241 246
242/** 247/**
248 * IPv4 address of our TUN interface.
249 */
250static struct in_addr exit_ipv4addr;
251
252/**
253 * IPv4 netmask of our TUN interface.
254 */
255static struct in_addr exit_ipv4mask;
256
257
258/**
243 * Statistics. 259 * Statistics.
244 */ 260 */
245static struct GNUNET_STATISTICS_Handle *stats; 261static struct GNUNET_STATISTICS_Handle *stats;
@@ -865,14 +881,12 @@ setup_fresh_address (int af,
865 { 881 {
866 case AF_INET: 882 case AF_INET:
867 { 883 {
868 const char *ipv4addr = exit_argv[4];
869 const char *ipv4mask = exit_argv[5];
870 struct in_addr addr; 884 struct in_addr addr;
871 struct in_addr mask; 885 struct in_addr mask;
872 struct in_addr rnd; 886 struct in_addr rnd;
873 887
874 GNUNET_assert (1 == inet_pton (AF_INET, ipv4addr, &addr)); 888 addr = exit_ipv4addr;
875 GNUNET_assert (1 == inet_pton (AF_INET, ipv4mask, &mask)); 889 mask = exit_ipv4mask;
876 if (0 == ~mask.s_addr) 890 if (0 == ~mask.s_addr)
877 { 891 {
878 /* only one valid IP anyway */ 892 /* only one valid IP anyway */
@@ -895,13 +909,12 @@ setup_fresh_address (int af,
895 break; 909 break;
896 case AF_INET6: 910 case AF_INET6:
897 { 911 {
898 const char *ipv6addr = exit_argv[2];
899 struct in6_addr addr; 912 struct in6_addr addr;
900 struct in6_addr mask; 913 struct in6_addr mask;
901 struct in6_addr rnd; 914 struct in6_addr rnd;
902 int i; 915 int i;
903 916
904 GNUNET_assert (1 == inet_pton (AF_INET6, ipv6addr, &addr)); 917 addr = exit_ipv6addr;
905 GNUNET_assert (ipv6prefix < 128); 918 GNUNET_assert (ipv6prefix < 128);
906 if (ipv6prefix == 127) 919 if (ipv6prefix == 127)
907 { 920 {
@@ -2142,8 +2155,6 @@ run (void *cls, char *const *args GNUNET_UNUSED,
2142 char *ipv6prefix_s; 2155 char *ipv6prefix_s;
2143 char *ipv4addr; 2156 char *ipv4addr;
2144 char *ipv4mask; 2157 char *ipv4mask;
2145 struct in_addr v4;
2146 struct in6_addr v6;
2147 2158
2148 cfg = cfg_; 2159 cfg = cfg_;
2149 stats = GNUNET_STATISTICS_create ("exit", cfg); 2160 stats = GNUNET_STATISTICS_create ("exit", cfg);
@@ -2219,7 +2230,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
2219 if ( (GNUNET_SYSERR == 2230 if ( (GNUNET_SYSERR ==
2220 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6ADDR", 2231 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6ADDR",
2221 &ipv6addr) || 2232 &ipv6addr) ||
2222 (1 != inet_pton (AF_INET6, ipv6addr, &v6))) ) 2233 (1 != inet_pton (AF_INET6, ipv6addr, &exit_ipv6addr))) )
2223 { 2234 {
2224 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2235 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2225 "No valid entry 'IPV6ADDR' in configuration!\n"); 2236 "No valid entry 'IPV6ADDR' in configuration!\n");
@@ -2258,7 +2269,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
2258 if ( (GNUNET_SYSERR == 2269 if ( (GNUNET_SYSERR ==
2259 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", 2270 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR",
2260 &ipv4addr) || 2271 &ipv4addr) ||
2261 (1 != inet_pton (AF_INET, ipv4addr, &v4))) ) 2272 (1 != inet_pton (AF_INET, ipv4addr, &exit_ipv4addr))) )
2262 { 2273 {
2263 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2264 "No valid entry for 'IPV4ADDR' in configuration!\n"); 2275 "No valid entry for 'IPV4ADDR' in configuration!\n");
@@ -2269,7 +2280,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
2269 if ( (GNUNET_SYSERR == 2280 if ( (GNUNET_SYSERR ==
2270 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK", 2281 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK",
2271 &ipv4mask) || 2282 &ipv4mask) ||
2272 (1 != inet_pton (AF_INET, ipv4mask, &v4))) ) 2283 (1 != inet_pton (AF_INET, ipv4mask, &exit_ipv4mask))) )
2273 { 2284 {
2274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2285 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2275 "No valid entry 'IPV4MASK' in configuration!\n"); 2286 "No valid entry 'IPV4MASK' in configuration!\n");