ReactOS  0.4.12-dev-57-g7050ac4
pipe.c File Reference
#include <rosdhcp.h>
#include <reactos/debug.h>
Include dependency graph for pipe.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define COMM_PIPE_OUTPUT_BUFFER   sizeof(COMM_DHCP_REQ)
 
#define COMM_PIPE_INPUT_BUFFER   sizeof(COMM_DHCP_REPLY)
 
#define COMM_PIPE_DEFAULT_TIMEOUT   1000
 

Functions

DWORD PipeSend (COMM_DHCP_REPLY *Reply)
 
DWORD WINAPI PipeThreadProc (LPVOID Parameter)
 
HANDLE PipeInit ()
 
VOID PipeDestroy ()
 

Variables

static HANDLE CommPipe = INVALID_HANDLE_VALUE
 
static HANDLE CommThread
 
DWORD CommThrId
 

Macro Definition Documentation

◆ COMM_PIPE_DEFAULT_TIMEOUT

#define COMM_PIPE_DEFAULT_TIMEOUT   1000

Definition at line 19 of file pipe.c.

Referenced by PipeInit().

◆ COMM_PIPE_INPUT_BUFFER

#define COMM_PIPE_INPUT_BUFFER   sizeof(COMM_DHCP_REPLY)

Definition at line 18 of file pipe.c.

Referenced by PipeInit().

◆ COMM_PIPE_OUTPUT_BUFFER

#define COMM_PIPE_OUTPUT_BUFFER   sizeof(COMM_DHCP_REQ)

Definition at line 17 of file pipe.c.

Referenced by PipeInit().

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file pipe.c.

Function Documentation

◆ PipeDestroy()

VOID PipeDestroy ( )

Definition at line 116 of file pipe.c.

116  {
119 }
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static HANDLE CommPipe
Definition: pipe.c:14

◆ PipeInit()

HANDLE PipeInit ( )

Definition at line 90 of file pipe.c.

Referenced by init_client().

90  {
95  1,
99  NULL );
100 
101  if( CommPipe == INVALID_HANDLE_VALUE ) {
102  DbgPrint("DHCP: Could not create named pipe\n");
103  return CommPipe;
104  }
105 
107 
108  if( !CommThread ) {
111  }
112 
113  return CommPipe;
114 }
#define COMM_PIPE_DEFAULT_TIMEOUT
Definition: pipe.c:19
DWORD WINAPI PipeThreadProc(LPVOID Parameter)
Definition: pipe.c:32
#define CloseHandle
Definition: compat.h:398
#define DbgPrint
Definition: loader.c:25
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168
#define PIPE_WAIT
Definition: winbase.h:171
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
smooth NULL
Definition: ftsmooth.c:416
#define COMM_PIPE_INPUT_BUFFER
Definition: pipe.c:18
#define FILE_FLAG_FIRST_PIPE_INSTANCE
Definition: piperead.cpp:20
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
#define COMM_PIPE_OUTPUT_BUFFER
Definition: pipe.c:17
DWORD CommThrId
Definition: pipe.c:15
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
static HANDLE CommThread
Definition: pipe.c:14
#define DHCP_PIPE_NAME
static HANDLE CommPipe
Definition: pipe.c:14
HANDLE WINAPI CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:246

◆ PipeSend()

DWORD PipeSend ( COMM_DHCP_REPLY Reply)

Definition at line 21 of file pipe.c.

Referenced by PipeThreadProc().

21  {
22  DWORD Written = 0;
23  BOOL Success =
25  Reply,
26  sizeof(*Reply),
27  &Written,
28  NULL );
29  return Success ? Written : -1;
30 }
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE CommPipe
Definition: pipe.c:14

◆ PipeThreadProc()

DWORD WINAPI PipeThreadProc ( LPVOID  Parameter)

Definition at line 32 of file pipe.c.

Referenced by PipeInit().

32  {
34  COMM_DHCP_REQ Req;
35  COMM_DHCP_REPLY Reply;
36  BOOL Result, Connected;
37 
38  while( TRUE ) {
39  Connected = ConnectNamedPipe( CommPipe, NULL ) ?
41 
42  if (!Connected) {
43  DbgPrint("DHCP: Could not connect named pipe\n");
46  break;
47  }
48 
49  Result = ReadFile( CommPipe, &Req, sizeof(Req), &BytesRead, NULL );
50  if( Result ) {
51  switch( Req.Type ) {
52  case DhcpReqQueryHWInfo:
53  DSQueryHWInfo( PipeSend, &Req );
54  break;
55 
57  DSLeaseIpAddress( PipeSend, &Req );
58  break;
59 
62  break;
63 
66  break;
67 
70  break;
71 
73  DSGetAdapterInfo( PipeSend, &Req );
74  break;
75 
76  default:
77  DPRINT1("Unrecognized request type %d\n", Req.Type);
78  ZeroMemory( &Reply, sizeof( COMM_DHCP_REPLY ) );
79  Reply.Reply = 0;
80  PipeSend( &Reply );
81  break;
82  }
83  }
85  }
86 
87  return TRUE;
88 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define DbgPrint
Definition: loader.c:25
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
DWORD DSGetAdapterInfo(PipeSendFunc Send, COMM_DHCP_REQ *Req)
Definition: api.c:209
DWORD DSRenewIpAddressLease(PipeSendFunc Send, COMM_DHCP_REQ *Req)
Definition: api.c:129
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
DWORD DSStaticRefreshParams(PipeSendFunc Send, COMM_DHCP_REQ *Req)
Definition: api.c:165
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD DSQueryHWInfo(PipeSendFunc Send, COMM_DHCP_REQ *Req)
Definition: api.c:68
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
BOOL WINAPI DisconnectNamedPipe(HANDLE hNamedPipe)
Definition: npipe.c:961
DWORD DSReleaseIpAddressLease(PipeSendFunc Send, COMM_DHCP_REQ *Req)
Definition: api.c:90
DWORD DSLeaseIpAddress(PipeSendFunc Send, COMM_DHCP_REQ *Req)
Definition: api.c:36
static HANDLE CommPipe
Definition: pipe.c:14
#define DPRINT1
Definition: precomp.h:8
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
DWORD PipeSend(COMM_DHCP_REPLY *Reply)
Definition: pipe.c:21

Variable Documentation

◆ CommPipe

HANDLE CommPipe = INVALID_HANDLE_VALUE
static

Definition at line 14 of file pipe.c.

Referenced by PipeInit().

◆ CommThread

HANDLE CommThread
static

Definition at line 14 of file pipe.c.

Referenced by PipeInit().

◆ CommThrId

DWORD CommThrId

Definition at line 15 of file pipe.c.

Referenced by PipeInit().