當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。