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.

230 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. // HOSTENT_CACHE_ENTRY_STATE - the hostent 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. } HOSTENT_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. // The structure is variable length, dependent on the amount of data in the
  37. // hostent. We also honour the time-to-live in the DNS answer. When we get a
  38. // response we set the ExpirationTime field. On future cache hits, if the
  39. // current time is >= the ExpirationTime value then we must throw out this entry
  40. // and refresh the cache
  41. //
  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 resolved to Hostent
  55. //
  56. LPSTR HostName;
  57. //
  58. // State - unused, in-use, or delete
  59. //
  60. HOSTENT_CACHE_ENTRY_STATE State;
  61. //
  62. // ReferenceCount - only change State when zero
  63. //
  64. LONG ReferenceCount;
  65. //
  66. // Hostent - the fixed data portion of a HOSTENT structure. The variable
  67. // part overflows the end of this structure
  68. //
  69. HOSTENT Hostent;
  70. } RESOLVER_CACHE_ENTRY, *LPRESOLVER_CACHE_ENTRY;
  71. //
  72. // prototypes
  73. //
  74. #if defined(__cplusplus)
  75. extern "C" {
  76. #endif
  77. BOOL
  78. QueryHostentCache(
  79. SERIALIZED_LIST* pResolverCache,
  80. IN LPSTR Name OPTIONAL,
  81. IN LPBYTE Address OPTIONAL,
  82. OUT LPHOSTENT * Hostent,
  83. OUT LPDWORD TimeToLive
  84. );
  85. VOID
  86. CacheHostent(
  87. SERIALIZED_LIST* pResolverCache,
  88. IN LPSTR lpszHostName,
  89. IN LPHOSTENT pHostent,
  90. IN DWORD TimeToLive,
  91. IN VOID** pAlloc=NULL,
  92. IN DWORD dwAllocSize=0
  93. );
  94. VOID
  95. FlushHostentCache(
  96. SERIALIZED_LIST* pResolverCache
  97. );
  98. VOID
  99. ThrowOutHostentCacheEntry(
  100. SERIALIZED_LIST* pResolverCache,
  101. IN LPHOSTENT lpHostent
  102. );
  103. VOID
  104. ReleaseHostentCacheEntry(
  105. SERIALIZED_LIST* pResolverCache,
  106. IN LPHOSTENT lpHostent
  107. );
  108. #if defined(__cplusplus)
  109. }
  110. #endif
  111. #if defined(RNR_SUPPORTED)
  112. /*++
  113. Copyright (c) 1996 Microsoft Corporation
  114. Module Name:
  115. rescache.h
  116. Abstract:
  117. Contains name resolution cache structure definition
  118. Contents:
  119. Author:
  120. Shishir Pardikar 2-14-96
  121. Environment:
  122. Win32 user mode
  123. Revision History:
  124. 2-14-96 shishirp
  125. Created
  126. --*/
  127. #if defined(__cplusplus)
  128. extern "C" {
  129. #endif
  130. DWORD
  131. InitNameresCache(
  132. VOID
  133. );
  134. DWORD
  135. AddNameresCacheEntry(
  136. DWORD dwNameSpace,
  137. LPGUID lpGuid,
  138. LPSTR lpName,
  139. int cntAddresses,
  140. LPCSADDR_INFO lpAddressInfoList
  141. );
  142. DWORD
  143. RemoveNameresCacheEntry(
  144. DWORD dwNameSpace,
  145. LPGUID lpGuid,
  146. LPSTR lpszName
  147. );
  148. DWORD
  149. RemoveNameresCacheEntryByAddr(
  150. int cntAddresses,
  151. LPCSADDR_INFO lpCsaddrInfo
  152. );
  153. DWORD
  154. GetNameresCacheEntry(
  155. DWORD dwNameSpace,
  156. LPGUID lpGuid,
  157. LPSTR lpName,
  158. INT *lpcntAddresses,
  159. LPCSADDR_INFO *lplpCsaddrInfoList
  160. );
  161. DWORD
  162. DeinitNameresCache(
  163. VOID
  164. );
  165. #if defined(__cplusplus)
  166. }
  167. #endif
  168. #endif // defined(RNR_SUPPORTED)