GNUnet  0.19.3
gnunet_nat_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2007-2017 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 
36 #ifndef GNUNET_NAT_SERVICE_H
37 #define GNUNET_NAT_SERVICE_H
38 
39 
40 #include "gnunet_util_lib.h"
41 
42 
54 {
59 
65 
71 
76 
82 
90 
97 
104 
110 
115 
124 
130 
134  GNUNET_NAT_AC_ANY = 65535
135 };
136 
137 
142 {
147 
152 
157 
162 
167 
172 
177 
182 
187 
192 
197 
202 
207 
212 
217 
222 
227 
232 
237 };
238 
239 
244 {
249 
254 
259 
264 
269 };
270 
271 
285 typedef void
286 (*GNUNET_NAT_AddressCallback) (void *cls,
287  void **app_ctx,
288  int add_remove,
290  const struct sockaddr *addr,
291  socklen_t addrlen);
292 
293 
303 typedef void
304 (*GNUNET_NAT_ReversalCallback) (void *cls,
305  const struct sockaddr *remote_addr,
306  socklen_t remote_addrlen);
307 
308 
312 struct GNUNET_NAT_Handle;
313 
314 
335 struct GNUNET_NAT_Handle *
337  const char *config_section,
338  uint8_t proto,
339  unsigned int num_addrs,
340  const struct sockaddr **addrs,
341  const socklen_t *addrlens,
344  void *callback_cls);
345 
346 
360 int
362  const void *addr,
363  socklen_t addrlen);
364 
365 
378 int
380  const struct sockaddr_in *local_sa,
381  const struct sockaddr_in *remote_sa);
382 
383 
397 void
399 
400 
424 int
426  const struct sockaddr *sender_addr,
427  size_t sender_addr_len,
428  const void *data,
429  size_t data_size);
430 
431 
438 
439 
447 typedef void
448 (*GNUNET_NAT_TestCallback) (void *cls,
450 
451 
466 struct GNUNET_NAT_STUN_Handle *
467 GNUNET_NAT_stun_make_request (const char *server,
468  uint16_t port,
469  struct GNUNET_NETWORK_Handle *sock,
471  void *cb_cls);
472 
473 
480 void
482 
483 
484 #endif
485  /* end of group */
487 
488 /* end of gnunet_nat_service.h */
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static uint16_t port
Port number.
Definition: gnunet-bcd.c:147
uint32_t data
The data value.
static struct GNUNET_NAT_Handle * nh
Handle to NAT operation.
Definition: gnunet-nat.c:80
static char * remote_addr
Remote address to use for connection reversal request.
Definition: gnunet-nat.c:70
static uint8_t proto
Protocol to use.
Definition: gnunet-nat.c:60
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static int result
Global testing status.
static void reversal_callback(void *cls, const struct sockaddr_in *ra)
We got a connection reversal request from another peer.
@ GNUNET_OK
int GNUNET_NAT_request_reversal(struct GNUNET_NAT_Handle *nh, const struct sockaddr_in *local_sa, const struct sockaddr_in *remote_sa)
We learned about a peer (possibly behind NAT) so run the gnunet-nat-client to send dummy ICMP respons...
Definition: nat_api.c:646
void(* GNUNET_NAT_ReversalCallback)(void *cls, const struct sockaddr *remote_addr, socklen_t remote_addrlen)
Signature of the callback passed to GNUNET_NAT_register().
GNUNET_NAT_StatusCode
Error Types for the NAT subsystem (which can then later be converted/resolved to a string)
void GNUNET_NAT_unregister(struct GNUNET_NAT_Handle *nh)
Stop port redirection and public IP address detection for the given handle.
Definition: nat_api.c:674
void(* GNUNET_NAT_TestCallback)(void *cls, enum GNUNET_NAT_StatusCode result)
Function called to report success or failure for NAT configuration test.
void GNUNET_NAT_stun_make_request_cancel(struct GNUNET_NAT_STUN_Handle *rh)
Cancel active STUN request.
Definition: nat_api_stun.c:247
GNUNET_NAT_Type
What the situation of the NAT connectivity.
struct GNUNET_NAT_STUN_Handle * GNUNET_NAT_stun_make_request(const char *server, uint16_t port, struct GNUNET_NETWORK_Handle *sock, GNUNET_NAT_TestCallback cb, void *cb_cls)
Make Generic STUN request.
Definition: nat_api_stun.c:211
void(* GNUNET_NAT_AddressCallback)(void *cls, void **app_ctx, int add_remove, enum GNUNET_NAT_AddressClass ac, const struct sockaddr *addr, socklen_t addrlen)
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of ...
int GNUNET_NAT_stun_handle_packet(struct GNUNET_NAT_Handle *nh, const struct sockaddr *sender_addr, size_t sender_addr_len, const void *data, size_t data_size)
Handle an incoming STUN message.
Definition: nat_api.c:572
GNUNET_NAT_AddressClass
Some addresses contain sensitive information or are not suitable for global distribution.
struct GNUNET_NAT_Handle * GNUNET_NAT_register(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *config_section, uint8_t proto, unsigned int num_addrs, const struct sockaddr **addrs, const socklen_t *addrlens, GNUNET_NAT_AddressCallback address_callback, GNUNET_NAT_ReversalCallback reversal_callback, void *callback_cls)
Attempt to enable port redirection and detect public IP address contacting UPnP or NAT-PMP routers on...
Definition: nat_api.c:366
int GNUNET_NAT_test_address(struct GNUNET_NAT_Handle *nh, const void *addr, socklen_t addrlen)
Test if the given address is (currently) a plausible IP address for this peer.
Definition: nat_api.c:614
@ GNUNET_NAT_ERROR_UPNPC_NOT_FOUND
upnpc command not found
@ GNUNET_NAT_ERROR_NOT_ONLINE
detected that we are offline
@ GNUNET_NAT_ERROR_UPNPC_TIMEOUT
‘upnpc’ command took too long, process killed
@ GNUNET_NAT_ERROR_SUCCESS
Just the default.
@ GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_OUTPUT_INVALID
‘external-ip’ command output invalid
@ GNUNET_NAT_ERROR_UPNPC_FAILED
Failed to run upnpc command.
@ GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED
Failed to run external-ip command.
@ GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR
Failure in network subsystem, check permissions.
@ GNUNET_NAT_ERROR_HELPER_NAT_CLIENT_NOT_FOUND
@ GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED
‘upnpc’ command failed to establish port mapping
@ GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND
‘external-ip’ command not found
@ GNUNET_NAT_ERROR_NAT_REGISTER_FAILED
NAT test failed to initiate.
@ GNUNET_NAT_ERROR_IPC_FAILURE
IPC Failure.
@ GNUNET_NAT_ERROR_NO_VALID_IF_IP_COMBO
Could not determine interface with internal/local network address.
@ GNUNET_NAT_ERROR_HELPER_NAT_SERVER_NOT_FOUND
No working gnunet-helper-nat-server found.
@ GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID
"no valid address was returned by `external-ip'"
@ GNUNET_NAT_ERROR_NAT_TEST_START_FAILED
NAT test could not be initialized.
@ GNUNET_NAT_ERROR_NAT_TEST_TIMEOUT
NAT test timeout.
@ GNUNET_NAT_ERROR_TIMEOUT
test timed out
@ GNUNET_NAT_TYPE_UPNP_NAT
We can traverse using UPNP.
@ GNUNET_NAT_TYPE_UNKNOWN
We know nothing about the NAT.
@ GNUNET_NAT_TYPE_UNREACHABLE_NAT
We are under a NAT but cannot traverse it.
@ GNUNET_NAT_TYPE_NO_NAT
We have a direct connection.
@ GNUNET_NAT_TYPE_STUN_PUNCHED_NAT
We can traverse using STUN.
@ GNUNET_NAT_AC_LAN_PRIVATE
Addresses useful in the local wired network, i.e.
@ GNUNET_NAT_AC_LAN
Addresses useful in the local wired network, i.e.
@ GNUNET_NAT_AC_GLOBAL_PRIVATE
Addresses that are global and are sensitive (i.e.
@ GNUNET_NAT_AC_GLOBAL
Addresses that are global (i.e.
@ GNUNET_NAT_AC_PRIVATE
Flag for addresses that are highly sensitive (i.e.
@ GNUNET_NAT_AC_EXTERN
Addresses that should be our external IP address on the outside of a NAT.
@ GNUNET_NAT_AC_ANY
Bitmask for "any" address.
@ GNUNET_NAT_AC_WLAN
Addresses useful in the local wireless network, i.e.
@ GNUNET_NAT_AC_OTHER
Addresses that fall into no other category (i.e.
@ GNUNET_NAT_AC_BT
Addresses useful in the local bluetooth network.
@ GNUNET_NAT_AC_NONE
No address.
@ GNUNET_NAT_AC_MANUAL
Addresses that were manually configured by the user.
@ GNUNET_NAT_AC_LOOPBACK
Loopback addresses, only useful under special circumstances.
Handle for active NAT registrations.
Definition: nat_api.c:72
void * callback_cls
Closure for the various callbacks.
Definition: nat_api.c:111
GNUNET_NAT_AddressCallback address_callback
Function to call when our addresses change.
Definition: nat_api.c:101
Handle to a request given to the resolver.
Definition: nat_api_stun.c:57
GNUNET_NAT_TestCallback cb
Function to call when a error occurs.
Definition: nat_api_stun.c:76
void * cb_cls
Closure for cb.
Definition: nat_api_stun.c:81
struct GNUNET_NETWORK_Handle * sock
Handle to the listen socket.
Definition: nat_api_stun.c:66
handle to a socket
Definition: network.c:53