jwadhcpcsdk.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. {******************************************************************************}
  2. { }
  3. { DHCP Client API interface unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: dhcpcsdk.h, released June 2000. The original Pascal }
  9. { code is: DhcpCSdk.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaDhcpCSdk;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "dhcpcsdk.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinType;
  51. //
  52. // DHCP Standard Options.
  53. //
  54. const
  55. OPTION_PAD = 0;
  56. {$EXTERNALSYM OPTION_PAD}
  57. OPTION_SUBNET_MASK = 1;
  58. {$EXTERNALSYM OPTION_SUBNET_MASK}
  59. OPTION_TIME_OFFSET = 2;
  60. {$EXTERNALSYM OPTION_TIME_OFFSET}
  61. OPTION_ROUTER_ADDRESS = 3;
  62. {$EXTERNALSYM OPTION_ROUTER_ADDRESS}
  63. OPTION_TIME_SERVERS = 4;
  64. {$EXTERNALSYM OPTION_TIME_SERVERS}
  65. OPTION_IEN116_NAME_SERVERS = 5;
  66. {$EXTERNALSYM OPTION_IEN116_NAME_SERVERS}
  67. OPTION_DOMAIN_NAME_SERVERS = 6;
  68. {$EXTERNALSYM OPTION_DOMAIN_NAME_SERVERS}
  69. OPTION_LOG_SERVERS = 7;
  70. {$EXTERNALSYM OPTION_LOG_SERVERS}
  71. OPTION_COOKIE_SERVERS = 8;
  72. {$EXTERNALSYM OPTION_COOKIE_SERVERS}
  73. OPTION_LPR_SERVERS = 9;
  74. {$EXTERNALSYM OPTION_LPR_SERVERS}
  75. OPTION_IMPRESS_SERVERS = 10;
  76. {$EXTERNALSYM OPTION_IMPRESS_SERVERS}
  77. OPTION_RLP_SERVERS = 11;
  78. {$EXTERNALSYM OPTION_RLP_SERVERS}
  79. OPTION_HOST_NAME = 12;
  80. {$EXTERNALSYM OPTION_HOST_NAME}
  81. OPTION_BOOT_FILE_SIZE = 13;
  82. {$EXTERNALSYM OPTION_BOOT_FILE_SIZE}
  83. OPTION_MERIT_DUMP_FILE = 14;
  84. {$EXTERNALSYM OPTION_MERIT_DUMP_FILE}
  85. OPTION_DOMAIN_NAME = 15;
  86. {$EXTERNALSYM OPTION_DOMAIN_NAME}
  87. OPTION_SWAP_SERVER = 16;
  88. {$EXTERNALSYM OPTION_SWAP_SERVER}
  89. OPTION_ROOT_DISK = 17;
  90. {$EXTERNALSYM OPTION_ROOT_DISK}
  91. OPTION_EXTENSIONS_PATH = 18;
  92. {$EXTERNALSYM OPTION_EXTENSIONS_PATH}
  93. //
  94. // IP layer parameters - per host
  95. //
  96. OPTION_BE_A_ROUTER = 19;
  97. {$EXTERNALSYM OPTION_BE_A_ROUTER}
  98. OPTION_NON_LOCAL_SOURCE_ROUTING = 20;
  99. {$EXTERNALSYM OPTION_NON_LOCAL_SOURCE_ROUTING}
  100. OPTION_POLICY_FILTER_FOR_NLSR = 21;
  101. {$EXTERNALSYM OPTION_POLICY_FILTER_FOR_NLSR}
  102. OPTION_MAX_REASSEMBLY_SIZE = 22;
  103. {$EXTERNALSYM OPTION_MAX_REASSEMBLY_SIZE}
  104. OPTION_DEFAULT_TTL = 23;
  105. {$EXTERNALSYM OPTION_DEFAULT_TTL}
  106. OPTION_PMTU_AGING_TIMEOUT = 24;
  107. {$EXTERNALSYM OPTION_PMTU_AGING_TIMEOUT}
  108. OPTION_PMTU_PLATEAU_TABLE = 25;
  109. {$EXTERNALSYM OPTION_PMTU_PLATEAU_TABLE}
  110. //
  111. // Link layer parameters - per interface.
  112. //
  113. OPTION_MTU = 26;
  114. {$EXTERNALSYM OPTION_MTU}
  115. OPTION_ALL_SUBNETS_MTU = 27;
  116. {$EXTERNALSYM OPTION_ALL_SUBNETS_MTU}
  117. OPTION_BROADCAST_ADDRESS = 28;
  118. {$EXTERNALSYM OPTION_BROADCAST_ADDRESS}
  119. OPTION_PERFORM_MASK_DISCOVERY = 29;
  120. {$EXTERNALSYM OPTION_PERFORM_MASK_DISCOVERY}
  121. OPTION_BE_A_MASK_SUPPLIER = 30;
  122. {$EXTERNALSYM OPTION_BE_A_MASK_SUPPLIER}
  123. OPTION_PERFORM_ROUTER_DISCOVERY = 31;
  124. {$EXTERNALSYM OPTION_PERFORM_ROUTER_DISCOVERY}
  125. OPTION_ROUTER_SOLICITATION_ADDR = 32;
  126. {$EXTERNALSYM OPTION_ROUTER_SOLICITATION_ADDR}
  127. OPTION_STATIC_ROUTES = 33;
  128. {$EXTERNALSYM OPTION_STATIC_ROUTES}
  129. OPTION_TRAILERS = 34;
  130. {$EXTERNALSYM OPTION_TRAILERS}
  131. OPTION_ARP_CACHE_TIMEOUT = 35;
  132. {$EXTERNALSYM OPTION_ARP_CACHE_TIMEOUT}
  133. OPTION_ETHERNET_ENCAPSULATION = 36;
  134. {$EXTERNALSYM OPTION_ETHERNET_ENCAPSULATION}
  135. //
  136. // TCP Paramters - per host
  137. //
  138. OPTION_TTL = 37;
  139. {$EXTERNALSYM OPTION_TTL}
  140. OPTION_KEEP_ALIVE_INTERVAL = 38;
  141. {$EXTERNALSYM OPTION_KEEP_ALIVE_INTERVAL}
  142. OPTION_KEEP_ALIVE_DATA_SIZE = 39;
  143. {$EXTERNALSYM OPTION_KEEP_ALIVE_DATA_SIZE}
  144. //
  145. // Application Layer Parameters
  146. //
  147. OPTION_NETWORK_INFO_SERVICE_DOM = 40;
  148. {$EXTERNALSYM OPTION_NETWORK_INFO_SERVICE_DOM}
  149. OPTION_NETWORK_INFO_SERVERS = 41;
  150. {$EXTERNALSYM OPTION_NETWORK_INFO_SERVERS}
  151. OPTION_NETWORK_TIME_SERVERS = 42;
  152. {$EXTERNALSYM OPTION_NETWORK_TIME_SERVERS}
  153. //
  154. // Vender specific information option
  155. //
  156. OPTION_VENDOR_SPEC_INFO = 43;
  157. {$EXTERNALSYM OPTION_VENDOR_SPEC_INFO}
  158. //
  159. // NetBIOS over TCP/IP Name server option
  160. //
  161. OPTION_NETBIOS_NAME_SERVER = 44;
  162. {$EXTERNALSYM OPTION_NETBIOS_NAME_SERVER}
  163. OPTION_NETBIOS_DATAGRAM_SERVER = 45;
  164. {$EXTERNALSYM OPTION_NETBIOS_DATAGRAM_SERVER}
  165. OPTION_NETBIOS_NODE_TYPE = 46;
  166. {$EXTERNALSYM OPTION_NETBIOS_NODE_TYPE}
  167. OPTION_NETBIOS_SCOPE_OPTION = 47;
  168. {$EXTERNALSYM OPTION_NETBIOS_SCOPE_OPTION}
  169. //
  170. // X Window System Options.
  171. //
  172. OPTION_XWINDOW_FONT_SERVER = 48;
  173. {$EXTERNALSYM OPTION_XWINDOW_FONT_SERVER}
  174. OPTION_XWINDOW_DISPLAY_MANAGER = 49;
  175. {$EXTERNALSYM OPTION_XWINDOW_DISPLAY_MANAGER}
  176. //
  177. // Other extensions
  178. //
  179. OPTION_REQUESTED_ADDRESS = 50;
  180. {$EXTERNALSYM OPTION_REQUESTED_ADDRESS}
  181. OPTION_LEASE_TIME = 51;
  182. {$EXTERNALSYM OPTION_LEASE_TIME}
  183. OPTION_OK_TO_OVERLAY = 52;
  184. {$EXTERNALSYM OPTION_OK_TO_OVERLAY}
  185. OPTION_MESSAGE_TYPE = 53;
  186. {$EXTERNALSYM OPTION_MESSAGE_TYPE}
  187. OPTION_SERVER_IDENTIFIER = 54;
  188. {$EXTERNALSYM OPTION_SERVER_IDENTIFIER}
  189. OPTION_PARAMETER_REQUEST_LIST = 55;
  190. {$EXTERNALSYM OPTION_PARAMETER_REQUEST_LIST}
  191. OPTION_MESSAGE = 56;
  192. {$EXTERNALSYM OPTION_MESSAGE}
  193. OPTION_MESSAGE_LENGTH = 57;
  194. {$EXTERNALSYM OPTION_MESSAGE_LENGTH}
  195. OPTION_RENEWAL_TIME = 58; // T1
  196. {$EXTERNALSYM OPTION_RENEWAL_TIME}
  197. OPTION_REBIND_TIME = 59; // T2
  198. {$EXTERNALSYM OPTION_REBIND_TIME}
  199. OPTION_CLIENT_CLASS_INFO = 60;
  200. {$EXTERNALSYM OPTION_CLIENT_CLASS_INFO}
  201. OPTION_CLIENT_ID = 61;
  202. {$EXTERNALSYM OPTION_CLIENT_ID}
  203. OPTION_TFTP_SERVER_NAME = 66;
  204. {$EXTERNALSYM OPTION_TFTP_SERVER_NAME}
  205. OPTION_BOOTFILE_NAME = 67;
  206. {$EXTERNALSYM OPTION_BOOTFILE_NAME}
  207. OPTION_END = 255;
  208. {$EXTERNALSYM OPTION_END}
  209. type
  210. _DHCPAPI_PARAMS = record
  211. Flags: ULONG; // for future use
  212. OptionId: ULONG; // what option is this?
  213. IsVendor: BOOL; // is this vendor specific?
  214. Data: LPBYTE; // the actual data
  215. nBytesData: DWORD; // how many bytes of data are there in Data?
  216. end;
  217. {$EXTERNALSYM _DHCPAPI_PARAMS}
  218. DHCPAPI_PARAMS = _DHCPAPI_PARAMS;
  219. {$EXTERNALSYM DHCPAPI_PARAMS}
  220. LPDHCPAPI_PARAMS = ^DHCPAPI_PARAMS;
  221. {$EXTERNALSYM LPDHCPAPI_PARAMS}
  222. PDHCPAPI_PARAMS = ^DHCPAPI_PARAMS;
  223. {$EXTERNALSYM PDHCPAPI_PARAMS}
  224. TDhcpApiParams = DHCPAPI_PARAMS;
  225. PDhcpApiParams = PDHCPAPI_PARAMS;
  226. DHCPCAPI_PARAMS = DHCPAPI_PARAMS;
  227. {$EXTERNALSYM DHCPCAPI_PARAMS}
  228. PDHCPCAPI_PARAMS = ^DHCPCAPI_PARAMS;
  229. {$EXTERNALSYM PDHCPCAPI_PARAMS}
  230. LPDHCPCAPI_PARAMS = ^DHCPCAPI_PARAMS;
  231. {$EXTERNALSYM LPDHCPCAPI_PARAMS}
  232. TDhcpCApiParams = DHCPCAPI_PARAMS;
  233. PDhcpCApiParams = PDHCPCAPI_PARAMS;
  234. _DHCPCAPI_PARAMS_ARRAY = record
  235. nParams: ULONG; // size of array
  236. Params: PDHCPCAPI_PARAMS; // actual array
  237. end;
  238. {$EXTERNALSYM _DHCPCAPI_PARAMS_ARRAY}
  239. DHCPCAPI_PARAMS_ARRAY = _DHCPCAPI_PARAMS_ARRAY;
  240. {$EXTERNALSYM DHCPCAPI_PARAMS_ARRAY}
  241. LPDHCPCAPI_PARAMS_ARRAY = ^DHCPCAPI_PARAMS_ARRAY;
  242. {$EXTERNALSYM LPDHCPCAPI_PARAMS_ARRAY}
  243. PDHCPCAPI_PARAMS_ARRAY = ^DHCPCAPI_PARAMS_ARRAY;
  244. {$EXTERNALSYM PDHCPCAPI_PARAMS_ARRAY}
  245. TDhcpcApiParamsArray = DHCPCAPI_PARAMS_ARRAY;
  246. PDhcpcApiParamsArray = PDHCPCAPI_PARAMS_ARRAY;
  247. _DHCPCAPI_CLASSID = record
  248. Flags: ULONG; // must be zero currently.
  249. Data: LPBYTE; // classid binary data.
  250. nBytesData: ULONG; // how many bytes of data are there?
  251. end;
  252. {$EXTERNALSYM _DHCPCAPI_CLASSID}
  253. DHCPCAPI_CLASSID = _DHCPCAPI_CLASSID;
  254. {$EXTERNALSYM DHCPCAPI_CLASSID}
  255. LPDHCPCAPI_CLASSID = ^DHCPCAPI_CLASSID;
  256. {$EXTERNALSYM LPDHCPCAPI_CLASSID}
  257. PDHCPCAPI_CLASSID = ^DHCPCAPI_CLASSID;
  258. {$EXTERNALSYM PDHCPCAPI_CLASSID}
  259. TDhcpcApiClassId = DHCPCAPI_CLASSID;
  260. PDhcpcApiClassId = PDHCPCAPI_CLASSID;
  261. const
  262. DHCPCAPI_REQUEST_PERSISTENT = $01; // request this options "permanently"
  263. {$EXTERNALSYM DHCPCAPI_REQUEST_PERSISTENT}
  264. DHCPCAPI_REQUEST_SYNCHRONOUS = $02; // request and block on it
  265. {$EXTERNALSYM DHCPCAPI_REQUEST_SYNCHRONOUS}
  266. DHCPCAPI_REQUEST_ASYNCHRONOUS = $04; // request and return, set event on completion
  267. {$EXTERNALSYM DHCPCAPI_REQUEST_ASYNCHRONOUS}
  268. DHCPCAPI_REQUEST_CANCEL = $08; // cancel request
  269. {$EXTERNALSYM DHCPCAPI_REQUEST_CANCEL}
  270. DHCPCAPI_REQUEST_MASK = $0F; // allowed flags..
  271. {$EXTERNALSYM DHCPCAPI_REQUEST_MASK}
  272. function DhcpCApiInitialize(var Version: DWORD): DWORD; stdcall;
  273. {$EXTERNALSYM DhcpCApiInitialize}
  274. procedure DhcpCApiCleanup; stdcall;
  275. {$EXTERNALSYM DhcpCApiCleanup}
  276. function DhcpRequestParams(Flags: DWORD; Reserved: LPVOID; AdapterName: LPWSTR;
  277. ClassId: PDHCPCAPI_CLASSID; SendParams, RecdParams: DHCPCAPI_PARAMS_ARRAY;
  278. Buffer: LPBYTE; pSize: LPDWORD; RequestIdStr: LPWSTR): DWORD; stdcall;
  279. {$EXTERNALSYM DhcpRequestParams}
  280. function DhcpUndoRequestParams(Flags: DWORD; Reserved: LPVOID; AdapterName: LPWSTR;
  281. RequestIdStr: LPWSTR): DWORD; stdcall;
  282. {$EXTERNALSYM DhcpUndoRequestParams}
  283. const
  284. DHCPCAPI_REGISTER_HANDLE_EVENT = $01; // handle returned is to an event
  285. {$EXTERNALSYM DHCPCAPI_REGISTER_HANDLE_EVENT}
  286. function DhcpRegisterParamChange(Flags: DWORD; Reserved: LPVOID; AdapterName: LPWSTR;
  287. ClassId: PDHCPCAPI_CLASSID; Params: DHCPCAPI_PARAMS_ARRAY; Handle: LPVOID): DWORD; stdcall;
  288. {$EXTERNALSYM DhcpRegisterParamChange}
  289. const
  290. DHCPCAPI_DEREGISTER_HANDLE_EVENT = $01; // de-register handle that is an event
  291. {$EXTERNALSYM DHCPCAPI_DEREGISTER_HANDLE_EVENT}
  292. function DhcpDeRegisterParamChange(Flags: DWORD; Reserved, Event: LPVOID): DWORD; stdcall;
  293. {$EXTERNALSYM DhcpDeRegisterParamChange}
  294. function DhcpRemoveDNSRegistrations: DWORD; stdcall;
  295. {$EXTERNALSYM DhcpRemoveDNSRegistrations}
  296. implementation
  297. const
  298. dhcpapi = 'dhcpcsvc.dll';
  299. {$IFDEF DYNAMIC_LINK}
  300. var
  301. _DhcpCApiInitialize: Pointer;
  302. function DhcpCApiInitialize;
  303. begin
  304. GetProcedureAddress(_DhcpCApiInitialize, dhcpapi, 'DhcpCApiInitialize');
  305. asm
  306. MOV ESP, EBP
  307. POP EBP
  308. JMP [_DhcpCApiInitialize]
  309. end;
  310. end;
  311. var
  312. _DhcpCApiCleanup: Pointer;
  313. procedure DhcpCApiCleanup;
  314. begin
  315. GetProcedureAddress(_DhcpCApiCleanup, dhcpapi, 'DhcpCApiCleanup');
  316. asm
  317. MOV ESP, EBP
  318. POP EBP
  319. JMP [_DhcpCApiCleanup]
  320. end;
  321. end;
  322. var
  323. _DhcpRequestParams: Pointer;
  324. function DhcpRequestParams;
  325. begin
  326. GetProcedureAddress(_DhcpRequestParams, dhcpapi, 'DhcpRequestParams');
  327. asm
  328. MOV ESP, EBP
  329. POP EBP
  330. JMP [_DhcpRequestParams]
  331. end;
  332. end;
  333. var
  334. _DhcpUndoRequestParams: Pointer;
  335. function DhcpUndoRequestParams;
  336. begin
  337. GetProcedureAddress(_DhcpUndoRequestParams, dhcpapi, 'DhcpUndoRequestParams');
  338. asm
  339. MOV ESP, EBP
  340. POP EBP
  341. JMP [_DhcpUndoRequestParams]
  342. end;
  343. end;
  344. var
  345. _DhcpRegisterParamChange: Pointer;
  346. function DhcpRegisterParamChange;
  347. begin
  348. GetProcedureAddress(_DhcpRegisterParamChange, dhcpapi, 'DhcpRegisterParamChange');
  349. asm
  350. MOV ESP, EBP
  351. POP EBP
  352. JMP [_DhcpRegisterParamChange]
  353. end;
  354. end;
  355. var
  356. _DhcpDeRegisterParamChange: Pointer;
  357. function DhcpDeRegisterParamChange;
  358. begin
  359. GetProcedureAddress(_DhcpDeRegisterParamChange, dhcpapi, 'DhcpDeRegisterParamChange');
  360. asm
  361. MOV ESP, EBP
  362. POP EBP
  363. JMP [_DhcpDeRegisterParamChange]
  364. end;
  365. end;
  366. var
  367. _DhcpRemoveDNSRegistrations: Pointer;
  368. function DhcpRemoveDNSRegistrations;
  369. begin
  370. GetProcedureAddress(_DhcpRemoveDNSRegistrations, dhcpapi, 'DhcpRemoveDNSRegistrations');
  371. asm
  372. MOV ESP, EBP
  373. POP EBP
  374. JMP [_DhcpRemoveDNSRegistrations]
  375. end;
  376. end;
  377. {$ELSE}
  378. function DhcpCApiInitialize; external dhcpapi name 'DhcpCApiInitialize';
  379. procedure DhcpCApiCleanup; external dhcpapi name 'DhcpCApiCleanup';
  380. function DhcpRequestParams; external dhcpapi name 'DhcpRequestParams';
  381. function DhcpUndoRequestParams; external dhcpapi name 'DhcpUndoRequestParams';
  382. function DhcpRegisterParamChange; external dhcpapi name 'DhcpRegisterParamChange';
  383. function DhcpDeRegisterParamChange; external dhcpapi name 'DhcpDeRegisterParamChange';
  384. function DhcpRemoveDNSRegistrations; external dhcpapi name 'DhcpRemoveDNSRegistrations';
  385. {$ENDIF DYNAMIC_LINK}
  386. end.