Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

356 lines
9.5 KiB

  1. #ifndef __DFS_INIT__
  2. #define __DFS_INIT__
  3. #include "DfsServerLibrary.hxx"
  4. #include "dfsstrings.hxx"
  5. class DfsFolderReferralData;
  6. class DfsReferralData;
  7. class DfsServerSiteInfo;
  8. class DfsStore;
  9. class DfsSiteSupport;
  10. class DfsRegistryStore;
  11. class DfsADBlobStore;
  12. class DfsEnterpriseStore;
  13. class DfsDomainInformation;
  14. class DfsSiteNameCache;
  15. class DfsSiteNameSupport;
  16. class DfsSite;
  17. class DfsISTGHandleSupport;
  18. #define DFS_DS_ACTIVE 1
  19. #define DFS_DS_NOTACTIVE 0
  20. #define DFS_CRIT_SPIN_COUNT 4000
  21. #define CheckDfsMigrate() (DfsServerGlobalData.Flags & DFS_MIGRATE)
  22. #define CheckLocalNamespace() (DfsServerGlobalData.Flags & DFS_LOCAL_NAMESPACE)
  23. #define DfsCheckCreateDirectories() ((DfsServerGlobalData.Flags & DFS_CREATE_DIRECTORIES) == DFS_CREATE_DIRECTORIES)
  24. #define DfsCheckDirectMode() (DfsServerGlobalData.Flags & DFS_DIRECT_MODE)
  25. #define DfsCheckSubstitutePaths() ((DfsServerGlobalData.Flags & DFS_DONT_SUBSTITUTE_PATHS) == 0)
  26. #define DfsCheckInsiteEnabled() (DfsServerGlobalData.Flags & DFS_INSITE_REFERRALS)
  27. #define DfsCheckSiteCostingEnabled() (DfsServerGlobalData.Flags & DFS_SITE_COSTED_REFERRALS)
  28. #define DfsStartupProcessingDone() (DfsServerGlobalData.IsStartupProcessingDone == TRUE)
  29. #define DFS_SKIP_DC_NAME 0x0001
  30. #define DFS_FORCE_DC_QUERY 0x0008
  31. #define REG_KEY_DFSSVC L"SYSTEM\\CurrentControlSet\\Services\\Dfs"
  32. #define REG_VALUE_DFSDNSCONFIG L"DfsDnsConfig"
  33. #define MAX_DFS_NAMESPACES 256
  34. typedef struct _DFS_MACHINE_INFORMATION {
  35. LPWSTR StaticComputerNameNetBIOS;
  36. LPWSTR StaticComputerNameDnsFullyQualified;
  37. LPWSTR StaticComputerNameDnsDomain;
  38. }DFS_MACHINE_INFORMATION;
  39. typedef struct _DFS_SERVER_GLOBAL_DATA {
  40. ULONG Flags;
  41. DWORD ServiceState;
  42. BOOLEAN IsWorkGroup;
  43. BOOLEAN IsStartupProcessingDone;
  44. BOOLEAN bDfsAdAlive;
  45. BOOLEAN bIsShuttingDown;
  46. CRITICAL_SECTION DataLock;
  47. DfsStore *pRegisteredStores;
  48. LPWSTR HandledNamespace[MAX_DFS_NAMESPACES];
  49. ULONG NumberOfNamespaces;
  50. DfsFolderReferralData *LoadedList;
  51. //
  52. // Three global caches to support site awareness.
  53. // They map ServerName->DfsSite, Ip->DfsSite
  54. // and SiteName->DfsSite, respectively.
  55. //
  56. DfsSiteSupport *pServerSiteSupport;
  57. DfsSiteNameCache *pClientSiteSupport;
  58. DfsSiteNameSupport *pSiteNameSupport;
  59. // Default DfsSite with a null sitename for site initialization.
  60. DfsSite *pDefaultSite;
  61. DfsRegistryStore *pDfsRegistryStore;
  62. DfsADBlobStore *pDfsADBlobStore;
  63. DfsEnterpriseStore *pDfsEnterpriseStore;
  64. DFS_MACHINE_INFORMATION DfsMachineInfo;
  65. ULONG CacheFlushInterval;
  66. DWORD DfsDnsConfig;
  67. DWORD SiteSupportRefreshInterval;
  68. DWORD DomainNameRefreshInterval;
  69. DWORD SiteSupportThreadInterval;
  70. DWORD SiteIpCacheTrimValue;
  71. DWORD QuerySiteCostTimeoutInSeconds;
  72. DWORD RootReferralRefreshInterval;
  73. DWORD RetryFailedReferralLoadInterval;
  74. DWORD NumWorkerThreads;
  75. LONG NumClientSiteEntriesAllowed;
  76. DWORD LdapTimeOut;
  77. LONG AllowedErrors;
  78. LONG DsActive;
  79. LONG FirstContact;
  80. BOOLEAN IsCluster;
  81. BOOLEAN bLimitRoots;
  82. BOOLEAN IsDc;
  83. BOOLEAN DisableSiteAwareness;
  84. HANDLE SiteSupportThreadHandle;
  85. HANDLE ShutdownHandle;
  86. HANDLE RegNotificationHandle;
  87. DfsDomainInformation *pDomainInfo;
  88. UNICODE_STRING DomainNameFlat;
  89. UNICODE_STRING DomainNameDns;
  90. UNICODE_STRING DfsAdNameContext;
  91. DfsString PDCName;
  92. ULONG PDCTimeStamp;
  93. DFSSTATUS PDCStatus;
  94. struct _DFS_PREFIX_TABLE *pDirectoryPrefixTable; // The directory namespace prefix table.
  95. struct _DFS_PREFIX_TABLE *pRootReferralTable;
  96. //
  97. // Support for Site Cost calculations
  98. //
  99. DfsISTGHandleSupport *pISTGHandleSupport;
  100. LIST_ENTRY SiteCostTableMruList;
  101. ULONG NumSiteCostTables;
  102. ULONG NumSiteCostTablesOnMruList;
  103. //
  104. // List of volumes that have dfs reparse points in them.
  105. // DFS_REPARSE_VOLUME_INFO is the host struct.
  106. //
  107. LIST_ENTRY ReparseVolumeList;
  108. // The following are primarily for debugging purposes.
  109. // Perhaps Statistics is where they belong.
  110. LONG NumDfsSites;
  111. LONG NumClientDfsSiteEntries;
  112. LONG NumServerDfsSiteEntries;
  113. LONG NumDfsSitesInCache;
  114. } DFS_SERVER_GLOBAL_DATA, *PDFS_SERVER_GLOBAL_DATA;
  115. extern DFS_SERVER_GLOBAL_DATA DfsServerGlobalData;
  116. #define DfsLimitRoots() (DfsServerGlobalData.bLimitRoots)
  117. #define DfsIsMachineDC() (DfsServerGlobalData.IsDc)
  118. #define DfsIsMachineCluster() (DfsServerGlobalData.IsCluster)
  119. #define DfsIsMachineWorkstation()(DfsServerGlobalData.IsWorkGroup)
  120. #define QueryCurrentServiceState() (DfsServerGlobalData.ServiceState)
  121. // decouple ServiceState from the Termination Boolean.
  122. // ServerLibrary functions technically have no knowledge of the 'ServiceState' of
  123. // the DfsSvc. It only knows whether it should stop or not.
  124. #define DfsIsShuttingDown() (DfsServerGlobalData.bIsShuttingDown == TRUE)
  125. #define DfsPostEventLog() ((DfsServerGlobalData.Flags & DFS_POST_EVENT_LOG) == DFS_POST_EVENT_LOG)
  126. LPWSTR
  127. DfsGetDfsAdNameContextString();
  128. DFSSTATUS
  129. DfsSetDomainNameFlat(LPWSTR DomainNameFlatString);
  130. DFSSTATUS
  131. DfsSetDomainNameDns( LPWSTR DomainNameDnsString );
  132. DFSSTATUS
  133. DfsAcquireReadLock(
  134. PCRITICAL_SECTION pLock);
  135. DFSSTATUS
  136. DfsAcquireWriteLock(
  137. PCRITICAL_SECTION pLock);
  138. #define DfsAcquireGlobalDataLock() DfsAcquireLock( &DfsServerGlobalData.DataLock )
  139. #define DfsReleaseGlobalDataLock() DfsReleaseLock( &DfsServerGlobalData.DataLock )
  140. #define DfsReleaseLock(_x) LeaveCriticalSection(_x)
  141. #define DfsAcquireLock(_x) DfsAcquireWriteLock(_x)
  142. #define CACHE_FLUSH_INTERVAL 60 * 60 * 1000
  143. #define CACHE_FLUSH_MIN_INTERVAL 15 * 60 * 1000
  144. #define MIN_SITE_REFRESH_INTERVAL 5 * 60 * 1000
  145. #define MIN_DOMAIN_REFRESH_INTERVAL 10 * 60 * 1000
  146. #define SITE_REFRESH_INTERVAL 720 * 60 * 1000
  147. #define SITE_THREAD_INTERVAL_DIFF 2 * 60 * 1000
  148. #define SITE_IPCACHE_TRIM_VALUE 30
  149. #define DFS_MAX_ROOT_ERRORS 1000
  150. #define DFS_LDAP_TIMEOUT 30 * 60
  151. #define DFS_INITIAL_CLIENTS_SITES 200000
  152. #define DFS_MINIMUM_CLIENTS_SITES 20000
  153. #define ROOTREF_REFRESH_INTERVAL 15 * 60 * 1000
  154. //
  155. // Thirty second default timeout for the DsQuerySiteCost api.
  156. // Minimum is 3 seconds and max is 5 minutes.
  157. //
  158. #define DFS_QUERY_SITE_COST_TIMEOUT 30
  159. #define DFS_MIN_QUERY_SITE_COST_TIMEOUT 3
  160. #define DFS_MAX_QUERY_SITE_COST_TIMEOUT (60 * 5)
  161. #define DFS_DEFAULT_WORKER_THREADS 4
  162. #define DFS_MIN_WORKER_THREADS 2
  163. #define DFS_MAX_WORKER_THREADS 20
  164. #define SCAVENGE_TIME DfsServerGlobalData.CacheFlushInterval
  165. #define ACQUIRE_LOADED_LIST_LOCK()\
  166. EnterCriticalSection(&DfsServerGlobalData.DataLock);
  167. #define RELEASE_LOADED_LIST_LOCK()\
  168. LeaveCriticalSection(&DfsServerGlobalData.DataLock);
  169. extern LPWSTR DfsRegistryHostLocation;
  170. extern LPWSTR DfsOldRegistryLocation;
  171. extern LPWSTR DfsOldStandaloneChild;
  172. extern LPWSTR DfsRegistryDfsLocation;
  173. extern LPWSTR DfsNewRegistryLocation;
  174. extern LPWSTR DfsStandaloneChild;
  175. extern LPWSTR DfsADBlobChild;
  176. extern LPWSTR DfsEnterpriseChild;
  177. extern LPWSTR DfsRootShareValueName;
  178. extern LPWSTR DfsMigratedValueName;
  179. extern LPWSTR DfsLogicalShareValueName;
  180. extern LPWSTR DfsFtDfsValueName;
  181. extern LPWSTR DfsFtDfsConfigDNValueName;
  182. VOID
  183. DfsAddReferralDataToLoadedList(
  184. DfsFolderReferralData *pRefData );
  185. VOID
  186. DfsGetAgedReferralList(
  187. DfsFolderReferralData **ppReferralData );
  188. DFSSTATUS
  189. DfsGetServerInfo (
  190. PUNICODE_STRING pServer,
  191. DfsServerSiteInfo **ppInfo,
  192. BOOLEAN * CacheHit,
  193. BOOLEAN SyncThread = FALSE );
  194. DFSSTATUS
  195. DfsReleaseServerInfo (
  196. DfsServerSiteInfo *pInfo);
  197. DFSSTATUS
  198. DfsGetMachineName(
  199. PUNICODE_STRING pName);
  200. VOID
  201. DfsReleaseMachineName(
  202. PUNICODE_STRING pName );
  203. DFSSTATUS
  204. DfsGetDomainName(
  205. PUNICODE_STRING pName);
  206. DFSSTATUS
  207. DfsGetDnsDomainName(
  208. PUNICODE_STRING pName);
  209. VOID
  210. DfsReleaseDomainName(
  211. PUNICODE_STRING pName );
  212. DFSSTATUS
  213. DfsAddHandledNamespace(
  214. LPWSTR Name,
  215. BOOLEAN Migrate );
  216. DFSSTATUS
  217. DfsInitializeComputerInfo();
  218. DFSSTATUS
  219. DfsGetRegistryStore(
  220. DfsRegistryStore **ppStore );
  221. DFSSTATUS
  222. DfsGetADBlobStore(
  223. DfsADBlobStore **ppStore );
  224. DFSSTATUS
  225. DfsAddKnownDirectoryPath(
  226. PUNICODE_STRING pDirectoryName,
  227. PUNICODE_STRING pLogicalShare );
  228. DFSSTATUS
  229. DfsRemoveKnownDirectoryPath(
  230. PUNICODE_STRING pDirectoryName,
  231. PUNICODE_STRING pLogicalShare );
  232. VOID
  233. DfsReleaseDomainInfo (
  234. DfsDomainInformation *pDomainInfo );
  235. DFSSTATUS
  236. DfsAcquireDomainInfo (
  237. DfsDomainInformation **ppDomainInfo );
  238. VOID
  239. DfsSetGlobalDomainInfo(
  240. DfsDomainInformation *pDomainInfo);
  241. BOOLEAN
  242. DfsIsNameContextDomainName( PUNICODE_STRING pName );
  243. DFSSTATUS DfsGetBlobPDCName( DfsString **ppPDCName, ULONG Flags, LPWSTR DomainName=NULL );
  244. DFSSTATUS DfsSetBlobPDCName( LPWSTR DcName, DfsString **ppPDCName);
  245. VOID DfsReleaseBlobPDCName( DfsString *pPDCName);
  246. DfsSite *
  247. DfsGetDefaultSite( VOID );
  248. BOOLEAN
  249. DfsIsTargetCurrentMachine (PUNICODE_STRING pServer );
  250. DFSSTATUS
  251. DfsRecognize(
  252. LPWSTR Name,
  253. PUNICODE_STRING pLogicalShare);
  254. DFSSTATUS
  255. DfsGetADRootReferralData(
  256. PUNICODE_STRING pRootName,
  257. DfsReferralData **ppReferralData );
  258. DFSSTATUS
  259. DfsCheckServerRootHandlingCapability();
  260. #define DfsGetTimeStamp(_x) (*_x) = GetTickCount()
  261. #endif __DFS_INIT__