summaryrefslogtreecommitdiffstats
path: root/private/ntos/nbt/inc/hosts.h
blob: 1ebf4755ed4c23de2026e7a92f133be4e3212b6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*++

Copyright (c) 1991  Microsoft Corporation

Module Name:

    lmhosts.h

Abstract:

    This is the header file for the lmhosts facility of the nbt driver.

Author:

    Eric Chin (ericc)           April 28, 1992

Revision History:

--*/
#ifndef _LMHOSTS_H_
#define _LMHOSTS_H_



//
// Configuration Defaults
//
// Only the first MAX_PARSE_BYTES of each line in the lmhosts file is
// examined.
//

#define DATABASEPATH                "\\SystemRoot\\nt\\system32\\drivers\\etc"

#define LMHOSTSFILE                 "lmhosts"           // name of lmhosts file

#define MAX_FILE_IO_THREADS         1                   // threads to read
                                                        //   lmhosts file
#ifdef VXD
#define MAX_PRELOAD                 100                 // max cache entries
                                                        //   to preload
#else
#define MAX_PRELOAD                 1000                // max cache entries
                                                        //   to preload
#endif

#define SPECIAL_GROUP_SUFFIX        0x1C                // for netlogon and
                                                        //   the browser
#define SPECIAL_BROWSER_SUFFIX      0x1D                // for the browser
#define MAX_MEMBERS_INTERNET_GROUP    50                // max size of internet group

//
// Reserved Keywords in the lmhosts File
//
#define BEG_ALT_TOKEN               "#BEGIN_ALTERNATE"  // alternate block
#define DOMAIN_TOKEN                "#DOM:"             // specifies LM domain
#define END_ALT_TOKEN               "#END_ALTERNATE"    // alternate block
#define INCLUDE_TOKEN               "#INCLUDE"          // include a file
#define PRELOAD_TOKEN               "#PRE"              // preload this entry
#define NOFNR_TOKEN                 "#NOFNR"            // no find name request


//
// Macro Definitions
//

//#define min(x, y)                   ((x) < (y) ? (x) : (y))



//
// Public Definitions
//
//
// For each file that is opened, a LM_FILE object is created.
//
typedef struct _LM_FILE
{
#ifndef VXD
    KSPIN_LOCK      f_lock;                     //  protects this object
    LONG            f_refcount;                 //  current no of references
#endif

    HANDLE          f_handle;                   //  handle from ZwOpenFile()
    LONG            f_lineno;                   //  current line number

#ifndef VXD
    LARGE_INTEGER   f_fileOffset;               //  current offset into file

    PUCHAR          f_current;                  //  buffer position to read
    PUCHAR          f_limit;                    //  last byte + 1 of buffer
    PUCHAR          f_buffer;                   //  start of buffer
#else
    PUCHAR          f_linebuffer;               //  line buffer
    PUCHAR          f_buffer;                   //  file buffer
    BOOL            f_EOF ;                     //  TRUE if EOF
    ULONG           f_CurPos ;                  //  Current Pos. in File Buffer
    ULONG           f_EndOfData ;               //  Last valid data in File Buffer
    PUCHAR          f_BackUp;                   //  copy here In case of #INCLUDE
#endif

} LM_FILE, *PLM_FILE;


//
// The LM_IPADDRESS_LIST object contains pertinent information about a
// group of ip addresses.
//
//
typedef struct _LM_IPADDRESS_LIST
{

    KSPIN_LOCK      i_rcntlock;                 // protects i_refcount
    LONG            i_refcount;                 // current no of references
    KSPIN_LOCK      i_lock;                     // only when adding to i_addrs[]
    int             i_maxaddrs;                 // max capacity of i_addrs[]
    int             i_numaddrs;                 // current no of ip addresses
    unsigned long   i_addrs[1];                 // the array of ip addresses

} LM_IPADDRESS_LIST, *PLM_IPADDRESS_LIST;


//
// An LM_PARSE_FUNCTION may be called recursively to handle #INCLUDE
// directives in an lmhosts file.
//
//
typedef unsigned long (* LM_PARSE_FUNCTION) (
    IN PUCHAR   path,                    // file to parse
    IN PUCHAR   target OPTIONAL,                  // NetBIOS name
    IN BOOLEAN  recurse,                         // process #INCLUDE's ?
    OUT BOOLEAN *NoFindName                     // do not do find name
);


//
// The LM_WORK_ITEM object is the interface between lm_lookup() and
// LmFindName().
//
//
typedef struct _LM_WORK_ITEM
{                  // work for io thread(s)

    LIST_ENTRY      w_list;                     //  links to other items
//    mblk_t         *w_mp;                       //  STREAMS buffer

} LM_WORK_ITEM, *PLM_WORK_ITEM;



//
// Private Function Prototypes
//
int
LmAddToDomAddrList (
    IN PUCHAR name,
    IN unsigned long inaddr
    );

NTSTATUS
LmCloseFile (
    IN PLM_FILE handle
    );

NTSTATUS
LmCreateThreads (
    IN int nthreads
    );

NTSTATUS
LmDeleteAllDomAddrLists (
    VOID
    );

VOID
LmDerefDomAddrList(
    PLM_IPADDRESS_LIST arrayp
    );

char *
LmExpandName (
    OUT PUCHAR dest,
    IN PUCHAR source,
    IN UCHAR last
    );

PUCHAR
LmFgets (
    IN PLM_FILE pfile,
    OUT int *nbytes
    );

NTSTATUS
LmFindName (
    VOID
    );

PLM_IPADDRESS_LIST
LmGetDomAddrList (
    PUCHAR name
    );

unsigned long
LmGetIpAddr (
    IN PUCHAR path,
    IN PUCHAR target,
    IN BOOLEAN recurse,
    OUT BOOLEAN *NoFindName
    );

NTSTATUS
LmGetFullPath (
    IN PUCHAR  target,
    OUT PUCHAR *path
    );

unsigned long
LmInclude(
    IN PUCHAR            file,
    IN LM_PARSE_FUNCTION function,
    IN PUCHAR            argument,
    OUT BOOLEAN          *NoFindName
    );

NTSTATUS
LmInitDomAddrLists (
    VOID
    );

VOID
LmLogOpenError (
    IN PUCHAR path,
    IN NTSTATUS unused
    );

VOID
LmLogSyntaxError (
    IN LONG lineno
    );

PLM_FILE
LmOpenFile (
    IN PUCHAR path
    );

int
LmPreloadEntry (
    IN PUCHAR name,
    IN unsigned long inaddr,
    IN unsigned int NoFNR
    );

BOOLEAN
LmPutCacheEntry (
//    IN mblk_t *mp,
    IN unsigned char *name,
    IN unsigned long inaddr,
    IN unsigned int ttl,
    IN LONG     nb_flags,
    IN unsigned int NoFNR
    );

NTSTATUS
LmTerminateThreads(
    VOID
    );

//
// Functions Imported from ..\common
//
extern unsigned long
inet_addr(
    IN char *cp
    );




#endif // _LMHOSTS_H_