wsdapi/tests: Add tests for AppSequence in Probe message.
[wine.git] / dlls / rpcrt4 / rpc_binding.h
blobca5388789fe54bbd9724745bf0995ebf240dfe73
1 /*
2 * RPC binding API
4 * Copyright 2001 Ove Kåven, TransGaming Technologies
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.
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.
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
21 #ifndef __WINE_RPC_BINDING_H
22 #define __WINE_RPC_BINDING_H
24 #include "rpcndr.h"
25 #include "security.h"
26 #include "wine/list.h"
27 #include "rpc_defs.h"
30 enum secure_packet_direction
32 SECURE_PACKET_SEND,
33 SECURE_PACKET_RECEIVE
36 typedef struct _RpcAuthInfo
38 LONG refs;
40 ULONG AuthnLevel;
41 ULONG AuthnSvc;
42 CredHandle cred;
43 TimeStamp exp;
44 ULONG cbMaxToken;
45 /* the auth identity pointer that the application passed us (freed by application) */
46 RPC_AUTH_IDENTITY_HANDLE *identity;
47 /* our copy of NT auth identity structure, if the authentication service
48 * takes an NT auth identity */
49 SEC_WINNT_AUTH_IDENTITY_W *nt_identity;
50 LPWSTR server_principal_name;
51 } RpcAuthInfo;
53 typedef struct _RpcQualityOfService
55 LONG refs;
57 RPC_SECURITY_QOS_V2_W *qos;
58 } RpcQualityOfService;
60 struct connection_ops;
62 typedef struct _RpcConnection
64 LONG ref;
65 BOOL server;
66 HANDLE wait_release;
67 LPSTR NetworkAddr;
68 LPSTR Endpoint;
69 LPWSTR NetworkOptions;
70 const struct connection_ops *ops;
71 USHORT MaxTransmissionSize;
73 /* authentication */
74 CtxtHandle ctx;
75 TimeStamp exp;
76 ULONG attr;
77 RpcAuthInfo *AuthInfo;
78 ULONG auth_context_id;
79 ULONG encryption_auth_len;
80 ULONG signature_auth_len;
81 RpcQualityOfService *QOS;
82 LPWSTR CookieAuth;
84 /* client-only */
85 struct list conn_pool_entry;
86 ULONG assoc_group_id; /* association group returned during binding */
87 RPC_ASYNC_STATE *async_state;
88 struct _RpcAssoc *assoc; /* association this connection is part of */
90 /* server-only */
91 /* The active interface bound to server. */
92 RPC_SYNTAX_IDENTIFIER ActiveInterface;
93 USHORT NextCallId;
94 struct list protseq_entry;
95 struct _RpcServerProtseq *protseq;
96 struct _RpcBinding *server_binding;
97 } RpcConnection;
99 struct connection_ops {
100 const char *name;
101 unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
102 RpcConnection *(*alloc)(void);
103 RPC_STATUS (*open_connection_client)(RpcConnection *conn);
104 RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
105 int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
106 int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
107 int (*close)(RpcConnection *conn);
108 void (*close_read)(RpcConnection *conn);
109 void (*cancel_call)(RpcConnection *conn);
110 RPC_STATUS (*is_server_listening)(const char *endpoint);
111 int (*wait_for_incoming_data)(RpcConnection *conn);
112 size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
113 RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
114 RPC_STATUS (*receive_fragment)(RpcConnection *conn, RpcPktHdr **Header, void **Payload);
115 BOOL (*is_authorized)(RpcConnection *conn);
116 RPC_STATUS (*authorize)(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len);
117 RPC_STATUS (*secure_packet)(RpcConnection *Connection, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size);
118 RPC_STATUS (*impersonate_client)(RpcConnection *conn);
119 RPC_STATUS (*revert_to_self)(RpcConnection *conn);
120 RPC_STATUS (*inquire_auth_client)(RpcConnection *, RPC_AUTHZ_HANDLE *, RPC_WSTR *, ULONG *, ULONG *, ULONG *, ULONG);
123 /* don't know what MS's structure looks like */
124 typedef struct _RpcBinding
126 LONG refs;
127 struct _RpcBinding* Next;
128 BOOL server;
129 UUID ObjectUuid;
130 LPSTR Protseq;
131 LPSTR NetworkAddr;
132 LPSTR Endpoint;
133 LPWSTR NetworkOptions;
134 RPC_BLOCKING_FN BlockingFn;
135 ULONG ServerTid;
136 RpcConnection* FromConn;
137 struct _RpcAssoc *Assoc;
139 /* authentication */
140 RpcAuthInfo *AuthInfo;
141 RpcQualityOfService *QOS;
142 LPWSTR CookieAuth;
143 } RpcBinding;
145 LPSTR RPCRT4_strndupA(LPCSTR src, INT len) DECLSPEC_HIDDEN;
146 LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len) DECLSPEC_HIDDEN;
147 LPSTR RPCRT4_strdupWtoA(LPCWSTR src) DECLSPEC_HIDDEN;
148 LPWSTR RPCRT4_strdupAtoW(LPCSTR src) DECLSPEC_HIDDEN;
149 void RPCRT4_strfree(LPSTR src) DECLSPEC_HIDDEN;
151 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
152 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
154 RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret) DECLSPEC_HIDDEN;
155 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN;
156 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN;
157 BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthInfo2) DECLSPEC_HIDDEN;
158 ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
159 ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
160 BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2) DECLSPEC_HIDDEN;
162 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq,
163 LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo,
164 RpcQualityOfService *QOS, LPCWSTR CookieAuth) DECLSPEC_HIDDEN;
165 RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn ) DECLSPEC_HIDDEN;
166 void RPCRT4_ReleaseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
167 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
168 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
169 RPC_STATUS RPCRT4_IsServerListening(const char *protseq, const char *endpoint) DECLSPEC_HIDDEN;
171 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint) DECLSPEC_HIDDEN;
172 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid) DECLSPEC_HIDDEN;
173 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection) DECLSPEC_HIDDEN;
174 void RPCRT4_AddRefBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
175 RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
176 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
177 const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId) DECLSPEC_HIDDEN;
178 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection) DECLSPEC_HIDDEN;
180 void rpcrt4_conn_release_and_wait(RpcConnection *connection) DECLSPEC_HIDDEN;
182 static inline const char *rpcrt4_conn_get_name(const RpcConnection *Connection)
184 return Connection->ops->name;
187 static inline int rpcrt4_conn_read(RpcConnection *Connection,
188 void *buffer, unsigned int len)
190 return Connection->ops->read(Connection, buffer, len);
193 static inline int rpcrt4_conn_write(RpcConnection *Connection,
194 const void *buffer, unsigned int len)
196 return Connection->ops->write(Connection, buffer, len);
199 static inline int rpcrt4_conn_close(RpcConnection *Connection)
201 return Connection->ops->close(Connection);
204 static inline void rpcrt4_conn_close_read(RpcConnection *connection)
206 connection->ops->close_read(connection);
209 static inline void rpcrt4_conn_cancel_call(RpcConnection *Connection)
211 Connection->ops->cancel_call(Connection);
214 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
216 return old_conn->ops->handoff(old_conn, new_conn);
219 static inline BOOL rpcrt4_conn_is_authorized(RpcConnection *Connection)
221 return Connection->ops->is_authorized(Connection);
224 static inline RPC_STATUS rpcrt4_conn_authorize(
225 RpcConnection *conn, BOOL first_time, unsigned char *in_buffer,
226 unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len)
228 return conn->ops->authorize(conn, first_time, in_buffer, in_len, out_buffer, out_len);
231 static inline RPC_STATUS rpcrt4_conn_secure_packet(
232 RpcConnection *conn, enum secure_packet_direction dir,
233 RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data,
234 unsigned int stub_data_size, RpcAuthVerifier *auth_hdr,
235 unsigned char *auth_value, unsigned int auth_value_size)
237 return conn->ops->secure_packet(conn, dir, hdr, hdr_size, stub_data, stub_data_size, auth_hdr, auth_value, auth_value_size);
240 static inline RPC_STATUS rpcrt4_conn_impersonate_client(
241 RpcConnection *conn)
243 return conn->ops->impersonate_client(conn);
246 static inline RPC_STATUS rpcrt4_conn_revert_to_self(
247 RpcConnection *conn)
249 return conn->ops->revert_to_self(conn);
252 static inline RPC_STATUS rpcrt4_conn_inquire_auth_client(
253 RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name,
254 ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
256 return conn->ops->inquire_auth_client(conn, privs, server_princ_name, authn_level, authn_svc, authz_svc, flags);
259 /* floors 3 and up */
260 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint) DECLSPEC_HIDDEN;
261 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint) DECLSPEC_HIDDEN;
263 void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection) DECLSPEC_HIDDEN;
264 void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding) DECLSPEC_HIDDEN;
265 RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void) DECLSPEC_HIDDEN;
266 void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN;
267 void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN;
268 NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void) DECLSPEC_HIDDEN;
270 #endif