/** * Decode an IPv6Address field * * @param \LibDNS\Decoder\DecodingContext $decodingContext * @param \LibDNS\Records\Types\IPv6Address $ipv6Address The object to populate with the result * @return int The number of packet bytes consumed by the operation * @throws \UnexpectedValueException When the packet data is invalid */ private function decodeIPv6Address(DecodingContext $decodingContext, IPv6Address $ipv6Address) { $shorts = unpack('n8', $this->readDataFromPacket($decodingContext->getPacket(), 16)); $ipv6Address->setShorts($shorts); return 16; }
/** * Encode an IPv6Address field * * @param \LibDNS\Records\Types\IPv6Address $ipv6Address * @return string */ private function encodeIPv6Address(IPv6Address $ipv6Address) { $shorts = $ipv6Address->getShorts(); return pack('n*', $shorts[0], $shorts[1], $shorts[2], $shorts[3], $shorts[4], $shorts[5], $shorts[6], $shorts[7]); }