summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/net/bpf.c15
-rw-r--r--sys/net/bpf.h4
-rw-r--r--sys/net/bpfdesc.h3
-rw-r--r--sys/net/if_ethersubr.c20
-rw-r--r--sys/net/if_fddisubr.c22
-rw-r--r--sys/sys/socket.h6
6 files changed, 55 insertions, 15 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index f215c49dd60..47ad8f3348a 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.26 2001/05/16 12:53:34 ho Exp $ */
+/* $OpenBSD: bpf.c,v 1.27 2001/05/28 19:51:06 dugsong Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -518,6 +518,9 @@ bpfwrite(dev, uio, ioflag)
return (EMSGSIZE);
}
+ if (d->bd_hdrcmplt)
+ dst.sa_family = pseudo_AF_HDRCMPLT;
+
s = splsoftnet();
error = (*ifp->if_output)(ifp, m, &dst, (struct rtentry *)0);
splx(s);
@@ -560,6 +563,8 @@ bpf_reset_d(d)
* BIOCGSTATS Get packet stats.
* BIOCIMMEDIATE Set immediate mode.
* BIOCVERSION Get filter language version.
+ * BIOCGHDRCMPLT Get "header already complete" flag
+ * BIOCSHDRCMPLT Set "header already complete" flag
*/
/* ARGSUSED */
int
@@ -737,6 +742,14 @@ bpfioctl(dev, cmd, addr, flag, p)
break;
}
+ case BIOCGHDRCMPLT: /* get "header already complete" flag */
+ *(u_int *)addr = d->bd_hdrcmplt;
+ break;
+
+ case BIOCSHDRCMPLT: /* set "header already complete" flag */
+ d->bd_hdrcmplt = *(u_int *)addr ? 1 : 0;
+ break;
+
case FIONBIO: /* Non-blocking I/O */
if (*(int *)addr)
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 37503941651..1fbc42e0392 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.h,v 1.13 2000/06/19 03:00:54 jason Exp $ */
+/* $OpenBSD: bpf.h,v 1.14 2001/05/28 19:51:06 dugsong Exp $ */
/* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */
/*
@@ -113,6 +113,8 @@ struct bpf_version {
#define BIOCVERSION _IOR('B',113, struct bpf_version)
#define BIOCSRSIG _IOW('B',114, u_int)
#define BIOCGRSIG _IOR('B',115, u_int)
+#define BIOCGHDRCMPLT _IOR('B',116, u_int)
+#define BIOCSHDRCMPLT _IOW('B',117, u_int)
/*
* Structure prepended to each packet.
diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h
index f3440b636c4..0d21bc82f84 100644
--- a/sys/net/bpfdesc.h
+++ b/sys/net/bpfdesc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpfdesc.h,v 1.6 2000/06/19 03:00:54 jason Exp $ */
+/* $OpenBSD: bpfdesc.h,v 1.7 2001/05/28 19:51:06 dugsong Exp $ */
/* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */
/*
@@ -75,6 +75,7 @@ struct bpf_d {
u_char bd_promisc; /* true if listening promiscuously */
u_char bd_state; /* idle, waiting, or timed out */
u_char bd_immediate; /* true to return on packet arrival */
+ int bd_hdrcmplt; /* false to fill in src lladdr automatically */
int bd_async; /* non-zero if packet reception should generate signal */
int bd_sig; /* signal to send upon packet reception */
pid_t bd_pgid; /* process or group id for signal */
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
/*
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 99f6c6448f7..5afc3bd19b6 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fddisubr.c,v 1.22 2000/02/07 06:09:08 itojun Exp $ */
+/* $OpenBSD: if_fddisubr.c,v 1.23 2001/05/28 19:51:06 dugsong Exp $ */
/* $NetBSD: if_fddisubr.c,v 1.5 1996/05/07 23:20:21 christos Exp $ */
/*
@@ -150,8 +150,8 @@ fddi_output(ifp, m0, dst, rt0)
struct rtentry *rt0;
{
u_int16_t type;
- 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;
@@ -339,6 +339,14 @@ fddi_output(ifp, m0, dst, rt0)
} break;
#endif /* CCITT */
+ case pseudo_AF_HDRCMPLT:
+ {
+ struct fddi_header *fh = (struct fddi_header *)dst->sa_data;
+ hdrcmplt = 1;
+ bcopy((caddr_t)fh->fddi_shost, (caddr_t)esrc, sizeof (esrc));
+ /* FALLTHROUGH */
+ }
+
case AF_UNSPEC:
{
struct ether_header *eh;
@@ -419,8 +427,12 @@ fddi_output(ifp, m0, dst, rt0)
#if NBPFILTER > 0
queue_it:
#endif
- bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost,
- sizeof(fh->fddi_shost));
+ if (hdrcmplt)
+ bcopy((caddr_t)esrc, (caddr_t)fh->fddi_shost,
+ sizeof(fh->fddi_shost));
+ else
+ bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost,
+ sizeof(fh->fddi_shost));
s = splimp();
/*
* Queue message on interface, and start output if interface
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index 30df7a16407..005cf1f826f 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: socket.h,v 1.35 2000/08/13 03:38:45 ericj Exp $ */
+/* $OpenBSD: socket.h,v 1.36 2001/05/28 19:51:05 dugsong Exp $ */
/* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */
/*
@@ -134,7 +134,9 @@ struct linger {
#define AF_ENCAP 28
#define AF_SIP 29 /* Simple Internet Protocol */
#define AF_KEY 30
-#define AF_MAX 31
+#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
+ in interface output routine */
+#define AF_MAX 32
/*
* Structure used by kernel to store most