2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
5
* DNS Library for handling lookups and updates.
9
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
10
* All rights reserved.
12
* Redistribution and use in source and binary forms, with or without
13
* modification, are permitted provided that the following conditions
16
* * Redistributions of source code must retain the above copyright
17
* notice, this list of conditions and the following disclaimer.
19
* * Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in
21
* the documentation and/or other materials provided with the
24
* * Neither the name of Mike Pultz nor the names of his contributors
25
* may be used to endorse or promote products derived from this
26
* software without specific prior written permission.
28
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
37
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39
* POSSIBILITY OF SUCH DAMAGE.
41
* @category Networking
43
* @author Mike Pultz <mike@mikepultz.com>
44
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
45
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
46
* @version SVN: $Id: PX.php 127 2011-12-03 03:29:39Z mike.pultz $
47
* @link http://pear.php.net/package/Net_DNS2
48
* @since File available since Release 0.6.0
53
* PX Resource Record - RFC2163 section 4
55
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
57
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
60
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
63
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
65
* @category Networking
67
* @author Mike Pultz <mike@mikepultz.com>
68
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
69
* @link http://pear.php.net/package/Net_DNS2
73
class Net_DNS2_RR_PX extends Net_DNS2_RR
81
* the RFC822 part of the MCGAM
86
* the X.400 part of the MCGAM
91
* method to return the rdata portion of the packet as a string
97
protected function rrToString()
99
return $this->preference . ' ' . $this->cleanString($this->map822) . '. ' .
100
$this->cleanString($this->mapx400) . '.';
104
* parses the rdata portion from a standard DNS config line
106
* @param array $rdata a string split line of values for the rdata
112
protected function rrFromString(array $rdata)
114
$this->preference = $rdata[0];
115
$this->map822 = $this->cleanString($rdata[1]);
116
$this->mapx400 = $this->cleanString($rdata[2]);
122
* parses the rdata of the Net_DNS2_Packet object
124
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
130
protected function rrSet(Net_DNS2_Packet &$packet)
132
if ($this->rdlength > 0) {
135
// parse the preference
137
$x = unpack('npreference', $this->rdata);
138
$this->preference = $x['preference'];
140
$offset = $packet->offset + 2;
142
$this->map822 = Net_DNS2_Packet::expand($packet, $offset);
143
$this->mapx400 = Net_DNS2_Packet::expand($packet, $offset);
152
* returns the rdata portion of the DNS packet
154
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
157
* @return mixed either returns a binary packed
158
* string or null on failure
162
protected function rrGet(Net_DNS2_Packet &$packet)
164
if (strlen($this->map822) > 0) {
166
$data = pack('n', $this->preference);
167
$packet->offset += 2;
169
$data .= $packet->compress($this->map822, $packet->offset);
170
$data .= $packet->compress($this->mapx400, $packet->offset);
183
* c-hanging-comment-ender-p: nil