Indy 9
TResultRecord
Hierarchy, Properties, Methods, See Also, Unit: IdDNSResolver
Collection item used to represent resource records returned by a DNS query.
TResultRecord = class(TCollectionItem)
Unit
IdDNSResolver
Description
TResultRecord is a TCollectionItem descendant that represents resource records returned in the results for a DNS query. TResultRecord contains data associated with names, aliases, and internet addresses in the tree-structured Domain Name Space.

Resource records are returned in the Answer, Authority, and Additional sections of a DNS response, and they all share the same format: a variable number of resource records, where the number of records is specified in the corresponding count field in the header.

A resource record has the following format:

  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                                               |
  .                                               .
  .                      NAME                     .
  .                                               .
  |                                               |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                      TYPE                     |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                     CLASS                     |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                      TTL                      |
  |                                               |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                    RDLENGTH                   |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
  .                                               .
  .                     RDATA                     .
  .                                               .
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

  • NAME - Domain name to which this resource record pertains.

  • TYPE - Two octets containing one of the encoded resource record type codes. TYPE specifies the meaning of the data in the RDATA field.

  • CLASS - Two octets which specify the class of the data in the RDATA field.

  • TTL - 32-bit unsigned integer that specifies the time interval (in seconds) that the resource record may be cached before it should be discarded. Zero values are interpreted to mean that the resource record can only be used for the transaction in progress, and should not be cached.

  • RDLENGTH - 16-bit unsigned integer that specifies the length in octets of the RDATA field.

  • RDATA - A variable length string of octets that describes the resource. The format of this information varies according to the TYPE and CLASS of the resource record. For example, the if the TYPE is A and the CLASS is IN, the RDATA field is a 4 octet ARPA Internet address.

TResultRecord provides properties that represent the values found in a resource record, including the resource record type, resource class, Time-To-Live, data for the resource record, and the length of data in the resource record.

TResultRecord also provides methods to handle parsing of raw data from a DNS query response, and storing the resulting values in properties for the object instance.

TResultRecord is also an ancestor class for other resource record types such as TARecord, TCNRecord, THINFORecord, TMINFORecord, TMXRecord, TNAMERecord, TNSRecord, TPTRRecord, TRDATARecord, TSOARecord, TTextRecord, and TWKSRecord. These descendant classes provide additional properties used for labels in the RDATA field that are specific to the resource class and resource record type.

TResultRecord is the type used to represent collection items maintained in the TQueryResult collection, and the item class returned when accessing the resource records returned by a DNS query in TIdDNSResolver.QueryResult.Items.


TResultRecord.Name
TResultRecord
Represents the domain name that is the owner of the resource record.
property Name: string;
Description
Name is a read-only String property that represents the domain name that is the owner of the resource record. Name is often implied, rather than forming an integral part of the resource record.

Many name servers internally form tree or hash structures for the domain name space, and link resource records to these nodes. The remaining resource record values are the fixed header (RecType, RecClass, and TTL) which is consistent for all resource records. Variable data that describes the resource record is attached to the RData property.


TResultRecord.RData
TResultRecord
Represents class-dependent data which describes the resource record.
property RData: String;
Description
RData is a read-only String property that represents class-dependent data which describes the resource record. RData can contain differing values based on the resource record type or class.

RData is often used to provide the raw data used for property values in TResultRecord decendant classes like TRDATARecord and TWKSRecord. Values in RData frequently contain "pointers" to other data in the Domain Name Space. Other TResultRecord descendants will use RData to populate properties, including the following resource record types and usages:

  • TARecord - For the IN class, a 32 bit IP address. For the CH class, a domain name followed by a 16 bit octal Chaos address.

  • TCNRecord - A domain name.

  • TMXRecord- A 16-bit preference value (where a lower number indicates a higher perference) followed by a host name willing to act as a mail exchange for the owner domain.

  • TNSRecord - A host name.

  • TPTRRecord - A domain name.

  • TSOARecord - Multiple field values.

TResultRecord.RDataLength
TResultRecord
Indicates the length of RData in the resource record.
property RDataLength: Integer;
Description
RDataLength is a read-only Integer property that indicates the length of RDATA values for a resource record read in a DNS query response. RDataLength is updated when the resource record is parsed from the DNS response packet, and added to TQueryResult in TIdDNSResolver.Resolve.

