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