|unsigned int||id |
This code provides some support for doing STUN transactions. Eventually it should be moved elsewhere as other protocols than RTP can benefit from it - e.g. SIP. STUN is described in RFC3489 and it is based on the exchange of UDP packets between a client and one or more servers to determine the externally visible address (and port) of the client once it has gone through the NAT boxes that connect it to the outside. The simplest request packet is just the header defined in struct stun_header, and from the response we may just look at one attribute, STUN_MAPPED_ADDRESS, that we find in the response. By doing more transactions with different server addresses we may determine more about the behaviour of the NAT boxes, of course - the details are in the RFC.
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.