*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_fw_log.c 200601 2009-12-16 10:48:40Z luigi $");
+__FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_fw_log.c 209845 2010-07-09 11:27:33Z glebius $");
/*
* Logging support for ipfw
return EINVAL;
}
+static int
+ipfw_log_output(struct ifnet *ifp, struct mbuf *m,
+ struct sockaddr *dst, struct route *ro)
+{
+ if (m != NULL)
+ m_freem(m);
+ return EINVAL;
+}
+
+static void
+ipfw_log_start(struct ifnet* ifp)
+{
+ panic("ipfw_log_start() must not be called");
+}
+
+static const u_char ipfwbroadcastaddr[6] =
+ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
void
ipfw_log_bpf(int onoff)
{
ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_init = (void *)log_dummy;
ifp->if_ioctl = log_dummy;
- ifp->if_start = (void *)log_dummy;
- ifp->if_output = (void *)log_dummy;
+ ifp->if_start = ipfw_log_start;
+ ifp->if_output = ipfw_log_output;
ifp->if_addrlen = 6;
ifp->if_hdrlen = 14;
if_attach(ifp);
+ ifp->if_broadcastaddr = ipfwbroadcastaddr;
ifp->if_baudrate = IF_Mbps(10);
bpfattach(ifp, DLT_EN10MB, 14);
log_if = ifp;
if (V_fw_verbose == 0) {
#ifndef WITHOUT_BPF
- struct m_hdr mh;
if (log_if == NULL || log_if->if_bpf == NULL)
return;
- /* BPF treats the "mbuf" as read-only */
- mh.mh_next = m;
- mh.mh_len = ETHER_HDR_LEN;
- if (args->eh) { /* layer2, use orig hdr */
- mh.mh_data = (char *)args->eh;
- } else {
- /* add fake header. Later we will store
- * more info in the header
+
+ if (args->eh) /* layer2, use orig hdr */
+ BPF_MTAP2(log_if, args->eh, ETHER_HDR_LEN, m);
+ else
+ /* Add fake header. Later we will store
+ * more info in the header.
*/
- mh.mh_data = "DDDDDDSSSSSS\x08\x00";
- }
- BPF_MTAP(log_if, (struct mbuf *)&mh);
+ BPF_MTAP2(log_if, "DDDDDDSSSSSS\x08\x00", ETHER_HDR_LEN, m);
#endif /* !WITHOUT_BPF */
return;
}