1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-04 03:43:14 +02:00

+- Added a hell lot of DNS debugging code, and fixed the BIGENDIAN problem

+  with resolver. Thanks to dawn and Trash.net for shell on a sparc
This commit is contained in:
stskeeps
2001-10-14 21:54:25 +00:00
parent 85ce15ddf7
commit 3f9849b5fd
8 changed files with 317 additions and 222 deletions
+2
View File
@@ -876,3 +876,5 @@ seen. gmtime warning still there
- Removed the tokens for /users, /summon, and /samode (these never come from a server so they don't need
it)
- Added a utility to auto create version.c for win32. It's the worst coding I've ever done, but it works :P
- Added a hell lot of DNS debugging code, and fixed the BIGENDIAN problem
with resolver. Thanks to dawn and Trash.net for shell on a sparc
+229 -173
View File
@@ -14,13 +14,13 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
@@ -76,10 +76,19 @@
*/
/*
* @(#)nameser.h 8.1 (Berkeley) 6/2/93
* $Id$
* @(#)nameser.h 8.1 (Berkeley) 6/2/93
* $NetBSD: nameser.h,v 1.14 2000/08/09 14:41:00 itojun Exp $
*/
#ifndef _ARPA_NAMESER_H_
#define _ARPA_NAMESER_H_
#include <sys/param.h>
#ifdef _AUX_SOURCE
# include <sys/types.h>
#endif
/*
* revision information. this is the release date in YYYYMMDD format.
* it can change every day so the right thing to do with it is use it
@@ -88,156 +97,198 @@
* is new enough to contain a certain feature.
*/
#define __BIND 19960801 /* interface version stamp */
#define __BIND 19960801 /* interface version stamp */
/*
* Define constants based on rfc883
*/
#define PACKETSZ 512 /* maximum packet size */
#define MAXDNAME 1025 /* maximum presentation domain name */
#define MAXCDNAME 255 /* maximum compressed domain name */
#define MAXLABEL 63 /* maximum length of domain label */
#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
#define INT32SZ 4 /* for systems without 32-bit ints */
#define INT16SZ 2 /* for systems without 16-bit ints */
#define INADDRSZ 4 /* IPv4 T_A */
#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
#define PACKETSZ 512 /* maximum packet size */
#define MAXDNAME 1025 /* maximum presentation domain name */
#define MAXCDNAME 255 /* maximum compressed domain name */
#define MAXLABEL 63 /* maximum length of domain label */
#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
#define INT32SZ 4 /* for systems without 32-bit ints */
#define INT16SZ 2 /* for systems without 16-bit ints */
#define INADDRSZ 4 /* IPv4 T_A */
#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
/*
* Internet nameserver port number
*/
#define NAMESERVER_PORT 53
#define NAMESERVER_PORT 53
/*
* Currently defined opcodes
*/
#define QUERY 0x0 /* standard query */
#define IQUERY 0x1 /* inverse query */
#define STATUS 0x2 /* nameserver status query */
/*#define xxx 0x3*/ /* 0x3 reserved */
#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
#define QUERY 0x0 /* standard query */
#define IQUERY 0x1 /* inverse query */
#define STATUS 0x2 /* nameserver status query */
/*#define xxx 0x3*/ /* 0x3 reserved */
#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
/*
* Currently defined response codes
*/
#define NOERROR 0 /* no error */
#define FORMERR 1 /* format error */
#define SERVFAIL 2 /* server failure */
#define NXDOMAIN 3 /* non existent domain */
#define NOTIMP 4 /* not implemented */
#define REFUSED 5 /* query refused */
#define NOERROR 0 /* no error */
#define FORMERR 1 /* format error */
#define SERVFAIL 2 /* server failure */
#define NXDOMAIN 3 /* non existent domain */
#define NOTIMP 4 /* not implemented */
#define REFUSED 5 /* query refused */
/*
* Type values for resources and queries
*/
#define T_A 1 /* host address */
#define T_NS 2 /* authoritative server */
#define T_MD 3 /* mail destination */
#define T_MF 4 /* mail forwarder */
#define T_CNAME 5 /* canonical name */
#define T_SOA 6 /* start of authority zone */
#define T_MB 7 /* mailbox domain name */
#define T_MG 8 /* mail group member */
#define T_MR 9 /* mail rename name */
#define T_NULL 10 /* null resource record */
#define T_WKS 11 /* well known service */
#define T_PTR 12 /* domain name pointer */
#define T_HINFO 13 /* host information */
#define T_MINFO 14 /* mailbox information */
#define T_MX 15 /* mail routing information */
#define T_TXT 16 /* text strings */
#define T_RP 17 /* responsible person */
#define T_AFSDB 18 /* AFS cell database */
#define T_X25 19 /* X_25 calling address */
#define T_ISDN 20 /* ISDN calling address */
#define T_RT 21 /* router */
#define T_NSAP 22 /* NSAP address */
#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
#define T_SIG 24 /* security signature */
#define T_KEY 25 /* security key */
#define T_PX 26 /* X.400 mail mapping */
#define T_GPOS 27 /* geographical position (withdrawn) */
#define T_AAAA 28 /* IP6 Address */
#define T_LOC 29 /* Location Information */
#define T_NXT 30 /* Next Valid Name in Zone */
#define T_EID 31 /* Endpoint identifier */
#define T_NIMLOC 32 /* Nimrod locator */
#define T_SRV 33 /* Server selection */
#define T_ATMA 34 /* ATM Address */
#define T_NAPTR 35 /* Naming Authority PoinTeR */
/* non standard */
#define T_UINFO 100 /* user (finger) information */
#define T_UID 101 /* user ID */
#define T_GID 102 /* group ID */
#define T_UNSPEC 103 /* Unspecified format (binary data) */
/* Query type values which do not appear in resource records */
#define T_IXFR 251 /* incremental zone transfer */
#define T_AXFR 252 /* transfer zone of authority */
#define T_MAILB 253 /* transfer mailbox records */
#define T_MAILA 254 /* transfer mail agent records */
#define T_ANY 255 /* wildcard match */
#define T_A 1 /* host address */
#define T_NS 2 /* authoritative server */
#define T_MD 3 /* mail destination */
#define T_MF 4 /* mail forwarder */
#define T_CNAME 5 /* canonical name */
#define T_SOA 6 /* start of authority zone */
#define T_MB 7 /* mailbox domain name */
#define T_MG 8 /* mail group member */
#define T_MR 9 /* mail rename name */
#define T_NULL 10 /* null resource record */
#define T_WKS 11 /* well known service */
#define T_PTR 12 /* domain name pointer */
#define T_HINFO 13 /* host information */
#define T_MINFO 14 /* mailbox information */
#define T_MX 15 /* mail routing information */
#define T_TXT 16 /* text strings */
#define T_RP 17 /* responsible person */
#define T_AFSDB 18 /* AFS cell database */
#define T_X25 19 /* X_25 calling address */
#define T_ISDN 20 /* ISDN calling address */
#define T_RT 21 /* router */
#define T_NSAP 22 /* NSAP address */
#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
#define T_SIG 24 /* security signature */
#define T_KEY 25 /* security key */
#define T_PX 26 /* X.400 mail mapping */
#define T_GPOS 27 /* geographical position (withdrawn) */
#define T_AAAA 28 /* IP6 Address */
#define T_LOC 29 /* Location Information */
#define T_NXT 30 /* Next Valid Name in Zone */
#define T_EID 31 /* Endpoint identifier */
#define T_NIMLOC 32 /* Nimrod locator */
#define T_SRV 33 /* Server selection */
#define T_ATMA 34 /* ATM Address */
#define T_NAPTR 35 /* Naming Authority PoinTeR */
#define T_OPT 41 /* OPT pseudo-RR, RFC2761 */
/* non standard */
#define T_UINFO 100 /* user (finger) information */
#define T_UID 101 /* user ID */
#define T_GID 102 /* group ID */
#define T_UNSPEC 103 /* Unspecified format (binary data) */
/* Query type values which do not appear in resource records */
#define T_IXFR 251 /* incremental zone transfer */
#define T_AXFR 252 /* transfer zone of authority */
#define T_MAILB 253 /* transfer mailbox records */
#define T_MAILA 254 /* transfer mail agent records */
#define T_ANY 255 /* wildcard match */
/*
* Values for class field
*/
#define C_IN 1 /* the arpa internet */
#define C_CHAOS 3 /* for chaos net (MIT) */
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
/* Query class values which do not appear in resource records */
#define C_ANY 255 /* wildcard match */
#define C_IN 1 /* the arpa internet */
#define C_CHAOS 3 /* for chaos net (MIT) */
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
/* Query class values which do not appear in resource records */
#define C_ANY 255 /* wildcard match */
/*
* Flags field of the KEY RR rdata
*/
#define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */
#define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
#define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
#define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
#define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
#define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */
#define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
#define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
#define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
#define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
/* The type bits can also be interpreted independently, as single bits: */
#define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */
#define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */
#define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */
#define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */
#define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */
#define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */
#define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */
#define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */
#define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */
#define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */
#define KEYFLAG_IPSEC 0x0080 /* key is for IPSEC use (host or user)*/
#define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */
#define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */
#define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */
#define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */
#define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */
#define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */
#define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */
#define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */
#define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */
#define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */
#define KEYFLAG_IPSEC 0x0080 /* key is for IPSEC use (host or user)*/
#define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */
#define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */
#define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */
#define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */
#define KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \
KEYFLAG_RESERVED4 | \
KEYFLAG_RESERVED10| KEYFLAG_RESERVED11)
KEYFLAG_RESERVED4 | \
KEYFLAG_RESERVED10| KEYFLAG_RESERVED11)
/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
#define ALGORITHM_MD5RSA 1 /* MD5 with RSA */
#define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */
#define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */
#define ALGORITHM_MD5RSA 1 /* MD5 with RSA */
#define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */
#define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */
/* Signatures */
/* Size of a mod or exp in bits */
#define MIN_MD5RSA_KEY_PART_BITS 512
#define MAX_MD5RSA_KEY_PART_BITS 2552
/* Total of binary mod and exp, bytes */
#define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3)
/* Max length of text sig block */
#define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4)
/* Size of a mod or exp in bits */
#define MIN_MD5RSA_KEY_PART_BITS 512
#define MAX_MD5RSA_KEY_PART_BITS 2552
/* Total of binary mod and exp, bytes */
#define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3)
/* Max length of text sig block */
#define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4)
/*
* Status return codes for T_UNSPEC conversion routines
*/
#define CONV_SUCCESS 0
#define CONV_OVERFLOW (-1)
#define CONV_BADFMT (-2)
#define CONV_BADCKSUM (-3)
#define CONV_BADBUFLEN (-4)
#define CONV_SUCCESS 0
#define CONV_OVERFLOW (-1)
#define CONV_BADFMT (-2)
#define CONV_BADCKSUM (-3)
#define CONV_BADBUFLEN (-4)
#ifndef BYTE_ORDER
#if (BSD >= 199103)
# include <machine/endian.h>
#else
#ifdef linux
# include <endian.h>
#else
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
defined(__alpha__) || defined(__alpha) || defined(__vax__)
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
defined(__hppa) || defined(__hp9000) || \
defined(__hp9000s300) || defined(__hp9000s700) || \
defined (BIT_ZERO_ON_LEFT) || defined(m68k)
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif /* linux */
#endif /* BSD */
#endif /* BYTE_ORDER */
#if !defined(BYTE_ORDER) || \
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
BYTE_ORDER != PDP_ENDIAN)
/* you must determine what the correct bit order is for
* your compiler - the next line is an intentional error
* which will force your compiles to bomb until you fix
* the above macros.
*/
error "Undefined or invalid BYTE_ORDER";
#endif
/*
* Structure for query header. The order of the fields is machine- and
@@ -247,45 +298,47 @@
*/
typedef struct {
unsigned id :16; /* query identification number */
#if WORDS_BIGENDIAN
/* fields in third byte */
unsigned qr: 1; /* response flag */
unsigned opcode: 4; /* purpose of message */
unsigned aa: 1; /* authoritive answer */
unsigned tc: 1; /* truncated message */
unsigned rd: 1; /* recursion desired */
/* fields in fourth byte */
unsigned ra: 1; /* recursion available */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /* authentic data from named */
unsigned cd: 1; /* checking disabled by resolver */
unsigned rcode :4; /* response code */
#else /* WORDS_BIGENDIAN */
/* fields in third byte */
unsigned rd :1; /* recursion desired */
unsigned tc :1; /* truncated message */
unsigned aa :1; /* authoritive answer */
unsigned opcode :4; /* purpose of message */
unsigned qr :1; /* response flag */
/* fields in fourth byte */
unsigned rcode :4; /* response code */
unsigned cd: 1; /* checking disabled by resolver */
unsigned ad: 1; /* authentic data from named */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /* recursion available */
#endif /* WORDS_BIGENDIAN */
/* remaining bytes */
unsigned qdcount :16; /* number of question entries */
unsigned ancount :16; /* number of answer entries */
unsigned nscount :16; /* number of authority entries */
unsigned arcount :16; /* number of resource entries */
unsigned id :16; /* query identification number */
#if BYTE_ORDER == BIG_ENDIAN
/* fields in third byte */
unsigned qr: 1; /* response flag */
unsigned opcode: 4; /* purpose of message */
unsigned aa: 1; /* authoritive answer */
unsigned tc: 1; /* truncated message */
unsigned rd: 1; /* recursion desired */
/* fields in fourth byte */
unsigned ra: 1; /* recursion available */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /* authentic data from named */
unsigned cd: 1; /* checking disabled by resolver */
unsigned rcode :4; /* response code */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
/* fields in third byte */
unsigned rd :1; /* recursion desired */
unsigned tc :1; /* truncated message */
unsigned aa :1; /* authoritive answer */
unsigned opcode :4; /* purpose of message */
unsigned qr :1; /* response flag */
/* fields in fourth byte */
unsigned rcode :4; /* response code */
unsigned cd: 1; /* checking disabled by resolver */
unsigned ad: 1; /* authentic data from named */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /* recursion available */
#endif
/* remaining bytes */
unsigned qdcount :16; /* number of question entries */
unsigned ancount :16; /* number of answer entries */
unsigned nscount :16; /* number of authority entries */
unsigned arcount :16; /* number of resource entries */
} HEADER;
/*
* Defines for handling compressed domain names
*/
#define INDIR_MASK 0xc0
#define INDIR_MASK 0xc0
/*
* Inline versions of get/put short/long. Pointer is advanced.
@@ -294,37 +347,40 @@ typedef struct {
* portable or it can be elegant but rarely both.
*/
#define GETSHORT(s, cp) { \
register u_char *t_cp = (u_char *)(cp); \
(s) = ((u_int16_t)t_cp[0] << 8) \
| ((u_int16_t)t_cp[1]) \
; \
(cp) += INT16SZ; \
register const u_char *t_cp = (const u_char *)(cp); \
(s) = ((const u_int16_t)t_cp[0] << 8) \
| ((const u_int16_t)t_cp[1]) \
; \
(cp) += INT16SZ; \
}
#define GETLONG(l, cp) { \
register u_char *t_cp = (u_char *)(cp); \
(l) = ((u_int32_t)t_cp[0] << 24) \
| ((u_int32_t)t_cp[1] << 16) \
| ((u_int32_t)t_cp[2] << 8) \
| ((u_int32_t)t_cp[3]) \
; \
(cp) += INT32SZ; \
register const u_char *t_cp = (const u_char *)(cp); \
(l) = ((const u_int32_t)t_cp[0] << 24) \
| ((const u_int32_t)t_cp[1] << 16) \
| ((const u_int32_t)t_cp[2] << 8) \
| ((const u_int32_t)t_cp[3]) \
; \
(cp) += INT32SZ; \
}
#define PUTSHORT(s, cp) { \
register u_int16_t t_s = (u_int16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += INT16SZ; \
register u_int16_t t_s = (u_int16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = (u_int32_t)t_s >> 8; \
*t_cp = t_s; \
(cp) += INT16SZ; \
}
#define PUTLONG(l, cp) { \
register u_int32_t t_l = (u_int32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += INT32SZ; \
register u_int32_t t_l = (u_int32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += INT32SZ; \
}
#endif /* _ARPA_NAMESER_H_ */
+64 -22
View File
@@ -111,6 +111,8 @@ int init_resolver(op)
if (!ircd_res.nscount)
{
ircd_res.nscount = 1;
Debug((DEBUG_DNS, "Setting nameserver to be %s",
NAME_SERVER));
#ifdef INET6
/* still IPv4 */
ircd_res.nsaddr_list[0].sin_addr.s_addr =
@@ -137,7 +139,7 @@ int init_resolver(op)
(void)setsockopt(ret, SOL_SOCKET, SO_BROADCAST, &on, on);
#endif
}
#ifdef DEBUG
#ifdef DEBUGMODE
if (op & RES_INITDEBG);
ircd_res.options |= RES_DEBUG;
#endif
@@ -193,7 +195,7 @@ static void rem_request(old)
last = r2ptr;
break;
}
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_INFO, "rem_request:Remove %#x at %#x %#x",
old, *rptr, r2ptr));
#endif
@@ -272,7 +274,7 @@ time_t timeout_query_list(now)
#endif
if (--rptr->retries <= 0)
{
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_ERROR, "timeout %x now %d cptr %x",
rptr, now, rptr->cinfo.value.cptr));
#endif
@@ -303,7 +305,7 @@ time_t timeout_query_list(now)
resend_query(rptr);
#endif
tout = now + rptr->timeout;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_INFO, "r %x now %d retry %d c %x",
rptr, now, rptr->retries,
rptr->cinfo.value.cptr));
@@ -344,6 +346,11 @@ static int send_res_msg(msg, len, rcount)
char *msg;
int len, rcount;
{
#ifdef DEBUGMODE
char debbuffer[50];
int j;
#endif
int i;
int sent = 0, max;
@@ -356,14 +363,44 @@ static int send_res_msg(msg, len, rcount)
if (!max)
max = 1;
#ifdef DEBUGMODE
Debug((DEBUG_DNS, "send_res_msg: Dumping packet contents"));
*debbuffer = '\0';
j = 0;
for (i = 0; i < len; i++)
{
debbuffer[j] = msg[i] > 32 ? msg[i] : '.';
j++;
if (j == 32)
{
debbuffer[j] = '\0';
Debug((DEBUG_DNS, "- %s", debbuffer));
j = 0;
}
}
if (j > 0)
{
debbuffer[j] = '\0';
Debug((DEBUG_DNS, "- %s", debbuffer));
}
#endif
for (i = 0; i < max; i++)
{
Debug((DEBUG_DNS, "Sending to nameserver %i",
i));
#ifndef INET6
Debug((DEBUG_DNS, "IP: %s",
inet_ntoa(ircd_res.nsaddr_list[i].sin_addr)));
#endif
#ifdef INET6
/* still IPv4 */
ircd_res.nsaddr_list[i].sin_family = AF_INET;
#else
ircd_res.nsaddr_list[i].sin_family = AF_INET;
#endif
ERRNO = 0;
#ifdef INET6
if (sendto(resfd, msg, len, 0,
(struct sockaddr *)&(ircd_res.nsaddr_list[i]),
@@ -375,6 +412,7 @@ static int send_res_msg(msg, len, rcount)
#endif
{
Debug((DEBUG_DNS, "send_res_msg, errno = %s",strerror(ERRNO)));
reinfo.re_sent++;
sent++;
}
@@ -541,6 +579,8 @@ static int do_query_number(lp, numb, rptr)
(u_int)(cp[3]), (u_int)(cp[2]), (u_int)(cp[1]), (u_int)(cp[0]));
#endif
#endif
Debug((DEBUG_DNS, "do_query_number: built %s rptr = %lx",
ipbuf, rptr));
if (!rptr)
{
@@ -596,6 +636,7 @@ static int query_name(name, class, type, rptr)
(u_char *)buf, sizeof(buf));
if (r <= 0)
{
Debug((DEBUG_DNS, "query_name: NO_RECOVERY"));
h_errno = NO_RECOVERY;
return r;
}
@@ -622,6 +663,7 @@ static int query_name(name, class, type, rptr)
s = send_res_msg(buf, r, rptr->sends);
if (s == -1)
{
Debug((DEBUG_DNS, "query_name: TRY_AGAIN"));
h_errno = TRY_AGAIN;
return -1;
}
@@ -819,7 +861,7 @@ static int proc_answer(rptr, hptr, buf, eob)
ans++;
break;
default:
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_INFO, "proc_answer: type:%d for:%s",
type, hostbuf));
#endif
@@ -880,7 +922,7 @@ struct hostent *get_res(lp,id)
hptr->qdcount = ntohs(hptr->qdcount);
hptr->nscount = ntohs(hptr->nscount);
hptr->arcount = ntohs(hptr->arcount);
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_NOTICE, "get_res:id = %d rcode = %d ancount = %d",
hptr->id, hptr->rcode, hptr->ancount));
#endif
@@ -982,7 +1024,7 @@ struct hostent *get_res(lp,id)
inetntoa((char *)&rptr->he.h_addr)));
#endif
}
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_INFO, "get_res:Proc answer = %d", a));
#endif
if (a > 0 && rptr->type == T_PTR)
@@ -1032,7 +1074,7 @@ struct hostent *get_res(lp,id)
if (lp)
bcopy((char *)&rptr->cinfo, lp, sizeof(Link));
cp = make_cache(rptr);
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_INFO, "get_res:cp=%#x rptr=%#x (made)", cp, rptr));
#endif
@@ -1177,7 +1219,7 @@ static aCache *add_to_cache(ocp)
aCache *cp = NULL;
int hashv;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_INFO,
"add_to_cache:ocp %#x he %#x name %#x addrl %#x 0 %#x",
ocp, HE(ocp), HE(ocp)->h_name, HE(ocp)->h_addr_list,
@@ -1194,7 +1236,7 @@ static aCache *add_to_cache(ocp)
ocp->hnum_next = hashtable[hashv].num_list;
hashtable[hashv].num_list = ocp;
#ifdef DEBUG
#ifdef DEBUGMODE
#ifdef INET6
Debug((DEBUG_INFO, "add_to_cache:added %s[%08x%08x%08x%08x] cache %#x.",
ocp->he.h_name,
@@ -1258,9 +1300,9 @@ static void update_list(rptr, cachep)
if (!rptr)
return;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_DEBUG, "u_l:cp %#x na %#x al %#x ad %#x",
cp, HE(cp)->h_name, HE(cp)->h_aliases, HE(cp)->he.h_addr));
cp, HE(cp)->h_name, HE(cp)->h_aliases, HE(cp)->h_addr));
Debug((DEBUG_DEBUG, "u_l:rptr %#x h_n %#x", rptr, HE(rptr)->h_name));
#endif
/*
@@ -1285,9 +1327,9 @@ static void update_list(rptr, cachep)
base = (char **)MyRealloc((char *)base,
sizeof(char *) * (addrcount + 1));
HE(cp)->h_aliases = base;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_DNS, "u_l:add name %s hal %x ac %d",
s, HE(CP)->h_aliases, addrcount));
s, HE(cp)->h_aliases, addrcount));
#endif
base[addrcount - 1] = strdup(s);
base[addrcount] = NULL;
@@ -1340,7 +1382,7 @@ static void update_list(rptr, cachep)
base = (char **)MyRealloc((char *)ab,
(addrcount + 1) * sizeof(*ab));
HE(cp)->h_addr_list = base;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_DNS, "u_l:add IP %x hal %x ac %d",
ntohl(((struct IN_ADDR *)s)->S_ADDR),
HE(cp)->h_addr_list, addrcount));
@@ -1368,7 +1410,7 @@ static aCache *find_cache_name(name)
hashv = hash_name(name);
cp = hashtable[hashv].name_list;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_DNS, "find_cache_name:find %s : hashv = %d", name, hashv));
#endif
@@ -1411,14 +1453,14 @@ static aCache *find_cache_number(rptr, numb)
{
aCache *cp;
int hashv, i;
#ifdef DEBUG
#ifdef DEBUGMODE
struct IN_ADDR *ip = (struct IN_ADDR *)numb;
#endif
hashv = hash_number((u_char *)numb);
cp = hashtable[hashv].num_list;
#ifdef DEBUG
#ifdef DEBUGMODE
#ifdef INET6
Debug((DEBUG_DNS,
"find_cache_number:find %s[%08x%08x%08x%08x]: hashv = %d",
@@ -1583,7 +1625,7 @@ static aCache *make_cache(rptr)
cp->ttl = rptr->ttl;
cp->expireat = TStime() + cp->ttl;
HE(rptr)->h_name = NULL;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_INFO, "make_cache:made cache %#x", cp));
#endif
return add_to_cache(cp);
@@ -1628,7 +1670,7 @@ static void rem_cache(ocp)
int hashv;
aClient *cptr;
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_DNS, "rem_cache: ocp %#x hp %#x l_n %#x aliases %#x",
ocp, hp, ocp->list_next, hp->h_aliases));
#endif
@@ -1652,7 +1694,7 @@ static void rem_cache(ocp)
* remove cache entry from hashed name lists
*/
hashv = hash_name(hp->h_name);
#ifdef DEBUG
#ifdef DEBUGMODE
Debug((DEBUG_DEBUG, "rem_cache: h_name %s hashv %d next %#x first %#x",
hp->h_name, hashv, ocp->hname_next, hashtable[hashv].name_list));
#endif
@@ -1666,7 +1708,7 @@ static void rem_cache(ocp)
* remove cache entry from hashed number list
*/
hashv = hash_number((u_char *)hp->h_addr);
#ifdef DEBUG
#ifdef DEBUGMODE
# ifdef INET6
Debug((DEBUG_DEBUG, "rem_cache: h_addr %s hashv %d next %#x first %#x",
inet_ntop(AF_INET6, hp->h_addr, mydummy, MYDUMMY_SIZE),
+14 -21
View File
@@ -488,14 +488,13 @@ int ircd_res_init()
dots--;
}
*pp = NULL;
#ifdef DEBUG
if (ircd_res.options & RES_DEBUG)
#ifdef DEBUGMODE
Debug((DEBUG_DNS, ";; res_init()... default dnsrch list:"));
for (pp = ircd_res.dnsrch; *pp; pp++)
{
printf(";; res_init()... default dnsrch list:\n");
for (pp = ircd_res.dnsrch; *pp; pp++)
printf(";;\t%s\n", *pp);
printf(";;\t..END..\n");
Debug((DEBUG_DNS, ";;\t%s", *pp));
}
Debug((DEBUG_DNS, ";;\t..END..\n"));
#endif /* DEBUG */
#endif /* !RFC1535 */
}
@@ -512,10 +511,9 @@ static void ircd_res_setoptions(options, source)
char *cp = options;
int i;
#ifdef DEBUG
if (ircd_res.options & RES_DEBUG)
printf(";; ircd_res_setoptions(\"%s\", \"%s\")...\n",
options, source);
#ifdef DEBUGMODE
Debug((DEBUG_DNS, ";; ircd_res_setoptions(\"%s\", \"%s\")...",
options, source));
#endif
while (*cp)
{
@@ -530,22 +528,17 @@ static void ircd_res_setoptions(options, source)
ircd_res.ndots = i;
else
ircd_res.ndots = RES_MAXNDOTS;
#ifdef DEBUG
if (ircd_res.options & RES_DEBUG)
printf(";;\tndots=%d\n", ircd_res.ndots);
#ifdef DEBUGMODE
Debug((DEBUG_DNS, ";;\tndots=%d", ircd_res.ndots));
#endif
}
else if (!strncmp(cp, "debug", sizeof("debug") - 1))
{
#ifdef DEBUG
if (!(ircd_res.options & RES_DEBUG))
{
printf
(";; ircd_res_setoptions(\"%s\", \"%s\")..\n",
options, source);
#ifdef DEBUGMODE
Debug((DEBUG_DNS,
";; ircd_res_setoptions(\"%s\", \"%s\")..",
options, source));
ircd_res.options |= RES_DEBUG;
}
printf(";;\tdebug\n");
#endif
}
else if (!strncmp(cp, "inet6", sizeof("inet6") - 1))
+4 -4
View File
@@ -99,10 +99,10 @@ ircd_res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
h_errno = NETDB_INTERNAL;
return (-1);
}
#ifdef DEBUG
if (ircd_res.options & RES_DEBUG)
printf(";; res_mkquery(%d, %s, %d, %d)\n",
op, dname, class, type);
#ifdef DEBUGMODE
Debug((DEBUG_DNS,
";; res_mkquery(%d, %s, %d, %d)",
op, dname, class, type));
#endif
/*
* Initialize header fields.
+2
View File
@@ -632,6 +632,7 @@ init_dgram:
#endif /*_WIN32*/
resfd = init_resolver(0x1f);
Debug((DEBUG_DNS, "resfd %d", resfd));
return;
}
@@ -1690,6 +1691,7 @@ int read_message(delay, listp)
#ifndef _WIN32
if (resfd >= 0 && FD_ISSET(resfd, &read_set))
{
Debug((DEBUG_DNS, "Doing DNS async.."));
do_dns_async();
nfds--;
FD_CLR(resfd, &read_set);
+2 -2
View File
@@ -243,8 +243,8 @@ void send_usage(cptr, nick)
if (getrusage(RUSAGE_SELF, &rus) == -1)
{
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__)
/* extern char *sys_errlist[]; */
#ifdef _SOLARIS
extern char *sys_errlist[];
#endif
sendto_one(cptr, ":%s NOTICE %s :Getruseage error: %s.",
me.name, nick, sys_errlist[errno]);
BIN
View File
Binary file not shown.