summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1998-01-08 23:47:10 +0000
committerbrian <brian@cvs.openbsd.org>1998-01-08 23:47:10 +0000
commitc5fbd66c4bb7851c1c1c91b406bb39df6786c3d8 (patch)
tree0510ba40eac121cba657e15dcbd76778a5c40b0b /usr.sbin
parent0439ddaa0b673a6fbae6fda1e4a76655a83c2b8f (diff)
Zap any addresses on the network side of the `tun' as soon
as we've successfully opened the /dev side.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/main.c3
-rw-r--r--usr.sbin/ppp/os.c37
-rw-r--r--usr.sbin/ppp/os.h3
3 files changed, 40 insertions, 3 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index d75e844936c..1a0536652a5 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.11 1997/12/30 23:22:37 brian Exp $
+ * $Id: main.c,v 1.12 1998/01/08 23:47:08 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@@ -428,6 +428,7 @@ main(int argc, char **argv)
LogPrintf(LogWARN, "OpenTunnel: %s\n", strerror(errno));
return EX_START;
}
+ CleanInterface(IfDevName);
if (mode & MODE_INTER)
fprintf(VarTerm, "Interactive mode\n");
else if ((mode & MODE_OUTGOING_DAEMON) && !(mode & MODE_DEDICATED))
diff --git a/usr.sbin/ppp/os.c b/usr.sbin/ppp/os.c
index ccf8c29d3c8..6d74a8e454c 100644
--- a/usr.sbin/ppp/os.c
+++ b/usr.sbin/ppp/os.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: os.c,v 1.4 1997/12/24 09:30:44 brian Exp $
+ * $Id: os.c,v 1.5 1998/01/08 23:47:08 brian Exp $
*
*/
#include <sys/param.h>
@@ -171,6 +171,41 @@ SetIpDevice(struct in_addr myaddr,
}
int
+CleanInterface(const char *name)
+{
+ int s;
+
+ s = ID0socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ LogPrintf(LogERROR, "SetIpDevice: socket(): %s\n", strerror(errno));
+ return (-1);
+ }
+ strncpy(ifrq.ifr_name, name, sizeof ifrq.ifr_name - 1);
+ ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0';
+ while (ID0ioctl(s, SIOCGIFADDR, &ifrq) == 0) {
+ memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask);
+ ifra.ifra_addr = ifrq.ifr_addr;
+ if (ID0ioctl(s, SIOCGIFDSTADDR, &ifrq) < 0) {
+ if (ifra.ifra_addr.sa_family == AF_INET)
+ LogPrintf(LogERROR, "tun_configure: Can't get dst for %s on %s !\n",
+ inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr),
+ name);
+ return 0;
+ }
+ ifra.ifra_broadaddr = ifrq.ifr_dstaddr;
+ if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) {
+ if (ifra.ifra_addr.sa_family == AF_INET)
+ LogPrintf(LogERROR, "tun_configure: Can't delete %s address on %s !\n",
+ inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr),
+ name);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+int
OsTrySetIpaddress(struct in_addr myaddr, struct in_addr hisaddr)
{
return (SetIpDevice(myaddr, hisaddr, ifnetmask, SET_TRY));
diff --git a/usr.sbin/ppp/os.h b/usr.sbin/ppp/os.h
index 65d3cb83c99..3197b2968e3 100644
--- a/usr.sbin/ppp/os.h
+++ b/usr.sbin/ppp/os.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: os.h,v 1.2 1997/12/15 22:44:55 brian Exp $
+ * $Id: os.h,v 1.3 1998/01/08 23:47:09 brian Exp $
*
* TODO:
*/
@@ -29,3 +29,4 @@ extern int OpenTunnel(int *);
extern void OsLinkup(void);
extern int OsLinkIsUp(void);
extern void OsLinkdown(void);
+extern int CleanInterface(const char *);