Class ResourceRecord
Contains some information on the named resource.
Inheritance
Inherited Members
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.dll
Syntax
public class ResourceRecord : DnsObject, IWireSerialiser, ICloneable, IPresentationSerialiser
Remarks
The ResourceRegistry contains the metadata on known resource records. When reading, if the registry does not contain the record, then an UnknownRecord is used.
Fields
| Improve this Doc View SourceDefaultHostTTL
The default time interval that a resource record containing a host name maybe cached.
Declaration
public static TimeSpan DefaultHostTTL
Field Value
Type | Description |
---|---|
TimeSpan | Defaults to 1 day. |
Remarks
Host names are in A, AAAA, and HINFO records.
DefaultTTL
The default time interval that a resource record maybe cached.
Declaration
public static TimeSpan DefaultTTL
Field Value
Type | Description |
---|---|
TimeSpan | Defaults to 1 day. |
Properties
| Improve this Doc View SourceCanonicalName
The canonical form of the owner name.
Declaration
public string CanonicalName { get; }
Property Value
Type | Description |
---|---|
String |
Remarks
All uppercase US-ASCII letters in the Name are replaced by the corresponding lowercase US-ASCII letters.
Class
One of the RR CLASS codes.
Declaration
public DnsClass Class { get; set; }
Property Value
Type | Description |
---|---|
DnsClass | Defaults to IN. |
Name
An owner name, i.e., the name of the node to which this resource record pertains.
Declaration
public DomainName Name { get; set; }
Property Value
Type | Description |
---|---|
DomainName |
TTL
Specifies the time interval that the resource record may be cached before the source of the information should again be consulted.
Declaration
public TimeSpan TTL { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan | The resolution is 1 second. Defaults to 1 day. |
Remarks
Zero values are interpreted to mean that the RR can only be used for the transaction in progress, and should not be cached.
See Also
| Improve this Doc View SourceType
One of the RR TYPE codes.
Declaration
public DnsType Type { get; set; }
Property Value
Type | Description |
---|---|
DnsType |
Methods
| Improve this Doc View SourceEquals(Object)
Determines if the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the specified object is equal to the current object; otherwise, false. |
Overrides
Remarks
Two Resource Records are considered equal if their Name, Class, Type and GetData() are equal. Note that the TTL field is explicitly excluded from the comparison.
GetData()
The resource specific data.
Declaration
public byte[] GetData()
Returns
Type | Description |
---|---|
Byte[] | A byte array, never null. |
Remarks
This is referred to as the RDATA
in the DNS spec.
GetDataLength()
The length of the resource specific data.
Declaration
public int GetDataLength()
Returns
Type | Description |
---|---|
Int32 | Number of bytes to represent the resource specific data. |
Remarks
This is referred to as the RDLENGTH
in the DNS spec.
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceIsExpired(Nullable<DateTime>)
Determines if the TTL has expired.
Declaration
public bool IsExpired(DateTime? from = default(DateTime? ))
Parameters
Type | Name | Description |
---|---|---|
Nullable<DateTime> | from | The time to compare against. If null, the default value, then Now is used. |
Returns
Type | Description |
---|---|
Boolean | true if the resource is no longer valid; otherwise false. |
Read(PresentationReader)
Reads the text representation of a resource record.
Declaration
public ResourceRecord Read(PresentationReader reader)
Parameters
Type | Name | Description |
---|---|---|
PresentationReader | reader | The source of the ResourceRecord. |
Returns
Type | Description |
---|---|
ResourceRecord | The final resource record. |
Remarks
Reading a ResourceRecord will return a new instance that is type specific
Read(WireReader)
Reads the DNS object that is encoded in the wire format.
Declaration
public override IWireSerialiser Read(WireReader reader)
Parameters
Type | Name | Description |
---|---|---|
WireReader | reader | The source of the DNS object. |
Returns
Type | Description |
---|---|
IWireSerialiser | The final DNS object. |
Overrides
Remarks
Reading a ResourceRecord will return a new instance that is type specific unless the GetDataLength() is zero.
Read(String)
Create a new ResourceRecord from the specified string.
Declaration
public ResourceRecord Read(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The presentation format. |
Returns
Type | Description |
---|---|
ResourceRecord |
ReadData(PresentationReader)
Read the textual representation of the data that is specific to the resource record Type.
Declaration
public virtual void ReadData(PresentationReader reader)
Parameters
Type | Name | Description |
---|---|---|
PresentationReader | reader | The source of the resource record's data. |
Remarks
Derived classes must implement this method.
ReadData(WireReader, Int32)
Read the data that is specific to the resource record Type.
Declaration
public virtual void ReadData(WireReader reader, int length)
Parameters
Type | Name | Description |
---|---|---|
WireReader | reader | The source of the resource record's data. |
Int32 | length | The length, in bytes, of the data. |
Remarks
Derived classes must implement this method.
ToString()
Returns the textual representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The presentation format of this resource record. |
Overrides
| Improve this Doc View SourceWrite(PresentationWriter)
Writes the text representation of a resource record.
Declaration
public void Write(PresentationWriter writer)
Parameters
Type | Name | Description |
---|---|---|
PresentationWriter | writer | The destination of the ResourceRecord. |
Write(WireWriter)
Writes the DNS object encoded in the wire format.
Declaration
public override void Write(WireWriter writer)
Parameters
Type | Name | Description |
---|---|---|
WireWriter | writer | The destination of the DNS object. |
Overrides
| Improve this Doc View SourceWriteData(PresentationWriter)
Write the textual representation of the data that is specific to the resource record.
Declaration
public virtual void WriteData(PresentationWriter writer)
Parameters
Type | Name | Description |
---|---|---|
PresentationWriter | writer | The destination for the resource record's data. |
Remarks
Derived classes should implement this method.
By default, this will write the hex encoding of the GetData() preceeded by "#" and the number integer bytes.
WriteData(WireWriter)
Write the data that is specific to the resource record Type.
Declaration
public virtual void WriteData(WireWriter writer)
Parameters
Type | Name | Description |
---|---|---|
WireWriter | writer | The destination for the DNS object's data. |
Remarks
Derived classes must implement this method.
Operators
| Improve this Doc View SourceEquality(ResourceRecord, ResourceRecord)
Value equality.
Declaration
public static bool operator ==(ResourceRecord a, ResourceRecord b)
Parameters
Type | Name | Description |
---|---|---|
ResourceRecord | a | |
ResourceRecord | b |
Returns
Type | Description |
---|---|
Boolean |
Remarks
Two Resource Records are considered equal if their Name, Class, Type and data fields are equal. Note that the TTL field is explicitly excluded from the comparison.
Inequality(ResourceRecord, ResourceRecord)
Value inequality.
Declaration
public static bool operator !=(ResourceRecord a, ResourceRecord b)
Parameters
Type | Name | Description |
---|---|---|
ResourceRecord | a | |
ResourceRecord | b |
Returns
Type | Description |
---|---|
Boolean |
Remarks
Two Resource Records are considered equal if their Name, Class, Type and data fields are equal. Note that the TTL field is explicitly excluded from the comparison.