Correct some ntohl/htonl bogons in the netmask handling.

This was pretty harmless as netmasks on a POINTOPOINT
interface are pretty much ignored, but it looked funny.

Mention the configured netmask in ``show ipcp''.

Describe in more detail what a proxy arp entry is.
This commit is contained in:
Brian Somers 1999-03-03 23:00:41 +00:00
parent b9bb98b32b
commit bc76350ef9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44455
6 changed files with 74 additions and 35 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.183 1999/02/25 20:05:54 brian Exp $
* $Id: command.c,v 1.184 1999/02/26 21:28:07 brian Exp $
*
*/
#include <sys/param.h>
@ -141,7 +141,7 @@
#define NEG_DNS 52
const char Version[] = "2.11";
const char VersionDate[] = "$Date: 1999/02/25 20:05:54 $";
const char VersionDate[] = "$Date: 1999/02/26 21:28:07 $";
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
@ -1295,7 +1295,7 @@ SetInterfaceAddr(struct cmdargs const *arg)
if (arg->argc > arg->argn+1) {
hisaddr = arg->argv[arg->argn+1];
if (arg->argc > arg->argn+2) {
ipcp->cfg.netmask = GetIpAddr(arg->argv[arg->argn+2]);
ipcp->ifmask = ipcp->cfg.netmask = GetIpAddr(arg->argv[arg->argn+2]);
if (arg->argc > arg->argn+3) {
ipcp->cfg.TriggerAddress = GetIpAddr(arg->argv[arg->argn+3]);
ipcp->cfg.HaveTriggerAddress = 1;

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.c,v 1.71 1999/02/06 02:54:45 brian Exp $
* $Id: ipcp.c,v 1.72 1999/02/26 21:28:11 brian Exp $
*
* TODO:
* o More RFC1772 backward compatibility
@ -288,11 +288,12 @@ ipcp_Show(struct cmdargs const *arg)
ipcp->cfg.fsm.maxtrm, ipcp->cfg.fsm.maxtrm == 1 ? "" : "s");
prompt_Printf(arg->prompt, " My Address: %s/%d",
inet_ntoa(ipcp->cfg.my_range.ipaddr), ipcp->cfg.my_range.width);
prompt_Printf(arg->prompt, ", netmask %s\n", inet_ntoa(ipcp->cfg.netmask));
if (ipcp->cfg.HaveTriggerAddress)
prompt_Printf(arg->prompt, " (trigger with %s)",
prompt_Printf(arg->prompt, " Trigger address: %s\n",
inet_ntoa(ipcp->cfg.TriggerAddress));
prompt_Printf(arg->prompt, "\n VJ compression: %s (%d slots %s slot "
prompt_Printf(arg->prompt, " VJ compression: %s (%d slots %s slot "
"compression)\n", command_ShowNegval(ipcp->cfg.vj.neg),
ipcp->cfg.vj.slots, ipcp->cfg.vj.slotcomp ? "with" : "without");
@ -479,9 +480,9 @@ ipcp_doproxyall(struct bundle *bundle,
ipcp = &bundle->ncp.ipcp;
for (rp = ipcp->route; rp != NULL; rp = rp->next) {
if (ntohl(rp->mask.s_addr) == INADDR_BROADCAST)
if (rp->mask.s_addr == INADDR_BROADCAST)
continue;
n = INADDR_BROADCAST - ntohl(rp->mask.s_addr) - 1;
n = ntohl(INADDR_BROADCAST) - ntohl(rp->mask.s_addr) - 1;
if (n > 0 && n <= 254 && rp->dst.s_addr != INADDR_ANY) {
addr = rp->dst;
while (n--) {
@ -503,14 +504,12 @@ ipcp_SetIPaddress(struct bundle *bundle, struct in_addr myaddr,
{
static struct in_addr none = { INADDR_ANY };
struct in_addr mask, oaddr;
u_int32_t addr;
addr = htonl(myaddr.s_addr);
mask.s_addr = addr2mask(addr);
mask = addr2mask(myaddr);
if (bundle->ncp.ipcp.ifmask.s_addr != INADDR_ANY &&
(ntohl(bundle->ncp.ipcp.ifmask.s_addr) & mask.s_addr) == mask.s_addr)
mask.s_addr = htonl(bundle->ncp.ipcp.ifmask.s_addr);
(bundle->ncp.ipcp.ifmask.s_addr & mask.s_addr) == mask.s_addr)
mask.s_addr = bundle->ncp.ipcp.ifmask.s_addr;
oaddr.s_addr = bundle->iface->in_addrs ?
bundle->iface->in_addr[0].ifa.s_addr : INADDR_ANY;
@ -1216,3 +1215,16 @@ ipcp_UseHisaddr(struct bundle *bundle, const char *hisaddr, int setaddr)
return 1;
}
struct in_addr
addr2mask(struct in_addr addr)
{
u_int32_t haddr = ntohl(addr.s_addr);
haddr = IN_CLASSA(haddr) ? IN_CLASSA_NET :
IN_CLASSB(haddr) ? IN_CLASSB_NET :
IN_CLASSC_NET;
addr.s_addr = htonl(haddr);
return addr;
}

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.h,v 1.23 1999/01/28 01:56:32 brian Exp $
* $Id: ipcp.h,v 1.24 1999/02/26 21:28:12 brian Exp $
*
* TODO:
*/
@ -34,14 +34,6 @@
#define TY_SECONDARY_NBNS 132
#define TY_ADJUST_NS 119 /* subtract from NS val for REJECT bit */
#define addr2mask(addr) ( \
IN_CLASSA(addr) ? \
htonl(IN_CLASSA_NET) : \
IN_CLASSB(addr) ? \
htonl(IN_CLASSB_NET) : htonl(IN_CLASSC_NET) \
)
struct sticky_route;
struct in_range {
@ -124,3 +116,4 @@ extern int ipcp_UseHisaddr(struct bundle *, const char *, int);
extern int ipcp_vjset(struct cmdargs const *);
extern void ipcp_CleanInterface(struct ipcp *);
extern int ipcp_InterfaceUp(struct ipcp *);
extern struct in_addr addr2mask(struct in_addr);

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.151 1999/02/25 12:00:04 brian Exp $
.\" $Id: ppp.8,v 1.152 1999/02/26 21:28:14 brian Exp $
.Dd 20 September 1995
.nr XX \w'\fC00'
.Os FreeBSD
@ -127,10 +127,9 @@ will use it to make
.Em RADIUS
requests when configured to do so.
.It Supports Proxy Arp.
When
.Nm
is set up as server, it can be configured to make one or more proxy arp
entries on behalf of the client. This allows routing to the LAN without
can be configured to make one or more proxy arp entries on behalf of
the peer. This allows routing from the peer to the LAN without
configuring each machine on that LAN.
.It Supports packet filtering.
User can define four kinds of filters: the
@ -2376,12 +2375,30 @@ as the client password in
.It proxy
Default: Disabled. Enabling this option will tell
.Nm
to proxy ARP for the peer.
to proxy ARP for the peer. This means that
.Nm
will make an entry in the ARP table using
.Dv HISADDR
and the
.Dv MAC
address of the local network in which
.Dv HISADDR
appears. The proxy entry cannot be made unless
.Dv HISADDR
is an address from a LAN.
.It proxyall
Default: Disabled. Enabling this will tell
.Nm
to add proxy arp entries for every IP address in all class C or
smaller subnets routed via the tun interface.
.Pp
Proxy arp entries are only made for sticky routes that are added
using the
.Dq add
command. No proxy arp entries are made for the interface address itself
(as created by the
.Dq set ifaddr
command).
.It sroutes
Default: Enabled. When the
.Dq add

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.151 1999/02/25 12:00:04 brian Exp $
.\" $Id: ppp.8,v 1.152 1999/02/26 21:28:14 brian Exp $
.Dd 20 September 1995
.nr XX \w'\fC00'
.Os FreeBSD
@ -127,10 +127,9 @@ will use it to make
.Em RADIUS
requests when configured to do so.
.It Supports Proxy Arp.
When
.Nm
is set up as server, it can be configured to make one or more proxy arp
entries on behalf of the client. This allows routing to the LAN without
can be configured to make one or more proxy arp entries on behalf of
the peer. This allows routing from the peer to the LAN without
configuring each machine on that LAN.
.It Supports packet filtering.
User can define four kinds of filters: the
@ -2376,12 +2375,30 @@ as the client password in
.It proxy
Default: Disabled. Enabling this option will tell
.Nm
to proxy ARP for the peer.
to proxy ARP for the peer. This means that
.Nm
will make an entry in the ARP table using
.Dv HISADDR
and the
.Dv MAC
address of the local network in which
.Dv HISADDR
appears. The proxy entry cannot be made unless
.Dv HISADDR
is an address from a LAN.
.It proxyall
Default: Disabled. Enabling this will tell
.Nm
to add proxy arp entries for every IP address in all class C or
smaller subnets routed via the tun interface.
.Pp
Proxy arp entries are only made for sticky routes that are added
using the
.Dq add
command. No proxy arp entries are made for the interface address itself
(as created by the
.Dq set ifaddr
command).
.It sroutes
Default: Enabled. When the
.Dq add

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: radius.c,v 1.2 1999/01/29 22:46:31 brian Exp $
* $Id: radius.c,v 1.3 1999/02/06 02:54:47 brian Exp $
*
*/
@ -183,7 +183,7 @@ radius_Process(struct radius *r, int got)
else {
if (dest.width == 32 && strchr(argv[0], '/') == NULL)
/* No mask specified - use the natural mask */
dest.mask.s_addr = addr2mask(dest.ipaddr.s_addr);
dest.mask = addr2mask(dest.ipaddr);
addrs = 0;
if (!strncasecmp(argv[0], "HISADDR", 7))