Net_DNS
[ class tree: Net_DNS ] [ index: Net_DNS ] [ all elements ]

Source for file SRV.php

Documentation is available at SRV.php

  1. <?php
  2. /*
  3.  *  License Information:
  4.  *
  5.  *    Net_DNS:  A resolver library for PHP
  6.  *    Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
  7.  *
  8.  *    This library is free software; you can redistribute it and/or
  9.  *    modify it under the terms of the GNU Lesser General Public
  10.  *    License as published by the Free Software Foundation; either
  11.  *    version 2.1 of the License, or (at your option) any later version.
  12.  *
  13.  *    This library is distributed in the hope that it will be useful,
  14.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  *    Lesser General Public License for more details.
  17.  *
  18.  *    You should have received a copy of the GNU Lesser General Public
  19.  *    License along with this library; if not, write to the Free Software
  20.  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  */
  22.  
  23. /* Net_DNS_RR_SRV definition {{{ */
  24. /**
  25.  * A representation of a resource record of type <b>SRV</b>
  26.  *
  27.  * @package Net_DNS
  28.  */
  29. class Net_DNS_RR_SRV extends Net_DNS_RR
  30. {
  31.     /* class variable definitions {{{ */
  32.     var $name;
  33.     var $type;
  34.     var $class;
  35.     var $ttl;
  36.     var $rdlength;
  37.     var $rdata;
  38.     var $preference;
  39.     var $weight;
  40.     var $port;
  41.     var $target;
  42.  
  43.     /* }}} */
  44.     /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
  45.     function Net_DNS_RR_SRV(&$rro$data$offset '')
  46.     {
  47.         $this->name = $rro->name;
  48.         $this->type = $rro->type;
  49.         $this->class = $rro->class;
  50.         $this->ttl = $rro->ttl;
  51.         $this->rdlength = $rro->rdlength;
  52.         $this->rdata = $rro->rdata;
  53.  
  54.         if ($offset{
  55.             if ($this->rdlength > 0{
  56.                 $a unpack("@$offset/npreference/nweight/nport"$data);
  57.                 $offset += 6;
  58.                 list($target$offsetNet_DNS_Packet::dn_expand($data$offset);
  59.                 $this->preference = $a['preference'];
  60.                 $this->weight = $a['weight'];
  61.                 $this->port = $a['port'];
  62.                 $this->target = $target;
  63.             }
  64.         else {
  65.             ereg("([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*$"$data$regs);
  66.             $this->preference = $regs[1];
  67.             $this->weight = $regs[2];
  68.             $this->port = $regs[3];
  69.             $this->target = ereg_replace('(.*)\.$''\\1'$regs[4]);
  70.         }
  71.     }
  72.  
  73.     /* }}} */
  74.     /* Net_DNS_RR_SRV::rdatastr() {{{ */
  75.     function rdatastr()
  76.     {
  77.         if ($this->port{
  78.             return intval($this->preference' ' intval($this->weight' ' intval($this->port' ' $this->target . '.';
  79.         }
  80.         return '; no data';
  81.     }
  82.  
  83.     /* }}} */
  84.     /* Net_DNS_RR_SRV::rr_rdata($packet, $offset) {{{ */
  85.     function rr_rdata($packet$offset)
  86.     {
  87.         if (isset($this->preference)) {
  88.             $rdata pack('nnn'$this->preference$this->weight$this->port);
  89.             $rdata .= $packet->dn_comp($this->target$offset strlen($rdata));
  90.             return $rdata;
  91.         }
  92.         return null;
  93.     }
  94.  
  95.     /* }}} */
  96. }
  97. /* }}} */
  98. /* VIM settings {{{
  99.  * Local variables:
  100.  * tab-width: 4
  101.  * c-basic-offset: 4
  102.  * soft-stop-width: 4
  103.  * c indent on
  104.  * End:
  105.  * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
  106.  * vim<600: sw=4 ts=4
  107.  * }}} */
  108. ?>

Documentation generated on Mon, 11 Mar 2019 14:35:57 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.