1a90cf9fGordon Ross/*
2a90cf9fGordon Ross * This file and its contents are supplied under the terms of the
3a90cf9fGordon Ross * Common Development and Distribution License ("CDDL"), version 1.0.
4a90cf9fGordon Ross * You may only use this file in accordance with the terms of version
5a90cf9fGordon Ross * 1.0 of the CDDL.
6a90cf9fGordon Ross *
7a90cf9fGordon Ross * A full copy of the text of the CDDL should have accompanied this
8a90cf9fGordon Ross * source.  A copy of the CDDL is also available via the Internet at
9a90cf9fGordon Ross * http://www.illumos.org/license/CDDL.
10a90cf9fGordon Ross */
11a90cf9fGordon Ross
12a90cf9fGordon Ross/*
135677e04Gordon Ross * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
144e065a9Alexander Stetsenko * Copyright 2020 RackTop Systems, Inc.
15a90cf9fGordon Ross */
16a90cf9fGordon Ross
17a90cf9fGordon Ross#ifndef _SMB2_KPROTO_H_
18a90cf9fGordon Ross#define	_SMB2_KPROTO_H_
19a90cf9fGordon Ross
20a90cf9fGordon Ross#include <smbsrv/smb_kproto.h>
21a90cf9fGordon Ross#include <smbsrv/smb2.h>
22a90cf9fGordon Ross
23a90cf9fGordon Ross#ifdef	__cplusplus
24a90cf9fGordon Rossextern "C" {
25a90cf9fGordon Ross#endif
26a90cf9fGordon Ross
27a90cf9fGordon Rossextern uint32_t smb2_tcp_rcvbuf;
28a90cf9fGordon Rossextern uint32_t smb2_max_rwsize;
29a90cf9fGordon Rossextern uint32_t smb2_max_trans;
30a90cf9fGordon Ross
31d082c87Gordon Rossextern int smb2_aapl_use_file_ids;
32811599aMatt Bardenextern uint32_t smb2_dh_def_timeout;
33811599aMatt Bardenextern uint32_t smb2_dh_max_timeout;
34811599aMatt Bardenextern uint32_t smb2_res_def_timeout;
35811599aMatt Bardenextern uint32_t smb2_res_max_timeout;
368d94f65Gordon Rossextern uint32_t smb2_persist_timeout;
37811599aMatt Bardenextern int smb2_enable_dh;
38d082c87Gordon Ross
391160dcfMatt Barden#define	SMB3_CLIENT_ENCRYPTS(sr) \
401160dcfMatt Barden	((sr->session->capabilities & SMB2_CAP_ENCRYPTION) != 0)
411160dcfMatt Barden
42a90cf9fGordon Rossvoid	smb2_dispatch_stats_init(smb_server_t *);
43a90cf9fGordon Rossvoid	smb2_dispatch_stats_fini(smb_server_t *);
44a90cf9fGordon Rossvoid	smb2_dispatch_stats_update(smb_server_t *,
45a90cf9fGordon Ross		smb_kstat_req_t *, int, int);
46a90cf9fGordon Ross
47a90cf9fGordon Rossint	smb2sr_newrq(smb_request_t *);
48a90cf9fGordon Rossvoid	smb2sr_work(smb_request_t *);
49148d1a4Matt Bardenuint32_t smb2sr_go_async(smb_request_t *);
5094047d4Gordon Rossvoid smb2sr_append_postwork(smb_request_t *, smb_request_t *);
51a90cf9fGordon Ross
52a90cf9fGordon Rossint smb2_decode_header(smb_request_t *);
53a90cf9fGordon Rossint smb2_encode_header(smb_request_t *, boolean_t);
541160dcfMatt Bardenint smb3_decode_tform_header(smb_request_t *);
551160dcfMatt Bardenint smb3_encode_tform_header(smb_request_t *, struct mbuf_chain *mbc);
561160dcfMatt Barden
57a90cf9fGordon Rossvoid smb2_send_reply(smb_request_t *);
58a90cf9fGordon Rossvoid smb2sr_put_error(smb_request_t *, uint32_t);
59a90cf9fGordon Rossvoid smb2sr_put_error_data(smb_request_t *, uint32_t, mbuf_chain_t *);
604e065a9Alexander Stetsenkovoid smb2sr_put_error_ctx(smb_request_t *, uint32_t, uint32_t, mbuf_chain_t *);
614e065a9Alexander Stetsenkovoid smb2sr_put_error_ctx0(smb_request_t *, uint32_t, mbuf_chain_t *);
62a90cf9fGordon Rossvoid smb2sr_put_errno(struct smb_request *, int);
63a90cf9fGordon Rossuint32_t smb2sr_lookup_fid(smb_request_t *, smb2fid_t *);
64a90cf9fGordon Ross
65a90cf9fGordon Ross/* SMB2 signing routines - smb2_signing.c */
66a90cf9fGordon Rossint smb2_sign_check_request(smb_request_t *);
67a90cf9fGordon Rossvoid smb2_sign_reply(smb_request_t *);
68c51c88bMatt Bardenvoid smb2_sign_init_mech(smb_session_t *);
694e065a9Alexander Stetsenkovoid smb31_preauth_init_mech(smb_session_t *);
704e065a9Alexander Stetsenkovoid smb31_preauth_fini(smb_session_t *s);
714e065a9Alexander Stetsenkoint smb31_preauth_sha512_calc(smb_request_t *, struct mbuf_chain *,
724e065a9Alexander Stetsenko    uint8_t *, uint8_t *);
73a90cf9fGordon Ross
741160dcfMatt Bardenint smb3_encrypt_sr(smb_request_t *, struct mbuf_chain *, struct mbuf_chain *);
751160dcfMatt Bardenint smb3_decrypt_sr(smb_request_t *);
761160dcfMatt Bardenint smb3_encrypt_init_mech(smb_session_t *s);
771160dcfMatt Barden
7855f0a24Gordon Rossuint32_t smb2_fsctl_fs(smb_request_t *, smb_fsctl_t *);
7955f0a24Gordon Rossuint32_t smb2_fsctl_netfs(smb_request_t *, smb_fsctl_t *);
8055f0a24Gordon Rossuint32_t smb2_fsctl_copychunk(smb_request_t *, smb_fsctl_t *);
818d499c8Gordon Rossuint32_t smb2_fsctl_odx_read(smb_request_t *, smb_fsctl_t *);
828d499c8Gordon Rossuint32_t smb2_fsctl_odx_write(smb_request_t *, smb_fsctl_t *);
8355f0a24Gordon Rossuint32_t smb2_fsctl_set_resilient(smb_request_t *, smb_fsctl_t *);
8455f0a24Gordon Ross
8555f0a24Gordon Ross/* smb2_fsctl_sparse.c */
8655f0a24Gordon Rossuint32_t smb2_fsctl_set_sparse(smb_request_t *, smb_fsctl_t *);
8755f0a24Gordon Rossuint32_t smb2_fsctl_set_zero_data(smb_request_t *, smb_fsctl_t *);
8855f0a24Gordon Rossuint32_t smb2_fsctl_query_alloc_ranges(smb_request_t *, smb_fsctl_t *);
89252bc4bGordon Rossuint32_t smb2_fsctl_query_file_regions(smb_request_t *, smb_fsctl_t *);
9055f0a24Gordon Rossuint32_t smb2_sparse_copy(smb_request_t *sr,
9155f0a24Gordon Ross    smb_ofile_t *src_ofile, smb_ofile_t *dst_ofile,
9255f0a24Gordon Ross    off64_t src_off, off64_t dst_off, uint32_t *residp,
9355f0a24Gordon Ross    void *buffer, size_t bufsize);
9455f0a24Gordon Ross
9555f0a24Gordon Rossuint32_t smb2_nego_validate(smb_request_t *, smb_fsctl_t *);
96a90cf9fGordon Ross
97a90cf9fGordon Rosssmb_sdrc_t smb2_negotiate(smb_request_t *);
98a90cf9fGordon Rosssmb_sdrc_t smb2_session_setup(smb_request_t *);
99a90cf9fGordon Rosssmb_sdrc_t smb2_logoff(smb_request_t *);
100a90cf9fGordon Rosssmb_sdrc_t smb2_tree_connect(smb_request_t *);
101a90cf9fGordon Rosssmb_sdrc_t smb2_tree_disconn(smb_request_t *);
102a90cf9fGordon Rosssmb_sdrc_t smb2_create(smb_request_t *);
103a90cf9fGordon Rosssmb_sdrc_t smb2_close(smb_request_t *);
104a90cf9fGordon Rosssmb_sdrc_t smb2_flush(smb_request_t *);
105a90cf9fGordon Rosssmb_sdrc_t smb2_read(smb_request_t *);
106a90cf9fGordon Rosssmb_sdrc_t smb2_write(smb_request_t *);
107a90cf9fGordon Rosssmb_sdrc_t smb2_lock(smb_request_t *);
108a90cf9fGordon Rosssmb_sdrc_t smb2_ioctl(smb_request_t *);
1095677e04Gordon Rosssmb_sdrc_t smb2_cancel(smb_request_t *);
110a90cf9fGordon Rosssmb_sdrc_t smb2_echo(smb_request_t *);
111a90cf9fGordon Rosssmb_sdrc_t smb2_query_dir(smb_request_t *);
112a90cf9fGordon Rosssmb_sdrc_t smb2_change_notify(smb_request_t *);
113a90cf9fGordon Rosssmb_sdrc_t smb2_query_info(smb_request_t *);
114a90cf9fGordon Rosssmb_sdrc_t smb2_set_info(smb_request_t *);
115a90cf9fGordon Rosssmb_sdrc_t smb2_oplock_break_ack(smb_request_t *);
11694047d4Gordon Rosssmb_sdrc_t smb2_lease_break_ack(smb_request_t *);
117a90cf9fGordon Ross
118a90cf9fGordon Rossint smb2_newrq_negotiate(smb_request_t *);
1195677e04Gordon Rossint smb2_newrq_cancel(smb_request_t *);
120a90cf9fGordon Ross
121d082c87Gordon Rossuint32_t smb2_aapl_crctx(smb_request_t *,
122d082c87Gordon Ross	mbuf_chain_t *, mbuf_chain_t *);
123d082c87Gordon Ross
124a90cf9fGordon Rossuint32_t smb2_ofile_getattr(smb_request_t *, smb_ofile_t *, smb_attr_t *);
125a90cf9fGordon Rossuint32_t smb2_ofile_getstd(smb_ofile_t *, smb_queryinfo_t *);
126a90cf9fGordon Rossuint32_t smb2_ofile_getname(smb_ofile_t *, smb_queryinfo_t *);
127a90cf9fGordon Ross
128a90cf9fGordon Rossuint32_t smb2_qinfo_file(smb_request_t *, smb_queryinfo_t *);
129a90cf9fGordon Rossuint32_t smb2_qinfo_fs(smb_request_t *, smb_queryinfo_t *);
130a90cf9fGordon Rossuint32_t smb2_qinfo_sec(smb_request_t *, smb_queryinfo_t *);
131a90cf9fGordon Rossuint32_t smb2_qinfo_quota(smb_request_t *, smb_queryinfo_t *);
132a90cf9fGordon Rossuint32_t smb2_qinfo_stream(smb_request_t *, smb_queryinfo_t *);
133a90cf9fGordon Ross
134a90cf9fGordon Rossuint32_t smb2_setinfo_file(smb_request_t *, smb_setinfo_t *, int);
135a90cf9fGordon Rossuint32_t smb2_setinfo_fs(smb_request_t *, smb_setinfo_t *, int);
136a90cf9fGordon Rossuint32_t smb2_setinfo_sec(smb_request_t *, smb_setinfo_t *, uint32_t);
137a90cf9fGordon Rossuint32_t smb2_setinfo_quota(smb_request_t *, smb_setinfo_t *);
138a90cf9fGordon Ross
13994047d4Gordon Rossvoid smb2_oplock_acquire(smb_request_t *sr);
14094047d4Gordon Rossvoid smb2_oplock_reconnect(smb_request_t *sr);
14194047d4Gordon Rossvoid smb2_lease_acquire(smb_request_t *sr);
1428d94f65Gordon Rossuint32_t smb2_lease_create(smb_request_t *sr, uint8_t *);
14394047d4Gordon Rossvoid smb2_lease_rele(smb_lease_t *);
14494047d4Gordon Rossvoid smb2_lease_init(void);
14594047d4Gordon Rossvoid smb2_lease_fini(void);
14694047d4Gordon Rossvoid smb2_lease_ofile_close(smb_ofile_t *);
14794047d4Gordon Ross
148811599aMatt Bardenvoid smb2_durable_timers(smb_server_t *);
149811599aMatt Barden
150811599aMatt Bardenuint32_t smb2_dh_reconnect(smb_request_t *);
151811599aMatt Bardenboolean_t smb_dh_should_save(smb_ofile_t *);
152811599aMatt Bardenextern void smb2_dh_shutdown(smb_server_t *);
1538d94f65Gordon Rossint smb2_dh_new_ca_share(smb_server_t *, smb_kshare_t *);
1548d94f65Gordon Rossvoid smb2_dh_close_persistent(smb_ofile_t *);
1558d94f65Gordon Rossvoid smb2_dh_close_my_orphans(smb_request_t *, smb_ofile_t *);
1568d94f65Gordon Rossint smb2_dh_make_persistent(smb_request_t *, smb_ofile_t *);
1578d94f65Gordon Rossvoid smb2_dh_setdoc_persistent(smb_ofile_t *);
1588d94f65Gordon Rossvoid smb2_dh_update_nvfile(smb_request_t *);
1598d94f65Gordon Rossvoid smb2_dh_update_oplock(smb_request_t *, smb_ofile_t *);
1608d94f65Gordon Rossvoid smb2_dh_update_locks(smb_request_t *, smb_ofile_t *);
1618d94f65Gordon Rossvoid smb2_dh_update_times(smb_request_t *, smb_ofile_t *, smb_attr_t *);
162811599aMatt Barden
163a90cf9fGordon Ross#ifdef	__cplusplus
164a90cf9fGordon Ross}
165a90cf9fGordon Ross#endif
166a90cf9fGordon Ross
167a90cf9fGordon Ross#endif /* _SMB2_KPROTO_H_ */
168