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.$typeand$classare optional and they default toAandINrespectively. so if you're lazy about it, you get a plain old A/IN query. slay. πnew_from_wireformat($data)β builds you a freshNet::LDNS::Packetout 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 forneeds_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 returns0if the packet doesn't have an OPT pseudo-RR, and0if 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 Unixtime_tscale. that is, the same kind of value thatTime::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$rrmust be aNet::LDNS::RRsubclass. 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
- ubuntu stonking: libnet-ldns-perl 0.75-7build7 Β· 2-clause-BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms