1package Net::DNS::RR::CNAME; 2# 3# $Id: CNAME.pm 632 2007-03-12 13:24:21Z olaf $ 4# 5use strict; 6BEGIN { 7 eval { require bytes; } 8} 9 10use vars qw(@ISA $VERSION); 11 12@ISA = qw(Net::DNS::RR); 13$VERSION = (qw$LastChangedRevision: 632 $)[1]; 14 15sub new { 16 my ($class, $self, $data, $offset) = @_; 17 18 if ($self->{"rdlength"} > 0) { 19 ($self->{"cname"}) = Net::DNS::Packet::dn_expand($data, $offset); 20 } 21 22 return bless $self, $class; 23} 24 25sub new_from_string { 26 my ($class, $self, $string) = @_; 27 28 if ($string) { 29 $string =~ s/\.+$//; 30 $self->{"cname"} = $string; 31 } 32 33 return bless $self, $class; 34} 35 36sub rdatastr { 37 my $self = shift; 38 39 return $self->{"cname"} ? "$self->{cname}." : ''; 40} 41 42sub rr_rdata { 43 my ($self, $packet, $offset) = @_; 44 my $rdata = ""; 45 46 if (exists $self->{"cname"}) { 47 $rdata = $packet->dn_comp($self->{"cname"}, $offset); 48 } 49 50 return $rdata; 51} 52 53# rdata contains a compressed domainname... we should not have that. 54sub _canonicalRdata { 55 my ($self) = @_; 56 return $self->_name2wire(lc($self->{"cname"})); 57} 58 591; 60__END__ 61 62=head1 NAME 63 64Net::DNS::RR::CNAME - DNS CNAME resource record 65 66=head1 SYNOPSIS 67 68C<use Net::DNS::RR>; 69 70=head1 DESCRIPTION 71 72Class for DNS Canonical Name (CNAME) resource records. 73 74=head1 METHODS 75 76=head2 cname 77 78 print "cname = ", $rr->cname, "\n"; 79 80Returns the RR's canonical name. 81 82=head1 COPYRIGHT 83 84Copyright (c) 1997-2002 Michael Fuhr. 85 86Portions Copyright (c) 2002-2004 Chris Reinhardt. 87 88All rights reserved. This program is free software; you may redistribute 89it and/or modify it under the same terms as Perl itself. 90 91=head1 SEE ALSO 92 93L<perl(1)>, L<Net::DNS>, L<Net::DNS::Resolver>, L<Net::DNS::Packet>, 94L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>, 95RFC 1035 Section 3.3.1 96 97=cut 98