Commit dabbf340 authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman

offline_ksk: ksr and skr records are verbose and multiline

parent f947e863
......@@ -75,7 +75,7 @@ void key_records_clear_rdatasets(key_records_t *r)
knot_rdataset_clear(&r->rrsig.rrs, NULL);
}
int key_records_dump(char **buf, size_t *buf_size, const key_records_t *r)
int key_records_dump(char **buf, size_t *buf_size, const key_records_t *r, bool verbose)
{
if (*buf == NULL) {
if (*buf_size == 0) {
......@@ -86,13 +86,23 @@ int key_records_dump(char **buf, size_t *buf_size, const key_records_t *r)
return KNOT_ENOMEM;
}
}
int ret = KNOT_EOK;
const knot_dump_style_t verb_style = {
.wrap = true,
.show_ttl = true,
.verbose = true,
.original_ttl = true,
.human_tmstamp = true
};
const knot_dump_style_t *style = verbose ? &verb_style : &KNOT_DUMP_STYLE_DEFAULT;
int ret = 0;
size_t total = 1;
const knot_rrset_t *all_rr[4] = { &r->dnskey, &r->cdnskey, &r->cds, &r->rrsig };
// first go: just detect the size
for (int i = 0; i < 4; i++) {
if (ret >= 0 && !knot_rrset_empty(all_rr[i])) {
ret = knot_rrset_txt_dump(all_rr[i], buf, buf_size, &KNOT_DUMP_STYLE_DEFAULT);
ret = knot_rrset_txt_dump(all_rr[i], buf, buf_size, style);
(void)buf;
total += ret;
}
......@@ -110,7 +120,7 @@ int key_records_dump(char **buf, size_t *buf_size, const key_records_t *r)
//second go: do it
for (int i = 0; i < 4; i++) {
if (ret >= 0 && !knot_rrset_empty(all_rr[i])) {
ret = knot_rrset_txt_dump(all_rr[i], &fake_buf, &fake_size, &KNOT_DUMP_STYLE_DEFAULT);
ret = knot_rrset_txt_dump(all_rr[i], &fake_buf, &fake_size, style);
fake_buf += ret, fake_size -= ret;
}
}
......
......@@ -27,7 +27,7 @@ void key_records_clear(key_records_t *r);
void key_records_clear_rdatasets(key_records_t *r);
int key_records_dump(char **buf, size_t *buf_size, const key_records_t *r);
int key_records_dump(char **buf, size_t *buf_size, const key_records_t *r, bool verbose);
int key_records_sign(const zone_key_t *key, key_records_t *r, const kdnssec_ctx_t *kctx);
......
......@@ -109,7 +109,15 @@ static int dump_rrset_to_buf(const knot_rrset_t *rrset, char **buf, size_t *buf_
return KNOT_ENOMEM;
}
}
return knot_rrset_txt_dump(rrset, buf, buf_size, &KNOT_DUMP_STYLE_DEFAULT);
knot_dump_style_t style = {
.wrap = true,
.show_ttl = true,
.verbose = true,
.original_ttl = true,
.human_tmstamp = true
};
return knot_rrset_txt_dump(rrset, buf, buf_size, &style);
}
int keymgr_print_offline_records(kdnssec_ctx_t *ctx, char *arg)
......@@ -127,7 +135,7 @@ int keymgr_print_offline_records(kdnssec_ctx_t *ctx, char *arg)
if (ret == KNOT_EOK) {
char *buf = NULL;
size_t buf_size = 512;
ret = key_records_dump(&buf, &buf_size, &r);
ret = key_records_dump(&buf, &buf_size, &r, true);
if (ret == KNOT_EOK) {
printf("%s", buf);
ret = KNOT_EOK;
......@@ -268,7 +276,7 @@ static int ksr_sign_dnskey(kdnssec_ctx_t *ctx, knot_rrset_t *zsk, knot_time_t no
goto done;
}
}
ret = key_records_dump(&buf, &buf_size, &r);
ret = key_records_dump(&buf, &buf_size, &r, true);
if (ret == KNOT_EOK) {
printf(";; SignedKeyResponse %s %"PRIu64" ===========\n%s",
KSR_SKR_VER, ctx->now, buf);
......
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