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.

231 lines
4.2 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. typedef struct {
  43. //
  44. // ListEntry - cache entries comprise a double-linked list
  45. //
  46. LIST_ENTRY ListEntry;
  47. //
  48. // ExpirationTime - formed by adding the time-to-live value from the DNS
  49. // response to the result obtained from time(). If ever time() returns a
  50. // value >= ExpirationTime, this entry is stale and must be refreshed
  51. //
  52. DWORD ExpirationTime;
  53. //
  54. // HostName - original name that resolved to this entry
  55. //
  56. LPSTR HostName;
  57. //
  58. // State - unused, in-use, or delete
  59. //
  60. RESOLVER_CACHE_ENTRY_STATE State;
  61. //
  62. // ReferenceCount - only change State when zero
  63. //
  64. LONG ReferenceCount;
  65. //
  66. // AddrInfo - pointer to a list of addrinfo structures
  67. //
  68. LPADDRINFO AddrInfo;
  69. } RESOLVER_CACHE_ENTRY, *LPRESOLVER_CACHE_ENTRY;
  70. //
  71. // prototypes
  72. //
  73. #if defined(__cplusplus)
  74. extern "C" {
  75. #endif
  76. LPRESOLVER_CACHE_ENTRY
  77. QueryResolverCache(
  78. SERIALIZED_LIST* pResolverCache,
  79. IN LPSTR Name OPTIONAL,
  80. IN LPSOCKADDR Address OPTIONAL,
  81. OUT LPADDRINFO * AddrInfo,
  82. OUT LPDWORD TimeToLive
  83. );
  84. VOID
  85. AddResolverCacheEntry(
  86. SERIALIZED_LIST* pResolverCache,
  87. IN LPSTR lpszHostName,
  88. IN LPADDRINFO lpAddrInfo,
  89. IN DWORD TimeToLive,
  90. IN VOID** pAlloc=NULL,
  91. IN DWORD dwAllocSize=0
  92. );
  93. VOID
  94. FlushResolverCache(
  95. SERIALIZED_LIST* pResolverCache
  96. );
  97. #ifdef NOT_USED
  98. VOID
  99. ThrowOutResolverCacheEntry(
  100. SERIALIZED_LIST* pResolverCache,
  101. IN LPADDRINFO lpAddrinfo
  102. );
  103. #endif //NOT_USED
  104. VOID
  105. ReleaseResolverCacheEntry(
  106. SERIALIZED_LIST* pResolverCache,
  107. IN LPRESOLVER_CACHE_ENTRY cacheEntry
  108. );
  109. #if defined(__cplusplus)
  110. }
  111. #endif
  112. #if defined(RNR_SUPPORTED)
  113. /*++
  114. Copyright (c) 1996 Microsoft Corporation
  115. Module Name:
  116. rescache.h
  117. Abstract:
  118. Contains name resolution cache structure definition
  119. Contents:
  120. Author:
  121. Shishir Pardikar 2-14-96
  122. Environment:
  123. Win32 user mode
  124. Revision History:
  125. 2-14-96 shishirp
  126. Created
  127. --*/
  128. #if defined(__cplusplus)
  129. extern "C" {
  130. #endif
  131. DWORD
  132. InitNameresCache(
  133. VOID
  134. );
  135. DWORD
  136. AddNameresCacheEntry(
  137. DWORD dwNameSpace,
  138. LPGUID lpGuid,
  139. LPSTR lpName,
  140. int cntAddresses,
  141. LPCSADDR_INFO lpAddressInfoList
  142. );
  143. DWORD
  144. RemoveNameresCacheEntry(
  145. DWORD dwNameSpace,
  146. LPGUID lpGuid,
  147. LPSTR lpszName
  148. );
  149. DWORD
  150. RemoveNameresCacheEntryByAddr(
  151. int cntAddresses,
  152. LPCSADDR_INFO lpCsaddrInfo
  153. );
  154. DWORD
  155. GetNameresCacheEntry(
  156. DWORD dwNameSpace,
  157. LPGUID lpGuid,
  158. LPSTR lpName,
  159. INT *lpcntAddresses,
  160. LPCSADDR_INFO *lplpCsaddrInfoList
  161. );
  162. DWORD
  163. DeinitNameresCache(
  164. VOID
  165. );
  166. #if defined(__cplusplus)
  167. }
  168. #endif
  169. #endif // defined(RNR_SUPPORTED)