Skip to content
Snippets Groups Projects
Commit da5feec3 authored by Robert Edmonds's avatar Robert Edmonds
Browse files

kdig: parse dnstap generate ("-G") command-line option

This adds support for parsing the "-G" flag and opens the dnstap input
file, but does not yet actually generate the dnstap message trace
output.
parent adbeaf9b
No related branches found
No related tags found
1 merge request!228Dnstap
......@@ -85,6 +85,9 @@ the shared secret encoded in Base64.
Export a dnstap trace of the response messages received to the file
\fItapfile\fR. If \fB+qr\fR is specified, also export query messages.
.TP
.BI \-G \ tapfile
Generate message output from a previously saved dnstap file \fItapfile\fR.
.TP
.BR + [ no ] multiline
Wrap long records to more lines and improve human readability.
.TP
......
......@@ -903,6 +903,7 @@ void dig_clean(dig_params_t *params)
#if USE_DNSTAP
// Cleanup dnstap.
dt_reader_free(params->config->dt_reader);
dt_writer_free(params->config->dt_writer);
#endif
......@@ -1098,6 +1099,22 @@ static int parse_dnstap_export(const char *value, query_t *query)
return KNOT_EOK;
}
static int parse_dnstap_generate(const char *value, query_t *query)
{
DBG("Generating message output from dnstap input file %s\n", value);
if (query->dt_reader != NULL) {
dt_reader_free(query->dt_reader);
}
query->dt_reader = dt_reader_create(value);
if (query->dt_reader == NULL) {
return KNOT_EINVAL;
}
return KNOT_EOK;
}
#endif
static void complete_servers(query_t *query, const query_t *conf)
......@@ -1223,6 +1240,7 @@ static void dig_help(void)
printf("Usage: kdig [-4] [-6] [-dh] [-b address] [-c class] [-p port]\n"
" [-q name] [-t type] [-x address] [-k keyfile]\n"
" [-y [algo:]keyname:key] [-E tapfile] name @server\n"
" kdig [-G tapfile]\n"
"\n"
" +[no]multiline Wrap long records to more lines.\n"
" +[no]short Show record data only.\n"
......@@ -1433,6 +1451,23 @@ static int parse_opt1(const char *opt, const char *value, dig_params_t *params,
#else
ERR("no dnstap support but -E specified\n");
return KNOT_EINVAL;
#endif
break;
case 'G':
#if USE_DNSTAP
if (val == NULL) {
ERR("missing filename\n");
return KNOT_EINVAL;
}
if (parse_dnstap_generate(val, query) != KNOT_EOK) {
ERR("unable to open dnstap input file %s\n", val);
return KNOT_EINVAL;
}
*index += add;
#else
ERR("no dnstap support but -G specified\n");
return KNOT_EINVAL;
#endif
break;
case '-':
......
......@@ -33,6 +33,7 @@
#include "utils/common/exec.h" // sign_context_t
#if USE_DNSTAP
# include "dnstap/reader.h"
# include "dnstap/writer.h"
#endif
......@@ -117,6 +118,8 @@ typedef struct {
/*!< Context for operations with signatures. */
sign_context_t sign_ctx;
#if USE_DNSTAP
/*!< Context for dnstap reader input. */
dt_reader_t *dt_reader;
/*!< Context for dnstap writer output. */
dt_writer_t *dt_writer;
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment