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 "wine/rpcss_shared.h"
26 #include "wine/list.h"
29 typedef struct _RpcAuthInfo
33 unsigned long AuthnLevel;
34 unsigned long AuthnSvc;
39 struct connection_ops;
41 typedef struct _RpcConnection
43 struct _RpcConnection* Next;
44 struct _RpcBinding* Used;
48 const struct connection_ops *ops;
49 USHORT MaxTransmissionSize;
50 /* The active interface bound to server. */
51 RPC_SYNTAX_IDENTIFIER ActiveInterface;
58 RpcAuthInfo *AuthInfo;
61 struct list conn_pool_entry;
64 struct connection_ops {
66 unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
67 RpcConnection *(*alloc)(void);
68 RPC_STATUS (*open_connection_client)(RpcConnection *conn);
69 RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
70 int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
71 int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
72 int (*close)(RpcConnection *conn);
73 size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
74 RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
77 /* don't know what MS's structure looks like */
78 typedef struct _RpcBinding
81 struct _RpcBinding* Next;
87 RPC_BLOCKING_FN BlockingFn;
89 RpcConnection* FromConn;
92 RpcAuthInfo *AuthInfo;
95 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
96 LPWSTR RPCRT4_strndupW(LPWSTR src, INT len);
97 LPSTR RPCRT4_strdupWtoA(LPWSTR src);
98 LPWSTR RPCRT4_strdupAtoW(LPSTR src);
99 void RPCRT4_strfree(LPSTR src);
101 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
102 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
104 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
105 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
107 RpcConnection *RPCRT4_GetIdleConnection(const RPC_SYNTAX_IDENTIFIER *InterfaceId, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, RpcAuthInfo* AuthInfo);
108 void RPCRT4_ReleaseIdleConnection(RpcConnection *Connection);
109 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcBinding* Binding);
110 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
111 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection);
112 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
113 RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
115 RPC_STATUS RPCRT4_CreateBindingA(RpcBinding** Binding, BOOL server, LPSTR Protseq);
116 RPC_STATUS RPCRT4_CreateBindingW(RpcBinding** Binding, BOOL server, LPWSTR Protseq);
117 RPC_STATUS RPCRT4_CompleteBindingA(RpcBinding* Binding, LPSTR NetworkAddr, LPSTR Endpoint, LPSTR NetworkOptions);
118 RPC_STATUS RPCRT4_CompleteBindingW(RpcBinding* Binding, LPWSTR NetworkAddr, LPWSTR Endpoint, LPWSTR NetworkOptions);
119 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPSTR Endpoint);
120 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, UUID* ObjectUuid);
121 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
122 RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
123 RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
124 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, PRPC_SYNTAX_IDENTIFIER TransferSyntax, PRPC_SYNTAX_IDENTIFIER InterfaceId);
125 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
126 BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPCSS_NP_REPLY reply);
127 HANDLE RPCRT4_GetMasterMutex(void);
128 HANDLE RPCRT4_RpcssNPConnect(void);
130 static inline const char *rpcrt4_conn_get_name(RpcConnection *Connection)
132 return Connection->ops->name;
135 static inline int rpcrt4_conn_read(RpcConnection *Connection,
136 void *buffer, unsigned int len)
138 return Connection->ops->read(Connection, buffer, len);
141 static inline int rpcrt4_conn_write(RpcConnection *Connection,
142 const void *buffer, unsigned int len)
144 return Connection->ops->write(Connection, buffer, len);
147 static inline int rpcrt4_conn_close(RpcConnection *Connection)
149 return Connection->ops->close(Connection);
152 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
154 return old_conn->ops->handoff(old_conn, new_conn);
157 /* floors 3 and up */
158 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint);
159 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint);