Compare commits

...
Author SHA1 Message Date
Mark Andrews 6de8eba8f9 Fix 'checking delv -c CH is ignored, and treated like IN' test description 2025-02-26 15:22:58 +11:00
Mark Andrews a6076ee7c1 Use UPDATE-LEASE instead of UL in output for EDNS UL
The offical EDNS option name "UL" is "UPDATE-LEASE".  Emit "UPDATE-LEASE"
instead of "UL" but keep "UL" as an alias on the command line.
2025-02-26 15:22:58 +11:00
Mark Andrews 08b6c9e6b5 Use YAML comments for durations rather than () pairs
This will allow the values to be parsed using standard yaml processing
tools and still provide the value in a human friendly form.
2025-02-26 15:22:58 +11:00
Mark Andrews 9d087bc98d Split EDNS COOKIE YAML into seperate parts
Split the YAML display of the EDNS COOKIE option into CLIENT and SERVER
parts.  The STATUS of the EDNS COOKIE in the reply is now a YAML element
rather than a comment.
2025-02-26 15:22:58 +11:00
Mark Andrews 60b792cd76 Update EDNS KEY-TAG YAML output format
Return the key tags as an array of integers.  This should make for
easier machine parsing.
2025-02-26 15:22:58 +11:00
Mark Andrews f4d877e7e1 Split EDNS UL LEASE and KEY-LEASE into seperate YAML values
Update leases consist of 1 or 2 values.  Give each component its
own name so they can be easily extracted.
2025-02-26 15:22:58 +11:00
Mark Andrews eaf93c4cae Fix EDNS TCP-KEEPALIVE option YAML output
There was missing white space between the option name and its value.
2025-02-26 15:22:58 +11:00
Mark Andrews 5a46ade68c Check EDNS CLIENT-TAG and EDNS SERVER-TAG emitted YAML
Check that when a EDNS CLIENT-TAG or EDNS SERVER-TAG option is
present in the message that the emitted YAML is valid.
2025-02-26 15:22:58 +11:00
Mark Andrews bc823e3cef Check the EDNS EXPIRE option is emitted using valid YAML
Check that when a EDNS EXPIRE option is present in the message that
the emitted YAML is valid.
2025-02-26 15:22:58 +11:00
Mark Andrews b657ac830a Add YAML escaping to render_nameopt
Domain names need to be YAML escaped in addition to the regular DNS
encoding when they are being displayed in yaml mode.
2025-02-26 15:22:58 +11:00
Mark Andrews ebc2345cb3 Collapse common switch cases when emitting EDNS options
The CHAIN and REPORT-CHANNEL EDNS options are both domain names so they
can be combined.  THE CLIENT-TAG and SERVER-TAG EDNS options are both 16
bit integers so they can be combined.
2025-02-26 15:22:58 +11:00
Mark Andrews 6cb12e85da Check the EDNS CLIENT-SUBNET option is emitted using valid YAML 2025-02-26 15:22:58 +11:00
Mark Andrews 494e4b3250 YAML escape EDNS EDE option EXTRA-TEXT value
The description in the EXTRA-TEXT field of the EDE option needs
to be escaped to ensure that the emitted message is valid YAML.
2025-02-26 15:22:58 +11:00
Mark Andrews f2da76bbb5 Check that EDNS KEY-TAG option is emitted using valid YAML 2025-02-26 15:22:58 +11:00
Mark Andrews f8e31184e5 Check that EDNS UL option is emitted using valid YAML 2025-02-26 15:22:58 +11:00
Mark Andrews 49add22f11 Render EDNS LLQ option using valid YAML
The LLQ EDNS option was not being emitted as valid YAML. Correct
the output to be valid YAML with each field of the LLQ being
individually selectable.
2025-02-26 15:22:58 +11:00
3 changed files with 387 additions and 107 deletions
+1
View File
@@ -1378,6 +1378,7 @@ typedef struct dig_ednsoptname {
dig_ednsoptname_t optnames[] = {
{ 1, "LLQ" }, /* draft-sekar-dns-llq */
{ 2, "UPDATE-LEASE" }, /* draft-ietf-dnssd-update-lease */
{ 2, "UL" }, /* draft-ietf-dnssd-update-lease */
{ 3, "NSID" }, /* RFC 5001 */
{ 5, "DAU" }, /* RFC 6975 */
+205 -8
View File
@@ -482,6 +482,18 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "checking dig +subnet=0 +yaml ($n)"
ret=0
dig_with_opts +yaml +tcp @10.53.0.2 +subnet=0 A a.example >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message response_message_data OPT_PSEUDOSECTION EDNS CLIENT-SUBNET >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "0.0.0.0/0/0" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "checking dig +subnet=::/0 ($n)"
ret=0
@@ -493,6 +505,28 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "checking dig +subnet=::/0 +yaml ($n)"
ret=0
dig_with_opts +yaml +tcp @10.53.0.2 +subnet=::/0 A a.example >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message response_message_data OPT_PSEUDOSECTION EDNS CLIENT-SUBNET >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "::/0/0" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "checking dig +subnet=dead::/16 +yaml ($n)"
ret=0
dig_with_opts +yaml +tcp @10.53.0.2 +qr +subnet=dead::/16 A a.example >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS CLIENT-SUBNET >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "dead::/16/0" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "checking dig +ednsopt=8:00000000 (family=0, source=0, scope=0) ($n)"
ret=0
@@ -562,24 +596,53 @@ if [ -x "$DIG" ]; then
status=$((status + ret))
n=$((n + 1))
echo_i "checking ednsopt UL prints as expected (single lease) ($n)"
echo_i "checking ednsopt UPDATE-LEASE prints as expected (single lease) ($n)"
ret=0
dig_with_opts @10.53.0.3 +ednsopt=UL:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
pat='UL: 3600 (1 hour)'
dig_with_opts @10.53.0.3 +ednsopt=UPDATE-LEASE:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
pat='UPDATE-LEASE: 3600 (1 hour)'
grep "$pat" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "checking ednsopt UPDATE-LEASE prints as expected (single lease) +yaml ($n)"
ret=0
dig_with_opts @10.53.0.3 +yaml +ednsopt=UPDATE-LEASE:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE LEASE >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "3600" ] || ret=1
grep "LEASE: 3600 # 1 hour" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "checking ednsopt UL prints as expected (split lease) ($n)"
echo_i "checking ednsopt UPDATE-LEASE prints as expected (split lease) ($n)"
ret=0
dig_with_opts @10.53.0.3 +ednsopt=UL:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
pat='UL: 3600/1209600 (1 hour/2 weeks)'
dig_with_opts @10.53.0.3 +ednsopt=UPDATE-LEASE:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
pat='UPDATE-LEASE: 3600/1209600 (1 hour/2 weeks)'
grep "$pat" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "checking ednsopt UPDATE-LEASE prints as expected (split lease) +yaml ($n)"
ret=0
dig_with_opts @10.53.0.3 +yaml +ednsopt=UPDATE-LEASE:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE LEASE >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "3600" ] || ret=1
grep "LEASE: 3600 # 1 hour" dig.out.test$n >/dev/null || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE KEY-LEASE >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "1209600" ] || ret=1
grep "KEY-LEASE: 1209600 # 2 weeks" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
echo_i "checking ednsopt LLQ prints as expected ($n)"
ret=0
@@ -589,6 +652,30 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "checking ednsopt LLQ prints as expected +yaml ($n)"
ret=0
dig_with_opts @10.53.0.3 +yaml +ednsopt=llq:0001000200001234567812345678fefefefe +qr a.example >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS LLQ LLQ-VERSION >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "1" ] || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS LLQ LLQ-OPCODE >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "2" ] || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS LLQ LLQ-ERROR >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "0" ] || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS LLQ LLQ-ID >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "1311768465173141112" ] || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS LLQ LLQ-LEASE >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "4278124286" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "checking that dig warns about .local queries ($n)"
ret=0
@@ -616,6 +703,18 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
ret=0
echo_i "check that dig processes +ednsopt=key-tag:<value-list> +yaml ($n)"
dig_with_opts @10.53.0.3 +yaml +ednsopt=key-tag:00010002 a.example +qr >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS KEY-TAG >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "[1, 2]" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "check that dig processes +ednsopt=key-tag:<malformed-value-list> and FORMERR is returned ($n)"
ret=0
@@ -634,6 +733,18 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "check that dig processes +ednsopt=client-tag:value +yaml ($n)"
ret=0
dig_with_opts @10.53.0.3 +yaml +ednsopt=client-tag:0001 a.example +qr >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS CLIENT-TAG >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "1" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "check that FORMERR is returned for a too short client-tag ($n)"
ret=0
@@ -661,6 +772,18 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "check that dig processes +ednsopt=server-tag:value +yaml ($n)"
ret=0
dig_with_opts @10.53.0.3 +yaml +ednsopt=server-tag:0001 a.example +qr >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS SERVER-TAG >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "1" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "check that FORMERR is returned for a too short server-tag ($n)"
ret=0
@@ -679,6 +802,67 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check that dig processes +ednsopt=chain:02002200 ($n)"
ret=0
dig_with_opts @10.53.0.3 +ednsopt=chain:02002200 'a.\000"' +qr >dig.out.test$n 2>&1 || ret=1
grep '; CHAIN: "\\000\\""' dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "check that dig processes +ednsopt=chain:02002200 +yaml ($n)"
ret=0
dig_with_opts @10.53.0.3 +yaml +ednsopt=chain:02002200 'a.\000"' +qr >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS CHAIN >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = '\000\"' ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "check that dig processes +expire ($n)"
ret=0
dig_with_opts @10.53.0.1 +expire . soa >dig.out.test$n 2>&1 || ret=1
grep '; EXPIRE: 1200 (20 minutes)' dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "check that dig processes +expire +yaml ($n)"
ret=0
dig_with_opts @10.53.0.1 +yaml +expire . soa >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message response_message_data OPT_PSEUDOSECTION EDNS EXPIRE >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "1200" ] || ret=1
grep "EXPIRE: 1200 # 20 minutes" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "check that dig processes +keepalive ($n)"
ret=0
dig_with_opts @10.53.0.1 +keepalive . soa +tcp >dig.out.test$n 2>&1 || ret=1
grep '; TCP-KEEPALIVE: 30.0 secs' dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "check that dig processes +keepalive +yaml ($n)"
ret=0
dig_with_opts @10.53.0.1 +yaml +keepalive . soa +tcp >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message response_message_data OPT_PSEUDOSECTION EDNS TCP-KEEPALIVE >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = "30.0 secs" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "check that Extended DNS Error 0 is printed correctly ($n)"
ret=0
@@ -689,6 +873,19 @@ if [ -x "$DIG" ]; then
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
if [ $HAS_PYYAML -ne 0 ]; then
n=$((n + 1))
echo_i "check that Extended DNS Error 0 is printed correctly +yaml ($n)"
ret=0
# add specials '"' and '\'
dig_with_opts @10.53.0.3 +yaml +ednsopt=ede:0000666f6f225c a.example +qr >dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS EDE EXTRA-TEXT >yamlget.out.test$n 2>&1 || ret=1
read -r value <yamlget.out.test$n
[ "$value" = 'foo"\' ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
fi
n=$((n + 1))
echo_i "check that Extended DNS Error 24 is printed correctly ($n)"
ret=0
@@ -1383,7 +1580,7 @@ if [ -x "$DELV" ]; then
status=$((status + ret))
n=$((n + 1))
echo_i "checking delv H is ignored, and treated like IN ($n)"
echo_i "checking delv -c CH is ignored, and treated like IN ($n)"
ret=0
delv_with_opts @10.53.0.3 -c CH -t a a.example >delv.out.test$n || ret=1
grep "a.example." <delv.out.test$n >/dev/null || ret=1
+181 -99
View File
@@ -3428,44 +3428,86 @@ cleanup:
}
static isc_result_t
render_llq(isc_buffer_t *optbuf, isc_buffer_t *target) {
render_llq(isc_buffer_t *optbuf, dns_message_t *msg,
const dns_master_style_t *style, isc_buffer_t *target) {
char buf[sizeof("18446744073709551615")]; /* 2^64-1 */
isc_result_t result = ISC_R_SUCCESS;
uint32_t u;
uint64_t q;
const char *sep1 = " ", *sep2 = ", ";
size_t count = msg->indent.count;
bool yaml = false;
if ((dns_master_styleflags(style) & DNS_STYLEFLAG_YAML) != 0) {
sep1 = sep2 = "\n";
msg->indent.count++;
yaml = true;
}
u = isc_buffer_getuint16(optbuf);
ADD_STRING(target, " Version: ");
ADD_STRING(target, sep1);
INDENT(style);
if (yaml) {
ADD_STRING(target, "LLQ-VERSION: ");
} else {
ADD_STRING(target, "Version: ");
}
snprintf(buf, sizeof(buf), "%u", u);
ADD_STRING(target, buf);
u = isc_buffer_getuint16(optbuf);
ADD_STRING(target, ", Opcode: ");
ADD_STRING(target, sep2);
INDENT(style);
if (yaml) {
ADD_STRING(target, "LLQ-OPCODE: ");
} else {
ADD_STRING(target, "Opcode: ");
}
snprintf(buf, sizeof(buf), "%u", u);
ADD_STRING(target, buf);
u = isc_buffer_getuint16(optbuf);
ADD_STRING(target, ", Error: ");
ADD_STRING(target, sep2);
INDENT(style);
if (yaml) {
ADD_STRING(target, "LLQ-ERROR: ");
} else {
ADD_STRING(target, "Error: ");
}
snprintf(buf, sizeof(buf), "%u", u);
ADD_STRING(target, buf);
q = isc_buffer_getuint32(optbuf);
q <<= 32;
q |= isc_buffer_getuint32(optbuf);
ADD_STRING(target, ", Identifier: ");
ADD_STRING(target, sep2);
INDENT(style);
if (yaml) {
ADD_STRING(target, "LLQ-ID: ");
} else {
ADD_STRING(target, "Identifier: ");
}
snprintf(buf, sizeof(buf), "%" PRIu64, q);
ADD_STRING(target, buf);
u = isc_buffer_getuint32(optbuf);
ADD_STRING(target, ", Lifetime: ");
ADD_STRING(target, sep2);
INDENT(style);
if (yaml) {
ADD_STRING(target, "LLQ-LEASE: ");
} else {
ADD_STRING(target, "Lifetime: ");
}
snprintf(buf, sizeof(buf), "%u", u);
ADD_STRING(target, buf);
cleanup:
msg->indent.count = count;
return result;
}
static isc_result_t
render_nameopt(isc_buffer_t *optbuf, isc_buffer_t *target) {
render_nameopt(isc_buffer_t *optbuf, bool yaml, isc_buffer_t *target) {
dns_decompress_t dctx = DNS_DECOMPRESS_NEVER;
dns_fixedname_t fixed;
dns_name_t *name = dns_fixedname_initname(&fixed);
@@ -3476,7 +3518,23 @@ render_nameopt(isc_buffer_t *optbuf, isc_buffer_t *target) {
if (result == ISC_R_SUCCESS && isc_buffer_activelength(optbuf) == 0) {
dns_name_format(name, namebuf, sizeof(namebuf));
ADD_STRING(target, " \"");
ADD_STRING(target, namebuf);
if (yaml) {
char *s = namebuf;
while (*s != 0) {
if (*s == '\\' || *s == '"') {
ADD_STRING(target, "\\");
}
if (isc_buffer_availablelength(target) < 1) {
result = ISC_R_NOSPACE;
goto cleanup;
}
isc_buffer_putmem(target, (unsigned char *)s,
1);
s++;
}
} else {
ADD_STRING(target, namebuf);
}
ADD_STRING(target, "\"");
return result;
}
@@ -3487,7 +3545,7 @@ cleanup:
static const char *option_names[] = {
[DNS_OPT_LLQ] = "LLQ",
[DNS_OPT_UL] = "UL",
[DNS_OPT_UL] = "UPDATE-LEASE",
[DNS_OPT_NSID] = "NSID",
[DNS_OPT_DAU] = "DAU",
[DNS_OPT_DHU] = "DHU",
@@ -3613,7 +3671,8 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
switch (optcode) {
case DNS_OPT_LLQ:
if (optlen == 18U) {
result = render_llq(&optbuf, target);
result = render_llq(&optbuf, msg, style,
target);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
@@ -3624,32 +3683,42 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
case DNS_OPT_UL:
if (optlen == 4U || optlen == 8U) {
uint32_t secs, key = 0;
msg->indent.count++;
secs = isc_buffer_getuint32(&optbuf);
ADD_STRING(target, "\n");
INDENT(style);
ADD_STRING(target, "LEASE:");
snprintf(buf, sizeof(buf), " %u", secs);
ADD_STRING(target, buf);
if (optlen == 8U) {
key = isc_buffer_getuint32(
&optbuf);
snprintf(buf, sizeof(buf),
"/%u", key);
ADD_STRING(target, buf);
}
ADD_STRING(target, " (");
ADD_STRING(target, " # ");
result = dns_ttl_totext(secs, true,
true, target);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
ADD_STRING(target, "\n");
if (optlen == 8U) {
ADD_STRING(target, "/");
key = isc_buffer_getuint32(
&optbuf);
INDENT(style);
ADD_STRING(target,
"KEY-LEASE:");
snprintf(buf, sizeof(buf),
" %u", key);
ADD_STRING(target, buf);
ADD_STRING(target, " # ");
result = dns_ttl_totext(
key, true, true,
target);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
ADD_STRING(target, "\n");
}
ADD_STRING(target, ")\n");
continue;
}
break;
@@ -3675,13 +3744,13 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
secs = isc_buffer_getuint32(&optbuf);
snprintf(buf, sizeof(buf), " %u", secs);
ADD_STRING(target, buf);
ADD_STRING(target, " (");
ADD_STRING(target, " # ");
result = dns_ttl_totext(secs, true,
true, target);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
ADD_STRING(target, ")\n");
ADD_STRING(target, "\n");
continue;
}
break;
@@ -3689,7 +3758,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
if (optlen == 2) {
unsigned int dsecs;
dsecs = isc_buffer_getuint16(&optbuf);
snprintf(buf, sizeof(buf), "%u.%u",
snprintf(buf, sizeof(buf), " %u.%u",
dsecs / 10U, dsecs % 10U);
ADD_STRING(target, buf);
ADD_STRING(target, " secs\n");
@@ -3697,10 +3766,11 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
}
break;
case DNS_OPT_CHAIN:
case DNS_OPT_REPORT_CHANNEL:
if (optlen > 0U) {
isc_buffer_t sb = optbuf;
isc_buffer_setactive(&optbuf, optlen);
result = render_nameopt(&optbuf,
result = render_nameopt(&optbuf, true,
target);
if (result == ISC_R_SUCCESS) {
ADD_STRING(target, "\n");
@@ -3711,7 +3781,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
break;
case DNS_OPT_KEY_TAG:
if (optlen > 0U && (optlen % 2U) == 0U) {
const char *sep = "";
const char *sep = " [";
while (optlen > 0U) {
uint16_t id =
isc_buffer_getuint16(
@@ -3722,7 +3792,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
sep = ",";
optlen -= 2;
}
ADD_STRING(target, "\n");
ADD_STRING(target, " ]\n");
continue;
}
break;
@@ -3753,14 +3823,6 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
}
break;
case DNS_OPT_CLIENT_TAG:
if (optlen == 2U) {
uint16_t id =
isc_buffer_getuint16(&optbuf);
snprintf(buf, sizeof(buf), " %u\n", id);
ADD_STRING(target, buf);
continue;
}
break;
case DNS_OPT_SERVER_TAG:
if (optlen == 2U) {
uint16_t id =
@@ -3770,17 +3832,66 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
continue;
}
break;
case DNS_OPT_REPORT_CHANNEL:
if (optlen > 0U) {
isc_buffer_t sb = optbuf;
isc_buffer_setactive(&optbuf, optlen);
result = render_nameopt(&optbuf,
target);
if (result == ISC_R_SUCCESS) {
ADD_STRING(target, "\n");
continue;
case DNS_OPT_COOKIE:
if (optlen == 8 ||
(optlen >= 16 && optlen < 40))
{
size_t i;
msg->indent.count++;
optdata = isc_buffer_current(&optbuf);
ADD_STRING(target, "\n");
INDENT(style);
ADD_STRING(target, "CLIENT: ");
for (i = 0; i < 8; i++) {
snprintf(buf, sizeof(buf),
"%02x", optdata[i]);
ADD_STRING(target, buf);
}
optbuf = sb;
ADD_STRING(target, "\n");
if (optlen >= 16) {
INDENT(style);
ADD_STRING(target, "SERVER: ");
for (; i < optlen; i++) {
snprintf(buf,
sizeof(buf),
"%02x",
optdata[i]);
ADD_STRING(target, buf);
}
ADD_STRING(target, "\n");
}
/*
* Valid server cookie?
*/
if (msg->cc_ok && optlen >= 16) {
INDENT(style);
ADD_STRING(target,
"STATUS: good\n");
}
/*
* Server cookie is not valid but
* we had our cookie echoed back.
*/
if (msg->cc_ok && optlen < 16) {
INDENT(style);
ADD_STRING(target,
"STATUS: echoed\n");
}
/*
* We didn't get our cookie echoed
* back.
*/
if (msg->cc_bad) {
INDENT(style);
ADD_STRING(target,
"STATUS: bad\n)");
}
isc_buffer_forward(&optbuf, optlen);
continue;
}
break;
default:
@@ -3818,32 +3929,9 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
isc_buffer_forward(&optbuf, optlen);
if (optcode == DNS_OPT_COOKIE) {
/*
* Valid server cookie?
*/
if (msg->cc_ok && optlen >= 16) {
ADD_STRING(target, " (good)");
}
/*
* Server cookie is not valid but
* we had our cookie echoed back.
*/
if (msg->cc_ok && optlen < 16) {
ADD_STRING(target, " (echoed)");
}
/*
* We didn't get our cookie echoed
* back.
*/
if (msg->cc_bad) {
ADD_STRING(target, " (bad)");
}
ADD_STRING(target, "\n");
continue;
}
if (optcode == DNS_OPT_CLIENT_SUBNET) {
if (optcode == DNS_OPT_COOKIE ||
optcode == DNS_OPT_CLIENT_SUBNET)
{
ADD_STRING(target, "\n");
continue;
}
@@ -3857,19 +3945,32 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
} else {
ADD_STRING(target, "\"");
}
if (isc_buffer_availablelength(target) < optlen)
{
result = ISC_R_NOSPACE;
goto cleanup;
}
for (i = 0; i < optlen; i++) {
if (isprint(optdata[i]) ||
(utf8ok && optdata[i] > 127))
{
/*
* We are emitting a yaml '"'
* delimited string so we need
* to escape '"' and '\'.
*/
if (extra_text &&
(optdata[i] == '"' ||
optdata[i] == '\\'))
{
ADD_STRING(target,
"\\");
}
if (isc_buffer_availablelength(
target) < 1)
{
result = ISC_R_NOSPACE;
goto cleanup;
}
isc_buffer_putmem(
target, &optdata[i], 1);
} else {
isc_buffer_putstr(target, ".");
ADD_STRING(target, ".");
}
}
if (!extra_text) {
@@ -4020,7 +4121,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
switch (optcode) {
case DNS_OPT_LLQ:
if (optlen == 18U) {
result = render_llq(&optbuf, target);
result = render_llq(&optbuf, msg, style,
target);
if (result != ISC_R_SUCCESS) {
return result;
}
@@ -4112,10 +4214,11 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
ADD_STRING(target, "\n");
continue;
case DNS_OPT_CHAIN:
case DNS_OPT_REPORT_CHANNEL:
if (optlen > 0U) {
isc_buffer_t sb = optbuf;
isc_buffer_setactive(&optbuf, optlen);
result = render_nameopt(&optbuf,
result = render_nameopt(&optbuf, false,
target);
if (result == ISC_R_SUCCESS) {
ADD_STRING(target, "\n");
@@ -4172,14 +4275,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
}
break;
case DNS_OPT_CLIENT_TAG:
if (optlen == 2U) {
uint16_t id =
isc_buffer_getuint16(&optbuf);
snprintf(buf, sizeof(buf), " %u\n", id);
ADD_STRING(target, buf);
continue;
}
break;
case DNS_OPT_SERVER_TAG:
if (optlen == 2U) {
uint16_t id =
@@ -4189,19 +4284,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
continue;
}
break;
case DNS_OPT_REPORT_CHANNEL:
if (optlen > 0U) {
isc_buffer_t sb = optbuf;
isc_buffer_setactive(&optbuf, optlen);
result = render_nameopt(&optbuf,
target);
if (result == ISC_R_SUCCESS) {
ADD_STRING(target, "\n");
continue;
}
optbuf = sb;
}
break;
default:
break;
}