summaryrefslogtreecommitdiff
path: root/source4/rpc_server/dnsserver/dnsserver.h
blob: 818dc60b626e23772e46794e5d2a659b40c413a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*
   Unix SMB/CIFS implementation.

   DNS Server

   Copyright (C) Amitay Isaacs 2011

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __DNSSERVER_H__
#define __DNSSERVER_H__

#include "librpc/gen_ndr/dnsp.h"
#include "librpc/gen_ndr/dnsserver.h"
#include "param/param.h"
#include "ldb.h"

struct dnsserver_serverinfo {
	uint32_t	dwVersion;
	uint8_t		fBootMethod;
	uint8_t		fAdminConfigured;
	uint8_t		fAllowUpdate;
	uint8_t		fDsAvailable;

	char *		pszServerName;
	char *		pszDsContainer;

	uint32_t	dwDsForestVersion;
	uint32_t	dwDsDomainVersion;
	uint32_t	dwDsDsaVersion;
	uint32_t	fReadOnlyDC;
	char *		pszDomainName;
	char *		pszForestName;
	char *		pszDomainDirectoryPartition;
	char *		pszForestDirectoryPartition;

	struct IP4_ARRAY * aipServerAddrs;
	struct IP4_ARRAY * aipListenAddrs;
	struct IP4_ARRAY * aipForwarders;

	struct IP4_ARRAY * aipLogFilter;
	char *		pwszLogFilePath;

	uint32_t 	dwLogLevel;
	uint32_t 	dwDebugLevel;
	uint32_t 	dwEventLogLevel;
	uint32_t 	dwLogFileMaxSize;

	uint32_t 	dwForwardTimeout;
	uint32_t 	dwRpcProtocol;
	uint32_t 	dwNameCheckFlag;
	uint32_t 	cAddressAnswerLimit;
	uint32_t 	dwRecursionRetry;
	uint32_t 	dwRecursionTimeout;
	uint32_t 	dwMaxCacheTtl;
	uint32_t 	dwDsPollingInterval;
	uint32_t 	dwLocalNetPriorityNetMask;

	uint32_t 	dwScavengingInterval;
	uint32_t 	dwDefaultRefreshInterval;
	uint32_t 	dwDefaultNoRefreshInterval;
	uint32_t 	dwLastScavengeTime;

	uint8_t 	fAutoReverseZones;
	uint8_t 	fAutoCacheUpdate;

	uint8_t 	fRecurseAfterForwarding;
	uint8_t 	fForwardDelegations;
	uint8_t 	fNoRecursion;
	uint8_t 	fSecureResponses;

	uint8_t 	fRoundRobin;
	uint8_t 	fLocalNetPriority;

	uint8_t 	fBindSecondaries;
	uint8_t 	fWriteAuthorityNs;

	uint8_t 	fStrictFileParsing;
	uint8_t 	fLooseWildcarding;
	uint8_t 	fDefaultAgingState;
};

struct dnsserver_zoneinfo {
	uint8_t		Version;
	uint32_t	Flags;
	uint8_t		dwZoneType;
	uint8_t		fReverse;
	uint8_t		fAllowUpdate;
	uint8_t		fPaused;
	uint8_t		fShutdown;
	uint8_t		fAutoCreated;

	uint8_t		fUseDatabase;
	char *		pszDataFile;

	struct IP4_ARRAY * aipMasters;

	uint32_t	fSecureSecondaries;
	uint32_t	fNotifyLevel;
	struct IP4_ARRAY * aipSecondaries;
	struct IP4_ARRAY * aipNotify;

	uint32_t	fUseWins;
	uint32_t	fUseNbstat;

	uint32_t	fAging;
	uint32_t	dwNoRefreshInterval;
	uint32_t	dwRefreshInterval;
	uint32_t	dwAvailForScavengeTime;
	struct IP4_ARRAY * aipScavengeServers;

	uint32_t	dwForwarderTimeout;
	uint32_t	fForwarderSlave;

	struct IP4_ARRAY * aipLocalMasters;

	uint32_t	dwDpFlags;
	char *		pszDpFqdn;
	char *		pwszZoneDn;

	uint32_t	dwLastSuccessfulSoaCheck;
	uint32_t	dwLastSuccessfulXfr;

	uint32_t	fQueuedForBackgroundLoad;
	uint32_t	fBackgroundLoadInProgress;
	uint8_t		fReadOnlyZone;

