Ejemplo n.º 1
0
 /**
  * Decode a Short field
  *
  * @param \LibDNS\Decoder\DecodingContext $decodingContext
  * @param \LibDNS\Records\Types\Short $short 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 decodeShort(DecodingContext $decodingContext, Short $short)
 {
     $value = unpack('n', $this->readDataFromPacket($decodingContext->getPacket(), 2))[1];
     $short->setValue($value);
     return 2;
 }
Ejemplo n.º 2
0
 /**
  * Encode a Short field
  *
  * @param \LibDNS\Records\Types\Short $short
  * @return string
  */
 private function encodeShort(Short $short)
 {
     return pack('n', $short->getValue());
 }