1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
14 */
15
16 #ifndef _SMB2_KPROTO_H_
17 #define _SMB2_KPROTO_H_
18
19 #include <smbsrv/smb_kproto.h>
20 #include <smbsrv/smb2.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 extern uint32_t smb2_tcp_rcvbuf;
27 extern uint32_t smb2_max_rwsize;
28 extern uint32_t smb2_max_trans;
29
30 extern int smb2_aapl_use_file_ids;
31 extern uint32_t smb2_dh_def_timeout;
32 extern uint32_t smb2_dh_max_timeout;
33 extern uint32_t smb2_res_def_timeout;
46 int smb2sr_newrq(smb_request_t *);
47 void smb2sr_work(smb_request_t *);
48 uint32_t smb2sr_go_async(smb_request_t *);
49 void smb2sr_append_postwork(smb_request_t *, smb_request_t *);
50
51 int smb2_decode_header(smb_request_t *);
52 int smb2_encode_header(smb_request_t *, boolean_t);
53 int smb3_decode_tform_header(smb_request_t *);
54 int smb3_encode_tform_header(smb_request_t *, struct mbuf_chain *mbc);
55
56 void smb2_send_reply(smb_request_t *);
57 void smb2sr_put_error(smb_request_t *, uint32_t);
58 void smb2sr_put_error_data(smb_request_t *, uint32_t, mbuf_chain_t *);
59 void smb2sr_put_errno(struct smb_request *, int);
60 uint32_t smb2sr_lookup_fid(smb_request_t *, smb2fid_t *);
61
62 /* SMB2 signing routines - smb2_signing.c */
63 int smb2_sign_check_request(smb_request_t *);
64 void smb2_sign_reply(smb_request_t *);
65 void smb2_sign_init_mech(smb_session_t *);
66
67 int smb3_encrypt_sr(smb_request_t *, struct mbuf_chain *, struct mbuf_chain *);
68 int smb3_decrypt_sr(smb_request_t *);
69 int smb3_encrypt_init_mech(smb_session_t *s);
70
71 uint32_t smb2_fsctl_fs(smb_request_t *, smb_fsctl_t *);
72 uint32_t smb2_fsctl_netfs(smb_request_t *, smb_fsctl_t *);
73 uint32_t smb2_fsctl_copychunk(smb_request_t *, smb_fsctl_t *);
74 uint32_t smb2_fsctl_odx_read(smb_request_t *, smb_fsctl_t *);
75 uint32_t smb2_fsctl_odx_write(smb_request_t *, smb_fsctl_t *);
76 uint32_t smb2_fsctl_set_resilient(smb_request_t *, smb_fsctl_t *);
77
78 /* smb2_fsctl_sparse.c */
79 uint32_t smb2_fsctl_set_sparse(smb_request_t *, smb_fsctl_t *);
80 uint32_t smb2_fsctl_set_zero_data(smb_request_t *, smb_fsctl_t *);
81 uint32_t smb2_fsctl_query_alloc_ranges(smb_request_t *, smb_fsctl_t *);
82 uint32_t smb2_fsctl_query_file_regions(smb_request_t *, smb_fsctl_t *);
83 uint32_t smb2_sparse_copy(smb_request_t *sr,
84 smb_ofile_t *src_ofile, smb_ofile_t *dst_ofile,
85 off64_t src_off, off64_t dst_off, uint32_t *residp,
|
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
14 * Copyright 2020 RackTop Systems, Inc.
15 */
16
17 #ifndef _SMB2_KPROTO_H_
18 #define _SMB2_KPROTO_H_
19
20 #include <smbsrv/smb_kproto.h>
21 #include <smbsrv/smb2.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 extern uint32_t smb2_tcp_rcvbuf;
28 extern uint32_t smb2_max_rwsize;
29 extern uint32_t smb2_max_trans;
30
31 extern int smb2_aapl_use_file_ids;
32 extern uint32_t smb2_dh_def_timeout;
33 extern uint32_t smb2_dh_max_timeout;
34 extern uint32_t smb2_res_def_timeout;
47 int smb2sr_newrq(smb_request_t *);
48 void smb2sr_work(smb_request_t *);
49 uint32_t smb2sr_go_async(smb_request_t *);
50 void smb2sr_append_postwork(smb_request_t *, smb_request_t *);
51
52 int smb2_decode_header(smb_request_t *);
53 int smb2_encode_header(smb_request_t *, boolean_t);
54 int smb3_decode_tform_header(smb_request_t *);
55 int smb3_encode_tform_header(smb_request_t *, struct mbuf_chain *mbc);
56
57 void smb2_send_reply(smb_request_t *);
58 void smb2sr_put_error(smb_request_t *, uint32_t);
59 void smb2sr_put_error_data(smb_request_t *, uint32_t, mbuf_chain_t *);
60 void smb2sr_put_errno(struct smb_request *, int);
61 uint32_t smb2sr_lookup_fid(smb_request_t *, smb2fid_t *);
62
63 /* SMB2 signing routines - smb2_signing.c */
64 int smb2_sign_check_request(smb_request_t *);
65 void smb2_sign_reply(smb_request_t *);
66 void smb2_sign_init_mech(smb_session_t *);
67 void smb31_preauth_init_mech(smb_session_t *);
68 void smb31_preauth_fini(smb_session_t *s);
69 int smb31_preauth_sha512_calc(smb_request_t *, struct mbuf_chain *,
70 uint8_t *);
71
72 int smb3_encrypt_sr(smb_request_t *, struct mbuf_chain *, struct mbuf_chain *);
73 int smb3_decrypt_sr(smb_request_t *);
74 int smb3_encrypt_init_mech(smb_session_t *s);
75
76 uint32_t smb2_fsctl_fs(smb_request_t *, smb_fsctl_t *);
77 uint32_t smb2_fsctl_netfs(smb_request_t *, smb_fsctl_t *);
78 uint32_t smb2_fsctl_copychunk(smb_request_t *, smb_fsctl_t *);
79 uint32_t smb2_fsctl_odx_read(smb_request_t *, smb_fsctl_t *);
80 uint32_t smb2_fsctl_odx_write(smb_request_t *, smb_fsctl_t *);
81 uint32_t smb2_fsctl_set_resilient(smb_request_t *, smb_fsctl_t *);
82
83 /* smb2_fsctl_sparse.c */
84 uint32_t smb2_fsctl_set_sparse(smb_request_t *, smb_fsctl_t *);
85 uint32_t smb2_fsctl_set_zero_data(smb_request_t *, smb_fsctl_t *);
86 uint32_t smb2_fsctl_query_alloc_ranges(smb_request_t *, smb_fsctl_t *);
87 uint32_t smb2_fsctl_query_file_regions(smb_request_t *, smb_fsctl_t *);
88 uint32_t smb2_sparse_copy(smb_request_t *sr,
89 smb_ofile_t *src_ofile, smb_ofile_t *dst_ofile,
90 off64_t src_off, off64_t dst_off, uint32_t *residp,
|