Scroll to navigation

dnsjit.core.object.dns(3) Library Functions Manual dnsjit.core.object.dns(3)

NAME

dnsjit.core.object.dns - Container of a DNS message

SYNOPSIS

Parse DNS header and check if query or response


local dns = require("dnsjit.core.object.dns").new(payload)
if dns:parse_header() == 0 then
if dns.qr == 0 then
print(dns.id, dns.opcode_tostring(dns.opcode))
else
print(dns.id, dns.rcode_tostring(dns.rcode))
end
end


local dns = require("dnsjit.core.object.dns").new(payload)
dns:print()

Parse a DNS payload


local dns = require("dnsjit.core.object.dns").new(payload)
local qs, q_labels, rrs, rr_labels = dns:parse()
if qs and q_labels then
...
if rrs and rr_labels then
...
end
end

DESCRIPTION

The object that describes a DNS message.

Attributes

If non-zero then this indicates that the DNS length is included in the payload (for example if the transport is TCP) and will affect parsing of it.
Set if the dnslen was included in the payload and could be read.
Set if there is a DNS ID.
Set if there is a QR flag.
Set if there is an OPCODE.
Set if there is a AA flag.
Set if there is a TC flag.
Set if there is a RD flag.
Set if there is a RA flag.
Set if there is a Z flag.
Set if there is a AD flag.
Set if there is a CD flag.
Set if there is a RCODE.
Set if there is an QDCOUNT.
Set if there is an ANCOUNT.
Set if there is a NSCOUNT.
Set if there is an ARCOUNT.
The DNS length found in the payload.
The DNS ID.
The QR flag.
The OPCODE.
The AA flag.
The TC flag.
The RD flag.
The RA flag.
The Z flag.
The AD flag.
The CD flag.
The RCODE.
The QDCOUNT.
The ANCOUNT.
The NSCOUNT.
The ARCOUNT.

Constants

The following tables exists for DNS parameters, taken from https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml on the 2016-12-09.

CLASS, CLASS_STR, TYPE, TYPE_STR, OPCODE, OPCODE_STR, RCODE, RCODE_STR, AFSDB, AFSDB_STR, DHCID, DHCID_STR, ENDS0, ENDS0_STR

The *_STR tables can be used to get a textual representation of the numbers, see also class_tostring(), type_tostring(), opcode_tostring(), rcode_tostring(), afsdb_tostring(), dhcid_tostring() and edns0_tostring().

Functions

Create a new DNS object, optionally on-top of another object.
Return the textual type of the object.
Return the previous object.
Cast the object to the underlining object module and return it.
Cast the object to the generic object module and return it.
Make a copy of the object and return it.
Free the object, should only be used on copies or otherwise allocated.
Return the Log object to control logging of this module.
Begin parsing the underlaying object, first the header is parsed then optionally continue calling parse_q() for the number of questions (see qdcount). After that continue calling parse_rr() for the number of answers, authorities and additionals resource records (see ancount, nscount and arcount). Returns 0 on success or negative integer on error which can be for malformed or truncated DNS (-2) or if more space for labels is needed (-3).
Parse the next resource record as a question. Returns 0 on success or negative integer on error which can be for malformed or truncated DNS (-2) or if more space for labels is needed (-3).
Parse the next resource record. Returns 0 on success or negative integer on error which can be for malformed or truncated DNS (-2) or if more space for labels is needed (-3).
Begin parsing the underlaying object using parse_header(), parse_q() and parse_rr(). The optional num_labels can be used to set a specific number of labels used for each question and resource record (default 16). Returns result code, an array of questions, an array of question labels, an array of resource records and an array of resource records labels. Result code is 0 on success or negative integer on error which can be for malformed or truncated DNS (-2) or if more space for labels is needed (-3).
Begin parsing the underlaying object using parse_header(), parse_q() and parse_rr(), and print it's content. The optional num_labels can be used to set a specific number of labels used for each question and resource record (default 16).
Return the textual name for a class.
Return the textual name for a type.
Return the textual name for an opcode.
Return the textual name for a rcode.
Return the textual name for an afsdb subtype.
Return the textual name for a dhcid type.
Return the textual name for an EDNS0 OPT record.

SEE ALSO

dnsjit.core.object(3), dnsjit.core.object.payload(3), dnsjit.core.object.dns.label(3), dnsjit.core.object.dns.q(3), dnsjit.core.object.dns.rr(3)

AUTHORS and CONTRIBUTORS

Jerry Lundström (DNS-OARC), Tomáš Křížek (CZ.NIC), Petr Špaček (ISC)

Maintained by DNS-OARC

BUGS

For issues and feature requests please use:

For question and help please use:

admin@dns-oarc.net
1.2.3 dnsjit