xref: /freebsd-src/contrib/libpcap/pflog.h (revision 6f9cba8f8b5efd16249633e52483ea351876b67b)
1*6f9cba8fSJoseph Mingrone /*
2*6f9cba8fSJoseph Mingrone  * Copyright (c) 1982, 1986, 1993
3*6f9cba8fSJoseph Mingrone  *	The Regents of the University of California.  All rights reserved.
4*6f9cba8fSJoseph Mingrone  *
5*6f9cba8fSJoseph Mingrone  * Redistribution and use in source and binary forms, with or without
6*6f9cba8fSJoseph Mingrone  * modification, are permitted provided that the following conditions
7*6f9cba8fSJoseph Mingrone  * are met:
8*6f9cba8fSJoseph Mingrone  * 1. Redistributions of source code must retain the above copyright
9*6f9cba8fSJoseph Mingrone  *    notice, this list of conditions and the following disclaimer.
10*6f9cba8fSJoseph Mingrone  * 2. Redistributions in binary form must reproduce the above copyright
11*6f9cba8fSJoseph Mingrone  *    notice, this list of conditions and the following disclaimer in the
12*6f9cba8fSJoseph Mingrone  *    documentation and/or other materials provided with the distribution.
13*6f9cba8fSJoseph Mingrone  * 3. All advertising materials mentioning features or use of this software
14*6f9cba8fSJoseph Mingrone  *    must display the following acknowledgement:
15*6f9cba8fSJoseph Mingrone  *	This product includes software developed by the University of
16*6f9cba8fSJoseph Mingrone  *	California, Berkeley and its contributors.
17*6f9cba8fSJoseph Mingrone  * 4. Neither the name of the University nor the names of its contributors
18*6f9cba8fSJoseph Mingrone  *    may be used to endorse or promote products derived from this software
19*6f9cba8fSJoseph Mingrone  *    without specific prior written permission.
20*6f9cba8fSJoseph Mingrone  *
21*6f9cba8fSJoseph Mingrone  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22*6f9cba8fSJoseph Mingrone  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23*6f9cba8fSJoseph Mingrone  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24*6f9cba8fSJoseph Mingrone  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25*6f9cba8fSJoseph Mingrone  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26*6f9cba8fSJoseph Mingrone  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27*6f9cba8fSJoseph Mingrone  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28*6f9cba8fSJoseph Mingrone  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29*6f9cba8fSJoseph Mingrone  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30*6f9cba8fSJoseph Mingrone  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*6f9cba8fSJoseph Mingrone  * SUCH DAMAGE.
32*6f9cba8fSJoseph Mingrone  */
33*6f9cba8fSJoseph Mingrone 
34*6f9cba8fSJoseph Mingrone /*
35*6f9cba8fSJoseph Mingrone  * pflog headers, at least as they exist now.
36*6f9cba8fSJoseph Mingrone  */
37*6f9cba8fSJoseph Mingrone #define PFLOG_IFNAMSIZ		16
38*6f9cba8fSJoseph Mingrone #define PFLOG_RULESET_NAME_SIZE	16
39*6f9cba8fSJoseph Mingrone 
40*6f9cba8fSJoseph Mingrone /*
41*6f9cba8fSJoseph Mingrone  * Direction values.
42*6f9cba8fSJoseph Mingrone  */
43*6f9cba8fSJoseph Mingrone #define PF_INOUT	0
44*6f9cba8fSJoseph Mingrone #define PF_IN		1
45*6f9cba8fSJoseph Mingrone #define PF_OUT		2
46*6f9cba8fSJoseph Mingrone #if defined(__OpenBSD__)
47*6f9cba8fSJoseph Mingrone #define PF_FWD		3
48*6f9cba8fSJoseph Mingrone #endif
49*6f9cba8fSJoseph Mingrone 
50*6f9cba8fSJoseph Mingrone /*
51*6f9cba8fSJoseph Mingrone  * Reason values.
52*6f9cba8fSJoseph Mingrone  */
53*6f9cba8fSJoseph Mingrone #define PFRES_MATCH	0
54*6f9cba8fSJoseph Mingrone #define PFRES_BADOFF	1
55*6f9cba8fSJoseph Mingrone #define PFRES_FRAG	2
56*6f9cba8fSJoseph Mingrone #define PFRES_SHORT	3
57*6f9cba8fSJoseph Mingrone #define PFRES_NORM	4
58*6f9cba8fSJoseph Mingrone #define PFRES_MEMORY	5
59*6f9cba8fSJoseph Mingrone #define PFRES_TS	6
60*6f9cba8fSJoseph Mingrone #define PFRES_CONGEST	7
61*6f9cba8fSJoseph Mingrone #define PFRES_IPOPTIONS 8
62*6f9cba8fSJoseph Mingrone #define PFRES_PROTCKSUM 9
63*6f9cba8fSJoseph Mingrone #define PFRES_BADSTATE	10
64*6f9cba8fSJoseph Mingrone #define PFRES_STATEINS	11
65*6f9cba8fSJoseph Mingrone #define PFRES_MAXSTATES	12
66*6f9cba8fSJoseph Mingrone #define PFRES_SRCLIMIT	13
67*6f9cba8fSJoseph Mingrone #define PFRES_SYNPROXY	14
68*6f9cba8fSJoseph Mingrone #if defined(__FreeBSD__)
69*6f9cba8fSJoseph Mingrone #define PFRES_MAPFAILED	15
70*6f9cba8fSJoseph Mingrone #elif defined(__NetBSD__)
71*6f9cba8fSJoseph Mingrone #define PFRES_STATELOCKED 15
72*6f9cba8fSJoseph Mingrone #elif defined(__OpenBSD__)
73*6f9cba8fSJoseph Mingrone #define PFRES_TRANSLATE	15
74*6f9cba8fSJoseph Mingrone #define PFRES_NOROUTE	16
75*6f9cba8fSJoseph Mingrone #elif defined(__APPLE__)
76*6f9cba8fSJoseph Mingrone #define PFRES_DUMMYNET  15
77*6f9cba8fSJoseph Mingrone #endif
78*6f9cba8fSJoseph Mingrone 
79*6f9cba8fSJoseph Mingrone /*
80*6f9cba8fSJoseph Mingrone  * Action values.
81*6f9cba8fSJoseph Mingrone  */
82*6f9cba8fSJoseph Mingrone #define PF_PASS			0
83*6f9cba8fSJoseph Mingrone #define PF_DROP			1
84*6f9cba8fSJoseph Mingrone #define PF_SCRUB		2
85*6f9cba8fSJoseph Mingrone #define PF_NOSCRUB		3
86*6f9cba8fSJoseph Mingrone #define PF_NAT			4
87*6f9cba8fSJoseph Mingrone #define PF_NONAT		5
88*6f9cba8fSJoseph Mingrone #define PF_BINAT		6
89*6f9cba8fSJoseph Mingrone #define PF_NOBINAT		7
90*6f9cba8fSJoseph Mingrone #define PF_RDR			8
91*6f9cba8fSJoseph Mingrone #define PF_NORDR		9
92*6f9cba8fSJoseph Mingrone #define PF_SYNPROXY_DROP	10
93*6f9cba8fSJoseph Mingrone #if defined(__FreeBSD__)
94*6f9cba8fSJoseph Mingrone #define PF_DEFER		11
95*6f9cba8fSJoseph Mingrone #elif defined(__OpenBSD__)
96*6f9cba8fSJoseph Mingrone #define PF_DEFER		11
97*6f9cba8fSJoseph Mingrone #define PF_MATCH		12
98*6f9cba8fSJoseph Mingrone #define PF_DIVERT		13
99*6f9cba8fSJoseph Mingrone #define PF_RT			14
100*6f9cba8fSJoseph Mingrone #define PF_AFRT			15
101*6f9cba8fSJoseph Mingrone #elif defined(__APPLE__)
102*6f9cba8fSJoseph Mingrone #define PF_DUMMYNET		11
103*6f9cba8fSJoseph Mingrone #define PF_NODUMMYNET		12
104*6f9cba8fSJoseph Mingrone #define PF_NAT64		13
105*6f9cba8fSJoseph Mingrone #define PF_NONAT64		14
106*6f9cba8fSJoseph Mingrone #endif
107*6f9cba8fSJoseph Mingrone 
108*6f9cba8fSJoseph Mingrone struct pf_addr {
109*6f9cba8fSJoseph Mingrone 	union {
110*6f9cba8fSJoseph Mingrone 		struct in_addr		v4;
111*6f9cba8fSJoseph Mingrone 		struct in6_addr		v6;
112*6f9cba8fSJoseph Mingrone 		uint8_t			addr8[16];
113*6f9cba8fSJoseph Mingrone 		uint16_t		addr16[8];
114*6f9cba8fSJoseph Mingrone 		uint32_t		addr32[4];
115*6f9cba8fSJoseph Mingrone 	} pfa;		    /* 128-bit address */
116*6f9cba8fSJoseph Mingrone #define v4	pfa.v4
117*6f9cba8fSJoseph Mingrone #define v6	pfa.v6
118*6f9cba8fSJoseph Mingrone #define addr8	pfa.addr8
119*6f9cba8fSJoseph Mingrone #define addr16	pfa.addr16
120*6f9cba8fSJoseph Mingrone #define addr32	pfa.addr32
121*6f9cba8fSJoseph Mingrone };
122*6f9cba8fSJoseph Mingrone 
123*6f9cba8fSJoseph Mingrone struct pfloghdr {
124*6f9cba8fSJoseph Mingrone 	uint8_t		length;
125*6f9cba8fSJoseph Mingrone 	uint8_t		af;
126*6f9cba8fSJoseph Mingrone 	uint8_t		action;
127*6f9cba8fSJoseph Mingrone 	uint8_t		reason;
128*6f9cba8fSJoseph Mingrone 	char		ifname[PFLOG_IFNAMSIZ];
129*6f9cba8fSJoseph Mingrone 	char		ruleset[PFLOG_RULESET_NAME_SIZE];
130*6f9cba8fSJoseph Mingrone 	uint32_t	rulenr;
131*6f9cba8fSJoseph Mingrone 	uint32_t	subrulenr;
132*6f9cba8fSJoseph Mingrone 	uint32_t	uid;
133*6f9cba8fSJoseph Mingrone 	int32_t		pid;
134*6f9cba8fSJoseph Mingrone 	uint32_t	rule_uid;
135*6f9cba8fSJoseph Mingrone 	int32_t		rule_pid;
136*6f9cba8fSJoseph Mingrone 	uint8_t		dir;
137*6f9cba8fSJoseph Mingrone #if defined(__OpenBSD__)
138*6f9cba8fSJoseph Mingrone 	uint8_t		rewritten;
139*6f9cba8fSJoseph Mingrone 	uint8_t		naf;
140*6f9cba8fSJoseph Mingrone 	uint8_t		pad[1];
141*6f9cba8fSJoseph Mingrone #else
142*6f9cba8fSJoseph Mingrone 	uint8_t		pad[3];
143*6f9cba8fSJoseph Mingrone #endif
144*6f9cba8fSJoseph Mingrone #if defined(__FreeBSD__)
145*6f9cba8fSJoseph Mingrone 	uint32_t	ridentifier;
146*6f9cba8fSJoseph Mingrone 	uint8_t		reserve;
147*6f9cba8fSJoseph Mingrone 	uint8_t		pad2[3];
148*6f9cba8fSJoseph Mingrone #elif defined(__OpenBSD__)
149*6f9cba8fSJoseph Mingrone 	struct pf_addr	saddr;
150*6f9cba8fSJoseph Mingrone 	struct pf_addr	daddr;
151*6f9cba8fSJoseph Mingrone 	uint16_t	sport;
152*6f9cba8fSJoseph Mingrone 	uint16_t	dport;
153*6f9cba8fSJoseph Mingrone #endif
154*6f9cba8fSJoseph Mingrone };
155*6f9cba8fSJoseph Mingrone 
156*6f9cba8fSJoseph Mingrone 
157*6f9cba8fSJoseph Mingrone 
158