dnsjit.core.object.dns(3)

πŸ“¦
version 1.5.1 Β· 5 versions
, in epel 10, epel 9, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸ’– dnsjit.core.object.dns β€” the manual page bestie πŸ’–

okay so you're reading the dnsjit.core.object.dns page from the Library Functions Manual, and honestly? it's giving container-of-a-DNS-message energy and I am obsessed. let's get into it πŸ¦‹


✨ NAME ✨

dnsjit.core.object.dns β€” the container of a DNS message. that's it, that's the whole vibe πŸ’…


🌸 SYNOPSIS 🌸

parse a DNS header and check if it's a query or a 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 πŸ‘‘

so this is the object that describes a DNS message. the main character, fr fr. πŸŽ€

πŸ’œ Attributes

  • includes_dnslen β€” if this is non-zero, that means the DNS length is included in the payload (like, for example, when the transport is TCP) and it affects how the payload gets parsed. lowkey important.
  • have_dnslen β€” set when the dnslen was actually included in the payload and could be read.
  • have_id β€” set if there's a DNS ID.
  • have_qr β€” set if there's a QR flag.
  • have_opcode β€” set if there's an OPCODE.
  • have_aa β€” set if there's an AA flag.
  • have_tc β€” set if there's a TC flag.
  • have_rd β€” set if there's a RD flag.
  • have_ra β€” set if there's a RA flag.
  • have_z β€” set if there's a Z flag.
  • have_ad β€” set if there's an AD flag.
  • have_cd β€” set if there's a CD flag.
  • have_rcode β€” set if there's a RCODE.
  • have_qdcount β€” set if there's a QDCOUNT.
  • have_ancount β€” set if there's an ANCOUNT.
  • have_nscount β€” set if there's a NSCOUNT.
  • have_arcount β€” set if there's an ARCOUNT.
  • dnslen β€” the DNS length that was found in the payload.
  • id β€” the DNS ID.
  • qr β€” the QR flag.
  • opcode β€” the OPCODE.
  • aa β€” the AA flag.
  • tc β€” the TC flag.
  • rd β€” the RD flag.
  • ra β€” the RA flag.
  • z β€” the Z flag.
  • ad β€” the AD flag.
  • cd β€” the CD flag.
  • rcode β€” the RCODE.
  • qdcount β€” the QDCOUNT.
  • ancount β€” the ANCOUNT.
  • nscount β€” the NSCOUNT.
  • arcount β€” the ARCOUNT.

🧚 Constants

these tables exist for DNS parameters, and they were taken from https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml on the 2016-12-09. periodt, that's the source date, no cap.

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

the *_STR tables are the ones you use to turn numbers into their textual glow-up ✨ see also class_tostring(), type_tostring(), opcode_tostring(), rcode_tostring(), afsdb_tostring(), dhcid_tostring() and edns0_tostring().

🫢 Functions

  • Dns.new(obj) β€” create a fresh new DNS object, optionally sitting on top of another object.
  • Dns:type() β€” returns the textual type of the object.
  • Dns:prev() β€” returns the previous object.
  • Dns:cast() β€” casts the object to the underlining object module and hands it back to you.
  • Dns:uncast() β€” casts the object to the generic object module and returns it.
  • Dns:copy() β€” makes a copy of the object and returns it.
  • Dns:free() β€” frees the object. only use this on copies or stuff that was otherwise allocated, bestie, I'm serious.
  • Dns:reset() β€” resets the object, getting it all ready for reuse.
  • Dns:log() β€” returns the Log object so you can control the logging of this module.
  • Dns:parse_header() β€” starts parsing the underlaying object: first the header gets parsed, then you optionally keep calling parse_q() for however many questions there are (check qdcount). after that you keep calling parse_rr() for the number of answers, authorities and additionals resource records (check ancount, nscount and arcount). returns 0 on success, or a negative integer on error β€” which can be malformed or truncated DNS (-2), or needing more space for labels (-3).
  • Dns:parse_q(q, labels, num_labels) β€” parses the next resource record as a question. returns 0 on success, or a negative integer on error β€” malformed or truncated DNS (-2), or needing more space for labels (-3).
  • Dns:parse_rr(rr, labels, num_labels) β€” parses the next resource record. returns 0 on success, or a negative integer on error β€” malformed or truncated DNS (-2), or needing more space for labels (-3).
  • Dns:parse(num_labels) β€” starts parsing the underlaying object using parse_header(), parse_q() and parse_rr(). the optional num_labels lets you set a specific number of labels used for each question and resource record (default is 16). returns a result code, an array of questions, an array of question labels, an array of resource records, and an array of resource records labels. the result code is 0 on success, or a negative integer on error β€” malformed or truncated DNS (-2), or needing more space for labels (-3).
  • Dns:print(num_labels) β€” starts parsing the underlaying object using parse_header(), parse_q() and parse_rr(), and prints its content. the optional num_labels lets you set a specific number of labels used for each question and resource record (default is 16).
  • Dns.class_tostring(class) β€” returns the textual name for a class. unknown classes come back as "CLASS<NUM>", exactly as described in RFC 3597.
  • Dns.type_tostring(type) β€” returns the textual name for a type. unknown types come back as "TYPE<NUM>", as described in RFC 3597.
  • Dns.opcode_tostring(opcode) β€” returns the textual name for an opcode.
  • Dns.rcode_tostring(rcode) β€” returns the textual name for a rcode.
  • Dns.afsdb_tostring(afsdb) β€” returns the textual name for an afsdb subtype.
  • Dns.dhcid_tostring(dhcid) β€” returns the textual name for a dhcid type.
  • Dns.edns0_tostring(edns0) β€” returns 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)

go read your siblings, they're iconic too πŸ’–


πŸ’« AUTHORS and CONTRIBUTORS πŸ’«

Jerry LundstrΓΆm (DNS-OARC), TomΓ‘Ε‘ KΕ™Γ­ΕΎek (CZ.NIC), Petr Ε paček (ISC)

maintained by DNS-OARC 🫢

https://www.dns-oarc.net/


😭 BUGS 😭

for issues and feature requests please use:

https://codeberg.org/DNS-OARC/dnsjit/issues

for questions and help please use:

admin@dns-oarc.net


okay bestie that's the whole page, you ate it, no crumbs left πŸ“ this was dnsjit 1.5.1, page dnsjit.core.object.dns(3), and yes it's the version from the Library Functions Manual β€” now go parse something and slay πŸ’…βœ¨πŸ¦‹