当前位置: 首页>>代码示例>>PHP>>正文


PHP Net_DNS2_Packet::expand方法代码示例

本文整理汇总了PHP中Net_DNS2_Packet::expand方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_DNS2_Packet::expand方法的具体用法?PHP Net_DNS2_Packet::expand怎么用?PHP Net_DNS2_Packet::expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_DNS2_Packet的用法示例。


在下文中一共展示了Net_DNS2_Packet::expand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rrSet

    /**
     * parses the rdata of the Net_DNS2_Packet object
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
     *
     * @return boolean
     * @access protected
     *
     */
    protected function rrSet(Net_DNS2_Packet &$packet)
    {
        if ($this->rdlength > 0) {

            //
            // unpack the algorithm and length values
            //
            $x = unpack('Chit_length/Cpk_algorithm/npk_length', $this->rdata);

            $this->hit_length   = $x['hit_length'];
            $this->pk_algorithm = $x['pk_algorithm'];
            $this->pk_length    = $x['pk_length'];

            $offset = 4;

            //
            // copy out the HIT value
            //
            $hit = unpack('H*', substr($this->rdata, $offset, $this->hit_length));
            
            $this->hit = strtoupper($hit[1]);
            $offset += $this->hit_length;

            //
            // copy out the public key
            //
            $this->public_key = base64_encode(
                substr($this->rdata, $offset, $this->pk_length)
            );
            $offset += $this->pk_length;

            //
            // copy out any possible rendezvous servers
            //
            $offset = $packet->offset + $offset;

            while ( ($offset - $packet->offset) < $this->rdlength) {

                $this->rendezvous_servers[] = Net_DNS2_Packet::expand(
                    $packet, $offset
                );
            }

            return true;
        }

        return false;
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:57,代码来源:HIP.php

示例2: rrSet

    /**
     * parses the rdata of the Net_DNS2_Packet object
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
     *
     * @return boolean
     * @access protected
     *
     */
    protected function rrSet(Net_DNS2_Packet &$packet)
    {
        if ($this->rdlength > 0) {

            //
            // parse the preference
            //
            $x = unpack('npreference', $this->rdata);
            $this->preference = $x['preference'];

            $offset         = $packet->offset + 2;

            $this->map822   = Net_DNS2_Packet::expand($packet, $offset);
            $this->mapx400  = Net_DNS2_Packet::expand($packet, $offset);

            return true;
        }

        return false;
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:29,代码来源:PX.php

示例3: rrSet

 /**
  * parses the rdata of the Net_DNS2_Packet object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
  *
  * @return boolean
  * @access protected
  *
  */
 protected function rrSet(Net_DNS2_Packet &$packet)
 {
     if ($this->rdlength > 0) {
         //
         // unpack
         //
         $x = unpack('ntc/Calgorithm/Clabels/Norigttl/Nsigexp/Nsigincep/nkeytag', $this->rdata);
         $this->typecovered = Net_DNS2_Lookups::$rr_types_by_id[$x['tc']];
         $this->algorithm = $x['algorithm'];
         $this->labels = $x['labels'];
         $this->origttl = $x['origttl'];
         //
         // the dates are in GM time
         //
         $this->sigexp = gmdate('YmdHis', $x['sigexp']);
         $this->sigincep = gmdate('YmdHis', $x['sigincep']);
         //
         // get the keytag
         //
         $this->keytag = $x['keytag'];
         //
         // get teh signers name and signature
         //
         $offset = $packet->offset + 18;
         $sigoffset = $offset;
         $this->signname = strtolower(Net_DNS2_Packet::expand($packet, $sigoffset));
         $this->signature = base64_encode(substr($this->rdata, 18 + ($sigoffset - $offset)));
         return true;
     }
     return false;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:40,代码来源:SIG.php

示例4: expand

 /**
  * expands the domain name stored at a given offset in a DNS Packet
  *
  * This logic was based on the Net::DNS::Packet::dn_expand() function
  * by Michanel Fuhr
  *
  * @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name
  * @param integer         &$offset the offset into the given packet object
  *
  * @return mixed either the domain name or null if it's not found.
  * @access public
  *
  */
 public static function expand(Net_DNS2_Packet &$packet, &$offset)
 {
     $name = '';
     while (1) {
         if ($packet->rdlength < $offset + 1) {
             return null;
         }
         $xlen = ord($packet->rdata[$offset]);
         if ($xlen == 0) {
             ++$offset;
             break;
         } else {
             if (($xlen & 0xc0) == 0xc0) {
                 if ($packet->rdlength < $offset + 2) {
                     return null;
                 }
                 $ptr = ord($packet->rdata[$offset]) << 8 | ord($packet->rdata[$offset + 1]);
                 $ptr = $ptr & 0x3fff;
                 $name2 = Net_DNS2_Packet::expand($packet, $ptr);
                 if (is_null($name2)) {
                     return null;
                 }
                 $name .= $name2;
                 $offset += 2;
                 break;
             } else {
                 ++$offset;
                 if ($packet->rdlength < $offset + $xlen) {
                     return null;
                 }
                 $elem = '';
                 $elem = substr($packet->rdata, $offset, $xlen);
                 $name .= $elem . '.';
                 $offset += $xlen;
             }
         }
     }
     return trim($name, '.');
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:52,代码来源:Packet.php

示例5: rrSet

 /**
  * parses the rdata of the Net_DNS2_Packet object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
  *
  * @return boolean
  * @access protected
  *
  */
 protected function rrSet(Net_DNS2_Packet &$packet)
 {
     if ($this->rdlength > 0) {
         //
         // parse off the precedence, gateway type and algorithm
         //
         $x = unpack('Cprecedence/Cgateway_type/Calgorithm', $this->rdata);
         $this->precedence = $x['precedence'];
         $this->gateway_type = $x['gateway_type'];
         $this->algorithm = $x['algorithm'];
         $offset = 3;
         //
         // extract the gatway based on the type
         //
         switch ($this->gateway_type) {
             case self::GATEWAY_TYPE_NONE:
                 $this->gateway = '';
                 break;
             case self::GATEWAY_TYPE_IPV4:
                 $this->gateway = inet_ntop(substr($this->rdata, $offset, 4));
                 $offset += 4;
                 break;
             case self::GATEWAY_TYPE_IPV6:
                 $ip = unpack('n8', substr($this->rdata, $offset, 16));
                 if (count($ip) == 8) {
                     $this->gateway = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $ip);
                     $offset += 16;
                 } else {
                     return false;
                 }
                 break;
             case self::GATEWAY_TYPE_DOMAIN:
                 $doffset = $offset + $packet->offset;
                 $this->gateway = Net_DNS2_Packet::expand($packet, $doffset);
                 $offset = $doffset - $packet->offset;
                 break;
             default:
                 return false;
         }
         //
         // extract the key
         //
         switch ($this->algorithm) {
             case self::ALGORITHM_NONE:
                 $this->key = '';
                 break;
             case self::ALGORITHM_DSA:
             case self::ALGORITHM_RSA:
                 $this->key = base64_encode(substr($this->rdata, $offset));
                 break;
             default:
                 return false;
         }
         return true;
     }
     return false;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:66,代码来源:IPSECKEY.php

示例6: rrSet

    /**
     * parses the rdata of the Net_DNS2_Packet object
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
     *
     * @return boolean
     * @access protected
     *
     */
    protected function rrSet(Net_DNS2_Packet &$packet)
    {
        if ($this->rdlength > 0) {
        
            //
            // expand the algorithm
            //
            $offset = $packet->offset;
            $this->algorithm = Net_DNS2_Packet::expand($packet, $offset);
            
            //
            // unpack inception, expiration, mode, error and key size
            //
            $x = unpack(
                '@' . $offset . '/Ninception/Nexpiration/nmode/nerror/nkey_size', 
                $packet->rdata
            );

            $this->inception    = Net_DNS2::expandUint32($x['inception']);
            $this->expiration   = Net_DNS2::expandUint32($x['expiration']);
            $this->mode         = $x['mode'];
            $this->error        = $x['error'];
            $this->key_size     = $x['key_size'];

            $offset += 14;

            //
            // if key_size > 0, then copy out the key
            //
            if ($this->key_size > 0) {

                $this->key_data = substr($packet->rdata, $offset, $this->key_size);
                $offset += $this->key_size;
            }

            //
            // unpack the other length
            //
            $x = unpack('@' . $offset . '/nother_size', $packet->rdata);
            
            $this->other_size = $x['other_size'];
            $offset += 2;

            //
            // if other_size > 0, then copy out the data
            //
            if ($this->other_size > 0) {

                $this->other_data = substr(
                    $packet->rdata, $offset, $this->other_size
                );
            }

            return true;
        }

        return false;
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:67,代码来源:TKEY.php

示例7: rrSet

 /**
  * parses the rdata of the Net_DNS2_Packet object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
  *
  * @return boolean
  * @access protected
  *
  */
 protected function rrSet(Net_DNS2_Packet &$packet)
 {
     if ($this->rdlength > 0) {
         //
         // parse the
         //
         $offset = $packet->offset;
         $this->mname = Net_DNS2_Packet::expand($packet, $offset);
         $this->rname = Net_DNS2_Packet::expand($packet, $offset);
         //
         // get the SOA values
         //
         $x = unpack('@' . $offset . '/Nserial/Nrefresh/Nretry/Nexpire/Nminimum/', $packet->rdata);
         $this->serial = Net_DNS2::expandUint32($x['serial']);
         $this->refresh = Net_DNS2::expandUint32($x['refresh']);
         $this->retry = Net_DNS2::expandUint32($x['retry']);
         $this->expire = Net_DNS2::expandUint32($x['expire']);
         $this->minimum = Net_DNS2::expandUint32($x['minimum']);
         return true;
     }
     return false;
 }
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:SOA.php

示例8: rrSet

 /**
  * parses the rdata of the Net_DNS2_Packet object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
  *
  * @return boolean
  * @access protected
  *
  */
 protected function rrSet(Net_DNS2_Packet &$packet)
 {
     if ($this->rdlength > 0) {
         //
         // unpack the priority and weight
         //
         $x = unpack('npriority/nweight', $this->rdata);
         $this->priority = $x['priority'];
         $this->weight = $x['weight'];
         $offset = $packet->offset + 4;
         $this->target = Net_DNS2_Packet::expand($packet, $offset);
         return true;
     }
     return false;
 }
开发者ID:TeamSF,项目名称:itdb-green,代码行数:24,代码来源:URI.php

示例9: rrSet

    /**
     * parses the rdata of the Net_DNS2_Packet object
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
     *
     * @return boolean
     * @access protected
     *
     */
    protected function rrSet(Net_DNS2_Packet &$packet)
    {
        if ($this->rdlength > 0) {

            //
            // expand the next domain name
            //
            $offset = $packet->offset;
            $this->next_domain_name = Net_DNS2_Packet::expand($packet, $offset);

            //
            // parse out the RR's from the bitmap
            //
            $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray(
                substr($this->rdata, $offset - $packet->offset)
            );

            return true;
        }

        return false;
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:31,代码来源:NSEC.php

示例10: rrSet

    /**
     * parses the rdata of the Net_DNS2_Packet object
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
     *
     * @return boolean
     * @access protected
     *
     */
    protected function rrSet(Net_DNS2_Packet &$packet)
    {
        if ($this->rdlength > 0) {

            $offset             = $packet->offset;

            $this->mboxdname    = Net_DNS2_Packet::expand($packet, $offset);
            $this->txtdname     = Net_DNS2_Packet::expand($packet, $offset);

            return true;
        }

        return false;
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:23,代码来源:RP.php

示例11: set

 /**
  * builds a new Net_DNS2_Header object from a Net_DNS2_Packet object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet object
  *
  * @return boolean
  * @throws Net_DNS2_Exception
  * @access public
  *
  */
 public function set(Net_DNS2_Packet &$packet)
 {
     //
     // expand the name
     //
     $this->qname = $packet->expand($packet, $packet->offset);
     if ($packet->rdlength < $packet->offset + 4) {
         throw new Net_DNS2_Exception('invalid question section: to small', Net_DNS2_Lookups::E_QUESTION_INVALID);
     }
     //
     // unpack the type and class
     //
     $type = ord($packet->rdata[$packet->offset++]) << 8 | ord($packet->rdata[$packet->offset++]);
     $class = ord($packet->rdata[$packet->offset++]) << 8 | ord($packet->rdata[$packet->offset++]);
     //
     // validate it
     //
     $type_name = Net_DNS2_Lookups::$rr_types_by_id[$type];
     $class_name = Net_DNS2_Lookups::$classes_by_id[$class];
     if (!isset($type_name) || !isset($class_name)) {
         throw new Net_DNS2_Exception('invalid question section: invalid type (' . $type . ') or class (' . $class . ') specified.', Net_DNS2_Lookups::E_QUESTION_INVALID);
     }
     //
     // store it
     //
     $this->qtype = $type_name;
     $this->qclass = $class_name;
     return true;
 }
开发者ID:TeamSF,项目名称:itdb-green,代码行数:39,代码来源:Question.php

示例12: rrSet

 /**
  * parses the rdata of the Net_DNS2_Packet object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
  *
  * @return boolean
  * @access protected
  *
  */
 protected function rrSet(Net_DNS2_Packet &$packet)
 {
     if ($this->rdlength > 0) {
         //
         // expand the algorithm
         //
         $newoffset = $packet->offset;
         $this->algorithm = Net_DNS2_Packet::expand($packet, $newoffset);
         $offset = $newoffset - $packet->offset;
         //
         // unpack time, fudge and mac_size
         //
         $x = unpack('@' . $offset . '/ntime_high/Ntime_low/nfudge/nmac_size', $this->rdata);
         $this->time_signed = Net_DNS2::expandUint32($x['time_low']);
         $this->fudge = $x['fudge'];
         $this->mac_size = $x['mac_size'];
         $offset += 10;
         //
         // copy out the mac
         //
         if ($this->mac_size > 0) {
             $this->mac = substr($this->rdata, $offset, $this->mac_size);
             $offset += $this->mac_size;
         }
         //
         // unpack the original id, error, and other_length values
         //
         $x = unpack('@' . $offset . '/noriginal_id/nerror/nother_length', $this->rdata);
         $this->original_id = $x['original_id'];
         $this->error = $x['error'];
         $this->other_length = $x['other_length'];
         //
         // the only time there is actually any "other data", is when there's
         // a BADTIME error code.
         //
         // The other length should be 6, and the other data field includes the
         // servers current time - per RFC 2845 section 4.5.2
         //
         if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) {
             if ($this->other_length != 6) {
                 return false;
             }
             //
             // other data is a 48bit timestamp
             //
             $x = unpack('nhigh/nlow', substr($this->rdata, $offset + 6, $this->other_length));
             $this->other_data = $x['low'];
         }
         return true;
     }
     return false;
 }
开发者ID:TeamSF,项目名称:itdb-green,代码行数:61,代码来源:TSIG.php

示例13: rrSet

    /**
     * parses the rdata of the Net_DNS2_Packet object
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
     *
     * @return boolean
     * @access protected
     *
     */
    protected function rrSet(Net_DNS2_Packet &$packet)
    {
        if ($this->rdlength > 0) {
            
            //
            // unpack the order and preference
            //
            $x = unpack('norder/npreference', $this->rdata);
            
            $this->order        = $x['order'];
            $this->preference   = $x['preference'];

            $offset             = $packet->offset + 4;

            $this->flags        = Net_DNS2_Packet::label($packet, $offset);
            $this->services     = Net_DNS2_Packet::label($packet, $offset);
            $this->regexp       = Net_DNS2_Packet::label($packet, $offset);

            $this->replacement  = Net_DNS2_Packet::expand($packet, $offset);

            return true;
        }

        return false;
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:34,代码来源:NAPTR.php

示例14: rrSet

 /**
  * parses the rdata of the Net_DNS2_Packet object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
  *
  * @return boolean
  * @access protected
  *
  */
 protected function rrSet(Net_DNS2_Packet &$packet)
 {
     if ($this->rdlength > 0) {
         //
         // parse the preference
         //
         $x = unpack('npreference', $this->rdata);
         $this->preference = $x['preference'];
         //
         // get the exchange entry server)
         //
         $offset = $packet->offset + 2;
         $this->exchange = Net_DNS2_Packet::expand($packet, $offset);
         return true;
     }
     return false;
 }
开发者ID:martinsv,项目名称:phpipam,代码行数:26,代码来源:MX.php

示例15: parse

 /**
  * parses a binary packet, and returns the appropriate Net_DNS2_RR object,
  * based on the RR type of the binary content.
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for
  *                                 decompressing names
  *
  * @return mixed                   returns a new Net_DNS2_RR_* object for
  *                                 the given RR
  * @throws Net_DNS2_Exception
  * @access public
  *
  */
 public static function parse(Net_DNS2_Packet &$packet)
 {
     $object = array();
     //
     // expand the name
     //
     $object['name'] = $packet->expand($packet, $packet->offset);
     if (is_null($object['name'])) {
         throw new Net_DNS2_Exception('failed to parse resource record: failed to expand name.', Net_DNS2_Lookups::E_PARSE_ERROR);
     }
     if ($packet->rdlength < $packet->offset + 10) {
         throw new Net_DNS2_Exception('failed to parse resource record: packet too small.', Net_DNS2_Lookups::E_PARSE_ERROR);
     }
     //
     // unpack the RR details
     //
     $object['type'] = ord($packet->rdata[$packet->offset++]) << 8 | ord($packet->rdata[$packet->offset++]);
     $object['class'] = ord($packet->rdata[$packet->offset++]) << 8 | ord($packet->rdata[$packet->offset++]);
     $object['ttl'] = ord($packet->rdata[$packet->offset++]) << 24 | ord($packet->rdata[$packet->offset++]) << 16 | ord($packet->rdata[$packet->offset++]) << 8 | ord($packet->rdata[$packet->offset++]);
     $object['rdlength'] = ord($packet->rdata[$packet->offset++]) << 8 | ord($packet->rdata[$packet->offset++]);
     if ($packet->rdlength < $packet->offset + $object['rdlength']) {
         return null;
     }
     //
     // lookup the class to use
     //
     $o = null;
     $class = Net_DNS2_Lookups::$rr_types_id_to_class[$object['type']];
     if (isset($class)) {
         $o = new $class($packet, $object);
         if ($o) {
             $packet->offset += $object['rdlength'];
         }
     } else {
         throw new Net_DNS2_Exception('un-implemented resource record type: ' . $object['type'], Net_DNS2_Lookups::E_RR_INVALID);
     }
     return $o;
 }
开发者ID:TeamSF,项目名称:itdb-green,代码行数:51,代码来源:RR.php


注:本文中的Net_DNS2_Packet::expand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。