Class ChannelData
TURN channel data: a channel number, a length, and the data, with four bytes of overhead instead of a Send or Data indication's thirty-six.
Inherited Members
Namespace: Uniform.Stun.Protocol
Assembly: Uniform.Stun.Protocol.dll
Syntax
public static class ChannelData
Fields
| Edit this page View SourceHeaderLength
Length of the header: channel number and data length.
Declaration
public const int HeaderLength = 4
Field Value
| Type | Description |
|---|---|
| int |
MaxChannel
The last channel number.
Declaration
public const ushort MaxChannel = 20479
Field Value
| Type | Description |
|---|---|
| ushort |
MinChannel
The first channel number.
Declaration
public const ushort MinChannel = 16384
Field Value
| Type | Description |
|---|---|
| ushort |
Methods
| Edit this page View SourceEncode(ushort, ReadOnlySpan<byte>, bool)
Return channel data for channel; over TCP and TLS, padded pads it to four bytes as streams need.
Declaration
public static byte[] Encode(ushort channel, ReadOnlySpan<byte> data, bool padded = false)
Parameters
| Type | Name | Description |
|---|---|---|
| ushort | channel | |
| ReadOnlySpan<byte> | data | |
| bool | padded |
Returns
| Type | Description |
|---|---|
| byte[] |
FrameLength(ReadOnlySpan<byte>)
Return the length of the STUN message or channel data at the start of a stream's bytes, padding included, or null when fewer than four bytes are there or they are neither.
Declaration
public static int? FrameLength(ReadOnlySpan<byte> stream)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | stream |
Returns
| Type | Description |
|---|---|
| int? |
Remarks
Over TCP and TLS, STUN messages and padded channel data follow each other; this frames them.
IsChannelData(ReadOnlySpan<byte>)
Return whether a datagram looks like channel data: its first byte is 64 to 79, as RFC 7983 tells it apart.
Declaration
public static bool IsChannelData(ReadOnlySpan<byte> datagram)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | datagram |
Returns
| Type | Description |
|---|---|
| bool |
IsValidChannel(ushort)
Return whether channel is a valid channel number.
Declaration
public static bool IsValidChannel(ushort channel)
Parameters
| Type | Name | Description |
|---|---|---|
| ushort | channel |
Returns
| Type | Description |
|---|---|
| bool |
TryParse(ReadOnlySpan<byte>, out ushort, out ReadOnlySpan<byte>)
Read channel data; return false when malformed or cut short.
Declaration
public static bool TryParse(ReadOnlySpan<byte> message, out ushort channel, out ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | message | The bytes, from a datagram or a stream. |
| ushort | channel | The channel number. |
| ReadOnlySpan<byte> | data | The data, without padding. |
Returns
| Type | Description |
|---|---|
| bool |