2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2010-2011
5 Copyright (C) Andrew Tridgell 2010-2011
6 Copyright (C) Simo Sorce 2010
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __DEFAULT_LIBRPC_RPCCOMMON_H__
23 #define __DEFAULT_LIBRPC_RPCCOMMON_H__
25 struct dcerpc_binding_handle;
27 struct ndr_interface_table;
28 struct ndr_interface_call;
33 struct tevent_context;
34 struct tstream_context;
36 enum dcerpc_transport_t {
37 NCA_UNKNOWN, NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC,
38 NCACN_VNS_SPP, NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM,
39 NCADG_UNIX_DGRAM, NCACN_HTTP, NCADG_IPX, NCACN_SPX, NCACN_INTERNAL };
41 /** this describes a binding to a particular transport/pipe */
42 struct dcerpc_binding {
43 enum dcerpc_transport_t transport;
44 struct ndr_syntax_id object;
46 const char *target_hostname;
47 const char *target_principal;
50 const char *localaddress;
52 uint32_t assoc_group_id;
55 /* The following definitions come from ../librpc/rpc/dcerpc_error.c */
57 const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
58 NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code);
60 /* The following definitions come from ../librpc/rpc/binding.c */
62 const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
63 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
64 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
66 /* The following definitions come from ../librpc/rpc/dcerpc_util.c */
68 void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v);
69 uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob);
70 void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v);
71 uint8_t dcerpc_get_endian_flag(DATA_BLOB *blob);
74 * @brief Pull a dcerpc_auth structure, taking account of any auth
75 * padding in the blob. For request/response packets we pass
76 * the whole data blob, so auth_data_only must be set to false
77 * as the blob contains data+pad+auth and no just pad+auth.
79 * @param pkt - The ncacn_packet strcuture
80 * @param mem_ctx - The mem_ctx used to allocate dcerpc_auth elements
81 * @param pkt_trailer - The packet trailer data, usually the trailing
82 * auth_info blob, but in the request/response case
83 * this is the stub_and_verifier blob.
84 * @param auth - A preallocated dcerpc_auth *empty* structure
85 * @param auth_length - The length of the auth trail, sum of auth header
86 * lenght and pkt->auth_length
87 * @param auth_data_only - Whether the pkt_trailer includes only the auth_blob
88 * (+ padding) or also other data.
90 * @return - A NTSTATUS error code.
92 NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt,
94 DATA_BLOB *pkt_trailer,
95 struct dcerpc_auth *auth,
96 uint32_t *auth_length,
98 struct tevent_req *dcerpc_read_ncacn_packet_send(TALLOC_CTX *mem_ctx,
99 struct tevent_context *ev,
100 struct tstream_context *stream);
101 NTSTATUS dcerpc_read_ncacn_packet_recv(struct tevent_req *req,
103 struct ncacn_packet **pkt,
106 /* The following definitions come from ../librpc/rpc/binding_handle.c */
108 struct dcerpc_binding_handle_ops {
111 bool (*is_connected)(struct dcerpc_binding_handle *h);
112 uint32_t (*set_timeout)(struct dcerpc_binding_handle *h,
115 struct tevent_req *(*raw_call_send)(TALLOC_CTX *mem_ctx,
116 struct tevent_context *ev,
117 struct dcerpc_binding_handle *h,
118 const struct GUID *object,
121 const uint8_t *in_data,
123 NTSTATUS (*raw_call_recv)(struct tevent_req *req,
127 uint32_t *out_flags);
129 struct tevent_req *(*disconnect_send)(TALLOC_CTX *mem_ctx,
130 struct tevent_context *ev,
131 struct dcerpc_binding_handle *h);
132 NTSTATUS (*disconnect_recv)(struct tevent_req *req);
134 /* TODO: remove the following functions */
135 bool (*push_bigendian)(struct dcerpc_binding_handle *h);
136 bool (*ref_alloc)(struct dcerpc_binding_handle *h);
137 bool (*use_ndr64)(struct dcerpc_binding_handle *h);
138 void (*do_ndr_print)(struct dcerpc_binding_handle *h,
140 const void *struct_ptr,
141 const struct ndr_interface_call *call);
142 void (*ndr_push_failed)(struct dcerpc_binding_handle *h,
144 const void *struct_ptr,
145 const struct ndr_interface_call *call);
146 void (*ndr_pull_failed)(struct dcerpc_binding_handle *h,
148 const DATA_BLOB *blob,
149 const struct ndr_interface_call *call);
150 NTSTATUS (*ndr_validate_in)(struct dcerpc_binding_handle *h,
152 const DATA_BLOB *blob,
153 const struct ndr_interface_call *call);
154 NTSTATUS (*ndr_validate_out)(struct dcerpc_binding_handle *h,
155 struct ndr_pull *pull_in,
156 const void *struct_ptr,
157 const struct ndr_interface_call *call);
160 struct dcerpc_binding_handle *_dcerpc_binding_handle_create(TALLOC_CTX *mem_ctx,
161 const struct dcerpc_binding_handle_ops *ops,
162 const struct GUID *object,
163 const struct ndr_interface_table *table,
167 const char *location);
168 #define dcerpc_binding_handle_create(mem_ctx, ops, object, table, \
169 state, type, location) \
170 _dcerpc_binding_handle_create(mem_ctx, ops, object, table, \
171 state, sizeof(type), #type, location)
173 void *_dcerpc_binding_handle_data(struct dcerpc_binding_handle *h);
174 #define dcerpc_binding_handle_data(_h, _type) \
175 talloc_get_type_abort(_dcerpc_binding_handle_data(_h), _type)
177 _DEPRECATED_ void dcerpc_binding_handle_set_sync_ev(struct dcerpc_binding_handle *h,
178 struct tevent_context *ev);
180 bool dcerpc_binding_handle_is_connected(struct dcerpc_binding_handle *h);
182 uint32_t dcerpc_binding_handle_set_timeout(struct dcerpc_binding_handle *h,
185 struct tevent_req *dcerpc_binding_handle_raw_call_send(TALLOC_CTX *mem_ctx,
186 struct tevent_context *ev,
187 struct dcerpc_binding_handle *h,
188 const struct GUID *object,
191 const uint8_t *in_data,
193 NTSTATUS dcerpc_binding_handle_raw_call_recv(struct tevent_req *req,
197 uint32_t *out_flags);
199 struct tevent_req *dcerpc_binding_handle_disconnect_send(TALLOC_CTX *mem_ctx,
200 struct tevent_context *ev,
201 struct dcerpc_binding_handle *h);
202 NTSTATUS dcerpc_binding_handle_disconnect_recv(struct tevent_req *req);
204 struct tevent_req *dcerpc_binding_handle_call_send(TALLOC_CTX *mem_ctx,
205 struct tevent_context *ev,
206 struct dcerpc_binding_handle *h,
207 const struct GUID *object,
208 const struct ndr_interface_table *table,
212 NTSTATUS dcerpc_binding_handle_call_recv(struct tevent_req *req);
213 NTSTATUS dcerpc_binding_handle_call(struct dcerpc_binding_handle *h,
214 const struct GUID *object,
215 const struct ndr_interface_table *table,
220 #endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */