std/dns/codes
std/dns/src/codes.trb
The numbers of the DNS as closed sets: RecordType, RecordClass, Operation and ResponseCode. Each has a case
for every code this package knows and Other(code) for the rest, and each compares by its code, so
RecordType.Other(1) == RecordType.A - a number read from the wire and a case written in a program are one value.
type RecordType
type RecordType with Show, Equals, Hash
The type of a record, or of the records a question asks for (RFC 1035 section 3.2.2, and the registry of IANA's "Resource Record (RR) TYPEs" for the later ones).
Examples
print RecordType.of(28)
print RecordType.Https.code()
case A
case A
An IPv4 address, 1.
case Ns
case Ns
An authoritative name server, 2.
case Cname
case Cname
The canonical name of an alias, 5.
case Soa
case Soa
The start of a zone of authority, 6.
case Ptr
case Ptr
A pointer to another name, 12: the reverse lookup of an address.
case Mx
case Mx
A mail exchange, 15.
case Txt
case Txt
Text strings, 16.
case Aaaa
case Aaaa
An IPv6 address, 28 (RFC 3596).
case Srv
case Srv
The location of a service, 33 (RFC 2782).
case Opt
case Opt
The EDNS0 pseudo-record, 41 (RFC 6891).
case Svcb
case Svcb
A service binding, 64 (RFC 9460).
case Https
case Https
A service binding for HTTPS, 65 (RFC 9460).
case Any
case Any
Every record of a name, 255: a question only.
case Caa
case Caa
A certification authority authorization, 257 (RFC 8659).
case Other
case Other(code: Int)
Any other type, by its number from 0 to 65535.
fn of
static fn of(code: Int): Self
The type of the number code, a named case where there is one. Taken modulo 65536.
fn code
fn code(): Int
The number on the wire.
fn show
fn show(): String
The mnemonic of a zone file: AAAA, HTTPS, and TYPE65280 for a type without one (RFC 3597 section 5).
fn equals
fn equals(other: RecordType): Bool
By the code.
fn hash
fn hash(): Int
Not documented.
type RecordClass
type RecordClass with Show, Equals, Hash
The class of a record (RFC 1035 section 3.2.4). Everything on the Internet is Internet.
case Internet
case Internet
IN, 1.
case Chaos
case Chaos
CH, 3: Chaosnet, still used for version.bind.
case Hesiod
case Hesiod
HS, 4: Hesiod.
case Any
case Any
ANY, 255: a question only.
case Other
case Other(code: Int)
Any other class, by its number from 0 to 65535.
fn of
static fn of(code: Int): Self
The class of the number code, a named case where there is one. Taken modulo 65536.
fn code
fn code(): Int
The number on the wire.
fn show
fn show(): String
IN, CH, HS, ANY, and CLASS{n} for the rest (RFC 3597 section 5).
fn equals
fn equals(other: RecordClass): Bool
By the code.
fn hash
fn hash(): Int
Not documented.
type Operation
type Operation with Show, Equals, Hash
What a message asks the server to do: the four bits of OPCODE (RFC 1035 section 4.1.1).
case Query
case Query
A standard query, 0.
case Status
case Status
A server status request, 2.
case Notify
case Notify
A zone change notification, 4 (RFC 1996).
case Update
case Update
A dynamic update, 5 (RFC 2136).
case Other
case Other(code: Int)
Any other operation, by its number from 0 to 15.
fn of
static fn of(code: Int): Self
The operation of the number code, a named case where there is one. Taken modulo 16.
fn code
fn code(): Int
The four bits on the wire.
fn show
fn show(): String
QUERY, STATUS, NOTIFY, UPDATE, and OPCODE{n} for the rest.
fn equals
fn equals(other: Operation): Bool
By the code.
fn hash
fn hash(): Int
Not documented.
type ResponseCode
type ResponseCode with Show, Equals, Hash
How a server answered: the twelve bits of the response code, four in the header and eight more in the EDNS0 record
(RFC 6891 section 6.1.3). A name that does not exist is NameError, the NXDOMAIN of the tools.
case NoError
case NoError
NOERROR, 0. An answer, possibly an empty one.
case FormatError
case FormatError
FORMERR, 1: the server could not read the query.
case ServerFailure
case ServerFailure
SERVFAIL, 2: the server could not answer.
case NameError
case NameError
NXDOMAIN, 3: the name does not exist.
case NotImplemented
case NotImplemented
NOTIMP, 4: the server does not do this kind of query.
case Refused
case Refused
REFUSED, 5: the server will not answer, by policy.
case NameExists
case NameExists
YXDOMAIN, 6: a name exists that an update said should not (RFC 2136).
case RecordSetExists
case RecordSetExists
YXRRSET, 7: a set of records exists that an update said should not.
case RecordSetMissing
case RecordSetMissing
NXRRSET, 8: a set of records does not exist that an update said should.
case NotAuthoritative
case NotAuthoritative
NOTAUTH, 9: the server is not authoritative for the zone.
case NotInZone
case NotInZone
NOTZONE, 10: a name is not inside the zone.
case BadVersion
case BadVersion
BADVERS, 16: the server does not speak the EDNS version of the query (RFC 6891).
case BadCookie
case BadCookie
BADCOOKIE, 23: the server cookie was wrong (RFC 7873).
case Other
case Other(code: Int)
Any other code, by its number from 0 to 4095.
fn of
static fn of(code: Int): Self
The response code of the number code, a named case where there is one. Taken modulo 4096.
fn code
fn code(): Int
The twelve bits: the low four go into the header, the high eight into the EDNS0 record.
fn show
fn show(): String
The mnemonic the tools print: NOERROR, NXDOMAIN, SERVFAIL, and RCODE{n} for a code without one.
fn equals
fn equals(other: ResponseCode): Bool
By the code.
fn hash
fn hash(): Int
Not documented.