X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=dummynet2%2Fip_fw_log.c;h=55b5c260528a7513049b6ddfa9bcc90a4cde9bf9;hb=28a7fe9d930667786b902af6697c01eb87694173;hp=1bc1216e0b528a09d92e1c08049748e988b6c0ff;hpb=4e189c94aef3d3e9a4e8edfd2bb989feeb5d5e26;p=ipfw.git diff --git a/dummynet2/ip_fw_log.c b/dummynet2/ip_fw_log.c index 1bc1216..55b5c26 100644 --- a/dummynet2/ip_fw_log.c +++ b/dummynet2/ip_fw_log.c @@ -24,7 +24,7 @@ */ #include -__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 @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_fw_log.c 200601 2009-12-16 10:48:40 #include #include #include +#include #include #include #include @@ -102,6 +103,24 @@ log_dummy(struct ifnet *ifp, u_long cmd, caddr_t addr) 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) { @@ -118,11 +137,12 @@ 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; @@ -151,22 +171,17 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ip_fw_args *args, 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; } @@ -394,7 +409,7 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ip_fw_args *args, if (offset & (IP6F_OFF_MASK | IP6F_MORE_FRAG)) snprintf(SNPARGS(fragment, 0), " (frag %08x:%d@%d%s)", - args->f_id.frag_id6, + args->f_id.extra, ntohs(ip6->ip6_plen) - hlen, ntohs(offset & IP6F_OFF_MASK) << 3, (offset & IP6F_MORE_FRAG) ? "+" : ""); @@ -412,7 +427,7 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ip_fw_args *args, (ipoff & IP_MF) ? "+" : ""); } } -#ifndef __linux__ +#ifdef __FreeBSD__ if (oif || m->m_pkthdr.rcvif) log(LOG_SECURITY | LOG_INFO, "ipfw: %d %s %s %s via %s%s\n",