s3:libsmb: add cli_tree_connect() for a generic tree connect
[samba.git] / source3 / libsmb / proto.h
1 /*
2    Unix SMB/CIFS implementation.
3
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
11
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.
16
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.
21
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/>.
24 */
25
26 #ifndef _LIBSMB_PROTO_H_
27 #define _LIBSMB_PROTO_H_
28
29 #include "ads.h"
30
31 struct smb_trans_enc_state;
32
33 /* The following definitions come from libsmb/cliconnect.c  */
34
35 NTSTATUS cli_session_setup(struct cli_state *cli,
36                            const char *user,
37                            const char *pass, int passlen,
38                            const char *ntpass, int ntpasslen,
39                            const char *workgroup);
40 struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
41                                                   struct event_context *ev,
42                                                   struct cli_state *cli,
43                                                   struct tevent_req **psmbreq);
44 struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
45                                                 struct event_context *ev,
46                                                 struct cli_state *cli);
47 NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
48 struct tevent_req *cli_ulogoff_send(TALLOC_CTX *mem_ctx,
49                                     struct tevent_context *ev,
50                                     struct cli_state *cli);
51 NTSTATUS cli_ulogoff_recv(struct tevent_req *req);
52 NTSTATUS cli_ulogoff(struct cli_state *cli);
53 struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
54                                         struct event_context *ev,
55                                         struct cli_state *cli,
56                                         const char *share, const char *dev,
57                                         const char *pass, int passlen,
58                                         struct tevent_req **psmbreq);
59 struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
60                                       struct event_context *ev,
61                                       struct cli_state *cli,
62                                       const char *share, const char *dev,
63                                       const char *pass, int passlen);
64 NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
65 NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
66                        const char *dev, const char *pass, int passlen);
67 NTSTATUS cli_tree_connect(struct cli_state *cli, const char *share,
68                           const char *dev, const char *pass, int passlen);
69 struct tevent_req *cli_tdis_send(TALLOC_CTX *mem_ctx,
70                                  struct tevent_context *ev,
71                                  struct cli_state *cli);
72 NTSTATUS cli_tdis_recv(struct tevent_req *req);
73 NTSTATUS cli_tdis(struct cli_state *cli);
74 NTSTATUS cli_negprot(struct cli_state *cli, enum protocol_types max_protocol);
75 struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
76                                     struct event_context *ev,
77                                     struct cli_state *cli,
78                                     enum protocol_types max_protocol);
79 NTSTATUS cli_negprot_recv(struct tevent_req *req);
80 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
81                         uint16_t port, int name_type, const char *myname,
82                         int signing_state, int flags, struct cli_state **pcli);
83 NTSTATUS cli_start_connection(struct cli_state **output_cli,
84                               const char *my_name,
85                               const char *dest_host,
86                               const struct sockaddr_storage *dest_ss, int port,
87                               int signing_state, int flags);
88 NTSTATUS cli_full_connection(struct cli_state **output_cli,
89                              const char *my_name,
90                              const char *dest_host,
91                              const struct sockaddr_storage *dest_ss, int port,
92                              const char *service, const char *service_type,
93                              const char *user, const char *domain,
94                              const char *password, int flags,
95                              int signing_state);
96 NTSTATUS cli_raw_tcon(struct cli_state *cli,
97                       const char *service, const char *pass, const char *dev,
98                       uint16 *max_xmit, uint16 *tid);
99 struct cli_state *get_ipc_connect(char *server,
100                                 struct sockaddr_storage *server_ss,
101                                 const struct user_auth_info *user_info);
102 struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
103                                 struct sockaddr_storage *mb_ip,
104                                 const struct user_auth_info *user_info,
105                                 char **pp_workgroup_out);
106 struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
107                                         const struct user_auth_info *user_info,
108                                         char **pp_workgroup_out);
109
110 /* The following definitions come from libsmb/clidfs.c  */
111
112 NTSTATUS cli_cm_force_encryption(struct cli_state *c,
113                         const char *username,
114                         const char *password,
115                         const char *domain,
116                         const char *sharename);
117 NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
118                                 struct cli_state *referring_cli,
119                                 const char *server,
120                                 const char *share,
121                                 const struct user_auth_info *auth_info,
122                                 bool show_hdr,
123                                 bool force_encrypt,
124                                 int max_protocol,
125                                 int port,
126                                 int name_type,
127                                 struct cli_state **pcli);
128 void cli_cm_display(struct cli_state *c);
129 struct client_dfs_referral;
130 NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
131                         struct cli_state *cli,
132                         const char *path,
133                         struct client_dfs_referral **refs,
134                         size_t *num_refs,
135                         size_t *consumed);
136 NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
137                           const char *mountpt,
138                           const struct user_auth_info *dfs_auth_info,
139                           struct cli_state *rootcli,
140                           const char *path,
141                           struct cli_state **targetcli,
142                           char **pp_targetpath);
143
144 bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
145                         struct cli_state *cli,
146                         const char *sharename,
147                         char **pp_newserver,
148                         char **pp_newshare,
149                         bool force_encrypt,
150                         const char *username,
151                         const char *password,
152                         const char *domain);
153
154 /* The following definitions come from libsmb/clientgen.c  */
155
156 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
157 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
158 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
159 NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
160 NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
161 NTSTATUS cli_set_password(struct cli_state *cli, const char *password);
162 NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
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 bool cli_state_encryption_on(struct cli_state *cli);
170 void cli_nt_pipes_close(struct cli_state *cli);
171 void cli_shutdown(struct cli_state *cli);
172 void cli_sockopt(struct cli_state *cli, const char *options);
173 const struct sockaddr_storage *cli_state_local_sockaddr(struct cli_state *cli);
174 const struct sockaddr_storage *cli_state_remote_sockaddr(struct cli_state *cli);
175 const char *cli_state_remote_name(struct cli_state *cli);
176 const char *cli_state_remote_realm(struct cli_state *cli);
177 uint16_t cli_state_get_vc_num(struct cli_state *cli);
178 uint32_t cli_state_server_session_key(struct cli_state *cli);
179 uint16 cli_setpid(struct cli_state *cli, uint16 pid);
180 uint16_t cli_getpid(struct cli_state *cli);
181 bool cli_state_has_tcon(struct cli_state *cli);
182 uint16_t cli_state_get_tid(struct cli_state *cli);
183 uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid);
184 uint16_t cli_state_get_uid(struct cli_state *cli);
185 uint16_t cli_state_set_uid(struct cli_state *cli, uint16_t uid);
186 bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
187 enum protocol_types cli_state_protocol(struct cli_state *cli);
188 uint32_t cli_state_capabilities(struct cli_state *cli);
189 uint32_t cli_state_available_size(struct cli_state *cli, uint32_t ofs);
190 uint16_t cli_state_max_requests(struct cli_state *cli);
191 const uint8_t *cli_state_server_challenge(struct cli_state *cli);
192 const DATA_BLOB *cli_state_server_gss_blob(struct cli_state *cli);
193 uint16_t cli_state_security_mode(struct cli_state *cli);
194 int cli_state_server_time_zone(struct cli_state *cli);
195 time_t cli_state_server_time(struct cli_state *cli);
196 struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
197                                  struct cli_state *cli, uint16_t num_echos,
198                                  DATA_BLOB data);
199 NTSTATUS cli_echo_recv(struct tevent_req *req);
200 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
201 bool cli_ucs2(struct cli_state *cli);
202 bool is_andx_req(uint8_t cmd);
203 NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
204                  uint8_t smb_command, uint8_t additional_flags,
205                  uint8_t wct, uint16_t *vwv,
206                  uint32_t num_bytes, const uint8_t *bytes,
207                  struct tevent_req **result_parent,
208                  uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
209                  uint32_t *pnum_bytes, uint8_t **pbytes);
210
211 /* The following definitions come from libsmb/clierror.c  */
212
213 const char *cli_errstr(struct cli_state *cli);
214 NTSTATUS cli_nt_error(struct cli_state *cli);
215 void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode);
216 int cli_errno(struct cli_state *cli);
217 bool cli_is_error(struct cli_state *cli);
218 bool cli_is_nt_error(struct cli_state *cli);
219 bool cli_is_dos_error(struct cli_state *cli);
220 bool cli_state_is_connected(struct cli_state *cli);
221 void cli_state_disconnect(struct cli_state *cli);
222
223 /* The following definitions come from libsmb/clifile.c  */
224
225 struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
226                                         struct tevent_context *ev,
227                                         struct cli_state *cli,
228                                         uint16_t level,
229                                         const char *path,
230                                         uint8_t *data,
231                                         size_t data_len);
232 NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
233 NTSTATUS cli_setpathinfo(struct cli_state *cli,
234                          uint16_t level,
235                          const char *path,
236                          uint8_t *data,
237                          size_t data_len);
238
239 struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
240                                         struct event_context *ev,
241                                         struct cli_state *cli,
242                                         const char *oldname,
243                                         const char *newname);
244 NTSTATUS cli_posix_symlink_recv(struct tevent_req *req);
245 NTSTATUS cli_posix_symlink(struct cli_state *cli,
246                         const char *oldname,
247                         const char *newname);
248 struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx,
249                                         struct event_context *ev,
250                                         struct cli_state *cli,
251                                         const char *fname,
252                                         size_t len);
253 NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli,
254                                 char *retpath, size_t len);
255 NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
256                         char *linkpath, size_t len);
257 struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx,
258                                         struct event_context *ev,
259                                         struct cli_state *cli,
260                                         const char *oldname,
261                                         const char *newname);
262 NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req);
263 NTSTATUS cli_posix_hardlink(struct cli_state *cli,
264                         const char *oldname,
265                         const char *newname);
266 uint32_t unix_perms_to_wire(mode_t perms);
267 mode_t wire_perms_to_unix(uint32_t perms);
268 struct tevent_req *cli_posix_getfacl_send(TALLOC_CTX *mem_ctx,
269                                         struct event_context *ev,
270                                         struct cli_state *cli,
271                                         const char *fname);
272 NTSTATUS cli_posix_getfacl_recv(struct tevent_req *req,
273                                 TALLOC_CTX *mem_ctx,
274                                 size_t *prb_size,
275                                 char **retbuf);
276 NTSTATUS cli_posix_getfacl(struct cli_state *cli,
277                         const char *fname,
278                         TALLOC_CTX *mem_ctx,
279                         size_t *prb_size,
280                         char **retbuf);
281 struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
282                                         struct event_context *ev,
283                                         struct cli_state *cli,
284                                         const char *fname);
285 NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
286                                 SMB_STRUCT_STAT *sbuf);
287 NTSTATUS cli_posix_stat(struct cli_state *cli,
288                         const char *fname,
289                         SMB_STRUCT_STAT *sbuf);
290 struct tevent_req *cli_posix_chmod_send(TALLOC_CTX *mem_ctx,
291                                         struct event_context *ev,
292                                         struct cli_state *cli,
293                                         const char *fname,
294                                         mode_t mode);
295 NTSTATUS cli_posix_chmod_recv(struct tevent_req *req);
296 NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
297 struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx,
298                                         struct event_context *ev,
299                                         struct cli_state *cli,
300                                         const char *fname,
301                                         uid_t uid,
302                                         gid_t gid);
303 NTSTATUS cli_posix_chown_recv(struct tevent_req *req);
304 NTSTATUS cli_posix_chown(struct cli_state *cli,
305                         const char *fname,
306                         uid_t uid,
307                         gid_t gid);
308 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
309                                 struct event_context *ev,
310                                 struct cli_state *cli,
311                                 const char *fname_src,
312                                 const char *fname_dst);
313 NTSTATUS cli_rename_recv(struct tevent_req *req);
314 NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
315 struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
316                                 struct event_context *ev,
317                                 struct cli_state *cli,
318                                 const char *fname_src,
319                                 const char *fname_dst);
320 NTSTATUS cli_ntrename_recv(struct tevent_req *req);
321 NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
322
323 struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
324                                 struct event_context *ev,
325                                 struct cli_state *cli,
326                                 const char *fname_src,
327                                 const char *fname_dst);
328 NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
329 NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
330
331 struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
332                                 struct event_context *ev,
333                                 struct cli_state *cli,
334                                 const char *fname,
335                                 uint16_t mayhave_attrs);
336 NTSTATUS cli_unlink_recv(struct tevent_req *req);
337 NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
338
339 struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
340                                   struct event_context *ev,
341                                   struct cli_state *cli,
342                                   const char *dname);
343 NTSTATUS cli_mkdir_recv(struct tevent_req *req);
344 NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
345 struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
346                                   struct event_context *ev,
347                                   struct cli_state *cli,
348                                   const char *dname);
349 NTSTATUS cli_rmdir_recv(struct tevent_req *req);
350 NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
351 struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
352                                         struct event_context *ev,
353                                         struct cli_state *cli,
354                                         uint16_t fnum,
355                                         bool flag);
356 NTSTATUS cli_nt_delete_on_close_recv(struct tevent_req *req);
357 NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
358 struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
359                                      struct event_context *ev,
360                                      struct cli_state *cli,
361                                      const char *fname,
362                                      uint32_t CreatFlags,
363                                      uint32_t DesiredAccess,
364                                      uint32_t FileAttributes,
365                                      uint32_t ShareAccess,
366                                      uint32_t CreateDisposition,
367                                      uint32_t CreateOptions,
368                                      uint8_t SecurityFlags);
369 NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
370 NTSTATUS cli_ntcreate(struct cli_state *cli,
371                       const char *fname,
372                       uint32_t CreatFlags,
373                       uint32_t DesiredAccess,
374                       uint32_t FileAttributes,
375                       uint32_t ShareAccess,
376                       uint32_t CreateDisposition,
377                       uint32_t CreateOptions,
378                       uint8_t SecurityFlags,
379                       uint16_t *pfid);
380 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
381                             size_t str_len, size_t *pconverted_size);
382 uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
383                               const uint8_t *bytes, size_t num_bytes);
384 uint8_t *trans2_bytes_push_str(uint8_t *buf, bool ucs2,
385                                const char *str, size_t str_len,
386                                size_t *pconverted_size);
387 uint8_t *trans2_bytes_push_bytes(uint8_t *buf,
388                                  const uint8_t *bytes, size_t num_bytes);
389 struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
390                                    struct event_context *ev,
391                                    struct cli_state *cli, const char *fname,
392                                    int flags, int share_mode,
393                                    struct tevent_req **psmbreq);
394 struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
395                                  struct cli_state *cli, const char *fname,
396                                  int flags, int share_mode);
397 NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
398 NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
399 struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
400                                     struct event_context *ev,
401                                     struct cli_state *cli, uint16_t fnum,
402                                     struct tevent_req **psubreq);
403 struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
404                                   struct event_context *ev,
405                                   struct cli_state *cli, uint16_t fnum);
406 NTSTATUS cli_close_recv(struct tevent_req *req);
407 NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
408 struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx,
409                                         struct event_context *ev,
410                                         struct cli_state *cli,
411                                         uint16_t fnum,
412                                         uint64_t size);
413 NTSTATUS cli_ftruncate_recv(struct tevent_req *req);
414 NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
415 NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
416                       uint32_t offset, uint32_t len,
417                       int timeout, unsigned char locktype);
418 NTSTATUS cli_lock32(struct cli_state *cli, uint16_t fnum, uint32_t offset,
419                     uint32_t len, int timeout, enum brl_type lock_type);
420 struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
421                                 struct event_context *ev,
422                                 struct cli_state *cli,
423                                 uint16_t fnum,
424                                 uint64_t offset,
425                                 uint64_t len);
426 NTSTATUS cli_unlock_recv(struct tevent_req *req);
427 NTSTATUS cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
428 NTSTATUS cli_lock64(struct cli_state *cli, uint16_t fnum,
429                     uint64_t offset, uint64_t len, int timeout,
430                     enum brl_type lock_type);
431 struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
432                                 struct event_context *ev,
433                                 struct cli_state *cli,
434                                 uint16_t fnum,
435                                 uint64_t offset,
436                                 uint64_t len);
437 NTSTATUS cli_unlock64_recv(struct tevent_req *req);
438 NTSTATUS cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
439 struct tevent_req *cli_posix_lock_send(TALLOC_CTX *mem_ctx,
440                                         struct event_context *ev,
441                                         struct cli_state *cli,
442                                         uint16_t fnum,
443                                         uint64_t offset,
444                                         uint64_t len,
445                                         bool wait_lock,
446                                         enum brl_type lock_type);
447 NTSTATUS cli_posix_lock_recv(struct tevent_req *req);
448 NTSTATUS cli_posix_lock(struct cli_state *cli, uint16_t fnum,
449                         uint64_t offset, uint64_t len,
450                         bool wait_lock, enum brl_type lock_type);
451 struct tevent_req *cli_posix_unlock_send(TALLOC_CTX *mem_ctx,
452                                         struct event_context *ev,
453                                         struct cli_state *cli,
454                                         uint16_t fnum,
455                                         uint64_t offset,
456                                         uint64_t len);
457 NTSTATUS cli_posix_unlock_recv(struct tevent_req *req);
458 NTSTATUS cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
459 struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
460                                 struct event_context *ev,
461                                 struct cli_state *cli,
462                                 uint16_t fnum);
463 NTSTATUS cli_getattrE_recv(struct tevent_req *req,
464                         uint16_t *attr,
465                         SMB_OFF_T *size,
466                         time_t *change_time,
467                         time_t *access_time,
468                         time_t *write_time);
469 NTSTATUS cli_getattrE(struct cli_state *cli,
470                         uint16_t fnum,
471                         uint16_t *attr,
472                         SMB_OFF_T *size,
473                         time_t *change_time,
474                         time_t *access_time,
475                         time_t *write_time);
476 struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
477                                 struct event_context *ev,
478                                 struct cli_state *cli,
479                                 uint16_t fnum,
480                                 time_t change_time,
481                                 time_t access_time,
482                                 time_t write_time);
483 NTSTATUS cli_setattrE_recv(struct tevent_req *req);
484 NTSTATUS cli_setattrE(struct cli_state *cli,
485                         uint16_t fnum,
486                         time_t change_time,
487                         time_t access_time,
488                         time_t write_time);
489 struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
490                                 struct event_context *ev,
491                                 struct cli_state *cli,
492                                 const char *fname);
493 NTSTATUS cli_getatr_recv(struct tevent_req *req,
494                                 uint16_t *attr,
495                                 SMB_OFF_T *size,
496                                 time_t *write_time);
497 NTSTATUS cli_getatr(struct cli_state *cli,
498                         const char *fname,
499                         uint16_t *attr,
500                         SMB_OFF_T *size,
501                         time_t *write_time);
502 struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
503                                 struct event_context *ev,
504                                 struct cli_state *cli,
505                                 const char *fname,
506                                 uint16_t attr,
507                                 time_t mtime);
508 NTSTATUS cli_setatr_recv(struct tevent_req *req);
509 NTSTATUS cli_setatr(struct cli_state *cli,
510                 const char *fname,
511                 uint16_t attr,
512                 time_t mtime);
513 struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
514                                   struct event_context *ev,
515                                   struct cli_state *cli,
516                                   const char *fname);
517 NTSTATUS cli_chkpath_recv(struct tevent_req *req);
518 NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
519 struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
520                                   struct event_context *ev,
521                                   struct cli_state *cli);
522 NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
523                           int *avail);
524 NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
525 struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
526                                 struct event_context *ev,
527                                 struct cli_state *cli,
528                                 const char *path);
529 NTSTATUS cli_ctemp_recv(struct tevent_req *req,
530                         TALLOC_CTX *ctx,
531                         uint16_t *pfnum,
532                         char **outfile);
533 NTSTATUS cli_ctemp(struct cli_state *cli,
534                         TALLOC_CTX *ctx,
535                         const char *path,
536                         uint16_t *pfnum,
537                         char **out_path);
538 NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
539 NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
540                          const char *ea_name, const char *ea_val,
541                          size_t ea_len);
542 NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
543                          const char *ea_name, const char *ea_val,
544                          size_t ea_len);
545 struct tevent_req *cli_get_ea_list_path_send(TALLOC_CTX *mem_ctx,
546                                              struct tevent_context *ev,
547                                              struct cli_state *cli,
548                                              const char *fname);
549 NTSTATUS cli_get_ea_list_path_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
550                                    size_t *pnum_eas, struct ea_struct **peas);
551 NTSTATUS cli_get_ea_list_path(struct cli_state *cli, const char *path,
552                 TALLOC_CTX *ctx,
553                 size_t *pnum_eas,
554                 struct ea_struct **pea_list);
555 struct tevent_req *cli_posix_open_send(TALLOC_CTX *mem_ctx,
556                                         struct event_context *ev,
557                                         struct cli_state *cli,
558                                         const char *fname,
559                                         int flags,
560                                         mode_t mode);
561 NTSTATUS cli_posix_open_recv(struct tevent_req *req, uint16_t *pfnum);
562 NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
563                         int flags, mode_t mode, uint16_t *fnum);
564 struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
565                                         struct event_context *ev,
566                                         struct cli_state *cli,
567                                         const char *fname,
568                                         mode_t mode);
569 NTSTATUS cli_posix_mkdir_recv(struct tevent_req *req);
570 NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
571
572 struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
573                                         struct event_context *ev,
574                                         struct cli_state *cli,
575                                         const char *fname);
576 NTSTATUS cli_posix_unlink_recv(struct tevent_req *req);
577 NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
578
579 struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
580                                         struct event_context *ev,
581                                         struct cli_state *cli,
582                                         const char *fname);
583 NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
584 NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
585 struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
586                                    struct tevent_context *ev,
587                                    struct cli_state *cli, uint16_t fnum,
588                                    uint32_t buffer_size,
589                                    uint32_t completion_filter, bool recursive);
590 NTSTATUS cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
591                          uint32_t *pnum_changes,
592                          struct notify_change **pchanges);
593
594 struct tevent_req *cli_nttrans_create_send(TALLOC_CTX *mem_ctx,
595                                            struct event_context *ev,
596                                            struct cli_state *cli,
597                                            const char *fname,
598                                            uint32_t CreatFlags,
599                                            uint32_t DesiredAccess,
600                                            uint32_t FileAttributes,
601                                            uint32_t ShareAccess,
602                                            uint32_t CreateDisposition,
603                                            uint32_t CreateOptions,
604                                            uint8_t SecurityFlags,
605                                            struct security_descriptor *secdesc,
606                                            struct ea_struct *eas,
607                                            int num_eas);
608 NTSTATUS cli_nttrans_create_recv(struct tevent_req *req, uint16_t *fnum);
609 NTSTATUS cli_nttrans_create(struct cli_state *cli,
610                             const char *fname,
611                             uint32_t CreatFlags,
612                             uint32_t DesiredAccess,
613                             uint32_t FileAttributes,
614                             uint32_t ShareAccess,
615                             uint32_t CreateDisposition,
616                             uint32_t CreateOptions,
617                             uint8_t SecurityFlags,
618                             struct security_descriptor *secdesc,
619                             struct ea_struct *eas,
620                             int num_eas,
621                             uint16_t *pfid);
622
623 /* The following definitions come from libsmb/clifsinfo.c  */
624
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 *pmajor,
633                                      uint16 *pminor, uint32 *pcaplow,
634                                      uint32 *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 major, uint16 minor,
641                                               uint32 caplow, uint32 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 *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 *optimal_transfer_size,
658                                uint32 *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
675 /* The following definitions come from libsmb/clilist.c  */
676
677 NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
678                       NTSTATUS (*fn)(const char *, struct file_info *,
679                                  const char *, void *), void *state);
680 NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
681                         uint16_t attribute, int info_level,
682                         NTSTATUS (*fn)(const char *mnt, struct file_info *finfo,
683                                    const char *mask, void *private_data),
684                         void *private_data);
685 struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
686                                  struct tevent_context *ev,
687                                  struct cli_state *cli,
688                                  const char *mask,
689                                  uint16_t attribute,
690                                  uint16_t info_level);
691 NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
692                        struct file_info **finfo, size_t *num_finfo);
693 NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
694                   NTSTATUS (*fn)(const char *, struct file_info *, const char *,
695                              void *), void *state);
696
697 /* The following definitions come from libsmb/climessage.c  */
698
699 struct tevent_req *cli_message_send(TALLOC_CTX *mem_ctx,
700                                     struct tevent_context *ev,
701                                     struct cli_state *cli,
702                                     const char *host, const char *username,
703                                     const char *message);
704 NTSTATUS cli_message_recv(struct tevent_req *req);
705 NTSTATUS cli_message(struct cli_state *cli, const char *host,
706                      const char *username, const char *message);
707
708 /* The following definitions come from libsmb/clioplock.c  */
709
710 struct tevent_req *cli_smb_oplock_break_waiter_send(TALLOC_CTX *mem_ctx,
711                                                     struct event_context *ev,
712                                                     struct cli_state *cli);
713 NTSTATUS cli_smb_oplock_break_waiter_recv(struct tevent_req *req,
714                                           uint16_t *pfnum,
715                                           uint8_t *plevel);
716
717 struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
718                                        struct tevent_context *ev,
719                                        struct cli_state *cli,
720                                        uint16_t fnum, uint8_t level);
721 NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
722
723 /* The following definitions come from libsmb/cliprint.c  */
724
725 int cli_print_queue(struct cli_state *cli,
726                     void (*fn)(struct print_job_info *));
727 int cli_printjob_del(struct cli_state *cli, int job);
728
729 /* The following definitions come from libsmb/cliquota.c  */
730
731 NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
732 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
733 NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum,
734                             SMB_NTQUOTA_STRUCT *pqt);
735 NTSTATUS cli_set_user_quota(struct cli_state *cli, int quota_fnum,
736                             SMB_NTQUOTA_STRUCT *pqt);
737 NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
738                              SMB_NTQUOTA_LIST **pqt_list);
739 NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
740                                SMB_NTQUOTA_STRUCT *pqt);
741 NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
742                                SMB_NTQUOTA_STRUCT *pqt);
743
744 /* The following definitions come from libsmb/clireadwrite.c  */
745
746 struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
747                                         struct event_context *ev,
748                                         struct cli_state *cli, uint16_t fnum,
749                                         off_t offset, size_t size,
750                                         struct tevent_req **psmbreq);
751 struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
752                                       struct event_context *ev,
753                                       struct cli_state *cli, uint16_t fnum,
754                                       off_t offset, size_t size);
755 NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
756                             uint8_t **rcvbuf);
757 struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
758                                  struct event_context *ev,
759                                  struct cli_state *cli,
760                                  uint16_t fnum, off_t start_offset,
761                                  SMB_OFF_T size, size_t window_size,
762                                  NTSTATUS (*sink)(char *buf, size_t n,
763                                                   void *priv),
764                                  void *priv);
765 NTSTATUS cli_pull_recv(struct tevent_req *req, SMB_OFF_T *received);
766 NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
767                   off_t start_offset, SMB_OFF_T size, size_t window_size,
768                   NTSTATUS (*sink)(char *buf, size_t n, void *priv),
769                   void *priv, SMB_OFF_T *received);
770 NTSTATUS cli_read(struct cli_state *cli, uint16_t fnum,
771                   char *buf, off_t offset, size_t size,
772                   size_t *nread);
773 NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
774                       off_t offset, size_t size1, size_t *ptotal);
775 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
776                                          struct event_context *ev,
777                                          struct cli_state *cli, uint16_t fnum,
778                                          uint16_t mode, const uint8_t *buf,
779                                          off_t offset, size_t size,
780                                          struct tevent_req **reqs_before,
781                                          int num_reqs_before,
782                                          struct tevent_req **psmbreq);
783 struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
784                                        struct event_context *ev,
785                                        struct cli_state *cli, uint16_t fnum,
786                                        uint16_t mode, const uint8_t *buf,
787                                        off_t offset, size_t size);
788 NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
789
790 NTSTATUS cli_writeall(struct cli_state *cli, uint16_t fnum, uint16_t mode,
791                       const uint8_t *buf, off_t offset, size_t size,
792                       size_t *pwritten);
793
794 struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
795                                  struct cli_state *cli,
796                                  uint16_t fnum, uint16_t mode,
797                                  off_t start_offset, size_t window_size,
798                                  size_t (*source)(uint8_t *buf, size_t n,
799                                                   void *priv),
800                                  void *priv);
801 NTSTATUS cli_push_recv(struct tevent_req *req);
802 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
803                   off_t start_offset, size_t window_size,
804                   size_t (*source)(uint8_t *buf, size_t n, void *priv),
805                   void *priv);
806
807 /* The following definitions come from libsmb/clisecdesc.c  */
808
809 NTSTATUS cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
810                           TALLOC_CTX *mem_ctx, struct security_descriptor **sd);
811 NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
812                          const struct security_descriptor *sd);
813
814 /* The following definitions come from libsmb/clistr.c  */
815
816 size_t clistr_pull_talloc(TALLOC_CTX *ctx,
817                           const char *base,
818                           uint16_t flags2,
819                           char **pp_dest,
820                           const void *src,
821                           int src_len,
822                           int flags);
823
824 /* The following definitions come from libsmb/clitrans.c  */
825
826 struct tevent_req *cli_trans_send(
827         TALLOC_CTX *mem_ctx, struct tevent_context *ev,
828         struct cli_state *cli, uint8_t cmd,
829         const char *pipe_name, uint16_t fid, uint16_t function, int flags,
830         uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
831         uint8_t *param, uint32_t num_param, uint32_t max_param,
832         uint8_t *data, uint32_t num_data, uint32_t max_data);
833 NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
834                         uint16_t *recv_flags2,
835                         uint16_t **setup, uint8_t min_setup,
836                         uint8_t *num_setup,
837                         uint8_t **param, uint32_t min_param,
838                         uint32_t *num_param,
839                         uint8_t **data, uint32_t min_data,
840                         uint32_t *num_data);
841 NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
842                    uint8_t trans_cmd,
843                    const char *pipe_name, uint16_t fid, uint16_t function,
844                    int flags,
845                    uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
846                    uint8_t *param, uint32_t num_param, uint32_t max_param,
847                    uint8_t *data, uint32_t num_data, uint32_t max_data,
848                    uint16_t *recv_flags2,
849                    uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
850                    uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
851                    uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
852
853 /* The following definitions come from libsmb/clisigning.c  */
854
855 bool cli_simple_set_signing(struct cli_state *cli,
856                             const DATA_BLOB user_session_key,
857                             const DATA_BLOB response);
858 bool cli_check_sign_mac(struct cli_state *cli, const char *buf, uint32_t seqnum);
859 bool client_is_signing_on(struct cli_state *cli);
860
861 /* The following definitions come from libsmb/reparse_symlink.c  */
862
863 bool symlink_reparse_buffer_marshall(
864         const char *substitute, const char *printname, uint32_t flags,
865         TALLOC_CTX *mem_ctx, uint8_t **pdst, size_t *pdstlen);
866 bool symlink_reparse_buffer_parse(
867         const uint8_t *src, size_t srclen, TALLOC_CTX *mem_ctx,
868         char **psubstitute_name, char **pprint_name, uint32_t *pflags);
869
870 /* The following definitions come from libsmb/clisymlink.c  */
871
872 struct tevent_req *cli_symlink_send(TALLOC_CTX *mem_ctx,
873                                     struct tevent_context *ev,
874                                     struct cli_state *cli,
875                                     const char *oldpath,
876                                     const char *newpath,
877                                     uint32_t flags);
878 NTSTATUS cli_symlink_recv(struct tevent_req *req);
879 NTSTATUS cli_symlink(struct cli_state *cli, const char *oldname,
880                      const char *newname, uint32_t flags);
881
882 struct tevent_req *cli_readlink_send(TALLOC_CTX *mem_ctx,
883                                      struct tevent_context *ev,
884                                      struct cli_state *cli,
885                                      const char *fname);
886 NTSTATUS cli_readlink_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
887                            char **psubstitute_name, char **pprint_name,
888                            uint32_t *pflags);
889 NTSTATUS cli_readlink(struct cli_state *cli, const char *fname,
890                        TALLOC_CTX *mem_ctx, char **psubstitute_name,
891                       char **pprint_name, uint32_t *pflags);
892
893 #endif /* _LIBSMB_PROTO_H_ */