rpcrt4: NdrClientInitializeNew shouldn't clear all of the stub message, only selected...
[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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_RPC_BINDING_H
22 #define __WINE_RPC_BINDING_H
23
24 #include "wine/rpcss_shared.h"
25 #include "security.h"
26
27
28 typedef struct _RpcAuthInfo
29 {
30   LONG refs;
31
32   unsigned long AuthnLevel;
33   unsigned long AuthnSvc;
34   CredHandle cred;
35   TimeStamp exp;
36 } RpcAuthInfo;
37
38 struct protseq_ops;
39
40 typedef struct _RpcConnection
41 {
42   struct _RpcConnection* Next;
43   struct _RpcBinding* Used;
44   BOOL server;
45   LPSTR NetworkAddr;
46   LPSTR Endpoint;
47   struct protseq_ops *ops;
48   USHORT MaxTransmissionSize;
49   /* The active interface bound to server. */
50   RPC_SYNTAX_IDENTIFIER ActiveInterface;
51   USHORT NextCallId;
52
53   /* authentication */
54   CtxtHandle ctx;
55   TimeStamp exp;
56   ULONG attr;
57   RpcAuthInfo *AuthInfo;
58 } RpcConnection;
59
60 struct protseq_ops {
61   char *name;
62   RpcConnection *(*alloc)(void);
63   RPC_STATUS (*open_connection)(RpcConnection *conn);
64   HANDLE (*get_connect_wait_handle)(RpcConnection *conn);
65   RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
66   int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
67   int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
68   int (*close)(RpcConnection *conn);
69 };
70
71 /* don't know what MS's structure looks like */
72 typedef struct _RpcBinding
73 {
74   LONG refs;
75   struct _RpcBinding* Next;
76   BOOL server;
77   UUID ObjectUuid;
78   LPSTR Protseq;
79   LPSTR NetworkAddr;
80   LPSTR Endpoint;
81   RPC_BLOCKING_FN BlockingFn;
82   ULONG ServerTid;
83   RpcConnection* FromConn;
84
85   /* authentication */
86   RpcAuthInfo *AuthInfo;
87 } RpcBinding;
88
89 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
90 LPWSTR RPCRT4_strndupW(LPWSTR src, INT len);
91 LPSTR RPCRT4_strdupWtoA(LPWSTR src);
92 LPWSTR RPCRT4_strdupAtoW(LPSTR src);
93 void RPCRT4_strfree(LPSTR src);
94
95 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
96 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
97
98 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
99 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
100
101 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcBinding* Binding);
102 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
103 RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection);
104 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
105 RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
106
107 RPC_STATUS RPCRT4_CreateBindingA(RpcBinding** Binding, BOOL server, LPSTR Protseq);
108 RPC_STATUS RPCRT4_CreateBindingW(RpcBinding** Binding, BOOL server, LPWSTR Protseq);
109 RPC_STATUS RPCRT4_CompleteBindingA(RpcBinding* Binding, LPSTR NetworkAddr,  LPSTR Endpoint,  LPSTR NetworkOptions);
110 RPC_STATUS RPCRT4_CompleteBindingW(RpcBinding* Binding, LPWSTR NetworkAddr, LPWSTR Endpoint, LPWSTR NetworkOptions);
111 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPSTR Endpoint);
112 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, UUID* ObjectUuid);
113 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
114 RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
115 RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
116 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, PRPC_SYNTAX_IDENTIFIER TransferSyntax, PRPC_SYNTAX_IDENTIFIER InterfaceId);
117 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
118 BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPCSS_NP_REPLY reply);
119 HANDLE RPCRT4_GetMasterMutex(void);
120 HANDLE RPCRT4_RpcssNPConnect(void);
121
122 static inline const char *rpcrt4_conn_get_name(RpcConnection *Connection)
123 {
124   return Connection->ops->name;
125 }
126
127 static inline int rpcrt4_conn_read(RpcConnection *Connection,
128                      void *buffer, unsigned int len)
129 {
130   return Connection->ops->read(Connection, buffer, len);
131 }
132
133 static inline int rpcrt4_conn_write(RpcConnection *Connection,
134                      const void *buffer, unsigned int len)
135 {
136   return Connection->ops->write(Connection, buffer, len);
137 }
138
139 static inline int rpcrt4_conn_close(RpcConnection *Connection)
140 {
141   return Connection->ops->close(Connection);
142 }
143
144 static inline HANDLE rpcrt4_conn_get_wait_object(RpcConnection *Connection)
145 {
146   return Connection->ops->get_connect_wait_handle(Connection);
147 }
148
149 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
150 {
151   return old_conn->ops->handoff(old_conn, new_conn);
152 }
153
154 #endif