diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-09-28 21:44:38 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-09-28 21:44:38 +0000 |
commit | 23376d0a8b9d0937f2335dd9f74343f696530d9b (patch) | |
tree | d7a986801e8cbde68ebb6ed88a7fdc2f502442d0 | |
parent | 13ef2b932d9ebc78d20e9de6d3f0c831f892c4df (diff) |
Allow pppd to change interface addr when demand dialing & dynamic addressing.
Fix from Dave Huang <khym@bga.com> based on what ifconfig does.
-rw-r--r-- | usr.sbin/pppd/sys-bsd.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c index 3ded09d9a2a..d307cc32778 100644 --- a/usr.sbin/pppd/sys-bsd.c +++ b/usr.sbin/pppd/sys-bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys-bsd.c,v 1.8 1997/09/05 04:32:45 millert Exp $ */ +/* $OpenBSD: sys-bsd.c,v 1.9 1997/09/28 21:44:37 millert Exp $ */ /* * sys-bsd.c - System-dependent procedures for setting up @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = "Id: sys-bsd.c,v 1.28 1997/04/30 05:57:46 paulus Exp"; #else -static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.8 1997/09/05 04:32:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.9 1997/09/28 21:44:37 millert Exp $"; #endif #endif @@ -1062,6 +1062,7 @@ sifaddr(u, o, h, m) u_int32_t o, h, m; { struct ifaliasreq ifra; + struct ifreq ifr; strncpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name) - 1); ifra.ifra_name[sizeof(ifra.ifra_name) - 1] = '\0'; @@ -1074,6 +1075,13 @@ sifaddr(u, o, h, m) ((struct sockaddr_in *) &ifra.ifra_mask)->sin_addr.s_addr = m; } else BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask)); + BZERO(&ifr, sizeof(ifr)); + strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); + ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; + if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifr) < 0) { + if (errno != EADDRNOTAVAIL) + syslog(LOG_WARNING, "Couldn't remove interface address: %m"); + } if (ioctl(sockfd, SIOCAIFADDR, (caddr_t) &ifra) < 0) { if (errno != EEXIST) { syslog(LOG_ERR, "Couldn't set interface address: %m"); |