return false;
SOAData sd;
fillSOAData(rr.content, sd);
- if(pdns_iequals(kind,"INCEPTION")) {
- time_t inception = getStartOfWeek();
- sd.serial = localtime_format_YYYYMMDDSS(inception, 1);
- }
- else if(pdns_iequals(kind,"INCEPTION-INCREMENT")) {
- time_t inception = getStartOfWeek();
-
- uint32_t inception_serial = localtime_format_YYYYMMDDSS(inception, 1);
- uint32_t dont_increment_after = localtime_format_YYYYMMDDSS(inception + 2*86400, 99);
-
- if(sd.serial <= dont_increment_after) {
- /* "day00" and "day01" are reserved for inception increasing, so increment sd.serial by two */
- sd.serial += 2;
- }
- else if(sd.serial < inception_serial) {
- sd.serial = inception_serial;
- }
- }
- else if(pdns_iequals(kind,"INCEPTION-WEEK")) {
- time_t inception = getStartOfWeek();
- sd.serial = inception / (7*86400);
- }
- else if(pdns_iequals(kind,"INCREMENT-WEEKS")) {
- time_t inception = getStartOfWeek();
- sd.serial += inception / (7*86400);
- }
- else if(pdns_iequals(kind,"EPOCH")) {
- sd.serial = time(0);
- }
- else if(pdns_iequals(kind,"INCEPTION-EPOCH")) {
- time_t inception = getStartOfWeek();
- if (sd.serial < inception) {
- sd.serial = inception;
- }
- }
- rr.content = serializeSOAData(sd);
+ sd.serial = calculateEditSoa(sd, kind);
+ rr.content = serializeSOAData(sd);
return true;
}
}
return false;
}
+
+
+uint32_t calculateEditSoa(SOAData sd, const string& kind) {
+ if(pdns_iequals(kind,"INCEPTION")) {
+ time_t inception = getStartOfWeek();
+ return localtime_format_YYYYMMDDSS(inception, 1);
+ }
+ else if(pdns_iequals(kind,"INCEPTION-INCREMENT")) {
+ time_t inception = getStartOfWeek();
+ uint32_t inception_serial = localtime_format_YYYYMMDDSS(inception, 1);
+ uint32_t dont_increment_after = localtime_format_YYYYMMDDSS(inception + 2*86400, 99);
+
+ if(sd.serial <= dont_increment_after)
+ return (sd.serial + 2); /* "day00" and "day01" are reserved for inception increasing, so increment sd.serial by two */
+ else if(sd.serial < inception_serial)
+ return inception_serial;
+ }
+ else if(pdns_iequals(kind,"INCEPTION-WEEK")) {
+ time_t inception = getStartOfWeek();
+ return ( inception / (7*86400) );
+ }
+ else if(pdns_iequals(kind,"INCREMENT-WEEKS")) {
+ time_t inception = getStartOfWeek();
+ return (sd.serial + (inception / (7*86400)));
+ }
+ else if(pdns_iequals(kind,"EPOCH")) {
+ return time(0);
+ }
+ else if(pdns_iequals(kind,"INCEPTION-EPOCH")) {
+ time_t inception = getStartOfWeek();
+ if (sd.serial < inception)
+ return inception;
+ }
+ else
+ return (sd.serial + 1);
+}