webrtc_turn_channel (webrtc v0.1.0)

View Source

TURN ChannelData framing (RFC 8656 §12.4).

A ChannelData message is a 4-byte header (channel number, length of the application data) followed by the data. Over UDP the padding to a multiple of four bytes is optional (§12.5); encode/2 always adds it and decode/1 accepts it, ignoring any trailing padding.

Summary

Functions

Decode a ChannelData message received over UDP. A datagram shorter than the claimed length, or a channel number outside the valid range (reserved values 0x5000-0xFFFF included), is rejected.

First byte in 64..79 (RFC 7983 as updated by RFC 9443).

True for channel numbers a client may bind (0x4000 to 0x4FFF).

Functions

decode(_)

-spec decode(binary()) ->
                {ok, 16384..20479, binary()} | {error, bad_channel | truncated | not_channel_data}.

Decode a ChannelData message received over UDP. A datagram shorter than the claimed length, or a channel number outside the valid range (reserved values 0x5000-0xFFFF included), is rejected.

encode(Channel, Data)

-spec encode(16384..20479, binary()) -> binary().

is_channel_data(_)

-spec is_channel_data(binary()) -> boolean().

First byte in 64..79 (RFC 7983 as updated by RFC 9443).

valid_number(N)

-spec valid_number(term()) -> boolean().

True for channel numbers a client may bind (0x4000 to 0x4FFF).