9e8086f3cfb0b9c6a4f48ba8920001f23d999436
[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 #define NDEBUG
16 #include "debug.h"
17
18 DWORD APIENTRY DhcpRosGetAdapterInfo(DWORD AdapterIndex,
19 PBOOL DhcpEnabled,
20 PDWORD DhcpServer,
21 time_t *LeaseObtained,
22 time_t *LeaseExpires);
23
24 DWORD getDhcpInfoForAdapter(DWORD AdapterIndex,
25 PBOOL DhcpEnabled,
26 PDWORD DhcpServer,
27 time_t *LeaseObtained,
28 time_t *LeaseExpires)
29 {
30 DWORD Status, Version = 0;
31
32 Status = DhcpCApiInitialize(&Version);
33 if (Status == ERROR_NOT_READY)
34 {
35 /* The DHCP server isn't running yet */
36 *DhcpEnabled = FALSE;
37 *DhcpServer = htonl(INADDR_NONE);
38 *LeaseObtained = 0;
39 *LeaseExpires = 0;
40 return ERROR_SUCCESS;
41 }
42 else if (Status != ERROR_SUCCESS)
43 {
44 return Status;
45 }
46
47 Status = DhcpRosGetAdapterInfo(AdapterIndex, DhcpEnabled, DhcpServer,
48 LeaseObtained, LeaseExpires);
49
50 DhcpCApiCleanup();
51
52 return Status;
53 }