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.

520 lines
12 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. w3site.h
  5. Abstract:
  6. Type definition for worker process implementation of IIS.
  7. Author:
  8. Taylor Weiss (TaylorW) 16-Dec-1999
  9. Revision History:
  10. --*/
  11. #ifndef _W3SITE_H_
  12. #define _W3SITE_H_
  13. /************************************************************
  14. * Include Headers
  15. ************************************************************/
  16. /************************************************************
  17. * Type Definitions
  18. ************************************************************/
  19. /*++
  20. class W3_SITE
  21. Encapsulates site level settings for an HTTP server run in
  22. a duct-tape worker process.
  23. Condenses the relevant functionality exposed in IIS
  24. through the IIS_SERVER_INSTANCE and W3_SERVER_INSTANCE.
  25. --*/
  26. #define W3_SITE_SIGNATURE (DWORD)' ISW'
  27. #define W3_SITE_SIGNATURE_FREE (DWORD)'fISW'
  28. #define MAX_SITEID_LENGTH 10
  29. class FILTER_LIST;
  30. class W3_SITE
  31. {
  32. public:
  33. //
  34. // Construction and Initialization
  35. //
  36. W3_SITE(DWORD SiteId);
  37. // global initialization and cleanup
  38. static HRESULT W3SiteInitialize()
  39. {
  40. INITIALIZE_CRITICAL_SECTION( &sm_csIISCertMapLock );
  41. return S_OK;
  42. }
  43. static VOID W3SiteTerminate()
  44. {
  45. DeleteCriticalSection( &sm_csIISCertMapLock );
  46. }
  47. // global lock & unlock for iis certmap
  48. VOID GlobalLockIISCertMap()
  49. {
  50. EnterCriticalSection( &sm_csIISCertMapLock );
  51. }
  52. VOID GlobalUnlockIISCertMap()
  53. {
  54. LeaveCriticalSection( &sm_csIISCertMapLock );
  55. }
  56. HRESULT Initialize(LOGGING *pLogging = NULL,
  57. FILTER_LIST *pFilterList = NULL);
  58. DWORD QueryId() const
  59. {
  60. return m_SiteId;
  61. }
  62. BOOL QueryUseDSMapper() const
  63. {
  64. return m_fUseDSMapper;
  65. }
  66. void AddRef()
  67. {
  68. InterlockedIncrement( &m_cRefs );
  69. }
  70. void Release()
  71. {
  72. DBG_ASSERT( m_cRefs > 0 );
  73. if ( InterlockedDecrement( &m_cRefs ) == 0 )
  74. {
  75. delete this;
  76. }
  77. }
  78. FILTER_LIST *QueryFilterList() const
  79. {
  80. return m_pInstanceFilterList;
  81. }
  82. STRA *QueryName()
  83. {
  84. return &m_SiteName;
  85. }
  86. STRU *QueryMBRoot()
  87. {
  88. return &m_SiteMBRoot;
  89. }
  90. STRU *QueryMBPath()
  91. {
  92. return &m_SiteMBPath;
  93. }
  94. HRESULT
  95. HandleMetabaseChange(
  96. const MD_CHANGE_OBJECT &ChangeObject,
  97. IN W3_SITE_LIST *pTempSiteList = NULL);
  98. BOOL QueryDoUlLogging() const
  99. {
  100. return m_pLogging->QueryDoUlLogging();
  101. }
  102. BOOL QueryDoCustomLogging() const
  103. {
  104. return m_pLogging->QueryDoCustomLogging();
  105. }
  106. BOOL IsRequiredExtraLoggingFields() const
  107. {
  108. return m_pLogging->IsRequiredExtraLoggingFields();
  109. }
  110. const MULTISZA *QueryExtraLoggingFields() const
  111. {
  112. return m_pLogging->QueryExtraLoggingFields();
  113. }
  114. void LogInformation(LOG_CONTEXT *pLogData)
  115. {
  116. m_pLogging->LogInformation(pLogData);
  117. }
  118. BOOL QueryAllowPathInfoForScriptMappings() const
  119. {
  120. return m_fAllowPathInfoForScriptMappings;
  121. }
  122. VOID GetStatistics(IISWPSiteCounters *pCounterData)
  123. {
  124. PBYTE pSrc = (PBYTE)&m_PerfCounters;
  125. PBYTE pDest = (PBYTE)pCounterData;
  126. //
  127. // Set the site id for the counters we
  128. // are sending.
  129. //
  130. pCounterData->SiteID = m_SiteId;
  131. for (DWORD i=0; i< WPSiteCtrsMaximum; i++)
  132. {
  133. // I am assuming all WP site counters are DWORDs and will
  134. // remain so, if not this code needs changing at that point
  135. DBG_ASSERT(aIISWPSiteDescription[i].Size == sizeof(DWORD));
  136. if (aIISWPSiteDescription[i].WPZeros)
  137. {
  138. //
  139. // For the total counters, we pass on the increment since
  140. // the last collection, so we need to zero them
  141. //
  142. *(DWORD *)(pDest + aIISWPSiteDescription[i].Offset) =
  143. InterlockedExchange(
  144. (LPLONG)(pSrc + aIISWPSiteDescription[i].Offset),
  145. 0);
  146. }
  147. else
  148. {
  149. *(DWORD *)(pDest + aIISWPSiteDescription[i].Offset) =
  150. *(DWORD *)(pSrc + aIISWPSiteDescription[i].Offset);
  151. }
  152. }
  153. }
  154. VOID IncFilesSent()
  155. {
  156. InterlockedIncrement((LPLONG)&m_PerfCounters.FilesSent);
  157. InterlockedIncrement((LPLONG)&m_PerfCounters.FilesTransferred);
  158. }
  159. VOID IncFilesRecvd()
  160. {
  161. InterlockedIncrement((LPLONG)&m_PerfCounters.FilesReceived);
  162. InterlockedIncrement((LPLONG)&m_PerfCounters.FilesTransferred);
  163. }
  164. VOID IncAnonUsers()
  165. {
  166. InterlockedIncrement((LPLONG)&m_PerfCounters.AnonUsers);
  167. DWORD currAnons = InterlockedIncrement((LPLONG)&m_PerfCounters.CurrentAnonUsers);
  168. DWORD currMaxAnons;
  169. while ((currMaxAnons = m_PerfCounters.MaxAnonUsers) <
  170. currAnons)
  171. {
  172. InterlockedCompareExchange((LPLONG)&m_PerfCounters.MaxAnonUsers,
  173. currAnons,
  174. currMaxAnons);
  175. }
  176. }
  177. VOID DecAnonUsers()
  178. {
  179. InterlockedDecrement((LPLONG)&m_PerfCounters.CurrentAnonUsers);
  180. }
  181. VOID IncNonAnonUsers()
  182. {
  183. InterlockedIncrement((LPLONG)&m_PerfCounters.NonAnonUsers);
  184. DWORD currNonAnons = InterlockedIncrement((LPLONG)&m_PerfCounters.CurrentNonAnonUsers);
  185. DWORD currMaxNonAnons;
  186. while ((currMaxNonAnons = m_PerfCounters.MaxNonAnonUsers) <
  187. currNonAnons)
  188. {
  189. InterlockedCompareExchange((LPLONG)&m_PerfCounters.MaxNonAnonUsers,
  190. currNonAnons,
  191. currMaxNonAnons);
  192. }
  193. }
  194. VOID DecNonAnonUsers()
  195. {
  196. InterlockedDecrement((LPLONG)&m_PerfCounters.CurrentNonAnonUsers);
  197. }
  198. VOID IncLogonAttempts()
  199. {
  200. InterlockedIncrement((LPLONG)&m_PerfCounters.LogonAttempts);
  201. }
  202. VOID IncReqType(HTTP_VERB VerbType)
  203. {
  204. switch (VerbType)
  205. {
  206. case HttpVerbGET:
  207. InterlockedIncrement((LPLONG)&m_PerfCounters.GetReqs);
  208. return;
  209. case HttpVerbPUT:
  210. InterlockedIncrement((LPLONG)&m_PerfCounters.PutReqs);
  211. IncFilesRecvd();
  212. return;
  213. case HttpVerbHEAD:
  214. InterlockedIncrement((LPLONG)&m_PerfCounters.HeadReqs);
  215. return;
  216. case HttpVerbPOST:
  217. InterlockedIncrement((LPLONG)&m_PerfCounters.PostReqs);
  218. return;
  219. case HttpVerbDELETE:
  220. InterlockedIncrement((LPLONG)&m_PerfCounters.DeleteReqs);
  221. return;
  222. case HttpVerbTRACE:
  223. case HttpVerbTRACK:
  224. InterlockedIncrement((LPLONG)&m_PerfCounters.TraceReqs);
  225. return;
  226. case HttpVerbOPTIONS:
  227. InterlockedIncrement((LPLONG)&m_PerfCounters.OptionsReqs);
  228. return;
  229. case HttpVerbMOVE:
  230. InterlockedIncrement((LPLONG)&m_PerfCounters.MoveReqs);
  231. return;
  232. case HttpVerbCOPY:
  233. InterlockedIncrement((LPLONG)&m_PerfCounters.CopyReqs);
  234. return;
  235. case HttpVerbPROPFIND:
  236. InterlockedIncrement((LPLONG)&m_PerfCounters.PropfindReqs);
  237. return;
  238. case HttpVerbPROPPATCH:
  239. InterlockedIncrement((LPLONG)&m_PerfCounters.ProppatchReqs);
  240. return;
  241. case HttpVerbMKCOL:
  242. InterlockedIncrement((LPLONG)&m_PerfCounters.MkcolReqs);
  243. return;
  244. case HttpVerbLOCK:
  245. InterlockedIncrement((LPLONG)&m_PerfCounters.LockReqs);
  246. return;
  247. default:
  248. InterlockedIncrement((LPLONG)&m_PerfCounters.OtherReqs);
  249. return;
  250. }
  251. }
  252. VOID IncCgiReqs()
  253. {
  254. InterlockedIncrement((LPLONG)&m_PerfCounters.CgiReqs);
  255. DWORD currCgis = InterlockedIncrement((LPLONG)&m_PerfCounters.CurrentCgiReqs);
  256. DWORD currMaxCgis;
  257. while ((currMaxCgis = m_PerfCounters.MaxCgiReqs) <
  258. currCgis)
  259. {
  260. InterlockedCompareExchange((LPLONG)&m_PerfCounters.MaxCgiReqs,
  261. currCgis,
  262. currMaxCgis);
  263. }
  264. }
  265. VOID DecCgiReqs()
  266. {
  267. InterlockedDecrement((LPLONG)&m_PerfCounters.CurrentCgiReqs);
  268. }
  269. VOID IncIsapiExtReqs()
  270. {
  271. InterlockedIncrement((LPLONG)&m_PerfCounters.IsapiExtReqs);
  272. DWORD currIsapiExts = InterlockedIncrement((LPLONG)&m_PerfCounters.CurrentIsapiExtReqs);
  273. DWORD currMaxIsapiExts;
  274. while ((currMaxIsapiExts = m_PerfCounters.MaxIsapiExtReqs) <
  275. currIsapiExts)
  276. {
  277. InterlockedCompareExchange((LPLONG)&m_PerfCounters.MaxIsapiExtReqs,
  278. currIsapiExts,
  279. currMaxIsapiExts);
  280. }
  281. }
  282. VOID DecIsapiExtReqs()
  283. {
  284. InterlockedDecrement((LPLONG)&m_PerfCounters.CurrentIsapiExtReqs);
  285. }
  286. VOID IncNotFound()
  287. {
  288. InterlockedIncrement((LPLONG)&m_PerfCounters.NotFoundErrors);
  289. }
  290. VOID IncLockedError()
  291. {
  292. InterlockedIncrement((LPLONG)&m_PerfCounters.LockedErrors);
  293. }
  294. BOOL
  295. IsAuthPwdChangeEnabled(
  296. VOID
  297. )
  298. {
  299. return !( m_dwAuthChangeFlags & MD_AUTH_CHANGE_DISABLE );
  300. }
  301. BOOL
  302. IsAuthPwdChangeNotificationEnabled(
  303. VOID
  304. )
  305. {
  306. return !( m_dwAuthChangeFlags & MD_AUTH_ADVNOTIFY_DISABLE );
  307. }
  308. STRU *
  309. QueryAuthChangeUrl(
  310. VOID
  311. )
  312. {
  313. return &m_strAuthChangeUrl;
  314. }
  315. STRU *
  316. QueryAuthExpiredUrl(
  317. VOID
  318. )
  319. {
  320. if ( m_dwAuthChangeFlags & MD_AUTH_CHANGE_DISABLE )
  321. {
  322. return NULL;
  323. }
  324. if ( m_dwAuthChangeFlags & MD_AUTH_CHANGE_UNSECURE )
  325. {
  326. return &m_strAuthExpiredUnsecureUrl;
  327. }
  328. else
  329. {
  330. return &m_strAuthExpiredUrl;
  331. }
  332. }
  333. STRU *
  334. QueryAdvNotPwdExpUrl(
  335. VOID
  336. )
  337. {
  338. if ( m_dwAuthChangeFlags & MD_AUTH_ADVNOTIFY_DISABLE )
  339. {
  340. return NULL;
  341. }
  342. if ( m_dwAuthChangeFlags & MD_AUTH_CHANGE_UNSECURE )
  343. {
  344. return &m_strAdvNotPwdExpUnsecureUrl;
  345. }
  346. else
  347. {
  348. return &m_strAdvNotPwdExpUrl;
  349. }
  350. }
  351. DWORD
  352. QueryAdvNotPwdExpInDays(
  353. VOID
  354. )
  355. {
  356. return m_dwAdvNotPwdExpInDays;
  357. }
  358. DWORD
  359. QueryAdvCacheTTL(
  360. VOID
  361. )
  362. {
  363. return m_dwAdvCacheTTL;
  364. }
  365. BOOL
  366. QuerySSLSupported(
  367. VOID
  368. )
  369. {
  370. return m_fSSLSupported;
  371. }
  372. HRESULT
  373. GetIISCertificateMapping(
  374. IIS_CERTIFICATE_MAPPING ** ppIISCertificateMapping
  375. );
  376. private:
  377. ~W3_SITE();
  378. HRESULT ReadPrivateProperties();
  379. DWORD m_Signature;
  380. LONG m_cRefs;
  381. DWORD m_SiteId;
  382. STRA m_SiteName;
  383. STRU m_SiteMBPath;
  384. STRU m_SiteMBRoot;
  385. FILTER_LIST *m_pInstanceFilterList;
  386. LOGGING *m_pLogging;
  387. BOOL m_fAllowPathInfoForScriptMappings;
  388. BOOL m_fUseDSMapper;
  389. IISWPSiteCounters m_PerfCounters;
  390. //
  391. // OWA related variables
  392. //
  393. STRU m_strAuthChangeUrl;
  394. STRU m_strAuthExpiredUrl;
  395. STRU m_strAdvNotPwdExpUrl;
  396. STRU m_strAuthExpiredUnsecureUrl;
  397. STRU m_strAdvNotPwdExpUnsecureUrl;
  398. DWORD m_dwAdvNotPwdExpInDays;
  399. DWORD m_dwAuthChangeFlags;
  400. DWORD m_dwAdvCacheTTL;
  401. //
  402. // Does this site support SSL
  403. //
  404. BOOL m_fSSLSupported;
  405. //
  406. // IIS certificate mapping
  407. // It is loaded on demand on first request to content
  408. // that enable IIS cert mapping
  409. //
  410. IIS_CERTIFICATE_MAPPING * m_pIISCertMap;
  411. BOOL m_fAlreadyAttemptedToLoadIISCertMap;
  412. static CRITICAL_SECTION sm_csIISCertMapLock;
  413. }; // W3_SITE
  414. #endif // _W3SITE_H_