mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
support printing AAAA in expanded form
This commit is contained in:
parent
6bb57c776e
commit
d8798098e8
7 changed files with 80 additions and 4 deletions
|
|
@ -187,6 +187,7 @@ help(void) {
|
|||
" +[no]ednsnegotiation (Set EDNS version negotiation)\n"
|
||||
" +ednsopt=###[:value] (Send specified EDNS option)\n"
|
||||
" +noednsopt (Clear list of +ednsopt options)\n"
|
||||
" +[no]expandaaaa (Expand AAAA records)\n"
|
||||
" +[no]expire (Request time to expire)\n"
|
||||
" +[no]fail (Don't try next server on SERVFAIL)\n"
|
||||
" +[no]header-only (Send query without a question section)\n"
|
||||
|
|
@ -473,6 +474,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, bool headers) {
|
|||
styleflags |= DNS_STYLEFLAG_NO_CLASS;
|
||||
if (query->lookup->nocrypto)
|
||||
styleflags |= DNS_STYLEFLAG_NOCRYPTO;
|
||||
if (query->lookup->expandaaaa)
|
||||
styleflags |= DNS_STYLEFLAG_EXPANDAAAA;
|
||||
if (query->lookup->multiline) {
|
||||
styleflags |= DNS_STYLEFLAG_OMIT_OWNER;
|
||||
styleflags |= DNS_STYLEFLAG_OMIT_CLASS;
|
||||
|
|
@ -1034,8 +1037,24 @@ plus_option(char *option, bool is_batchfile,
|
|||
}
|
||||
break;
|
||||
case 'x':
|
||||
FULLCHECK("expire");
|
||||
lookup->expire = state;
|
||||
switch (cmd[2]) {
|
||||
case 'p':
|
||||
switch(cmd[3]) {
|
||||
case 'a':
|
||||
FULLCHECK("expandaaaa");
|
||||
lookup->expandaaaa = state;
|
||||
break;
|
||||
case 'i':
|
||||
FULLCHECK("expire");
|
||||
lookup->expire = state;
|
||||
break;
|
||||
default:
|
||||
goto invalid_option;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto invalid_option;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto invalid_option;
|
||||
|
|
|
|||
|
|
@ -747,6 +747,16 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>+[no]expandaaaa</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
When printing AAAA record print all zero nibbles rather
|
||||
than the default RFC 5952 preferred presentation format.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>+[no]fail</option></term>
|
||||
<listitem>
|
||||
|
|
|
|||
|
|
@ -621,6 +621,7 @@ make_empty_lookup(void) {
|
|||
looknew->nocrypto = false;
|
||||
looknew->ttlunits = false;
|
||||
looknew->ttlunits = false;
|
||||
looknew->expandaaaa = false;
|
||||
looknew->qr = false;
|
||||
#ifdef HAVE_LIBIDN2
|
||||
looknew->idnin = isatty(1)?(getenv("IDN_DISABLE") == NULL):false;
|
||||
|
|
@ -769,6 +770,7 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
|
|||
looknew->use_usec = lookold->use_usec;
|
||||
looknew->nocrypto = lookold->nocrypto;
|
||||
looknew->ttlunits = lookold->ttlunits;
|
||||
looknew->expandaaaa = lookold->expandaaaa;
|
||||
looknew->qr = lookold->qr;
|
||||
looknew->idnin = lookold->idnin;
|
||||
looknew->idnout = lookold->idnout;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ struct dig_lookup {
|
|||
ttlunits,
|
||||
idnin,
|
||||
idnout,
|
||||
expandaaaa,
|
||||
qr;
|
||||
char textname[MXNAME]; /*% Name we're going to be looking up */
|
||||
char cmdline[MXNAME];
|
||||
|
|
|
|||
|
|
@ -636,6 +636,30 @@ if [ -x "$DIG" ] ; then
|
|||
[ `grep "communications error.*end of file" dig.out.test$n | wc -l` -eq 1 ] || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status+ret))
|
||||
|
||||
n=$((n+1))
|
||||
echo_i "check that dig +expandaaaa works ($n)"
|
||||
ret=0
|
||||
dig_with_opts @10.53.0.3 +expandaaaa AAAA ns2.example > dig.out.test$n 2>&1 || ret=1
|
||||
grep "ns2.example.*fd92:7065:0b8e:ffff:0000:0000:0000:0002" dig.out.test$n > /dev/null || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status+ret))
|
||||
|
||||
n=$((n+1))
|
||||
echo_i "check that dig +noexpandaaaa works ($n)"
|
||||
ret=0
|
||||
dig_with_opts @10.53.0.3 +noexpandaaaa AAAA ns2.example > dig.out.test$n 2>&1 || ret=1
|
||||
grep "ns2.example.*fd92:7065:b8e:ffff::2" dig.out.test$n > /dev/null || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status+ret))
|
||||
|
||||
n=$((n+1))
|
||||
echo_i "check that dig default for +[no]expandaaa (+noexpandaaaa) works ($n)"
|
||||
ret=0
|
||||
dig_with_opts @10.53.0.3 AAAA ns2.example > dig.out.test$n 2>&1 || ret=1
|
||||
grep "ns2.example.*fd92:7065:b8e:ffff::2" dig.out.test$n > /dev/null || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status+ret))
|
||||
else
|
||||
echo_i "$DIG is needed, so skipping these dig tests"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -172,6 +172,9 @@ struct dns_rdata {
|
|||
/*% Output textual RR type and RDATA in RFC 3597 unknown format */
|
||||
#define DNS_STYLEFLAG_UNKNOWNFORMAT 0x00000010ULL
|
||||
|
||||
/*% Print AAAA record fully expanded */
|
||||
#define DNS_STYLEFLAG_EXPANDAAAA 0x00000020ULL
|
||||
|
||||
#define DNS_RDATA_DOWNCASE DNS_NAME_DOWNCASE
|
||||
#define DNS_RDATA_CHECKNAMES DNS_NAME_CHECKNAMES
|
||||
#define DNS_RDATA_CHECKNAMESFAIL DNS_NAME_CHECKNAMESFAIL
|
||||
|
|
|
|||
|
|
@ -50,12 +50,29 @@ static inline isc_result_t
|
|||
totext_in_aaaa(ARGS_TOTEXT) {
|
||||
isc_region_t region;
|
||||
|
||||
UNUSED(tctx);
|
||||
|
||||
REQUIRE(rdata->type == dns_rdatatype_aaaa);
|
||||
REQUIRE(rdata->rdclass == dns_rdataclass_in);
|
||||
REQUIRE(rdata->length == 16);
|
||||
|
||||
if ((tctx->flags & DNS_STYLEFLAG_EXPANDAAAA) != 0) {
|
||||
char buf[5*8];
|
||||
const char *sep = "";
|
||||
int i, n;
|
||||
unsigned int len = 0;
|
||||
|
||||
for (i = 0; i < 16; i += 2) {
|
||||
INSIST(len < sizeof(buf));
|
||||
n = snprintf(buf + len, sizeof(buf) - len,
|
||||
"%s%02x%02x", sep,
|
||||
rdata->data[i], rdata->data[i + 1]);
|
||||
if (n < 0) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
len += n;
|
||||
sep = ":";
|
||||
}
|
||||
return (str_totext(buf, target));
|
||||
}
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
return (inet_totext(AF_INET6, ®ion, target));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue