home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / AFSDB.pm < prev    next >
Encoding:
Perl POD Document  |  2004-01-04  |  2.4 KB  |  121 lines

  1. package Net::DNS::RR::AFSDB;
  2. #
  3. # $Id: AFSDB.pm,v 2.101 2004/01/04 04:31:10 ctriv Exp $
  4. #
  5. use strict;
  6. use vars qw(@ISA $VERSION);
  7.  
  8. use Net::DNS;
  9. use Net::DNS::Packet;
  10.  
  11. @ISA     = qw(Net::DNS::RR);
  12. $VERSION = (qw$Revision: 2.101 $)[1];
  13.  
  14. sub new {
  15.     my ($class, $self, $data, $offset) = @_;
  16.  
  17.     if ($self->{"rdlength"} > 0) {
  18.         my ($subtype) = unpack("\@$offset n", $$data);
  19.         $offset += &Net::DNS::INT16SZ;
  20.         my($hostname) = Net::DNS::Packet::dn_expand($data, $offset);
  21.         $self->{"subtype"} = $subtype;
  22.         $self->{"hostname"} = $hostname;
  23.     }
  24.  
  25.     return bless $self, $class;
  26. }
  27.  
  28. sub new_from_string {
  29.     my ($class, $self, $string) = @_;
  30.  
  31.     if ($string && ($string =~ /^(\d+)\s+(\S+)$/)) {
  32.         $self->{"subtype"}  = $1;
  33.         $self->{"hostname"} = $2;
  34.         $self->{"hostname"} =~ s/\.+$//;;
  35.     }
  36.  
  37.     return bless $self, $class;
  38. }
  39.  
  40. sub rdatastr {
  41.     my $self = shift;
  42.  
  43.     return exists $self->{"subtype"}
  44.            ? "$self->{subtype} $self->{hostname}."
  45.            : '';
  46. }
  47.  
  48. sub rr_rdata {
  49.     my ($self, $packet, $offset) = @_;
  50.     my $rdata = "";
  51.  
  52.     if (exists $self->{"subtype"}) {
  53.         $rdata .= pack("n", $self->{"subtype"});
  54.         $rdata .= $packet->dn_comp($self->{"hostname"},
  55.                        $offset + length $rdata);
  56.     }
  57.  
  58.     return $rdata;
  59. }
  60.  
  61.  
  62.  
  63. sub _canonicalRdata {
  64.     # rdata contains a compressed domainname... we should not have that.
  65.     my ($self) = @_;
  66.     my $rdata;
  67.     if (exists $self->{"subtype"}) {
  68.         $rdata .= pack("n", $self->{"subtype"});
  69.         $rdata .=  $self->_name2wire($self->{"hostname"});
  70.     }
  71.     return $rdata;
  72. }
  73.  
  74.  
  75. 1;
  76. __END__
  77.  
  78. =head1 NAME
  79.  
  80. Net::DNS::RR::AFSDB - DNS AFSDB resource record
  81.  
  82. =head1 SYNOPSIS
  83.  
  84. C<use Net::DNS::RR>;
  85.  
  86. =head1 DESCRIPTION
  87.  
  88. Class for DNS AFS Data Base (AFSDB) resource records.
  89.  
  90. =head1 METHODS
  91.  
  92. =head2 subtype
  93.  
  94.     print "subtype = ", $rr->subtype, "\n";
  95.  
  96. Returns the RR's subtype field.  Use of the subtype field is documented
  97. in RFC 1183.
  98.  
  99. =head2 hostname
  100.  
  101.     print "hostname = ", $rr->hostname, "\n";
  102.  
  103. Returns the RR's hostname field.  See RFC 1183.
  104.  
  105. =head1 COPYRIGHT
  106.  
  107. Copyright (c) 1997-2002 Michael Fuhr. 
  108.  
  109. Portions Copyright (c) 2002-2003 Chris Reinhardt.
  110.  
  111. All rights reserved.  This program is free software; you may redistribute
  112. it and/or modify it under the same terms as Perl itself.
  113.  
  114. =head1 SEE ALSO
  115.  
  116. L<perl(1)>, L<Net::DNS>, L<Net::DNS::Resolver>, L<Net::DNS::Packet>,
  117. L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>,
  118. RFC 1183 Section 1
  119.  
  120. =cut
  121.