46#define LOG(kind, ...) GNUNET_log_from (kind, "stun", __VA_ARGS__)
48#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
106 return ((msg_class & 1) << 4) | ((msg_class & 2) << 7)
107 | (method & 0x000f) | ((method & 0x0070) << 1) | ((method & 0x0f800)
121 for (
unsigned int x = 0; x < 3; x++)
136 const struct sockaddr *
addr,
141 struct sockaddr_in server;
149 "Error resolving host %s\n",
169 memset (&server, 0,
sizeof(server));
170 server.sin_family = AF_INET;
171 server.sin_addr = ((
struct sockaddr_in *) addr)->sin_addr;
173#if HAVE_SOCKADDR_IN_SIN_LEN
174 server.sin_len = (u_char)
sizeof(
struct sockaddr_in);
188 (
const struct sockaddr *) &server,
static uint16_t port
Port number.
Functions related to doing DNS lookups.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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.
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.
@ GNUNET_NAT_ERROR_NOT_ONLINE
detected that we are offline
@ GNUNET_NAT_ERROR_SUCCESS
Just the default.
@ GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR
Failure in network subsystem, check permissions.
ssize_t GNUNET_NETWORK_socket_sendto(const struct GNUNET_NETWORK_Handle *desc, const void *message, size_t length, const struct sockaddr *dest_addr, socklen_t dest_len)
Send data to a particular destination (always non-blocking).
struct GNUNET_RESOLVER_RequestHandle * GNUNET_RESOLVER_ip_get(const char *hostname, int af, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, void *callback_cls)
Convert a string to one or more IP addresses.
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
static void stun_dns_callback(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Try to establish a connection given the specified address.
static int encode_message(enum StunClasses msg_class, enum StunMethods method)
Encode a class and method to a compatible STUN format.
static void generate_request_id(struct stun_header *req)
Fill the stun_header with a random request_id.
Message types for STUN server resolution.
#define STUN_MAGIC_COOKIE
StunClasses
STUN message classes.
Handle to a request given to the resolver.
int dns_success
Do we got a DNS resolution successfully?
GNUNET_NAT_TestCallback cb
Function to call when a error occurs.
struct GNUNET_RESOLVER_RequestHandle * dns_active
Handle to a pending DNS lookup request.
void * cb_cls
Closure for cb.
char * stun_server
Stun server address.
uint16_t stun_port
STUN port.
struct GNUNET_NETWORK_Handle * sock
Handle to the listen socket.
struct sockaddr * addr
Address we were bound to, or NULL.
socklen_t addrlen
Number of bytes in addr.
Handle to a request given to the resolver.