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.

382 lines
10 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. dhcpsapi.h
  5. -*/
  6. #ifndef _DHCPSAPI_
  7. #define _DHCPSAPI_
  8. #if defined(MIDL_PASS)
  9. #define LPWSTR [string] wchar_t *
  10. #endif
  11. #if (_MSC_VER >= 800)
  12. #define DHCP_API_FUNCTION __stdcall
  13. #else
  14. #define DHCP_API_FUNCTION
  15. #endif
  16. #ifdef __cplusplus
  17. #define DHCP_CONST const
  18. extern "C" {
  19. #else
  20. #define DHCP_CONST
  21. #endif // __cplusplus
  22. typedef DWORD DHCP_IP_ADDRESS, *PDHCP_IP_ADDRESS, *LPDHCP_IP_ADDRESS;
  23. typedef DWORD DHCP_IP_MASK;
  24. typedef DWORD DHCP_RESUME_HANDLE;
  25. typedef DWORD DHCP_OPTION_ID;
  26. typedef struct _DATE_TIME {
  27. DWORD dwLowDateTime;
  28. DWORD dwHighDateTime;
  29. } DATE_TIME, *LPDATE_TIME;
  30. typedef struct _DWORD_DWORD {
  31. DWORD DWord1;
  32. DWORD DWord2;
  33. } DWORD_DWORD, *LPDWORD_DWORD;
  34. typedef struct _DHCP_BINARY_DATA {
  35. DWORD DataLength;
  36. #if defined(MIDL_PASS)
  37. [size_is(DataLength)]
  38. #endif // MIDL_PASS
  39. BYTE *Data;
  40. } DHCP_BINARY_DATA, *LPDHCP_BINARY_DATA;
  41. typedef DHCP_BINARY_DATA DHCP_CLIENT_UID;
  42. #define DHCP_ENDPOINT_FLAG_CANT_MODIFY 0x01
  43. typedef struct _DHCP_BIND_ELEMENT {
  44. ULONG Flags;
  45. BOOL fBoundToDHCPServer;
  46. DHCP_IP_ADDRESS AdapterPrimaryAddress;
  47. DHCP_IP_ADDRESS AdapterSubnetAddress;
  48. LPWSTR IfDescription;
  49. ULONG IfIdSize;
  50. #if defined (MIDL_PASS)
  51. [size_is(IfIdSize)]
  52. #endif // MIDL_PASS
  53. LPBYTE IfId;
  54. } DHCP_BIND_ELEMENT, *LPDHCP_BIND_ELEMENT;
  55. typedef struct _DHCP_BIND_ELEMENT_ARRAY {
  56. DWORD NumElements;
  57. #if defined (MIDL_PASS)
  58. [size_is(NumElements)]
  59. #endif // MIDL_PASS
  60. LPDHCP_BIND_ELEMENT Elements; //array
  61. } DHCP_BIND_ELEMENT_ARRAY, *LPDHCP_BIND_ELEMENT_ARRAY;
  62. typedef enum _DHCP_CLIENT_SEARCH_TYPE {
  63. DhcpClientIpAddress,
  64. DhcpClientHardwareAddress,
  65. DhcpClientName
  66. } DHCP_SEARCH_INFO_TYPE, *LPDHCP_SEARCH_INFO_TYPE;
  67. typedef struct _DHCP_CLIENT_SEARCH_INFO {
  68. DHCP_SEARCH_INFO_TYPE SearchType;
  69. #if defined(MIDL_PASS)
  70. [switch_is(SearchType), switch_type(DHCP_SEARCH_INFO_TYPE)]
  71. union _DHCP_CLIENT_SEARCH_UNION {
  72. [case(DhcpClientIpAddress)] DHCP_IP_ADDRESS ClientIpAddress;
  73. [case(DhcpClientHardwareAddress)] DHCP_CLIENT_UID ClientHardwareAddress;
  74. [case(DhcpClientName)] LPWSTR ClientName;
  75. [default] ;
  76. } SearchInfo;
  77. #else
  78. union _DHCP_CLIENT_SEARCH_UNION {
  79. DHCP_IP_ADDRESS ClientIpAddress;
  80. DHCP_CLIENT_UID ClientHardwareAddress;
  81. LPWSTR ClientName;
  82. } SearchInfo;
  83. #endif // MIDL_PASS
  84. } DHCP_SEARCH_INFO, *LPDHCP_SEARCH_INFO;
  85. typedef enum _DHCP_OPTION_SCOPE_TYPE {
  86. DhcpDefaultOptions,
  87. DhcpGlobalOptions,
  88. DhcpSubnetOptions,
  89. DhcpReservedOptions,
  90. DhcpMScopeOptions
  91. } DHCP_OPTION_SCOPE_TYPE, *LPDHCP_OPTION_SCOPE_TYPE;
  92. typedef struct _DHCP_RESERVED_SCOPE {
  93. DHCP_IP_ADDRESS ReservedIpAddress;
  94. DHCP_IP_ADDRESS ReservedIpSubnetAddress;
  95. } DHCP_RESERVED_SCOPE, *LPDHCP_RESERVED_SCOPE;
  96. typedef struct _DHCP_OPTION_SCOPE_INFO {
  97. DHCP_OPTION_SCOPE_TYPE ScopeType;
  98. #if defined(MIDL_PASS)
  99. [switch_is(ScopeType), switch_type(DHCP_OPTION_SCOPE_TYPE)]
  100. union _DHCP_OPTION_SCOPE_UNION {
  101. [case(DhcpDefaultOptions)] ; // PVOID DefaultScopeInfo;
  102. [case(DhcpGlobalOptions)] ; // PVOID GlobalScopeInfo;
  103. [case(DhcpSubnetOptions)] DHCP_IP_ADDRESS SubnetScopeInfo;
  104. [case(DhcpReservedOptions)] DHCP_RESERVED_SCOPE ReservedScopeInfo;
  105. [case(DhcpMScopeOptions)] LPWSTR MScopeInfo;
  106. [default] ;
  107. } ScopeInfo;
  108. #else
  109. union _DHCP_OPTION_SCOPE_UNION {
  110. PVOID DefaultScopeInfo; // must be NULL
  111. PVOID GlobalScopeInfo; // must be NULL
  112. DHCP_IP_ADDRESS SubnetScopeInfo;
  113. DHCP_RESERVED_SCOPE ReservedScopeInfo;
  114. LPWSTR MScopeInfo;
  115. } ScopeInfo;
  116. #endif // MIDL_PASS
  117. } DHCP_OPTION_SCOPE_INFO, *LPDHCP_OPTION_SCOPE_INFO;
  118. typedef struct _DHCP_HOST_INFO {
  119. DHCP_IP_ADDRESS IpAddress; // minimum information always available
  120. LPWSTR NetBiosName; // optional information
  121. LPWSTR HostName; // optional information
  122. } DHCP_HOST_INFO, *LPDHCP_HOST_INFO;
  123. typedef struct _DHCP_CLIENT_INFO {
  124. DHCP_IP_ADDRESS ClientIpAddress; // currently assigned IP address.
  125. DHCP_IP_MASK SubnetMask;
  126. DHCP_CLIENT_UID ClientHardwareAddress;
  127. LPWSTR ClientName; // optional.
  128. LPWSTR ClientComment;
  129. DATE_TIME ClientLeaseExpires; // UTC time in FILE_TIME format.
  130. DHCP_HOST_INFO OwnerHost; // host that distributed this IP address.
  131. } DHCP_CLIENT_INFO, *LPDHCP_CLIENT_INFO;
  132. typedef struct _DHCP_CLIENT_INFO_ARRAY {
  133. DWORD NumElements;
  134. #if defined(MIDL_PASS)
  135. [size_is(NumElements)]
  136. #endif // MIDL_PASS
  137. LPDHCP_CLIENT_INFO *Clients; // array of pointers
  138. } DHCP_CLIENT_INFO_ARRAY, *LPDHCP_CLIENT_INFO_ARRAY;
  139. typedef struct _DHCP_IP_ARRAY {
  140. DWORD NumElements;
  141. #if defined(MIDL_PASS)
  142. [size_is(NumElements)]
  143. #endif // MIDL_PASS
  144. LPDHCP_IP_ADDRESS Elements; //array
  145. } DHCP_IP_ARRAY, *LPDHCP_IP_ARRAY;
  146. //
  147. // Subnet State.
  148. //
  149. // Currently a Subnet scope can be Enabled or Disabled.
  150. //
  151. // If the state is Enabled State,
  152. // The server distributes address to the client, extends leases and
  153. // accepts releases.
  154. //
  155. // If the state is Disabled State,
  156. // The server does not distribute address to any new client, and does
  157. // extent (and sends NACK) old leases, but the servers accepts lease
  158. // releases.
  159. //
  160. // The idea behind this subnet state is, when the admin wants to stop
  161. // serving a subnet, he moves the state from Enbaled to Disabled so
  162. // that the clients from the subnets smoothly move to another servers
  163. // serving that subnet. When all or most of the clients move to
  164. // another server, the admin can delete the subnet without any force
  165. // if no client left in that subnet, otherwise the admin should use
  166. // full force to delete the subnet.
  167. //
  168. typedef enum _DHCP_SUBNET_STATE {
  169. DhcpSubnetEnabled = 0,
  170. DhcpSubnetDisabled,
  171. DhcpSubnetEnabledSwitched,
  172. DhcpSubnetDisabledSwitched,
  173. DhcpSubnetInvalidState
  174. } DHCP_SUBNET_STATE, *LPDHCP_SUBNET_STATE;
  175. //
  176. // Subnet related data structures.
  177. //
  178. typedef struct _DHCP_SUBNET_INFO {
  179. DHCP_IP_ADDRESS SubnetAddress;
  180. DHCP_IP_MASK SubnetMask;
  181. LPWSTR SubnetName;
  182. LPWSTR SubnetComment;
  183. DHCP_HOST_INFO PrimaryHost;
  184. DHCP_SUBNET_STATE SubnetState;
  185. } DHCP_SUBNET_INFO, *LPDHCP_SUBNET_INFO;
  186. //
  187. // DHCP Options related data structures.
  188. //
  189. typedef enum _DHCP_OPTION_DATA_TYPE {
  190. DhcpByteOption,
  191. DhcpWordOption,
  192. DhcpDWordOption,
  193. DhcpDWordDWordOption,
  194. DhcpIpAddressOption,
  195. DhcpStringDataOption,
  196. DhcpBinaryDataOption,
  197. DhcpEncapsulatedDataOption
  198. } DHCP_OPTION_DATA_TYPE, *LPDHCP_OPTION_DATA_TYPE;
  199. typedef struct _DHCP_OPTION_DATA_ELEMENT {
  200. DHCP_OPTION_DATA_TYPE OptionType;
  201. #if defined(MIDL_PASS)
  202. [switch_is(OptionType), switch_type(DHCP_OPTION_DATA_TYPE)]
  203. union _DHCP_OPTION_ELEMENT_UNION {
  204. [case(DhcpByteOption)] BYTE ByteOption;
  205. [case(DhcpWordOption)] WORD WordOption;
  206. [case(DhcpDWordOption)] DWORD DWordOption;
  207. [case(DhcpDWordDWordOption)] DWORD_DWORD DWordDWordOption;
  208. [case(DhcpIpAddressOption)] DHCP_IP_ADDRESS IpAddressOption;
  209. [case(DhcpStringDataOption)] LPWSTR StringDataOption;
  210. [case(DhcpBinaryDataOption)] DHCP_BINARY_DATA BinaryDataOption;
  211. [case(DhcpEncapsulatedDataOption)] DHCP_BINARY_DATA EncapsulatedDataOption;
  212. [default] ;
  213. } Element;
  214. #else
  215. union _DHCP_OPTION_ELEMENT_UNION {
  216. BYTE ByteOption;
  217. WORD WordOption;
  218. DWORD DWordOption;
  219. DWORD_DWORD DWordDWordOption;
  220. DHCP_IP_ADDRESS IpAddressOption;
  221. LPWSTR StringDataOption;
  222. DHCP_BINARY_DATA BinaryDataOption;
  223. DHCP_BINARY_DATA EncapsulatedDataOption;
  224. // for vendor specific information option.
  225. } Element;
  226. #endif // MIDL_PASS
  227. } DHCP_OPTION_DATA_ELEMENT, *LPDHCP_OPTION_DATA_ELEMENT;
  228. typedef struct _DHCP_OPTION_DATA {
  229. DWORD NumElements; // number of option elements in the pointed array
  230. #if defined(MIDL_PASS)
  231. [size_is(NumElements)]
  232. #endif // MIDL_PASS
  233. LPDHCP_OPTION_DATA_ELEMENT Elements; //array
  234. } DHCP_OPTION_DATA, *LPDHCP_OPTION_DATA;
  235. typedef struct _DHCP_OPTION_VALUE {
  236. DHCP_OPTION_ID OptionID;
  237. DHCP_OPTION_DATA Value;
  238. } DHCP_OPTION_VALUE, *LPDHCP_OPTION_VALUE;
  239. DWORD DHCP_API_FUNCTION
  240. DhcpGetVersion(
  241. LPWSTR ServerIpAddress,
  242. LPDWORD MajorVersion,
  243. LPDWORD MinorVersion
  244. );
  245. DWORD DHCP_API_FUNCTION
  246. DhcpSetServerBindingInfo(
  247. DHCP_CONST WCHAR *ServerIpAddress,
  248. ULONG Flags,
  249. LPDHCP_BIND_ELEMENT_ARRAY BindElementInfo
  250. );
  251. DWORD DHCP_API_FUNCTION
  252. DhcpGetServerBindingInfo(
  253. DHCP_CONST WCHAR *ServerIpAddress,
  254. ULONG Flags,
  255. LPDHCP_BIND_ELEMENT_ARRAY *BindElementsInfo
  256. );
  257. DWORD DHCP_API_FUNCTION
  258. DhcpCreateClientInfo(
  259. DHCP_CONST WCHAR *ServerIpAddress,
  260. DHCP_CONST DHCP_CLIENT_INFO *ClientInfo
  261. );
  262. DWORD DHCP_API_FUNCTION
  263. DhcpSetClientInfo(
  264. DHCP_CONST WCHAR *ServerIpAddress,
  265. DHCP_CONST DHCP_CLIENT_INFO *ClientInfo
  266. );
  267. DWORD DHCP_API_FUNCTION
  268. DhcpGetClientInfo(
  269. DHCP_CONST WCHAR *ServerIpAddress,
  270. DHCP_CONST DHCP_SEARCH_INFO *SearchInfo,
  271. LPDHCP_CLIENT_INFO *ClientInfo
  272. );
  273. DWORD DHCP_API_FUNCTION
  274. DhcpDeleteClientInfo(
  275. DHCP_CONST WCHAR *ServerIpAddress,
  276. DHCP_CONST DHCP_SEARCH_INFO *ClientInfo
  277. );
  278. DWORD DHCP_API_FUNCTION
  279. DhcpEnumSubnetClients(
  280. DHCP_CONST WCHAR *ServerIpAddress,
  281. DHCP_IP_ADDRESS SubnetAddress,
  282. DHCP_RESUME_HANDLE *ResumeHandle,
  283. DWORD PreferredMaximum,
  284. LPDHCP_CLIENT_INFO_ARRAY *ClientInfo,
  285. DWORD *ClientsRead,
  286. DWORD *ClientsTotal
  287. );
  288. DWORD DHCP_API_FUNCTION
  289. DhcpEnumSubnets(
  290. DHCP_CONST WCHAR *ServerIpAddress,
  291. DHCP_RESUME_HANDLE *ResumeHandle,
  292. DWORD PreferredMaximum,
  293. LPDHCP_IP_ARRAY *EnumInfo,
  294. DWORD *ElementsRead,
  295. DWORD *ElementsTotal
  296. );
  297. DWORD DHCP_API_FUNCTION
  298. DhcpGetSubnetInfo(
  299. DHCP_CONST WCHAR *ServerIpAddress,
  300. DHCP_IP_ADDRESS SubnetAddress,
  301. LPDHCP_SUBNET_INFO * SubnetInfo
  302. );
  303. DWORD DHCP_API_FUNCTION
  304. DhcpGetOptionValue(
  305. DHCP_CONST WCHAR *ServerIpAddress,
  306. DHCP_OPTION_ID OptionID,
  307. DHCP_CONST DHCP_OPTION_SCOPE_INFO *ScopeInfo,
  308. LPDHCP_OPTION_VALUE *OptionValue
  309. );
  310. VOID DHCP_API_FUNCTION
  311. DhcpRpcFreeMemory(
  312. PVOID BufferPointer
  313. );
  314. #ifdef __cplusplus
  315. }
  316. #endif
  317. #endif // _DHCPSAPI_