winex11: Remove an unused variable.
[wine] / dlls / rpcrt4 / rpc_binding.h
1 /*
2  * RPC binding API
3  *
4  * Copyright 2001 Ove Kåven, TransGaming Technologies
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_RPC_BINDING_H
22 #define __WINE_RPC_BINDING_H
23
24 #include "wine/rpcss_shared.h"
25 #include "security.h"
26 #include "wine/list.h"
27
28
29 typedef struct _RpcAuthInfo
30 {
31   LONG refs;
32
33   ULONG AuthnLevel;
34   ULONG AuthnSvc;
35   CredHandle cred;
36   TimeStamp exp;
37   ULONG cbMaxToken;
38   /* the auth identity pointer that the application passed us (freed by application) */
39   RPC_AUTH_IDENTITY_HANDLE *identity;
40   /* our copy of NT auth identity structure, if the authentication service
41    * takes an NT auth identity */
42   SEC_WINNT_AUTH_IDENTITY_W *nt_identity;
43 } RpcAuthInfo;
44
45 typedef struct _RpcQualityOfService
46 {
47     LONG refs;
48
49     RPC_SECURITY_QOS_V2_W *qos;
50 } RpcQualityOfService;
51
52 typedef struct _RpcAssoc
53 {
54     struct list entry; /* entry in the global list of associations */
55     LONG refs;
56
57     LPSTR Protseq;
58     LPSTR NetworkAddr;
59     LPSTR Endpoint;
60     LPWSTR NetworkOptions;
61
62     /* id of this association group */
63     ULONG assoc_group_id;
64
65     CRITICAL_SECTION cs;
66     struct list connection_pool;
67 } RpcAssoc;
68
69 struct connection_ops;
70
71 typedef struct _RpcConnection
72 {
73   struct _RpcConnection* Next;
74   BOOL server;
75   LPSTR NetworkAddr;
76   LPSTR Endpoint;
77   LPWSTR NetworkOptions;
78   const struct connection_ops *ops;
79   USHORT MaxTransmissionSize;
80   /* The active interface bound to server. */
81   RPC_SYNTAX_IDENTIFIER ActiveInterface;
82   USHORT NextCallId;
83
84   /* authentication */
85   CtxtHandle ctx;
86   TimeStamp exp;
87   ULONG attr;
88   RpcAuthInfo *AuthInfo;
89   ULONG encryption_auth_len;
90   ULONG signature_auth_len;
91   RpcQualityOfService *QOS;
92
93   /* client-only */
94   struct list conn_pool_entry;
95   ULONG assoc_group_id; /* association group returned during binding */
96 } RpcConnection;
97
98 struct connection_ops {
99   const char *name;
100   unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
101   RpcConnection *(*alloc)(void);
102   RPC_STATUS (*open_connection_client)(RpcConnection *conn);
103   RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
104   int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
105   int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
106   int (*close)(RpcConnection *conn);
107   void (*cancel_call)(RpcConnection *conn);
108   size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
109   RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
110 };
111
112 /* don't know what MS's structure looks like */
113 typedef struct _RpcBinding
114 {
115   LONG refs;
116   struct _RpcBinding* Next;
117   BOOL server;
118   UUID ObjectUuid;
119   LPSTR Protseq;
120   LPSTR NetworkAddr;
121   LPSTR Endpoint;
122   LPWSTR NetworkOptions;
123   RPC_BLOCKING_FN BlockingFn;
124   ULONG ServerTid;
125   RpcConnection* FromConn;
126   RpcAssoc *Assoc;
127
128   /* authentication */
129   RpcAuthInfo *AuthInfo;
130   RpcQualityOfService *QOS;
131 } RpcBinding;
132
133 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
134 LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len);
135 LPSTR RPCRT4_strdupWtoA(LPCWSTR src);
136 LPWSTR RPCRT4_strdupAtoW(LPCSTR src);
137 void RPCRT4_strfree(LPSTR src);
138
139 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
140 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
141
142 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
143 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
144 BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthInfo2);
145 ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos);
146 ULONG RpcQualityOfService_Release(RpcQualityOfService *qos);
147 BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2);
148
149 RPC_STATUS RPCRT4_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAssoc **assoc);
150 RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc, const RPC_SYNTAX_IDENTIFIER *InterfaceId, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, RpcAuthInfo *AuthInfo, RpcQualityOfService *QOS, RpcConnection **Connection);
151 void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection);
152 ULONG RpcAssoc_Release(RpcAssoc *assoc);
153
154 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS);
155 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
156 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection);
157 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
158 RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
159
160 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint);
161 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid);
162 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
163 RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
164 RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
165 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
166                               const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId);
167 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
168 BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPCSS_NP_REPLY reply);
169 HANDLE RPCRT4_GetMasterMutex(void);
170 HANDLE RPCRT4_RpcssNPConnect(void);
171
172 static inline const char *rpcrt4_conn_get_name(const RpcConnection *Connection)
173 {
174   return Connection->ops->name;
175 }
176
177 static inline int rpcrt4_conn_read(RpcConnection *Connection,
178                      void *buffer, unsigned int len)
179 {
180   return Connection->ops->read(Connection, buffer, len);
181 }
182
183 static inline int rpcrt4_conn_write(RpcConnection *Connection,
184                      const void *buffer, unsigned int len)
185 {
186   return Connection->ops->write(Connection, buffer, len);
187 }
188
189 static inline int rpcrt4_conn_close(RpcConnection *Connection)
190 {
191   return Connection->ops->close(Connection);
192 }
193
194 static inline void rpcrt4_conn_cancel_call(RpcConnection *Connection)
195 {
196   Connection->ops->cancel_call(Connection);
197 }
198
199 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
200 {
201   return old_conn->ops->handoff(old_conn, new_conn);
202 }
203
204 /* floors 3 and up */
205 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint);
206 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint);
207
208 void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection);
209
210 #endif