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

344 lines
7.7 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. browsenet.h
  5. Abstract:
  6. Private header file to be included by Browser service modules that
  7. need to deal with the network specific browser tables.
  8. Author:
  9. Rita Wong (ritaw) 22-May-1991
  10. Revision History:
  11. --*/
  12. #ifndef _BROWSENET_INCLUDED_
  13. #define _BROWSENET_INCLUDED_
  14. #define NETWORK_BECOME_MASTER_POSTED 0x00000001
  15. #define NETWORK_ANNOUNCE_NEEDED 0x00000002
  16. #define NETWORK_GET_MASTER_ANNOUNCE_POSTED 0x00000008
  17. #define NETWORK_WANNISH 0x80000000
  18. #define NETWORK_RAS 0x40000000
  19. #define NETWORK_IPX 0x20000000
  20. #define NETWORK_BOUND 0x10000000
  21. #define NETWORK_PDC 0x08000000
  22. #define OTHERDOMAIN_INVALID 0x00000001
  23. typedef struct _NET_OTHER_DOMAIN {
  24. LIST_ENTRY Next;
  25. ULONG Flags;
  26. WCHAR Name[DNLEN+1];
  27. } NET_OTHER_DOMAIN, *PNET_OTHER_DOMAIN;
  28. //
  29. // Network.
  30. //
  31. // Almost all of the browser data structures are tied to the "Network"
  32. // structure.
  33. //
  34. // It contains the browse list for the network and information about the
  35. // domain (including the name of the master, etc).
  36. //
  37. typedef struct _NETWORK {
  38. //
  39. // The Lock protects the contents of the network structure, including
  40. // the browse list, backup list and domain list.
  41. //
  42. RTL_RESOURCE Lock;
  43. LONG LockCount;
  44. ULONG Flags;
  45. //
  46. // The NextNet list links the structure to other networks.
  47. //
  48. LIST_ENTRY NextNet;
  49. //
  50. // Domain this network is specific to
  51. //
  52. PDOMAIN_INFO DomainInfo;
  53. //
  54. // The ReferenceCount indicates the number of threads accessing this
  55. // network structure.
  56. //
  57. ULONG ReferenceCount;
  58. //
  59. // The NetworkName is the name of the network driver that is used
  60. // to access the network. This is used to identify the network
  61. // to the bowser driver so it can return the correct network list.
  62. //
  63. UNICODE_STRING NetworkName; // Name of network (\Device\Nbf)
  64. struct _NETWORK *AlternateNetwork; // Alternate name for network (if IPX).
  65. //
  66. // This is a bitmask indicating the role of this browser server.
  67. //
  68. ULONG Role;
  69. ULONG MasterAnnouncementIndex;
  70. ULONG UpdateAnnouncementIndex;
  71. ULONG NumberOfFailedBackupTimers;
  72. ULONG NumberOfFailedPromotions;
  73. ULONG NumberOfPromotionEventsLogged;
  74. LONG LastBackupBrowserReturned;
  75. LONG LastDomainControllerBrowserReturned;
  76. //
  77. // The time we stopped being a backup browser.
  78. //
  79. ULONG TimeStoppedBackup;
  80. //
  81. // The UncMasterBrowserName contains the name of the master browser server
  82. // for this network.
  83. //
  84. WCHAR UncMasterBrowserName[UNCLEN+1]; // Name of master browser server
  85. //
  86. // Timer used when server is a backup browser server.
  87. //
  88. // When it expires, the browser downloads a new browser server
  89. // list from the master browser server.
  90. //
  91. BROWSER_TIMER BackupBrowserTimer;
  92. //
  93. // Timer used if SMB server refuses an announcement
  94. //
  95. BROWSER_TIMER UpdateAnnouncementTimer;
  96. //
  97. // Server and domain list for backup browser (and # of entries in each).
  98. //
  99. PSERVER_INFO_101 BackupServerList;
  100. DWORD TotalBackupServerListEntries;
  101. DWORD BytesToHoldBackupServerList;
  102. PSERVER_INFO_101 BackupDomainList;
  103. DWORD TotalBackupDomainListEntries;
  104. DWORD BytesToHoldBackupDomainList;
  105. //
  106. // Lock protecting MasterFlags section of Network structure.
  107. //
  108. ULONG MasterFlags;
  109. ULONG MasterBrowserTimerCount; // # of times we've run the master timer.
  110. //
  111. // Master browsers maintain their server list in an "interim server
  112. // list", not as raw data from the server.
  113. //
  114. ULONG LastBowserServerQueried;
  115. INTERIM_SERVER_LIST BrowseTable; // Browse list for network.
  116. ULONG LastBowserDomainQueried;
  117. INTERIM_SERVER_LIST DomainList; // List of domains active on network
  118. //
  119. // If the browser's role is MasterBrowserServer, then the
  120. // OtherDomainsList contains the list of other domains.
  121. //
  122. LIST_ENTRY OtherDomainsList; // List of domain master browser.
  123. //
  124. // Timer used when server is a master browser server.
  125. //
  126. // When it expires, the master browser downloads a new browser
  127. // server list from the domain master browser server
  128. //
  129. BROWSER_TIMER MasterBrowserTimer;
  130. //
  131. // Timer used to announce the domain.
  132. //
  133. BROWSER_TIMER MasterBrowserAnnouncementTimer;
  134. //
  135. // List of cached browser responses.
  136. //
  137. CRITICAL_SECTION ResponseCacheLock;
  138. LIST_ENTRY ResponseCache;
  139. //
  140. // For browse masters, this is the time the cache was last flushed.
  141. //
  142. // Every <n> seconds, we will age the cache on the master and refresh
  143. // the list with the list from the driver.
  144. //
  145. DWORD TimeCacheFlushed;
  146. DWORD NumberOfCachedResponses;
  147. // How many times have we failed to access this network in a row
  148. LONG NetworkAccessFailures;
  149. } NETWORK, *PNETWORK;
  150. #if DBG
  151. BOOL
  152. BrLockNetwork(
  153. IN PNETWORK Network,
  154. IN PCHAR FileName,
  155. IN ULONG LineNumber
  156. );
  157. BOOL
  158. BrLockNetworkShared(
  159. IN PNETWORK Network,
  160. IN PCHAR FileName,
  161. IN ULONG LineNumber
  162. );
  163. VOID
  164. BrUnlockNetwork(
  165. IN PNETWORK Network,
  166. IN PCHAR FileName,
  167. IN ULONG LineNumber
  168. );
  169. #define LOCK_NETWORK(Network) BrLockNetwork(Network, __FILE__, __LINE__)
  170. #define LOCK_NETWORK_SHARED(Network) BrLockNetworkShared(Network, __FILE__, __LINE__)
  171. #define UNLOCK_NETWORK(Network) BrUnlockNetwork(Network, __FILE__, __LINE__)
  172. #else
  173. #define LOCK_NETWORK(Network) RtlAcquireResourceExclusive(&(Network)->Lock, TRUE)
  174. #define LOCK_NETWORK_SHARED(Network) RtlAcquireResourceShared(&(Network)->Lock, TRUE)
  175. #define UNLOCK_NETWORK(Network) RtlReleaseResource(&(Network)->Lock)
  176. #endif
  177. //
  178. // The NET_ENUM_CALLBACK is a callback for BrEnumerateNetworks.
  179. //
  180. // It defines a routine that takes two parameters, the first is a network
  181. // structure, the second is a context for that network.
  182. //
  183. typedef
  184. NET_API_STATUS
  185. (*PNET_ENUM_CALLBACK)(
  186. PNETWORK Network,
  187. PVOID Context
  188. );
  189. VOID
  190. BrInitializeNetworks(
  191. VOID
  192. );
  193. VOID
  194. BrUninitializeNetworks(
  195. IN ULONG BrInitState
  196. );
  197. PNETWORK
  198. BrReferenceNetwork(
  199. PNETWORK PotentialNetwork
  200. );
  201. VOID
  202. BrDereferenceNetwork(
  203. IN PNETWORK Network
  204. );
  205. PNETWORK
  206. BrFindNetwork(
  207. PDOMAIN_INFO DomainInfo,
  208. PUNICODE_STRING TransportName
  209. );
  210. PNETWORK
  211. BrFindWannishMasterBrowserNetwork(
  212. PDOMAIN_INFO DomainInfo
  213. );
  214. VOID
  215. BrDumpNetworks(
  216. VOID
  217. );
  218. NET_API_STATUS
  219. BrEnumerateNetworks(
  220. PNET_ENUM_CALLBACK Callback,
  221. PVOID Context
  222. );
  223. NET_API_STATUS
  224. BrEnumerateNetworksForDomain(
  225. PDOMAIN_INFO DomainInfo,
  226. PNET_ENUM_CALLBACK Callback,
  227. PVOID Context
  228. );
  229. NET_API_STATUS
  230. BrCreateNetworks(
  231. PDOMAIN_INFO DomainInfo
  232. );
  233. NET_API_STATUS
  234. BrCreateNetwork(
  235. PUNICODE_STRING TransportName,
  236. IN ULONG TransportFlags,
  237. IN PUNICODE_STRING AlternateTransportName OPTIONAL,
  238. IN PDOMAIN_INFO DomainInfo
  239. );
  240. NET_API_STATUS
  241. BrDeleteNetwork(
  242. IN PNETWORK Network,
  243. IN PVOID Context
  244. );
  245. extern ULONG NumberOfServicedNetworks;
  246. extern CRITICAL_SECTION NetworkCritSect;
  247. #endif // _BROWSENET_INCLUDED_