Skip to content

JDWX DNSQuery Packet RequestPacket

JDW edited this page Jul 17, 2022 · 1 revision

JDWX\DNSQuery\Packet\RequestPacket

This class handles building new DNS request packets; packets used for DNS queries and updates.

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

__construct

mixed JDWX\DNSQuery\Packet\RequestPacket::__construct(string i_name, ?string i_type, ?string i_class)

Constructor - builds a new RequestPacket object

  • Visibility: public

Arguments

  • i_name string - the domain name for the packet
  • i_type ?string - the DNS RR type for the packet
  • i_class ?string - the DNS class for the packet

set

bool JDWX\DNSQuery\Packet\RequestPacket::set(string i_name, ?string i_type, ?string i_class)

Build a new RequestPacket object

  • Visibility: public

Arguments

  • i_name string - Domain name for the packet
  • i_type ?string - RR-type for the packet
  • i_class ?string - DNS class for the packet

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

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.

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.

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

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.

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

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()).

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

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()).

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

Clone this wiki locally