+++ /dev/null
-<?php\r
-/**\r
-* Class to provide IPv4 calculations\r
-*\r
-* Module written/ported by Eric Kilfoil <eric@ypass.net>\r
-*\r
-* This is the copyright notice from the PERL Net::DNS module:\r
-*\r
-* Copyright (c) 1997-2000 Michael Fuhr. All rights reserved. This\r
-* program is free software; you can redistribute it and/or modify it\r
-* under the same terms as Perl itself.\r
-*\r
-* The majority of this is _NOT_ my code. I simply ported it from the\r
-* PERL Net::DNS module.\r
-*\r
-* The author of the Net::DNS module is Michael Fuhr <mike@fuhr.org>\r
-* http://www.fuhr.org/~mfuhr/perldns/\r
-*\r
-* Michael Fuhr has nothing to with the porting of this code to PHP.\r
-* Any questions directly related to this class library should be directed\r
-* to the maintainer.\r
-*\r
-*\r
-* PHP versions 4 and 5\r
-*\r
-* LICENSE: This source file is subject to version 3.01 of the PHP license\r
-* that is available through the world-wide-web at the following URI:\r
-* http://www.php.net/license/3_01.txt. If you did not receive a copy of\r
-* the PHP License and are unable to obtain it through the web, please\r
-* send a note to license@php.net so we can mail you a copy immediately.\r
-*\r
-* @category Net\r
-* @package Net_IPv4\r
-* @author Eric Kilfoil <edk@ypass.net>\r
-* @author Marco Kaiser <bate@php.net>\r
-* @author Florian Anderiasch <fa@php.net>\r
-* @copyright 1997-2005 The PHP Group\r
-* @license http://www.php.net/license/3_01.txt PHP License 3.01\r
-* @version CVS: $Id: DNS.php,v 1.14 2006/10/25 17:52:44 bate Exp $\r
-* @link http://pear.php.net/package/Net_DNS\r
-*/\r
-\r
-/* Include information {{{ */\r
-\r
- require_once("Net/DNS/Header.php");\r
- require_once("Net/DNS/Question.php");\r
- require_once("Net/DNS/Packet.php");\r
- require_once("Net/DNS/Resolver.php");\r
- require_once("Net/DNS/RR.php");\r
-\r
-/* }}} */\r
-/* GLOBAL VARIABLE definitions {{{ */\r
-\r
-// Used by the Net_DNS_Resolver object to generate an ID\r
-\r
-$GLOBALS['_Net_DNS_packet_id'] = mt_rand(0, 65535);\r
-\r
-/* }}} */\r
-/* Net_DNS object definition (incomplete) {{{ */\r
-/**\r
- * Initializes a resolver object\r
- *\r
- * Net_DNS allows you to query a nameserver for DNS lookups. It bypasses the\r
- * system resolver library entirely, which allows you to query any nameserver,\r
- * set your own values for retries, timeouts, recursion, etc.\r
- *\r
- * @author Eric Kilfoil <eric@ypass.net>\r
- * @package Net_DNS\r
- * @version 0.01alpha\r
- */\r
-class Net_DNS\r
-{\r
- /* class variable definitions {{{ */\r
- /**\r
- * A default resolver object created on instantiation\r
- *\r
- * @var Net_DNS_Resolver object\r
- */\r
- var $resolver;\r
- var $VERSION = '1.00b2'; // This should probably be a define :(\r
- var $PACKETSZ = 512;\r
- var $HFIXEDSZ = 12;\r
- var $QFIXEDSZ = 4;\r
- var $RRFIXEDSZ = 10;\r
- var $INT32SZ = 4;\r
- var $INT16SZ = 2;\r
- /* }}} */\r
- /* class constructor - Net_DNS() {{{ */\r
-\r
- /**\r
- * Initializes a resolver object\r
- *\r
- * @see Net_DNS_Resolver\r
- * @param array $defaults\r
- * @return Net_DNS\r
- */\r
- function Net_DNS($defaults = array())\r
- {\r
- $this->resolver = new Net_DNS_Resolver($defaults);\r
- }\r
- /* }}} */\r
- /* Net_DNS::opcodesbyname() {{{ */\r
- /**\r
- * Translates opcode names to integers\r
- *\r
- * Translates the name of a DNS OPCODE into it's assigned number\r
- * listed in RFC1035, RFC1996, or RFC2136. Valid OPCODES are:\r
- * <ul>\r
- * <li>QUERY\r
- * <li>IQUERY\r
- * <li>STATUS\r
- * <li>NS_NOTIFY_OP\r
- * <li>UPDATE\r
- * <ul>\r
- *\r
- * @param string $opcode A DNS Packet OPCODE name\r
- * @return integer The integer value of an OPCODE\r
- * @see Net_DNS::opcodesbyval()\r
- */\r
- function opcodesbyname($opcode)\r
- {\r
- $op = array(\r
- 'QUERY' => 0, // RFC 1035\r
- 'IQUERY' => 1, // RFC 1035\r
- 'STATUS' => 2, // RFC 1035\r
- 'NS_NOTIFY_OP' => 4, // RFC 1996\r
- 'UPDATE' => 5, // RFC 2136\r
- );\r
- if (! strlen($op[$opcode])) {\r
- $op[$opcode] = null;\r
- }\r
- return $op[$opcode];\r
- }\r
-\r
- /* }}} */\r
- /* Net_DNS::opcodesbyval() {{{*/\r
- /**\r
- * Translates opcode integers into names\r
- *\r
- * Translates the integer value of an opcode into it's name\r
- *\r
- * @param integer $opcodeval A DNS packet opcode integer\r
- * @return string The name of the OPCODE\r
- * @see Net_DNS::opcodesbyname()\r
- */\r
- function opcodesbyval($opcodeval)\r
- {\r
- $opval = array(\r
- 0 => 'QUERY',\r
- 1 => 'IQUERY',\r
- 2 => 'STATUS',\r
- 4 => 'NS_NOTIFY_OP',\r
- 5 => 'UPDATE',\r
- );\r
- if (! strlen($opval[$opcodeval])) {\r
- $opval[$opcodeval] = null;\r
- }\r
- return $opval[$opcodeval];\r
- }\r
-\r
- /*}}}*/\r
- /* Net_DNS::rcodesbyname() {{{*/\r
- /**\r
- * Translates rcode names to integers\r
- *\r
- * Translates the name of a DNS RCODE (result code) into it's assigned number.\r
- * <ul>\r
- * <li>NOERROR\r
- * <li>FORMERR\r
- * <li>SERVFAIL\r
- * <li>NXDOMAIN\r
- * <li>NOTIMP\r
- * <li>REFUSED\r
- * <li>YXDOMAIN\r
- * <li>YXRRSET\r
- * <li>NXRRSET\r
- * <li>NOTAUTH\r
- * <li>NOTZONE\r
- * <ul>\r
- *\r
- * @param string $rcode A DNS Packet RCODE name\r
- * @return integer The integer value of an RCODE\r
- * @see Net_DNS::rcodesbyval()\r
- */\r
- function rcodesbyname($rcode)\r
- {\r
- $rc = array(\r
- 'NOERROR' => 0, // RFC 1035\r
- 'FORMERR' => 1, // RFC 1035\r
- 'SERVFAIL' => 2, // RFC 1035\r
- 'NXDOMAIN' => 3, // RFC 1035\r
- 'NOTIMP' => 4, // RFC 1035\r
- 'REFUSED' => 5, // RFC 1035\r
- 'YXDOMAIN' => 6, // RFC 2136\r
- 'YXRRSET' => 7, // RFC 2136\r
- 'NXRRSET' => 8, // RFC 2136\r
- 'NOTAUTH' => 9, // RFC 2136\r
- 'NOTZONE' => 10, // RFC 2136\r
- );\r
- if (! strlen($rc[$rcode])) {\r
- $rc[$rcode] = null;\r
- }\r
- return $rc[$rcode];\r
- }\r
-\r
- /*}}}*/\r
- /* Net_DNS::rcodesbyval() {{{*/\r
- /**\r
- * Translates rcode integers into names\r
- *\r
- * Translates the integer value of an rcode into it's name\r
- *\r
- * @param integer $rcodeval A DNS packet rcode integer\r
- * @return string The name of the RCODE\r
- * @see Net_DNS::rcodesbyname()\r
- */\r
- function rcodesbyval($rcodeval)\r
- {\r
- $rc = array(\r
- 0 => 'NOERROR',\r
- 1 => 'FORMERR',\r
- 2 => 'SERVFAIL',\r
- 3 => 'NXDOMAIN',\r
- 4 => 'NOTIMP',\r
- 5 => 'REFUSED',\r
- 6 => 'YXDOMAIN',\r
- 7 => 'YXRRSET',\r
- 8 => 'NXRRSET',\r
- 9 => 'NOTAUTH',\r
- 10 => 'NOTZONE',\r
- );\r
- if (! strlen($rc[$rcodeval])) {\r
- $rc[$rcodeval] = null;\r
- }\r
- return $rc[$rcodeval];\r
- }\r
-\r
- /*}}}*/\r
- /* Net_DNS::typesbyname() {{{*/\r
- /**\r
- * Translates RR type names into integers\r
- *\r
- * Translates a Resource Record from it's name to it's integer value.\r
- * Valid resource record types are:\r
- *\r
- * <ul>\r
- * <li>A\r
- * <li>NS\r
- * <li>MD\r
- * <li>MF\r
- * <li>CNAME\r
- * <li>SOA\r
- * <li>MB\r
- * <li>MG\r
- * <li>MR\r
- * <li>NULL\r
- * <li>WKS\r
- * <li>PTR\r
- * <li>HINFO\r
- * <li>MINFO\r
- * <li>MX\r
- * <li>TXT\r
- * <li>RP\r
- * <li>AFSDB\r
- * <li>X25\r
- * <li>ISDN\r
- * <li>RT\r
- * <li>NSAP\r
- * <li>NSAP_PTR\r
- * <li>SIG\r
- * <li>KEY\r
- * <li>PX\r
- * <li>GPOS\r
- * <li>AAAA\r
- * <li>LOC\r
- * <li>NXT\r
- * <li>EID\r
- * <li>NIMLOC\r
- * <li>SRV\r
- * <li>ATMA\r
- * <li>NAPTR\r
- * <li>TSIG\r
- * <li>UINFO\r
- * <li>UID\r
- * <li>GID\r
- * <li>UNSPEC\r
- * <li>IXFR\r
- * <li>AXFR\r
- * <li>MAILB\r
- * <li>MAILA\r
- * <li>ANY\r
- * <ul>\r
- *\r
- * @param string $rrtype A DNS packet RR type name\r
- * @return integer The integer value of an RR type\r
- * @see Net_DNS::typesbyval()\r
- */\r
- function typesbyname($rrtype)\r
- {\r
- $rc = array(\r
- 'A' => 1,\r
- 'NS' => 2,\r
- 'MD' => 3,\r
- 'MF' => 4,\r
- 'CNAME' => 5,\r
- 'SOA' => 6,\r
- 'MB' => 7,\r
- 'MG' => 8,\r
- 'MR' => 9,\r
- 'NULL' => 10,\r
- 'WKS' => 11,\r
- 'PTR' => 12,\r
- 'HINFO' => 13,\r
- 'MINFO' => 14,\r
- 'MX' => 15,\r
- 'TXT' => 16,\r
- 'RP' => 17,\r
- 'AFSDB' => 18,\r
- 'X25' => 19,\r
- 'ISDN' => 20,\r
- 'RT' => 21,\r
- 'NSAP' => 22,\r
- 'NSAP_PTR' => 23,\r
- 'SIG' => 24,\r
- 'KEY' => 25,\r
- 'PX' => 26,\r
- 'GPOS' => 27,\r
- 'AAAA' => 28,\r
- 'LOC' => 29,\r
- 'NXT' => 30,\r
- 'EID' => 31,\r
- 'NIMLOC' => 32,\r
- 'SRV' => 33,\r
- 'ATMA' => 34,\r
- 'NAPTR' => 35,\r
- 'UINFO' => 100,\r
- 'UID' => 101,\r
- 'GID' => 102,\r
- 'UNSPEC' => 103,\r
- 'TSIG' => 250,\r
- 'IXFR' => 251,\r
- 'AXFR' => 252,\r
- 'MAILB' => 253,\r
- 'MAILA' => 254,\r
- 'ANY' => 255,\r
- );\r
- if (empty($rc[$rrtype])) {\r
- $rc[$rrtype] = null;\r
- }\r
- return $rc[$rrtype];\r
- }\r
-\r
- /*}}}*/\r
- /* Net_DNS::typesbyval() {{{*/\r
- /**\r
- * Translates RR type integers into names\r
- *\r
- * Translates the integer value of an RR type into it's name\r
- *\r
- * @param integer $rrtypeval A DNS packet RR type integer\r
- * @return string The name of the RR type\r
- * @see Net_DNS::typesbyname()\r
- */\r
- function typesbyval($rrtypeval)\r
- {\r
- $rc = array(\r
- 1 => 'A',\r
- 2 => 'NS',\r
- 3 => 'MD',\r
- 4 => 'MF',\r
- 5 => 'CNAME',\r
- 6 => 'SOA',\r
- 7 => 'MB',\r
- 8 => 'MG',\r
- 9 => 'MR',\r
- 10 => 'NULL',\r
- 11 => 'WKS',\r
- 12 => 'PTR',\r
- 13 => 'HINFO',\r
- 14 => 'MINFO',\r
- 15 => 'MX',\r
- 16 => 'TXT',\r
- 17 => 'RP',\r
- 18 => 'AFSDB',\r
- 19 => 'X25',\r
- 20 => 'ISDN',\r
- 21 => 'RT',\r
- 22 => 'NSAP',\r
- 23 => 'NSAP_PTR',\r
- 24 => 'SIG',\r
- 25 => 'KEY',\r
- 26 => 'PX',\r
- 27 => 'GPOS',\r
- 28 => 'AAAA',\r
- 29 => 'LOC',\r
- 30 => 'NXT',\r
- 31 => 'EID',\r
- 32 => 'NIMLOC',\r
- 33 => 'SRV',\r
- 34 => 'ATMA',\r
- 35 => 'NAPTR',\r
- 100 => 'UINFO',\r
- 101 => 'UID',\r
- 102 => 'GID',\r
- 103 => 'UNSPEC',\r
- 250 => 'TSIG',\r
- 251 => 'IXFR',\r
- 252 => 'AXFR',\r
- 253 => 'MAILB',\r
- 254 => 'MAILA',\r
- 255 => 'ANY',\r
- );\r
- $rrtypeval = preg_replace(array('/\s*/',' /^0*/'), '', $rrtypeval);\r
- if (empty($rc[$rrtypeval])) {\r
- $rc[$rrtypeval] = null;\r
- }\r
- return $rc[$rrtypeval];\r
- }\r
-\r
- /*}}}*/\r
- /* Net_DNS::classesbyname() {{{*/\r
- /**\r
- * translates a DNS class from it's name to it's integer value. Valid\r
- * class names are:\r
- * <ul>\r
- * <li>IN\r
- * <li>CH\r
- * <li>HS\r
- * <li>NONE\r
- * <li>ANY\r
- * </ul>\r
- *\r
- * @param string $class A DNS packet class type\r
- * @return integer The integer value of an class type\r
- * @see Net_DNS::classesbyval()\r
- */\r
- function classesbyname($class)\r
- {\r
- $rc = array(\r
- 'IN' => 1, // RFC 1035\r
- 'CH' => 3, // RFC 1035\r
- 'HS' => 4, // RFC 1035\r
- 'NONE' => 254, // RFC 2136\r
- 'ANY' => 255 // RFC 1035\r
- );\r
- if (!isset($rc[$class])) {\r
- $rc[$class] = null;\r
- }\r
- return $rc[$class];\r
- }\r
-\r
- /*}}}*/\r
- /* Net_DNS::classesbyval() {{{*/\r
- /**\r
- * Translates RR class integers into names\r
- *\r
- * Translates the integer value of an RR class into it's name\r
- *\r
- * @param integer $classval A DNS packet RR class integer\r
- * @return string The name of the RR class\r
- * @see Net_DNS::classesbyname()\r
- */\r
- function classesbyval($classval)\r
- {\r
- $rc = array(\r
- 1 => 'IN',\r
- 3 => 'CH',\r
- 4 => 'HS',\r
- 254 => 'NONE',\r
- 255 => 'ANY'\r
- );\r
- $classval = preg_replace(array('/\s*/',' /^0*/'), '', $classval);\r
- if (empty($rc[$classval])) {\r
- $rc[$classval] = null;\r
- }\r
- return $rc[$classval];\r
- }\r
-\r
- /*}}}*/\r
- /* not completed - Net_DNS::mx() {{{*/\r
- /*}}}*/\r
- /* not completed - Net_DNS::yxrrset() {{{*/\r
- /*}}}*/\r
- /* not completed - Net_DNS::nxrrset() {{{*/\r
- /*}}}*/\r
- /* not completed - Net_DNS::yxdomain() {{{*/\r
- /*}}}*/\r
- /* not completed - Net_DNS::nxdomain() {{{*/\r
- /*}}}*/\r
- /* not completed - Net_DNS::rr_add() {{{*/\r
- /*}}}*/\r
- /* not completed - Net_DNS::rr_del() {{{*/\r
- /*}}}*/\r
-}\r
-/* }}} */\r
-/* VIM Settings {{{\r
- * Local variables:\r
- * tab-width: 4\r
- * c-basic-offset: 4\r
- * soft-stop-width: 4\r
- * c indent on\r
- * End:\r
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
- * vim<600: sw=4 ts=4\r
- * }}} */\r
-?>\r