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