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 / SRV.pm < prev    next >
Encoding:
Perl POD Document  |  2004-01-04  |  2.6 KB  |  136 lines

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