Net::L...:Packet(3pm)

✨ Net::LDNS::Packet β€” the manual page but make it a group chat ✨

okay bestie so this is Net::LDNS::Packet, which lives in the Perl world under the name Net::LDNS::Packet(3pm) (a perl module doc, third section, you know the drill πŸ’…). It's literally just objects that represent DNS packets. That's it. That's the vibe. πŸ¦‹


🌸 NAME 🌸

Net::LDNS::Packet β€” objects representing DNS packets. yes queen, that's the whole name, iconic behaviour, no notes ✨


πŸŽ€ SYNOPSIS πŸŽ€

here's the little taste test, look at it, isn't it cute:

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

see? you query, you loop over the answers, you print the A records. main character energy fr fr πŸ”₯


πŸ’– CLASS METHODS πŸ’–

  • new($name, $type, $class) β€” makes you a brand new packet, and it's holding literally nothing except a query record for the triplet you handed it. $type and $class are optional and they default to A and IN respectively. so if you're lazy about it, you get a plain old A/IN query. slay. πŸ’…
  • new_from_wireformat($data) β€” builds you a fresh Net::LDNS::Packet out of the wireformat data you give it, if it possibly can. if it can't? it throws an exception at you. no soft launch, just an exception. πŸ’€

🫢 INSTANCE METHODS 🫢

  • rcode([$string]) β€” gives you back the packet's RCODE. hand it an argument and it'll try to set the RCODE to the relevant value. but if that string isn't recognized as an RCODE? exception. thrown. immediately. be careful bestie 😭
  • opcode([$string]) β€” same deal, but for the OPCODE. returns it, or with an argument tries to set it to the relevant value, and if the string isn't recognized as an OPCODE you get an exception. she's strict like that. πŸ™ˆ
  • id([$value]) β€” returns the packet's id number. give it an argument and it just sets the ID to that value. simple. drama-free. we love her. ✨
  • qr(), aa(), tc(), rd(), cd(), ra(), ad(), do() β€” the whole flag squad. each one reads and/or sets the flag of the equivalently matching name. one method, one flag, no crossover, periodt. πŸ‘‘
  • size() β€” returns the length of the packet's wireformat form, measured in octets. that's the number, that's all it is. 🌸
  • edns_size() β€” gets and/or sets the EDNS0 UDP size. both directions, your choice bb. πŸ’œ
  • edns_rcode() β€” gets and/or sets the EDNS0 Extended RCODE field. yes, the extended one, very fancy. ✨
  • needs_edns() β€” returns true when the packet has the DO flag set, an EDNS0 size set, and an EDNS0 extended RCODE set, OR when the OPT pseudo-RR has one or more RDATA fields. lowkey there's a hole in it though: it can fail to correctly flag a packet that has an OPT pseudo-RR as having EDNS if that pseudo-RR specifies a UDP size of zero, an extended RCODE of zero, and the DO flag is unset. but since any UDP size less than 512 has to be interpreted as 512, packets like that should be very rare in practice β€” if they exist at all. so don't spiral about it. 🌈
also important, don't forget: the OPT pseudo-RR is not visible as an RR in the packet, and it is not included in the RR count header fields. keep that in your notes bestie πŸŽ€
  • has_edns() β€” it's an alias for needs_edns(). literally the same thing wearing a different outfit. πŸ’…
  • 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 thus rather pointless until such time as EDNS1 gets defined. not her fault, she's doing her best πŸ₯²
  • querytime([$value]) β€” returns how long the query that this packet answers took to execute, in milliseconds. give it a value and it sets the querytime to that value. ⏱️
  • answerfrom($ipaddr) β€” returns the IP address the packet was received from, and optionally sets it. but if you try to set it to a string that can't be parsed as an IPv4 or IPv6 address, an exception gets thrown. do NOT just type vibes in there. 😀
  • timestamp($time) β€” the time when the query was sent or received (the ldns docs don't specify which, so take that as you will πŸ™ƒ), as a floating-point value on the Unix time_t scale. that is, the same kind of value that Time::HiRes::time() gives you. heads up though: conversion effects between floating-point and "struct timeval" mean the precision of the value is probably not reliable at the microsecond level β€” even if your computer's clock happens to be. so like, don't bet the farm on the microseconds. πŸ’€
  • question(), answer(), authority(), additional() β€” each one returns a list of objects representing the RRs in the named section. they'll be instances of classes appropriate to their types, but every single one of them has "Net::LDNS::RR" as a base class. one big happy family 🫢
  • unique_push($section, $rr) β€” pushes an RR object into the given section, but only if an identical RR isn't already in there. no duplicates, we don't do repeats. if the section isn't one of "question", "answer", "authority" or "additional", an exception will be thrown. and $rr must be a Net::LDNS::RR subclass. those are the rules, sorry not sorry ✨
  • string() β€” returns a string with the packet and all its contents in common presentation format. the pretty version. the readable one. the one you actually want to look at. πŸ’–
  • wireformat() β€” returns a Perl string holding the packet in wire format. the raw, unglamorous, on-the-wire version. πŸ”₯
  • type() β€” returns the ldns library's guess as to the content of the packet. it'll be one of the strings "question", "referral", "answer", "nxdomain", "nodata" or "unknown". yes bestie, guess. she's guessing. she's usually right but she's guessing. 🌸

🌟 SEE ALSO 🌟

nothing else listed here, it's just her. solo act. main character. πŸ’…


okay so that's the whole page, and this was perl v5.42.3, dated 2026-08-19, from the User Contributed Perl Documentation, Net::LDNS::Packet(3pm). go forth and parse those DNS packets, bestie, you're gonna eat πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from