1package Net::DNS::RR::NAPTR;
2
3use strict;
4use warnings;
5our $VERSION = (qw$Id: NAPTR.pm 1814 2020-10-14 21:49:16Z willem $)[2];
6
7use base qw(Net::DNS::RR);
8
9
10=head1 NAME
11
12Net::DNS::RR::NAPTR - DNS NAPTR resource record
13
14=cut
15
16use integer;
17
18use Net::DNS::DomainName;
19use Net::DNS::Text;
20
21
22sub _decode_rdata {			## decode rdata from wire-format octet string
23	my $self = shift;
24	my ( $data, $offset, @opaque ) = @_;
25
26	@{$self}{qw(order preference)} = unpack "\@$offset n2", $$data;
27	( $self->{flags},   $offset ) = Net::DNS::Text->decode( $data, $offset + 4 );
28	( $self->{service}, $offset ) = Net::DNS::Text->decode( $data, $offset );
29	( $self->{regexp},  $offset ) = Net::DNS::Text->decode( $data, $offset );
30	$self->{replacement} = Net::DNS::DomainName2535->decode( $data, $offset, @opaque );
31	return;
32}
33
34
35sub _encode_rdata {			## encode rdata as wire-format octet string
36	my $self = shift;
37	my ( $offset, @opaque ) = @_;
38
39	my $rdata = pack 'n2', @{$self}{qw(order preference)};
40	$rdata .= $self->{flags}->encode;
41	$rdata .= $self->{service}->encode;
42	$rdata .= $self->{regexp}->encode;
43	$rdata .= $self->{replacement}->encode( $offset + length($rdata), @opaque );
44	return $rdata;
45}
46
47
48sub _format_rdata {			## format rdata portion of RR string.
49	my $self = shift;
50
51	my @order = @{$self}{qw(order preference)};
52	my @rdata = ( @order, map { $_->string } @{$self}{qw(flags service regexp replacement)} );
53	return @rdata;
54}
55
56
57sub _parse_rdata {			## populate RR from rdata in argument list
58	my $self = shift;
59
60	foreach (qw(order preference flags service regexp replacement)) { $self->$_(shift) }
61	return;
62}
63
64
65sub order {
66	my $self = shift;
67
68	$self->{order} = 0 + shift if scalar @_;
69	return $self->{order} || 0;
70}
71
72
73sub preference {
74	my $self = shift;
75
76	$self->{preference} = 0 + shift if scalar @_;
77	return $self->{preference} || 0;
78}
79
80
81sub flags {
82	my $self = shift;
83
84	$self->{flags} = Net::DNS::Text->new(shift) if scalar @_;
85	return $self->{flags} ? $self->{flags}->value : undef;
86}
87
88
89sub service {
90	my $self = shift;
91
92	$self->{service} = Net::DNS::Text->new(shift) if scalar @_;
93	return $self->{service} ? $self->{service}->value : undef;
94}
95
96
97sub regexp {
98	my $self = shift;
99
100	$self->{regexp} = Net::DNS::Text->new(shift) if scalar @_;
101	return $self->{regexp} ? $self->{regexp}->value : undef;
102}
103
104
105sub replacement {
106	my $self = shift;
107
108	$self->{replacement} = Net::DNS::DomainName2535->new(shift) if scalar @_;
109	return $self->{replacement} ? $self->{replacement}->name : undef;
110}
111
112
113my $function = sub {
114	my ( $a, $b ) = ( $Net::DNS::a, $Net::DNS::b );
115	return $a->{order} <=> $b->{order}
116			|| $a->{preference} <=> $b->{preference};
117};
118
119__PACKAGE__->set_rrsort_func( 'order', $function );
120
121__PACKAGE__->set_rrsort_func( 'default_sort', $function );
122
123
1241;
125__END__
126
127
128=head1 SYNOPSIS
129
130    use Net::DNS;
131    $rr = Net::DNS::RR->new('name NAPTR order preference flags service regexp replacement');
132
133=head1 DESCRIPTION
134
135DNS Naming Authority Pointer (NAPTR) resource records.
136
137=head1 METHODS
138
139The available methods are those inherited from the base class augmented
140by the type-specific methods defined in this package.
141
142Use of undocumented package features or direct access to internal data
143structures is discouraged and could result in program termination or
144other unpredictable behaviour.
145
146
147=head2 order
148
149    $order = $rr->order;
150    $rr->order( $order );
151
152A 16-bit unsigned integer specifying the order in which the NAPTR
153records must be processed to ensure the correct ordering of rules.
154Low numbers are processed before high numbers.
155
156=head2 preference
157
158    $preference = $rr->preference;
159    $rr->preference( $preference );
160
161A 16-bit unsigned integer that specifies the order in which NAPTR
162records with equal "order" values should be processed, low numbers
163being processed before high numbers.
164
165=head2 flags
166
167    $flags = $rr->flags;
168    $rr->flags( $flags );
169
170A string containing flags to control aspects of the rewriting and
171interpretation of the fields in the record.  Flags are single
172characters from the set [A-Z0-9].
173
174=head2 service
175
176    $service = $rr->service;
177    $rr->service( $service );
178
179Specifies the service(s) available down this rewrite path. It may
180also specify the protocol used to communicate with the service.
181
182=head2 regexp
183
184    $regexp = $rr->regexp;
185    $rr->regexp;
186
187A string containing a substitution expression that is applied to
188the original string held by the client in order to construct the
189next domain name to lookup.
190
191=head2 replacement
192
193    $replacement = $rr->replacement;
194    $rr->replacement( $replacement );
195
196The next NAME to query for NAPTR, SRV, or address records
197depending on the value of the flags field.
198
199
200=head1 COPYRIGHT
201
202Copyright (c)1997 Michael Fuhr.
203
204Portions Copyright (c)2005 Olaf Kolkman, NLnet Labs.
205
206Based on code contributed by Ryan Moats.
207
208All rights reserved.
209
210Package template (c)2009,2012 O.M.Kolkman and R.W.Franks.
211
212
213=head1 LICENSE
214
215Permission to use, copy, modify, and distribute this software and its
216documentation for any purpose and without fee is hereby granted, provided
217that the above copyright notice appear in all copies and that both that
218copyright notice and this permission notice appear in supporting
219documentation, and that the name of the author not be used in advertising
220or publicity pertaining to distribution of the software without specific
221prior written permission.
222
223THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
224IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
225FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
226THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
227LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
228FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
229DEALINGS IN THE SOFTWARE.
230
231
232=head1 SEE ALSO
233
234L<perl>, L<Net::DNS>, L<Net::DNS::RR>, RFC2915, RFC2168, RFC3403
235
236=cut
237