Windows NT 4.0 source code leak
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.

279 lines
6.1 KiB

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