use Net::DNS::DomainName; $object = Net::DNS::DomainName->new('example.com'); $name = $object->name; $data = $object->encode; ( $object, $next ) = Net::DNS::DomainName->decode( \$data, $offset );
Net::DNS::DomainName defines methods for encoding and decoding wire format octet strings. All other behaviour is inherited from Net::DNS::Domain.
The Net::DNS::DomainName1035 and Net::DNS::DomainName2535 packages implement disjoint domain name subtypes which provide the name compression and canonicalisation specified by RFC1035 and RFC2535. These are necessary to meet the backward compatibility requirements introduced by RFC3597.
$object = Net::DNS::DomainName->new('example.com');
Creates a domain name object which identifies the domain specified by the character string argument.
$data = $object->canonical;
Returns the canonical wire-format representation of the domain name as defined in RFC2535(8.1).
$object = Net::DNS::DomainName->decode( \$buffer, $offset, $hash ); ( $object, $next ) = Net::DNS::DomainName->decode( \$buffer, $offset, $hash );
Creates a domain name object which represents the DNS domain name identified by the wire-format data at the indicated offset within the data buffer.
The argument list consists of a reference to a scalar containing the wire-format data and specified offset. The optional reference to a hash table provides improved efficiency of decoding compressed names by exploiting already cached compression pointers.
The returned offset value indicates the start of the next item in the data buffer.
$data = $object->encode;
Returns the wire-format representation of the domain name suitable for inclusion in a DNS packet buffer.
use Net::DNS::DomainName; $object = Net::DNS::DomainName1035->new('compressible.example.com'); $data = $object->encode( $offset, $hash ); ( $object, $next ) = Net::DNS::DomainName1035->decode( \$data, $offset );
Note that RFC3597 implies that the RR types defined in RFC1035 section 3.3 are the only types eligible for compression.
$data = $object->encode( $offset, $hash );
Returns the wire-format representation of the domain name suitable for inclusion in a DNS packet buffer.
The optional arguments are the offset within the packet data where the domain name is to be stored and a reference to a hash table used to index compressed names within the packet.
If the hash reference is undefined, encode() returns the lowercase uncompressed canonical representation defined in RFC2535(8.1).
Note that RFC3597, and latterly RFC4034, specifies that the lower case canonical encoding defined in RFC2535 is to be used for RR types defined prior to RFC3597.
use Net::DNS::DomainName; $object = Net::DNS::DomainName2535->new('incompressible.example.com'); $data = $object->encode( $offset, $hash ); ( $object, $next ) = Net::DNS::DomainName2535->decode( \$data, $offset );
$data = $object->encode( $offset, $hash );
Returns the uncompressed wire-format representation of the domain name suitable for inclusion in a DNS packet buffer.
If the hash reference is undefined, encode() returns the lowercase canonical form defined in RFC2535(8.1).
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.