Net_DNS_Packet Net_DNS_Packet(
[boolean
$debug = false]
)
|
|
Initalizes a Net_DNS_Packet object
Parameters:
|
boolean |
$debug: |
Turns debugging on or off |
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:
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 |
Prints out the packet in a human readable formatted string
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:
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 |
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 |
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 |
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. |
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. |
Builds a human readable formatted string representing a packet