Service for handling UPnP and NAT-PMP port forwarding and external IP address retrieval. More...
Data Structures | |
struct | GNUNET_BurstSync |
Wrapper struct with the avarage RTT of message to some peer and if this peer und us is ready to sync. More... | |
struct | GNUNET_BurstMessage |
Message send during burst mode. More... | |
struct | GNUNET_StartBurstCls |
Struct wrapping information we use for starting the burst. More... | |
struct | GNUNET_UdpSocketInfo |
Struct with the socket we like to use to send messages to another peer. More... | |
Typedefs | |
typedef void(* | GNUNET_NAT_AUTO_AutoResultCallback) (void *cls, const struct GNUNET_CONFIGURATION_Handle *diff, enum GNUNET_NAT_StatusCode result, enum GNUNET_NAT_Type type) |
Function called with the result from the autoconfiguration. More... | |
typedef void(* | GNUNET_NotifyUdpSocket) (struct GNUNET_UdpSocketInfo *sock_info) |
typedef 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 'valid' addresses changes. More... | |
typedef void(* | GNUNET_NAT_ReversalCallback) (void *cls, const struct sockaddr *remote_addr, socklen_t remote_addrlen) |
Signature of the callback passed to GNUNET_NAT_register(). More... | |
typedef void(* | GNUNET_NAT_TestCallback) (void *cls, enum GNUNET_NAT_StatusCode result) |
Function called to report success or failure for NAT configuration test. More... | |
Functions | |
struct GNUNET_NAT_AUTO_Test * | GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, uint8_t proto, const char *section_name, GNUNET_NAT_TestCallback report, void *report_cls) |
Start testing if NAT traversal works using the given configuration. More... | |
void | GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst) |
Stop an active NAT test. More... | |
const char * | GNUNET_NAT_AUTO_status2string (enum GNUNET_NAT_StatusCode err) |
Converts enum GNUNET_NAT_StatusCode to string. More... | |
struct GNUNET_NAT_AUTO_AutoHandle * | GNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NAT_AUTO_AutoResultCallback cb, void *cb_cls) |
Start auto-configuration routine. More... | |
void | GNUNET_NAT_AUTO_autoconfig_cancel (struct GNUNET_NAT_AUTO_AutoHandle *ah) |
Abort autoconfiguration. More... | |
struct GNUNET_BurstSync * | GNUNET_get_burst_sync_msg (struct GNUNET_TIME_Relative rtt_avarage, enum GNUNET_GenericReturnValue sync_ready) |
Create GNUNET_BurstSync message. More... | |
void | GNUNET_is_burst_ready (struct GNUNET_TIME_Relative rtt_avarage, struct GNUNET_BurstSync *burst_sync, GNUNET_SCHEDULER_TaskCallback task, struct GNUNET_StartBurstCls *task_cls) |
Checks if we are ready and starts burst when we and the other peer is ready. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_get_udp_socket (struct GNUNET_UdpSocketInfo *sock_info, GNUNET_NotifyUdpSocket nus) |
Method to get a UDP socket for a peer that is natted. More... | |
void | GNUNET_stop_burst (struct GNUNET_NETWORK_Handle *do_not_touch) |
Method to stop all sockets we established to the other peer. More... | |
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 the local network. More... | |
void | GNUNET_NAT_add_global_address (struct GNUNET_NAT_Handle *nh, char *addr, unsigned int address_length) |
Add global address to the list of addresses and notify clients. More... | |
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. More... | |
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 responses to cause that peer to connect to us (connection reversal). More... | |
void | GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *nh) |
Stop port redirection and public IP address detection for the given handle. More... | |
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. More... | |
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. More... | |
void | GNUNET_NAT_stun_make_request_cancel (struct GNUNET_NAT_STUN_Handle *rh) |
Cancel active STUN request. More... | |
Service for handling UPnP and NAT-PMP port forwarding and external IP address retrieval.
typedef void(* GNUNET_NAT_AUTO_AutoResultCallback) (void *cls, const struct GNUNET_CONFIGURATION_Handle *diff, enum GNUNET_NAT_StatusCode result, enum GNUNET_NAT_Type type) |
Function called with the result from the autoconfiguration.
cls | closure |
diff | minimal suggested changes to the original configuration to make it work (as best as we can) |
result | GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code |
type | what the situation of the NAT |
Definition at line 101 of file gnunet_nat_auto_service.h.
typedef void(* GNUNET_NotifyUdpSocket) (struct GNUNET_UdpSocketInfo *sock_info) |
Definition at line 111 of file gnunet_nat_lib.h.
typedef 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 'valid' addresses changes.
cls | closure |
app_ctx[in,out] | location where the app can store stuff on add and retrieve it on remove |
add_remove | GNUNET_YES to add a new public IP address, GNUNET_NO to remove a previous (now invalid) one |
ac | address class the address belongs to |
addr | either the previous or the new public IP address |
addrlen | actual length of the addr |
Definition at line 285 of file gnunet_nat_service.h.
typedef void(* GNUNET_NAT_ReversalCallback) (void *cls, const struct sockaddr *remote_addr, socklen_t remote_addrlen) |
Signature of the callback passed to GNUNET_NAT_register().
for a function to call whenever someone asks us to do connection reversal.
cls | closure |
remote_addr | public IP address of the other peer |
remote_addrlen | actual length of the remote_addr |
Definition at line 303 of file gnunet_nat_service.h.
typedef void(* GNUNET_NAT_TestCallback) (void *cls, enum GNUNET_NAT_StatusCode result) |
Function called to report success or failure for NAT configuration test.
cls | closure |
result | GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code |
Definition at line 460 of file gnunet_nat_service.h.
Some addresses contain sensitive information or are not suitable for global distribution.
We use address classes to filter addresses by which domain they make sense to be used in. These are used in a bitmask.
FIXME: might want to define this elsewhere; we have an equivalent enum in gnunet_transport_hello_service.h; might ultimately belong with the new HELLO definition.
Enumerator | |
---|---|
GNUNET_NAT_AC_NONE | No address. |
GNUNET_NAT_AC_OTHER | Addresses that fall into no other category (i.e. incoming which we cannot use elsewhere). |
GNUNET_NAT_AC_PRIVATE | Flag for addresses that are highly sensitive (i.e. IPv6 with our MAC). |
GNUNET_NAT_AC_GLOBAL | Addresses that are global (i.e. IPv4). |
GNUNET_NAT_AC_GLOBAL_PRIVATE | Addresses that are global and are sensitive (i.e. IPv6 with our MAC). |
GNUNET_NAT_AC_LAN | Addresses useful in the local wired network, i.e. a MAC. Sensitive, but obvious to people nearby. Useful for broadcasts. |
GNUNET_NAT_AC_LAN_PRIVATE | Addresses useful in the local wired network, i.e. a MAC. Sensitive, but obvious to people nearby. Useful for broadcasts. |
GNUNET_NAT_AC_WLAN | Addresses useful in the local wireless network, i.e. a MAC. Sensitive, but obvious to people nearby. Useful for broadcasts. |
GNUNET_NAT_AC_BT | Addresses useful in the local bluetooth network. Sensitive, but obvious to people nearby. Useful for broadcasts. |
GNUNET_NAT_AC_LOOPBACK | Loopback addresses, only useful under special circumstances. |
GNUNET_NAT_AC_EXTERN | Addresses that should be our external IP address on the outside of a NAT. Might be incorrectly determined. Used as a bit in combination with GNUNET_NAT_AC_GLOBAL, or in case of double-NAT with GNUNET_NAT_AC_LAN. |
GNUNET_NAT_AC_MANUAL | Addresses that were manually configured by the user. Used as a bit in combination with GNUNET_NAT_AC_GLOBAL. |
GNUNET_NAT_AC_ANY | Bitmask for "any" address. |
Definition at line 53 of file gnunet_nat_service.h.
Error Types for the NAT subsystem (which can then later be converted/resolved to a string)
Definition at line 141 of file gnunet_nat_service.h.
enum GNUNET_NAT_Type |
What the situation of the NAT connectivity.
Definition at line 243 of file gnunet_nat_service.h.
struct GNUNET_NAT_AUTO_Test * GNUNET_NAT_AUTO_test_start | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
uint8_t | proto, | ||
const char * | section_name, | ||
GNUNET_NAT_TestCallback | report, | ||
void * | report_cls | ||
) |
Start testing if NAT traversal works using the given configuration.
The transport adapters should be down while using this function.
cfg | configuration for the NAT traversal |
proto | protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP |
section_name | configuration section to use for configuration |
report | function to call with the result of the test |
report_cls | closure for report |
Definition at line 426 of file nat_auto_api_test.c.
References _, addr_cb(), cfg, GNUNET_NAT_Handle::cfg, do_accept(), do_fail(), do_udp_read(), GNUNET_a2s(), GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR, GNUNET_NAT_ERROR_NAT_REGISTER_FAILED, GNUNET_NAT_ERROR_SUCCESS, GNUNET_NAT_register(), GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NETWORK_socket_listen(), GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_cancel(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, LOG, nh, proto, reversal_cb(), and section_name.
Referenced by run().
void GNUNET_NAT_AUTO_test_stop | ( | struct GNUNET_NAT_AUTO_Test * | tst | ) |
Stop an active NAT test.
tst | test to stop. |
Definition at line 558 of file nat_auto_api_test.c.
References GNUNET_NAT_AUTO_Test::ca_head, GNUNET_NAT_AUTO_Test::ca_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_NAT_unregister(), GNUNET_NETWORK_socket_close(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_NAT_AUTO_Test::lsock, GNUNET_NAT_AUTO_Test::ltask, ClientActivity::mq, GNUNET_NAT_AUTO_Test::na_head, GNUNET_NAT_AUTO_Test::na_tail, GNUNET_NAT_AUTO_Test::nat, NatActivity::rtask, GNUNET_NAT_AUTO_Test::section_name, NatActivity::sock, and GNUNET_NAT_AUTO_Test::ttask.
Referenced by do_shutdown().
const char * GNUNET_NAT_AUTO_status2string | ( | enum GNUNET_NAT_StatusCode | err | ) |
Converts enum GNUNET_NAT_StatusCode
to string.
err | error code to resolve to a string |
Definition at line 68 of file nat_auto_api.c.
References _, GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID, GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED, GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND, GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_OUTPUT_INVALID, GNUNET_NAT_ERROR_HELPER_NAT_CLIENT_NOT_FOUND, GNUNET_NAT_ERROR_HELPER_NAT_SERVER_NOT_FOUND, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR, GNUNET_NAT_ERROR_IPC_FAILURE, GNUNET_NAT_ERROR_NAT_REGISTER_FAILED, GNUNET_NAT_ERROR_NAT_TEST_START_FAILED, GNUNET_NAT_ERROR_NAT_TEST_TIMEOUT, GNUNET_NAT_ERROR_NO_VALID_IF_IP_COMBO, GNUNET_NAT_ERROR_NOT_ONLINE, GNUNET_NAT_ERROR_SUCCESS, GNUNET_NAT_ERROR_TIMEOUT, GNUNET_NAT_ERROR_UPNPC_FAILED, GNUNET_NAT_ERROR_UPNPC_NOT_FOUND, GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED, and GNUNET_NAT_ERROR_UPNPC_TIMEOUT.
Referenced by auto_config_cb(), and test_report_cb().
struct GNUNET_NAT_AUTO_AutoHandle * GNUNET_NAT_AUTO_autoconfig_start | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
GNUNET_NAT_AUTO_AutoResultCallback | cb, | ||
void * | cb_cls | ||
) |
Start auto-configuration routine.
The transport adapters should be stopped while this function is called.
cfg | initial configuration |
cb | function to call with autoconfiguration result |
cb_cls | closure for cb |
Definition at line 225 of file nat_auto_api.c.
References ah, ah_error_handler(), GNUNET_NAT_AUTO_AutoHandle::arc, GNUNET_NAT_AUTO_AutoHandle::arc_cls, cfg, env, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_CONFIGURATION_serialize(), GNUNET_free, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT, GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, handlers, GNUNET_NAT_AUTO_AutoHandle::mq, and size.
Referenced by run().
void GNUNET_NAT_AUTO_autoconfig_cancel | ( | struct GNUNET_NAT_AUTO_AutoHandle * | ah | ) |
Abort autoconfiguration.
ah | handle for operation to abort |
Definition at line 285 of file nat_auto_api.c.
References ah, GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_NAT_AUTO_AutoHandle::mq.
Referenced by ah_error_handler(), do_shutdown(), and handle_auto_result().
struct GNUNET_BurstSync * GNUNET_get_burst_sync_msg | ( | struct GNUNET_TIME_Relative | rtt_avarage, |
enum GNUNET_GenericReturnValue | sync_ready | ||
) |
Create GNUNET_BurstSync message.
rtt_avarage | The avarage RTT for the peer to communicate with. |
sync_ready | Is this peer already ready to sync. |
rtt_avarage | The avarage RTT for the peer to communicate with. |
sync_ready | Is this peer already ready to sync. |
Definition at line 66 of file nat.c.
References GNUNET_new, GNUNET_TIME_relative_hton(), GNUNET_BurstSync::rtt_avarage, and GNUNET_BurstSync::sync_ready.
void GNUNET_is_burst_ready | ( | struct GNUNET_TIME_Relative | rtt_avarage, |
struct GNUNET_BurstSync * | burst_sync, | ||
GNUNET_SCHEDULER_TaskCallback | task, | ||
struct GNUNET_StartBurstCls * | task_cls | ||
) |
Checks if we are ready and starts burst when we and the other peer is ready.
rtt_avarage | The avarage RTT for the peer to communicate with. |
sync_ready | Is this peer already ready to sync. |
burst_sync | The GNUNET_BurstSync from the other peer. |
task | Task to be executed if both peers are ready. |
task_cls | Closure for the task. |
rtt_avarage | The avarage RTT for the peer to communicate with. |
burst_sync | The GNUNET_BurstSync from the other peer. |
task | Task to be executed if both peers are ready. |
task_cls | Closure for the task. |
Definition at line 89 of file nat.c.
References GNUNET_StartBurstCls::delay, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_TIME_relative_ntoh(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_TIME_relative_subtract(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GNUNET_TIME_Relative::rel_value_us, GNUNET_BurstSync::rtt_avarage, RTT_DIFF, GNUNET_BurstSync::sync_ready, and GNUNET_StartBurstCls::sync_ready.
Referenced by handle_flow_control().
struct GNUNET_SCHEDULER_Task * GNUNET_get_udp_socket | ( | struct GNUNET_UdpSocketInfo * | sock_info, |
GNUNET_NotifyUdpSocket | nus | ||
) |
Method to get a UDP socket for a peer that is natted.
sock_info | Struct with information correlated to a specific port at the other peer. |
nus | Callback to give the caller the struct GNUNET_UdpSocketInfo to use to connect the other peer. |
Definition at line 509 of file nat.c.
References address, GNUNET_UdpSocketInfo::address, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_NETWORK_socket_sendto(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative2s(), GNUNET_UdpSocketInfo::has_port, GNUNET_BurstMessage::local_port, nr_open_sockets, GNUNET_UdpSocketInfo::nus, read_send(), read_send_task, GNUNET_UdpSocketInfo::rtt, SEND_DELAY, GNUNET_UdpSocketInfo::std_port, udp_address_to_sockaddr(), udp_port, and GNUNET_UdpSocketInfo::udp_sock.
Referenced by start_burst().
void GNUNET_stop_burst | ( | struct GNUNET_NETWORK_Handle * | do_not_touch | ) |
Method to stop all sockets we established to the other peer.
do_not_touch | The network handle we will use to connect to the other peer. This socket must not be closed. |
Definition at line 564 of file nat.c.
References GNUNET_UdpSocketInfo::address, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NETWORK_socket_close(), GNUNET_SCHEDULER_cancel(), GNUNET_UdpSocketInfo::next, read_send_task, GNUNET_UdpSocketInfo::read_task, sock_infos_head, sock_infos_tail, GNUNET_UdpSocketInfo::timeout_task, and GNUNET_UdpSocketInfo::udp_sock.
Referenced by do_shutdown(), sock_read(), and start_burst().
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 the local network.
Use addr to specify to which of the local host's addresses should the external port be mapped. The port is taken from the corresponding sockaddr_in[6] field. The NAT module should call the given address_callback for any 'plausible' external address.
cfg | configuration to use |
config_section | name of the configuration section for options |
proto | protocol this is about, IPPROTO_TCP or IPPROTO_UDP |
num_addrs | number of addresses in addrs |
addrs | list of local addresses packets should be redirected to |
addrlens | actual lengths of the addresses in addrs |
address_callback | function to call every time the public IP address changes |
reversal_callback | function to call if someone wants connection reversal from us, NULL if connection reversal is not supported |
callback_cls | closure for callbacks |
Definition at line 366 of file nat_api.c.
References GNUNET_NAT_Handle::address_callback, GNUNET_NAT_Handle::callback_cls, cfg, GNUNET_NAT_Handle::cfg, do_connect(), GNUNET_NAT_RegisterMessage::flags, GNUNET_break, GNUNET_free, GNUNET_malloc, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAT_REGISTER, GNUNET_NAT_RF_ADDRESSES, GNUNET_NAT_RF_NONE, GNUNET_NAT_RF_REVERSAL, GNUNET_new, GNUNET_NAT_RegisterMessage::header, nh, GNUNET_NAT_RegisterMessage::num_addrs, proto, GNUNET_NAT_RegisterMessage::proto, GNUNET_NAT_Handle::reg, reversal_callback(), GNUNET_NAT_Handle::reversal_callback, GNUNET_MessageHeader::size, GNUNET_NAT_RegisterMessage::str_len, and GNUNET_MessageHeader::type.
Referenced by GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_test_start(), nat_register(), run(), and try_anat().
void GNUNET_NAT_add_global_address | ( | struct GNUNET_NAT_Handle * | nh, |
char * | addr, | ||
unsigned int | address_length | ||
) |
Add global address to the list of addresses and notify clients.
nh | the handle returned by register |
addr | IP address to add. |
address_length | number of bytes in addr |
Definition at line 460 of file nat_api.c.
References GNUNET_NAT_AddGlobalAddressMessage::address_length, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAT_Handle::mq, and nh.
Referenced by handle_flow_control().
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.
Mostly a convenience function so that clients do not have to explicitly track all IPs that the GNUNET_NAT_AddressCallback has returned so far.
nh | the handle returned by register |
addr | IP address to test (IPv4 or IPv6) |
addrlen | number of bytes in addr |
Definition at line 643 of file nat_api.c.
References AddrEntry::addrlen, GNUNET_NAT_Handle::ae_head, GNUNET_break, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, AddrEntry::next, and nh.
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 responses to cause that peer to connect to us (connection reversal).
nh | handle (used for configuration) |
local_sa | our local address of the peer (IPv4-only) |
remote_sa | the remote address of the peer (IPv4-only) |
Definition at line 675 of file nat_api.c.
References env, GNUNET_break, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_NAT_RequestConnectionReversalMessage::local_addr_size, GNUNET_NAT_Handle::mq, nh, and GNUNET_NAT_RequestConnectionReversalMessage::remote_addr_size.
Referenced by mq_init(), run(), and try_anat().
void GNUNET_NAT_unregister | ( | struct GNUNET_NAT_Handle * | nh | ) |
Stop port redirection and public IP address detection for the given handle.
This frees the handle, after having sent the needed commands to close open ports.
FIXME: No, the implementation of this API does not do anything beyond cleaning up the handle. This is a problem for applications that use GNUNET_NAT_AddressCallback and use the app_ctx to store objects, because the callback will never be called for cleanup on unregister.
nh | the handle to unregister |
Definition at line 703 of file nat_api.c.
References GNUNET_NAT_Handle::ae_head, GNUNET_NAT_Handle::ae_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_NAT_Handle::mq, AddrEntry::next, nh, GNUNET_NAT_Handle::reconnect_task, and GNUNET_NAT_Handle::reg.
Referenced by do_shutdown(), GNUNET_NAT_AUTO_test_stop(), GNUNET_NAT_test_stop(), and try_anat().
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.
This function is useful as some GNUnet service may be listening on a UDP port and might thus receive STUN messages while trying to receive other data. In this case, this function can be used to process replies to STUN requests.
The function does some basic sanity checks on packet size and content, try to extract a bit of information.
At the moment this only processes BIND requests, and returns the externally visible address of the request to the rest of the NAT logic.
nh | handle to the NAT service |
sender_addr | address from which we got data |
sender_addr_len | number of bytes in sender_addr |
data | the packet |
data_size | number of bytes in data |
Definition at line 601 of file nat_api.c.
References data, data_size, env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_NAT_Handle::mq, nh, GNUNET_NAT_HandleStunMessage::payload_size, GNUNET_NAT_HandleStunMessage::sender_addr_size, and test_stun_packet().
Referenced by do_udp_read(), and stun_read_task().
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.
Sends a generic stun request to the server specified using the specified socket. If we do this, we need to watch for possible responses and call GNUNET_NAT_stun_handle_packet() on incoming packets.
server | the address of the stun server |
port | port of the stun server, in host byte order |
sock | the socket used to send the request, must be a UDP socket |
cb | callback in case of error |
cb_cls | closure for cb |
Sends a generic stun request to the server specified using the specified socket.
server | the address of the stun server |
port | port of the stun server, in host byte order |
sock | the socket used to send the request |
cb | callback in case of error |
cb_cls | closure for cb |
Definition at line 211 of file nat_api_stun.c.
References GNUNET_NAT_STUN_Handle::cb, GNUNET_NAT_STUN_Handle::cb_cls, GNUNET_NAT_STUN_Handle::dns_active, GNUNET_NAT_STUN_Handle::dns_success, GNUNET_NAT_stun_make_request_cancel(), GNUNET_new, GNUNET_NO, GNUNET_RESOLVER_ip_get(), GNUNET_strdup, port, GNUNET_NAT_STUN_Handle::sock, stun_dns_callback(), GNUNET_NAT_STUN_Handle::stun_port, GNUNET_NAT_STUN_Handle::stun_server, and TIMEOUT.
Referenced by test_stun().
void GNUNET_NAT_stun_make_request_cancel | ( | struct GNUNET_NAT_STUN_Handle * | rh | ) |
Cancel active STUN request.
Frees associated resources and ensures that the callback is no longer invoked.
rh | request to cancel |
Definition at line 247 of file nat_api_stun.c.
References GNUNET_NAT_STUN_Handle::dns_active, GNUNET_free, GNUNET_RESOLVER_request_cancel(), and GNUNET_NAT_STUN_Handle::stun_server.
Referenced by GNUNET_NAT_stun_make_request(), and stun_dns_callback().