NAME

Net::DNS::ToolKit - tools for working with DNS packets


SYNOPSIS

  use Net::DNS::ToolKit qw(
        get1char
        get16
        get32
        put1char
        put16
        put32
        getIPv4
        putIPv4
        putIPv6
        getIPv6
        getstring
        putstring
        dn_comp
        dn_expand
        parse_char
        gethead
        newhead
        getflags
        get_qdcount
        get_ancount
        get_nscount
        get_arcount
        put_qdcount
        put_ancount
        put_nscount
        put_arcount
        inet_aton
        inet_ntoa
        ipv6_aton
        ipv6_n2x
        ipv6_n2d   
        sec2time
        ttlAlpha2Num
        collapse
        strip
        get_ns
        gettimeofday
  );
  $char = get1char(\$buffer,$offset);
  ($int, $newoff)  = get16(\$buffer,$offset);
  ($long, $newoff) = get32(\$buffer,$offset);
  $newoff = put1char(\$buffer,$offset,$u_char);
  $newoff = put16(\$buffer,$offset,$int);
  $newoff = put32(\$buffer,$offset,$long);
  $flags = getflags(\$buffer);
  $int = get_qdcount(\$buffer);
  $int = get_ancount(\$buffer);
  $int = get_nscount(\$buffer);
  $int = get_arcount(\$buffer);
  $newoff = put_qdcount(\$buffer,$int);
  $newoff = put_ancount(\$buffer,$int);
  $newoff = put_nscount(\$buffer,$int);
  $newoff = put_arcount(\$buffer,$int);
  ($netaddr,$newoff)=getIPv4(\$buffer,$offset);
  $newoff = putIPv4(\$buffer,$offset,$netaddr);
  ($ipv6addr,$newoff)=getIPv6(\$buffer,$offset);
  $newoff = putIPv6(\$buffer,$offset,$ipv6addr);
  ($offset,
   $id,$qr,$opcode,$aa,$tc,$rd,$ra,$mbz,$ad,$cd,$rcode,
   $qdcount,$ancount,$nscount,$arcount)
        = gethead(\$buffer);
  $newoff = newhead(\$buffer,$id,$flags,
        $qdcount,$ancount,$nscount,$arcount);
  ($b,$h,$d,$a)=parse_char($char);
  ($newoff,$name) = dn_expand(\$buffer,$offset);
  ($newoff,@dnptrs)=dn_comp(\$buffer,$offset,\$name,\@dnptrs);
  $dotquad = inet_ntoa($netaddr);
  $netaddr = inet_aton($dotquad);
  $ipv6addr = ipv6_aton($ipv6_text);
  $hex_text = ipv6_n2x($ipv6addr);
  $dec_text = ipv6_n2d($ipv6addr);
  $timetxt = sec2time($seconds);
  $seconds = ttlAlpha2Num($timetext);
  $shorthost = collapse($zonename,$longhost);
  $tag = strip($P_tag);
  @nameservers = get_ns();
  ($secs,$usecs) = gettimeofday();


DESCRIPTION

Routines to pick apart, examine and put together DNS packets. They can be used for diagnostic purposes or as building blocks for DNS applications such as DNS servers and clients or to allow user applications to interact directly with remote DNS servers.

See: Net::DNS::ToolKit for individual Resource Record methods.

These functions return a value and offset in list context and first value only in scalar context.

  ($int,$newoff)        = get16(...
  ($long,$newoff)       = get32(...
  ($netaddr,$newoff)    = getIPv4(...
  ($ipv6addr,$newoff)   = getIPv6(...
  ($string,$newoff)     = getstring(...
  ($newoff,$name)       = dn_expand(...
  ($secs,$usecs)        = gettimeofday(...

These functions return only a value or an offset.

  $newoff       = put1char(...
  $newoff       = put16(...  
  $newoff       = put32(...
  $newoff       = put_qdcount(...
  $newoff       = put_ancount(...
  $newoff       = put_nscount(...
  $newoff       = put_arcount(...
  $newoff       = putIPv4(...
  $newoff       = putIPv4(...
  $newoff       = putstring(...
  $newoff       = newhead(...
  $flags        = getflags(...
  $int          = get_qdcount(...
  $int          = get_ancount(...
  $int          = get_nscount(...
  $int          = get_arcount(...
  $char         = get1char(...
  $dotquad      = inet_ntoa(...
  $netaddr      = inet_aton(...
  $timetxt      = sec2time(...
  $seconds      = ttlAlpha2Num(...
  $tag          = strip(...
  $shorthost    = collapse(...

This function always return list context prefixed by a new offset.

  ($newoff,@dnptrs) = dn_comp(...
  ($offset,@list)   = gethead(...

These functions always return list context.

  @list         = parse_char(...
  @nameservers  = get_ns(...


INSTALLATION

To install this module, type:

        perl Makefile.PL
        make
        make test
        make install


DEPENDENCIES

        perl 5.00503
        Net::DNS::Codes 0.06


EXAMPLES

See the scripts directory in this distribution


EXPORT

None


EXPORT_OK

get1char get16 get32 put1char put16 put32 getIPv4 putIPv4 getIPv6 putIPv6 getstring putstring dn_comp dn_expand parse_char gethead newhead getflags get_qdcount get_ancount get_nscount get_arcount put_qdcount put_ancount put_nscount put_arcount inet_aton inet_ntoa ipv6_aton ipv6_n2x ipv6_n2d sec2time ttlAlpha2Num collapse strip get_ns gettimeofday


BUGS

There have been some reports of the ``C'' library function for

  "int res_init(void);

not properly returning the local resolver nameserver configuration information for certain Perl 5.6 -> 5.8 hosts. This is for the ToolKit function ``get_ns()''.

I have been unable to duplicate this on any of the ix86 Linux or Sun-Sparc systems that I have. If you have a system that exhibits this problem and can provide a user account, I'd appreciate it if you would contact me so I can fix it.


AUTHOR

Michael Robinton <michael@bizsystems.com>


ACKNOWLEDGEMENTS

The following functions are used in whole or in part as include files to ToolKit.xs. The copyrights are include in the respective files.

  file:           functions:
  dn_expand.inc   dn_expand

dn_expand is from Michael Fuhr's Net::DNS package (DNS.pm), copyright (c) 1997-2002. Thank you Michael.


COPYRIGHT

    Copyright 2003 - 2007, Michael Robinton <michael@bizsystems.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


See also:

Net::DNS::Codes(3), Net::DNS::ToolKit::RR(3), Net::DNS::ToolKit::Debug(3), Net::DNS::ToolKit::Utilities, NetAdder::IP::Util