1package Net::DNS::RR::RT;
2
3use strict;
4use warnings;
5our $VERSION = (qw$Id: RT.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::RT - DNS RT resource record
13
14=cut
15
16use integer;
17
18use Net::DNS::DomainName;
19
20
21sub _decode_rdata {			## decode rdata from wire-format octet string
22	my $self = shift;
23	my ( $data, $offset, @opaque ) = @_;
24
25	$self->{preference}   = unpack( "\@$offset n", $$data );
26	$self->{intermediate} = Net::DNS::DomainName2535->decode( $data, $offset + 2, @opaque );
27	return;
28}
29
30
31sub _encode_rdata {			## encode rdata as wire-format octet string
32	my $self = shift;
33	my ( $offset, @opaque ) = @_;
34
35	return pack 'n a*', $self->preference, $self->{intermediate}->encode( $offset + 2, @opaque );
36}
37
38
39sub _format_rdata {			## format rdata portion of RR string.
40	my $self = shift;
41
42	return join ' ', $self->preference, $self->{intermediate}->string;
43}
44
45
46sub _parse_rdata {			## populate RR from rdata in argument list
47	my $self = shift;
48
49	$self->preference(shift);
50	$self->intermediate(shift);
51	return;
52}
53
54
55sub preference {
56	my $self = shift;
57
58	$self->{preference} = 0 + shift if scalar @_;
59	return $self->{preference} || 0;
60}
61
62
63sub intermediate {
64	my $self = shift;
65
66	$self->{intermediate} = Net::DNS::DomainName2535->new(shift) if scalar @_;
67	return $self->{intermediate} ? $self->{intermediate}->name : undef;
68}
69
70
71my $function = sub {			## sort RRs in numerically ascending order.
72	return $Net::DNS::a->{'preference'} <=> $Net::DNS::b->{'preference'};
73};
74
75__PACKAGE__->set_rrsort_func( 'preference', $function );
76
77__PACKAGE__->set_rrsort_func( 'default_sort', $function );
78
79
801;
81__END__
82
83
84=head1 SYNOPSIS
85
86    use Net::DNS;
87    $rr = Net::DNS::RR->new('name RT preference intermediate');
88
89=head1 DESCRIPTION
90
91Class for DNS Route Through (RT) resource records.
92
93=head1 METHODS
94
95The available methods are those inherited from the base class augmented
96by the type-specific methods defined in this package.
97
98Use of undocumented package features or direct access to internal data
99structures is discouraged and could result in program termination or
100other unpredictable behaviour.
101
102
103=head2 preference
104
105    $preference = $rr->preference;
106    $rr->preference( $preference );
107
108 A 16 bit integer representing the preference of the route.
109Smaller numbers indicate more preferred routes.
110
111=head2 intermediate
112
113    $intermediate = $rr->intermediate;
114    $rr->intermediate( $intermediate );
115
116The domain name of a host which will serve as an intermediate
117in reaching the host specified by the owner name.
118The DNS RRs associated with the intermediate host are expected
119to include at least one A, X25, or ISDN record.
120
121
122=head1 COPYRIGHT
123
124Copyright (c)1997 Michael Fuhr.
125
126All rights reserved.
127
128Package template (c)2009,2012 O.M.Kolkman and R.W.Franks.
129
130
131=head1 LICENSE
132
133Permission to use, copy, modify, and distribute this software and its
134documentation for any purpose and without fee is hereby granted, provided
135that the above copyright notice appear in all copies and that both that
136copyright notice and this permission notice appear in supporting
137documentation, and that the name of the author not be used in advertising
138or publicity pertaining to distribution of the software without specific
139prior written permission.
140
141THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
142IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
143FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
144THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
145LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
146FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
147DEALINGS IN THE SOFTWARE.
148
149
150=head1 SEE ALSO
151
152L<perl>, L<Net::DNS>, L<Net::DNS::RR>, RFC1183 Section 3.3
153
154=cut
155