Electroneum
pcp_msg_struct.h
Go to the documentation of this file.
1 /* $Id: pcp_msg_struct.h,v 1.3 2013/12/16 16:02:19 nanard Exp $ */
2 /* MiniUPnP project
3  * Website : http://miniupnp.free.fr/
4  * Author : Peter Tatrai
5 
6 Copyright (c) 2013 by Cisco Systems, Inc.
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
11 
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.
19 
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.
31  */
32 #ifndef PCP_MSG_STRUCT_H_INCLUDED
33 #define PCP_MSG_STRUCT_H_INCLUDED
34 
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
41 
42 /* Possible response codes sent by server, as a result of client request*/
43 #define PCP_SUCCESS 0
44 
45 #define PCP_ERR_UNSUPP_VERSION 1
46 
51 #define PCP_ERR_NOT_AUTHORIZED 2
52 
58 #define PCP_ERR_MALFORMED_REQUEST 3
59 
63 #define PCP_ERR_UNSUPP_OPCODE 4
64 
67 #define PCP_ERR_UNSUPP_OPTION 5
68 
73 #define PCP_ERR_MALFORMED_OPTION 6
74 
78 #define PCP_ERR_NETWORK_FAILURE 7
79 
84 #define PCP_ERR_NO_RESOURCES 8
85 
96 #define PCP_ERR_UNSUPP_PROTOCOL 9
97 
101 #define PCP_ERR_USER_EX_QUOTA 10
102 
106 #define PCP_ERR_CANNOT_PROVIDE_EXTERNAL 11
107 
116 #define PCP_ERR_ADDRESS_MISMATCH 12
117 
123 #define PCP_ERR_EXCESSIVE_REMOTE_PEERS 13
124 
130 typedef enum pcp_options {
134 #ifdef PCP_FLOWP
135  PCP_OPTION_FLOW_PRIORITY = 4, /*TODO: change it to correct value*/
136 #endif
137 } pcp_options_t;
138 
139 
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)
153 
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)
170 
171 
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)
181 
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)
196 
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)
210 
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)
227 
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)
245 
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)
256 
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 */
266 
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)
276 
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)
287 
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
305 
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)
318 
319 #endif /* PCP_MSG_STRUCT_H_INCLUDED */
pcp_options
unsigned short uint16_t
Definition: stdint.h:125
enum pcp_options pcp_options_t
unsigned char uint8_t
Definition: stdint.h:124
Definition: options.h:86
unsigned int uint32_t
Definition: stdint.h:126
boost::endian::big_uint32_t ip
Definition: socks.cpp:61