xref: /freebsd/sys/net/pfvar.h (revision cecfaf9b)
1fe267a55SPedro F. Giffuni /*-
2fe267a55SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause
3fe267a55SPedro F. Giffuni  *
43b3a8eb9SGleb Smirnoff  * Copyright (c) 2001 Daniel Hartmeier
53b3a8eb9SGleb Smirnoff  * All rights reserved.
63b3a8eb9SGleb Smirnoff  *
73b3a8eb9SGleb Smirnoff  * Redistribution and use in source and binary forms, with or without
83b3a8eb9SGleb Smirnoff  * modification, are permitted provided that the following conditions
93b3a8eb9SGleb Smirnoff  * are met:
103b3a8eb9SGleb Smirnoff  *
113b3a8eb9SGleb Smirnoff  *    - Redistributions of source code must retain the above copyright
123b3a8eb9SGleb Smirnoff  *      notice, this list of conditions and the following disclaimer.
133b3a8eb9SGleb Smirnoff  *    - Redistributions in binary form must reproduce the above
143b3a8eb9SGleb Smirnoff  *      copyright notice, this list of conditions and the following
153b3a8eb9SGleb Smirnoff  *      disclaimer in the documentation and/or other materials provided
163b3a8eb9SGleb Smirnoff  *      with the distribution.
173b3a8eb9SGleb Smirnoff  *
183b3a8eb9SGleb Smirnoff  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
193b3a8eb9SGleb Smirnoff  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
203b3a8eb9SGleb Smirnoff  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
213b3a8eb9SGleb Smirnoff  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
223b3a8eb9SGleb Smirnoff  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
233b3a8eb9SGleb Smirnoff  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
243b3a8eb9SGleb Smirnoff  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
253b3a8eb9SGleb Smirnoff  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
263b3a8eb9SGleb Smirnoff  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
273b3a8eb9SGleb Smirnoff  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
283b3a8eb9SGleb Smirnoff  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
293b3a8eb9SGleb Smirnoff  * POSSIBILITY OF SUCH DAMAGE.
303b3a8eb9SGleb Smirnoff  *
319ed8bbbdSGleb Smirnoff  *	$OpenBSD: pfvar.h,v 1.282 2009/01/29 15:12:28 pyr Exp $
329e8c4accSGleb Smirnoff  *	$FreeBSD$
333b3a8eb9SGleb Smirnoff  */
343b3a8eb9SGleb Smirnoff 
353b3a8eb9SGleb Smirnoff #ifndef _NET_PFVAR_H_
363b3a8eb9SGleb Smirnoff #define _NET_PFVAR_H_
373b3a8eb9SGleb Smirnoff 
383b3a8eb9SGleb Smirnoff #include <sys/param.h>
393b3a8eb9SGleb Smirnoff #include <sys/queue.h>
4048278b88SGleb Smirnoff #include <sys/counter.h>
41455969d3SKristof Provost #include <sys/cpuset.h>
428ec07310SGleb Smirnoff #include <sys/malloc.h>
433b3a8eb9SGleb Smirnoff #include <sys/refcount.h>
448f2ac656SPatrick Kelsey #include <sys/sysctl.h>
45d25c25dcSKristof Provost #include <sys/lock.h>
46455969d3SKristof Provost #include <sys/rmlock.h>
473b3a8eb9SGleb Smirnoff #include <sys/tree.h>
488ec07310SGleb Smirnoff #include <vm/uma.h>
493b3a8eb9SGleb Smirnoff 
503b3a8eb9SGleb Smirnoff #include <net/radix.h>
513b3a8eb9SGleb Smirnoff #include <netinet/in.h>
523b3a8eb9SGleb Smirnoff 
5375bf2db3SGleb Smirnoff #include <netpfil/pf/pf.h>
5475bf2db3SGleb Smirnoff #include <netpfil/pf/pf_altq.h>
5575bf2db3SGleb Smirnoff #include <netpfil/pf/pf_mtag.h>
563b3a8eb9SGleb Smirnoff 
573b3a8eb9SGleb Smirnoff #ifdef _KERNEL
583b3a8eb9SGleb Smirnoff 
598f2ac656SPatrick Kelsey SYSCTL_DECL(_net_pf);
608f2ac656SPatrick Kelsey MALLOC_DECLARE(M_PFHASH);
618f2ac656SPatrick Kelsey 
623b3a8eb9SGleb Smirnoff struct pfi_dynaddr {
633b3a8eb9SGleb Smirnoff 	TAILQ_ENTRY(pfi_dynaddr)	 entry;
643b3a8eb9SGleb Smirnoff 	struct pf_addr			 pfid_addr4;
653b3a8eb9SGleb Smirnoff 	struct pf_addr			 pfid_mask4;
663b3a8eb9SGleb Smirnoff 	struct pf_addr			 pfid_addr6;
673b3a8eb9SGleb Smirnoff 	struct pf_addr			 pfid_mask6;
683b3a8eb9SGleb Smirnoff 	struct pfr_ktable		*pfid_kt;
69320c1116SKristof Provost 	struct pfi_kkif			*pfid_kif;
703b3a8eb9SGleb Smirnoff 	int				 pfid_net;	/* mask or 128 */
713b3a8eb9SGleb Smirnoff 	int				 pfid_acnt4;	/* address count IPv4 */
723b3a8eb9SGleb Smirnoff 	int				 pfid_acnt6;	/* address count IPv6 */
733b3a8eb9SGleb Smirnoff 	sa_family_t			 pfid_af;	/* rule af */
743b3a8eb9SGleb Smirnoff 	u_int8_t			 pfid_iflags;	/* PFI_AFLAG_* */
753b3a8eb9SGleb Smirnoff };
763b3a8eb9SGleb Smirnoff 
773b3a8eb9SGleb Smirnoff /*
783b3a8eb9SGleb Smirnoff  * Address manipulation macros
793b3a8eb9SGleb Smirnoff  */
803b3a8eb9SGleb Smirnoff #define	HTONL(x)	(x) = htonl((__uint32_t)(x))
813b3a8eb9SGleb Smirnoff #define	HTONS(x)	(x) = htons((__uint16_t)(x))
823b3a8eb9SGleb Smirnoff #define	NTOHL(x)	(x) = ntohl((__uint32_t)(x))
833b3a8eb9SGleb Smirnoff #define	NTOHS(x)	(x) = ntohs((__uint16_t)(x))
843b3a8eb9SGleb Smirnoff 
853b3a8eb9SGleb Smirnoff #define	PF_NAME		"pf"
863b3a8eb9SGleb Smirnoff 
873b3a8eb9SGleb Smirnoff #define	PF_HASHROW_ASSERT(h)	mtx_assert(&(h)->lock, MA_OWNED)
883b3a8eb9SGleb Smirnoff #define	PF_HASHROW_LOCK(h)	mtx_lock(&(h)->lock)
893b3a8eb9SGleb Smirnoff #define	PF_HASHROW_UNLOCK(h)	mtx_unlock(&(h)->lock)
903b3a8eb9SGleb Smirnoff 
913b3a8eb9SGleb Smirnoff #define	PF_STATE_LOCK(s)						\
923b3a8eb9SGleb Smirnoff 	do {								\
933b3a8eb9SGleb Smirnoff 		struct pf_idhash *_ih = &V_pf_idhash[PF_IDHASH(s)];	\
943b3a8eb9SGleb Smirnoff 		PF_HASHROW_LOCK(_ih);					\
953b3a8eb9SGleb Smirnoff 	} while (0)
963b3a8eb9SGleb Smirnoff 
973b3a8eb9SGleb Smirnoff #define	PF_STATE_UNLOCK(s)						\
983b3a8eb9SGleb Smirnoff 	do {								\
993b3a8eb9SGleb Smirnoff 		struct pf_idhash *_ih = &V_pf_idhash[PF_IDHASH((s))];	\
1003b3a8eb9SGleb Smirnoff 		PF_HASHROW_UNLOCK(_ih);					\
1013b3a8eb9SGleb Smirnoff 	} while (0)
1023b3a8eb9SGleb Smirnoff 
1033b3a8eb9SGleb Smirnoff #ifdef INVARIANTS
1043b3a8eb9SGleb Smirnoff #define	PF_STATE_LOCK_ASSERT(s)						\
1053b3a8eb9SGleb Smirnoff 	do {								\
1063b3a8eb9SGleb Smirnoff 		struct pf_idhash *_ih = &V_pf_idhash[PF_IDHASH(s)];	\
1073b3a8eb9SGleb Smirnoff 		PF_HASHROW_ASSERT(_ih);					\
1083b3a8eb9SGleb Smirnoff 	} while (0)
1093b3a8eb9SGleb Smirnoff #else /* !INVARIANTS */
1103b3a8eb9SGleb Smirnoff #define	PF_STATE_LOCK_ASSERT(s)		do {} while (0)
1113b3a8eb9SGleb Smirnoff #endif /* INVARIANTS */
1123b3a8eb9SGleb Smirnoff 
1133b3a8eb9SGleb Smirnoff extern struct mtx pf_unlnkdrules_mtx;
1143b3a8eb9SGleb Smirnoff #define	PF_UNLNKDRULES_LOCK()	mtx_lock(&pf_unlnkdrules_mtx)
1153b3a8eb9SGleb Smirnoff #define	PF_UNLNKDRULES_UNLOCK()	mtx_unlock(&pf_unlnkdrules_mtx)
1163b3a8eb9SGleb Smirnoff 
117455969d3SKristof Provost extern struct rmlock pf_rules_lock;
118455969d3SKristof Provost #define	PF_RULES_RLOCK_TRACKER	struct rm_priotracker _pf_rules_tracker
119455969d3SKristof Provost #define	PF_RULES_RLOCK()	rm_rlock(&pf_rules_lock, &_pf_rules_tracker)
120455969d3SKristof Provost #define	PF_RULES_RUNLOCK()	rm_runlock(&pf_rules_lock, &_pf_rules_tracker)
121455969d3SKristof Provost #define	PF_RULES_WLOCK()	rm_wlock(&pf_rules_lock)
122455969d3SKristof Provost #define	PF_RULES_WUNLOCK()	rm_wunlock(&pf_rules_lock)
123455969d3SKristof Provost #define	PF_RULES_ASSERT()	rm_assert(&pf_rules_lock, RA_LOCKED)
124455969d3SKristof Provost #define	PF_RULES_RASSERT()	rm_assert(&pf_rules_lock, RA_RLOCKED)
125455969d3SKristof Provost #define	PF_RULES_WASSERT()	rm_assert(&pf_rules_lock, RA_WLOCKED)
1263b3a8eb9SGleb Smirnoff 
1272f8fb3a8SKristof Provost extern struct sx pf_end_lock;
1282f8fb3a8SKristof Provost 
1293b3a8eb9SGleb Smirnoff #define	PF_MODVER	1
1303b3a8eb9SGleb Smirnoff #define	PFLOG_MODVER	1
1313b3a8eb9SGleb Smirnoff #define	PFSYNC_MODVER	1
1323b3a8eb9SGleb Smirnoff 
1333b3a8eb9SGleb Smirnoff #define	PFLOG_MINVER	1
1343b3a8eb9SGleb Smirnoff #define	PFLOG_PREFVER	PFLOG_MODVER
1353b3a8eb9SGleb Smirnoff #define	PFLOG_MAXVER	1
1363b3a8eb9SGleb Smirnoff #define	PFSYNC_MINVER	1
1373b3a8eb9SGleb Smirnoff #define	PFSYNC_PREFVER	PFSYNC_MODVER
1383b3a8eb9SGleb Smirnoff #define	PFSYNC_MAXVER	1
1393b3a8eb9SGleb Smirnoff 
1403b3a8eb9SGleb Smirnoff #ifdef INET
1413b3a8eb9SGleb Smirnoff #ifndef INET6
1423b3a8eb9SGleb Smirnoff #define	PF_INET_ONLY
1433b3a8eb9SGleb Smirnoff #endif /* ! INET6 */
1443b3a8eb9SGleb Smirnoff #endif /* INET */
1453b3a8eb9SGleb Smirnoff 
1463b3a8eb9SGleb Smirnoff #ifdef INET6
1473b3a8eb9SGleb Smirnoff #ifndef INET
1483b3a8eb9SGleb Smirnoff #define	PF_INET6_ONLY
1493b3a8eb9SGleb Smirnoff #endif /* ! INET */
1503b3a8eb9SGleb Smirnoff #endif /* INET6 */
1513b3a8eb9SGleb Smirnoff 
1523b3a8eb9SGleb Smirnoff #ifdef INET
1533b3a8eb9SGleb Smirnoff #ifdef INET6
1543b3a8eb9SGleb Smirnoff #define	PF_INET_INET6
1553b3a8eb9SGleb Smirnoff #endif /* INET6 */
1563b3a8eb9SGleb Smirnoff #endif /* INET */
1573b3a8eb9SGleb Smirnoff 
1583b3a8eb9SGleb Smirnoff #else
1593b3a8eb9SGleb Smirnoff 
1603b3a8eb9SGleb Smirnoff #define	PF_INET_INET6
1613b3a8eb9SGleb Smirnoff 
1623b3a8eb9SGleb Smirnoff #endif /* _KERNEL */
1633b3a8eb9SGleb Smirnoff 
1643b3a8eb9SGleb Smirnoff /* Both IPv4 and IPv6 */
1653b3a8eb9SGleb Smirnoff #ifdef PF_INET_INET6
1663b3a8eb9SGleb Smirnoff 
1673b3a8eb9SGleb Smirnoff #define PF_AEQ(a, b, c) \
1683b3a8eb9SGleb Smirnoff 	((c == AF_INET && (a)->addr32[0] == (b)->addr32[0]) || \
1696332e4ccSGeorge V. Neville-Neil 	(c == AF_INET6 && (a)->addr32[3] == (b)->addr32[3] && \
1703b3a8eb9SGleb Smirnoff 	(a)->addr32[2] == (b)->addr32[2] && \
1713b3a8eb9SGleb Smirnoff 	(a)->addr32[1] == (b)->addr32[1] && \
1723b3a8eb9SGleb Smirnoff 	(a)->addr32[0] == (b)->addr32[0])) \
1733b3a8eb9SGleb Smirnoff 
1743b3a8eb9SGleb Smirnoff #define PF_ANEQ(a, b, c) \
1757d762423SKristof Provost 	((c == AF_INET && (a)->addr32[0] != (b)->addr32[0]) || \
17626022843SKristof Provost 	(c == AF_INET6 && ((a)->addr32[0] != (b)->addr32[0] || \
1773b3a8eb9SGleb Smirnoff 	(a)->addr32[1] != (b)->addr32[1] || \
1786332e4ccSGeorge V. Neville-Neil 	(a)->addr32[2] != (b)->addr32[2] || \
17926022843SKristof Provost 	(a)->addr32[3] != (b)->addr32[3]))) \
1803b3a8eb9SGleb Smirnoff 
1813b3a8eb9SGleb Smirnoff #define PF_AZERO(a, c) \
1823b3a8eb9SGleb Smirnoff 	((c == AF_INET && !(a)->addr32[0]) || \
1836332e4ccSGeorge V. Neville-Neil 	(c == AF_INET6 && !(a)->addr32[0] && !(a)->addr32[1] && \
1843b3a8eb9SGleb Smirnoff 	!(a)->addr32[2] && !(a)->addr32[3] )) \
1853b3a8eb9SGleb Smirnoff 
1863b3a8eb9SGleb Smirnoff #define PF_MATCHA(n, a, m, b, f) \
1873b3a8eb9SGleb Smirnoff 	pf_match_addr(n, a, m, b, f)
1883b3a8eb9SGleb Smirnoff 
1893b3a8eb9SGleb Smirnoff #define PF_ACPY(a, b, f) \
1903b3a8eb9SGleb Smirnoff 	pf_addrcpy(a, b, f)
1913b3a8eb9SGleb Smirnoff 
1923b3a8eb9SGleb Smirnoff #define PF_AINC(a, f) \
1933b3a8eb9SGleb Smirnoff 	pf_addr_inc(a, f)
1943b3a8eb9SGleb Smirnoff 
1953b3a8eb9SGleb Smirnoff #define PF_POOLMASK(a, b, c, d, f) \
1963b3a8eb9SGleb Smirnoff 	pf_poolmask(a, b, c, d, f)
1973b3a8eb9SGleb Smirnoff 
1983b3a8eb9SGleb Smirnoff #else
1993b3a8eb9SGleb Smirnoff 
2003b3a8eb9SGleb Smirnoff /* Just IPv6 */
2013b3a8eb9SGleb Smirnoff 
2023b3a8eb9SGleb Smirnoff #ifdef PF_INET6_ONLY
2033b3a8eb9SGleb Smirnoff 
2043b3a8eb9SGleb Smirnoff #define PF_AEQ(a, b, c) \
2053b3a8eb9SGleb Smirnoff 	((a)->addr32[3] == (b)->addr32[3] && \
2063b3a8eb9SGleb Smirnoff 	(a)->addr32[2] == (b)->addr32[2] && \
2073b3a8eb9SGleb Smirnoff 	(a)->addr32[1] == (b)->addr32[1] && \
2083b3a8eb9SGleb Smirnoff 	(a)->addr32[0] == (b)->addr32[0]) \
2093b3a8eb9SGleb Smirnoff 
2103b3a8eb9SGleb Smirnoff #define PF_ANEQ(a, b, c) \
2113b3a8eb9SGleb Smirnoff 	((a)->addr32[3] != (b)->addr32[3] || \
2123b3a8eb9SGleb Smirnoff 	(a)->addr32[2] != (b)->addr32[2] || \
2133b3a8eb9SGleb Smirnoff 	(a)->addr32[1] != (b)->addr32[1] || \
2143b3a8eb9SGleb Smirnoff 	(a)->addr32[0] != (b)->addr32[0]) \
2153b3a8eb9SGleb Smirnoff 
2163b3a8eb9SGleb Smirnoff #define PF_AZERO(a, c) \
2173b3a8eb9SGleb Smirnoff 	(!(a)->addr32[0] && \
2183b3a8eb9SGleb Smirnoff 	!(a)->addr32[1] && \
2193b3a8eb9SGleb Smirnoff 	!(a)->addr32[2] && \
2203b3a8eb9SGleb Smirnoff 	!(a)->addr32[3] ) \
2213b3a8eb9SGleb Smirnoff 
2223b3a8eb9SGleb Smirnoff #define PF_MATCHA(n, a, m, b, f) \
2233b3a8eb9SGleb Smirnoff 	pf_match_addr(n, a, m, b, f)
2243b3a8eb9SGleb Smirnoff 
2253b3a8eb9SGleb Smirnoff #define PF_ACPY(a, b, f) \
2263b3a8eb9SGleb Smirnoff 	pf_addrcpy(a, b, f)
2273b3a8eb9SGleb Smirnoff 
2283b3a8eb9SGleb Smirnoff #define PF_AINC(a, f) \
2293b3a8eb9SGleb Smirnoff 	pf_addr_inc(a, f)
2303b3a8eb9SGleb Smirnoff 
2313b3a8eb9SGleb Smirnoff #define PF_POOLMASK(a, b, c, d, f) \
2323b3a8eb9SGleb Smirnoff 	pf_poolmask(a, b, c, d, f)
2333b3a8eb9SGleb Smirnoff 
2343b3a8eb9SGleb Smirnoff #else
2353b3a8eb9SGleb Smirnoff 
2363b3a8eb9SGleb Smirnoff /* Just IPv4 */
2373b3a8eb9SGleb Smirnoff #ifdef PF_INET_ONLY
2383b3a8eb9SGleb Smirnoff 
2393b3a8eb9SGleb Smirnoff #define PF_AEQ(a, b, c) \
2403b3a8eb9SGleb Smirnoff 	((a)->addr32[0] == (b)->addr32[0])
2413b3a8eb9SGleb Smirnoff 
2423b3a8eb9SGleb Smirnoff #define PF_ANEQ(a, b, c) \
2433b3a8eb9SGleb Smirnoff 	((a)->addr32[0] != (b)->addr32[0])
2443b3a8eb9SGleb Smirnoff 
2453b3a8eb9SGleb Smirnoff #define PF_AZERO(a, c) \
2463b3a8eb9SGleb Smirnoff 	(!(a)->addr32[0])
2473b3a8eb9SGleb Smirnoff 
2483b3a8eb9SGleb Smirnoff #define PF_MATCHA(n, a, m, b, f) \
2493b3a8eb9SGleb Smirnoff 	pf_match_addr(n, a, m, b, f)
2503b3a8eb9SGleb Smirnoff 
2513b3a8eb9SGleb Smirnoff #define PF_ACPY(a, b, f) \
2523b3a8eb9SGleb Smirnoff 	(a)->v4.s_addr = (b)->v4.s_addr
2533b3a8eb9SGleb Smirnoff 
2543b3a8eb9SGleb Smirnoff #define PF_AINC(a, f) \
2553b3a8eb9SGleb Smirnoff 	do { \
2563b3a8eb9SGleb Smirnoff 		(a)->addr32[0] = htonl(ntohl((a)->addr32[0]) + 1); \
2573b3a8eb9SGleb Smirnoff 	} while (0)
2583b3a8eb9SGleb Smirnoff 
2593b3a8eb9SGleb Smirnoff #define PF_POOLMASK(a, b, c, d, f) \
2603b3a8eb9SGleb Smirnoff 	do { \
2613b3a8eb9SGleb Smirnoff 		(a)->addr32[0] = ((b)->addr32[0] & (c)->addr32[0]) | \
2623b3a8eb9SGleb Smirnoff 		(((c)->addr32[0] ^ 0xffffffff ) & (d)->addr32[0]); \
2633b3a8eb9SGleb Smirnoff 	} while (0)
2643b3a8eb9SGleb Smirnoff 
2653b3a8eb9SGleb Smirnoff #endif /* PF_INET_ONLY */
2663b3a8eb9SGleb Smirnoff #endif /* PF_INET6_ONLY */
2673b3a8eb9SGleb Smirnoff #endif /* PF_INET_INET6 */
2683b3a8eb9SGleb Smirnoff 
2693b3a8eb9SGleb Smirnoff /*
2703b3a8eb9SGleb Smirnoff  * XXX callers not FIB-aware in our version of pf yet.
2713b3a8eb9SGleb Smirnoff  * OpenBSD fixed it later it seems, 2010/05/07 13:33:16 claudio.
2723b3a8eb9SGleb Smirnoff  */
2733b3a8eb9SGleb Smirnoff #define	PF_MISMATCHAW(aw, x, af, neg, ifp, rtid)			\
2743b3a8eb9SGleb Smirnoff 	(								\
2753b3a8eb9SGleb Smirnoff 		(((aw)->type == PF_ADDR_NOROUTE &&			\
2763b3a8eb9SGleb Smirnoff 		    pf_routable((x), (af), NULL, (rtid))) ||		\
2773b3a8eb9SGleb Smirnoff 		(((aw)->type == PF_ADDR_URPFFAILED && (ifp) != NULL &&	\
2783b3a8eb9SGleb Smirnoff 		    pf_routable((x), (af), (ifp), (rtid))) ||		\
2793b3a8eb9SGleb Smirnoff 		((aw)->type == PF_ADDR_TABLE &&				\
2803b3a8eb9SGleb Smirnoff 		    !pfr_match_addr((aw)->p.tbl, (x), (af))) ||		\
2813b3a8eb9SGleb Smirnoff 		((aw)->type == PF_ADDR_DYNIFTL &&			\
2823b3a8eb9SGleb Smirnoff 		    !pfi_match_addr((aw)->p.dyn, (x), (af))) ||		\
2833b3a8eb9SGleb Smirnoff 		((aw)->type == PF_ADDR_RANGE &&				\
2843b3a8eb9SGleb Smirnoff 		    !pf_match_addr_range(&(aw)->v.a.addr,		\
2853b3a8eb9SGleb Smirnoff 		    &(aw)->v.a.mask, (x), (af))) ||			\
2863b3a8eb9SGleb Smirnoff 		((aw)->type == PF_ADDR_ADDRMASK &&			\
2873b3a8eb9SGleb Smirnoff 		    !PF_AZERO(&(aw)->v.a.mask, (af)) &&			\
2883b3a8eb9SGleb Smirnoff 		    !PF_MATCHA(0, &(aw)->v.a.addr,			\
2893b3a8eb9SGleb Smirnoff 		    &(aw)->v.a.mask, (x), (af))))) !=			\
2903b3a8eb9SGleb Smirnoff 		(neg)							\
2913b3a8eb9SGleb Smirnoff 	)
2923b3a8eb9SGleb Smirnoff 
293c3f69af0SKristof Provost #define PF_ALGNMNT(off) (((off) % 2) == 0)
294c3f69af0SKristof Provost 
29517ad7334SKristof Provost #ifdef _KERNEL
296e86bddeaSKristof Provost 
297320c1116SKristof Provost struct pf_kpooladdr {
298320c1116SKristof Provost 	struct pf_addr_wrap		 addr;
299320c1116SKristof Provost 	TAILQ_ENTRY(pf_kpooladdr)	 entries;
300320c1116SKristof Provost 	char				 ifname[IFNAMSIZ];
301320c1116SKristof Provost 	struct pfi_kkif			*kif;
302320c1116SKristof Provost };
303320c1116SKristof Provost 
304320c1116SKristof Provost TAILQ_HEAD(pf_kpalist, pf_kpooladdr);
305320c1116SKristof Provost 
306320c1116SKristof Provost struct pf_kpool {
307320c1116SKristof Provost 	struct pf_kpalist	 list;
308320c1116SKristof Provost 	struct pf_kpooladdr	*cur;
309320c1116SKristof Provost 	struct pf_poolhashkey	 key;
310320c1116SKristof Provost 	struct pf_addr		 counter;
311320c1116SKristof Provost 	int			 tblidx;
312320c1116SKristof Provost 	u_int16_t		 proxy_port[2];
313320c1116SKristof Provost 	u_int8_t		 opts;
314320c1116SKristof Provost };
315320c1116SKristof Provost 
316e86bddeaSKristof Provost union pf_krule_ptr {
317e86bddeaSKristof Provost 	struct pf_krule		*ptr;
318e86bddeaSKristof Provost 	u_int32_t		 nr;
319e86bddeaSKristof Provost };
320e86bddeaSKristof Provost 
321e86bddeaSKristof Provost struct pf_krule {
322e86bddeaSKristof Provost 	struct pf_rule_addr	 src;
323e86bddeaSKristof Provost 	struct pf_rule_addr	 dst;
324e86bddeaSKristof Provost 	union pf_krule_ptr	 skip[PF_SKIP_COUNT];
325e86bddeaSKristof Provost 	char			 label[PF_RULE_LABEL_SIZE];
326e86bddeaSKristof Provost 	char			 ifname[IFNAMSIZ];
327e86bddeaSKristof Provost 	char			 qname[PF_QNAME_SIZE];
328e86bddeaSKristof Provost 	char			 pqname[PF_QNAME_SIZE];
329e86bddeaSKristof Provost 	char			 tagname[PF_TAG_NAME_SIZE];
330e86bddeaSKristof Provost 	char			 match_tagname[PF_TAG_NAME_SIZE];
331e86bddeaSKristof Provost 
332e86bddeaSKristof Provost 	char			 overload_tblname[PF_TABLE_NAME_SIZE];
333e86bddeaSKristof Provost 
334e86bddeaSKristof Provost 	TAILQ_ENTRY(pf_krule)	 entries;
335320c1116SKristof Provost 	struct pf_kpool		 rpool;
336e86bddeaSKristof Provost 
337c3adacdaSKristof Provost 	counter_u64_t		 evaluations;
338c3adacdaSKristof Provost 	counter_u64_t		 packets[2];
339c3adacdaSKristof Provost 	counter_u64_t		 bytes[2];
340e86bddeaSKristof Provost 
341320c1116SKristof Provost 	struct pfi_kkif		*kif;
342e86bddeaSKristof Provost 	struct pf_kanchor	*anchor;
343e86bddeaSKristof Provost 	struct pfr_ktable	*overload_tbl;
344e86bddeaSKristof Provost 
345e86bddeaSKristof Provost 	pf_osfp_t		 os_fingerprint;
346e86bddeaSKristof Provost 
347e86bddeaSKristof Provost 	int			 rtableid;
348e86bddeaSKristof Provost 	u_int32_t		 timeout[PFTM_MAX];
349e86bddeaSKristof Provost 	u_int32_t		 max_states;
350e86bddeaSKristof Provost 	u_int32_t		 max_src_nodes;
351e86bddeaSKristof Provost 	u_int32_t		 max_src_states;
352e86bddeaSKristof Provost 	u_int32_t		 max_src_conn;
353e86bddeaSKristof Provost 	struct {
354e86bddeaSKristof Provost 		u_int32_t		limit;
355e86bddeaSKristof Provost 		u_int32_t		seconds;
356e86bddeaSKristof Provost 	}			 max_src_conn_rate;
357e86bddeaSKristof Provost 	u_int32_t		 qid;
358e86bddeaSKristof Provost 	u_int32_t		 pqid;
359e86bddeaSKristof Provost 	u_int32_t		 rt_listid;
360e86bddeaSKristof Provost 	u_int32_t		 nr;
361e86bddeaSKristof Provost 	u_int32_t		 prob;
362e86bddeaSKristof Provost 	uid_t			 cuid;
363e86bddeaSKristof Provost 	pid_t			 cpid;
364e86bddeaSKristof Provost 
365e86bddeaSKristof Provost 	counter_u64_t		 states_cur;
366e86bddeaSKristof Provost 	counter_u64_t		 states_tot;
367e86bddeaSKristof Provost 	counter_u64_t		 src_nodes;
368e86bddeaSKristof Provost 
369e86bddeaSKristof Provost 	u_int16_t		 return_icmp;
370e86bddeaSKristof Provost 	u_int16_t		 return_icmp6;
371e86bddeaSKristof Provost 	u_int16_t		 max_mss;
372e86bddeaSKristof Provost 	u_int16_t		 tag;
373e86bddeaSKristof Provost 	u_int16_t		 match_tag;
374e86bddeaSKristof Provost 	u_int16_t		 scrub_flags;
375e86bddeaSKristof Provost 
376e86bddeaSKristof Provost 	struct pf_rule_uid	 uid;
377e86bddeaSKristof Provost 	struct pf_rule_gid	 gid;
378e86bddeaSKristof Provost 
379e86bddeaSKristof Provost 	u_int32_t		 rule_flag;
380e86bddeaSKristof Provost 	u_int8_t		 action;
381e86bddeaSKristof Provost 	u_int8_t		 direction;
382e86bddeaSKristof Provost 	u_int8_t		 log;
383e86bddeaSKristof Provost 	u_int8_t		 logif;
384e86bddeaSKristof Provost 	u_int8_t		 quick;
385e86bddeaSKristof Provost 	u_int8_t		 ifnot;
386e86bddeaSKristof Provost 	u_int8_t		 match_tag_not;
387e86bddeaSKristof Provost 	u_int8_t		 natpass;
388e86bddeaSKristof Provost 
389e86bddeaSKristof Provost 	u_int8_t		 keep_state;
390e86bddeaSKristof Provost 	sa_family_t		 af;
391e86bddeaSKristof Provost 	u_int8_t		 proto;
392e86bddeaSKristof Provost 	u_int8_t		 type;
393e86bddeaSKristof Provost 	u_int8_t		 code;
394e86bddeaSKristof Provost 	u_int8_t		 flags;
395e86bddeaSKristof Provost 	u_int8_t		 flagset;
396e86bddeaSKristof Provost 	u_int8_t		 min_ttl;
397e86bddeaSKristof Provost 	u_int8_t		 allow_opts;
398e86bddeaSKristof Provost 	u_int8_t		 rt;
399e86bddeaSKristof Provost 	u_int8_t		 return_ttl;
400e86bddeaSKristof Provost 	u_int8_t		 tos;
401e86bddeaSKristof Provost 	u_int8_t		 set_tos;
402e86bddeaSKristof Provost 	u_int8_t		 anchor_relative;
403e86bddeaSKristof Provost 	u_int8_t		 anchor_wildcard;
404e86bddeaSKristof Provost 
405e86bddeaSKristof Provost 	u_int8_t		 flush;
406e86bddeaSKristof Provost 	u_int8_t		 prio;
407e86bddeaSKristof Provost 	u_int8_t		 set_prio[2];
408e86bddeaSKristof Provost 
409e86bddeaSKristof Provost 	struct {
410e86bddeaSKristof Provost 		struct pf_addr		addr;
411e86bddeaSKristof Provost 		u_int16_t		port;
412e86bddeaSKristof Provost 	}			divert;
413e86bddeaSKristof Provost };
414e86bddeaSKristof Provost 
41517ad7334SKristof Provost struct pf_ksrc_node {
41617ad7334SKristof Provost 	LIST_ENTRY(pf_ksrc_node) entry;
4173b3a8eb9SGleb Smirnoff 	struct pf_addr	 addr;
4183b3a8eb9SGleb Smirnoff 	struct pf_addr	 raddr;
419e86bddeaSKristof Provost 	union pf_krule_ptr rule;
420320c1116SKristof Provost 	struct pfi_kkif	*kif;
421fbbf270eSKristof Provost 	counter_u64_t	 bytes[2];
422fbbf270eSKristof Provost 	counter_u64_t	 packets[2];
4233b3a8eb9SGleb Smirnoff 	u_int32_t	 states;
4243b3a8eb9SGleb Smirnoff 	u_int32_t	 conn;
4253b3a8eb9SGleb Smirnoff 	struct pf_threshold	conn_rate;
4263b3a8eb9SGleb Smirnoff 	u_int32_t	 creation;
4273b3a8eb9SGleb Smirnoff 	u_int32_t	 expire;
4283b3a8eb9SGleb Smirnoff 	sa_family_t	 af;
4293b3a8eb9SGleb Smirnoff 	u_int8_t	 ruletype;
4303b3a8eb9SGleb Smirnoff };
43117ad7334SKristof Provost #endif
4323b3a8eb9SGleb Smirnoff 
4333b3a8eb9SGleb Smirnoff struct pf_state_scrub {
4343b3a8eb9SGleb Smirnoff 	struct timeval	pfss_last;	/* time received last packet	*/
4353b3a8eb9SGleb Smirnoff 	u_int32_t	pfss_tsecr;	/* last echoed timestamp	*/
4363b3a8eb9SGleb Smirnoff 	u_int32_t	pfss_tsval;	/* largest timestamp		*/
4373b3a8eb9SGleb Smirnoff 	u_int32_t	pfss_tsval0;	/* original timestamp		*/
4383b3a8eb9SGleb Smirnoff 	u_int16_t	pfss_flags;
4393b3a8eb9SGleb Smirnoff #define PFSS_TIMESTAMP	0x0001		/* modulate timestamp		*/
4403b3a8eb9SGleb Smirnoff #define PFSS_PAWS	0x0010		/* stricter PAWS checks		*/
4413b3a8eb9SGleb Smirnoff #define PFSS_PAWS_IDLED	0x0020		/* was idle too long.  no PAWS	*/
4423b3a8eb9SGleb Smirnoff #define PFSS_DATA_TS	0x0040		/* timestamp on data packets	*/
4433b3a8eb9SGleb Smirnoff #define PFSS_DATA_NOTS	0x0080		/* no timestamp on data packets	*/
4443b3a8eb9SGleb Smirnoff 	u_int8_t	pfss_ttl;	/* stashed TTL			*/
4453b3a8eb9SGleb Smirnoff 	u_int8_t	pad;
4463b3a8eb9SGleb Smirnoff 	u_int32_t	pfss_ts_mod;	/* timestamp modulation		*/
4473b3a8eb9SGleb Smirnoff };
4483b3a8eb9SGleb Smirnoff 
4493b3a8eb9SGleb Smirnoff struct pf_state_host {
4503b3a8eb9SGleb Smirnoff 	struct pf_addr	addr;
4513b3a8eb9SGleb Smirnoff 	u_int16_t	port;
4523b3a8eb9SGleb Smirnoff 	u_int16_t	pad;
4533b3a8eb9SGleb Smirnoff };
4543b3a8eb9SGleb Smirnoff 
4553b3a8eb9SGleb Smirnoff struct pf_state_peer {
4563b3a8eb9SGleb Smirnoff 	struct pf_state_scrub	*scrub;	/* state is scrubbed		*/
4573b3a8eb9SGleb Smirnoff 	u_int32_t	seqlo;		/* Max sequence number sent	*/
4583b3a8eb9SGleb Smirnoff 	u_int32_t	seqhi;		/* Max the other end ACKd + win	*/
4593b3a8eb9SGleb Smirnoff 	u_int32_t	seqdiff;	/* Sequence number modulator	*/
4603b3a8eb9SGleb Smirnoff 	u_int16_t	max_win;	/* largest window (pre scaling)	*/
4613b3a8eb9SGleb Smirnoff 	u_int16_t	mss;		/* Maximum segment size option	*/
4623b3a8eb9SGleb Smirnoff 	u_int8_t	state;		/* active state level		*/
4633b3a8eb9SGleb Smirnoff 	u_int8_t	wscale;		/* window scaling factor	*/
4643b3a8eb9SGleb Smirnoff 	u_int8_t	tcp_est;	/* Did we reach TCPS_ESTABLISHED */
4653b3a8eb9SGleb Smirnoff 	u_int8_t	pad[1];
4663b3a8eb9SGleb Smirnoff };
4673b3a8eb9SGleb Smirnoff 
4683b3a8eb9SGleb Smirnoff /* Keep synced with struct pf_state_key. */
4693b3a8eb9SGleb Smirnoff struct pf_state_key_cmp {
4703b3a8eb9SGleb Smirnoff 	struct pf_addr	 addr[2];
4713b3a8eb9SGleb Smirnoff 	u_int16_t	 port[2];
4723b3a8eb9SGleb Smirnoff 	sa_family_t	 af;
4733b3a8eb9SGleb Smirnoff 	u_int8_t	 proto;
4743b3a8eb9SGleb Smirnoff 	u_int8_t	 pad[2];
4753b3a8eb9SGleb Smirnoff };
4763b3a8eb9SGleb Smirnoff 
4773b3a8eb9SGleb Smirnoff struct pf_state_key {
4783b3a8eb9SGleb Smirnoff 	struct pf_addr	 addr[2];
4793b3a8eb9SGleb Smirnoff 	u_int16_t	 port[2];
4803b3a8eb9SGleb Smirnoff 	sa_family_t	 af;
4813b3a8eb9SGleb Smirnoff 	u_int8_t	 proto;
4823b3a8eb9SGleb Smirnoff 	u_int8_t	 pad[2];
4833b3a8eb9SGleb Smirnoff 
4843b3a8eb9SGleb Smirnoff 	LIST_ENTRY(pf_state_key) entry;
4853b3a8eb9SGleb Smirnoff 	TAILQ_HEAD(, pf_state)	 states[2];
4863b3a8eb9SGleb Smirnoff };
4873b3a8eb9SGleb Smirnoff 
4883b3a8eb9SGleb Smirnoff /* Keep synced with struct pf_state. */
4893b3a8eb9SGleb Smirnoff struct pf_state_cmp {
4903b3a8eb9SGleb Smirnoff 	u_int64_t		 id;
4913b3a8eb9SGleb Smirnoff 	u_int32_t		 creatorid;
4923b3a8eb9SGleb Smirnoff 	u_int8_t		 direction;
4933b3a8eb9SGleb Smirnoff 	u_int8_t		 pad[3];
4943b3a8eb9SGleb Smirnoff };
4953b3a8eb9SGleb Smirnoff 
496e86bddeaSKristof Provost #define	PFSTATE_ALLOWOPTS	0x01
497e86bddeaSKristof Provost #define	PFSTATE_SLOPPY		0x02
498e86bddeaSKristof Provost /*  was	PFSTATE_PFLOW		0x04 */
499e86bddeaSKristof Provost #define	PFSTATE_NOSYNC		0x08
500e86bddeaSKristof Provost #define	PFSTATE_ACK		0x10
501e86bddeaSKristof Provost #define	PFSTATE_SETPRIO		0x0200
502e86bddeaSKristof Provost #define	PFSTATE_SETMASK   (PFSTATE_SETPRIO)
503e86bddeaSKristof Provost 
504e86bddeaSKristof Provost #ifdef _KERNEL
5053b3a8eb9SGleb Smirnoff struct pf_state {
5063b3a8eb9SGleb Smirnoff 	u_int64_t		 id;
5073b3a8eb9SGleb Smirnoff 	u_int32_t		 creatorid;
5083b3a8eb9SGleb Smirnoff 	u_int8_t		 direction;
5093b3a8eb9SGleb Smirnoff 	u_int8_t		 pad[3];
5103b3a8eb9SGleb Smirnoff 
5113b3a8eb9SGleb Smirnoff 	u_int			 refs;
5123b3a8eb9SGleb Smirnoff 	TAILQ_ENTRY(pf_state)	 sync_list;
5133b3a8eb9SGleb Smirnoff 	TAILQ_ENTRY(pf_state)	 key_list[2];
5143b3a8eb9SGleb Smirnoff 	LIST_ENTRY(pf_state)	 entry;
5153b3a8eb9SGleb Smirnoff 	struct pf_state_peer	 src;
5163b3a8eb9SGleb Smirnoff 	struct pf_state_peer	 dst;
517e86bddeaSKristof Provost 	union pf_krule_ptr	 rule;
518e86bddeaSKristof Provost 	union pf_krule_ptr	 anchor;
519e86bddeaSKristof Provost 	union pf_krule_ptr	 nat_rule;
5203b3a8eb9SGleb Smirnoff 	struct pf_addr		 rt_addr;
5213b3a8eb9SGleb Smirnoff 	struct pf_state_key	*key[2];	/* addresses stack and wire  */
522320c1116SKristof Provost 	struct pfi_kkif		*kif;
523320c1116SKristof Provost 	struct pfi_kkif		*rt_kif;
52417ad7334SKristof Provost 	struct pf_ksrc_node	*src_node;
52517ad7334SKristof Provost 	struct pf_ksrc_node	*nat_src_node;
5261c00efe9SKristof Provost 	counter_u64_t		 packets[2];
5271c00efe9SKristof Provost 	counter_u64_t		 bytes[2];
5283b3a8eb9SGleb Smirnoff 	u_int32_t		 creation;
5293b3a8eb9SGleb Smirnoff 	u_int32_t	 	 expire;
5303b3a8eb9SGleb Smirnoff 	u_int32_t		 pfsync_time;
5313b3a8eb9SGleb Smirnoff 	u_int16_t		 tag;
5323b3a8eb9SGleb Smirnoff 	u_int8_t		 log;
5333b3a8eb9SGleb Smirnoff 	u_int8_t		 state_flags;
5343b3a8eb9SGleb Smirnoff 	u_int8_t		 timeout;
5353b3a8eb9SGleb Smirnoff 	u_int8_t		 sync_state; /* PFSYNC_S_x */
5363b3a8eb9SGleb Smirnoff 
5373b3a8eb9SGleb Smirnoff 	/* XXX */
5383b3a8eb9SGleb Smirnoff 	u_int8_t		 sync_updates;
5393b3a8eb9SGleb Smirnoff 	u_int8_t		_tail[3];
5403b3a8eb9SGleb Smirnoff };
541e86bddeaSKristof Provost #endif
5423b3a8eb9SGleb Smirnoff 
5433b3a8eb9SGleb Smirnoff /*
5443b3a8eb9SGleb Smirnoff  * Unified state structures for pulling states out of the kernel
5453b3a8eb9SGleb Smirnoff  * used by pfsync(4) and the pf(4) ioctl.
5463b3a8eb9SGleb Smirnoff  */
5473b3a8eb9SGleb Smirnoff struct pfsync_state_scrub {
5483b3a8eb9SGleb Smirnoff 	u_int16_t	pfss_flags;
5493b3a8eb9SGleb Smirnoff 	u_int8_t	pfss_ttl;	/* stashed TTL		*/
5503b3a8eb9SGleb Smirnoff #define PFSYNC_SCRUB_FLAG_VALID		0x01
5513b3a8eb9SGleb Smirnoff 	u_int8_t	scrub_flag;
5523b3a8eb9SGleb Smirnoff 	u_int32_t	pfss_ts_mod;	/* timestamp modulation	*/
5533b3a8eb9SGleb Smirnoff } __packed;
5543b3a8eb9SGleb Smirnoff 
5553b3a8eb9SGleb Smirnoff struct pfsync_state_peer {
5563b3a8eb9SGleb Smirnoff 	struct pfsync_state_scrub scrub;	/* state is scrubbed	*/
5573b3a8eb9SGleb Smirnoff 	u_int32_t	seqlo;		/* Max sequence number sent	*/
5583b3a8eb9SGleb Smirnoff 	u_int32_t	seqhi;		/* Max the other end ACKd + win	*/
5593b3a8eb9SGleb Smirnoff 	u_int32_t	seqdiff;	/* Sequence number modulator	*/
5603b3a8eb9SGleb Smirnoff 	u_int16_t	max_win;	/* largest window (pre scaling)	*/
5613b3a8eb9SGleb Smirnoff 	u_int16_t	mss;		/* Maximum segment size option	*/
5623b3a8eb9SGleb Smirnoff 	u_int8_t	state;		/* active state level		*/
5633b3a8eb9SGleb Smirnoff 	u_int8_t	wscale;		/* window scaling factor	*/
5643b3a8eb9SGleb Smirnoff 	u_int8_t	pad[6];
5653b3a8eb9SGleb Smirnoff } __packed;
5663b3a8eb9SGleb Smirnoff 
5673b3a8eb9SGleb Smirnoff struct pfsync_state_key {
5683b3a8eb9SGleb Smirnoff 	struct pf_addr	 addr[2];
5693b3a8eb9SGleb Smirnoff 	u_int16_t	 port[2];
5703b3a8eb9SGleb Smirnoff };
5713b3a8eb9SGleb Smirnoff 
5723b3a8eb9SGleb Smirnoff struct pfsync_state {
5733b3a8eb9SGleb Smirnoff 	u_int64_t	 id;
5743b3a8eb9SGleb Smirnoff 	char		 ifname[IFNAMSIZ];
5753b3a8eb9SGleb Smirnoff 	struct pfsync_state_key	key[2];
5763b3a8eb9SGleb Smirnoff 	struct pfsync_state_peer src;
5773b3a8eb9SGleb Smirnoff 	struct pfsync_state_peer dst;
5783b3a8eb9SGleb Smirnoff 	struct pf_addr	 rt_addr;
5793b3a8eb9SGleb Smirnoff 	u_int32_t	 rule;
5803b3a8eb9SGleb Smirnoff 	u_int32_t	 anchor;
5813b3a8eb9SGleb Smirnoff 	u_int32_t	 nat_rule;
5823b3a8eb9SGleb Smirnoff 	u_int32_t	 creation;
5833b3a8eb9SGleb Smirnoff 	u_int32_t	 expire;
5843b3a8eb9SGleb Smirnoff 	u_int32_t	 packets[2][2];
5853b3a8eb9SGleb Smirnoff 	u_int32_t	 bytes[2][2];
5863b3a8eb9SGleb Smirnoff 	u_int32_t	 creatorid;
5873b3a8eb9SGleb Smirnoff 	sa_family_t	 af;
5883b3a8eb9SGleb Smirnoff 	u_int8_t	 proto;
5893b3a8eb9SGleb Smirnoff 	u_int8_t	 direction;
5903b3a8eb9SGleb Smirnoff 	u_int8_t	 __spare[2];
5913b3a8eb9SGleb Smirnoff 	u_int8_t	 log;
5923b3a8eb9SGleb Smirnoff 	u_int8_t	 state_flags;
5933b3a8eb9SGleb Smirnoff 	u_int8_t	 timeout;
5943b3a8eb9SGleb Smirnoff 	u_int8_t	 sync_flags;
5953b3a8eb9SGleb Smirnoff 	u_int8_t	 updates;
5963b3a8eb9SGleb Smirnoff } __packed;
5973b3a8eb9SGleb Smirnoff 
5983b3a8eb9SGleb Smirnoff #ifdef _KERNEL
5993b3a8eb9SGleb Smirnoff /* pfsync */
6003b3a8eb9SGleb Smirnoff typedef int		pfsync_state_import_t(struct pfsync_state *, u_int8_t);
6013b3a8eb9SGleb Smirnoff typedef	void		pfsync_insert_state_t(struct pf_state *);
6023b3a8eb9SGleb Smirnoff typedef	void		pfsync_update_state_t(struct pf_state *);
6033b3a8eb9SGleb Smirnoff typedef	void		pfsync_delete_state_t(struct pf_state *);
6043b3a8eb9SGleb Smirnoff typedef void		pfsync_clear_states_t(u_int32_t, const char *);
6053b3a8eb9SGleb Smirnoff typedef int		pfsync_defer_t(struct pf_state *, struct mbuf *);
606fbbf436dSKristof Provost typedef void		pfsync_detach_ifnet_t(struct ifnet *);
6073b3a8eb9SGleb Smirnoff 
6085f6cf24eSKristof Provost VNET_DECLARE(pfsync_state_import_t *, pfsync_state_import_ptr);
6095f6cf24eSKristof Provost #define V_pfsync_state_import_ptr	VNET(pfsync_state_import_ptr)
6105f6cf24eSKristof Provost VNET_DECLARE(pfsync_insert_state_t *, pfsync_insert_state_ptr);
6115f6cf24eSKristof Provost #define V_pfsync_insert_state_ptr	VNET(pfsync_insert_state_ptr)
6125f6cf24eSKristof Provost VNET_DECLARE(pfsync_update_state_t *, pfsync_update_state_ptr);
6135f6cf24eSKristof Provost #define V_pfsync_update_state_ptr	VNET(pfsync_update_state_ptr)
6145f6cf24eSKristof Provost VNET_DECLARE(pfsync_delete_state_t *, pfsync_delete_state_ptr);
6155f6cf24eSKristof Provost #define V_pfsync_delete_state_ptr	VNET(pfsync_delete_state_ptr)
6165f6cf24eSKristof Provost VNET_DECLARE(pfsync_clear_states_t *, pfsync_clear_states_ptr);
6175f6cf24eSKristof Provost #define V_pfsync_clear_states_ptr	VNET(pfsync_clear_states_ptr)
6185f6cf24eSKristof Provost VNET_DECLARE(pfsync_defer_t *, pfsync_defer_ptr);
6195f6cf24eSKristof Provost #define V_pfsync_defer_ptr		VNET(pfsync_defer_ptr)
620fbbf436dSKristof Provost extern pfsync_detach_ifnet_t	*pfsync_detach_ifnet_ptr;
6213b3a8eb9SGleb Smirnoff 
6223b3a8eb9SGleb Smirnoff void			pfsync_state_export(struct pfsync_state *,
6233b3a8eb9SGleb Smirnoff 			    struct pf_state *);
6243b3a8eb9SGleb Smirnoff 
6253b3a8eb9SGleb Smirnoff /* pflog */
626e86bddeaSKristof Provost struct pf_kruleset;
6273b3a8eb9SGleb Smirnoff struct pf_pdesc;
628320c1116SKristof Provost typedef int pflog_packet_t(struct pfi_kkif *, struct mbuf *, sa_family_t,
629e86bddeaSKristof Provost     u_int8_t, u_int8_t, struct pf_krule *, struct pf_krule *,
630e86bddeaSKristof Provost     struct pf_kruleset *, struct pf_pdesc *, int);
6313b3a8eb9SGleb Smirnoff extern pflog_packet_t		*pflog_packet_ptr;
6323b3a8eb9SGleb Smirnoff 
6333b3a8eb9SGleb Smirnoff #endif /* _KERNEL */
6343b3a8eb9SGleb Smirnoff 
6353b3a8eb9SGleb Smirnoff #define	PFSYNC_FLAG_SRCNODE	0x04
6363b3a8eb9SGleb Smirnoff #define	PFSYNC_FLAG_NATSRCNODE	0x08
6373b3a8eb9SGleb Smirnoff 
6383b3a8eb9SGleb Smirnoff /* for copies to/from network byte order */
6393b3a8eb9SGleb Smirnoff /* ioctl interface also uses network byte order */
6403b3a8eb9SGleb Smirnoff #define pf_state_peer_hton(s,d) do {		\
6413b3a8eb9SGleb Smirnoff 	(d)->seqlo = htonl((s)->seqlo);		\
6423b3a8eb9SGleb Smirnoff 	(d)->seqhi = htonl((s)->seqhi);		\
6433b3a8eb9SGleb Smirnoff 	(d)->seqdiff = htonl((s)->seqdiff);	\
6443b3a8eb9SGleb Smirnoff 	(d)->max_win = htons((s)->max_win);	\
6453b3a8eb9SGleb Smirnoff 	(d)->mss = htons((s)->mss);		\
6463b3a8eb9SGleb Smirnoff 	(d)->state = (s)->state;		\
6473b3a8eb9SGleb Smirnoff 	(d)->wscale = (s)->wscale;		\
6483b3a8eb9SGleb Smirnoff 	if ((s)->scrub) {						\
6493b3a8eb9SGleb Smirnoff 		(d)->scrub.pfss_flags = 				\
6503b3a8eb9SGleb Smirnoff 		    htons((s)->scrub->pfss_flags & PFSS_TIMESTAMP);	\
6513b3a8eb9SGleb Smirnoff 		(d)->scrub.pfss_ttl = (s)->scrub->pfss_ttl;		\
6523b3a8eb9SGleb Smirnoff 		(d)->scrub.pfss_ts_mod = htonl((s)->scrub->pfss_ts_mod);\
6533b3a8eb9SGleb Smirnoff 		(d)->scrub.scrub_flag = PFSYNC_SCRUB_FLAG_VALID;	\
6543b3a8eb9SGleb Smirnoff 	}								\
6553b3a8eb9SGleb Smirnoff } while (0)
6563b3a8eb9SGleb Smirnoff 
6573b3a8eb9SGleb Smirnoff #define pf_state_peer_ntoh(s,d) do {		\
6583b3a8eb9SGleb Smirnoff 	(d)->seqlo = ntohl((s)->seqlo);		\
6593b3a8eb9SGleb Smirnoff 	(d)->seqhi = ntohl((s)->seqhi);		\
6603b3a8eb9SGleb Smirnoff 	(d)->seqdiff = ntohl((s)->seqdiff);	\
6613b3a8eb9SGleb Smirnoff 	(d)->max_win = ntohs((s)->max_win);	\
6623b3a8eb9SGleb Smirnoff 	(d)->mss = ntohs((s)->mss);		\
6633b3a8eb9SGleb Smirnoff 	(d)->state = (s)->state;		\
6643b3a8eb9SGleb Smirnoff 	(d)->wscale = (s)->wscale;		\
6653b3a8eb9SGleb Smirnoff 	if ((s)->scrub.scrub_flag == PFSYNC_SCRUB_FLAG_VALID && 	\
6663b3a8eb9SGleb Smirnoff 	    (d)->scrub != NULL) {					\
6673b3a8eb9SGleb Smirnoff 		(d)->scrub->pfss_flags =				\
6683b3a8eb9SGleb Smirnoff 		    ntohs((s)->scrub.pfss_flags) & PFSS_TIMESTAMP;	\
6693b3a8eb9SGleb Smirnoff 		(d)->scrub->pfss_ttl = (s)->scrub.pfss_ttl;		\
6703b3a8eb9SGleb Smirnoff 		(d)->scrub->pfss_ts_mod = ntohl((s)->scrub.pfss_ts_mod);\
6713b3a8eb9SGleb Smirnoff 	}								\
6723b3a8eb9SGleb Smirnoff } while (0)
6733b3a8eb9SGleb Smirnoff 
6743b3a8eb9SGleb Smirnoff #define pf_state_counter_hton(s,d) do {				\
6753b3a8eb9SGleb Smirnoff 	d[0] = htonl((s>>32)&0xffffffff);			\
6763b3a8eb9SGleb Smirnoff 	d[1] = htonl(s&0xffffffff);				\
6773b3a8eb9SGleb Smirnoff } while (0)
6783b3a8eb9SGleb Smirnoff 
6793b3a8eb9SGleb Smirnoff #define pf_state_counter_from_pfsync(s)				\
6803b3a8eb9SGleb Smirnoff 	(((u_int64_t)(s[0])<<32) | (u_int64_t)(s[1]))
6813b3a8eb9SGleb Smirnoff 
6823b3a8eb9SGleb Smirnoff #define pf_state_counter_ntoh(s,d) do {				\
6833b3a8eb9SGleb Smirnoff 	d = ntohl(s[0]);					\
6843b3a8eb9SGleb Smirnoff 	d = d<<32;						\
6853b3a8eb9SGleb Smirnoff 	d += ntohl(s[1]);					\
6863b3a8eb9SGleb Smirnoff } while (0)
6873b3a8eb9SGleb Smirnoff 
688e86bddeaSKristof Provost TAILQ_HEAD(pf_krulequeue, pf_krule);
6893b3a8eb9SGleb Smirnoff 
690e86bddeaSKristof Provost struct pf_kanchor;
6913b3a8eb9SGleb Smirnoff 
692e86bddeaSKristof Provost struct pf_kruleset {
6933b3a8eb9SGleb Smirnoff 	struct {
694e86bddeaSKristof Provost 		struct pf_krulequeue	 queues[2];
6953b3a8eb9SGleb Smirnoff 		struct {
696e86bddeaSKristof Provost 			struct pf_krulequeue	*ptr;
697e86bddeaSKristof Provost 			struct pf_krule		**ptr_array;
6983b3a8eb9SGleb Smirnoff 			u_int32_t		 rcount;
6993b3a8eb9SGleb Smirnoff 			u_int32_t		 ticket;
7003b3a8eb9SGleb Smirnoff 			int			 open;
7013b3a8eb9SGleb Smirnoff 		}			 active, inactive;
7023b3a8eb9SGleb Smirnoff 	}			 rules[PF_RULESET_MAX];
703e86bddeaSKristof Provost 	struct pf_kanchor	*anchor;
7043b3a8eb9SGleb Smirnoff 	u_int32_t		 tticket;
7053b3a8eb9SGleb Smirnoff 	int			 tables;
7063b3a8eb9SGleb Smirnoff 	int			 topen;
7073b3a8eb9SGleb Smirnoff };
7083b3a8eb9SGleb Smirnoff 
709e86bddeaSKristof Provost RB_HEAD(pf_kanchor_global, pf_kanchor);
710e86bddeaSKristof Provost RB_HEAD(pf_kanchor_node, pf_kanchor);
711e86bddeaSKristof Provost struct pf_kanchor {
712e86bddeaSKristof Provost 	RB_ENTRY(pf_kanchor)	 entry_global;
713e86bddeaSKristof Provost 	RB_ENTRY(pf_kanchor)	 entry_node;
714e86bddeaSKristof Provost 	struct pf_kanchor	*parent;
715e86bddeaSKristof Provost 	struct pf_kanchor_node	 children;
7163b3a8eb9SGleb Smirnoff 	char			 name[PF_ANCHOR_NAME_SIZE];
7173b3a8eb9SGleb Smirnoff 	char			 path[MAXPATHLEN];
718e86bddeaSKristof Provost 	struct pf_kruleset	 ruleset;
7193b3a8eb9SGleb Smirnoff 	int			 refcnt;	/* anchor rules */
7201d6139c0SGleb Smirnoff 	int			 match;	/* XXX: used for pfctl black magic */
7213b3a8eb9SGleb Smirnoff };
722e86bddeaSKristof Provost RB_PROTOTYPE(pf_kanchor_global, pf_kanchor, entry_global, pf_anchor_compare);
723e86bddeaSKristof Provost RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare);
7243b3a8eb9SGleb Smirnoff 
7253b3a8eb9SGleb Smirnoff #define PF_RESERVED_ANCHOR	"_pf"
7263b3a8eb9SGleb Smirnoff 
7273b3a8eb9SGleb Smirnoff #define PFR_TFLAG_PERSIST	0x00000001
7283b3a8eb9SGleb Smirnoff #define PFR_TFLAG_CONST		0x00000002
7293b3a8eb9SGleb Smirnoff #define PFR_TFLAG_ACTIVE	0x00000004
7303b3a8eb9SGleb Smirnoff #define PFR_TFLAG_INACTIVE	0x00000008
7313b3a8eb9SGleb Smirnoff #define PFR_TFLAG_REFERENCED	0x00000010
7323b3a8eb9SGleb Smirnoff #define PFR_TFLAG_REFDANCHOR	0x00000020
7333b3a8eb9SGleb Smirnoff #define PFR_TFLAG_COUNTERS	0x00000040
7343b3a8eb9SGleb Smirnoff /* Adjust masks below when adding flags. */
7353b3a8eb9SGleb Smirnoff #define PFR_TFLAG_USRMASK	(PFR_TFLAG_PERSIST	| \
7363b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_CONST	| \
7373b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_COUNTERS)
7383b3a8eb9SGleb Smirnoff #define PFR_TFLAG_SETMASK	(PFR_TFLAG_ACTIVE	| \
7393b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_INACTIVE	| \
7403b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_REFERENCED	| \
7413b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_REFDANCHOR)
7423b3a8eb9SGleb Smirnoff #define PFR_TFLAG_ALLMASK	(PFR_TFLAG_PERSIST	| \
7433b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_CONST	| \
7443b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_ACTIVE	| \
7453b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_INACTIVE	| \
7463b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_REFERENCED	| \
7473b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_REFDANCHOR	| \
7483b3a8eb9SGleb Smirnoff 				 PFR_TFLAG_COUNTERS)
7493b3a8eb9SGleb Smirnoff 
750e86bddeaSKristof Provost struct pf_kanchor_stackframe;
7511d6139c0SGleb Smirnoff 
7523b3a8eb9SGleb Smirnoff struct pfr_table {
7533b3a8eb9SGleb Smirnoff 	char			 pfrt_anchor[MAXPATHLEN];
7543b3a8eb9SGleb Smirnoff 	char			 pfrt_name[PF_TABLE_NAME_SIZE];
7553b3a8eb9SGleb Smirnoff 	u_int32_t		 pfrt_flags;
7563b3a8eb9SGleb Smirnoff 	u_int8_t		 pfrt_fback;
7573b3a8eb9SGleb Smirnoff };
7583b3a8eb9SGleb Smirnoff 
7593b3a8eb9SGleb Smirnoff enum { PFR_FB_NONE, PFR_FB_MATCH, PFR_FB_ADDED, PFR_FB_DELETED,
7603b3a8eb9SGleb Smirnoff 	PFR_FB_CHANGED, PFR_FB_CLEARED, PFR_FB_DUPLICATE,
7613b3a8eb9SGleb Smirnoff 	PFR_FB_NOTMATCH, PFR_FB_CONFLICT, PFR_FB_NOCOUNT, PFR_FB_MAX };
7623b3a8eb9SGleb Smirnoff 
7633b3a8eb9SGleb Smirnoff struct pfr_addr {
7643b3a8eb9SGleb Smirnoff 	union {
7653b3a8eb9SGleb Smirnoff 		struct in_addr	 _pfra_ip4addr;
7663b3a8eb9SGleb Smirnoff 		struct in6_addr	 _pfra_ip6addr;
7673b3a8eb9SGleb Smirnoff 	}		 pfra_u;
7683b3a8eb9SGleb Smirnoff 	u_int8_t	 pfra_af;
7693b3a8eb9SGleb Smirnoff 	u_int8_t	 pfra_net;
7703b3a8eb9SGleb Smirnoff 	u_int8_t	 pfra_not;
7713b3a8eb9SGleb Smirnoff 	u_int8_t	 pfra_fback;
7723b3a8eb9SGleb Smirnoff };
7733b3a8eb9SGleb Smirnoff #define	pfra_ip4addr	pfra_u._pfra_ip4addr
7743b3a8eb9SGleb Smirnoff #define	pfra_ip6addr	pfra_u._pfra_ip6addr
7753b3a8eb9SGleb Smirnoff 
7763b3a8eb9SGleb Smirnoff enum { PFR_DIR_IN, PFR_DIR_OUT, PFR_DIR_MAX };
7773b3a8eb9SGleb Smirnoff enum { PFR_OP_BLOCK, PFR_OP_PASS, PFR_OP_ADDR_MAX, PFR_OP_TABLE_MAX };
778c1be8399SMark Johnston enum { PFR_TYPE_PACKETS, PFR_TYPE_BYTES, PFR_TYPE_MAX };
779c1be8399SMark Johnston #define	PFR_NUM_COUNTERS	(PFR_DIR_MAX * PFR_OP_ADDR_MAX * PFR_TYPE_MAX)
7803b3a8eb9SGleb Smirnoff #define PFR_OP_XPASS	PFR_OP_ADDR_MAX
7813b3a8eb9SGleb Smirnoff 
7823b3a8eb9SGleb Smirnoff struct pfr_astats {
7833b3a8eb9SGleb Smirnoff 	struct pfr_addr	 pfras_a;
7843b3a8eb9SGleb Smirnoff 	u_int64_t	 pfras_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
7853b3a8eb9SGleb Smirnoff 	u_int64_t	 pfras_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
7863b3a8eb9SGleb Smirnoff 	long		 pfras_tzero;
7873b3a8eb9SGleb Smirnoff };
7883b3a8eb9SGleb Smirnoff 
7893b3a8eb9SGleb Smirnoff enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX };
7903b3a8eb9SGleb Smirnoff 
7913b3a8eb9SGleb Smirnoff struct pfr_tstats {
7923b3a8eb9SGleb Smirnoff 	struct pfr_table pfrts_t;
7933b3a8eb9SGleb Smirnoff 	u_int64_t	 pfrts_packets[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
7943b3a8eb9SGleb Smirnoff 	u_int64_t	 pfrts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
7953b3a8eb9SGleb Smirnoff 	u_int64_t	 pfrts_match;
7963b3a8eb9SGleb Smirnoff 	u_int64_t	 pfrts_nomatch;
7973b3a8eb9SGleb Smirnoff 	long		 pfrts_tzero;
7983b3a8eb9SGleb Smirnoff 	int		 pfrts_cnt;
7993b3a8eb9SGleb Smirnoff 	int		 pfrts_refcnt[PFR_REFCNT_MAX];
8003b3a8eb9SGleb Smirnoff };
80159048686SKristof Provost 
80259048686SKristof Provost struct pfr_ktstats {
80359048686SKristof Provost 	struct pfr_table pfrts_t;
80459048686SKristof Provost 	counter_u64_t	 pfrkts_packets[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
80559048686SKristof Provost 	counter_u64_t	 pfrkts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
80659048686SKristof Provost 	counter_u64_t	 pfrkts_match;
80759048686SKristof Provost 	counter_u64_t	 pfrkts_nomatch;
80859048686SKristof Provost 	long		 pfrkts_tzero;
80959048686SKristof Provost 	int		 pfrkts_cnt;
81059048686SKristof Provost 	int		 pfrkts_refcnt[PFR_REFCNT_MAX];
81159048686SKristof Provost };
8123b3a8eb9SGleb Smirnoff #define	pfrts_name	pfrts_t.pfrt_name
8133b3a8eb9SGleb Smirnoff #define pfrts_flags	pfrts_t.pfrt_flags
8143b3a8eb9SGleb Smirnoff 
8153b3a8eb9SGleb Smirnoff #ifndef _SOCKADDR_UNION_DEFINED
8163b3a8eb9SGleb Smirnoff #define	_SOCKADDR_UNION_DEFINED
8173b3a8eb9SGleb Smirnoff union sockaddr_union {
8183b3a8eb9SGleb Smirnoff 	struct sockaddr		sa;
8193b3a8eb9SGleb Smirnoff 	struct sockaddr_in	sin;
8203b3a8eb9SGleb Smirnoff 	struct sockaddr_in6	sin6;
8213b3a8eb9SGleb Smirnoff };
8223b3a8eb9SGleb Smirnoff #endif /* _SOCKADDR_UNION_DEFINED */
8233b3a8eb9SGleb Smirnoff 
8243b3a8eb9SGleb Smirnoff struct pfr_kcounters {
825c1be8399SMark Johnston 	counter_u64_t		 pfrkc_counters;
82659048686SKristof Provost 	long			 pfrkc_tzero;
8273b3a8eb9SGleb Smirnoff };
828c1be8399SMark Johnston #define	pfr_kentry_counter(kc, dir, op, t)		\
829c1be8399SMark Johnston 	((kc)->pfrkc_counters +				\
830c1be8399SMark Johnston 	    (dir) * PFR_OP_ADDR_MAX * PFR_TYPE_MAX + (op) * PFR_TYPE_MAX + (t))
8313b3a8eb9SGleb Smirnoff 
832e86bddeaSKristof Provost #ifdef _KERNEL
8333b3a8eb9SGleb Smirnoff SLIST_HEAD(pfr_kentryworkq, pfr_kentry);
8343b3a8eb9SGleb Smirnoff struct pfr_kentry {
8353b3a8eb9SGleb Smirnoff 	struct radix_node	 pfrke_node[2];
8363b3a8eb9SGleb Smirnoff 	union sockaddr_union	 pfrke_sa;
8373b3a8eb9SGleb Smirnoff 	SLIST_ENTRY(pfr_kentry)	 pfrke_workq;
83859048686SKristof Provost 	struct pfr_kcounters	 pfrke_counters;
8393b3a8eb9SGleb Smirnoff 	u_int8_t		 pfrke_af;
8403b3a8eb9SGleb Smirnoff 	u_int8_t		 pfrke_net;
8413b3a8eb9SGleb Smirnoff 	u_int8_t		 pfrke_not;
8423b3a8eb9SGleb Smirnoff 	u_int8_t		 pfrke_mark;
8433b3a8eb9SGleb Smirnoff };
8443b3a8eb9SGleb Smirnoff 
8453b3a8eb9SGleb Smirnoff SLIST_HEAD(pfr_ktableworkq, pfr_ktable);
8463b3a8eb9SGleb Smirnoff RB_HEAD(pfr_ktablehead, pfr_ktable);
8473b3a8eb9SGleb Smirnoff struct pfr_ktable {
84859048686SKristof Provost 	struct pfr_ktstats	 pfrkt_kts;
8493b3a8eb9SGleb Smirnoff 	RB_ENTRY(pfr_ktable)	 pfrkt_tree;
8503b3a8eb9SGleb Smirnoff 	SLIST_ENTRY(pfr_ktable)	 pfrkt_workq;
8513b3a8eb9SGleb Smirnoff 	struct radix_node_head	*pfrkt_ip4;
8523b3a8eb9SGleb Smirnoff 	struct radix_node_head	*pfrkt_ip6;
8533b3a8eb9SGleb Smirnoff 	struct pfr_ktable	*pfrkt_shadow;
8543b3a8eb9SGleb Smirnoff 	struct pfr_ktable	*pfrkt_root;
855e86bddeaSKristof Provost 	struct pf_kruleset	*pfrkt_rs;
8563b3a8eb9SGleb Smirnoff 	long			 pfrkt_larg;
8573b3a8eb9SGleb Smirnoff 	int			 pfrkt_nflags;
8583b3a8eb9SGleb Smirnoff };
85959048686SKristof Provost #define pfrkt_t		pfrkt_kts.pfrts_t
8603b3a8eb9SGleb Smirnoff #define pfrkt_name	pfrkt_t.pfrt_name
8613b3a8eb9SGleb Smirnoff #define pfrkt_anchor	pfrkt_t.pfrt_anchor
8623b3a8eb9SGleb Smirnoff #define pfrkt_ruleset	pfrkt_t.pfrt_ruleset
8633b3a8eb9SGleb Smirnoff #define pfrkt_flags	pfrkt_t.pfrt_flags
86459048686SKristof Provost #define pfrkt_cnt	pfrkt_kts.pfrkts_cnt
86559048686SKristof Provost #define pfrkt_refcnt	pfrkt_kts.pfrkts_refcnt
86659048686SKristof Provost #define pfrkt_packets	pfrkt_kts.pfrkts_packets
86759048686SKristof Provost #define pfrkt_bytes	pfrkt_kts.pfrkts_bytes
86859048686SKristof Provost #define pfrkt_match	pfrkt_kts.pfrkts_match
86959048686SKristof Provost #define pfrkt_nomatch	pfrkt_kts.pfrkts_nomatch
87059048686SKristof Provost #define pfrkt_tzero	pfrkt_kts.pfrkts_tzero
871e86bddeaSKristof Provost #endif
8723b3a8eb9SGleb Smirnoff 
873320c1116SKristof Provost #ifdef _KERNEL
874320c1116SKristof Provost struct pfi_kkif {
8753b3a8eb9SGleb Smirnoff 	char				 pfik_name[IFNAMSIZ];
8763b3a8eb9SGleb Smirnoff 	union {
877320c1116SKristof Provost 		RB_ENTRY(pfi_kkif)	 _pfik_tree;
878320c1116SKristof Provost 		LIST_ENTRY(pfi_kkif)	 _pfik_list;
8793b3a8eb9SGleb Smirnoff 	} _pfik_glue;
8803b3a8eb9SGleb Smirnoff #define	pfik_tree	_pfik_glue._pfik_tree
8813b3a8eb9SGleb Smirnoff #define	pfik_list	_pfik_glue._pfik_list
8825a3b9507SKristof Provost 	counter_u64_t			 pfik_packets[2][2][2];
8835a3b9507SKristof Provost 	counter_u64_t			 pfik_bytes[2][2][2];
8843b3a8eb9SGleb Smirnoff 	u_int32_t			 pfik_tzero;
8853b3a8eb9SGleb Smirnoff 	u_int				 pfik_flags;
8863b3a8eb9SGleb Smirnoff 	struct ifnet			*pfik_ifp;
8873b3a8eb9SGleb Smirnoff 	struct ifg_group		*pfik_group;
8883b3a8eb9SGleb Smirnoff 	u_int				 pfik_rulerefs;
8893b3a8eb9SGleb Smirnoff 	TAILQ_HEAD(, pfi_dynaddr)	 pfik_dynaddrs;
8903b3a8eb9SGleb Smirnoff };
891320c1116SKristof Provost #endif
8923b3a8eb9SGleb Smirnoff 
8933b3a8eb9SGleb Smirnoff #define	PFI_IFLAG_REFS		0x0001	/* has state references */
8943b3a8eb9SGleb Smirnoff #define PFI_IFLAG_SKIP		0x0100	/* skip filtering on interface */
8953b3a8eb9SGleb Smirnoff 
89629698ed9SKristof Provost #ifdef _KERNEL
8973b3a8eb9SGleb Smirnoff struct pf_pdesc {
8983b3a8eb9SGleb Smirnoff 	struct {
8993b3a8eb9SGleb Smirnoff 		int	 done;
9003b3a8eb9SGleb Smirnoff 		uid_t	 uid;
9013b3a8eb9SGleb Smirnoff 		gid_t	 gid;
9023b3a8eb9SGleb Smirnoff 	}		 lookup;
9033b3a8eb9SGleb Smirnoff 	u_int64_t	 tot_len;	/* Make Mickey money */
9043b3a8eb9SGleb Smirnoff 	union {
9053b3a8eb9SGleb Smirnoff 		struct tcphdr		*tcp;
9063b3a8eb9SGleb Smirnoff 		struct udphdr		*udp;
9073b3a8eb9SGleb Smirnoff 		struct icmp		*icmp;
9083b3a8eb9SGleb Smirnoff #ifdef INET6
9093b3a8eb9SGleb Smirnoff 		struct icmp6_hdr	*icmp6;
9103b3a8eb9SGleb Smirnoff #endif /* INET6 */
9113b3a8eb9SGleb Smirnoff 		void			*any;
9123b3a8eb9SGleb Smirnoff 	} hdr;
9133b3a8eb9SGleb Smirnoff 
914e86bddeaSKristof Provost 	struct pf_krule	*nat_rule;	/* nat/rdr rule applied to packet */
9153b3a8eb9SGleb Smirnoff 	struct pf_addr	*src;		/* src address */
9163b3a8eb9SGleb Smirnoff 	struct pf_addr	*dst;		/* dst address */
9173b3a8eb9SGleb Smirnoff 	u_int16_t *sport;
9183b3a8eb9SGleb Smirnoff 	u_int16_t *dport;
9193b3a8eb9SGleb Smirnoff 	struct pf_mtag	*pf_mtag;
9203b3a8eb9SGleb Smirnoff 
9213b3a8eb9SGleb Smirnoff 	u_int32_t	 p_len;		/* total length of payload */
9223b3a8eb9SGleb Smirnoff 
9233b3a8eb9SGleb Smirnoff 	u_int16_t	*ip_sum;
9243b3a8eb9SGleb Smirnoff 	u_int16_t	*proto_sum;
9253b3a8eb9SGleb Smirnoff 	u_int16_t	 flags;		/* Let SCRUB trigger behavior in
9263b3a8eb9SGleb Smirnoff 					 * state code. Easier than tags */
9273b3a8eb9SGleb Smirnoff #define PFDESC_TCP_NORM	0x0001		/* TCP shall be statefully scrubbed */
9283b3a8eb9SGleb Smirnoff #define PFDESC_IP_REAS	0x0002		/* IP frags would've been reassembled */
9293b3a8eb9SGleb Smirnoff 	sa_family_t	 af;
9303b3a8eb9SGleb Smirnoff 	u_int8_t	 proto;
9313b3a8eb9SGleb Smirnoff 	u_int8_t	 tos;
9323b3a8eb9SGleb Smirnoff 	u_int8_t	 dir;		/* direction */
9333b3a8eb9SGleb Smirnoff 	u_int8_t	 sidx;		/* key index for source */
9343b3a8eb9SGleb Smirnoff 	u_int8_t	 didx;		/* key index for destination */
9353b3a8eb9SGleb Smirnoff };
93629698ed9SKristof Provost #endif
9373b3a8eb9SGleb Smirnoff 
9383b3a8eb9SGleb Smirnoff /* flags for RDR options */
9393b3a8eb9SGleb Smirnoff #define PF_DPORT_RANGE	0x01		/* Dest port uses range */
9403b3a8eb9SGleb Smirnoff #define PF_RPORT_RANGE	0x02		/* RDR'ed port uses range */
9413b3a8eb9SGleb Smirnoff 
9423b3a8eb9SGleb Smirnoff /* UDP state enumeration */
9433b3a8eb9SGleb Smirnoff #define PFUDPS_NO_TRAFFIC	0
9443b3a8eb9SGleb Smirnoff #define PFUDPS_SINGLE		1
9453b3a8eb9SGleb Smirnoff #define PFUDPS_MULTIPLE		2
9463b3a8eb9SGleb Smirnoff 
9473b3a8eb9SGleb Smirnoff #define PFUDPS_NSTATES		3	/* number of state levels */
9483b3a8eb9SGleb Smirnoff 
9493b3a8eb9SGleb Smirnoff #define PFUDPS_NAMES { \
9503b3a8eb9SGleb Smirnoff 	"NO_TRAFFIC", \
9513b3a8eb9SGleb Smirnoff 	"SINGLE", \
9523b3a8eb9SGleb Smirnoff 	"MULTIPLE", \
9533b3a8eb9SGleb Smirnoff 	NULL \
9543b3a8eb9SGleb Smirnoff }
9553b3a8eb9SGleb Smirnoff 
9563b3a8eb9SGleb Smirnoff /* Other protocol state enumeration */
9573b3a8eb9SGleb Smirnoff #define PFOTHERS_NO_TRAFFIC	0
9583b3a8eb9SGleb Smirnoff #define PFOTHERS_SINGLE		1
9593b3a8eb9SGleb Smirnoff #define PFOTHERS_MULTIPLE	2
9603b3a8eb9SGleb Smirnoff 
9613b3a8eb9SGleb Smirnoff #define PFOTHERS_NSTATES	3	/* number of state levels */
9623b3a8eb9SGleb Smirnoff 
9633b3a8eb9SGleb Smirnoff #define PFOTHERS_NAMES { \
9643b3a8eb9SGleb Smirnoff 	"NO_TRAFFIC", \
9653b3a8eb9SGleb Smirnoff 	"SINGLE", \
9663b3a8eb9SGleb Smirnoff 	"MULTIPLE", \
9673b3a8eb9SGleb Smirnoff 	NULL \
9683b3a8eb9SGleb Smirnoff }
9693b3a8eb9SGleb Smirnoff 
9703b3a8eb9SGleb Smirnoff #define ACTION_SET(a, x) \
9713b3a8eb9SGleb Smirnoff 	do { \
9723b3a8eb9SGleb Smirnoff 		if ((a) != NULL) \
9733b3a8eb9SGleb Smirnoff 			*(a) = (x); \
9743b3a8eb9SGleb Smirnoff 	} while (0)
9753b3a8eb9SGleb Smirnoff 
9763b3a8eb9SGleb Smirnoff #define REASON_SET(a, x) \
9773b3a8eb9SGleb Smirnoff 	do { \
9783b3a8eb9SGleb Smirnoff 		if ((a) != NULL) \
9793b3a8eb9SGleb Smirnoff 			*(a) = (x); \
9803b3a8eb9SGleb Smirnoff 		if (x < PFRES_MAX) \
981a9572d8fSGleb Smirnoff 			counter_u64_add(V_pf_status.counters[x], 1); \
9823b3a8eb9SGleb Smirnoff 	} while (0)
9833b3a8eb9SGleb Smirnoff 
984a9572d8fSGleb Smirnoff struct pf_kstatus {
985a9572d8fSGleb Smirnoff 	counter_u64_t	counters[PFRES_MAX]; /* reason for passing/dropping */
986a9572d8fSGleb Smirnoff 	counter_u64_t	lcounters[LCNT_MAX]; /* limit counters */
987a9572d8fSGleb Smirnoff 	counter_u64_t	fcounters[FCNT_MAX]; /* state operation counters */
988a9572d8fSGleb Smirnoff 	counter_u64_t	scounters[SCNT_MAX]; /* src_node operation counters */
989a9572d8fSGleb Smirnoff 	uint32_t	states;
990a9572d8fSGleb Smirnoff 	uint32_t	src_nodes;
991a9572d8fSGleb Smirnoff 	uint32_t	running;
992a9572d8fSGleb Smirnoff 	uint32_t	since;
993a9572d8fSGleb Smirnoff 	uint32_t	debug;
994a9572d8fSGleb Smirnoff 	uint32_t	hostid;
9953b3a8eb9SGleb Smirnoff 	char		ifname[IFNAMSIZ];
996a9572d8fSGleb Smirnoff 	uint8_t		pf_chksum[PF_MD5_DIGEST_LENGTH];
9973b3a8eb9SGleb Smirnoff };
9983b3a8eb9SGleb Smirnoff 
9993b3a8eb9SGleb Smirnoff struct pf_divert {
10003b3a8eb9SGleb Smirnoff 	union {
10013b3a8eb9SGleb Smirnoff 		struct in_addr	ipv4;
10023b3a8eb9SGleb Smirnoff 		struct in6_addr	ipv6;
10033b3a8eb9SGleb Smirnoff 	}		addr;
10043b3a8eb9SGleb Smirnoff 	u_int16_t	port;
10053b3a8eb9SGleb Smirnoff };
10063b3a8eb9SGleb Smirnoff 
10073b3a8eb9SGleb Smirnoff #define PFFRAG_FRENT_HIWAT	5000	/* Number of fragment entries */
10083b3a8eb9SGleb Smirnoff #define PFR_KENTRY_HIWAT	200000	/* Number of table entries */
10093b3a8eb9SGleb Smirnoff 
10103b3a8eb9SGleb Smirnoff /*
1011fd2ea405SKristof Provost  * Limit the length of the fragment queue traversal.  Remember
1012fd2ea405SKristof Provost  * search entry points based on the fragment offset.
1013fd2ea405SKristof Provost  */
1014fd2ea405SKristof Provost #define PF_FRAG_ENTRY_POINTS		16
1015fd2ea405SKristof Provost 
1016fd2ea405SKristof Provost /*
1017790194cdSKristof Provost  * The number of entries in the fragment queue must be limited
1018790194cdSKristof Provost  * to avoid DoS by linear seaching.  Instead of a global limit,
1019790194cdSKristof Provost  * use a limit per entry point.  For large packets these sum up.
1020790194cdSKristof Provost  */
1021790194cdSKristof Provost #define PF_FRAG_ENTRY_LIMIT		64
1022790194cdSKristof Provost 
1023790194cdSKristof Provost /*
10243b3a8eb9SGleb Smirnoff  * ioctl parameter structures
10253b3a8eb9SGleb Smirnoff  */
10263b3a8eb9SGleb Smirnoff 
10273b3a8eb9SGleb Smirnoff struct pfioc_pooladdr {
10283b3a8eb9SGleb Smirnoff 	u_int32_t		 action;
10293b3a8eb9SGleb Smirnoff 	u_int32_t		 ticket;
10303b3a8eb9SGleb Smirnoff 	u_int32_t		 nr;
10313b3a8eb9SGleb Smirnoff 	u_int32_t		 r_num;
10323b3a8eb9SGleb Smirnoff 	u_int8_t		 r_action;
10333b3a8eb9SGleb Smirnoff 	u_int8_t		 r_last;
10343b3a8eb9SGleb Smirnoff 	u_int8_t		 af;
10353b3a8eb9SGleb Smirnoff 	char			 anchor[MAXPATHLEN];
10363b3a8eb9SGleb Smirnoff 	struct pf_pooladdr	 addr;
10373b3a8eb9SGleb Smirnoff };
10383b3a8eb9SGleb Smirnoff 
10393b3a8eb9SGleb Smirnoff struct pfioc_rule {
10403b3a8eb9SGleb Smirnoff 	u_int32_t	 action;
10413b3a8eb9SGleb Smirnoff 	u_int32_t	 ticket;
10423b3a8eb9SGleb Smirnoff 	u_int32_t	 pool_ticket;
10433b3a8eb9SGleb Smirnoff 	u_int32_t	 nr;
10443b3a8eb9SGleb Smirnoff 	char		 anchor[MAXPATHLEN];
10453b3a8eb9SGleb Smirnoff 	char		 anchor_call[MAXPATHLEN];
10463b3a8eb9SGleb Smirnoff 	struct pf_rule	 rule;
10473b3a8eb9SGleb Smirnoff };
10483b3a8eb9SGleb Smirnoff 
10493b3a8eb9SGleb Smirnoff struct pfioc_natlook {
10503b3a8eb9SGleb Smirnoff 	struct pf_addr	 saddr;
10513b3a8eb9SGleb Smirnoff 	struct pf_addr	 daddr;
10523b3a8eb9SGleb Smirnoff 	struct pf_addr	 rsaddr;
10533b3a8eb9SGleb Smirnoff 	struct pf_addr	 rdaddr;
10543b3a8eb9SGleb Smirnoff 	u_int16_t	 sport;
10553b3a8eb9SGleb Smirnoff 	u_int16_t	 dport;
10563b3a8eb9SGleb Smirnoff 	u_int16_t	 rsport;
10573b3a8eb9SGleb Smirnoff 	u_int16_t	 rdport;
10583b3a8eb9SGleb Smirnoff 	sa_family_t	 af;
10593b3a8eb9SGleb Smirnoff 	u_int8_t	 proto;
10603b3a8eb9SGleb Smirnoff 	u_int8_t	 direction;
10613b3a8eb9SGleb Smirnoff };
10623b3a8eb9SGleb Smirnoff 
10633b3a8eb9SGleb Smirnoff struct pfioc_state {
10643b3a8eb9SGleb Smirnoff 	struct pfsync_state	state;
10653b3a8eb9SGleb Smirnoff };
10663b3a8eb9SGleb Smirnoff 
10673b3a8eb9SGleb Smirnoff struct pfioc_src_node_kill {
10683b3a8eb9SGleb Smirnoff 	sa_family_t psnk_af;
10693b3a8eb9SGleb Smirnoff 	struct pf_rule_addr psnk_src;
10703b3a8eb9SGleb Smirnoff 	struct pf_rule_addr psnk_dst;
10713b3a8eb9SGleb Smirnoff 	u_int		    psnk_killed;
10723b3a8eb9SGleb Smirnoff };
10733b3a8eb9SGleb Smirnoff 
10743b3a8eb9SGleb Smirnoff struct pfioc_state_kill {
10753b3a8eb9SGleb Smirnoff 	struct pf_state_cmp	psk_pfcmp;
10763b3a8eb9SGleb Smirnoff 	sa_family_t		psk_af;
10773b3a8eb9SGleb Smirnoff 	int			psk_proto;
10783b3a8eb9SGleb Smirnoff 	struct pf_rule_addr	psk_src;
10793b3a8eb9SGleb Smirnoff 	struct pf_rule_addr	psk_dst;
10803b3a8eb9SGleb Smirnoff 	char			psk_ifname[IFNAMSIZ];
10813b3a8eb9SGleb Smirnoff 	char			psk_label[PF_RULE_LABEL_SIZE];
10823b3a8eb9SGleb Smirnoff 	u_int			psk_killed;
10833b3a8eb9SGleb Smirnoff };
10843b3a8eb9SGleb Smirnoff 
10853b3a8eb9SGleb Smirnoff struct pfioc_states {
10863b3a8eb9SGleb Smirnoff 	int	ps_len;
10873b3a8eb9SGleb Smirnoff 	union {
10883b3a8eb9SGleb Smirnoff 		caddr_t			 psu_buf;
10893b3a8eb9SGleb Smirnoff 		struct pfsync_state	*psu_states;
10903b3a8eb9SGleb Smirnoff 	} ps_u;
10913b3a8eb9SGleb Smirnoff #define ps_buf		ps_u.psu_buf
10923b3a8eb9SGleb Smirnoff #define ps_states	ps_u.psu_states
10933b3a8eb9SGleb Smirnoff };
10943b3a8eb9SGleb Smirnoff 
10953b3a8eb9SGleb Smirnoff struct pfioc_src_nodes {
10963b3a8eb9SGleb Smirnoff 	int	psn_len;
10973b3a8eb9SGleb Smirnoff 	union {
10983b3a8eb9SGleb Smirnoff 		caddr_t		 psu_buf;
10993b3a8eb9SGleb Smirnoff 		struct pf_src_node	*psu_src_nodes;
11003b3a8eb9SGleb Smirnoff 	} psn_u;
11013b3a8eb9SGleb Smirnoff #define psn_buf		psn_u.psu_buf
11023b3a8eb9SGleb Smirnoff #define psn_src_nodes	psn_u.psu_src_nodes
11033b3a8eb9SGleb Smirnoff };
11043b3a8eb9SGleb Smirnoff 
11053b3a8eb9SGleb Smirnoff struct pfioc_if {
11063b3a8eb9SGleb Smirnoff 	char		 ifname[IFNAMSIZ];
11073b3a8eb9SGleb Smirnoff };
11083b3a8eb9SGleb Smirnoff 
11093b3a8eb9SGleb Smirnoff struct pfioc_tm {
11103b3a8eb9SGleb Smirnoff 	int		 timeout;
11113b3a8eb9SGleb Smirnoff 	int		 seconds;
11123b3a8eb9SGleb Smirnoff };
11133b3a8eb9SGleb Smirnoff 
11143b3a8eb9SGleb Smirnoff struct pfioc_limit {
11153b3a8eb9SGleb Smirnoff 	int		 index;
11163b3a8eb9SGleb Smirnoff 	unsigned	 limit;
11173b3a8eb9SGleb Smirnoff };
11183b3a8eb9SGleb Smirnoff 
1119249cc75fSPatrick Kelsey struct pfioc_altq_v0 {
11203b3a8eb9SGleb Smirnoff 	u_int32_t	 action;
11213b3a8eb9SGleb Smirnoff 	u_int32_t	 ticket;
11223b3a8eb9SGleb Smirnoff 	u_int32_t	 nr;
1123249cc75fSPatrick Kelsey 	struct pf_altq_v0 altq;
11243b3a8eb9SGleb Smirnoff };
11253b3a8eb9SGleb Smirnoff 
1126249cc75fSPatrick Kelsey struct pfioc_altq_v1 {
1127249cc75fSPatrick Kelsey 	u_int32_t	 action;
1128249cc75fSPatrick Kelsey 	u_int32_t	 ticket;
1129249cc75fSPatrick Kelsey 	u_int32_t	 nr;
1130249cc75fSPatrick Kelsey 	/*
1131249cc75fSPatrick Kelsey 	 * Placed here so code that only uses the above parameters can be
1132249cc75fSPatrick Kelsey 	 * written entirely in terms of the v0 or v1 type.
1133249cc75fSPatrick Kelsey 	 */
1134249cc75fSPatrick Kelsey 	u_int32_t	 version;
1135249cc75fSPatrick Kelsey 	struct pf_altq_v1 altq;
1136249cc75fSPatrick Kelsey };
1137249cc75fSPatrick Kelsey 
1138249cc75fSPatrick Kelsey /*
1139249cc75fSPatrick Kelsey  * Latest version of struct pfioc_altq_vX.  This must move in lock-step with
1140249cc75fSPatrick Kelsey  * the latest version of struct pf_altq_vX as it has that struct as a
1141249cc75fSPatrick Kelsey  * member.
1142249cc75fSPatrick Kelsey  */
1143249cc75fSPatrick Kelsey #define PFIOC_ALTQ_VERSION	PF_ALTQ_VERSION
1144249cc75fSPatrick Kelsey 
1145249cc75fSPatrick Kelsey struct pfioc_qstats_v0 {
11463b3a8eb9SGleb Smirnoff 	u_int32_t	 ticket;
11473b3a8eb9SGleb Smirnoff 	u_int32_t	 nr;
11483b3a8eb9SGleb Smirnoff 	void		*buf;
11493b3a8eb9SGleb Smirnoff 	int		 nbytes;
11503b3a8eb9SGleb Smirnoff 	u_int8_t	 scheduler;
11513b3a8eb9SGleb Smirnoff };
11523b3a8eb9SGleb Smirnoff 
1153249cc75fSPatrick Kelsey struct pfioc_qstats_v1 {
1154249cc75fSPatrick Kelsey 	u_int32_t	 ticket;
1155249cc75fSPatrick Kelsey 	u_int32_t	 nr;
1156249cc75fSPatrick Kelsey 	void		*buf;
1157249cc75fSPatrick Kelsey 	int		 nbytes;
1158249cc75fSPatrick Kelsey 	u_int8_t	 scheduler;
1159249cc75fSPatrick Kelsey 	/*
1160249cc75fSPatrick Kelsey 	 * Placed here so code that only uses the above parameters can be
1161249cc75fSPatrick Kelsey 	 * written entirely in terms of the v0 or v1 type.
1162249cc75fSPatrick Kelsey 	 */
1163249cc75fSPatrick Kelsey 	u_int32_t	 version;  /* Requested version of stats struct */
1164249cc75fSPatrick Kelsey };
1165249cc75fSPatrick Kelsey 
1166249cc75fSPatrick Kelsey /* Latest version of struct pfioc_qstats_vX */
1167249cc75fSPatrick Kelsey #define PFIOC_QSTATS_VERSION	1
1168249cc75fSPatrick Kelsey 
11693b3a8eb9SGleb Smirnoff struct pfioc_ruleset {
11703b3a8eb9SGleb Smirnoff 	u_int32_t	 nr;
11713b3a8eb9SGleb Smirnoff 	char		 path[MAXPATHLEN];
11723b3a8eb9SGleb Smirnoff 	char		 name[PF_ANCHOR_NAME_SIZE];
11733b3a8eb9SGleb Smirnoff };
11743b3a8eb9SGleb Smirnoff 
11753b3a8eb9SGleb Smirnoff #define PF_RULESET_ALTQ		(PF_RULESET_MAX)
11763b3a8eb9SGleb Smirnoff #define PF_RULESET_TABLE	(PF_RULESET_MAX+1)
11773b3a8eb9SGleb Smirnoff struct pfioc_trans {
11783b3a8eb9SGleb Smirnoff 	int		 size;	/* number of elements */
11793b3a8eb9SGleb Smirnoff 	int		 esize; /* size of each element in bytes */
11803b3a8eb9SGleb Smirnoff 	struct pfioc_trans_e {
11813b3a8eb9SGleb Smirnoff 		int		rs_num;
11823b3a8eb9SGleb Smirnoff 		char		anchor[MAXPATHLEN];
11833b3a8eb9SGleb Smirnoff 		u_int32_t	ticket;
11843b3a8eb9SGleb Smirnoff 	}		*array;
11853b3a8eb9SGleb Smirnoff };
11863b3a8eb9SGleb Smirnoff 
11873b3a8eb9SGleb Smirnoff #define PFR_FLAG_ATOMIC		0x00000001	/* unused */
11883b3a8eb9SGleb Smirnoff #define PFR_FLAG_DUMMY		0x00000002
11893b3a8eb9SGleb Smirnoff #define PFR_FLAG_FEEDBACK	0x00000004
11903b3a8eb9SGleb Smirnoff #define PFR_FLAG_CLSTATS	0x00000008
11913b3a8eb9SGleb Smirnoff #define PFR_FLAG_ADDRSTOO	0x00000010
11923b3a8eb9SGleb Smirnoff #define PFR_FLAG_REPLACE	0x00000020
11933b3a8eb9SGleb Smirnoff #define PFR_FLAG_ALLRSETS	0x00000040
11943b3a8eb9SGleb Smirnoff #define PFR_FLAG_ALLMASK	0x0000007F
11953b3a8eb9SGleb Smirnoff #ifdef _KERNEL
11963b3a8eb9SGleb Smirnoff #define PFR_FLAG_USERIOCTL	0x10000000
11973b3a8eb9SGleb Smirnoff #endif
11983b3a8eb9SGleb Smirnoff 
11993b3a8eb9SGleb Smirnoff struct pfioc_table {
12003b3a8eb9SGleb Smirnoff 	struct pfr_table	 pfrio_table;
12013b3a8eb9SGleb Smirnoff 	void			*pfrio_buffer;
12023b3a8eb9SGleb Smirnoff 	int			 pfrio_esize;
12033b3a8eb9SGleb Smirnoff 	int			 pfrio_size;
12043b3a8eb9SGleb Smirnoff 	int			 pfrio_size2;
12053b3a8eb9SGleb Smirnoff 	int			 pfrio_nadd;
12063b3a8eb9SGleb Smirnoff 	int			 pfrio_ndel;
12073b3a8eb9SGleb Smirnoff 	int			 pfrio_nchange;
12083b3a8eb9SGleb Smirnoff 	int			 pfrio_flags;
12093b3a8eb9SGleb Smirnoff 	u_int32_t		 pfrio_ticket;
12103b3a8eb9SGleb Smirnoff };
12113b3a8eb9SGleb Smirnoff #define	pfrio_exists	pfrio_nadd
12123b3a8eb9SGleb Smirnoff #define	pfrio_nzero	pfrio_nadd
12133b3a8eb9SGleb Smirnoff #define	pfrio_nmatch	pfrio_nadd
12143b3a8eb9SGleb Smirnoff #define pfrio_naddr	pfrio_size2
12153b3a8eb9SGleb Smirnoff #define pfrio_setflag	pfrio_size2
12163b3a8eb9SGleb Smirnoff #define pfrio_clrflag	pfrio_nadd
12173b3a8eb9SGleb Smirnoff 
12183b3a8eb9SGleb Smirnoff struct pfioc_iface {
12193b3a8eb9SGleb Smirnoff 	char	 pfiio_name[IFNAMSIZ];
12203b3a8eb9SGleb Smirnoff 	void	*pfiio_buffer;
12213b3a8eb9SGleb Smirnoff 	int	 pfiio_esize;
12223b3a8eb9SGleb Smirnoff 	int	 pfiio_size;
12233b3a8eb9SGleb Smirnoff 	int	 pfiio_nzero;
12243b3a8eb9SGleb Smirnoff 	int	 pfiio_flags;
12253b3a8eb9SGleb Smirnoff };
12263b3a8eb9SGleb Smirnoff 
12273b3a8eb9SGleb Smirnoff /*
12283b3a8eb9SGleb Smirnoff  * ioctl operations
12293b3a8eb9SGleb Smirnoff  */
12303b3a8eb9SGleb Smirnoff 
12313b3a8eb9SGleb Smirnoff #define DIOCSTART	_IO  ('D',  1)
12323b3a8eb9SGleb Smirnoff #define DIOCSTOP	_IO  ('D',  2)
12333b3a8eb9SGleb Smirnoff #define DIOCADDRULE	_IOWR('D',  4, struct pfioc_rule)
12343b3a8eb9SGleb Smirnoff #define DIOCGETRULES	_IOWR('D',  6, struct pfioc_rule)
12353b3a8eb9SGleb Smirnoff #define DIOCGETRULE	_IOWR('D',  7, struct pfioc_rule)
12363b3a8eb9SGleb Smirnoff /* XXX cut 8 - 17 */
12373b3a8eb9SGleb Smirnoff #define DIOCCLRSTATES	_IOWR('D', 18, struct pfioc_state_kill)
1238cc535c95SWill Andrews #define DIOCGETSTATE	_IOWR('D', 19, struct pfioc_state)
12393b3a8eb9SGleb Smirnoff #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if)
12403b3a8eb9SGleb Smirnoff #define DIOCGETSTATUS	_IOWR('D', 21, struct pf_status)
12413b3a8eb9SGleb Smirnoff #define DIOCCLRSTATUS	_IO  ('D', 22)
12423b3a8eb9SGleb Smirnoff #define DIOCNATLOOK	_IOWR('D', 23, struct pfioc_natlook)
12433b3a8eb9SGleb Smirnoff #define DIOCSETDEBUG	_IOWR('D', 24, u_int32_t)
12443b3a8eb9SGleb Smirnoff #define DIOCGETSTATES	_IOWR('D', 25, struct pfioc_states)
1245cc535c95SWill Andrews #define DIOCCHANGERULE	_IOWR('D', 26, struct pfioc_rule)
12463b3a8eb9SGleb Smirnoff /* XXX cut 26 - 28 */
12473b3a8eb9SGleb Smirnoff #define DIOCSETTIMEOUT	_IOWR('D', 29, struct pfioc_tm)
12483b3a8eb9SGleb Smirnoff #define DIOCGETTIMEOUT	_IOWR('D', 30, struct pfioc_tm)
1249cc535c95SWill Andrews #define DIOCADDSTATE	_IOWR('D', 37, struct pfioc_state)
1250cc535c95SWill Andrews #define DIOCCLRRULECTRS	_IO  ('D', 38)
12513b3a8eb9SGleb Smirnoff #define DIOCGETLIMIT	_IOWR('D', 39, struct pfioc_limit)
12523b3a8eb9SGleb Smirnoff #define DIOCSETLIMIT	_IOWR('D', 40, struct pfioc_limit)
12533b3a8eb9SGleb Smirnoff #define DIOCKILLSTATES	_IOWR('D', 41, struct pfioc_state_kill)
12543b3a8eb9SGleb Smirnoff #define DIOCSTARTALTQ	_IO  ('D', 42)
12553b3a8eb9SGleb Smirnoff #define DIOCSTOPALTQ	_IO  ('D', 43)
1256249cc75fSPatrick Kelsey #define DIOCADDALTQV0	_IOWR('D', 45, struct pfioc_altq_v0)
1257249cc75fSPatrick Kelsey #define DIOCADDALTQV1	_IOWR('D', 45, struct pfioc_altq_v1)
1258249cc75fSPatrick Kelsey #define DIOCGETALTQSV0	_IOWR('D', 47, struct pfioc_altq_v0)
1259249cc75fSPatrick Kelsey #define DIOCGETALTQSV1	_IOWR('D', 47, struct pfioc_altq_v1)
1260249cc75fSPatrick Kelsey #define DIOCGETALTQV0	_IOWR('D', 48, struct pfioc_altq_v0)
1261249cc75fSPatrick Kelsey #define DIOCGETALTQV1	_IOWR('D', 48, struct pfioc_altq_v1)
1262249cc75fSPatrick Kelsey #define DIOCCHANGEALTQV0 _IOWR('D', 49, struct pfioc_altq_v0)
1263249cc75fSPatrick Kelsey #define DIOCCHANGEALTQV1 _IOWR('D', 49, struct pfioc_altq_v1)
1264249cc75fSPatrick Kelsey #define DIOCGETQSTATSV0	_IOWR('D', 50, struct pfioc_qstats_v0)
1265249cc75fSPatrick Kelsey #define DIOCGETQSTATSV1	_IOWR('D', 50, struct pfioc_qstats_v1)
12663b3a8eb9SGleb Smirnoff #define DIOCBEGINADDRS	_IOWR('D', 51, struct pfioc_pooladdr)
12673b3a8eb9SGleb Smirnoff #define DIOCADDADDR	_IOWR('D', 52, struct pfioc_pooladdr)
12683b3a8eb9SGleb Smirnoff #define DIOCGETADDRS	_IOWR('D', 53, struct pfioc_pooladdr)
12693b3a8eb9SGleb Smirnoff #define DIOCGETADDR	_IOWR('D', 54, struct pfioc_pooladdr)
1270cc535c95SWill Andrews #define DIOCCHANGEADDR	_IOWR('D', 55, struct pfioc_pooladdr)
12713b3a8eb9SGleb Smirnoff /* XXX cut 55 - 57 */
12723b3a8eb9SGleb Smirnoff #define	DIOCGETRULESETS	_IOWR('D', 58, struct pfioc_ruleset)
12733b3a8eb9SGleb Smirnoff #define	DIOCGETRULESET	_IOWR('D', 59, struct pfioc_ruleset)
12743b3a8eb9SGleb Smirnoff #define	DIOCRCLRTABLES	_IOWR('D', 60, struct pfioc_table)
12753b3a8eb9SGleb Smirnoff #define	DIOCRADDTABLES	_IOWR('D', 61, struct pfioc_table)
12763b3a8eb9SGleb Smirnoff #define	DIOCRDELTABLES	_IOWR('D', 62, struct pfioc_table)
12773b3a8eb9SGleb Smirnoff #define	DIOCRGETTABLES	_IOWR('D', 63, struct pfioc_table)
12783b3a8eb9SGleb Smirnoff #define	DIOCRGETTSTATS	_IOWR('D', 64, struct pfioc_table)
12793b3a8eb9SGleb Smirnoff #define DIOCRCLRTSTATS	_IOWR('D', 65, struct pfioc_table)
12803b3a8eb9SGleb Smirnoff #define	DIOCRCLRADDRS	_IOWR('D', 66, struct pfioc_table)
12813b3a8eb9SGleb Smirnoff #define	DIOCRADDADDRS	_IOWR('D', 67, struct pfioc_table)
12823b3a8eb9SGleb Smirnoff #define	DIOCRDELADDRS	_IOWR('D', 68, struct pfioc_table)
12833b3a8eb9SGleb Smirnoff #define	DIOCRSETADDRS	_IOWR('D', 69, struct pfioc_table)
12843b3a8eb9SGleb Smirnoff #define	DIOCRGETADDRS	_IOWR('D', 70, struct pfioc_table)
12853b3a8eb9SGleb Smirnoff #define	DIOCRGETASTATS	_IOWR('D', 71, struct pfioc_table)
12863b3a8eb9SGleb Smirnoff #define	DIOCRCLRASTATS	_IOWR('D', 72, struct pfioc_table)
12873b3a8eb9SGleb Smirnoff #define	DIOCRTSTADDRS	_IOWR('D', 73, struct pfioc_table)
12883b3a8eb9SGleb Smirnoff #define	DIOCRSETTFLAGS	_IOWR('D', 74, struct pfioc_table)
12893b3a8eb9SGleb Smirnoff #define	DIOCRINADEFINE	_IOWR('D', 77, struct pfioc_table)
12903b3a8eb9SGleb Smirnoff #define	DIOCOSFPFLUSH	_IO('D', 78)
12913b3a8eb9SGleb Smirnoff #define	DIOCOSFPADD	_IOWR('D', 79, struct pf_osfp_ioctl)
12923b3a8eb9SGleb Smirnoff #define	DIOCOSFPGET	_IOWR('D', 80, struct pf_osfp_ioctl)
12933b3a8eb9SGleb Smirnoff #define	DIOCXBEGIN	_IOWR('D', 81, struct pfioc_trans)
12943b3a8eb9SGleb Smirnoff #define	DIOCXCOMMIT	_IOWR('D', 82, struct pfioc_trans)
12953b3a8eb9SGleb Smirnoff #define	DIOCXROLLBACK	_IOWR('D', 83, struct pfioc_trans)
12963b3a8eb9SGleb Smirnoff #define	DIOCGETSRCNODES	_IOWR('D', 84, struct pfioc_src_nodes)
12973b3a8eb9SGleb Smirnoff #define	DIOCCLRSRCNODES	_IO('D', 85)
12983b3a8eb9SGleb Smirnoff #define	DIOCSETHOSTID	_IOWR('D', 86, u_int32_t)
12993b3a8eb9SGleb Smirnoff #define	DIOCIGETIFACES	_IOWR('D', 87, struct pfioc_iface)
13003b3a8eb9SGleb Smirnoff #define	DIOCSETIFFLAG	_IOWR('D', 89, struct pfioc_iface)
13013b3a8eb9SGleb Smirnoff #define	DIOCCLRIFFLAG	_IOWR('D', 90, struct pfioc_iface)
13023b3a8eb9SGleb Smirnoff #define	DIOCKILLSRCNODES	_IOWR('D', 91, struct pfioc_src_node_kill)
1303249cc75fSPatrick Kelsey struct pf_ifspeed_v0 {
13043b3a8eb9SGleb Smirnoff 	char			ifname[IFNAMSIZ];
13053b3a8eb9SGleb Smirnoff 	u_int32_t		baudrate;
13063b3a8eb9SGleb Smirnoff };
1307249cc75fSPatrick Kelsey 
1308249cc75fSPatrick Kelsey struct pf_ifspeed_v1 {
1309249cc75fSPatrick Kelsey 	char			ifname[IFNAMSIZ];
1310249cc75fSPatrick Kelsey 	u_int32_t		baudrate32;
1311249cc75fSPatrick Kelsey 	/* layout identical to struct pf_ifspeed_v0 up to this point */
1312249cc75fSPatrick Kelsey 	u_int64_t		baudrate;
1313249cc75fSPatrick Kelsey };
1314249cc75fSPatrick Kelsey 
1315249cc75fSPatrick Kelsey /* Latest version of struct pf_ifspeed_vX */
1316249cc75fSPatrick Kelsey #define PF_IFSPEED_VERSION	1
1317249cc75fSPatrick Kelsey 
1318249cc75fSPatrick Kelsey #define	DIOCGIFSPEEDV0	_IOWR('D', 92, struct pf_ifspeed_v0)
1319249cc75fSPatrick Kelsey #define	DIOCGIFSPEEDV1	_IOWR('D', 92, struct pf_ifspeed_v1)
1320249cc75fSPatrick Kelsey 
1321249cc75fSPatrick Kelsey /*
1322249cc75fSPatrick Kelsey  * Compatibility and convenience macros
1323249cc75fSPatrick Kelsey  */
1324249cc75fSPatrick Kelsey #ifndef _KERNEL
1325249cc75fSPatrick Kelsey #ifdef PFIOC_USE_LATEST
1326249cc75fSPatrick Kelsey /*
1327249cc75fSPatrick Kelsey  * Maintaining in-tree consumers of the ioctl interface is easier when that
1328249cc75fSPatrick Kelsey  * code can be written in terms old names that refer to the latest interface
1329249cc75fSPatrick Kelsey  * version as that reduces the required changes in the consumers to those
1330249cc75fSPatrick Kelsey  * that are functionally necessary to accommodate a new interface version.
1331249cc75fSPatrick Kelsey  */
1332249cc75fSPatrick Kelsey #define	pfioc_altq	__CONCAT(pfioc_altq_v, PFIOC_ALTQ_VERSION)
1333249cc75fSPatrick Kelsey #define	pfioc_qstats	__CONCAT(pfioc_qstats_v, PFIOC_QSTATS_VERSION)
1334249cc75fSPatrick Kelsey #define	pf_ifspeed	__CONCAT(pf_ifspeed_v, PF_IFSPEED_VERSION)
1335249cc75fSPatrick Kelsey 
1336249cc75fSPatrick Kelsey #define	DIOCADDALTQ	__CONCAT(DIOCADDALTQV, PFIOC_ALTQ_VERSION)
1337249cc75fSPatrick Kelsey #define	DIOCGETALTQS	__CONCAT(DIOCGETALTQSV, PFIOC_ALTQ_VERSION)
1338249cc75fSPatrick Kelsey #define	DIOCGETALTQ	__CONCAT(DIOCGETALTQV, PFIOC_ALTQ_VERSION)
1339249cc75fSPatrick Kelsey #define	DIOCCHANGEALTQ	__CONCAT(DIOCCHANGEALTQV, PFIOC_ALTQ_VERSION)
1340249cc75fSPatrick Kelsey #define	DIOCGETQSTATS	__CONCAT(DIOCGETQSTATSV, PFIOC_QSTATS_VERSION)
1341249cc75fSPatrick Kelsey #define	DIOCGIFSPEED	__CONCAT(DIOCGIFSPEEDV, PF_IFSPEED_VERSION)
1342249cc75fSPatrick Kelsey #else
1343249cc75fSPatrick Kelsey /*
1344249cc75fSPatrick Kelsey  * When building out-of-tree code that is written for the old interface,
1345249cc75fSPatrick Kelsey  * such as may exist in ports for example, resolve the old struct tags and
1346249cc75fSPatrick Kelsey  * ioctl command names to the v0 versions.
1347249cc75fSPatrick Kelsey  */
1348249cc75fSPatrick Kelsey #define	pfioc_altq	__CONCAT(pfioc_altq_v, 0)
1349249cc75fSPatrick Kelsey #define	pfioc_qstats	__CONCAT(pfioc_qstats_v, 0)
1350249cc75fSPatrick Kelsey #define	pf_ifspeed	__CONCAT(pf_ifspeed_v, 0)
1351249cc75fSPatrick Kelsey 
1352249cc75fSPatrick Kelsey #define	DIOCADDALTQ	__CONCAT(DIOCADDALTQV, 0)
1353249cc75fSPatrick Kelsey #define	DIOCGETALTQS	__CONCAT(DIOCGETALTQSV, 0)
1354249cc75fSPatrick Kelsey #define	DIOCGETALTQ	__CONCAT(DIOCGETALTQV, 0)
1355249cc75fSPatrick Kelsey #define	DIOCCHANGEALTQ	__CONCAT(DIOCCHANGEALTQV, 0)
1356249cc75fSPatrick Kelsey #define	DIOCGETQSTATS	__CONCAT(DIOCGETQSTATSV, 0)
1357249cc75fSPatrick Kelsey #define	DIOCGIFSPEED	__CONCAT(DIOCGIFSPEEDV, 0)
1358249cc75fSPatrick Kelsey #endif /* PFIOC_USE_LATEST */
1359249cc75fSPatrick Kelsey #endif /* _KERNEL */
13603b3a8eb9SGleb Smirnoff 
13613b3a8eb9SGleb Smirnoff #ifdef _KERNEL
136217ad7334SKristof Provost LIST_HEAD(pf_ksrc_node_list, pf_ksrc_node);
13633b3a8eb9SGleb Smirnoff struct pf_srchash {
136417ad7334SKristof Provost 	struct pf_ksrc_node_list		nodes;
13653b3a8eb9SGleb Smirnoff 	struct mtx			lock;
13663b3a8eb9SGleb Smirnoff };
13673b3a8eb9SGleb Smirnoff 
13683b3a8eb9SGleb Smirnoff struct pf_keyhash {
13693b3a8eb9SGleb Smirnoff 	LIST_HEAD(, pf_state_key)	keys;
13703b3a8eb9SGleb Smirnoff 	struct mtx			lock;
13713b3a8eb9SGleb Smirnoff };
13723b3a8eb9SGleb Smirnoff 
13733b3a8eb9SGleb Smirnoff struct pf_idhash {
13743b3a8eb9SGleb Smirnoff 	LIST_HEAD(, pf_state)		states;
13753b3a8eb9SGleb Smirnoff 	struct mtx			lock;
13763b3a8eb9SGleb Smirnoff };
13773b3a8eb9SGleb Smirnoff 
13786828cc99SGleb Smirnoff extern u_long		pf_hashmask;
13796828cc99SGleb Smirnoff extern u_long		pf_srchashmask;
138091e0f2d2SKristof Provost #define	PF_HASHSIZ	(131072)
1381bf56a3feSKristof Provost #define	PF_SRCHASHSIZ	(PF_HASHSIZ/4)
13823b3a8eb9SGleb Smirnoff VNET_DECLARE(struct pf_keyhash *, pf_keyhash);
13833b3a8eb9SGleb Smirnoff VNET_DECLARE(struct pf_idhash *, pf_idhash);
13843b3a8eb9SGleb Smirnoff #define V_pf_keyhash	VNET(pf_keyhash)
13853b3a8eb9SGleb Smirnoff #define	V_pf_idhash	VNET(pf_idhash)
13863b3a8eb9SGleb Smirnoff VNET_DECLARE(struct pf_srchash *, pf_srchash);
13873b3a8eb9SGleb Smirnoff #define	V_pf_srchash	VNET(pf_srchash)
13883b3a8eb9SGleb Smirnoff 
13896828cc99SGleb Smirnoff #define PF_IDHASH(s)	(be64toh((s)->id) % (pf_hashmask + 1))
13903b3a8eb9SGleb Smirnoff 
13913b3a8eb9SGleb Smirnoff VNET_DECLARE(void *, pf_swi_cookie);
13923b3a8eb9SGleb Smirnoff #define V_pf_swi_cookie	VNET(pf_swi_cookie)
1393cecfaf9bSKristof Provost VNET_DECLARE(struct intr_event *, pf_swi_ie);
1394cecfaf9bSKristof Provost #define	V_pf_swi_ie	VNET(pf_swi_ie)
13953b3a8eb9SGleb Smirnoff 
13963b3a8eb9SGleb Smirnoff VNET_DECLARE(uint64_t, pf_stateid[MAXCPU]);
13973b3a8eb9SGleb Smirnoff #define	V_pf_stateid	VNET(pf_stateid)
13983b3a8eb9SGleb Smirnoff 
13993b3a8eb9SGleb Smirnoff TAILQ_HEAD(pf_altqqueue, pf_altq);
14008f2ac656SPatrick Kelsey VNET_DECLARE(struct pf_altqqueue,	 pf_altqs[4]);
14013b3a8eb9SGleb Smirnoff #define	V_pf_altqs			 VNET(pf_altqs)
1402320c1116SKristof Provost VNET_DECLARE(struct pf_kpalist,		 pf_pabuf);
14033b3a8eb9SGleb Smirnoff #define	V_pf_pabuf			 VNET(pf_pabuf)
14043b3a8eb9SGleb Smirnoff 
14053b3a8eb9SGleb Smirnoff VNET_DECLARE(u_int32_t,			 ticket_altqs_active);
14063b3a8eb9SGleb Smirnoff #define	V_ticket_altqs_active		 VNET(ticket_altqs_active)
14073b3a8eb9SGleb Smirnoff VNET_DECLARE(u_int32_t,			 ticket_altqs_inactive);
14083b3a8eb9SGleb Smirnoff #define	V_ticket_altqs_inactive		 VNET(ticket_altqs_inactive)
14093b3a8eb9SGleb Smirnoff VNET_DECLARE(int,			 altqs_inactive_open);
14103b3a8eb9SGleb Smirnoff #define	V_altqs_inactive_open		 VNET(altqs_inactive_open)
14113b3a8eb9SGleb Smirnoff VNET_DECLARE(u_int32_t,			 ticket_pabuf);
14123b3a8eb9SGleb Smirnoff #define	V_ticket_pabuf			 VNET(ticket_pabuf)
14133b3a8eb9SGleb Smirnoff VNET_DECLARE(struct pf_altqqueue *,	 pf_altqs_active);
14143b3a8eb9SGleb Smirnoff #define	V_pf_altqs_active		 VNET(pf_altqs_active)
14158f2ac656SPatrick Kelsey VNET_DECLARE(struct pf_altqqueue *,	 pf_altq_ifs_active);
14168f2ac656SPatrick Kelsey #define	V_pf_altq_ifs_active		 VNET(pf_altq_ifs_active)
14173b3a8eb9SGleb Smirnoff VNET_DECLARE(struct pf_altqqueue *,	 pf_altqs_inactive);
14183b3a8eb9SGleb Smirnoff #define	V_pf_altqs_inactive		 VNET(pf_altqs_inactive)
14198f2ac656SPatrick Kelsey VNET_DECLARE(struct pf_altqqueue *,	 pf_altq_ifs_inactive);
14208f2ac656SPatrick Kelsey #define	V_pf_altq_ifs_inactive		 VNET(pf_altq_ifs_inactive)
14213b3a8eb9SGleb Smirnoff 
1422e86bddeaSKristof Provost VNET_DECLARE(struct pf_krulequeue, pf_unlinked_rules);
14233b3a8eb9SGleb Smirnoff #define	V_pf_unlinked_rules	VNET(pf_unlinked_rules)
14243b3a8eb9SGleb Smirnoff 
1425efc6c51fSGleb Smirnoff void				 pf_initialize(void);
14267e92ce73SMartin Matuska void				 pf_mtag_initialize(void);
14277e92ce73SMartin Matuska void				 pf_mtag_cleanup(void);
14283b3a8eb9SGleb Smirnoff void				 pf_cleanup(void);
14293b3a8eb9SGleb Smirnoff 
14303b3a8eb9SGleb Smirnoff struct pf_mtag			*pf_get_mtag(struct mbuf *);
14313b3a8eb9SGleb Smirnoff 
1432e86bddeaSKristof Provost extern void			 pf_calc_skip_steps(struct pf_krulequeue *);
14333b3a8eb9SGleb Smirnoff #ifdef ALTQ
14343b3a8eb9SGleb Smirnoff extern	void			 pf_altq_ifnet_event(struct ifnet *, int);
14353b3a8eb9SGleb Smirnoff #endif
14363b3a8eb9SGleb Smirnoff VNET_DECLARE(uma_zone_t,	 pf_state_z);
14373b3a8eb9SGleb Smirnoff #define	V_pf_state_z		 VNET(pf_state_z)
14383b3a8eb9SGleb Smirnoff VNET_DECLARE(uma_zone_t,	 pf_state_key_z);
14393b3a8eb9SGleb Smirnoff #define	V_pf_state_key_z	 VNET(pf_state_key_z)
14403b3a8eb9SGleb Smirnoff VNET_DECLARE(uma_zone_t,	 pf_state_scrub_z);
14413b3a8eb9SGleb Smirnoff #define	V_pf_state_scrub_z	 VNET(pf_state_scrub_z)
14423b3a8eb9SGleb Smirnoff 
14433b3a8eb9SGleb Smirnoff extern void			 pf_purge_thread(void *);
1444a0429b54SBjoern A. Zeeb extern void			 pf_unload_vnet_purge(void);
14453b3a8eb9SGleb Smirnoff extern void			 pf_intr(void *);
14463b3a8eb9SGleb Smirnoff extern void			 pf_purge_expired_src_nodes(void);
14473b3a8eb9SGleb Smirnoff 
14483b3a8eb9SGleb Smirnoff extern int			 pf_unlink_state(struct pf_state *, u_int);
14493b3a8eb9SGleb Smirnoff #define	PF_ENTER_LOCKED		0x00000001
14503b3a8eb9SGleb Smirnoff #define	PF_RETURN_LOCKED	0x00000002
1451320c1116SKristof Provost extern int			 pf_state_insert(struct pfi_kkif *,
14523b3a8eb9SGleb Smirnoff 				    struct pf_state_key *,
14533b3a8eb9SGleb Smirnoff 				    struct pf_state_key *,
14543b3a8eb9SGleb Smirnoff 				    struct pf_state *);
14553b3a8eb9SGleb Smirnoff extern void			 pf_free_state(struct pf_state *);
14563b3a8eb9SGleb Smirnoff 
14573b3a8eb9SGleb Smirnoff static __inline void
14583b3a8eb9SGleb Smirnoff pf_ref_state(struct pf_state *s)
14593b3a8eb9SGleb Smirnoff {
14603b3a8eb9SGleb Smirnoff 
14613b3a8eb9SGleb Smirnoff 	refcount_acquire(&s->refs);
14623b3a8eb9SGleb Smirnoff }
14633b3a8eb9SGleb Smirnoff 
14643b3a8eb9SGleb Smirnoff static __inline int
14653b3a8eb9SGleb Smirnoff pf_release_state(struct pf_state *s)
14663b3a8eb9SGleb Smirnoff {
14673b3a8eb9SGleb Smirnoff 
14683b3a8eb9SGleb Smirnoff 	if (refcount_release(&s->refs)) {
14693b3a8eb9SGleb Smirnoff 		pf_free_state(s);
14703b3a8eb9SGleb Smirnoff 		return (1);
14713b3a8eb9SGleb Smirnoff 	} else
14723b3a8eb9SGleb Smirnoff 		return (0);
14733b3a8eb9SGleb Smirnoff }
14743b3a8eb9SGleb Smirnoff 
14753b3a8eb9SGleb Smirnoff extern struct pf_state		*pf_find_state_byid(uint64_t, uint32_t);
14763b3a8eb9SGleb Smirnoff extern struct pf_state		*pf_find_state_all(struct pf_state_key_cmp *,
14773b3a8eb9SGleb Smirnoff 				    u_int, int *);
147817ad7334SKristof Provost extern struct pf_ksrc_node	*pf_find_src_node(struct pf_addr *,
1479e86bddeaSKristof Provost 				    struct pf_krule *, sa_family_t, int);
148017ad7334SKristof Provost extern void			 pf_unlink_src_node(struct pf_ksrc_node *);
148117ad7334SKristof Provost extern u_int			 pf_free_src_nodes(struct pf_ksrc_node_list *);
148207d9bc07SGleb Smirnoff extern void			 pf_print_state(struct pf_state *);
148307d9bc07SGleb Smirnoff extern void			 pf_print_flags(u_int8_t);
14843b3a8eb9SGleb Smirnoff extern u_int16_t		 pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t,
14853b3a8eb9SGleb Smirnoff 				    u_int8_t);
1486c110fc49SKristof Provost extern u_int16_t		 pf_proto_cksum_fixup(struct mbuf *, u_int16_t,
1487c110fc49SKristof Provost 				    u_int16_t, u_int16_t, u_int8_t);
14883b3a8eb9SGleb Smirnoff 
14893b3a8eb9SGleb Smirnoff VNET_DECLARE(struct ifnet *,		 sync_ifp);
14903b3a8eb9SGleb Smirnoff #define	V_sync_ifp		 	 VNET(sync_ifp);
1491e86bddeaSKristof Provost VNET_DECLARE(struct pf_krule,		 pf_default_rule);
14923b3a8eb9SGleb Smirnoff #define	V_pf_default_rule		  VNET(pf_default_rule)
14933b3a8eb9SGleb Smirnoff extern void			 pf_addrcpy(struct pf_addr *, struct pf_addr *,
14943b3a8eb9SGleb Smirnoff 				    u_int8_t);
1495e86bddeaSKristof Provost void				pf_free_rule(struct pf_krule *);
14963b3a8eb9SGleb Smirnoff 
14973b3a8eb9SGleb Smirnoff #ifdef INET
1498effaab88SKristof Provost int	pf_test(int, int, struct ifnet *, struct mbuf **, struct inpcb *);
1499320c1116SKristof Provost int	pf_normalize_ip(struct mbuf **, int, struct pfi_kkif *, u_short *,
15000324938aSGleb Smirnoff 	    struct pf_pdesc *);
15013b3a8eb9SGleb Smirnoff #endif /* INET */
15023b3a8eb9SGleb Smirnoff 
15033b3a8eb9SGleb Smirnoff #ifdef INET6
1504effaab88SKristof Provost int	pf_test6(int, int, struct ifnet *, struct mbuf **, struct inpcb *);
1505320c1116SKristof Provost int	pf_normalize_ip6(struct mbuf **, int, struct pfi_kkif *, u_short *,
15060324938aSGleb Smirnoff 	    struct pf_pdesc *);
15073b3a8eb9SGleb Smirnoff void	pf_poolmask(struct pf_addr *, struct pf_addr*,
15083b3a8eb9SGleb Smirnoff 	    struct pf_addr *, struct pf_addr *, u_int8_t);
15093b3a8eb9SGleb Smirnoff void	pf_addr_inc(struct pf_addr *, sa_family_t);
15108dc98c2aSGleb Smirnoff int	pf_refragment6(struct ifnet *, struct mbuf **, struct m_tag *);
15113b3a8eb9SGleb Smirnoff #endif /* INET6 */
15123b3a8eb9SGleb Smirnoff 
15133b3a8eb9SGleb Smirnoff u_int32_t	pf_new_isn(struct pf_state *);
15143b3a8eb9SGleb Smirnoff void   *pf_pull_hdr(struct mbuf *, int, void *, int, u_short *, u_short *,
15153b3a8eb9SGleb Smirnoff 	    sa_family_t);
15163b3a8eb9SGleb Smirnoff void	pf_change_a(void *, u_int16_t *, u_int32_t, u_int8_t);
1517c110fc49SKristof Provost void	pf_change_proto_a(struct mbuf *, void *, u_int16_t *, u_int32_t,
1518c110fc49SKristof Provost 	    u_int8_t);
1519c110fc49SKristof Provost void	pf_change_tcp_a(struct mbuf *, void *, u_int16_t *, u_int32_t);
1520c3f69af0SKristof Provost void	pf_patch_16_unaligned(struct mbuf *, u_int16_t *, void *, u_int16_t,
1521c3f69af0SKristof Provost 	    bool, u_int8_t);
1522c3f69af0SKristof Provost void	pf_patch_32_unaligned(struct mbuf *, u_int16_t *, void *, u_int32_t,
1523c3f69af0SKristof Provost     bool, u_int8_t);
15243b3a8eb9SGleb Smirnoff void	pf_send_deferred_syn(struct pf_state *);
15253b3a8eb9SGleb Smirnoff int	pf_match_addr(u_int8_t, struct pf_addr *, struct pf_addr *,
15263b3a8eb9SGleb Smirnoff 	    struct pf_addr *, sa_family_t);
15273b3a8eb9SGleb Smirnoff int	pf_match_addr_range(struct pf_addr *, struct pf_addr *,
15283b3a8eb9SGleb Smirnoff 	    struct pf_addr *, sa_family_t);
15293b3a8eb9SGleb Smirnoff int	pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t);
15303b3a8eb9SGleb Smirnoff 
1531efc6c51fSGleb Smirnoff void	pf_normalize_init(void);
15323b3a8eb9SGleb Smirnoff void	pf_normalize_cleanup(void);
1533320c1116SKristof Provost int	pf_normalize_tcp(int, struct pfi_kkif *, struct mbuf *, int, int, void *,
15343b3a8eb9SGleb Smirnoff 	    struct pf_pdesc *);
15353b3a8eb9SGleb Smirnoff void	pf_normalize_tcp_cleanup(struct pf_state *);
15363b3a8eb9SGleb Smirnoff int	pf_normalize_tcp_init(struct mbuf *, int, struct pf_pdesc *,
15373b3a8eb9SGleb Smirnoff 	    struct tcphdr *, struct pf_state_peer *, struct pf_state_peer *);
15383b3a8eb9SGleb Smirnoff int	pf_normalize_tcp_stateful(struct mbuf *, int, struct pf_pdesc *,
15393b3a8eb9SGleb Smirnoff 	    u_short *, struct tcphdr *, struct pf_state *,
15403b3a8eb9SGleb Smirnoff 	    struct pf_state_peer *, struct pf_state_peer *, int *);
15413b3a8eb9SGleb Smirnoff u_int32_t
15423b3a8eb9SGleb Smirnoff 	pf_state_expires(const struct pf_state *);
15433b3a8eb9SGleb Smirnoff void	pf_purge_expired_fragments(void);
15445d0020d6SKristof Provost void	pf_purge_fragments(uint32_t);
1545320c1116SKristof Provost int	pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kkif *,
15463b3a8eb9SGleb Smirnoff 	    int);
15473b3a8eb9SGleb Smirnoff int	pf_socket_lookup(int, struct pf_pdesc *, struct mbuf *);
15483b3a8eb9SGleb Smirnoff struct pf_state_key *pf_alloc_state_key(int);
15493b3a8eb9SGleb Smirnoff void	pfr_initialize(void);
15503b3a8eb9SGleb Smirnoff void	pfr_cleanup(void);
15513b3a8eb9SGleb Smirnoff int	pfr_match_addr(struct pfr_ktable *, struct pf_addr *, sa_family_t);
15523b3a8eb9SGleb Smirnoff void	pfr_update_stats(struct pfr_ktable *, struct pf_addr *, sa_family_t,
15533b3a8eb9SGleb Smirnoff 	    u_int64_t, int, int, int);
15543b3a8eb9SGleb Smirnoff int	pfr_pool_get(struct pfr_ktable *, int *, struct pf_addr *, sa_family_t);
15553b3a8eb9SGleb Smirnoff void	pfr_dynaddr_update(struct pfr_ktable *, struct pfi_dynaddr *);
15563b3a8eb9SGleb Smirnoff struct pfr_ktable *
1557e86bddeaSKristof Provost 	pfr_attach_table(struct pf_kruleset *, char *);
15583b3a8eb9SGleb Smirnoff void	pfr_detach_table(struct pfr_ktable *);
15593b3a8eb9SGleb Smirnoff int	pfr_clr_tables(struct pfr_table *, int *, int);
15603b3a8eb9SGleb Smirnoff int	pfr_add_tables(struct pfr_table *, int, int *, int);
15613b3a8eb9SGleb Smirnoff int	pfr_del_tables(struct pfr_table *, int, int *, int);
1562adfe2f6aSKristof Provost int	pfr_table_count(struct pfr_table *, int);
15633b3a8eb9SGleb Smirnoff int	pfr_get_tables(struct pfr_table *, struct pfr_table *, int *, int);
15643b3a8eb9SGleb Smirnoff int	pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int);
15653b3a8eb9SGleb Smirnoff int	pfr_clr_tstats(struct pfr_table *, int, int *, int);
15663b3a8eb9SGleb Smirnoff int	pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int);
15673b3a8eb9SGleb Smirnoff int	pfr_clr_addrs(struct pfr_table *, int *, int);
15683b3a8eb9SGleb Smirnoff int	pfr_insert_kentry(struct pfr_ktable *, struct pfr_addr *, long);
15693b3a8eb9SGleb Smirnoff int	pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
15703b3a8eb9SGleb Smirnoff 	    int);
15713b3a8eb9SGleb Smirnoff int	pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
15723b3a8eb9SGleb Smirnoff 	    int);
15733b3a8eb9SGleb Smirnoff int	pfr_set_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
15743b3a8eb9SGleb Smirnoff 	    int *, int *, int *, int, u_int32_t);
15753b3a8eb9SGleb Smirnoff int	pfr_get_addrs(struct pfr_table *, struct pfr_addr *, int *, int);
15763b3a8eb9SGleb Smirnoff int	pfr_get_astats(struct pfr_table *, struct pfr_astats *, int *, int);
15773b3a8eb9SGleb Smirnoff int	pfr_clr_astats(struct pfr_table *, struct pfr_addr *, int, int *,
15783b3a8eb9SGleb Smirnoff 	    int);
15793b3a8eb9SGleb Smirnoff int	pfr_tst_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
15803b3a8eb9SGleb Smirnoff 	    int);
15813b3a8eb9SGleb Smirnoff int	pfr_ina_begin(struct pfr_table *, u_int32_t *, int *, int);
15823b3a8eb9SGleb Smirnoff int	pfr_ina_rollback(struct pfr_table *, u_int32_t, int *, int);
15833b3a8eb9SGleb Smirnoff int	pfr_ina_commit(struct pfr_table *, u_int32_t, int *, int *, int);
15843b3a8eb9SGleb Smirnoff int	pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *,
15853b3a8eb9SGleb Smirnoff 	    int *, u_int32_t, int);
15863b3a8eb9SGleb Smirnoff 
15873b3a8eb9SGleb Smirnoff MALLOC_DECLARE(PFI_MTYPE);
1588320c1116SKristof Provost VNET_DECLARE(struct pfi_kkif *,		 pfi_all);
15893b3a8eb9SGleb Smirnoff #define	V_pfi_all	 		 VNET(pfi_all)
15903b3a8eb9SGleb Smirnoff 
1591efc6c51fSGleb Smirnoff void		 pfi_initialize(void);
1592a0429b54SBjoern A. Zeeb void		 pfi_initialize_vnet(void);
15933b3a8eb9SGleb Smirnoff void		 pfi_cleanup(void);
1594a0429b54SBjoern A. Zeeb void		 pfi_cleanup_vnet(void);
1595320c1116SKristof Provost void		 pfi_kkif_ref(struct pfi_kkif *);
1596320c1116SKristof Provost void		 pfi_kkif_unref(struct pfi_kkif *);
1597320c1116SKristof Provost struct pfi_kkif	*pfi_kkif_find(const char *);
1598320c1116SKristof Provost struct pfi_kkif	*pfi_kkif_attach(struct pfi_kkif *, const char *);
1599320c1116SKristof Provost int		 pfi_kkif_match(struct pfi_kkif *, struct pfi_kkif *);
1600320c1116SKristof Provost void		 pfi_kkif_purge(void);
16013b3a8eb9SGleb Smirnoff int		 pfi_match_addr(struct pfi_dynaddr *, struct pf_addr *,
16023b3a8eb9SGleb Smirnoff 		    sa_family_t);
16033b3a8eb9SGleb Smirnoff int		 pfi_dynaddr_setup(struct pf_addr_wrap *, sa_family_t);
16043b3a8eb9SGleb Smirnoff void		 pfi_dynaddr_remove(struct pfi_dynaddr *);
16053b3a8eb9SGleb Smirnoff void		 pfi_dynaddr_copyout(struct pf_addr_wrap *);
16063b3a8eb9SGleb Smirnoff void		 pfi_update_status(const char *, struct pf_status *);
16073b3a8eb9SGleb Smirnoff void		 pfi_get_ifaces(const char *, struct pfi_kif *, int *);
16083b3a8eb9SGleb Smirnoff int		 pfi_set_flags(const char *, int);
16093b3a8eb9SGleb Smirnoff int		 pfi_clear_flags(const char *, int);
16103b3a8eb9SGleb Smirnoff 
1611e86bddeaSKristof Provost int		 pf_match_tag(struct mbuf *, struct pf_krule *, int *, int);
16123b3a8eb9SGleb Smirnoff int		 pf_tag_packet(struct mbuf *, struct pf_pdesc *, int);
161360048052SGleb Smirnoff int		 pf_addr_cmp(struct pf_addr *, struct pf_addr *,
161460048052SGleb Smirnoff 		    sa_family_t);
16153b3a8eb9SGleb Smirnoff void		 pf_qid2qname(u_int32_t, char *);
16163b3a8eb9SGleb Smirnoff 
1617a9572d8fSGleb Smirnoff VNET_DECLARE(struct pf_kstatus, pf_status);
16183b3a8eb9SGleb Smirnoff #define	V_pf_status	VNET(pf_status)
16193b3a8eb9SGleb Smirnoff 
16203b3a8eb9SGleb Smirnoff struct pf_limit {
16213b3a8eb9SGleb Smirnoff 	uma_zone_t	zone;
16223b3a8eb9SGleb Smirnoff 	u_int		limit;
16233b3a8eb9SGleb Smirnoff };
16243b3a8eb9SGleb Smirnoff VNET_DECLARE(struct pf_limit, pf_limits[PF_LIMIT_MAX]);
16253b3a8eb9SGleb Smirnoff #define	V_pf_limits VNET(pf_limits)
16263b3a8eb9SGleb Smirnoff 
16273b3a8eb9SGleb Smirnoff #endif /* _KERNEL */
16283b3a8eb9SGleb Smirnoff 
16293b3a8eb9SGleb Smirnoff #ifdef _KERNEL
1630e86bddeaSKristof Provost VNET_DECLARE(struct pf_kanchor_global,		 pf_anchors);
16313b3a8eb9SGleb Smirnoff #define	V_pf_anchors				 VNET(pf_anchors)
1632e86bddeaSKristof Provost VNET_DECLARE(struct pf_kanchor,			 pf_main_anchor);
16333b3a8eb9SGleb Smirnoff #define	V_pf_main_anchor			 VNET(pf_main_anchor)
16343b3a8eb9SGleb Smirnoff #define pf_main_ruleset	V_pf_main_anchor.ruleset
16353b3a8eb9SGleb Smirnoff 
1636e86bddeaSKristof Provost void			 pf_init_kruleset(struct pf_kruleset *);
1637e86bddeaSKristof Provost int			 pf_kanchor_setup(struct pf_krule *,
1638e86bddeaSKristof Provost 			    const struct pf_kruleset *, const char *);
1639e86bddeaSKristof Provost int			 pf_kanchor_copyout(const struct pf_kruleset *,
1640e86bddeaSKristof Provost 			    const struct pf_krule *, struct pfioc_rule *);
1641e86bddeaSKristof Provost void			 pf_kanchor_remove(struct pf_krule *);
1642e86bddeaSKristof Provost void			 pf_remove_if_empty_kruleset(struct pf_kruleset *);
1643e86bddeaSKristof Provost struct pf_kruleset	*pf_find_kruleset(const char *);
1644e86bddeaSKristof Provost struct pf_kruleset	*pf_find_or_create_kruleset(const char *);
16453b3a8eb9SGleb Smirnoff void			 pf_rs_initialize(void);
16465e9dae8eSKristof Provost 
16475e9dae8eSKristof Provost void			 pf_krule_free(struct pf_krule *);
1648e86bddeaSKristof Provost #endif
16493b3a8eb9SGleb Smirnoff 
16503b3a8eb9SGleb Smirnoff /* The fingerprint functions can be linked into userland programs (tcpdump) */
16513b3a8eb9SGleb Smirnoff int	pf_osfp_add(struct pf_osfp_ioctl *);
16523b3a8eb9SGleb Smirnoff #ifdef _KERNEL
16533b3a8eb9SGleb Smirnoff struct pf_osfp_enlist *
16543b3a8eb9SGleb Smirnoff 	pf_osfp_fingerprint(struct pf_pdesc *, struct mbuf *, int,
16553b3a8eb9SGleb Smirnoff 	    const struct tcphdr *);
16563b3a8eb9SGleb Smirnoff #endif /* _KERNEL */
16573b3a8eb9SGleb Smirnoff void	pf_osfp_flush(void);
16583b3a8eb9SGleb Smirnoff int	pf_osfp_get(struct pf_osfp_ioctl *);
16593b3a8eb9SGleb Smirnoff int	pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t);
16603b3a8eb9SGleb Smirnoff 
16613b3a8eb9SGleb Smirnoff #ifdef _KERNEL
166207d9bc07SGleb Smirnoff void			 pf_print_host(struct pf_addr *, u_int16_t, u_int8_t);
166307d9bc07SGleb Smirnoff 
1664e86bddeaSKristof Provost void			 pf_step_into_anchor(struct pf_kanchor_stackframe *, int *,
1665e86bddeaSKristof Provost 			    struct pf_kruleset **, int, struct pf_krule **,
1666e86bddeaSKristof Provost 			    struct pf_krule **, int *);
1667e86bddeaSKristof Provost int			 pf_step_out_of_anchor(struct pf_kanchor_stackframe *, int *,
1668e86bddeaSKristof Provost 			    struct pf_kruleset **, int, struct pf_krule **,
1669e86bddeaSKristof Provost 			    struct pf_krule **, int *);
16703b3a8eb9SGleb Smirnoff 
1671e86bddeaSKristof Provost int			 pf_map_addr(u_int8_t, struct pf_krule *,
16723b3a8eb9SGleb Smirnoff 			    struct pf_addr *, struct pf_addr *,
167317ad7334SKristof Provost 			    struct pf_addr *, struct pf_ksrc_node **);
1674e86bddeaSKristof Provost struct pf_krule		*pf_get_translation(struct pf_pdesc *, struct mbuf *,
1675320c1116SKristof Provost 			    int, int, struct pfi_kkif *, struct pf_ksrc_node **,
16763b3a8eb9SGleb Smirnoff 			    struct pf_state_key **, struct pf_state_key **,
16773b3a8eb9SGleb Smirnoff 			    struct pf_addr *, struct pf_addr *,
1678e86bddeaSKristof Provost 			    uint16_t, uint16_t, struct pf_kanchor_stackframe *);
16793b3a8eb9SGleb Smirnoff 
16803b3a8eb9SGleb Smirnoff struct pf_state_key	*pf_state_key_setup(struct pf_pdesc *, struct pf_addr *,
16813b3a8eb9SGleb Smirnoff 			    struct pf_addr *, u_int16_t, u_int16_t);
16823b3a8eb9SGleb Smirnoff struct pf_state_key	*pf_state_key_clone(struct pf_state_key *);
168326c841e2SKristof Provost 
168426c841e2SKristof Provost struct pfi_kkif		*pf_kkif_create(int);
168526c841e2SKristof Provost void			 pf_kkif_free(struct pfi_kkif *);
16865a3b9507SKristof Provost void			 pf_kkif_zero(struct pfi_kkif *);
16873b3a8eb9SGleb Smirnoff #endif /* _KERNEL */
16883b3a8eb9SGleb Smirnoff 
16893b3a8eb9SGleb Smirnoff #endif /* _NET_PFVAR_H_ */
1690