ReactOS 0.4.15-dev-8135-g1bc6c90
dhcp_reactos.c File Reference
#include "iphlpapi_private.h"
Include dependency graph for dhcp_reactos.c:

Go to the source code of this file.

Functions

DWORD APIENTRY DhcpRosGetAdapterInfo (DWORD AdapterIndex, PBOOL DhcpEnabled, PDWORD DhcpServer, time_t *LeaseObtained, time_t *LeaseExpires)
 
DWORD getDhcpInfoForAdapter (DWORD AdapterIndex, PBOOL DhcpEnabled, PDWORD DhcpServer, time_t *LeaseObtained, time_t *LeaseExpires)
 

Function Documentation

◆ DhcpRosGetAdapterInfo()

DWORD APIENTRY DhcpRosGetAdapterInfo ( DWORD  AdapterIndex,
PBOOL  DhcpEnabled,
PDWORD  DhcpServer,
time_t LeaseObtained,
time_t LeaseExpires 
)

Get DHCP info for an adapter

Parameters
[in]AdapterIndexIndex of the adapter (iphlpapi-style) for which info is requested
[out]DhcpEnabledReturns whether DHCP is enabled for the adapter
[out]DhcpServerReturns DHCP server IP address (255.255.255.255 if no server reached yet), in network byte order
[out]LeaseObtainedReturns time at which the lease was obtained
[out]LeaseExpiresReturns time at which the lease will expire
Returns
non-zero on success
Remarks
This is a ReactOS-only routine

Definition at line 300 of file dhcpcsvc.c.

305{
306 COMM_DHCP_REQ Req;
307 COMM_DHCP_REPLY Reply;
309 BOOL Result;
310
312
314 Req.AdapterIndex = AdapterIndex;
315
317 &Req, sizeof(Req),
318 &Reply, sizeof(Reply),
319 &BytesRead, NULL);
320
321 if (Result && Reply.Reply != 0)
322 *DhcpEnabled = Reply.GetAdapterInfo.DhcpEnabled;
323 else
324 *DhcpEnabled = FALSE;
325
326 if (*DhcpEnabled)
327 {
328 *DhcpServer = Reply.GetAdapterInfo.DhcpServer;
329 *LeaseObtained = Reply.GetAdapterInfo.LeaseObtained;
330 *LeaseExpires = Reply.GetAdapterInfo.LeaseExpires;
331 }
332 else
333 {
334 *DhcpServer = INADDR_NONE;
335 *LeaseObtained = 0;
336 *LeaseExpires = 0;
337 }
338
339 return Reply.Reply;
340}
#define INADDR_NONE
Definition: tcp.c:42
static HANDLE PipeHandle
Definition: dhcpcsvc.c:22
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ASSERT(a)
Definition: mode.c:44
BOOL WINAPI TransactNamedPipe(IN HANDLE hNamedPipe, IN LPVOID lpInBuffer, IN DWORD nInBufferSize, OUT LPVOID lpOutBuffer, IN DWORD nOutBufferSize, OUT LPDWORD lpBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: npipe.c:1315
@ DhcpReqGetAdapterInfo
struct _COMM_DHCP_REPLY::@3464 GetAdapterInfo
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by getDhcpInfoForAdapter().

◆ getDhcpInfoForAdapter()

DWORD getDhcpInfoForAdapter ( DWORD  AdapterIndex,
PBOOL  DhcpEnabled,
PDWORD  DhcpServer,
time_t LeaseObtained,
time_t LeaseExpires 
)

Definition at line 17 of file dhcp_reactos.c.

22{
23 DWORD Status, Version = 0;
24
26 if (Status != ERROR_SUCCESS)
27 {
28 /* We assume that the DHCP service isn't running yet */
29 *DhcpEnabled = FALSE;
30 *DhcpServer = htonl(INADDR_NONE);
31 *LeaseObtained = 0;
32 *LeaseExpires = 0;
33 return ERROR_SUCCESS;
34 }
35
36 Status = DhcpRosGetAdapterInfo(AdapterIndex, DhcpEnabled, DhcpServer,
37 LeaseObtained, LeaseExpires);
38
40
41 return Status;
42}
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD APIENTRY DhcpRosGetAdapterInfo(DWORD AdapterIndex, PBOOL DhcpEnabled, PDWORD DhcpServer, time_t *LeaseObtained, time_t *LeaseExpires)
Definition: dhcpcsvc.c:300
void WINAPI DhcpCApiCleanup(void)
Definition: dhcpcsvc.c:71
DWORD APIENTRY DhcpCApiInitialize(LPDWORD Version)
Definition: dhcpcsvc.c:26
Status
Definition: gdiplustypes.h:25
#define htonl(x)
Definition: module.h:214
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

Referenced by GetAdaptersInfo().