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 typedef struct _RpcQualityOfService
43 RPC_SECURITY_QOS_V2_W *qos;
44 } RpcQualityOfService;
46 struct connection_ops;
48 typedef struct _RpcConnection
50 struct _RpcConnection* Next;
51 struct _RpcBinding* Used;
55 LPWSTR NetworkOptions;
56 const struct connection_ops *ops;
57 USHORT MaxTransmissionSize;
58 /* The active interface bound to server. */
59 RPC_SYNTAX_IDENTIFIER ActiveInterface;
66 RpcAuthInfo *AuthInfo;
67 RpcQualityOfService *QOS;
70 struct list conn_pool_entry;
73 struct connection_ops {
75 unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
76 RpcConnection *(*alloc)(void);
77 RPC_STATUS (*open_connection_client)(RpcConnection *conn);
78 RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
79 int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
80 int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
81 int (*close)(RpcConnection *conn);
82 size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
83 RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
86 /* don't know what MS's structure looks like */
87 typedef struct _RpcBinding
90 struct _RpcBinding* Next;
96 LPWSTR NetworkOptions;
97 RPC_BLOCKING_FN BlockingFn;
99 RpcConnection* FromConn;
102 RpcAuthInfo *AuthInfo;
103 RpcQualityOfService *QOS;
106 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
107 LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len);
108 LPSTR RPCRT4_strdupWtoA(LPCWSTR src);
109 LPWSTR RPCRT4_strdupAtoW(LPCSTR src);
110 void RPCRT4_strfree(LPSTR src);
112 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
113 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
115 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
116 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
117 ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos);
118 ULONG RpcQualityOfService_Release(RpcQualityOfService *qos);
120 RpcConnection *RPCRT4_GetIdleConnection(const RPC_SYNTAX_IDENTIFIER *InterfaceId, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, const RpcAuthInfo* AuthInfo, const RpcQualityOfService *QOS);
121 void RPCRT4_ReleaseIdleConnection(RpcConnection *Connection);
122 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS, RpcBinding* Binding);
123 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
124 RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection);
125 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
126 RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
128 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPSTR Endpoint);
129 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, UUID* ObjectUuid);
130 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
131 RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
132 RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
133 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, PRPC_SYNTAX_IDENTIFIER TransferSyntax, PRPC_SYNTAX_IDENTIFIER InterfaceId);
134 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
135 BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPCSS_NP_REPLY reply);
136 HANDLE RPCRT4_GetMasterMutex(void);
137 HANDLE RPCRT4_RpcssNPConnect(void);
139 static inline const char *rpcrt4_conn_get_name(RpcConnection *Connection)
141 return Connection->ops->name;
144 static inline int rpcrt4_conn_read(RpcConnection *Connection,
145 void *buffer, unsigned int len)
147 return Connection->ops->read(Connection, buffer, len);
150 static inline int rpcrt4_conn_write(RpcConnection *Connection,
151 const void *buffer, unsigned int len)
153 return Connection->ops->write(Connection, buffer, len);
156 static inline int rpcrt4_conn_close(RpcConnection *Connection)
158 return Connection->ops->close(Connection);
161 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
163 return old_conn->ops->handoff(old_conn, new_conn);
166 /* floors 3 and up */
167 RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint);
168 RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint);