Merge MSVC fixes from cmake branch
[reactos.git] / reactos / dll / win32 / iphlpapi / dhcp_reactos.c
1 /*
2 * PROJECT: ReactOS Networking
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/iphlpapi/dhcp_reactos.c
5 * PURPOSE: DHCP helper functions for ReactOS
6 * COPYRIGHT: Copyright 2006 Ge van Geldorp <gvg@reactos.org>
7 */
8
9 #include "iphlpapi_private.h"
10 #include "dhcp.h"
11 #include "dhcpcsdk.h"
12 #include "dhcpcapi.h"
13 #include <assert.h>
14
15 DWORD APIENTRY DhcpRosGetAdapterInfo(DWORD AdapterIndex,
16 PBOOL DhcpEnabled,
17 PDWORD DhcpServer,
18 time_t *LeaseObtained,
19 time_t *LeaseExpires);
20
21 DWORD getDhcpInfoForAdapter(DWORD AdapterIndex,
22 PBOOL DhcpEnabled,
23 PDWORD DhcpServer,
24 time_t *LeaseObtained,
25 time_t *LeaseExpires)
26 {
27 DWORD Status, Version = 0;
28
29 Status = DhcpCApiInitialize(&Version);
30 if (Status != ERROR_SUCCESS)
31 {
32 /* We assume that the DHCP service isn't running yet */
33 *DhcpEnabled = FALSE;
34 *DhcpServer = htonl(INADDR_NONE);
35 *LeaseObtained = 0;
36 *LeaseExpires = 0;
37 return ERROR_SUCCESS;
38 }
39
40 Status = DhcpRosGetAdapterInfo(AdapterIndex, DhcpEnabled, DhcpServer,
41 LeaseObtained, LeaseExpires);
42
43 DhcpCApiCleanup();
44
45 return Status;
46 }