本文整理汇总了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;
}
示例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;
}