include/arpa/nameser_compat.h: merged

Removing compatibility macros, and updating the two tools still using
them.

Change-Id: I636f045d76a8f92440ebe1503f52f7e5d704a316
This commit is contained in:
Lionel Sambuc 2013-12-02 16:03:29 +01:00
parent d1ae7749c8
commit fe1223849e
3 changed files with 43 additions and 51 deletions

View file

@ -479,10 +479,10 @@ printinfo(answer, eom, filter, isls)
* find first satisfactory answer * find first satisfactory answer
*/ */
hp = (HEADER *) answer; hp = (HEADER *) answer;
ancount = ntohs(hp->dh_ancount); ancount = ntohs(hp->ancount);
qdcount = ntohs(hp->dh_qdcount); qdcount = ntohs(hp->qdcount);
nscount = ntohs(hp->dh_nscount); nscount = ntohs(hp->nscount);
arcount = ntohs(hp->dh_arcount); arcount = ntohs(hp->arcount);
if (_res.options & RES_DEBUG || (verbose && isls == 0)) if (_res.options & RES_DEBUG || (verbose && isls == 0))
printf("rcode = %d (%s), ancount=%d\n", printf("rcode = %d (%s), ancount=%d\n",
hp->rcode, hp->rcode,
@ -1040,7 +1040,7 @@ ListHosts(namePtr, queryType)
} }
cp = answer.qb2 + sizeof(HEADER); cp = answer.qb2 + sizeof(HEADER);
if (ntohs(answer.qb1.dh_qdcount) > 0) if (ntohs(answer.qb1.qdcount) > 0)
cp += dn_skipname(cp, answer.qb2 + msglen) + QFIXEDSZ; cp += dn_skipname(cp, answer.qb2 + msglen) + QFIXEDSZ;
numns = 0; numns = 0;
@ -1261,7 +1261,7 @@ again:
i = buf.qb1.rcode; i = buf.qb1.rcode;
if (i != NOERROR || ntohs(buf.qb1.dh_ancount) == 0) { if (i != NOERROR || ntohs(buf.qb1.ancount) == 0) {
if ((thisns+1) < numnsaddr && if ((thisns+1) < numnsaddr &&
(i == SERVFAIL || i == NOTIMP || i == REFUSED)) { (i == SERVFAIL || i == NOTIMP || i == REFUSED)) {
if (_res.options & RES_DEBUG || verbose) if (_res.options & RES_DEBUG || verbose)
@ -1285,7 +1285,7 @@ again:
} }
numAnswers++; numAnswers++;
cp = buf.qb2 + sizeof(HEADER); cp = buf.qb2 + sizeof(HEADER);
if (ntohs(buf.qb1.dh_qdcount) > 0) if (ntohs(buf.qb1.qdcount) > 0)
cp += dn_skipname(cp, buf.qb2 + len) + QFIXEDSZ; cp += dn_skipname(cp, buf.qb2 + len) + QFIXEDSZ;
nmp = cp; nmp = cp;
@ -1321,9 +1321,9 @@ again:
fprintf(stderr, fprintf(stderr,
" result: %s, answers = %d, authority = %d, additional = %d\n", " result: %s, answers = %d, authority = %d, additional = %d\n",
resultcodes[headerPtr->rcode], resultcodes[headerPtr->rcode],
ntohs(headerPtr->dh_ancount), ntohs(headerPtr->ancount),
ntohs(headerPtr->dh_nscount), ntohs(headerPtr->nscount),
ntohs(headerPtr->dh_arcount)); ntohs(headerPtr->arcount));
return(ERROR); return(ERROR);
default: default:
return(ERROR); return(ERROR);

View file

@ -365,10 +365,10 @@ static void dns_tell(int indent, dns_t *dp, size_t size)
if (dp->hdr.cd) printf(" CD"); if (dp->hdr.cd) printf(" CD");
fputc('\n', stdout); fputc('\n', stdout);
count[0]= ntohs(dp->hdr.dh_qdcount); count[0]= ntohs(dp->hdr.qdcount);
count[1]= ntohs(dp->hdr.dh_ancount); count[1]= ntohs(dp->hdr.ancount);
count[2]= ntohs(dp->hdr.dh_nscount); count[2]= ntohs(dp->hdr.nscount);
count[3]= ntohs(dp->hdr.dh_arcount); count[3]= ntohs(dp->hdr.arcount);
cp = dp->data; cp = dp->data;
for (i= 0; i < 4; i++) { for (i= 0; i < 4; i++) {
while (count[i] > 0) { while (count[i] > 0) {
@ -402,10 +402,10 @@ static u32_t dns_ttl(dns_t *dp, size_t size, u32_t delta)
if (size < sizeof(HEADER)) return 0; if (size < sizeof(HEADER)) return 0;
rcode= dp->hdr.rcode; rcode= dp->hdr.rcode;
count[0]= ntohs(dp->hdr.dh_qdcount); count[0]= ntohs(dp->hdr.qdcount);
count[1]= ntohs(dp->hdr.dh_ancount); count[1]= ntohs(dp->hdr.ancount);
count[2]= ntohs(dp->hdr.dh_nscount); count[2]= ntohs(dp->hdr.nscount);
count[3]= ntohs(dp->hdr.dh_arcount); count[3]= ntohs(dp->hdr.arcount);
cp = dp->data; cp = dp->data;
for (i= 0; i < 4 && cp < dlim; i++) { for (i= 0; i < 4 && cp < dlim; i++) {
while (count[i] > 0) { while (count[i] > 0) {
@ -915,10 +915,10 @@ static int query_hosts(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
dns.hdr.ad = 0; dns.hdr.ad = 0;
dns.hdr.cd = 0; dns.hdr.cd = 0;
dns.hdr.rcode = 0; dns.hdr.rcode = 0;
dns.hdr.dh_qdcount= HTONS(1); dns.hdr.qdcount= HTONS(1);
ancount= 0; ancount= 0;
dns.hdr.dh_nscount= HTONS(0); dns.hdr.nscount= HTONS(0);
dns.hdr.dh_arcount= HTONS(0); dns.hdr.arcount= HTONS(0);
dnvec[0]= dns2oct(&dns); dnvec[0]= dns2oct(&dns);
dnvec[1]= nil; dnvec[1]= nil;
@ -1036,7 +1036,7 @@ static int query_hosts(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
if (r == -1 || ancount == 0) return 0; if (r == -1 || ancount == 0) return 0;
dns.hdr.dh_ancount= htons(ancount); dns.hdr.ancount= htons(ancount);
memcpy(dp, &dns, *pdlen= cp - dns2oct(&dns)); memcpy(dp, &dns, *pdlen= cp - dns2oct(&dns));
return 1; return 1;
} }
@ -1061,10 +1061,10 @@ static int query_chaos(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
dns.hdr.ad = 0; dns.hdr.ad = 0;
dns.hdr.cd = 0; dns.hdr.cd = 0;
dns.hdr.rcode = 0; dns.hdr.rcode = 0;
dns.hdr.dh_qdcount= HTONS(1); dns.hdr.qdcount= HTONS(1);
dns.hdr.dh_ancount= HTONS(1); dns.hdr.ancount= HTONS(1);
dns.hdr.dh_nscount= HTONS(0); dns.hdr.nscount= HTONS(0);
dns.hdr.dh_arcount= htons(n_nameds); dns.hdr.arcount= htons(n_nameds);
dnvec[0]= dns2oct(&dns); dnvec[0]= dns2oct(&dns);
dnvec[1]= nil; dnvec[1]= nil;
@ -1129,7 +1129,7 @@ static void cache_reply(dns_t *dp, size_t dlen)
u32_t minttl; u32_t minttl;
if ((dp->hdr.rd && !dp->hdr.tc)) return; if ((dp->hdr.rd && !dp->hdr.tc)) return;
if (dp->hdr.dh_qdcount != HTONS(1)) return; if (dp->hdr.qdcount != HTONS(1)) return;
cp= dp->data; cp= dp->data;
r= dn_expand(dns2oct(dp), dns2oct(dp) + dlen, cp, name, MAXDNAME); r= dn_expand(dns2oct(dp), dns2oct(dp) + dlen, cp, name, MAXDNAME);
if (r == -1) return; if (r == -1) return;
@ -1211,7 +1211,7 @@ static int compose_reply(dns_t *dp, size_t *pdlen)
} }
/* Remember ID and RD. */ /* Remember ID and RD. */
id= dp->hdr.dh_id; id= dp->hdr.id;
rd= dp->hdr.rd; rd= dp->hdr.rd;
if (r == -1) { if (r == -1) {
@ -1269,7 +1269,7 @@ static int compose_reply(dns_t *dp, size_t *pdlen)
} }
/* Copy ID and RD back to answer. */ /* Copy ID and RD back to answer. */
dp->hdr.dh_id= id; dp->hdr.id= id;
dp->hdr.rd = rd; dp->hdr.rd = rd;
*pdlen= dlen; *pdlen= dlen;
return 1; return 1;
@ -1322,7 +1322,7 @@ static void refresh_cache(void)
cp += sizeof(u16_t); cp += sizeof(u16_t);
dlen= cp - dns2oct(&udp.dns); dlen= cp - dns2oct(&udp.dns);
udp.dns.hdr.dh_id= new_id(ID_REFRESH, my_port, ID_IPSELF); udp.dns.hdr.id= new_id(ID_REFRESH, my_port, ID_IPSELF);
udp.dns.hdr.qr = 0; udp.dns.hdr.qr = 0;
udp.dns.hdr.opcode = 0; udp.dns.hdr.opcode = 0;
udp.dns.hdr.aa = 0; udp.dns.hdr.aa = 0;
@ -1334,10 +1334,10 @@ static void refresh_cache(void)
udp.dns.hdr.ad = 0; udp.dns.hdr.ad = 0;
udp.dns.hdr.cd = 0; udp.dns.hdr.cd = 0;
udp.dns.hdr.rcode = 0; udp.dns.hdr.rcode = 0;
udp.dns.hdr.dh_qdcount= HTONS(1); udp.dns.hdr.qdcount= HTONS(1);
udp.dns.hdr.dh_ancount= HTONS(0); udp.dns.hdr.ancount= HTONS(0);
udp.dns.hdr.dh_nscount= HTONS(0); udp.dns.hdr.nscount= HTONS(0);
udp.dns.hdr.dh_arcount= HTONS(0); udp.dns.hdr.arcount= HTONS(0);
udp.hdr.uih_dst_addr= current_named(); udp.hdr.uih_dst_addr= current_named();
udp.hdr.uih_dst_port= named_port; udp.hdr.uih_dst_port= named_port;
@ -1400,7 +1400,7 @@ static int job_read_udp(void *data, int expired)
/* This is a remote named reply, not a query. */ /* This is a remote named reply, not a query. */
/* Response to a query previously relayed? */ /* Response to a query previously relayed? */
if (!old_id(udp.dns.hdr.dh_id, &id, &port, &ip)) return 1; if (!old_id(udp.dns.hdr.id, &id, &port, &ip)) return 1;
if (ip == ID_IPSELF && id == ID_PROBE) { if (ip == ID_IPSELF && id == ID_PROBE) {
if (searching()) { if (searching()) {
@ -1438,13 +1438,13 @@ static int job_read_udp(void *data, int expired)
if (ip == ID_IPSELF) return 1; if (ip == ID_IPSELF) return 1;
/* Send the reply to the process that asked for it. */ /* Send the reply to the process that asked for it. */
udp.dns.hdr.dh_id= id; udp.dns.hdr.id= id;
udp.hdr.uih_dst_addr= ip; udp.hdr.uih_dst_addr= ip;
udp.hdr.uih_dst_port= port; udp.hdr.uih_dst_port= port;
if (debug >= 1) printf("To client %s:%u\n", inet_ntoa(ip), ntohs(port)); if (debug >= 1) printf("To client %s:%u\n", inet_ntoa(ip), ntohs(port));
} else { } else {
/* A query. */ /* A query. */
if (udp.dns.hdr.dh_qdcount != HTONS(1)) return 1; if (udp.dns.hdr.qdcount != HTONS(1)) return 1;
if(localonly) { if(localonly) {
/* Check if it's a local query. */ /* Check if it's a local query. */
@ -1471,7 +1471,7 @@ static int job_read_udp(void *data, int expired)
} }
} else { } else {
/* Let a real name daemon handle the query. */ /* Let a real name daemon handle the query. */
udp.dns.hdr.dh_id= new_id(udp.dns.hdr.dh_id, udp.dns.hdr.id= new_id(udp.dns.hdr.id,
udp.hdr.uih_src_port, udp.hdr.uih_src_addr); udp.hdr.uih_src_port, udp.hdr.uih_src_addr);
udp.hdr.uih_dst_addr= current_named(); udp.hdr.uih_dst_addr= current_named();
udp.hdr.uih_dst_port= named_port; udp.hdr.uih_dst_port= named_port;
@ -1954,7 +1954,7 @@ static void named_probe(ipaddr_t ip)
/* Send a simple DNS query that all name servers can answer easily: /* Send a simple DNS query that all name servers can answer easily:
* "What are the name servers for the root domain?" * "What are the name servers for the root domain?"
*/ */
udp.dns.hdr.dh_id= new_id(ID_PROBE, my_port, ID_IPSELF); udp.dns.hdr.id= new_id(ID_PROBE, my_port, ID_IPSELF);
udp.dns.hdr.qr = 0; udp.dns.hdr.qr = 0;
udp.dns.hdr.opcode = 0; udp.dns.hdr.opcode = 0;
udp.dns.hdr.aa = 0; udp.dns.hdr.aa = 0;
@ -1965,10 +1965,10 @@ static void named_probe(ipaddr_t ip)
udp.dns.hdr.ad = 0; udp.dns.hdr.ad = 0;
udp.dns.hdr.cd = 0; udp.dns.hdr.cd = 0;
udp.dns.hdr.rcode = 0; udp.dns.hdr.rcode = 0;
udp.dns.hdr.dh_qdcount= HTONS(1); udp.dns.hdr.qdcount= HTONS(1);
udp.dns.hdr.dh_ancount= HTONS(0); udp.dns.hdr.ancount= HTONS(0);
udp.dns.hdr.dh_nscount= HTONS(0); udp.dns.hdr.nscount= HTONS(0);
udp.dns.hdr.dh_arcount= HTONS(0); udp.dns.hdr.arcount= HTONS(0);
udp.dns.data[0] = 0; /* Null name. */ udp.dns.data[0] = 0; /* Null name. */
pack16(udp.dns.data+1, HTONS(T_NS)); pack16(udp.dns.data+1, HTONS(T_NS));

View file

@ -133,14 +133,6 @@ typedef struct {
unsigned arcount :16; /*%< number of resource entries */ unsigned arcount :16; /*%< number of resource entries */
} HEADER; } HEADER;
#if defined(__minix) && defined(_NETBSD_SOURCE)
#define dh_id id
#define dh_qdcount qdcount
#define dh_ancount ancount
#define dh_nscount nscount
#define dh_arcount arcount
#endif /* defined(__minix) && defined(_NETBSD_SOURCE) */
#define PACKETSZ NS_PACKETSZ #define PACKETSZ NS_PACKETSZ
#define MAXDNAME NS_MAXDNAME #define MAXDNAME NS_MAXDNAME
#define MAXCDNAME NS_MAXCDNAME #define MAXCDNAME NS_MAXCDNAME