aboutsummaryrefslogtreecommitdiff
path: root/resolv/res_debug.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-07-26 10:14:02 +0000
committerRoland McGrath <roland@gnu.org>1995-07-26 10:14:02 +0000
commit3d61b63cc722951e3a5261e6bc3f0488eb35d441 (patch)
tree19195b08df7f3f992f0d539205df60ff690cd0f6 /resolv/res_debug.c
parent958f803fc021993cc2ee1d4157d0092b830368aa (diff)
downloadglibc-3d61b63cc722951e3a5261e6bc3f0488eb35d441.zip
glibc-3d61b63cc722951e3a5261e6bc3f0488eb35d441.tar.gz
glibc-3d61b63cc722951e3a5261e6bc3f0488eb35d441.tar.bz2
* asia, backward, europe, leapseconds, southamerica: New data from
ADO's 95e. * inet/Makefile (routines): Removed inet_addr. * inet/inet_addr.c: Moved to resolv/ subdirectory. * resolv/Makefile (routines): Added inet_addr. * resolv/inet_addr.c: Incorporated from BIND 4.9.3-BETA24 release. * resolv/gethnamaddr.c: Likewise. * resolv/getnetbyaddr.c: Likewise. * resolv/getnetbyname.c: Likewise. * resolv/getnetent.c: Likewise. * resolv/getnetnamadr.c: Likewise. * resolv/herror.c: Likewise. * resolv/nsap_addr.c: Likewise. * resolv/res_comp.c: Likewise. * resolv/res_debug.c: Likewise. * resolv/res_init.c: Likewise. * resolv/res_mkquery.c: Likewise. * resolv/res_query.c: Likewise. * resolv/res_send.c: Likewise. * resolv/resolv.h: Likewise. * resolv/sethostent.c: Likewise. * resolv/arpa/nameser.h: Likewise. * inet/netdb.h: Incorporated from BIND 4.9.3-BETA24 release. [__GNU_LIBRARY__]: Include <rpc/netdb.h> instead of repeating its declarations (and doing so only #ifdef sun!). * posix/sys/types.h [__USE_BSD] (__BIT_TYPES_DEFINED__): New macro. [__USE_BSD] [__GNUC__] (int64_t, u_int64_t, register_t): New typedefs.
Diffstat (limited to 'resolv/res_debug.c')
-rw-r--r--resolv/res_debug.c70
1 files changed, 45 insertions, 25 deletions
diff --git a/resolv/res_debug.c b/resolv/res_debug.c
index 254e1ef..602042e 100644
--- a/resolv/res_debug.c
+++ b/resolv/res_debug.c
@@ -64,6 +64,7 @@ static char rcsid[] = "$Id$";
#include <arpa/nameser.h>
#include <stdio.h>
+#include <netdb.h>
#include <resolv.h>
#if defined(BSD) && (BSD >= 199103)
# include <string.h>
@@ -113,12 +114,13 @@ const char *_res_resultcodes[] = {
"NOCHANGE",
};
-static char retbuf[16];
-
+/* XXX: we should use getservbyport() instead. */
static const char *
dewks(wks)
int wks;
{
+ static char nbuf[20];
+
switch (wks) {
case 5: return "rje";
case 7: return "echo";
@@ -166,14 +168,17 @@ dewks(wks)
case 161: return "snmp";
case 162: return "snmp-trap";
case 170: return "print-srv";
- default: (void) sprintf(retbuf, "%d", wks); return (retbuf);
+ default: (void) sprintf(nbuf, "%d", wks); return (nbuf);
}
}
+/* XXX: we should use getprotobynumber() instead. */
static const char *
deproto(protonum)
int protonum;
{
+ static char nbuf[20];
+
switch (protonum) {
case 1: return "icmp";
case 2: return "igmp";
@@ -187,13 +192,13 @@ deproto(protonum)
case 12: return "pup";
case 16: return "chaos";
case 17: return "udp";
- default: (void) sprintf(retbuf, "%d", protonum); return (retbuf);
+ default: (void) sprintf(nbuf, "%d", protonum); return (nbuf);
}
}
static const u_char *
-do_rrset(msg, cp, cnt, pflag, file, hs)
- int cnt, pflag;
+do_rrset(msg, len, cp, cnt, pflag, file, hs)
+ int cnt, pflag, len;
const u_char *cp, *msg;
const char *hs;
FILE *file;
@@ -222,7 +227,7 @@ do_rrset(msg, cp, cnt, pflag, file, hs)
cp += INT16SZ;
cp += dlen;
}
- if ((cp - msg) > PACKETSZ)
+ if ((cp - msg) > len)
return (NULL);
}
if ((!_res.pfcode) ||
@@ -285,6 +290,9 @@ __fp_nquery(msg, len, file)
register const HEADER *hp;
register int n;
+ if ((_res.options & RES_INIT) == 0 && res_init() == -1)
+ return;
+
#define TruncTest(x) if (x >= endMark) goto trunc
#define ErrorTest(x) if (x == NULL) goto error
@@ -314,8 +322,6 @@ __fp_nquery(msg, len, file)
fprintf(file, " rd");
if (hp->ra)
fprintf(file, " ra");
- if (hp->pr)
- fprintf(file, " pr");
}
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
fprintf(file, "; Ques: %d", ntohs(hp->qdcount));
@@ -336,7 +342,7 @@ __fp_nquery(msg, len, file)
while (--n >= 0) {
fprintf(file, ";;\t");
TruncTest(cp);
- cp = p_cdname(cp, msg, file);
+ cp = p_cdnname(cp, msg, len, file);
ErrorTest(cp);
TruncTest(cp);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
@@ -355,7 +361,7 @@ __fp_nquery(msg, len, file)
* Print authoritative answer records
*/
TruncTest(cp);
- cp = do_rrset(msg, cp, hp->ancount, RES_PRF_ANS, file,
+ cp = do_rrset(msg, len, cp, hp->ancount, RES_PRF_ANS, file,
";; ANSWERS:\n");
ErrorTest(cp);
@@ -363,7 +369,7 @@ __fp_nquery(msg, len, file)
* print name server records
*/
TruncTest(cp);
- cp = do_rrset(msg, cp, hp->nscount, RES_PRF_AUTH, file,
+ cp = do_rrset(msg, len, cp, hp->nscount, RES_PRF_AUTH, file,
";; AUTHORITY RECORDS:\n");
ErrorTest(cp);
@@ -371,7 +377,7 @@ __fp_nquery(msg, len, file)
/*
* print additional records
*/
- cp = do_rrset(msg, cp, hp->arcount, RES_PRF_ADD, file,
+ cp = do_rrset(msg, len, cp, hp->arcount, RES_PRF_ADD, file,
";; ADDITIONAL RECORDS:\n");
ErrorTest(cp);
return;
@@ -425,7 +431,7 @@ __p_fqname(cp, msg, file)
FILE *file;
{
char name[MAXDNAME];
- int n, len;
+ int n;
if ((n = dn_expand(msg, cp + MAXCDNAME, cp, name, sizeof name)) < 0)
return (NULL);
@@ -453,6 +459,10 @@ __p_rr(cp, msg, file)
u_int32_t tmpttl, t;
int lcnt;
+ if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ h_errno = NETDB_INTERNAL;
+ return (NULL);
+ }
if ((cp = p_fqname(cp, msg, file)) == NULL)
return (NULL); /* compression error */
type = _getshort((u_char*)cp);
@@ -465,7 +475,7 @@ __p_rr(cp, msg, file)
cp += INT16SZ;
cp1 = cp;
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID))
- fprintf(file, "\t%lu", tmpttl);
+ fprintf(file, "\t%lu", (u_long)tmpttl);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS))
fprintf(file, "\t%s", __p_class(class));
fprintf(file, "\t%s", __p_type(type));
@@ -534,15 +544,19 @@ __p_rr(cp, msg, file)
return (NULL);
fputs(" (\n", file);
t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; serial\n", t);
+ fprintf(file, "\t\t\t%lu\t; serial\n", (u_long)t);
t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; refresh (%s)\n", t, __p_time(t));
+ fprintf(file, "\t\t\t%lu\t; refresh (%s)\n",
+ (u_long)t, __p_time(t));
t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; retry (%s)\n", t, __p_time(t));
+ fprintf(file, "\t\t\t%lu\t; retry (%s)\n",
+ (u_long)t, __p_time(t));
t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; expire (%s)\n", t, __p_time(t));
+ fprintf(file, "\t\t\t%lu\t; expire (%s)\n",
+ (u_long)t, __p_time(t));
t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu )\t; minimum (%s)", t, __p_time(t));
+ fprintf(file, "\t\t\t%lu )\t; minimum (%s)",
+ (u_long)t, __p_time(t));
break;
case T_MX:
@@ -673,8 +687,6 @@ __p_rr(cp, msg, file)
return (cp);
}
-static char nbuf[40];
-
/*
* Return a string for the type
*/
@@ -682,6 +694,8 @@ const char *
__p_type(type)
int type;
{
+ static char nbuf[20];
+
switch (type) {
case T_A: return "A";
case T_NS: return "NS";
@@ -731,6 +745,8 @@ const char *
__p_class(class)
int class;
{
+ static char nbuf[20];
+
switch (class) {
case C_IN: return "IN";
case C_HS: return "HS";
@@ -746,12 +762,14 @@ const char *
__p_option(option)
u_long option;
{
+ static char nbuf[40];
+
switch (option) {
case RES_INIT: return "init";
case RES_DEBUG: return "debug";
- case RES_AAONLY: return "aaonly";
+ case RES_AAONLY: return "aaonly(unimpl)";
case RES_USEVC: return "usevc";
- case RES_PRIMARY: return "primry";
+ case RES_PRIMARY: return "primry(unimpl)";
case RES_IGNTC: return "igntc";
case RES_RECURSE: return "recurs";
case RES_DEFNAMES: return "defnam";
@@ -759,7 +777,8 @@ __p_option(option)
case RES_DNSRCH: return "dnsrch";
case RES_INSECURE1: return "insecure1";
case RES_INSECURE2: return "insecure2";
- default: sprintf(nbuf, "?0x%x?", option); return (nbuf);
+ default: sprintf(nbuf, "?0x%lx?", (u_long)option);
+ return (nbuf);
}
}
@@ -770,6 +789,7 @@ char *
__p_time(value)
u_int32_t value;
{
+ static char nbuf[40];
int secs, mins, hours, days;
register char *p;