aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1995-09-22 17:57:48 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1995-09-22 17:57:48 +0000
commit963e4c2a50872e0f22859106be7585ff7a32b02f (patch)
tree5ad506a8546e1e713cc5fcbf8cf04de5537bc5ca /sys
parentf001bbb882a65852ae9de00ef08194f06b1ea779 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/net/bpf.c44
-rw-r--r--sys/net/if.c37
-rw-r--r--sys/net/if_disc.c10
-rw-r--r--sys/net/if_loop.c10
4 files changed, 59 insertions, 42 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 236ccfae64ee7..57355314dbe28 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -37,7 +37,7 @@
*
* @(#)bpf.c 8.2 (Berkeley) 3/28/94
*
- * $Id: bpf.c,v 1.11 1995/09/08 11:08:52 bde Exp $
+ * $Id: bpf.c,v 1.12 1995/09/20 20:48:29 wollman Exp $
*/
#include "bpfilter.h"
@@ -192,10 +192,10 @@ bpf_movein(uio, linktype, mp, sockp, datlen)
if ((unsigned)len > MCLBYTES)
return (EIO);
- MGET(m, M_WAIT, MT_DATA);
+ MGETHDR(m, M_WAIT, MT_DATA);
if (m == 0)
return (ENOBUFS);
- if (len > MLEN) {
+ if (len > MHLEN) {
#if BSD >= 199103
MCLGET(m, M_WAIT);
if ((m->m_flags & M_EXT) == 0) {
@@ -207,7 +207,8 @@ bpf_movein(uio, linktype, mp, sockp, datlen)
goto bad;
}
}
- m->m_len = len;
+ m->m_pkthdr.len = m->m_len = len;
+ m->m_pkthdr.rcvif = NULL;
*mp = m;
/*
* Make room for link header.
@@ -1308,39 +1309,4 @@ bpfattach(driverp, ifp, dlt, hdrlen)
if (bootverbose)
printf("bpf: %s%d attached\n", ifp->if_name, ifp->if_unit);
}
-
-#if BSD >= 199103
-/* XXX This routine belongs in net/if.c. */
-/*
- * Set/clear promiscuous mode on interface ifp based on the truth value
- * of pswitch. The calls are reference counted so that only the first
- * "on" request actually has an effect, as does the final "off" request.
- * Results are undefined if the "off" and "on" requests are not matched.
- */
-int
-ifpromisc(ifp, pswitch)
- struct ifnet *ifp;
- int pswitch;
-{
- struct ifreq ifr;
-
- if (pswitch) {
- /*
- * If the device is not configured up, we cannot put it in
- * promiscuous mode.
- */
- if ((ifp->if_flags & IFF_UP) == 0)
- return (ENETDOWN);
- if (ifp->if_pcount++ != 0)
- return (0);
- ifp->if_flags |= IFF_PROMISC;
- } else {
- if (--ifp->if_pcount > 0)
- return (0);
- ifp->if_flags &= ~IFF_PROMISC;
- }
- ifr.ifr_flags = ifp->if_flags;
- return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr));
-}
-#endif
#endif
diff --git a/sys/net/if.c b/sys/net/if.c
index b0601811d901b..6b92c64a1f148 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.c 8.3 (Berkeley) 1/4/94
- * $Id: if.c,v 1.18 1995/08/28 09:19:00 julian Exp $
+ * $Id: if.c,v 1.19 1995/09/09 18:10:20 davidg Exp $
*/
#include <sys/param.h>
@@ -44,6 +44,7 @@
#include <sys/kernel.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
+#include <sys/syslog.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -646,6 +647,40 @@ ifioctl(so, cmd, data, p)
}
/*
+ * Set/clear promiscuous mode on interface ifp based on the truth value
+ * of pswitch. The calls are reference counted so that only the first
+ * "on" request actually has an effect, as does the final "off" request.
+ * Results are undefined if the "off" and "on" requests are not matched.
+ */
+int
+ifpromisc(ifp, pswitch)
+ struct ifnet *ifp;
+ int pswitch;
+{
+ struct ifreq ifr;
+
+ if (pswitch) {
+ /*
+ * If the device is not configured up, we cannot put it in
+ * promiscuous mode.
+ */
+ if ((ifp->if_flags & IFF_UP) == 0)
+ return (ENETDOWN);
+ if (ifp->if_pcount++ != 0)
+ return (0);
+ ifp->if_flags |= IFF_PROMISC;
+ log(LOG_NOTICE, "%s%d: promiscuous mode enabled",
+ ifp->if_name, ifp->if_unit);
+ } else {
+ if (--ifp->if_pcount > 0)
+ return (0);
+ ifp->if_flags &= ~IFF_PROMISC;
+ }
+ ifr.ifr_flags = ifp->if_flags;
+ return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr));
+}
+
+/*
* Return interface configuration
* of system. List may be used
* in later ioctl's (above) to get
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index 9344d6520be11..76fb9ec98d909 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* From: @(#)if_loop.c 8.1 (Berkeley) 6/10/93
- * $Id: if_disc.c,v 1.5 1995/08/30 00:33:17 bde Exp $
+ * $Id: if_disc.c,v 1.6 1995/09/09 18:10:21 davidg Exp $
*/
/*
@@ -123,6 +123,14 @@ dsoutput(ifp, m, dst, rt)
panic("dsoutput no HDR");
ifp->if_lastchange = time;
#if NBPFILTER > 0
+ /* BPF write needs to be handled specially */
+ if (dst->sa_family == AF_UNSPEC) {
+ dst->sa_family = *(mtod(m, int *));
+ m->m_len -= sizeof(int);
+ m->m_pkthdr.len -= sizeof(int);
+ m->m_data += sizeof(int);
+ }
+
if (dsif.if_bpf) {
/*
* We need to prepend the address family as
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 460ad2fa2ae7f..5bf79ee06ae2d 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_loop.c 8.1 (Berkeley) 6/10/93
- * $Id: if_loop.c,v 1.11 1995/08/30 00:33:18 bde Exp $
+ * $Id: if_loop.c,v 1.12 1995/09/09 18:10:22 davidg Exp $
*/
/*
@@ -126,6 +126,14 @@ looutput(ifp, m, dst, rt)
panic("looutput no HDR");
ifp->if_lastchange = time;
#if NBPFILTER > 0
+ /* BPF write needs to be handled specially */
+ if (dst->sa_family == AF_UNSPEC) {
+ dst->sa_family = *(mtod(m, int *));
+ m->m_len -= sizeof(int);
+ m->m_pkthdr.len -= sizeof(int);
+ m->m_data += sizeof(int);
+ }
+
if (ifp->if_bpf) {
/*
* We need to prepend the address family as