Bring ng_iface up-to-date with what has happenned to the bpf code.

This commit is contained in:
Julian Elischer 1999-10-25 22:36:39 +00:00
parent 06e36c4d7b
commit 382667d313

View File

@ -103,12 +103,7 @@
#include <netns/ns_if.h> #include <netns/ns_if.h>
#endif #endif
#include "bpfilter.h"
#if NBPFILTER > 0
#include <net/bpf.h> #include <net/bpf.h>
#include <net/bpfdesc.h>
#endif
/* This struct describes one address family */ /* This struct describes one address family */
struct iffam { struct iffam {
@ -135,7 +130,7 @@ const static struct iffam gFamilies[] = {
NG_IFACE_HOOK_INET, NG_IFACE_HOOK_INET,
AF_INET, AF_INET,
NETISR_NONE, NETISR_NONE,
ip_input { ip_input }
}, },
#endif #endif
#ifdef NETATALK #ifdef NETATALK
@ -143,7 +138,7 @@ const static struct iffam gFamilies[] = {
NG_IFACE_HOOK_ATALK, NG_IFACE_HOOK_ATALK,
AF_APPLETALK, AF_APPLETALK,
NETISR_ATALK, NETISR_ATALK,
&atintrq2 { &atintrq2 }
}, },
#endif #endif
#ifdef IPX #ifdef IPX
@ -151,7 +146,7 @@ const static struct iffam gFamilies[] = {
NG_IFACE_HOOK_IPX, NG_IFACE_HOOK_IPX,
AF_IPX, AF_IPX,
NETISR_IPX, NETISR_IPX,
&ipxintrq { &ipxintrq }
}, },
#endif #endif
#ifdef NS #ifdef NS
@ -159,7 +154,7 @@ const static struct iffam gFamilies[] = {
NG_IFACE_HOOK_NS, NG_IFACE_HOOK_NS,
AF_NS, AF_NS,
NETISR_NS, NETISR_NS,
&nsintrq { &nsintrq }
}, },
#endif #endif
}; };
@ -179,9 +174,7 @@ static void ng_iface_start(struct ifnet *ifp);
static int ng_iface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int ng_iface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
static int ng_iface_output(struct ifnet *ifp, struct mbuf *m0, static int ng_iface_output(struct ifnet *ifp, struct mbuf *m0,
struct sockaddr *dst, struct rtentry *rt0); struct sockaddr *dst, struct rtentry *rt0);
#if NBPFILTER > 0
static void ng_iface_bpftap(struct ifnet *ifp, struct mbuf *m, u_int af); static void ng_iface_bpftap(struct ifnet *ifp, struct mbuf *m, u_int af);
#endif
#ifdef DEBUG #ifdef DEBUG
static void ng_iface_print_ioctl(struct ifnet *ifp, int cmd, caddr_t data); static void ng_iface_print_ioctl(struct ifnet *ifp, int cmd, caddr_t data);
#endif #endif
@ -373,9 +366,7 @@ ng_iface_output(struct ifnet *ifp, struct mbuf *m,
} }
/* Berkeley packet filter */ /* Berkeley packet filter */
#if NBPFILTER > 0
ng_iface_bpftap(ifp, m, dst->sa_family); ng_iface_bpftap(ifp, m, dst->sa_family);
#endif
/* Check address family to determine hook (if known) */ /* Check address family to determine hook (if known) */
if (iffam == NULL) { if (iffam == NULL) {
@ -409,7 +400,6 @@ ng_iface_start(struct ifnet *ifp)
printf("%s%d: %s called?", ifp->if_name, ifp->if_unit, __FUNCTION__); printf("%s%d: %s called?", ifp->if_name, ifp->if_unit, __FUNCTION__);
} }
#if NBPFILTER > 0
/* /*
* Flash a packet by the BPF (requires prepending 4 byte AF header) * Flash a packet by the BPF (requires prepending 4 byte AF header)
* Note the phoney mbuf; this is OK because BPF treats it read-only. * Note the phoney mbuf; this is OK because BPF treats it read-only.
@ -419,20 +409,21 @@ ng_iface_bpftap(struct ifnet *ifp, struct mbuf *m, u_int af)
{ {
struct mbuf m2; struct mbuf m2;
if (af == AF_UNSPEC) { if (ifp->if_bpf) {
af = *(mtod(m, int *)); if (af == AF_UNSPEC) {
m->m_len -= sizeof(int); af = *(mtod(m, int *));
m->m_pkthdr.len -= sizeof(int); m->m_len -= sizeof(int);
m->m_data += sizeof(int); m->m_pkthdr.len -= sizeof(int);
m->m_data += sizeof(int);
}
if (!ifp->if_bpf)
return;
m2.m_next = m;
m2.m_len = 4;
m2.m_data = (char *) &af;
bpf_mtap(ifp, &m2);
} }
if (!ifp->if_bpf)
return;
m2.m_next = m;
m2.m_len = 4;
m2.m_data = (char *) &af;
bpf_mtap(ifp, &m2);
} }
#endif /* NBPFILTER > 0 */
#ifdef DEBUG #ifdef DEBUG
/* /*
@ -536,9 +527,7 @@ ng_iface_constructor(node_p *nodep)
/* Attach the interface */ /* Attach the interface */
if_attach(ifp); if_attach(ifp);
#if NBPFILTER > 0
bpfattach(ifp, DLT_NULL, sizeof(u_int)); bpfattach(ifp, DLT_NULL, sizeof(u_int));
#endif
/* Done */ /* Done */
return (0); return (0);
@ -713,10 +702,8 @@ ng_iface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
/* Note receiving interface */ /* Note receiving interface */
m->m_pkthdr.rcvif = ifp; m->m_pkthdr.rcvif = ifp;
#if NBPFILTER > 0
/* Berkeley packet filter */ /* Berkeley packet filter */
ng_iface_bpftap(ifp, m, iffam->af); ng_iface_bpftap(ifp, m, iffam->af);
#endif
/* Ignore any meta-data */ /* Ignore any meta-data */
NG_FREE_META(meta); NG_FREE_META(meta);