Table of Contents

Class DnsWireFormat

Namespace
AppleTvControlLibrary.Discovery.Dns
Assembly
AppleTvControlLibrary.Discovery.dll

Low-level encode/decode helpers for the DNS wire format used by DNS-SD.

public static class DnsWireFormat
Inheritance
DnsWireFormat
Inherited Members

Methods

ParseDomainName(DnsBufferReader)

Unpacks a domain name, handling DNS name compression (RFC 1035 sections 3.1, 4.1.4).

public static string ParseDomainName(DnsBufferReader buffer)

Parameters

buffer DnsBufferReader

The buffer to read from.

Returns

string

The decoded, dot-joined domain name.

ParseRData(QueryType, DnsBufferReader, int)

Parses the RDATA of a DNS resource record according to its type. Falls back to raw bytes for unhandled types.

public static object ParseRData(QueryType type, DnsBufferReader buffer, int length)

Parameters

type QueryType

The record type.

buffer DnsBufferReader

The buffer to read from.

length int

The RDATA length in bytes.

Returns

object

The decoded RDATA, whose runtime type depends on type.

ParseSrvRecord(DnsBufferReader)

Parses a DNS SRV record's RDATA.

public static SrvRecord ParseSrvRecord(DnsBufferReader buffer)

Parameters

buffer DnsBufferReader

The buffer to read from.

Returns

SrvRecord

The parsed priority, weight, port, and target.

ParseString(DnsBufferReader)

Unpacks a DNS character-string: a single length byte followed by data.

public static byte[] ParseString(DnsBufferReader buffer)

Parameters

buffer DnsBufferReader

The buffer to read from.

Returns

byte[]

The raw character-string bytes.

ParseTxtDict(DnsBufferReader, int)

Parses DNS-SD TXT records into a case-insensitive key/value map.

public static Dictionary<string, byte[]> ParseTxtDict(DnsBufferReader buffer, int length)

Parameters

buffer DnsBufferReader

The buffer to read from.

length int

The total byte length of the TXT record data.

Returns

Dictionary<string, byte[]>

The decoded properties, keyed case-insensitively.

QNameEncode(string)

Encodes a QNAME without using name compression. Labels are UTF-8 encoded, NFC normalized, truncated to 63 bytes without splitting multi-byte code points, and terminated with an empty root label.

public static byte[] QNameEncode(string name)

Parameters

name string

The dotted name, or a service instance name, to encode.

Returns

byte[]

The encoded QNAME bytes.