Modified: trunk/reactos/include/libs/dhcp/rosdhcp_public.h
Modified: trunk/reactos/lib/dhcpcsvc/dhcpcsvc.c
Deleted: trunk/reactos/lib/dhcpcsvc/dhcpcsvc.def
Added: trunk/reactos/lib/dhcpcsvc/dhcpcsvc.spec
Modified: trunk/reactos/lib/dhcpcsvc/dhcpcsvc.xml
Added: trunk/reactos/lib/iphlpapi/dhcp.h
Added: trunk/reactos/lib/iphlpapi/dhcp_reactos.c
Modified: trunk/reactos/lib/iphlpapi/iphlpapi.xml
Modified: trunk/reactos/lib/iphlpapi/iphlpapi_main.c
Modified: trunk/reactos/services/dhcp/api.c
Modified: trunk/reactos/services/dhcp/dhclient.c
Modified: trunk/reactos/services/dhcp/include/dhcpd.h
Modified: trunk/reactos/services/dhcp/include/rosdhcp.h
Modified: trunk/reactos/services/dhcp/pipe.c
--- trunk/reactos/include/libs/dhcp/rosdhcp_public.h 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/include/libs/dhcp/rosdhcp_public.h 2006-01-08 22:14:26 UTC (rev 20736)
@@ -7,6 +7,7 @@
DhcpReqReleaseIpAddress,
DhcpReqRenewIpAddress,
DhcpReqStaticRefreshParams,
+ DhcpReqGetAdapterInfo,
};
typedef struct _COMM_DHCP_REQ {
@@ -39,6 +40,12 @@
DWORD Mtu;
DWORD Speed;
} QueryHWInfo;
+ struct {
+ BOOL DhcpEnabled;
+ DWORD DhcpServer;
+ time_t LeaseObtained;
+ time_t LeaseExpires;
+ } GetAdapterInfo;
} COMM_DHCP_REPLY;
#define DHCP_PIPE_NAME "\\\\.\\pipe\\dhcpclient"
--- trunk/reactos/lib/dhcpcsvc/dhcpcsvc.c 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/dhcpcsvc/dhcpcsvc.c 2006-01-08 22:14:26 UTC (rev 20736)
@@ -12,6 +12,7 @@
#include <roscfg.h>
#include <winsock2.h>
#include <dhcpcsdk.h>
+#include <time.h>
#include <dhcp/rosdhcp_public.h>
#define DHCP_TIMEOUT 1000
@@ -117,6 +118,70 @@
return Reply.Reply;
}
+/*++
+ * @name DhcpRosGetAdapterInfo
+ * @implemented ReactOS only
+ *
+ * Get DHCP info for an adapter
+ *
+ * @param AdapterIndex
+ * Index of the adapter (iphlpapi-style) for which info is
+ * requested
+ *
+ * @param DhcpEnabled
+ * Returns whether DHCP is enabled for the adapter
+ *
+ * @param DhcpServer
+ * Returns DHCP server IP address (255.255.255.255 if no
+ * server reached yet), in network byte order
+ *
+ * @param LeaseObtained
+ * Returns time at which the lease was obtained
+ *
+ * @param LeaseExpires
+ * Returns time at which the lease will expire
+ *
+ * @return non-zero on success
+ *
+ * @remarks This is a ReactOS-only routine
+ *
+ *--*/
+DWORD APIENTRY DhcpRosGetAdapterInfo( DWORD AdapterIndex,
+ PBOOL DhcpEnabled,
+ PDWORD DhcpServer,
+ time_t *LeaseObtained,
+ time_t *LeaseExpires )
+{
+ COMM_DHCP_REQ Req;
+ COMM_DHCP_REPLY Reply;
+ DWORD BytesRead;
+ BOOL Result;
+
+ Req.Type = DhcpReqGetAdapterInfo;
+ Req.AdapterIndex = AdapterIndex;
+
+ Result = CallNamedPipe
+ ( DHCP_PIPE_NAME, &Req, sizeof(Req), &Reply, sizeof(Reply),
+ &BytesRead, DHCP_TIMEOUT );
+
+ if ( 0 != Result && 0 != Reply.Reply ) {
+ *DhcpEnabled = Reply.GetAdapterInfo.DhcpEnabled;
+ } else {
+ *DhcpEnabled = FALSE;
+ }
+ if ( *DhcpEnabled ) {
+ *DhcpServer = Reply.GetAdapterInfo.DhcpServer;
+ *LeaseObtained = Reply.GetAdapterInfo.LeaseObtained;
+ *LeaseExpires = Reply.GetAdapterInfo.LeaseExpires;
+ } else {
+ *DhcpServer = INADDR_NONE;
+ *LeaseObtained = 0;
+ *LeaseExpires = 0;
+ }
+
+ return Reply.Reply;
+}
+
INT STDCALL
DllMain(PVOID hinstDll,
ULONG dwReason,
--- trunk/reactos/lib/dhcpcsvc/dhcpcsvc.def 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/dhcpcsvc/dhcpcsvc.def 2006-01-08 22:14:26 UTC (rev 20736)
@@ -1,16 +0,0 @@
-; $Id: dhcpcapi.def 14337 2005-03-26 22:10:04Z $
-;
-; dhcpcsvc.def
-;
-; ReactOS Operating System
-;
-LIBRARY dhcpcsvc.dll
-EXPORTS
-DhcpCApiInitialize@4
-DhcpCApiCleanup@0
-DhcpQueryHWInfo@16
-DhcpLeaseIpAddress@4
-DhcpReleaseIpAddressLease@4
-DhcpRenewIpAddressLease@4
-DhcpStaticRefreshParams@12
-; EOF
--- trunk/reactos/lib/dhcpcsvc/dhcpcsvc.spec 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/dhcpcsvc/dhcpcsvc.spec 2006-01-08 22:14:26 UTC (rev 20736)
@@ -0,0 +1,47 @@
+#
+# PROJECT: ReactOS Networking
+# LICENSE: GPL - See COPYING in the top level directory
+# FILE: lib/dhcpcsvc/dhcpcsvc.spec
+# PURPOSE: dhcpcsvc exports
+# COPYRIGHT: Copyright 2006 Ge van Geldorp <gvg@reactos.org>
+#
+@ stub DhcpAcquireParameters
+@ stub DhcpAcquireParametersByBroadcast
+@ stdcall DhcpCApiCleanup()
+@ stdcall DhcpCApiInitialize(ptr)
+@ stub DhcpDelPersistentRequestParams
+@ stub DhcpDeRegisterOptions
+@ stub DhcpDeRegisterParamChange
+@ stub DhcpEnumClasses
+@ stub DhcpFallbackRefreshParams
+@ stub DhcpHandlePnPEvent
+@ stdcall DhcpLeaseIpAddress(long)
+@ stub DhcpLeaseIpAddressEx
+@ stub DhcpNotifyConfigChange
+@ stub DhcpNotifyConfigChangeEx
+@ stub DhcpNotifyMediaReconnected
+@ stub DhcpOpenGlobalEvent
+@ stub DhcpPersistentRequestParams
+@ stdcall DhcpQueryHWInfo(long ptr ptr ptr)
+@ stub DhcpRegisterOptions
+@ stub DhcpRegisterParamChange
+@ stdcall DhcpReleaseIpAddressLease(long)
+@ stub DhcpReleaseIpAddressLeaseEx
+@ stub DhcpReleaseParameters
+@ stub DhcpRemoveDNSRegistrations
+@ stdcall DhcpRenewIpAddressLease(long)
+@ stub DhcpRenewIpAddressLeaseEx
+@ stub DhcpRequestOptions
+@ stub DhcpRequestParams
+@ stdcall DhcpStaticRefreshParams(long long long)
+@ stub DhcpUndoRequestParams
+@ stub McastApiCleanup
+@ stub McastApiStartup
+@ stub McastEnumerateScopes
+@ stub McastGenUID
+@ stub McastReleaseAddress
+@ stub McastRenewAddress
+@ stub McastRequestAddress
+@ stdcall DhcpRosGetAdapterInfo(long ptr ptr ptr ptr)
+# The Windows DHCP client service is implemented in the DLL too
+#@ stub ServiceMain
--- trunk/reactos/lib/dhcpcsvc/dhcpcsvc.xml 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/dhcpcsvc/dhcpcsvc.xml 2006-01-08 22:14:26 UTC (rev 20736)
@@ -1,5 +1,5 @@
<module name="dhcpcsvc" type="win32dll" installbase="system32" installname="dhcpcsvc.dll">
- <importlibrary definition="dhcpcsvc.def" />
+ <importlibrary definition="dhcpcsvc.spec.def" />
<include base="dhcpcsvc">include</include>
<define name="_DISABLE_TIDENTS" />
<define name="__USE_W32API" />
@@ -11,4 +11,5 @@
<library>iphlpapi</library>
<file>dhcpcsvc.c</file>
<file>dhcpcsvc.rc</file>
+ <file>dhcpcsvc.spec</file>
</module>
--- trunk/reactos/lib/iphlpapi/dhcp.h 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/iphlpapi/dhcp.h 2006-01-08 22:14:26 UTC (rev 20736)
@@ -0,0 +1,18 @@
+/*
+ * PROJECT: ReactOS Networking
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: lib/iphlpapi/dhcp_reactos.c
+ * PURPOSE: DHCP helper functions for ReactOS
+ * COPYRIGHT: Copyright 2006 Ge van Geldorp <gvg@reactos.org>
+ */
+
+#ifndef WINE_DHCP_H_
+#define WINE_DHCP_H_
+
+DWORD getDhcpInfoForAdapter(DWORD AdapterIndex,
+ PBOOL DhcpEnabled,
+ PDWORD DhcpServer,
+ time_t *LeaseObtained,
+ time_t *LeaseExpires);
+
+#endif /* ndef WINE_DHCP_H_ */
Property changes on: trunk/reactos/lib/iphlpapi/dhcp.h
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
--- trunk/reactos/lib/iphlpapi/dhcp_reactos.c 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/iphlpapi/dhcp_reactos.c 2006-01-08 22:14:26 UTC (rev 20736)
@@ -0,0 +1,30 @@
+/*
+ * PROJECT: ReactOS Networking
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: lib/iphlpapi/dhcp_reactos.c
+ * PURPOSE: DHCP helper functions for ReactOS
+ * COPYRIGHT: Copyright 2006 Ge van Geldorp <gvg@reactos.org>
+ */
+
+#include "iphlpapi_private.h"
+#include "dhcp.h"
+#include <assert.h>
+
+#define NDEBUG
+#include "debug.h"
+
+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)
+{
+ return DhcpRosGetAdapterInfo(AdapterIndex, DhcpEnabled, DhcpServer,
+ LeaseObtained, LeaseExpires);
+}
Property changes on: trunk/reactos/lib/iphlpapi/dhcp_reactos.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
--- trunk/reactos/lib/iphlpapi/iphlpapi.xml 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/iphlpapi/iphlpapi.xml 2006-01-08 22:14:26 UTC (rev 20736)
@@ -11,6 +11,8 @@
<library>kernel32</library>
<library>advapi32</library>
<library>ws2_32</library>
+ <library>dhcpcsvc</library>
+ <file>dhcp_reactos.c</file>
<file>ifenum_reactos.c</file>
<file>ipstats_reactos.c</file>
<file>iphlpapi_main.c</file>
--- trunk/reactos/lib/iphlpapi/iphlpapi_main.c 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/lib/iphlpapi/iphlpapi_main.c 2006-01-08 22:14:26 UTC (rev 20736)
@@ -42,6 +42,7 @@
#include "winbase.h"
#include "winreg.h"
#include "iphlpapi.h"
+#include "dhcp.h"
#include "ifenum.h"
#include "ipstats.h"
#include "resinfo.h"
@@ -559,6 +560,8 @@
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
{
DWORD ret;
+ BOOL dhcpEnabled;
+ DWORD dhcpServer;
TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo, pOutBufLen);
if (!pOutBufLen)
@@ -637,6 +640,12 @@
ptr->IpAddressList.IpAddress.String);
toIPAddressString(getInterfaceMaskByIndex(table->indexes[ndx]),
ptr->IpAddressList.IpMask.String);
+ getDhcpInfoForAdapter(table->indexes[ndx], &dhcpEnabled,
+ &dhcpServer, &ptr->LeaseObtained,
+ &ptr->LeaseExpires);
+ ptr->DhcpEnabled = (DWORD) dhcpEnabled;
+ toIPAddressString(dhcpServer,
+ ptr->DhcpServer.IpAddress.String);
if (winsEnabled) {
ptr->HaveWins = TRUE;
memcpy(ptr->PrimaryWinsServer.IpAddress.String,
--- trunk/reactos/services/dhcp/api.c 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/services/dhcp/api.c 2006-01-08 22:14:26 UTC (rev 20736)
@@ -11,6 +11,9 @@
#include <winsock2.h>
#include <iphlpapi.h>
+#define NDEBUG
+#include <reactos/debug.h>
+
static CRITICAL_SECTION ApiCriticalSection;
VOID ApiInit() {
@@ -140,3 +143,40 @@
return Send( &Reply );
}
+
+DWORD DSGetAdapterInfo( PipeSendFunc Send, COMM_DHCP_REQ *Req ) {
+ COMM_DHCP_REPLY Reply;
+ PDHCP_ADAPTER Adapter;
+
+ ApiLock();
+
+ Adapter = AdapterFindIndex( Req->AdapterIndex );
+
+ Reply.Reply = Adapter ? 1 : 0;
+
+ if( Adapter ) {
+ Reply.GetAdapterInfo.DhcpEnabled = (S_STATIC != Adapter->DhclientState.state);
+ if (S_BOUND == Adapter->DhclientState.state) {
+ if (sizeof(Reply.GetAdapterInfo.DhcpServer) ==
+ Adapter->DhclientState.active->serveraddress.len) {
+ memcpy(&Reply.GetAdapterInfo.DhcpServer,
+ Adapter->DhclientState.active->serveraddress.iabuf,
+ Adapter->DhclientState.active->serveraddress.len);
+ } else {
+ DPRINT1("Unexpected server address len %d\n",
+ Adapter->DhclientState.active->serveraddress.len);
+ Reply.GetAdapterInfo.DhcpServer = htonl(INADDR_NONE);
+ }
+ Reply.GetAdapterInfo.LeaseObtained = Adapter->DhclientState.active->obtained;
+ Reply.GetAdapterInfo.LeaseExpires = Adapter->DhclientState.active->expiry;
+ } else {
+ Reply.GetAdapterInfo.DhcpServer = htonl(INADDR_NONE);
+ Reply.GetAdapterInfo.LeaseObtained = 0;
+ Reply.GetAdapterInfo.LeaseExpires = 0;
+ }
+ }
+
+ ApiUnlock();
+
+ return Send( &Reply );
+}
--- trunk/reactos/services/dhcp/dhclient.c 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/services/dhcp/dhclient.c 2006-01-08 22:14:26 UTC (rev 20736)
@@ -420,6 +420,9 @@
ip->client->new->rebind = ip->client->new->renewal +
ip->client->new->renewal / 2 + ip->client->new->renewal / 4;
+#ifdef _REACTOS_
+ ip->client->new->obtained = cur_time;
+#endif
ip->client->new->expiry += cur_time;
/* Lease lengths can never be negative. */
if (ip->client->new->expiry < cur_time)
@@ -809,6 +812,10 @@
lease->address.len = sizeof(packet->raw->yiaddr);
memcpy(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len);
+#ifdef _REACTOS_
+ lease->serveraddress.len = sizeof(packet->raw->siaddr);
+ memcpy(lease->serveraddress.iabuf, &packet->raw->siaddr, lease->address.len);
+#endif
/* If the server name was filled out, copy it. */
if ((!packet->options[DHO_DHCP_OPTION_OVERLOAD].len ||
--- trunk/reactos/services/dhcp/include/dhcpd.h 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/services/dhcp/include/dhcpd.h 2006-01-08 22:14:26 UTC (rev 20736)
@@ -158,6 +158,10 @@
time_t expiry, renewal, rebind;
struct iaddr address;
char *server_name;
+#ifdef _REACTOS_
+ time_t obtained;
+ struct iaddr serveraddress;
+#endif
char *filename;
struct string_list *medium;
unsigned int is_static : 1;
--- trunk/reactos/services/dhcp/include/rosdhcp.h 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/services/dhcp/include/rosdhcp.h 2006-01-08 22:14:26 UTC (rev 20736)
@@ -67,6 +67,8 @@
extern DWORD DSLeaseIpAddress( PipeSendFunc Send, COMM_DHCP_REQ *Req );
extern DWORD DSRenewIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req );
extern DWORD DSReleaseIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req );
+extern DWORD DSStaticRefreshParams( PipeSendFunc Send, COMM_DHCP_REQ *Req );
+extern DWORD DSGetAdapterInfo( PipeSendFunc Send, COMM_DHCP_REQ *Req );
extern int inet_aton(const char *s, struct in_addr *addr);
int warn( char *format, ... );
#endif/*ROSDHCP_H*/
--- trunk/reactos/services/dhcp/pipe.c 2006-01-08 21:38:13 UTC (rev 20735)
+++ trunk/reactos/services/dhcp/pipe.c 2006-01-08 22:14:26 UTC (rev 20736)
@@ -9,6 +9,9 @@
#include <rosdhcp.h>
+#define NDEBUG
+#include <reactos/debug.h>
+
static HANDLE CommPipe = INVALID_HANDLE_VALUE, CommThread;
DWORD CommThrId;
@@ -30,8 +33,8 @@
DWORD WINAPI PipeThreadProc( LPVOID Parameter ) {
DWORD BytesRead, BytesWritten;
COMM_DHCP_REQ Req;
- BOOL Result;
- BOOLEAN Connection;
+ COMM_DHCP_REPLY Reply;
+ BOOL Result, Connection;
while( (Connection = ConnectNamedPipe( CommPipe, NULL )) ) {
Result = ReadFile( CommPipe, &Req, sizeof(Req), &BytesRead, NULL );
@@ -52,6 +55,21 @@
case DhcpReqRenewIpAddress:
BytesWritten = DSRenewIpAddressLease( PipeSend, &Req );
break;
+
+ case DhcpReqStaticRefreshParams:
+ BytesWritten = DSStaticRefreshParams( PipeSend, &Req );
+ break;
+
+ case DhcpReqGetAdapterInfo:
+ BytesWritten = DSGetAdapterInfo( PipeSend, &Req );
+ break;
+
+ default:
+ DPRINT1("Unrecognized request type %d\n", Req.Type);
+ ZeroMemory( &Reply, sizeof( COMM_DHCP_REPLY ) );
+ Reply.Reply = 0;
+ BytesWritten = PipeSend( &Reply );
+ break;
}
}
DisconnectNamedPipe( CommPipe );