rpcrt4: Add functions for generating and parsing the upper floors in endpoint-mapper...
[wine.git] / dlls / rpcrt4 / rpc_binding.h
blob49f20b0f5eaabfc1fc420bb9b89df461b8c2bee8
1 /*
2 * RPC binding API
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"
25 #include "security.h"
28 typedef struct _RpcAuthInfo
30 LONG refs;
32 unsigned long AuthnLevel;
33 unsigned long AuthnSvc;
34 CredHandle cred;
35 TimeStamp exp;
36 } RpcAuthInfo;
38 struct protseq_ops;
40 typedef struct _RpcConnection
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;
53 /* authentication */
54 CtxtHandle ctx;
55 TimeStamp exp;
56 ULONG attr;
57 RpcAuthInfo *AuthInfo;
58 } RpcConnection;
60 struct protseq_ops {
61 const char *name;
62 unsigned char epm_protocols[2]; /* only floors 3 and 4. see http://www.opengroup.org/onlinepubs/9629399/apdxl.htm */
63 RpcConnection *(*alloc)(void);
64 RPC_STATUS (*open_connection)(RpcConnection *conn);
65 HANDLE (*get_connect_wait_handle)(RpcConnection *conn);
66 RPC_STATUS (*handoff)(RpcConnection *old_conn, RpcConnection *new_conn);
67 int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
68 int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
69 int (*close)(RpcConnection *conn);
70 size_t (*get_top_of_tower)(unsigned char *tower_data, const char *networkaddr, const char *endpoint);
71 RPC_STATUS (*parse_top_of_tower)(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint);
74 /* don't know what MS's structure looks like */
75 typedef struct _RpcBinding
77 LONG refs;
78 struct _RpcBinding* Next;
79 BOOL server;
80 UUID ObjectUuid;
81 LPSTR Protseq;
82 LPSTR NetworkAddr;
83 LPSTR Endpoint;
84 RPC_BLOCKING_FN BlockingFn;
85 ULONG ServerTid;
86 RpcConnection* FromConn;
88 /* authentication */
89 RpcAuthInfo *AuthInfo;
90 } RpcBinding;
92 LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
93 LPWSTR RPCRT4_strndupW(LPWSTR src, INT len);
94 LPSTR RPCRT4_strdupWtoA(LPWSTR src);
95 LPWSTR RPCRT4_strdupAtoW(LPSTR src);
96 void RPCRT4_strfree(LPSTR src);
98 #define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1)
99 #define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1)
101 ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo);
102 ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo);
104 RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcBinding* Binding);
105 RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection);
106 RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection);
107 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection);
108 RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
110 RPC_STATUS RPCRT4_CreateBindingA(RpcBinding** Binding, BOOL server, LPSTR Protseq);
111 RPC_STATUS RPCRT4_CreateBindingW(RpcBinding** Binding, BOOL server, LPWSTR Protseq);
112 RPC_STATUS RPCRT4_CompleteBindingA(RpcBinding* Binding, LPSTR NetworkAddr, LPSTR Endpoint, LPSTR NetworkOptions);
113 RPC_STATUS RPCRT4_CompleteBindingW(RpcBinding* Binding, LPWSTR NetworkAddr, LPWSTR Endpoint, LPWSTR NetworkOptions);
114 RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPSTR Endpoint);
115 RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, UUID* ObjectUuid);
116 RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
117 RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
118 RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
119 RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, PRPC_SYNTAX_IDENTIFIER TransferSyntax, PRPC_SYNTAX_IDENTIFIER InterfaceId);
120 RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
121 BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPCSS_NP_REPLY reply);
122 HANDLE RPCRT4_GetMasterMutex(void);
123 HANDLE RPCRT4_RpcssNPConnect(void);
125 static inline const char *rpcrt4_conn_get_name(RpcConnection *Connection)
127 return Connection->ops->name;
130 static inline int rpcrt4_conn_read(RpcConnection *Connection,
131 void *buffer, unsigned int len)
133 return Connection->ops->read(Connection, buffer, len);
136 static inline int rpcrt4_conn_write(RpcConnection *Connection,
137 const void *buffer, unsigned int len)
139 return Connection->ops->write(Connection, buffer, len);
142 static inline int rpcrt4_conn_close(RpcConnection *Connection)
144 return Connection->ops->close(Connection);
147 static inline HANDLE rpcrt4_conn_get_wait_object(RpcConnection *Connection)
149 return Connection->ops->get_connect_wait_handle(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);
161 #endif