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 / MX.pm < prev    next >
Encoding:
Perl POD Document  |  2004-02-10  |  2.3 KB  |  119 lines

  1. package Net::DNS::RR::MX;
  2. #
  3. # $Id: MX.pm,v 2.102 2004/02/09 23:28:31 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.102 $)[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.         
  20.         $offset += &Net::DNS::INT16SZ;
  21.         
  22.         ($self->{"exchange"}) = 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+)$/)) {
  32.         $self->{"preference"} = $1;
  33.         $self->{"exchange"}   = $2;
  34.         $self->{"exchange"}   =~ s/\.+$//;;
  35.     }
  36.  
  37.     return bless $self, $class;
  38. }
  39.  
  40. sub rdatastr {
  41.     my $self = shift;
  42.  
  43.     return defined $self->{"preference"}
  44.            ? "$self->{preference} $self->{exchange}."
  45.            : '';
  46. }
  47.  
  48. sub rr_rdata {
  49.     my ($self, $packet, $offset) = @_;
  50.     my $rdata = "";
  51.  
  52.     if (exists $self->{"preference"}) {
  53.         $rdata .= pack("n", $self->{"preference"});
  54.         $rdata .= $packet->dn_comp($self->{"exchange"},
  55.                        $offset + length $rdata);
  56.     }
  57.  
  58.     return $rdata;
  59. }
  60.  
  61. sub _canonicalRdata {
  62.     my ($self) = @_;
  63.     my $rdata = "";
  64.     
  65.     if (exists $self->{"preference"}) {
  66.     $rdata .= pack("n", $self->{"preference"});
  67.     $rdata .= $self->_name2wire($self->{"exchange"})
  68.     }
  69.     
  70.     return $rdata;
  71. }
  72.  
  73.  
  74. 1;
  75. __END__
  76.  
  77. =head1 NAME
  78.  
  79. Net::DNS::RR::MX - DNS MX resource record
  80.  
  81. =head1 SYNOPSIS
  82.  
  83. C<use Net::DNS::RR>;
  84.  
  85. =head1 DESCRIPTION
  86.  
  87. Class for DNS Mail Exchanger (MX) resource records.
  88.  
  89. =head1 METHODS
  90.  
  91. =head2 preference
  92.  
  93.     print "preference = ", $rr->preference, "\n";
  94.  
  95. Returns the preference for this mail exchange.
  96.  
  97. =head2 exchange
  98.  
  99.     print "exchange = ", $rr->exchange, "\n";
  100.  
  101. Returns name of this mail exchange.
  102.  
  103. =head1 COPYRIGHT
  104.  
  105. Copyright (c) 1997-2002 Michael Fuhr. 
  106.  
  107. Portions Copyright (c) 2002-2003 Chris Reinhardt.
  108.  
  109. All rights reserved.  This program is free software; you may redistribute
  110. it and/or modify it under the same terms as Perl itself.
  111.  
  112. =head1 SEE ALSO
  113.  
  114. L<perl(1)>, L<Net::DNS>, L<Net::DNS::Resolver>, L<Net::DNS::Packet>,
  115. L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>,
  116. RFC 1035 Section 3.3.9
  117.  
  118. =cut
  119.