#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_nat_service.h"
#include "gnunet_nat_auto_service.h"
#include "nat-auto.h"
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_AUTO_Test |
Handle to a NAT test. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "nat-auto", __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, void **app_ctx, int add_remove, enum GNUNET_NAT_AddressClass ac, const struct sockaddr *addr, socklen_t addrlen) |
Address-callback, used to send message to gnunet-nat-server. More... | |
static void | do_fail (void *cls) |
Calls the report-callback reporting failure. More... | |
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... | |
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "nat-auto", __VA_ARGS__) |
Definition at line 31 of file nat_auto_api_test.c.
#define NAT_SERVER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
Definition at line 33 of file nat_auto_api_test.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 nat_auto_api_test.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_NAT_ERROR_SUCCESS, h, and LOG.
Referenced by GNUNET_NAT_AUTO_test_start().
|
static |
Activity on our incoming socket.
Read data from the incoming connection.
cls | the struct GNUNET_NAT_AUTO_Test |
Definition at line 212 of file nat_auto_api_test.c.
References data, GNUNET_NAT_AUTO_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_AUTO_Test::lsock, GNUNET_NAT_AUTO_Test::ltask, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_NAT_AUTO_Test::report, GNUNET_NAT_AUTO_Test::report_cls, tc, and GNUNET_SCHEDULER_TaskContext::write_ready.
Referenced by do_udp_read(), and GNUNET_NAT_AUTO_test_start().
|
static |
Activity on our incoming socket.
Read data from the incoming connection.
cls | the struct NatActivity |
Definition at line 247 of file nat_auto_api_test.c.
References data, GNUNET_NAT_AUTO_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_AUTO_Test::na_head, GNUNET_NAT_AUTO_Test::na_tail, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_NAT_AUTO_Test::report, GNUNET_NAT_AUTO_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_AUTO_Test |
Definition at line 284 of file nat_auto_api_test.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_AUTO_Test::lsock, GNUNET_NAT_AUTO_Test::ltask, GNUNET_NAT_AUTO_Test::na_head, GNUNET_NAT_AUTO_Test::na_tail, NatActivity::rtask, and NatActivity::sock.
Referenced by do_accept(), and GNUNET_NAT_AUTO_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 nat_auto_api_test.c.
References GNUNET_NAT_AUTO_Test::ca_head, GNUNET_NAT_AUTO_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 | |
[in,out] | app_ctx | location where the app can store stuff on add and retrieve it on remove |
add_remove | GNUNET_YES to mean the new public IP address, GNUNET_NO to mean the 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 345 of file nat_auto_api_test.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_AUTO_test_start().
|
static |
Calls the report-callback reporting failure.
Destroys the nat handle after the callback has been processed.
cls | handle to the timed out NAT test |
Definition at line 405 of file nat_auto_api_test.c.
References nh.
Referenced by GNUNET_NAT_AUTO_test_start().