libcli/smb: move {smb,trans2}_bytes_push_{str,bytes}() to common code
[Samba.git] / source3 / libsmb / proto.h
blob6355c2433e7a1006ff97226e03175247bbd176d1
1 /*
2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Bartlett 2001-2003
5 Copyright (C) Andrew Tridgell 1994-1998,2000-2001
6 Copyright (C) Gerald (Jerry) Carter 2004
7 Copyright (C) Jelmer Vernooij 2003
8 Copyright (C) Jeremy Allison 2001-2009,2011
9 Copyright (C) Stefan Metzmacher 2003,2009
10 Copyright (C) Volker Lendecke 2011
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #ifndef _LIBSMB_PROTO_H_
27 #define _LIBSMB_PROTO_H_
29 #include "ads.h"
30 #include "auth_info.h"
32 struct smb_trans_enc_state;
34 /* The following definitions come from libsmb/cliconnect.c */
36 struct tevent_req *cli_session_setup_send(TALLOC_CTX *mem_ctx,
37 struct tevent_context *ev,
38 struct cli_state *cli,
39 const char *user,
40 const char *pass,
41 const char *workgroup);
42 NTSTATUS cli_session_setup_recv(struct tevent_req *req);
43 NTSTATUS cli_session_setup(struct cli_state *cli,
44 const char *user,
45 const char *pass,
46 const char *workgroup);
47 struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
48 struct tevent_context *ev,
49 struct cli_state *cli,
50 struct tevent_req **psmbreq);
51 struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
52 struct tevent_context *ev,
53 struct cli_state *cli);
54 NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
55 NTSTATUS cli_ulogoff(struct cli_state *cli);
56 struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
57 struct tevent_context *ev,
58 struct cli_state *cli,
59 const char *share, const char *dev,
60 const char *pass, int passlen,
61 struct tevent_req **psmbreq);
62 struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
63 struct tevent_context *ev,
64 struct cli_state *cli,
65 const char *share, const char *dev,
66 const char *pass, int passlen);
67 NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
68 NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
69 const char *dev, const char *pass, int passlen);
70 NTSTATUS cli_tree_connect(struct cli_state *cli, const char *share,
71 const char *dev, const char *pass, int passlen);
72 NTSTATUS cli_tdis(struct cli_state *cli);
73 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
74 uint16_t port, int name_type, const char *myname,
75 int signing_state, int flags, struct cli_state **pcli);
76 NTSTATUS cli_start_connection(struct cli_state **output_cli,
77 const char *my_name,
78 const char *dest_host,
79 const struct sockaddr_storage *dest_ss, int port,
80 int signing_state, int flags);
81 struct tevent_req *cli_full_connection_send(
82 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
83 const char *my_name, const char *dest_host,
84 const struct sockaddr_storage *dest_ss, int port,
85 const char *service, const char *service_type,
86 const char *user, const char *domain,
87 const char *password, int flags, int signing_state);
88 NTSTATUS cli_full_connection_recv(struct tevent_req *req,
89 struct cli_state **output_cli);
90 NTSTATUS cli_full_connection(struct cli_state **output_cli,
91 const char *my_name,
92 const char *dest_host,
93 const struct sockaddr_storage *dest_ss, int port,
94 const char *service, const char *service_type,
95 const char *user, const char *domain,
96 const char *password, int flags,
97 int signing_state);
98 NTSTATUS cli_raw_tcon(struct cli_state *cli,
99 const char *service, const char *pass, const char *dev,
100 uint16_t *max_xmit, uint16_t *tid);
101 struct cli_state *get_ipc_connect(char *server,
102 struct sockaddr_storage *server_ss,
103 const struct user_auth_info *user_info);
104 struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
105 struct sockaddr_storage *mb_ip,
106 const struct user_auth_info *user_info,
107 char **pp_workgroup_out);
108 struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
109 const struct user_auth_info *user_info,
110 char **pp_workgroup_out);
112 /* The following definitions come from libsmb/clidfs.c */
114 NTSTATUS cli_cm_force_encryption(struct cli_state *c,
115 const char *username,
116 const char *password,
117 const char *domain,
118 const char *sharename);
119 NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
120 struct cli_state *referring_cli,
121 const char *server,
122 const char *share,
123 const struct user_auth_info *auth_info,
124 bool show_hdr,
125 bool force_encrypt,
126 int max_protocol,
127 int port,
128 int name_type,
129 struct cli_state **pcli);
130 void cli_cm_display(struct cli_state *c);
131 struct client_dfs_referral;
132 NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
133 struct cli_state *cli,
134 const char *path,
135 struct client_dfs_referral **refs,
136 size_t *num_refs,
137 size_t *consumed);
138 NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
139 const char *mountpt,
140 const struct user_auth_info *dfs_auth_info,
141 struct cli_state *rootcli,
142 const char *path,
143 struct cli_state **targetcli,
144 char **pp_targetpath);
146 bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
147 struct cli_state *cli,
148 const char *sharename,
149 char **pp_newserver,
150 char **pp_newshare,
151 bool force_encrypt,
152 const char *username,
153 const char *password,
154 const char *domain);
156 /* The following definitions come from libsmb/clientgen.c */
158 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
159 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
160 bool cli_set_backup_intent(struct cli_state *cli, bool flag);
161 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
162 extern struct GUID cli_state_client_guid;
163 struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
164 int fd,
165 const char *remote_name,
166 const char *remote_realm,
167 int signing_state,
168 int flags);
169 void cli_nt_pipes_close(struct cli_state *cli);
170 void cli_shutdown(struct cli_state *cli);
171 const char *cli_state_remote_realm(struct cli_state *cli);
172 uint16_t cli_state_get_vc_num(struct cli_state *cli);
173 uint32_t cli_setpid(struct cli_state *cli, uint32_t pid);
174 uint32_t cli_getpid(struct cli_state *cli);
175 bool cli_state_has_tcon(struct cli_state *cli);
176 uint16_t cli_state_get_tid(struct cli_state *cli);
177 uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid);
178 uint16_t cli_state_get_uid(struct cli_state *cli);
179 uint16_t cli_state_set_uid(struct cli_state *cli, uint16_t uid);
180 bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
181 uint32_t cli_state_available_size(struct cli_state *cli, uint32_t ofs);
182 time_t cli_state_server_time(struct cli_state *cli);
183 struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
184 struct cli_state *cli, uint16_t num_echos,
185 DATA_BLOB data);
186 NTSTATUS cli_echo_recv(struct tevent_req *req);
187 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
188 bool is_andx_req(uint8_t cmd);
189 NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
190 uint8_t smb_command, uint8_t additional_flags,
191 uint8_t wct, uint16_t *vwv,
192 uint32_t num_bytes, const uint8_t *bytes,
193 struct tevent_req **result_parent,
194 uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
195 uint32_t *pnum_bytes, uint8_t **pbytes);
197 /* The following definitions come from libsmb/clierror.c */
199 const char *cli_errstr(struct cli_state *cli);
200 NTSTATUS cli_nt_error(struct cli_state *cli);
201 void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode);
202 int cli_errno(struct cli_state *cli);
203 bool cli_is_error(struct cli_state *cli);
204 bool cli_is_nt_error(struct cli_state *cli);
205 bool cli_is_dos_error(struct cli_state *cli);
206 bool cli_state_is_connected(struct cli_state *cli);
208 /* The following definitions come from libsmb/clifile.c */
210 struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
211 struct tevent_context *ev,
212 struct cli_state *cli,
213 uint16_t level,
214 const char *path,
215 uint8_t *data,
216 size_t data_len);
217 NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
218 NTSTATUS cli_setpathinfo(struct cli_state *cli,
219 uint16_t level,
220 const char *path,
221 uint8_t *data,
222 size_t data_len);
224 struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
225 struct tevent_context *ev,
226 struct cli_state *cli,
227 const char *oldname,
228 const char *newname);
229 NTSTATUS cli_posix_symlink_recv(struct tevent_req *req);
230 NTSTATUS cli_posix_symlink(struct cli_state *cli,
231 const char *oldname,
232 const char *newname);
233 struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx,
234 struct tevent_context *ev,
235 struct cli_state *cli,
236 const char *fname,
237 size_t len);
238 NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli,
239 char *retpath, size_t len);
240 NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
241 char *linkpath, size_t len);
242 struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx,
243 struct tevent_context *ev,
244 struct cli_state *cli,
245 const char *oldname,
246 const char *newname);
247 NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req);
248 NTSTATUS cli_posix_hardlink(struct cli_state *cli,
249 const char *oldname,
250 const char *newname);
251 uint32_t unix_perms_to_wire(mode_t perms);
252 mode_t wire_perms_to_unix(uint32_t perms);
253 struct tevent_req *cli_posix_getacl_send(TALLOC_CTX *mem_ctx,
254 struct tevent_context *ev,
255 struct cli_state *cli,
256 const char *fname);
257 NTSTATUS cli_posix_getacl_recv(struct tevent_req *req,
258 TALLOC_CTX *mem_ctx,
259 size_t *prb_size,
260 char **retbuf);
261 NTSTATUS cli_posix_getacl(struct cli_state *cli,
262 const char *fname,
263 TALLOC_CTX *mem_ctx,
264 size_t *prb_size,
265 char **retbuf);
266 struct tevent_req *cli_posix_setacl_send(TALLOC_CTX *mem_ctx,
267 struct tevent_context *ev,
268 struct cli_state *cli,
269 const char *fname,
270 const void *acl_buf,
271 size_t acl_buf_size);
272 NTSTATUS cli_posix_setacl_recv(struct tevent_req *req);
273 NTSTATUS cli_posix_setacl(struct cli_state *cli,
274 const char *fname,
275 const void *acl_buf,
276 size_t acl_buf_size);
277 struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
278 struct tevent_context *ev,
279 struct cli_state *cli,
280 const char *fname);
281 NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
282 SMB_STRUCT_STAT *sbuf);
283 NTSTATUS cli_posix_stat(struct cli_state *cli,
284 const char *fname,
285 SMB_STRUCT_STAT *sbuf);
286 struct tevent_req *cli_posix_chmod_send(TALLOC_CTX *mem_ctx,
287 struct tevent_context *ev,
288 struct cli_state *cli,
289 const char *fname,
290 mode_t mode);
291 NTSTATUS cli_posix_chmod_recv(struct tevent_req *req);
292 NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
293 struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx,
294 struct tevent_context *ev,
295 struct cli_state *cli,
296 const char *fname,
297 uid_t uid,
298 gid_t gid);
299 NTSTATUS cli_posix_chown_recv(struct tevent_req *req);
300 NTSTATUS cli_posix_chown(struct cli_state *cli,
301 const char *fname,
302 uid_t uid,
303 gid_t gid);
304 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
305 struct tevent_context *ev,
306 struct cli_state *cli,
307 const char *fname_src,
308 const char *fname_dst);
309 NTSTATUS cli_rename_recv(struct tevent_req *req);
310 NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
311 struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
312 struct tevent_context *ev,
313 struct cli_state *cli,
314 const char *fname_src,
315 const char *fname_dst);
316 NTSTATUS cli_ntrename_recv(struct tevent_req *req);
317 NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
319 struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
320 struct tevent_context *ev,
321 struct cli_state *cli,
322 const char *fname_src,
323 const char *fname_dst);
324 NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
325 NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
327 struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
328 struct tevent_context *ev,
329 struct cli_state *cli,
330 const char *fname,
331 uint16_t mayhave_attrs);
332 NTSTATUS cli_unlink_recv(struct tevent_req *req);
333 NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
335 struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
336 struct tevent_context *ev,
337 struct cli_state *cli,
338 const char *dname);
339 NTSTATUS cli_mkdir_recv(struct tevent_req *req);
340 NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
341 struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
342 struct tevent_context *ev,
343 struct cli_state *cli,
344 const char *dname);
345 NTSTATUS cli_rmdir_recv(struct tevent_req *req);
346 NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
347 struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
348 struct tevent_context *ev,
349 struct cli_state *cli,
350 uint16_t fnum,
351 bool flag);
352 NTSTATUS cli_nt_delete_on_close_recv(struct tevent_req *req);
353 NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
354 struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
355 struct tevent_context *ev,
356 struct cli_state *cli,
357 const char *fname,
358 uint32_t CreatFlags,
359 uint32_t DesiredAccess,
360 uint32_t FileAttributes,
361 uint32_t ShareAccess,
362 uint32_t CreateDisposition,
363 uint32_t CreateOptions,
364 uint8_t SecurityFlags);
365 NTSTATUS cli_ntcreate_recv(struct tevent_req *req,
366 uint16_t *pfnum,
367 struct smb_create_returns *cr);
368 NTSTATUS cli_ntcreate(struct cli_state *cli,
369 const char *fname,
370 uint32_t CreatFlags,
371 uint32_t DesiredAccess,
372 uint32_t FileAttributes,
373 uint32_t ShareAccess,
374 uint32_t CreateDisposition,
375 uint32_t CreateOptions,
376 uint8_t SecurityFlags,
377 uint16_t *pfid,
378 struct smb_create_returns *cr);
379 struct tevent_req *cli_openx_create(TALLOC_CTX *mem_ctx,
380 struct tevent_context *ev,
381 struct cli_state *cli, const char *fname,
382 int flags, int share_mode,
383 struct tevent_req **psmbreq);
384 struct tevent_req *cli_openx_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
385 struct cli_state *cli, const char *fname,
386 int flags, int share_mode);
387 NTSTATUS cli_openx_recv(struct tevent_req *req, uint16_t *fnum);
388 NTSTATUS cli_openx(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
389 NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
390 struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
391 struct tevent_context *ev,
392 struct cli_state *cli, uint16_t fnum,
393 struct tevent_req **psubreq);
394 struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
395 struct tevent_context *ev,
396 struct cli_state *cli, uint16_t fnum);
397 NTSTATUS cli_close_recv(struct tevent_req *req);
398 NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
399 struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx,
400 struct tevent_context *ev,
401 struct cli_state *cli,
402 uint16_t fnum,
403 uint64_t size);
404 NTSTATUS cli_ftruncate_recv(struct tevent_req *req);
405 NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
406 NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
407 uint32_t offset, uint32_t len,
408 int timeout, unsigned char locktype);
409 NTSTATUS cli_lock32(struct cli_state *cli, uint16_t fnum, uint32_t offset,
410 uint32_t len, int timeout, enum brl_type lock_type);
411 struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
412 struct tevent_context *ev,
413 struct cli_state *cli,
414 uint16_t fnum,
415 uint64_t offset,
416 uint64_t len);
417 NTSTATUS cli_unlock_recv(struct tevent_req *req);
418 NTSTATUS cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
419 NTSTATUS cli_lock64(struct cli_state *cli, uint16_t fnum,
420 uint64_t offset, uint64_t len, int timeout,
421 enum brl_type lock_type);
422 struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
423 struct tevent_context *ev,
424 struct cli_state *cli,
425 uint16_t fnum,
426 uint64_t offset,
427 uint64_t len);
428 NTSTATUS cli_unlock64_recv(struct tevent_req *req);
429 NTSTATUS cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
430 struct tevent_req *cli_posix_lock_send(TALLOC_CTX *mem_ctx,
431 struct tevent_context *ev,
432 struct cli_state *cli,
433 uint16_t fnum,
434 uint64_t offset,
435 uint64_t len,
436 bool wait_lock,
437 enum brl_type lock_type);
438 NTSTATUS cli_posix_lock_recv(struct tevent_req *req);
439 NTSTATUS cli_posix_lock(struct cli_state *cli, uint16_t fnum,
440 uint64_t offset, uint64_t len,
441 bool wait_lock, enum brl_type lock_type);
442 struct tevent_req *cli_posix_unlock_send(TALLOC_CTX *mem_ctx,
443 struct tevent_context *ev,
444 struct cli_state *cli,
445 uint16_t fnum,
446 uint64_t offset,
447 uint64_t len);
448 NTSTATUS cli_posix_unlock_recv(struct tevent_req *req);
449 NTSTATUS cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
450 struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
451 struct tevent_context *ev,
452 struct cli_state *cli,
453 uint16_t fnum);
454 NTSTATUS cli_getattrE_recv(struct tevent_req *req,
455 uint16_t *attr,
456 off_t *size,
457 time_t *change_time,
458 time_t *access_time,
459 time_t *write_time);
460 NTSTATUS cli_getattrE(struct cli_state *cli,
461 uint16_t fnum,
462 uint16_t *attr,
463 off_t *size,
464 time_t *change_time,
465 time_t *access_time,
466 time_t *write_time);
467 struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
468 struct tevent_context *ev,
469 struct cli_state *cli,
470 uint16_t fnum,
471 time_t change_time,
472 time_t access_time,
473 time_t write_time);
474 NTSTATUS cli_setattrE_recv(struct tevent_req *req);
475 NTSTATUS cli_setattrE(struct cli_state *cli,
476 uint16_t fnum,
477 time_t change_time,
478 time_t access_time,
479 time_t write_time);
480 struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
481 struct tevent_context *ev,
482 struct cli_state *cli,
483 const char *fname);
484 NTSTATUS cli_getatr_recv(struct tevent_req *req,
485 uint16_t *attr,
486 off_t *size,
487 time_t *write_time);
488 NTSTATUS cli_getatr(struct cli_state *cli,
489 const char *fname,
490 uint16_t *attr,
491 off_t *size,
492 time_t *write_time);
493 struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
494 struct tevent_context *ev,
495 struct cli_state *cli,
496 const char *fname,
497 uint16_t attr,
498 time_t mtime);
499 NTSTATUS cli_setatr_recv(struct tevent_req *req);
500 NTSTATUS cli_setatr(struct cli_state *cli,
501 const char *fname,
502 uint16_t attr,
503 time_t mtime);
504 struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
505 struct tevent_context *ev,
506 struct cli_state *cli,
507 const char *fname);
508 NTSTATUS cli_chkpath_recv(struct tevent_req *req);
509 NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
510 struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
511 struct tevent_context *ev,
512 struct cli_state *cli);
513 NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
514 int *avail);
515 NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
516 NTSTATUS cli_disk_size(struct cli_state *cli, const char *path, uint64_t *bsize,
517 uint64_t *total, uint64_t *avail);
518 struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
519 struct tevent_context *ev,
520 struct cli_state *cli,
521 const char *path);
522 NTSTATUS cli_ctemp_recv(struct tevent_req *req,
523 TALLOC_CTX *ctx,
524 uint16_t *pfnum,
525 char **outfile);
526 NTSTATUS cli_ctemp(struct cli_state *cli,
527 TALLOC_CTX *ctx,
528 const char *path,
529 uint16_t *pfnum,
530 char **out_path);
531 NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
532 NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
533 const char *ea_name, const char *ea_val,
534 size_t ea_len);
535 NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
536 const char *ea_name, const char *ea_val,
537 size_t ea_len);
538 struct tevent_req *cli_get_ea_list_path_send(TALLOC_CTX *mem_ctx,
539 struct tevent_context *ev,
540 struct cli_state *cli,
541 const char *fname);
542 NTSTATUS cli_get_ea_list_path_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
543 size_t *pnum_eas, struct ea_struct **peas);
544 NTSTATUS cli_get_ea_list_path(struct cli_state *cli, const char *path,
545 TALLOC_CTX *ctx,
546 size_t *pnum_eas,
547 struct ea_struct **pea_list);
548 struct tevent_req *cli_posix_open_send(TALLOC_CTX *mem_ctx,
549 struct tevent_context *ev,
550 struct cli_state *cli,
551 const char *fname,
552 int flags,
553 mode_t mode);
554 NTSTATUS cli_posix_open_recv(struct tevent_req *req, uint16_t *pfnum);
555 NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
556 int flags, mode_t mode, uint16_t *fnum);
557 struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
558 struct tevent_context *ev,
559 struct cli_state *cli,
560 const char *fname,
561 mode_t mode);
562 NTSTATUS cli_posix_mkdir_recv(struct tevent_req *req);
563 NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
565 struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
566 struct tevent_context *ev,
567 struct cli_state *cli,
568 const char *fname);
569 NTSTATUS cli_posix_unlink_recv(struct tevent_req *req);
570 NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
572 struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
573 struct tevent_context *ev,
574 struct cli_state *cli,
575 const char *fname);
576 NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
577 NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
578 struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
579 struct tevent_context *ev,
580 struct cli_state *cli, uint16_t fnum,
581 uint32_t buffer_size,
582 uint32_t completion_filter, bool recursive);
583 NTSTATUS cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
584 uint32_t *pnum_changes,
585 struct notify_change **pchanges);
586 NTSTATUS cli_notify(struct cli_state *cli, uint16_t fnum, uint32_t buffer_size,
587 uint32_t completion_filter, bool recursive,
588 TALLOC_CTX *mem_ctx, uint32_t *pnum_changes,
589 struct notify_change **pchanges);
591 struct tevent_req *cli_nttrans_create_send(TALLOC_CTX *mem_ctx,
592 struct tevent_context *ev,
593 struct cli_state *cli,
594 const char *fname,
595 uint32_t CreatFlags,
596 uint32_t DesiredAccess,
597 uint32_t FileAttributes,
598 uint32_t ShareAccess,
599 uint32_t CreateDisposition,
600 uint32_t CreateOptions,
601 uint8_t SecurityFlags,
602 struct security_descriptor *secdesc,
603 struct ea_struct *eas,
604 int num_eas);
605 NTSTATUS cli_nttrans_create_recv(struct tevent_req *req,
606 uint16_t *fnum,
607 struct smb_create_returns *cr);
608 NTSTATUS cli_nttrans_create(struct cli_state *cli,
609 const char *fname,
610 uint32_t CreatFlags,
611 uint32_t DesiredAccess,
612 uint32_t FileAttributes,
613 uint32_t ShareAccess,
614 uint32_t CreateDisposition,
615 uint32_t CreateOptions,
616 uint8_t SecurityFlags,
617 struct security_descriptor *secdesc,
618 struct ea_struct *eas,
619 int num_eas,
620 uint16_t *pfid,
621 struct smb_create_returns *cr);
623 /* The following definitions come from libsmb/clifsinfo.c */
625 struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
626 struct tevent_context *ev,
627 struct cli_state *cli);
628 NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
629 uint16_t *pmajor, uint16_t *pminor,
630 uint32_t *pcaplow,
631 uint32_t *pcaphigh);
632 NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16_t *pmajor,
633 uint16_t *pminor, uint32_t *pcaplow,
634 uint32_t *pcaphigh);
635 struct tevent_req *cli_set_unix_extensions_capabilities_send(
636 TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
637 uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh);
638 NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req);
639 NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
640 uint16_t major, uint16_t minor,
641 uint32_t caplow, uint32_t caphigh);
642 struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
643 struct tevent_context *ev,
644 struct cli_state *cli);
645 NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr);
646 NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
647 NTSTATUS cli_get_fs_volume_info(struct cli_state *cli,
648 TALLOC_CTX *mem_ctx, char **volume_name,
649 uint32_t *pserial_number, time_t *pdate);
650 NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
651 uint64_t *total_allocation_units,
652 uint64_t *caller_allocation_units,
653 uint64_t *actual_allocation_units,
654 uint64_t *sectors_per_allocation_unit,
655 uint64_t *bytes_per_sector);
656 NTSTATUS cli_get_posix_fs_info(struct cli_state *cli,
657 uint32_t *optimal_transfer_size,
658 uint32_t *block_size,
659 uint64_t *total_blocks,
660 uint64_t *blocks_available,
661 uint64_t *user_blocks_available,
662 uint64_t *total_file_nodes,
663 uint64_t *free_file_nodes,
664 uint64_t *fs_identifier);
665 NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
666 const char *user,
667 const char *pass,
668 const char *domain);
669 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli);
670 NTSTATUS cli_force_encryption(struct cli_state *c,
671 const char *username,
672 const char *password,
673 const char *domain);
674 struct tevent_req *cli_posix_whoami_send(TALLOC_CTX *mem_ctx,
675 struct tevent_context *ev,
676 struct cli_state *cli);
677 NTSTATUS cli_posix_whoami_recv(struct tevent_req *req,
678 TALLOC_CTX *mem_ctx,
679 uint64_t *puid,
680 uint64_t *pgid,
681 uint32_t *pnum_gids,
682 uint64_t **pgids,
683 uint32_t *pnum_sids,
684 struct dom_sid **psids,
685 bool *pguest);
686 NTSTATUS cli_posix_whoami(struct cli_state *cli,
687 TALLOC_CTX *mem_ctx,
688 uint64_t *puid,
689 uint64_t *pgid,
690 uint32_t *num_gids,
691 uint64_t **gids,
692 uint32_t *num_sids,
693 struct dom_sid **sids,
694 bool *pguest);
696 /* The following definitions come from libsmb/clilist.c */
698 NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16_t attribute,
699 NTSTATUS (*fn)(const char *, struct file_info *,
700 const char *, void *), void *state);
701 NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
702 uint16_t attribute, int info_level,
703 NTSTATUS (*fn)(const char *mnt, struct file_info *finfo,
704 const char *mask, void *private_data),
705 void *private_data);
706 struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
707 struct tevent_context *ev,
708 struct cli_state *cli,
709 const char *mask,
710 uint16_t attribute,
711 uint16_t info_level);
712 NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
713 struct file_info **finfo, size_t *num_finfo);
714 NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16_t attribute,
715 NTSTATUS (*fn)(const char *, struct file_info *, const char *,
716 void *), void *state);
718 /* The following definitions come from libsmb/climessage.c */
720 struct tevent_req *cli_message_send(TALLOC_CTX *mem_ctx,
721 struct tevent_context *ev,
722 struct cli_state *cli,
723 const char *host, const char *username,
724 const char *message);
725 NTSTATUS cli_message_recv(struct tevent_req *req);
726 NTSTATUS cli_message(struct cli_state *cli, const char *host,
727 const char *username, const char *message);
729 /* The following definitions come from libsmb/clioplock.c */
731 struct tevent_req *cli_smb_oplock_break_waiter_send(TALLOC_CTX *mem_ctx,
732 struct tevent_context *ev,
733 struct cli_state *cli);
734 NTSTATUS cli_smb_oplock_break_waiter_recv(struct tevent_req *req,
735 uint16_t *pfnum,
736 uint8_t *plevel);
738 struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
739 struct tevent_context *ev,
740 struct cli_state *cli,
741 uint16_t fnum, uint8_t level);
742 NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
744 /* The following definitions come from libsmb/cliprint.c */
746 int cli_print_queue(struct cli_state *cli,
747 void (*fn)(struct print_job_info *));
748 int cli_printjob_del(struct cli_state *cli, int job);
750 /* The following definitions come from libsmb/cliquota.c */
752 NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
753 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
754 bool parse_user_quota_record(const uint8_t *rdata,
755 unsigned int rdata_count,
756 unsigned int *offset,
757 SMB_NTQUOTA_STRUCT *pqt);
758 bool add_record_to_ntquota_list(TALLOC_CTX *mem_ctx,
759 SMB_NTQUOTA_STRUCT *pqt,
760 SMB_NTQUOTA_LIST **pqt_list);
761 NTSTATUS parse_user_quota_list(const uint8_t *curdata,
762 uint32_t curdata_size,
763 TALLOC_CTX *mem_ctx,
764 SMB_NTQUOTA_LIST **pqt_list);
765 NTSTATUS parse_fs_quota_buffer(const uint8_t *rdata,
766 unsigned int rdata_count,
767 SMB_NTQUOTA_STRUCT *pqt);
768 NTSTATUS build_user_quota_buffer(SMB_NTQUOTA_LIST *qt_list,
769 uint32_t maxlen,
770 TALLOC_CTX *mem_ctx,
771 DATA_BLOB *outbuf,
772 SMB_NTQUOTA_LIST **end_ptr);
773 NTSTATUS build_fs_quota_buffer(TALLOC_CTX *mem_ctx,
774 const SMB_NTQUOTA_STRUCT *pqt,
775 DATA_BLOB *blob,
776 uint32_t maxlen);
777 NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum,
778 SMB_NTQUOTA_STRUCT *pqt);
779 NTSTATUS cli_set_user_quota(struct cli_state *cli,
780 int quota_fnum,
781 SMB_NTQUOTA_LIST *qtl);
782 NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
783 SMB_NTQUOTA_LIST **pqt_list);
784 NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
785 SMB_NTQUOTA_STRUCT *pqt);
786 NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
787 SMB_NTQUOTA_STRUCT *pqt);
789 /* The following definitions come from libsmb/clireadwrite.c */
791 struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
792 struct tevent_context *ev,
793 struct cli_state *cli, uint16_t fnum,
794 off_t offset, size_t size,
795 struct tevent_req **psmbreq);
796 struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
797 struct tevent_context *ev,
798 struct cli_state *cli, uint16_t fnum,
799 off_t offset, size_t size);
800 NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
801 uint8_t **rcvbuf);
802 struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
803 struct tevent_context *ev,
804 struct cli_state *cli,
805 uint16_t fnum, off_t start_offset,
806 off_t size, size_t window_size,
807 NTSTATUS (*sink)(char *buf, size_t n,
808 void *priv),
809 void *priv);
810 NTSTATUS cli_pull_recv(struct tevent_req *req, off_t *received);
811 NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
812 off_t start_offset, off_t size, size_t window_size,
813 NTSTATUS (*sink)(char *buf, size_t n, void *priv),
814 void *priv, off_t *received);
815 NTSTATUS cli_read(struct cli_state *cli, uint16_t fnum,
816 char *buf, off_t offset, size_t size,
817 size_t *nread);
818 NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
819 off_t offset, size_t size1, size_t *ptotal);
820 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
821 struct tevent_context *ev,
822 struct cli_state *cli, uint16_t fnum,
823 uint16_t mode, const uint8_t *buf,
824 off_t offset, size_t size,
825 struct tevent_req **reqs_before,
826 int num_reqs_before,
827 struct tevent_req **psmbreq);
828 struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
829 struct tevent_context *ev,
830 struct cli_state *cli, uint16_t fnum,
831 uint16_t mode, const uint8_t *buf,
832 off_t offset, size_t size);
833 NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
835 NTSTATUS cli_writeall(struct cli_state *cli, uint16_t fnum, uint16_t mode,
836 const uint8_t *buf, off_t offset, size_t size,
837 size_t *pwritten);
839 struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
840 struct cli_state *cli,
841 uint16_t fnum, uint16_t mode,
842 off_t start_offset, size_t window_size,
843 size_t (*source)(uint8_t *buf, size_t n,
844 void *priv),
845 void *priv);
846 NTSTATUS cli_push_recv(struct tevent_req *req);
847 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
848 off_t start_offset, size_t window_size,
849 size_t (*source)(uint8_t *buf, size_t n, void *priv),
850 void *priv);
852 NTSTATUS cli_splice(struct cli_state *srccli, struct cli_state *dstcli,
853 uint16_t src_fnum, uint16_t dst_fnum,
854 off_t size,
855 off_t src_offset, off_t dst_offset,
856 off_t *written,
857 int (*splice_cb)(off_t n, void *priv), void *priv);
859 /* The following definitions come from libsmb/clisecdesc.c */
861 NTSTATUS cli_query_security_descriptor(struct cli_state *cli,
862 uint16_t fnum,
863 uint32_t sec_info,
864 TALLOC_CTX *mem_ctx,
865 struct security_descriptor **sd);
866 NTSTATUS cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
867 TALLOC_CTX *mem_ctx, struct security_descriptor **sd);
868 NTSTATUS cli_set_security_descriptor(struct cli_state *cli,
869 uint16_t fnum,
870 uint32_t sec_info,
871 const struct security_descriptor *sd);
872 NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
873 const struct security_descriptor *sd);
875 /* The following definitions come from libsmb/clistr.c */
877 size_t clistr_pull_talloc(TALLOC_CTX *ctx,
878 const char *base,
879 uint16_t flags2,
880 char **pp_dest,
881 const void *src,
882 int src_len,
883 int flags);
884 bool clistr_is_previous_version_path(const char *path,
885 const char **startp,
886 const char **endp,
887 time_t *ptime);
889 /* The following definitions come from libsmb/clitrans.c */
891 struct tevent_req *cli_trans_send(
892 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
893 struct cli_state *cli, uint16_t additional_flags2, uint8_t cmd,
894 const char *pipe_name, uint16_t fid, uint16_t function, int flags,
895 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
896 uint8_t *param, uint32_t num_param, uint32_t max_param,
897 uint8_t *data, uint32_t num_data, uint32_t max_data);
898 NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
899 uint16_t *recv_flags2,
900 uint16_t **setup, uint8_t min_setup,
901 uint8_t *num_setup,
902 uint8_t **param, uint32_t min_param,
903 uint32_t *num_param,
904 uint8_t **data, uint32_t min_data,
905 uint32_t *num_data);
906 NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
907 uint8_t trans_cmd,
908 const char *pipe_name, uint16_t fid, uint16_t function,
909 int flags,
910 uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
911 uint8_t *param, uint32_t num_param, uint32_t max_param,
912 uint8_t *data, uint32_t num_data, uint32_t max_data,
913 uint16_t *recv_flags2,
914 uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
915 uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
916 uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
918 /* The following definitions come from libsmb/reparse_symlink.c */
920 bool symlink_reparse_buffer_marshall(
921 const char *substitute, const char *printname, uint32_t flags,
922 TALLOC_CTX *mem_ctx, uint8_t **pdst, size_t *pdstlen);
923 bool symlink_reparse_buffer_parse(
924 const uint8_t *src, size_t srclen, TALLOC_CTX *mem_ctx,
925 char **psubstitute_name, char **pprint_name, uint32_t *pflags);
927 /* The following definitions come from libsmb/clisymlink.c */
929 struct tevent_req *cli_symlink_send(TALLOC_CTX *mem_ctx,
930 struct tevent_context *ev,
931 struct cli_state *cli,
932 const char *oldpath,
933 const char *newpath,
934 uint32_t flags);
935 NTSTATUS cli_symlink_recv(struct tevent_req *req);
936 NTSTATUS cli_symlink(struct cli_state *cli, const char *oldname,
937 const char *newname, uint32_t flags);
939 struct tevent_req *cli_readlink_send(TALLOC_CTX *mem_ctx,
940 struct tevent_context *ev,
941 struct cli_state *cli,
942 const char *fname);
943 NTSTATUS cli_readlink_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
944 char **psubstitute_name, char **pprint_name,
945 uint32_t *pflags);
946 NTSTATUS cli_readlink(struct cli_state *cli, const char *fname,
947 TALLOC_CTX *mem_ctx, char **psubstitute_name,
948 char **pprint_name, uint32_t *pflags);
950 #endif /* _LIBSMB_PROTO_H_ */