d370116b4e0fb5ced941720efa27b1b5b24a9e15
[reactos.git] / reactos / ntoskrnl / lpc / port.c
1 /* $Id: port.c,v 1.17 2004/02/02 23:48: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 EiNextLpcMessageId = 0;
71
72 return(STATUS_SUCCESS);
73 }
74
75
76 /**********************************************************************
77 * NAME INTERNAL
78 * NiInitializePort
79 *
80 * DESCRIPTION
81 * Initialize the EPORT object attributes. The Port
82 * object enters the inactive state.
83 *
84 * ARGUMENTS
85 * Port Pointer to an EPORT object to initialize.
86 *
87 * RETURN VALUE
88 * STATUS_SUCCESS if initialization succedeed. An error code
89 * otherwise.
90 */
91 NTSTATUS STDCALL
92 NiInitializePort (IN OUT PEPORT Port,
93 IN USHORT Type,
94 IN PEPORT Parent OPTIONAL)
95 {
96 if ((Type != EPORT_TYPE_SERVER_RQST_PORT) &&
97 (Type != EPORT_TYPE_SERVER_COMM_PORT) &&
98 (Type != EPORT_TYPE_CLIENT_COMM_PORT))
99 {
100 return STATUS_INVALID_PARAMETER_2;
101 }
102 memset (Port, 0, sizeof(EPORT));
103 KeInitializeSpinLock (& Port->Lock);
104 KeInitializeSemaphore( &Port->Semaphore, 0, LONG_MAX );
105 Port->RequestPort = Parent;
106 Port->OtherPort = NULL;
107 Port->QueueLength = 0;
108 Port->ConnectQueueLength = 0;
109 Port->Type = Type;
110 Port->State = EPORT_INACTIVE;
111 InitializeListHead (& Port->QueueListHead);
112 InitializeListHead (& Port->ConnectQueueListHead);
113
114 return (STATUS_SUCCESS);
115 }
116
117
118 /* MISCELLANEA SYSTEM SERVICES */
119
120
121 /**********************************************************************
122 * NAME SYSTEM
123 * NtImpersonateClientOfPort@8
124 *
125 * DESCRIPTION
126 *
127 * ARGUMENTS
128 * PortHandle,
129 * ClientMessage
130 *
131 * RETURN VALUE
132 */
133 NTSTATUS STDCALL
134 NtImpersonateClientOfPort (HANDLE PortHandle,
135 PLPC_MESSAGE ClientMessage)
136 {
137 UNIMPLEMENTED;
138 return(STATUS_NOT_IMPLEMENTED);
139 }
140
141
142
143 /* EOF */