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.

441 lines
7.3 KiB

  1. /*++
  2. Copyright (C) 2000 Microsoft Corporation
  3. Module Name:
  4. precomp.h
  5. Abstract:
  6. precompiled header
  7. --*/
  8. //#pragma warning(disable : 4115 )
  9. //#pragma warning(disable : 4214 )
  10. //#pragma warning(disable : 4200 )
  11. //#pragma warning(disable : 4213 )
  12. //#pragma warning(disable : 4211 )
  13. //#pragma warning(disable : 4310 )
  14. //
  15. // NT public header files
  16. //
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <ntseapi.h>
  21. #include <windows.h>
  22. #include <shellapi.h>
  23. #include <align.h>
  24. #include <time.h>
  25. //#pragma warning(disable : 4115 )
  26. //#pragma warning(disable : 4214 )
  27. //#pragma warning(disable : 4200 )
  28. //#pragma warning(disable : 4213 )
  29. //#pragma warning(disable : 4211 )
  30. //#pragma warning(disable : 4310 )
  31. #include <lmcons.h>
  32. #include <netlib.h>
  33. #include <lmapibuf.h>
  34. #include <winsock2.h>
  35. #include <excpt.h>
  36. #include <accctrl.h>
  37. //
  38. // C Runtime library includes.
  39. //
  40. #include <stdlib.h>
  41. #include <stdio.h>
  42. #include <string.h>
  43. //
  44. // MM related files
  45. //
  46. #include <mm\mm.h>
  47. #include <mm\array.h>
  48. #include <mm\opt.h>
  49. #include <mm\optl.h>
  50. #include <mm\optdefl.h>
  51. #include <mm\optclass.h>
  52. #include <mm\classdefl.h>
  53. #include <mm\bitmask.h>
  54. #include <mm\reserve.h>
  55. #include <mm\range.h>
  56. #include <mm\subnet.h>
  57. #include <mm\sscope.h>
  58. #include <mm\oclassdl.h>
  59. #include <mm\server.h>
  60. #include <mm\address.h>
  61. #include <mm\server2.h>
  62. #include <mm\memfree.h>
  63. #include <mmreg\regutil.h>
  64. #include <mmreg\regread.h>
  65. #include <mmreg\regsave.h>
  66. #include <stdio.h>
  67. #include <stdlib.h>
  68. #include <winsock2.h>
  69. #include <dhcpupg.h>
  70. #include <esent.h>
  71. #include <dhcpmsg.h>
  72. #include <dhcplib.h>
  73. #include <dhcpexim.h>
  74. #include <dhcpapi.h>
  75. //
  76. // Constants
  77. //
  78. #define DHCPEXIM_REG_CFG_LOC5 TEXT("Software\\Microsoft\\DHCPServer\\Configuration")
  79. #define DHCPEXIM_REG_CFG_LOC4 TEXT("System\\CurrentControlSet\\Services\\DHCPServer\\Configuration")
  80. #define SAVE_BUF_SIZE (1004096L)
  81. extern CHAR DhcpEximOemDatabaseName[2048];
  82. extern CHAR DhcpEximOemDatabasePath[2048];
  83. extern HANDLE hTextFile; // defined in dbfile.c
  84. extern PUCHAR SaveBuf; // defined in dbfile.c
  85. extern ULONG SaveBufSize; //defined in dbfile.c
  86. enum {
  87. LoadJet200,
  88. LoadJet500,
  89. LoadJet97, /* Win2K, ESENT */
  90. LoadJet2001 /* Whistler, ESENT */
  91. };
  92. typedef struct _MM_ITERATE_CTXT {
  93. //
  94. // This is filled in for all Iterate* routines
  95. //
  96. PM_SERVER Server;
  97. PVOID ExtraCtxt;
  98. //
  99. // This is filled in for IterateClasses
  100. //
  101. PM_CLASSDEF ClassDef;
  102. //
  103. // This is filled in for IterateOptDefs
  104. //
  105. PM_OPTDEF OptDef;
  106. //
  107. // This is filled in for IterateOptions
  108. //
  109. PM_OPTION Option;
  110. //
  111. // These two are filled in by both IterateOptDefs and IterateOptions
  112. //
  113. PM_CLASSDEF UserClass;
  114. PM_CLASSDEF VendorClass;
  115. //
  116. // This is used by IterateScopes
  117. //
  118. PM_SUBNET Scope;
  119. PM_SSCOPE SScope;
  120. //
  121. // This is used by IterateScopeRanges
  122. //
  123. PM_RANGE Range;
  124. //
  125. // This is used by IterateScopeExclusions
  126. //
  127. PM_EXCL Excl;
  128. //
  129. // This is used by IterateScopeReservations
  130. //
  131. PM_RESERVATION Res;
  132. }MM_ITERATE_CTXT, *PMM_ITERATE_CTXT;
  133. DWORD
  134. IterateClasses(
  135. IN PM_SERVER Server,
  136. IN PVOID ExtraCtxt,
  137. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  138. );
  139. DWORD
  140. IterateOptDefs(
  141. IN PM_SERVER Server,
  142. IN PVOID ExtraCtxt,
  143. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  144. );
  145. DWORD
  146. IterateOptionsOnOptClass(
  147. IN PM_SERVER Server,
  148. IN PM_OPTCLASS OptClass,
  149. IN PVOID ExtraCtxt,
  150. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  151. );
  152. DWORD
  153. IterateServerOptions(
  154. IN PM_SERVER Server,
  155. IN PVOID ExtraCtxt,
  156. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  157. );
  158. DWORD
  159. IterateScopeOptions(
  160. IN PM_SUBNET Subnet,
  161. IN PVOID ExtraCtxt,
  162. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  163. );
  164. DWORD
  165. IterateReservationOptions(
  166. IN PM_SERVER Server,
  167. IN PM_RESERVATION Res,
  168. IN PVOID ExtraCtxt,
  169. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  170. );
  171. DWORD
  172. IterateScopes(
  173. IN PM_SERVER Server,
  174. IN PVOID ExtraCtxt,
  175. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  176. );
  177. DWORD
  178. IterateScopeRanges(
  179. IN PM_SUBNET Scope,
  180. IN PVOID ExtraCtxt,
  181. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  182. );
  183. DWORD
  184. IterateScopeExclusions(
  185. IN PM_SUBNET Scope,
  186. IN PVOID ExtraCtxt,
  187. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  188. );
  189. DWORD
  190. IterateScopeReservations(
  191. IN PM_SUBNET Scope,
  192. IN PVOID ExtraCtxt,
  193. IN DWORD (*Callback)( IN OUT PMM_ITERATE_CTXT )
  194. );
  195. //
  196. // readreg.c
  197. //
  198. DWORD
  199. DhcpeximReadRegistryConfiguration(
  200. IN OUT PM_SERVER *Server
  201. );
  202. DWORD
  203. DhcpeximReadRegistryParameters(
  204. VOID
  205. );
  206. //
  207. // writereg.c
  208. //
  209. DWORD
  210. DhcpeximWriteRegistryConfiguration(
  211. IN PM_SERVER Server
  212. );
  213. //
  214. // readdb.c
  215. //
  216. DWORD
  217. DhcpeximReadDatabaseConfiguration(
  218. IN OUT PM_SERVER *Server
  219. );
  220. //
  221. // writedb.c
  222. //
  223. DWORD
  224. DhcpeximWriteDatabaseConfiguration(
  225. IN PM_SERVER Server
  226. );
  227. //
  228. // dbfile.c
  229. //
  230. DWORD
  231. AddRecordNoSize(
  232. IN LPSTR Buffer,
  233. IN ULONG BufSize
  234. );
  235. DWORD
  236. InitializeDatabaseParameters(
  237. VOID
  238. );
  239. DWORD
  240. CleanupDatabaseParameters(
  241. VOID
  242. );
  243. DWORD
  244. SaveDatabaseEntriesToFile(
  245. IN PULONG Subnets,
  246. IN ULONG nSubnets
  247. );
  248. DWORD
  249. SaveFileEntriesToDatabase(
  250. IN LPBYTE Mem,
  251. IN ULONG MemSize,
  252. IN PULONG Subnets,
  253. IN ULONG nSubnets
  254. );
  255. DWORD
  256. OpenTextFile(
  257. IN LPWSTR FileName,
  258. IN BOOL fRead,
  259. OUT HANDLE *hFile,
  260. OUT LPBYTE *Mem,
  261. OUT ULONG *MemSize
  262. );
  263. VOID
  264. CloseTextFile(
  265. IN OUT HANDLE hFile,
  266. IN OUT LPBYTE Mem
  267. );
  268. //
  269. // mmfile.c
  270. //
  271. DWORD
  272. SaveConfigurationToFile(
  273. IN PM_SERVER Server
  274. );
  275. DWORD
  276. ReadDbEntries(
  277. IN OUT LPBYTE *Mem,
  278. IN OUT ULONG *MemSize,
  279. IN OUT PM_SERVER *Server
  280. );
  281. //
  282. // merge.c
  283. //
  284. DWORD
  285. MergeConfigurations(
  286. IN OUT PM_SERVER DestServer,
  287. IN OUT PM_SERVER Server
  288. );
  289. //
  290. // main.c
  291. //
  292. DWORD
  293. Tr(
  294. IN LPSTR Format, ...
  295. );
  296. BOOL IsNT4();
  297. BOOL IsNT5();
  298. VOID
  299. IpAddressToStringW(
  300. IN DWORD IpAddress,
  301. IN LPWSTR String // must have enough space preallocated
  302. );
  303. DWORD
  304. CmdLineDoExport(
  305. IN LPWSTR *Args,
  306. IN ULONG nArgs
  307. );
  308. DWORD
  309. CmdLineDoImport(
  310. IN LPWSTR *Args,
  311. IN ULONG nArgs
  312. );
  313. DWORD
  314. ImportConfiguration(
  315. IN OUT PM_SERVER SvcConfig,
  316. IN ULONG *Subnets,
  317. IN ULONG nSubnets,
  318. IN LPBYTE Mem, // import file : shared mem
  319. IN ULONG MemSize // shared mem size
  320. );
  321. DWORD
  322. ExportConfiguration(
  323. IN OUT PM_SERVER SvcConfig,
  324. IN ULONG *Subnets,
  325. IN ULONG nSubnets,
  326. IN HANDLE hFile
  327. );
  328. DWORD
  329. CleanupServiceConfig(
  330. IN OUT PM_SERVER Server
  331. );
  332. DWORD
  333. InitializeAndGetServiceConfig(
  334. OUT PM_SERVER *pServer
  335. );
  336. //
  337. // select.c
  338. //
  339. DWORD
  340. SelectConfiguration(
  341. IN OUT PM_SERVER Server,
  342. IN ULONG *Subnets,
  343. IN ULONG nSubnets
  344. );
  345. #pragma hdrstop