20 printf(
"Usage: %s [OPTIONS] <zonefile>\n", progname);
21 printf(
"\tReads the zonefile and prints it.\n");
22 printf(
"\tThe RR count of the zone is printed to stderr.\n");
23 printf(
"\t-b include Bubble Babble encoding of DS's.\n");
24 printf(
"\t-0 zeroize timestamps and signature in RRSIG records.\n");
25 printf(
"\t-c canonicalize all rrs in the zone.\n");
26 printf(
"\t-d only show DNSSEC data from the zone\n");
27 printf(
"\t-h show this text\n");
28 printf(
"\t-n do not print the SOA record\n");
29 printf(
"\t-p prepend SOA serial with spaces so" 30 " it takes exactly ten characters.\n");
31 printf(
"\t-s strip DNSSEC data from the zone\n");
32 printf(
"\t-S [[+|-]<number> | YYYYMMDDxx | " 34 "\t\tSet serial number to <number> or," 35 " when preceded by a sign,\n" 36 "\t\toffset the existing number with " 37 "<number>. With YYYYMMDDxx\n" 38 "\t\tthe serial is formatted as a datecounter" 39 ", and with unixtime as\n" 40 "\t\tthe number of seconds since 1-1-1970." 41 " However, on serial\n" 42 "\t\tnumber decrease, +1 is used in stead" 44 printf(
"\t-u <rr type>\n");
45 printf(
"\t\tMark <rr type> for printing in unknown type format.\n");
46 printf(
"\t\tThis option may be given multiple times.\n");
47 printf(
"\t\t-u is not meant to be used together with -U.\n");
48 printf(
"\t-U <rr type>\n");
49 printf(
"\t\tMark <rr type> for not printing in unknown type format.\n");
50 printf(
"\t\tThis option may be given multiple times.\n");
52 "\t\tThe first occurrence of the -U option marks all RR types for" 53 "\n\t\tprinting in unknown type format except for the given <rr type>." 54 "\n\t\tSubsequent -U options will clear the mark for those <rr type>s" 55 "\n\t\ttoo, so that only the given <rr type>s will be printed in the" 56 "\n\t\tpresentation format specific for those <rr type>s.\n");
57 printf(
"\t\t-U is not meant to be used together with -u.\n");
58 printf(
"\t-v shows the version and exits\n");
59 printf(
"\t-z sort the zone (implies -c).\n");
60 printf(
"\nif no file is given standard input is read\n");
65 main(
int argc,
char **argv)
72 bool canonicalize =
false;
75 bool only_dnssec =
false;
76 bool print_soa =
true;
86 int soa_serial_increment_func_data = 0;
88 while ((c = getopt(argc, argv,
"0bcdhnpsu:U:vzS:")) != -1) {
104 fprintf(stderr,
"Warning: stripping both DNSSEC and non-DNSSEC records. Output will be sparse.\n");
119 fprintf(stderr,
"Warning: stripping both DNSSEC and non-DNSSEC records. Output will be sparse.\n");
127 ,
"Cannot set rr type %s " 128 "in output format to " 129 "print as unknown type: %s\n" 143 ,
"Cannot set rr type %s " 144 "in output format to not " 145 "print as unknown type: %s\n" 164 if (*optarg ==
'+' || *optarg ==
'-') {
165 soa_serial_increment_func_data =
167 soa_serial_increment_func =
169 }
else if (! strtok(optarg,
"0123456789")) {
170 soa_serial_increment_func_data =
172 soa_serial_increment_func =
174 }
else if (!strcasecmp(optarg,
"YYYYMMDDxx")){
175 soa_serial_increment_func =
177 }
else if (!strcasecmp(optarg,
"unixtime")){
178 soa_serial_increment_func =
181 fprintf(stderr,
"-S expects a number " 182 "optionally preceded by a " 183 "+ or - sign to indicate an " 184 "offset, or the text YYYYMM" 185 "DDxx or unixtime\n");
200 fp = fopen(filename,
"r");
202 fprintf(stderr,
"Unable to open %s: %s\n", filename, strerror(errno));
211 fprintf(stderr,
"%s at %d\n",
264 if (soa_serial_increment_func) {
267 , soa_serial_increment_func
268 , soa_serial_increment_func_data
void ldns_zone_set_rrs(ldns_zone *z, ldns_rr_list *rrlist)
Set the zone's contents.
ldns_rr * ldns_zone_soa(const ldns_zone *z)
Return the soa record of a zone.
void ldns_rr2canonical(ldns_rr *rr)
converts each dname in a rr to its canonical form.
#define LDNS_COMMENT_BUBBLEBABBLE
Provide bubblebabble representation for DS RR's as comment.
bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
List or Set of Resource Records.
ldns_status ldns_zone_new_frm_fp_l(ldns_zone **z, FILE *fp, ldns_rdf *origin, uint32_t ttl, ldns_rr_class c __attribute__((unused)), int *line_nr)
#define LDNS_FMT_PAD_SOA_SERIAL
void ldns_rr_free(ldns_rr *rr)
frees an RR structure
ldns_rr_type ldns_get_rr_type_by_name(const char *name)
retrieves a rrtype by looking up its name.
void ldns_rr_list_free(ldns_rr_list *rr_list)
frees an rr_list structure.
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
void print_usage(const char *progname)
Including this file will include all ldns files, and define some lookup tables.
void ldns_rr_soa_increment_func_int(ldns_rr *soa, ldns_soa_serial_increment_func_t f, int data)
Increment the serial number of the given SOA with the given function using data as an argument for th...
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
const char * ldns_version(void)
Show the internal library version.
void ldns_rr_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_rr *rr)
Prints the data in the resource record to the given file stream (in presentation format) ...
ldns_rr * ldns_rr_list_pop_rr(ldns_rr_list *rr_list)
pops the last rr from an rrlist.
ldns_rr_list * ldns_rr_list_new(void)
creates a new rr_list structure.
uint32_t(* ldns_soa_serial_increment_func_t)(uint32_t, void *)
The type of function to be passed to ldns_rr_soa_increment_func, ldns_rr_soa_increment_func_data or l...
host2str.h - txt presentation of RRs
void ldns_zone_deep_free(ldns_zone *zone)
Frees the allocated memory for the zone, the soa rr in it, and the rr_list structure in it...
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
uint32_t ldns_soa_serial_increment_by(uint32_t s, void *data)
Function to be used with dns_rr_soa_increment_func_int, to increment the soa serial number with a cer...
enum ldns_enum_status ldns_status
ldns_status ldns_output_format_set_type(ldns_output_format *fmt, ldns_rr_type t)
Makes sure the LDNS_FMT_RFC3597 is set in the output format.
#define LDNS_FMT_ZEROIZE_RRSIGS
#define LDNS_COMMENT_FLAGS
Show when a NSEC3 RR has the optout flag set as comment.
ldns_status ldns_output_format_clear_type(ldns_output_format *fmt, ldns_rr_type t)
Makes sure the LDNS_FMT_RFC3597 is set in the output format.
ldns_rr_list * ldns_zone_rrs(const ldns_zone *z)
Get a list of a zone's content.
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.
enum ldns_enum_rr_type ldns_rr_type
void ldns_zone_sort(ldns_zone *zone)
Sort the rrs in a zone, with the current impl.
const char * ldns_get_errorstr_by_id(ldns_status err)
look up a descriptive text by each error.
uint32_t ldns_soa_serial_datecounter(uint32_t s, void *data)
Function to be used with ldns_rr_soa_increment_func or ldns_rr_soa_increment_func_int to set the soa ...
uint32_t ldns_soa_serial_identity(uint32_t unused __attribute__((unused)), void *data)
int main(int argc, char **argv)
void ldns_rr_list_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_rr_list *lst)
print a rr_list to output
uint32_t ldns_soa_serial_unixtime(uint32_t s, void *data)
Function to be used with ldns_rr_soa_increment_func or ldns_rr_soa_increment_func_int to set the soa ...