1 | <?php |
||
21 | class DHCID implements RdataInterface |
||
22 | { |
||
23 | use RdataTrait; |
||
24 | |||
25 | const TYPE = 'DHCID'; |
||
26 | const TYPE_CODE = 49; |
||
27 | |||
28 | /** |
||
29 | * 16-bit DHCID RR Identifier Type Code specifies what data from the DHCP |
||
30 | * client's request was used as input into the hash function. |
||
31 | * |
||
32 | * @var int |
||
33 | */ |
||
34 | private $identifierType; |
||
35 | |||
36 | /** |
||
37 | * The 1-octet 'htype' followed by 'hlen' octets of 'chaddr' from a DHCPv4 |
||
38 | * client's DHCPREQUEST. |
||
39 | * |
||
40 | * The data octets (i.e., the Type and Client-Identifier fields) from a |
||
41 | * DHCPv4 client's Client Identifier option. |
||
42 | * |
||
43 | * The client's DUID (i.e., the data octets of a DHCPv6 client's Client |
||
44 | * Identifier option or the DUID field from a DHCPv4 client's Client |
||
45 | * Identifier option). |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | private $identifier; |
||
50 | |||
51 | /** |
||
52 | * Hardware Type {@link https://tools.ietf.org/html/rfc2131}. |
||
53 | * |
||
54 | * @var int Hardware type used if identifier is DHCPv4 DHCPREQUEST carrying client hardware address (chaddr or MAC) |
||
55 | */ |
||
56 | private $htype = 1; |
||
57 | |||
58 | /** |
||
59 | * The Fully Qualified Domain Name of the DHCP client. |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | private $fqdn; |
||
64 | |||
65 | /** |
||
66 | * The digest type. Only one type is defined by IANA, SHA256 with value 1. |
||
67 | * |
||
68 | * @var int |
||
69 | */ |
||
70 | private $digestType = 1; |
||
71 | |||
72 | /** |
||
73 | * @var string |
||
74 | */ |
||
75 | private $digest; |
||
76 | |||
77 | /** |
||
78 | * @param int $identifierType |
||
79 | */ |
||
80 | 12 | public function setIdentifierType(int $identifierType): void |
|
87 | |||
88 | /** |
||
89 | * @return int |
||
90 | */ |
||
91 | 6 | public function getIdentifierType(): int |
|
95 | |||
96 | /** |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getIdentifier(): string |
||
103 | |||
104 | /** |
||
105 | * @return int |
||
106 | */ |
||
107 | public function getHtype(): int |
||
111 | |||
112 | /** |
||
113 | * @param int $htype |
||
114 | */ |
||
115 | public function setHtype(int $htype): void |
||
122 | |||
123 | /** |
||
124 | * @param int $identifierType |
||
125 | * @param string $identifier |
||
126 | * |
||
127 | * @throws \InvalidArgumentException |
||
128 | */ |
||
129 | 12 | public function setIdentifier(int $identifierType, string $identifier): void |
|
134 | |||
135 | /** |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getFqdn(): string |
||
142 | |||
143 | /** |
||
144 | * @param string $fqdn |
||
145 | */ |
||
146 | 12 | public function setFqdn(string $fqdn): void |
|
153 | |||
154 | /** |
||
155 | * @return int |
||
156 | */ |
||
157 | 6 | public function getDigestType(): int |
|
161 | |||
162 | /** |
||
163 | * @return string Digest as hexadecimal string |
||
164 | */ |
||
165 | 6 | public function getDigest(): string |
|
169 | |||
170 | /** |
||
171 | * @param string $digest Digest as hexadecimal string |
||
172 | */ |
||
173 | 6 | public function setDigest(string $digest): void |
|
177 | |||
178 | /** |
||
179 | * Calculate the digest from the identifier and fully qualified domain name already set on the object. |
||
180 | * |
||
181 | * @throws \BadMethodCallException |
||
182 | */ |
||
183 | 12 | public function calculateDigest(): void |
|
197 | |||
198 | /** |
||
199 | * {@inheritdoc} |
||
200 | * |
||
201 | * @throws \BadMethodCallException |
||
202 | */ |
||
203 | 12 | public function toText(): string |
|
207 | |||
208 | /** |
||
209 | * {@inheritdoc} |
||
210 | */ |
||
211 | 12 | public function toWire(): string |
|
219 | |||
220 | /** |
||
221 | * {@inheritdoc} |
||
222 | * |
||
223 | * @return DHCID |
||
224 | * |
||
225 | * @throws \Exception |
||
226 | */ |
||
227 | 3 | public static function fromText(string $text): RdataInterface |
|
240 | |||
241 | /** |
||
242 | * {@inheritdoc} |
||
243 | */ |
||
244 | 3 | public static function fromWire(string $rdata): RdataInterface |
|
253 | } |
||
254 |