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.

427 lines
11 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. tdi.h
  5. Abstract:
  6. This module defines all the constructs that are used when referencing
  7. the TDI (Transport Driver Interface) driver in NT.
  8. Author:
  9. Larry Osterman (LarryO) 1-Jun-1990
  10. Revision History:
  11. 1-Jun-1990 LarryO
  12. Created
  13. --*/
  14. #ifndef _BOWTDI_
  15. #define _BOWTDI_
  16. struct _TRANSPORT;
  17. struct _TRANSPORT_NAME;
  18. struct _BOWSER_TIMER;
  19. typedef enum {
  20. None,
  21. PotentialBackup,
  22. Backup,
  23. Master
  24. } BROWSERROLE, *PBROWSERROLES;
  25. typedef enum {
  26. Idle,
  27. ElectionInProgress,
  28. RunningElection,
  29. DeafToElections // Set if no become master IRPs outstanding.
  30. } ELECTIONROLE, *PELECTIONROLE;
  31. struct _PAGED_TRANSPORT;
  32. struct _PAGED_TRANSPORT_NAME;
  33. typedef struct _TRANSPORT {
  34. CSHORT Signature; // Structure signature.
  35. CSHORT Size; // Structure size in bytes.
  36. ULONG ReferenceCount; // Reference count for structure.
  37. struct _PAGED_TRANSPORT *PagedTransport;
  38. struct _TRANSPORT_NAME *ComputerName; // Computer name.
  39. struct _TRANSPORT_NAME *PrimaryDomain;// Primary domain.
  40. struct _TRANSPORT_NAME *AltPrimaryDomain;// Primary domain.
  41. struct _TRANSPORT_NAME *MasterBrowser;// Master browser name.
  42. struct _TRANSPORT_NAME *BrowserElection;// Master browser name.
  43. PDOMAIN_INFO DomainInfo; // Domain being emulated.
  44. ULONG DatagramSize; // Size of largest DG in bytes.
  45. //
  46. // The token is used to match incoming getbrowserserverlist responses with
  47. // the request that they are associated with.
  48. //
  49. // It is protected by the backup list spin lock, and is incremented every
  50. // time we send a GetBackupList request.
  51. //
  52. ULONG BrowserServerListToken; // Token for GetBrowserList request.
  53. PFILE_OBJECT IpxSocketFileObject;
  54. PDEVICE_OBJECT IpxSocketDeviceObject;
  55. PBACKUP_LIST_RESPONSE_1 BowserBackupList;
  56. //
  57. // Role of workstation in election.
  58. //
  59. ELECTIONROLE ElectionState;
  60. ERESOURCE AnnounceTableLock; // Lock for announce table.
  61. ERESOURCE Lock; // Lock protecting fields below.
  62. BOWSER_TIMER ElectionTimer;
  63. BOWSER_TIMER FindMasterTimer;
  64. //
  65. // List of browser servers active
  66. //
  67. ERESOURCE BrowserServerListResource;// Resource protecting BrowserServerList.
  68. KEVENT GetBackupListComplete;
  69. IRP_QUEUE BecomeBackupQueue;
  70. IRP_QUEUE BecomeMasterQueue;
  71. IRP_QUEUE FindMasterQueue;
  72. IRP_QUEUE WaitForMasterAnnounceQueue;
  73. IRP_QUEUE ChangeRoleQueue;
  74. IRP_QUEUE WaitForNewMasterNameQueue;
  75. } TRANSPORT, *PTRANSPORT;
  76. typedef struct _PAGED_TRANSPORT {
  77. CSHORT Signature; // Structure signature.
  78. CSHORT Size; // Structure size in bytes.
  79. PTRANSPORT NonPagedTransport;
  80. LIST_ENTRY GlobalNext; // Pointer to next transport.
  81. LIST_ENTRY NameChain; // List of names bound to this xport.
  82. UNICODE_STRING TransportName; // Name of transport
  83. ULONG NumberOfBrowserServers; // Number of browser servers in table.
  84. ULONG NumberOfServersInTable; // Number of servers in browser svc.
  85. RTL_GENERIC_TABLE AnnouncementTable; // Announcement table for xport
  86. RTL_GENERIC_TABLE DomainTable; // Domain table for xport
  87. LIST_ENTRY BackupBrowserList; // List of active backup browsers.
  88. ULONG NumberOfBackupServerListEntries;
  89. HANDLE IpxSocketHandle;
  90. //
  91. // WinBALL compatible browser fields.
  92. //
  93. BROWSERROLE Role; // Role of browser in domain.
  94. ULONG ServiceStatus; // Status of browser service.
  95. ULONG ElectionCount;
  96. ULONG ElectionsSent; // Number of election requests sent.
  97. ULONG NextElection;
  98. ULONG Uptime;
  99. ULONG TimeLastLost;
  100. ULONG ElectionCriteria;
  101. ULONG TimeMaster; // The time we became the master.
  102. ULONG LastElectionSeen; // The last time we saw an election.
  103. ULONG OtherMasterTime; // Next time we can complain about another master browser
  104. UNICODE_STRING MasterName;
  105. STRING MasterBrowserAddress;
  106. PWCHAR *BrowserServerListBuffer; // Buffer containing browser server names
  107. ULONG BrowserServerListLength; // Number of browser servers in list.
  108. ULONG IpSubnetNumber; //
  109. USHORT Flags; // Flags for transport.
  110. #define ELECT_LOST_LAST_ELECTION 0x0001 // True if we lost the last election.
  111. #define DIRECT_HOST_IPX 0x8000 // True if Xport is a direct host IPX
  112. BOOLEAN Wannish; // True if transport is wannish.
  113. BOOLEAN PointToPoint; // True if transport is a gateway (RAS).
  114. BOOLEAN IsPrimaryDomainController; // True if transport has the Domain[1B] name registered
  115. BOOLEAN DisabledTransport; // True if transport is disabled
  116. BOOLEAN DeletedTransport; // True if transport has been deleted
  117. } PAGED_TRANSPORT, *PPAGED_TRANSPORT;
  118. typedef struct _TRANSPORT_NAME {
  119. USHORT Signature; // Structure signature.
  120. USHORT Size; // Structure size in bytes.
  121. CHAR NameType;
  122. BOOLEAN ProcessHostAnnouncements; // TRUE if processing announcements.
  123. LONG ReferenceCount; // Reference count for T.N.
  124. struct _PAGED_TRANSPORT_NAME *PagedTransportName;
  125. PTRANSPORT Transport;
  126. PFILE_OBJECT FileObject; // File object for transport device
  127. PDEVICE_OBJECT DeviceObject; // Device object for transport
  128. ANSI_STRING TransportAddress; // Transport address for user.
  129. } TRANSPORT_NAME, *PTRANSPORT_NAME;
  130. typedef struct _PAGED_TRANSPORT_NAME {
  131. CSHORT Signature; // Structure signature.
  132. CSHORT Size; // Structure size in bytes.
  133. PTRANSPORT_NAME NonPagedTransportName;
  134. PBOWSER_NAME Name;
  135. LIST_ENTRY TransportNext; // Pointer to next name on transport.
  136. LIST_ENTRY NameNext; // Pointer to next name on bowser name.
  137. HANDLE Handle; // Handle to transport endpoint
  138. } PAGED_TRANSPORT_NAME, *PPAGED_TRANSPORT_NAME;
  139. #define LOCK_TRANSPORT(Transport) \
  140. ExAcquireResourceExclusiveLite(&(Transport)->Lock, TRUE);
  141. #define LOCK_TRANSPORT_SHARED(Transport) \
  142. ExAcquireResourceSharedLite(&(Transport)->Lock, TRUE);
  143. #define UNLOCK_TRANSPORT(Transport) \
  144. ExReleaseResourceLite(&(Transport)->Lock);
  145. #define INITIALIZE_ANNOUNCE_DATABASE(Transport) \
  146. ExInitializeResourceLite(&Transport->AnnounceTableLock);
  147. #define UNINITIALIZE_ANNOUNCE_DATABASE(Transport) \
  148. ExDeleteResourceLite(&Transport->AnnounceTableLock);
  149. #define LOCK_ANNOUNCE_DATABASE_SHARED(Transport) \
  150. ExAcquireResourceSharedLite(&Transport->AnnounceTableLock,\
  151. TRUE \
  152. );
  153. #define LOCK_ANNOUNCE_DATABASE(Transport) \
  154. ExAcquireResourceExclusiveLite(&Transport->AnnounceTableLock,\
  155. TRUE \
  156. );
  157. #define UNLOCK_ANNOUNCE_DATABASE(Transport) \
  158. ExReleaseResourceLite(&Transport->AnnounceTableLock);
  159. //
  160. // The first parameter to the BowserEnumerateTransports routine.
  161. //
  162. typedef
  163. NTSTATUS
  164. (*PTRANSPORT_ENUM_ROUTINE) (
  165. IN PTRANSPORT Transport,
  166. IN OUT PVOID Context
  167. );
  168. typedef
  169. NTSTATUS
  170. (*PTRANSPORT_NAME_ENUM_ROUTINE) (
  171. IN PTRANSPORT_NAME Transport,
  172. IN OUT PVOID Context
  173. );
  174. //
  175. // TDI Interface routines
  176. //
  177. NTSTATUS
  178. BowserTdiAllocateTransport (
  179. PUNICODE_STRING TransportName,
  180. PUNICODE_STRING EmulatedDomainName,
  181. PUNICODE_STRING EmulatedComputerName
  182. );
  183. PTRANSPORT_NAME
  184. BowserFindTransportName(
  185. IN PTRANSPORT Transport,
  186. IN PBOWSER_NAME Name
  187. );
  188. NTSTATUS
  189. BowserCreateTransportName (
  190. IN PTRANSPORT Transport,
  191. IN PBOWSER_NAME Name
  192. );
  193. NTSTATUS
  194. BowserFreeTransportByName (
  195. IN PUNICODE_STRING TransportName,
  196. IN PUNICODE_STRING EmulatedDomainName
  197. );
  198. NTSTATUS
  199. BowserUnbindFromAllTransports(
  200. VOID
  201. );
  202. NTSTATUS
  203. BowserDeleteTransportNameByName(
  204. IN PTRANSPORT Transport,
  205. IN PUNICODE_STRING Name,
  206. IN DGRECEIVER_NAME_TYPE NameType
  207. );
  208. NTSTATUS
  209. BowserEnumerateTransports (
  210. OUT PVOID OutputBuffer,
  211. OUT ULONG OutputBufferLength,
  212. IN OUT PULONG EntriesRead,
  213. IN OUT PULONG TotalEntries,
  214. IN OUT PULONG TotalBytesNeeded,
  215. IN ULONG_PTR OutputBufferDisplacement);
  216. PTRANSPORT
  217. BowserFindTransport (
  218. IN PUNICODE_STRING TransportName,
  219. IN PUNICODE_STRING EmulatedDomainName OPTIONAL
  220. );
  221. VOID
  222. BowserReferenceTransport (
  223. IN PTRANSPORT Transport
  224. );
  225. VOID
  226. BowserDereferenceTransport (
  227. IN PTRANSPORT Transport
  228. );
  229. VOID
  230. BowserReferenceTransportName(
  231. IN PTRANSPORT_NAME TransportName
  232. );
  233. NTSTATUS
  234. BowserDereferenceTransportName(
  235. IN PTRANSPORT_NAME TransportName
  236. );
  237. NTSTATUS
  238. BowserSendRequestAnnouncement(
  239. IN PUNICODE_STRING DestinationName,
  240. IN DGRECEIVER_NAME_TYPE NameType,
  241. IN PTRANSPORT Transport
  242. );
  243. VOID
  244. BowserpInitializeTdi (
  245. VOID
  246. );
  247. VOID
  248. BowserpUninitializeTdi (
  249. VOID
  250. );
  251. NTSTATUS
  252. BowserBuildTransportAddress (
  253. OUT PANSI_STRING RemoteAddress,
  254. IN PUNICODE_STRING Name,
  255. IN DGRECEIVER_NAME_TYPE NameType,
  256. IN PTRANSPORT Transport
  257. );
  258. NTSTATUS
  259. BowserFreeTransportName(
  260. IN PTRANSPORT_NAME TransportName
  261. );
  262. NTSTATUS
  263. BowserForEachTransportInDomain (
  264. IN PDOMAIN_INFO DomainInfo,
  265. IN PTRANSPORT_ENUM_ROUTINE Routine,
  266. IN OUT PVOID Context
  267. );
  268. NTSTATUS
  269. BowserForEachTransport (
  270. IN PTRANSPORT_ENUM_ROUTINE Routine,
  271. IN OUT PVOID Context
  272. );
  273. NTSTATUS
  274. BowserForEachTransportName (
  275. IN PTRANSPORT Transport,
  276. IN PTRANSPORT_NAME_ENUM_ROUTINE Routine,
  277. IN OUT PVOID Context
  278. );
  279. NTSTATUS
  280. BowserSendSecondClassMailslot (
  281. IN PTRANSPORT Transport,
  282. IN PVOID RecipientAddress,
  283. IN DGRECEIVER_NAME_TYPE NameType,
  284. IN PVOID Message,
  285. IN ULONG MessageLength,
  286. IN BOOLEAN WaitForCompletion,
  287. IN PCHAR mailslotNameData,
  288. IN PSTRING DestinationAddress OPTIONAL
  289. );
  290. NTSTATUS
  291. BowserUpdateProviderInformation(
  292. IN OUT PPAGED_TRANSPORT PagedTransport
  293. );
  294. NTSTATUS
  295. BowserSetDomainName(
  296. PDOMAIN_INFO DomainInfo,
  297. PUNICODE_STRING DomainName
  298. );
  299. NTSTATUS
  300. BowserAddDefaultNames(
  301. IN PTRANSPORT Transport,
  302. IN PVOID Context
  303. );
  304. NTSTATUS
  305. BowserDeleteDefaultDomainNames(
  306. IN PTRANSPORT Transport,
  307. IN PVOID Context
  308. );
  309. ULONG
  310. BowserTransportFlags(
  311. IN PPAGED_TRANSPORT PagedTransport
  312. );
  313. extern
  314. LIST_ENTRY
  315. BowserTransportHead;
  316. extern
  317. ERESOURCE
  318. BowserTransportDatabaseResource;
  319. #endif // _BOWTDI_