From fc6b5ad58550a4e67aee577848e3c165df8a6d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Fri, 15 Jun 2018 09:59:20 +0200 Subject: [PATCH] Extract print_summary() from dns_zoneverify_dnssec() Extract the part of dns_zoneverify_dnssec() responsible for printing a summary for a fully signed zone to a separate function. --- lib/dns/zoneverify.c | 59 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/lib/dns/zoneverify.c b/lib/dns/zoneverify.c index 7568d1ab3f..c12eb81d33 100644 --- a/lib/dns/zoneverify.c +++ b/lib/dns/zoneverify.c @@ -1495,14 +1495,42 @@ check_bad_algorithms(const vctx_t *vctx) { } } +static void +print_summary(const vctx_t *vctx, isc_boolean_t keyset_kskonly) { + char algbuf[DNS_SECALG_FORMATSIZE]; + int i; + + fprintf(stderr, "Zone fully signed:\n"); + for (i = 0; i < 256; i++) { + if ((vctx->ksk_algorithms[i] != 0) || + (vctx->standby_ksk[i] != 0) || + (vctx->revoked_ksk[i] != 0) || + (vctx->zsk_algorithms[i] != 0) || + (vctx->standby_zsk[i] != 0) || + (vctx->revoked_zsk[i] != 0)) { + dns_secalg_format(i, algbuf, sizeof(algbuf)); + fprintf(stderr, "Algorithm: %s: KSKs: " + "%u active, %u stand-by, %u revoked\n", + algbuf, vctx->ksk_algorithms[i], + vctx->standby_ksk[i], + vctx->revoked_ksk[i]); + fprintf(stderr, "%*sZSKs: " + "%u active, %u %s, %u revoked\n", + (int) strlen(algbuf) + 13, "", + vctx->zsk_algorithms[i], + vctx->standby_zsk[i], + keyset_kskonly ? "present" : "stand-by", + vctx->revoked_zsk[i]); + } + } +} + void dns_zoneverify_dnssec(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_name_t *origin, isc_mem_t *mctx, isc_boolean_t ignore_kskflag, isc_boolean_t keyset_kskonly) { - char algbuf[80]; - int i; isc_result_t result, vresult = ISC_R_UNSET; vctx_t vctx; @@ -1539,32 +1567,7 @@ dns_zoneverify_dnssec(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_result_totext(vresult)); if (vctx.goodksk || ignore_kskflag) { - /* - * Print the success summary. - */ - fprintf(stderr, "Zone fully signed:\n"); - for (i = 0; i < 256; i++) { - if ((vctx.ksk_algorithms[i] != 0) || - (vctx.standby_ksk[i] != 0) || - (vctx.revoked_ksk[i] != 0) || - (vctx.zsk_algorithms[i] != 0) || - (vctx.standby_zsk[i] != 0) || - (vctx.revoked_zsk[i] != 0)) { - dns_secalg_format(i, algbuf, sizeof(algbuf)); - fprintf(stderr, "Algorithm: %s: KSKs: " - "%u active, %u stand-by, %u revoked\n", - algbuf, vctx.ksk_algorithms[i], - vctx.standby_ksk[i], - vctx.revoked_ksk[i]); - fprintf(stderr, "%*sZSKs: " - "%u active, %u %s, %u revoked\n", - (int) strlen(algbuf) + 13, "", - vctx.zsk_algorithms[i], - vctx.standby_zsk[i], - keyset_kskonly ? "present" : "stand-by", - vctx.revoked_zsk[i]); - } - } + print_summary(&vctx, keyset_kskonly); } vctx_destroy(&vctx);