Show / Hide Table of Contents

Class WireWriter

Methods to write DNS wire formatted data items.

Inheritance
Object
WireWriter
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 WireWriter

Constructors

| Improve this Doc View Source

WireWriter(Stream)

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

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

The destination for data items.

Fields

| Improve this Doc View Source

Position

The writer relative position within the stream.

Declaration
public int Position
Field Value
Type Description
Int32

Properties

| Improve this Doc View Source

CanonicalForm

Determines if canonical records are produced.

Declaration
public bool CanonicalForm { get; set; }
Property Value
Type Description
Boolean

true to produce canonical records; otherwise false. Defaults to false.

Remarks

When enabled, the following rules are applied

  • Domain names are uncompressed
  • Domain names are converted to US-ASCII lowercase

See Also
https://tools.ietf.org/html/rfc4034#section-6.2

Methods

| Improve this Doc View Source

PopLengthPrefixedScope()

Start a length prefixed stream.

Declaration
public ushort PopLengthPrefixedScope()
Returns
Type Description
UInt16
Remarks

A memory stream is created for writing. When it is popped, the memory stream's position is writen as an UInt16 and its contents are copied to the current stream.

| Improve this Doc View Source

PushLengthPrefixedScope()

Start a length prefixed stream.

Declaration
public void PushLengthPrefixedScope()
Remarks

A memory stream is created for writing. When it is popped, the memory stream's position is writen as an UInt16 and its contents are copied to the current stream.

| Improve this Doc View Source

WriteBitmap(IEnumerable<UInt16>)

Write the bitmap(s) for the values.

Declaration
public void WriteBitmap(IEnumerable<ushort> values)
Parameters
Type Name Description
IEnumerable<UInt16> values

The sequence of values to encode into a bitmap.

| Improve this Doc View Source

WriteByte(Byte)

Write a byte.

Declaration
public void WriteByte(byte value)
Parameters
Type Name Description
Byte value
| Improve this Doc View Source

WriteByteLengthPrefixedBytes(Byte[])

Write a sequence of bytes prefixed with the length as a byte.

Declaration
public void WriteByteLengthPrefixedBytes(byte[] bytes)
Parameters
Type Name Description
Byte[] bytes

A sequence of bytes to write.

Exceptions
Type Condition
ArgumentException

When the length is greater than MaxValue.

| Improve this Doc View Source

WriteBytes(Byte[])

Write a sequence of bytes.

Declaration
public void WriteBytes(byte[] bytes)
Parameters
Type Name Description
Byte[] bytes

A sequence of bytes to write.

| Improve this Doc View Source

WriteDateTime32(DateTime)

Write a date/time.

Declaration
public void WriteDateTime32(DateTime value)
Parameters
Type Name Description
DateTime value

The DateTime in UTC to write.

Remarks

Write the value as the number seconds since the Unix epoch. The seconds is represented as 32-bit unsigned int

Exceptions
Type Condition
OverflowException

value seconds cannot be represented in 32 bits.

| Improve this Doc View Source

WriteDateTime48(DateTime)

Write a date/time.

Declaration
public void WriteDateTime48(DateTime value)
Parameters
Type Name Description
DateTime value

The DateTime in UTC to write.

Remarks

Write the value as the number seconds since the Unix epoch. The seconds is represented as 48-bit unsigned int

Exceptions
Type Condition
OverflowException

value seconds cannot be represented in 48 bits.

| Improve this Doc View Source

WriteDomainName(DomainName, Boolean)

Write a domain name.

Declaration
public void WriteDomainName(DomainName name, bool uncompressed = false)
Parameters
Type Name Description
DomainName name

The name to write.

Boolean uncompressed

Determines if the name must be uncompressed. The defaultl is false (allow compression). CanonicalForm overrides this value.

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 that this field may be an odd number of octets; no padding is used.

Exceptions
Type Condition
ArgumentException

When a label length is greater than 63 octets.

| Improve this Doc View Source

WriteDomainName(String, Boolean)

Write a domain name.

Declaration
public void WriteDomainName(string name, bool uncompressed = false)
Parameters
Type Name Description
String name

The name to write.

Boolean uncompressed

Determines if the name must be uncompressed. The defaultl is false (allow compression). CanonicalForm overrides this value.

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 that this field may be an odd number of octets; no padding is used.

Exceptions
Type Condition
ArgumentException

When a label length is greater than 63 octets.

| Improve this Doc View Source

WriteIPAddress(IPAddress)

Write an IP address.

Declaration
public void WriteIPAddress(IPAddress value)
Parameters
Type Name Description
IPAddress value
| Improve this Doc View Source

WriteString(String)

Write a string.

Declaration
public void WriteString(string value)
Parameters
Type Name Description
String value
Remarks

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

Exceptions
Type Condition
ArgumentException

When the length is greater than MaxValue or the string is not ASCII.

| Improve this Doc View Source

WriteTimeSpan16(TimeSpan)

Write a time span with 16-bits.

Declaration
public void WriteTimeSpan16(TimeSpan value)
Parameters
Type Name Description
TimeSpan value

The number of non-negative seconds.

Remarks

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

| Improve this Doc View Source

WriteTimeSpan32(TimeSpan)

Write a time span with 32-bits.

Declaration
public void WriteTimeSpan32(TimeSpan value)
Parameters
Type Name Description
TimeSpan value

The number of non-negative seconds.

Remarks

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

| Improve this Doc View Source

WriteUInt16(UInt16)

Write an unsigned short.

Declaration
public void WriteUInt16(ushort value)
Parameters
Type Name Description
UInt16 value
| Improve this Doc View Source

WriteUint16LengthPrefixedBytes(Byte[])

Write a sequence of bytes prefixed with the length as a unint16.

Declaration
public void WriteUint16LengthPrefixedBytes(byte[] bytes)
Parameters
Type Name Description
Byte[] bytes

A sequence of bytes to write.

Exceptions
Type Condition
ArgumentException

When the length is greater than MaxValue.

| Improve this Doc View Source

WriteUInt32(UInt32)

Write an unsigned int.

Declaration
public void WriteUInt32(uint value)
Parameters
Type Name Description
UInt32 value
| Improve this Doc View Source

WriteUInt48(UInt64)

Write an unsigned long in 48 bits.

Declaration
public void WriteUInt48(ulong value)
Parameters
Type Name Description
UInt64 value
  • Improve this Doc
  • View Source
Back to top Generated by DocFX