aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_nat_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_nat_service.h')
-rw-r--r--src/include/gnunet_nat_service.h91
1 files changed, 42 insertions, 49 deletions
diff --git a/src/include/gnunet_nat_service.h b/src/include/gnunet_nat_service.h
index b96b2386e..7f0e9764b 100644
--- a/src/include/gnunet_nat_service.h
+++ b/src/include/gnunet_nat_service.h
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @author Christian Grothoff 22 * @author Christian Grothoff
@@ -49,9 +49,7 @@
49 * an equivalent enum in gnunet_transport_hello_service.h; 49 * an equivalent enum in gnunet_transport_hello_service.h;
50 * might ultimately belong with the new HELLO definition. 50 * might ultimately belong with the new HELLO definition.
51 */ 51 */
52enum GNUNET_NAT_AddressClass 52enum GNUNET_NAT_AddressClass {
53{
54
55 /** 53 /**
56 * No address. 54 * No address.
57 */ 55 */
@@ -87,7 +85,7 @@ enum GNUNET_NAT_AddressClass
87 * Useful for broadcasts. 85 * Useful for broadcasts.
88 */ 86 */
89 GNUNET_NAT_AC_LAN = 8, 87 GNUNET_NAT_AC_LAN = 8,
90 88
91 /** 89 /**
92 * Addresses useful in the local wired network, 90 * Addresses useful in the local wired network,
93 * i.e. a MAC. Sensitive, but obvious to people nearby. 91 * i.e. a MAC. Sensitive, but obvious to people nearby.
@@ -112,12 +110,12 @@ enum GNUNET_NAT_AddressClass
112 * Loopback addresses, only useful under special cirumstances. 110 * Loopback addresses, only useful under special cirumstances.
113 */ 111 */
114 GNUNET_NAT_AC_LOOPBACK = 64, 112 GNUNET_NAT_AC_LOOPBACK = 64,
115 113
116 /** 114 /**
117 * Addresses that should be our external IP address 115 * Addresses that should be our external IP address
118 * on the outside of a NAT. Might be incorrectly determined. 116 * on the outside of a NAT. Might be incorrectly determined.
119 * Used as a bit in combination with #GNUNET_NAT_AC_GLOBAL, 117 * Used as a bit in combination with #GNUNET_NAT_AC_GLOBAL,
120 * or in case of double-NAT with 118 * or in case of double-NAT with
121 * #GNUNET_NAT_AC_LAN. 119 * #GNUNET_NAT_AC_LAN.
122 */ 120 */
123 GNUNET_NAT_AC_EXTERN = 128, 121 GNUNET_NAT_AC_EXTERN = 128,
@@ -132,15 +130,13 @@ enum GNUNET_NAT_AddressClass
132 * Bitmask for "any" address. 130 * Bitmask for "any" address.
133 */ 131 */
134 GNUNET_NAT_AC_ANY = 65535 132 GNUNET_NAT_AC_ANY = 65535
135
136}; 133};
137 134
138 135
139/** 136/**
140 * Error Types for the NAT subsystem (which can then later be converted/resolved to a string) 137 * Error Types for the NAT subsystem (which can then later be converted/resolved to a string)
141 */ 138 */
142enum GNUNET_NAT_StatusCode 139enum GNUNET_NAT_StatusCode {
143{
144 /** 140 /**
145 * Just the default 141 * Just the default
146 */ 142 */
@@ -235,7 +231,6 @@ enum GNUNET_NAT_StatusCode
235 * 231 *
236 */ 232 */
237 GNUNET_NAT_ERROR_HELPER_NAT_CLIENT_NOT_FOUND 233 GNUNET_NAT_ERROR_HELPER_NAT_CLIENT_NOT_FOUND
238
239}; 234};
240 235
241 236
@@ -243,8 +238,7 @@ enum GNUNET_NAT_StatusCode
243/** 238/**
244 * What the situation of the NAT connectivity 239 * What the situation of the NAT connectivity
245 */ 240 */
246enum GNUNET_NAT_Type 241enum GNUNET_NAT_Type {
247{
248 /** 242 /**
249 * We have a direct connection 243 * We have a direct connection
250 */ 244 */
@@ -269,7 +263,6 @@ enum GNUNET_NAT_Type
269 * We know nothing about the NAT. 263 * We know nothing about the NAT.
270 */ 264 */
271 GNUNET_NAT_TYPE_UNKNOWN 265 GNUNET_NAT_TYPE_UNKNOWN
272
273}; 266};
274 267
275 268
@@ -281,7 +274,7 @@ enum GNUNET_NAT_Type
281 * @param cls closure 274 * @param cls closure
282 * @param app_ctx[in,out] location where the app can store stuff 275 * @param app_ctx[in,out] location where the app can store stuff
283 * on add and retrieve it on remove 276 * on add and retrieve it on remove
284 * @param add_remove #GNUNET_YES to add a new public IP address, 277 * @param add_remove #GNUNET_YES to add a new public IP address,
285 * #GNUNET_NO to remove a previous (now invalid) one 278 * #GNUNET_NO to remove a previous (now invalid) one
286 * @param ac address class the address belongs to 279 * @param ac address class the address belongs to
287 * @param addr either the previous or the new public IP address 280 * @param addr either the previous or the new public IP address
@@ -289,9 +282,9 @@ enum GNUNET_NAT_Type
289 */ 282 */
290typedef void 283typedef void
291(*GNUNET_NAT_AddressCallback) (void *cls, 284(*GNUNET_NAT_AddressCallback) (void *cls,
292 void **app_ctx, 285 void **app_ctx,
293 int add_remove, 286 int add_remove,
294 enum GNUNET_NAT_AddressClass ac, 287 enum GNUNET_NAT_AddressClass ac,
295 const struct sockaddr *addr, 288 const struct sockaddr *addr,
296 socklen_t addrlen); 289 socklen_t addrlen);
297 290
@@ -307,7 +300,7 @@ typedef void
307 */ 300 */
308typedef void 301typedef void
309(*GNUNET_NAT_ReversalCallback) (void *cls, 302(*GNUNET_NAT_ReversalCallback) (void *cls,
310 const struct sockaddr *remote_addr, 303 const struct sockaddr *remote_addr,
311 socklen_t remote_addrlen); 304 socklen_t remote_addrlen);
312 305
313 306
@@ -338,15 +331,15 @@ struct GNUNET_NAT_Handle;
338 * @return NULL on error, otherwise handle that can be used to unregister 331 * @return NULL on error, otherwise handle that can be used to unregister
339 */ 332 */
340struct GNUNET_NAT_Handle * 333struct GNUNET_NAT_Handle *
341GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, 334GNUNET_NAT_register(const struct GNUNET_CONFIGURATION_Handle *cfg,
342 const char *config_section, 335 const char *config_section,
343 uint8_t proto, 336 uint8_t proto,
344 unsigned int num_addrs, 337 unsigned int num_addrs,
345 const struct sockaddr **addrs, 338 const struct sockaddr **addrs,
346 const socklen_t *addrlens, 339 const socklen_t *addrlens,
347 GNUNET_NAT_AddressCallback address_callback, 340 GNUNET_NAT_AddressCallback address_callback,
348 GNUNET_NAT_ReversalCallback reversal_callback, 341 GNUNET_NAT_ReversalCallback reversal_callback,
349 void *callback_cls); 342 void *callback_cls);
350 343
351 344
352/** 345/**
@@ -363,9 +356,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
363 * #GNUNET_SYSERR if the address is malformed 356 * #GNUNET_SYSERR if the address is malformed
364 */ 357 */
365int 358int
366GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *nh, 359GNUNET_NAT_test_address(struct GNUNET_NAT_Handle *nh,
367 const void *addr, 360 const void *addr,
368 socklen_t addrlen); 361 socklen_t addrlen);
369 362
370 363
371/** 364/**
@@ -376,14 +369,14 @@ GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *nh,
376 * @param nh handle (used for configuration) 369 * @param nh handle (used for configuration)
377 * @param local_sa our local address of the peer (IPv4-only) 370 * @param local_sa our local address of the peer (IPv4-only)
378 * @param remote_sa the remote address of the peer (IPv4-only) 371 * @param remote_sa the remote address of the peer (IPv4-only)
379 * @return #GNUNET_SYSERR on error, 372 * @return #GNUNET_SYSERR on error,
380 * #GNUNET_NO if connection reversal is unavailable, 373 * #GNUNET_NO if connection reversal is unavailable,
381 * #GNUNET_OK otherwise (presumably in progress) 374 * #GNUNET_OK otherwise (presumably in progress)
382 */ 375 */
383int 376int
384GNUNET_NAT_request_reversal (struct GNUNET_NAT_Handle *nh, 377GNUNET_NAT_request_reversal(struct GNUNET_NAT_Handle *nh,
385 const struct sockaddr_in *local_sa, 378 const struct sockaddr_in *local_sa,
386 const struct sockaddr_in *remote_sa); 379 const struct sockaddr_in *remote_sa);
387 380
388 381
389/** 382/**
@@ -394,7 +387,7 @@ GNUNET_NAT_request_reversal (struct GNUNET_NAT_Handle *nh,
394 * @param nh the handle to unregister 387 * @param nh the handle to unregister
395 */ 388 */
396void 389void
397GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *nh); 390GNUNET_NAT_unregister(struct GNUNET_NAT_Handle *nh);
398 391
399 392
400/** 393/**
@@ -406,7 +399,7 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *nh);
406 * 399 *
407 * The function does some basic sanity checks on packet size and 400 * The function does some basic sanity checks on packet size and
408 * content, try to extract a bit of information. 401 * content, try to extract a bit of information.
409 * 402 *
410 * At the moment this only processes BIND requests, and returns the 403 * At the moment this only processes BIND requests, and returns the
411 * externally visible address of the request to the rest of the 404 * externally visible address of the request to the rest of the
412 * NAT logic. 405 * NAT logic.
@@ -421,11 +414,11 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *nh);
421 * #GNUNET_SYSERR on internal error handling the packet 414 * #GNUNET_SYSERR on internal error handling the packet
422 */ 415 */
423int 416int
424GNUNET_NAT_stun_handle_packet (struct GNUNET_NAT_Handle *nh, 417GNUNET_NAT_stun_handle_packet(struct GNUNET_NAT_Handle *nh,
425 const struct sockaddr *sender_addr, 418 const struct sockaddr *sender_addr,
426 size_t sender_addr_len, 419 size_t sender_addr_len,
427 const void *data, 420 const void *data,
428 size_t data_size); 421 size_t data_size);
429 422
430 423
431/** 424/**
@@ -445,7 +438,7 @@ struct GNUNET_NAT_STUN_Handle;
445 */ 438 */
446typedef void 439typedef void
447(*GNUNET_NAT_TestCallback) (void *cls, 440(*GNUNET_NAT_TestCallback) (void *cls,
448 enum GNUNET_NAT_StatusCode result); 441 enum GNUNET_NAT_StatusCode result);
449 442
450 443
451/** 444/**
@@ -463,11 +456,11 @@ typedef void
463 * @return NULL on error 456 * @return NULL on error
464 */ 457 */
465struct GNUNET_NAT_STUN_Handle * 458struct GNUNET_NAT_STUN_Handle *
466GNUNET_NAT_stun_make_request (const char *server, 459GNUNET_NAT_stun_make_request(const char *server,
467 uint16_t port, 460 uint16_t port,
468 struct GNUNET_NETWORK_Handle *sock, 461 struct GNUNET_NETWORK_Handle *sock,
469 GNUNET_NAT_TestCallback cb, 462 GNUNET_NAT_TestCallback cb,
470 void *cb_cls); 463 void *cb_cls);
471 464
472 465
473/** 466/**
@@ -477,7 +470,7 @@ GNUNET_NAT_stun_make_request (const char *server,
477 * @param rh request to cancel 470 * @param rh request to cancel
478 */ 471 */
479void 472void
480GNUNET_NAT_stun_make_request_cancel (struct GNUNET_NAT_STUN_Handle *rh); 473GNUNET_NAT_stun_make_request_cancel(struct GNUNET_NAT_STUN_Handle *rh);
481 474
482 475
483#endif 476#endif