mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Fix "delete ...", it now only insists on
one arg too. Discovered by: Rikk Salamat <rikks@web-impact.com>
This commit is contained in:
parent
94b3022ec7
commit
e696ee3b80
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26591
@ -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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
OsSetRoute(RTM_DELETE, dest, gateway, netmask);
|
||||
} else if (argc == 1 && strcasecmp(argv[0], "all") == 0) {
|
||||
if (argc == 1 && strcasecmp(argv[0], "all") == 0)
|
||||
DeleteIfRoutes(0);
|
||||
else if (argc > 0 && argc < 4) {
|
||||
dest = GetIpAddr(argv[0]);
|
||||
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
|
||||
return -1;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user