diff options
Diffstat (limited to 'source4/dns_server')
-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, |