include postgres db url in error message
[oweals/gnunet.git] / src / nat / nat.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2011, 2016 GNUnet e.V.
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file src/nat/nat.h
23  * @brief Messages for interaction with gnunet-nat-server and gnunet-nat-service
24  * @author Christian Grothoff
25  *
26  */
27 #ifndef NAT_H
28 #define NAT_H
29 #include "gnunet_util_lib.h"
30
31
32 GNUNET_NETWORK_STRUCT_BEGIN
33
34 /**
35  * Request to test NAT traversal, sent to the gnunet-nat-server
36  * (not the service!).
37  */
38 struct GNUNET_NAT_TestMessage
39 {
40   /**
41    * Header with type #GNUNET_MESSAGE_TYPE_NAT_TEST
42    */
43   struct GNUNET_MessageHeader header;
44
45   /**
46    * IPv4 target IP address
47    */
48   uint32_t dst_ipv4;
49
50   /**
51    * Port to use, 0 to send dummy ICMP response.
52    */
53   uint16_t dport;
54
55   /**
56    * Data to send OR advertised-port (in NBO) to use for dummy ICMP.
57    */
58   uint16_t data;
59
60   /**
61    * #GNUNET_YES for TCP, #GNUNET_NO for UDP.
62    */
63   int32_t is_tcp;
64
65 };
66
67
68 /**
69  * Flags specifying the events this client would be
70  * interested in being told about.
71  */
72 enum GNUNET_NAT_RegisterFlags
73 {
74   /**
75    * This client does not want any notifications.
76    */
77   GNUNET_NAT_RF_NONE = 0,
78
79   /**
80    * This client wants to be informed about changes to our
81    * external addresses.
82    */
83   GNUNET_NAT_RF_ADDRESSES = 1,
84
85   /**
86    * This client supports address reversal.
87    */
88   GNUNET_NAT_RF_REVERSAL = 2
89 };
90
91
92 /**
93  * Message sent by a client to register with its addresses.
94  */
95 struct GNUNET_NAT_RegisterMessage
96 {
97   /**
98    * Header with type #GNUNET_MESSAGE_TYPE_NAT_REGISTER
99    */
100   struct GNUNET_MessageHeader header;
101
102   /**
103    * An `enum GNUNET_NAT_RegisterFlags`.
104    */
105   uint8_t flags;
106
107   /**
108    * Client's IPPROTO, e.g. IPPROTO_UDP or IPPROTO_TCP.
109    */
110   uint8_t proto;
111
112   /**
113    * Port we would like as we are configured to use this one for
114    * advertising (in addition to the one we are binding to).
115    */
116   uint16_t adv_port GNUNET_PACKED;
117
118   /**
119    * Number of addresses that this service is bound to that follow.
120    * Given as an array of "struct sockaddr" entries, the size of
121    * each entry being determined by the "sa_family" at the beginning.
122    */
123   uint16_t num_addrs GNUNET_PACKED;
124
125   /* Followed by @e num_addrs addresses of type 'struct
126      sockaddr' */
127   
128 };
129
130
131 /**
132  * Client telling the service to (possibly) handle a STUN message.
133  */
134 struct GNUNET_NAT_HandleStunMessage
135 {
136   /**
137    * Header with type #GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN
138    */
139   struct GNUNET_MessageHeader header;
140
141   /**
142    * Size of the sender address included, in NBO.
143    */
144   uint16_t sender_addr_size;
145
146   /**
147    * Number of bytes of payload included, in NBO.
148    */
149   uint16_t payload_size;
150
151   /* followed by a `struct sockaddr` of @e sender_addr_size bytes */
152
153   /* followed by payload with @e payload_size bytes */
154 };
155
156
157 /**
158  * Client asking the service to initiate connection reversal.
159  */
160 struct GNUNET_NAT_RequestConnectionReversalMessage
161 {
162   /**
163    * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL
164    */
165   struct GNUNET_MessageHeader header;
166
167   /**
168    * Size of the local address included, in NBO.
169    */
170   uint16_t local_addr_size;
171
172   /**
173    * Size of the remote address included, in NBO.
174    */
175   uint16_t remote_addr_size;
176
177   /* followed by a `struct sockaddr` of @e local_addr_size bytes */
178
179   /* followed by a `struct sockaddr` of @e remote_addr_size bytes */
180
181 };
182
183
184 /**
185  * Service telling a client that connection reversal was requested.
186  */
187 struct GNUNET_NAT_ConnectionReversalRequestedMessage
188 {
189   /**
190    * Header with type #GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED
191    */
192   struct GNUNET_MessageHeader header;
193
194   /**
195    * Size of the local address where we received the request, in NBO.
196    */
197   uint16_t local_addr_size;
198
199   /**
200    * Size of the remote address making the request, in NBO.
201    */
202   uint16_t remote_addr_size;
203
204   /* followed by a `struct sockaddr` of @e local_addr_size bytes */
205
206   /* followed by a `struct sockaddr` of @e remote_addr_size bytes */
207   
208 };
209
210
211 /**
212  * Service notifying the client about changes in the set of 
213  * addresses it has.
214  */
215 struct GNUNET_NAT_AddressChangeNotificationMessage
216 {
217   /**
218    * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE
219    */
220   struct GNUNET_MessageHeader header;
221
222   /**
223    * #GNUNET_YES to add, #GNUNET_NO to remove the address from the list.
224    */ 
225   int32_t add_remove GNUNET_PACKED;
226
227   /**
228    * Type of the address, an `enum GNUNET_NAT_AddressClass` in NBO.
229    */
230   uint32_t addr_class GNUNET_PACKED;
231   /* followed by a `struct sockaddr` */
232   
233 };
234
235
236 /**
237  * Client requesting test of network connectivity.
238  */
239 struct GNUNET_NAT_RequestTestMessage
240 {
241   /**
242    * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_TEST
243    */
244   struct GNUNET_MessageHeader header;
245
246   /**
247    * Port to bind to, in NBO
248    */
249   uint16_t bind_port GNUNET_PACKED;
250
251   /**
252    * Port external verifier should try to connect to, in NBO.
253    */
254   uint16_t extern_port GNUNET_PACKED;
255
256   /**
257    * IPv4 to bind to, in NBO.
258    */
259   struct in_addr bind_ip GNUNET_PACKED;
260
261   /**
262    * IPv4 external verifier should try to connect to, in NBO.
263    */
264   struct in_addr extern_ip GNUNET_PACKED;
265   
266   /**
267    * IP protocol to use, i.e. IPPROTO_UDP or IPPROTO_TCP.
268    */
269   uint8_t proto;
270
271 };
272
273
274 /**
275  * Service responding with network connectivity test result.
276  */
277 struct GNUNET_NAT_TestResultMessage
278 {
279   /**
280    * Header with type #GNUNET_MESSAGE_TYPE_NAT_TEST_RESULT
281    */
282   struct GNUNET_MessageHeader header;
283
284   /**
285    * An `enum GNUNET_NAT_StatusCode` in NBO.
286    */
287   int32_t status_code GNUNET_PACKED;
288 };
289
290
291 /**
292  * Client requesting automatic configuration.
293  */
294 struct GNUNET_NAT_AutoconfigRequestMessage
295 {
296   /**
297    * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG
298    */
299   struct GNUNET_MessageHeader header;
300
301   /* Followed by configuration (diff, serialized, compressed) */
302   
303 };
304
305
306 /**
307  * Service responding with proposed configuration.
308  */
309 struct GNUNET_NAT_AutoconfigResultMessage
310 {
311   /**
312    * Header with type #GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT
313    */
314   struct GNUNET_MessageHeader header;
315   
316   /**
317    * An `enum GNUNET_NAT_StatusCode` in NBO.
318    */
319   int32_t status_code GNUNET_PACKED;
320
321   /**
322    * An `enum GNUNET_NAT_Type` in NBO.
323    */
324   int32_t type GNUNET_PACKED;
325
326   /* Followed by configuration (diff, serialized, compressed) */
327 };
328
329
330 GNUNET_NETWORK_STRUCT_END
331
332 #endif