Zonema...Packet(3pm)

πŸ’– Zonemaster::LDNS::Packet β€” objects representing DNS packets πŸ’–

okay bestie. this is the page for Zonemaster::LDNS::Packet (the manpage is filed under the kinda-truncated name Zonema...Packet(3pm), don't let that jump you πŸ’€). it's a Perl thing, it lives in the User Contributed Perl Documentation pile, and it's literally just... a DNS packet as an object. every record, every flag, every vibe. let's go πŸ¦‹


✨ SYNOPSIS ✨

look, here's the whole entire mood in five lines:

my $p = $resolver->query('www.iis.se');
foreach my $rr ($p->answer) {
    say $rr->string if $rr->type eq 'A';
}

you ask, you get a packet, you loop the answers, you print the A records. that's it that's the whole lifestyle πŸŽ€


🌸 CLASS METHODS 🌸

these ones you call on the class itself. constructor core.

  • new($name, $type, $class) β€” makes you a fresh new Zonemaster::LDNS::Packet object, and ngl it holds nothing except a query record for the triplet you gave it. nothing else. it's a whole packet that's just a question, main character energy. $name is the QNAME. $type and $class are optional and default to A and IN respectively β€” so if you don't say anything it's an A IN question, periodt.
  • new_from_wireformat($data) β€” builds a new Zonemaster::LDNS::Packet out of the wireformat data you hand it, if possible. if it's not possible? it throws an exception. no cap. 😭

πŸ‘‘ INSTANCE METHODS πŸ‘‘

everything below you call on a packet object. buckle up, there's a lot, and honestly? obsessed.

πŸ’… the rcode / opcode / id trio

  • rcode([$string]) β€” gives you the packet RCODE. hand it an argument and it tries to set the RCODE to the relevant value. if the string you gave isn't recognized as an RCODE, an exception gets thrown at you. so be normal about it πŸ™ˆ
  • opcode([$string]) β€” gives you the packet OPCODE. hand it an argument and it tries to set the OPCODE to the relevant value. if the string isn't recognized as an OPCODE, exception. same energy, different field. ✨
  • id([$value]) β€” returns the packet id number. hand it an argument and it sets the ID value to that value. simple. iconic. no notes.

🌈 the flags crew

  • qr()
  • aa()
  • tc()
  • rd()
  • cd()
  • ra()
  • ad()
  • do()

all of these read and/or set the equivalently named flags. that's the whole bit β€” flag name in, flag name out. one bullet because they're a little squad πŸ’œ

πŸ“ size & EDNS stuff

  • size() β€” returns the length of the packet's wireformat form, in octets. yes, octets. not vibes. octets. πŸ’€
  • edns_size() β€” gets and/or sets the EDNS0 UDP size.
  • edns_rcode() β€” gets and/or sets the EDNS0 Extended RCODE field.
  • ends_z() β€” gets and/or sets the EDNS0 Z bits. (yes, the method really is spelled ends_z, we don't make the rules, we just respect them 🫢)
  • edns_data() β€” gets and/or sets the EDNS0 RDATA. for the actual details on this one you gotta go look at LDNS.xs, that's where the lore lives.
  • needs_edns() β€” returns true if the packet has the DO flag set, an EDNS0 size set, and an EDNS0 extended RCODE set β€” or if the OPT pseudo-RR has one or more RDATA fields.
⚠️ heads up bestie, this can fail to correctly flag a packet with an OPT pseudo-RR as having EDNS if the pseudo-RR specifies a UDP size of zero, an extended RCODE of zero, and the DO flag is unset. and because any UDP size less than 512 has to be interpreted as 512, packets like that should be super rare in practice β€” like, if they exist at all. πŸ‘€

also, important: the OPT pseudo-RR is not visible as an RR in the packet, and it is not included in the RR count header fields. it's lowkey hiding in there.

  • has_edns() β€” an alias for needs_edns(). same method, different name, we love a rebrand. ✨
  • edns_version($version) β€” get or set the EDNS version in the packet. for incoming packets it returns 0 if the packet doesn't have an OPT pseudo-RR, and 0 if it is an EDNS0 packet. so it's, um. rather pointless until such time as EDNS1 actually gets defined. it's giving placeholder. 😭
  • set_edns_present β€” sets the edns_present flag to true.

you can set this flag when you're creating a packet with EDNS corner cases data that the need_edns / has_edns methods couldn't detect on their own.

when it's set, the need_edns / has_edns methods return a true value. slay.

  • unset_edns_present β€” sets the edns_present flag to false. the off switch. πŸŽ€

πŸ• timing & where it came from

  • querytime([$value]) β€” returns how long the query that this packet is the answer to took to execute, in milliseconds. hand it a value and it sets the querytime to that value.
  • answerfrom($ipaddr) β€” returns and optionally sets the IP address the packet was received from. if you try to set it to a string that can't be parsed as an IPv4 or IPv6 address, an exception gets thrown. don't try it. πŸ™ˆ
  • timestamp($time) β€” the time when the query was sent or received (the ldns docs don't specify which, so 😢). it's a floating-point value on the Unix time_t scale β€” meaning the same kind of value that Time::HiRes::time() uses.
⚠️ conversion effects between floating-point and struct timeval mean the precision of this value is probably not reliable at the microsecond level, even if your computer's clock happens to be. so like... don't build your whole personality on that microsecond. πŸ’€

πŸ“š grabbing all the records

  • all() β€” returns a Zonemaster::LDNS::RRList object containing the resource records from all sections except the question section. everything but the question. the whole buffet minus the appetizer.
  • question() β€” returns a list of objects representing the RRs in the question section. they'll be of classes appropriate to their types, but all of them have Zonemaster::LDNS::RR as a base class. found family 🫢
  • question_rrlist() β€” similar to question(), but instead returns a single (and sorted) Zonemaster::LDNS::RRList object.
  • answer() β€” similar to answer_unfiltered(), but it ignores incomplete resource records. picky in a good way. πŸ’…
  • answer_rrlist() β€” similar to answer(), but instead returns a single (and sorted) Zonemaster::LDNS::RRList object.
  • answer_unfiltered() β€” returns a list of objects representing the RRs in the answer section. they'll be of classes appropriate to their types, but all have Zonemaster::LDNS::RR as a base class.
  • authority() β€” similar to authority_unfiltered(), but ignores incomplete resource records.
  • authority_rrlist() β€” similar to authority(), but instead returns a single (and sorted) Zonemaster::LDNS::RRList object.
  • authority_unfiltered() β€” returns a list of objects representing the RRs in the authority section. classes appropriate to their types, all with Zonemaster::LDNS::RR as a base class.
  • additional() β€” similar to additional_unfiltered(), but ignores incomplete resource records.
  • additional_rrlist() β€” similar to additional(), but instead returns a single (and sorted) Zonemaster::LDNS::RRList object.
  • additional_unfiltered() β€” returns a list of objects representing the RRs in the additional section. classes appropriate to their types, all with Zonemaster::LDNS::RR as a base class.
πŸ’‘ notice the pattern? every section has a plain getter, a _rrlist sorted-single-object version, and an _unfiltered version that keeps the incomplete records. the filtered ones drop incomplete RRs. iykyk. ✨

🧺 pushing stuff in & spitting stuff out

  • unique_push($section, $rr) β€” pushes an RR object into the given section, if an identical RR isn't already present. if the section isn't one of "question", "answer", "authority" or "additional", an exception gets thrown. and $rr must be a Zonemaster::LDNS::RR subclass. no impostors allowed. πŸ‘‘
  • string() β€” returns a string with the packet and its contents in common presentation format. the readable one. the pretty one. πŸ’–
  • wireformat() β€” returns a Perl string holding the packet in wire format. the feral one. the bytes. 🌈
  • type() β€” returns the ldns library's guess as to the content of the packet. one of the strings "question", "referral", "answer", "nxdomain", "nodata" or "unknown". note it says guess, bestie, the library is doing its best 🫢

and that's the entire page, no skips, no cuts πŸ’œ

this beauty is Zonema...Packet(3pm) from the User Contributed Perl Documentation, running under perl v5.42.3, dated 2026-08-19. go forth and parse your packets, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from