Reverted latest changes.
[reactos.git] / reactos / ntoskrnl / lpc / create.c
1 /* $Id: create.c,v 1.9 2002/09/08 10:23:32 chorns Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/create.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/port.h>
16 #include <internal/dbg.h>
17
18 #define NDEBUG
19 #include <internal/debug.h>
20
21 STATIC NTSTATUS STDCALL
22 VerifyCreateParameters (IN PHANDLE PortHandle,
23 IN POBJECT_ATTRIBUTES ObjectAttributes,
24 IN ULONG MaxConnectInfoLength,
25 IN ULONG MaxDataLength,
26 IN ULONG Reserved)
27 {
28 if (NULL == PortHandle)
29 {
30 return (STATUS_INVALID_PARAMETER_1);
31 }
32 if (NULL == ObjectAttributes)
33 {
34 return (STATUS_INVALID_PARAMETER_2);
35 }
36 if ((ObjectAttributes->Attributes & OBJ_OPENLINK)
37 || (ObjectAttributes->Attributes & OBJ_OPENIF)
38 || (ObjectAttributes->Attributes & OBJ_EXCLUSIVE)
39 || (ObjectAttributes->Attributes & OBJ_PERMANENT)
40 || (ObjectAttributes->Attributes & OBJ_INHERIT))
41 {
42 return (STATUS_INVALID_PORT_ATTRIBUTES);
43 }
44 if (MaxConnectInfoLength > 0x104) /* FIXME: use a macro! */
45 {
46 return (STATUS_INVALID_PARAMETER_3);
47 }
48 if (MaxDataLength > 0x148) /* FIXME: use a macro! */
49 {
50 return (STATUS_INVALID_PARAMETER_4);
51 }
52 /* FIXME: some checking is done also on Reserved */
53 return (STATUS_SUCCESS);
54 }
55
56
57 NTSTATUS STDCALL
58 NiCreatePort (PVOID ObjectBody,
59 PVOID Parent,
60 PWSTR RemainingPath,
61 POBJECT_ATTRIBUTES ObjectAttributes)
62 {
63 if (RemainingPath == NULL)
64 {
65 return (STATUS_SUCCESS);
66 }
67
68 if (wcschr(RemainingPath+1, '\\') != NULL)
69 {
70 return (STATUS_UNSUCCESSFUL);
71 }
72
73 return (STATUS_SUCCESS);
74 }
75
76
77 /**********************************************************************
78 * NAME EXPORTED
79 * NtCreatePort@20
80 *
81 * DESCRIPTION
82 *
83 * ARGUMENTS
84 * PortHandle,
85 * ObjectAttributes,
86 * MaxConnectInfoLength,
87 * MaxDataLength,
88 * Reserved
89 *
90 * RETURN VALUE
91 *
92 */
93 EXPORTED NTSTATUS STDCALL
94 NtCreatePort (PHANDLE PortHandle,
95 POBJECT_ATTRIBUTES ObjectAttributes,
96 ULONG MaxConnectInfoLength,
97 ULONG MaxDataLength,
98 ULONG Reserved)
99 {
100 PEPORT Port;
101 NTSTATUS Status;
102
103 DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer);
104
105 /* Verify parameters */
106 Status = VerifyCreateParameters (PortHandle,
107 ObjectAttributes,
108 MaxConnectInfoLength,
109 MaxDataLength,
110 Reserved);
111 if (!NT_SUCCESS(Status))
112 {
113 return (Status);
114 }
115 /* Ask Ob to create the object */
116 Status = ObCreateObject (PortHandle,
117 PORT_ALL_ACCESS,
118 ObjectAttributes,
119 ExPortType,
120 (PVOID*)&Port);
121 if (!NT_SUCCESS(Status))
122 {
123 return (Status);
124 }
125
126 Status = NiInitializePort (Port);
127 Port->MaxConnectInfoLength = 260; /* FIXME: use a macro! */
128 Port->MaxDataLength = 328; /* FIXME: use a macro! */
129
130 ObDereferenceObject (Port);
131
132 return (Status);
133 }
134
135 /**********************************************************************
136 * NAME EXPORTED
137 * NtCreateWaitablePort@20
138 *
139 * DESCRIPTION
140 * Waitable ports can be connected to with NtSecureConnectPort.
141 * No port interface can be used with waitable ports but
142 * NtReplyWaitReceivePort and NtReplyWaitReceivePortEx.
143 * Present only in w2k+.
144 *
145 * ARGUMENTS
146 * PortHandle,
147 * ObjectAttributes,
148 * MaxConnectInfoLength,
149 * MaxDataLength,
150 * Reserved
151 *
152 * RETURN VALUE
153 *
154 */
155 EXPORTED NTSTATUS STDCALL
156 NtCreateWaitablePort (OUT PHANDLE PortHandle,
157 IN POBJECT_ATTRIBUTES ObjectAttributes,
158 IN ULONG MaxConnectInfoLength,
159 IN ULONG MaxDataLength,
160 IN ULONG Reserved)
161 {
162 NTSTATUS Status;
163
164 /* Verify parameters */
165 Status = VerifyCreateParameters (PortHandle,
166 ObjectAttributes,
167 MaxConnectInfoLength,
168 MaxDataLength,
169 Reserved);
170 if (STATUS_SUCCESS != Status)
171 {
172 return (Status);
173 }
174 /* TODO */
175 return (STATUS_NOT_IMPLEMENTED);
176 }
177
178 /* EOF */