windowscodecs: Add metadata reader information to the registry.
[wine/multimedia.git] / dlls / rpcrt4 / rpc_binding.h
blob21c962d91fa1af9b222c3b72772d3f77dedf6372
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;
82 /* client-only */
83 struct list conn_pool_entry;
84 ULONG assoc_group_id; /* association group returned during binding */
85 RPC_ASYNC_STATE *async_state;
86 struct _RpcAssoc *assoc; /* association this connection is part of */
88 /* server-only */
89 /* The active interface bound to server. */
90 RPC_SYNTAX_IDENTIFIER ActiveInterface;
91 USHORT NextCallId;
92 struct _RpcConnection* Next;
93 struct _RpcBinding *server_binding;
94 } RpcConnection;
96 struct connection_ops {
97 const char *name;
98 unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
99 RpcConnection *(*alloc)(void);
100 RPC_STATUS (*open_connection_client)(RpcConnection *conn);
101 RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
102 int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
103 int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
104 int (*close)(RpcConnection *conn);
105 void (*cancel_call)(RpcConnection *conn);
106 int (*wait_for_incoming_data)(RpcConnection *conn);
107 size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
108 RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
109 RPC_STATUS (*receive_fragment)(RpcConnection *conn, RpcPktHdr **Header, void **Payload);
110 BOOL (*is_authorized)(RpcConnection *conn);
111 RPC_STATUS (*authorize)(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len);
112 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);
113 RPC_STATUS (*impersonate_client)(RpcConnection *conn);
114 RPC_STATUS (*revert_to_self)(RpcConnection *conn);
115 RPC_STATUS (*inquire_auth_client)(RpcConnection *, RPC_AUTHZ_HANDLE *, RPC_WSTR *, ULONG *, ULONG *, ULONG *, ULONG);
118 /* don't know what MS's structure looks like */
119 typedef struct _RpcBinding
121 LONG refs;
122 struct _RpcBinding* Next;
123 BOOL server;
124 UUID ObjectUuid;
125 LPSTR Protseq;
126 LPSTR NetworkAddr;
127 LPSTR Endpoint;
128 LPWSTR NetworkOptions;
129 RPC_BLOCKING_FN BlockingFn;
130 ULONG ServerTid;
131 RpcConnection* FromConn;
132 struct _RpcAssoc *Assoc;
134 /* authentication */
135 RpcAuthInfo *AuthInfo;
136 RpcQualityOfService *QOS;
137 } RpcBinding;
139 LPSTR RPCRT4_strndupA(LPCSTR src, INT len) DECLSPEC_HIDDEN;
140 LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len) DECLSPEC_HIDDEN;
141 LPSTR RPCRT4_strdupWtoA(LPCWSTR src) DECLSPEC_HIDDEN;
142 LPWSTR RPCRT4_strdupAtoW(LPCSTR src) DECLSPEC_HIDDEN;
143 void RPCRT4_strfree(LPSTR src) DECLSPEC_HIDDEN;
145 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
146 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
148 RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret) DECLSPEC_HIDDEN;
149 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN;
150 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN;
151 BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthInfo2) DECLSPEC_HIDDEN;
152 ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
153 ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
154 BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2) DECLSPEC_HIDDEN;
156 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS) DECLSPEC_HIDDEN;
157 RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn ) DECLSPEC_HIDDEN;
158 RPC_STATUS RPCRT4_ReleaseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
159 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
160 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN;
162 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint) DECLSPEC_HIDDEN;
163 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid) DECLSPEC_HIDDEN;
164 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection) DECLSPEC_HIDDEN;
165 void RPCRT4_AddRefBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
166 RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding) DECLSPEC_HIDDEN;
167 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
168 const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId) DECLSPEC_HIDDEN;
169 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection) DECLSPEC_HIDDEN;
171 static inline const char *rpcrt4_conn_get_name(const RpcConnection *Connection)
173 return Connection->ops->name;
176 static inline int rpcrt4_conn_read(RpcConnection *Connection,
177 void *buffer, unsigned int len)
179 return Connection->ops->read(Connection, buffer, len);
182 static inline int rpcrt4_conn_write(RpcConnection *Connection,
183 const void *buffer, unsigned int len)
185 return Connection->ops->write(Connection, buffer, len);
188 static inline int rpcrt4_conn_close(RpcConnection *Connection)
190 return Connection->ops->close(Connection);
193 static inline void rpcrt4_conn_cancel_call(RpcConnection *Connection)
195 Connection->ops->cancel_call(Connection);
198 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
200 return old_conn->ops->handoff(old_conn, new_conn);
203 static inline BOOL rpcrt4_conn_is_authorized(RpcConnection *Connection)
205 return Connection->ops->is_authorized(Connection);
208 static inline RPC_STATUS rpcrt4_conn_authorize(
209 RpcConnection *conn, BOOL first_time, unsigned char *in_buffer,
210 unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len)
212 return conn->ops->authorize(conn, first_time, in_buffer, in_len, out_buffer, out_len);
215 static inline RPC_STATUS rpcrt4_conn_secure_packet(
216 RpcConnection *conn, enum secure_packet_direction dir,
217 RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data,
218 unsigned int stub_data_size, RpcAuthVerifier *auth_hdr,
219 unsigned char *auth_value, unsigned int auth_value_size)
221 return conn->ops->secure_packet(conn, dir, hdr, hdr_size, stub_data, stub_data_size, auth_hdr, auth_value, auth_value_size);
224 static inline RPC_STATUS rpcrt4_conn_impersonate_client(
225 RpcConnection *conn)
227 return conn->ops->impersonate_client(conn);
230 static inline RPC_STATUS rpcrt4_conn_revert_to_self(
231 RpcConnection *conn)
233 return conn->ops->revert_to_self(conn);
236 static inline RPC_STATUS rpcrt4_conn_inquire_auth_client(
237 RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name,
238 ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
240 return conn->ops->inquire_auth_client(conn, privs, server_princ_name, authn_level, authn_svc, authz_svc, flags);
243 /* floors 3 and up */
244 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint) DECLSPEC_HIDDEN;
245 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint) DECLSPEC_HIDDEN;
247 void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection) DECLSPEC_HIDDEN;
248 void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding) DECLSPEC_HIDDEN;
249 RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void) DECLSPEC_HIDDEN;
250 void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN;
251 void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN;
252 NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void) DECLSPEC_HIDDEN;
254 #endif