migrate substitution keywords to SVN
[reactos.git] / reactos / ntoskrnl / lpc / listen.c
1 /* $Id$
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 <ntoskrnl.h>
15 #define NDEBUG
16 #include <internal/debug.h>
17
18 /* FUNCTIONS *****************************************************************/
19
20 /**********************************************************************
21 * NAME EXPORTED
22 * NtListenPort@8
23 *
24 * DESCRIPTION
25 * Listen on a named port and wait for a connection attempt.
26 *
27 * ARGUMENTS
28 * PortHandle [IN] LPC port to listen on.
29 *
30 * ConnectMsg [IN] User provided storage for a
31 * possible connection request LPC message.
32 *
33 * RETURN VALUE
34 * STATUS_SUCCESS if a connection request is received
35 * successfully; otherwise an error code.
36 *
37 * The buffer ConnectMessage is filled with the connection
38 * request message queued by NtConnectPort() in PortHandle.
39 *
40 * NOTE
41 */
42 /*EXPORTED*/ NTSTATUS STDCALL
43 NtListenPort (IN HANDLE PortHandle,
44 IN PLPC_MESSAGE ConnectMsg)
45 {
46 NTSTATUS Status;
47
48 /*
49 * Wait forever for a connection request.
50 */
51 for (;;)
52 {
53 Status = NtReplyWaitReceivePort(PortHandle,
54 NULL,
55 NULL,
56 ConnectMsg);
57 /*
58 * Accept only LPC_CONNECTION_REQUEST requests.
59 * Drop any other message.
60 */
61 if (!NT_SUCCESS(Status) ||
62 LPC_CONNECTION_REQUEST == ConnectMsg->MessageType)
63 {
64 DPRINT("Got message (type %x)\n", LPC_CONNECTION_REQUEST);
65 break;
66 }
67 DPRINT("Got message (type %x)\n", ConnectMsg->MessageType);
68 }
69
70 return (Status);
71 }
72
73
74 /* EOF */