Go to the source code of this file.
Data Structures | |
struct | NatActivity |
Entry we keep for each incoming connection. More... | |
struct | ClientActivity |
Entry we keep for each connection to the gnunet-nat-service. More... | |
struct | GNUNET_NAT_Test |
Handle to a NAT test. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "nat", __VA_ARGS__) |
#define | NAT_SERVER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
Functions | |
static void | reversal_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
Function called from GNUNET_NAT_register whenever someone asks us to do connection reversal. More... | |
static void | do_udp_read (void *cls) |
Activity on our incoming socket. More... | |
static void | do_read (void *cls) |
Activity on our incoming socket. More... | |
static void | do_accept (void *cls) |
Activity on our listen socket. More... | |
static void | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
We got disconnected from the NAT server. More... | |
static void | addr_cb (void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen) |
Address-callback, used to send message to gnunet-nat-server. More... | |
static void | do_timeout (void *cls) |
Timeout task for a nat test. More... | |
struct GNUNET_NAT_Test * | GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp, uint16_t bnd_port, uint16_t adv_port, struct GNUNET_TIME_Relative timeout, GNUNET_NAT_TestCallback report, void *report_cls) |
Start testing if NAT traversal works using the given configuration (IPv4-only). More... | |
void | GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst) |
Stop an active NAT test. More... | |
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "nat", __VA_ARGS__) |
Definition at line 31 of file gnunet-nat-auto_legacy.c.
#define NAT_SERVER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
Definition at line 33 of file gnunet-nat-auto_legacy.c.
|
static |
Function called from GNUNET_NAT_register whenever someone asks us to do connection reversal.
cls | closure, our struct GNUNET_NAT_Handle |
addr | public IP address of the other peer |
addrlen | actual length of the addr |
Definition at line 186 of file gnunet-nat-auto_legacy.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_NAT_ERROR_SUCCESS, h, and LOG.
Referenced by GNUNET_NAT_test_start().
|
static |
Activity on our incoming socket.
Read data from the incoming connection.
cls | the struct GNUNET_NAT_Test |
Definition at line 212 of file gnunet-nat-auto_legacy.c.
References data, GNUNET_NAT_Test::data, do_udp_read(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NAT_ERROR_SUCCESS, GNUNET_NETWORK_fdset_isset(), GNUNET_NETWORK_socket_recv(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_get_task_context(), GNUNET_TIME_UNIT_FOREVER_REL, LOG, GNUNET_NAT_Test::lsock, GNUNET_NAT_Test::ltask, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_NAT_Test::report, GNUNET_NAT_Test::report_cls, tc, and GNUNET_SCHEDULER_TaskContext::write_ready.
Referenced by do_udp_read(), and GNUNET_NAT_test_start().
|
static |
Activity on our incoming socket.
Read data from the incoming connection.
cls | the struct NatActivity |
Definition at line 247 of file gnunet-nat-auto_legacy.c.
References data, GNUNET_NAT_Test::data, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NAT_ERROR_SUCCESS, GNUNET_NETWORK_fdset_isset(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_recv(), GNUNET_SCHEDULER_get_task_context(), NatActivity::h, LOG, GNUNET_NAT_Test::na_head, GNUNET_NAT_Test::na_tail, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_NAT_Test::report, GNUNET_NAT_Test::report_cls, NatActivity::rtask, NatActivity::sock, tc, and GNUNET_SCHEDULER_TaskContext::write_ready.
Referenced by do_accept().
|
static |
Activity on our listen socket.
Accept the incoming connection.
cls | the struct GNUNET_NAT_Test |
Definition at line 284 of file gnunet-nat-auto_legacy.c.
References do_accept(), do_read(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log_strerror, GNUNET_NETWORK_socket_accept(), GNUNET_new, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, NatActivity::h, LOG, GNUNET_NAT_Test::lsock, GNUNET_NAT_Test::ltask, GNUNET_NAT_Test::na_head, GNUNET_NAT_Test::na_tail, NatActivity::rtask, and NatActivity::sock.
Referenced by do_accept(), and GNUNET_NAT_test_start().
|
static |
We got disconnected from the NAT server.
Stop waiting for a reply.
cls | the struct ClientActivity |
error | error code |
Definition at line 321 of file gnunet-nat-auto_legacy.c.
References GNUNET_NAT_Test::ca_head, GNUNET_NAT_Test::ca_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), ClientActivity::h, and ClientActivity::mq.
Referenced by addr_cb().
|
static |
Address-callback, used to send message to gnunet-nat-server.
cls | closure |
add_remove | GNUNET_YES to mean the new public IP address, GNUNET_NO to mean the previous (now invalid) one |
addr | either the previous or the new public IP address |
addrlen | actual length of the addr |
Definition at line 342 of file gnunet-nat-auto_legacy.c.
References _, GNUNET_ARM_Handle::cfg, env, GNUNET_a2s(), GNUNET_CLIENT_connect(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_NAT_TEST, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_YES, h, ClientActivity::h, LOG, ClientActivity::mq, mq_error_handler(), and msg.
Referenced by GNUNET_NAT_test_start().
|
static |
Timeout task for a nat test.
Calls the report-callback with a timeout return value
Destroys the nat handle after the callback has been processed.
cls | handle to the timed out NAT test |
Definition at line 400 of file gnunet-nat-auto_legacy.c.
References GNUNET_NAT_ERROR_SUCCESS, GNUNET_NAT_ERROR_TIMEOUT, and nh.
Referenced by GNUNET_NAT_test_start().
struct GNUNET_NAT_Test * GNUNET_NAT_test_start | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
int | is_tcp, | ||
uint16_t | bnd_port, | ||
uint16_t | adv_port, | ||
struct GNUNET_TIME_Relative | timeout, | ||
GNUNET_NAT_TestCallback | report, | ||
void * | report_cls | ||
) |
Start testing if NAT traversal works using the given configuration (IPv4-only).
ALL failures are reported directly to the report callback
cfg | configuration for the NAT traversal |
is_tcp | GNUNET_YES to test TCP, GNUNET_NO to test UDP |
bnd_port | port to bind to, 0 for connection reversal |
adv_port | externally advertised port to use |
timeout | delay after which the test should be aborted |
report | function to call with the result of the test |
report_cls | closure for report |
Definition at line 428 of file gnunet-nat-auto_legacy.c.
References _, addr_cb(), cfg, GNUNET_NAT_Handle::cfg, do_accept(), do_timeout(), do_udp_read(), GNUNET_a2s(), GNUNET_break, 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_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, LOG, nh, reversal_cb(), and timeout.
Referenced by reversal_test().
void GNUNET_NAT_test_stop | ( | struct GNUNET_NAT_Test * | tst | ) |
Stop an active NAT test.
tst | test to stop. |
Definition at line 554 of file gnunet-nat-auto_legacy.c.
References GNUNET_NAT_Test::ca_head, GNUNET_NAT_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_Test::lsock, GNUNET_NAT_Test::ltask, ClientActivity::mq, GNUNET_NAT_Test::na_head, GNUNET_NAT_Test::na_tail, GNUNET_NAT_Test::nat, NatActivity::rtask, NatActivity::sock, and GNUNET_NAT_Test::ttask.
Referenced by GNUNET_NAT_autoconfig_cancel(), and result_callback().