summaryrefslogtreecommitdiff
path: root/sys/net/if_ethersubr.c
diff options
context:
space:
mode:
authorDug Song <dugsong@cvs.openbsd.org>2001-05-28 19:51:07 +0000
committerDug Song <dugsong@cvs.openbsd.org>2001-05-28 19:51:07 +0000
commit003b06d76be118f7d0071a6b79dd42e11590fce2 (patch)
tree617e45e542da0ade707be8ec2038535a5bcc214f /sys/net/if_ethersubr.c
parent8448a6e5ece6a73c5a4ce842966a9c198f74284f (diff)
add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok
Diffstat (limited to 'sys/net/if_ethersubr.c')
-rw-r--r--sys/net/if_ethersubr.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 348488dae7c..8e1357d2397 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.44 2001/03/23 02:15:23 jason Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.45 2001/05/28 19:51:06 dugsong Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -245,8 +245,8 @@ ether_output(ifp, m0, dst, rt0)
struct rtentry *rt0;
{
u_int16_t etype;
- int s, error = 0;
- u_char edst[6];
+ int s, error = 0, hdrcmplt = 0;
+ u_char edst[6], esrc[6];
register struct mbuf *m = m0;
register struct rtentry *rt;
struct mbuf *mcopy = (struct mbuf *)0;
@@ -478,6 +478,12 @@ ether_output(ifp, m0, dst, rt0)
#endif /* LLC_DEBUG */
} break;
+ case pseudo_AF_HDRCMPLT:
+ hdrcmplt = 1;
+ eh = (struct ether_header *)dst->sa_data;
+ bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, sizeof (esrc));
+ /* FALLTHROUGH */
+
case AF_UNSPEC:
eh = (struct ether_header *)dst->sa_data;
bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
@@ -505,8 +511,12 @@ ether_output(ifp, m0, dst, rt0)
bcopy((caddr_t)&etype,(caddr_t)&eh->ether_type,
sizeof(eh->ether_type));
bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
- bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost,
- sizeof(eh->ether_shost));
+ if (hdrcmplt)
+ bcopy((caddr_t)esrc, (caddr_t)eh->ether_shost,
+ sizeof(eh->ether_shost));
+ else
+ bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost,
+ sizeof(eh->ether_shost));
#if NBRIDGE > 0
/*