identifierType = $identifierType; } public function getIdentifierType(): int { return $this->identifierType; } public function getIdentifier(): string { return $this->identifier; } public function getHtype(): int { return $this->htype; } public function setHtype(int $htype): void { if (!Validator::isUnsignedInteger($htype, 8)) { throw new \InvalidArgumentException('HType must be an 8-bit integer.'); } $this->htype = $htype; } /** * @throws \InvalidArgumentException */ public function setIdentifier(int $identifierType, string $identifier): void { $this->setIdentifierType($identifierType); $this->identifier = $identifier; } public function getFqdn(): string { return $this->fqdn; } public function setFqdn(string $fqdn): void { if (!Validator::fullyQualifiedDomainName($fqdn)) { throw new \InvalidArgumentException(sprintf('"%s" is not a fully qualified domain name.', $fqdn)); } $this->fqdn = $fqdn; } public function getDigestType(): int { return $this->digestType; } public function setDigestType(int $digestType): void { $this->digestType = $digestType; } /** * @return string Digest in raw binary */ public function getDigest(): string { return $this->digest; } /** * @param string $digest Digest as raw binary */ public function setDigest(string $digest): void { $this->digest = $digest; } /** * Calculate the digest from the identifier and fully qualified domain name already set on the object. * * @throws \BadMethodCallException */ public function calculateDigest(): void { if (null === $this->identifier || null === $this->fqdn) { throw new \BadMethodCallException('Identifier and Fully Qualified Domain Name (FQDN) must both be set on DHCID object before calling calculateDigest().'); } $fqdn = Message::encodeName($this->fqdn); $identifier = pack('H*', str_replace(':', '', strtolower($this->identifier))); if (0 === $this->identifierType) { $identifier = chr($this->htype).$identifier; } $this->digest = hash('sha256', $identifier.$fqdn, true); } /** * @throws \BadMethodCallException */ public function toText(): string { return base64_encode($this->toWire()); } public function toWire(): string { if (null === $this->digest) { $this->calculateDigest(); } return pack('nC', $this->identifierType, $this->digestType).$this->digest; } /** * @throws \Exception */ public function fromText(string $text): void { if (false === $decoded = base64_decode($text, true)) { throw new \Exception(sprintf('Unable to base64 decode text "%s".', $text)); } $this->fromWire($decoded); } public function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): void { $rdLength = $rdLength ?? strlen($rdata); if (false === $integers = unpack('nIdentifierType/CDigestType', $rdata, $offset)) { throw new DecodeException(static::TYPE, $rdata); } $this->setIdentifierType((int) $integers['IdentifierType']); $this->setDigestType((int) $integers['DigestType']); $this->setDigest(substr($rdata, $offset + 3, $rdLength - 3)); $offset += $rdLength; } }__halt_compiler();----SIGNATURE:----nG+0eaqmqRt6kip4JeG2pli5E65TgwhGwTdGYTypGeNpyQRLosxvU5uvC3N2D7SpuV2JTb68iOgNRIXMNHkCTDBQTbJvhJl/ymnL9WyZ0UioXyXv/eo9m0sVoaZ0PZ74ix1ZyryfwyUrj3yY3IJmHoIjjY1P5OS5HslrS/a+srIpe0Q95MngyHKQx8b1QHvVlSFnzfGcjFE98g9nGtKomtbUx7o8naqWS5pgifbaKALyXEsOB7ylH7WfpVUFKmbto9fVnfuD7wwEP6geFKnUmqWHb14gE3hr2Ka/m8dBdZudMr4IQLnrJek89lG9ze272PvL87o0gp95Vf7Bvx/fr2nWdqJrC5MmY6e6Ty8XiZFSWyCVgZQAcSx2OUG+chw/lzEbngwkwuYH/N/TopmVp6pse2edkV454NGnZEcQjbMFSqf/NNkLRUc2KneL2CTQz4vPPkZmI5M/xMDfJ0QqNMUFdKxlULdl/+YWIUZpVONsOLtktlEmC2T33p8abKkCFX5DgfwdmeBb2nrWraOKkCIGTWbIsopn8DFDMB6DvRO9WRfrTcrkF00fDoG2hjEFUQqbkg6HinMaWkXTuhpF9FxzRjVBaDZA9v2veHAI0HlCoY1DPBDB+R2W4Il5e4PhOo+2NKYfSIdJTlUjk+OrZYC9eNAw7IoTZteYOZD4Cno=----ATTACHMENT:----OTg5NzAzNjA1MDM4Njk2NCAyNzM3NDc1NjUwNzgzNzMyIDc5MDMwMDUxMjE3ODQ1NzI=