MAN page from Mandrake Other perl-Net-DNS-0.12-1.i386.rpm
lib::Net::DNS::Packet
Section: User Contributed Perl Documentation (3)
Updated: perl 5.004, patch 04
Index NAME
Net::DNS::Packet - DNS packet object class
SYNOPSIS
use Net::DNS::Packet; DESCRIPTION
A
Net::DNS::Packet object represents a DNS packet.
METHODS
new
$packet = new Net::DNS::Packet(\$data); $packet = new Net::DNS::Packet(\$data, 1); # set debugging
$packet = new Net::DNS::Packet("foo.com"); $packet = new Net::DNS::Packet("foo.com", "MX", "IN"); ($packet, $err) = new Net::DNS::Packet(\$data);
If passed a reference to a scalar containing
DNS packet data,
new creates a packet object from that data. A second argumentcan be passed to turn on debugging output for packet parsing.
If passed a domain, type, and class, new creates a packetobject appropriate for making a DNS query for the requestedinformation. The type and class can be omitted; they defaultto A and IN.
If called in array context, returns a packet object and anerror string. The error string will only be defined if thepacket object is undefined (i.e., couldn't be created).
Returns undef if unable to create a packet object (e.g., ifthe packet data is truncated).
data
$data = $packet->data;
Returns the packet data in binary format, suitable for sending toa nameserver.
header
$header = $packet->header;
Returns a
Net::DNS::Header object representing the header sectionof the packet.
question, zone
@question = $packet->question;
Returns a list of
Net::DNS::Question objects representing thequestion section of the packet.
In dynamic update packets, this section is known as zone andspecifies the zone to be updated.
answer, pre, prerequisite
@answer = $packet->answer;
Returns a list of
Net::DNS::RR objects representing the answersection of the packet.
In dynamic update packets, this section is known as pre orprerequisite and specifies the RRs or RRsets which must ormust not preexist.
authority, update
@authority = $packet->authority;
Returns a list of
Net::DNS::RR objects representing the authoritysection of the packet.
In dynamic update packets, this section is known as update andspecifies the RRs or RRsets to be added or delted.
additional
@additional = $packet->additional;
Returns a list of
Net::DNS::RR objects representing the additionalsection of the packet.
print
$packet->print;
Prints the packet data on the standard output in an
ASCII formatsimilar to that used in
DNS zone files.
string
print $packet->string;
Returns a string representation of the packet.
answerfrom
print "packet received from ", $packet->answerfrom, "\n";
Returns the
IP address from which we received this packet. User-createdpackets will return undef for this method.
answersize
print "packet size: ", $packet->answersize, " bytes\n";
Returns the size of the packet in bytes as it was received from anameserver. User-created packets will return undef for this method(use
length $packet->
data instead).
push
$packet->push("pre", $rr); $packet->push("update", $rr); $packet->push("additional", $rr); $packet->push("update", $rr1, $rr2, $rr3); $packet->push("update", @rr);Adds RRs to the specified section of the packet.
dn_comp
$compname = $packet->dn_comp("foo.bar.com", $offset);Returns a domain name compressed for a particular packet object, tobe stored beginning at the given offset within the packet data. Thename will be added to a running list of compressed domain names forfuture use.
dn_expand
use Net::DNS::Packet qw(dn_expand); ($name, $nextoffset) = dn_expand(\$data, $offset);
($name, $nextoffset) = Net::DNS::Packet::dn_expand(\$data, $offset);
Expands the domain name stored at a particular location in a
DNSpacket. The first argument is a reference to a scalar containingthe packet data. The second argument is the offset within thepacket where the (possibly compressed) domain name is stored.
Returns the domain name and the offset of the next location in thepacket.
Returns (undef, undef) if the domain name couldn't be expanded.
COPYRIGHT
Copyright (c) 1997 Michael Fuhr. All rights reserved. This program is freesoftware; you can redistribute it and/or modify it under the same terms asPerl itself.
SEE ALSO
the
perl(1) manpage, the
Net::DNS manpage, the
Net::DNS::Resolver manpage, the
Net::DNS::Update manpage,the
Net::DNS::Header manpage, the
Net::DNS::Question manpage, the
Net::DNS::RR manpage,RFC 1035 Section 4.1, RFC 2136 Section 2
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- METHODS
- COPYRIGHT
- SEE ALSO
This document was created byman2html,using the manual pages.