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