Skip to content

JDWX DNSQuery Packet Packet

JDW edited this page Jul 17, 2022 · 1 revision

JDWX\DNSQuery\Packet\Packet

This is the base class that holds a standard DNS packet.

The RequestPacket and ResponsePacket classes extend this class.

  • Class name: Packet
  • Namespace: \JDWX\DNSQuery\Packet

Properties

rdata

public  rdata
  • Visibility: public

rdLength

public  rdLength
  • Visibility: public

offset

public  offset
  • Visibility: public

header

public  header
  • Visibility: public

question

public  question = []
  • Visibility: public

answer

public  answer = []
  • Visibility: public

authority

public  authority = []
  • Visibility: public

additional

public  additional = []
  • Visibility: public

compressed

private  compressed = []
  • Visibility: private

Methods

label

?string JDWX\DNSQuery\Packet\Packet::label(\JDWX\DNSQuery\Packet\Packet packet, int offset)

parses a domain label from a DNS Packet at the given offset

  • Visibility: public
  • This method is static.

Arguments

  • packet JDWX\DNSQuery\Packet\Packet - Packet to look in for the domain name
  • offset int - (input/output) Offset into the given packet object

pack

string JDWX\DNSQuery\Packet\Packet::pack(string name)

Write the name in DNS binary format.

RFC 1035 specifies that names should be written as a series of labels with a single null byte at the end. Each label starts with its length, followed by the label itself. This function converts a provided name to that format, but does not perform any compression.

  • Visibility: public
  • This method is static.

Arguments

  • name string - the name to be compressed

__toString

string JDWX\DNSQuery\Packet\Packet::__toString()

Return a summary of the packet as a human-readable string

Loosely inspired by the dig/drill format.

  • Visibility: public

compress

string JDWX\DNSQuery\Packet\Packet::compress(string name, int offset)

Apply standard DNS name compression on the given name and write it to the packet at offset.

This logic was based on the Net::DNS::Packet::dn_comp() function by Michael Fuhr

  • Visibility: public

Arguments

  • name string - Name to be compressed
  • offset int - Offset into the given packet object

copy

void JDWX\DNSQuery\Packet\Packet::copy(\JDWX\DNSQuery\Packet\Packet i_packet)

Copy the contents of the given packet to the local packet object.

This function intentionally ignores some packet data.

  • Visibility: public

Arguments

expand

?string JDWX\DNSQuery\Packet\Packet::expand(int io_offset, bool i_escapeDotLiterals)

expands the domain name stored at a given offset in a DNS Packet

This logic was based on the Net::DNS::Packet::dn_expand() function by Michael Fuhr

  • Visibility: public

Arguments

  • io_offset int - (input/output) Offset into the given packet object
  • i_escapeDotLiterals bool - Escape periods in names

expandEx

string JDWX\DNSQuery\Packet\Packet::expandEx(int io_offset, bool i_escapeDotLiterals)

expands the domain name stored at a given offset in this DNS Packet and throws an exception on failure (contrast static::expand()).

  • Visibility: public

Arguments

  • io_offset int - (input/output) Offset into the given Packet object
  • i_escapeDotLiterals bool - if we should escape periods in names

get

string JDWX\DNSQuery\Packet\Packet::get()

Return a full binary DNS packet

  • Visibility: public

labelEx

string JDWX\DNSQuery\Packet\Packet::labelEx(int io_offset)

Parse a domain label from a DNS Packet at the given offset and throws an exception on failure (contrast static::label()).

  • Visibility: public

Arguments

  • io_offset int - (input/output) Offset into the given packet object

reset

bool JDWX\DNSQuery\Packet\Packet::reset()

resets the values in the current packet object

  • Visibility: public
Clone this wiki locally