Implemented LPC sections
[reactos.git] / reactos / ntoskrnl / lpc / listen.c
1 /* $Id: listen.c,v 1.3 2001/12/02 23:34:42 dwelch Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/listen.c
6 * PURPOSE: Communication mechanism
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 */
11
12 /* INCLUDES ******************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <internal/ob.h>
16 #include <internal/port.h>
17 #include <internal/dbg.h>
18
19 #define NDEBUG
20 #include <internal/debug.h>
21
22 /* FUNCTIONS *****************************************************************/
23
24 /**********************************************************************
25 * NAME EXPORTED
26 * NtListenPort@8
27 *
28 * DESCRIPTION
29 * Listen on a named port and wait for a connection attempt.
30 *
31 * ARGUMENTS
32 * PortHandle [IN] LPC port to listen on.
33 *
34 * ConnectMsg [IN] User provided storage for a
35 * possible connection request LPC message.
36 *
37 * RETURN VALUE
38 * STATUS_SUCCESS if a connection request is received
39 * successfully; otherwise an error code.
40 *
41 * The buffer ConnectMessage is filled with the connection
42 * request message queued by NtConnectPort() in PortHandle.
43 *
44 * NOTE
45 *
46 */
47 EXPORTED NTSTATUS STDCALL
48 NtListenPort (IN HANDLE PortHandle,
49 IN PLPC_MESSAGE ConnectMsg)
50 {
51 NTSTATUS Status;
52
53 /*
54 * Wait forever for a connection request.
55 */
56 for (;;)
57 {
58 Status = NtReplyWaitReceivePort(PortHandle,
59 NULL,
60 NULL,
61 ConnectMsg);
62 /*
63 * Accept only LPC_CONNECTION_REQUEST requests.
64 * Drop any other message.
65 */
66 if (!NT_SUCCESS(Status) ||
67 LPC_CONNECTION_REQUEST == ConnectMsg->MessageType)
68 {
69 DPRINT("Got message (type %x)\n", LPC_CONNECTION_REQUEST);
70 break;
71 }
72 DPRINT("Got message (type %x)\n", ConnectMsg->MessageType);
73 }
74
75 return (Status);
76 }
77
78
79 /* EOF */