summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r--sys/netinet/ip_input.c54
1 files changed, 19 insertions, 35 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 929f0b91b29..72a00c38fa8 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.27 1998/02/01 18:09:23 mickey Exp $ */
+/* $OpenBSD: ip_input.c,v 1.28 1998/02/01 21:46:02 deraadt Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -196,6 +196,7 @@ ipintr()
register struct ip *ip;
register struct mbuf *m;
register struct ipq *fp;
+ register struct in_ifaddr *ia;
struct ipqent *ipqe;
int hlen, mff, s;
@@ -305,9 +306,23 @@ next:
/*
* Check our list of addresses, to see if the packet is for us.
*/
- if (in_iawithaddr(ip->ip_dst, m))
- goto ours;
-
+ for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
+ if (ip->ip_dst.s_addr == ia->ia_addr.sin_addr.s_addr)
+ goto ours;
+ if (((ip_directedbcast == 0) || (ip_directedbcast &&
+ ia->ia_ifp == m->m_pkthdr.rcvif)) &&
+ (ia->ia_ifp->if_flags & IFF_BROADCAST)) {
+ if (ip->ip_dst.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
+ ip->ip_dst.s_addr == ia->ia_netbroadcast.s_addr ||
+ /*
+ * Look for all-0's host part (old broadcast addr),
+ * either for subnet or net.
+ */
+ ip->ip_dst.s_addr == ia->ia_subnet ||
+ ip->ip_dst.s_addr == ia->ia_net)
+ goto ours;
+ }
+ }
if (IN_MULTICAST(ip->ip_dst.s_addr)) {
struct in_multi *inm;
#ifdef MROUTING
@@ -463,37 +478,6 @@ bad:
goto next;
}
-struct in_ifaddr *
-in_iawithaddr(ina, m)
- struct in_addr ina;
- register struct mbuf *m;
-{
- register struct in_ifaddr *ia;
-
- for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
- if ((ina.s_addr == ia->ia_addr.sin_addr.s_addr) ||
- ((ia->ia_ifp->if_flags & (IFF_LOOPBACK|IFF_LINK1)) ==
- (IFF_LOOPBACK|IFF_LINK1) &&
- ia->ia_subnet == (ina.s_addr & ia->ia_subnetmask)))
- return ia;
- if (m && ((ip_directedbcast == 0) || (ip_directedbcast &&
- ia->ia_ifp == m->m_pkthdr.rcvif)) &&
- (ia->ia_ifp->if_flags & IFF_BROADCAST)) {
- if (ina.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
- ina.s_addr == ia->ia_netbroadcast.s_addr ||
- /*
- * Look for all-0's host part (old broadcast addr),
- * either for subnet or net.
- */
- ina.s_addr == ia->ia_subnet ||
- ina.s_addr == ia->ia_net)
- return ia;
- }
- }
-
- return NULL;
-}
-
/*
* Take incoming datagram fragment and try to
* reassemble it into whole datagram. If a chain for