Implement dig +[no]svcparamkeycompat

The new +[no]svcparamkeycompat option for dig enables the
backward-compatible mode for the Service Parameter Keys'
(SvcParamKeys) representation format. See the previous commit
for more information.
This commit is contained in:
Aram Sargsyan 2025-02-10 13:22:58 +00:00 committed by Arаm Sаrgsyаn
parent d5d63d6253
commit 583a838c25
4 changed files with 23 additions and 3 deletions

View file

@ -303,6 +303,8 @@ help(void) {
"statistics)\n"
" +subnet=addr (Set edns-client-subnet "
"option)\n"
" +[no]svcparamkeycompat (Display backward-"
"compatible SvcParamKey names (keyN) for non-initial entries)\n"
" +[no]tcflag (Set TC flag in query "
"(+[no]tcflag))\n"
" +[no]tcp (TCP mode (+[no]vc))\n"
@ -502,6 +504,9 @@ say_message(dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf) {
if (query->lookup->expandaaaa) {
styleflags |= DNS_STYLEFLAG_EXPANDAAAA;
}
if (query->lookup->svcparamkeycompat) {
styleflags |= DNS_STYLEFLAG_SVCPARAMKEYCOMPAT;
}
result = dns_rdata_tofmttext(rdata, NULL, styleflags, 0, splitwidth,
" ", buf);
if (result == ISC_R_NOSPACE) {
@ -695,6 +700,9 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
if (query->lookup->expandaaaa) {
styleflags |= DNS_STYLEFLAG_EXPANDAAAA;
}
if (query->lookup->svcparamkeycompat) {
styleflags |= DNS_STYLEFLAG_SVCPARAMKEYCOMPAT;
}
if (query->lookup->multiline) {
styleflags |= DNS_STYLEFLAG_OMIT_OWNER;
styleflags |= DNS_STYLEFLAG_OMIT_CLASS;
@ -2394,6 +2402,10 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
goto exit_or_usage;
}
break;
case 'v': /* svcparamkeycompat */
FULLCHECK("svcparamkeycompat");
lookup->svcparamkeycompat = state;
break;
default:
goto invalid_option;
}

View file

@ -642,6 +642,14 @@ abbreviation is unambiguous; for example, :option:`+cd` is equivalent to
prefix-length of zero, which signals a resolver that the client's
address information must *not* be used when resolving this query.
.. option:: +svcparamkeycompat, +nosvcparamkeycompat
This option sets [or does not set] the backward-compatible representation of
the Service Parameter Keys (SvcParamKeys) for SVCB records, in which case
the keys, which were not defined initially in :rfc:`9460` are represented
in their opaque "keyN"-like format, where "N" is their numerical value. The
default is ``+nosvcparamkeycompat``.
.. option:: +tcflag, +notcflag
This option sets [or does not set] the TC (TrunCation) bit in the query. The default is

View file

@ -758,6 +758,7 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
looknew->nocrypto = lookold->nocrypto;
looknew->ttlunits = lookold->ttlunits;
looknew->expandaaaa = lookold->expandaaaa;
looknew->svcparamkeycompat = lookold->svcparamkeycompat;
looknew->qr = lookold->qr;
looknew->idnin = lookold->idnin;
looknew->idnout = lookold->idnout;

View file

@ -104,9 +104,8 @@ struct dig_lookup {
isc_refcount_t references;
bool aaonly, adflag, badcookie, besteffort, cdflag, cleared, comments,
dns64prefix, dnssec, doing_xfr, done_as_is, ednsneg, expandaaaa,
expire, fuzzing, header_only, identify, /*%< Append an "on
server <foo>" message
*/
svcparamkeycompat, expire, fuzzing, header_only,
identify, /*%< Append an "on server <foo>" message */
identify_previous_line, /*% Prepend a "Nameserver <foo>:"
message, with newline and tab */
idnin, idnout, ignore, multiline, need_search, new_search,