1package Net::DNS::RR::ISDN;
2#
3# $Id: ISDN.pm 388 2005-06-22 10:06:05Z olaf $
4#
5use strict;
6BEGIN {
7    eval { require bytes; }
8}
9use vars qw(@ISA $VERSION);
10
11@ISA     = qw(Net::DNS::RR);
12$VERSION = (qw$LastChangedRevision: 388 $)[1];
13
14sub new {
15	my ($class, $self, $data, $offset) = @_;
16
17	if ($self->{"rdlength"} > 0) {
18		my ($address, $sa, $len);
19
20		($len) = unpack("\@$offset C", $$data);
21		++$offset;
22		$address = substr($$data, $offset, $len);
23		$offset += $len;
24
25		if ($len + 1 < $self->{"rdlength"}) {
26			($len) = unpack("\@$offset C", $$data);
27			++$offset;
28			$sa = substr($$data, $offset, $len);
29			$offset += $len;
30		}
31		else {
32			$sa = "";
33		}
34
35		$self->{"address"} = $address;
36		$self->{"sa"}  = $sa;
37	}
38
39	return bless $self, $class;
40}
41
42sub new_from_string {
43	my ($class, $self, $string) = @_;
44
45	if ($string && $string =~ /^['"](.*?)['"](.*)/s) {
46		$self->{"address"} = $1;
47		my $rest = $2;
48
49		if ($rest =~ /^\s+['"](.*?)['"]$/) {
50			$self->{"sa"} = $1;
51		}
52		else {
53			$self->{"sa"} = "";
54		}
55	}
56
57	return bless $self, $class;
58}
59
60sub rdatastr {
61	my $self = shift;
62
63	return $self->{"address"}
64	       ? qq("$self->{address}" "$self->{sa}")
65	       : '';
66}
67
68sub rr_rdata {
69	my $self = shift;
70	my $rdata = "";
71
72	if (exists $self->{"address"}) {
73		$rdata .= pack("C", length $self->{"address"});
74		$rdata .= $self->{"address"};
75
76		if ($self->{"sa"}) {
77			$rdata .= pack("C", length $self->{"sa"});
78			$rdata .= $self->{"sa"};
79		}
80	}
81
82	return $rdata;
83}
84
851;
86__END__
87
88=head1 NAME
89
90Net::DNS::RR::ISDN - DNS ISDN resource record
91
92=head1 SYNOPSIS
93
94C<use Net::DNS::RR>;
95
96=head1 DESCRIPTION
97
98Class for DNS ISDN resource records.
99
100=head1 METHODS
101
102=head2 address
103
104    print "address = ", $rr->address, "\n";
105
106Returns the RR's address field.
107
108=head2 sa
109
110    print "subaddress = ", $rr->sa, "\n";
111
112Returns the RR's subaddress field.
113
114=head1 COPYRIGHT
115
116Copyright (c) 1997-2002 Michael Fuhr.
117
118Portions Copyright (c) 2002-2004 Chris Reinhardt.
119
120All rights reserved.  This program is free software; you may redistribute
121it and/or modify it under the same terms as Perl itself.
122
123=head1 SEE ALSO
124
125L<perl(1)>, L<Net::DNS>, L<Net::DNS::Resolver>, L<Net::DNS::Packet>,
126L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>,
127RFC 1183 Section 3.2
128
129=cut
130