miniupnpd 1.9 (20160113)
[tomato.git] / release / src / router / miniupnpd / pcp_msg_struct.h
blobc6d98ebf9a78367d6258eb8b742956dde863891e
1 /* $Id: pcp_msg_struct.h,v 1.6 2015/09/22 10:10:54 nanard Exp $ */
2 /* MiniUPnP project
3 * Website : http://miniupnp.free.fr/
4 * Author : Peter Tatrai
6 Copyright (c) 2013 by Cisco Systems, Inc.
7 All rights reserved.
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 * The name of the author may not be used to endorse or promote products
18 derived from this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 #ifndef PCP_MSG_STRUCT_H_INCLUDED
33 #define PCP_MSG_STRUCT_H_INCLUDED
35 #define PCP_OPCODE_ANNOUNCE 0
36 #define PCP_OPCODE_MAP 1
37 #define PCP_OPCODE_PEER 2
38 #ifdef PCP_SADSCP
39 #define PCP_OPCODE_SADSCP 3
40 #endif
42 /* Possible response codes sent by server, as a result of client request*/
43 #define PCP_SUCCESS 0
45 #define PCP_ERR_UNSUPP_VERSION 1
46 /** The version number at the start of the PCP Request
47 * header is not recognized by this PCP server. This is a long
48 * lifetime error. This document describes PCP version 2.
51 #define PCP_ERR_NOT_AUTHORIZED 2
52 /**The requested operation is disabled for this PCP
53 * client, or the PCP client requested an operation that cannot be
54 * fulfilled by the PCP server's security policy. This is a long
55 * lifetime error.
58 #define PCP_ERR_MALFORMED_REQUEST 3
59 /**The request could not be successfully parsed.
60 * This is a long lifetime error.
63 #define PCP_ERR_UNSUPP_OPCODE 4
64 /** Unsupported Opcode. This is a long lifetime error.
67 #define PCP_ERR_UNSUPP_OPTION 5
68 /**Unsupported Option. This error only occurs if the
69 * Option is in the mandatory-to-process range. This is a long
70 * lifetime error.
73 #define PCP_ERR_MALFORMED_OPTION 6
74 /**Malformed Option (e.g., appears too many times,
75 * invalid length). This is a long lifetime error.
78 #define PCP_ERR_NETWORK_FAILURE 7
79 /**The PCP server or the device it controls are
80 * experiencing a network failure of some sort (e.g., has not
81 * obtained an External IP address). This is a short lifetime error.
84 #define PCP_ERR_NO_RESOURCES 8
85 /**Request is well-formed and valid, but the server has
86 * insufficient resources to complete the requested operation at this
87 * time. For example, the NAT device cannot create more mappings at
88 * this time, is short of CPU cycles or memory, or is unable to
89 * handle the request due to some other temporary condition. The
90 * same request may succeed in the future. This is a system-wide
91 * error, different from USER_EX_QUOTA. This can be used as a catch-
92 * all error, should no other error message be suitable. This is a
93 * short lifetime error.
96 #define PCP_ERR_UNSUPP_PROTOCOL 9
97 /**Unsupported transport protocol, e.g. SCTP in a
98 * NAT that handles only UDP and TCP. This is a long lifetime error.
101 #define PCP_ERR_USER_EX_QUOTA 10
102 /** This attempt to create a new mapping would exceed
103 * this subscriber's port quota. This is a short lifetime error.
106 #define PCP_ERR_CANNOT_PROVIDE_EXTERNAL 11
107 /** The suggested external port and/or
108 * external address cannot be provided. This error MUST only be
109 * returned for:
110 * * MAP requests that included the PREFER_FAILURE Option
111 * (normal MAP requests will return an available external port)
112 * * MAP requests for the SCTP protocol (PREFER_FAILURE is implied)
113 * * PEER requests
116 #define PCP_ERR_ADDRESS_MISMATCH 12
117 /** The source IP address of the request packet does
118 * not match the contents of the PCP Client's IP Address field, due
119 * to an unexpected NAT on the path between the PCP client and the
120 * PCP-controlled NAT or firewall. This is a long lifetime error.
123 #define PCP_ERR_EXCESSIVE_REMOTE_PEERS 13
124 /** The PCP server was not able to create the
125 * filters in this request. This result code MUST only be returned
126 * if the MAP request contained the FILTER Option. See Section 13.3
127 * for processing information. This is a long lifetime error.
130 typedef enum pcp_options {
131 PCP_OPTION_3RD_PARTY = 1,
132 PCP_OPTION_PREF_FAIL = 2,
133 PCP_OPTION_FILTER = 3,
134 #ifdef PCP_FLOWP
135 PCP_OPTION_FLOW_PRIORITY = 4, /*TODO: change it to correct value*/
136 #endif
137 } pcp_options_t;
140 /* PCP common request header*/
141 #if 0
142 typedef struct pcp_request {
143 uint8_t ver;
144 uint8_t r_opcode;
145 uint16_t reserved;
146 uint32_t req_lifetime;
147 struct in6_addr ip; /* ipv4 will be represented
148 by the ipv4 mapped ipv6 */
149 uint8_t next_data[0];
150 } pcp_request_t;
151 #endif
152 #define PCP_COMMON_REQUEST_SIZE (24)
154 /* PCP common response header*/
155 #if 0
156 typedef struct pcp_response {
157 uint8_t ver;
158 uint8_t r_opcode; /* R indicates Request (0) or Response (1)
159 Opcode is 7 bit value specifying operation MAP or PEER */
160 uint8_t reserved; /* reserved bits, must be 0 on transmission and must be ignored on reception */
161 uint8_t result_code; /* */
162 uint32_t lifetime; /* an unsigned 32-bit integer, in seconds {0, 2^32-1}*/
163 uint32_t epochtime; /* epoch indicates how long has PCP server had its current mappings
164 it increases by 1 every second */
165 uint32_t reserved1[3];/* For requests that were successfully parsed this must be sent as 0 */
166 uint8_t next_data[0];
167 } pcp_response_t;
168 #endif
169 #define PCP_COMMON_RESPONSE_SIZE (24)
172 #if 0
173 typedef struct pcp_options_hdr {
174 uint8_t code; /* Most significant bit indicates if this option is mandatory (0) or optional (1) */
175 uint8_t reserved; /* MUST be set to 0 on transmission and MUST be ignored on reception */
176 uint16_t len; /* indicates the length of the enclosed data in octets (see RFC) */
177 uint8_t next_data[0]; /* */
178 } pcp_options_hdr_t;
179 #endif
180 #define PCP_OPTION_HDR_SIZE (4)
182 /* same for both request and response */
183 #if 0
184 typedef struct pcp_map_v2 {
185 uint32_t nonce[3];
186 uint8_t protocol; /* 6 = TCP, 17 = UDP, 0 = 'all protocols' */
187 uint8_t reserved[3];
188 uint16_t int_port; /* 0 indicates 'all ports' */
189 uint16_t ext_port; /* suggested external port */
190 struct in6_addr ext_ip; /* suggested external IP address
191 * ipv4 will be represented by the ipv4 mapped ipv6 */
192 uint8_t next_data[0];
193 } pcp_map_v2_t;
194 #endif
195 #define PCP_MAP_V2_SIZE (36)
197 #if 0
198 /* same for both request and response */
199 typedef struct pcp_map_v1 {
200 uint8_t protocol;
201 uint8_t reserved[3];
202 uint16_t int_port;
203 uint16_t ext_port;
204 struct in6_addr ext_ip; /* ipv4 will be represented
205 by the ipv4 mapped ipv6 */
206 uint8_t next_data[0];
207 } pcp_map_v1_t;
208 #endif
209 #define PCP_MAP_V1_SIZE (24)
211 /* same for both request and response */
212 #if 0
213 typedef struct pcp_peer_v1 {
214 uint8_t protocol;
215 uint8_t reserved[3];
216 uint16_t int_port;
217 uint16_t ext_port;
218 struct in6_addr ext_ip; /* ipv4 will be represented
219 by the ipv4 mapped ipv6 */
220 uint16_t peer_port;
221 uint16_t reserved1;
222 struct in6_addr peer_ip;
223 uint8_t next_data[0];
224 } pcp_peer_v1_t;
225 #endif
226 #define PCP_PEER_V1_SIZE (44)
228 /* same for both request and response */
229 #if 0
230 typedef struct pcp_peer_v2 {
231 uint32_t nonce[3];
232 uint8_t protocol;
233 uint8_t reserved[3];
234 uint16_t int_port;
235 uint16_t ext_port;
236 struct in6_addr ext_ip; /* ipv4 will be represented
237 by the ipv4 mapped ipv6 */
238 uint16_t peer_port;
239 uint16_t reserved1;
240 struct in6_addr peer_ip;
241 uint8_t next_data[0];
242 } pcp_peer_v2_t;
243 #endif
244 #define PCP_PEER_V2_SIZE (56)
246 #ifdef PCP_SADSCP
247 #if 0
248 typedef struct pcp_sadscp_req {
249 uint32_t nonce[3];
250 uint8_t tolerance_fields;
251 uint8_t app_name_length;
252 char app_name[0];
253 } pcp_sadscp_req_t;
254 #endif
255 #define PCP_SADSCP_REQ_SIZE (14)
257 #if 0
258 typedef struct pcp_sadscp_resp {
259 uint32_t nonce[3];
260 uint8_t a_r_dscp_value;
261 uint8_t reserved[3];
262 } pcp_sadscp_resp_t;
263 #endif
264 #define PCP_SADSCP_MASK ((1<<6)-1)
265 #endif /* PCP_SADSCP */
267 #if 0
268 typedef struct pcp_prefer_fail_option {
269 uint8_t option;
270 uint8_t reserved;
271 uint16_t len;
272 uint8_t next_data[0];
273 } pcp_prefer_fail_option_t;
274 #endif
275 #define PCP_PREFER_FAIL_OPTION_SIZE (4)
277 #if 0
278 typedef struct pcp_3rd_party_option{
279 uint8_t option;
280 uint8_t reserved;
281 uint16_t len;
282 struct in6_addr ip;
283 uint8_t next_data[0];
284 } pcp_3rd_party_option_t;
285 #endif
286 #define PCP_3RD_PARTY_OPTION_SIZE (20)
288 #ifdef PCP_FLOWP
289 #if 0
290 typedef struct pcp_flow_priority_option{
291 uint8_t option;
292 uint8_t reserved;
293 uint16_t len;
294 uint8_t dscp_up;
295 uint8_t dscp_down;
296 uint8_t reserved2;
297 /* most significant bit is used for response */
298 uint8_t response_bit;
299 uint8_t next_data[0];
300 } pcp_flow_priority_option_t;
301 #endif
302 #define PCP_DSCP_MASK ((1<<6)-1)
303 #define PCP_FLOW_PRIORITY_OPTION_SIZE (8)
304 #endif
306 #if 0
307 typedef struct pcp_filter_option {
308 uint8_t option;
309 uint8_t reserved1;
310 uint16_t len;
311 uint8_t reserved2;
312 uint8_t prefix_len;
313 uint16_t peer_port;
314 struct in6_addr peer_ip;
315 }pcp_filter_option_t;
316 #endif
317 #define PCP_FILTER_OPTION_SIZE (24)
319 #endif /* PCP_MSG_STRUCT_H_INCLUDED */