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