From: Jelte Jansen Date: Wed, 20 Jun 2007 09:11:10 +0000 (+0000) Subject: -s (strip DNSSEC) option in read-zone X-Git-Tag: ldns-1.3.0_pre_20070822~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3aa2e2542e0cae7b328f8eaaa89d4ac343fa2240;p=thirdparty%2Fldns.git -s (strip DNSSEC) option in read-zone --- diff --git a/examples/ldns-read-zone.c b/examples/ldns-read-zone.c index b9db5aa1..64833143 100644 --- a/examples/ldns-read-zone.c +++ b/examples/ldns-read-zone.c @@ -22,10 +22,13 @@ main(int argc, char **argv) int c; bool canonicalize = false; bool sort = false; + bool strip = false; ldns_status s; size_t i; + ldns_rr_list *stripped_list; + ldns_rr *cur_rr; - while ((c = getopt(argc, argv, "chvz")) != -1) { + while ((c = getopt(argc, argv, "chsvz")) != -1) { switch(c) { case 'c': canonicalize = true; @@ -36,11 +39,15 @@ main(int argc, char **argv) printf("\tThe RR count of the zone is printed to stderr.\n"); printf("\t-c canonicalize all rrs in the zone.\n"); printf("\t-h show this text\n"); + printf("\t-s strip DNSSEC data from the zone\n"); printf("\t-v shows the version and exits\n"); printf("\t-z sort the zone (implies -c).\n"); printf("\nif no file is given standard input is read\n"); exit(EXIT_SUCCESS); break; + case 's': + strip = true; + break; case 'v': printf("read zone version %s (ldns version %s)\n", LDNS_VERSION, ldns_version()); exit(EXIT_SUCCESS); @@ -68,6 +75,26 @@ main(int argc, char **argv) } s = ldns_zone_new_frm_fp_l(&z, fp, NULL, 0, LDNS_RR_CLASS_IN, &line_nr); + + if (strip) { + stripped_list = ldns_rr_list_new(); + while ((cur_rr = ldns_rr_list_pop_rr(ldns_zone_rrs(z)))) { + if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_RRSIG || + ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_NSEC + ) { + + printf("remove:\n"); + ldns_rr_print(stdout, cur_rr); + + ldns_rr_free(cur_rr); + } else { + ldns_rr_list_push_rr(stripped_list, cur_rr); + } + } + ldns_rr_list_free(ldns_zone_rrs(z)); + ldns_zone_set_rrs(z, stripped_list); + } + if (s == LDNS_STATUS_OK) { if (canonicalize) { ldns_rr2canonical(ldns_zone_soa(z));