c987f67c811e356aad3b3fee799a52ee284e2bb3
[reactos.git] / reactos / ntoskrnl / include / internal / port.h
1 #ifndef __INCLUDE_INTERNAL_PORT_H
2 #define __INCLUDE_INTERNAL_PORT_H
3
4 typedef struct _EPORT_LISTENER
5 {
6 HANDLE ListenerPid;
7 LIST_ENTRY ListenerListEntry;
8 } EPORT_LISTENER, *PEPORT_LISTENER;
9
10 typedef struct _EPORT
11 {
12 KSPIN_LOCK Lock;
13 KSEMAPHORE Semaphore;
14
15 USHORT Type;
16 USHORT State;
17
18 struct _EPORT * RequestPort;
19 struct _EPORT * OtherPort;
20
21 ULONG QueueLength;
22 LIST_ENTRY QueueListHead;
23
24 ULONG ConnectQueueLength;
25 LIST_ENTRY ConnectQueueListHead;
26
27 ULONG MaxDataLength;
28 ULONG MaxConnectInfoLength;
29 ULONG MaxPoolUsage; /* size of NP zone */
30 } EPORT, * PEPORT;
31
32
33 typedef struct _EPORT_TERMINATION_REQUEST
34 {
35 LIST_ENTRY ThreadListEntry;
36 PEPORT Port;
37 } EPORT_TERMINATION_REQUEST, *PEPORT_TERMINATION_REQUEST;
38
39
40 typedef struct _EPORT_CONNECT_REQUEST_MESSAGE
41 {
42 LPC_MESSAGE MessageHeader;
43 PEPROCESS ConnectingProcess;
44 struct _SECTION_OBJECT* SendSectionObject;
45 LARGE_INTEGER SendSectionOffset;
46 ULONG SendViewSize;
47 ULONG ConnectDataLength;
48 UCHAR ConnectData[0];
49 } EPORT_CONNECT_REQUEST_MESSAGE, *PEPORT_CONNECT_REQUEST_MESSAGE;
50
51 typedef struct _EPORT_CONNECT_REPLY_MESSAGE
52 {
53 LPC_MESSAGE MessageHeader;
54 PVOID SendServerViewBase;
55 ULONG ReceiveClientViewSize;
56 PVOID ReceiveClientViewBase;
57 ULONG MaximumMessageSize;
58 ULONG ConnectDataLength;
59 UCHAR ConnectData[0];
60 } EPORT_CONNECT_REPLY_MESSAGE, *PEPORT_CONNECT_REPLY_MESSAGE;
61
62 NTSTATUS STDCALL
63 LpcRequestPort (PEPORT Port,
64 PLPC_MESSAGE LpcMessage);
65 NTSTATUS
66 STDCALL
67 LpcSendTerminationPort (PEPORT Port,
68 LARGE_INTEGER CreationTime);
69
70 /* EPORT.Type */
71
72 #define EPORT_TYPE_SERVER_RQST_PORT (0)
73 #define EPORT_TYPE_SERVER_COMM_PORT (1)
74 #define EPORT_TYPE_CLIENT_COMM_PORT (2)
75
76 /* EPORT.State */
77
78 #define EPORT_INACTIVE (0)
79 #define EPORT_WAIT_FOR_CONNECT (1)
80 #define EPORT_WAIT_FOR_ACCEPT (2)
81 #define EPORT_WAIT_FOR_COMPLETE_SRV (3)
82 #define EPORT_WAIT_FOR_COMPLETE_CLT (4)
83 #define EPORT_CONNECTED_CLIENT (5)
84 #define EPORT_CONNECTED_SERVER (6)
85 #define EPORT_DISCONNECTED (7)
86
87 /* Pool Tags */
88
89 #define TAG_LPC_MESSAGE TAG('L', 'p', 'c', 'M')
90 #define TAG_LPC_ZONE TAG('L', 'p', 'c', 'Z')
91
92
93 typedef struct _QUEUEDMESSAGE
94 {
95 PEPORT Sender;
96 LIST_ENTRY QueueListEntry;
97 LPC_MESSAGE Message;
98 UCHAR MessageData [MAX_MESSAGE_DATA];
99 } QUEUEDMESSAGE, *PQUEUEDMESSAGE;
100
101 /* Code in ntoskrnl/lpc/close.h */
102
103 VOID STDCALL
104 NiClosePort (PVOID ObjectBody,
105 ULONG HandleCount);
106 VOID STDCALL
107 NiDeletePort (IN PVOID ObjectBody);
108
109 /* Code in ntoskrnl/lpc/queue.c */
110
111 VOID STDCALL
112 EiEnqueueConnectMessagePort (IN OUT PEPORT Port,
113 IN PQUEUEDMESSAGE Message);
114 VOID STDCALL
115 EiEnqueueMessagePort (IN OUT PEPORT Port,
116 IN PQUEUEDMESSAGE Message);
117 VOID STDCALL
118 EiEnqueueMessageAtHeadPort (IN OUT PEPORT Port,
119 IN PQUEUEDMESSAGE Message);
120 PQUEUEDMESSAGE
121 STDCALL
122 EiDequeueConnectMessagePort (IN OUT PEPORT Port);
123 PQUEUEDMESSAGE STDCALL
124 EiDequeueMessagePort (IN OUT PEPORT Port);
125
126 /* Code in ntoskrnl/lpc/create.c */
127
128 NTSTATUS STDCALL
129 NiCreatePort (PVOID ObjectBody,
130 PVOID Parent,
131 PWSTR RemainingPath,
132 POBJECT_ATTRIBUTES ObjectAttributes);
133
134 /* Code in ntoskrnl/lpc/port.c */
135
136 NTSTATUS STDCALL
137 LpcpInitializePort (IN OUT PEPORT Port,
138 IN USHORT Type,
139 IN PEPORT Parent OPTIONAL);
140 NTSTATUS
141 LpcpInitSystem (VOID);
142
143 extern POBJECT_TYPE LpcPortObjectType;
144 extern ULONG LpcpNextMessageId;
145 extern FAST_MUTEX LpcpLock;
146
147 /* Code in ntoskrnl/lpc/reply.c */
148
149 NTSTATUS STDCALL
150 EiReplyOrRequestPort (IN PEPORT Port,
151 IN PLPC_MESSAGE LpcReply,
152 IN ULONG MessageType,
153 IN PEPORT Sender);
154
155
156 #endif /* __INCLUDE_INTERNAL_PORT_H */