Oberon || Library || Module Index || Search Engine || Definition || Module
(* non-obsolete record types from RFC 1035, 3.2.2 *) CONST a = 1; ns = 2; cname = 5; CONST soa = 6; ptr = 12; mx = 15; CONST txt = 16; CONST loc = 29; (* RFC 1876 *) CONST aaaa = 28; (* RFC 1886 *) CONST sig = 24; key = 25; nxt = 30; (* RFC 2065 *) CONST srv = 33; (* RFC 2782 *) CONST naptr = 35; (* RFC 2915 *) (* QTYPE values = RFC 1035 = 3.2.3 *) CONST axfr = 252; all = 255; TYPE RRType = Types.Int32; (* unsigned 2-byte integer, a .. all *) TYPE RRName = ARRAY 8 OF CHAR; VAR rrName: ARRAY 256 OF RRName;
(* classes according to RFC 1035, section 3.2.4 *) CONST classIN = 1; (* the Internet *) CONST classCS = 2; (* obsolete CSNET class *) CONST classCH = 3; (* the CHAOS class *) CONST classHS = 4; (* Hesiod *) CONST classNone = 254; (* RFC 2136 *) CONST classAny = 255; (* any class *) TYPE Class = Types.Int32; TYPE ClassName = ARRAY 8 OF CHAR; VAR className: ARRAY 256 OF ClassName;
CONST namelen = 512; TYPE Name = ARRAY namelen OF CHAR; (* qualified DNS names *)
TYPE Record = POINTER TO RecordRec; RecordRec = RECORD (Objects.ObjectRec) next: Record; name: Name; type: RRType; class: Class; ttl: Types.Int32; rdata: Streams.Stream; (* data of this record *) pdata: Streams.Stream; (* entire response packet *) rpos: Streams.Count; (* position of rdata within pdata *) END;
TYPE ListOfTextRecords = POINTER TO ListOfTextRecordsRec; TYPE ListOfTextRecordsRec = RECORD (Objects.ObjectRec) text: Name; next: ListOfTextRecords; END;
PROCEDURE ReadQuestion(s: Streams.Stream; VAR name: ARRAY OF CHAR; VAR type: RRType; VAR class: Class) : BOOLEAN; PROCEDURE WriteQuestion(s: Streams.Stream; name: ARRAY OF CHAR; type: RRType; class: Class) : BOOLEAN;
PROCEDURE ReadRecord(s: Streams.Stream; VAR name: ARRAY OF CHAR; VAR type: RRType; VAR class: Class; VAR ttl: Types.Int32; VAR rdata: Streams.Stream; VAR rpos: Streams.Count) : BOOLEAN; PROCEDURE WriteRecord(s: Streams.Stream; name: ARRAY OF CHAR; type: RRType; class: Class; ttl: Types.Int32; rdata: Streams.Stream) : BOOLEAN;
PROCEDURE ReadRecords(s: Streams.Stream; count: INTEGER; packetlen: Streams.Count; VAR records: Record) : BOOLEAN;
PROCEDURE ReadName(s: Streams.Stream; VAR name: ARRAY OF CHAR) : BOOLEAN; PROCEDURE WriteName(s: Streams.Stream; name: ARRAY OF CHAR) : BOOLEAN;
PROCEDURE ExtractName(record: Record; VAR name: ARRAY OF CHAR) : BOOLEAN; PROCEDURE ExtractA(record: Record; VAR ipaddr: IPv4Addresses.Address) : BOOLEAN; PROCEDURE ExtractAAAA(record: Record; VAR ipaddr: IPv6Addresses.Address) : BOOLEAN; PROCEDURE ExtractMX(record: Record; VAR preference: INTEGER; VAR name: ARRAY OF CHAR) : BOOLEAN; PROCEDURE ExtractTXT(record: Record; VAR list: ListOfTextRecords) : BOOLEAN; PROCEDURE ExtractSOA(record: Record; VAR mname: ARRAY OF CHAR; VAR rname: ARRAY OF CHAR; VAR serial: Types.Int32; VAR refresh: Types.Int32; VAR retry: Types.Int32; VAR expire: Types.Int32; VAR minimum: Types.Int32) : BOOLEAN;
PROCEDURE WriteA(s: Streams.Stream; ipaddr: IPv4Addresses.Address) : BOOLEAN; PROCEDURE WriteAAAA(s: Streams.Stream; ipaddr: IPv6Addresses.Address) : BOOLEAN; PROCEDURE WriteMX(s: Streams.Stream; preference: INTEGER; name: ARRAY OF CHAR) : BOOLEAN; PROCEDURE WriteTXT(s: Streams.Stream; list: ListOfTextRecords) : BOOLEAN; PROCEDURE WriteSOA(s: Streams.Stream; mname: ARRAY OF CHAR; rname: ARRAY OF CHAR; serial: Types.Int32; refresh: Types.Int32; retry: Types.Int32; expire: Types.Int32; minimum: Types.Int32) : BOOLEAN;
ReadQuestion and WriteQuestion read or write a single question record from or to s. Note that the actual number of question records is reflected by the QR value within the header, see DNSHeaders.
ReadRecord and WriteRecord read or write a single resource record from or to s. The stream rdata that is returned by ReadRecord is a substream (see SubStreams) of s. Note that rdata does not necessarily cover the entire record if compression is used as it might contain pointers to other parts of the DNS packet.
ReadRecords allows to read an entire section of resource records from s which is returned as a linear list. The returned records have following additional fields:
Names can be read or written using ReadName and WriteName. ReadName supports the compression format but WriteName does not attempt to compress names.
The extraction of some popular records is supported. ExtractName extracts compressed names for all record types that consist of a name only like PTR, CNAME, or NS records. ExtractA, ExtractAAAA, ExtractMX, ExtractTXT, and ExtractSOA extract the corresponding resource records. Note that in case of ExtractTXT multiple texts can be present within one resource record.
rrName and className provide the printable names for all resource record types and all classes. Unused (or yet unknown) values are represented as decimal numbers.
Likewise, the generation of popular records is supported by WriteA, WriteAAAA, WriteMX, WriteTXT, and WriteSOA.
Oberon || Library || Module Index || Search Engine || Definition || Module