First instance of DHCP client API. Not tested yet. Next, the control
panel.
Added: trunk/reactos/lib/dhcpcapi/
Added: trunk/reactos/lib/dhcpcapi/dhcpcapi.c
Added: trunk/reactos/lib/dhcpcapi/dhcpcapi.def
Added: trunk/reactos/lib/dhcpcapi/dhcpcapi.rc
Added: trunk/reactos/lib/dhcpcapi/makefile
_____
Added: trunk/reactos/lib/dhcpcapi/dhcpcapi.c
--- trunk/reactos/lib/dhcpcapi/dhcpcapi.c 2005-04-12 23:23:26 UTC
(rev 14599)
+++ trunk/reactos/lib/dhcpcapi/dhcpcapi.c 2005-04-12 23:25:14 UTC
(rev 14600)
@@ -0,0 +1,140 @@
+/* $Id: dllmain.c 12852 2005-01-06 13:58:04Z mf $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/dhcpcapi/dhcpcapi.c
+ * PURPOSE: Client API for DHCP
+ * PROGRAMMER: arty (ayerkes(a)speakeasy.net)
+ * UPDATE HISTORY:
+ * Created 12/04/2005
+ */
+
+#include <roscfg.h>
+#include <winsock2.h>
+#include <dhcpcsdk.h>
+#include <rosdhcp_public.h>
+
+#define DHCP_TIMEOUT 1000
+
+#define EXPORT __declspec(dllexport) WINAPI
+
+DWORD EXPORT DhcpCApiInitialize(LPDWORD Version) {
+ *Version = 2;
+ return 0;
+}
+
+VOID EXPORT DhcpCApiCleanup() {
+}
+
+DWORD EXPORT DhcpQueryHWInfo( DWORD AdapterIndex,
+ PDWORD MediaType,
+ PDWORD Mtu,
+ PDWORD Speed ) {
+ COMM_DHCP_REQ Req;
+ COMM_DHCP_REPLY Reply;
+ DWORD BytesRead;
+ BOOL Result;
+
+ Req.Type = DhcpReqQueryHWInfo;
+ Req.AdapterIndex = AdapterIndex;
+
+ Result = CallNamedPipe
+ ( DHCP_PIPE_NAME, &Req, sizeof(Req), &Reply, sizeof(Reply),
+ &BytesRead, DHCP_TIMEOUT );
+
+ if( !Reply.Reply ) return 0;
+ else {
+ *MediaType = Reply.QueryHWInfo.MediaType;
+ *Mtu = Reply.QueryHWInfo.Mtu;
+ *Speed = Reply.QueryHWInfo.Speed;
+ return 1;
+ }
+}
+
+DWORD EXPORT DhcpLeaseIpAddress( DWORD AdapterIndex ) {
+ COMM_DHCP_REQ Req;
+ COMM_DHCP_REPLY Reply;
+ DWORD BytesRead;
+ BOOL Result;
+
+ Req.Type = DhcpReqLeaseIpAddress;
+ Req.AdapterIndex = AdapterIndex;
+
+ Result = CallNamedPipe
+ ( DHCP_PIPE_NAME, &Req, sizeof(Req), &Reply, sizeof(Reply),
+ &BytesRead, DHCP_TIMEOUT );
+
+ return Reply.Reply;
+}
+
+DWORD EXPORT DhcpReleaseIpAddressLease( DWORD AdapterIndex ) {
+ COMM_DHCP_REQ Req;
+ COMM_DHCP_REPLY Reply;
+ DWORD BytesRead;
+ BOOL Result;
+
+ Req.Type = DhcpReqReleaseIpAddress;
+ Req.AdapterIndex = AdapterIndex;
+
+ Result = CallNamedPipe
+ ( DHCP_PIPE_NAME, &Req, sizeof(Req), &Reply, sizeof(Reply),
+ &BytesRead, DHCP_TIMEOUT );
+
+ return Reply.Reply;
+}
+
+DWORD EXPORT DhcpRenewIpAddressLease( DWORD AdapterIndex ) {
+ COMM_DHCP_REQ Req;
+ COMM_DHCP_REPLY Reply;
+ DWORD BytesRead;
+ BOOL Result;
+
+ Req.Type = DhcpReqRenewIpAddress;
+ Req.AdapterIndex = AdapterIndex;
+
+ Result = CallNamedPipe
+ ( DHCP_PIPE_NAME, &Req, sizeof(Req), &Reply, sizeof(Reply),
+ &BytesRead, DHCP_TIMEOUT );
+
+ return Reply.Reply;
+}
+
+DWORD EXPORT DhcpStaticRefreshParams( DWORD AdapterIndex,
+ DWORD Address,
+ DWORD Netmask ) {
+ COMM_DHCP_REQ Req;
+ COMM_DHCP_REPLY Reply;
+ DWORD BytesRead;
+ BOOL Result;
+
+ Req.Type = DhcpReqStaticRefreshParams;
+ Req.AdapterIndex = AdapterIndex;
+ Req.Body.StaticRefreshParams.IPAddress = Address;
+ Req.Body.StaticRefreshParams.Netmask = Netmask;
+
+ Result = CallNamedPipe
+ ( DHCP_PIPE_NAME, &Req, sizeof(Req), &Reply, sizeof(Reply),
+ &BytesRead, DHCP_TIMEOUT );
+
+ return Reply.Reply;
+}
+
+INT STDCALL
+DllMain(PVOID hinstDll,
+ ULONG dwReason,
+ PVOID reserved)
+{
+ switch (dwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinstDll);
+ break;
+
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+
+ return TRUE;
+}
+
+/* EOF */
_____
Added: trunk/reactos/lib/dhcpcapi/dhcpcapi.def
--- trunk/reactos/lib/dhcpcapi/dhcpcapi.def 2005-04-12 23:23:26 UTC
(rev 14599)
+++ trunk/reactos/lib/dhcpcapi/dhcpcapi.def 2005-04-12 23:25:14 UTC
(rev 14600)
@@ -0,0 +1,16 @@
+; $Id: dhcpcapi.def 14337 2005-03-26 22:10:04Z $
+;
+; dhcpcapi.def
+;
+; ReactOS Operating System
+;
+LIBRARY dhcpcapi.dll
+EXPORTS
+DhcpCApiInitialize@4
+DhcpCApiCleanup@0
+DhcpQueryHWInfo@16
+DhcpLeaseIpAddress@4
+DhcpReleaseIpAddressLease@4
+DhcpRenewIpAddressLease@4
+DhcpStaticRefreshParams@12
+; EOF
_____
Added: trunk/reactos/lib/dhcpcapi/dhcpcapi.rc
--- trunk/reactos/lib/dhcpcapi/dhcpcapi.rc 2005-04-12 23:23:26 UTC
(rev 14599)
+++ trunk/reactos/lib/dhcpcapi/dhcpcapi.rc 2005-04-12 23:25:14 UTC
(rev 14600)
@@ -0,0 +1,7 @@
+#include <defines.h>
+
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION "DHCP Client API\0"
+#define REACTOS_STR_INTERNAL_NAME "dhcpcapi\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "dhcpcapi.dll\0"
+#include <reactos/version.rc>
_____
Added: trunk/reactos/lib/dhcpcapi/makefile
--- trunk/reactos/lib/dhcpcapi/makefile 2005-04-12 23:23:26 UTC (rev
14599)
+++ trunk/reactos/lib/dhcpcapi/makefile 2005-04-12 23:25:14 UTC (rev
14600)
@@ -0,0 +1,27 @@
+# $Id: makefile 12852 2005-01-06 13:58:04Z mf $
+
+PATH_TO_TOP = ../..
+
+TARGET_TYPE = dynlink
+
+TARGET_NAME = dhcpcapi
+
+TARGET_CFLAGS = -Wall -Werror \
+ -D__USE_W32API \
+ -D_WIN32_IE=0x0500 \
+ -D_WIN32_WINNT=0x501 \
+ -DWINVER=0x600 \
+
+TARGET_LFLAGS = -nostartfiles -nostdlib
+
+TARGET_SDKLIBS = ntdll.a kernel32.a
+
+TARGET_OBJECTS = dhcpcapi.o
+
+DEP_OBJECTS = $(TARGET_OBJECTS)
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+include $(TOOLS_PATH)/depend.mk