s3:pylibsmb: Make .list() work for SMBv2
[samba.git] / source3 / rpc_client / rpc_transport.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  RPC client transport
4  *  Copyright (C) Volker Lendecke 2009
5  *  Copyright (C) Simo Sorce 2010
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef _RPC_CLIENT_RPC_TRANSPORT_H_
22 #define _RPC_CLIENT_RPC_TRANSPORT_H_
23
24 #include "librpc/rpc/dcerpc.h"
25
26 /**
27  * rpc_cli_transport defines a transport mechanism to ship rpc requests
28  * asynchronously to a server and receive replies
29  */
30
31 struct rpc_cli_transport {
32
33         enum dcerpc_transport_t transport;
34
35         /**
36          * Trigger an async read from the server. May return a short read.
37          */
38         struct tevent_req *(*read_send)(TALLOC_CTX *mem_ctx,
39                                         struct tevent_context *ev,
40                                         uint8_t *data, size_t size,
41                                         void *priv);
42         /**
43          * Get the result from the read_send operation.
44          */
45         NTSTATUS (*read_recv)(struct tevent_req *req, ssize_t *preceived);
46
47         /**
48          * Trigger an async write to the server. May return a short write.
49          */
50         struct tevent_req *(*write_send)(TALLOC_CTX *mem_ctx,
51                                          struct tevent_context *ev,
52                                          const uint8_t *data, size_t size,
53                                          void *priv);
54         /**
55          * Get the result from the read_send operation.
56          */
57         NTSTATUS (*write_recv)(struct tevent_req *req, ssize_t *psent);
58
59         /**
60          * This is an optimization for the SMB transport. It models the
61          * TransactNamedPipe API call: Send and receive data in one round
62          * trip. The transport implementation is free to set this to NULL,
63          * cli_pipe.c will fall back to the explicit write/read routines.
64          */
65         struct tevent_req *(*trans_send)(TALLOC_CTX *mem_ctx,
66                                          struct tevent_context *ev,
67                                          const uint8_t *data, size_t data_len,
68                                          uint32_t max_rdata_len,
69                                          void *priv);
70         /**
71          * Get the result from the trans_send operation.
72          */
73         NTSTATUS (*trans_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx,
74                                uint8_t **prdata, uint32_t *prdata_len);
75
76         bool (*is_connected)(void *priv);
77         unsigned int (*set_timeout)(void *priv, unsigned int timeout);
78
79         void *priv;
80 };
81
82 /* The following definitions come from rpc_client/rpc_transport_np.c  */
83 struct cli_state;
84 struct tevent_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
85                                               struct tevent_context *ev,
86                                               struct cli_state *cli,
87                                               const struct ndr_interface_table *table);
88 NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
89                                     TALLOC_CTX *mem_ctx,
90                                     struct rpc_cli_transport **presult);
91 NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
92                                const struct ndr_interface_table *table,
93                                struct rpc_cli_transport **presult);
94
95 /* The following definitions come from rpc_client/rpc_transport_sock.c  */
96
97 NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
98                                  struct rpc_cli_transport **presult);
99
100 /* The following definitions come from rpc_client/rpc_transport_tstream.c  */
101
102 NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx,
103                                 struct tstream_context **stream,
104                                 struct rpc_cli_transport **presult);
105
106 #endif /* _RPC_CLIENT_RPC_TRANSPORT_H_ */