Indy 9 | Content | Index | Reference

TDNSHeader
Hierarchy, Properties, Methods, Unit: IdDNSResolver
Represents the Header section in a DNS message packet.

    TDNSHeader = class

Unit
IdDNSResolver
Description
TDNSHeader is a TObject descendant that represents the Header section in a DNS message packet. A DNS message packet may contain 5 sections:

      +------------+
      |   Header   |
      +------------+
      |  Question  |  question for the name server
      +------------+
      |   Answer   |  resource records answering the question
      +------------+
      | Authority  |  resource records pointing toward an authority
      +------------+
      | Additional |  resource records holding additional information
      +------------+

TDNSHeader is always present in the message packet, and includes values that specify which of the remaining sections are present. TDNSHeader also provides properties specific to the header section or the entire message packet, including:

- ID - Identifier assigned to a DNS query.

- Qr - Query (0) or Response (1) flag.

- OpCode - Indicates the kind of query to be performed.

- AA - Indicates the responsing DNS server is an authority for the domain.

- TC - Indicates the message was truncated.

- RD - Indicates recurive queries are desired on the DNS server.

- RA - Indicates recurive queries are available on the DNS server.

- RCode - Response code from the DNS server.

- QDCount - Number of entries in the DNS Question section.

- ANCount - Number of resource records in the DNS Answer section.

- NSCount - Number of resource records in the DNS Authority section.

- ARCount - Number of resource records in the DNS Additional section.

TDNSHeader is used in the message packet for both a DNS query and a DNS response, although some values are only appropriate in one context.

TDNSHeader.AA
TDNSHeader
Indicates if the name server is an authority for the requested domain.

    property AA: Word;

Description
AA is a Word property that indicates if the responding Domain Name Server is an authority for the Domain name space in the question section of a DNS query.

AA is used in a DNS response that may contain multiple resource records in the answer section of the DNS response, and each resource record may have a different owner. AA corresponds to the name which matches the Omain name in the query, or the owner name for the first resource record in the answer section.

AA is represented in a DNS header as a bit flag. Changing the value of AA insures that the appropriate bit field is updated in the DNS header for the message packet.

TDNSHeader.ANCount
TDNSHeader
Number of resource records in the Answer section of a DNS response.

    property ANCount: Word;

Description
ANCount is a Word property that indicates the number of resource records found in the Answer section of a DNS response.

Use NSCount to determine the number of name server resource records in the DNS response.

Use ARCount to determine the number of additional resource records in in the DNS response.

TDNSHeader.ARCount
TDNSHeader
Number of resource records in the Additional section of a DNS response.

    property ARCount: Word;

Description
ARCount is a Word property that indicates the number of resource records found in the Additional section of a DNS response.

Use ANCount to determine the number of Answer resource records in the DNS response.

Use NSCount to determine the number of name server resource records in the DNS response.

TDNSHeader.BitCode
TDNSHeader
Represents temporary storage for bit fields used in the DNS header.

    property BitCode: Word;

Description
BitCode is a read-only Word property used to represent the individual bit fields that appear in the DNS header. BitCode acts as a temporary storage slot for bit field values.

BitCode is used when updating values for bit fields while creating the DNS query, and when reading the values from bit fields in the DNS response. BitCode is ANDed with the appropriate value to access a particular bit field in the DNS header.

Use ClearByteCode to reset the value of all bit fields in BitCode.

TDNSHeader.ID
TDNSHeader
Identifier assigned to match DNS query and response packets.

    property ID: Word;

Description
ID is a Word property that represents the 16-bit identifier assigned by the DNS Resolver to allow matching a response to the DNS query that generates the message packet. ID is copied from the DNS request to the corresponding reply and can be used by the requester to match up replies to outstanding queries.

The value in ID is assigned in the Create constructor, and contains a random value in the range 0 to 65535.

ID is read from the DNS Header returned in a DNS response packet, when the results are parsed after a call to TIdDNSResolver.Resolve.

TDNSHeader.NSCount
TDNSHeader
Number of resource records in the Authority section of a DNS response.

    property NSCount: Word;

Description
NSCount is a Word property that indicates the number of resource records found in the Authority section of a DNS response.

Use ARCount to determine the number of Additional resource records in the DNS response.

Use ANCount to determine the number of resource records in the Answer scetion of the DNS response.

TDNSHeader.OpCode
TDNSHeader
Indicates the kind of query to be performed on the DNS server.

    property OpCode: Word;

Description
OpCode is a Word property and contains an Integer value that specifies the kind of query in a DNS request packet. OpCode is specified in the DNS query, and returned in the DNS response. OpCode may contain one of the follwing values and meanings:

- 0 - A standard query (QUERY)

- 1 - An inverse query (IQUERY)

- 2 - A server status request (STATUS)

- 3 - Reserved for future use

- 4 - Reserved for future use

- 5 - Reserved for future use

- 6 - Reserved for future use

- 7 - Reserved for future use

- 8 - Reserved for future use

- 9 - Reserved for future use

- 10 - Reserved for future use

- 11 - Reserved for future use

- 12 - Reserved for future use

- 13 - Reserved for future use

- 14 - Reserved for future use

