dns: Add dns_get_authoritative_zone helper function
authorKai Blin <kai@samba.org>
Wed, 29 Oct 2014 12:35:36 +0000 (13:35 +0100)
committerKai Blin <kai@samba.org>
Thu, 6 Aug 2015 09:03:13 +0000 (11:03 +0200)
Signed-off-by: Kai Blin <kai@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/dns_server/dns_server.h
source4/dns_server/dns_utils.c

index 3423ee03593a85d4f488807130bc21f0a5de433e..64b716a2542e5cbf138038210af8cbfdc78dd351 100644 (file)
@@ -93,6 +93,8 @@ bool dns_records_match(struct dnsp_DnssrvRpcRecord *rec1,
                       struct dnsp_DnssrvRpcRecord *rec2);
 bool dns_authorative_for_zone(struct dns_server *dns,
                              const char *name);
+const char *dns_get_authoritative_zone(struct dns_server *dns,
+                                      const char *name);
 WERROR dns_lookup_records(struct dns_server *dns,
                          TALLOC_CTX *mem_ctx,
                          struct ldb_dn *dn,
index c757c1576266929335892c54666244ba008f12e0..28412eb76818d0d308e6fa6f0d65221bd33e0f03 100644 (file)
@@ -199,6 +199,22 @@ bool dns_authorative_for_zone(struct dns_server *dns,
        return true;
 }
 
+const char *dns_get_authoritative_zone(struct dns_server *dns,
+                                      const char *name)
+{
+       const struct dns_server_zone *z;
+       size_t host_part_len = 0;
+
+       for (z = dns->zones; z != NULL; z = z->next) {
+               bool match;
+               match = dns_name_match(z->name, name, &host_part_len);
+               if (match) {
+                       return z->name;
+               }
+       }
+       return NULL;
+}
+
 WERROR dns_name2dn(struct dns_server *dns,
                   TALLOC_CTX *mem_ctx,
                   const char *name,