Net::DNS::RR (3)
Leading comments
Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) Standard preamble: ========================================================================
NAME
Net::DNS::RR - DNS resource record base classSYNOPSIS
use Net::DNS; $rr = new Net::DNS::RR('example.com IN A 192.0.2.99'); $rr = new Net::DNS::RR( name => 'example.com', type => 'A', address => '192.0.2.99' );
DESCRIPTION
Net::DNS::RR is the base class forMETHODS
new (from string)
$a = new Net::DNS::RR('host.example.com. 86400 A 192.0.2.1'); $mx = new Net::DNS::RR('example.com. 7200 MX 10 mailhost.example.com.'); $cname = new Net::DNS::RR('www.example.com 300 IN CNAME host.example.com'); $txt = new Net::DNS::RR('txt.example.com 3600 HS TXT "text data"');
Returns an
extracted from the string passed by the user. The syntax of the argument string follows the
The name and
All names are interpreted as fully qualified domain names. The trailing dot (.) is optional.
new (from hash)
$rr = new Net::DNS::RR( name => 'host.example.com', ttl => 86400, class => 'IN', type => 'A', address => '192.0.2.1' ); $rr = new Net::DNS::RR( name => 'txt.example.com', type => 'TXT', txtdata => [ 'one', 'two' ] );
Returns an
each
The "name" and "type" fields are required; all others are optional. If omitted, "ttl" defaults to 0 and "class" defaults to
decode
( $rr, $next ) = decode Net::DNS::RR( \$data, $offset, @opaque );
Decodes a
The argument list consists of a reference to the buffer containing the packet data and offset indicating where resource record begins. Remaining arguments, if any, are passed as opaque data to subordinate decoders.
Returns a "Net::DNS::RR" object and the offset of the next record in the packet.
An exception is raised if the data buffer contains insufficient or corrupt data.
Any remaining arguments are passed as opaque data to subordinate decoders and do not form part of the published interface.
encode
$data = $rr->encode( $offset, @opaque );
Returns the "Net::DNS::RR" in binary format suitable for inclusion in a
The offset indicates the intended location within the packet data where the "Net::DNS::RR" is to be stored.
Any remaining arguments are opaque data which are passed intact to subordinate encoders.
canonical
$data = $rr->canonical;
Returns the "Net::DNS::RR" in canonical binary format suitable for
The absence of the associative array argument signals to subordinate encoders that the canonical uncompressed lower case form of embedded domain names is to be used.
$rr->print;
Prints the record to the standard output. Calls the string method to get the
string
print $rr->string, "\n";
Returns a string representation of the
owner name
$owner = $rr->name;
Returns the owner name of the record.
type
$type = $rr->type;
Returns the record type.
class
$class = $rr->class;
Resource record class.
ttl
$ttl = $rr->ttl; $ttl = $rr->ttl(3600);
Resource record time to live in seconds.
rdata
$rr = new Net::DNS::RR( type => NULL, rdata => 'arbitrary' );
Resource record data section when viewed as opaque octets.
rdstring
$rdstring = $rr->rdstring;
Returns a string representation of the RR-specific data.
plain
$plain = $rr->plain;
Returns a simplified single line representation of the
token
@token = $rr->token;
Returns a token list representation of the
Sorting of RR arrays
Sorting ofset_rrsort_func
Net::DNS::RR::MX->set_rrsort_func( 'preference', sub { $Net::DNS::a->preference <=> $Net::DNS::b->preference } ); Net::DNS::RR::MX->set_rrsort_func( 'default_sort', Net::DNS::RR::MX->get_rrsort_func('preference') );
set_rrsort_func() must be called as a class method. The first argument is the attribute name on which the sorting is to take place. If you specify ``default_sort'' then that is the sort algorithm that will be used when rrsort() is called without an
The second argument is a reference to a comparison function that uses the global variables $a and $b in the Net::DNS package. During sorting, the variables $a and $b will contain references to objects of the class whose set_rrsort_func() was called. The above sorting function will only be applied to Net::DNS::RR::MX objects.
The above example is the sorting function implemented in
COPYRIGHT
Copyright (c)1997-2002 Michael Fuhr.Portions Copyright (c)2002-2004 Chris Reinhardt.
Portions Copyright (c)2005-2007 Olaf Kolkman.
Portions Copyright (c)2007,2012 Dick Franks.
All rights reserved.
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.