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.

357 lines
12 KiB

  1. /*++
  2. Copyright(c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. brdgctl.h
  5. Abstract:
  6. Ethernet MAC bridge.
  7. IOCTL interface definitions
  8. Author:
  9. Mark Aiken
  10. Environment:
  11. Kernel mode driver
  12. Revision History:
  13. Apr 2000 - Original version
  14. --*/
  15. // ===========================================================================
  16. //
  17. // CONSTANTS / TYPES
  18. //
  19. // ===========================================================================
  20. // The bridge's device name when using it from user-mode
  21. #define BRIDGE_DOS_DEVICE_NAME "\\\\.\\BRIDGE"
  22. // Opaque handle uniquely identifying an adapter
  23. typedef ULONG_PTR BRIDGE_ADAPTER_HANDLE, *PBRIDGE_ADAPTER_HANDLE;
  24. // Length of an Ethernet MAC address
  25. #define ETH_LENGTH_OF_ADDRESS 6
  26. // No reported physical medium (assume 802.3)
  27. #define BRIDGE_NO_MEDIUM (NDIS_PHYSICAL_MEDIUM)-1
  28. // Types of notifications
  29. typedef enum
  30. {
  31. BrdgNotifyEnumerateAdapters,
  32. BrdgNotifyAddAdapter,
  33. BrdgNotifyRemoveAdapter,
  34. BrdgNotifyLinkSpeedChange,
  35. BrdgNotifyMediaStateChange,
  36. BrdgNotifyAdapterStateChange // This only occurs when the STA is active
  37. } BRIDGE_NOTIFICATION_TYPE;
  38. //
  39. // Possible states for an adapter. If the STA is not compiled in, adapters are
  40. // always in the Forwarding state.
  41. //
  42. typedef enum _PORT_STATE
  43. {
  44. Disabled, // The STA is disabled on this adapter. This happens when the adapter's
  45. // media is disconnected.
  46. Blocking, // Not learning or relaying
  47. Listening, // Transitory
  48. Learning, // Learning but not relaying
  49. Forwarding // Learning and relaying
  50. } PORT_STATE;
  51. //
  52. // STA types and constants
  53. //
  54. // Time values are exchanged between bridges as 16-bit unsigned values
  55. // in units of 1/256th of a second
  56. typedef USHORT STA_TIME;
  57. // Path costs are 32-bit unsigned values
  58. typedef ULONG PATH_COST;
  59. // Port identifiers are 2-byte unsigned values
  60. typedef USHORT PORT_ID;
  61. // Size of bridge identifiers
  62. #define BRIDGE_ID_LEN 8
  63. #if( BRIDGE_ID_LEN < ETH_LENGTH_OF_ADDRESS )
  64. #error "BRIDGE_ID_LEN must be >= ETH_LENGTH_OF_ADDRESS"
  65. #endif
  66. // ===========================================================================
  67. //
  68. // STRUCTURES
  69. //
  70. // ===========================================================================
  71. //
  72. // Common notification header
  73. //
  74. typedef struct _BRIDGE_NOTIFY_HEADER
  75. {
  76. //
  77. // If NotifyType == BrdgNotifyRemoveAdapter, there is no further data.
  78. //
  79. // If NotifyType != BrdgNotifyRemoveAdapter, the header is followed by
  80. // a BRIDGE_ADAPTER_INFO structure.
  81. //
  82. BRIDGE_NOTIFICATION_TYPE NotifyType;
  83. BRIDGE_ADAPTER_HANDLE Handle;
  84. } BRIDGE_NOTIFY_HEADER, *PBRIDGE_NOTIFY_HEADER;
  85. //
  86. // Data provided with adapter notifications
  87. //
  88. typedef struct _BRIDGE_ADAPTER_INFO
  89. {
  90. // These fields can be the subject of a specific change notification
  91. ULONG LinkSpeed;
  92. NDIS_MEDIA_STATE MediaState;
  93. PORT_STATE State;
  94. // These fields are never the subject of a change notification
  95. UCHAR MACAddress[ETH_LENGTH_OF_ADDRESS];
  96. NDIS_PHYSICAL_MEDIUM PhysicalMedium;
  97. } BRIDGE_ADAPTER_INFO, *PBRIDGE_ADAPTER_INFO;
  98. //
  99. // Data provided in response to
  100. //
  101. typedef struct _BRIDGE_STA_ADAPTER_INFO
  102. {
  103. PORT_ID ID;
  104. ULONG PathCost;
  105. UCHAR DesignatedRootID[BRIDGE_ID_LEN];
  106. PATH_COST DesignatedCost;
  107. UCHAR DesignatedBridgeID[BRIDGE_ID_LEN];
  108. PORT_ID DesignatedPort;
  109. } BRIDGE_STA_ADAPTER_INFO, *PBRIDGE_STA_ADAPTER_INFO;
  110. //
  111. // Data provided with BrdgNotifySTAGlobalInfoChange
  112. //
  113. typedef struct _BRIDGE_STA_GLOBAL_INFO
  114. {
  115. UCHAR OurID[BRIDGE_ID_LEN];
  116. UCHAR DesignatedRootID[BRIDGE_ID_LEN];
  117. PATH_COST RootCost;
  118. BRIDGE_ADAPTER_HANDLE RootAdapter;
  119. BOOLEAN bTopologyChangeDetected;
  120. BOOLEAN bTopologyChange;
  121. STA_TIME MaxAge;
  122. STA_TIME HelloTime;
  123. STA_TIME ForwardDelay;
  124. } BRIDGE_STA_GLOBAL_INFO, *PBRIDGE_STA_GLOBAL_INFO;
  125. //
  126. // This structure is used to report statistics relating to the bridge's packet handling.
  127. //
  128. typedef struct _BRIDGE_PACKET_STATISTICS
  129. {
  130. // Local-source frames
  131. LARGE_INTEGER TransmittedFrames;
  132. // Local-source frames whose transmission failed because of errors
  133. LARGE_INTEGER TransmittedErrorFrames;
  134. // Local-source bytes
  135. LARGE_INTEGER TransmittedBytes;
  136. // Breakdown of transmitted frames
  137. LARGE_INTEGER DirectedTransmittedFrames;
  138. LARGE_INTEGER MulticastTransmittedFrames;
  139. LARGE_INTEGER BroadcastTransmittedFrames;
  140. // Breakdown of transmitted bytes
  141. LARGE_INTEGER DirectedTransmittedBytes;
  142. LARGE_INTEGER MulticastTransmittedBytes;
  143. LARGE_INTEGER BroadcastTransmittedBytes;
  144. // Frames indicated to the local machine
  145. LARGE_INTEGER IndicatedFrames;
  146. // Frames that should have been indicated to the local machine but
  147. // were not due to errors
  148. LARGE_INTEGER IndicatedDroppedFrames;
  149. // Bytes indicated to the local machine
  150. LARGE_INTEGER IndicatedBytes;
  151. // Breakdown of indicated frames
  152. LARGE_INTEGER DirectedIndicatedFrames;
  153. LARGE_INTEGER MulticastIndicatedFrames;
  154. LARGE_INTEGER BroadcastIndicatedFrames;
  155. // Breakdown of indicated bytes
  156. LARGE_INTEGER DirectedIndicatedBytes;
  157. LARGE_INTEGER MulticastIndicatedBytes;
  158. LARGE_INTEGER BroadcastIndicatedBytes;
  159. // Total received frames / bytes, including frames not indicated
  160. LARGE_INTEGER ReceivedFrames;
  161. LARGE_INTEGER ReceivedBytes;
  162. // Breakdown of how many frames were received with/without copying
  163. LARGE_INTEGER ReceivedCopyFrames ;
  164. LARGE_INTEGER ReceivedCopyBytes;
  165. LARGE_INTEGER ReceivedNoCopyFrames;
  166. LARGE_INTEGER ReceivedNoCopyBytes;
  167. } BRIDGE_PACKET_STATISTICS, *PBRIDGE_PACKET_STATISTICS;
  168. //
  169. // This structure is used to report the packet-handling statistics for a particular
  170. // adapter
  171. //
  172. typedef struct _BRIDGE_ADAPTER_PACKET_STATISTICS
  173. {
  174. // These include all sent packets (including relay)
  175. LARGE_INTEGER SentFrames;
  176. LARGE_INTEGER SentBytes;
  177. // These include only packets sent by the local machine
  178. LARGE_INTEGER SentLocalFrames;
  179. LARGE_INTEGER SentLocalBytes;
  180. // These include all received packets (including relay)
  181. LARGE_INTEGER ReceivedFrames;
  182. LARGE_INTEGER ReceivedBytes;
  183. } BRIDGE_ADAPTER_PACKET_STATISTICS, *PBRIDGE_ADAPTER_PACKET_STATISTICS;
  184. //
  185. // This structure is used to report statistics relating the bridge's internal
  186. // buffer management
  187. //
  188. typedef struct _BRIDGE_BUFFER_STATISTICS
  189. {
  190. // Packets of each type currently used
  191. ULONG UsedCopyPackets;
  192. ULONG UsedWrapperPackets;
  193. // Size of each pool
  194. ULONG MaxCopyPackets;
  195. ULONG MaxWrapperPackets;
  196. // Size of the safety buffer for each pool
  197. ULONG SafetyCopyPackets;
  198. ULONG SafetyWrapperPackets;
  199. // Number of times alloc requests from each pool have been denied because the
  200. // pool was completely full
  201. LARGE_INTEGER CopyPoolOverflows;
  202. LARGE_INTEGER WrapperPoolOverflows;
  203. // Number of times memory allocations have failed unexpectedly (presumably
  204. // because of low system resources)
  205. LARGE_INTEGER AllocFailures;
  206. } BRIDGE_BUFFER_STATISTICS, *PBRIDGE_BUFFER_STATISTICS;
  207. // ===========================================================================
  208. //
  209. // IOCTLS
  210. //
  211. // ===========================================================================
  212. //
  213. // This IOCTL will pend until the bridge has a notification to send up to the caller.
  214. //
  215. // Associated structures: BRIDGE_NOTIFY_HEADER and BRIDGE_ADAPTER_INFO
  216. //
  217. // The buffer provided with IOCTLs of this type must be at least sizeof(BRIDGE_NOTIFY_HEADER) +
  218. // sizeof(BRIDGE_ADAPTER_INFO) large, in order to accomodate notifications that include adapter
  219. // information
  220. //
  221. #define BRIDGE_IOCTL_REQUEST_NOTIFY CTL_CODE(FILE_DEVICE_NETWORK, 0x800, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  222. //
  223. // This IOCTL causes the bridge driver to send a new notification for every bound adapter, with
  224. // BrdgNotifyEnumerateAdapters as the notification type.
  225. //
  226. #define BRIDGE_IOCTL_GET_ADAPTERS CTL_CODE(FILE_DEVICE_NETWORK, 0x801, METHOD_BUFFERED, FILE_READ_ACCESS)
  227. //
  228. // These codes retrieve the device name / friendly name for a bound adapter. Input buffer must be the adapter handle.
  229. //
  230. // As many bytes as possible of the name are read into the supplied buffer. If the buffer is not large enough,
  231. // the number of necessary bytes is returned as the number of written bytes.
  232. //
  233. #define BRIDGE_IOCTL_GET_ADAPT_DEVICE_NAME CTL_CODE(FILE_DEVICE_NETWORK, 0x802, METHOD_BUFFERED, FILE_READ_ACCESS)
  234. #define BRIDGE_IOCTL_GET_ADAPT_FRIENDLY_NAME CTL_CODE(FILE_DEVICE_NETWORK, 0x803, METHOD_BUFFERED, FILE_READ_ACCESS)
  235. //
  236. // This code retrieves the MAC address of the bridge component (which is different from the MAC address
  237. // of any particular adapter).
  238. //
  239. // The associated buffer must be at least ETH_LENGTH_OF_ADDRESS bytes long
  240. //
  241. #define BRIDGE_IOCTL_GET_MAC_ADDRESS CTL_CODE(FILE_DEVICE_NETWORK, 0x804, METHOD_BUFFERED, FILE_READ_ACCESS)
  242. //
  243. // This code retrieves packet statistics from the bridge
  244. //
  245. // Associated structure: BRIDGE_PACKET_STATISTICS
  246. //
  247. #define BRIDGE_IOCTL_GET_PACKET_STATS CTL_CODE(FILE_DEVICE_NETWORK, 0x805, METHOD_BUFFERED, FILE_READ_ACCESS)
  248. //
  249. // This code retrieves packet statistics for a particular adapter
  250. //
  251. // Associated structure: BRIDGE_ADAPTER_PACKET_STATISTICS
  252. //
  253. #define BRIDGE_IOCTL_GET_ADAPTER_PACKET_STATS CTL_CODE(FILE_DEVICE_NETWORK, 0x806, METHOD_BUFFERED, FILE_READ_ACCESS)
  254. //
  255. // This code retrieves buffer management statistics from the bridge
  256. //
  257. // Associated structure: BRIDGE_BUFFER_STATISTICS
  258. //
  259. #define BRIDGE_IOCTL_GET_BUFFER_STATS CTL_CODE(FILE_DEVICE_NETWORK, 0x807, METHOD_BUFFERED, FILE_READ_ACCESS)
  260. //
  261. // This code retrieves all forwarding table entries associated with the adapter whose handle
  262. // is given in the input buffer
  263. //
  264. // Data is output as an array of MAC addresses, each ETH_LENGTH_OF_ADDRESS bytes long.
  265. // If the provided buffer is too small to handle all entries, as many as possible are copied, the result
  266. // status is STATUS_BUFFER_OVERFLOW (a warning value) and the count of written bytes is actually the
  267. // required number of bytes to hold all table entries
  268. //
  269. #define BRIDGE_IOCTL_GET_TABLE_ENTRIES CTL_CODE(FILE_DEVICE_NETWORK, 0x80a, METHOD_BUFFERED, FILE_READ_ACCESS)
  270. //
  271. // STA IOCTLs
  272. //
  273. //
  274. // This code queries for the STA information for a particular adapter
  275. //
  276. // Input is an adapter handle. Output is the BRIDGE_STA_ADAPTER_INFO structure.
  277. //
  278. #define BRIDGE_IOCTL_GET_ADAPTER_STA_INFO CTL_CODE(FILE_DEVICE_NETWORK, 0x80b, METHOD_BUFFERED, FILE_READ_ACCESS)
  279. //
  280. // This code queries for global STA information
  281. //
  282. // No data is input. Output is the BRIDGE_STA_GLOBAL_INFO structure.
  283. //
  284. #define BRIDGE_IOCTL_GET_GLOBAL_STA_INFO CTL_CODE(FILE_DEVICE_NETWORK, 0x80c, METHOD_BUFFERED, FILE_READ_ACCESS)