diff options
author | Kai Blin <kai@samba.org> | 2011-12-16 09:24:18 +0100 |
---|---|---|
committer | Kai Blin <kai@samba.org> | 2011-12-17 02:46:08 +0100 |
commit | 0922953b10f3495e5d62867025e7e99ebc3e6613 (patch) | |
tree | d3101c16cea50abffd3b4d636c0b777a21cf5c05 | |
parent | db2573eadfd9389391f6daf73432de7f73b46e81 (diff) | |
download | samba-0922953b10f3495e5d62867025e7e99ebc3e6613.tar.gz samba-0922953b10f3495e5d62867025e7e99ebc3e6613.tar.bz2 samba-0922953b10f3495e5d62867025e7e99ebc3e6613.zip |
s4 dns: Implement dns record comparison function
-rw-r--r-- | source4/dns_server/dns_server.h | 3 | ||||
-rw-r--r-- | source4/dns_server/dns_utils.c | 54 |
2 files changed, 57 insertions, 0 deletions
diff --git a/source4/dns_server/dns_server.h b/source4/dns_server/dns_server.h index 0339fff01f..7387641c63 100644 --- a/source4/dns_server/dns_server.h +++ b/source4/dns_server/dns_server.h @@ -23,6 +23,7 @@ #define __DNS_SERVER_H__ #include "librpc/gen_ndr/dns.h" +#include "librpc/gen_ndr/ndr_dnsp.h" struct tsocket_address; @@ -56,6 +57,8 @@ WERROR dns_server_process_update(struct dns_server *dns, uint8_t werr_to_dns_err(WERROR werror); bool dns_name_match(const char *zone, const char *name, size_t *host_part_len); bool dns_name_equal(const char *name1, const char *name2); +bool dns_records_match(struct dnsp_DnssrvRpcRecord *rec1, + struct dnsp_DnssrvRpcRecord *rec2); WERROR dns_name2dn(struct dns_server *dns, TALLOC_CTX *mem_ctx, const char *name, diff --git a/source4/dns_server/dns_utils.c b/source4/dns_server/dns_utils.c index f179546849..5da32c0c53 100644 --- a/source4/dns_server/dns_utils.c +++ b/source4/dns_server/dns_utils.c @@ -109,6 +109,60 @@ bool dns_name_equal(const char *name1, const char *name2) return ret && (host_part_len == 0); } +/* + see if two dns records match + */ +bool dns_records_match(struct dnsp_DnssrvRpcRecord *rec1, + struct dnsp_DnssrvRpcRecord *rec2) +{ + if (rec1->wType != rec2->wType) { + return false; + } + + /* see if the data matches */ + switch (rec1->wType) { + case DNS_TYPE_A: + return strcmp(rec1->data.ipv4, rec2->data.ipv4) == 0; + case DNS_TYPE_AAAA: + return strcmp(rec1->data.ipv6, rec2->data.ipv6) == 0; + case DNS_TYPE_CNAME: + return dns_name_equal(rec1->data.cname, rec2->data.cname); + case DNS_TYPE_TXT: + return strcmp(rec1->data.txt, rec2->data.txt) == 0; + case DNS_TYPE_PTR: + return strcmp(rec1->data.ptr, rec2->data.ptr) == 0; + case DNS_TYPE_NS: + return dns_name_equal(rec1->data.ns, rec2->data.ns); + + case DNS_TYPE_SRV: + return rec1->data.srv.wPriority == rec2->data.srv.wPriority && + rec1->data.srv.wWeight == rec2->data.srv.wWeight && + rec1->data.srv.wPort == rec2->data.srv.wPort && + dns_name_equal(rec1->data.srv.nameTarget, rec2->data.srv.nameTarget); + + case DNS_TYPE_MX: + return rec1->data.mx.wPriority == rec2->data.mx.wPriority && + dns_name_equal(rec1->data.mx.nameTarget, rec2->data.mx.nameTarget); + + case DNS_TYPE_HINFO: + return strcmp(rec1->data.hinfo.cpu, rec2->data.hinfo.cpu) == 0 && + strcmp(rec1->data.hinfo.os, rec2->data.hinfo.os) == 0; + + case DNS_TYPE_SOA: + return dns_name_equal(rec1->data.soa.mname, rec2->data.soa.mname) && + dns_name_equal(rec1->data.soa.rname, rec2->data.soa.rname) && + rec1->data.soa.serial == rec2->data.soa.serial && + rec1->data.soa.refresh == rec2->data.soa.refresh && + rec1->data.soa.retry == rec2->data.soa.retry && + rec1->data.soa.expire == rec2->data.soa.expire && + rec1->data.soa.minimum == rec2->data.soa.minimum; + default: + break; + } + + return false; +} + WERROR dns_name2dn(struct dns_server *dns, TALLOC_CTX *mem_ctx, const char *name, |