diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-10-29 19:51:05 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-10-29 19:51:05 +0000 |
commit | 6f521bf77023b728eac468a07e077ee039120a27 (patch) | |
tree | 815d51036ede312eddbdd83e874264355a0eb92c /sys/net/if_pflog.c | |
parent | c8811b30c30f967b1b25387b30bc1cfd2e619a84 (diff) |
keep all pflog goodies in pflog sources, avoids code duplications; okski frantzen@ and dhartmei@
Diffstat (limited to 'sys/net/if_pflog.c')
-rw-r--r-- | sys/net/if_pflog.c | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/sys/net/if_pflog.c b/sys/net/if_pflog.c index 176bf6d2451..7c1648ce6e5 100644 --- a/sys/net/if_pflog.c +++ b/sys/net/if_pflog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflog.c,v 1.6 2002/06/30 13:04:36 itojun Exp $ */ +/* $OpenBSD: if_pflog.c,v 1.7 2002/10/29 19:51:04 mickey Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -33,6 +33,9 @@ * PURPOSE. */ +#include "bpfilter.h" +#include "pflog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> @@ -44,11 +47,11 @@ #include <net/route.h> #include <net/bpf.h> -#include <net/if_pflog.h> - #ifdef INET #include <netinet/in.h> #include <netinet/in_var.h> +#include <netinet/in_systm.h> +#include <netinet/ip.h> #endif #ifdef INET6 @@ -58,8 +61,8 @@ #include <netinet6/nd6.h> #endif /* INET6 */ -#include "bpfilter.h" -#include "pflog.h" +#include <net/pfvar.h> +#include <net/if_pflog.h> #define PFLOGMTU (32768 + MHLEN + MLEN) @@ -167,3 +170,46 @@ pflogioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return (0); } + +int +pflog_packet(struct ifnet *ifp, struct mbuf *m, sa_family_t af, u_short dir, + u_short reason, struct pf_rule *rm) +{ +#if NBPFILTER > 0 + struct ifnet *ifn; + struct pfloghdr hdr; + struct mbuf m1; + + if (ifp == NULL || m == NULL || rm == NULL) + return (-1); + + hdr.af = htonl(af); + memcpy(hdr.ifname, ifp->if_xname, sizeof(hdr.ifname)); + + hdr.rnr = htons(rm->nr); + hdr.reason = htons(reason); + hdr.dir = htons(dir); + hdr.action = htons(rm->action); + +#ifdef INET + if (af == AF_INET && dir == PF_OUT) { + struct ip *ip; + + ip = mtod(m, struct ip *); + ip->ip_sum = 0; + ip->ip_sum = in_cksum(m, ip->ip_hl << 2); + } +#endif /* INET */ + + m1.m_next = m; + m1.m_len = PFLOG_HDRLEN; + m1.m_data = (char *) &hdr; + + ifn = &(pflogif[0].sc_if); + + if (ifn->if_bpf) + bpf_mtap(ifn->if_bpf, &m1); +#endif + + return (0); +} |