43 #define LOG(kind, ...) GNUNET_log_from (kind, "stun", __VA_ARGS__)
71 struct sockaddr_in *
arg)
74 struct sockaddr_in *sa = (
struct sockaddr_in *)
arg;
100 returned_addr = (
const struct stun_addr *) (attr + 1);
101 if (AF_INET != returned_addr->
family)
104 sa->sin_family = AF_INET;
105 sa->sin_port = returned_addr->
port ^ htons (ntohl (magic) >> 16);
106 sa->sin_addr.s_addr = returned_addr->
addr ^ magic;
127 struct sockaddr_in *
arg)
132 uint32_t advertised_message_size;
133 uint32_t message_magic_cookie;
143 "Packet too short to be a STUN packet\n");
152 advertised_message_size = ntohs (hdr->
msglen);
153 message_magic_cookie = ntohl (hdr->
magic);
158 "Invalid magic cookie for STUN packet\n");
163 "STUN Packet, msg %s (%04x), length: %d\n",
166 advertised_message_size);
167 if (advertised_message_size >
len)
170 "Scrambled STUN packet length (got %d, expecting %d)\n",
171 advertised_message_size,
175 len = advertised_message_size;
176 memset (&
st, 0,
sizeof(
st));
183 "Attribute too short (got %d, expecting %d)\n",
191 advertised_message_size = ntohs (
attr->len) +
sizeof(
struct stun_attr);
194 if (advertised_message_size >
len)
197 "Inconsistent attribute (length %d exceeds remaining msg len %d)\n",
198 advertised_message_size,
208 data += advertised_message_size;
209 len -= advertised_message_size;
static int ret
Return value of the commandline.
static struct GNUNET_SCHEDULER_Task * st
The shutdown task.
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
int GNUNET_NAT_stun_handle_packet_(const void *data, size_t len, struct sockaddr_in *arg)
Handle an incoming STUN response.
static int stun_get_mapped(struct StunState *st, const struct stun_attr *attr, uint32_t magic, struct sockaddr_in *arg)
Extract the STUN_MAPPED_ADDRESS from the stun response.
@ GNUNET_ERROR_TYPE_DEBUG
Message types for STUN server resolution.
#define STUN_MAGIC_COOKIE
@ STUN_MS_XOR_MAPPED_ADDRESS
@ STUN_XOR_MAPPED_ADDRESS
static const char * stun_msg2str(int msg)
Print a class and method from a STUN message.
Context for stun_get_mapped().
The format normally used for addresses carried by STUN messages.
uint8_t family
Address family, we expect AF_INET.
uint32_t addr
IPv4 address.
uint16_t port
Port number.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model