Documentation

Decoder
in package

Decodes raw network data to Message objects

Tags
category

LibDNS

author

Chris Wright https://github.com/DaveRandom

Table of Contents

Properties

$allowTrailingData  : bool
$decodingContextFactory  : DecodingContextFactory
$messageFactory  : MessageFactory
$packetFactory  : PacketFactory
$questionFactory  : QuestionFactory
$resourceBuilder  : ResourceBuilder
$typeBuilder  : TypeBuilder

Methods

__construct()  : mixed
Constructor
decode()  : Message
Decode a Message from raw network data
decodeAnything()  : int
Decode an Anything field
decodeBitMap()  : int
Decode a BitMap field
decodeChar()  : int
Decode a Char field
decodeCharacterString()  : int
Decode a CharacterString field
decodeDomainName()  : int
Decode a DomainName field
decodeHeader()  : mixed
Decode the header section of the message
decodeIPv4Address()  : int
Decode an IPv4Address field
decodeIPv6Address()  : int
Decode an IPv6Address field
decodeLong()  : int
Decode a Long field
decodeQuestionRecord()  : Question
Decode a question record
decodeResourceRecord()  : Resource
Decode a resource record
decodeShort()  : int
Decode a Short field
decodeType()  : int
Decode a Type field
readDataFromPacket()  : string
Read a specified number of bytes of data from a packet

Properties

$allowTrailingData

private bool $allowTrailingData

Methods

__construct()

Constructor

public __construct(PacketFactory $packetFactory, MessageFactory $messageFactory, QuestionFactory $questionFactory, ResourceBuilder $resourceBuilder, TypeBuilder $typeBuilder, DecodingContextFactory $decodingContextFactory[, bool $allowTrailingData = true ]) : mixed
Parameters
$packetFactory : PacketFactory
$messageFactory : MessageFactory
$questionFactory : QuestionFactory
$resourceBuilder : ResourceBuilder
$typeBuilder : TypeBuilder
$decodingContextFactory : DecodingContextFactory
$allowTrailingData : bool = true

decode()

Decode a Message from raw network data

public decode(string $data) : Message
Parameters
$data : string

The data string to decode

Tags
throws
UnexpectedValueException

When the packet data is invalid

throws
InvalidArgumentException

When a type subtype is unknown

Return values
Message

decodeAnything()

Decode an Anything field

private decodeAnything(DecodingContext $decodingContext, Anything $anything, int $length) : int
Parameters
$decodingContext : DecodingContext
$anything : Anything

The object to populate with the result

$length : int
Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeBitMap()

Decode a BitMap field

private decodeBitMap(DecodingContext $decodingContext, BitMap $bitMap, int $length) : int
Parameters
$decodingContext : DecodingContext
$bitMap : BitMap

The object to populate with the result

$length : int
Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeChar()

Decode a Char field

private decodeChar(DecodingContext $decodingContext, Char $char) : int
Parameters
$decodingContext : DecodingContext
$char : Char

The object to populate with the result

Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeCharacterString()

Decode a CharacterString field

private decodeCharacterString(DecodingContext $decodingContext, CharacterString $characterString) : int
Parameters
$decodingContext : DecodingContext
$characterString : CharacterString

The object to populate with the result

Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeDomainName()

Decode a DomainName field

private decodeDomainName(DecodingContext $decodingContext, DomainName $domainName) : int
Parameters
$decodingContext : DecodingContext
$domainName : DomainName

The object to populate with the result

Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeHeader()

Decode the header section of the message

private decodeHeader(DecodingContext $decodingContext, Message $message) : mixed
Parameters
$decodingContext : DecodingContext
$message : Message
Tags
throws
UnexpectedValueException

When the header section is invalid

decodeIPv4Address()

Decode an IPv4Address field

private decodeIPv4Address(DecodingContext $decodingContext, IPv4Address $ipv4Address) : int
Parameters
$decodingContext : DecodingContext
$ipv4Address : IPv4Address

The object to populate with the result

Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeIPv6Address()

Decode an IPv6Address field

private decodeIPv6Address(DecodingContext $decodingContext, IPv6Address $ipv6Address) : int
Parameters
$decodingContext : DecodingContext
$ipv6Address : IPv6Address

The object to populate with the result

Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeLong()

Decode a Long field

private decodeLong(DecodingContext $decodingContext, Long $long) : int
Parameters
$decodingContext : DecodingContext
$long : Long

The object to populate with the result

Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeResourceRecord()

Decode a resource record

private decodeResourceRecord(DecodingContext $decodingContext) : Resource
Parameters
$decodingContext : DecodingContext
Tags
throws
UnexpectedValueException

When the record is invalid

throws
InvalidArgumentException

When a type subtype is unknown

Return values
Resource

decodeShort()

Decode a Short field

private decodeShort(DecodingContext $decodingContext, Short $short) : int
Parameters
$decodingContext : DecodingContext
$short : Short

The object to populate with the result

Tags
throws
UnexpectedValueException

When the packet data is invalid

Return values
int

The number of packet bytes consumed by the operation

decodeType()

Decode a Type field

private decodeType(DecodingContext $decodingContext, Type $type, int $length) : int
Parameters
$decodingContext : DecodingContext
$type : Type

The object to populate with the result

$length : int

Expected data length

Tags
throws
UnexpectedValueException

When the packet data is invalid

throws
InvalidArgumentException

When the Type subtype is unknown

Return values
int

The number of packet bytes consumed by the operation

readDataFromPacket()

Read a specified number of bytes of data from a packet

private readDataFromPacket(Packet $packet, int $length) : string
Parameters
$packet : Packet
$length : int
Tags
throws
UnexpectedValueException

When the read operation does not result in the requested number of bytes

Return values
string

        
On this page

Search results