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