version 1.13, 1994/05/13 06:06:21 |
version 1.16, 1995/05/14 08:23:00 |
|
|
|
/* $NetBSD$ */ |
|
|
/* |
/* |
* Copyright (c) 1982, 1986, 1988, 1993 |
* Copyright (c) 1982, 1986, 1988, 1993 |
* The Regents of the University of California. All rights reserved. |
* The Regents of the University of California. All rights reserved. |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
* |
* |
* from: @(#)ip_input.c 8.2 (Berkeley) 1/4/94 |
* @(#)ip_input.c 8.2 (Berkeley) 1/4/94 |
* $Id$ |
|
*/ |
*/ |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
Line 97 static struct ip_srcrt { |
|
Line 98 static struct ip_srcrt { |
|
|
|
#ifdef GATEWAY |
#ifdef GATEWAY |
extern int if_index; |
extern int if_index; |
u_long *ip_ifmatrix; |
u_int32_t *ip_ifmatrix; |
#endif |
#endif |
|
|
static void save_rte __P((u_char *, struct in_addr)); |
static void save_rte __P((u_char *, struct in_addr)); |
|
|
ip_id = time.tv_sec & 0xffff; |
ip_id = time.tv_sec & 0xffff; |
ipintrq.ifq_maxlen = ipqmaxlen; |
ipintrq.ifq_maxlen = ipqmaxlen; |
#ifdef GATEWAY |
#ifdef GATEWAY |
i = (if_index + 1) * (if_index + 1) * sizeof (u_long); |
i = (if_index + 1) * (if_index + 1) * sizeof (u_int32_t); |
ip_ifmatrix = (u_long *) malloc(i, M_RTABLE, M_WAITOK); |
ip_ifmatrix = (u_int32_t *) malloc(i, M_RTABLE, M_WAITOK); |
bzero((char *)ip_ifmatrix, i); |
bzero((char *)ip_ifmatrix, i); |
#endif |
#endif |
} |
} |
|
|
ia->ia_ifp == m->m_pkthdr.rcvif && |
ia->ia_ifp == m->m_pkthdr.rcvif && |
#endif |
#endif |
(ia->ia_ifp->if_flags & IFF_BROADCAST)) { |
(ia->ia_ifp->if_flags & IFF_BROADCAST)) { |
u_long t; |
u_int32_t t; |
|
|
if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr == |
if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr == |
ip->ip_dst.s_addr) |
ip->ip_dst.s_addr) |
|
|
} |
} |
goto ours; |
goto ours; |
} |
} |
if (ip->ip_dst.s_addr == (u_long)INADDR_BROADCAST) |
if (ip->ip_dst.s_addr == (u_int32_t)INADDR_BROADCAST) |
goto ours; |
goto ours; |
if (ip->ip_dst.s_addr == INADDR_ANY) |
if (ip->ip_dst.s_addr == INADDR_ANY) |
goto ours; |
goto ours; |
|
|
*/ |
*/ |
ip->ip_len -= hlen; |
ip->ip_len -= hlen; |
((struct ipasfrag *)ip)->ipf_mff &= ~1; |
((struct ipasfrag *)ip)->ipf_mff &= ~1; |
if (ip->ip_off & IP_MF) |
if (ip->ip_off & IP_MF) { |
|
/* |
|
* Make sure that fragments have a data length |
|
* that's a non-zero multiple of 8 bytes. |
|
*/ |
|
if (ip->ip_len == 0 || (ip->ip_len & 0x7) != 0) |
|
ipstat.ips_badfrags++; |
|
goto bad; |
|
} |
((struct ipasfrag *)ip)->ipf_mff |= 1; |
((struct ipasfrag *)ip)->ipf_mff |= 1; |
|
} |
ip->ip_off <<= 3; |
ip->ip_off <<= 3; |
|
|
/* |
/* |
|
|
ipt = (struct ip_timestamp *)cp; |
ipt = (struct ip_timestamp *)cp; |
if (ipt->ipt_len < 5) |
if (ipt->ipt_len < 5) |
goto bad; |
goto bad; |
if (ipt->ipt_ptr > ipt->ipt_len - sizeof (long)) { |
if (ipt->ipt_ptr > ipt->ipt_len - sizeof (int32_t)) { |
if (++ipt->ipt_oflw == 0) |
if (++ipt->ipt_oflw == 0) |
goto bad; |
goto bad; |
break; |
break; |
Line 1073 ip_forward(m, srcrt) |
|
Line 1083 ip_forward(m, srcrt) |
|
satosin(rt_key(rt))->sin_addr.s_addr != 0 && |
satosin(rt_key(rt))->sin_addr.s_addr != 0 && |
ipsendredirects && !srcrt) { |
ipsendredirects && !srcrt) { |
#define RTA(rt) ((struct in_ifaddr *)(rt->rt_ifa)) |
#define RTA(rt) ((struct in_ifaddr *)(rt->rt_ifa)) |
u_long src = ntohl(ip->ip_src.s_addr); |
u_int32_t src = ntohl(ip->ip_src.s_addr); |
|
|
if (RTA(rt) && |
if (RTA(rt) && |
(src & RTA(rt)->ia_subnetmask) == RTA(rt)->ia_subnet) { |
(src & RTA(rt)->ia_subnetmask) == RTA(rt)->ia_subnet) { |
Line 1086 ip_forward(m, srcrt) |
|
Line 1096 ip_forward(m, srcrt) |
|
code = ICMP_REDIRECT_HOST; |
code = ICMP_REDIRECT_HOST; |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (ipprintfs) |
if (ipprintfs) |
printf("redirect (%d) to %lx\n", code, (u_long)dest); |
printf("redirect (%d) to %lx\n", code, (u_int32_t)dest); |
#endif |
#endif |
} |
} |
} |
} |