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