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

NAME

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

SYNOPSIS

9       "use Net::DNS::RR"
10

DESCRIPTION

12       "Net::DNS::RR" is the base class for DNS Resource Record (RR) objects.
13       See also the manual pages for each RR type.
14

METHODS

16       WARNING!!!  Don't assume the RR objects you receive from a query are of
17       a particular type -- always check an object's type before calling any
18       of its methods.  If you call an unknown method, you'll get a nasty
19       warning message and "Net::DNS::RR" will return "undef" to the caller.
20
21       new (from string)
22
23        $a     = Net::DNS::RR->new("foo.example.com. 86400 A 10.1.2.3");
24        $mx    = Net::DNS::RR->new("example.com. 7200 MX 10 mailhost.example.com.");
25        $cname = Net::DNS::RR->new("www.example.com 300 IN CNAME www1.example.com");
26        $txt   = Net::DNS::RR->new('baz.example.com 3600 HS TXT "text record"');
27
28       Returns a "Net::DNS::RR" object of the appropriate type and initialized
29       from the string passed by the user.  The format of the string is that
30       used in zone files, and is compatible with the string returned by
31       "Net::DNS::RR->string".
32
33       The name and RR type are required; all other information is optional.
34       If omitted, the TTL defaults to 0 and the RR class defaults to IN.
35       Omitting the optional fields is useful for creating the empty RDATA
36       sections required for certain dynamic update operations.  See the
37       "Net::DNS::Update" manual page for additional examples.
38
39       All names must be fully qualified.  The trailing dot (.) is optional.
40
41       new (from hash)
42
43        $rr = Net::DNS::RR->new(
44                name    => "foo.example.com",
45                ttl     => 86400,
46                class   => "IN",
47                type    => "A",
48                address => "10.1.2.3",
49        );
50
51        $rr = Net::DNS::RR->new(
52                name => "foo.example.com",
53                type => "A",
54        );
55
56       Returns an RR object of the appropriate type, or a "Net::DNS::RR"
57       object if the type isn't implemented.  See the manual pages for each RR
58       type to see what fields the type requires.
59
60       The "Name" and "Type" fields are required; all others are optional.  If
61       omitted, "TTL" defaults to 0 and "Class" defaults to IN.  Omitting the
62       optional fields is useful for creating the empty RDATA sections
63       required for certain dynamic update operations.
64
65       The fields are case-insensitive, but starting each with uppercase is
66       recommended.
67
68       print
69
70           $rr->print;
71
72       Prints the record to the standard output.  Calls the string method to
73       get the RR's string representation.
74
75       string
76
77           print $rr->string, "\n";
78
79       Returns a string representation of the RR.  Calls the rdatastr method
80       to get the RR-specific data.
81
82       rdatastr
83
84           $s = $rr->rdatastr;
85
86       Returns a string containing RR-specific data.  Subclasses will need to
87       implement this method.
88
89       name
90
91           $name = $rr->name;
92
93       Returns the record's domain name.
94
95       type
96
97           $type = $rr->type;
98
99       Returns the record's type.
100
101       class
102
103           $class = $rr->class;
104
105       Returns the record's class.
106
107       ttl
108
109           $ttl = $rr->ttl;
110
111       Returns the record's time-to-live (TTL).
112
113       rdlength
114
115           $rdlength = $rr->rdlength;
116
117       Returns the length of the record's data section.
118
119       rdata
120
121           $rdata = $rr->rdata
122
123       Returns the record's data section as binary data.
124

Sorting of RR arrays

126       As of version 0.55 there is functionality to help you sort RR arrays.
127       The sorting is done by Net::DNS::rrsort(), see the Net::DNS documenta‐
128       tion. This package provides class methods to set the sorting functions
129       used for a particular RR based on a particular attribute.
130
131       set_rrsort_func
132
133       Net::DNS::RR::SRV->set_rrsort_func("priority",
134       sub {                        my ($a,$b)=($Net::DNS::a,$Net::DNS::b);
135                              $a->priority <=> $b->priority
136                              ⎪⎪                        $b->weight <=>
137       $a->weight
138                            }
139
140       Net::DNS::RR::SRV->set_rrsort_func("default_sort",
141       sub {                        my ($a,$b)=($Net::DNS::a,$Net::DNS::b);
142                              $a->priority <=> $b->priority
143                              ⎪⎪                        $b->weight <=>
144       $a->weight
145                            }
146
147       set_rrsort_func needs to be called as a class method. The first argu‐
148       ment is the attribute name on which the sorting will need to take
149       place. If you specify "default_sort" than that is the sort algorithm
150       that will be used in the case that rrsort() is called without an RR
151       attribute as argument.
152
153       The second argument is a reference to a function that uses the vari‐
154       ables $a and $b global to the "from Net::DNS"(!!)package for the sort‐
155       ing. During the sorting $a and $b will contain references to objects
156       from the class you called the set_prop_sort from. In other words, you
157       can rest assured that the above sorting function will only get
158       Net::DNS::RR::SRV objects.
159
160       The above example is the sorting function that actually is implemented
161       in SRV.
162

BUGS

164       This version of "Net::DNS::RR" does little sanity checking on user-cre‐
165       ated RR objects.
166
168       Copyright (c) 1997-2002 Michael Fuhr.
169
170       Portions Copyright (c) 2002-2004 Chris Reinhardt.
171
172       Portions Copyright (c) 2005 Olaf Kolkman
173
174       All rights reserved.  This program is free software; you may redis‐
175       tribute it and/or modify it under the same terms as Perl itself.
176
177       EDNS0 extensions by Olaf Kolkman.
178

SEE ALSO

180       perl(1), Net::DNS, Net::DNS::Resolver, Net::DNS::Packet,
181       Net::DNS::Update, Net::DNS::Header, Net::DNS::Question, RFC 1035 Sec‐
182       tion 4.1.3
183
184
185
186perl v5.8.8                       2007-08-01                   Net::DNS::RR(3)
Impressum