summaryrefslogtreecommitdiff
path: root/usr.sbin/nsd/difffile.h
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/nsd/difffile.h')
-rw-r--r--usr.sbin/nsd/difffile.h143
1 files changed, 102 insertions, 41 deletions
diff --git a/usr.sbin/nsd/difffile.h b/usr.sbin/nsd/difffile.h
index d54c629b5a7..d5f2cb8833f 100644
--- a/usr.sbin/nsd/difffile.h
+++ b/usr.sbin/nsd/difffile.h
@@ -1,7 +1,7 @@
/*
* difffile.h - nsd.diff file handling header file. Read/write diff files.
*
- * Copyright (c) 2001-2011, NLnet Labs. All rights reserved.
+ * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
*
* See LICENSE for the license.
*
@@ -9,62 +9,123 @@
#ifndef DIFFFILE_H
#define DIFFFILE_H
-#include "config.h"
#include "rbtree.h"
#include "namedb.h"
#include "options.h"
+#include "udb.h"
+struct nsd;
+struct nsdst;
-#define DIFF_PART_IXFR ('I'<<24 | 'X'<<16 | 'F'<<8 | 'R')
-#define DIFF_PART_SURE ('S'<<24 | 'U'<<16 | 'R'<<8 | 'E')
-
-/*
- * Used to pass commit logs
- */
-struct diff_log {
- char* zone_name;
- char* error;
- char* comment;
- struct diff_log* next;
-};
+#define DIFF_PART_XXFR ('X'<<24 | 'X'<<16 | 'F'<<8 | 'R')
+#define DIFF_PART_XFRF ('X'<<24 | 'F'<<16 | 'R'<<8 | 'F')
/* write an xfr packet data to the diff file, type=IXFR.
- The diff file is created if necessary. */
-void diff_write_packet(const char* zone, uint32_t new_serial, uint16_t id,
- uint32_t seq_nr, uint8_t* data, size_t len, nsd_options_t* opt);
+ The diff file is created if necessary, with initial header(notcommitted). */
+void diff_write_packet(const char* zone, const char* pat, uint32_t old_serial,
+ uint32_t new_serial, uint32_t seq_nr, uint8_t* data, size_t len,
+ struct nsd* nsd, uint64_t filenumber);
/*
- * Write a commit packet to the diff file, type=SURE.
- * The zone data (preceding ixfr packets) are committed.
- * See NSD-DIFFFILE for meaning of the arguments.
+ * Overwrite header of diff file with committed vale and other data.
+ * append log string.
*/
void diff_write_commit(const char* zone, uint32_t old_serial,
- uint32_t new_serial, uint16_t id, uint32_t num_parts,
- uint8_t commit, const char* log_msg,
- nsd_options_t* opt);
-
-/* check if the crc in the nsd.db is the same in memory as on disk.
- returns 1 if different. 0 if the same. returns -1 on error. */
-int db_crc_different(namedb_type* db);
-
-/* read the diff file and apply to the database in memory.
- It will attempt to skip bad data.
- If you pass a non-null value log, log comments are alloced in namedb.region
- then, *log must be 0 on start of call (entries are prepended).
- returns 0 on an unrecoverable error. */
-int diff_read_file(namedb_type* db, nsd_options_t* opt, struct diff_log** log,
- size_t child_count);
-
-/* check the diff file for garbage at the end (bad type, partial write)
- * and snip it off.
- */
-void diff_snip_garbage(namedb_type* db, nsd_options_t* opt);
+ uint32_t new_serial, uint32_t num_parts, uint8_t commit,
+ const char* log_msg, struct nsd* nsd, uint64_t filenumber);
/*
* These functions read parts of the diff file.
*/
int diff_read_32(FILE *in, uint32_t* result);
-int diff_read_16(FILE *in, uint16_t* result);
int diff_read_8(FILE *in, uint8_t* result);
int diff_read_str(FILE* in, char* buf, size_t len);
+/* delete the RRs for a zone from memory */
+void delete_zone_rrs(namedb_type* db, zone_type* zone);
+/* delete an RR */
+int delete_RR(namedb_type* db, const dname_type* dname,
+ uint16_t type, uint16_t klass,
+ buffer_type* packet, size_t rdatalen, zone_type *zone,
+ region_type* temp_region, struct udb_ptr* udbz);
+/* add an RR */
+int add_RR(namedb_type* db, const dname_type* dname,
+ uint16_t type, uint16_t klass, uint32_t ttl,
+ buffer_type* packet, size_t rdatalen, zone_type *zone,
+ struct udb_ptr* udbz);
+
+/* task udb structure */
+struct task_list_d {
+ /** next task in list */
+ udb_rel_ptr next;
+ /** task type */
+ enum {
+ /** expire or un-expire a zone */
+ task_expire,
+ /** apply an ixfr or axfr to a zone */
+ task_apply_xfr,
+ /** soa info for zone */
+ task_soa_info,
+ /** check mtime of zonefiles and read them, done on SIGHUP */
+ task_check_zonefiles,
+ /** write zonefiles (if changed) */
+ task_write_zonefiles,
+ /** set verbosity */
+ task_set_verbosity,
+ /** statistic info */
+ task_stat_info,
+ /** add a zone */
+ task_add_zone,
+ /** delete zone */
+ task_del_zone,
+ /** add TSIG key */
+ task_add_key,
+ /** delete TSIG key */
+ task_del_key,
+ /** add pattern */
+ task_add_pattern,
+ /** delete pattern */
+ task_del_pattern,
+ /** options change */
+ task_opt_change
+ } task_type;
+ uint32_t size; /* size of this struct */
+
+ /** soainfo: zonename dname, soaRR wireform */
+ /** expire: zonename, boolyesno */
+ /** apply_xfr: zonename, serials, yesno is filenamecounter */
+ uint32_t oldserial, newserial;
+ /** general variable. for some used to see if zname is present. */
+ uint64_t yesno;
+ struct dname zname[0];
+};
+#define TASKLIST(ptr) ((struct task_list_d*)UDB_PTR(ptr))
+/** create udb for tasks */
+struct udb_base* task_file_create(const char* file);
+void task_remap(udb_base* udb);
+void task_process_sync(udb_base* udb);
+void task_clear(udb_base* udb);
+void task_new_soainfo(udb_base* udb, udb_ptr* last, struct zone* z);
+void task_new_expire(udb_base* udb, udb_ptr* last,
+ const struct dname* z, int expired);
+void* task_new_stat_info(udb_base* udb, udb_ptr* last, struct nsdst* stat,
+ size_t child_count);
+void task_new_check_zonefiles(udb_base* udb, udb_ptr* last,
+ const dname_type* zone);
+void task_new_write_zonefiles(udb_base* udb, udb_ptr* last,
+ const dname_type* zone);
+void task_new_set_verbosity(udb_base* udb, udb_ptr* last, int v);
+void task_new_add_zone(udb_base* udb, udb_ptr* last, const char* zone,
+ const char* pattern);
+void task_new_del_zone(udb_base* udb, udb_ptr* last, const dname_type* dname);
+void task_new_add_key(udb_base* udb, udb_ptr* last, key_options_t* key);
+void task_new_del_key(udb_base* udb, udb_ptr* last, const char* name);
+void task_new_add_pattern(udb_base* udb, udb_ptr* last, pattern_options_t* p);
+void task_new_del_pattern(udb_base* udb, udb_ptr* last, const char* name);
+void task_new_opt_change(udb_base* udb, udb_ptr* last, nsd_options_t* opt);
+int task_new_apply_xfr(udb_base* udb, udb_ptr* last, const dname_type* zone,
+ uint32_t old_serial, uint32_t new_serial, uint64_t filenumber);
+void task_process_in_reload(struct nsd* nsd, udb_base* udb, udb_ptr *last_task,
+ udb_ptr* task);
+void task_process_expire(namedb_type* db, struct task_list_d* task);
+
#endif /* DIFFFILE_H */