diff options
Diffstat (limited to 'src/service/nat/nat.h')
-rw-r--r-- | src/service/nat/nat.h | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/src/service/nat/nat.h b/src/service/nat/nat.h new file mode 100644 index 000000000..30e6f0901 --- /dev/null +++ b/src/service/nat/nat.h | |||
@@ -0,0 +1,242 @@ | |||
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 it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
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 | * Flags specifying the events this client would be | ||
69 | * interested in being told about. | ||
70 | */ | ||
71 | enum GNUNET_NAT_RegisterFlags | ||
72 | { | ||
73 | /** | ||
74 | * This client does not want any notifications. | ||
75 | */ | ||
76 | GNUNET_NAT_RF_NONE = 0, | ||
77 | |||
78 | /** | ||
79 | * This client wants to be informed about changes to our | ||
80 | * applicable addresses. | ||
81 | */ | ||
82 | GNUNET_NAT_RF_ADDRESSES = 1, | ||
83 | |||
84 | /** | ||
85 | * This client supports address reversal. | ||
86 | */ | ||
87 | GNUNET_NAT_RF_REVERSAL = 2 | ||
88 | }; | ||
89 | |||
90 | |||
91 | /** | ||
92 | * Message sent by a client to register with its addresses. | ||
93 | */ | ||
94 | struct GNUNET_NAT_RegisterMessage | ||
95 | { | ||
96 | /** | ||
97 | * Header with type #GNUNET_MESSAGE_TYPE_NAT_REGISTER | ||
98 | */ | ||
99 | struct GNUNET_MessageHeader header; | ||
100 | |||
101 | /** | ||
102 | * An `enum GNUNET_NAT_RegisterFlags`. | ||
103 | */ | ||
104 | uint8_t flags; | ||
105 | |||
106 | /** | ||
107 | * Client's IPPROTO, e.g. IPPROTO_UDP or IPPROTO_TCP. | ||
108 | */ | ||
109 | uint8_t proto; | ||
110 | |||
111 | /** | ||
112 | * Number of bytes in the string that follow which | ||
113 | * specifies a section name in the configuration. | ||
114 | */ | ||
115 | uint16_t str_len GNUNET_PACKED; | ||
116 | |||
117 | /** | ||
118 | * Number of addresses that this service is bound to that follow. | ||
119 | * Given as an array of "struct sockaddr" entries, the size of | ||
120 | * each entry being determined by the "sa_family" at the beginning. | ||
121 | */ | ||
122 | uint16_t num_addrs GNUNET_PACKED; | ||
123 | |||
124 | /* Followed by @e num_addrs addresses of type 'struct | ||
125 | sockaddr' */ | ||
126 | |||
127 | /* Followed by @e str_len section name to use for options */ | ||
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 | * Service telling a client that connection reversal was requested. | ||
185 | */ | ||
186 | struct GNUNET_NAT_ConnectionReversalRequestedMessage | ||
187 | { | ||
188 | /** | ||
189 | * Header with type #GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED | ||
190 | */ | ||
191 | struct GNUNET_MessageHeader header; | ||
192 | |||
193 | /* followed by a `struct sockaddr_in` */ | ||
194 | }; | ||
195 | |||
196 | |||
197 | /** | ||
198 | * Service notifying the client about changes in the set of | ||
199 | * addresses it has. | ||
200 | */ | ||
201 | struct GNUNET_NAT_AddressChangeNotificationMessage | ||
202 | { | ||
203 | /** | ||
204 | * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE | ||
205 | */ | ||
206 | struct GNUNET_MessageHeader header; | ||
207 | |||
208 | /** | ||
209 | * #GNUNET_YES to add, #GNUNET_NO to remove the address from the list. | ||
210 | */ | ||
211 | int32_t add_remove GNUNET_PACKED; | ||
212 | |||
213 | /** | ||
214 | * Type of the address, an `enum GNUNET_NAT_AddressClass` in NBO. | ||
215 | */ | ||
216 | uint32_t addr_class GNUNET_PACKED; | ||
217 | /* followed by a `struct sockaddr` */ | ||
218 | }; | ||
219 | |||
220 | |||
221 | /** | ||
222 | * Message sent by client to add a global address. | ||
223 | */ | ||
224 | struct GNUNET_NAT_AddGlobalAddressMessage | ||
225 | { | ||
226 | /** | ||
227 | * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS | ||
228 | */ | ||
229 | struct GNUNET_MessageHeader header; | ||
230 | |||
231 | /** | ||
232 | * Length of the address following the struct, in NBO. | ||
233 | */ | ||
234 | unsigned int address_length; | ||
235 | |||
236 | /* Followed by the address to add */ | ||
237 | }; | ||
238 | |||
239 | |||
240 | GNUNET_NETWORK_STRUCT_END | ||
241 | |||
242 | #endif | ||