NAME
Net::LDNS::Packet - objects representing DNS packets
SYNOPSIS
my $p = $resolver->query('www.iis.se');
foreach my $rr ($p->answer) {
say $rr->string if $rr->type eq 'A';
}
CLASS METHODS
- new($name, $type, $class)
-
Create a new packet, holding nothing by a query record for the provided triplet.
$type
and$class
are optional, and default to A and IN respectively. - new_from_wireformat($data)
-
Creates a new Net::LDNS::Packet object from the given wireformat data, if possible. Throws an exception if not.
INSTANCE METHODS
- rcode()
-
Returns the packet RCODE.
- opcode()
-
Returns the packet OPCODE.
- id()
-
Returns the packet id number.
- aa()
- tc()
- rd()
- cd()
- ra()
- ad()
- do()
-
Reads and/or sets the equivalently named flags.
- size()
-
Returns the length of the packet's wireformat form in octets.
- edns_size()
-
Gets and/or sets the EDNS0 UDP size.
- edns_rcode()
-
Gets and/or sets the EDNS0 Extended RCODE field.
- querytime()
-
Returns the time the query this packet is the answer to took to execute, i milliseconds.
- answerfrom($ipaddr)
-
Returns and optionally sets the IP address the packet was received from. If an attempt is made to set it to a string that cannot be parsed as an IPv4 or IPv6 address, an exception is thrown.
- timestamp($time)
-
The time when the query was sent or received (the ldns docs don't specify), as a floating-point value on the Unix time_t scale (that is, the same kind of value used by Time::HiRes::time()). Conversion effects between floating-point and
struct timeval
means that the precision of the value is probably not reliable at the microsecond level, even if you computer's clock happen to be. -
Returns list of objects representing the RRs in the named section. They will be of classes appropriate to their types, but all will have
Net::LDNS::RR
as a base class. - unique_push($section, $rr)
-
Push 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 will be thrown.
$rr
must be a Net::LDNS::RR subclass. - string()
-
Returns a string with the packet and its contents in common presentation format.
- wireformat()
-
Returns a Perl string holding the packet in wire format.
- type()
-
Returns the ldns library's guess as to the content of the packet. One of the strings
question
,referral
,answer
,nxdomain
,nodata
orunknown
.