Go to the source code of this file.
Typedefs | |
typedef void(* | GNUNET_NAT_IPCallback) (void *cls, const struct in_addr *addr, enum GNUNET_NAT_StatusCode result) |
Signature of a callback that is given an IP address. More... | |
typedef void(* | GNUNET_NAT_MiniAddressCallback) (void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen, enum GNUNET_NAT_StatusCode result) |
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of 'valid' addresses changes. More... | |
Functions | |
struct GNUNET_NAT_ExternalHandle * | GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb, void *cb_cls) |
Try to get the external IPv4 address of this peer. More... | |
void | GNUNET_NAT_mini_get_external_ipv4_cancel_ (struct GNUNET_NAT_ExternalHandle *eh) |
Cancel operation. More... | |
struct GNUNET_NAT_MiniHandle * | GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp, GNUNET_NAT_MiniAddressCallback ac, void *ac_cls) |
Start mapping the given port using (mini)upnpc. More... | |
void | GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini) |
Remove a mapping created with (mini)upnpc. More... | |
typedef void(* GNUNET_NAT_IPCallback) (void *cls, const struct in_addr *addr, enum GNUNET_NAT_StatusCode result) |
Signature of a callback that is given an IP address.
cls | closure |
addr | the address, NULL on errors |
result | GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code |
Definition at line 37 of file gnunet-service-nat_mini.h.
typedef void(* GNUNET_NAT_MiniAddressCallback) (void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen, enum GNUNET_NAT_StatusCode result) |
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of 'valid' addresses changes.
cls | closure |
add_remove | GNUNET_YES to mean the new public IP address, GNUNET_NO to mean the previous (now invalid) one, GNUNET_SYSERR indicates an error |
addr | either the previous or the new public IP address |
addrlen | actual length of the addr |
result | GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code |
Definition at line 88 of file gnunet-service-nat_mini.h.
struct GNUNET_NAT_ExternalHandle * GNUNET_NAT_mini_get_external_ipv4_ | ( | GNUNET_NAT_IPCallback | cb, |
void * | cb_cls | ||
) |
Try to get the external IPv4 address of this peer.
cb | function to call with result |
cb_cls | closure for cb |
cb | function to call with result |
cb_cls | closure for cb |
Definition at line 177 of file gnunet-service-nat_mini.c.
References _, GNUNET_NAT_ExternalHandle::cb, GNUNET_NAT_ExternalHandle::cb_cls, GNUNET_NAT_ExternalHandle::eip, GNUNET_DISK_PF_BLOCKING_RW, GNUNET_DISK_pipe(), GNUNET_DISK_pipe_close(), GNUNET_DISK_pipe_close_end(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_PIPE_END_WRITE, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED, GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND, GNUNET_NAT_ERROR_IPC_FAILURE, GNUNET_NAT_ERROR_SUCCESS, GNUNET_new, GNUNET_NO, GNUNET_OS_check_helper_binary(), GNUNET_OS_INHERIT_STD_NONE, GNUNET_OS_start_process(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_file(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, LOG, GNUNET_NAT_ExternalHandle::opipe, GNUNET_NAT_ExternalHandle::r, read_external_ipv4(), GNUNET_NAT_ExternalHandle::ret, signal_external_ip_error(), and GNUNET_NAT_ExternalHandle::task.
Referenced by run_external_ip().
void GNUNET_NAT_mini_get_external_ipv4_cancel_ | ( | struct GNUNET_NAT_ExternalHandle * | eh | ) |
Cancel operation.
eh | operation to cancel |
Definition at line 232 of file gnunet-service-nat_mini.c.
References GNUNET_NAT_ExternalHandle::eip, GNUNET_break, GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_OK, GNUNET_OS_process_destroy(), GNUNET_OS_process_kill(), GNUNET_OS_process_wait(), GNUNET_SCHEDULER_cancel(), GNUNET_NAT_ExternalHandle::opipe, and GNUNET_NAT_ExternalHandle::task.
Referenced by GN_nat_status_changed(), read_external_ipv4(), and run_external_ip().
struct GNUNET_NAT_MiniHandle * GNUNET_NAT_mini_map_start | ( | uint16_t | port, |
int | is_tcp, | ||
GNUNET_NAT_MiniAddressCallback | ac, | ||
void * | ac_cls | ||
) |
Start mapping the given port using (mini)upnpc.
This function should typically not be used directly (it is used within the general-purpose GNUNET_NAT_register() code). However, it can be used if specifically UPnP-based NAT traversal is to be used or tested.
port | port to map |
is_tcp | GNUNET_YES to map TCP, GNUNET_NO for UDP |
ac | function to call with mapping result |
ac_cls | closure for ac |
This function should typically not be used directly (it is used within the general-purpose GNUNET_NAT_register() code). However, it can be used if specifically UPnP-based NAT traversal is to be used or tested.
port | port to map |
is_tcp | GNUNET_YES to map TCP, GNUNET_NO for UDP |
ac | function to call with mapping result |
ac_cls | closure for ac |
Definition at line 593 of file gnunet-service-nat_mini.c.
References _, GNUNET_NAT_MiniHandle::ac, GNUNET_NAT_MiniHandle::ac_cls, do_refresh(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_NAT_ERROR_UPNPC_NOT_FOUND, GNUNET_new, GNUNET_NO, GNUNET_OS_check_helper_binary(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SYSERR, GNUNET_NAT_MiniHandle::is_tcp, LOG, MAP_REFRESH_FREQ, port, ret, and run_upnpc_r().
Referenced by handle_register().
void GNUNET_NAT_mini_map_stop | ( | struct GNUNET_NAT_MiniHandle * | mini | ) |
Remove a mapping created with (mini)upnpc.
Calling this function will give 'upnpc' 1s to remove the mapping, so while this function is non-blocking, a task will be left with the scheduler for up to 1s past this call.
mini | the handle |
Definition at line 643 of file gnunet-service-nat_mini.c.
References GNUNET_NAT_MiniHandle::ac, GNUNET_NAT_MiniHandle::ac_cls, GNUNET_NAT_MiniHandle::current_addr, GNUNET_NAT_MiniHandle::did_map, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NAT_ERROR_SUCCESS, GNUNET_NO, GNUNET_OS_command_run(), GNUNET_OS_command_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_snprintf(), GNUNET_NAT_MiniHandle::is_tcp, LOG, GNUNET_NAT_MiniHandle::map_cmd, process_unmap_output(), GNUNET_NAT_MiniHandle::refresh_cmd, GNUNET_NAT_MiniHandle::refresh_task, GNUNET_NAT_MiniHandle::unmap_cmd, and UNMAP_TIMEOUT.
Referenced by client_disconnect_cb().