jwadhcpcsdk.pas 15 KB

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