d3d8: Get rid of the format switching code in d3d8_device_CopyRects().
[wine.git] / dlls / rpcrt4 / rpc_binding.h
blob7b8eaf38dde22e3c7d58a96cf85e8a881aebdc08
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 LPSTR NetworkAddr;
67 LPSTR Endpoint;
68 LPWSTR NetworkOptions;
69 const struct connection_ops *ops;
70 USHORT MaxTransmissionSize;
72 /* authentication */
73 CtxtHandle ctx;
74 TimeStamp exp;
75 ULONG attr;
76 RpcAuthInfo *AuthInfo;
77 ULONG auth_context_id;
78 ULONG encryption_auth_len;
79 ULONG signature_auth_len;
80 RpcQualityOfService *QOS;
81 LPWSTR CookieAuth;
83 /* client-only */
84 struct list conn_pool_entry;
85 ULONG assoc_group_id; /* association group returned during binding */
86 RPC_ASYNC_STATE *async_state;
87 struct _RpcAssoc *assoc; /* association this connection is part of */
89 /* server-only */
90 /* The active interface bound to server. */
91 RPC_SYNTAX_IDENTIFIER ActiveInterface;
92 USHORT NextCallId;
93 struct _RpcConnection* Next;
94 struct _RpcBinding *server_binding;
95 } RpcConnection;
97 struct connection_ops {
98 const char *name;
99 unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
100 RpcConnection *(*alloc)(void);
101 RPC_STATUS (*open_connection_client)(RpcConnection *conn);
102 RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
103 int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
104 int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
105 int (*close)(RpcConnection *conn);
106 void (*cancel_call)(RpcConnection *conn);
107 int (*wait_for_incoming_data)(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 RPC_STATUS (*receive_fragment)(RpcConnection *conn, RpcPktHdr **Header, void **Payload);
111 BOOL (*is_authorized)(RpcConnection *conn);
112 RPC_STATUS (*authorize)(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len);
113 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);
114 RPC_STATUS (*impersonate_client)(RpcConnection *conn);
115 RPC_STATUS (*revert_to_self)(RpcConnection *conn);
116 RPC_STATUS (*inquire_auth_client)(RpcConnection *, RPC_AUTHZ_HANDLE *, RPC_WSTR *, ULONG *, ULONG *, ULONG *, ULONG);
119 /* don't know what MS's structure looks like */
120 typedef struct _RpcBinding
122 LONG refs;
123 struct _RpcBinding* Next;
124 BOOL server;
125 UUID ObjectUuid;
126 LPSTR Protseq;
127 LPSTR NetworkAddr;
128 LPSTR Endpoint;
129 LPWSTR NetworkOptions;
130 RPC_BLOCKING_FN BlockingFn;
131 ULONG ServerTid;
132 RpcConnection* FromConn;
133 struct _RpcAssoc *Assoc;
135 /* authentication */
136 RpcAuthInfo *AuthInfo;
137 RpcQualityOfService *QOS;
138 LPWSTR CookieAuth;
139 } RpcBinding;
141 LPSTR RPCRT4_strndupA(LPCSTR src, INT len) DECLSPEC_HIDDEN;
142 LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len) DECLSPEC_HIDDEN;
143 LPSTR RPCRT4_strdupWtoA(LPCWSTR src) DECLSPEC_HIDDEN;
144 LPWSTR RPCRT4_strdupAtoW(LPCSTR src) DECLSPEC_HIDDEN;
145 void RPCRT4_strfree(LPSTR src) DECLSPEC_HIDDEN;
147 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
148 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
150 RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret) DECLSPEC_HIDDEN;
151 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN;
152 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN;
153 BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthInfo2) DECLSPEC_HIDDEN;
154 ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
155 ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
156 BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2) DECLSPEC_HIDDEN;
158 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq,
159 LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo,
160 RpcQualityOfService *QOS, LPCWSTR CookieAuth) DECLSPEC_HIDDEN;
161 RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn ) DECLSPEC_HIDDEN;
162 RPC_STATUS RPCRT4_ReleaseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
163 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
164 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
166 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint) DECLSPEC_HIDDEN;
167 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid) DECLSPEC_HIDDEN;
168 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection) DECLSPEC_HIDDEN;
169 void RPCRT4_AddRefBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
170 RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
171 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
172 const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId) DECLSPEC_HIDDEN;
173 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection) DECLSPEC_HIDDEN;
175 static inline const char *rpcrt4_conn_get_name(const RpcConnection *Connection)
177 return Connection->ops->name;
180 static inline int rpcrt4_conn_read(RpcConnection *Connection,
181 void *buffer, unsigned int len)
183 return Connection->ops->read(Connection, buffer, len);
186 static inline int rpcrt4_conn_write(RpcConnection *Connection,
187 const void *buffer, unsigned int len)
189 return Connection->ops->write(Connection, buffer, len);
192 static inline int rpcrt4_conn_close(RpcConnection *Connection)
194 return Connection->ops->close(Connection);
197 static inline void rpcrt4_conn_cancel_call(RpcConnection *Connection)
199 Connection->ops->cancel_call(Connection);
202 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
204 return old_conn->ops->handoff(old_conn, new_conn);
207 static inline BOOL rpcrt4_conn_is_authorized(RpcConnection *Connection)
209 return Connection->ops->is_authorized(Connection);
212 static inline RPC_STATUS rpcrt4_conn_authorize(
213 RpcConnection *conn, BOOL first_time, unsigned char *in_buffer,
214 unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len)
216 return conn->ops->authorize(conn, first_time, in_buffer, in_len, out_buffer, out_len);
219 static inline RPC_STATUS rpcrt4_conn_secure_packet(
220 RpcConnection *conn, enum secure_packet_direction dir,
221 RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data,
222 unsigned int stub_data_size, RpcAuthVerifier *auth_hdr,
223 unsigned char *auth_value, unsigned int auth_value_size)
225 return conn->ops->secure_packet(conn, dir, hdr, hdr_size, stub_data, stub_data_size, auth_hdr, auth_value, auth_value_size);
228 static inline RPC_STATUS rpcrt4_conn_impersonate_client(
229 RpcConnection *conn)
231 return conn->ops->impersonate_client(conn);
234 static inline RPC_STATUS rpcrt4_conn_revert_to_self(
235 RpcConnection *conn)
237 return conn->ops->revert_to_self(conn);
240 static inline RPC_STATUS rpcrt4_conn_inquire_auth_client(
241 RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name,
242 ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
244 return conn->ops->inquire_auth_client(conn, privs, server_princ_name, authn_level, authn_svc, authz_svc, flags);
247 /* floors 3 and up */
248 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint) DECLSPEC_HIDDEN;
249 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint) DECLSPEC_HIDDEN;
251 void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection) DECLSPEC_HIDDEN;
252 void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding) DECLSPEC_HIDDEN;
253 RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void) DECLSPEC_HIDDEN;
254 void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN;
255 void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN;
256 NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void) DECLSPEC_HIDDEN;
258 #endif