e2ea739cf3d18a349c5cb36a95c34ef094473881
[metze/samba/wip.git] / librpc / rpc / rpc_common.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    Copyright (C) Stefan Metzmacher 2010-2011
5    Copyright (C) Andrew Tridgell 2010-2011
6    Copyright (C) Simo Sorce 2010
7
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.
12
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.
17
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/>.
20 */
21
22 #ifndef __DEFAULT_LIBRPC_RPCCOMMON_H__
23 #define __DEFAULT_LIBRPC_RPCCOMMON_H__
24
25 #include "gen_ndr/dcerpc.h"
26 #include "lib/util/attr.h"
27
28 struct dcerpc_binding_handle;
29 struct dcerpc_pipe_handle;
30 struct dcerpc_pipe_handle_connection;
31 struct GUID;
32 struct ndr_interface_table;
33 struct ndr_interface_call;
34 struct ndr_push;
35 struct ndr_pull;
36 struct ncacn_packet;
37 struct epm_floor;
38 struct epm_tower;
39 struct tevent_context;
40 struct tstream_context;
41 struct gensec_security;
42
43 enum dcerpc_transport_t {
44         NCA_UNKNOWN, NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, 
45         NCACN_VNS_SPP, NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, 
46         NCADG_UNIX_DGRAM, NCACN_HTTP, NCADG_IPX, NCACN_SPX, NCACN_INTERNAL };
47
48 /** this describes a binding to a particular transport/pipe */
49 struct dcerpc_binding;
50
51 /* dcerpc pipe flags */
52 #define DCERPC_DEBUG_PRINT_IN          (1<<0)
53 #define DCERPC_DEBUG_PRINT_OUT         (1<<1)
54 #define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)
55
56 #define DCERPC_DEBUG_VALIDATE_IN       (1<<2)
57 #define DCERPC_DEBUG_VALIDATE_OUT      (1<<3)
58 #define DCERPC_DEBUG_VALIDATE_BOTH (DCERPC_DEBUG_VALIDATE_IN | DCERPC_DEBUG_VALIDATE_OUT)
59
60 #define DCERPC_CONNECT                 (1<<4)
61 #define DCERPC_SIGN                    (1<<5)
62 #define DCERPC_SEAL                    (1<<6)
63
64 #define DCERPC_PUSH_BIGENDIAN          (1<<7)
65 #define DCERPC_PULL_BIGENDIAN          (1<<8)
66
67 #define DCERPC_SCHANNEL                (1<<9)
68
69 #define DCERPC_ANON_FALLBACK           (1<<10)
70
71 /* use a 128 bit session key */
72 #define DCERPC_SCHANNEL_128            (1<<12)
73
74 /* check incoming pad bytes */
75 #define DCERPC_DEBUG_PAD_CHECK         (1<<13)
76
77 /* set LIBNDR_FLAG_REF_ALLOC flag when decoding NDR */
78 #define DCERPC_NDR_REF_ALLOC           (1<<14)
79
80 #define DCERPC_AUTH_OPTIONS    (DCERPC_SEAL|DCERPC_SIGN|DCERPC_SCHANNEL|DCERPC_AUTH_SPNEGO|DCERPC_AUTH_KRB5|DCERPC_AUTH_NTLM)
81
82 /* select spnego auth */
83 #define DCERPC_AUTH_SPNEGO             (1<<15)
84
85 /* select krb5 auth */
86 #define DCERPC_AUTH_KRB5               (1<<16)
87
88 #define DCERPC_SMB2                    (1<<17)
89
90 /* select NTLM auth */
91 #define DCERPC_AUTH_NTLM               (1<<18)
92
93 /* this triggers the DCERPC_PFC_FLAG_CONC_MPX flag in the bind request */
94 #define DCERPC_CONCURRENT_MULTIPLEX     (1<<19)
95
96 /* this indicates DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag was negotiated */
97 #define DCERPC_HEADER_SIGNING          (1<<20)
98
99 /* use NDR64 transport */
100 #define DCERPC_NDR64                   (1<<21)
101
102 /* handle upgrades or downgrades automatically */
103 #define DCERPC_SCHANNEL_AUTO           (1<<23)
104
105 /* use aes schannel with hmac-sh256 session key */
106 #define DCERPC_SCHANNEL_AES            (1<<24)
107
108 /* this triggers the DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag in the bind request */
109 #define DCERPC_PROPOSE_HEADER_SIGNING          (1<<25)
110
111 #define DCERPC_PACKET                   (1<<26)
112
113 #define DCERPC_SMB1                    (1<<27)
114
115 /* The following definitions come from ../librpc/rpc/dcerpc_error.c  */
116
117 const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
118 NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code);
119 uint32_t dcerpc_fault_from_nt_status(NTSTATUS nt_status);
120
121 /* The following definitions come from ../librpc/rpc/binding.c  */
122
123 const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
124 char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
125 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
126 struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx,
127                                           const struct dcerpc_binding *b);
128 NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx,
129                                     const struct dcerpc_binding *binding,
130                                     struct epm_tower *tower);
131 NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
132                                    struct epm_tower *tower,
133                                    struct dcerpc_binding **b_out);
134 NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out);
135 char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b);
136 struct GUID dcerpc_binding_get_object(const struct dcerpc_binding *b);
137 NTSTATUS dcerpc_binding_set_object(struct dcerpc_binding *b,
138                                    struct GUID object);
139 enum dcerpc_transport_t dcerpc_binding_get_transport(const struct dcerpc_binding *b);
140 NTSTATUS dcerpc_binding_set_transport(struct dcerpc_binding *b,
141                                       enum dcerpc_transport_t transport);
142 void dcerpc_binding_get_auth_info(const struct dcerpc_binding *b,
143                                   enum dcerpc_AuthType *_auth_type,
144                                   enum dcerpc_AuthLevel *_auth_level);
145 uint32_t dcerpc_binding_get_assoc_group_id(const struct dcerpc_binding *b);
146 NTSTATUS dcerpc_binding_set_assoc_group_id(struct dcerpc_binding *b,
147                                            uint32_t assoc_group_id);
148 struct ndr_syntax_id dcerpc_binding_get_abstract_syntax(const struct dcerpc_binding *b);
149 NTSTATUS dcerpc_binding_set_abstract_syntax(struct dcerpc_binding *b,
150                                             const struct ndr_syntax_id *syntax);
151 const char *dcerpc_binding_get_string_option(const struct dcerpc_binding *b,
152                                              const char *name);
153 char *dcerpc_binding_copy_string_option(TALLOC_CTX *mem_ctx,
154                                         const struct dcerpc_binding *b,
155                                         const char *name);
156 NTSTATUS dcerpc_binding_set_string_option(struct dcerpc_binding *b,
157                                           const char *name,
158                                           const char *value);
159 void *_dcerpc_binding_get_pointer_option(const struct dcerpc_binding *b,
160                                          const char *name,
161                                          const char *type);
162 #define dcerpc_binding_get_pointer_option(b, name, type) \
163         talloc_get_type(_dcerpc_binding_get_pointer_option(b, name, #type), type)
164 NTSTATUS _dcerpc_binding_set_pointer_option(struct dcerpc_binding *b,
165                                             const char *name,
166                                             const char *type,
167                                             const void *vp);
168 #define dcerpc_binding_set_pointer_option(b, name, type, vp) \
169         _dcerpc_binding_set_pointer_option(b, name, #type, vp)
170 uint32_t dcerpc_binding_get_flags(const struct dcerpc_binding *b);
171 NTSTATUS dcerpc_binding_set_flags(struct dcerpc_binding *b,
172                                   uint32_t additional,
173                                   uint32_t clear);
174 NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor, struct ndr_syntax_id *syntax);
175 const char *derpc_transport_string_by_transport(enum dcerpc_transport_t t);
176 enum dcerpc_transport_t dcerpc_transport_by_name(const char *name);
177 enum dcerpc_transport_t dcerpc_transport_by_tower(const struct epm_tower *tower);
178
179 /* The following definitions come from ../librpc/rpc/dcerpc_util.c  */
180
181 void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v);
182 uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob);
183 void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v);
184 uint16_t dcerpc_get_auth_length(const DATA_BLOB *blob);
185 uint8_t dcerpc_get_endian_flag(DATA_BLOB *blob);
186 uint8_t dcerpc_get_auth_type(const DATA_BLOB *blob);
187 uint8_t dcerpc_get_auth_level(const DATA_BLOB *blob);
188 uint32_t dcerpc_get_auth_context_id(const DATA_BLOB *blob);
189 const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
190                                               enum dcerpc_transport_t transport,
191                                               const struct ndr_interface_table *table);
192
193 NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
194                                   const DATA_BLOB *blob,
195                                   struct ncacn_packet *r);
196
197 /**
198 * @brief        Pull a dcerpc_auth structure, taking account of any auth
199 *               padding in the blob. For request/response packets we pass
200 *               the whole data blob, so auth_data_only must be set to false
201 *               as the blob contains data+pad+auth and no just pad+auth.
202 *
203 * @param pkt            - The ncacn_packet strcuture
204 * @param mem_ctx        - The mem_ctx used to allocate dcerpc_auth elements
205 * @param pkt_trailer    - The packet trailer data, usually the trailing
206 *                         auth_info blob, but in the request/response case
207 *                         this is the stub_and_verifier blob.
208 * @param auth           - A preallocated dcerpc_auth *empty* structure
209 * @param auth_length    - The length of the auth trail, sum of auth header
210 *                         lenght and pkt->auth_length
211 * @param auth_data_only - Whether the pkt_trailer includes only the auth_blob
212 *                         (+ padding) or also other data.
213 *
214 * @return               - A NTSTATUS error code.
215 */
216 NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt,
217                                   TALLOC_CTX *mem_ctx,
218                                   const DATA_BLOB *pkt_trailer,
219                                   struct dcerpc_auth *auth,
220                                   uint32_t *auth_length,
221                                   bool auth_data_only);
222 NTSTATUS dcerpc_verify_ncacn_packet_header(const struct ncacn_packet *pkt,
223                                            enum dcerpc_pkt_type ptype,
224                                            size_t max_auth_info,
225                                            uint8_t required_flags,
226                                            uint8_t optional_flags);
227 NTSTATUS dcerpc_ncacn_pull_pkt_auth(const struct dcerpc_auth *auth_state,
228                                     struct gensec_security *gensec,
229                                     TALLOC_CTX *mem_ctx,
230                                     enum dcerpc_pkt_type ptype,
231                                     uint8_t required_flags,
232                                     uint8_t optional_flags,
233                                     uint8_t payload_offset,
234                                     DATA_BLOB *payload_and_verifier,
235                                     DATA_BLOB *raw_packet,
236                                     const struct ncacn_packet *pkt);
237 NTSTATUS dcerpc_ncacn_push_pkt_auth(const struct dcerpc_auth *auth_state,
238                                     struct gensec_security *gensec,
239                                     TALLOC_CTX *mem_ctx,
240                                     DATA_BLOB *raw_packet,
241                                     size_t sig_size,
242                                     uint8_t payload_offset,
243                                     const DATA_BLOB *payload,
244                                     const struct ncacn_packet *pkt);
245 struct tevent_req *dcerpc_read_ncacn_packet_send(TALLOC_CTX *mem_ctx,
246                                                  struct tevent_context *ev,
247                                                  struct tstream_context *stream);
248 NTSTATUS dcerpc_read_ncacn_packet_recv(struct tevent_req *req,
249                                        TALLOC_CTX *mem_ctx,
250                                        struct ncacn_packet **pkt,
251                                        DATA_BLOB *buffer);
252
253 /* The following definitions come from ../librpc/rpc/binding_handle.c  */
254
255 struct dcerpc_binding_handle_ops {
256         const char *name;
257
258         bool (*is_connected)(struct dcerpc_binding_handle *h);
259         uint32_t (*set_timeout)(struct dcerpc_binding_handle *h,
260                                 uint32_t timeout);
261
262         void (*auth_info)(struct dcerpc_binding_handle *h,
263                           enum dcerpc_AuthType *auth_type,
264                           enum dcerpc_AuthLevel *auth_level);
265
266         struct tevent_req *(*raw_call_send)(TALLOC_CTX *mem_ctx,
267                                             struct tevent_context *ev,
268                                             struct dcerpc_binding_handle *h,
269                                             const struct GUID *object,
270                                             uint32_t opnum,
271                                             uint32_t in_flags,
272                                             const uint8_t *in_data,
273                                             size_t in_length);
274         NTSTATUS (*raw_call_recv)(struct tevent_req *req,
275                                   TALLOC_CTX *mem_ctx,
276                                   uint8_t **out_data,
277                                   size_t *out_length,
278                                   uint32_t *out_flags);
279
280         struct tevent_req *(*disconnect_send)(TALLOC_CTX *mem_ctx,
281                                               struct tevent_context *ev,
282                                               struct dcerpc_binding_handle *h);
283         NTSTATUS (*disconnect_recv)(struct tevent_req *req);
284
285         /* TODO: remove the following functions */
286         bool (*push_bigendian)(struct dcerpc_binding_handle *h);
287         bool (*ref_alloc)(struct dcerpc_binding_handle *h);
288         bool (*use_ndr64)(struct dcerpc_binding_handle *h);
289         void (*do_ndr_print)(struct dcerpc_binding_handle *h,
290                              int ndr_flags,
291                              const void *struct_ptr,
292                              const struct ndr_interface_call *call);
293         void (*ndr_push_failed)(struct dcerpc_binding_handle *h,
294                                 NTSTATUS error,
295                                 const void *struct_ptr,
296                                 const struct ndr_interface_call *call);
297         void (*ndr_pull_failed)(struct dcerpc_binding_handle *h,
298                                 NTSTATUS error,
299                                 const DATA_BLOB *blob,
300                                 const struct ndr_interface_call *call);
301         NTSTATUS (*ndr_validate_in)(struct dcerpc_binding_handle *h,
302                                     TALLOC_CTX *mem_ctx,
303                                     const DATA_BLOB *blob,
304                                     const struct ndr_interface_call *call);
305         NTSTATUS (*ndr_validate_out)(struct dcerpc_binding_handle *h,
306                                      struct ndr_pull *pull_in,
307                                      const void *struct_ptr,
308                                      const struct ndr_interface_call *call);
309 };
310
311 struct dcerpc_binding_handle *_dcerpc_binding_handle_create(TALLOC_CTX *mem_ctx,
312                                         const struct dcerpc_binding_handle_ops *ops,
313                                         const struct GUID *object,
314                                         const struct ndr_interface_table *table,
315                                         void *pstate,
316                                         size_t psize,
317                                         const char *type,
318                                         const char *location);
319 #define dcerpc_binding_handle_create(mem_ctx, ops, object, table, \
320                                 state, type, location) \
321         _dcerpc_binding_handle_create(mem_ctx, ops, object, table, \
322                                 state, sizeof(type), #type, location)
323
324 void *_dcerpc_binding_handle_data(struct dcerpc_binding_handle *h);
325 #define dcerpc_binding_handle_data(_h, _type) \
326         talloc_get_type_abort(_dcerpc_binding_handle_data(_h), _type)
327
328 _DEPRECATED_ void dcerpc_binding_handle_set_sync_ev(struct dcerpc_binding_handle *h,
329                                                     struct tevent_context *ev);
330
331 bool dcerpc_binding_handle_is_connected(struct dcerpc_binding_handle *h);
332
333 uint32_t dcerpc_binding_handle_set_timeout(struct dcerpc_binding_handle *h,
334                                            uint32_t timeout);
335
336 void dcerpc_binding_handle_auth_info(struct dcerpc_binding_handle *h,
337                                      enum dcerpc_AuthType *auth_type,
338                                      enum dcerpc_AuthLevel *auth_level);
339
340 struct tevent_req *dcerpc_binding_handle_raw_call_send(TALLOC_CTX *mem_ctx,
341                                                 struct tevent_context *ev,
342                                                 struct dcerpc_binding_handle *h,
343                                                 const struct GUID *object,
344                                                 uint32_t opnum,
345                                                 uint32_t in_flags,
346                                                 const uint8_t *in_data,
347                                                 size_t in_length);
348 NTSTATUS dcerpc_binding_handle_raw_call_recv(struct tevent_req *req,
349                                              TALLOC_CTX *mem_ctx,
350                                              uint8_t **out_data,
351                                              size_t *out_length,
352                                              uint32_t *out_flags);
353 NTSTATUS dcerpc_binding_handle_raw_call(struct dcerpc_binding_handle *h,
354                                         const struct GUID *object,
355                                         uint32_t opnum,
356                                         uint32_t in_flags,
357                                         const uint8_t *in_data,
358                                         size_t in_length,
359                                         TALLOC_CTX *mem_ctx,
360                                         uint8_t **out_data,
361                                         size_t *out_length,
362                                         uint32_t *out_flags);
363
364 struct tevent_req *dcerpc_binding_handle_disconnect_send(TALLOC_CTX *mem_ctx,
365                                                 struct tevent_context *ev,
366                                                 struct dcerpc_binding_handle *h);
367 NTSTATUS dcerpc_binding_handle_disconnect_recv(struct tevent_req *req);
368
369 struct tevent_req *dcerpc_binding_handle_call_send(TALLOC_CTX *mem_ctx,
370                                         struct tevent_context *ev,
371                                         struct dcerpc_binding_handle *h,
372                                         const struct GUID *object,
373                                         const struct ndr_interface_table *table,
374                                         uint32_t opnum,
375                                         TALLOC_CTX *r_mem,
376                                         void *r_ptr);
377 NTSTATUS dcerpc_binding_handle_call_recv(struct tevent_req *req);
378 NTSTATUS dcerpc_binding_handle_call(struct dcerpc_binding_handle *h,
379                                     const struct GUID *object,
380                                     const struct ndr_interface_table *table,
381                                     uint32_t opnum,
382                                     TALLOC_CTX *r_mem,
383                                     void *r_ptr);
384
385 /**
386  * Extract header information from a ncacn_packet
387  * as a dcerpc_sec_vt_header2 as used by the security verification trailer.
388  *
389  * @param[in] pkt a packet
390  *
391  * @return a dcerpc_sec_vt_header2
392  */
393 struct dcerpc_sec_vt_header2 dcerpc_sec_vt_header2_from_ncacn_packet(const struct ncacn_packet *pkt);
394
395
396 /**
397  * Test if two dcerpc_sec_vt_header2 structures are equal
398  * without consideration of reserved fields.
399  *
400  * @param v1 a pointer to a dcerpc_sec_vt_header2 structure
401  * @param v2 a pointer to a dcerpc_sec_vt_header2 structure
402  *
403  * @retval true if *v1 equals *v2
404  */
405 bool dcerpc_sec_vt_header2_equal(const struct dcerpc_sec_vt_header2 *v1,
406                                  const struct dcerpc_sec_vt_header2 *v2);
407
408 /**
409  * Check for consistency of the security verification trailer with the PDU header.
410  * See <a href="http://msdn.microsoft.com/en-us/library/cc243559.aspx">MS-RPCE 2.2.2.13</a>.
411  * A check with an empty trailer succeeds.
412  *
413  * @param[in] vt a pointer to the security verification trailer.
414  * @param[in] bitmask1 which flags were negotiated on the connection.
415  * @param[in] pcontext the syntaxes negotiatied for the presentation context.
416  * @param[in] header2 some fields from the PDU header.
417  *
418  * @retval true on success.
419  */
420 bool dcerpc_sec_verification_trailer_check(
421                 const struct dcerpc_sec_verification_trailer *vt,
422                 const uint32_t *bitmask1,
423                 const struct dcerpc_sec_vt_pcontext *pcontext,
424                 const struct dcerpc_sec_vt_header2 *header2);
425
426 /**
427  * @brief check and optionally extract the Bind Time Features from
428  * the given ndr_syntax_id.
429  *
430  * <a href="http://msdn.microsoft.com/en-us/library/cc243715.aspx">MS-RPCE 3.3.1.5.3 Bind Time Feature Negotiation</a>.
431  *
432  * @param[in]  s the syntax that should be checked.
433  *
434  * @param[out] features This is optional, it will be filled with the extracted
435  *                      features the on success, otherwise it's filled with 0.
436  *
437  * @return true if the syntax matches the 6CB71C2C-9812-4540 prefix with version 1, false otherwise.
438  *
439  * @see dcerpc_construct_bind_time_features
440  */
441 bool dcerpc_extract_bind_time_features(struct ndr_syntax_id syntax, uint64_t *features);
442
443 /**
444  * @brief Construct a ndr_syntax_id used for Bind Time Features Negotiation.
445  *
446  * <a href="http://msdn.microsoft.com/en-us/library/cc243715.aspx">MS-RPCE 3.3.1.5.3 Bind Time Feature Negotiation</a>.
447  *
448  * @param[in] features The supported features.
449  *
450  * @return The ndr_syntax_id with the given features.
451  *
452  * @see dcerpc_extract_bind_time_features
453  */
454 struct ndr_syntax_id dcerpc_construct_bind_time_features(uint64_t features);
455
456 #define DCERPC_AUTH_PAD_LENGTH(stub_length) (\
457         (((stub_length) % DCERPC_AUTH_PAD_ALIGNMENT) > 0)?\
458         (DCERPC_AUTH_PAD_ALIGNMENT - (stub_length) % DCERPC_AUTH_PAD_ALIGNMENT):\
459         0)
460
461 struct dcerpc_pipe_handle_connection *dcerpc_pipe_handle_connection_create(
462                                         TALLOC_CTX *mem_ctx,
463                                         const char *chunk_struct_name,
464                                         size_t chunk_struct_size);
465 bool _dcerpc_pipe_handle_connection_connect(
466                                 struct dcerpc_pipe_handle_connection *pc,
467                                 const char *chunk_struct_name,
468                                 size_t chunk_struct_size,
469                                 struct dcerpc_pipe_handle *p,
470                                 bool push);
471 #define dcerpc_pipe_handle_connection_push_connect(pc, csn, css, p) \
472         _dcerpc_pipe_handle_connection_connect(pc, csn, css, p, true)
473 #define dcerpc_pipe_handle_connection_pull_connect(pc, csn, css, p) \
474         _dcerpc_pipe_handle_connection_connect(pc, csn, css, p, false)
475 void dcerpc_pipe_handle_connection_disconnect(
476                                 struct dcerpc_pipe_handle_connection *pc);
477
478 struct dcerpc_pipe_handle_ops {
479         const char *name;
480
481         struct tevent_req *(*chunk_push_send)(TALLOC_CTX *mem_ctx,
482                                             struct tevent_context *ev,
483                                             struct dcerpc_pipe_handle *p,
484                                             const void *chunk_ptr);
485         NTSTATUS (*chunk_push_recv)(struct tevent_req *req);
486
487         struct tevent_req *(*chunk_pull_send)(TALLOC_CTX *mem_ctx,
488                                             struct tevent_context *ev,
489                                             struct dcerpc_pipe_handle *p,
490                                             void *chunk_mem,
491                                             void *chunk_ptr);
492         NTSTATUS (*chunk_pull_recv)(struct tevent_req *req);
493 };
494
495 struct dcerpc_pipe_handle *_dcerpc_pipe_handle_create(
496                                         TALLOC_CTX *mem_ctx,
497                                         const struct dcerpc_pipe_handle_ops *ops,
498                                         void *pstate,
499                                         size_t psize,
500                                         const char *type,
501                                         const char *location);
502 #define dcerpc_pipe_handle_create(mem_ctx, ops, \
503                                   state, type) \
504         _dcerpc_pipe_handle_create(mem_ctx, ops, \
505                                 state, sizeof(type), #type, __location__)
506
507 void *_dcerpc_pipe_handle_data(struct dcerpc_pipe_handle *p);
508 #define dcerpc_pipe_handle_data(_p, _type) \
509         talloc_get_type_abort(_dcerpc_pipe_handle_data(_p), _type)
510
511 struct tevent_req *dcerpc_pipe_handle_push_send(TALLOC_CTX *mem_ctx,
512                                         struct tevent_context *ev,
513                                         struct dcerpc_pipe_handle_connection *pc,
514                                         const void *chunk_ptr);
515 NTSTATUS dcerpc_pipe_handle_push_recv(struct tevent_req *req);
516
517 struct tevent_req *dcerpc_pipe_handle_pull_send(TALLOC_CTX *mem_ctx,
518                                         struct tevent_context *ev,
519                                         struct dcerpc_pipe_handle_connection *pc,
520                                         void *chunk_mem,
521                                         void *chunk_ptr);
522 NTSTATUS dcerpc_pipe_handle_pull_recv(struct tevent_req *req);
523
524 #endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */