View Source ExSTUN.Message.RawAttribute (ex_stun v0.1.0)
STUN Message Attribute
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Value (variable) ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 4: Format of STUN Attributes
Link to this section Summary
Functions
Encodes attribute to binary.
Link to this section Types
@type t() :: %ExSTUN.Message.RawAttribute{type: non_neg_integer(), value: binary()}
Link to this section Functions
Encodes attribute to binary.
This function adds padding to align attributes on 32 bit boundary.
example
Example
iex> attr = %ExSTUN.Message.RawAttribute{type: 0x8022, value: "my_ex_stun_client"}
iex> ExSTUN.Message.RawAttribute.encode(attr)
<<0x8022::16, 17::16, "my_ex_stun_client"::binary, 0, 0, 0>>