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.

234 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. rescache.h
  5. Abstract:
  6. Contains prototypes, structures, manifests for rescache.c
  7. Author:
  8. Richard L Firth (rfirth) 10-Jul-1994
  9. Revision History:
  10. rfirth 10-Jul-1994
  11. Created
  12. --*/
  13. //
  14. // manifests
  15. //
  16. #define RESOLVER_CACHE_DISABLED -1
  17. #define MINIMUM_RESOLVER_CACHE_ENTRIES 1
  18. #define MAXIMUM_RESOLVER_CACHE_ENTRIES 128 // arbitrary, just in case user decides to wack it up
  19. #define LIVE_FOREVER ((DWORD)-1)
  20. #define LIVE_DEFAULT ((DWORD)0)
  21. //
  22. // types
  23. //
  24. //
  25. // RESOLVER_CACHE_ENTRY_STATE - the cache entry can be in-use, unused, or
  26. // awaiting deletion
  27. //
  28. typedef enum {
  29. ENTRY_UNUSED = 1,
  30. ENTRY_IN_USE,
  31. ENTRY_DELETE
  32. } RESOLVER_CACHE_ENTRY_STATE;
  33. //
  34. // RESOLVER_CACHE_ENTRY - we maintain a doubly-linked list of these. The list is
  35. // maintained in MRU order - we throw out the one at the far end of the list.
  36. // Because the name resolution APIs do not return the time-to-live in the DNS
  37. // answer, we cannot honor it (an argument for why we should let the resolver
  38. // do the caching - if only all platforms did this). When we get a response we
  39. // set the ExpirationTime field to a default value. On future cache hits, if
  40. // the current time is >= the ExpirationTime value then we must throw out this
  41. // entry and refresh the cache
  42. //
  43. typedef struct {
  44. //
  45. // ListEntry - cache entries comprise a double-linked list
  46. //
  47. LIST_ENTRY ListEntry;
  48. //
  49. // ExpirationTime - formed by adding the time-to-live value from the DNS
  50. // response to the result obtained from time(). If ever time() returns a
  51. // value >= ExpirationTime, this entry is stale and must be refreshed
  52. //
  53. DWORD ExpirationTime;
  54. //
  55. // HostName - original name that resolved to this entry
  56. //
  57. LPSTR HostName;
  58. //
  59. // State - unused, in-use, or delete
  60. //
  61. RESOLVER_CACHE_ENTRY_STATE State;
  62. //
  63. // ReferenceCount - only change State when zero
  64. //
  65. LONG ReferenceCount;
  66. //
  67. // AddrInfo - pointer to a list of addrinfo structures
  68. //
  69. LPADDRINFO AddrInfo;
  70. } RESOLVER_CACHE_ENTRY, *LPRESOLVER_CACHE_ENTRY;
  71. //
  72. // prototypes
  73. //
  74. #if defined(__cplusplus)
  75. extern "C" {
  76. #endif
  77. VOID
  78. InitializeResolverCache(
  79. VOID
  80. );
  81. VOID
  82. TerminateResolverCache(
  83. VOID
  84. );
  85. LPRESOLVER_CACHE_ENTRY
  86. QueryResolverCache(
  87. IN LPSTR Name OPTIONAL,
  88. IN LPSOCKADDR Address OPTIONAL,
  89. OUT LPADDRINFO * AddrInfo,
  90. OUT LPDWORD TimeToLive
  91. );
  92. VOID
  93. AddResolverCacheEntry(
  94. IN LPSTR lpszHostName,
  95. IN LPADDRINFO lpAddrInfo,
  96. IN DWORD TimeToLive
  97. );
  98. VOID
  99. FlushResolverCache(
  100. VOID
  101. );
  102. VOID
  103. ThrowOutResolverCacheEntry(
  104. IN LPADDRINFO lpAddrinfo
  105. );
  106. VOID
  107. ReleaseResolverCacheEntry(
  108. IN LPRESOLVER_CACHE_ENTRY cacheEntry
  109. );
  110. #if defined(__cplusplus)
  111. }
  112. #endif
  113. #if defined(RNR_SUPPORTED)
  114. /*++
  115. Copyright (c) 1996 Microsoft Corporation
  116. Module Name:
  117. rescache.h
  118. Abstract:
  119. Contains name resolution cache structure definition
  120. Contents:
  121. Author:
  122. Shishir Pardikar 2-14-96
  123. Environment:
  124. Win32 user mode
  125. Revision History:
  126. 2-14-96 shishirp
  127. Created
  128. --*/
  129. #if defined(__cplusplus)
  130. extern "C" {
  131. #endif
  132. DWORD
  133. InitNameresCache(
  134. VOID
  135. );
  136. DWORD
  137. AddNameresCacheEntry(
  138. DWORD dwNameSpace,
  139. LPGUID lpGuid,
  140. LPSTR lpName,
  141. int cntAddresses,
  142. LPCSADDR_INFO lpAddressInfoList
  143. );
  144. DWORD
  145. RemoveNameresCacheEntry(
  146. DWORD dwNameSpace,
  147. LPGUID lpGuid,
  148. LPSTR lpszName
  149. );
  150. DWORD
  151. RemoveNameresCacheEntryByAddr(
  152. int cntAddresses,
  153. LPCSADDR_INFO lpCsaddrInfo
  154. );
  155. DWORD
  156. GetNameresCacheEntry(
  157. DWORD dwNameSpace,
  158. LPGUID lpGuid,
  159. LPSTR lpName,
  160. INT *lpcntAddresses,
  161. LPCSADDR_INFO *lplpCsaddrInfoList
  162. );
  163. DWORD
  164. DeinitNameresCache(
  165. VOID
  166. );
  167. #if defined(__cplusplus)
  168. }
  169. #endif
  170. #endif // defined(RNR_SUPPORTED)