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.

429 lines
11 KiB

  1. /*++
  2. Copyright (c) 1998-2002 Microsoft Corporation
  3. Module Name:
  4. cgroup.h
  5. Abstract:
  6. The public definition of config group interfaces.
  7. Author:
  8. Paul McDaniel (paulmcd) 11-Jan-1999
  9. Revision History:
  10. --*/
  11. #ifndef _CGROUP_H_
  12. #define _CGROUP_H_
  13. //
  14. // Forwarders.
  15. //
  16. typedef struct _UL_CONNECTION_COUNT_ENTRY *PUL_CONNECTION_COUNT_ENTRY;
  17. typedef struct _UL_CG_URL_TREE_HEADER *PUL_CG_URL_TREE_HEADER;
  18. typedef struct _UL_CG_URL_TREE_ENTRY *PUL_CG_URL_TREE_ENTRY;
  19. typedef struct _UL_CONTROL_CHANNEL *PUL_CONTROL_CHANNEL;
  20. typedef struct _UL_APP_POOL_OBJECT *PUL_APP_POOL_OBJECT;
  21. typedef struct _UL_INTERNAL_RESPONSE *PUL_INTERNAL_RESPONSE;
  22. typedef struct _UL_LOG_FILE_ENTRY *PUL_LOG_FILE_ENTRY;
  23. typedef struct _UL_SITE_COUNTER_ENTRY *PUL_SITE_COUNTER_ENTRY;
  24. typedef struct _UL_HTTP_CONNECTION *PUL_HTTP_CONNECTION;
  25. typedef struct _UL_INTERNAL_REQUEST *PUL_INTERNAL_REQUEST;
  26. //
  27. // Kernel mode mappings to the user mode set defined in HttpP.w
  28. //
  29. // IRQL == PASSIVE_LEVEL
  30. //
  31. NTSTATUS
  32. UlCreateConfigGroup(
  33. IN PUL_CONTROL_CHANNEL pControlChannel,
  34. OUT HTTP_CONFIG_GROUP_ID * pConfigGroupId
  35. );
  36. // IRQL == PASSIVE_LEVEL
  37. //
  38. NTSTATUS
  39. UlDeleteConfigGroup(
  40. IN HTTP_CONFIG_GROUP_ID ConfigGroupId
  41. );
  42. // IRQL == PASSIVE_LEVEL
  43. //
  44. NTSTATUS
  45. UlAddUrlToConfigGroup(
  46. IN PHTTP_CONFIG_GROUP_URL_INFO pInfo,
  47. IN PUNICODE_STRING pUrl,
  48. IN PACCESS_STATE pAccessState,
  49. IN ACCESS_MASK AccessMask,
  50. IN KPROCESSOR_MODE RequestorMode
  51. );
  52. // IRQL == PASSIVE_LEVEL
  53. //
  54. NTSTATUS
  55. UlRemoveUrlFromConfigGroup(
  56. IN PHTTP_CONFIG_GROUP_URL_INFO pInfo,
  57. IN PUNICODE_STRING pUrl,
  58. IN PACCESS_STATE AccessState,
  59. IN ACCESS_MASK AccessMask,
  60. IN KPROCESSOR_MODE RequestorMode
  61. );
  62. // IRQL == PASSIVE_LEVEL
  63. //
  64. NTSTATUS
  65. UlRemoveAllUrlsFromConfigGroup(
  66. IN HTTP_CONFIG_GROUP_ID ConfigGroupId
  67. );
  68. // IRQL == PASSIVE_LEVEL
  69. //
  70. NTSTATUS
  71. UlQueryConfigGroupInformation(
  72. IN HTTP_CONFIG_GROUP_ID ConfigGroupId,
  73. IN HTTP_CONFIG_GROUP_INFORMATION_CLASS InformationClass,
  74. IN PVOID pConfigGroupInformation,
  75. IN ULONG Length,
  76. OUT PULONG pReturnLength
  77. );
  78. // IRQL == PASSIVE_LEVEL
  79. //
  80. NTSTATUS
  81. UlSetConfigGroupInformation(
  82. IN HTTP_CONFIG_GROUP_ID ConfigGroupId,
  83. IN HTTP_CONFIG_GROUP_INFORMATION_CLASS InformationClass,
  84. IN PVOID pConfigGroupInformation,
  85. IN ULONG Length,
  86. IN KPROCESSOR_MODE RequestorMode
  87. );
  88. //
  89. // This structure represents an internal cfg group object. These are linked
  90. // and owned by control channels via a LIST_ENTRY list.
  91. //
  92. #define IS_VALID_CONFIG_GROUP(pObject) \
  93. HAS_VALID_SIGNATURE(pObject, UL_CG_OBJECT_POOL_TAG)
  94. typedef struct _UL_CONFIG_GROUP_OBJECT
  95. {
  96. //
  97. // PagedPool
  98. //
  99. ULONG Signature; // UL_CG_OBJECT_POOL_TAG
  100. LONG RefCount;
  101. HTTP_CONFIG_GROUP_ID ConfigGroupId;
  102. ULONG SiteId;
  103. UL_NOTIFY_ENTRY HandleEntry; // Links us to an apool or
  104. // control channel handle
  105. UL_NOTIFY_ENTRY ParentEntry; // Links transient groups
  106. // to their static parents
  107. UL_NOTIFY_HEAD ChildHead; // Links transient children
  108. // into this group
  109. LIST_ENTRY ControlChannelEntry;// Links into the
  110. // control channel
  111. PUL_CONTROL_CHANNEL pControlChannel; // the control channel
  112. LIST_ENTRY UrlListHead; // Links UL_CG_URL_TREE_ENTRY
  113. // into this group
  114. HTTP_PROPERTY_FLAGS AppPoolFlags;
  115. PUL_APP_POOL_OBJECT pAppPool; // Maps to our app
  116. // pool.
  117. HTTP_CONFIG_GROUP_MAX_BANDWIDTH MaxBandwidth; // Applies all the flows below
  118. LIST_ENTRY FlowListHead; // Links our flows to us so we can
  119. // do a faster lookup and cleanup.
  120. HTTP_CONFIG_GROUP_MAX_CONNECTIONS MaxConnections;
  121. PUL_CONNECTION_COUNT_ENTRY pConnectionCountEntry;
  122. HTTP_CONFIG_GROUP_STATE State; // The current state
  123. // (active, etc.)
  124. HTTP_CONFIG_GROUP_LOGGING LoggingConfig; // logging config for the
  125. // site�s root app.
  126. PUL_LOG_FILE_ENTRY pLogFileEntry;
  127. PUL_SITE_COUNTER_ENTRY pSiteCounters; // Perfmon Counters (ref'd)
  128. LONGLONG ConnectionTimeout; // Connection Timeout override
  129. // in 100ns ticks
  130. } UL_CONFIG_GROUP_OBJECT, *PUL_CONFIG_GROUP_OBJECT;
  131. //
  132. // Public functions for config group objects:
  133. //
  134. //
  135. // IRQL == PASSIVE_LEVEL
  136. //
  137. VOID
  138. UlReferenceConfigGroup(
  139. IN PVOID pObject
  140. REFERENCE_DEBUG_FORMAL_PARAMS
  141. );
  142. #define REFERENCE_CONFIG_GROUP( pConfigGroup ) \
  143. UlReferenceConfigGroup( \
  144. (pConfigGroup) \
  145. REFERENCE_DEBUG_ACTUAL_PARAMS \
  146. )
  147. //
  148. // IRQL == PASSIVE_LEVEL
  149. //
  150. VOID
  151. UlDereferenceConfigGroup(
  152. PUL_CONFIG_GROUP_OBJECT pConfigGroup
  153. REFERENCE_DEBUG_FORMAL_PARAMS
  154. );
  155. #define DEREFERENCE_CONFIG_GROUP( pConfigGroup ) \
  156. UlDereferenceConfigGroup( \
  157. (pConfigGroup) \
  158. REFERENCE_DEBUG_ACTUAL_PARAMS \
  159. )
  160. //
  161. // IRQL == PASSIVE_LEVEL
  162. //
  163. HTTP_CONFIG_GROUP_ID
  164. UlConfigGroupFromListEntry(
  165. IN PLIST_ENTRY pControlChannelEntry
  166. );
  167. //
  168. // This info is built for an URL, and returned from UlGetConfigGroupForUrl
  169. //
  170. #define IS_VALID_URL_CONFIG_GROUP_INFO(pInfo) \
  171. HAS_VALID_SIGNATURE(pInfo, UL_CG_URL_INFO_POOL_TAG)
  172. typedef struct _UL_URL_CONFIG_GROUP_INFO
  173. {
  174. //
  175. // NonPagedPool
  176. //
  177. //
  178. // UL_CG_URL_INFO_POOL_TAG
  179. //
  180. ULONG Signature;
  181. //
  182. // Set if we have applied UlpSetUrlInfo on this object.
  183. //
  184. BOOLEAN UrlInfoSet;
  185. //
  186. // used by the http engine routing to the app pool, no
  187. // need to be live. copies work great.
  188. //
  189. HTTP_ENABLED_STATE CurrentState; // a copy of the above, for
  190. // callers that don't need
  191. // live access
  192. PUL_CONTROL_CHANNEL pControlChannel;
  193. HTTP_URL_CONTEXT UrlContext; // The context for the url.
  194. // NULL = not set
  195. PUL_APP_POOL_OBJECT pAppPool; // Points the app pool
  196. // associated with this url
  197. //
  198. // The matching UL_CONFIG_GROUP_OBJECT. If pConfigGroup is not NULL,
  199. // this means we only take 1 reference of pConfigGroup but no individual
  200. // references are taken for pMaxBandwidth, pMaxConnections, pCurrentState
  201. // and pLoggingConfig.
  202. //
  203. PUL_CONFIG_GROUP_OBJECT pConfigGroup;
  204. //
  205. // used by the cache mgr and need to be live from the
  206. // real config group objects
  207. //
  208. PUL_CONFIG_GROUP_OBJECT pMaxBandwidth;
  209. PUL_CONFIG_GROUP_OBJECT pMaxConnections;
  210. PUL_CONFIG_GROUP_OBJECT pCurrentState;
  211. PUL_CONFIG_GROUP_OBJECT pLoggingConfig;
  212. PUL_CONNECTION_COUNT_ENTRY pConnectionCountEntry;
  213. //
  214. // Site Counters (ref'd)
  215. //
  216. ULONG SiteId;
  217. PUL_SITE_COUNTER_ENTRY pSiteCounters;
  218. //
  219. // Connection Timeout (100ns Ticks)
  220. //
  221. LONGLONG ConnectionTimeout;
  222. //
  223. // Used to determine the binding type of the site that this request
  224. // is being routed to.
  225. //
  226. HTTP_URL_SITE_TYPE SiteUrlType;
  227. } UL_URL_CONFIG_GROUP_INFO, *PUL_URL_CONFIG_GROUP_INFO;
  228. //
  229. // IRQL == PASSIVE_LEVEL
  230. //
  231. NTSTATUS
  232. UlGetConfigGroupInfoForUrl(
  233. IN PWSTR pUrl,
  234. IN PUL_INTERNAL_REQUEST pRequest,
  235. OUT PUL_URL_CONFIG_GROUP_INFO pInfo
  236. );
  237. //
  238. // IRQL == PASSIVE_LEVEL
  239. //
  240. NTSTATUS
  241. UlInitializeCG(
  242. VOID
  243. );
  244. VOID
  245. UlTerminateCG(
  246. VOID
  247. );
  248. BOOLEAN
  249. UlNotifyOrphanedConfigGroup(
  250. IN PUL_NOTIFY_ENTRY pEntry,
  251. IN PVOID pHost,
  252. IN PVOID pv
  253. );
  254. //
  255. // IRQL == PASSIVE_LEVEL
  256. //
  257. __inline
  258. VOID
  259. UlInitializeUrlInfo(
  260. OUT PUL_URL_CONFIG_GROUP_INFO pInfo
  261. )
  262. {
  263. ASSERT(pInfo != NULL);
  264. RtlZeroMemory(
  265. (PCHAR)pInfo,
  266. sizeof(UL_URL_CONFIG_GROUP_INFO)
  267. );
  268. pInfo->Signature = UL_CG_URL_INFO_POOL_TAG;
  269. pInfo->CurrentState = HttpEnabledStateInactive;
  270. }
  271. NTSTATUS
  272. UlConfigGroupInfoRelease(
  273. IN PUL_URL_CONFIG_GROUP_INFO pInfo
  274. );
  275. NTSTATUS
  276. UlConfigGroupInfoDeepCopy(
  277. IN const PUL_URL_CONFIG_GROUP_INFO pOrigInfo,
  278. IN OUT PUL_URL_CONFIG_GROUP_INFO pNewInfo
  279. );
  280. NTSTATUS
  281. UlLookupHostPlusIPSite(
  282. IN PUL_INTERNAL_REQUEST pRequest
  283. );
  284. NTSTATUS
  285. UlSanitizeUrl(
  286. IN PWCHAR pUrl,
  287. IN ULONG UrlCharCount,
  288. IN BOOLEAN TrailingSlashRequired,
  289. OUT PWSTR* ppUrl,
  290. OUT PHTTP_PARSED_URL pParsedUrl
  291. );
  292. //
  293. // This entry is used to remove a url from endpoint list.
  294. //
  295. typedef struct _UL_DEFERRED_REMOVE_ITEM
  296. {
  297. ULONG Signature;
  298. //
  299. // Url scheme and port to remove from endpoint.
  300. // CODEWORK: Change BOOLEAN for scheme when more protocols are supported.
  301. //
  302. BOOLEAN UrlSecure;
  303. USHORT UrlPort;
  304. // Actual work item.
  305. UL_WORK_ITEM WorkItem;
  306. } UL_DEFERRED_REMOVE_ITEM, *PUL_DEFERRED_REMOVE_ITEM;
  307. #define IS_VALID_DEFERRED_REMOVE_ITEM(p) \
  308. ((p) && (p)->Signature == UL_DEFERRED_REMOVE_ITEM_POOL_TAG)
  309. VOID
  310. UlRemoveSite(
  311. IN PUL_DEFERRED_REMOVE_ITEM pRemoveItem
  312. );
  313. //
  314. // Small macro which tells whether bandwidth throttling is enabled or not.
  315. //
  316. #define BWT_ENABLED_FOR_CGROUP(pCGroup) \
  317. ((pCGroup) != NULL && \
  318. (pCGroup)->MaxBandwidth.Flags.Present != 0 && \
  319. (pCGroup)->MaxBandwidth.MaxBandwidth != HTTP_LIMIT_INFINITE)
  320. #endif // _CGROUP_H_