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