printed.
.TP
-\fB-S\fR \fI[+|0]number\fR
+\fB-S\fR \fI[[+|0]number | YYYYMMDDxx | unixtime ]\fR
Set serial number to the given \fInumber\fR, or when preceded by a sign,
-offset the exisiting number with it.
+offset the exisiting number with it. When giving the literal strings
+\fIYYYYMMDDxx\fR or \fIunixtime\fR, the serial number is tried to be reset
+in date or in unixtime format respectively. Though is the updated serial
+number is smaller than the original one, the original one is simply
+increased by one.
+
+When updating a zone's serial serial number, it will be stripped from DNSSEC
+data as well.
+
.TP
\fB-v\fR
printf("\t-h show this text\n");
printf("\t-n do not print the SOA record\n");
printf("\t-s strip DNSSEC data from the zone\n");
- printf("\t-S [+|-]<number>\n"
+ printf("\t-S [[+|-]<number> | YYYYMMDDxx | "
+ " unixtime ]\n"
"\t\tSet serial number to <number> or,"
" when preceded by a sign,\n"
"\t\toffset the exisiting number with "
- "<number>.\n");
-
+ "<number>. With YYYYMMDDxx\n"
+ "\t\tthe serial is formatted as a date"
+ ", and with unixtime as the\n"
+ "\t\tnumber of seconds since 1-1-1970."
+ " However, on serial number"
+ "\n\t\tdecrease, +1 is used in stead"
+ ". (implies -s)\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");
atoi(optarg);
soa_serial_increment_func =
ldns_soa_serial_identity;
+ } else if (!strcasecmp(optarg, "YYYYMMDDxx")){
+ soa_serial_increment_func =
+ ldns_soa_serial_YYYYMMDDxx;
+ } else if (!strcasecmp(optarg, "unixtime")){
+ soa_serial_increment_func =
+ ldns_soa_serial_unixtime;
} else {
fprintf(stderr, "-S expects a number "
"optionally preceded by a "
"+ or - sign to indicate an "
- "offset.\n");
+ "offset, or the text YYYYMM"
+ "DDxx or unixtime\n");
exit(EXIT_FAILURE);
}
break;
uint32_t ldns_soa_serial_identity(uint32_t _, void *data);
uint32_t ldns_soa_serial_increment(uint32_t s, void *_);
uint32_t ldns_soa_serial_increment_by(uint32_t s, void *data);
+uint32_t ldns_soa_serial_unixtime(uint32_t s, void *data);
+uint32_t ldns_soa_serial_YYYYMMDDxx(uint32_t s, void *data);
void ldns_rr_soa_increment(
ldns_rr *soa);
ldns_sign_public_evp
ldns_sign_public_rsamd5
ldns_sign_public_rsasha1
+ldns_soa_serial_YYYYMMDDxx
ldns_soa_serial_identity
ldns_soa_serial_increment
ldns_soa_serial_increment_by
+ldns_soa_serial_unixtime
ldns_sockaddr_storage2rdf
ldns_str2period
ldns_str2rdf_a
return s + (intptr_t) data;
}
+uint32_t ldns_soa_serial_YYYYMMDDxx(uint32_t s, void *data)
+{
+ struct tm tm;
+ char s_str[11];
+ uint32_t new_s;
+ time_t t = data ? (time_t) (intptr_t) data : ldns_time(NULL);
+
+ strftime(s_str, 11, "%Y%m%d00", localtime_r(&t, &tm));
+ s_str[10] = 0;
+ new_s = atoi(s_str);
+ return new_s > s ? new_s : s+1;
+}
+
+uint32_t ldns_soa_serial_unixtime(uint32_t s, void *data)
+{
+ uint32_t new_s = (uint32_t)(data ? (intptr_t) data : ldns_time(NULL));
+ return new_s > s ? new_s : s+1;
+}
+
void
ldns_rr_soa_increment(ldns_rr *soa)
{