Michael Vincent > Net-Frame-Layer-DNS > Net::Frame::Layer::DNS

Download:
Net-Frame-Layer-DNS-1.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.04   Source  

NAME ^

Net::Frame::Layer::DNS - Domain Name System layer object

SYNOPSIS ^

   use Net::Frame::Simple;
   use Net::Frame::Layer::DNS qw(:consts);

   my $dns = Net::Frame::Layer::DNS->new(
      id      => getRandom16bitsInt(),
      qr      => NF_DNS_QR_QUERY,
      opcode  => NF_DNS_OPCODE_QUERY,
      flags   => NF_DNS_FLAGS_RD,
      rcode   => NF_DNS_RCODE_NOERROR,
      qdCount => 1,
      anCount => 0,
      nsCount => 0,
      arCount => 0,
   );

   #
   # Read a raw layer
   #

   my $layer = Net::Frame::Layer::DNS->new(raw => $raw);

   print $layer->print."\n";
   print 'PAYLOAD: '.unpack('H*', $layer->payload)."\n"
      if $layer->payload;

DESCRIPTION ^

This modules implements the encoding and decoding of the DNS layer.

RFC: ftp://ftp.rfc-editor.org/in-notes/rfc1035.txt

See also Net::Frame::Layer for other attributes and methods.

ATTRIBUTES ^

id

Identification - used to match request/reply packets.

qr
opcode
flags
rcode

Qr, opcode, flags and rcode fields. See CONSTANTS.

qdCount

Number of entries in the question list.

anCount

Number of entries in the answer resource record that were returned.

nsCount

Number of entries in the authority resource record list that were returned.

arCount

Number of entries in the additional resource record list that were returned.

The following are inherited attributes. See Net::Frame::Layer for more information.

raw
payload
nextLayer

METHODS ^

new
new (hash)

Object constructor. You can pass attributes that will overwrite default ones. See SYNOPSIS for default values.

getKey
getKeyReverse

These two methods are basically used to increase the speed when using recv method from Net::Frame::Simple. Usually, you write them when you need to write match method.

match (Net::Frame::Layer::DNS object)

This method is mostly used internally. You pass a Net::Frame::Layer::DNS layer as a parameter, and it returns true if this is a response corresponding for the request, or returns false if not.

The following are inherited methods. Some of them may be overriden in this layer, and some others may not be meaningful in this layer. See Net::Frame::Layer for more information.

layer
computeLengths
pack
unpack
encapsulate
getLength
getPayloadLength
print
dump

USEFUL SUBROUTINES ^

Load them: use Net::Frame::Layer::DNS qw(:subs);

dnsAton (domain name)

Takes domain name and returns the network form.

dnsNtoa (domain name network form)

Takes domain name in network format, and returns the domain name human form and number of bytes read. Call with:

   my ($name, $bytesRead) = dnsNtoa( ... ) # returns name, bytes read
   my ($name)             = dnsNtoa( ... ) # returns name only

CONSTANTS ^

Load them: use Net::Frame::Layer::DNS qw(:consts);

NF_DNS_QR_QUERY
NF_DNS_QR_RESPONSE

Query / Response flag.

NF_DNS_OPCODE_QUERY
NF_DNS_OPCODE_IQUERY
NF_DNS_OPCODE_STATUS
NF_DNS_OPCODE_NOTIFY
NF_DNS_OPCODE_UPDATE

Opcode values.

NF_DNS_FLAGS_AA
NF_DNS_FLAGS_TC
NF_DNS_FLAGS_RD
NF_DNS_FLAGS_RA
NF_DNS_FLAGS_Z
NF_DNS_FLAGS_AD
NF_DNS_FLAGS_CD

Flag values.

NF_DNS_RCODE_NOERROR
NF_DNS_RCODE_FORMATERROR
NF_DNS_RCODE_SERVERFAILURE
NF_DNS_RCODE_NAMEERROR
NF_DNS_RCODE_NOTIMPLEMENTED
NF_DNS_RCODE_REFUSED
NF_DNS_RCODE_YXDOMAIN
NF_DNS_RCODE_YXRRSET
NF_DNS_RCODE_NXRRSET
NF_DNS_RCODE_NOTAUTH
NF_DNS_RCODE_NOTZONE

RCode Values.

LIMITATIONS ^

While this module can decode DNS compression with pointers, it does not automatically encode compression with pointers.

RData encoder / decoders are provided for common RData types, but not all RData types. If an RData type is encountered during decoding for which a decoder is not present, the RData is simply displayed as a hex stream.

SEE ALSO ^

Net::Frame::Layer

For a non Net::Frame::Layer DNS solution in Perl, Net::DNS.

AUTHOR ^

Michael Vincent

COPYRIGHT AND LICENSE ^

Copyright (c) 2012, Michael Vincent

You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.

syntax highlighting: