2 This file is part of GNUnet.
3 Copyright (C) 2011, 2016 GNUnet e.V.
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.
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.
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.
23 * @brief Messages for interaction with gnunet-nat-server and gnunet-nat-service
24 * @author Christian Grothoff
29 #include "gnunet_util_lib.h"
32 GNUNET_NETWORK_STRUCT_BEGIN
35 * Request to test NAT traversal, sent to the gnunet-nat-server
38 struct GNUNET_NAT_TestMessage
41 * Header with type #GNUNET_MESSAGE_TYPE_NAT_TEST
43 struct GNUNET_MessageHeader header;
46 * IPv4 target IP address
51 * Port to use, 0 to send dummy ICMP response.
56 * Data to send OR advertised-port (in NBO) to use for dummy ICMP.
61 * #GNUNET_YES for TCP, #GNUNET_NO for UDP.
69 * Flags specifying the events this client would be
70 * interested in being told about.
72 enum GNUNET_NAT_RegisterFlags
75 * This client does not want any notifications.
77 GNUNET_NAT_RF_NONE = 0,
80 * This client wants to be informed about changes to our
83 GNUNET_NAT_RF_ADDRESSES = 1,
86 * This client supports address reversal.
88 GNUNET_NAT_RF_REVERSAL = 2
93 * Message sent by a client to register with its addresses.
95 struct GNUNET_NAT_RegisterMessage
98 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REGISTER
100 struct GNUNET_MessageHeader header;
103 * An `enum GNUNET_NAT_RegisterFlags`.
108 * Client's IPPROTO, e.g. IPPROTO_UDP or IPPROTO_TCP.
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).
116 uint16_t adv_port GNUNET_PACKED;
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.
123 uint16_t num_addrs GNUNET_PACKED;
125 /* Followed by @e num_addrs addresses of type 'struct
132 * Client telling the service to (possibly) handle a STUN message.
134 struct GNUNET_NAT_HandleStunMessage
137 * Header with type #GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN
139 struct GNUNET_MessageHeader header;
142 * Size of the sender address included, in NBO.
144 uint16_t sender_addr_size;
147 * Number of bytes of payload included, in NBO.
149 uint16_t payload_size;
151 /* followed by a `struct sockaddr` of @e sender_addr_size bytes */
153 /* followed by payload with @e payload_size bytes */
158 * Client asking the service to initiate connection reversal.
160 struct GNUNET_NAT_RequestConnectionReversalMessage
163 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL
165 struct GNUNET_MessageHeader header;
168 * Size of the local address included, in NBO.
170 uint16_t local_addr_size;
173 * Size of the remote address included, in NBO.
175 uint16_t remote_addr_size;
177 /* followed by a `struct sockaddr` of @e local_addr_size bytes */
179 /* followed by a `struct sockaddr` of @e remote_addr_size bytes */
185 * Service telling a client that connection reversal was requested.
187 struct GNUNET_NAT_ConnectionReversalRequestedMessage
190 * Header with type #GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED
192 struct GNUNET_MessageHeader header;
195 * Size of the local address where we received the request, in NBO.
197 uint16_t local_addr_size;
200 * Size of the remote address making the request, in NBO.
202 uint16_t remote_addr_size;
204 /* followed by a `struct sockaddr` of @e local_addr_size bytes */
206 /* followed by a `struct sockaddr` of @e remote_addr_size bytes */
212 * Service notifying the client about changes in the set of
215 struct GNUNET_NAT_AddressChangeNotificationMessage
218 * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE
220 struct GNUNET_MessageHeader header;
223 * #GNUNET_YES to add, #GNUNET_NO to remove the address from the list.
225 int32_t add_remove GNUNET_PACKED;
228 * Type of the address, an `enum GNUNET_NAT_AddressClass` in NBO.
230 uint32_t addr_class GNUNET_PACKED;
231 /* followed by a `struct sockaddr` */
237 * Client requesting automatic configuration.
239 struct GNUNET_NAT_AutoconfigRequestMessage
242 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG
244 struct GNUNET_MessageHeader header;
246 /* Followed by configuration (diff, serialized, compressed) */
252 * Service responding with proposed configuration.
254 struct GNUNET_NAT_AutoconfigResultMessage
257 * Header with type #GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT
259 struct GNUNET_MessageHeader header;
262 * An `enum GNUNET_NAT_StatusCode` in NBO.
264 int32_t status_code GNUNET_PACKED;
267 * An `enum GNUNET_NAT_Type` in NBO.
269 int32_t type GNUNET_PACKED;
271 /* Followed by configuration (diff, serialized, compressed) */
275 GNUNET_NETWORK_STRUCT_END