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 / RT.pm < prev    next >
Encoding:
Perl POD Document  |  2004-01-04  |  2.3 KB  |  118 lines

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