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

Class: Net_DNS_Packet

Source Location: /qp_plugins/basic_antispam_plugin/Net/DNS/Packet.php

Class Net_DNS_Packet

Class Overview

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.

Located in /qp_plugins/basic_antispam_plugin/Net/DNS/Packet.php [line 31]



		
		
		
		

Properties

Methods

[ Top ]
Property Summary
array   $additional   An array of Net_DNS_RR ADDITIONAL objects
array   $answer   An array of Net_DNS_RR ANSWER objects
string   $answerfrom   The origin of the packet, if the packet is a server response.
string   $answersize   The size of the answer packet, if the packet is a server response.
array   $authority   An array of Net_DNS_RR AUTHORITY objects
array   $compnames   A hash of compressed labels
boolean   $debug   debugging flag
object Net_DNS_Header   $header   A packet Header object.
array   $question   An array of Net_DNS_Question objects

[ Top ]
Method Summary
Net_DNS_Packet   Net_DNS_Packet()   Initalizes a Net_DNS_Packet object
void   buildQuestion()   Adds a DNS question to the DNS packet
string   data()   Build a packet from a Packet object hierarchy
void   display()   Prints out the packet in a human readable formatted string
string   dn_comp()   DNS packet compression method
array   dn_expand()   DNS packet decompression method
array   label_extract()   DNS packet decompression method
boolean   parse()   Parses a DNS packet returned by a DNS server
array   parse_question()   Parses the question section of a packet
array   parse_rr()   Parses a resource record section of a packet
void   string()   Builds a human readable formatted string representing a packet

[ Top ]
Properties
array   $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.

API Tags:
Access:  public


[ Top ]
array   $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.

API Tags:
Access:  public


[ Top ]
string   $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.

API Tags:
Access:  public


[ Top ]
string   $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.

API Tags:
Access:  public


[ Top ]
array   $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.

API Tags:
Access:  public


[ Top ]
array   $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.


[ Top ]
boolean   $debug [line 43]

debugging flag

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

API Tags:
Access:  public


[ Top ]
object Net_DNS_Header   $header [line 53]

A packet Header object.

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

API Tags:
Access:  public


[ Top ]
array   $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.

API Tags:
Access:  public


[ Top ]
Methods
Constructor Net_DNS_Packet  [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

API Tags:
See:  Net_DNS::typesbyname(), Net_DNS::classesbyname()


[ 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.


API Tags:
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.

API Tags:
Return:  A binary string containing the compressed label.
See:  Net_DNS_Packet::dn_expand()


[ 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.

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

API Tags:
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


[ 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.

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

API Tags:
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


[ 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

Parameters:
string   $data:  A binary string containing a DNS packet

API Tags:
Return:  true on success, null on parser error


[ 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.

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

API Tags:
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.


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

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

API Tags:
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.


[ Top ]
string  [line 604]

  void string( )

Builds a human readable formatted string representing a packet



[ Top ]
Constants
INT16SZ = 2 [line 126]

[ Top ]
INT32SZ = 4 [line 125]

[ Top ]