diff options
author | brian <brian@FreeBSD.org> | 1997-06-13 03:59:36 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-06-13 03:59:36 +0000 |
commit | 328f05607739b87e89e82b9a75c64168aa4107e1 (patch) | |
tree | f1feca7aaf4f7cdee76ee3603fab2f4f53431e3f /usr.sbin | |
parent | 1fd5f260cda7f6c95c4ac594c6bf879aeab7e3e4 (diff) | |
download | FreeBSD-src-328f05607739b87e89e82b9a75c64168aa4107e1.zip FreeBSD-src-328f05607739b87e89e82b9a75c64168aa4107e1.tar.gz |
Fix "delete ...", it now only insists on
one arg too.
Discovered by: Rikk Salamat <rikks@web-impact.com>
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/command.c | 31 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp.8 | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp.8.m4 | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/route.c | 24 |
4 files changed, 40 insertions, 23 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index a808669..9d413a7 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -291,7 +291,7 @@ struct cmdtab const Commands[] = { { "close", NULL, CloseCommand, LOCAL_AUTH, "Close connection", "close"}, { "delete", NULL, DeleteCommand, LOCAL_AUTH, - "delete route", "delete ALL | dest gateway [mask]"}, + "delete route", "delete ALL | dest [gateway [mask]]"}, { "deny", NULL, DenyCommand, LOCAL_AUTH, "Deny option request", "deny option .."}, { "dial", "call", DialCommand, LOCAL_AUTH, @@ -1316,22 +1316,25 @@ char **argv; { struct in_addr dest, gateway, netmask; - if (argc >= 2) { + if (argc == 1 && strcasecmp(argv[0], "all") == 0) + DeleteIfRoutes(0); + else if (argc > 0 && argc < 4) { dest = GetIpAddr(argv[0]); - if (strcasecmp(argv[1], "HISADDR") == 0) - gateway = IpcpInfo.his_ipaddr; - else - gateway = GetIpAddr(argv[1]); - netmask.s_addr = 0; - if (argc == 3) { - if (inet_aton(argv[2], &netmask) == 0) { - LogPrintf(LogWARN, "Bad netmask value.\n"); - return -1; + netmask.s_addr = INADDR_ANY; + if (argc > 1) { + if (strcasecmp(argv[1], "HISADDR") == 0) + gateway = IpcpInfo.his_ipaddr; + else + gateway = GetIpAddr(argv[1]); + if (argc == 3) { + if (inet_aton(argv[2], &netmask) == 0) { + LogPrintf(LogWARN, "Bad netmask value.\n"); + return -1; + } } - } + } else + gateway.s_addr = INADDR_ANY; OsSetRoute(RTM_DELETE, dest, gateway, netmask); - } else if (argc == 1 && strcasecmp(argv[0], "all") == 0) { - DeleteIfRoutes(0); } else return -1; diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index b040a05..d36eae3 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.37 1997/06/13 00:04:58 brian Exp $ +.\" $Id: ppp.8,v 1.38 1997/06/13 02:07:32 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -1382,7 +1382,7 @@ machine/network. .It close Close the current connection (but don't quit). -.It delete ALL | dest gateway [mask] +.It delete ALL | dest [gateway [mask]] If .Dq ALL is specified, all entries in the routing table created by diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index b040a05..d36eae3 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.37 1997/06/13 00:04:58 brian Exp $ +.\" $Id: ppp.8,v 1.38 1997/06/13 02:07:32 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -1382,7 +1382,7 @@ machine/network. .It close Close the current connection (but don't quit). -.It delete ALL | dest gateway [mask] +.It delete ALL | dest [gateway [mask]] If .Dq ALL is specified, all entries in the routing table created by diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index 7fcbd49..a88afa3 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.13 1997/05/10 01:22:18 brian Exp $ + * $Id: route.c,v 1.14 1997/06/09 03:27:36 brian Exp $ * */ #include <sys/types.h> @@ -73,8 +73,7 @@ struct in_addr mask; bzero(&rtmes, sizeof(rtmes)); rtmes.m_rtm.rtm_version = RTM_VERSION; rtmes.m_rtm.rtm_type = cmd; - rtmes.m_rtm.rtm_addrs = RTA_DST | RTA_NETMASK; - if (cmd == RTM_ADD) rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; + rtmes.m_rtm.rtm_addrs = RTA_DST | RTA_NETMASK | RTA_GATEWAY; rtmes.m_rtm.rtm_seq = ++seqno; rtmes.m_rtm.rtm_pid = getpid(); rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC; @@ -111,9 +110,24 @@ struct in_addr mask; rtmes.m_rtm.rtm_msglen = nb; wb = write(s, &rtmes, nb); if (wb < 0) { - LogPrintf(LogTCPIP, "Already set route addr dst=%x, gateway=%x\n" - ,dst.s_addr, gateway.s_addr); + LogPrintf(LogTCPIP, "OsSetRoute: Dst = %s\n", inet_ntoa(dst)); + LogPrintf(LogTCPIP, "OsSetRoute: Gateway = %s\n", inet_ntoa(gateway)); + LogPrintf(LogTCPIP, "OsSetRoute: Mask = %s\n", inet_ntoa(mask)); + switch(rtmes.m_rtm.rtm_errno) { + case EEXIST: + LogPrintf(LogTCPIP, "Add route failed: Already exists\n"); + break; + case ESRCH: + LogPrintf(LogTCPIP, "Del route failed: Non-existent\n"); + break; + case ENOBUFS: + default: + LogPrintf(LogTCPIP, "Add/Del route failed: %s\n", + strerror(rtmes.m_rtm.rtm_errno)); + break; + } } + LogPrintf(LogDEBUG, "wrote %d: dst = %x, gateway = %x\n", nb, dst.s_addr, gateway.s_addr); close(s); |