xref: /freebsd/sys/netpfil/pf/pf_nl.h (revision 63f537551380d2dab29fa402ad1269feae17e594)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2023 Alexander V. Chernikov <melifaro@FreeBSD.org>
5  * Copyright (c) 2023 Rubicon Communications, LLC (Netgate)
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef _NETPFIL_PF_PF_NL_H_
31 #define _NETPFIL_PF_PF_NL_H_
32 
33 /* Genetlink family */
34 #define PFNL_FAMILY_NAME	"pfctl"
35 
36 /* available commands */
37 enum {
38 	PFNL_CMD_UNSPEC = 0,
39 	PFNL_CMD_GETSTATES = 1,
40 	PFNL_CMD_GETCREATORS = 2,
41 	PFNL_CMD_START = 3,
42 	PFNL_CMD_STOP = 4,
43 	__PFNL_CMD_MAX,
44 };
45 #define PFNL_CMD_MAX (__PFNL_CMD_MAX -1)
46 
47 enum pfstate_key_type_t {
48 	PF_STK_UNSPEC,
49 	PF_STK_ADDR0		= 1, /* ip */
50 	PF_STK_ADDR1		= 2, /* ip */
51 	PF_STK_PORT0		= 3, /* u16 */
52 	PF_STK_PORT1		= 4, /* u16 */
53 };
54 
55 enum pfstate_peer_type_t {
56 	PF_STP_UNSPEC,
57 	PF_STP_PFSS_FLAGS	= 1, /* u16 */
58 	PF_STP_PFSS_TTL		= 2, /* u8 */
59 	PF_STP_SCRUB_FLAG	= 3, /* u8 */
60 	PF_STP_PFSS_TS_MOD	= 4, /* u32 */
61 	PF_STP_SEQLO		= 5, /* u32 */
62 	PF_STP_SEQHI		= 6, /* u32 */
63 	PF_STP_SEQDIFF		= 7, /* u32 */
64 	PF_STP_MAX_WIN		= 8, /* u16 */
65 	PF_STP_MSS		= 9, /* u16 */
66 	PF_STP_STATE		= 10, /* u8 */
67 	PF_STP_WSCALE		= 11, /* u8 */
68 };
69 
70 enum pfstate_type_t {
71 	PF_ST_UNSPEC,
72 	PF_ST_ID		= 1, /* u32, state id */
73 	PF_ST_CREATORID		= 2, /* u32, */
74 	PF_ST_IFNAME		= 3, /* string */
75 	PF_ST_ORIG_IFNAME	= 4, /* string */
76 	PF_ST_KEY_WIRE		= 5, /* nested, pfstate_key_type_t */
77 	PF_ST_KEY_STACK		= 6, /* nested, pfstate_key_type_t */
78 	PF_ST_PEER_SRC		= 7, /* nested, pfstate_peer_type_t*/
79 	PF_ST_PEER_DST		= 8, /* nested, pfstate_peer_type_t */
80 	PF_ST_RT_ADDR		= 9, /* ip */
81 	PF_ST_RULE		= 10, /* u32 */
82 	PF_ST_ANCHOR		= 11, /* u32 */
83 	PF_ST_NAT_RULE		= 12, /* u32 */
84 	PF_ST_CREATION		= 13, /* u32 */
85 	PF_ST_EXPIRE		= 14, /* u32 */
86 	PF_ST_PACKETS0		= 15, /* u64 */
87 	PF_ST_PACKETS1		= 16, /* u64 */
88 	PF_ST_BYTES0		= 17, /* u64 */
89 	PF_ST_BYTES1		= 18, /* u64 */
90 	PF_ST_AF		= 19, /* u8 */
91 	PF_ST_PROTO		= 21, /* u8 */
92 	PF_ST_DIRECTION		= 22, /* u8 */
93 	PF_ST_LOG		= 23, /* u8 */
94 	PF_ST_TIMEOUT		= 24, /* u8 */
95 	PF_ST_STATE_FLAGS	= 25, /* u8 */
96 	PF_ST_SYNC_FLAGS	= 26, /* u8 */
97 	PF_ST_UPDATES		= 27, /* u8 */
98 	PF_ST_VERSION		= 28, /* u64 */
99 };
100 
101 #ifdef _KERNEL
102 
103 void	pf_nl_register(void);
104 void	pf_nl_unregister(void);
105 
106 #endif
107 
108 #endif
109