Show / Hide Table of Contents

Class WireReader

Methods to read DNS wire formatted data items.

Inheritance
Object
WireReader
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.dll
Syntax
public class WireReader

Constructors

| Improve this Doc View Source

WireReader(Stream)

Creates a new instance of the WireReader on the specified Stream.

Declaration
public WireReader(Stream stream)
Parameters
Type Name Description
Stream stream

The source for data items.

Fields

| Improve this Doc View Source

Position

The reader relative position within the stream.

Declaration
public int Position
Field Value
Type Description
Int32

Methods

| Improve this Doc View Source

ReadBitmap()

Reads a bitmap.

Declaration
public List<ushort> ReadBitmap()
Returns
Type Description
List<UInt16>

The sequence of values encoded by the bitmap.

Remarks

https://tools.ietf.org/html/rfc3845#section-2.1.2 for the encoding details.

| Improve this Doc View Source

ReadByte()

Read a byte.

Declaration
public byte ReadByte()
Returns
Type Description
Byte

The next byte in the stream.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadByteLengthPrefixedBytes()

Read the bytes with a byte length prefix.

Declaration
public byte[] ReadByteLengthPrefixedBytes()
Returns
Type Description
Byte[]

The next N bytes.

| Improve this Doc View Source

ReadBytes(Int32)

Read the specified number of bytes.

Declaration
public byte[] ReadBytes(int length)
Parameters
Type Name Description
Int32 length

The number of bytes to read.

Returns
Type Description
Byte[]

The next length bytes in the stream.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadDateTime32()

Read a DateTime that is represented in seconds (32 bits) from the Unix epoch.

Declaration
public DateTime ReadDateTime32()
Returns
Type Description
DateTime

A DateTime in Utc.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadDateTime48()

Read a DateTime that is represented in seconds (48 bits) from the Unix epoch.

Declaration
public DateTime ReadDateTime48()
Returns
Type Description
DateTime

A DateTime in Utc.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadDomainName()

Read a domain name.

Declaration
public DomainName ReadDomainName()
Returns
Type Description
DomainName

The domain name.

Remarks

A domain name is represented as a sequence of labels, where each label consists of a length octet followed by that number of octets. The domain name terminates with the zero length octet for the null label of the root.

note

Compressed domain names are also supported.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

InvalidDataException

Only ASCII characters are allowed.

| Improve this Doc View Source

ReadIPAddress(Int32)

Read an Internet address.

Declaration
public IPAddress ReadIPAddress(int length = 4)
Parameters
Type Name Description
Int32 length
Returns
Type Description
IPAddress

An IPAddress.

Remarks

Use a length of 4 to read an IPv4 address and 16 to read an IPv6 address.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadString()

Read a string.

Declaration
public string ReadString()
Returns
Type Description
String

The string.

Remarks

Strings are encoded with a length prefixed byte. All strings are ASCII.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

InvalidDataException

Only ASCII characters are allowed.

| Improve this Doc View Source

ReadTimeSpan16()

Read a time span (interval) with 16-bits.

Declaration
public TimeSpan ReadTimeSpan16()
Returns
Type Description
TimeSpan

A TimeSpan with second resolution.

Remarks

The interval is represented as the number of seconds in two bytes.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadTimeSpan32()

Read a time span (interval) with 32-bits.

Declaration
public TimeSpan ReadTimeSpan32()
Returns
Type Description
TimeSpan

A TimeSpan with second resolution.

Remarks

The interval is represented as the number of seconds in four bytes.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadUInt16()

Read an unsigned short.

Declaration
public ushort ReadUInt16()
Returns
Type Description
UInt16

The two byte little-endian value as an unsigned short.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadUInt16LengthPrefixedBytes()

Read the bytes with an uint16 length prefix.

Declaration
public byte[] ReadUInt16LengthPrefixedBytes()
Returns
Type Description
Byte[]

The next N bytes.

| Improve this Doc View Source

ReadUInt32()

Read an unsigned int.

Declaration
public uint ReadUInt32()
Returns
Type Description
UInt32

The four byte little-endian value as an unsigned int.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

| Improve this Doc View Source

ReadUInt48()

Read an unsigned long from 48 bits.

Declaration
public ulong ReadUInt48()
Returns
Type Description
UInt64

The six byte little-endian value as an unsigned long.

Exceptions
Type Condition
EndOfStreamException

When no more data is available.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX