s3: tests: Add new test_stream_dir_rename.sh test.
[Samba.git] / source4 / rpc_server / dnsserver / dnsserver.h
blob2e46e7c66a434ad765a886a495de406e232842a4
1 /*
2 Unix SMB/CIFS implementation.
4 DNS Server
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"
28 #include "ldb.h"
30 struct dnsserver_serverinfo {
31 uint32_t dwVersion;
32 uint8_t fBootMethod;
33 uint8_t fAdminConfigured;
34 uint8_t fAllowUpdate;
35 uint8_t fDsAvailable;
37 char * pszServerName;
38 char * pszDsContainer;
40 uint32_t dwDsForestVersion;
41 uint32_t dwDsDomainVersion;
42 uint32_t dwDsDsaVersion;
43 uint32_t fReadOnlyDC;
44 char * pszDomainName;
45 char * pszForestName;
46 char * pszDomainDirectoryPartition;
47 char * pszForestDirectoryPartition;
49 struct DNS_ADDR_ARRAY * aipServerAddrs;
50 struct DNS_ADDR_ARRAY * aipListenAddrs;
51 struct IP4_ARRAY * aipForwarders;
53 struct IP4_ARRAY * aipLogFilter;
54 char * pwszLogFilePath;
56 uint32_t dwLogLevel;
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;
81 uint8_t fNoRecursion;
82 uint8_t fSecureResponses;
84 uint8_t fRoundRobin;
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 {
96 uint8_t Version;
97 uint32_t Flags;
98 uint8_t dwZoneType;
99 uint8_t fReverse;
100 uint8_t fAllowUpdate;
101 uint8_t fPaused;
102 uint8_t fShutdown;
103 uint8_t fAutoCreated;
105 uint8_t fUseDatabase;
106 char * pszDataFile;
108 struct IP4_ARRAY * aipMasters;
110 uint32_t fSecureSecondaries;
111 uint32_t fNotifyLevel;
112 struct IP4_ARRAY * aipSecondaries;
113 struct IP4_ARRAY * aipNotify;
115 uint32_t fUseWins;
116 uint32_t fUseNbstat;
118 uint32_t fAging;
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;
129 char * pwszZoneDn;
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;
147 uint32_t dwDpFlags;
148 bool is_forest;
149 int zones_count;
153 struct dnsserver_partition_info {
154 const char *pszCrDn;
155 uint32_t dwState;
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;
164 const char *name;
165 struct ldb_dn *zone_dn;
166 struct dnsserver_zoneinfo *zoneinfo;
167 struct dnsp_DnsProperty *tmp_props;
168 int32_t num_props;
172 struct dns_tree {
173 const char *name;
174 int level;
175 unsigned int num_children;
176 struct dns_tree **children;
177 void *data;
180 /* Data structure manipulation functions from dnsdata.c */
182 struct IP4_ARRAY *ip4_array_copy(TALLOC_CTX *mem_ctx, struct IP4_ARRAY *ip4);
183 struct DNS_ADDR_ARRAY *ip4_array_to_dns_addr_array(TALLOC_CTX *mem_ctx, struct IP4_ARRAY *ip4);
184 struct IP4_ARRAY *dns_addr_array_to_ip4_array(TALLOC_CTX *mem_ctx,
185 struct DNS_ADDR_ARRAY *ip);
186 struct DNS_ADDR_ARRAY *dns_addr_array_copy(TALLOC_CTX *mem_ctx, struct DNS_ADDR_ARRAY *addr);
188 int dns_split_name_components(TALLOC_CTX *mem_ctx, const char *name, char ***components);
189 char *dns_split_node_name(TALLOC_CTX *mem_ctx, const char *node_name, const char *zone_name);
191 int dns_name_compare(struct ldb_message * const *m1, struct ldb_message * const *m2,
192 const char *search_name);
193 bool dns_record_match(struct dnsp_DnssrvRpcRecord *rec1, struct dnsp_DnssrvRpcRecord *rec2);
195 void dnsp_to_dns_copy(TALLOC_CTX *mem_ctx, struct dnsp_DnssrvRpcRecord *dnsp,
196 struct DNS_RPC_RECORD *dns);
197 WERROR dns_to_dnsp_convert(TALLOC_CTX *mem_ctx, struct DNS_RPC_RECORD *dns,
198 struct dnsp_DnssrvRpcRecord **out_dnsp,
199 bool check_name);
201 struct dns_tree *dns_build_tree(TALLOC_CTX *mem_ctx, const char *name, struct ldb_result *res);
202 WERROR dns_fill_records_array(TALLOC_CTX *mem_ctx, struct dnsserver_zone *z,
203 enum dns_record_type record_type,
204 unsigned int select_flag, const char *zone_name,
205 struct ldb_message *msg, int num_children,
206 struct DNS_RPC_RECORDS_ARRAY *recs,
207 char ***add_names, int *add_count);
210 /* Utility functions from dnsutils.c */
212 struct dnsserver_serverinfo *dnsserver_init_serverinfo(TALLOC_CTX *mem_ctx,
213 struct loadparm_context *lp_ctx,
214 struct ldb_context *samdb);
215 struct dnsserver_zoneinfo *dnsserver_init_zoneinfo(struct dnsserver_zone *zone,
216 struct dnsserver_serverinfo *serverinfo);
217 struct dnsserver_zone *dnsserver_find_zone(struct dnsserver_zone *zones,
218 const char *zone_name);
219 struct ldb_dn *dnsserver_name_to_dn(TALLOC_CTX *mem_ctx, struct dnsserver_zone *z,
220 const char *name);
221 uint32_t dnsserver_zone_to_request_filter(const char *zone);
223 /* Database functions from dnsdb.c */
225 struct dnsserver_partition *dnsserver_db_enumerate_partitions(TALLOC_CTX *mem_ctx,
226 struct dnsserver_serverinfo *serverinfo,
227 struct ldb_context *samdb);
228 struct dnsserver_zone *dnsserver_db_enumerate_zones(TALLOC_CTX *mem_ctx,
229 struct ldb_context *samdb,
230 struct dnsserver_partition *p);
231 struct dnsserver_partition_info *dnsserver_db_partition_info(TALLOC_CTX *mem_ctx,
232 struct ldb_context *samdb,
233 struct dnsserver_partition *p);
234 WERROR dnsserver_db_add_empty_node(TALLOC_CTX *mem_ctx,
235 struct ldb_context *samdb,
236 struct dnsserver_zone *z,
237 const char *node_name);
238 WERROR dnsserver_db_add_record(TALLOC_CTX *mem_ctx,
239 struct ldb_context *samdb,
240 struct dnsserver_zone *z,
241 const char *node_name,
242 struct DNS_RPC_RECORD *add_record);
243 WERROR dnsserver_db_update_record(TALLOC_CTX *mem_ctx,
244 struct ldb_context *samdb,
245 struct dnsserver_zone *z,
246 const char *node_name,
247 struct DNS_RPC_RECORD *add_record,
248 struct DNS_RPC_RECORD *del_record);
249 WERROR dnsserver_db_do_reset_dword(struct ldb_context *samdb,
250 struct dnsserver_zone *z,
251 struct DNS_RPC_NAME_AND_PARAM *n_p);
252 WERROR dnsserver_db_delete_record(TALLOC_CTX *mem_ctx,
253 struct ldb_context *samdb,
254 struct dnsserver_zone *z,
255 const char *node_name,
256 struct DNS_RPC_RECORD *del_record);
257 WERROR dnsserver_db_create_zone(struct ldb_context *samdb,
258 struct dnsserver_partition *partitions,
259 struct dnsserver_zone *z,
260 struct loadparm_context *lp_ctx);
261 WERROR dnsserver_db_delete_zone(struct ldb_context *samdb,
262 struct dnsserver_zone *z);
264 #endif /* __DNSSERVER_H__ */