Lines 165-170
Link Here
|
165 |
|
165 |
|
166 |
#endif /* INET6 */ |
166 |
#endif /* INET6 */ |
167 |
|
167 |
|
|
|
168 |
#ifndef SIOCKILLADDR |
169 |
#define SIOCKILLADDR 0x8939 |
170 |
#endif |
171 |
|
168 |
/* We can get an EIO error on an ioctl if the modem has hung up */ |
172 |
/* We can get an EIO error on an ioctl if the modem has hung up */ |
169 |
#define ok_error(num) ((num)==EIO) |
173 |
#define ok_error(num) ((num)==EIO) |
170 |
|
174 |
|
Lines 209-214
Link Here
|
209 |
static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */ |
213 |
static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */ |
210 |
static char proxy_arp_dev[16]; /* Device for proxy arp entry */ |
214 |
static char proxy_arp_dev[16]; /* Device for proxy arp entry */ |
211 |
static u_int32_t our_old_addr; /* for detecting address changes */ |
215 |
static u_int32_t our_old_addr; /* for detecting address changes */ |
|
|
216 |
static u_int32_t our_current_addr; |
212 |
static int dynaddr_set; /* 1 if ip_dynaddr set */ |
217 |
static int dynaddr_set; /* 1 if ip_dynaddr set */ |
213 |
static int looped; /* 1 if using loop */ |
218 |
static int looped; /* 1 if using loop */ |
214 |
static int link_mtu; /* mtu for the link (not bundle) */ |
219 |
static int link_mtu; /* mtu for the link (not bundle) */ |
Lines 537-542
Link Here
|
537 |
return -1; |
542 |
return -1; |
538 |
} |
543 |
} |
539 |
|
544 |
|
|
|
545 |
static void do_killaddr(u_int32_t oldaddr) |
546 |
{ |
547 |
struct ifreq ifr; |
548 |
|
549 |
memset(&ifr,0,sizeof ifr); |
550 |
|
551 |
SET_SA_FAMILY (ifr.ifr_addr, AF_INET); |
552 |
SET_SA_FAMILY (ifr.ifr_dstaddr, AF_INET); |
553 |
SET_SA_FAMILY (ifr.ifr_netmask, AF_INET); |
554 |
|
555 |
SIN_ADDR(ifr.ifr_addr) = oldaddr; |
556 |
|
557 |
strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); |
558 |
|
559 |
if(ioctl(sock_fd,SIOCKILLADDR,&ifr) < 0) { |
560 |
if (!ok_error (errno)) |
561 |
error("ioctl(SIOCKILLADDR): %m(%d)", errno); |
562 |
return; |
563 |
} |
564 |
} |
565 |
|
540 |
/******************************************************************** |
566 |
/******************************************************************** |
541 |
* |
567 |
* |
542 |
* tty_disestablish_ppp - Restore the serial port to normal operation. |
568 |
* tty_disestablish_ppp - Restore the serial port to normal operation. |
Lines 2366-2386
Link Here
|
2366 |
} |
2392 |
} |
2367 |
} |
2393 |
} |
2368 |
|
2394 |
|
2369 |
/* set ip_dynaddr in demand mode if address changes */ |
2395 |
if(persist && our_old_addr && our_old_addr != our_adr) { |
2370 |
if (demand && tune_kernel && !dynaddr_set |
2396 |
|
2371 |
&& our_old_addr && our_old_addr != our_adr) { |
2397 |
if(killoldaddr) |
|
|
2398 |
do_killaddr(our_old_addr); |
2399 |
|
2400 |
|
2401 |
/* set ip_dynaddr in persist mode if address changes */ |
2402 |
if (tune_kernel && !dynaddr_set) { |
2372 |
/* set ip_dynaddr if possible */ |
2403 |
/* set ip_dynaddr if possible */ |
2373 |
char *path; |
2404 |
char *path; |
2374 |
int fd; |
2405 |
int fd; |
2375 |
|
2406 |
|
2376 |
path = path_to_procfs("/sys/net/ipv4/ip_dynaddr"); |
2407 |
path = path_to_procfs("/sys/net/ipv4/ip_dynaddr"); |
2377 |
if (path != 0 && (fd = open(path, O_WRONLY)) >= 0) { |
2408 |
if (path != 0 && (fd = open(path, O_WRONLY)) >= 0) { |
2378 |
if (write(fd, "1", 1) != 1) |
2409 |
if (write(fd, "1", 1) != 1) |
2379 |
error("Couldn't enable dynamic IP addressing: %m"); |
2410 |
error("Couldn't enable dynamic IP addressing: %m"); |
2380 |
close(fd); |
2411 |
close(fd); |
2381 |
} |
2412 |
} |
2382 |
dynaddr_set = 1; /* only 1 attempt */ |
2413 |
dynaddr_set = 1; /* only 1 attempt */ |
|
|
2414 |
} |
2383 |
} |
2415 |
} |
|
|
2416 |
|
2417 |
our_current_addr = our_adr; |
2384 |
our_old_addr = 0; |
2418 |
our_old_addr = 0; |
2385 |
|
2419 |
|
2386 |
return 1; |
2420 |
return 1; |
Lines 2436-2442
Link Here
|
2436 |
} |
2470 |
} |
2437 |
|
2471 |
|
2438 |
our_old_addr = our_adr; |
2472 |
our_old_addr = our_adr; |
2439 |
|
2473 |
our_current_addr = 0; |
|
|
2474 |
|
2440 |
return 1; |
2475 |
return 1; |
2441 |
} |
2476 |
} |
2442 |
|
2477 |
|