FreeBSD kernel netgraph code
ng_nat.h
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org>
5 * All rights reserved.
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 * $FreeBSD$
29 */
30
31#define NG_NAT_NODE_TYPE "nat"
32#define NGM_NAT_COOKIE 1107718711
33
34#define NG_NAT_HOOK_IN "in"
35#define NG_NAT_HOOK_OUT "out"
36
37/* Arguments for NGM_NAT_SET_MODE message */
39 uint32_t flags;
40 uint32_t mask;
41};
42
43/* Keep this in sync with the above structure definition */
44#define NG_NAT_MODE_INFO { \
45 { "flags", &ng_parse_uint32_type }, \
46 { "mask", &ng_parse_uint32_type }, \
47 { NULL } \
48}
49
50#define NG_NAT_LOG 0x01
51#define NG_NAT_DENY_INCOMING 0x02
52#define NG_NAT_SAME_PORTS 0x04
53#define NG_NAT_UNREGISTERED_ONLY 0x10
54#define NG_NAT_RESET_ON_ADDR_CHANGE 0x20
55#define NG_NAT_PROXY_ONLY 0x40
56#define NG_NAT_REVERSE 0x80
57#define NG_NAT_UNREGISTERED_CGN 0x100
58
59#define NG_NAT_DESC_LENGTH 64
60#define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */
61
62/* Arguments for NGM_NAT_REDIRECT_PORT message */
64 struct in_addr local_addr;
65 struct in_addr alias_addr;
66 struct in_addr remote_addr;
67 uint16_t local_port;
68 uint16_t alias_port;
69 uint16_t remote_port;
70 uint8_t proto;
72};
73
74/* Keep this in sync with the above structure definition */
75#define NG_NAT_REDIRECT_PORT_TYPE_INFO(desctype) { \
76 { "local_addr", &ng_parse_ipaddr_type }, \
77 { "alias_addr", &ng_parse_ipaddr_type }, \
78 { "remote_addr", &ng_parse_ipaddr_type }, \
79 { "local_port", &ng_parse_uint16_type }, \
80 { "alias_port", &ng_parse_uint16_type }, \
81 { "remote_port", &ng_parse_uint16_type }, \
82 { "proto", &ng_parse_uint8_type }, \
83 { "description", (desctype) }, \
84 { NULL } \
85}
86
87/* Arguments for NGM_NAT_REDIRECT_ADDR message */
89 struct in_addr local_addr;
90 struct in_addr alias_addr;
92};
93
94/* Keep this in sync with the above structure definition */
95#define NG_NAT_REDIRECT_ADDR_TYPE_INFO(desctype) { \
96 { "local_addr", &ng_parse_ipaddr_type }, \
97 { "alias_addr", &ng_parse_ipaddr_type }, \
98 { "description", (desctype) }, \
99 { NULL } \
100}
101
102/* Arguments for NGM_NAT_REDIRECT_PROTO message */
104 struct in_addr local_addr;
105 struct in_addr alias_addr;
106 struct in_addr remote_addr;
107 uint8_t proto;
109};
110
111/* Keep this in sync with the above structure definition */
112#define NG_NAT_REDIRECT_PROTO_TYPE_INFO(desctype) { \
113 { "local_addr", &ng_parse_ipaddr_type }, \
114 { "alias_addr", &ng_parse_ipaddr_type }, \
115 { "remote_addr", &ng_parse_ipaddr_type }, \
116 { "proto", &ng_parse_uint8_type }, \
117 { "description", (desctype) }, \
118 { NULL } \
119}
120
121/* Arguments for NGM_NAT_ADD_SERVER message */
123 uint32_t id;
124 struct in_addr addr;
125 uint16_t port;
126};
127
128/* Keep this in sync with the above structure definition */
129#define NG_NAT_ADD_SERVER_TYPE_INFO { \
130 { "id", &ng_parse_uint32_type }, \
131 { "addr", &ng_parse_ipaddr_type }, \
132 { "port", &ng_parse_uint16_type }, \
133 { NULL } \
134}
135
136/* List entry of array returned in NGM_NAT_LIST_REDIRECTS message */
138 uint32_t id; /* Anything except zero */
139 struct in_addr local_addr;
140 struct in_addr alias_addr;
141 struct in_addr remote_addr;
142 uint16_t local_port;
143 uint16_t alias_port;
144 uint16_t remote_port;
145 uint16_t proto; /* Valid proto or NG_NAT_REDIRPROTO_ADDR */
146 uint16_t lsnat; /* LSNAT servers count */
148};
149
150/* Keep this in sync with the above structure definition */
151#define NG_NAT_LISTRDRS_ENTRY_TYPE_INFO(desctype) { \
152 { "id", &ng_parse_uint32_type }, \
153 { "local_addr", &ng_parse_ipaddr_type }, \
154 { "alias_addr", &ng_parse_ipaddr_type }, \
155 { "remote_addr", &ng_parse_ipaddr_type }, \
156 { "local_port", &ng_parse_uint16_type }, \
157 { "alias_port", &ng_parse_uint16_type }, \
158 { "remote_port", &ng_parse_uint16_type }, \
159 { "proto", &ng_parse_uint16_type }, \
160 { "lsnat", &ng_parse_uint16_type }, \
161 { "description", (desctype) }, \
162 { NULL } \
163}
164
165/* Structure returned by NGM_NAT_LIST_REDIRECTS */
167 uint32_t total_count;
169};
170
171/* Keep this in sync with the above structure definition */
172#define NG_NAT_LIST_REDIRECTS_TYPE_INFO(redirtype) { \
173 { "total_count", &ng_parse_uint32_type }, \
174 { "redirects", (redirtype) }, \
175 { NULL } \
176}
177
178/* Structure returned by NGM_NAT_LIBALIAS_INFO */
181 uint32_t udpLinkCount;
182 uint32_t tcpLinkCount;
188 uint32_t sockCount;
189};
190
191/* Keep this in sync with the above structure definition */
192#define NG_NAT_LIBALIAS_INFO { \
193 { "icmpLinkCount", &ng_parse_uint32_type }, \
194 { "udpLinkCount", &ng_parse_uint32_type }, \
195 { "tcpLinkCount", &ng_parse_uint32_type }, \
196 { "sctpLinkCount", &ng_parse_uint32_type }, \
197 { "pptpLinkCount", &ng_parse_uint32_type }, \
198 { "protoLinkCount", &ng_parse_uint32_type }, \
199 { "fragmentIdLinkCount", &ng_parse_uint32_type }, \
200 { "fragmentPtrLinkCount", &ng_parse_uint32_type }, \
201 { "sockCount", &ng_parse_uint32_type }, \
202 { NULL } \
203}
204
205enum {
220};
#define NG_NAT_DESC_LENGTH
Definition: ng_nat.h:59
@ NGM_NAT_ADD_SERVER
Definition: ng_nat.h:214
@ NGM_NAT_SET_DLT
Definition: ng_nat.h:218
@ NGM_NAT_SET_TARGET
Definition: ng_nat.h:208
@ NGM_NAT_SET_IPADDR
Definition: ng_nat.h:206
@ NGM_NAT_LIST_REDIRECTS
Definition: ng_nat.h:215
@ NGM_NAT_SET_MODE
Definition: ng_nat.h:207
@ NGM_NAT_REDIRECT_PORT
Definition: ng_nat.h:209
@ NGM_NAT_GET_DLT
Definition: ng_nat.h:219
@ NGM_NAT_REDIRECT_ADDR
Definition: ng_nat.h:210
@ NGM_NAT_LIBALIAS_INFO
Definition: ng_nat.h:217
@ NGM_NAT_REDIRECT_DYNAMIC
Definition: ng_nat.h:212
@ NGM_NAT_REDIRECT_PROTO
Definition: ng_nat.h:211
@ NGM_NAT_PROXY_RULE
Definition: ng_nat.h:216
@ NGM_NAT_REDIRECT_DELETE
Definition: ng_nat.h:213
uint32_t id
Definition: ng_nat.h:123
uint16_t port
Definition: ng_nat.h:125
struct in_addr addr
Definition: ng_nat.h:124
uint32_t sockCount
Definition: ng_nat.h:188
uint32_t icmpLinkCount
Definition: ng_nat.h:180
uint32_t udpLinkCount
Definition: ng_nat.h:181
uint32_t protoLinkCount
Definition: ng_nat.h:185
uint32_t pptpLinkCount
Definition: ng_nat.h:184
uint32_t fragmentPtrLinkCount
Definition: ng_nat.h:187
uint32_t fragmentIdLinkCount
Definition: ng_nat.h:186
uint32_t sctpLinkCount
Definition: ng_nat.h:183
uint32_t tcpLinkCount
Definition: ng_nat.h:182
uint32_t total_count
Definition: ng_nat.h:167
struct ng_nat_listrdrs_entry redirects[]
Definition: ng_nat.h:168
Definition: ng_nat.h:137
struct in_addr remote_addr
Definition: ng_nat.h:141
struct in_addr alias_addr
Definition: ng_nat.h:140
uint16_t local_port
Definition: ng_nat.h:142
uint16_t alias_port
Definition: ng_nat.h:143
uint16_t remote_port
Definition: ng_nat.h:144
struct in_addr local_addr
Definition: ng_nat.h:139
uint16_t lsnat
Definition: ng_nat.h:146
uint16_t proto
Definition: ng_nat.h:145
char description[NG_NAT_DESC_LENGTH]
Definition: ng_nat.h:147
uint32_t id
Definition: ng_nat.h:138
uint32_t flags
Definition: ng_nat.h:39
uint32_t mask
Definition: ng_nat.h:40
struct in_addr alias_addr
Definition: ng_nat.h:90
struct in_addr local_addr
Definition: ng_nat.h:89
char description[NG_NAT_DESC_LENGTH]
Definition: ng_nat.h:91
struct in_addr remote_addr
Definition: ng_nat.h:66
uint16_t alias_port
Definition: ng_nat.h:68
struct in_addr local_addr
Definition: ng_nat.h:64
struct in_addr alias_addr
Definition: ng_nat.h:65
char description[NG_NAT_DESC_LENGTH]
Definition: ng_nat.h:71
uint16_t local_port
Definition: ng_nat.h:67
uint16_t remote_port
Definition: ng_nat.h:69
char description[NG_NAT_DESC_LENGTH]
Definition: ng_nat.h:108
struct in_addr remote_addr
Definition: ng_nat.h:106
struct in_addr alias_addr
Definition: ng_nat.h:105
struct in_addr local_addr
Definition: ng_nat.h:104