ActivePerl Documentation
|
NAMENet::DNS::Packet - DNS packet object class
SUPPORTED PLATFORMS
SYNOPSIS
DESCRIPTIONA
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,
If passed a domain, type, and class, If called in array context, returns a packet object and an error string. The error string will only be defined if the packet object is undefined (i.e., couldn't be created). Returns undef if unable to create a packet object (e.g., if the packet data is truncated).
data
$data = $packet->data;
Returns the packet data in binary format, suitable for sending to a nameserver.
header
$header = $packet->header;
Returns a
question, zone
@question = $packet->question;
Returns a list of In dynamic update packets, this section is known as
answer, pre, prerequisite
@answer = $packet->answer;
Returns a list of In dynamic update packets, this section is known as
authority, update
@authority = $packet->authority;
Returns a list of In dynamic update packets, this section is known as
additional
@additional = $packet->additional;
Returns a list of
$packet->print;
Prints the packet data on the standard output in an ASCII format similar 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-created packets 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 a
nameserver. User-created packets will return undef for this method
(use
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, to be stored beginning at the given offset within the packet data. The name will be added to a running list of compressed domain names for future 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 DNS packet. The first argument is a reference to a scalar containing the packet data. The second argument is the offset within the packet where the (possibly compressed) domain name is stored. Returns the domain name and the offset of the next location in the packet. Returns (undef, undef) if the domain name couldn't be expanded.
COPYRIGHTCopyright (c) 1997 Michael Fuhr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSOperl(1), 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
|