libcli/smb: move smb2cli_flush.c from source3 to the toplevel
[Samba/gebeck_regimport.git] / libcli / smb / smbXcli_base.h
blobdf6ed31b3617949b1ab36c2aa71a980e1286a997
1 /*
2 Unix SMB/CIFS implementation.
3 Infrastructure for async SMB client requests
4 Copyright (C) Volker Lendecke 2008
5 Copyright (C) Stefan Metzmacher 2011
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 _SMBXCLI_BASE_H_
22 #define _SMBXCLI_BASE_H_
24 struct smbXcli_conn;
25 struct smbXcli_session;
26 struct smb_trans_enc_state;
27 struct GUID;
29 struct smbXcli_conn *smbXcli_conn_create(TALLOC_CTX *mem_ctx,
30 int fd,
31 const char *remote_name,
32 enum smb_signing_setting signing_state,
33 uint32_t smb1_capabilities,
34 struct GUID *client_guid,
35 uint32_t smb2_capabilities);
37 bool smbXcli_conn_is_connected(struct smbXcli_conn *conn);
38 void smbXcli_conn_disconnect(struct smbXcli_conn *conn, NTSTATUS status);
40 bool smbXcli_conn_has_async_calls(struct smbXcli_conn *conn);
42 enum protocol_types smbXcli_conn_protocol(struct smbXcli_conn *conn);
43 bool smbXcli_conn_use_unicode(struct smbXcli_conn *conn);
45 void smbXcli_conn_set_sockopt(struct smbXcli_conn *conn, const char *options);
46 const struct sockaddr_storage *smbXcli_conn_local_sockaddr(struct smbXcli_conn *conn);
47 const struct sockaddr_storage *smbXcli_conn_remote_sockaddr(struct smbXcli_conn *conn);
48 const char *smbXcli_conn_remote_name(struct smbXcli_conn *conn);
50 uint16_t smbXcli_conn_max_requests(struct smbXcli_conn *conn);
51 NTTIME smbXcli_conn_server_system_time(struct smbXcli_conn *conn);
52 const DATA_BLOB *smbXcli_conn_server_gss_blob(struct smbXcli_conn *conn);
53 const struct GUID *smbXcli_conn_server_guid(struct smbXcli_conn *conn);
55 struct tevent_req *smbXcli_conn_samba_suicide_send(TALLOC_CTX *mem_ctx,
56 struct tevent_context *ev,
57 struct smbXcli_conn *conn,
58 uint8_t exitcode);
59 NTSTATUS smbXcli_conn_samba_suicide_recv(struct tevent_req *req);
60 NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
61 uint8_t exitcode);
63 void smbXcli_req_unset_pending(struct tevent_req *req);
64 bool smbXcli_req_set_pending(struct tevent_req *req);
66 uint32_t smb1cli_conn_capabilities(struct smbXcli_conn *conn);
67 uint32_t smb1cli_conn_max_xmit(struct smbXcli_conn *conn);
68 uint32_t smb1cli_conn_server_session_key(struct smbXcli_conn *conn);
69 const uint8_t *smb1cli_conn_server_challenge(struct smbXcli_conn *conn);
70 uint16_t smb1cli_conn_server_security_mode(struct smbXcli_conn *conn);
71 bool smb1cli_conn_server_readbraw(struct smbXcli_conn *conn);
72 bool smb1cli_conn_server_writebraw(struct smbXcli_conn *conn);
73 bool smb1cli_conn_server_lockread(struct smbXcli_conn *conn);
74 bool smb1cli_conn_server_writeunlock(struct smbXcli_conn *conn);
75 int smb1cli_conn_server_time_zone(struct smbXcli_conn *conn);
77 bool smb1cli_conn_activate_signing(struct smbXcli_conn *conn,
78 const DATA_BLOB user_session_key,
79 const DATA_BLOB response);
80 bool smb1cli_conn_check_signing(struct smbXcli_conn *conn,
81 const uint8_t *buf, uint32_t seqnum);
82 bool smb1cli_conn_signing_is_active(struct smbXcli_conn *conn);
84 void smb1cli_conn_set_encryption(struct smbXcli_conn *conn,
85 struct smb_trans_enc_state *es);
86 bool smb1cli_conn_encryption_on(struct smbXcli_conn *conn);
88 bool smb1cli_is_andx_req(uint8_t cmd);
89 size_t smb1cli_req_wct_ofs(struct tevent_req **reqs, int num_reqs);
91 uint16_t smb1cli_req_mid(struct tevent_req *req);
92 void smb1cli_req_set_mid(struct tevent_req *req, uint16_t mid);
94 uint32_t smb1cli_req_seqnum(struct tevent_req *req);
95 void smb1cli_req_set_seqnum(struct tevent_req *req, uint32_t seqnum);
97 struct smb1cli_req_expected_response {
98 NTSTATUS status;
99 uint8_t wct;
102 struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx,
103 struct tevent_context *ev,
104 struct smbXcli_conn *conn,
105 uint8_t smb_command,
106 uint8_t additional_flags,
107 uint8_t clear_flags,
108 uint16_t additional_flags2,
109 uint16_t clear_flags2,
110 uint32_t timeout_msec,
111 uint32_t pid,
112 uint16_t tid,
113 uint16_t uid,
114 uint8_t wct, uint16_t *vwv,
115 int iov_count,
116 struct iovec *bytes_iov);
117 NTSTATUS smb1cli_req_chain_submit(struct tevent_req **reqs, int num_reqs);
119 struct tevent_req *smb1cli_req_send(TALLOC_CTX *mem_ctx,
120 struct tevent_context *ev,
121 struct smbXcli_conn *conn,
122 uint8_t smb_command,
123 uint8_t additional_flags,
124 uint8_t clear_flags,
125 uint16_t additional_flags2,
126 uint16_t clear_flags2,
127 uint32_t timeout_msec,
128 uint32_t pid,
129 uint16_t tid,
130 uint16_t uid,
131 uint8_t wct, uint16_t *vwv,
132 uint32_t num_bytes,
133 const uint8_t *bytes);
134 NTSTATUS smb1cli_req_recv(struct tevent_req *req,
135 TALLOC_CTX *mem_ctx,
136 struct iovec **piov,
137 uint8_t **phdr,
138 uint8_t *pwct,
139 uint16_t **pvwv,
140 uint32_t *pvwv_offset,
141 uint32_t *pnum_bytes,
142 uint8_t **pbytes,
143 uint32_t *pbytes_offset,
144 uint8_t **pinbuf,
145 const struct smb1cli_req_expected_response *expected,
146 size_t num_expected);
148 struct tevent_req *smb1cli_trans_send(
149 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
150 struct smbXcli_conn *conn, uint8_t cmd,
151 uint8_t additional_flags, uint8_t clear_flags,
152 uint16_t additional_flags2, uint16_t clear_flags2,
153 uint32_t timeout_msec,
154 uint32_t pid, uint16_t tid, uint16_t uid,
155 const char *pipe_name, uint16_t fid, uint16_t function, int flags,
156 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
157 uint8_t *param, uint32_t num_param, uint32_t max_param,
158 uint8_t *data, uint32_t num_data, uint32_t max_data);
159 NTSTATUS smb1cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
160 uint16_t *recv_flags2,
161 uint16_t **setup, uint8_t min_setup,
162 uint8_t *num_setup,
163 uint8_t **param, uint32_t min_param,
164 uint32_t *num_param,
165 uint8_t **data, uint32_t min_data,
166 uint32_t *num_data);
167 NTSTATUS smb1cli_trans(TALLOC_CTX *mem_ctx, struct smbXcli_conn *conn,
168 uint8_t trans_cmd,
169 uint8_t additional_flags, uint8_t clear_flags,
170 uint16_t additional_flags2, uint16_t clear_flags2,
171 uint32_t timeout_msec,
172 uint32_t pid, uint16_t tid, uint16_t uid,
173 const char *pipe_name, uint16_t fid, uint16_t function,
174 int flags,
175 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
176 uint8_t *param, uint32_t num_param, uint32_t max_param,
177 uint8_t *data, uint32_t num_data, uint32_t max_data,
178 uint16_t *recv_flags2,
179 uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
180 uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
181 uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
183 uint32_t smb2cli_conn_server_capabilities(struct smbXcli_conn *conn);
184 uint16_t smb2cli_conn_server_security_mode(struct smbXcli_conn *conn);
185 uint32_t smb2cli_conn_max_trans_size(struct smbXcli_conn *conn);
186 uint32_t smb2cli_conn_max_read_size(struct smbXcli_conn *conn);
187 uint32_t smb2cli_conn_max_write_size(struct smbXcli_conn *conn);
188 void smb2cli_conn_set_max_credits(struct smbXcli_conn *conn,
189 uint16_t max_credits);
191 struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
192 struct tevent_context *ev,
193 struct smbXcli_conn *conn,
194 uint16_t cmd,
195 uint32_t additional_flags,
196 uint32_t clear_flags,
197 uint32_t timeout_msec,
198 uint32_t pid,
199 uint32_t tid,
200 struct smbXcli_session *session,
201 const uint8_t *fixed,
202 uint16_t fixed_len,
203 const uint8_t *dyn,
204 uint32_t dyn_len);
205 void smb2cli_req_set_notify_async(struct tevent_req *req);
206 NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
207 int num_reqs);
208 void smb2cli_req_set_credit_charge(struct tevent_req *req, uint16_t charge);
210 struct smb2cli_req_expected_response {
211 NTSTATUS status;
212 uint16_t body_size;
215 struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
216 struct tevent_context *ev,
217 struct smbXcli_conn *conn,
218 uint16_t cmd,
219 uint32_t additional_flags,
220 uint32_t clear_flags,
221 uint32_t timeout_msec,
222 uint32_t pid,
223 uint32_t tid,
224 struct smbXcli_session *session,
225 const uint8_t *fixed,
226 uint16_t fixed_len,
227 const uint8_t *dyn,
228 uint32_t dyn_len);
229 NTSTATUS smb2cli_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
230 struct iovec **piov,
231 const struct smb2cli_req_expected_response *expected,
232 size_t num_expected);
234 struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
235 struct tevent_context *ev,
236 struct smbXcli_conn *conn,
237 uint32_t timeout_msec,
238 enum protocol_types min_protocol,
239 enum protocol_types max_protocol);
240 NTSTATUS smbXcli_negprot_recv(struct tevent_req *req);
241 NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
242 uint32_t timeout_msec,
243 enum protocol_types min_protocol,
244 enum protocol_types max_protocol);
246 struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx,
247 struct smbXcli_conn *conn);
248 uint8_t smb2cli_session_security_mode(struct smbXcli_session *session);
249 uint64_t smb2cli_session_current_id(struct smbXcli_session *session);
250 uint16_t smb2cli_session_get_flags(struct smbXcli_session *session);
251 NTSTATUS smb2cli_session_application_key(struct smbXcli_session *session,
252 TALLOC_CTX *mem_ctx,
253 DATA_BLOB *key);
254 void smb2cli_session_set_id_and_flags(struct smbXcli_session *session,
255 uint64_t session_id,
256 uint16_t session_flags);
257 NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
258 const DATA_BLOB session_key,
259 const struct iovec *recv_iov);
260 NTSTATUS smb2cli_session_create_channel(TALLOC_CTX *mem_ctx,
261 struct smbXcli_session *session1,
262 struct smbXcli_conn *conn,
263 struct smbXcli_session **_session2);
264 NTSTATUS smb2cli_session_set_channel_key(struct smbXcli_session *session,
265 const DATA_BLOB channel_key,
266 const struct iovec *recv_iov);
268 struct tevent_req *smb2cli_session_setup_send(TALLOC_CTX *mem_ctx,
269 struct tevent_context *ev,
270 struct smbXcli_conn *conn,
271 uint32_t timeout_msec,
272 struct smbXcli_session *session,
273 uint8_t in_flags,
274 uint32_t in_capabilities,
275 uint32_t in_channel,
276 uint64_t in_previous_session_id,
277 const DATA_BLOB *in_security_buffer);
278 NTSTATUS smb2cli_session_setup_recv(struct tevent_req *req,
279 TALLOC_CTX *mem_ctx,
280 struct iovec **recv_iov,
281 DATA_BLOB *out_security_buffer);
283 struct tevent_req *smb2cli_logoff_send(TALLOC_CTX *mem_ctx,
284 struct tevent_context *ev,
285 struct smbXcli_conn *conn,
286 uint32_t timeout_msec,
287 struct smbXcli_session *session);
288 NTSTATUS smb2cli_logoff_recv(struct tevent_req *req);
289 NTSTATUS smb2cli_logoff(struct smbXcli_conn *conn,
290 uint32_t timeout_msec,
291 struct smbXcli_session *session);
293 struct tevent_req *smb2cli_create_send(
294 TALLOC_CTX *mem_ctx,
295 struct tevent_context *ev,
296 struct smbXcli_conn *conn,
297 uint32_t timeout_msec,
298 struct smbXcli_session *session,
299 uint32_t tcon_id,
300 const char *filename,
301 uint8_t oplock_level, /* SMB2_OPLOCK_LEVEL_* */
302 uint32_t impersonation_level, /* SMB2_IMPERSONATION_* */
303 uint32_t desired_access,
304 uint32_t file_attributes,
305 uint32_t share_access,
306 uint32_t create_disposition,
307 uint32_t create_options,
308 struct smb2_create_blobs *blobs);
309 NTSTATUS smb2cli_create_recv(struct tevent_req *req,
310 uint64_t *fid_persistent,
311 uint64_t *fid_volatile);
312 NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
313 uint32_t timeout_msec,
314 struct smbXcli_session *session,
315 uint32_t tcon_id,
316 const char *filename,
317 uint8_t oplock_level, /* SMB2_OPLOCK_LEVEL_* */
318 uint32_t impersonation_level, /* SMB2_IMPERSONATION_* */
319 uint32_t desired_access,
320 uint32_t file_attributes,
321 uint32_t share_access,
322 uint32_t create_disposition,
323 uint32_t create_options,
324 struct smb2_create_blobs *blobs,
325 uint64_t *fid_persistent,
326 uint64_t *fid_volatile);
328 struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx,
329 struct tevent_context *ev,
330 struct smbXcli_conn *conn,
331 uint32_t timeout_msec,
332 struct smbXcli_session *session,
333 uint32_t tcon_id,
334 uint16_t flags,
335 uint64_t fid_persistent,
336 uint64_t fid_volatile);
337 NTSTATUS smb2cli_close_recv(struct tevent_req *req);
338 NTSTATUS smb2cli_close(struct smbXcli_conn *conn,
339 uint32_t timeout_msec,
340 struct smbXcli_session *session,
341 uint32_t tcon_id,
342 uint16_t flags,
343 uint64_t fid_persistent,
344 uint64_t fid_volatile);
346 struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx,
347 struct tevent_context *ev,
348 struct smbXcli_conn *conn,
349 uint32_t timeout_msec,
350 struct smbXcli_session *session,
351 uint32_t tcon_id,
352 uint32_t length,
353 uint64_t offset,
354 uint64_t fid_persistent,
355 uint64_t fid_volatile,
356 uint64_t minimum_count,
357 uint64_t remaining_bytes);
358 NTSTATUS smb2cli_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
359 uint8_t **data, uint32_t *data_length);
360 NTSTATUS smb2cli_read(struct smbXcli_conn *conn,
361 uint32_t timeout_msec,
362 struct smbXcli_session *session,
363 uint32_t tcon_id,
364 uint32_t length,
365 uint64_t offset,
366 uint64_t fid_persistent,
367 uint64_t fid_volatile,
368 uint64_t minimum_count,
369 uint64_t remaining_bytes,
370 TALLOC_CTX *mem_ctx,
371 uint8_t **data,
372 uint32_t *data_length);
374 struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx,
375 struct tevent_context *ev,
376 struct smbXcli_conn *conn,
377 uint32_t timeout_msec,
378 struct smbXcli_session *session,
379 uint32_t tcon_id,
380 uint32_t length,
381 uint64_t offset,
382 uint64_t fid_persistent,
383 uint64_t fid_volatile,
384 uint32_t remaining_bytes,
385 uint32_t flags,
386 const uint8_t *data);
387 NTSTATUS smb2cli_write_recv(struct tevent_req *req);
388 NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
389 uint32_t timeout_msec,
390 struct smbXcli_session *session,
391 uint32_t tcon_id,
392 uint32_t length,
393 uint64_t offset,
394 uint64_t fid_persistent,
395 uint64_t fid_volatile,
396 uint32_t remaining_bytes,
397 uint32_t flags,
398 const uint8_t *data);
400 struct tevent_req *smb2cli_flush_send(TALLOC_CTX *mem_ctx,
401 struct tevent_context *ev,
402 struct smbXcli_conn *conn,
403 uint32_t timeout_msec,
404 struct smbXcli_session *session,
405 uint32_t tcon_id,
406 uint64_t fid_persistent,
407 uint64_t fid_volatile);
408 NTSTATUS smb2cli_flush_recv(struct tevent_req *req);
409 NTSTATUS smb2cli_flush(struct smbXcli_conn *conn,
410 uint32_t timeout_msec,
411 struct smbXcli_session *session,
412 uint32_t tcon_id,
413 uint64_t fid_persistent,
414 uint64_t fid_volatile);
416 #endif /* _SMBXCLI_BASE_H_ */