TResultRecord.RecClass
TResultRecord
Represents the encoded resource class for the resource record.
property RecClass: word;
Description
RecClass is a read-only Word property that represents the two byte protocol family or instance of a protocol for the resource record encoded as a 16-bit value. The DNS protocol specifies the following unencoded values for the property:

  • IN - The Internet system

  • CH - The CHAOS system

  • CS - CSNet (Obsolete)

  • HS - Hesoid

Note: Currently, the TIdDNSResolver implementation does not support all aspects of the DNS protocol, and includes the following limitations:

  • The DNS query class field is limited to examining resource records for the IN (Internet) class only. CS (CSNet), CH (CHAOS), and HS (Hesiod) are not supported at this time.

RecClass is updated when resource records are parsed, and added to TQueryResult from the TIdDNSResolver.Resolve method.


TResultRecord.RecType
TResultRecord
Represents the type for a resource record read in a DNS query response.
property RecType: TQueryRecordTypes;
Description
RecType is a read-only TQueryRecordTypes property that represents the type for a resource record read in a DNS query response. Like RecClass, RecType is an encoded 16-bit value that specifies the type of the resource record as defined in QueryRecordValues.

RecType will normally contain one of the TQueryRecordTypes values specified in TIdDNSResolver.QueryRecords prior to calling TIdDNSResolver.Resolve.

RecType may contain one of the following values and associated meanings for the resource record type:

  • 1 - Host address

  • 2 - Authoritative name server

  • 3 - Mail destination (Obsolete - use MX)

  • 4 - Mail forwarder (Obsolete - use MX)

  • 5 - Canonical name for an alias

  • 6 - Start of a zone of authority marker

  • 7 - Mailbox domain name (EXPERIMENTAL)

  • 8 - Mail group member (EXPERIMENTAL)

  • 9 - Mail rename domain name (EXPERIMENTAL)

  • 10 - Null resource record (EXPERIMENTAL)

  • 11 - Well known service description

  • 12 - Domain name pointer

  • 13 - Host information

  • 14 - Mailbox or mail list information

  • 15 - Mail exchange

  • 16 - Text strings

  • 255 - All resource record types

RecType is updated when TQueryResult.Add is used to create a resource record read from a DNS response in TIdDNSResolver.Resolve.


TResultRecord.TTL
TResultRecord
Indicates the Time-To-Live for the resource record.
property TTL: cardinal;
Description
TTL is a read-only Cardinal property that indicates the Time-To-Live for the resource record. TTL represents a time limit that is the number of seconds that a resource record is considered valid in the cache for a TIdDNSResolver object instance.

TTL does not apply to authoritative data in a DNS zone, but can timeout by use of refreshing policies for the zone. TTL is assigned by the administrator for the zone where the data originates.

While short TTLs can be used to minimize caching, and a zero TTL prohibits caching, the realities of Internet performance suggest that these times should be on the order of days for the typical host. If a change can be anticipated, the TTL can be reduced on the DNS server prior to the change to minimize inconsistency during the change, and then increased back to its former value following the change.


TResultRecord.Destroy
TResultRecord, See Also
Frees the object instance.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance. Destroy calls the inherited Destroy method prior to exit.

TResultRecord.Parse
TResultRecord
Parses the raw data for a resource record from a DNS response.
procedure Parse(CompleteMessage: String; APos: Integer); virtual;
Parameters
CompleteMessage: String
Raw data for the resource record from a DNS Answer.
APos: Integer
Integer position where data values begin in the DNS response (One-based).
Description
Parse is a virtual procedure that allows the collection item to perform parsing required to extract property values from the raw data for the resource record, as specified in CompleteMessage.

APos is the one-based integer position where data for the resource record can be located in the values specified in CompleteMessage.

Parse is not implemented in TResultRecord, and should be overridden in TResultRecord descendant classes to perform parsing specific to the content for the resource record type.

Parse is used by TIdDNSResolver when resolving a DNS query, and parsing the answer values returned in the DNS response.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.