Skip to content

Commit fe12238

Browse files
committed
include/arpa/nameser_compat.h: merged
Removing compatibility macros, and updating the two tools still using them. Change-Id: I636f045d76a8f92440ebe1503f52f7e5d704a316
1 parent d1ae774 commit fe12238

3 files changed

Lines changed: 43 additions & 51 deletions

File tree

‎commands/host/host.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,10 @@ printinfo(answer, eom, filter, isls)
479479
* find first satisfactory answer
480480
*/
481481
hp = (HEADER *) answer;
482-
ancount = ntohs(hp->dh_ancount);
483-
qdcount = ntohs(hp->dh_qdcount);
484-
nscount = ntohs(hp->dh_nscount);
485-
arcount = ntohs(hp->dh_arcount);
482+
ancount = ntohs(hp->ancount);
483+
qdcount = ntohs(hp->qdcount);
484+
nscount = ntohs(hp->nscount);
485+
arcount = ntohs(hp->arcount);
486486
if (_res.options & RES_DEBUG || (verbose && isls == 0))
487487
printf("rcode = %d (%s), ancount=%d\n",
488488
hp->rcode,
@@ -1040,7 +1040,7 @@ ListHosts(namePtr, queryType)
10401040
}
10411041

10421042
cp = answer.qb2 + sizeof(HEADER);
1043-
if (ntohs(answer.qb1.dh_qdcount) > 0)
1043+
if (ntohs(answer.qb1.qdcount) > 0)
10441044
cp += dn_skipname(cp, answer.qb2 + msglen) + QFIXEDSZ;
10451045

10461046
numns = 0;
@@ -1261,7 +1261,7 @@ ListHosts(namePtr, queryType)
12611261

12621262
i = buf.qb1.rcode;
12631263

