version 1.77, 1999/01/11 22:35:06 |
version 1.88, 1999/06/26 06:16:48 |
|
|
} |
} |
ip = mtod(m, struct ip *); |
ip = mtod(m, struct ip *); |
} |
} |
if ((ip->ip_sum = in_cksum(m, hlen)) != 0) { |
/* |
|
* we drop packets that have a multicast address as source |
|
* as wanted by rfc 1112 |
|
*/ |
|
if (IN_MULTICAST(ip->ip_src.s_addr)) { |
|
goto bad; |
|
} |
|
|
|
if (in_cksum(m, hlen) != 0) { |
ipstat.ips_badsum++; |
ipstat.ips_badsum++; |
goto bad; |
goto bad; |
} |
} |
|
|
* Convert fields to host representation. |
* Convert fields to host representation. |
*/ |
*/ |
NTOHS(ip->ip_len); |
NTOHS(ip->ip_len); |
NTOHS(ip->ip_id); |
|
NTOHS(ip->ip_off); |
NTOHS(ip->ip_off); |
len = ip->ip_len; |
len = ip->ip_len; |
|
|
/* |
/* |
|
* Check for additional length bogosity |
|
*/ |
|
if (len < hlen) { |
|
ipstat.ips_badlen++; |
|
goto bad; |
|
} |
|
|
|
/* |
* Check that the amount of data in the buffers |
* Check that the amount of data in the buffers |
* is as at least much as the IP header would have us expect. |
* is as at least much as the IP header would have us expect. |
* Trim mbufs if longer than we expect. |
* Trim mbufs if longer than we expect. |
|
|
* Check our list of addresses, to see if the packet is for us. |
* Check our list of addresses, to see if the packet is for us. |
*/ |
*/ |
INADDR_TO_IA(ip->ip_dst, ia); |
INADDR_TO_IA(ip->ip_dst, ia); |
if (ia != NULL) goto ours; |
if (ia != NULL) |
|
goto ours; |
if (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST) { |
if (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST) { |
for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; |
for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; |
ifa != NULL; ifa = ifa->ifa_list.tqe_next) { |
ifa != NULL; ifa = ifa->ifa_list.tqe_next) { |
|
|
* as expected when ip_mforward() is called from |
* as expected when ip_mforward() is called from |
* ip_output().) |
* ip_output().) |
*/ |
*/ |
ip->ip_id = htons(ip->ip_id); |
|
if (ip_mforward(m, m->m_pkthdr.rcvif) != 0) { |
if (ip_mforward(m, m->m_pkthdr.rcvif) != 0) { |
ipstat.ips_cantforward++; |
ipstat.ips_cantforward++; |
m_freem(m); |
m_freem(m); |
goto next; |
goto next; |
} |
} |
ip->ip_id = ntohs(ip->ip_id); |
|
|
|
/* |
/* |
* The process-level routing demon needs to receive |
* The process-level routing demon needs to receive |
|
|
ipstat.ips_reassembled++; |
ipstat.ips_reassembled++; |
ip = mtod(m, struct ip *); |
ip = mtod(m, struct ip *); |
hlen = ip->ip_hl << 2; |
hlen = ip->ip_hl << 2; |
|
ip->ip_len += hlen; |
} else |
} else |
if (fp) |
if (fp) |
ip_freef(fp); |
ip_freef(fp); |
IPQ_UNLOCK(); |
IPQ_UNLOCK(); |
} else |
} |
ip->ip_len -= hlen; |
|
|
|
/* |
/* |
* Switch out to protocol's input routine. |
* Switch out to protocol's input routine. |
*/ |
*/ |
|
#if IFA_STATS |
|
ia->ia_ifa.ifa_data.ifad_inbytes += ip->ip_len; |
|
#endif |
ipstat.ips_delivered++; |
ipstat.ips_delivered++; |
(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen); |
(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen); |
goto next; |
goto next; |
Line 1021 ip_dooptions(m) |
|
Line 1038 ip_dooptions(m) |
|
} |
} |
return (0); |
return (0); |
bad: |
bad: |
ip->ip_len -= ip->ip_hl << 2; /* XXX icmp_error adds in hdr length */ |
|
icmp_error(m, type, code, 0, 0); |
icmp_error(m, type, code, 0, 0); |
ipstat.ips_badoptions++; |
ipstat.ips_badoptions++; |
return (1); |
return (1); |
Line 1164 ip_stripoptions(m, mopt) |
|
Line 1180 ip_stripoptions(m, mopt) |
|
register caddr_t opts; |
register caddr_t opts; |
int olen; |
int olen; |
|
|
olen = (ip->ip_hl<<2) - sizeof (struct ip); |
olen = (ip->ip_hl << 2) - sizeof (struct ip); |
opts = (caddr_t)(ip + 1); |
opts = (caddr_t)(ip + 1); |
i = m->m_len - (sizeof (struct ip) + olen); |
i = m->m_len - (sizeof (struct ip) + olen); |
bcopy(opts + olen, opts, (unsigned)i); |
bcopy(opts + olen, opts, (unsigned)i); |
m->m_len -= olen; |
m->m_len -= olen; |
if (m->m_flags & M_PKTHDR) |
if (m->m_flags & M_PKTHDR) |
m->m_pkthdr.len -= olen; |
m->m_pkthdr.len -= olen; |
ip->ip_hl = sizeof(struct ip) >> 2; |
ip->ip_len -= olen; |
|
ip->ip_hl = sizeof (struct ip) >> 2; |
} |
} |
|
|
int inetctlerrmap[PRC_NCMDS] = { |
int inetctlerrmap[PRC_NCMDS] = { |
Line 1409 ip_sysctl(name, namelen, oldp, oldlenp, |
|
Line 1426 ip_sysctl(name, namelen, oldp, oldlenp, |
|
void *newp; |
void *newp; |
size_t newlen; |
size_t newlen; |
{ |
{ |
extern int subnetsarelocal; |
extern int subnetsarelocal, hostzeroisbroadcast; |
|
|
int error, old; |
int error, old; |
|
|
Line 1501 ip_sysctl(name, namelen, oldp, oldlenp, |
|
Line 1518 ip_sysctl(name, namelen, oldp, oldlenp, |
|
return (error); |
return (error); |
} |
} |
#endif |
#endif |
|
case IPCTL_HOSTZEROBROADCAST: |
|
return (sysctl_int(oldp, oldlenp, newp, newlen, |
|
&hostzeroisbroadcast)); |
|
|
default: |
default: |
return (EOPNOTSUPP); |
return (EOPNOTSUPP); |
} |
} |