util:datablob: data_blob_pad checks its alignment assumption
[samba.git] / source3 / rpc_client / rpc_transport.h
blob6c08860de17b386bcd66b9c95b4b1e154c7f4647
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC client transport
4 * Copyright (C) Volker Lendecke 2009
5 * Copyright (C) Simo Sorce 2010
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.
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.
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/>.
21 #ifndef _RPC_CLIENT_RPC_TRANSPORT_H_
22 #define _RPC_CLIENT_RPC_TRANSPORT_H_
24 #include "librpc/rpc/dcerpc.h"
26 /**
27 * rpc_cli_transport defines a transport mechanism to ship rpc requests
28 * asynchronously to a server and receive replies
31 struct rpc_cli_transport {
33 enum dcerpc_transport_t transport;
35 /**
36 * Trigger an async read from the server. May return a short read.
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.
45 NTSTATUS (*read_recv)(struct tevent_req *req, ssize_t *preceived);
47 /**
48 * Trigger an async write to the server. May return a short write.
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.
57 NTSTATUS (*write_recv)(struct tevent_req *req, ssize_t *psent);
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.
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.
73 NTSTATUS (*trans_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx,
74 uint8_t **prdata, uint32_t *prdata_len);
76 bool (*is_connected)(void *priv);
77 unsigned int (*set_timeout)(void *priv, unsigned int timeout);
79 void *priv;
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 char *pipe_name);
88 NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
89 TALLOC_CTX *mem_ctx,
90 struct rpc_cli_transport **presult);
92 /* The following definitions come from rpc_client/rpc_transport_sock.c */
94 NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
95 struct rpc_cli_transport **presult);
97 /* The following definitions come from rpc_client/rpc_transport_tstream.c */
99 NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx,
100 struct tstream_context **stream,
101 struct rpc_cli_transport **presult);
102 struct tstream_context *rpc_transport_get_tstream(
103 struct rpc_cli_transport *transport);
104 #endif /* _RPC_CLIENT_RPC_TRANSPORT_H_ */