xref: /freebsd/sys/net/if_pflog.h (revision 1ba1e152f8889865e58df6c64d1e595f81f0babc)
13b3a8eb9SGleb Smirnoff /* $OpenBSD: if_pflog.h,v 1.13 2006/10/23 12:46:09 henning Exp $ */
2fe267a55SPedro F. Giffuni /*-
3fe267a55SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause
4fe267a55SPedro F. Giffuni  *
53b3a8eb9SGleb Smirnoff  * Copyright 2001 Niels Provos <provos@citi.umich.edu>
63b3a8eb9SGleb Smirnoff  * All rights reserved.
73b3a8eb9SGleb Smirnoff  *
83b3a8eb9SGleb Smirnoff  * Redistribution and use in source and binary forms, with or without
93b3a8eb9SGleb Smirnoff  * modification, are permitted provided that the following conditions
103b3a8eb9SGleb Smirnoff  * are met:
113b3a8eb9SGleb Smirnoff  * 1. Redistributions of source code must retain the above copyright
123b3a8eb9SGleb Smirnoff  *    notice, this list of conditions and the following disclaimer.
133b3a8eb9SGleb Smirnoff  * 2. Redistributions in binary form must reproduce the above copyright
143b3a8eb9SGleb Smirnoff  *    notice, this list of conditions and the following disclaimer in the
153b3a8eb9SGleb Smirnoff  *    documentation and/or other materials provided with the distribution.
163b3a8eb9SGleb Smirnoff  *
173b3a8eb9SGleb Smirnoff  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
183b3a8eb9SGleb Smirnoff  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
193b3a8eb9SGleb Smirnoff  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
203b3a8eb9SGleb Smirnoff  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
213b3a8eb9SGleb Smirnoff  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b3a8eb9SGleb Smirnoff  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
233b3a8eb9SGleb Smirnoff  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
243b3a8eb9SGleb Smirnoff  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
253b3a8eb9SGleb Smirnoff  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
263b3a8eb9SGleb Smirnoff  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273b3a8eb9SGleb Smirnoff  */
283b3a8eb9SGleb Smirnoff 
293b3a8eb9SGleb Smirnoff #ifndef _NET_IF_PFLOG_H_
303b3a8eb9SGleb Smirnoff #define	_NET_IF_PFLOG_H_
313b3a8eb9SGleb Smirnoff 
32dc04fa80SKristof Provost #include <sys/types.h>
33dc04fa80SKristof Provost 
34dc04fa80SKristof Provost #include <net/if.h>
356d4baa0dSKristof Provost 
363b3a8eb9SGleb Smirnoff #define	PFLOG_RULESET_NAME_SIZE	16
373b3a8eb9SGleb Smirnoff 
383b3a8eb9SGleb Smirnoff struct pfloghdr {
393b3a8eb9SGleb Smirnoff 	u_int8_t	length;
403b3a8eb9SGleb Smirnoff 	sa_family_t	af;
413b3a8eb9SGleb Smirnoff 	u_int8_t	action;
423b3a8eb9SGleb Smirnoff 	u_int8_t	reason;
433b3a8eb9SGleb Smirnoff 	char		ifname[IFNAMSIZ];
443b3a8eb9SGleb Smirnoff 	char		ruleset[PFLOG_RULESET_NAME_SIZE];
453b3a8eb9SGleb Smirnoff 	u_int32_t	rulenr;
463b3a8eb9SGleb Smirnoff 	u_int32_t	subrulenr;
473b3a8eb9SGleb Smirnoff 	uid_t		uid;
483b3a8eb9SGleb Smirnoff 	pid_t		pid;
493b3a8eb9SGleb Smirnoff 	uid_t		rule_uid;
503b3a8eb9SGleb Smirnoff 	pid_t		rule_pid;
513b3a8eb9SGleb Smirnoff 	u_int8_t	dir;
52fcdb520cSKristof Provost 	u_int8_t	pad1;	/* rewritten, on OpenBSD */
53fcdb520cSKristof Provost 	sa_family_t	naf;
54fcdb520cSKristof Provost 	u_int8_t	pad[1];
5576c5eeccSKristof Provost 	u_int32_t	ridentifier;
566d4baa0dSKristof Provost 	u_int8_t	reserve;	/* Appease broken software like Wireshark. */
576d4baa0dSKristof Provost 	u_int8_t	pad2[3];
583b3a8eb9SGleb Smirnoff };
593b3a8eb9SGleb Smirnoff 
604daa31c1SKristof Provost #define PFLOG_ALIGNMENT		sizeof(uint32_t)
614daa31c1SKristof Provost #define PFLOG_ALIGN(x)		(((x) + PFLOG_ALIGNMENT - 1) & ~(PFLOG_ALIGNMENT - 1))
624daa31c1SKristof Provost #define	PFLOG_HDRLEN		PFLOG_ALIGN(offsetof(struct pfloghdr, pad2))
633b3a8eb9SGleb Smirnoff /* minus pad, also used as a signature */
646d4baa0dSKristof Provost #define	PFLOG_REAL_HDRLEN	offsetof(struct pfloghdr, pad2)
653b3a8eb9SGleb Smirnoff 
663b3a8eb9SGleb Smirnoff #ifdef _KERNEL
673b3a8eb9SGleb Smirnoff struct pf_rule;
683b3a8eb9SGleb Smirnoff struct pf_ruleset;
693b3a8eb9SGleb Smirnoff struct pfi_kif;
703b3a8eb9SGleb Smirnoff struct pf_pdesc;
713b3a8eb9SGleb Smirnoff 
72*1ba1e152SKristof Provost #define	PFLOG_PACKET(b,t,c,d,e,f,g,h) do {		\
733b3a8eb9SGleb Smirnoff 	if (pflog_packet_ptr != NULL)			\
74*1ba1e152SKristof Provost 		pflog_packet_ptr(b,t,c,d,e,f,g,h);	\
753b3a8eb9SGleb Smirnoff } while (0)
763b3a8eb9SGleb Smirnoff #endif /* _KERNEL */
773b3a8eb9SGleb Smirnoff #endif /* _NET_IF_PFLOG_H_ */
78