remove network mask calculation for Classful network

Nowadays it's not necessary to compute network mask from the IP address and
compare to given by DHCP.

Submitted by:	kczekirda
Reviewed by:	glebius, bapt
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D8740
This commit is contained in:
Baptiste Daroussin 2017-01-07 23:42:17 +00:00
parent ee2c73e559
commit 0922cf8d32
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311659

View File

@ -62,8 +62,6 @@ __FBSDID("$FreeBSD$");
struct in_addr servip; struct in_addr servip;
static n_long nmask, smask;
static time_t bot; static time_t bot;
static char vm_rfc1048[4] = VM_RFC1048; static char vm_rfc1048[4] = VM_RFC1048;
@ -223,30 +221,19 @@ bootp(sock, flag)
bcopy(rbuf.rbootp.bp_file, bootfile, sizeof(bootfile)); bcopy(rbuf.rbootp.bp_file, bootfile, sizeof(bootfile));
bootfile[sizeof(bootfile) - 1] = '\0'; bootfile[sizeof(bootfile) - 1] = '\0';
if (IN_CLASSA(ntohl(myip.s_addr))) if (!netmask) {
nmask = htonl(IN_CLASSA_NET); if (IN_CLASSA(ntohl(myip.s_addr)))
else if (IN_CLASSB(ntohl(myip.s_addr))) netmask = htonl(IN_CLASSA_NET);
nmask = htonl(IN_CLASSB_NET); else if (IN_CLASSB(ntohl(myip.s_addr)))
else netmask = htonl(IN_CLASSB_NET);
nmask = htonl(IN_CLASSC_NET); else
#ifdef BOOTP_DEBUG netmask = htonl(IN_CLASSC_NET);
if (debug)
printf("'native netmask' is %s\n", intoa(nmask));
#endif
/* Check subnet mask against net mask; toss if bogus */
if ((nmask & smask) != nmask) {
#ifdef BOOTP_DEBUG #ifdef BOOTP_DEBUG
if (debug) if (debug)
printf("subnet mask (%s) bad\n", intoa(smask)); printf("'native netmask' is %s\n", intoa(netmask));
#endif #endif
smask = 0;
} }
/* Get subnet (or natural net) mask */
netmask = nmask;
if (smask)
netmask = smask;
#ifdef BOOTP_DEBUG #ifdef BOOTP_DEBUG
if (debug) if (debug)
printf("mask: %s\n", intoa(netmask)); printf("mask: %s\n", intoa(netmask));
@ -385,7 +372,7 @@ vend_rfc1048(cp, len)
break; break;
if (tag == TAG_SUBNET_MASK) { if (tag == TAG_SUBNET_MASK) {
bcopy(cp, &smask, sizeof(smask)); bcopy(cp, &netmask, sizeof(netmask));
} }
if (tag == TAG_GATEWAY) { if (tag == TAG_GATEWAY) {
bcopy(cp, &gateip.s_addr, sizeof(gateip.s_addr)); bcopy(cp, &gateip.s_addr, sizeof(gateip.s_addr));
@ -445,7 +432,7 @@ vend_cmu(cp)
vp = (struct cmu_vend *)cp; vp = (struct cmu_vend *)cp;
if (vp->v_smask.s_addr != 0) { if (vp->v_smask.s_addr != 0) {
smask = vp->v_smask.s_addr; netmask = vp->v_smask.s_addr;
} }
if (vp->v_dgate.s_addr != 0) { if (vp->v_dgate.s_addr != 0) {
gateip = vp->v_dgate; gateip = vp->v_dgate;