.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Net::LDNS::Packet 3pm" .TH Net::LDNS::Packet 3pm "2016-06-27" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::LDNS::Packet \- objects representing DNS packets .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& my $p = $resolver\->query(\*(Aqwww.iis.se\*(Aq); \& foreach my $rr ($p\->answer) { \& say $rr\->string if $rr\->type eq \*(AqA\*(Aq; \& } .Ve .SH "CLASS METHODS" .IX Header "CLASS METHODS" .ie n .IP "new($name, $type, $class)" 4 .el .IP "new($name, \f(CW$type\fR, \f(CW$class\fR)" 4 .IX Item "new($name, $type, $class)" Create a new packet, holding nothing by a query record for the provided triplet. \f(CW$type\fR and \f(CW$class\fR are optional, and default to A and \s-1IN\s0 respectively. .IP "new_from_wireformat($data)" 4 .IX Item "new_from_wireformat($data)" Creates a new Net::LDNS::Packet object from the given wireformat data, if possible. Throws an exception if not. .SH "INSTANCE METHODS" .IX Header "INSTANCE METHODS" .IP "rcode([$string])" 4 .IX Item "rcode([$string])" Returns the packet \s-1RCODE.\s0 If given an argument, tries to set the \s-1RCODE\s0 to the relevant value. If the given string isn't recognized as an \s-1RCODE,\s0 an exception will be thrown. .IP "opcode([$string])" 4 .IX Item "opcode([$string])" Returns the packet \s-1OPCODE.\s0 If given an argument, tries to set the \s-1OPCODE\s0 to the relevant value. If the given string isn't recognized as an \s-1OPCODE,\s0 an exception will be thrown. .IP "id([$value])" 4 .IX Item "id([$value])" Returns the packet id number. If given an argument, sets the \s-1ID\s0 value to that value. .IP "\fIqr()\fR" 4 .IX Item "qr()" .PD 0 .IP "\fIaa()\fR" 4 .IX Item "aa()" .IP "\fItc()\fR" 4 .IX Item "tc()" .IP "\fIrd()\fR" 4 .IX Item "rd()" .IP "\fIcd()\fR" 4 .IX Item "cd()" .IP "\fIra()\fR" 4 .IX Item "ra()" .IP "\fIad()\fR" 4 .IX Item "ad()" .IP "\fIdo()\fR" 4 .IX Item "do()" .PD Reads and/or sets the equivalently named flags. .IP "\fIsize()\fR" 4 .IX Item "size()" Returns the length of the packet's wireformat form in octets. .IP "\fIedns_size()\fR" 4 .IX Item "edns_size()" Gets and/or sets the \s-1EDNS0 UDP\s0 size. .IP "\fIedns_rcode()\fR" 4 .IX Item "edns_rcode()" Gets and/or sets the \s-1EDNS0\s0 Extended \s-1RCODE\s0 field. .IP "\fIneeds_edns()\fR" 4 .IX Item "needs_edns()" This method returns true if the packet has the \s-1DO\s0 flag set, an \s-1EDNS0\s0 size set, and \s-1EDNS0\s0 extended \s-1RCODE\s0 set or if the \s-1OPT\s0 pseudo-RR has one or more \s-1RDATA\s0 fields. It can fail to correctly flag a packet with an \s-1OPT\s0 pseudo-RR as having \&\s-1EDNS,\s0 if the pseudo-RR specifies an \s-1UDP\s0 size of zero, an extended \s-1RCODE\s0 of zero and the \s-1DO\s0 flag is unset. Since any \s-1UDP\s0 size less than 512 must be interpreted as 512, packets like that should be very rare in practice if they exist at all. .Sp Note that the \s-1OPT\s0 pseudo-RR is not visible as an \s-1RR\s0 in the packet, nor is it included in the \s-1RR\s0 count header fields. .IP "\fIhas_edns()\fR" 4 .IX Item "has_edns()" An alias for \fIneeds_edns()\fR. .IP "edns_version($version)" 4 .IX Item "edns_version($version)" Get or set the \s-1EDNS\s0 version in the packet. For incoming packets, returns 0 if the packet does not have an \s-1OPT\s0 pseudo-RR and 0 if it's an \s-1EDNS0\s0 packet. It's thus rather pointless until such time as \s-1EDNS1\s0 is defined. .IP "querytime([$value])" 4 .IX Item "querytime([$value])" Returns the time the query this packet is the answer to took to execute, in milliseconds. If given a value, sets the querytime to that value. .IP "answerfrom($ipaddr)" 4 .IX Item "answerfrom($ipaddr)" Returns and optionally sets the \s-1IP\s0 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. .IP "timestamp($time)" 4 .IX Item "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 \fITime::HiRes::time()\fR). Conversion effects between floating-point and \f(CW\*(C`struct timeval\*(C'\fR means that the precision of the value is probably not reliable at the microsecond level, even if you computer's clock happen to be. .IP "\fIquestion()\fR" 4 .IX Item "question()" .PD 0 .IP "\fIanswer()\fR" 4 .IX Item "answer()" .IP "\fIauthority()\fR" 4 .IX Item "authority()" .IP "\fIadditional()\fR" 4 .IX Item "additional()" .PD Returns list of objects representing the RRs in the named section. They will be of classes appropriate to their types, but all will have \&\f(CW\*(C`Net::LDNS::RR\*(C'\fR as a base class. .ie n .IP "unique_push($section, $rr)" 4 .el .IP "unique_push($section, \f(CW$rr\fR)" 4 .IX Item "unique_push($section, $rr)" Push an \s-1RR\s0 object into the given section, if an identical \s-1RR\s0 isn't already present. If the section isn't one of \*(L"question\*(R", \*(L"answer\*(R", \*(L"authority\*(R" or \*(L"additional\*(R" an exception will be thrown. \f(CW$rr\fR must be a Net::LDNS::RR subclass. .IP "\fIstring()\fR" 4 .IX Item "string()" Returns a string with the packet and its contents in common presentation format. .IP "\fIwireformat()\fR" 4 .IX Item "wireformat()" Returns a Perl string holding the packet in wire format. .IP "\fItype()\fR" 4 .IX Item "type()" Returns the ldns library's guess as to the content of the packet. One of the strings \f(CW\*(C`question\*(C'\fR, \f(CW\*(C`referral\*(C'\fR, \f(CW\*(C`answer\*(C'\fR, \f(CW\*(C`nxdomain\*(C'\fR, \f(CW\*(C`nodata\*(C'\fR or \f(CW\*(C`unknown\*(C'\fR.