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