From 27bf32ee31ea4ad2575756ce6f8e04b118604f83 Mon Sep 17 00:00:00 2001 From: Casey Deccio Date: Fri, 3 May 2019 08:16:20 -0600 Subject: DNS: Add printing the EDNS options (pull request #762) --- print-domain.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'print-domain.c') diff --git a/print-domain.c b/print-domain.c index fcd49520..01270098 100644 --- a/print-domain.c +++ b/print-domain.c @@ -267,6 +267,27 @@ ns_cprint(netdissect_options *ndo, return (cp + i); } +extern const struct tok edns_opt2str[]; + +/* print an */ +static const u_char * +eopt_print(netdissect_options *ndo, + const u_char *cp) +{ + u_int i; + + if (!ND_TTEST_2(cp)) + return (NULL); + i = GET_BE_U_2(cp); + cp += 2; + ND_PRINT(" %s", tok2str(edns_opt2str, "Opt%u", i)); + if (!ND_TTEST_2(cp)) + return (NULL); + i = GET_BE_U_2(cp); + cp += 2; + return (cp + i); +} + extern const struct tok ns_type2str[]; /* https://www.iana.org/assignments/dns-parameters */ @@ -346,6 +367,23 @@ const struct tok ns_class2str[] = { { 0, NULL } }; +extern const struct tok edns_opt2str[]; + +const struct tok edns_opt2str[] = { + { E_NSID, "NSID" }, + { E_DAU, "DAU" }, + { E_DHU, "DHU" }, + { E_N3U, "N3U" }, + { E_ECS, "ECS" }, + { E_EXPIRE, "EXPIRE" }, + { E_COOKIE, "COOKIE" }, + { E_KEEPALIVE, "KEEPALIVE" }, + { E_PADDING, "PADDING" }, + { E_CHAIN, "CHAIN" }, + { E_KEYTAG, "KEYTAG" }, + { 0, NULL } +}; + /* print a query */ static const u_char * ns_qprint(netdissect_options *ndo, @@ -565,6 +603,11 @@ ns_rprint(netdissect_options *ndo, ND_PRINT(" UDPsize=%u", class); if (opt_flags & 0x8000) ND_PRINT(" DO"); + while (cp < rp) { + cp = eopt_print(ndo, cp); + if (cp == NULL) + return(NULL); + } break; case T_UNSPECA: /* One long string */ -- cgit v1.2.1