	uint32_t	dwLastXfrAttempt;
	uint32_t	dwLastXfrResult;
};


struct dnsserver_zone {
	struct dnsserver_zone *prev, *next;
	const char *name;
	struct ldb_dn *partition_dn;
	struct ldb_dn *zone_dn;
	struct dnsserver_zoneinfo *zoneinfo;
};


struct dns_tree {
	const char *name;
	int level;
	unsigned int num_children;
	struct dns_tree **children;
	void *data;
};

/* Data structure manipulation functions from dnsdata.c */

struct IP4_ARRAY *ip4_array_copy(TALLOC_CTX *mem_ctx, struct IP4_ARRAY *ip4);
struct DNS_ADDR_ARRAY *ip4_array_to_dns_addr_array(TALLOC_CTX *mem_ctx, struct IP4_ARRAY *ip4);
struct DNS_ADDR_ARRAY *dns_addr_array_copy(TALLOC_CTX *mem_ctx, struct DNS_ADDR_ARRAY *addr);

int dns_split_name_components(TALLOC_CTX *mem_ctx, const char *name, char ***components);
char *dns_split_node_name(TALLOC_CTX *mem_ctx, const char *node_name, const char *zone_name);

int dns_name_compare(const struct ldb_message **m1, const struct ldb_message **m2,
			char *search_name);
bool dns_name_equal(const char *name1, const char *name2);
bool dns_record_match(struct dnsp_DnssrvRpcRecord *rec1, struct dnsp_DnssrvRpcRecord *rec2);

void dnsp_to_dns_copy(TALLOC_CTX *mem_ctx, struct dnsp_DnssrvRpcRecord *dnsp,
			struct DNS_RPC_RECORD *dns);
struct dnsp_DnssrvRpcRecord *dns_to_dnsp_copy(TALLOC_CTX *mem_ctx, struct DNS_RPC_RECORD *dns);

struct dns_tree *dns_build_tree(TALLOC_CTX *mem_ctx, const char *name, struct ldb_result *res);
WERROR dns_fill_records_array(TALLOC_CTX *mem_ctx, struct dnsserver_zone *z,
			enum dns_record_type record_type,
			unsigned int select_flag, const char *zone_name,
			struct ldb_message *msg, int num_children,
			struct DNS_RPC_RECORDS_ARRAY *recs,
			char ***add_names, int *add_count);


/* Utility functions from dnsutils.c */

struct dnsserver_serverinfo *dnsserver_init_serverinfo(TALLOC_CTX *mem_ctx,
					struct loadparm_context *lp_ctx,
					struct ldb_context *samdb);
struct dnsserver_zoneinfo *dnsserver_init_zoneinfo(struct dnsserver_zone *zone,
					struct dnsserver_serverinfo *serverinfo,
					bool is_forest);
struct dnsserver_zone *dnsserver_find_zone(struct dnsserver_zone *zones,
					const char *zone_name);
struct ldb_dn *dnsserver_name_to_dn(TALLOC_CTX *mem_ctx, struct dnsserver_zone *z,
					const char *name);
uint32_t dnsserver_zone_to_request_filter(const char *zone);


/* Database functions from dnsdb.c */

struct dnsserver_zone *dnsserver_db_enumerate_zones(TALLOC_CTX *mem_ctx,
					struct ldb_context *samdb,
					bool is_forest);
WERROR dnsserver_db_add_empty_node(TALLOC_CTX *mem_ctx,
					struct ldb_context *samdb,
					struct dnsserver_zone *z,
					const char *node_name);
WERROR dnsserver_db_add_record(TALLOC_CTX *mem_ctx,
					struct ldb_context *samdb,
					struct dnsserver_zone *z,
					const char *node_name,
					struct DNS_RPC_RECORD *add_record);
WERROR dnsserver_db_update_record(TALLOC_CTX *mem_ctx,
					struct ldb_context *samdb,
					struct dnsserver_zone *z,
					const char *node_name,
					struct DNS_RPC_RECORD *add_record,
					struct DNS_RPC_RECORD *del_record);
WERROR dnsserver_db_delete_record(TALLOC_CTX *mem_ctx,
					struct ldb_context *samdb,
					struct dnsserver_zone *z,
					const char *node_name,
					struct DNS_RPC_RECORD *del_record);

#endif /* __DNSSERVER_H__ */