1 /* $Id: dllmain.c 12852 2005-01-06 13:58:04Z mf $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/dhcpcapi/dhcpcapi.c
6 * PURPOSE: Client API for DHCP
7 * PROGRAMMER: arty (ayerkes@speakeasy.net)
15 #include <dhcp/rosdhcp_public.h>
17 #define DHCP_TIMEOUT 1000
19 DWORD APIENTRY
DhcpCApiInitialize(LPDWORD Version
) {
24 VOID APIENTRY
DhcpCApiCleanup() {
27 DWORD APIENTRY
DhcpQueryHWInfo( DWORD AdapterIndex
,
32 COMM_DHCP_REPLY Reply
;
36 Req
.Type
= DhcpReqQueryHWInfo
;
37 Req
.AdapterIndex
= AdapterIndex
;
39 Result
= CallNamedPipe
40 ( DHCP_PIPE_NAME
, &Req
, sizeof(Req
), &Reply
, sizeof(Reply
),
41 &BytesRead
, DHCP_TIMEOUT
);
43 if( !Reply
.Reply
) return 0;
45 *MediaType
= Reply
.QueryHWInfo
.MediaType
;
46 *Mtu
= Reply
.QueryHWInfo
.Mtu
;
47 *Speed
= Reply
.QueryHWInfo
.Speed
;
52 DWORD APIENTRY
DhcpLeaseIpAddress( DWORD AdapterIndex
) {
54 COMM_DHCP_REPLY Reply
;
58 Req
.Type
= DhcpReqLeaseIpAddress
;
59 Req
.AdapterIndex
= AdapterIndex
;
61 Result
= CallNamedPipe
62 ( DHCP_PIPE_NAME
, &Req
, sizeof(Req
), &Reply
, sizeof(Reply
),
63 &BytesRead
, DHCP_TIMEOUT
);
68 DWORD APIENTRY
DhcpReleaseIpAddressLease( DWORD AdapterIndex
) {
70 COMM_DHCP_REPLY Reply
;
74 Req
.Type
= DhcpReqReleaseIpAddress
;
75 Req
.AdapterIndex
= AdapterIndex
;
77 Result
= CallNamedPipe
78 ( DHCP_PIPE_NAME
, &Req
, sizeof(Req
), &Reply
, sizeof(Reply
),
79 &BytesRead
, DHCP_TIMEOUT
);
84 DWORD APIENTRY
DhcpRenewIpAddressLease( DWORD AdapterIndex
) {
86 COMM_DHCP_REPLY Reply
;
90 Req
.Type
= DhcpReqRenewIpAddress
;
91 Req
.AdapterIndex
= AdapterIndex
;
93 Result
= CallNamedPipe
94 ( DHCP_PIPE_NAME
, &Req
, sizeof(Req
), &Reply
, sizeof(Reply
),
95 &BytesRead
, DHCP_TIMEOUT
);
100 DWORD APIENTRY
DhcpStaticRefreshParams( DWORD AdapterIndex
,
104 COMM_DHCP_REPLY Reply
;
108 Req
.Type
= DhcpReqStaticRefreshParams
;
109 Req
.AdapterIndex
= AdapterIndex
;
110 Req
.Body
.StaticRefreshParams
.IPAddress
= Address
;
111 Req
.Body
.StaticRefreshParams
.Netmask
= Netmask
;
113 Result
= CallNamedPipe
114 ( DHCP_PIPE_NAME
, &Req
, sizeof(Req
), &Reply
, sizeof(Reply
),
115 &BytesRead
, DHCP_TIMEOUT
);
121 DllMain(PVOID hinstDll
,
127 case DLL_PROCESS_ATTACH
:
128 DisableThreadLibraryCalls(hinstDll
);
131 case DLL_PROCESS_DETACH
: