diff options
author | brian <brian@FreeBSD.org> | 1997-12-07 04:09:15 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-12-07 04:09:15 +0000 |
commit | 1a5893522dca2ac497646830f3ace6242210e60c (patch) | |
tree | 2cb5b6de0d9b4ba666c8319391dbe82a6f7a0cfe /usr.sbin/ppp/command.c | |
parent | d1f6ae4ce34df5a70d63e6d996f9bb89d98a2f54 (diff) | |
download | FreeBSD-src-1a5893522dca2ac497646830f3ace6242210e60c.zip FreeBSD-src-1a5893522dca2ac497646830f3ace6242210e60c.tar.gz |
Only allow one arg to `delete' - the mask & gateway aren't necessary.
Delete AF_LINK routes as well as AF_INET.
Allow the word `default' as the arg to `delete' or in place of the
first two args (dest & netmask) to `add'.
Accept INTERFACE as the third arg to `add'.
You can now say `add default interface' to create a default route
through the tun interface. It's reported that subsequent bind()s
will bind to a broadcast address and not to the address currently
assigned to the tun device - this is the first step towards
supporting that first connection that was around from before the
dynamic IP negotiation....
Diffstat (limited to 'usr.sbin/ppp/command.c')
-rw-r--r-- | usr.sbin/ppp/command.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 35d30fd..5e7912c 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.105 1997/11/22 03:37:28 brian Exp $ + * $Id: command.c,v 1.106 1997/11/23 20:05:18 brian Exp $ * */ #include <sys/param.h> @@ -1461,51 +1461,55 @@ static int AddCommand(struct cmdargs const *arg) { struct in_addr dest, gateway, netmask; + int gw; - if (arg->argc == 3) { + if (arg->argc != 3 && arg->argc != 2) + return -1; + + if (arg->argc == 2) + if (strcasecmp(arg->argv[0], "default")) + return -1; + else { + dest.s_addr = netmask.s_addr = INADDR_ANY; + gw = 1; + } + else { if (strcasecmp(arg->argv[0], "MYADDR") == 0) dest = IpcpInfo.want_ipaddr; else dest = GetIpAddr(arg->argv[0]); netmask = GetIpAddr(arg->argv[1]); - if (strcasecmp(arg->argv[2], "HISADDR") == 0) - gateway = IpcpInfo.his_ipaddr; - else - gateway = GetIpAddr(arg->argv[2]); - OsSetRoute(RTM_ADD, dest, gateway, netmask); - return 0; + gw = 2; } - return -1; + if (strcasecmp(arg->argv[gw], "HISADDR") == 0) + gateway = IpcpInfo.his_ipaddr; + else if (strcasecmp(arg->argv[gw], "INTERFACE") == 0) + gateway.s_addr = INADDR_ANY; + else + gateway = GetIpAddr(arg->argv[gw]); + OsSetRoute(RTM_ADD, dest, gateway, netmask); + return 0; } static int DeleteCommand(struct cmdargs const *arg) { - struct in_addr dest, gateway, netmask; + struct in_addr dest, none; - if (arg->argc == 1 && strcasecmp(arg->argv[0], "all") == 0) - DeleteIfRoutes(0); - else if (arg->argc > 0 && arg->argc < 4) { - if (strcasecmp(arg->argv[0], "MYADDR") == 0) - dest = IpcpInfo.want_ipaddr; - else - dest = GetIpAddr(arg->argv[0]); - netmask.s_addr = INADDR_ANY; - if (arg->argc > 1) { - if (strcasecmp(arg->argv[1], "HISADDR") == 0) - gateway = IpcpInfo.his_ipaddr; + if (arg->argc == 1) + if(strcasecmp(arg->argv[0], "all") == 0) + DeleteIfRoutes(0); + else { + if (strcasecmp(arg->argv[0], "MYADDR") == 0) + dest = IpcpInfo.want_ipaddr; + else if (strcasecmp(arg->argv[0], "default") == 0) + dest.s_addr = INADDR_ANY; else - gateway = GetIpAddr(arg->argv[1]); - if (arg->argc == 3) { - if (inet_aton(arg->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 + dest = GetIpAddr(arg->argv[0]); + none.s_addr = INADDR_ANY; + OsSetRoute(RTM_DELETE, dest, none, none); + } + else return -1; return 0; |