Source code of Windows XP (NT5)
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.

276 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. lmhosts.h
  5. Abstract:
  6. This is the header file for the lmhosts facility of the nbt driver.
  7. Author:
  8. Eric Chin (ericc) April 28, 1992
  9. Revision History:
  10. --*/
  11. #ifndef _LMHOSTS_H_
  12. #define _LMHOSTS_H_
  13. //
  14. // Configuration Defaults
  15. //
  16. // Only the first MAX_PARSE_BYTES of each line in the lmhosts file is
  17. // examined.
  18. //
  19. #define DATABASEPATH "\\SystemRoot\\nt\\system32\\drivers\\etc"
  20. #define LMHOSTSFILE "lmhosts" // name of lmhosts file
  21. #define MAX_FILE_IO_THREADS 1 // threads to read
  22. // lmhosts file
  23. #ifdef VXD
  24. #define DEF_PRELOAD 100 // Default entries to preload
  25. #define MAX_PRELOAD 500 // Max cache entries to preload
  26. #else
  27. #define DEF_PRELOAD 1000 // Default entries to preload
  28. #define MAX_PRELOAD 2000 // max cache entries to preload
  29. #endif
  30. #define MAX_MEMBERS_INTERNET_GROUP 50 // max size of internet group
  31. //
  32. // Reserved Keywords in the lmhosts File
  33. //
  34. #define BEG_ALT_TOKEN "#BEGIN_ALTERNATE" // alternate block
  35. #define DOMAIN_TOKEN "#DOM:" // specifies LM domain
  36. #define END_ALT_TOKEN "#END_ALTERNATE" // alternate block
  37. #define INCLUDE_TOKEN "#INCLUDE" // include a file
  38. #define PRELOAD_TOKEN "#PRE" // preload this entry
  39. #define NOFNR_TOKEN "#NOFNR" // no find name request
  40. //
  41. // Macro Definitions
  42. //
  43. //#define min(x, y) ((x) < (y) ? (x) : (y))
  44. //
  45. // Public Definitions
  46. //
  47. //
  48. // For each file that is opened, a LM_FILE object is created.
  49. //
  50. typedef struct _LM_FILE
  51. {
  52. #ifndef VXD
  53. KSPIN_LOCK f_lock; // protects this object
  54. LONG f_refcount; // current no of references
  55. #endif
  56. HANDLE f_handle; // handle from ZwOpenFile()
  57. LONG f_lineno; // current line number
  58. #ifndef VXD
  59. LARGE_INTEGER f_fileOffset; // current offset into file
  60. PUCHAR f_current; // buffer position to read
  61. PUCHAR f_limit; // last byte + 1 of buffer
  62. PUCHAR f_buffer; // start of buffer
  63. #else
  64. PUCHAR f_linebuffer; // line buffer
  65. PUCHAR f_buffer; // file buffer
  66. BOOL f_EOF ; // TRUE if EOF
  67. ULONG f_CurPos ; // Current Pos. in File Buffer
  68. ULONG f_EndOfData ; // Last valid data in File Buffer
  69. PUCHAR f_BackUp; // copy here In case of #INCLUDE
  70. #endif
  71. } LM_FILE, *PLM_FILE;
  72. //
  73. // The LM_IPADDRESS_LIST object contains pertinent information about a
  74. // group of ip addresses.
  75. //
  76. //
  77. typedef struct _LM_IPADDRESS_LIST
  78. {
  79. KSPIN_LOCK i_rcntlock; // protects i_refcount
  80. LONG i_refcount; // current no of references
  81. KSPIN_LOCK i_lock; // only when adding to i_addrs[]
  82. int i_maxaddrs; // max capacity of i_addrs[]
  83. int i_numaddrs; // current no of ip addresses
  84. unsigned long i_addrs[1]; // the array of ip addresses
  85. } LM_IPADDRESS_LIST, *PLM_IPADDRESS_LIST;
  86. //
  87. // An LM_PARSE_FUNCTION may be called recursively to handle #INCLUDE
  88. // directives in an lmhosts file.
  89. //
  90. //
  91. typedef unsigned long (* LM_PARSE_FUNCTION) (
  92. IN PUCHAR path, // file to parse
  93. IN PUCHAR target OPTIONAL, // NetBIOS name
  94. IN CHAR RecurseLevel, // process #INCLUDE's ?
  95. OUT BOOLEAN *NoFindName // do not do find name
  96. );
  97. //
  98. // The LM_WORK_ITEM object is the interface between lm_lookup() and
  99. // LmFindName().
  100. //
  101. //
  102. typedef struct _LM_WORK_ITEM
  103. { // work for io thread(s)
  104. LIST_ENTRY w_list; // links to other items
  105. // mblk_t *w_mp; // STREAMS buffer
  106. } LM_WORK_ITEM, *PLM_WORK_ITEM;
  107. //
  108. // Private Function Prototypes
  109. //
  110. int
  111. LmAddToDomAddrList (
  112. IN PUCHAR name,
  113. IN unsigned long inaddr
  114. );
  115. NTSTATUS
  116. LmCloseFile (
  117. IN PLM_FILE handle
  118. );
  119. NTSTATUS
  120. LmCreateThreads (
  121. IN int nthreads
  122. );
  123. NTSTATUS
  124. LmDeleteAllDomAddrLists (
  125. VOID
  126. );
  127. VOID
  128. LmDerefDomAddrList(
  129. PLM_IPADDRESS_LIST arrayp
  130. );
  131. char *
  132. LmExpandName (
  133. OUT PUCHAR dest,
  134. IN PUCHAR source,
  135. IN UCHAR last
  136. );
  137. PUCHAR
  138. LmFgets (
  139. IN PLM_FILE pfile,
  140. OUT int *nbytes
  141. );
  142. NTSTATUS
  143. LmFindName (
  144. VOID
  145. );
  146. PLM_IPADDRESS_LIST
  147. LmGetDomAddrList (
  148. PUCHAR name
  149. );
  150. unsigned long
  151. LmGetIpAddr (
  152. IN PUCHAR path,
  153. IN PUCHAR target,
  154. IN CHAR RecurseDepth,
  155. OUT BOOLEAN *NoFindName
  156. );
  157. NTSTATUS
  158. LmGetFullPath (
  159. IN PUCHAR target,
  160. OUT PUCHAR *path
  161. );
  162. unsigned long
  163. LmInclude(
  164. IN PUCHAR file,
  165. IN LM_PARSE_FUNCTION function,
  166. IN PUCHAR argument,
  167. IN CHAR RecurseDepth,
  168. OUT BOOLEAN *NoFindName
  169. );
  170. NTSTATUS
  171. LmInitDomAddrLists (
  172. VOID
  173. );
  174. VOID
  175. LmLogOpenError (
  176. IN PUCHAR path,
  177. IN NTSTATUS unused
  178. );
  179. VOID
  180. LmLogSyntaxError (
  181. IN LONG lineno
  182. );
  183. PLM_FILE
  184. LmOpenFile (
  185. IN PUCHAR path
  186. );
  187. int
  188. LmPreloadEntry (
  189. IN PUCHAR name,
  190. IN unsigned long inaddr,
  191. IN unsigned int NoFNR
  192. );
  193. BOOLEAN
  194. LmPutCacheEntry (
  195. // IN mblk_t *mp,
  196. IN unsigned char *name,
  197. IN unsigned long inaddr,
  198. IN unsigned int ttl,
  199. IN LONG nb_flags,
  200. IN unsigned int NoFNR
  201. );
  202. NTSTATUS
  203. LmTerminateThreads(
  204. VOID
  205. );
  206. //
  207. // Functions Imported from ..\common
  208. //
  209. extern unsigned long
  210. inet_addr(
  211. IN char *cp
  212. );
  213. #endif // _LMHOSTS_H_