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


PHP Net_DNS2_Packet::pack方法代码示例

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


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

示例1: rrGet

    /**
     * returns the rdata portion of the DNS packet
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
     *                                 compressed names
     *
     * @return mixed                   either returns a binary packed
     *                                 string or null on failure
     * @access protected
     *
     */
    protected function rrGet(Net_DNS2_Packet &$packet)
    {
        if (strlen($this->algorithm) > 0) {

            //
            // make sure the size values are correct
            //
            $this->key_size     = strlen($this->key_data);
            $this->other_size   = strlen($this->other_data);

            //
            // add the algorithm without compression
            //
            $data = Net_DNS2_Packet::pack($this->algorithm);

            //
            // pack in the inception, expiration, mode, error and key size
            //
            $data .= pack(
                'NNnnn', $this->inception, $this->expiration, 
                $this->mode, 0, $this->key_size
            );

            //
            // if the key_size > 0, then add the key
            //
            if ($this->key_size > 0) {
            
                $data .= $this->key_data;
            }

            //
            // pack in the other size
            //
            $data .= pack('n', $this->other_size);
            if ($this->other_size > 0) {

                $data .= $this->other_data;
            }

            $packet->offset += strlen($data);

            return $data;
        }

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

示例2: rrGet

 /**
  * returns the rdata portion of the DNS packet
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
  *                                 compressed names
  *
  * @return mixed                   either returns a binary packed
  *                                 string or null on failure
  * @access protected
  *
  */
 protected function rrGet(Net_DNS2_Packet &$packet)
 {
     if (strlen($this->key) > 0) {
         //
         // create a new packet for the signature-
         //
         $new_packet = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN');
         //
         // copy the packet data over
         //
         $new_packet->copy($packet);
         //
         // remove the TSIG object from the additional list
         //
         array_pop($new_packet->additional);
         $new_packet->header->arcount = count($new_packet->additional);
         //
         // copy out the data
         //
         $sig_data = $new_packet->get();
         //
         // add the name without compressing
         //
         $sig_data .= Net_DNS2_Packet::pack($this->name);
         //
         // add the class and TTL
         //
         $sig_data .= pack('nN', Net_DNS2_Lookups::$classes_by_name[$this->class], $this->ttl);
         //
         // add the algorithm name without compression
         //
         $sig_data .= Net_DNS2_Packet::pack(strtolower($this->algorithm));
         //
         // add the rest of the values
         //
         $sig_data .= pack('nNnnn', 0, $this->time_signed, $this->fudge, $this->error, $this->other_length);
         if ($this->other_length > 0) {
             $sig_data .= pack('nN', 0, $this->other_data);
         }
         //
         // sign the data
         //
         $this->mac = $this->_signHMAC($sig_data, base64_decode($this->key), $this->algorithm);
         $this->mac_size = strlen($this->mac);
         //
         // compress the algorithm
         //
         $data = Net_DNS2_Packet::pack(strtolower($this->algorithm));
         //
         // pack the time, fudge and mac size
         //
         $data .= pack('nNnn', 0, $this->time_signed, $this->fudge, $this->mac_size);
         $data .= $this->mac;
         //
         // check the error and other_length
         //
         if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) {
             $this->other_length = strlen($this->other_data);
             if ($this->other_length != 6) {
                 return null;
             }
         } else {
             $this->other_length = 0;
             $this->other_data = '';
         }
         //
         // pack the id, error and other_length
         //
         $data .= pack('nnn', $packet->header->id, $this->error, $this->other_length);
         if ($this->other_length > 0) {
             $data .= pack('nN', 0, $this->other_data);
         }
         $packet->offset += strlen($data);
         return $data;
     }
     return null;
 }
开发者ID:TeamSF,项目名称:itdb-green,代码行数:88,代码来源:TSIG.php


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