3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: subsys/system/dhcp/pipe.c
6 * PURPOSE: DHCP client pipe
12 static HANDLE CommPipe
= INVALID_HANDLE_VALUE
, CommThread
;
15 #define COMM_PIPE_OUTPUT_BUFFER sizeof(COMM_DHCP_REQ)
16 #define COMM_PIPE_INPUT_BUFFER sizeof(COMM_DHCP_REPLY)
17 #define COMM_PIPE_DEFAULT_TIMEOUT 1000
19 DWORD
PipeSend( COMM_DHCP_REPLY
*Reply
) {
27 return Success
? Written
: -1;
30 DWORD WINAPI
PipeThreadProc( LPVOID Parameter
) {
31 DWORD BytesRead
, BytesWritten
;
36 while( (Connection
= ConnectNamedPipe( CommPipe
, NULL
)) ) {
37 Result
= ReadFile( CommPipe
, &Req
, sizeof(Req
), &BytesRead
, NULL
);
40 case DhcpReqQueryHWInfo
:
41 BytesWritten
= DSQueryHWInfo( PipeSend
, &Req
);
44 case DhcpReqLeaseIpAddress
:
45 BytesWritten
= DSLeaseIpAddress( PipeSend
, &Req
);
48 case DhcpReqReleaseIpAddress
:
49 BytesWritten
= DSReleaseIpAddressLease( PipeSend
, &Req
);
52 case DhcpReqRenewIpAddress
:
53 BytesWritten
= DSRenewIpAddressLease( PipeSend
, &Req
);
57 CloseHandle( CommPipe
);
64 CommPipe
= CreateNamedPipe
66 PIPE_ACCESS_DUPLEX
| FILE_FLAG_FIRST_PIPE_INSTANCE
,
67 PIPE_TYPE_MESSAGE
| PIPE_READMODE_MESSAGE
| PIPE_WAIT
,
69 COMM_PIPE_OUTPUT_BUFFER
,
70 COMM_PIPE_INPUT_BUFFER
,
71 COMM_PIPE_DEFAULT_TIMEOUT
,
74 if( CommPipe
== INVALID_HANDLE_VALUE
) {
75 DbgPrint("DHCP: Could not create named pipe\n");
79 CommThread
= CreateThread( NULL
, 0, PipeThreadProc
, NULL
, 0, &CommThrId
);
82 CloseHandle( CommPipe
);
83 CommPipe
= INVALID_HANDLE_VALUE
;
90 CloseHandle( CommPipe
);
91 CommPipe
= INVALID_HANDLE_VALUE
;