Skip to content

Commit 0bd6b3d

Browse files
committed
[DHCPCSVC][PSDK] Clean up, add some documentation and missing declarations
1 parent f6346c6 commit 0bd6b3d

File tree

3 files changed

+133
-75
lines changed

3 files changed

+133
-75
lines changed

base/services/dhcpcsvc/dhcpcsvc.c

Lines changed: 110 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,46 @@ PDHCP_SERVER_NAME_unbind(
8787
}
8888
}
8989

90-
90+
/*!
91+
* Initializes the DHCP interface
92+
*
93+
* \param[out] Version
94+
* Returns the DHCP Interface Version
95+
*
96+
* \return ERROR_SUCCESS on success
97+
*
98+
* \remarks DhcpCApiInitialized must be called before any other DHCP Function.
99+
*/
91100
DWORD
92101
APIENTRY
93102
DhcpCApiInitialize(
94103
_Out_ LPDWORD Version)
95104
{
96105
*Version = 2;
97-
return NO_ERROR;
106+
return ERROR_SUCCESS;
98107
}
99108

109+
/*!
110+
* Cleans up the DHCP interface
111+
*
112+
* \remarks Other DHCP Functions must not be called after DhcpCApiCleanup.
113+
*/
100114
VOID
101115
APIENTRY
102116
DhcpCApiCleanup(VOID)
103117
{
104118
}
105119

120+
/*!
121+
* Renews a DHCP Lease
122+
*
123+
* \param[in] AdapterName
124+
* Name (GUID) of the Adapter
125+
*
126+
* \return ERROR_SUCCESS on success
127+
*
128+
* \remarks Undocumented by Microsoft
129+
*/
106130
DWORD
107131
APIENTRY
108132
DhcpAcquireParameters(
@@ -125,28 +149,6 @@ DhcpAcquireParameters(
125149
return ret;
126150
}
127151

128-
DWORD
129-
APIENTRY
130-
DhcpReleaseParameters(
131-
_In_ PWSTR AdapterName)
132-
{
133-
DWORD ret;
134-
135-
DPRINT("DhcpReleaseParameters(%S)\n", AdapterName);
136-
137-
RpcTryExcept
138-
{
139-
ret = Client_ReleaseParameters(NULL, AdapterName);
140-
}
141-
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
142-
{
143-
ret = I_RpcMapWin32Status(RpcExceptionCode());
144-
}
145-
RpcEndExcept;
146-
147-
return ret;
148-
}
149-
150152
DWORD
151153
APIENTRY
152154
DhcpEnumClasses(
@@ -174,6 +176,58 @@ DhcpHandlePnPEvent(
174176
return 0;
175177
}
176178

179+
/*!
180+
* Set new TCP/IP parameters and notify DHCP client service of this
181+
*
182+
* \param[in] ServerName
183+
* NULL for local machine
184+
*
185+
* \param[in] AdapterName
186+
* IPHLPAPI name of adapter to change
187+
*
188+
* \param[in] NewIpAddress
189+
* TRUE if IP address changes
190+
191+
* \param[in] IpIndex
192+
* ...
193+
*
194+
* \param[in] IpAddress
195+
* New IP address (network byte order)
196+
*
197+
* \param[in] SubnetMask
198+
* New subnet mask (network byte order)
199+
*
200+
* \param[in] DhcpAction
201+
* 0 - don't modify
202+
* 1 - enable DHCP
203+
* 2 - disable DHCP
204+
*
205+
* \return ERROR_SUCCESS on success
206+
*
207+
* \remarks Undocumented by Microsoft
208+
*/
209+
DWORD
210+
APIENTRY
211+
DhcpNotifyConfigChange(
212+
_In_ LPWSTR ServerName,
213+
_In_ LPWSTR AdapterName,
214+
_In_ BOOL NewIpAddress,
215+
_In_ DWORD IpIndex,
216+
_In_ DWORD IpAddress,
217+
_In_ DWORD SubnetMask,
218+
_In_ INT DhcpAction)
219+
{
220+
DPRINT1("DHCPCSVC: DhcpNotifyConfigChange not implemented yet\n");
221+
DPRINT1("DhcpNotifyConfigChange(%S %S %lu %lu %lu %lu %d)\n",
222+
ServerName, AdapterName, NewIpAddress, IpIndex, IpAddress, SubnetMask, DhcpAction);
223+
224+
if (AdapterName == NULL)
225+
return ERROR_INVALID_PARAMETER;
226+
227+
UNIMPLEMENTED;
228+
return ERROR_SUCCESS;
229+
}
230+
177231
DWORD APIENTRY
178232
DhcpQueryHWInfo(DWORD AdapterIndex,
179233
PDWORD MediaType,
@@ -197,6 +251,38 @@ DhcpQueryHWInfo(DWORD AdapterIndex,
197251
return (ret == ERROR_SUCCESS) ? 1 : 0;
198252
}
199253

254+
/*!
255+
* Releases a DHCP Lease
256+
*
257+
* \param[in] AdapterName
258+
* Name (GUID) of the Adapter
259+
*
260+
* \return ERROR_SUCCESS on success
261+
*
262+
* \remarks Undocumented by Microsoft
263+
*/
264+
DWORD
265+
APIENTRY
266+
DhcpReleaseParameters(
267+
_In_ PWSTR AdapterName)
268+
{
269+
DWORD ret;
270+
271+
DPRINT("DhcpReleaseParameters(%S)\n", AdapterName);
272+
273+
RpcTryExcept
274+
{
275+
ret = Client_ReleaseParameters(NULL, AdapterName);
276+
}
277+
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
278+
{
279+
ret = I_RpcMapWin32Status(RpcExceptionCode());
280+
}
281+
RpcEndExcept;
282+
283+
return ret;
284+
}
285+
200286
DWORD
201287
APIENTRY
202288
DhcpStaticRefreshParams(DWORD AdapterIndex,
@@ -220,45 +306,6 @@ DhcpStaticRefreshParams(DWORD AdapterIndex,
220306
return (ret == ERROR_SUCCESS) ? 1 : 0;
221307
}
222308

223-
/*!
224-
* Set new TCP/IP parameters and notify DHCP client service of this
225-
*
226-
* \param[in] ServerName
227-
* NULL for local machine
228-
*
229-
* \param[in] AdapterName
230-
* IPHLPAPI name of adapter to change
231-
*
232-
* \param[in] NewIpAddress
233-
* TRUE if IP address changes
234-
*
235-
* \param[in] IpAddress
236-
* New IP address (network byte order)
237-
*
238-
* \param[in] SubnetMask
239-
* New subnet mask (network byte order)
240-
*
241-
* \param[in] DhcpAction
242-
* 0 - don't modify
243-
* 1 - enable DHCP
244-
* 2 - disable DHCP
245-
*
246-
* \return non-zero on success
247-
*
248-
* \remarks Undocumented by Microsoft
249-
*/
250-
DWORD APIENTRY
251-
DhcpNotifyConfigChange(LPWSTR ServerName,
252-
LPWSTR AdapterName,
253-
BOOL NewIpAddress,
254-
DWORD IpIndex,
255-
DWORD IpAddress,
256-
DWORD SubnetMask,
257-
INT DhcpAction)
258-
{
259-
DPRINT1("DHCPCSVC: DhcpNotifyConfigChange not implemented yet\n");
260-
return 0;
261-
}
262309

263310
DWORD APIENTRY
264311
DhcpRequestParams(DWORD Flags,

sdk/include/psdk/dhcpcapi.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,33 @@ DhcpHandlePnPEvent(
2727
_In_ DWORD Unknown4,
2828
_In_ DWORD Unknown5);
2929

30+
DWORD
31+
APIENTRY
32+
DhcpNotifyConfigChange(
33+
_In_ LPWSTR ServerName,
34+
_In_ LPWSTR AdapterName,
35+
_In_ BOOL NewIpAddress,
36+
_In_ DWORD IpIndex,
37+
_In_ DWORD IpAddress,
38+
_In_ DWORD SubnetMask,
39+
_In_ INT DhcpAction);
40+
41+
DWORD
42+
APIENTRY
43+
DhcpQueryHWInfo(
44+
_In_ DWORD AdapterIndex,
45+
_Out_ PDWORD MediaType,
46+
_Out_ PDWORD Mtu,
47+
_Out_ PDWORD Speed);
48+
3049
DWORD
3150
APIENTRY
3251
DhcpReleaseParameters(
3352
_In_ PWSTR AdapterName);
3453

35-
DWORD APIENTRY DhcpQueryHWInfo( DWORD AdapterIndex,
36-
PDWORD MediaType,
37-
PDWORD Mtu,
38-
PDWORD Speed );
3954
DWORD APIENTRY DhcpStaticRefreshParams( DWORD AdapterIndex,
4055
DWORD Address,
4156
DWORD Netmask );
42-
DWORD APIENTRY
43-
DhcpNotifyConfigChange(LPWSTR ServerName,
44-
LPWSTR AdapterName,
45-
BOOL NewIpAddress,
46-
DWORD IpIndex,
47-
DWORD IpAddress,
48-
DWORD SubnetMask,
49-
int DhcpAction);
5057

5158
#ifdef __cplusplus
5259
}

sdk/include/psdk/dhcpcsdk.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ typedef struct _DHCPCAPI_CLASSID
119119

120120
void WINAPI DhcpCApiCleanup(void);
121121
DWORD WINAPI DhcpCApiInitialize(DWORD *);
122+
DWORD WINAPI DhcpDeRegisterParamChange(DWORD, void *, void *);
123+
DWORD WINAPI DhcpRegisterParamChange(DWORD, LPVOID, LPWSTR, LPDHCPCAPI_CLASSID, DHCPCAPI_PARAMS_ARRAY, LPVOID);
124+
DWORD WINAPI DhcpRemoveDNSRegistrations(VOID);
122125
DWORD WINAPI DhcpRequestParams(DWORD, void *, WCHAR *, DHCPCAPI_CLASSID *, DHCPCAPI_PARAMS_ARRAY,
123126
DHCPCAPI_PARAMS_ARRAY, BYTE *, DWORD *, WCHAR *);
127+
DWORD WINAPI DhcpUndoRequestParams(DWORD, LPVOID, LPWSTR, LPWSTR);
124128

125129
#endif

0 commit comments

Comments
 (0)