rpcrt4: Split the transport layer into a different file.
[wine] / dlls / rpcrt4 / rpc_binding.h
1 /*
2  * RPC binding API
3  *
4  * Copyright 2001 Ove Kåven, TransGaming Technologies
5  *
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.
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_RPC_BINDING_H
22 #define __WINE_RPC_BINDING_H
23
24 #include "wine/rpcss_shared.h"
25
26 struct protseq_ops;
27
28 typedef struct _RpcConnection
29 {
30   struct _RpcConnection* Next;
31   struct _RpcBinding* Used;
32   BOOL server;
33   LPSTR NetworkAddr;
34   LPSTR Endpoint;
35   struct protseq_ops *ops;
36   HANDLE conn, thread;
37   OVERLAPPED ovl;
38   USHORT MaxTransmissionSize;
39   /* The active interface bound to server. */
40   RPC_SYNTAX_IDENTIFIER ActiveInterface;
41 } RpcConnection;
42
43 struct protseq_ops {
44   char *name;
45   RPC_STATUS (*open_connection)(RpcConnection *conn);
46   HANDLE (*get_connect_wait_handle)(RpcConnection *conn);
47   int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
48   int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
49   int (*close)(RpcConnection *conn);
50 };
51
52 /* don't know what MS's structure looks like */
53 typedef struct _RpcBinding
54 {
55   LONG refs;
56   struct _RpcBinding* Next;
57   BOOL server;
58   UUID ObjectUuid;
59   LPSTR Protseq;
60   LPSTR NetworkAddr;
61   LPSTR Endpoint;
62   RPC_BLOCKING_FN BlockingFn;
63   ULONG ServerTid;
64   RpcConnection* FromConn;
65 } RpcBinding;
66
67 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
68 LPWSTR RPCRT4_strndupW(LPWSTR src, INT len);
69 LPSTR RPCRT4_strdupWtoA(LPWSTR src);
70 LPWSTR RPCRT4_strdupAtoW(LPSTR src);
71 void RPCRT4_strfree(LPSTR src);
72
73 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
74 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
75
76 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCSTR NetworkOptions, RpcBinding* Binding);
77 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
78 RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection);
79 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
80 RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
81
82 RPC_STATUS RPCRT4_CreateBindingA(RpcBinding** Binding, BOOL server, LPSTR Protseq);
83 RPC_STATUS RPCRT4_CreateBindingW(RpcBinding** Binding, BOOL server, LPWSTR Protseq);
84 RPC_STATUS RPCRT4_CompleteBindingA(RpcBinding* Binding, LPSTR NetworkAddr,  LPSTR Endpoint,  LPSTR NetworkOptions);
85 RPC_STATUS RPCRT4_CompleteBindingW(RpcBinding* Binding, LPWSTR NetworkAddr, LPWSTR Endpoint, LPWSTR NetworkOptions);
86 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPSTR Endpoint);
87 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, UUID* ObjectUuid);
88 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
89 RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
90 RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
91 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, PRPC_SYNTAX_IDENTIFIER TransferSyntax, PRPC_SYNTAX_IDENTIFIER InterfaceId);
92 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
93 BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPCSS_NP_REPLY reply);
94 HANDLE RPCRT4_GetMasterMutex(void);
95 HANDLE RPCRT4_RpcssNPConnect(void);
96
97 static inline const char *rpcrt4_conn_get_name(RpcConnection *Connection)
98 {
99   return Connection->ops->name;
100 }
101
102 static inline int rpcrt4_conn_read(RpcConnection *Connection,
103                      void *buffer, unsigned int len)
104 {
105   return Connection->ops->read(Connection, buffer, len);
106 }
107
108 static inline int rpcrt4_conn_write(RpcConnection *Connection,
109                      const void *buffer, unsigned int len)
110 {
111   return Connection->ops->write(Connection, buffer, len);
112 }
113
114 static inline int rpcrt4_conn_close(RpcConnection *Connection)
115 {
116   return Connection->ops->close(Connection);
117 }
118
119 static inline HANDLE rpcrt4_conn_get_wait_object(RpcConnection *Connection)
120 {
121   return Connection->ops->get_connect_wait_handle(Connection);
122 }
123
124 #endif