Source code of Windows XP (NT5)
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.

1588 lines
54 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: PKT.H
  6. //
  7. // Contents: This module defines the data structures that make up the
  8. // major internal part of the Partition Knowledge Table (PKT).
  9. // The Partition Knowledge Table is used by the Dfs file
  10. // system to resolve a name to a specific partition (volume).
  11. //
  12. // Functions:
  13. //
  14. // History: 1 May 1992 PeterCo Created.
  15. //-----------------------------------------------------------------------------
  16. #ifndef _PKT_
  17. #define _PKT_
  18. //
  19. // Pick up marshalling info for gluons
  20. //
  21. #include "dfsgluon.h"
  22. //
  23. // New Prefix Table Implementation
  24. //
  25. #include "prefix.h"
  26. //
  27. // For determining the status of the Uid
  28. //
  29. #define GuidEqual(g1, g2)\
  30. (RtlCompareMemory((g1), (g2), sizeof(GUID)) == sizeof(GUID))
  31. extern GUID _TheNullGuid;
  32. #define NullGuid( guid )\
  33. (GuidEqual(guid, &_TheNullGuid))
  34. #define DEFAULT_PKT_ENTRY_TIMEOUT 300
  35. //
  36. // Defines for Create Dispositions (we mimic the io system here).
  37. //
  38. #define PKT_ENTRY_CREATE FILE_CREATE
  39. #define PKT_ENTRY_REPLACE FILE_OPEN
  40. #define PKT_ENTRY_SUPERSEDE FILE_SUPERSEDE
  41. //
  42. // Different kind of referrals that a DC can give out.
  43. //
  44. #define DFS_STORAGE_REFERRAL (0x0001)
  45. #define DFS_REFERRAL_REFERRAL (0x0002)
  46. //
  47. // Types of service that can be supported by a provider.
  48. // A disjunction of any of the following values.
  49. //
  50. #define DFS_SERVICE_TYPE_MASTER (0x0001)
  51. #define DFS_SERVICE_TYPE_READONLY (0x0002)
  52. #define DFS_SERVICE_TYPE_LOCAL (0x0004)
  53. #define DFS_SERVICE_TYPE_REFERRAL (0x0008)
  54. #define DFS_SERVICE_TYPE_ACTIVE (0x0010)
  55. #define DFS_SERVICE_TYPE_DOWN_LEVEL (0x0020)
  56. #define DFS_SERVICE_TYPE_COSTLIER (0x0040)
  57. #define DFS_SERVICE_TYPE_OFFLINE (0x0080)
  58. //
  59. // The status possibilities...
  60. //
  61. #define DFS_SERVICE_STATUS_VERIFIED (0x0001)
  62. #define DFS_SERVICE_STATUS_UNVERIFIED (0x0002)
  63. //
  64. // Types of Partition Knowledge Table Entries.
  65. // Low-order bits in these definitions correspond to volume object
  66. // types as defined in dfsh.idl. High-order bits are specific
  67. // to PKT entries.
  68. //
  69. #define PKT_ENTRY_TYPE_CAIRO 0x0001 // Entry refers to Cairo srv
  70. #define PKT_ENTRY_TYPE_MACHINE 0x0002 // Entry is a machine volume
  71. #define PKT_ENTRY_TYPE_NONCAIRO 0x0004 // Entry refers to downlevel
  72. #define PKT_ENTRY_TYPE_LEAFONLY 0x0008
  73. #define PKT_ENTRY_TYPE_OUTSIDE_MY_DOM 0x0010 // Entry refers to volume in
  74. // foreign domain
  75. #define PKT_ENTRY_TYPE_INSITE_ONLY 0x0020 // Only give insite referrals.
  76. #define PKT_ENTRY_TYPE_REFERRAL_SVC 0x0080 // Entry refers to a DC
  77. #define PKT_ENTRY_TYPE_PERMANENT 0x0100 // Entry cannot be scavenged
  78. #define PKT_ENTRY_TYPE_LOCAL 0x0400 // Entry refers to local vol
  79. #define PKT_ENTRY_TYPE_LOCAL_XPOINT 0x0800 // Entry refers to exit pt
  80. #define PKT_ENTRY_TYPE_MACH_SHARE 0x1000 // Entry refers to a private
  81. // machine share
  82. #define PKT_ENTRY_TYPE_OFFLINE 0x2000 // Entry refers to a volume
  83. // that is offline
  84. #define PKT_ENTRY_TYPE_STALE 0x4000 // Entry is stale
  85. #define PKT_ENTRY_TYPE_INHERIT_MASK PKT_ENTRY_TYPE_INSITE_ONLY
  86. //
  87. // Type of messages the driver can send to DfsManager / DfsService
  88. //
  89. #define DFS_MSGTYPE_KNOW_INCONSISTENCY 0x0001
  90. #define DFS_MSGTYPE_GET_DOMAIN_REFERRAL 0x0002
  91. #if (DBG == 1) || (_CT_TEST_HOOK == 1)
  92. #define DFS_MSGTYPE_SET_RECOVERY_BREAK_POINT 0x0003
  93. #endif
  94. //
  95. // There is one DFS_MACHINE_ENTRY for every unique DS_MACHINE that the
  96. // Dfs driver knows about. If a particular cairo server services multiple Dfs
  97. // volumes, then multiple DFS_SERVICE structs will point to a single, ref
  98. // counted DFS_MACHINE_ENTRY.
  99. //
  100. typedef struct DFS_MACHINE_ENTRY {
  101. PDS_MACHINE pMachine; // The addressing info is here.
  102. UNICODE_STRING MachineName; // The MachineName (principalName).
  103. ULONG UseCount; // Number of DFS_SVC structs using this
  104. ULONG ConnectionCount;// The number of pkt entries that are
  105. // using this as their active machine
  106. UNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry;
  107. } DFS_MACHINE_ENTRY, *PDFS_MACHINE_ENTRY;
  108. //
  109. // Marshalling info for DFS_MACHINE_ENTRY
  110. //
  111. extern MARSHAL_INFO MiMachineEntry;
  112. #define INIT_DFS_MACHINE_ENTRY_MARSHAL_INFO() \
  113. static MARSHAL_TYPE_INFO _MCode_Machine_Entry[] = { \
  114. _MCode_pstruct(DFS_MACHINE_ENTRY, pMachine, &MiDSMachine) \
  115. }; \
  116. MARSHAL_INFO MiMachineEntry = _mkMarshalInfo(DFS_SERVICE, _MCode_Machine_Entry);
  117. //
  118. // A DFS_SERVICE structure is used to describe the provider and
  119. // network address to be contacted for a specific partition of
  120. // the distributed file system.
  121. //
  122. typedef struct _DFS_SERVICE {
  123. ULONG Type; // type of service (see above)
  124. ULONG Capability; // capability of this service
  125. ULONG Status; // current status
  126. ULONG ProviderId; // identifies which provider
  127. UNICODE_STRING Name; // service name (for authentication)
  128. PFILE_OBJECT ConnFile; // pointer to tree conn. file if active connection
  129. struct _PROVIDER_DEF* pProvider; // pointer to provider definition
  130. UNICODE_STRING Address; // network address
  131. UNICODE_STRING StgId; // The local storage id on the server.
  132. PDFS_MACHINE_ENTRY pMachEntry; // The addressing info is here.
  133. ULONG Cost; // The site based cost of this service.
  134. } DFS_SERVICE, *PDFS_SERVICE;
  135. //
  136. // Marshalling information for DFS_SERVICE
  137. //
  138. // NOTE: ConnFile and pProvider have significance only to the driver and
  139. // are not marshalled.
  140. //
  141. extern MARSHAL_INFO MiService;
  142. #define INIT_DFS_SERVICE_MARSHAL_INFO() \
  143. static MARSHAL_TYPE_INFO _MCode_Service[] = { \
  144. _MCode_ul(DFS_SERVICE, Type), \
  145. _MCode_ul(DFS_SERVICE, Capability), \
  146. _MCode_ul(DFS_SERVICE, Status), \
  147. _MCode_ul(DFS_SERVICE, ProviderId), \
  148. _MCode_ustr(DFS_SERVICE, Name), \
  149. _MCode_ustr(DFS_SERVICE, Address), \
  150. _MCode_ustr(DFS_SERVICE, StgId), \
  151. _MCode_pstruct(DFS_SERVICE, pMachEntry, &MiMachineEntry) \
  152. }; \
  153. MARSHAL_INFO MiService = _mkMarshalInfo(DFS_SERVICE, _MCode_Service);
  154. //
  155. // Structure used in FSCTL_DFS_UPDATE_MACH_ADDRESS
  156. //
  157. typedef struct _DFS_MACHINE_INFO {
  158. UNICODE_STRING MachineName; // Name of Machine (prefix alone).
  159. PDS_MACHINE pMachine; // The new addressing info is here
  160. } DFS_MACHINE_INFO, *PDFS_MACHINE_INFO;
  161. //
  162. // Marshalling info for DFS_MACHINE_INFO
  163. //
  164. extern MARSHAL_INFO MiDfsMachineInfo;
  165. #define INIT_DFS_MACHINE_INFO() \
  166. static MARSHAL_TYPE_INFO _MCode_MachineInfo[] = { \
  167. _MCode_ustr(DFS_MACHINE_INFO, MachineName), \
  168. _MCode_pstruct(DFS_MACHINE_INFO, pMachine, &MiDSMachine) \
  169. }; \
  170. MARSHAL_INFO MiDfsMachineInfo = \
  171. _mkMarshalInfo(DFS_MACHINE_INFO, _MCode_MachineInfo);
  172. //
  173. // How a partition table entry is identified.
  174. //
  175. typedef struct _DFS_PKT_ENTRY_ID {
  176. GUID Uid; // a unique identifier for this partition
  177. UNICODE_STRING Prefix; // The entry path prefix of this partition
  178. UNICODE_STRING ShortPrefix; // 8.3 version of entry path
  179. } DFS_PKT_ENTRY_ID, *PDFS_PKT_ENTRY_ID;
  180. //
  181. // Marshalling information for DFS_PKT_ENTRY_ID
  182. //
  183. extern MARSHAL_INFO MiPktEntryId;
  184. #define INIT_DFS_PKT_ENTRY_ID_MARSHAL_INFO() \
  185. static MARSHAL_TYPE_INFO _MCode_PktEntryId[] = { \
  186. _MCode_guid(DFS_PKT_ENTRY_ID, Uid), \
  187. _MCode_ustr(DFS_PKT_ENTRY_ID, Prefix), \
  188. _MCode_ustr(DFS_PKT_ENTRY_ID, ShortPrefix) \
  189. }; \
  190. MARSHAL_INFO MiPktEntryId = \
  191. _mkMarshalInfo(DFS_PKT_ENTRY_ID, _MCode_PktEntryId);
  192. //
  193. // The DfsCreate/DeleteExitPoint FSCTRLs arguments are passed through
  194. // following structure.
  195. //
  196. typedef struct _DFS_EXIT_POINT_ARG {
  197. DFS_PKT_ENTRY_ID Id;
  198. ULONG Type;
  199. } DFS_EXIT_POINT_ARG, *PDFS_EXIT_POINT_ARG;
  200. //
  201. // Marshalling information for DFS_EXIT_POINT_ARG
  202. //
  203. extern MARSHAL_INFO MiExitPointArg;
  204. #define INIT_DFS_EXIT_POINT_ARG_MARSHAL_INFO() \
  205. static MARSHAL_TYPE_INFO _MCode_ExitPointArg[] = { \
  206. _MCode_struct(DFS_EXIT_POINT_ARG, Id, &MiPktEntryId), \
  207. _MCode_ul(DFS_EXIT_POINT_ARG, Type) \
  208. }; \
  209. MARSHAL_INFO MiExitPointArg = \
  210. _mkMarshalInfo(DFS_EXIT_POINT_ARG, _MCode_ExitPointArg);
  211. //
  212. // The DfsSetVolumeState FSCTRLs arguments are passed through the following
  213. // structure
  214. //
  215. typedef DFS_EXIT_POINT_ARG DFS_SETSTATE_ARG;
  216. #define MiSetStateArg MiExitPointArg
  217. //
  218. // The DfsSetVolumeTimeout FSCTRLs arguments are passed through
  219. // following structure.
  220. //
  221. typedef struct _DFS_SET_VOLUME_TIMEOUT_ARG {
  222. DFS_PKT_ENTRY_ID Id;
  223. ULONG Timeout;
  224. } DFS_SET_VOLUME_TIMEOUT_ARG, *PDFS_SET_VOLUME_TIMEOUT_ARG;
  225. //
  226. // Marshalling information for DFS_SET_VOLUME_TIMEOUT_ARG
  227. //
  228. extern MARSHAL_INFO MiSetVolTimeoutArg;
  229. #define INIT_DFS_SET_VOLUME_TIMEOUT_ARG_MARSHAL_INFO() \
  230. static MARSHAL_TYPE_INFO _MCode_SetVolTimeoutArg[] = { \
  231. _MCode_struct(DFS_SET_VOLUME_TIMEOUT_ARG, Id, &MiPktEntryId), \
  232. _MCode_ul(DFS_SET_VOLUME_TIMEOUT_ARG, Timeout) \
  233. }; \
  234. MARSHAL_INFO MiSetVolTimeoutArg = \
  235. _mkMarshalInfo(DFS_SET_VOLUME_TIMEOUT_ARG, _MCode_SetVolTimeoutArg);
  236. //
  237. // The DfsSetServiceState FSCTRLs arguments are passed through the following
  238. // structure
  239. //
  240. typedef struct _DFS_DC_SET_SERVICE_STATE {
  241. DFS_PKT_ENTRY_ID Id;
  242. UNICODE_STRING ServiceName;
  243. ULONG State;
  244. } DFS_DC_SET_SERVICE_STATE, *PDFS_DC_SET_SERVICE_STATE;
  245. //
  246. // Marshalling information for DFS_DC_SET_SERVICE_STATE
  247. //
  248. extern MARSHAL_INFO MiDCSetServiceState;
  249. #define INIT_DFS_DC_SET_SERVICE_STATE_MARSHAL_INFO() \
  250. static MARSHAL_TYPE_INFO _MCode_DfsDCSetServiceState[] = { \
  251. _MCode_struct(DFS_DC_SET_SERVICE_STATE, Id, &MiPktEntryId), \
  252. _MCode_ustr(DFS_DC_SET_SERVICE_STATE, ServiceName), \
  253. _MCode_ul(DFS_DC_SET_SERVICE_STATE, State) \
  254. }; \
  255. MARSHAL_INFO MiDCSetServiceState = \
  256. _mkMarshalInfo(DFS_DC_SET_SERVICE_STATE, _MCode_DfsDCSetServiceState);
  257. //
  258. // The DfsVolumeVerifyArgs are passed through this marshalled structure.
  259. //
  260. typedef struct _DFS_VOLUME_VERIFY_ARG {
  261. DFS_PKT_ENTRY_ID Id;
  262. UNICODE_STRING ServiceName;
  263. } DFS_VOLUME_VERIFY_ARG, *PDFS_VOLUME_VERIFY_ARG;
  264. //
  265. // Marshalling information for DFS_VOLUME_VERIFY_ARG;
  266. //
  267. extern MARSHAL_INFO MiVolumeVerifyArg;
  268. #define INIT_DFS_VOLUME_VERIFY_ARG_MARSHAL_INFO() \
  269. static MARSHAL_TYPE_INFO _MCode_VolumeVerifyArg[] = { \
  270. _MCode_struct(DFS_VOLUME_VERIFY_ARG, Id, &MiPktEntryId), \
  271. _MCode_ustr(DFS_VOLUME_VERIFY_ARG, ServiceName) \
  272. }; \
  273. MARSHAL_INFO MiVolumeVerifyArg = \
  274. _mkMarshalInfo(DFS_VOLUME_VERIFY_ARG, _MCode_VolumeVerifyArg);
  275. //
  276. // The guts of a partition table entry
  277. //
  278. typedef struct _DFS_PKT_ENTRY_INFO {
  279. ULONG Timeout; // this entry's timeout
  280. ULONG ServiceCount; // number of services in list
  281. PDFS_SERVICE ServiceList; // array of servers that support the partition
  282. } DFS_PKT_ENTRY_INFO, *PDFS_PKT_ENTRY_INFO;
  283. //
  284. // Marshalling information for DFS_PKT_ENTRY_INFO
  285. //
  286. extern MARSHAL_INFO MiPktEntryInfo;
  287. #define INIT_DFS_PKT_ENTRY_INFO_MARSHAL_INFO() \
  288. static MARSHAL_TYPE_INFO _MCode_PktEntryInfo[] = { \
  289. _MCode_ul(DFS_PKT_ENTRY_INFO, Timeout), \
  290. _MCode_ul(DFS_PKT_ENTRY_INFO, ServiceCount), \
  291. _MCode_pcastruct(DFS_PKT_ENTRY_INFO,ServiceList,ServiceCount,&MiService)\
  292. }; \
  293. MARSHAL_INFO MiPktEntryInfo = \
  294. _mkMarshalInfo(DFS_PKT_ENTRY_INFO, _MCode_PktEntryInfo);
  295. //
  296. // A Partition Knowledge Table Entry (PktEntry) identifies each known
  297. // partition.
  298. //
  299. typedef struct _DFS_PKT_ENTRY {
  300. NODE_TYPE_CODE NodeTypeCode; // node type -> DSFS_NTC_PKT_ENTRY
  301. NODE_BYTE_SIZE NodeByteSize; // node size
  302. LIST_ENTRY Link; // link for PKT EntryList
  303. ULONG Type; // type of partition (see above)
  304. ULONG USN; // Unique Serial Number
  305. DFS_PKT_ENTRY_ID Id; // the Id of this entry
  306. DFS_PKT_ENTRY_INFO Info; // info of this entry
  307. ULONG ExpireTime; // time when partition should be deleted
  308. ULONG UseCount; // # threads (DnrContexts) are looking at it.
  309. ULONG FileOpenCount; // # of files opened via this entry
  310. PDFS_SERVICE ActiveService; // pointer into info to active service
  311. PDFS_SERVICE LocalService; // pointer to local service (if any)
  312. struct _DFS_PKT_ENTRY *Superior;// this entrys superior (if any)
  313. ULONG SubordinateCount; // number of subordinates (if any)
  314. LIST_ENTRY SubordinateList; // list of subordinates (if any)
  315. LIST_ENTRY SiblingLink; // link to other siblings (if any)
  316. struct _DFS_PKT_ENTRY *ClosestDC; // Link to closest superiorDC in PKT.
  317. LIST_ENTRY ChildList; // Link to subordinate PKT entries (if any)
  318. LIST_ENTRY NextLink; // Link to link up parent's Subord list.
  319. UNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry;// prefix table entry
  320. } DFS_PKT_ENTRY, *PDFS_PKT_ENTRY;
  321. //
  322. // Marshalling information for DFS_PKT_ENTRY
  323. //
  324. // Note that we only marshal the id and the info...no relational info
  325. //
  326. //
  327. extern MARSHAL_INFO MiPktEntry;
  328. #define INIT_DFS_PKT_ENTRY_MARSHAL_INFO() \
  329. static MARSHAL_TYPE_INFO _MCode_PktEntry[] = { \
  330. _MCode_ul(DFS_PKT_ENTRY, Type), \
  331. _MCode_struct(DFS_PKT_ENTRY, Id, &MiPktEntryId), \
  332. _MCode_struct(DFS_PKT_ENTRY, Info, &MiPktEntryInfo) \
  333. }; \
  334. MARSHAL_INFO MiPktEntry = _mkMarshalInfo(DFS_PKT_ENTRY, _MCode_PktEntry);
  335. //
  336. // A Local Volume Entry is a back pointer from the local volume name to
  337. // a pkt entry whose local service == local volume name.
  338. //
  339. typedef struct _DFS_LOCAL_VOL_ENTRY {
  340. PDFS_PKT_ENTRY PktEntry;
  341. UNICODE_STRING LocalPath;
  342. UNICODE_STRING ShareName;
  343. UNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry;
  344. } DFS_LOCAL_VOL_ENTRY, *PDFS_LOCAL_VOL_ENTRY;
  345. //
  346. // A Parition Knowledge Table encapsulates all the knowledge that has
  347. // been obtained about partitions in the distributed file system. There
  348. // is only one instance of this struct in the entire system, and is
  349. // part of the DsData structure.
  350. //
  351. typedef struct _DFS_PKT {
  352. NODE_TYPE_CODE NodeTypeCode; // node type -> DSFS_NTC_PKT
  353. NODE_BYTE_SIZE NodeByteSize; // node size...
  354. ERESOURCE Resource; // resource to guard access to Pkt
  355. KSPIN_LOCK UseCountLock; // Use while changing UseCount
  356. ULONG EntryCount; // number of entries in the PKT
  357. LIST_ENTRY EntryList; // list of entries in the PKT
  358. PDFS_PKT_ENTRY DomainPktEntry; // pointer to domain service.
  359. DFS_PREFIX_TABLE LocalVolTable; // table of local volumes
  360. DFS_PREFIX_TABLE PrefixTable; // prefix table
  361. DFS_PREFIX_TABLE ShortPrefixTable; // prefix table containing 8.3 prefixes
  362. UNICODE_PREFIX_TABLE DSMachineTable;// Table for DSMachines
  363. ULONG DefaultTimeToLive; // Default time to live (in seconds)
  364. ULONG MaxReferrals; // maximum referrals to return.
  365. } DFS_PKT, *PDFS_PKT;
  366. //
  367. // PKT Relational Information structure
  368. //
  369. // This structure incapsulates the relationship between a pkt entry and
  370. // all of its subordinates.
  371. //
  372. typedef struct _DFS_PKT_RELATION_INFO {
  373. DFS_PKT_ENTRY_ID EntryId; // the Id of the parent entry
  374. ULONG SubordinateIdCount; // number of subordinates
  375. PDFS_PKT_ENTRY_ID SubordinateIdList; // list of subordinate Ids
  376. } DFS_PKT_RELATION_INFO, *PDFS_PKT_RELATION_INFO;
  377. //
  378. // Marshalling information for DFS_PKT_RELATION_INFO
  379. //
  380. extern MARSHAL_INFO MiPktRelationInfo;
  381. #define INIT_DFS_PKT_RELATION_INFO_MARSHAL_INFO() \
  382. static MARSHAL_TYPE_INFO _MCode_PktRelationInfo[] = { \
  383. _MCode_struct(DFS_PKT_RELATION_INFO, EntryId, &MiPktEntryId), \
  384. _MCode_ul(DFS_PKT_RELATION_INFO, SubordinateIdCount), \
  385. _MCode_pcastruct(DFS_PKT_RELATION_INFO, SubordinateIdList, \
  386. SubordinateIdCount, &MiPktEntryId) \
  387. }; \
  388. MARSHAL_INFO MiPktRelationInfo = \
  389. _mkMarshalInfo(DFS_PKT_RELATION_INFO, _MCode_PktRelationInfo);
  390. //
  391. // The Local Volume Config structure
  392. //
  393. // Encapsulates a local volume configuration information.
  394. //
  395. typedef struct _DFS_LOCAL_VOLUME_CONFIG {
  396. ULONG EntryType;
  397. ULONG ServiceType;
  398. UNICODE_STRING StgId;
  399. UNICODE_STRING Share;
  400. DFS_PKT_RELATION_INFO RelationInfo;
  401. } DFS_LOCAL_VOLUME_CONFIG, *PDFS_LOCAL_VOLUME_CONFIG;
  402. //
  403. // Marshalling information for DFS_LOCAL_VOLUME_CONFIG
  404. //
  405. extern MARSHAL_INFO MiLocalVolumeConfig;
  406. #define INIT_LOCAL_VOLUME_CONFIG_MARSHAL_INFO() \
  407. static MARSHAL_TYPE_INFO _MCode_LocalVolumeConfig[] = { \
  408. _MCode_ul(DFS_LOCAL_VOLUME_CONFIG, EntryType), \
  409. _MCode_ul(DFS_LOCAL_VOLUME_CONFIG, ServiceType), \
  410. _MCode_struct(DFS_LOCAL_VOLUME_CONFIG, RelationInfo, &MiPktRelationInfo) \
  411. }; \
  412. MARSHAL_INFO MiLocalVolumeConfig = _mkMarshalInfo(DFS_LOCAL_VOLUME_CONFIG, _MCode_LocalVolumeConfig);
  413. //
  414. // The DFS_CHECK_VOLUME_ARG structure encapsulates the arguments to
  415. // CheckRemotePartition call.
  416. //
  417. typedef struct _DFS_CHECK_VOLUME_ARG {
  418. DFS_LOCAL_VOLUME_CONFIG ConfigInfo;
  419. UNICODE_STRING ServiceName;
  420. } DFS_CHECK_VOLUME_ARG, *PDFS_CHECK_VOLUME_ARG;
  421. //
  422. // Marshalling information for DFS_CHECK_VOLUME_ARG.
  423. //
  424. extern MARSHAL_INFO MiCheckVolumeArg;
  425. #define INIT_DFS_CHECK_VOLUME_ARG_MARSHAL_INFO() \
  426. static MARSHAL_TYPE_INFO _MCode_CheckVolumeArg[] = { \
  427. _MCode_struct(DFS_CHECK_VOLUME_ARG, ConfigInfo, &MiLocalVolumeConfig), \
  428. _MCode_ustr(DFS_CHECK_VOLUME_ARG, ServiceName) \
  429. }; \
  430. MARSHAL_INFO MiCheckVolumeArg = \
  431. _mkMarshalInfo(DFS_CHECK_VOLUME_ARG, _MCode_CheckVolumeArg);
  432. //
  433. // The DFS_PKT_CREATE_ENTRY_ARG structure encapsulates the arguments
  434. // to the create entry call.
  435. //
  436. typedef struct _DFS_PKT_CREATE_ENTRY_ARG {
  437. ULONG EntryType;
  438. DFS_PKT_ENTRY_ID EntryId;
  439. DFS_PKT_ENTRY_INFO EntryInfo;
  440. ULONG CreateDisposition;
  441. } DFS_PKT_CREATE_ENTRY_ARG, *PDFS_PKT_CREATE_ENTRY_ARG;
  442. //
  443. // Marshalling information for DFS_PKT_CREATE_ENTRY_ARG
  444. //
  445. extern MARSHAL_INFO MiPktCreateEntryArg;
  446. #define INIT_DFS_PKT_CREATE_ENTRY_ARG_MARSHAL_INFO() \
  447. static MARSHAL_TYPE_INFO _MCode_PktCreateEntryArg[] = { \
  448. _MCode_ul(DFS_PKT_CREATE_ENTRY_ARG, EntryType), \
  449. _MCode_struct(DFS_PKT_CREATE_ENTRY_ARG, EntryId, &MiPktEntryId), \
  450. _MCode_struct(DFS_PKT_CREATE_ENTRY_ARG, EntryInfo, &MiPktEntryInfo),\
  451. _MCode_ul(DFS_PKT_CREATE_ENTRY_ARG, CreateDisposition) \
  452. }; \
  453. MARSHAL_INFO MiPktCreateEntryArg = \
  454. _mkMarshalInfo(DFS_PKT_CREATE_ENTRY_ARG, _MCode_PktCreateEntryArg);
  455. //
  456. // The DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG structure encapsulates the arguments
  457. // to the create entry call.
  458. //
  459. typedef struct _DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG {
  460. DFS_PKT_ENTRY_ID EntryId;
  461. ULONG SubEntryType;
  462. DFS_PKT_ENTRY_ID SubEntryId;
  463. DFS_PKT_ENTRY_INFO SubEntryInfo;
  464. ULONG CreateDisposition;
  465. } DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG, *PDFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG;
  466. //
  467. // Marshalling information for DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG
  468. //
  469. extern MARSHAL_INFO MiPktCreateSubordinateEntryArg;
  470. #define INIT_DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG_MARSHAL_INFO() \
  471. static MARSHAL_TYPE_INFO _MCode_PktCreateSubordinateEntryArg[] = { \
  472. _MCode_struct(DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG, EntryId, \
  473. &MiPktEntryId), \
  474. _MCode_ul(DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG, SubEntryType), \
  475. _MCode_struct(DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG, SubEntryId, \
  476. &MiPktEntryId), \
  477. _MCode_struct(DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG, SubEntryInfo, \
  478. &MiPktEntryInfo), \
  479. _MCode_ul(DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG, CreateDisposition) \
  480. }; \
  481. MARSHAL_INFO MiPktCreateSubordinateEntryArg = \
  482. _mkMarshalInfo(DFS_PKT_CREATE_SUBORDINATE_ENTRY_ARG, \
  483. _MCode_PktCreateSubordinateEntryArg);
  484. //
  485. // The DFS_HANDLE_SERVER_INFO data structure is used to pass back the
  486. // full file name and server DN, and server Machine ID to the caller.
  487. //
  488. typedef struct _DFS_HANDLE_SERVER_INFO {
  489. UNICODE_STRING FullFileName;
  490. UNICODE_STRING ServerDN;
  491. UNICODE_STRING ServerNetBIOSName;
  492. GUID ServerID;
  493. } DFS_HANDLE_SERVER_INFO, *PDFS_HANDLE_SERVER_INFO;
  494. //
  495. // Marshalling info for DFS_HANDLE_SERVER_INFO
  496. //
  497. extern MARSHAL_INFO MiHandleServerInfo;
  498. #define INIT_DFS_HANDLE_SERVER_INFO_MARSHAL_INFO() \
  499. static MARSHAL_TYPE_INFO _MCode_HandleServerInfo[] = { \
  500. _MCode_ustr(DFS_HANDLE_SERVER_INFO, FullFileName), \
  501. _MCode_ustr(DFS_HANDLE_SERVER_INFO, ServerDN), \
  502. _MCode_ustr(DFS_HANDLE_SERVER_INFO, ServerNetBIOSName), \
  503. _MCode_guid(DFS_HANDLE_SERVER_INFO, ServerID) \
  504. }; \
  505. MARSHAL_INFO MiHandleServerInfo = \
  506. _mkMarshalInfo(DFS_HANDLE_SERVER_INFO, _MCode_HandleServerInfo);
  507. #ifndef _UPKT_
  508. //
  509. // PARTITION KNOWLEDGE TABLE PUBLIC INLINE FUNCTIONS
  510. //
  511. #define _GetPkt() (&DfsData.Pkt)
  512. //+-------------------------------------------------------------------------
  513. //
  514. // Function: PktAcquireShared, public inline
  515. //
  516. // Synopsis: PktAcquireShared acquires the partition knowledge table
  517. // for shared access.
  518. //
  519. // Arguments: [Pkt] - pointer to an initialized PKT
  520. // [WaitOk] - indicates if the call is allowed to wait for
  521. // the PKT to become available or must return immediately.
  522. //
  523. // Returns: [TRUE] - is the PKT has been acquired.
  524. // [FALSE] - the PKT could not be acquired.
  525. //
  526. // Notes:
  527. //
  528. //--------------------------------------------------------------------------
  529. #define PktAcquireShared( pPkt, WaitOk )\
  530. { \
  531. FsRtlEnterFileSystem(); \
  532. ExAcquireResourceSharedLite( &((pPkt)->Resource), WaitOk ); \
  533. }
  534. //+-------------------------------------------------------------------------
  535. //
  536. // Function: PktAcquireExclusive, public inline
  537. //
  538. // Synopsis: PktAcquireExclusive acquires the partition knowledge table
  539. // for exclusive access.
  540. //
  541. // Arguments: [Pkt] - pointer to an initialized PKT
  542. // [WaitOk] - indicates if the call is allowed to wait for
  543. // the PKT to become available or must return immediately.
  544. //
  545. // Returns: [TRUE] - is the PKT has been acquired.
  546. // [FALSE] - the PKT could not be acquired.
  547. //
  548. // Notes:
  549. //
  550. //--------------------------------------------------------------------------
  551. #define PktAcquireExclusive( pPkt, WaitOk )\
  552. { \
  553. FsRtlEnterFileSystem(); \
  554. ExAcquireResourceExclusiveLite( &((pPkt)->Resource), WaitOk ); \
  555. }
  556. //+-------------------------------------------------------------------------
  557. //
  558. // Function: PktRelease, public inline
  559. //
  560. // Synopsis: PktRelease releases the PKT. It can have been acquired
  561. // for exclusive or shared access.
  562. //
  563. // Arguments: [Pkt] - pointer to an initialized PKT
  564. //
  565. // Returns: VOID
  566. //
  567. // Notes:
  568. //
  569. //--------------------------------------------------------------------------
  570. #define PktRelease( pPkt )\
  571. { \
  572. ExReleaseResourceLite( &((pPkt)->Resource) ); \
  573. FsRtlExitFileSystem(); \
  574. }
  575. //+-------------------------------------------------------------------------
  576. //
  577. // Function: PktInvalidateEntry, public inline
  578. //
  579. // Synopsis: PktInvalidateEntry destroys a PKT Entry. The entry cannot
  580. // be local, and it cannot be an exit point.
  581. //
  582. // Arguments: [Pkt] - pointer to an initialized PKT.
  583. // [Victim] - pointer to the entry to be invalidated.
  584. //
  585. // Returns: [STATUS_SUCCESS] - all is well.
  586. // [DFS_STATUS_LOCAL_ENTRY] - an attempt was made to
  587. // invalidate a local entry, or an entry that is a
  588. // local exit point.
  589. //
  590. // Notes:
  591. //
  592. //--------------------------------------------------------------------------
  593. #define PktInvalidateEntry(p, e) ( \
  594. ((e)->Type & (PKT_ENTRY_TYPE_LOCAL|PKT_ENTRY_TYPE_LOCAL_XPOINT)) \
  595. ? (DFS_STATUS_LOCAL_ENTRY) \
  596. : (PktEntryDestroy(e, p, (BOOLEAN)TRUE), STATUS_SUCCESS) \
  597. )
  598. //+-------------------------------------------------------------------------
  599. //
  600. // Function: PktFirstEntry, public inline
  601. //
  602. // Synopsis: PktFirstEntry returns the first entry in the list of
  603. // PKT entries.
  604. //
  605. // Arguments: [Pkt] - pointer to an initialized PKT.
  606. //
  607. // Returns: A pointer to the first entry in the PKT, or NULL if the
  608. // PKT is empty.
  609. //
  610. // Notes:
  611. //
  612. //--------------------------------------------------------------------------
  613. #define PktFirstEntry(p) ( \
  614. ((p)->EntryList.Flink != &(p)->EntryList) \
  615. ? (CONTAINING_RECORD((p)->EntryList.Flink, DFS_PKT_ENTRY, Link)) \
  616. : (NULL) \
  617. )
  618. //+-------------------------------------------------------------------------
  619. //
  620. // Function: PktNextEntry, public inline
  621. //
  622. // Synopsis: PktNextEntry returns the next entry in the list of
  623. // PKT entries.
  624. //
  625. // Arguments: [Pkt] - pointer to an initialized PKT.
  626. // [Entry] - a pointer to the previous entry.
  627. //
  628. // Returns: A pointer to the next entry in the PKT, or NULL if we
  629. // are at the end of the list.
  630. //
  631. // Notes:
  632. //
  633. //--------------------------------------------------------------------------
  634. #define PktNextEntry(p, e) ( \
  635. ((e)->Link.Flink != &(p)->EntryList) \
  636. ? (CONTAINING_RECORD((e)->Link.Flink, DFS_PKT_ENTRY, Link)) \
  637. : (NULL) \
  638. )
  639. //+-------------------------------------------------------------------------
  640. //
  641. // Function: PktLinkEntry, public inline
  642. //
  643. // Synopsis: PktLinkEntry links an entry into the list of entries
  644. // in the PKT.
  645. //
  646. // Arguments: [Pkt] - pointer to an initialized PKT.
  647. // [Entry] - a pointer to the entry to be linked in.
  648. //
  649. // Returns: VOID
  650. //
  651. // Notes: Care must be taken to insure that the entry is not already
  652. // linked into the PKT entry list before calling this routine.
  653. // No checking is done to prevent an entry from being linked
  654. // twice...
  655. //
  656. //--------------------------------------------------------------------------
  657. #define PktLinkEntry(p, e) { \
  658. InsertTailList(&(p)->EntryList, &(e)->Link); \
  659. (p)->EntryCount++; \
  660. }
  661. //+-------------------------------------------------------------------------
  662. //
  663. // Function: PktUnlinkEntry, public inline
  664. //
  665. // Synopsis: PktUnlinkEntry unlinks an entry from the list of entries
  666. // in the PKT.
  667. //
  668. // Arguments: [Pkt] - pointer to an initialized PKT.
  669. // [Entry] - a pointer to the entry to be unlinked.
  670. //
  671. // Returns: VOID
  672. //
  673. // Notes: Care must be taken to insure that the entry is in fact
  674. // already linked into the PKT entry list before calling this
  675. // routine. No checking is done to prevent an entry from being
  676. // unlinked twice...
  677. //
  678. //--------------------------------------------------------------------------
  679. #define PktUnlinkEntry(p, e) { \
  680. RemoveEntryList(&(e)->Link); \
  681. (p)->EntryCount--; \
  682. }
  683. //+----------------------------------------------------------------------------
  684. //
  685. // Function: PktSetDomainEntry, public inline
  686. //
  687. // Synopsis: Sets the Domain Pkt Entry in the Pkt to point to the given
  688. // pkt entry.
  689. //
  690. // Arguments: [Pkt] -- pointer to the pkt whose DomainPktEnry field is to be
  691. // set.
  692. // [DCEntry] -- pointer to the pkt entry to serve as the domain
  693. // pkt entry.
  694. //
  695. // Returns: Nothing
  696. //
  697. //-----------------------------------------------------------------------------
  698. #define PktSetDomainEntry(p, e) { \
  699. (p)->DomainPktEntry = e; \
  700. if (SeRenameSd == NULL) { \
  701. (VOID) DfspInitSecDesc(p); \
  702. } \
  703. }
  704. //+----------------------------------------------------------------------------
  705. //
  706. // Function: PktSetTypeInheritance, public inline
  707. //
  708. // Synopsis: Sets the Domain Pkt Entry type to inherit the main parent's type
  709. //
  710. // Arguments: [sup] -- Parent entry.
  711. // [sub] -- Child entry
  712. //
  713. // Returns: Nothing
  714. //
  715. //-----------------------------------------------------------------------------
  716. #define PktSetTypeInheritance(sup, sub) { \
  717. (sub)->Type |= (sup)->Type & PKT_ENTRY_TYPE_INHERIT_MASK; \
  718. }
  719. #define PktServiceListValidate(e) TRUE
  720. //
  721. // PARTITION KNOWLEDGE TABLE PUBLIC FUNCTIONS (pkt.c)
  722. //
  723. NTSTATUS
  724. PktInitialize(
  725. IN PDFS_PKT Pkt
  726. );
  727. VOID
  728. PktUninitialize(
  729. IN PDFS_PKT Pkt);
  730. NTSTATUS
  731. PktInitializeLocalPartition(
  732. IN PDFS_PKT Pkt,
  733. IN PUNICODE_STRING LocalVolumeName,
  734. IN PDFS_LOCAL_VOLUME_CONFIG ConfigInfo
  735. );
  736. NTSTATUS
  737. PktCreateEntry(
  738. IN PDFS_PKT Pkt,
  739. IN ULONG EntryType,
  740. IN PDFS_PKT_ENTRY_ID PktEntryId,
  741. IN PDFS_PKT_ENTRY_INFO PktEntryInfo OPTIONAL,
  742. IN ULONG CreateDisposition,
  743. OUT PDFS_PKT_ENTRY *ppPktEntry
  744. );
  745. NTSTATUS
  746. PktCreateDomainEntry(
  747. IN PUNICODE_STRING DomainName);
  748. NTSTATUS
  749. PktCreateMachineEntry(
  750. IN PUNICODE_STRING MachineName);
  751. NTSTATUS
  752. PktCreateEntryFromReferral(
  753. IN PDFS_PKT Pkt,
  754. IN PUNICODE_STRING ReferralPath,
  755. IN ULONG ReferralSize,
  756. IN PVOID ReferralBuffer,
  757. IN ULONG CreateDisposition,
  758. OUT ULONG *ReferralType,
  759. OUT PDFS_PKT_ENTRY *ppPktEntry
  760. );
  761. NTSTATUS
  762. PktCreateSubordinateEntry(
  763. IN PDFS_PKT Pkt,
  764. IN PDFS_PKT_ENTRY Superior,
  765. IN ULONG SubordinateType,
  766. IN PDFS_PKT_ENTRY_ID SubordinateId,
  767. IN PDFS_PKT_ENTRY_INFO SubordinateInfo OPTIONAL,
  768. IN ULONG CreateDisposition,
  769. IN OUT PDFS_PKT_ENTRY *Subordinate
  770. );
  771. PDFS_PKT_ENTRY
  772. PktLookupEntryById(
  773. IN PDFS_PKT Pkt,
  774. IN PDFS_PKT_ENTRY_ID Id
  775. );
  776. PDFS_PKT_ENTRY
  777. PktLookupEntryByPrefix(
  778. IN PDFS_PKT Pkt,
  779. IN PUNICODE_STRING Prefix,
  780. OUT PUNICODE_STRING Remaining
  781. );
  782. PDFS_PKT_ENTRY
  783. PktLookupEntryByShortPrefix(
  784. IN PDFS_PKT Pkt,
  785. IN PUNICODE_STRING Prefix,
  786. OUT PUNICODE_STRING Remaining
  787. );
  788. NTSTATUS
  789. PktEntryModifyPrefix(
  790. IN PDFS_PKT Pkt,
  791. IN PUNICODE_STRING LocalPath,
  792. IN PDFS_PKT_ENTRY Entry
  793. );
  794. PDFS_PKT_ENTRY
  795. PktLookupEntryByUid(
  796. IN PDFS_PKT Pkt,
  797. IN GUID *Uid
  798. );
  799. PDFS_PKT_ENTRY
  800. PktLookupReferralEntry(
  801. IN PDFS_PKT Pkt,
  802. IN PDFS_PKT_ENTRY pEntry
  803. );
  804. PDFS_PKT_ENTRY
  805. PktGetReferralEntryForPath(
  806. PDFS_PKT Pkt,
  807. UNICODE_STRING Path,
  808. ULONG *Type
  809. );
  810. NTSTATUS
  811. PktSetRelationInfo(
  812. IN PDFS_PKT Pkt,
  813. IN PDFS_PKT_RELATION_INFO RelationInfo
  814. );
  815. VOID
  816. PktTrimSubordinates(
  817. IN PDFS_PKT Pkt,
  818. IN PDFS_PKT_ENTRY Entry,
  819. IN PDFS_PKT_RELATION_INFO RInfo
  820. );
  821. //
  822. // DFS PKT PRIVATE FUNCTIONS (pkt.c)
  823. //
  824. NTSTATUS
  825. PktpRecoverLocalPartition(
  826. IN PDFS_PKT Pkt,
  827. IN PDFS_LOCAL_VOLUME_CONFIG ConfigInfo,
  828. IN PVOID Buffer,
  829. IN ULONG BufferSize,
  830. IN NTSTATUS ErrorStatus
  831. );
  832. NTSTATUS
  833. PktpOpenDomainService(
  834. IN PDFS_PKT Pkt,
  835. IN PDFS_PKT_ENTRY PktEntry,
  836. IN OUT PHANDLE DomainServiceHandle
  837. );
  838. NTSTATUS
  839. PktpValidateLocalPartition(
  840. IN PDFS_PKT Pkt,
  841. IN PDFS_LOCAL_VOLUME_CONFIG ConfigInfo
  842. );
  843. NTSTATUS
  844. DfsGetMachPktEntry(
  845. UNICODE_STRING Path
  846. );
  847. VOID
  848. RemoveLastComponent(
  849. IN PUNICODE_STRING Prefix,
  850. OUT PUNICODE_STRING newPrefix);
  851. VOID
  852. RemoveFirstComponent(
  853. IN PUNICODE_STRING Prefix,
  854. OUT PUNICODE_STRING newPrefix);
  855. //
  856. // DFS SERVICE PUBLIC FUNCTIONS (pktsup.c)
  857. //
  858. NTSTATUS
  859. PktEntrySetLocalService(
  860. IN PDFS_PKT Pkt,
  861. IN PDFS_PKT_ENTRY Entry,
  862. IN PDFS_SERVICE LocalService,
  863. IN PDFS_LOCAL_VOL_ENTRY LocalVolEntry,
  864. IN PUNICODE_STRING LocalPath,
  865. IN PUNICODE_STRING ShareName);
  866. VOID
  867. PktEntryUnsetLocalService(
  868. IN PDFS_PKT Pkt,
  869. IN PDFS_PKT_ENTRY Entry,
  870. IN PUNICODE_STRING LocalPath);
  871. VOID
  872. PktEntryRemoveLocalService(
  873. IN PDFS_PKT Pkt,
  874. IN PDFS_PKT_ENTRY Entry,
  875. IN PUNICODE_STRING LocalPath);
  876. PDFS_LOCAL_VOL_ENTRY
  877. PktEntryLookupLocalService(
  878. IN PDFS_PKT Pkt,
  879. IN PUNICODE_STRING LocalPath,
  880. OUT PUNICODE_STRING Remaining
  881. );
  882. NTSTATUS
  883. PktServiceConstruct(
  884. OUT PDFS_SERVICE Service,
  885. IN ULONG ServiceType,
  886. IN ULONG ServiceCapability,
  887. IN ULONG ServiceStatus,
  888. IN ULONG ServiceProviderId,
  889. IN PUNICODE_STRING ServiceName OPTIONAL,
  890. IN PUNICODE_STRING ServiceAddress OPTIONAL
  891. );
  892. VOID
  893. PktServiceDestroy(
  894. IN PDFS_SERVICE Victim OPTIONAL,
  895. IN BOOLEAN DeallocateAll
  896. );
  897. VOID
  898. PktDSTransportDestroy(
  899. IN PDS_TRANSPORT Victim OPTIONAL,
  900. IN BOOLEAN DeallocateAll
  901. );
  902. VOID
  903. PktDSMachineDestroy(
  904. IN PDS_MACHINE Victim OPTIONAL,
  905. IN BOOLEAN DeallocateAll
  906. );
  907. //
  908. // PKT ENTRY ID PUBLIC FUNCTIONS (pktsup.c)
  909. //
  910. NTSTATUS
  911. PktEntryIdConstruct(
  912. OUT PDFS_PKT_ENTRY_ID PktEntryId,
  913. IN GUID *Uid OPTIONAL,
  914. IN UNICODE_STRING *Prefix OPTIONAL,
  915. IN UNICODE_STRING *ShortPrefix OPTIONAL
  916. );
  917. VOID
  918. PktEntryIdDestroy(
  919. IN PDFS_PKT_ENTRY_ID Victim OPTIONAL,
  920. IN BOOLEAN DeallocateAll
  921. );
  922. PDFS_SERVICE
  923. PktGetService(
  924. IN PDFS_PKT_ENTRY entry,
  925. IN PUNICODE_STRING serviceName
  926. );
  927. //
  928. // PKT ENTRY ID PUBLIC INLINE FUNCTIONS
  929. //
  930. //+-------------------------------------------------------------------------
  931. //
  932. // Function: PktEntryIdEqual, public inline
  933. //
  934. // Synopsis: PktpEntryIdEqual determines if two entry Ids are equal
  935. // or not.
  936. //
  937. // Arguments: [Id1] - a pointer to an Id to compare.
  938. // [Id2] - a pointer to an Id to compare.
  939. //
  940. // Returns: [TRUE] - if both Ids are equal.
  941. // [FALSE] - if the Ids are not equal.
  942. //
  943. // Notes: The comparison on the Prefix is done case insensitive.
  944. //
  945. //--------------------------------------------------------------------------
  946. #define PktEntryIdEqual(Id1, Id2) ( \
  947. (GuidEqual(&(Id1)->Uid, &(Id2)->Uid)) && \
  948. (RtlEqualUnicodeString(&(Id1)->Prefix, &(Id2)->Prefix, (BOOLEAN)TRUE)) \
  949. )
  950. //
  951. // PKT ENTRY ID PRIVATE INLINE FUNCTIONS
  952. //
  953. //+-------------------------------------------------------------------------
  954. //
  955. // Function: PktpEntryIdMove, private inline
  956. //
  957. // Synopsis: PktpEntryIdMove removes the values from the source Id and
  958. // places them on the destination Id.
  959. //
  960. // Arguments: [DestId] - a pointer to an Id that is to receive the
  961. // sources values.
  962. // [SrcId] - a pointer to an Id that is to be stripped of
  963. // its values.
  964. //
  965. // Returns: VOID
  966. //
  967. // Notes: Any values that are currently on the destination Id are
  968. // overwritten. No memory is freed (either on the source,
  969. // or the destination) by this call.
  970. //
  971. //--------------------------------------------------------------------------
  972. #define PktpEntryIdMove(DestId, SrcId) { \
  973. (*(DestId)) = (*(SrcId)); \
  974. (SrcId)->Prefix.Length = (SrcId)->Prefix.MaximumLength = 0; \
  975. (SrcId)->Prefix.Buffer = NULL; \
  976. (SrcId)->ShortPrefix.Length = (SrcId)->ShortPrefix.MaximumLength = 0; \
  977. (SrcId)->ShortPrefix.Buffer = NULL; \
  978. }
  979. //
  980. // PKT ENTRY INFO PUBLIC FUNCTIONS (pktsup.c)
  981. //
  982. //NTSTATUS
  983. //PktEntryInfoConstruct(
  984. // OUT PDFS_PKT_ENTRY_INFO PktEntryInfo,
  985. // IN PULONG ExpireTime OPTIONAL,
  986. // IN ULONG ServiceCount,
  987. // IN PDFS_SERVICE ServiceList OPTIONAL
  988. // );
  989. VOID
  990. PktEntryInfoDestroy(
  991. IN PDFS_PKT_ENTRY_INFO Victim OPTIONAL,
  992. IN BOOLEAN DeallocateAll
  993. );
  994. //
  995. // PKT ENTRY INFO PRIVATE INLINE FUNCTIONS
  996. //
  997. //
  998. // The following inlines operate on Entry Infos
  999. //
  1000. //+-------------------------------------------------------------------------
  1001. //
  1002. // Function: PktpEntryInfoMove, private inline
  1003. //
  1004. // Synopsis: PktpEntryInfoMove removes the values from the source Info and
  1005. // places them on the destination Info.
  1006. //
  1007. // Arguments: [DestInfo] - a pointer to an Info that is to receive the
  1008. // sources values.
  1009. // [SrcInfo] - a pointer to an Info that is to be stripped of
  1010. // its values.
  1011. //
  1012. // Returns: VOID
  1013. //
  1014. // Notes: Any values that are currently on the destination Info are
  1015. // overwritten. No memory is freed (either on the source,
  1016. // or the destination) by this call.
  1017. //
  1018. //--------------------------------------------------------------------------
  1019. #define PktpEntryInfoMove(DestInfo, SrcInfo) { \
  1020. (*(DestInfo)) = (*(SrcInfo)); \
  1021. (SrcInfo)->ServiceCount = 0L; \
  1022. (SrcInfo)->ServiceList = NULL; \
  1023. }
  1024. //
  1025. // PKT ENTRY PUBLIC INLINE FUNCTIONS
  1026. //
  1027. //+-------------------------------------------------------------------------
  1028. //
  1029. // Function: PktEntryFirstSubordinate, public inline
  1030. //
  1031. // Synopsis: PktEntryFirstSubordinate returns the first entry in the
  1032. // list of subordinates.
  1033. //
  1034. // Arguments: [Superior] - pointer to a PKT entry.
  1035. //
  1036. // Returns: A pointer to the first entry in the list of subordinates,
  1037. // or NULL if the list is empty.
  1038. //
  1039. // Notes:
  1040. //
  1041. //--------------------------------------------------------------------------
  1042. #define PktEntryFirstSubordinate(s) ( \
  1043. ((s)->SubordinateList.Flink != &(s)->SubordinateList) \
  1044. ? (CONTAINING_RECORD((s)->SubordinateList.Flink, DFS_PKT_ENTRY, \
  1045. SiblingLink)) \
  1046. : (NULL) \
  1047. )
  1048. //+-------------------------------------------------------------------------
  1049. //
  1050. // Function: PktEntryNextSubordinate, public inline
  1051. //
  1052. // Synopsis: PktEntryNextSubordinate returns the next entry in the
  1053. // list of subordinates.
  1054. //
  1055. // Arguments: [Superior] - pointer to the superior PKT entry (the one
  1056. // which we are getting the subordinates for).
  1057. // [Subordinate] - pointer to the last subordinate retreived
  1058. // via this routine (or PktEntryFirstSubordinate).
  1059. //
  1060. // Returns: A pointer to the next entry in the list of subordinates,
  1061. // or NULL if we've hit the end of the list.
  1062. //
  1063. // Notes:
  1064. //
  1065. //--------------------------------------------------------------------------
  1066. #define PktEntryNextSubordinate(s, m) ( \
  1067. ((m)->SiblingLink.Flink != &(s)->SubordinateList) \
  1068. ? (CONTAINING_RECORD((m)->SiblingLink.Flink,DFS_PKT_ENTRY,SiblingLink))\
  1069. : (NULL) \
  1070. )
  1071. //+-------------------------------------------------------------------------
  1072. //
  1073. // Function: PktEntryLinkSubordinate, public inline
  1074. //
  1075. // Synopsis: PktEntryLinkSubordinate links a subordinate to a superior's
  1076. // list of subordinates.
  1077. //
  1078. // Arguments: [Superior] - pointer to the superior PKT entry.
  1079. // [Subordinate] - pointer to the subordinate to be linked in.
  1080. //
  1081. // Returns: VOID
  1082. //
  1083. // Notes: If the subordinate is part of another superior's list, it
  1084. // will be removed from that list as a by-product of being
  1085. // put on the specified Superior's list. The Superior pointer
  1086. // of the subordinate is adjusted appropriately.
  1087. //
  1088. // If the superior is a local entry, the subordinate will
  1089. // be modified to indicate that it is a local exit point.
  1090. //
  1091. //--------------------------------------------------------------------------
  1092. #define PktEntryLinkSubordinate(sup, sub) { \
  1093. while(1) { \
  1094. if((sub)->Superior == (sup)) \
  1095. break; \
  1096. if((sub)->Superior != NULL) \
  1097. PktEntryUnlinkSubordinate((sub)->Superior, (sub)); \
  1098. InsertTailList(&(sup)->SubordinateList, &(sub)->SiblingLink); \
  1099. (sup)->SubordinateCount++; \
  1100. (sub)->Superior = (sup); \
  1101. if((sup)->Type & PKT_ENTRY_TYPE_LOCAL) \
  1102. (sub)->Type |= PKT_ENTRY_TYPE_LOCAL_XPOINT; \
  1103. break; \
  1104. } \
  1105. }
  1106. //+-------------------------------------------------------------------------
  1107. //
  1108. // Function: PktEntryUnlinkSubordinate, public inline
  1109. //
  1110. // Synopsis: PktEntryUnlinkSubordinate unlinks a subordinate from a
  1111. // superior's list of subordinates.
  1112. //
  1113. // Arguments: [Superior] - pointer to the superior PKT entry.
  1114. // [Subordinate] - pointer to the subordinate to be unlinked.
  1115. //
  1116. // Returns: VOID
  1117. //
  1118. // Notes: The Superior pointer of the subordinate is NULLed as a
  1119. // by-product of this operation.
  1120. //
  1121. // By default, the subordinate is modified to indicate that
  1122. // it is not an exit point (it cannot be an exit point if it
  1123. // has no superior).
  1124. //
  1125. // Milans - We need to turn off the PKT_ENTRY_TYPE_PERMANENT
  1126. // bit if the PKT_ENTRY_TYPE_LOCAL bit is not set, and we are
  1127. // not the DC. If we decide that a machine can be a server for
  1128. // a volume in another domain, then we need to do something
  1129. // about the != DS_DC clause.
  1130. //
  1131. //--------------------------------------------------------------------------
  1132. #define PktEntryUnlinkSubordinate(sup, sub) { \
  1133. ASSERT((sub)->Superior == (sup)); \
  1134. ASSERT((sup)->SubordinateCount > 0); \
  1135. RemoveEntryList(&(sub)->SiblingLink); \
  1136. (sup)->SubordinateCount--; \
  1137. (sub)->Superior = NULL; \
  1138. (sub)->Type &= ~PKT_ENTRY_TYPE_LOCAL_XPOINT; \
  1139. if ( DfsData.MachineState != DFS_ROOT_SERVER && \
  1140. (((sub)->Type & PKT_ENTRY_TYPE_LOCAL) == 0) ) { \
  1141. (sub)->Type &= ~PKT_ENTRY_TYPE_PERMANENT; \
  1142. } \
  1143. }
  1144. //
  1145. // The following set of inline functions work on the Links maintained in
  1146. // the PKT to be able to get to referral entries for interdomain stuff real
  1147. // fast. These functions are similar to the above functions.
  1148. //
  1149. //+-------------------------------------------------------------------------
  1150. //
  1151. // Function: PktEntryFirstChild, public inline
  1152. //
  1153. // Synopsis: PktEntryFirstChild returns the first entry in the
  1154. // list of child links of a PKT entry.
  1155. //
  1156. // Arguments: [SuperiorDC] - pointer to a PKT entry.
  1157. //
  1158. // Returns: A pointer to the first entry in the list of children,
  1159. // or NULL if the list is empty.
  1160. //
  1161. // Notes:
  1162. //
  1163. //--------------------------------------------------------------------------
  1164. #define PktEntryFirstChild(s) ( \
  1165. ((s)->ChildList.Flink != &(s)->ChildList) \
  1166. ? (CONTAINING_RECORD((s)->ChildList.Flink,DFS_PKT_ENTRY,NextLink)) \
  1167. : (NULL) \
  1168. )
  1169. //+-------------------------------------------------------------------------
  1170. //
  1171. // Function: PktEntryNextChild, public inline
  1172. //
  1173. // Synopsis: PktEntryNextChild returns the next entry in the
  1174. // list of children.
  1175. //
  1176. // Arguments: [Superior] - pointer to the superior PKT entry (the one
  1177. // which we are getting the subordinates for).
  1178. // [Subordinate] - pointer to the last child retreived
  1179. // via this routine (or PktEntryFirstChild).
  1180. //
  1181. // Returns: A pointer to the next entry in the list of children,
  1182. // or NULL if we've hit the end of the list.
  1183. //
  1184. // Notes:
  1185. //
  1186. //--------------------------------------------------------------------------
  1187. #define PktEntryNextChild(s, m) ( \
  1188. ((m)->NextLink.Flink != &(s)->ChildList) \
  1189. ? (CONTAINING_RECORD((m)->NextLink.Flink,DFS_PKT_ENTRY,NextLink)) \
  1190. : (NULL) \
  1191. )
  1192. //+-------------------------------------------------------------------------
  1193. //
  1194. // Function: PktEntryLinkChild, public inline
  1195. //
  1196. // Synopsis: PktEntryLinkChild links a child to a closestDC's
  1197. // list of children.
  1198. //
  1199. // Arguments: [Superior] - pointer to the superior PKT entry.
  1200. // [Subordinate] - pointer to the subordinate to be linked in.
  1201. //
  1202. // Returns: VOID
  1203. //
  1204. // Notes: If the child is part of another superior's list, it
  1205. // will be removed from that list as a by-product of being
  1206. // put on the specified Superior's list. The Superior pointer
  1207. // of the child is adjusted appropriately.
  1208. //
  1209. //
  1210. //--------------------------------------------------------------------------
  1211. #define PktEntryLinkChild(sup, sub) { \
  1212. while(1) { \
  1213. if (sub == sup) { \
  1214. (sub)->ClosestDC = NULL; \
  1215. break; \
  1216. } \
  1217. if((sub)->ClosestDC == (sup)) \
  1218. break; \
  1219. if((sub)->ClosestDC != NULL) \
  1220. PktEntryUnlinkChild((sub)->ClosestDC, (sub)); \
  1221. InsertTailList(&(sup)->ChildList, &(sub)->NextLink); \
  1222. (sub)->ClosestDC = (sup); \
  1223. break; \
  1224. } \
  1225. }
  1226. //+-------------------------------------------------------------------------
  1227. //
  1228. // Function: PktEntryUnlinkChild, public inline
  1229. //
  1230. // Synopsis: PktEntryUnlinkChild unlinks a child from a
  1231. // superior's list of children.
  1232. //
  1233. // Arguments: [Superior] - pointer to the superior PKT entry.
  1234. // [Subordinate] - pointer to the subordinate to be unlinked.
  1235. //
  1236. // Returns: VOID
  1237. //
  1238. // Notes: The Superior pointer of the child is NULLed as a
  1239. // by-product of this operation.
  1240. //
  1241. //
  1242. //--------------------------------------------------------------------------
  1243. #define PktEntryUnlinkChild(sup, sub) { \
  1244. ASSERT((sub)->ClosestDC == (sup)); \
  1245. RemoveEntryList(&(sub)->NextLink); \
  1246. (sub)->ClosestDC = NULL; \
  1247. }
  1248. //+-------------------------------------------------------------------------
  1249. //
  1250. // Function: PktEntryUnlinkAndRelinkChild, public inline
  1251. //
  1252. // Synopsis: PktEntryUnlinkAndRelinkChild unlinks a child from a
  1253. // superior's list of children and relinks it to the parent of
  1254. // the superior.
  1255. //
  1256. // Arguments: [Superior] - pointer to the superior PKT entry.
  1257. // [Subordinate] - pointer to the subordinate to be unlinked.
  1258. //
  1259. // Returns: VOID
  1260. //
  1261. //--------------------------------------------------------------------------
  1262. #define PktEntryUnlinkAndRelinkChild(sup, sub) { \
  1263. PktEntryUnlinkChild(sup, sub); \
  1264. if ((sup)->ClosestDC != NULL) { \
  1265. PktEntryLinkChild((sup)->ClosestDC, sub); \
  1266. } \
  1267. }
  1268. //
  1269. // PKT ENTRY PUBLIC FUNCTIONS (pktsup.c)
  1270. //
  1271. NTSTATUS
  1272. PktEntryAssemble(
  1273. IN OUT PDFS_PKT_ENTRY Entry,
  1274. IN PDFS_PKT Pkt,
  1275. IN ULONG EntryType,
  1276. IN PDFS_PKT_ENTRY_ID EntryId,
  1277. IN PDFS_PKT_ENTRY_INFO EntryInfo OPTIONAL
  1278. );
  1279. NTSTATUS
  1280. PktEntryReassemble(
  1281. IN OUT PDFS_PKT_ENTRY Entry,
  1282. IN PDFS_PKT Pkt OPTIONAL,
  1283. IN ULONG EntryType,
  1284. IN PDFS_PKT_ENTRY_ID EntryId OPTIONAL,
  1285. IN PDFS_PKT_ENTRY_INFO EntryInfo OPTIONAL
  1286. );
  1287. VOID
  1288. PktEntryDestroy(
  1289. IN PDFS_PKT_ENTRY Victim OPTIONAL,
  1290. IN PDFS_PKT Pkt,
  1291. IN BOOLEAN DeallocateAll
  1292. );
  1293. VOID
  1294. PktEntryClearSubordinates(
  1295. IN PDFS_PKT_ENTRY PktEntry
  1296. );
  1297. VOID
  1298. PktEntryClearChildren(
  1299. IN PDFS_PKT_ENTRY PktEntry
  1300. );
  1301. NTSTATUS
  1302. PktEntryCreateReferral(
  1303. IN PDFS_PKT_ENTRY PktEntry,
  1304. IN ULONG ServiceTypes,
  1305. IN PVOID ReferralBuffer
  1306. );
  1307. //
  1308. // PKT RELATION INFO PUBLIC FUNCTIONS (pktsup.c)
  1309. //
  1310. NTSTATUS
  1311. PktRelationInfoConstruct(
  1312. IN OUT PDFS_PKT_RELATION_INFO RelationInfo,
  1313. IN PDFS_PKT Pkt,
  1314. IN PDFS_PKT_ENTRY_ID PktEntryId
  1315. );
  1316. NTSTATUS
  1317. PktRelationInfoValidate(
  1318. IN PDFS_PKT_RELATION_INFO Local,
  1319. IN PDFS_PKT_RELATION_INFO Remote,
  1320. IN UNICODE_STRING ServiceName
  1321. );
  1322. VOID
  1323. PktRelationInfoDestroy(
  1324. IN PDFS_PKT_RELATION_INFO RelationInfo,
  1325. IN BOOLEAN DeallocateAll
  1326. );
  1327. VOID
  1328. LocalVolumeConfigInfoDestroy(
  1329. IN PDFS_LOCAL_VOLUME_CONFIG Victim OPTIONAL,
  1330. IN BOOLEAN DeallocateAll
  1331. );
  1332. #endif // NOT _UPKT_
  1333. #endif // _PKT_