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 / PX.pm < prev    next >
Encoding:
Perl POD Document  |  2004-01-04  |  2.7 KB  |  133 lines

  1. package Net::DNS::RR::PX;
  2. #
  3. # $Id: PX.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.         ($self->{"preference"}) = unpack("\@$offset n", $$data);
  19.         $offset += &Net::DNS::INT16SZ;
  20.  
  21.         ($self->{"map822"},  $offset) = Net::DNS::Packet::dn_expand($data, $offset);
  22.         ($self->{"mapx400"}, $offset) = Net::DNS::Packet::dn_expand($data, $offset);
  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+)\s+(\S+)$/)) {
  32.         $self->{"preference"} = $1;
  33.         $self->{"map822"}     = $2;
  34.         $self->{"mapx400"}    = $3;
  35.         $self->{"map822"}     =~ s/\.+$//;;
  36.         $self->{"mapx400"}    =~ s/\.+$//;;
  37.     }
  38.  
  39.     return bless $self, $class;
  40. }
  41.  
  42. sub rdatastr {
  43.     my $self = shift;
  44.  
  45.     return $self->{"preference"}
  46.            ? "$self->{preference} $self->{map822}. $self->{mapx400}."
  47.            : '';
  48. }
  49.  
  50. sub rr_rdata {
  51.     my ($self, $packet, $offset) = @_;
  52.     my $rdata = "";
  53.  
  54.     if (exists $self->{"preference"}) {
  55.         $rdata .= pack("n", $self->{"preference"});
  56.  
  57.         $rdata .= $packet->dn_comp($self->{"map822"},
  58.                         $offset + length $rdata);
  59.  
  60.         $rdata .= $packet->dn_comp($self->{"mapx400"},
  61.                         $offset + length $rdata);
  62.     }
  63.  
  64.     return $rdata;
  65. }
  66.  
  67.  
  68. sub _canonicalRdata {
  69.     my ($self) = shift;
  70.     my $rdata = "";
  71.  
  72.     if (exists $self->{"preference"}) {
  73.         $rdata .= pack("n", $self->{"preference"});
  74.         $rdata .= $self->_name2wire($self->{"map822"});                       
  75.         $rdata .= $self->_name2wire($self->{"mapx400"});
  76.     }
  77.  
  78.     return $rdata;
  79. }
  80.  
  81.  
  82. 1;
  83. __END__
  84.  
  85. =head1 NAME
  86.  
  87. Net::DNS::RR::PX - DNS PX resource record
  88.  
  89. =head1 SYNOPSIS
  90.  
  91. C<use Net::DNS::RR>;
  92.  
  93. =head1 DESCRIPTION
  94.  
  95. Class for DNS X.400 Mail Mapping Information (PX) resource records.
  96.  
  97. =head1 METHODS
  98.  
  99. =head2 preference
  100.  
  101.     print "preference = ", $rr->preference, "\n";
  102.  
  103. Returns the preference given to this RR.
  104.  
  105. =head2 map822
  106.  
  107.     print "map822 = ", $rr->map822, "\n";
  108.  
  109. Returns the RFC822 part of the RFC1327 mapping information.
  110.  
  111. =head2 mapx400
  112.  
  113.     print "mapx400 = ", $rr->mapx400, "\n";
  114.  
  115. Returns the X.400 part of the RFC1327 mapping information.
  116.  
  117. =head1 COPYRIGHT
  118.  
  119. Copyright (c) 1997-2002 Michael Fuhr. 
  120.  
  121. Portions Copyright (c) 2002-2003 Chris Reinhardt.
  122.  
  123. All rights reserved.  This program is free software; you may redistribute
  124. it and/or modify it under the same terms as Perl itself.
  125.  
  126. =head1 SEE ALSO
  127.  
  128. L<perl(1)>, L<Net::DNS>, L<Net::DNS::Resolver>, L<Net::DNS::Packet>,
  129. L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>,
  130. RFC822, RFC 1327, RFC 2163
  131.  
  132. =cut
  133.