Source code of Windows XP (NT5)
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.

298 lines
9.5 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. dhcpcapi.h
  5. Abstract:
  6. This file contains function proto types for the DHCP CONFIG API
  7. functions.
  8. Author:
  9. Madan Appiah (madana) Dec-22-1993
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. --*/
  14. #ifndef _DHCPCAPI_
  15. #define _DHCPCAPI_
  16. #include <time.h>
  17. HANDLE
  18. APIENTRY
  19. DhcpOpenGlobalEvent(
  20. VOID
  21. );
  22. typedef enum _SERVICE_ENABLE {
  23. IgnoreFlag,
  24. DhcpEnable,
  25. DhcpDisable
  26. } SERVICE_ENABLE, *LPSERVICE_ENABLE;
  27. DWORD
  28. APIENTRY
  29. DhcpAcquireParameters(
  30. LPWSTR AdapterName
  31. );
  32. DWORD
  33. APIENTRY
  34. DhcpFallbackRefreshParams(
  35. LPWSTR AdapterName
  36. );
  37. DWORD
  38. APIENTRY
  39. DhcpReleaseParameters(
  40. LPWSTR AdapterName
  41. );
  42. DWORD
  43. APIENTRY
  44. DhcpEnableDynamicConfig(
  45. LPWSTR AdapterName
  46. );
  47. DWORD
  48. APIENTRY
  49. DhcpDisableDynamicConfig(
  50. LPWSTR AdapterName
  51. );
  52. DWORD
  53. APIENTRY
  54. DhcpNotifyConfigChange(
  55. LPWSTR ServerName,
  56. LPWSTR AdapterName,
  57. BOOL IsNewIpAddress,
  58. DWORD IpIndex,
  59. DWORD IpAddress,
  60. DWORD SubnetMask,
  61. SERVICE_ENABLE DhcpServiceEnabled
  62. );
  63. #define NOTIFY_FLG_DO_DNS 0x01
  64. #define NOTIFY_FLG_RESET_IPADDR 0x02
  65. DWORD
  66. APIENTRY
  67. DhcpNotifyConfigChangeEx(
  68. IN LPWSTR ServerName,
  69. IN LPWSTR AdapterName,
  70. IN BOOL IsNewIpAddress,
  71. IN DWORD IpIndex,
  72. IN DWORD IpAddress,
  73. IN DWORD SubnetMask,
  74. IN SERVICE_ENABLE DhcpServiceEnabled,
  75. IN ULONG Flags
  76. );
  77. DWORD
  78. DhcpQueryHWInfo(
  79. DWORD IpInterfaceContext,
  80. DWORD *pIpInterfaceInstance,
  81. LPBYTE HardwareAddressType,
  82. LPBYTE *HardwareAddress,
  83. LPDWORD HardwareAddressLength
  84. );
  85. //
  86. // IP address lease apis for RAS .
  87. //
  88. typedef struct _DHCP_CLIENT_UID {
  89. LPBYTE ClientUID;
  90. DWORD ClientUIDLength;
  91. } DHCP_CLIENT_UID, *LPDHCP_CLIENT_UID;
  92. typedef struct _DHCP_LEASE_INFO {
  93. DHCP_CLIENT_UID ClientUID;
  94. DWORD IpAddress;
  95. DWORD SubnetMask;
  96. DWORD DhcpServerAddress;
  97. DWORD Lease;
  98. time_t LeaseObtained;
  99. time_t T1Time;
  100. time_t T2Time;
  101. time_t LeaseExpires;
  102. } DHCP_LEASE_INFO, *LPDHCP_LEASE_INFO;
  103. typedef struct _DHCP_OPTION_DATA {
  104. DWORD OptionID;
  105. DWORD OptionLen;
  106. LPBYTE Option;
  107. } DHCP_OPTION_DATA, *LPDHCP_OPTION_DATA;
  108. typedef struct _DHCP_OPTION_INFO {
  109. DWORD NumOptions;
  110. LPDHCP_OPTION_DATA OptionDataArray;
  111. } DHCP_OPTION_INFO, *LPDHCP_OPTION_INFO;
  112. typedef struct _DHCP_OPTION_LIST {
  113. DWORD NumOptions;
  114. LPWORD OptionIDArray;
  115. } DHCP_OPTION_LIST, *LPDHCP_OPTION_LIST;
  116. DWORD
  117. DhcpLeaseIpAddress(
  118. DWORD AdapterIpAddress,
  119. LPDHCP_CLIENT_UID ClientUID,
  120. DWORD DesiredIpAddress,
  121. LPDHCP_OPTION_LIST OptionList,
  122. LPDHCP_LEASE_INFO *LeaseInfo,
  123. LPDHCP_OPTION_INFO *OptionInfo
  124. );
  125. DWORD
  126. DhcpRenewIpAddressLease(
  127. DWORD AdapterIpAddress,
  128. LPDHCP_LEASE_INFO ClientLeaseInfo,
  129. LPDHCP_OPTION_LIST OptionList,
  130. LPDHCP_OPTION_INFO *OptionInfo
  131. );
  132. DWORD
  133. DhcpReleaseIpAddressLease(
  134. DWORD AdapterIpAddress,
  135. LPDHCP_LEASE_INFO ClientLeaseInfo
  136. );
  137. //DOC
  138. //DOC The following are the APIs needed for dhcp-class id UI.
  139. //DOC
  140. enum /* anonymous */ {
  141. DHCP_CLASS_INFO_VERSION_0 // first cut structure version
  142. };
  143. typedef struct _DHCP_CLASS_INFO {
  144. DWORD Version; // MUST BE DHCP_CLASS_INFO_VERSION_0
  145. LPWSTR ClassName; // Name of the Class.
  146. LPWSTR ClassDescr; // Description about the class
  147. LPBYTE ClassData; // byte stream on the wire data.
  148. DWORD ClassDataLen; // # of bytes in the ClassData (must be > 0)
  149. } DHCP_CLASS_INFO, *PDHCP_CLASS_INFO, *LPDHCP_CLASS_INFO;
  150. typedef
  151. DWORD
  152. (WINAPI *LPDHCPENUMCLASSES)(
  153. IN DWORD Flags,
  154. IN LPWSTR AdapterName,
  155. IN OUT DWORD *Size,
  156. IN OUT DHCP_CLASS_INFO *ClassesArray
  157. );
  158. //DOC DhcpEnumClasses enumerates the list of classes available on the system for configuration.
  159. //DOC This is predominantly going to be used by the NetUI. (in which case the ClassData part of the
  160. //DOC DHCP_CLASS_INFO structure is essentially useless).
  161. //DOC Note that Flags is used for future use.
  162. //DOC The AdapterName can currently be only GUIDs but may soon be EXTENDED to be IpAddress strings or
  163. //DOC h-w addresses or any other user friendly means of denoting the Adapter. Note that if the Adapter
  164. //DOC Name is NULL (not the empty string L""), then it refers to either ALL adapters.
  165. //DOC The Size parameter is an input/output parameter. The input value is the # of bytes of allocated
  166. //DOC space in the ClassesArray buffer. On return, the meaning of this value depends on the return value.
  167. //DOC If the function returns ERROR_SUCCESS, then, this parameter would return the # of elements in the
  168. //DOC array ClassesArray. If the function returns ERROR_MORE_DATA, then, this parameter refers to the
  169. //DOC # of bytes space that is actually REQUIRED to hold the information.
  170. //DOC In all other cases, the values in Size and ClassesArray dont mean anything.
  171. //DOC
  172. //DOC Return Values:
  173. //DOC ERROR_DEVICE_DOES_NOT_EXIST The AdapterName is illegal in the given context
  174. //DOC ERROR_INVALID_PARAMETER
  175. //DOC ERROR_MORE_DATA
  176. //DOC ERROR_FILE_NOT_FOUND The DHCP Client is not running and could not be started up.
  177. //DOC ERROR_NOT_ENOUGH_MEMORY This is NOT the same as ERROR_MORE_DATA
  178. //DOC Win32 errors
  179. //DOC
  180. //DOC Remarks:
  181. //DOC To notify DHCP that some class has changed, please use the DhcpHandlePnPEvent API.
  182. DWORD
  183. WINAPI
  184. DhcpEnumClasses( // enumerate the list of classes available
  185. IN DWORD Flags, // currently must be zero
  186. IN LPWSTR AdapterName, // currently must be AdapterGUID (cannot be NULL yet)
  187. IN OUT DWORD *Size, // input # of bytes available in BUFFER, output # of elements in array
  188. IN OUT DHCP_CLASS_INFO *ClassesArray // pre-allocated buffer
  189. );
  190. enum /* anonymous */ { // who are the recognized callers of this API
  191. DHCP_CALLER_OTHER = 0, // un-specified user, not one of below
  192. DHCP_CALLER_TCPUI, // the TcpIp UI
  193. DHCP_CALLER_RAS, // the RAS Api
  194. DHCP_CALLER_API, // some one else via DHCP API
  195. };
  196. enum /* anonymous */ { // supported structure versions..
  197. DHCP_PNP_CHANGE_VERSION_0 = 0 // first cut version structure
  198. };
  199. typedef struct _DHCP_PNP_CHANGE {
  200. DWORD Version; // MUST BE DHCP_PNP_CHANGE_VERSION_0
  201. BOOL DnsListChanged;// DNS Server list changed
  202. BOOL DomainChanged; // Domain Name changed
  203. BOOL HostNameChanged; // the DNS Host name changed..
  204. BOOL ClassIdChanged;// ClassId changed
  205. BOOL MaskChanged; // SubnetMask changed; CURRENTLY NOT USED
  206. BOOL GateWayChanged;// DefaultGateWay changed; CURRENTLY NOT USED
  207. BOOL RouteChanged; // some STATIC route changed; CURRENTLY NOT USED
  208. BOOL OptsChanged; // some options changed. CURRENTLY NOT USED
  209. BOOL OptDefsChanged;// some option definitions changed. CURRENTLY NOT USED
  210. BOOL DnsOptionsChanged; // some DNS specific options have changed.
  211. } DHCP_PNP_CHANGE, *PDHCP_PNP_CHANGE, *LPDHCP_PNP_CHANGE;
  212. typedef // this typedef SHOULD match the following declaration.
  213. DWORD
  214. (WINAPI FAR *LPDHCPHANDLEPNPEVENT)(
  215. IN DWORD Flags,
  216. IN DWORD Caller,
  217. IN LPWSTR AdapterName,
  218. IN LPDHCP_PNP_CHANGE Changes,
  219. IN LPVOID Reserved
  220. );
  221. //DOC DhcpHandlePnpEvent can be called as an API by any process (excepting that executing within the
  222. //DOC DHCP process itself) when any of the registry based configuration has changed and DHCP client has to
  223. //DOC re-read the registry. The Flags parameter is for future expansion.
  224. //DOC The AdapterName can currently be only GUIDs but may soon be EXTENDED to be IpAddress strings or
  225. //DOC h-w addresses or any other user friendly means of denoting the Adapter. Note that if the Adapter
  226. //DOC Name is NULL (not the empty string L""), then it refers to either GLOBAL parameters or ALL adapters
  227. //DOC depending on which BOOL has been set. (this may not get done for BETA2).
  228. //DOC The Changes structure gives the information on what changed.
  229. //DOC Currently, only a few of the defined BOOLs would be supported (for BETA2 NT5).
  230. //DOC
  231. //DOC Return Values:
  232. //DOC ERROR_DEVICE_DOES_NOT_EXIST The AdapterName is illegal in the given context
  233. //DOC ERROR_INVALID_PARAMETER
  234. //DOC ERROR_CALL_NOT_SUPPORTED The particular parameter that has changed is not completely pnp yet.
  235. //DOC Win32 errors
  236. DWORD
  237. WINAPI
  238. DhcpHandlePnPEvent(
  239. IN DWORD Flags, // MUST BE ZERO
  240. IN DWORD Caller, // currently must be DHCP_CALLER_TCPUI
  241. IN LPWSTR AdapterName, // currently must be the adapter GUID or NULL if global
  242. IN LPDHCP_PNP_CHANGE Changes, // specify what changed
  243. IN LPVOID Reserved // reserved for future use..
  244. );
  245. //================================================================================
  246. // end of file
  247. //================================================================================
  248. #endif