- 15 - Reserved for future use

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

- The DNS query type is limited to standard queries, where the DNS Header OpCode is 0. Inverse queries (OpCode=1) and Status queries (OpCode=2) are not supported at this time.

OpCode is represented in a DNS header as a 4-bit field. Changing the value of OpCode insures that the appropriate bit field is updated in the DNS header for the message packet.

TDNSHeader.QDCount
TDNSHeader
Number of Questions in the DNS message packet.

    property QDCount: Word;

Description
QDCount is a Word property that indicates the number of entries in the Question section of a DNS message packet. QDCount is calculated and included in the DNS query when the query is constructed after a call to TIdDNSResolver.Resolve. QDCount will indicate the numer of values assigned to TIdDNSResolver.QueryRecords.

QDCount is returned in the DNS response to indicate the number of Questions handled by the DNS server.

Use ANCount to determine the number of resource records returned in the Answer section of the DNS response.

Use NSCount to determine the number of name server resource records returned in the Authoruty section of the DNS response.

Use ARCount to determine the number of resource records returned in the Additional section of the DNS response.

TDNSHeader.Qr
TDNSHeader
Indicates if the DNS message packet contains a query or a response.

    property Qr: Word;

Description
Qr is a Word property that specifies if the contents of the DNS message packet contains a DNS query or DNS a response. Qr will contain the value 0 when the message is a query, and the value 1 when the message is a response.

Qr is represented in a DNS header as a bit field. Changing the value of Qr insures that the appropriate bit field is updated in the DNS header for the message packet.

TDNSHeader.RA
TDNSHeader
Indicates if recursive query support is available on a name server.

    property RA: Word;

Description
RA is a Word property that indicates if recursive query support is available on the DNS server responding to the DNS query. RA will contain the value 1 when recursive queries are availabale on the name server, or the value 0 when recursive queries are not supported or allowed for the DNS resolver.

Use RD to indicate if recursive query support is desired in a DNS request.

RA is represented in a DNS header as a bit field. Changing the value of RA insures that the appropriate bit field is updated in the DNS header for the message packet.

TDNSHeader.RCode
TDNSHeader
Result code returned in a DNS response.

    property RCode: Word;

Description
RCode is a Word property that represents the result code returned by a DNS server as part of a response to a DNS query. RCode may contain one of the following values and meanings:

- 0 - No error condition.

- 1 - Query Format error. The name server was unable to interpret the query.

- 2 - Server failure. The name server was unable to process this query due to a problem with the name server.

- 3 - Name Error. Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.

- 4 - Not Implemented. The name server does not support the requested kind of query.

- 5 - Operation Refused. The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.

- 6 - Reserved for future use.

- 7 - Reserved for future use.

- 8 - Reserved for future use.

- 9 - Reserved for future use.

- 10 - Reserved for future use.

- 11 - Reserved for future use.

- 12 - Reserved for future use.

- 13 - Reserved for future use.

- 14 - Reserved for future use.

- 15 - Reserved for future use.

RCode is represented in a DNS header as a 4-bit field. Changing the value of RCode insures that the appropriate bit field is updated in the DNS header for the message packet.

TDNSHeader.RD
TDNSHeader
Indicates if recursive query support is desired for DNS request.

    property RD: Word;

Description
RD is a Word property that indicates if recursive query support is desired on the DNS server responding to a DNS query. RD will contain the value 1 when recursive queries are desired on the name server, or the value 0 when recursive queries are not desired by the DNS resolver.

Use RA to detgermine if recursive query support is available on a DNS server issuing a response.

RD is represented in a DNS header as a bit field. Changing the value of RD insures that the appropriate bit field is updated in the DNS header for the message packet.

TDNSHeader.TC
TDNSHeader
Indicates if a DNS response message packet has been truncated due to excessive length.

    property TC: Word;

Description
TC is a Word property that indicates if a DNS response message packet has been truncated when the length of the message packet exceeds the maximum permitted on the transmission channel. TC will contain the value 1 when the mesaage packet has been truncated, or the value 0 when the packet contains the entire response issued by the name server.

Messages handled by the UDP-based DNS Resolver are restricted to 512 bytes (not counting the UDP headers). Longer messages are truncated and TC is set to 1 in the header. For this reason, the UDP-based TIdDNSResolver does not implement DNS zone transfers, but is the recommended method for standard queries in the Internet.

TC is represented in a DNS header as a bit field. Changing the value of TC insures that the appropriate bit field is updated in the DNS header for the message packet.

TDNSHeader.ClearByteCode
TDNSHeader
Resets the temporary storage for bit field in the DNS header.

    procedure ClearByteCode;

Description
ClearByteCode is a procedure that resets the temporary storage allocated for the bit fields in BitCode. ClearByteCode is used when the DNS resolver creates the DNS query used in TIdDNSResolver.Resolve.

Use BitCode to access the value for an individual bit field in the DNS Header.

TDNSHeader.Create
TDNSHeader, See Also
Constructor for the object instance.

    constructor Create;

Description
Create is the constructor for the object instance. Create calls the Randomize procedure to initialize the runtime random number generator with an arbitrary value prior to assigning the identifier used in ID.

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