Allow /nn specifications in the `add' command.

Suggested by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>

It's now possible to

  add myaddr 127.0.0.1		(add myaddr 255.255.255.255 127.0.0.1)
  add hisaddr/24 hisaddr	(add hisaddr 255.255.255.0 hisaddr)
  add 0 hisaddr			(add 0 0 hisaddr)
  add default hisaddr		(add 0 0 hisaddr)
This commit is contained in:
Brian Somers 1998-05-10 09:26:21 +00:00
parent c0d9a87722
commit 52ff8cacf6
2 changed files with 33 additions and 18 deletions

View File

@ -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.131.2.80 1998/05/08 18:49:53 brian Exp $
* $Id: command.c,v 1.131.2.81 1998/05/08 18:50:14 brian Exp $
*
*/
#include <sys/types.h>
@ -123,7 +123,7 @@
#define NEG_DNS 50
const char Version[] = "2.0-beta";
const char VersionDate[] = "$Date: 1998/05/08 18:49:53 $";
const char VersionDate[] = "$Date: 1998/05/08 18:50:14 $";
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
@ -1436,9 +1436,19 @@ AddCommand(struct cmdargs const *arg)
addrs = 0;
if (arg->argc == arg->argn+2) {
if (strcasecmp(arg->argv[arg->argn], "default"))
return -1;
if (!strcasecmp(arg->argv[arg->argn], "default"))
dest.s_addr = netmask.s_addr = INADDR_ANY;
else {
int width;
if (!ParseAddr(&arg->bundle->ncp.ipcp, 1, arg->argv + arg->argn,
&dest, &netmask, &width))
return -1;
if (!strncasecmp(arg->argv[arg->argn], "MYADDR", 6))
addrs = ROUTE_DSTMYADDR;
else if (!strncasecmp(arg->argv[arg->argn], "HISADDR", 7))
addrs = ROUTE_DSTHISADDR;
}
gw = 1;
} else {
if (strcasecmp(arg->argv[arg->argn], "MYADDR") == 0) {
@ -1452,6 +1462,7 @@ AddCommand(struct cmdargs const *arg)
netmask = GetIpAddr(arg->argv[arg->argn+1]);
gw = 2;
}
if (strcasecmp(arg->argv[arg->argn+gw], "HISADDR") == 0) {
gateway = arg->bundle->ncp.ipcp.peer_ip;
addrs |= ROUTE_GWHISADDR;
@ -1459,9 +1470,11 @@ AddCommand(struct cmdargs const *arg)
gateway.s_addr = INADDR_ANY;
else
gateway = GetIpAddr(arg->argv[arg->argn+gw]);
if (bundle_SetRoute(arg->bundle, RTM_ADD, dest, gateway, netmask,
arg->cmd->args ? 1 : 0))
route_Add(&arg->bundle->ncp.ipcp.route, addrs, dest, netmask, gateway);
return 0;
}

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.97.2.29 1998/05/08 18:49:59 brian Exp $
.\" $Id: ppp.8,v 1.97.2.30 1998/05/08 18:50:24 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@ -920,7 +920,7 @@ on ui-gate (the receiver) should contain the following:
ppp-in:
set timeout 0
set ifaddr 10.0.4.1 10.0.4.2
add 10.0.1.0 255.255.255.0 10.0.4.2
add 10.0.1.0/24 10.0.4.2
.Ed
.Pp
You may also want to enable PAP or CHAP for security. To enable PAP, add
@ -954,7 +954,7 @@ ui-gate:
set timeout 30
set log Phase Chat Connect hdlc LCP IPCP CCP tun
set ifaddr 10.0.4.2 10.0.4.1
add 10.0.2.0 255.255.255.0 10.0.4.1
add 10.0.2.0/24 10.0.4.1
.Ed
.Pp
Again, if you're enabling PAP, you'll also need:
@ -1904,19 +1904,21 @@ not to make any utmp or wtmp entries. This is usually only necessary if
you require the user to both login and authenticate themselves.
.El
.Pp
.It add[!] Ar dest mask gateway
.It add[!] Ar dest[/nn] [mask] gateway
.Ar Dest
is the destination IP address and
.Ar mask
is its netmask.
is the destination IP address. The netmask is specified either as a
number of bits with
.Ar /nn
or as an IP number using
.Ar mask .
.Ar 0 0
refers to the default route, and it is possible to use the symbolic name
or simply
.Ar 0
with no mask refers to the default route. It is also possible to use the
literal name
.Sq default
in place of both the
.Ar dest
and
.Ar mask
arguments.
instead of
.Ar 0 .
.Ar Gateway
is the next hop gateway to get to the given
.Ar dest