Net_DNS
[ class tree: Net_DNS ] [ index: Net_DNS ] [ all elements ]

Class: Net_DNS_Packet

Source Location: /Net_DNS-1.0.7/Net/DNS/Packet.php

Class Overview


A object represation of a DNS packet (RFC1035)


Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 31]
A object represation of a DNS packet (RFC1035)

This object is used to manage a DNS packet. It contains methods for DNS packet compression as defined in RFC1035, as well as parsing a DNS packet response from a DNS server, or building a DNS packet from the instance variables contained in the class.



[ Top ]


Class Variables

$additional =

[line 123]

An array of Net_DNS_RR ADDITIONAL objects

Contains all of the additional RRs within the packet. Each additional is stored as an object of type Net_DNS_RR.

  • Access: public

Type:   array


[ Top ]

$answer =

[line 103]

An array of Net_DNS_RR ANSWER objects

Contains all of the answer RRs within the packet. Each answer is stored as an object of type Net_DNS_RR.

  • Access: public

Type:   array


[ Top ]

$answerfrom =

[line 72]

The origin of the packet, if the packet is a server response.

This contains a string containing the IP address of the name server from which the answer was given.

  • Access: public

Type:   string


[ Top ]

$answersize =

[line 83]

The size of the answer packet, if the packet is a server response.

This contains a integer containing the size of the DNS packet the server responded with if this packet was received by a DNS server using the query() method.

  • Access: public

Type:   string


[ Top ]

$authority =

[line 113]

An array of Net_DNS_RR AUTHORITY objects

Contains all of the authority RRs within the packet. Each authority is stored as an object of type Net_DNS_RR.

  • Access: public

Type:   array


[ Top ]

$compnames =

[line 62]

A hash of compressed labels

A list of all labels which have been compressed in the DNS packet and the location offset of the label within the packet.


Type:   array


[ Top ]

$debug =

[line 43]

debugging flag

If set to true (non-zero), debugging code will be displayed as the packet is parsed.

  • Access: public

Type:   boolean


[ Top ]

$header =

[line 53]

A packet Header object.

An object of type Net_DNS_Header which contains the header information of the packet.

  • Access: public



[ Top ]

$question =

[line 93]

An array of Net_DNS_Question objects

Contains all of the questions within the packet. Each question is stored as an object of type Net_DNS_Question.

  • Access: public

Type:   array


[ Top ]



Method Detail

Net_DNS_Packet (Constructor)   [line 143]

Net_DNS_Packet Net_DNS_Packet( [boolean $debug = false])

Initalizes a Net_DNS_Packet object

Parameters:

boolean   $debug     Turns debugging on or off

[ Top ]

buildQuestion   [line 159]

void buildQuestion( string $name, [string $type = 'A'], [string $class = 'IN'])

Adds a DNS question to the DNS packet

Parameters:

string   $name     The name of the record to query
string   $type     The type of record to query
string   $class     The class of record to query

[ Top ]

data   [line 321]

string data( )

Build a packet from a Packet object hierarchy

Builds a valid DNS packet suitable for sending to a DNS server or resolver client containing all of the data in the packet hierarchy.

  • Return: A binary string containing a DNS Packet

[ Top ]

display   [line 594]

void display( )

Prints out the packet in a human readable formatted string

[ Top ]

dn_comp   [line 365]

string dn_comp( string $name, integer $offset)

DNS packet compression method

Returns a domain name compressed for a particular packet object, to be stored beginning at the given offset within the packet data. The name will be added to a running list of compressed domain names for future use.


Parameters:

string   $name     The name of the label to compress
integer   $offset     The location offset in the packet to where the label will be stored.

[ Top ]

dn_expand   [line 406]

array dn_expand( string $packet, integer $offset)

DNS packet decompression method

Expands the domain name stored at a particular location in a DNS packet. The first argument is a variable containing the packet data. The second argument is the offset within the packet where the (possibly) compressed domain name is stored.

  • Return: Returns a list of type array($name, $offset) where $name is the name of the label which was decompressed and $offset is the offset of the next field in the packet. Returns array(null, null) on error

Parameters:

string   $packet     The packet data
integer   $offset     The location offset in the packet of the label to decompress.

[ Top ]

label_extract   [line 470]

array label_extract( string $packet, integer $offset)

DNS packet decompression method

Extracts the label stored at a particular location in a DNS packet. The first argument is a variable containing the packet data. The second argument is the offset within the packet where the (possibly) compressed domain name is stored.

  • Return: Returns a list of type array($name, $offset) where $name is the name of the label which was decompressed and $offset is the offset of the next field in the packet. Returns array(null, null) on error

Parameters:

string   $packet     The packet data
integer   $offset     The location offset in the packet of the label to extract.

[ Top ]

parse   [line 192]

boolean parse( string $data)

Parses a DNS packet returned by a DNS server

Parses a complete DNS packet and builds an object hierarchy containing all of the parts of the packet:

  • HEADER
  • QUESTION
  • ANSWER || PREREQUISITE
  • ADDITIONAL || UPDATE
  • AUTHORITY

  • Return: true on success, null on parser error

Parameters:

string   $data     A binary string containing a DNS packet

[ Top ]

parse_question   [line 508]

array parse_question( string $data, integer $offset)

Parses the question section of a packet

Examines a DNS packet at the specified offset and parses the data of the QUESTION section.

  • Return: An array of type array($q, $offset) where $q is a Net_DNS_Question object and $offset is the location of the next section of the packet which needs to be parsed.

Parameters:

string   $data     The packet data returned from the server
integer   $offset     The location offset of the start of the question section.

[ Top ]

parse_rr   [line 547]

array parse_rr( string $data, integer $offset)

Parses a resource record section of a packet

Examines a DNS packet at the specified offset and parses the data of a section which contains RRs (ANSWER, AUTHORITY, ADDITIONAL).

  • Return: An array of type array($rr, $offset) where $rr is a Net_DNS_RR object and $offset is the location of the next section of the packet which needs to be parsed.

Parameters:

string   $data     The packet data returned from the server
integer   $offset     The location offset of the start of the resource record section.

[ Top ]

string   [line 604]

void string( )

Builds a human readable formatted string representing a packet

[ Top ]


Documentation generated on Wed, 03 Nov 2010 11:00:06 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.