This code provides some support for doing STUN transactions. More...
#include "platform.h"
Go to the source code of this file.
Functions | |
int | GNUNET_NAT_stun_handle_packet_ (const void *data, size_t len, struct sockaddr_in *arg) |
Handle an incoming STUN response. More... | |
This code provides some support for doing STUN transactions.
We receive the simplest possible packet as the STUN server and try to respond properly.
All STUN packets start with a simple header made of a type, length (excluding the header) and a 16-byte random transaction id. Following the header we may have zero or more attributes, each structured as a type, length and a value (whose format depends on the type, but often contains addresses). Of course all fields are in network format.
This code was based on ministun.c.
Functions for STUN functionality
Definition in file gnunet-service-nat_stun.h.
int GNUNET_NAT_stun_handle_packet_ | ( | const void * | data, |
size_t | len, | ||
struct sockaddr_in * | arg | ||
) |
Handle an incoming STUN response.
Do some basic sanity checks on packet size and content, try to extract information. At the moment this only processes BIND requests, and returns the externally visible address of the original request.
data | the packet | |
len | the length of the packet in data | |
[out] | arg | sockaddr_in where we will set our discovered address |
Definition at line 126 of file gnunet-service-nat_stun.c.
References find_typedefs::arg, stun_attr::attr, data, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, stun_attr::len, LOG, stun_header::magic, stun_header::msglen, stun_header::msgtype, ret, st, stun_get_mapped(), STUN_MAGIC_COOKIE, and stun_msg2str().
Referenced by handle_stun().