xref: /freebsd/sys/net/if_pflog.h (revision fcdb520c1b4e1a5d5a2e54cb916dccbc848d32ba)
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	PFLOGIFS_MAX	16
373b3a8eb9SGleb Smirnoff 
383b3a8eb9SGleb Smirnoff #define	PFLOG_RULESET_NAME_SIZE	16
393b3a8eb9SGleb Smirnoff 
403b3a8eb9SGleb Smirnoff struct pfloghdr {
413b3a8eb9SGleb Smirnoff 	u_int8_t	length;
423b3a8eb9SGleb Smirnoff 	sa_family_t	af;
433b3a8eb9SGleb Smirnoff 	u_int8_t	action;
443b3a8eb9SGleb Smirnoff 	u_int8_t	reason;
453b3a8eb9SGleb Smirnoff 	char		ifname[IFNAMSIZ];
463b3a8eb9SGleb Smirnoff 	char		ruleset[PFLOG_RULESET_NAME_SIZE];
473b3a8eb9SGleb Smirnoff 	u_int32_t	rulenr;
483b3a8eb9SGleb Smirnoff 	u_int32_t	subrulenr;
493b3a8eb9SGleb Smirnoff 	uid_t		uid;
503b3a8eb9SGleb Smirnoff 	pid_t		pid;
513b3a8eb9SGleb Smirnoff 	uid_t		rule_uid;
523b3a8eb9SGleb Smirnoff 	pid_t		rule_pid;
533b3a8eb9SGleb Smirnoff 	u_int8_t	dir;
54*fcdb520cSKristof Provost 	u_int8_t	pad1;	/* rewritten, on OpenBSD */
55*fcdb520cSKristof Provost 	sa_family_t	naf;
56*fcdb520cSKristof Provost 	u_int8_t	pad[1];
5776c5eeccSKristof Provost 	u_int32_t	ridentifier;
586d4baa0dSKristof Provost 	u_int8_t	reserve;	/* Appease broken software like Wireshark. */
596d4baa0dSKristof Provost 	u_int8_t	pad2[3];
603b3a8eb9SGleb Smirnoff };
613b3a8eb9SGleb Smirnoff 
624daa31c1SKristof Provost #define PFLOG_ALIGNMENT		sizeof(uint32_t)
634daa31c1SKristof Provost #define PFLOG_ALIGN(x)		(((x) + PFLOG_ALIGNMENT - 1) & ~(PFLOG_ALIGNMENT - 1))
644daa31c1SKristof Provost #define	PFLOG_HDRLEN		PFLOG_ALIGN(offsetof(struct pfloghdr, pad2))
653b3a8eb9SGleb Smirnoff /* minus pad, also used as a signature */
666d4baa0dSKristof Provost #define	PFLOG_REAL_HDRLEN	offsetof(struct pfloghdr, pad2)
673b3a8eb9SGleb Smirnoff 
683b3a8eb9SGleb Smirnoff #ifdef _KERNEL
693b3a8eb9SGleb Smirnoff struct pf_rule;
703b3a8eb9SGleb Smirnoff struct pf_ruleset;
713b3a8eb9SGleb Smirnoff struct pfi_kif;
723b3a8eb9SGleb Smirnoff struct pf_pdesc;
733b3a8eb9SGleb Smirnoff 
749a405864SKristof Provost #define	PFLOG_PACKET(b,t,c,d,e,f,g) do {		\
753b3a8eb9SGleb Smirnoff 	if (pflog_packet_ptr != NULL)			\
769a405864SKristof Provost 		pflog_packet_ptr(b,t,c,d,e,f,g);	\
773b3a8eb9SGleb Smirnoff } while (0)
783b3a8eb9SGleb Smirnoff #endif /* _KERNEL */
793b3a8eb9SGleb Smirnoff #endif /* _NET_IF_PFLOG_H_ */
80