Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
DNSResolvers


NAME

DNSResolvers - general interface for the retrieval of DNS records

SYNOPSIS

TYPE Resolver = POINTER TO ResolverRec;
TYPE ResolverRec = RECORD (Services.ObjectRec) END;


TYPE IPv4AddressList = POINTER TO IPv4AddressListRec; TYPE IPv4AddressListRec = RECORD (Objects.ObjectRec) addr: IPv4Addresses.Address; next: IPv4AddressList; END;

TYPE IPv6AddressList = POINTER TO IPv6AddressListRec; TYPE IPv6AddressListRec = RECORD (Objects.ObjectRec) addr: IPv6Addresses.Address; next: IPv6AddressList; END;

TYPE HostnameList = POINTER TO HostnameListRec; TYPE HostnameListRec = RECORD (Objects.ObjectRec) hostname: DNSRecords.Name; next: HostnameList; END;

TYPE MXList = POINTER TO MXListRec; TYPE MXListRec = RECORD (Objects.ObjectRec) hostname: DNSRecords.Name; preference: INTEGER; next: MXList; END;

TYPE TXTList = POINTER TO TXTListRec; TYPE TXTListRec = RECORD (Objects.ObjectRec) text: DNSRecords.Name; next: TXTList; END;

TYPE GetRecordsProc = PROCEDURE(resolver: Resolver; hostname: ARRAY OF CHAR; rrtype: DNSRecords.RRType; trysuffixes: BOOLEAN; VAR records: DNSRecords.Record; errors: RelatedEvents.Object) : BOOLEAN; TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) getRecords: GetRecordsProc; END;

CONST corruptedRecords = 0; CONST errors = 1; TYPE ErrorCode = SHORTINT; (* corruptedRecords... *) TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: ErrorCode; domain: DNSRecords.Name; rrtype: DNSRecords.RRType; END; VAR errormsg: ARRAY errors OF Events.Message; VAR error: Events.EventType;

VAR std: Resolver; (* standard resolver *)

PROCEDURE Init(resolver: Resolver; if: Interface);

PROCEDURE GetRecords(resolver: Resolver; hostname: ARRAY OF CHAR; rrtype: DNSRecords.RRType; trysuffixes: BOOLEAN; VAR records: DNSRecords.Record; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE GetIPv4AddrByHost(resolver: Resolver; hostname: ARRAY OF CHAR; VAR addresses: IPv4AddressList; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE GetIPv6AddrByHost(resolver: Resolver; hostname: ARRAY OF CHAR; VAR addresses: IPv6AddressList; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE GetReverseRecords(resolver: Resolver; revname: ARRAY OF CHAR; VAR hosts: HostnameList; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE GetHostByIPv4Addr(resolver: Resolver; address: IPv4Addresses.Address; VAR hosts: HostnameList; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE GetHostByIPv6Addr(resolver: Resolver; address: IPv6Addresses.Address; VAR hosts: HostnameList; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE GetMXRecords(resolver: Resolver; domain: ARRAY OF CHAR; VAR mxrecords: MXList; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE GetTXTRecords(resolver: Resolver; domain: ARRAY OF CHAR; VAR txtrecords: TXTList; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE GetAttribute(resolver: Resolver; domain: ARRAY OF CHAR; attribute: ARRAY OF CHAR; VAR value: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN;

DESCRIPTION

DNSResolvers provide a general interface for DNS resolvers that are able to retrieve a set of records for a given resource record type and a domain name. Implementations are usually based on DNSRequests but are able to follow chains of CNAME records and have additional knowledge about DNS caches they can ask and are able to apply rewriting rules for domain names (e.g. appending the local domain name). In addition, DNSResolvers provides handy operations to extract the most common resource record types.

Standard implementations (one candidate is DNSStdResolvers) are expected to make their implementation available through std. Note, however, that this variable is initially NIL as no default implementation is provided by DNSResolvers.

Implementations are required to implement following interface procedure:

getRecords: PROCEDURE(resolver: Resolver; hostname: ARRAY OF CHAR; rrtype: DNSRecords.RRType; trysuffixes: BOOLEAN; VAR records: DNSRecords.Record; errors: RelatedEvents.Object) : BOOLEAN;
Retrieve all resource records of type rrtype out of the class DNSRecords.classIN for hostname, following chains of DNSRecords.cname references, if any. If trysuffixes is set to TRUE, the application of rewriting rules (e.g. appending the local domain name) is permitted. In case of failures, FALSE is to be returned, and error events are to be related to errors. On success, all retrieved records are to be returned as linear list in records. Note that the behaviour is not defined if CNAME records are in conflict to other resource records for the same domain name (see also RFC 1912, section 2.4).

GetRecords provides a direct access to the interface procedure.

GetIPv4AddrByHost and GetIPv6AddrByHost return all IPv4 and IPv6 addresses that are associated with hostname, respectively.

GetReverseRecords looks for PTR records associated with revname. As CNAME records are followed, classless delegations according to RFC 2317 are supported. The structure of the domain name revname depends on the address space to be used.

GetHostByIPv4Addr attempts to find the domain names associated with the given IPv4 address using GetReverseRecords with a corresponding revname of the ``in-addr.arpa'' domain according to RFC 1034. Likewise GetHostByIPv6Addr attempts to find the domain names for a given IPv6 address. This is at first attempted using the ``ip6.arpa'' domain according to RFC 3152 and, if this fails, using the ``ip6.int'' domain according to RFC 1886.

GetMXRecords returns all MX records associated with domain in no particular order.

GetTXTRecords returns all TXT records associated with domain in no particular order. Note that this operation presents all texts as flat list independent from their origin, be it from a separate record or be it from a text that is embedded among other texts within one record. GetAttribute supports the retrieval of attributes out of TXT records according to RFC 1464.

DIAGNOSTICS

DNSRecords passes all errors events of the underlying implementation to errors. Following errors lead to error events generated by DNSRecords itself:
corruptedRecords
One of the extraction operations of DNSRecords failed for one of the records returned by the implementation.

SEE ALSO

DNSRecords
structure of resource records
DNSStdResolvers
standard implementation of DNSResolvers

Edited by: borchert, last change: 2004/03/19, revision: 1.1, converted to HTML: 2004/03/19

Oberon || Library || Module Index || Search Engine || Definition || Module