Fix typo.
[dragonfly.git] / sys / netgraph7 / ng_nat.h
blob8adc9f99024a2ac91406ab66149734936a4ca226
1 /*-
2 * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org>
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
26 * $FreeBSD: src/sys/netgraph/ng_nat.h,v 1.4 2008/03/04 11:10:54 mav Exp $
27 * $DragonFly: src/sys/netgraph7/ng_nat.h,v 1.2 2008/06/26 23:05:35 dillon Exp $
30 #define NG_NAT_NODE_TYPE "nat"
31 #define NGM_NAT_COOKIE 1107718711
33 #define NG_NAT_HOOK_IN "in"
34 #define NG_NAT_HOOK_OUT "out"
36 /* Arguments for NGM_NAT_SET_MODE message */
37 struct ng_nat_mode {
38 uint32_t flags;
39 uint32_t mask;
42 /* Keep this in sync with the above structure definition */
43 #define NG_NAT_MODE_INFO { \
44 { "flags", &ng_parse_uint32_type }, \
45 { "mask", &ng_parse_uint32_type }, \
46 { NULL } \
49 #define NG_NAT_LOG 0x01
50 #define NG_NAT_DENY_INCOMING 0x02
51 #define NG_NAT_SAME_PORTS 0x04
52 #define NG_NAT_UNREGISTERED_ONLY 0x10
53 #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20
54 #define NG_NAT_PROXY_ONLY 0x40
55 #define NG_NAT_REVERSE 0x80
57 #define NG_NAT_DESC_LENGTH 64
58 #define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */
60 /* Arguments for NGM_NAT_REDIRECT_PORT message */
61 struct ng_nat_redirect_port {
62 struct in_addr local_addr;
63 struct in_addr alias_addr;
64 struct in_addr remote_addr;
65 uint16_t local_port;
66 uint16_t alias_port;
67 uint16_t remote_port;
68 uint8_t proto;
69 char description[NG_NAT_DESC_LENGTH];
72 /* Keep this in sync with the above structure definition */
73 #define NG_NAT_REDIRECT_PORT_TYPE_INFO(desctype) { \
74 { "local_addr", &ng_parse_ipaddr_type }, \
75 { "alias_addr", &ng_parse_ipaddr_type }, \
76 { "remote_addr", &ng_parse_ipaddr_type }, \
77 { "local_port", &ng_parse_uint16_type }, \
78 { "alias_port", &ng_parse_uint16_type }, \
79 { "remote_port", &ng_parse_uint16_type }, \
80 { "proto", &ng_parse_uint8_type }, \
81 { "description", (desctype) }, \
82 { NULL } \
85 /* Arguments for NGM_NAT_REDIRECT_ADDR message */
86 struct ng_nat_redirect_addr {
87 struct in_addr local_addr;
88 struct in_addr alias_addr;
89 char description[NG_NAT_DESC_LENGTH];
92 /* Keep this in sync with the above structure definition */
93 #define NG_NAT_REDIRECT_ADDR_TYPE_INFO(desctype) { \
94 { "local_addr", &ng_parse_ipaddr_type }, \
95 { "alias_addr", &ng_parse_ipaddr_type }, \
96 { "description", (desctype) }, \
97 { NULL } \
100 /* Arguments for NGM_NAT_REDIRECT_PROTO message */
101 struct ng_nat_redirect_proto {
102 struct in_addr local_addr;
103 struct in_addr alias_addr;
104 struct in_addr remote_addr;
105 uint8_t proto;
106 char description[NG_NAT_DESC_LENGTH];
109 /* Keep this in sync with the above structure definition */
110 #define NG_NAT_REDIRECT_PROTO_TYPE_INFO(desctype) { \
111 { "local_addr", &ng_parse_ipaddr_type }, \
112 { "alias_addr", &ng_parse_ipaddr_type }, \
113 { "remote_addr", &ng_parse_ipaddr_type }, \
114 { "proto", &ng_parse_uint8_type }, \
115 { "description", (desctype) }, \
116 { NULL } \
119 /* Arguments for NGM_NAT_ADD_SERVER message */
120 struct ng_nat_add_server {
121 uint32_t id;
122 struct in_addr addr;
123 uint16_t port;
126 /* Keep this in sync with the above structure definition */
127 #define NG_NAT_ADD_SERVER_TYPE_INFO { \
128 { "id", &ng_parse_uint32_type }, \
129 { "addr", &ng_parse_ipaddr_type }, \
130 { "port", &ng_parse_uint16_type }, \
131 { NULL } \
134 /* List entry of array returned in NGM_NAT_LIST_REDIRECTS message */
135 struct ng_nat_listrdrs_entry {
136 uint32_t id; /* Anything except zero */
137 struct in_addr local_addr;
138 struct in_addr alias_addr;
139 struct in_addr remote_addr;
140 uint16_t local_port;
141 uint16_t alias_port;
142 uint16_t remote_port;
143 uint16_t proto; /* Valid proto or NG_NAT_REDIRPROTO_ADDR */
144 uint16_t lsnat; /* LSNAT servers count */
145 char description[NG_NAT_DESC_LENGTH];
148 /* Keep this in sync with the above structure definition */
149 #define NG_NAT_LISTRDRS_ENTRY_TYPE_INFO(desctype) { \
150 { "id", &ng_parse_uint32_type }, \
151 { "local_addr", &ng_parse_ipaddr_type }, \
152 { "alias_addr", &ng_parse_ipaddr_type }, \
153 { "remote_addr", &ng_parse_ipaddr_type }, \
154 { "local_port", &ng_parse_uint16_type }, \
155 { "alias_port", &ng_parse_uint16_type }, \
156 { "remote_port", &ng_parse_uint16_type }, \
157 { "proto", &ng_parse_uint16_type }, \
158 { "lsnat", &ng_parse_uint16_type }, \
159 { "description", (desctype) }, \
160 { NULL } \
163 /* Structure returned by NGM_NAT_LIST_REDIRECTS */
164 struct ng_nat_list_redirects {
165 uint32_t total_count;
166 struct ng_nat_listrdrs_entry redirects[];
169 /* Keep this in sync with the above structure definition */
170 #define NG_NAT_LIST_REDIRECTS_TYPE_INFO(redirtype) { \
171 { "total_count", &ng_parse_uint32_type }, \
172 { "redirects", (redirtype) }, \
173 { NULL } \
176 enum {
177 NGM_NAT_SET_IPADDR = 1,
178 NGM_NAT_SET_MODE,
179 NGM_NAT_SET_TARGET,
180 NGM_NAT_REDIRECT_PORT,
181 NGM_NAT_REDIRECT_ADDR,
182 NGM_NAT_REDIRECT_PROTO,
183 NGM_NAT_REDIRECT_DYNAMIC,
184 NGM_NAT_REDIRECT_DELETE,
185 NGM_NAT_ADD_SERVER,
186 NGM_NAT_LIST_REDIRECTS,
187 NGM_NAT_PROXY_RULE,