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.

230 lines
7.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: dnr.h
  6. //
  7. // Contents: Definitions for distributed name resolution context
  8. //
  9. // History: 26 May 1992 Alanw Created
  10. // 04 Sep 1992 Milans Added support for replica selection
  11. //
  12. //--------------------------------------------------------------------------
  13. #include "rpselect.h"
  14. //
  15. // Maximum number of times we'll go around the main loop in DnrResolveName.
  16. //
  17. #define MAX_DNR_ATTEMPTS 16
  18. // The following define a Name resolution context which describes the
  19. // state of an ongoing name resolution. A pointer to this context is
  20. // used as the argument to a DPC which will initiate the next step of
  21. // name resolution.
  22. typedef enum {
  23. DnrStateEnter = 0,
  24. DnrStateStart, // Start or restart nameres process
  25. DnrStateGetFirstDC, // contact a dc, so that we can...
  26. DnrStateGetReferrals, // ask knowledge server for referral
  27. DnrStateGetNextDC,
  28. DnrStateCompleteReferral, // waiting for I/O completion of referral req.
  29. DnrStateSendRequest, // requesting Open, ResolveName, etc.
  30. DnrStatePostProcessOpen, // resume Dnr after call to provider
  31. DnrStateGetFirstReplica, // select the first server.
  32. DnrStateGetNextReplica, // a server failed, select another
  33. DnrStateSvcListCheck, // exhausted svc list, see if svc list changed
  34. DnrStateDone, // done, complete the IRP
  35. DnrStateLocalCompletion = 101 // like done, small optimization
  36. } DNR_STATE;
  37. typedef struct _DNR_CONTEXT {
  38. //
  39. // The type and size of this record (must be DSFS_NTC_DNR_CONTEXT)
  40. //
  41. NODE_TYPE_CODE NodeTypeCode;
  42. NODE_BYTE_SIZE NodeByteSize;
  43. DNR_STATE State; // State of name resolution
  44. SECURITY_CLIENT_CONTEXT SecurityContext; // Security context of caller.
  45. PDFS_PKT_ENTRY pPktEntry; // pointer to locked PKT entry
  46. ULONG USN; // USN of pPktEntry when we cached it
  47. PDFS_SERVICE pService; // pointer to file service being used
  48. PPROVIDER_DEF pProvider; // Same as pService->pProvider
  49. //
  50. // The Provider Defs are protected by DfsData.Resource. We don't want
  51. // to hold this (or any other) resource when going over the net. So, we
  52. // cache that part of the provider def that we need to use upon returning
  53. // from the network call.
  54. //
  55. USHORT ProviderId;
  56. PDEVICE_OBJECT TargetDevice;
  57. //
  58. // Since we don't want to hold any locks while going over the net,
  59. // we need to reference the authenticated tree connection to the server
  60. // we will send the open request to.
  61. //
  62. PFILE_OBJECT AuthConn;
  63. // The pService field is protected by Pkt.Resource. Again, we don't want
  64. // to hold this resource when going over the net. However, we need to
  65. // use pService->ConnFile to send a referral request. So, we reference
  66. // and cache the pService->ConnFile in the DnrContext, release the Pkt,
  67. // then send the referral request over the cached DCConnFile.
  68. //
  69. PFILE_OBJECT DCConnFile;
  70. PDFS_CREDENTIALS Credentials; // Credentials to use during Dnr
  71. PIRP_CONTEXT pIrpContext; // associated IRP context
  72. PIRP OriginalIrp; // original IRP we started with
  73. NTSTATUS FinalStatus; // status to complete IRP with
  74. PDFS_FCB FcbToUse; // If DNR succeeds, FCB to use.
  75. PDFS_VCB Vcb; // associated DFS_VCB
  76. // The DFS_NAME_CONTEXT instance is required to be passed down to all
  77. // the underlying providers. The FileName is the first field in the
  78. // DFS_NAME_CONTEXT as well.
  79. // This overlaying facilitates the manipulation of DFS_NAME_CONTEXT
  80. UNICODE_STRING FileName; // file name being processed
  81. union {
  82. UNICODE_STRING ContextFileName; // file name being processed
  83. DFS_NAME_CONTEXT DfsNameContext; // the Dfs name context to be passed down
  84. };
  85. UNICODE_STRING RemainingPart; // remaining part of file name
  86. UNICODE_STRING SavedFileName; // The one that came with the file
  87. PFILE_OBJECT SavedRelatedFileObject; // object.
  88. USHORT NewNameLen; // Length of translated name.
  89. REPL_SELECT_CONTEXT RSelectContext; // Context for replica selection
  90. REPL_SELECT_CONTEXT RDCSelectContext; // Context for DC replica selection
  91. ULONG ReferralSize; // size of buffer needed for referral
  92. unsigned int Attempts; // number of name resolution attempts
  93. BOOLEAN ReleasePkt; // if TRUE, Pkt resource must be freed
  94. BOOLEAN DnrActive; // if TRUE, DnrNameResolve active on this context
  95. BOOLEAN GotReferral; // if TRUE, last action was a referral
  96. BOOLEAN FoundInconsistency; // if TRUE, last referral involved
  97. // inconsistencies in it.
  98. BOOLEAN CalledDCLocator;// if TRUE, we have already called locator
  99. BOOLEAN Impersonate; // if TRUE, we need to impersonate using SecurityToken
  100. BOOLEAN NameAllocated; // if TRUE, FileName.Buffer was allocated separately
  101. BOOLEAN GotReparse; // if TRUE, the a non-mup redir returned STATUS_REPARSE
  102. BOOLEAN CachedConnFile; // if TRUE, the connfile connection was a cached one
  103. PDEVICE_OBJECT DeviceObject;
  104. LARGE_INTEGER StartTime;
  105. PDFS_TARGET_INFO pDfsTargetInfo;
  106. PDFS_TARGET_INFO pNewTargetInfo;
  107. } DNR_CONTEXT, *PDNR_CONTEXT;
  108. //
  109. // The initial length of a referral requested over the network.
  110. //
  111. #define MAX_REFERRAL_LENGTH PAGE_SIZE
  112. //
  113. // The max length we'll go for a referral
  114. //
  115. #define MAX_REFERRAL_MAX (0xe000)
  116. typedef struct DFS_OFFLINE_SERVER {
  117. UNICODE_STRING LogicalServerName;
  118. LIST_ENTRY ListEntry;
  119. } DFS_OFFLINE_SERVER, *PDFS_OFFLINE_SERVER;
  120. extern BOOLEAN MupUseNullSessionForDfs;
  121. //
  122. // Prototypes for functions in dnr.c
  123. //
  124. NTSTATUS
  125. DnrStartNameResolution(
  126. IN PIRP_CONTEXT IrpContext,
  127. IN PIRP Irp,
  128. IN PDFS_VCB Vcb
  129. );
  130. NTSTATUS
  131. DnrNameResolve(
  132. IN PDNR_CONTEXT DnrContext
  133. );
  134. VOID
  135. DnrComposeFileName(
  136. OUT PUNICODE_STRING FullName,
  137. IN PDFS_VCB Vcb,
  138. IN PFILE_OBJECT RelatedFile,
  139. IN PUNICODE_STRING FileName
  140. );
  141. NTSTATUS
  142. DfsCreateConnection(
  143. IN PDFS_SERVICE pService,
  144. IN PPROVIDER_DEF pProvider,
  145. IN BOOLEAN CSCAgentCreate,
  146. OUT PHANDLE handle
  147. );
  148. NTSTATUS
  149. DfsCloseConnection(
  150. IN PDFS_SERVICE pService
  151. );
  152. BOOLEAN
  153. DnrConcatenateFilePath (
  154. IN PUNICODE_STRING Dest,
  155. IN PWSTR RemainingPath,
  156. IN USHORT Length
  157. );
  158. PIRP
  159. DnrBuildFsControlRequest (
  160. IN PFILE_OBJECT FileObject OPTIONAL,
  161. IN PVOID Context,
  162. IN ULONG IoControlCode,
  163. IN PVOID MainBuffer,
  164. IN ULONG InputBufferLength,
  165. IN PVOID AuxiliaryBuffer OPTIONAL,
  166. IN ULONG OutputBufferLength,
  167. IN PIO_COMPLETION_ROUTINE CompletionRoutine
  168. );
  169. NTSTATUS
  170. DfspIsRootOnline(
  171. PUNICODE_STRING Name,
  172. BOOLEAN CSCAgentCreate
  173. );
  174. NTSTATUS
  175. DfspMarkServerOffline(
  176. PUNICODE_STRING ServerName
  177. );
  178. NTSTATUS
  179. DfspMarkServerOnline(
  180. PUNICODE_STRING ServerName
  181. );
  182. PLIST_ENTRY
  183. DfspGetOfflineEntry(
  184. PUNICODE_STRING ServerName
  185. );