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:----BowNS0i+tnR8tz76bedDaVUa4u2I05Alyk85hRkp2xXerBYlo5hmmkFHzPktpD7GWqwyYBSmlQH51K6WyGPwZZ/qQcciShqs5ovX5qO8+3DnmB7Y962VzaqUcVgXCo26cAAFe7R5S3t/H++N5lq6FSV1BYoSRBEYumIXi1jHzuG596Yx4Qowz+aG7PM8Eb7UE8jdwIkayC2GSTeAMxj1d55OR8e9C6FoFEQH+vZV5Kh4vhN9E0K7ee7KUn7+76e8aZ3ZqXNUgGpiRyeDOsk4xtADBKlL/odq6u3/3IGz2Eloj/TrON9VqdDCCWPU5fry3wOpLkye5VjaLsl1T6n5IRI4DDDlXlvK9wJ2IodbW9iJpLVCDveW9EPrAXLEmjY6Rx1lbZi4hocAB1V/9jV0zyOjTnsusHYxG3HH97wh8M7Ac+dDvPTBGDxlnfinfpIwGGm7UfJFWtU8ryJl/zqI67z0929Ar5wkF+cIXZmElIOWwkOupVc6yeAIeirLEWMD6mjxvWXRYV3N3e+hTt1mVYa8f1vxBK5iqOlgYqG9GMfFiJHkWku87qeoOVkDO+jTH1Siv4uozygPUNmgs9fcpRG/47m2eam8izOX7I4HNJoFCxoFBQI7X9YnxCpapsJ9iQIRdcj5bGNgGNmX1ABTxEu2OjiP6BI5aU1BRm6L2mo=----ATTACHMENT:----ODM2ODQ4NTgyNjQyNjEzOSA5OTU2ODQxNDIxODc5NDQ4IDYxNTA1OTA2NDM4MDU3MTM=