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.

544 lines
13 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 ReferenceSite()
  67. {
  68. InterlockedIncrement( &m_cRefs );
  69. }
  70. void DereferenceSite()
  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 HttpVerbOPTIONS:
  207. InterlockedIncrement((LPLONG)&m_PerfCounters.OptionsReqs);
  208. return;
  209. case HttpVerbGET:
  210. InterlockedIncrement((LPLONG)&m_PerfCounters.GetReqs);
  211. return;
  212. case HttpVerbHEAD:
  213. InterlockedIncrement((LPLONG)&m_PerfCounters.HeadReqs);
  214. return;
  215. case HttpVerbPOST:
  216. InterlockedIncrement((LPLONG)&m_PerfCounters.PostReqs);
  217. return;
  218. case HttpVerbPUT:
  219. InterlockedIncrement((LPLONG)&m_PerfCounters.PutReqs);
  220. IncFilesRecvd();
  221. return;
  222. case HttpVerbDELETE:
  223. InterlockedIncrement((LPLONG)&m_PerfCounters.DeleteReqs);
  224. return;
  225. case HttpVerbTRACE:
  226. InterlockedIncrement((LPLONG)&m_PerfCounters.TraceReqs);
  227. return;
  228. case HttpVerbMOVE:
  229. InterlockedIncrement((LPLONG)&m_PerfCounters.MoveReqs);
  230. return;
  231. case HttpVerbCOPY:
  232. InterlockedIncrement((LPLONG)&m_PerfCounters.CopyReqs);
  233. return;
  234. case HttpVerbPROPFIND:
  235. InterlockedIncrement((LPLONG)&m_PerfCounters.PropfindReqs);
  236. return;
  237. case HttpVerbPROPPATCH:
  238. InterlockedIncrement((LPLONG)&m_PerfCounters.ProppatchReqs);
  239. return;
  240. case HttpVerbMKCOL:
  241. InterlockedIncrement((LPLONG)&m_PerfCounters.MkcolReqs);
  242. return;
  243. case HttpVerbLOCK:
  244. InterlockedIncrement((LPLONG)&m_PerfCounters.LockReqs);
  245. return;
  246. case HttpVerbUNLOCK:
  247. InterlockedIncrement((LPLONG)&m_PerfCounters.UnlockReqs);
  248. return;
  249. case HttpVerbSEARCH:
  250. InterlockedIncrement((LPLONG)&m_PerfCounters.SearchReqs);
  251. return;
  252. default:
  253. InterlockedIncrement((LPLONG)&m_PerfCounters.OtherReqs);
  254. return;
  255. }
  256. }
  257. VOID IncCgiReqs()
  258. {
  259. InterlockedIncrement((LPLONG)&m_PerfCounters.CgiReqs);
  260. DWORD currCgis = InterlockedIncrement((LPLONG)&m_PerfCounters.CurrentCgiReqs);
  261. DWORD currMaxCgis;
  262. while ((currMaxCgis = m_PerfCounters.MaxCgiReqs) <
  263. currCgis)
  264. {
  265. InterlockedCompareExchange((LPLONG)&m_PerfCounters.MaxCgiReqs,
  266. currCgis,
  267. currMaxCgis);
  268. }
  269. }
  270. VOID DecCgiReqs()
  271. {
  272. InterlockedDecrement((LPLONG)&m_PerfCounters.CurrentCgiReqs);
  273. }
  274. VOID IncIsapiExtReqs()
  275. {
  276. InterlockedIncrement((LPLONG)&m_PerfCounters.IsapiExtReqs);
  277. DWORD currIsapiExts = InterlockedIncrement((LPLONG)&m_PerfCounters.CurrentIsapiExtReqs);
  278. DWORD currMaxIsapiExts;
  279. while ((currMaxIsapiExts = m_PerfCounters.MaxIsapiExtReqs) <
  280. currIsapiExts)
  281. {
  282. InterlockedCompareExchange((LPLONG)&m_PerfCounters.MaxIsapiExtReqs,
  283. currIsapiExts,
  284. currMaxIsapiExts);
  285. }
  286. }
  287. VOID DecIsapiExtReqs()
  288. {
  289. InterlockedDecrement((LPLONG)&m_PerfCounters.CurrentIsapiExtReqs);
  290. }
  291. VOID IncNotFound()
  292. {
  293. InterlockedIncrement((LPLONG)&m_PerfCounters.NotFoundErrors);
  294. }
  295. VOID IncLockedError()
  296. {
  297. InterlockedIncrement((LPLONG)&m_PerfCounters.LockedErrors);
  298. }
  299. BOOL
  300. IsAuthPwdChangeEnabled(
  301. VOID
  302. )
  303. {
  304. return !( m_dwAuthChangeFlags & MD_AUTH_CHANGE_DISABLE );
  305. }
  306. BOOL
  307. IsAuthPwdChangeNotificationEnabled(
  308. VOID
  309. )
  310. {
  311. return !( m_dwAuthChangeFlags & MD_AUTH_ADVNOTIFY_DISABLE );
  312. }
  313. STRU *
  314. QueryAuthChangeUrl(
  315. VOID
  316. )
  317. {
  318. return &m_strAuthChangeUrl;
  319. }
  320. STRU *
  321. QueryAuthExpiredUrl(
  322. VOID
  323. )
  324. {
  325. if ( m_dwAuthChangeFlags & MD_AUTH_CHANGE_DISABLE )
  326. {
  327. return NULL;
  328. }
  329. if ( m_dwAuthChangeFlags & MD_AUTH_CHANGE_UNSECURE )
  330. {
  331. return &m_strAuthExpiredUnsecureUrl;
  332. }
  333. else
  334. {
  335. return &m_strAuthExpiredUrl;
  336. }
  337. }
  338. STRU *
  339. QueryAdvNotPwdExpUrl(
  340. VOID
  341. )
  342. {
  343. if ( m_dwAuthChangeFlags & MD_AUTH_ADVNOTIFY_DISABLE )
  344. {
  345. return NULL;
  346. }
  347. if ( m_dwAuthChangeFlags & MD_AUTH_CHANGE_UNSECURE )
  348. {
  349. return &m_strAdvNotPwdExpUnsecureUrl;
  350. }
  351. else
  352. {
  353. return &m_strAdvNotPwdExpUrl;
  354. }
  355. }
  356. DWORD
  357. QueryAdvNotPwdExpInDays(
  358. VOID
  359. )
  360. {
  361. return m_dwAdvNotPwdExpInDays;
  362. }
  363. DWORD
  364. QueryAdvCacheTTL(
  365. VOID
  366. )
  367. {
  368. return m_dwAdvCacheTTL;
  369. }
  370. BOOL
  371. QuerySSLSupported(
  372. VOID
  373. )
  374. {
  375. return m_fSSLSupported;
  376. }
  377. HRESULT
  378. GetIISCertificateMapping(
  379. IIS_CERTIFICATE_MAPPING ** ppIISCertificateMapping
  380. );
  381. HRESULT
  382. GetDataSetCache(
  383. DATA_SET_CACHE ** ppDataSetCache
  384. );
  385. VOID
  386. RemoveDataSetCache(
  387. VOID
  388. );
  389. private:
  390. ~W3_SITE();
  391. HRESULT ReadPrivateProperties();
  392. DWORD m_Signature;
  393. LONG m_cRefs;
  394. DWORD m_SiteId;
  395. STRA m_SiteName;
  396. STRU m_SiteMBPath;
  397. STRU m_SiteMBRoot;
  398. FILTER_LIST *m_pInstanceFilterList;
  399. LOGGING *m_pLogging;
  400. BOOL m_fAllowPathInfoForScriptMappings;
  401. BOOL m_fUseDSMapper;
  402. IISWPSiteCounters m_PerfCounters;
  403. //
  404. // OWA related variables
  405. //
  406. STRU m_strAuthChangeUrl;
  407. STRU m_strAuthExpiredUrl;
  408. STRU m_strAdvNotPwdExpUrl;
  409. STRU m_strAuthExpiredUnsecureUrl;
  410. STRU m_strAdvNotPwdExpUnsecureUrl;
  411. DWORD m_dwAdvNotPwdExpInDays;
  412. DWORD m_dwAuthChangeFlags;
  413. DWORD m_dwAdvCacheTTL;
  414. //
  415. // Data set cache management
  416. //
  417. CReaderWriterLock3 m_DataSetCacheLock;
  418. DATA_SET_CACHE * m_pDataSetCache;
  419. //
  420. // Does this site support SSL
  421. //
  422. BOOL m_fSSLSupported;
  423. //
  424. // IIS certificate mapping
  425. // It is loaded on demand on first request to content
  426. // that enable IIS cert mapping
  427. //
  428. IIS_CERTIFICATE_MAPPING * m_pIISCertMap;
  429. BOOL m_fAlreadyAttemptedToLoadIISCertMap;
  430. static CRITICAL_SECTION sm_csIISCertMapLock;
  431. }; // W3_SITE
  432. #endif // _W3SITE_H_