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.

1382 lines
47 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. //
  35. // Defines for Create Dispositions (we mimic the io system here).
  36. //
  37. #define PKT_ENTRY_CREATE FILE_CREATE
  38. #define PKT_ENTRY_REPLACE FILE_OPEN
  39. #define PKT_ENTRY_SUPERSEDE FILE_SUPERSEDE
  40. //
  41. // Different kind of referrals that a DC can give out.
  42. //
  43. #define DFS_STORAGE_REFERRAL (0x0001)
  44. #define DFS_REFERRAL_REFERRAL (0x0002)
  45. //
  46. // Types of service that can be supported by a provider.
  47. // A disjunction of any of the following values.
  48. //
  49. #define DFS_SERVICE_TYPE_MASTER (0x0001)
  50. #define DFS_SERVICE_TYPE_READONLY (0x0002)
  51. #define DFS_SERVICE_TYPE_LOCAL (0x0004)
  52. #define DFS_SERVICE_TYPE_REFERRAL (0x0008)
  53. #define DFS_SERVICE_TYPE_ACTIVE (0x0010)
  54. #define DFS_SERVICE_TYPE_DOWN_LEVEL (0x0020)
  55. #define DFS_SERVICE_TYPE_COSTLIER (0x0040)
  56. #define DFS_SERVICE_TYPE_OFFLINE (0x0080)
  57. //
  58. // The status possibilities...
  59. //
  60. #define DFS_SERVICE_STATUS_VERIFIED (0x0001)
  61. #define DFS_SERVICE_STATUS_UNVERIFIED (0x0002)
  62. //
  63. // Types of Partition Knowledge Table Entries.
  64. // Low-order bits in these definitions correspond to volume object
  65. // types as defined in dfsh.idl. High-order bits are specific
  66. // to PKT entries.
  67. //
  68. #define PKT_ENTRY_TYPE_DFS 0x0001 // Entry is to Dfs Aware srv
  69. #define PKT_ENTRY_TYPE_MACHINE 0x0002 // Entry is a machine volume
  70. #define PKT_ENTRY_TYPE_NONDFS 0x0004 // Entry refers to downlevel
  71. #define PKT_ENTRY_TYPE_LEAFONLY 0x0008
  72. #define PKT_ENTRY_TYPE_OUTSIDE_MY_DOM 0x0010 // Entry refers to volume in
  73. // foreign domain
  74. #define PKT_ENTRY_TYPE_SYSVOL 0x0040 // Sysvol
  75. #define PKT_ENTRY_TYPE_REFERRAL_SVC 0x0080 // Entry refers to a DC
  76. #define PKT_ENTRY_TYPE_PERMANENT 0x0100 // Entry cannot be scavenged
  77. #define PKT_ENTRY_TYPE_DELETE_PENDING 0x0200 // Entry has pending delete
  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_OFFLINE 0x2000 // Entry refers to a volume
  81. // that is offline
  82. //
  83. // Type of messages the driver can send to DfsManager / DfsService
  84. //
  85. #define DFS_MSGTYPE_KNOW_INCONSISTENCY 0x0001
  86. #define DFS_MSGTYPE_GET_DOMAIN_REFERRAL 0x0002
  87. #define DFS_MSGTYPE_GET_DC_NAME 0x0003
  88. //
  89. // There is one DFS_MACHINE_ENTRY for every unique DS_MACHINE that the
  90. // Dfs driver knows about. If a particular cairo server services multiple Dfs
  91. // volumes, then multiple DFS_SERVICE structs will point to a single, ref
  92. // counted DFS_MACHINE_ENTRY.
  93. //
  94. typedef struct DFS_MACHINE_ENTRY {
  95. PDS_MACHINE pMachine; // The addressing info is here.
  96. UNICODE_STRING MachineName; // The MachineName (principalName).
  97. ULONG UseCount; // Number of DFS_SVC structs using this
  98. ULONG ConnectionCount;// The number of pkt entries that are
  99. // using this as their active machine
  100. PFILE_OBJECT AuthConn; // Handle to the tree connect with
  101. struct _DFS_CREDENTIALS *Credentials; // these credentials.
  102. UNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry;
  103. } DFS_MACHINE_ENTRY, *PDFS_MACHINE_ENTRY;
  104. //
  105. // Marshalling info for DFS_MACHINE_ENTRY
  106. //
  107. extern MARSHAL_INFO MiMachineEntry;
  108. #define INIT_DFS_MACHINE_ENTRY_MARSHAL_INFO() \
  109. static MARSHAL_TYPE_INFO _MCode_Machine_Entry[] = { \
  110. _MCode_pstruct(DFS_MACHINE_ENTRY, pMachine, &MiDSMachine) \
  111. }; \
  112. MARSHAL_INFO MiMachineEntry = _mkMarshalInfo(DFS_SERVICE, _MCode_Machine_Entry);
  113. //
  114. // A DFS_SERVICE structure is used to describe the provider and
  115. // network address to be contacted for a specific partition of
  116. // the distributed file system.
  117. //
  118. typedef struct _DFS_SERVICE {
  119. ULONG Type; // type of service (see above)
  120. ULONG Capability; // capability of this service
  121. ULONG ProviderId; // identifies which provider
  122. UNICODE_STRING Name; // service name (for authentication)
  123. PFILE_OBJECT ConnFile; // FileObject for tree conn to IPC$ of server
  124. struct _PROVIDER_DEF* pProvider; // pointer to provider definition
  125. UNICODE_STRING Address; // network address
  126. PDFS_MACHINE_ENTRY pMachEntry; // The addressing info is here.
  127. ULONG Cost; // The site based cost of this service.
  128. } DFS_SERVICE, *PDFS_SERVICE;
  129. //
  130. // Marshalling information for DFS_SERVICE
  131. //
  132. // NOTE: ConnFile and pProvider have significance only to the driver and
  133. // are not marshalled.
  134. //
  135. extern MARSHAL_INFO MiService;
  136. #define INIT_DFS_SERVICE_MARSHAL_INFO() \
  137. static MARSHAL_TYPE_INFO _MCode_Service[] = { \
  138. _MCode_ul(DFS_SERVICE, Type), \
  139. _MCode_ul(DFS_SERVICE, Capability), \
  140. _MCode_ul(DFS_SERVICE, ProviderId), \
  141. _MCode_ustr(DFS_SERVICE, Name), \
  142. _MCode_ustr(DFS_SERVICE, Address), \
  143. _MCode_pstruct(DFS_SERVICE, pMachEntry, &MiMachineEntry) \
  144. }; \
  145. MARSHAL_INFO MiService = _mkMarshalInfo(DFS_SERVICE, _MCode_Service);
  146. //
  147. // Structure used in FSCTL_DFS_UPDATE_MACH_ADDRESS
  148. //
  149. typedef struct _DFS_MACHINE_INFO {
  150. UNICODE_STRING MachineName; // Name of Machine (prefix alone).
  151. PDS_MACHINE pMachine; // The new addressing info is here
  152. } DFS_MACHINE_INFO, *PDFS_MACHINE_INFO;
  153. //
  154. // Marshalling info for DFS_MACHINE_INFO
  155. //
  156. extern MARSHAL_INFO MiDfsMachineInfo;
  157. #define INIT_DFS_MACHINE_INFO() \
  158. static MARSHAL_TYPE_INFO _MCode_MachineInfo[] = { \
  159. _MCode_ustr(DFS_MACHINE_INFO, MachineName), \
  160. _MCode_pstruct(DFS_MACHINE_INFO, pMachine, &MiDSMachine) \
  161. }; \
  162. MARSHAL_INFO MiDfsMachineInfo = \
  163. _mkMarshalInfo(DFS_MACHINE_INFO, _MCode_MachineInfo);
  164. //
  165. // How a partition table entry is identified.
  166. //
  167. typedef struct _DFS_PKT_ENTRY_ID {
  168. GUID Uid; // a unique identifier for this partition
  169. UNICODE_STRING Prefix; // The entry path prefix of this partition
  170. UNICODE_STRING ShortPrefix; // The 8.3 form of entry path prefix
  171. } DFS_PKT_ENTRY_ID, *PDFS_PKT_ENTRY_ID;
  172. //
  173. // Marshalling information for DFS_PKT_ENTRY_ID
  174. //
  175. extern MARSHAL_INFO MiPktEntryId;
  176. #define INIT_DFS_PKT_ENTRY_ID_MARSHAL_INFO() \
  177. static MARSHAL_TYPE_INFO _MCode_PktEntryId[] = { \
  178. _MCode_guid(DFS_PKT_ENTRY_ID, Uid), \
  179. _MCode_ustr(DFS_PKT_ENTRY_ID, Prefix) \
  180. }; \
  181. MARSHAL_INFO MiPktEntryId = \
  182. _mkMarshalInfo(DFS_PKT_ENTRY_ID, _MCode_PktEntryId);
  183. //
  184. // The guts of a partition table entry
  185. //
  186. typedef struct _DFS_PKT_ENTRY_INFO {
  187. ULONG ServiceCount; // number of services in list
  188. PDFS_SERVICE ServiceList; // array of servers that support the partition
  189. } DFS_PKT_ENTRY_INFO, *PDFS_PKT_ENTRY_INFO;
  190. typedef struct _DFS_TARGET_INFO_HEADER {
  191. ULONG Type;
  192. LONG UseCount;
  193. ULONG Flags;
  194. } DFS_TARGET_INFO_HEADER, *PDFS_TARGET_INFO_HEADER;
  195. #define TARGET_INFO_DFS 1
  196. #define TARGET_INFO_LMR 2
  197. typedef struct _DFS_TARGET_INFO {
  198. DFS_TARGET_INFO_HEADER DfsHeader;
  199. union {
  200. CREDENTIAL_TARGET_INFORMATIONW TargetInfo;
  201. LMR_QUERY_TARGET_INFO LMRTargetInfo;
  202. };
  203. } DFS_TARGET_INFO, *PDFS_TARGET_INFO;
  204. NTSTATUS
  205. PktGetTargetInfo(
  206. HANDLE IpcHandle,
  207. PUNICODE_STRING pDomainName,
  208. PUNICODE_STRING pShareName,
  209. PDFS_TARGET_INFO *ppTargetInfo );
  210. VOID
  211. PktAcquireTargetInfo(
  212. pTargetInfo);
  213. VOID
  214. PktReleaseTargetInfo(
  215. pTargetInfo);
  216. //
  217. // Marshalling information for DFS_PKT_ENTRY_INFO
  218. //
  219. extern MARSHAL_INFO MiPktEntryInfo;
  220. #define INIT_DFS_PKT_ENTRY_INFO_MARSHAL_INFO() \
  221. static MARSHAL_TYPE_INFO _MCode_PktEntryInfo[] = { \
  222. _MCode_ul(DFS_PKT_ENTRY_INFO, ServiceCount), \
  223. _MCode_pcastruct(DFS_PKT_ENTRY_INFO,ServiceList,ServiceCount,&MiService)\
  224. }; \
  225. MARSHAL_INFO MiPktEntryInfo = \
  226. _mkMarshalInfo(DFS_PKT_ENTRY_INFO, _MCode_PktEntryInfo);
  227. //
  228. // A Partition Knowledge Table Entry (PktEntry) identifies each known
  229. // partition.
  230. //
  231. typedef struct _DFS_PKT_ENTRY {
  232. NODE_TYPE_CODE NodeTypeCode; // node type -> DSFS_NTC_PKT_ENTRY
  233. NODE_BYTE_SIZE NodeByteSize; // node size
  234. LIST_ENTRY Link; // link for PKT EntryList
  235. ULONG Type; // type of partition (see above)
  236. ULONG USN; // Unique Serial Number
  237. DFS_PKT_ENTRY_ID Id; // the Id of this entry
  238. DFS_PKT_ENTRY_INFO Info; // info of this entry
  239. ULONG ExpireTime; // time when partition should be deleted
  240. ULONG TimeToLive; // time to keep this entry in the cache
  241. ULONG UseCount; // # threads (DnrContexts) are looking at it.
  242. ULONG FileOpenCount; // # of files opened via this entry
  243. PDFS_TARGET_INFO pDfsTargetInfo;
  244. PDFS_SERVICE ActiveService; // pointer into info to active service
  245. PDFS_SERVICE LocalService; // pointer to local service (if any)
  246. struct _DFS_PKT_ENTRY *Superior;// this entrys superior (if any)
  247. ULONG SubordinateCount; // number of subordinates (if any)
  248. LIST_ENTRY SubordinateList; // list of subordinates (if any)
  249. LIST_ENTRY SiblingLink; // link to other siblings (if any)
  250. struct _DFS_PKT_ENTRY *ClosestDC; // Link to closest superiorDC in PKT.
  251. LIST_ENTRY ChildList; // Link to subordinate PKT entries (if any)
  252. LIST_ENTRY NextLink; // Link to link up parent's Subord list.
  253. UNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry;// prefix table entry
  254. } DFS_PKT_ENTRY, *PDFS_PKT_ENTRY;
  255. //
  256. // Marshalling information for DFS_PKT_ENTRY
  257. //
  258. // Note that we only marshal the id and the info...no relational info
  259. //
  260. //
  261. extern MARSHAL_INFO MiPktEntry;
  262. #define INIT_DFS_PKT_ENTRY_MARSHAL_INFO() \
  263. static MARSHAL_TYPE_INFO _MCode_PktEntry[] = { \
  264. _MCode_ul(DFS_PKT_ENTRY, Type), \
  265. _MCode_struct(DFS_PKT_ENTRY, Id, &MiPktEntryId), \
  266. _MCode_struct(DFS_PKT_ENTRY, Info, &MiPktEntryInfo) \
  267. }; \
  268. MARSHAL_INFO MiPktEntry = _mkMarshalInfo(DFS_PKT_ENTRY, _MCode_PktEntry);
  269. //
  270. // A special entry table contains a special name and a list of expanded
  271. // names.
  272. //
  273. typedef struct _DFS_EXPANDED_NAME {
  274. UNICODE_STRING ExpandedName; // expanded name itself
  275. GUID Guid; // GUID associated with this name;
  276. } DFS_EXPANDED_NAME, *PDFS_EXPANDED_NAME;
  277. typedef struct _DFS_SPECIAL_ENTRY {
  278. NODE_TYPE_CODE NodeTypeCode; // node type -> DSFS_NTC_SPECIAL_ENTRY
  279. NODE_BYTE_SIZE NodeByteSize; // node size
  280. LIST_ENTRY Link; // link for PKT SpecialEntryList
  281. ULONG USN; // unique serial number
  282. ULONG UseCount; // # threads (DnrContexts) are looking at it.
  283. UNICODE_STRING SpecialName; // Special name itself
  284. ULONG ExpandedCount; // count of expanded names
  285. ULONG Active; // active expanded name
  286. UNICODE_STRING DCName; // DC to go to, to get referrals
  287. PDFS_EXPANDED_NAME ExpandedNames; // the expanded names
  288. BOOLEAN NeedsExpansion; // need to expand this name
  289. BOOLEAN Stale; // Entry has gone stale
  290. BOOLEAN GotDCReferral; // This domain name has already
  291. // been checked for
  292. } DFS_SPECIAL_ENTRY, *PDFS_SPECIAL_ENTRY;
  293. typedef struct _DFS_SPECIAL_TABLE {
  294. LIST_ENTRY SpecialEntryList; // list of special entries in the PKT
  295. ULONG SpecialEntryCount; // number of special entries in the PKT
  296. ULONG TimeToLive; // time when table should be deleted
  297. } DFS_SPECIAL_TABLE, *PDFS_SPECIAL_TABLE;
  298. //
  299. // A Parition Knowledge Table encapsulates all the knowledge that has
  300. // been obtained about partitions in the distributed file system. There
  301. // is only one instance of this struct in the entire system, and is
  302. // part of the DsData structure.
  303. //
  304. typedef struct _DFS_PKT {
  305. NODE_TYPE_CODE NodeTypeCode; // node type -> DSFS_NTC_PKT
  306. NODE_BYTE_SIZE NodeByteSize; // node size...
  307. ERESOURCE Resource; // resource to guard access to Pkt
  308. KSPIN_LOCK UseCountLock; // Use while changing UseCount
  309. ULONG EntryCount; // number of entries in the PKT
  310. ULONG EntryTimeToLive; // time to live for each entry
  311. LIST_ENTRY EntryList; // list of entries in the PKT
  312. UNICODE_STRING DCName; // where to go for expanded referrals
  313. UNICODE_STRING DomainNameFlat; // our domain name (flat)
  314. UNICODE_STRING DomainNameDns; // our domain in dns format
  315. DFS_SPECIAL_TABLE SpecialTable; // special entry table
  316. DFS_PREFIX_TABLE PrefixTable; // prefix table
  317. DFS_PREFIX_TABLE ShortPrefixTable; // prefix table for 8.3 names
  318. UNICODE_PREFIX_TABLE DSMachineTable;// Table for DSMachines
  319. } DFS_PKT, *PDFS_PKT;
  320. #ifndef _UPKT_
  321. //
  322. // PARTITION KNOWLEDGE TABLE PUBLIC INLINE FUNCTIONS
  323. //
  324. #define _GetPkt() (&DfsData.Pkt)
  325. //+-------------------------------------------------------------------------
  326. //
  327. // Function: PktAcquireShared, public inline
  328. //
  329. // Synopsis: PktAcquireShared acquires the partition knowledge table
  330. // for shared access.
  331. //
  332. // Arguments: [WaitOk] - indicates if the call is allowed to wait for
  333. // the PKT to become available or must return immediately
  334. // [Result] - Pointer to boolean that will receive result of
  335. // lock acquisition
  336. //
  337. // Returns: Nothing
  338. //
  339. // Notes: We first check to see if there are any threads waiting to
  340. // update the Pkt. If so, we hold off until that thread has
  341. // finished before we acquire a shared lock on the Pkt.
  342. // Under NT, a thread waiting to acquire a resource exclusive
  343. // does !not! automatically prevent threads from acquiring it
  344. // shared. This is necessary to allow for recursive acquisition
  345. // of resources. So, this event mechanism is required.
  346. //
  347. //--------------------------------------------------------------------------
  348. #define PktAcquireShared( WaitOk, Result ) \
  349. { \
  350. KeWaitForSingleObject( \
  351. &DfsData.PktWritePending, \
  352. Spare2, \
  353. KernelMode, \
  354. FALSE, \
  355. NULL); \
  356. *(Result) = ExAcquireResourceSharedLite( \
  357. &DfsData.Pkt.Resource, \
  358. WaitOk ); \
  359. }
  360. //+-------------------------------------------------------------------------
  361. //
  362. // Function: PktAcquireExclusive, public inline
  363. //
  364. // Synopsis: PktAcquireExclusive acquires the partition knowledge table
  365. // for exclusive access.
  366. //
  367. // Arguments: [WaitOk] - indicates if the call is allowed to wait for
  368. // the PKT to become available or must return immediately.
  369. // [Result] - Pointer to boolean that will receive result of
  370. // lock acquisition
  371. //
  372. // Returns: Nothing
  373. //
  374. // Notes:
  375. //
  376. //--------------------------------------------------------------------------
  377. #define PktAcquireExclusive( WaitOk, Result ) \
  378. { \
  379. KeResetEvent(&DfsData.PktWritePending); \
  380. *(Result) = ExAcquireResourceExclusiveLite( \
  381. &DfsData.Pkt.Resource, \
  382. WaitOk ); \
  383. }
  384. //+-------------------------------------------------------------------------
  385. //
  386. // Function: PktRelease, public inline
  387. //
  388. // Synopsis: PktRelease releases the PKT. It can have been acquired
  389. // for exclusive or shared access.
  390. //
  391. // Arguments: None
  392. //
  393. // Returns: Nothing
  394. //
  395. // Notes:
  396. //
  397. //--------------------------------------------------------------------------
  398. #define PktRelease() \
  399. { \
  400. ExReleaseResourceLite( &DfsData.Pkt.Resource ); \
  401. KeSetEvent( \
  402. &DfsData.PktWritePending, \
  403. 0, \
  404. FALSE); \
  405. }
  406. //+----------------------------------------------------------------------------
  407. //
  408. // Function: PktConvertExclusiveToShared, public inline
  409. //
  410. // Synopsis: Converts an exclusive lock on Pkt to a shared lock
  411. //
  412. // Arguments: None
  413. //
  414. // Returns: Nothing
  415. //
  416. //-----------------------------------------------------------------------------
  417. #define PktConvertExclusiveToShared() \
  418. { \
  419. ExConvertExclusiveToSharedLite( &DfsData.Pkt.Resource ); \
  420. KeSetEvent(&DfsData.PktWritePending, 0, FALSE); \
  421. }
  422. //+----------------------------------------------------------------------------
  423. //
  424. // Function: PKT_LOCKED_FOR_SHARED_ACCESS, public inline
  425. //
  426. // Synopsis: Returns TRUE if Pkt is locked for shared access, FALSE if not
  427. //
  428. // Arguments: None
  429. //
  430. // Returns: TRUE if Pkt is locked for shared access, FALSE otherwise
  431. //
  432. //-----------------------------------------------------------------------------
  433. #define PKT_LOCKED_FOR_SHARED_ACCESS() \
  434. ( ExIsResourceAcquiredSharedLite( &DfsData.Pkt.Resource ) )
  435. //+----------------------------------------------------------------------------
  436. //
  437. // Function: PKT_LOCKED_FOR_EXCLUSIVE_ACCESS, public inline
  438. //
  439. // Synopsis: Returns TRUE if Pkt is locked for exclusive access, FALSE if
  440. // not
  441. //
  442. // Arguments: None
  443. //
  444. // Returns: TRUE if Pkt is locked for exclusive access, FALSE otherwise
  445. //
  446. //-----------------------------------------------------------------------------
  447. #define PKT_LOCKED_FOR_EXCLUSIVE_ACCESS() \
  448. ( ExIsResourceAcquiredExclusiveLite( &DfsData.Pkt.Resource ) )
  449. //+-------------------------------------------------------------------------
  450. //
  451. // Function: PktInvalidateEntry, public inline
  452. //
  453. // Synopsis: PktInvalidateEntry destroys a PKT Entry. The entry cannot
  454. // be local, and it cannot be an exit point.
  455. //
  456. // Arguments: [Pkt] - pointer to an initialized PKT.
  457. // [Victim] - pointer to the entry to be invalidated.
  458. //
  459. // Returns: [STATUS_SUCCESS] - all is well.
  460. // [DFS_STATUS_LOCAL_ENTRY] - an attempt was made to
  461. // invalidate a local entry, or an entry that is a
  462. // local exit point.
  463. //
  464. // Notes:
  465. //
  466. //--------------------------------------------------------------------------
  467. #define PktInvalidateEntry(p, e) ( \
  468. ((e)->Type & (PKT_ENTRY_TYPE_LOCAL|PKT_ENTRY_TYPE_LOCAL_XPOINT)) \
  469. ? (DFS_STATUS_LOCAL_ENTRY) \
  470. : (PktEntryDestroy(e, p, (BOOLEAN)TRUE), STATUS_SUCCESS) \
  471. )
  472. //+-------------------------------------------------------------------------
  473. //
  474. // Function: PktFirstEntry, public inline
  475. //
  476. // Synopsis: PktFirstEntry returns the first entry in the list of
  477. // PKT entries.
  478. //
  479. // Arguments: [Pkt] - pointer to an initialized PKT.
  480. //
  481. // Returns: A pointer to the first entry in the PKT, or NULL if the
  482. // PKT is empty.
  483. //
  484. // Notes:
  485. //
  486. //--------------------------------------------------------------------------
  487. #define PktFirstEntry(p) ( \
  488. ((p)->EntryList.Flink != &(p)->EntryList) \
  489. ? (CONTAINING_RECORD((p)->EntryList.Flink, DFS_PKT_ENTRY, Link)) \
  490. : (NULL) \
  491. )
  492. //+-------------------------------------------------------------------------
  493. //
  494. // Function: PktNextEntry, public inline
  495. //
  496. // Synopsis: PktNextEntry returns the next entry in the list of
  497. // PKT entries.
  498. //
  499. // Arguments: [Pkt] - pointer to an initialized PKT.
  500. // [Entry] - a pointer to the previous entry.
  501. //
  502. // Returns: A pointer to the next entry in the PKT, or NULL if we
  503. // are at the end of the list.
  504. //
  505. // Notes:
  506. //
  507. //--------------------------------------------------------------------------
  508. #define PktNextEntry(p, e) ( \
  509. ((e)->Link.Flink != &(p)->EntryList) \
  510. ? (CONTAINING_RECORD((e)->Link.Flink, DFS_PKT_ENTRY, Link)) \
  511. : (NULL) \
  512. )
  513. //+-------------------------------------------------------------------------
  514. //
  515. // Function: PktFirstSpecialEntry, public inline
  516. //
  517. // Synopsis: PktFirstSpecialEntry returns the first special entry in the list of
  518. // PKT entries.
  519. //
  520. // Arguments: [Pkt] - pointer to an initialized PKT.
  521. //
  522. // Returns: A pointer to the first special entry in the PKT, or NULL if the
  523. // PKT is empty.
  524. //
  525. // Notes:
  526. //
  527. //--------------------------------------------------------------------------
  528. #define PktFirstSpecialEntry(p) ( \
  529. ((p)->SpecialEntryList.Flink != &(p)->SpecialEntryList) \
  530. ? (CONTAINING_RECORD((p)->SpecialEntryList.Flink, DFS_SPECIAL_ENTRY, Link)) \
  531. : (NULL) \
  532. )
  533. //+-------------------------------------------------------------------------
  534. //
  535. // Function: PktNextSpecialEntry, public inline
  536. //
  537. // Synopsis: PktNextSpecialEntry returns the next special entry in the list of
  538. // PKT entries.
  539. //
  540. // Arguments: [Pkt] - pointer to an initialized PKT.
  541. // [Entry] - a pointer to the previous special entry.
  542. //
  543. // Returns: A pointer to the next special entry in the PKT, or NULL if we
  544. // are at the end of the list.
  545. //
  546. // Notes:
  547. //
  548. //--------------------------------------------------------------------------
  549. #define PktNextSpecialEntry(p, e) ( \
  550. ((e)->Link.Flink != &(p)->SpecialEntryList) \
  551. ? (CONTAINING_RECORD((e)->Link.Flink, DFS_SPECIAL_ENTRY, Link)) \
  552. : (NULL) \
  553. )
  554. //+-------------------------------------------------------------------------
  555. //
  556. // Function: PktLinkEntry, public inline
  557. //
  558. // Synopsis: PktLinkEntry links an entry into the list of entries
  559. // in the PKT.
  560. //
  561. // Arguments: [Pkt] - pointer to an initialized PKT.
  562. // [Entry] - a pointer to the entry to be linked in.
  563. //
  564. // Returns: VOID
  565. //
  566. // Notes: Care must be taken to insure that the entry is not already
  567. // linked into the PKT entry list before calling this routine.
  568. // No checking is done to prevent an entry from being linked
  569. // twice...
  570. //
  571. //--------------------------------------------------------------------------
  572. #define PktLinkEntry(p, e) { \
  573. InsertTailList(&(p)->EntryList, &(e)->Link); \
  574. (p)->EntryCount++; \
  575. }
  576. //+-------------------------------------------------------------------------
  577. //
  578. // Function: PktUnlinkEntry, public inline
  579. //
  580. // Synopsis: PktUnlinkEntry unlinks an entry from the list of entries
  581. // in the PKT.
  582. //
  583. // Arguments: [Pkt] - pointer to an initialized PKT.
  584. // [Entry] - a pointer to the entry to be unlinked.
  585. //
  586. // Returns: VOID
  587. //
  588. // Notes: Care must be taken to insure that the entry is in fact
  589. // already linked into the PKT entry list before calling this
  590. // routine. No checking is done to prevent an entry from being
  591. // unlinked twice...
  592. //
  593. //--------------------------------------------------------------------------
  594. #define PktUnlinkEntry(p, e) { \
  595. RemoveEntryList(&(e)->Link); \
  596. (p)->EntryCount--; \
  597. }
  598. #define PktServiceListValidate(e) TRUE
  599. //
  600. // PARTITION KNOWLEDGE TABLE PUBLIC FUNCTIONS (pkt.c)
  601. //
  602. NTSTATUS
  603. PktInitialize(
  604. IN PDFS_PKT Pkt
  605. );
  606. VOID
  607. PktUninitialize(
  608. IN PDFS_PKT Pkt
  609. );
  610. NTSTATUS
  611. PktCreateEntry(
  612. IN PDFS_PKT Pkt,
  613. IN ULONG EntryType,
  614. IN PDFS_PKT_ENTRY_ID PktEntryId,
  615. IN PDFS_PKT_ENTRY_INFO PktEntryInfo OPTIONAL,
  616. IN ULONG CreateDisposition,
  617. IN PDFS_TARGET_INFO pDfsTargetInfo,
  618. OUT PDFS_PKT_ENTRY *ppPktEntry
  619. );
  620. NTSTATUS
  621. PktCreateDomainEntry(
  622. IN PUNICODE_STRING DomainName,
  623. IN PUNICODE_STRING ShareName,
  624. IN BOOLEAN CSCAgentCreate);
  625. NTSTATUS
  626. PktCreateEntryFromReferral(
  627. IN PDFS_PKT Pkt,
  628. IN PUNICODE_STRING ReferralPath,
  629. IN ULONG ReferralSize,
  630. IN PVOID ReferralBuffer,
  631. IN ULONG CreateDisposition,
  632. IN PDFS_TARGET_INFO pDfsTargetInfo,
  633. OUT ULONG *MatchingLength,
  634. OUT ULONG *ReferralType,
  635. OUT PDFS_PKT_ENTRY *ppPktEntry
  636. );
  637. NTSTATUS
  638. PktExpandSpecialEntryFromReferral(
  639. IN PDFS_PKT Pkt,
  640. IN PUNICODE_STRING ReferralPath,
  641. IN ULONG ReferralSize,
  642. IN PVOID ReferralBuffer,
  643. IN PDFS_SPECIAL_ENTRY pSpecialEntry
  644. );
  645. VOID
  646. PktSpecialEntryDestroy(
  647. IN PDFS_SPECIAL_ENTRY pSpecialEntry
  648. );
  649. NTSTATUS
  650. PktCreateSubordinateEntry(
  651. IN PDFS_PKT Pkt,
  652. IN PDFS_PKT_ENTRY Superior,
  653. IN ULONG SubordinateType,
  654. IN PDFS_PKT_ENTRY_ID SubordinateId,
  655. IN PDFS_PKT_ENTRY_INFO SubordinateInfo OPTIONAL,
  656. IN ULONG CreateDisposition,
  657. IN OUT PDFS_PKT_ENTRY *Subordinate
  658. );
  659. PDFS_PKT_ENTRY
  660. PktLookupEntryById(
  661. IN PDFS_PKT Pkt,
  662. IN PDFS_PKT_ENTRY_ID Id
  663. );
  664. PDFS_PKT_ENTRY
  665. PktLookupEntryByPrefix(
  666. IN PDFS_PKT Pkt,
  667. IN PUNICODE_STRING Prefix,
  668. OUT PUNICODE_STRING Remaining
  669. );
  670. PDFS_PKT_ENTRY
  671. PktLookupEntryByShortPrefix(
  672. IN PDFS_PKT Pkt,
  673. IN PUNICODE_STRING Prefix,
  674. OUT PUNICODE_STRING Remaining
  675. );
  676. NTSTATUS
  677. PktEntryModifyPrefix(
  678. IN PDFS_PKT Pkt,
  679. IN PUNICODE_STRING LocalPath,
  680. IN PDFS_PKT_ENTRY Entry
  681. );
  682. PDFS_PKT_ENTRY
  683. PktLookupEntryByUid(
  684. IN PDFS_PKT Pkt,
  685. IN GUID *Uid
  686. );
  687. PDFS_PKT_ENTRY
  688. PktLookupReferralEntry(
  689. IN PDFS_PKT Pkt,
  690. IN PDFS_PKT_ENTRY pEntry
  691. );
  692. PDFS_PKT_ENTRY
  693. PktGetReferralEntryForPath(
  694. PDFS_PKT Pkt,
  695. UNICODE_STRING Path,
  696. ULONG *Type
  697. );
  698. //
  699. // DFS PKT PRIVATE FUNCTIONS (pkt.c)
  700. //
  701. NTSTATUS
  702. PktpOpenDomainService(
  703. IN PDFS_PKT Pkt,
  704. IN PDFS_PKT_ENTRY PktEntry,
  705. IN OUT PHANDLE DomainServiceHandle
  706. );
  707. NTSTATUS
  708. DfsGetMachPktEntry(
  709. UNICODE_STRING Path
  710. );
  711. VOID
  712. RemoveLastComponent(
  713. IN PUNICODE_STRING Prefix,
  714. OUT PUNICODE_STRING newPrefix);
  715. //
  716. // DFS SERVICE PUBLIC FUNCTIONS (pktsup.c)
  717. //
  718. NTSTATUS
  719. PktServiceConstruct(
  720. OUT PDFS_SERVICE Service,
  721. IN ULONG ServiceType,
  722. IN ULONG ServiceCapability,
  723. IN ULONG ServiceStatus,
  724. IN ULONG ServiceProviderId,
  725. IN PUNICODE_STRING ServiceName OPTIONAL,
  726. IN PUNICODE_STRING ServiceAddress OPTIONAL
  727. );
  728. VOID
  729. PktServiceDestroy(
  730. IN PDFS_SERVICE Victim OPTIONAL,
  731. IN BOOLEAN DeallocateAll
  732. );
  733. VOID
  734. DfsDecrementMachEntryCount(
  735. PDFS_MACHINE_ENTRY pMachEntry,
  736. BOOLEAN DeallocateMachine
  737. );
  738. VOID
  739. PktDSMachineDestroy(
  740. IN PDS_MACHINE Victim OPTIONAL,
  741. IN BOOLEAN DeallocateAll
  742. );
  743. VOID
  744. PktDSTransportDestroy(
  745. IN PDS_TRANSPORT Victim OPTIONAL,
  746. IN BOOLEAN DeallocateAll
  747. );
  748. //
  749. // PKT ENTRY ID PUBLIC FUNCTIONS (pktsup.c)
  750. //
  751. NTSTATUS
  752. PktEntryIdConstruct(
  753. OUT PDFS_PKT_ENTRY_ID PktEntryId,
  754. IN GUID *Uid OPTIONAL,
  755. IN UNICODE_STRING *Prefix OPTIONAL
  756. );
  757. VOID
  758. PktEntryIdDestroy(
  759. IN PDFS_PKT_ENTRY_ID Victim OPTIONAL,
  760. IN BOOLEAN DeallocateAll
  761. );
  762. //
  763. // PKT ENTRY ID PUBLIC INLINE FUNCTIONS
  764. //
  765. //+-------------------------------------------------------------------------
  766. //
  767. // Function: PktEntryIdEqual, public inline
  768. //
  769. // Synopsis: PktpEntryIdEqual determines if two entry Ids are equal
  770. // or not.
  771. //
  772. // Arguments: [Id1] - a pointer to an Id to compare.
  773. // [Id2] - a pointer to an Id to compare.
  774. //
  775. // Returns: [TRUE] - if both Ids are equal.
  776. // [FALSE] - if the Ids are not equal.
  777. //
  778. // Notes: The comparison on the Prefix is done case insensitive.
  779. //
  780. //--------------------------------------------------------------------------
  781. #define PktEntryIdEqual(Id1, Id2) ( \
  782. (GuidEqual(&(Id1)->Uid, &(Id2)->Uid)) && \
  783. (RtlEqualUnicodeString(&(Id1)->Prefix, &(Id2)->Prefix, (BOOLEAN)TRUE)) \
  784. )
  785. //
  786. // PKT ENTRY ID PRIVATE INLINE FUNCTIONS
  787. //
  788. //+-------------------------------------------------------------------------
  789. //
  790. // Function: PktpEntryIdMove, private inline
  791. //
  792. // Synopsis: PktpEntryIdMove removes the values from the source Id and
  793. // places them on the destination Id.
  794. //
  795. // Arguments: [DestId] - a pointer to an Id that is to receive the
  796. // sources values.
  797. // [SrcId] - a pointer to an Id that is to be stripped of
  798. // its values.
  799. //
  800. // Returns: VOID
  801. //
  802. // Notes: Any values that are currently on the destination Id are
  803. // overwritten. No memory is freed (either on the source,
  804. // or the destination) by this call.
  805. //
  806. //--------------------------------------------------------------------------
  807. #define PktpEntryIdMove(DestId, SrcId) { \
  808. (*(DestId)) = (*(SrcId)); \
  809. (SrcId)->Prefix.Length = (SrcId)->Prefix.MaximumLength = 0; \
  810. (SrcId)->Prefix.Buffer = NULL; \
  811. (SrcId)->ShortPrefix.Length = (SrcId)->ShortPrefix.MaximumLength = 0; \
  812. (SrcId)->ShortPrefix.Buffer = NULL; \
  813. }
  814. //
  815. // PKT ENTRY INFO PUBLIC FUNCTIONS (pktsup.c)
  816. //
  817. //NTSTATUS
  818. //PktEntryInfoConstruct(
  819. // OUT PDFS_PKT_ENTRY_INFO PktEntryInfo,
  820. // IN PULONG ExpireTime OPTIONAL,
  821. // IN ULONG ServiceCount,
  822. // IN PDFS_SERVICE ServiceList OPTIONAL
  823. // );
  824. VOID
  825. PktEntryInfoDestroy(
  826. IN PDFS_PKT_ENTRY_INFO Victim OPTIONAL,
  827. IN BOOLEAN DeallocateAll
  828. );
  829. //
  830. // PKT ENTRY INFO PRIVATE INLINE FUNCTIONS
  831. //
  832. //
  833. // The following inlines operate on Entry Infos
  834. //
  835. //+-------------------------------------------------------------------------
  836. //
  837. // Function: PktpEntryInfoMove, private inline
  838. //
  839. // Synopsis: PktpEntryInfoMove removes the values from the source Info and
  840. // places them on the destination Info.
  841. //
  842. // Arguments: [DestInfo] - a pointer to an Info that is to receive the
  843. // sources values.
  844. // [SrcInfo] - a pointer to an Info that is to be stripped of
  845. // its values.
  846. //
  847. // Returns: VOID
  848. //
  849. // Notes: Any values that are currently on the destination Info are
  850. // overwritten. No memory is freed (either on the source,
  851. // or the destination) by this call.
  852. //
  853. //--------------------------------------------------------------------------
  854. #define PktpEntryInfoMove(DestInfo, SrcInfo) { \
  855. (*(DestInfo)) = (*(SrcInfo)); \
  856. (SrcInfo)->ServiceCount = 0L; \
  857. (SrcInfo)->ServiceList = NULL; \
  858. }
  859. //
  860. // PKT ENTRY PUBLIC INLINE FUNCTIONS
  861. //
  862. //+-------------------------------------------------------------------------
  863. //
  864. // Function: PktEntryFirstSubordinate, public inline
  865. //
  866. // Synopsis: PktEntryFirstSubordinate returns the first entry in the
  867. // list of subordinates.
  868. //
  869. // Arguments: [Superior] - pointer to a PKT entry.
  870. //
  871. // Returns: A pointer to the first entry in the list of subordinates,
  872. // or NULL if the list is empty.
  873. //
  874. // Notes:
  875. //
  876. //--------------------------------------------------------------------------
  877. #define PktEntryFirstSubordinate(s) ( \
  878. ((s)->SubordinateList.Flink != &(s)->SubordinateList) \
  879. ? (CONTAINING_RECORD((s)->SubordinateList.Flink, DFS_PKT_ENTRY, \
  880. SiblingLink)) \
  881. : (NULL) \
  882. )
  883. //+-------------------------------------------------------------------------
  884. //
  885. // Function: PktEntryNextSubordinate, public inline
  886. //
  887. // Synopsis: PktEntryNextSubordinate returns the next entry in the
  888. // list of subordinates.
  889. //
  890. // Arguments: [Superior] - pointer to the superior PKT entry (the one
  891. // which we are getting the subordinates for).
  892. // [Subordinate] - pointer to the last subordinate retreived
  893. // via this routine (or PktEntryFirstSubordinate).
  894. //
  895. // Returns: A pointer to the next entry in the list of subordinates,
  896. // or NULL if we've hit the end of the list.
  897. //
  898. // Notes:
  899. //
  900. //--------------------------------------------------------------------------
  901. #define PktEntryNextSubordinate(s, m) ( \
  902. ((m)->SiblingLink.Flink != &(s)->SubordinateList) \
  903. ? (CONTAINING_RECORD((m)->SiblingLink.Flink,DFS_PKT_ENTRY,SiblingLink))\
  904. : (NULL) \
  905. )
  906. //+-------------------------------------------------------------------------
  907. //
  908. // Function: PktEntryLinkSubordinate, public inline
  909. //
  910. // Synopsis: PktEntryLinkSubordinate links a subordinate to a superior's
  911. // list of subordinates.
  912. //
  913. // Arguments: [Superior] - pointer to the superior PKT entry.
  914. // [Subordinate] - pointer to the subordinate to be linked in.
  915. //
  916. // Returns: VOID
  917. //
  918. // Notes: If the subordinate is part of another superior's list, it
  919. // will be removed from that list as a by-product of being
  920. // put on the specified Superior's list. The Superior pointer
  921. // of the subordinate is adjusted appropriately.
  922. //
  923. // If the superior is a local entry, the subordinate will
  924. // be modified to indicate that it is a local exit point.
  925. //
  926. //--------------------------------------------------------------------------
  927. #define PktEntryLinkSubordinate(sup, sub) { \
  928. while(1) { \
  929. if((sub)->Superior == (sup)) \
  930. break; \
  931. if((sub)->Superior != NULL) \
  932. PktEntryUnlinkSubordinate((sub)->Superior, (sub)); \
  933. InsertTailList(&(sup)->SubordinateList, &(sub)->SiblingLink); \
  934. (sup)->SubordinateCount++; \
  935. (sub)->Superior = (sup); \
  936. if((sup)->Type & PKT_ENTRY_TYPE_LOCAL) \
  937. (sub)->Type |= PKT_ENTRY_TYPE_LOCAL_XPOINT; \
  938. break; \
  939. } \
  940. }
  941. //+-------------------------------------------------------------------------
  942. //
  943. // Function: PktEntryUnlinkSubordinate, public inline
  944. //
  945. // Synopsis: PktEntryUnlinkSubordinate unlinks a subordinate from a
  946. // superior's list of subordinates.
  947. //
  948. // Arguments: [Superior] - pointer to the superior PKT entry.
  949. // [Subordinate] - pointer to the subordinate to be unlinked.
  950. //
  951. // Returns: VOID
  952. //
  953. // Notes: The Superior pointer of the subordinate is NULLed as a
  954. // by-product of this operation.
  955. //
  956. // By default, the subordinate is modified to indicate that
  957. // it is not an exit point (it cannot be an exit point if it
  958. // has no superior).
  959. //
  960. // Milans - We need to turn off the PKT_ENTRY_TYPE_PERMANENT
  961. // bit if the PKT_ENTRY_TYPE_LOCAL bit is not set, and we are
  962. // not the DC. If we decide that a machine can be a server for
  963. // a volume in another domain, then we need to do something
  964. // about the != DS_DC clause.
  965. //
  966. //--------------------------------------------------------------------------
  967. #define PktEntryUnlinkSubordinate(sup, sub) { \
  968. ASSERT((sub)->Superior == (sup)); \
  969. ASSERT((sup)->SubordinateCount > 0); \
  970. RemoveEntryList(&(sub)->SiblingLink); \
  971. (sup)->SubordinateCount--; \
  972. (sub)->Superior = NULL; \
  973. (sub)->Type &= ~PKT_ENTRY_TYPE_LOCAL_XPOINT; \
  974. if ( DfsData.MachineState != DFS_ROOT_SERVER && \
  975. (((sub)->Type & PKT_ENTRY_TYPE_LOCAL) == 0) ) { \
  976. (sub)->Type &= ~PKT_ENTRY_TYPE_PERMANENT; \
  977. } \
  978. }
  979. //
  980. // The following set of inline functions work on the Links maintained in
  981. // the PKT to be able to get to referral entries for interdomain stuff real
  982. // fast. These functions are similar to the above functions.
  983. //
  984. //+-------------------------------------------------------------------------
  985. //
  986. // Function: PktEntryFirstChild, public inline
  987. //
  988. // Synopsis: PktEntryFirstChild returns the first entry in the
  989. // list of child links of a PKT entry.
  990. //
  991. // Arguments: [SuperiorDC] - pointer to a PKT entry.
  992. //
  993. // Returns: A pointer to the first entry in the list of children,
  994. // or NULL if the list is empty.
  995. //
  996. // Notes:
  997. //
  998. //--------------------------------------------------------------------------
  999. #define PktEntryFirstChild(s) ( \
  1000. ((s)->ChildList.Flink != &(s)->ChildList) \
  1001. ? (CONTAINING_RECORD((s)->ChildList.Flink,DFS_PKT_ENTRY,NextLink)) \
  1002. : (NULL) \
  1003. )
  1004. //+-------------------------------------------------------------------------
  1005. //
  1006. // Function: PktEntryNextChild, public inline
  1007. //
  1008. // Synopsis: PktEntryNextChild returns the next entry in the
  1009. // list of children.
  1010. //
  1011. // Arguments: [Superior] - pointer to the superior PKT entry (the one
  1012. // which we are getting the subordinates for).
  1013. // [Subordinate] - pointer to the last child retreived
  1014. // via this routine (or PktEntryFirstChild).
  1015. //
  1016. // Returns: A pointer to the next entry in the list of children,
  1017. // or NULL if we've hit the end of the list.
  1018. //
  1019. // Notes:
  1020. //
  1021. //--------------------------------------------------------------------------
  1022. #define PktEntryNextChild(s, m) ( \
  1023. ((m)->NextLink.Flink != &(s)->ChildList) \
  1024. ? (CONTAINING_RECORD((m)->NextLink.Flink,DFS_PKT_ENTRY,NextLink)) \
  1025. : (NULL) \
  1026. )
  1027. //+-------------------------------------------------------------------------
  1028. //
  1029. // Function: PktEntryLinkChild, public inline
  1030. //
  1031. // Synopsis: PktEntryLinkChild links a child to a closestDC's
  1032. // list of children.
  1033. //
  1034. // Arguments: [Superior] - pointer to the superior PKT entry.
  1035. // [Subordinate] - pointer to the subordinate to be linked in.
  1036. //
  1037. // Returns: VOID
  1038. //
  1039. // Notes: If the child is part of another superior's list, it
  1040. // will be removed from that list as a by-product of being
  1041. // put on the specified Superior's list. The Superior pointer
  1042. // of the child is adjusted appropriately.
  1043. //
  1044. //
  1045. //--------------------------------------------------------------------------
  1046. #define PktEntryLinkChild(sup, sub) { \
  1047. while(1) { \
  1048. if (sub == sup) { \
  1049. (sub)->ClosestDC = NULL; \
  1050. break; \
  1051. } \
  1052. if((sub)->ClosestDC == (sup)) \
  1053. break; \
  1054. if((sub)->ClosestDC != NULL) \
  1055. PktEntryUnlinkChild((sub)->ClosestDC, (sub)); \
  1056. InsertTailList(&(sup)->ChildList, &(sub)->NextLink); \
  1057. (sub)->ClosestDC = (sup); \
  1058. break; \
  1059. } \
  1060. }
  1061. //+-------------------------------------------------------------------------
  1062. //
  1063. // Function: PktEntryUnlinkChild, public inline
  1064. //
  1065. // Synopsis: PktEntryUnlinkChild unlinks a child from a
  1066. // superior's list of children.
  1067. //
  1068. // Arguments: [Superior] - pointer to the superior PKT entry.
  1069. // [Subordinate] - pointer to the subordinate to be unlinked.
  1070. //
  1071. // Returns: VOID
  1072. //
  1073. // Notes: The Superior pointer of the child is NULLed as a
  1074. // by-product of this operation.
  1075. //
  1076. //
  1077. //--------------------------------------------------------------------------
  1078. #define PktEntryUnlinkChild(sup, sub) { \
  1079. ASSERT((sub)->ClosestDC == (sup)); \
  1080. RemoveEntryList(&(sub)->NextLink); \
  1081. (sub)->ClosestDC = NULL; \
  1082. }
  1083. //+-------------------------------------------------------------------------
  1084. //
  1085. // Function: PktEntryUnlinkAndRelinkChild, public inline
  1086. //
  1087. // Synopsis: PktEntryUnlinkAndRelinkChild unlinks a child from a
  1088. // superior's list of children and relinks it to the parent of
  1089. // the superior.
  1090. //
  1091. // Arguments: [Superior] - pointer to the superior PKT entry.
  1092. // [Subordinate] - pointer to the subordinate to be unlinked.
  1093. //
  1094. // Returns: VOID
  1095. //
  1096. //--------------------------------------------------------------------------
  1097. #define PktEntryUnlinkAndRelinkChild(sup, sub) { \
  1098. PktEntryUnlinkChild(sup, sub); \
  1099. if ((sup)->ClosestDC != NULL) { \
  1100. PktEntryLinkChild((sup)->ClosestDC, sub); \
  1101. } \
  1102. }
  1103. //
  1104. // PKT ENTRY PUBLIC FUNCTIONS (pktsup.c)
  1105. //
  1106. NTSTATUS
  1107. PktEntryAssemble(
  1108. IN OUT PDFS_PKT_ENTRY Entry,
  1109. IN PDFS_PKT Pkt,
  1110. IN ULONG EntryType,
  1111. IN PDFS_PKT_ENTRY_ID EntryId,
  1112. IN PDFS_PKT_ENTRY_INFO EntryInfo OPTIONAL,
  1113. IN PDFS_TARGET_INFO pDfsTargetInfo
  1114. );
  1115. NTSTATUS
  1116. PktEntryReassemble(
  1117. IN OUT PDFS_PKT_ENTRY Entry,
  1118. IN PDFS_PKT Pkt OPTIONAL,
  1119. IN ULONG EntryType,
  1120. IN PDFS_PKT_ENTRY_ID EntryId OPTIONAL,
  1121. IN PDFS_PKT_ENTRY_INFO EntryInfo OPTIONAL,
  1122. IN PDFS_TARGET_INFO pDfsTargetInfo
  1123. );
  1124. VOID
  1125. PktEntryDestroy(
  1126. IN PDFS_PKT_ENTRY Victim OPTIONAL,
  1127. IN PDFS_PKT Pkt,
  1128. IN BOOLEAN DeallocateAll
  1129. );
  1130. VOID
  1131. PktEntryClearSubordinates(
  1132. IN PDFS_PKT_ENTRY PktEntry
  1133. );
  1134. VOID
  1135. PktEntryClearChildren(
  1136. IN PDFS_PKT_ENTRY PktEntry
  1137. );
  1138. NTSTATUS
  1139. PktEntryCreateReferral(
  1140. IN PDFS_PKT_ENTRY PktEntry,
  1141. IN ULONG ServiceTypes,
  1142. IN PVOID ReferralBuffer
  1143. );
  1144. VOID
  1145. PktParsePath(
  1146. IN PUNICODE_STRING PathName,
  1147. OUT PUNICODE_STRING MachineName,
  1148. OUT PUNICODE_STRING ShareName,
  1149. OUT PUNICODE_STRING Remainder OPTIONAL
  1150. );
  1151. NTSTATUS
  1152. PktExpandSpecialName(
  1153. IN PUNICODE_STRING Name,
  1154. OUT PDFS_SPECIAL_ENTRY *ppSpecialEntry
  1155. );
  1156. PDFS_SPECIAL_ENTRY
  1157. PktLookupSpecialNameEntry(
  1158. PUNICODE_STRING Name
  1159. );
  1160. NTSTATUS
  1161. PktCreateSpecialNameEntry(
  1162. PDFS_SPECIAL_ENTRY pSpecialEntry
  1163. );
  1164. NTSTATUS
  1165. PktGetDCName(
  1166. ULONG Flags
  1167. );
  1168. NTSTATUS
  1169. PktGetSpecialReferralTable(
  1170. PUNICODE_STRING Machine,
  1171. BOOLEAN Type
  1172. );
  1173. NTSTATUS
  1174. PktCreateSpecialEntryTableFromReferral(
  1175. IN PDFS_PKT Pkt,
  1176. IN PUNICODE_STRING ReferralPath,
  1177. IN ULONG ReferralSize,
  1178. IN PVOID ReferralBuffer,
  1179. IN PUNICODE_STRING DCName
  1180. );
  1181. NTSTATUS
  1182. PktEntryFromSpecialEntry(
  1183. IN PDFS_SPECIAL_ENTRY pSpecialEntry,
  1184. IN PUNICODE_STRING pShareName,
  1185. OUT PDFS_PKT_ENTRY *ppPktEntry
  1186. );
  1187. PDFS_PKT_ENTRY
  1188. PktFindEntryByPrefix(
  1189. IN PDFS_PKT Pkt,
  1190. IN PUNICODE_STRING Prefix
  1191. );
  1192. #endif // NOT _UPKT_
  1193. #endif // _PKT_