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 2014 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 void smb2_dispatch_stats_init(smb_server_t *);
31 void smb2_dispatch_stats_fini(smb_server_t *);
32 void smb2_dispatch_stats_update(smb_server_t *,
33 smb_kstat_req_t *, int, int);
34
35 int smb2sr_newrq(smb_request_t *);
36 int smb2sr_newrq_async(smb_request_t *);
37 int smb2sr_newrq_cancel(smb_request_t *);
38 void smb2sr_work(smb_request_t *);
39
40 int smb2_decode_header(smb_request_t *);
41 int smb2_encode_header(smb_request_t *, boolean_t);
42 void smb2_send_reply(smb_request_t *);
43 void smb2sr_put_error(smb_request_t *, uint32_t);
44 void smb2sr_put_error_data(smb_request_t *, uint32_t, mbuf_chain_t *);
45 void smb2sr_put_errno(struct smb_request *, int);
46 uint32_t smb2sr_lookup_fid(smb_request_t *, smb2fid_t *);
47
48 /* SMB2 signing routines - smb2_signing.c */
49 int smb2_sign_check_request(smb_request_t *);
50 void smb2_sign_reply(smb_request_t *);
51
52 uint32_t smb2_fsctl_vneginfo(smb_request_t *, smb_fsctl_t *);
53
54 smb_sdrc_t smb2_negotiate(smb_request_t *);
55 smb_sdrc_t smb2_session_setup(smb_request_t *);
56 smb_sdrc_t smb2_logoff(smb_request_t *);
57 smb_sdrc_t smb2_tree_connect(smb_request_t *);
58 smb_sdrc_t smb2_tree_disconn(smb_request_t *);
59 smb_sdrc_t smb2_create(smb_request_t *);
60 smb_sdrc_t smb2_close(smb_request_t *);
61 smb_sdrc_t smb2_flush(smb_request_t *);
62 smb_sdrc_t smb2_read(smb_request_t *);
63 smb_sdrc_t smb2_write(smb_request_t *);
64 smb_sdrc_t smb2_lock(smb_request_t *);
65 smb_sdrc_t smb2_ioctl(smb_request_t *);
66 /* No smb2_cancel() - see smb2_dispatch.c */
67 smb_sdrc_t smb2_echo(smb_request_t *);
68 smb_sdrc_t smb2_query_dir(smb_request_t *);
69 smb_sdrc_t smb2_change_notify(smb_request_t *);
70 smb_sdrc_t smb2_query_info(smb_request_t *);
71 smb_sdrc_t smb2_set_info(smb_request_t *);
72 smb_sdrc_t smb2_oplock_break_ack(smb_request_t *);
73
74 int smb2_newrq_negotiate(smb_request_t *);
75
76 uint32_t smb2_ofile_getattr(smb_request_t *, smb_ofile_t *, smb_attr_t *);
77 uint32_t smb2_ofile_getstd(smb_ofile_t *, smb_queryinfo_t *);
78 uint32_t smb2_ofile_getname(smb_ofile_t *, smb_queryinfo_t *);
79
80 uint32_t smb2_qinfo_file(smb_request_t *, smb_queryinfo_t *);
81 uint32_t smb2_qinfo_fs(smb_request_t *, smb_queryinfo_t *);
82 uint32_t smb2_qinfo_sec(smb_request_t *, smb_queryinfo_t *);
83 uint32_t smb2_qinfo_quota(smb_request_t *, smb_queryinfo_t *);
84 uint32_t smb2_qinfo_stream(smb_request_t *, smb_queryinfo_t *);
85
86 uint32_t smb2_setinfo_file(smb_request_t *, smb_setinfo_t *, int);
87 uint32_t smb2_setinfo_fs(smb_request_t *, smb_setinfo_t *, int);
88 uint32_t smb2_setinfo_sec(smb_request_t *, smb_setinfo_t *, uint32_t);
89 uint32_t smb2_setinfo_quota(smb_request_t *, smb_setinfo_t *);
90
91 #ifdef __cplusplus
92 }
93 #endif
94
95 #endif /* _SMB2_KPROTO_H_ */
|
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;
34 extern uint32_t smb2_res_max_timeout;
35 extern uint32_t smb2_persist_timeout;
36 extern int smb2_enable_dh;
37
38 #define SMB2_KEYLEN 16
39 #define SMB3_KEYLEN 16 /* AES-128 keys */
40
41 #define SMB3_CLIENT_ENCRYPTS(sr) \
42 ((sr->session->capabilities & SMB2_CAP_ENCRYPTION) != 0)
43
44 void smb2_dispatch_stats_init(smb_server_t *);
45 void smb2_dispatch_stats_fini(smb_server_t *);
46 void smb2_dispatch_stats_update(smb_server_t *,
47 smb_kstat_req_t *, int, int);
48
49 int smb2sr_newrq(smb_request_t *);
50 void smb2sr_work(smb_request_t *);
51 uint32_t smb2sr_go_async(smb_request_t *);
52 void smb2sr_append_postwork(smb_request_t *, smb_request_t *);
53
54 int smb2_decode_header(smb_request_t *);
55 int smb2_encode_header(smb_request_t *, boolean_t);
56 int smb3_decode_tform_header(smb_request_t *);
57 int smb3_encode_tform_header(smb_request_t *, struct mbuf_chain *mbc);
58
59 void smb2_send_reply(smb_request_t *);
60 void smb2sr_put_error(smb_request_t *, uint32_t);
61 void smb2sr_put_error_data(smb_request_t *, uint32_t, mbuf_chain_t *);
62 void smb2sr_put_errno(struct smb_request *, int);
63 uint32_t smb2sr_lookup_fid(smb_request_t *, smb2fid_t *);
64
65 /* SMB2 signing routines - smb2_signing.c */
66 int smb2_sign_check_request(smb_request_t *);
67 void smb2_sign_reply(smb_request_t *);
68 void smb2_sign_init_mech(smb_session_t *);
69
70 int smb3_encrypt_sr(smb_request_t *, struct mbuf_chain *, struct mbuf_chain *);
71 int smb3_decrypt_sr(smb_request_t *);
72 int smb3_encrypt_init_mech(smb_session_t *s);
73
74 uint32_t smb2_fsctl_fs(smb_request_t *, smb_fsctl_t *);
75 uint32_t smb2_fsctl_netfs(smb_request_t *, smb_fsctl_t *);
76 uint32_t smb2_fsctl_copychunk(smb_request_t *, smb_fsctl_t *);
77 uint32_t smb2_fsctl_odx_read(smb_request_t *, smb_fsctl_t *);
78 uint32_t smb2_fsctl_odx_write(smb_request_t *, smb_fsctl_t *);
79 uint32_t smb2_fsctl_set_resilient(smb_request_t *, smb_fsctl_t *);
80
81 /* smb2_fsctl_sparse.c */
82 uint32_t smb2_fsctl_set_sparse(smb_request_t *, smb_fsctl_t *);
83 uint32_t smb2_fsctl_set_zero_data(smb_request_t *, smb_fsctl_t *);
84 uint32_t smb2_fsctl_query_alloc_ranges(smb_request_t *, smb_fsctl_t *);
85 uint32_t smb2_fsctl_query_file_regions(smb_request_t *, smb_fsctl_t *);
86 uint32_t smb2_sparse_copy(smb_request_t *sr,
87 smb_ofile_t *src_ofile, smb_ofile_t *dst_ofile,
88 off64_t src_off, off64_t dst_off, uint32_t *residp,
89 void *buffer, size_t bufsize);
90
91 uint32_t smb2_nego_validate(smb_request_t *, smb_fsctl_t *);
92
93 smb_sdrc_t smb2_negotiate(smb_request_t *);
94 smb_sdrc_t smb2_session_setup(smb_request_t *);
95 smb_sdrc_t smb2_logoff(smb_request_t *);
96 smb_sdrc_t smb2_tree_connect(smb_request_t *);
97 smb_sdrc_t smb2_tree_disconn(smb_request_t *);
98 smb_sdrc_t smb2_create(smb_request_t *);
99 smb_sdrc_t smb2_close(smb_request_t *);
100 smb_sdrc_t smb2_flush(smb_request_t *);
101 smb_sdrc_t smb2_read(smb_request_t *);
102 smb_sdrc_t smb2_write(smb_request_t *);
103 smb_sdrc_t smb2_lock(smb_request_t *);
104 smb_sdrc_t smb2_ioctl(smb_request_t *);
105 smb_sdrc_t smb2_cancel(smb_request_t *);
106 smb_sdrc_t smb2_echo(smb_request_t *);
107 smb_sdrc_t smb2_query_dir(smb_request_t *);
108 smb_sdrc_t smb2_change_notify(smb_request_t *);
109 smb_sdrc_t smb2_query_info(smb_request_t *);
110 smb_sdrc_t smb2_set_info(smb_request_t *);
111 smb_sdrc_t smb2_oplock_break_ack(smb_request_t *);
112 smb_sdrc_t smb2_lease_break_ack(smb_request_t *);
113
114 int smb2_newrq_negotiate(smb_request_t *);
115 int smb2_newrq_cancel(smb_request_t *);
116
117 uint32_t smb2_aapl_crctx(smb_request_t *,
118 mbuf_chain_t *, mbuf_chain_t *);
119
120 uint32_t smb2_ofile_getattr(smb_request_t *, smb_ofile_t *, smb_attr_t *);
121 uint32_t smb2_ofile_getstd(smb_ofile_t *, smb_queryinfo_t *);
122 uint32_t smb2_ofile_getname(smb_ofile_t *, smb_queryinfo_t *);
123
124 uint32_t smb2_qinfo_file(smb_request_t *, smb_queryinfo_t *);
125 uint32_t smb2_qinfo_fs(smb_request_t *, smb_queryinfo_t *);
126 uint32_t smb2_qinfo_sec(smb_request_t *, smb_queryinfo_t *);
127 uint32_t smb2_qinfo_quota(smb_request_t *, smb_queryinfo_t *);
128 uint32_t smb2_qinfo_stream(smb_request_t *, smb_queryinfo_t *);
129
130 uint32_t smb2_setinfo_file(smb_request_t *, smb_setinfo_t *, int);
131 uint32_t smb2_setinfo_fs(smb_request_t *, smb_setinfo_t *, int);
132 uint32_t smb2_setinfo_sec(smb_request_t *, smb_setinfo_t *, uint32_t);
133 uint32_t smb2_setinfo_quota(smb_request_t *, smb_setinfo_t *);
134
135 void smb2_oplock_acquire(smb_request_t *sr);
136 void smb2_lease_acquire(smb_request_t *sr);
137 uint32_t smb2_lease_create(smb_request_t *sr, uint8_t *);
138 void smb2_lease_rele(smb_lease_t *);
139 void smb2_lease_init(void);
140 void smb2_lease_fini(void);
141 void smb2_lease_ofile_close(smb_ofile_t *);
142
143 void smb2_durable_timers(smb_server_t *);
144
145 uint32_t smb2_dh_reconnect(smb_request_t *);
146 boolean_t smb_dh_should_save(smb_ofile_t *);
147 extern void smb2_dh_shutdown(smb_server_t *);
148 int smb2_dh_new_ca_share(smb_server_t *, smb_kshare_t *);
149 void smb2_dh_close_persistent(smb_ofile_t *);
150 void smb2_dh_close_my_orphans(smb_request_t *, smb_ofile_t *);
151 int smb2_dh_make_persistent(smb_request_t *, smb_ofile_t *);
152 void smb2_dh_setdoc_persistent(smb_ofile_t *);
153 void smb2_dh_update_nvfile(smb_request_t *);
154 void smb2_dh_update_oplock(smb_request_t *, smb_ofile_t *);
155 void smb2_dh_update_locks(smb_request_t *, smb_ofile_t *);
156 void smb2_dh_update_times(smb_request_t *, smb_ofile_t *, smb_attr_t *);
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif /* _SMB2_KPROTO_H_ */
|