3f5216bdecc0693e6189933fc3ee3b07ba07e5c0
[samba.git] / librpc / rpc / rpc_common.h
1 #ifndef __DEFAULT_LIBRPC_RPCCOMMON_H__
2 #define __DEFAULT_LIBRPC_RPCCOMMON_H__
3
4 /* The following definitions come from ../librpc/rpc/dcerpc_error.c  */
5
6
7 /* The following definitions come from ../librpc/rpc/binding.c  */
8
9 const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
10 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
11 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
12
13 /* The following definitions come from ../librpc/rpc/dcerpc_util.c  */
14
15 void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v);
16 uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob);
17 void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v);
18 uint8_t dcerpc_get_endian_flag(DATA_BLOB *blob);
19
20 /**
21 * @brief        Pull a dcerpc_auth structure, taking account of any auth
22 *               padding in the blob. For request/response packets we pass
23 *               the whole data blob, so auth_data_only must be set to false
24 *               as the blob contains data+pad+auth and no just pad+auth.
25 *
26 * @param pkt            - The ncacn_packet strcuture
27 * @param mem_ctx        - The mem_ctx used to allocate dcerpc_auth elements
28 * @param pkt_trailer    - The packet trailer data, usually the trailing
29 *                         auth_info blob, but in the request/response case
30 *                         this is the stub_and_verifier blob.
31 * @param auth           - A preallocated dcerpc_auth *empty* structure
32 * @param auth_length    - The length of the auth trail, sum of auth header
33 *                         lenght and pkt->auth_length
34 * @param auth_data_only - Whether the pkt_trailer includes only the auth_blob
35 *                         (+ padding) or also other data.
36 *
37 * @return               - A NTSTATUS error code.
38 */
39 NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt,
40                                   TALLOC_CTX *mem_ctx,
41                                   DATA_BLOB *pkt_trailer,
42                                   struct dcerpc_auth *auth,
43                                   uint32_t *auth_length,
44                                   bool auth_data_only);
45 struct tevent_req *dcerpc_read_ncacn_packet_send(TALLOC_CTX *mem_ctx,
46                                                  struct tevent_context *ev,
47                                                  struct tstream_context *stream);
48 NTSTATUS dcerpc_read_ncacn_packet_recv(struct tevent_req *req,
49                                        TALLOC_CTX *mem_ctx,
50                                        struct ncacn_packet **pkt,
51                                        DATA_BLOB *buffer);
52
53 /* The following definitions come from ../librpc/rpc/binding_handle.c  */
54
55 struct dcerpc_binding_handle *_dcerpc_binding_handle_create(TALLOC_CTX *mem_ctx,
56                                         const struct dcerpc_binding_handle_ops *ops,
57                                         const struct GUID *object,
58                                         const struct ndr_interface_table *table,
59                                         void *pstate,
60                                         size_t psize,
61                                         const char *type,
62                                         const char *location);
63 void *_dcerpc_binding_handle_data(struct dcerpc_binding_handle *h);
64 void dcerpc_binding_handle_set_sync_ev(struct dcerpc_binding_handle *h,
65                                        struct tevent_context *ev);
66 bool dcerpc_binding_handle_is_connected(struct dcerpc_binding_handle *h);
67 uint32_t dcerpc_binding_handle_set_timeout(struct dcerpc_binding_handle *h,
68                                            uint32_t timeout);
69 struct tevent_req *dcerpc_binding_handle_raw_call_send(TALLOC_CTX *mem_ctx,
70                                                 struct tevent_context *ev,
71                                                 struct dcerpc_binding_handle *h,
72                                                 const struct GUID *object,
73                                                 uint32_t opnum,
74                                                 uint32_t in_flags,
75                                                 const uint8_t *in_data,
76                                                 size_t in_length);
77 NTSTATUS dcerpc_binding_handle_raw_call_recv(struct tevent_req *req,
78                                              TALLOC_CTX *mem_ctx,
79                                              uint8_t **out_data,
80                                              size_t *out_length,
81                                              uint32_t *out_flags);
82 struct tevent_req *dcerpc_binding_handle_disconnect_send(TALLOC_CTX *mem_ctx,
83                                                 struct tevent_context *ev,
84                                                 struct dcerpc_binding_handle *h);
85 NTSTATUS dcerpc_binding_handle_disconnect_recv(struct tevent_req *req);
86 struct tevent_req *dcerpc_binding_handle_call_send(TALLOC_CTX *mem_ctx,
87                                         struct tevent_context *ev,
88                                         struct dcerpc_binding_handle *h,
89                                         const struct GUID *object,
90                                         const struct ndr_interface_table *table,
91                                         uint32_t opnum,
92                                         TALLOC_CTX *r_mem,
93                                         void *r_ptr);
94 NTSTATUS dcerpc_binding_handle_call_recv(struct tevent_req *req);
95 NTSTATUS dcerpc_binding_handle_call(struct dcerpc_binding_handle *h,
96                                     const struct GUID *object,
97                                     const struct ndr_interface_table *table,
98                                     uint32_t opnum,
99                                     TALLOC_CTX *r_mem,
100                                     void *r_ptr);
101 #endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */