Class WireWriter
Methods to write DNS wire formatted data items.
Inherited Members
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.dll
Syntax
public class WireWriter
Constructors
| Improve this Doc View SourceWireWriter(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 SourcePosition
The writer relative position within the stream.
Declaration
public int Position
Field Value
Type | Description |
---|---|
Int32 |
Properties
| Improve this Doc View SourceCanonicalForm
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
Methods
| Improve this Doc View SourcePopLengthPrefixedScope()
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.
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.
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. |
WriteByte(Byte)
Write a byte.
Declaration
public void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
Byte | value |
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. |
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. |
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 |
|
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 |
|
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 |
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. |
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 |
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. |
WriteIPAddress(IPAddress)
Write an IP address.
Declaration
public void WriteIPAddress(IPAddress value)
Parameters
Type | Name | Description |
---|---|---|
IPAddress | value |
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. |
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.
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.
WriteUInt16(UInt16)
Write an unsigned short.
Declaration
public void WriteUInt16(ushort value)
Parameters
Type | Name | Description |
---|---|---|
UInt16 | value |
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. |
WriteUInt32(UInt32)
Write an unsigned int.
Declaration
public void WriteUInt32(uint value)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | value |
WriteUInt48(UInt64)
Write an unsigned long in 48 bits.
Declaration
public void WriteUInt48(ulong value)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | value |