taskkill: Add Lithuanian translation.
[wine.git] / dlls / rpcrt4 / rpc_binding.h
blobe523ba69778a3e7448aa0d29455c3606b0e7ec13
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 BOOL server;
65 LPSTR NetworkAddr;
66 LPSTR Endpoint;
67 LPWSTR NetworkOptions;
68 const struct connection_ops *ops;
69 USHORT MaxTransmissionSize;
71 /* authentication */
72 CtxtHandle ctx;
73 TimeStamp exp;
74 ULONG attr;
75 RpcAuthInfo *AuthInfo;
76 ULONG auth_context_id;
77 ULONG encryption_auth_len;
78 ULONG signature_auth_len;
79 RpcQualityOfService *QOS;
81 /* client-only */
82 struct list conn_pool_entry;
83 ULONG assoc_group_id; /* association group returned during binding */
84 RPC_ASYNC_STATE *async_state;
85 struct _RpcAssoc *assoc; /* association this connection is part of */
87 /* server-only */
88 /* The active interface bound to server. */
89 RPC_SYNTAX_IDENTIFIER ActiveInterface;
90 USHORT NextCallId;
91 struct _RpcConnection* Next;
92 struct _RpcBinding *server_binding;
93 } RpcConnection;
95 struct connection_ops {
96 const char *name;
97 unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
98 RpcConnection *(*alloc)(void);
99 RPC_STATUS (*open_connection_client)(RpcConnection *conn);
100 RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
101 int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
102 int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
103 int (*close)(RpcConnection *conn);
104 void (*cancel_call)(RpcConnection *conn);
105 int (*wait_for_incoming_data)(RpcConnection *conn);
106 size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
107 RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
108 RPC_STATUS (*receive_fragment)(RpcConnection *conn, RpcPktHdr **Header, void **Payload);
109 BOOL (*is_authorized)(RpcConnection *conn);
110 RPC_STATUS (*authorize)(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len);
111 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);
112 RPC_STATUS (*impersonate_client)(RpcConnection *conn);
113 RPC_STATUS (*revert_to_self)(RpcConnection *conn);
114 RPC_STATUS (*inquire_auth_client)(RpcConnection *, RPC_AUTHZ_HANDLE *, RPC_WSTR *, ULONG *, ULONG *, ULONG *, ULONG);
117 /* don't know what MS's structure looks like */
118 typedef struct _RpcBinding
120 LONG refs;
121 struct _RpcBinding* Next;
122 BOOL server;
123 UUID ObjectUuid;
124 LPSTR Protseq;
125 LPSTR NetworkAddr;
126 LPSTR Endpoint;
127 LPWSTR NetworkOptions;
128 RPC_BLOCKING_FN BlockingFn;
129 ULONG ServerTid;
130 RpcConnection* FromConn;
131 struct _RpcAssoc *Assoc;
133 /* authentication */
134 RpcAuthInfo *AuthInfo;
135 RpcQualityOfService *QOS;
136 } RpcBinding;
138 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
139 LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len);
140 LPSTR RPCRT4_strdupWtoA(LPCWSTR src);
141 LPWSTR RPCRT4_strdupAtoW(LPCSTR src);
142 void RPCRT4_strfree(LPSTR src);
144 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
145 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
147 RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret);
148 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
149 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
150 BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthInfo2);
151 ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos);
152 ULONG RpcQualityOfService_Release(RpcQualityOfService *qos);
153 BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2);
155 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS);
156 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
157 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection);
158 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
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 void RPCRT4_AddRefBinding(RpcBinding* Binding);
164 RPC_STATUS RPCRT4_ReleaseBinding(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);
169 static inline const char *rpcrt4_conn_get_name(const RpcConnection *Connection)
171 return Connection->ops->name;
174 static inline int rpcrt4_conn_read(RpcConnection *Connection,
175 void *buffer, unsigned int len)
177 return Connection->ops->read(Connection, buffer, len);
180 static inline int rpcrt4_conn_write(RpcConnection *Connection,
181 const void *buffer, unsigned int len)
183 return Connection->ops->write(Connection, buffer, len);
186 static inline int rpcrt4_conn_close(RpcConnection *Connection)
188 return Connection->ops->close(Connection);
191 static inline void rpcrt4_conn_cancel_call(RpcConnection *Connection)
193 Connection->ops->cancel_call(Connection);
196 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
198 return old_conn->ops->handoff(old_conn, new_conn);
201 static inline BOOL rpcrt4_conn_is_authorized(RpcConnection *Connection)
203 return Connection->ops->is_authorized(Connection);
206 static inline RPC_STATUS rpcrt4_conn_authorize(
207 RpcConnection *conn, BOOL first_time, unsigned char *in_buffer,
208 unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len)
210 return conn->ops->authorize(conn, first_time, in_buffer, in_len, out_buffer, out_len);
213 static inline RPC_STATUS rpcrt4_conn_secure_packet(
214 RpcConnection *conn, enum secure_packet_direction dir,
215 RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data,
216 unsigned int stub_data_size, RpcAuthVerifier *auth_hdr,
217 unsigned char *auth_value, unsigned int auth_value_size)
219 return conn->ops->secure_packet(conn, dir, hdr, hdr_size, stub_data, stub_data_size, auth_hdr, auth_value, auth_value_size);
222 static inline RPC_STATUS rpcrt4_conn_impersonate_client(
223 RpcConnection *conn)
225 return conn->ops->impersonate_client(conn);
228 static inline RPC_STATUS rpcrt4_conn_revert_to_self(
229 RpcConnection *conn)
231 return conn->ops->revert_to_self(conn);
234 static inline RPC_STATUS rpcrt4_conn_inquire_auth_client(
235 RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name,
236 ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
238 return conn->ops->inquire_auth_client(conn, privs, server_princ_name, authn_level, authn_svc, authz_svc, flags);
241 /* floors 3 and up */
242 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint);
243 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint);
245 void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection);
246 void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding);
247 RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void);
248 void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext);
249 void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext);
250 NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void);
252 #endif