ReactOS  0.4.13-dev-1148-g9b75b67
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 298 of file dhcpcsvc.c.

303 {
304  COMM_DHCP_REQ Req;
305  COMM_DHCP_REPLY Reply;
307  BOOL Result;
308 
310 
312  Req.AdapterIndex = AdapterIndex;
313 
315  &Req, sizeof(Req),
316  &Reply, sizeof(Reply),
317  &BytesRead, NULL);
318 
319  if (Result && Reply.Reply != 0)
320  *DhcpEnabled = Reply.GetAdapterInfo.DhcpEnabled;
321  else
322  *DhcpEnabled = FALSE;
323 
324  if (*DhcpEnabled)
325  {
326  *DhcpServer = Reply.GetAdapterInfo.DhcpServer;
327  *LeaseObtained = Reply.GetAdapterInfo.LeaseObtained;
328  *LeaseExpires = Reply.GetAdapterInfo.LeaseExpires;
329  }
330  else
331  {
332  *DhcpServer = INADDR_NONE;
333  *LeaseObtained = 0;
334  *LeaseExpires = 0;
335  }
336 
337  return Reply.Reply;
338 }
#define INADDR_NONE
Definition: tcp.c:42
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_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:426
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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
static HANDLE PipeHandle
Definition: dhcpcsvc.c:21
struct _COMM_DHCP_REPLY::@3296 GetAdapterInfo
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

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 }
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
#define ERROR_SUCCESS
Definition: deptool.c:10
#define htonl(x)
Definition: module.h:212
#define INADDR_NONE
Definition: tcp.c:42
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD APIENTRY DhcpCApiInitialize(LPDWORD Version)
Definition: dhcpcsvc.c:24
Status
Definition: gdiplustypes.h:24
DWORD APIENTRY DhcpRosGetAdapterInfo(DWORD AdapterIndex, PBOOL DhcpEnabled, PDWORD DhcpServer, time_t *LeaseObtained, time_t *LeaseExpires)
Definition: dhcpcsvc.c:298
VOID APIENTRY DhcpCApiCleanup(VOID)
Definition: dhcpcsvc.c:69

Referenced by GetAdaptersInfo().