diff options
author | brian <brian@cvs.openbsd.org> | 1999-03-03 23:01:13 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1999-03-03 23:01:13 +0000 |
commit | 5cbfdb9a7592584c808156bd339dde73fb2e0353 (patch) | |
tree | 29b20a79f220357f5f0022987afa13f4226ecf08 | |
parent | 7ab07e189e67def4b6e60c8649db0e5031f1567c (diff) |
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.
-rw-r--r-- | usr.sbin/ppp/ppp/command.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ipcp.c | 34 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ipcp.h | 11 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ppp.8 | 27 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/radius.c | 4 |
5 files changed, 52 insertions, 30 deletions
diff --git a/usr.sbin/ppp/ppp/command.c b/usr.sbin/ppp/ppp/command.c index 301d6fe86a8..a3449ced960 100644 --- a/usr.sbin/ppp/ppp/command.c +++ b/usr.sbin/ppp/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.12 1999/02/26 21:28:20 brian Exp $ + * $Id: command.c,v 1.13 1999/03/03 23:01:09 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/26 21:28:20 $"; +const char VersionDate[] = "$Date: 1999/03/03 23:01:09 $"; 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; diff --git a/usr.sbin/ppp/ppp/ipcp.c b/usr.sbin/ppp/ppp/ipcp.c index 5d57dbb7a5a..57bb138bd0a 100644 --- a/usr.sbin/ppp/ppp/ipcp.c +++ b/usr.sbin/ppp/ppp/ipcp.c @@ -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.8 1999/02/26 21:28:22 brian Exp $ + * $Id: ipcp.c,v 1.9 1999/03/03 23:01:10 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; +} diff --git a/usr.sbin/ppp/ppp/ipcp.h b/usr.sbin/ppp/ppp/ipcp.h index b32b3cdc026..b8529b5b417 100644 --- a/usr.sbin/ppp/ppp/ipcp.h +++ b/usr.sbin/ppp/ppp/ipcp.h @@ -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.4 1999/02/26 21:28:23 brian Exp $ + * $Id: ipcp.h,v 1.5 1999/03/03 23:01:11 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); diff --git a/usr.sbin/ppp/ppp/ppp.8 b/usr.sbin/ppp/ppp/ppp.8 index a7e8bcc6ff9..20a111dcaeb 100644 --- a/usr.sbin/ppp/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.23 1999/02/26 21:28:24 brian Exp $ +.\" $Id: ppp.8,v 1.24 1999/03/03 23:01:11 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 diff --git a/usr.sbin/ppp/ppp/radius.c b/usr.sbin/ppp/ppp/radius.c index 2e7296db8fc..2387bc7b9d1 100644 --- a/usr.sbin/ppp/ppp/radius.c +++ b/usr.sbin/ppp/ppp/radius.c @@ -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.1 1999/02/06 03:22:44 brian Exp $ + * $Id: radius.c,v 1.2 1999/03/03 23:01:12 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)) |