5
* Net_DNS: A resolver library for PHP
6
* Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
8
* Marco Kaiser <bate@php.net>
9
* Florian Anderiasch <fa@php.net>
11
* PHP versions 4 and 5
13
* LICENSE: This source file is subject to version 3.01 of the PHP license
14
* that is available through the world-wide-web at the following URI:
15
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
16
* the PHP License and are unable to obtain it through the web, please
17
* send a note to license@php.net so we can mail you a copy immediately.
20
/* Net_DNS_RR_SRV definition {{{ */
22
* A representation of a resource record of type <b>SRV</b>
26
class Net_DNS_RR_SRV extends Net_DNS_RR
28
/* class variable definitions {{{ */
41
/* class constructor - RR(&$rro, $data, $offset = '') {{{ */
42
function Net_DNS_RR_SRV(&$rro, $data, $offset = '')
44
$this->name = $rro->name;
45
$this->type = $rro->type;
46
$this->class = $rro->class;
47
$this->ttl = $rro->ttl;
48
$this->rdlength = $rro->rdlength;
49
$this->rdata = $rro->rdata;
52
if ($this->rdlength > 0) {
53
$a = unpack("@$offset/npreference/nweight/nport", $data);
55
$packet = new Net_DNS_Packet();
57
list($target, $offset) = $packet->dn_expand($data, $offset);
58
$this->preference = $a['preference'];
59
$this->weight = $a['weight'];
60
$this->port = $a['port'];
61
$this->target = $target;
63
} elseif (is_array($data)) {
64
$this->preference = $data['preference'];
65
$this->weight = $data['weight'];
66
$this->port = $data['port'];
67
$this->target = $data['target'];
69
preg_match("/([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*$/", $data, $regs);
70
$this->preference = $regs[1];
71
$this->weight = $regs[2];
72
$this->port = $regs[3];
73
$this->target = preg_replace('/(.*)\.$/', '\\1', $regs[4]);
78
/* Net_DNS_RR_SRV::rdatastr() {{{ */
82
return intval($this->preference) . ' ' . intval($this->weight) . ' ' . intval($this->port) . ' ' . $this->target . '.';
88
/* Net_DNS_RR_SRV::rr_rdata($packet, $offset) {{{ */
89
function rr_rdata($packet, $offset)
91
if (isset($this->preference)) {
92
$rdata = pack('nnn', $this->preference, $this->weight, $this->port);
93
$rdata .= $packet->dn_comp($this->target, $offset + strlen($rdata));
109
* vim600: sw=4 ts=4 sts=4 cindent fdm=marker et