From 8df2ed42cc4662bd385ea34169ebd3bcd4d8bc17 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 27 Sep 2011 16:53:45 +1000 Subject: s4-dns: Added DCERPC dns server for DNS management dnsserver.h - typedefs and prototypes dnsserver.c - RPC API and implementation methods dnsdb.c - samdb operations dnsdata.c - functions to manipulate dns structures dnsutils.c - function for serverinfo and zoneinfo structures Signed-off-by: Andrew Tridgell --- source4/rpc_server/dnsserver/dnsserver.h | 220 +++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 source4/rpc_server/dnsserver/dnsserver.h (limited to 'source4/rpc_server/dnsserver/dnsserver.h') diff --git a/source4/rpc_server/dnsserver/dnsserver.h b/source4/rpc_server/dnsserver/dnsserver.h new file mode 100644 index 0000000000..5fc13c8704 --- /dev/null +++ b/source4/rpc_server/dnsserver/dnsserver.h @@ -0,0 +1,220 @@ +/* + 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 . +*/ + +#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; +}; + + +/* 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); + +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, 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__ */ -- cgit