Expand description
The STUN message itself: header, attributes, and encoding. The STUN message: header, attributes, and encoding.
A Message is a class and method (MessageType), a 96-bit TransactionId, and a
list of attributes. Build one by applying Setters, read one back with Getters, and
move it across the wire with marshal/unmarshal.
Two attributes are special, because their value covers the encoded message: FINGERPRINT
and MESSAGE-INTEGRITY must be appended last and are validated through Checker. That is
why Message::raw is kept alongside the parsed attributes — those checks are computed over
it rather than over a re-encoding.
Structs§
- Message
- A STUN message: type, transaction id, and attributes, plus the encoded bytes.
- Message
Class - A STUN message class: request, indication, success response or error response.
- Message
Type - A message’s class and method together, as encoded in the first two header bytes.
- Method
- A STUN method, such as Binding or one of TURN’s.
- Transaction
Id - A 96-bit transaction id, which pairs a response with its request.
Constants§
- ATTRIBUTE_
HEADER_ SIZE - Bytes of type and length preceding each attribute value.
- BINDING_
ERROR - Binding error response message type.
- BINDING_
REQUEST - Common STUN message types. Binding request message type.
- BINDING_
SUCCESS - Binding success response message type.
- CLASS_
ERROR_ RESPONSE - 0b11.
- CLASS_
INDICATION - 0b01.
- CLASS_
REQUEST - Possible values for message class in STUN Message Type. 0b00.
- CLASS_
SUCCESS_ RESPONSE - 0b10.
- MAGIC_
COOKIE - Fixed value that aids in distinguishing STUN packets from packets of other protocols when STUN is multiplexed with those other protocols on the same Port.
- MESSAGE_
HEADER_ SIZE - Bytes in the STUN message header.
- METHOD_
ALLOCATE - TURN Allocate: asks a relay for a public address.
- METHOD_
BINDING - Possible methods for STUN Message.
- METHOD_
CHANNEL_ BIND - TURN ChannelBind: binds a channel number to a peer for compact framing.
- METHOD_
CONNECT - Methods from RFC 6062.
- METHOD_
CONNECTION_ ATTEMPT - TURN-TCP ConnectionAttempt: notifies the client of an inbound TCP connection.
- METHOD_
CONNECTION_ BIND - TURN-TCP ConnectionBind: associates a new TCP connection with an allocation.
- METHOD_
CREATE_ PERMISSION - TURN CreatePermission: authorizes traffic to and from a peer address.
- METHOD_
DATA - TURN Data: an indication carrying data from a peer through the relay.
- METHOD_
REFRESH - TURN Refresh: extends or releases an allocation.
- METHOD_
SEND - TURN Send: an indication carrying data to a peer through the relay.
- TRANSACTION_
ID_ SIZE - Length of transaction id array (in bytes). 96 bit.
Traits§
- Checker
- Checker checks *Message attribute.
- Getter
- Getter parses attribute from *Message.
- Setter
- Interfaces that are implemented by message attributes, shorthands for them, or helpers for message fields as type or transaction id.
Functions§
- is_
stun_ message - Is_stun_message returns true if b looks like STUN message. Useful for multiplexing. is_stun_message does not guarantee that decoding will be successful.