1264-
if (i != NOERROR || ntohs(buf.qb1.dh_ancount) == 0) {
1264+
if (i != NOERROR || ntohs(buf.qb1.ancount) == 0) {
12651265
if ((thisns+1) < numnsaddr &&
12661266
(i == SERVFAIL || i == NOTIMP || i == REFUSED)) {
12671267
if (_res.options & RES_DEBUG || verbose)
@@ -1285,7 +1285,7 @@ ListHosts(namePtr, queryType)
12851285
}
12861286
numAnswers++;
12871287
cp = buf.qb2 + sizeof(HEADER);
1288-
if (ntohs(buf.qb1.dh_qdcount) > 0)
1288+
if (ntohs(buf.qb1.qdcount) > 0)
12891289
cp += dn_skipname(cp, buf.qb2 + len) + QFIXEDSZ;
12901290

12911291
nmp = cp;
@@ -1321,9 +1321,9 @@ ListHosts(namePtr, queryType)
13211321
fprintf(stderr,
13221322
" result: %s, answers = %d, authority = %d, additional = %d\n",
13231323
resultcodes[headerPtr->rcode],
1324-
ntohs(headerPtr->dh_ancount),
1325-
ntohs(headerPtr->dh_nscount),
1326-
ntohs(headerPtr->dh_arcount));
1324+
ntohs(headerPtr->ancount),
1325+
ntohs(headerPtr->nscount),
1326+
ntohs(headerPtr->arcount));
13271327
return(ERROR);
13281328
default:
13291329
return(ERROR);

‎commands/nonamed/nonamed.c‎

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,10 @@ static void dns_tell(int indent, dns_t *dp, size_t size)
365365
if (dp->hdr.cd) printf(" CD");
366366
fputc('\n', stdout);
367367

368-
count[0]= ntohs(dp->hdr.dh_qdcount);
369-
count[1]= ntohs(dp->hdr.dh_ancount);
370-
count[2]= ntohs(dp->hdr.dh_nscount);
371-
count[3]= ntohs(dp->hdr.dh_arcount);
368+
count[0]= ntohs(dp->hdr.qdcount);
369+
count[1]= ntohs(dp->hdr.ancount);
370+
count[2]= ntohs(dp->hdr.nscount);
371+
count[3]= ntohs(dp->hdr.arcount);
372372
cp = dp->data;
373373
for (i= 0; i < 4; i++) {
374374
while (count[i] > 0) {
@@ -402,10 +402,10 @@ static u32_t dns_ttl(dns_t *dp, size_t size, u32_t delta)
402402
if (size < sizeof(HEADER)) return 0;
403403

404404
rcode= dp->hdr.rcode;
405-
count[0]= ntohs(dp->hdr.dh_qdcount);
406-
count[1]= ntohs(dp->hdr.dh_ancount);
407-
count[2]= ntohs(dp->hdr.dh_nscount);
408-
count[3]= ntohs(dp->hdr.dh_arcount);
405+
count[0]= ntohs(dp->hdr.qdcount);
406+
count[1]= ntohs(dp->hdr.ancount);
407+
count[2]= ntohs(dp->hdr.nscount);
408+
count[3]= ntohs(dp->hdr.arcount);
409409
cp = dp->data;
410410
for (i= 0; i < 4 && cp < dlim; i++) {
411411
while (count[i] > 0) {
@@ -915,10 +915,10 @@ static int query_hosts(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
915915
dns.hdr.ad = 0;
916916
dns.hdr.cd = 0;
917917
dns.hdr.rcode = 0;
918-
dns.hdr.dh_qdcount= HTONS(1);
918+
dns.hdr.qdcount= HTONS(1);
919919
ancount= 0;
920-
dns.hdr.dh_nscount= HTONS(0);
921-
dns.hdr.dh_arcount= HTONS(0);
920+
dns.hdr.nscount= HTONS(0);
921+
dns.hdr.arcount= HTONS(0);
922922

923923
dnvec[0]= dns2oct(&dns);
924924
dnvec[1]= nil;
@@ -1036,7 +1036,7 @@ static int query_hosts(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
10361036

10371037
if (r == -1 || ancount == 0) return 0;
10381038

1039-
dns.hdr.dh_ancount= htons(ancount);
1039+
dns.hdr.ancount= htons(ancount);
10401040
memcpy(dp, &dns, *pdlen= cp - dns2oct(&dns));
10411041
return 1;
10421042
}
@@ -1061,10 +1061,10 @@ static int query_chaos(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
10611061
dns.hdr.ad = 0;
10621062
dns.hdr.cd = 0;
10631063
dns.hdr.rcode = 0;
1064-
dns.hdr.dh_qdcount= HTONS(1);
1065-
dns.hdr.dh_ancount= HTONS(1);
1066-
dns.hdr.dh_nscount= HTONS(0);
1067-
dns.hdr.dh_arcount= htons(n_nameds);
1064+
dns.hdr.qdcount= HTONS(1);
1065+
dns.hdr.ancount= HTONS(1);
1066+
dns.hdr.nscount= HTONS(0);
1067+
dns.hdr.arcount= htons(n_nameds);
10681068

10691069
dnvec[0]= dns2oct(&dns);
10701070
dnvec[1]= nil;
@@ -1129,7 +1129,7 @@ static void cache_reply(dns_t *dp, size_t dlen)
11291129
u32_t minttl;
11301130

11311131
if ((dp->hdr.rd && !dp->hdr.tc)) return;
1132-
if (dp->hdr.dh_qdcount != HTONS(1)) return;
1132+
if (dp->hdr.qdcount != HTONS(1)) return;
11331133
cp= dp->data;
11341134
r= dn_expand(dns2oct(dp), dns2oct(dp) + dlen, cp, name, MAXDNAME);
11351135
if (r == -1) return;
@@ -1211,7 +1211,7 @@ static int compose_reply(dns_t *dp, size_t *pdlen)
12111211
}
12121212

12131213
/* Remember ID and RD. */
1214-
id= dp->hdr.dh_id;
1214+
id= dp->hdr.id;
12151215
rd= dp->hdr.rd;
12161216

12171217
if (r == -1) {
@@ -1269,7 +1269,7 @@ static int compose_reply(dns_t *dp, size_t *pdlen)
12691269
}
12701270

12711271
/* Copy ID and RD back to answer. */
1272-
dp->hdr.dh_id= id;
1272+
dp->hdr.id= id;
12731273
dp->hdr.rd = rd;
12741274
*pdlen= dlen;
12751275
return 1;
@@ -1322,7 +1322,7 @@ static void refresh_cache(void)
13221322
cp += sizeof(u16_t);
13231323
dlen= cp - dns2oct(&udp.dns);
13241324

1325-
udp.dns.hdr.dh_id= new_id(ID_REFRESH, my_port, ID_IPSELF);
1325+
udp.dns.hdr.id= new_id(ID_REFRESH, my_port, ID_IPSELF);
13261326
udp.dns.hdr.qr = 0;
13271327
udp.dns.hdr.opcode = 0;
13281328
udp.dns.hdr.aa = 0;
@@ -1334,10 +1334,10 @@ static void refresh_cache(void)
13341334
udp.dns.hdr.ad = 0;
13351335
udp.dns.hdr.cd = 0;
13361336
udp.dns.hdr.rcode = 0;
1337-
udp.dns.hdr.dh_qdcount= HTONS(1);
1338-
udp.dns.hdr.dh_ancount= HTONS(0);
1339-
udp.dns.hdr.dh_nscount= HTONS(0);
1340-
udp.dns.hdr.dh_arcount= HTONS(0);
1337+
udp.dns.hdr.qdcount= HTONS(1);
1338+
udp.dns.hdr.ancount= HTONS(0);
1339+
udp.dns.hdr.nscount= HTONS(0);
1340+
udp.dns.hdr.arcount= HTONS(0);
13411341

13421342
udp.hdr.uih_dst_addr= current_named();
13431343
udp.hdr.uih_dst_port= named_port;
@@ -1400,7 +1400,7 @@ static int job_read_udp(void *data, int expired)
14001400
/* This is a remote named reply, not a query. */
14011401

14021402
/* Response to a query previously relayed? */
1403-
if (!old_id(udp.dns.hdr.dh_id, &id, &port, &ip)) return 1;
1403+
if (!old_id(udp.dns.hdr.id, &id, &port, &ip)) return 1;
14041404

14051405
if (ip == ID_IPSELF && id == ID_PROBE) {
14061406
if (searching()) {
@@ -1438,13 +1438,13 @@ static int job_read_udp(void *data, int expired)
14381438
if (ip == ID_IPSELF) return 1;
14391439

14401440
/* Send the reply to the process that asked for it. */
1441-
udp.dns.hdr.dh_id= id;
1441+
udp.dns.hdr.id= id;
14421442
udp.hdr.uih_dst_addr= ip;
14431443
udp.hdr.uih_dst_port= port;
14441444
if (debug >= 1) printf("To client %s:%u\n", inet_ntoa(ip), ntohs(port));
14451445
} else {
14461446
/* A query. */
1447-
if (udp.dns.hdr.dh_qdcount != HTONS(1)) return 1;
1447+
if (udp.dns.hdr.qdcount != HTONS(1)) return 1;
14481448

14491449
if(localonly) {
14501450
/* Check if it's a local query. */
@@ -1471,7 +1471,7 @@ static int job_read_udp(void *data, int expired)
14711471
}
14721472
} else {
14731473
/* Let a real name daemon handle the query. */
1474-
udp.dns.hdr.dh_id= new_id(udp.dns.hdr.dh_id,
1474+
udp.dns.hdr.id= new_id(udp.dns.hdr.id,
14751475
udp.hdr.uih_src_port, udp.hdr.uih_src_addr);
14761476
udp.hdr.uih_dst_addr= current_named();
14771477
udp.hdr.uih_dst_port= named_port;
@@ -1954,7 +1954,7 @@ static void named_probe(ipaddr_t ip)
19541954
/* Send a simple DNS query that all name servers can answer easily:
19551955
* "What are the name servers for the root domain?"
19561956
*/
1957-
udp.dns.hdr.dh_id= new_id(ID_PROBE, my_port, ID_IPSELF);
1957+
udp.dns.hdr.id= new_id(ID_PROBE, my_port, ID_IPSELF);
19581958
udp.dns.hdr.qr = 0;
19591959
udp.dns.hdr.opcode = 0;
19601960
udp.dns.hdr.aa = 0;
@@ -1965,10 +1965,10 @@ static void named_probe(ipaddr_t ip)
19651965
udp.dns.hdr.ad = 0;
19661966
udp.dns.hdr.cd = 0;
19671967
udp.dns.hdr.rcode = 0;
1968-
udp.dns.hdr.dh_qdcount= HTONS(1);
1969-
udp.dns.hdr.dh_ancount= HTONS(0);
1970-
udp.dns.hdr.dh_nscount= HTONS(0);
1971-
udp.dns.hdr.dh_arcount= HTONS(0);
1968+
udp.dns.hdr.qdcount= HTONS(1);
1969+
udp.dns.hdr.ancount= HTONS(0);
1970+
udp.dns.hdr.nscount= HTONS(0);
1971+
udp.dns.hdr.arcount= HTONS(0);
19721972

19731973
udp.dns.data[0] = 0; /* Null name. */
19741974
pack16(udp.dns.data+1, HTONS(T_NS));

‎include/arpa/nameser_compat.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,6 @@ typedef struct {
133133
unsigned arcount :16; /*%< number of resource entries */
134134
} HEADER;
135135

136-
#if defined(__minix) && defined(_NETBSD_SOURCE)
137-
#define dh_id id
138-
#define dh_qdcount qdcount
139-
#define dh_ancount ancount
140-
#define dh_nscount nscount
141-
#define dh_arcount arcount
142-
#endif /* defined(__minix) && defined(_NETBSD_SOURCE) */
143-
144136
#define PACKETSZ NS_PACKETSZ
145137
#define MAXDNAME NS_MAXDNAME
146138
#define MAXCDNAME NS_MAXCDNAME

0 commit comments

Comments
 (0)