Commit 9c9d28ba authored by Mark Karpilovskij's avatar Mark Karpilovskij

kdig: add +[no]comments option

parent a10d5a5c
...@@ -197,6 +197,9 @@ Show the query packet. ...@@ -197,6 +197,9 @@ Show the query packet.
\fB+\fP[\fBno\fP]\fBheader\fP \fB+\fP[\fBno\fP]\fBheader\fP
Show the packet header. Show the packet header.
.TP .TP
\fB+\fP[\fBno\fP]\fBcomments\fP
Show commented section names.
.TP
\fB+\fP[\fBno\fP]\fBopt\fP \fB+\fP[\fBno\fP]\fBopt\fP
Show the EDNS pseudosection. Show the EDNS pseudosection.
.TP .TP
......
...@@ -176,6 +176,9 @@ Options ...@@ -176,6 +176,9 @@ Options
**+**\ [\ **no**\ ]\ **header** **+**\ [\ **no**\ ]\ **header**
Show the packet header. Show the packet header.
**+**\ [\ **no**\ ]\ **comments**
Show commented section names.
**+**\ [\ **no**\ ]\ **opt** **+**\ [\ **no**\ ]\ **opt**
Show the EDNS pseudosection. Show the EDNS pseudosection.
......
...@@ -608,7 +608,7 @@ void print_packet(const knot_pkt_t *packet, ...@@ -608,7 +608,7 @@ void print_packet(const knot_pkt_t *packet,
// Print EDNS section. // Print EDNS section.
if (style->show_edns && knot_pkt_has_edns(packet)) { if (style->show_edns && knot_pkt_has_edns(packet)) {
printf("\n;; EDNS PSEUDOSECTION:\n;; "); printf("%s", style->show_section ? "\n;; EDNS PSEUDOSECTION:\n;; " : ";;");
print_section_opt(packet); print_section_opt(packet);
} }
...@@ -628,7 +628,7 @@ void print_packet(const knot_pkt_t *packet, ...@@ -628,7 +628,7 @@ void print_packet(const knot_pkt_t *packet,
break; break;
case FORMAT_NSUPDATE: case FORMAT_NSUPDATE:
if (style->show_question && qdcount > 0) { if (style->show_question && qdcount > 0) {
printf("\n;; ZONE SECTION:\n;; "); printf("%s", style->show_section ? "\n;; ZONE SECTION:\n;; " : ";;");
print_section_question(knot_pkt_qname(packet), print_section_question(knot_pkt_qname(packet),
knot_pkt_qclass(packet), knot_pkt_qclass(packet),
knot_pkt_qtype(packet), knot_pkt_qtype(packet),
...@@ -636,23 +636,23 @@ void print_packet(const knot_pkt_t *packet, ...@@ -636,23 +636,23 @@ void print_packet(const knot_pkt_t *packet,
} }
if (style->show_answer && ancount > 0) { if (style->show_answer && ancount > 0) {
printf("\n;; PREREQUISITE SECTION:\n"); printf("%s", style->show_section ? "\n;; PREREQUISITE SECTION:\n" : "");
print_section_full(knot_pkt_rr(answers, 0), ancount, style, true); print_section_full(knot_pkt_rr(answers, 0), ancount, style, true);
} }
if (style->show_authority && nscount > 0) { if (style->show_authority && nscount > 0) {
printf("\n;; UPDATE SECTION:\n"); printf("%s", style->show_section ? "\n;; UPDATE SECTION:\n" : "");
print_section_full(knot_pkt_rr(authority, 0), nscount, style, true); print_section_full(knot_pkt_rr(authority, 0), nscount, style, true);
} }
if (style->show_additional && arcount > 0) { if (style->show_additional && arcount > 0) {
printf("\n;; ADDITIONAL DATA:\n"); printf("%s", style->show_section ? "\n;; ADDITIONAL DATA:\n" : "");
print_section_full(knot_pkt_rr(additional, 0), arcount, style, true); print_section_full(knot_pkt_rr(additional, 0), arcount, style, true);
} }
break; break;
case FORMAT_FULL: case FORMAT_FULL:
if (style->show_question && qdcount > 0) { if (style->show_question && qdcount > 0) {
printf("\n;; QUESTION SECTION:\n;; "); printf("%s", style->show_section ? "\n;; QUESTION SECTION:\n;; " : ";;");
print_section_question(knot_pkt_qname(packet), print_section_question(knot_pkt_qname(packet),
knot_pkt_qclass(packet), knot_pkt_qclass(packet),
knot_pkt_qtype(packet), knot_pkt_qtype(packet),
...@@ -660,17 +660,17 @@ void print_packet(const knot_pkt_t *packet, ...@@ -660,17 +660,17 @@ void print_packet(const knot_pkt_t *packet,
} }
if (style->show_answer && ancount > 0) { if (style->show_answer && ancount > 0) {
printf("\n;; ANSWER SECTION:\n"); printf("%s", style->show_section ? "\n;; ANSWER SECTION:\n" : "");
print_section_full(knot_pkt_rr(answers, 0), ancount, style, true); print_section_full(knot_pkt_rr(answers, 0), ancount, style, true);
} }
if (style->show_authority && nscount > 0) { if (style->show_authority && nscount > 0) {
printf("\n;; AUTHORITY SECTION:\n"); printf("%s", style->show_section ? "\n;; AUTHORITY SECTION:\n" : "");
print_section_full(knot_pkt_rr(authority, 0), nscount, style, true); print_section_full(knot_pkt_rr(authority, 0), nscount, style, true);
} }
if (style->show_additional && arcount > 0) { if (style->show_additional && arcount > 0) {
printf("\n;; ADDITIONAL SECTION:\n"); printf("%s", style->show_section ? "\n;; ADDITIONAL SECTION:\n" : "");
print_section_full(knot_pkt_rr(additional, 0), arcount, style, true); print_section_full(knot_pkt_rr(additional, 0), arcount, style, true);
} }
break; break;
...@@ -680,7 +680,7 @@ void print_packet(const knot_pkt_t *packet, ...@@ -680,7 +680,7 @@ void print_packet(const knot_pkt_t *packet,
// Print TSIG section. // Print TSIG section.
if (style->show_tsig && knot_pkt_has_tsig(packet)) { if (style->show_tsig && knot_pkt_has_tsig(packet)) {
printf("\n;; TSIG PSEUDOSECTION:\n"); printf("%s", style->show_section ? "\n;; TSIG PSEUDOSECTION:\n" : "");
print_section_full(packet->tsig_rr, 1, style, false); print_section_full(packet->tsig_rr, 1, style, false);
} }
......
...@@ -72,6 +72,8 @@ typedef struct { ...@@ -72,6 +72,8 @@ typedef struct {
bool show_query; bool show_query;
/*!< Show header info. */ /*!< Show header info. */
bool show_header; bool show_header;
/*!< Show section name. */
bool show_section;
/*!< Show EDNS pseudosection. */ /*!< Show EDNS pseudosection. */
bool show_edns; bool show_edns;
/*!< Show QUERY/ZONE section. */ /*!< Show QUERY/ZONE section. */
......
...@@ -69,6 +69,7 @@ static const style_t DEFAULT_STYLE_DIG = { ...@@ -69,6 +69,7 @@ static const style_t DEFAULT_STYLE_DIG = {
}, },
.show_query = false, .show_query = false,
.show_header = true, .show_header = true,
.show_section = true,
.show_edns = true, .show_edns = true,
.show_question = true, .show_question = true,
.show_answer = true, .show_answer = true,
...@@ -353,6 +354,24 @@ static int opt_noheader(const char *arg, void *query) ...@@ -353,6 +354,24 @@ static int opt_noheader(const char *arg, void *query)
return KNOT_EOK; return KNOT_EOK;
} }
static int opt_comments(const char *arg, void *query)
{
query_t *q = query;
q->style.show_section = true;
return KNOT_EOK;
}
static int opt_nocomments(const char *arg, void *query)
{
query_t *q = query;
q->style.show_section = false;
return KNOT_EOK;
}
static int opt_opt(const char *arg, void *query) static int opt_opt(const char *arg, void *query)
{ {
query_t *q = query; query_t *q = query;
...@@ -1152,6 +1171,10 @@ static const param_t kdig_opts2[] = { ...@@ -1152,6 +1171,10 @@ static const param_t kdig_opts2[] = {
{ "header", ARG_NONE, opt_header }, { "header", ARG_NONE, opt_header },
{ "noheader", ARG_NONE, opt_noheader }, { "noheader", ARG_NONE, opt_noheader },
{ "comments", ARG_NONE, opt_comments },
{ "nocomments", ARG_NONE, opt_nocomments },
{ "opt", ARG_NONE, opt_opt },
{ "opt", ARG_NONE, opt_opt }, { "opt", ARG_NONE, opt_opt },
{ "noopt", ARG_NONE, opt_noopt }, { "noopt", ARG_NONE, opt_noopt },
...@@ -1889,6 +1912,7 @@ static void print_help(void) ...@@ -1889,6 +1912,7 @@ static void print_help(void)
" +[no]all Show all packet sections.\n" " +[no]all Show all packet sections.\n"
" +[no]qr Show query packet.\n" " +[no]qr Show query packet.\n"
" +[no]header Show packet header.\n" " +[no]header Show packet header.\n"
" +[no]comments Show commented section names.\n"
" +[no]opt Show EDNS pseudosection.\n" " +[no]opt Show EDNS pseudosection.\n"
" +[no]question Show question section.\n" " +[no]question Show question section.\n"
" +[no]answer Show answer section.\n" " +[no]answer Show answer section.\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment