xref: /reactos/dll/win32/iphlpapi/dhcp_reactos.c (revision 40462c92)
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 
11 DWORD APIENTRY DhcpRosGetAdapterInfo(DWORD AdapterIndex,
12                                      PBOOL DhcpEnabled,
13                                      PDWORD DhcpServer,
14                                      time_t *LeaseObtained,
15                                      time_t *LeaseExpires);
16 
17 DWORD getDhcpInfoForAdapter(DWORD AdapterIndex,
18                             PBOOL DhcpEnabled,
19                             PDWORD DhcpServer,
20                             time_t *LeaseObtained,
21                             time_t *LeaseExpires)
22 {
23     DWORD Status, Version = 0;
24 
25     Status = DhcpCApiInitialize(&Version);
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 
39     DhcpCApiCleanup();
40 
41     return Status;
42 }
43