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.

275 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 2000-2002 Microsoft Corporation
  3. Module Name :
  4. Ultci.h
  5. Abstract:
  6. This module implements a wrapper for QoS TC ( Traffic Control )
  7. Interface since the Kernel level API don't exist at this time.
  8. Any HTTP module might use this interface to make QoS calls.
  9. Author:
  10. Ali Ediz Turkoglu (aliTu) 28-Jul-2000
  11. Project:
  12. Internet Information Server 6.0 - HTTP.SYS
  13. Revision History:
  14. -
  15. --*/
  16. #ifndef __ULTCI_H__
  17. #define __ULTCI_H__
  18. //
  19. // UL does not use GPC_CF_CLASS_MAP client, all of the interfaces
  20. // assumed to be using GPC_CF_QOS client type. And it's registered
  21. // for all interfaces.
  22. //
  23. // #define MAX_STRING_LENGTH (256) from traffic.h
  24. //
  25. // The interface objects get allocated during initialization.
  26. // They hold the necessary information to create other
  27. // QoS structures like flow & filter
  28. //
  29. typedef struct _UL_TCI_INTERFACE
  30. {
  31. ULONG Signature; // UL_TC_INTERFACE_POOL_TAG
  32. LIST_ENTRY Linkage; // Linkage for the list of interfaces
  33. BOOLEAN IsQoSEnabled; // To see if QoS enabled or not for this interface
  34. ULONG IfIndex; // Interface Index from TCPIP
  35. USHORT NameLength; // Friendly name of the interface
  36. WCHAR Name[MAX_STRING_LENGTH];
  37. USHORT InstanceIDLength; // ID from our WMI provider the beloved PSched
  38. WCHAR InstanceID[MAX_STRING_LENGTH];
  39. LIST_ENTRY FlowList; // List of site flows on this interface
  40. ULONG FlowListSize;
  41. ULONG AddrListBytesCount; // Address list acquired from tc with Wmi call
  42. PADDRESS_LIST_DESCRIPTOR pAddressListDesc; // Points to a seperately allocated memory
  43. #if REFERENCE_DEBUG
  44. //
  45. // Reference trace log.
  46. //
  47. PTRACE_LOG pTraceLog;
  48. #endif
  49. } UL_TCI_INTERFACE, *PUL_TCI_INTERFACE;
  50. #define IS_VALID_TCI_INTERFACE( entry ) \
  51. HAS_VALID_SIGNATURE(entry, UL_TCI_INTERFACE_POOL_TAG)
  52. //
  53. // The structure to hold the all of the flow related info.
  54. // Each site may have one flow on each interface plus one
  55. // extra global flow on each interface.
  56. //
  57. typedef struct _UL_TCI_FLOW
  58. {
  59. ULONG Signature; // UL_TC_FLOW_POOL_TAG
  60. HANDLE FlowHandle; // Flow handle from TC
  61. LIST_ENTRY Linkage; // Links us to flow list of "the interface"
  62. // we have installed on
  63. PUL_TCI_INTERFACE pInterface; // Back ptr to interface struc. Necessary to gather
  64. // some information occasionally
  65. LIST_ENTRY Siblings; // Links us to flow list of "the owner"
  66. // In other words all the flows of the site or app.
  67. PVOID pOwner; // Either points to a cgroup or a control channel
  68. // For which we created the flow.
  69. TC_GEN_FLOW GenFlow; // The details of the flowspec is stored in here
  70. UL_SPIN_LOCK FilterListSpinLock; // To LOCK the filterlist & its counter
  71. LIST_ENTRY FilterList; // The list of filters on this flow
  72. ULONGLONG FilterListSize; // The number filters installed
  73. } UL_TCI_FLOW, *PUL_TCI_FLOW;
  74. #define IS_VALID_TCI_FLOW( entry ) \
  75. HAS_VALID_SIGNATURE(entry, UL_TCI_FLOW_POOL_TAG)
  76. //
  77. // The structure to hold the filter information.
  78. // Each connection can only have one filter at a time.
  79. //
  80. typedef struct _UL_TCI_FILTER
  81. {
  82. ULONG Signature; // UL_TC_FILTER_POOL_TAG
  83. HANDLE FilterHandle; // GPC handle
  84. PUL_HTTP_CONNECTION pHttpConnection; // For proper cleanup and
  85. // to avoid the race conditions
  86. LIST_ENTRY Linkage; // Next filter on the flow
  87. } UL_TCI_FILTER, *PUL_TCI_FILTER;
  88. #define IS_VALID_TCI_FILTER( entry ) \
  89. HAS_VALID_SIGNATURE(entry, UL_TCI_FILTER_POOL_TAG)
  90. //
  91. // To identify the local_loopbacks. This is a translation of
  92. // 127.0.0.1.
  93. //
  94. #define LOOPBACK_ADDR (0x0100007f)
  95. //
  96. // The functionality we expose to the other pieces.
  97. //
  98. /* Generic */
  99. NTSTATUS
  100. UlTcInitPSched(
  101. VOID
  102. );
  103. BOOLEAN
  104. UlTcPSchedInstalled(
  105. VOID
  106. );
  107. /* Filters */
  108. NTSTATUS
  109. UlTcAddFilter(
  110. IN PUL_HTTP_CONNECTION pHttpConnection,
  111. IN PVOID pOwner,
  112. IN BOOLEAN Global
  113. );
  114. NTSTATUS
  115. UlTcDeleteFilter(
  116. IN PUL_HTTP_CONNECTION pHttpConnection
  117. );
  118. /* Flow manipulation */
  119. NTSTATUS
  120. UlTcAddFlows(
  121. IN PVOID pOwner,
  122. IN HTTP_BANDWIDTH_LIMIT MaxBandwidth,
  123. IN BOOLEAN Global
  124. );
  125. NTSTATUS
  126. UlTcModifyFlows(
  127. IN PVOID pOwner,
  128. IN HTTP_BANDWIDTH_LIMIT MaxBandwidth,
  129. IN BOOLEAN Global
  130. );
  131. VOID
  132. UlTcRemoveFlows(
  133. IN PVOID pOwner,
  134. IN BOOLEAN Global
  135. );
  136. /* Init & Terminate */
  137. NTSTATUS
  138. UlTcInitialize(
  139. VOID
  140. );
  141. VOID
  142. UlTcTerminate(
  143. VOID
  144. );
  145. /* Inline function to handle filter additions */
  146. __inline
  147. NTSTATUS
  148. UlTcAddFilterForConnection(
  149. IN PUL_HTTP_CONNECTION pHttpConn, /* connection */
  150. IN PUL_URL_CONFIG_GROUP_INFO pConfigInfo /* request's config */
  151. )
  152. {
  153. NTSTATUS Status = STATUS_SUCCESS;
  154. PUL_CONFIG_GROUP_OBJECT pCGroup = NULL;
  155. PUL_CONTROL_CHANNEL pControlChannel = NULL;
  156. //
  157. // Sanity Check.
  158. //
  159. ASSERT(UL_IS_VALID_HTTP_CONNECTION(pHttpConn));
  160. ASSERT(IS_VALID_URL_CONFIG_GROUP_INFO(pConfigInfo));
  161. //
  162. // No support for IPv6, however return success, we will still let
  163. // the connection in.
  164. //
  165. if (pHttpConn->pConnection->AddressType != TDI_ADDRESS_TYPE_IP)
  166. {
  167. return STATUS_SUCCESS;
  168. }
  169. //
  170. // If exists enforce the site bandwidth limit.
  171. //
  172. pCGroup = pConfigInfo->pMaxBandwidth;
  173. if (BWT_ENABLED_FOR_CGROUP(pCGroup))
  174. {
  175. ASSERT(IS_VALID_CONFIG_GROUP(pCGroup));
  176. Status = UlTcAddFilter(
  177. pHttpConn,
  178. pCGroup,
  179. FALSE
  180. );
  181. }
  182. else
  183. {
  184. //
  185. // Otherwise try to enforce the global (control channel)
  186. // bandwidth limit.
  187. //
  188. pControlChannel = pConfigInfo->pControlChannel;
  189. ASSERT(IS_VALID_CONTROL_CHANNEL(pControlChannel));
  190. if (BWT_ENABLED_FOR_CONTROL_CHANNEL(pControlChannel))
  191. {
  192. Status = UlTcAddFilter(
  193. pHttpConn,
  194. pControlChannel,
  195. TRUE
  196. );
  197. }
  198. }
  199. return Status;
  200. }
  201. #endif // __ULTCI_H__