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