setupapi: Add a stub implementation for SetupPromptReboot.
[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 #include "wine/list.h"
27
28
29 typedef struct _RpcAuthInfo
30 {
31   LONG refs;
32
33   unsigned long AuthnLevel;
34   unsigned long AuthnSvc;
35   CredHandle cred;
36   TimeStamp exp;
37 } RpcAuthInfo;
38
39 struct connection_ops;
40
41 typedef struct _RpcConnection
42 {
43   struct _RpcConnection* Next;
44   struct _RpcBinding* Used;
45   BOOL server;
46   LPSTR NetworkAddr;
47   LPSTR Endpoint;
48   const struct connection_ops *ops;
49   USHORT MaxTransmissionSize;
50   /* The active interface bound to server. */
51   RPC_SYNTAX_IDENTIFIER ActiveInterface;
52   USHORT NextCallId;
53
54   /* authentication */
55   CtxtHandle ctx;
56   TimeStamp exp;
57   ULONG attr;
58   RpcAuthInfo *AuthInfo;
59
60   /* client-only */
61   struct list conn_pool_entry;
62 } RpcConnection;
63
64 struct connection_ops {
65   const char *name;
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);
75 };
76
77 /* don't know what MS's structure looks like */
78 typedef struct _RpcBinding
79 {
80   LONG refs;
81   struct _RpcBinding* Next;
82   BOOL server;
83   UUID ObjectUuid;
84   LPSTR Protseq;
85   LPSTR NetworkAddr;
86   LPSTR Endpoint;
87   RPC_BLOCKING_FN BlockingFn;
88   ULONG ServerTid;
89   RpcConnection* FromConn;
90
91   /* authentication */
92   RpcAuthInfo *AuthInfo;
93 } RpcBinding;
94
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);
100
101 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
102 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
103
104 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
105 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
106
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);
114
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);
129
130 static inline const char *rpcrt4_conn_get_name(RpcConnection *Connection)
131 {
132   return Connection->ops->name;
133 }
134
135 static inline int rpcrt4_conn_read(RpcConnection *Connection,
136                      void *buffer, unsigned int len)
137 {
138   return Connection->ops->read(Connection, buffer, len);
139 }
140
141 static inline int rpcrt4_conn_write(RpcConnection *Connection,
142                      const void *buffer, unsigned int len)
143 {
144   return Connection->ops->write(Connection, buffer, len);
145 }
146
147 static inline int rpcrt4_conn_close(RpcConnection *Connection)
148 {
149   return Connection->ops->close(Connection);
150 }
151
152 static inline RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
153 {
154   return old_conn->ops->handoff(old_conn, new_conn);
155 }
156
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);
160
161 #endif