2 Unix SMB/CIFS implementation.
6 Copyright (C) Amitay Isaacs 2011
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __DNSSERVER_H__
23 #define __DNSSERVER_H__
25 #include "librpc/gen_ndr/dnsp.h"
26 #include "librpc/gen_ndr/dnsserver.h"
27 #include "param/param.h"
30 struct dnsserver_serverinfo
{
33 uint8_t fAdminConfigured
;
38 char * pszDsContainer
;
40 uint32_t dwDsForestVersion
;
41 uint32_t dwDsDomainVersion
;
42 uint32_t dwDsDsaVersion
;
46 char * pszDomainDirectoryPartition
;
47 char * pszForestDirectoryPartition
;
49 struct IP4_ARRAY
* aipServerAddrs
;
50 struct IP4_ARRAY
* aipListenAddrs
;
51 struct IP4_ARRAY
* aipForwarders
;
53 struct IP4_ARRAY
* aipLogFilter
;
54 char * pwszLogFilePath
;
57 uint32_t dwDebugLevel
;
58 uint32_t dwEventLogLevel
;
59 uint32_t dwLogFileMaxSize
;
61 uint32_t dwForwardTimeout
;
62 uint32_t dwRpcProtocol
;
63 uint32_t dwNameCheckFlag
;
64 uint32_t cAddressAnswerLimit
;
65 uint32_t dwRecursionRetry
;
66 uint32_t dwRecursionTimeout
;
67 uint32_t dwMaxCacheTtl
;
68 uint32_t dwDsPollingInterval
;
69 uint32_t dwLocalNetPriorityNetMask
;
71 uint32_t dwScavengingInterval
;
72 uint32_t dwDefaultRefreshInterval
;
73 uint32_t dwDefaultNoRefreshInterval
;
74 uint32_t dwLastScavengeTime
;
76 uint8_t fAutoReverseZones
;
77 uint8_t fAutoCacheUpdate
;
79 uint8_t fRecurseAfterForwarding
;
80 uint8_t fForwardDelegations
;
82 uint8_t fSecureResponses
;
85 uint8_t fLocalNetPriority
;
87 uint8_t fBindSecondaries
;
88 uint8_t fWriteAuthorityNs
;
90 uint8_t fStrictFileParsing
;
91 uint8_t fLooseWildcarding
;
92 uint8_t fDefaultAgingState
;
95 struct dnsserver_zoneinfo
{
100 uint8_t fAllowUpdate
;
103 uint8_t fAutoCreated
;
105 uint8_t fUseDatabase
;
108 struct IP4_ARRAY
* aipMasters
;
110 uint32_t fSecureSecondaries
;
111 uint32_t fNotifyLevel
;
112 struct IP4_ARRAY
* aipSecondaries
;
113 struct IP4_ARRAY
* aipNotify
;
119 uint32_t dwNoRefreshInterval
;
120 uint32_t dwRefreshInterval
;
121 uint32_t dwAvailForScavengeTime
;
122 struct IP4_ARRAY
* aipScavengeServers
;
124 uint32_t dwForwarderTimeout
;
125 uint32_t fForwarderSlave
;
127 struct IP4_ARRAY
* aipLocalMasters
;
131 uint32_t dwLastSuccessfulSoaCheck
;
132 uint32_t dwLastSuccessfulXfr
;
134 uint32_t fQueuedForBackgroundLoad
;
135 uint32_t fBackgroundLoadInProgress
;
136 uint8_t fReadOnlyZone
;
138 uint32_t dwLastXfrAttempt
;
139 uint32_t dwLastXfrResult
;
143 struct dnsserver_partition
{
144 struct dnsserver_partition
*prev
, *next
;
145 struct ldb_dn
*partition_dn
;
146 const char *pszDpFqdn
;
153 struct dnsserver_partition_info
{
156 uint32_t dwReplicaCount
;
157 struct DNS_RPC_DP_REPLICA
**ReplicaArray
;
161 struct dnsserver_zone
{
162 struct dnsserver_zone
*prev
, *next
;
163 struct dnsserver_partition
*partition
;
165 struct ldb_dn
*zone_dn
;
166 struct dnsserver_zoneinfo
*zoneinfo
;
173 unsigned int num_children
;
174 struct dns_tree
**children
;
178 /* Data structure manipulation functions from dnsdata.c */
180 struct IP4_ARRAY
*ip4_array_copy(TALLOC_CTX
*mem_ctx
, struct IP4_ARRAY
*ip4
);
181 struct DNS_ADDR_ARRAY
*ip4_array_to_dns_addr_array(TALLOC_CTX
*mem_ctx
, struct IP4_ARRAY
*ip4
);
182 struct DNS_ADDR_ARRAY
*dns_addr_array_copy(TALLOC_CTX
*mem_ctx
, struct DNS_ADDR_ARRAY
*addr
);
184 int dns_split_name_components(TALLOC_CTX
*mem_ctx
, const char *name
, char ***components
);
185 char *dns_split_node_name(TALLOC_CTX
*mem_ctx
, const char *node_name
, const char *zone_name
);
187 int dns_name_compare(const struct ldb_message
**m1
, const struct ldb_message
**m2
,
189 bool dns_name_equal(const char *name1
, const char *name2
);
190 bool dns_record_match(struct dnsp_DnssrvRpcRecord
*rec1
, struct dnsp_DnssrvRpcRecord
*rec2
);
192 void dnsp_to_dns_copy(TALLOC_CTX
*mem_ctx
, struct dnsp_DnssrvRpcRecord
*dnsp
,
193 struct DNS_RPC_RECORD
*dns
);
194 struct dnsp_DnssrvRpcRecord
*dns_to_dnsp_copy(TALLOC_CTX
*mem_ctx
, struct DNS_RPC_RECORD
*dns
);
196 struct dns_tree
*dns_build_tree(TALLOC_CTX
*mem_ctx
, const char *name
, struct ldb_result
*res
);
197 WERROR
dns_fill_records_array(TALLOC_CTX
*mem_ctx
, struct dnsserver_zone
*z
,
198 enum dns_record_type record_type
,
199 unsigned int select_flag
, const char *zone_name
,
200 struct ldb_message
*msg
, int num_children
,
201 struct DNS_RPC_RECORDS_ARRAY
*recs
,
202 char ***add_names
, int *add_count
);
205 /* Utility functions from dnsutils.c */
207 struct dnsserver_serverinfo
*dnsserver_init_serverinfo(TALLOC_CTX
*mem_ctx
,
208 struct loadparm_context
*lp_ctx
,
209 struct ldb_context
*samdb
);
210 struct dnsserver_zoneinfo
*dnsserver_init_zoneinfo(struct dnsserver_zone
*zone
,
211 struct dnsserver_serverinfo
*serverinfo
);
212 struct dnsserver_partition
*dnsserver_find_partition(struct dnsserver_partition
*partitions
,
213 const char *dp_fqdn
);
214 struct dnsserver_zone
*dnsserver_find_zone(struct dnsserver_zone
*zones
,
215 const char *zone_name
);
216 struct ldb_dn
*dnsserver_name_to_dn(TALLOC_CTX
*mem_ctx
, struct dnsserver_zone
*z
,
218 uint32_t dnsserver_zone_to_request_filter(const char *zone
);
221 /* Database functions from dnsdb.c */
223 struct dnsserver_partition
*dnsserver_db_enumerate_partitions(TALLOC_CTX
*mem_ctx
,
224 struct dnsserver_serverinfo
*serverinfo
,
225 struct ldb_context
*samdb
);
226 struct dnsserver_zone
*dnsserver_db_enumerate_zones(TALLOC_CTX
*mem_ctx
,
227 struct ldb_context
*samdb
,
228 struct dnsserver_partition
*p
);
229 struct dnsserver_partition_info
*dnsserver_db_partition_info(TALLOC_CTX
*mem_ctx
,
230 struct ldb_context
*samdb
,
231 struct dnsserver_partition
*p
);
232 WERROR
dnsserver_db_add_empty_node(TALLOC_CTX
*mem_ctx
,
233 struct ldb_context
*samdb
,
234 struct dnsserver_zone
*z
,
235 const char *node_name
);
236 WERROR
dnsserver_db_add_record(TALLOC_CTX
*mem_ctx
,
237 struct ldb_context
*samdb
,
238 struct dnsserver_zone
*z
,
239 const char *node_name
,
240 struct DNS_RPC_RECORD
*add_record
);
241 WERROR
dnsserver_db_update_record(TALLOC_CTX
*mem_ctx
,
242 struct ldb_context
*samdb
,
243 struct dnsserver_zone
*z
,
244 const char *node_name
,
245 struct DNS_RPC_RECORD
*add_record
,
246 struct DNS_RPC_RECORD
*del_record
);
247 WERROR
dnsserver_db_delete_record(TALLOC_CTX
*mem_ctx
,
248 struct ldb_context
*samdb
,
249 struct dnsserver_zone
*z
,
250 const char *node_name
,
251 struct DNS_RPC_RECORD
*del_record
);
252 WERROR
dnsserver_db_create_zone(struct ldb_context
*samdb
,
253 struct dnsserver_partition
*partitions
,
254 struct dnsserver_zone
*z
,
255 struct loadparm_context
*lp_ctx
);
256 WERROR
dnsserver_db_delete_zone(struct ldb_context
*samdb
,
257 struct dnsserver_zone
*z
);
259 #endif /* __DNSSERVER_H__ */