]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
print layout and comments (disabled by default)
authorMatthijs Mekking <matje@NLnetLabs.nl>
Thu, 22 Sep 2011 09:52:14 +0000 (09:52 +0000)
committerMatthijs Mekking <matje@NLnetLabs.nl>
Thu, 22 Sep 2011 09:52:14 +0000 (09:52 +0000)
dnssec_zone.c
examples/ldns-signzone.c
ldns/host2str.h

index cdd4e2d889e878a2af320a14679a3825e3703dbf..9132321a3b7e36df13fdc3c61319c5ecb428fb9a 100644 (file)
@@ -82,7 +82,8 @@ ldns_dnssec_rrs_print_fmt(FILE *out, const ldns_output_format *fmt,
               ldns_dnssec_rrs *rrs)
 {
        if (!rrs) {
-               fprintf(out, "<void>");
+               if ((fmt->flags & LDNS_COMMENT_LAYOUT))
+                       fprintf(out, "; <void>");
        } else {
                if (rrs->rr) {
                        ldns_rr_print_fmt(out, fmt, rrs->rr);
@@ -276,7 +277,8 @@ ldns_dnssec_rrsets_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
                bool show_soa)
 {
        if (!rrsets) {
-               fprintf(out, "<void>\n");
+               if ((fmt->flags & LDNS_COMMENT_LAYOUT))
+                       fprintf(out, "; <void>\n");
        } else {
                if (rrsets->rrs &&
                    (show_soa ||
@@ -570,7 +572,7 @@ ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
                if(name->rrsets) {
                        ldns_dnssec_rrsets_print_soa_fmt(out, fmt, 
                                        name->rrsets, true, show_soa);
-               } else {
+               } else if ((fmt->flags & LDNS_COMMENT_LAYOUT)) {
                        fprintf(out, ";; Empty nonterminal: ");
                        ldns_rdf_print(out, name->name);
                        fprintf(out, "\n");
@@ -582,8 +584,8 @@ ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
                        ldns_dnssec_rrs_print_fmt(out, fmt, 
                                        name->nsec_signatures);
                }
-       } else {
-               fprintf(out, "<void>\n");
+       } else if ((fmt->flags & LDNS_COMMENT_LAYOUT)) {
+               fprintf(out, "<void>\n");
        }
 }
 
@@ -773,7 +775,8 @@ ldns_dnssec_zone_names_print_fmt(FILE *out, const ldns_output_format *fmt,
        while (node != LDNS_RBTREE_NULL) {
                name = (ldns_dnssec_name *) node->data;
                ldns_dnssec_name_print_soa_fmt(out, fmt, name, print_soa);
-               fprintf(out, ";\n");
+               if ((fmt->flags & LDNS_COMMENT_LAYOUT))
+                       fprintf(out, ";\n");
                node = ldns_rbtree_next(node);
        }
 }
@@ -791,16 +794,19 @@ ldns_dnssec_zone_print_fmt(FILE *out, const ldns_output_format *fmt,
 {
        if (zone) {
                if (zone->soa) {
-                       fprintf(out, ";; Zone: ");
+                       if ((fmt->flags & LDNS_COMMENT_LAYOUT))
+                               fprintf(out, ";; Zone: ");
                        ldns_rdf_print(out,
                                        ldns_dnssec_name_name(zone->soa));
-                       fprintf(out, "\n;\n");
+                       if ((fmt->flags & LDNS_COMMENT_LAYOUT))
+                               fprintf(out, "\n;\n");
                        ldns_dnssec_rrsets_print_fmt(out, fmt,
                                        ldns_dnssec_name_find_rrset(
                                                zone->soa, 
                                                LDNS_RR_TYPE_SOA), 
                                        false);
-                       fprintf(out, ";\n");
+                       if ((fmt->flags & LDNS_COMMENT_LAYOUT))
+                               fprintf(out, ";\n");
                }
 
                if (zone->names) {
index 486a02394d5aaa34916aeaa6ef90f0f3ce4fd5fe..ed094df7ebff7753e6afd7f276840aa1a4379f19 100644 (file)
@@ -31,6 +31,7 @@ static void
 usage(FILE *fp, const char *prog) {
        fprintf(fp, "%s [OPTIONS] zonefile key [key [key]]\n", prog);
        fprintf(fp, "  signs the zone with the given key(s)\n");
+       fprintf(fp, "  -b\t\tuse layout in signed zone and print comments DNSSEC records\n");
        fprintf(fp, "  -d\t\tused keys are not added to the zone\n");
        fprintf(fp, "  -e <date>\texpiration date\n");
        fprintf(fp, "  -f <file>\toutput zone to file (default <name>.signed)\n");
@@ -50,8 +51,6 @@ usage(FILE *fp, const char *prog) {
        fprintf(fp, "\t\t-t [number] number of hash iterations\n");
        fprintf(fp, "\t\t-s [string] salt\n");
        fprintf(fp, "\t\t-p set the opt-out flag on all nsec3 rrs\n");
-       fprintf(fp, "\t\t-u include the unhashed NSEC3 names as comments "
-                       "in the zone\n");
        fprintf(fp, "\n");
        fprintf(fp, "  keys must be specified by their base name (usually K<name>+<alg>+<id>),\n");
        fprintf(fp, "  i.e. WITHOUT the .private extension.\n");
@@ -390,11 +389,18 @@ main(int argc, char *argv[])
 
        OPENSSL_config(NULL);
 
-       while ((c = getopt(argc, argv, "a:de:f:i:k:lno:ps:t:uvAE:K:")) != -1) {
+       while ((c = getopt(argc, argv, "a:bde:f:i:k:lno:ps:t:vAE:K:")) != -1) {
                switch (c) {
                case 'a':
                        nsec3_algorithm = (uint8_t) atoi(optarg);
                        break;
+               case 'b':
+                       fmt.flags |= LDNS_COMMENT_BUBBLEBABBLE;
+                       fmt.flags |= LDNS_COMMENT_FLAGS;
+                       fmt.flags |= LDNS_COMMENT_NSEC3_CHAIN;
+                       fmt.flags |= LDNS_COMMENT_LAYOUT;
+                       hashmap = (ldns_rbtree_t **)&fmt.data;
+                       break;
                case 'd':
                        add_keys = false;
                        break;
@@ -460,7 +466,6 @@ main(int argc, char *argv[])
                                usage(stderr, prog);
                                exit(EXIT_FAILURE);
                        }
-                       
                        break;
                case 'p':
                        nsec3_flags = nsec3_flags | LDNS_NSEC3_VARS_OPTOUT_MASK;
@@ -594,10 +599,6 @@ main(int argc, char *argv[])
                        }
                        nsec3_iterations = (uint16_t) nsec3_iterations_cmd;
                        break;
-               case 'u':
-                       fmt.flags |= LDNS_COMMENT_NSEC3_CHAIN;
-                       hashmap = (ldns_rbtree_t **)&fmt.data;
-                       break;
                default:
                        usage(stderr, prog);
                        exit(EXIT_SUCCESS);
index 3b4fb7d344a01bebc10e83495d35a7b11341ed31..bfca985e75872b89adbe17f5763d03d679f54755 100644 (file)
@@ -60,6 +60,8 @@ extern "C" {
 #define LDNS_COMMENT_FLAGS             0x20
 /** Show the unhashed owner and next owner names for NSEC3 RR's as comment */
 #define LDNS_COMMENT_NSEC3_CHAIN       0x40
+/** Print mark up */
+#define LDNS_COMMENT_LAYOUT            0x80
 
 /**
  * Output format specifier