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.

153 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. iisassoc.hxx
  5. Abstract:
  6. This include file contains the declaration of the IIS_ASSOCIATION class.
  7. An IIS_ASSOCIATION is used to create an N-way association between
  8. IIS_ENDPOINTs and IIS_SERVER_INSTANCEs.
  9. The current IIS_ASSOCIATION is hash based. It may hash on either the
  10. IP address, the host name, or both. The hash method is specified when
  11. the object is constructed.
  12. Author:
  13. Keith Moore (keithmo) 16-Jan-1997
  14. Revision History:
  15. --*/
  16. #ifndef _IISASSOC_HXX_
  17. #define _IISASSOC_HXX_
  18. //
  19. // We will need to do some perf tuning to get a more reasonable value for
  20. // this number. We may need to make this metabase configurable, or at least
  21. // base it on the 'size' of the server.
  22. //
  23. #define DEFAULT_ASSOCIATION_HASH_BUCKETS 97
  24. typedef
  25. BOOL
  26. (WINAPI * LPFN_ASSOCIATION_CALLBACK)(
  27. IN LPVOID CallbackContext,
  28. IN LPVOID DescriptorContext,
  29. IN DWORD IpAddress,
  30. IN const CHAR * HostName
  31. );
  32. class IIS_ASSOCIATION {
  33. public:
  34. //
  35. // This hash context is used to avoid redundant hash context calculations
  36. // while searching through multiple associations.
  37. //
  38. typedef struct _HASH_CONTEXT {
  39. DWORD IpAddressHash;
  40. DWORD HostNameHash;
  41. } HASH_CONTEXT, *PHASH_CONTEXT;
  42. static
  43. VOID
  44. InitializeHashContext(
  45. OUT PHASH_CONTEXT HashContext
  46. ) {
  47. HashContext->IpAddressHash = 0;
  48. HashContext->HostNameHash = 0;
  49. }
  50. //
  51. // Usual constructor/destructor stuff.
  52. //
  53. IIS_ASSOCIATION(
  54. IN BOOL HashIpAddress,
  55. IN BOOL HashHostName,
  56. IN INT NumHashBuckets = DEFAULT_ASSOCIATION_HASH_BUCKETS
  57. );
  58. ~IIS_ASSOCIATION();
  59. //
  60. // Descriptor management.
  61. //
  62. DWORD
  63. AddDescriptor(
  64. IN DWORD IpAddress,
  65. IN const CHAR * HostName OPTIONAL,
  66. IN LPVOID Context,
  67. IN OUT PHASH_CONTEXT HashContext = NULL
  68. );
  69. DWORD
  70. LookupDescriptor(
  71. IN DWORD IpAddress,
  72. IN const CHAR * HostName OPTIONAL,
  73. OUT LPVOID *Context,
  74. IN OUT PHASH_CONTEXT HashContext = NULL
  75. );
  76. DWORD
  77. RemoveDescriptor(
  78. IN DWORD IpAddress,
  79. IN const CHAR * HostName OPTIONAL,
  80. OUT LPVOID *Context,
  81. IN OUT PHASH_CONTEXT HashContext = NULL
  82. );
  83. VOID
  84. EnumDescriptors(
  85. IN LPFN_ASSOCIATION_CALLBACK Callback,
  86. IN LPVOID CallbackContext
  87. );
  88. private:
  89. VOID
  90. CalculateHash(
  91. IN DWORD IpAddress,
  92. IN const CHAR * HostName OPTIONAL,
  93. OUT PHASH_CONTEXT HashContext
  94. );
  95. struct _HASH_ENTRY *
  96. FindDescriptor(
  97. IN DWORD IpAddress,
  98. IN const CHAR * HostName OPTIONAL,
  99. IN PHASH_CONTEXT HashContext
  100. );
  101. struct _HASH_ENTRY *
  102. CreateHashEntry(
  103. IN DWORD IpAddress,
  104. IN const CHAR * HostName OPTIONAL,
  105. IN PHASH_CONTEXT HashContext
  106. );
  107. INT m_NumHashBuckets;
  108. PLIST_ENTRY m_HashBuckets;
  109. BOOL m_HashIpAddress;
  110. BOOL m_HashHostName;
  111. }; // IIS_ASSOCIATION
  112. #endif // _IISASSOC_HXX_