msi/tests: automation: Session::Installer conformance test.
[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 } RpcAuthInfo;
39
40 typedef struct _RpcQualityOfService
41 {
42     LONG refs;
43
44     RPC_SECURITY_QOS_V2_W *qos;
45 } RpcQualityOfService;
46
47 typedef struct _RpcAssoc
48 {
49     struct list entry; /* entry in the global list of associations */
50     LONG refs;
51
52     LPSTR Protseq;
53     LPSTR NetworkAddr;
54     LPSTR Endpoint;
55     LPWSTR NetworkOptions;
56     RpcAuthInfo *AuthInfo;
57
58     CRITICAL_SECTION cs;
59     struct list connection_pool;
60 } RpcAssoc;
61
62 struct connection_ops;
63
64 typedef struct _RpcConnection
65 {
66   struct _RpcConnection* Next;
67   struct _RpcBinding* Used;
68   BOOL server;
69   LPSTR NetworkAddr;
70   LPSTR Endpoint;
71   LPWSTR NetworkOptions;
72   const struct connection_ops *ops;
73   USHORT MaxTransmissionSize;
74   /* The active interface bound to server. */
75   RPC_SYNTAX_IDENTIFIER ActiveInterface;
76   USHORT NextCallId;
77
78   /* authentication */
79   CtxtHandle ctx;
80   TimeStamp exp;
81   ULONG attr;
82   RpcAuthInfo *AuthInfo;
83   ULONG encryption_auth_len;
84   ULONG signature_auth_len;
85   RpcQualityOfService *QOS;
86
87   /* client-only */
88   struct list conn_pool_entry;
89 } RpcConnection;
90
91 struct connection_ops {
92   const char *name;
93   unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
94   RpcConnection *(*alloc)(void);
95   RPC_STATUS (*open_connection_client)(RpcConnection *conn);
96   RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
97   int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
98   int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
99   int (*close)(RpcConnection *conn);
100   size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
101   RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
102 };
103
104 /* don't know what MS's structure looks like */
105 typedef struct _RpcBinding
106 {
107   LONG refs;
108   struct _RpcBinding* Next;
109   BOOL server;
110   UUID ObjectUuid;
111   LPSTR Protseq;
112   LPSTR NetworkAddr;
113   LPSTR Endpoint;
114   LPWSTR NetworkOptions;
115   RPC_BLOCKING_FN BlockingFn;
116   ULONG ServerTid;
117   RpcConnection* FromConn;
118   RpcAssoc *Assoc;
119
120   /* authentication */
121   RpcAuthInfo *AuthInfo;
122   RpcQualityOfService *QOS;
123 } RpcBinding;
124
125 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
126 LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len);
127 LPSTR RPCRT4_strdupWtoA(LPCWSTR src);
128 LPWSTR RPCRT4_strdupAtoW(LPCSTR src);
129 void RPCRT4_strfree(LPSTR src);
130
131 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
132 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
133
134 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
135 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
136 ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos);
137 ULONG RpcQualityOfService_Release(RpcQualityOfService *qos);
138
139 RPC_STATUS RPCRT4_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAssoc **assoc);
140 RpcConnection *RpcAssoc_GetIdleConnection(RpcAssoc *assoc, const RPC_SYNTAX_IDENTIFIER *InterfaceId, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RpcAuthInfo *AuthInfo, const RpcQualityOfService *QOS);
141 void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection);
142 ULONG RpcAssoc_Release(RpcAssoc *assoc);
143
144 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS, RpcBinding* Binding);
145 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
146 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection);
147 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
148 RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
149
150 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint);
151 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid);
152 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
153 RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
154 RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
155 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, PRPC_SYNTAX_IDENTIFIER TransferSyntax, PRPC_SYNTAX_IDENTIFIER InterfaceId);
156 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
157 BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPCSS_NP_REPLY reply);
158 HANDLE RPCRT4_GetMasterMutex(void);
159 HANDLE RPCRT4_RpcssNPConnect(void);
160
161 static inline const char *rpcrt4_conn_get_name(RpcConnection *Connection)
162 {
163   return Connection->ops->name;
164 }
165
166 static inline int rpcrt4_conn_read(RpcConnection *Connection,
167                      void *buffer, unsigned int len)
168 {
169   return Connection->ops->read(Connection, buffer, len);
170 }
171
172 static inline int rpcrt4_conn_write(RpcConnection *Connection,
173                      const void *buffer, unsigned int len)
174 {
175   return Connection->ops->write(Connection, buffer, len);
176 }
177
178 static inline int rpcrt4_conn_close(RpcConnection *Connection)
179 {
180   return Connection->ops->close(Connection);
181 }
182
183 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
184 {
185   return old_conn->ops->handoff(old_conn, new_conn);
186 }
187
188 /* floors 3 and up */
189 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint);
190 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint);
191
192 #endif