diff options
author | Casey Deccio <casey@deccio.net> | 2019-05-03 08:16:20 -0600 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2020-04-10 13:17:35 +0200 |
commit | 27bf32ee31ea4ad2575756ce6f8e04b118604f83 (patch) | |
tree | d2a6e06815636808a76acda7d0b89ee5cd74a199 /print-domain.c | |
parent | 85b39920a628a21b8c2c2e51be1560f377d6666d (diff) | |
download | tcpdump-27bf32ee31ea4ad2575756ce6f8e04b118604f83.tar.gz |
DNS: Add printing the EDNS options
(pull request #762)
Diffstat (limited to 'print-domain.c')
-rw-r--r-- | print-domain.c | 43 |
1 files changed, 43 insertions, 0 deletions
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 <EDNS-option> */ +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 */ |