1Net::DNS::RR(3)       User Contributed Perl Documentation      Net::DNS::RR(3)
2
3
4

NAME

6       Net::DNS::RR - DNS Resource Record base class
7

SYNOPSIS

9           use Net::DNS;
10
11           $rr = new Net::DNS::RR('example.com IN A 192.0.2.99');
12
13           $rr = new Net::DNS::RR(
14                   name    => 'example.com',
15                   type    => 'A',
16                   address => '192.0.2.99'
17                   );
18

DESCRIPTION

20       Net::DNS::RR is the base class for DNS Resource Record (RR) objects.
21       See also the manual pages for each specific RR type.
22

METHODS

24       WARNING!!!  Do not assume the RR objects you receive from a query are
25       of a particular type -- always check the object type before calling any
26       of its methods.  If you call an unknown method, you will get an error
27       message and execution will be terminated.
28
29   new (from string)
30           $a     = new Net::DNS::RR('host.example.com. 86400 A 192.0.2.1');
31           $mx    = new Net::DNS::RR('example.com. 7200 MX 10 mailhost.example.com.');
32           $cname = new Net::DNS::RR('www.example.com 300 IN CNAME host.example.com');
33           $txt   = new Net::DNS::RR('txt.example.com 3600 HS TXT "text data"');
34
35       Returns an RR object of the appropriate type, or a "Net::DNS::RR"
36       object if the type is not implemented.   The attribute values are
37       extracted from the string passed by the user.  The syntax of the
38       argument string follows the RFC1035 specification for zone files, and
39       is compatible with the result returned by the string method.
40
41       The name and RR type are required; all other information is optional.
42       If omitted, the TTL defaults to 0 and the RR class defaults to IN.
43       Omitting the optional fields is useful for creating the empty RDATA
44       sections required for certain dynamic update operations.  See the
45       "Net::DNS::Update" manual page for additional examples.
46
47       All names are interpreted as fully qualified domain names.  The
48       trailing dot (.) is optional.
49
50       RR owner names in in-addr.arpa or ip6.arpa namespaces may be specified
51       using appropriate RFC4291 or RFC4632 IP address/prefix notation.
52
53   new (from hash)
54           $rr = new Net::DNS::RR(
55                   name    => 'host.example.com',
56                   ttl     => 86400,
57                   class   => 'IN',
58                   type    => 'A',
59                   address => '192.0.2.1'
60                   );
61
62           $rr = new Net::DNS::RR(
63                   name    => 'txt.example.com',
64                   type    => 'TXT',
65                   txtdata => [ 'one', 'two' ]
66                   );
67
68       Returns an RR object of the appropriate type, or a "Net::DNS::RR"
69       object if the type is not implemented.   See the manual pages for each
70       RR type to see what fields the type requires.
71
72       The "name" and "type" fields are required; all others are optional.  If
73       omitted, "ttl" defaults to 0 and "class" defaults to IN.  Omitting the
74       optional fields is useful for creating the empty RDATA sections
75       required for certain dynamic update operations.
76
77   decode
78           ( $rr, $next ) = decode Net::DNS::RR( \$data, $offset, @opaque );
79
80       Decodes a DNS resource record at the specified location within a DNS
81       packet.
82
83       The argument list consists of a reference to the buffer containing the
84       packet data and offset indicating where resource record begins.
85       Remaining arguments, if any, are passed as opaque data to subordinate
86       decoders.
87
88       Returns a "Net::DNS::RR" object and the offset of the next record in
89       the packet.
90
91       An exception is raised if the data buffer contains insufficient or
92       corrupt data.
93
94       Any remaining arguments are passed as opaque data to subordinate
95       decoders and do not form part of the published interface.
96
97   encode
98           $data = $rr->encode( $offset, @opaque );
99
100       Returns the "Net::DNS::RR" in binary format suitable for inclusion in a
101       DNS packet buffer.
102
103       The offset indicates the intended location within the packet data where
104       the "Net::DNS::RR" is to be stored.
105
106       Any remaining arguments are opaque data which are passed intact to
107       subordinate encoders.
108
109   canonical
110           $data = $rr->canonical;
111
112       Returns the "Net::DNS::RR" in canonical binary format suitable for
113       DNSSEC signature validation.
114
115       The absence of the associative array argument signals to subordinate
116       encoders that the canonical uncompressed lower case form of embedded
117       domain names is to be used.
118
119   name
120           $name = $rr->name;
121
122       Returns the owner name of the record.
123
124   type
125           $type = $rr->type;
126
127       Returns the record type.
128
129   class
130           $class = $rr->class;
131
132       Resource record class.
133
134   ttl
135           $ttl = $rr->ttl;
136           $ttl = $rr->ttl(3600);
137
138       Resource record time to live in seconds.
139
140   rdata
141           $rr = new Net::DNS::RR( type => NULL, rdata => 'arbitrary' );
142
143       Resource record data section when viewed as opaque octets.
144
145   print
146           $rr->print;
147
148       Prints the record to the standard output.  Calls the string method to
149       get the RR string representation.
150
151   string
152           print $rr->string, "\n";
153
154       Returns a string representation of the RR using the zone file format
155       described in RFC1035.  All domain names are fully qualified with
156       trailing dot.  This differs from RR attribute methods, which omit the
157       trailing dot.
158
159   rdstring
160           $rdstring = $rr->rdstring;
161
162       Returns a string representation of the RR-specific data.
163

Sorting of RR arrays

165       Sorting of RR arrays is done by Net::DNS::rrsort(), see documentation
166       for Net::DNS. This package provides class methods to set the sorting
167       functions used for a particular RR based on its attributes.
168
169   set_rrsort_func
170           Net::DNS::RR::SRV->set_rrsort_func('priority',
171                                      sub {
172                                          my ($a,$b)=($Net::DNS::a,$Net::DNS::b);
173                                          $a->priority <=> $b->priority
174                                          ||
175                                          $b->weight <=> $a->weight
176                            }
177
178           Net::DNS::RR::SRV->set_rrsort_func('default_sort',
179                                      sub {
180                                          my ($a,$b)=($Net::DNS::a,$Net::DNS::b);
181                                          $a->priority <=> $b->priority
182                                          ||
183                                          $b->weight <=> $a->weight
184                            }
185
186       set_rrsort_func needs to be called as a class method. The first
187       argument is the attribute name on which the sorting will need to take
188       place. If you specify "default_sort" then that is the sort algorithm
189       that will be used in the case that rrsort() is called without an RR
190       attribute as argument.
191
192       The second argument is a reference to a comparison function that uses
193       the global variables $a and $b in the "from Net::DNS"(!!)package.
194       During sorting, the variables $a and $b will contain references to
195       objects of the class from which you called the set_prop_sort. In other
196       words, you can rest assured that the above sorting function will only
197       be applied to Net::DNS::RR::SRV objects.
198
199       The above example is the sorting function implemented in SRV.
200
202       Copyright (c)1997-2002 Michael Fuhr.
203
204       Portions Copyright (c)2002-2004 Chris Reinhardt.
205
206       Portions Copyright (c)2005-2007 Olaf Kolkman.
207
208       Portions Copyright (c)2007,2012 Dick Franks.
209
210       All rights reserved.
211
212       This program is free software; you may redistribute it and/or modify it
213       under the same terms as Perl itself.
214

SEE ALSO

216       perl, Net::DNS, Net::DNS::Question, Net::DNS::Packet, Net::DNS::Update,
217       RFC1035 Section 4.1.3, RFC1123, RFC3597
218
219
220
221perl v5.16.3                      2012-12-28                   Net::DNS::RR(3)
Impressum