cb340033f858e035af8c72879700e03c51f1a467
[reactos.git] / reactos / ntoskrnl / lpc / port.c
1 /* $Id: port.c,v 1.18 2004/08/04 12:50:42 ea Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/port.c
6 * PURPOSE: Communication mechanism
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 *
11 * 2000-06-04 (ea)
12 * ntoskrnl/nt/port.c moved in ntoskrnl/lpc/port.c
13 */
14
15 /* INCLUDES *****************************************************************/
16
17 #include <limits.h>
18
19 #include <ddk/ntddk.h>
20 #include <internal/ob.h>
21 #include <internal/port.h>
22 #include <internal/dbg.h>
23 #include <internal/pool.h>
24 #include <rosrtl/string.h>
25
26 #define NDEBUG
27 #include <internal/debug.h>
28
29
30 /* GLOBALS *******************************************************************/
31
32 POBJECT_TYPE ExPortType = NULL;
33 ULONG EiNextLpcMessageId = 0;
34
35 static GENERIC_MAPPING ExpPortMapping = {
36 STANDARD_RIGHTS_READ,
37 STANDARD_RIGHTS_WRITE,
38 0,
39 PORT_ALL_ACCESS};
40
41 /* FUNCTIONS *****************************************************************/
42
43
44 NTSTATUS INIT_FUNCTION
45 NiInitPort (VOID)
46 {
47 ExPortType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
48
49 RtlRosInitUnicodeStringFromLiteral(&ExPortType->TypeName,L"Port");
50
51 ExPortType->Tag = TAG('L', 'P', 'R', 'T');
52 ExPortType->MaxObjects = ULONG_MAX;
53 ExPortType->MaxHandles = ULONG_MAX;
54 ExPortType->TotalObjects = 0;
55 ExPortType->TotalHandles = 0;
56 ExPortType->PagedPoolCharge = 0;
57 ExPortType->NonpagedPoolCharge = sizeof(EPORT);
58 ExPortType->Mapping = &ExpPortMapping;
59 ExPortType->Dump = NULL;
60 ExPortType->Open = NULL;
61 ExPortType->Close = NiClosePort;
62 ExPortType->Delete = NiDeletePort;
63 ExPortType->Parse = NULL;
64 ExPortType->Security = NULL;
65 ExPortType->QueryName = NULL;
66 ExPortType->OkayToClose = NULL;
67 ExPortType->Create = NiCreatePort;
68 ExPortType->DuplicationNotify = NULL;
69
70 ObpCreateTypeObject(ExPortType);
71
72 EiNextLpcMessageId = 0;
73
74 return(STATUS_SUCCESS);
75 }
76
77
78 /**********************************************************************
79 * NAME INTERNAL
80 * NiInitializePort/3
81 *
82 * DESCRIPTION
83 * Initialize the EPORT object attributes. The Port
84 * object enters the inactive state.
85 *
86 * ARGUMENTS
87 * Port Pointer to an EPORT object to initialize.
88 *
89 * RETURN VALUE
90 * STATUS_SUCCESS if initialization succedeed. An error code
91 * otherwise.
92 */
93 NTSTATUS STDCALL
94 NiInitializePort (IN OUT PEPORT Port,
95 IN USHORT Type,
96 IN PEPORT Parent OPTIONAL)
97 {
98 if ((Type != EPORT_TYPE_SERVER_RQST_PORT) &&
99 (Type != EPORT_TYPE_SERVER_COMM_PORT) &&
100 (Type != EPORT_TYPE_CLIENT_COMM_PORT))
101 {
102 return STATUS_INVALID_PARAMETER_2;
103 }
104 memset (Port, 0, sizeof(EPORT));
105 KeInitializeSpinLock (& Port->Lock);
106 KeInitializeSemaphore( &Port->Semaphore, 0, LONG_MAX );
107 Port->RequestPort = Parent;
108 Port->OtherPort = NULL;
109 Port->QueueLength = 0;
110 Port->ConnectQueueLength = 0;
111 Port->Type = Type;
112 Port->State = EPORT_INACTIVE;
113 InitializeListHead (& Port->QueueListHead);
114 InitializeListHead (& Port->ConnectQueueListHead);
115
116 return (STATUS_SUCCESS);
117 }
118
119
120 /* MISCELLANEA SYSTEM SERVICES */
121
122
123 /**********************************************************************
124 * NAME SYSTEM
125 * NtImpersonateClientOfPort/2
126 *
127 * DESCRIPTION
128 *
129 * ARGUMENTS
130 * PortHandle,
131 * ClientMessage
132 *
133 * RETURN VALUE
134 */
135 NTSTATUS STDCALL
136 NtImpersonateClientOfPort (HANDLE PortHandle,
137 PLPC_MESSAGE ClientMessage)
138 {
139 UNIMPLEMENTED;
140 return(STATUS_NOT_IMPLEMENTED);
141 }
142
143 /* EOF */