4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2019 Nexenta by DDN, Inc. All rights reserved.
24 */
25
26 /*
27 * Structures and type definitions for the SMB module.
28 */
29
30 #ifndef _SMBSRV_SMB_KTYPES_H
31 #define _SMBSRV_SMB_KTYPES_H
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #include <sys/note.h>
38 #include <sys/systm.h>
39 #include <sys/param.h>
40 #include <sys/types.h>
41 #include <sys/synch.h>
42 #include <sys/taskq.h>
43 #include <sys/socket.h>
871 *
872 *
873 * Transition T4
874 *
875 *
876 *
877 * Transition T5
878 *
879 *
880 *
881 * Transition T6
882 *
883 *
884 *
885 */
886 #define SMB_SESSION_MAGIC 0x53455353 /* 'SESS' */
887 #define SMB_SESSION_VALID(p) \
888 ASSERT(((p) != NULL) && ((p)->s_magic == SMB_SESSION_MAGIC))
889
890 #define SMB_CHALLENGE_SZ 8
891
892 typedef enum {
893 SMB_SESSION_STATE_INITIALIZED = 0,
894 SMB_SESSION_STATE_DISCONNECTED,
895 SMB_SESSION_STATE_CONNECTED,
896 SMB_SESSION_STATE_ESTABLISHED,
897 SMB_SESSION_STATE_NEGOTIATED,
898 SMB_SESSION_STATE_TERMINATED,
899 SMB_SESSION_STATE_SHUTDOWN,
900 SMB_SESSION_STATE_SENTINEL
901 } smb_session_state_t;
902
903 /* Bits in s_flags below */
904 #define SMB_SSN_AAPL_CCEXT 1 /* Saw "AAPL" create ctx. ext. */
905 #define SMB_SSN_AAPL_READDIR 2 /* Wants MacOS ext. readdir */
906
907 typedef struct smb_session {
908 list_node_t s_lnd;
909 uint32_t s_magic;
910 smb_rwx_t s_lock;
921 uint32_t keep_alive;
922 uint64_t opentime;
923 uint16_t s_local_port;
924 uint16_t s_remote_port;
925 smb_inaddr_t ipaddr;
926 smb_inaddr_t local_ipaddr;
927 int dialect;
928 int native_os;
929 int native_lm;
930
931 kmutex_t s_credits_mutex;
932 uint16_t s_cur_credits;
933 uint16_t s_max_credits;
934
935 uint32_t capabilities;
936 uint32_t srv_cap;
937
938 struct smb_sign signing; /* SMB1 */
939 void *sign_mech; /* mechanism info */
940 void *enc_mech;
941
942 /* SMB2/SMB3 signing support */
943 int (*sign_calc)(struct smb_request *,
944 struct mbuf_chain *, uint8_t *);
945 void (*sign_fini)(struct smb_session *);
946
947 ksocket_t sock;
948
949 smb_slist_t s_req_list;
950 smb_llist_t s_xa_list;
951 smb_llist_t s_user_list;
952 smb_llist_t s_tree_list;
953 smb_idpool_t s_uid_pool;
954 smb_idpool_t s_tid_pool;
955 smb_txlst_t s_txlst;
956
957 volatile uint32_t s_tree_cnt;
958 volatile uint32_t s_file_cnt;
959 volatile uint32_t s_dir_cnt;
960
961 uint16_t cli_secmode;
962 uint16_t srv_secmode;
963 uint32_t sesskey;
964 uint32_t challenge_len;
965 unsigned char challenge_key[SMB_CHALLENGE_SZ];
966 int64_t activity_timestamp;
967 timeout_id_t s_auth_tmo;
968
969 /*
970 * Maximum negotiated buffer sizes between SMB client and server
971 * in SMB_SESSION_SETUP_ANDX
972 */
973 int cmd_max_bytes;
974 int reply_max_bytes;
975 uint16_t smb_msg_size;
976 uint16_t smb_max_mpx;
977 smb_srqueue_t *s_srqueue;
978 uint64_t start_time;
979 unsigned char MAC_key[44];
980 char ip_addr_str[INET6_ADDRSTRLEN];
981 uint8_t clnt_uuid[16];
982 char workstation[SMB_PI_MAX_HOST];
983 } smb_session_t;
984
985 /*
986 * The "user" object.
987 *
988 * Note that smb_user_t object here corresponds to what MS-SMB2 calls
989 * a "session". (Our smb_session_t is something else -- see above).
990 */
991
992 #define SMB_USER_MAGIC 0x55534552 /* 'USER' */
993 #define SMB_USER_VALID(u) \
994 ASSERT(((u) != NULL) && ((u)->u_magic == SMB_USER_MAGIC))
995
996 /* These flags are all <= 0x00000010 */
997 #define SMB_USER_FLAG_GUEST SMB_ATF_GUEST
998 #define SMB_USER_FLAG_ANON SMB_ATF_ANON
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2019 Nexenta by DDN, Inc. All rights reserved.
24 * Copyright 2020 RackTop Systems, Inc.
25 */
26
27 /*
28 * Structures and type definitions for the SMB module.
29 */
30
31 #ifndef _SMBSRV_SMB_KTYPES_H
32 #define _SMBSRV_SMB_KTYPES_H
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #include <sys/note.h>
39 #include <sys/systm.h>
40 #include <sys/param.h>
41 #include <sys/types.h>
42 #include <sys/synch.h>
43 #include <sys/taskq.h>
44 #include <sys/socket.h>
872 *
873 *
874 * Transition T4
875 *
876 *
877 *
878 * Transition T5
879 *
880 *
881 *
882 * Transition T6
883 *
884 *
885 *
886 */
887 #define SMB_SESSION_MAGIC 0x53455353 /* 'SESS' */
888 #define SMB_SESSION_VALID(p) \
889 ASSERT(((p) != NULL) && ((p)->s_magic == SMB_SESSION_MAGIC))
890
891 #define SMB_CHALLENGE_SZ 8
892 #define SMB3_PREAUTH_HASHVAL_SZ 64
893
894 typedef enum {
895 SMB_SESSION_STATE_INITIALIZED = 0,
896 SMB_SESSION_STATE_DISCONNECTED,
897 SMB_SESSION_STATE_CONNECTED,
898 SMB_SESSION_STATE_ESTABLISHED,
899 SMB_SESSION_STATE_NEGOTIATED,
900 SMB_SESSION_STATE_TERMINATED,
901 SMB_SESSION_STATE_SHUTDOWN,
902 SMB_SESSION_STATE_SENTINEL
903 } smb_session_state_t;
904
905 /* Bits in s_flags below */
906 #define SMB_SSN_AAPL_CCEXT 1 /* Saw "AAPL" create ctx. ext. */
907 #define SMB_SSN_AAPL_READDIR 2 /* Wants MacOS ext. readdir */
908
909 typedef struct smb_session {
910 list_node_t s_lnd;
911 uint32_t s_magic;
912 smb_rwx_t s_lock;
923 uint32_t keep_alive;
924 uint64_t opentime;
925 uint16_t s_local_port;
926 uint16_t s_remote_port;
927 smb_inaddr_t ipaddr;
928 smb_inaddr_t local_ipaddr;
929 int dialect;
930 int native_os;
931 int native_lm;
932
933 kmutex_t s_credits_mutex;
934 uint16_t s_cur_credits;
935 uint16_t s_max_credits;
936
937 uint32_t capabilities;
938 uint32_t srv_cap;
939
940 struct smb_sign signing; /* SMB1 */
941 void *sign_mech; /* mechanism info */
942 void *enc_mech;
943 void *preauth_mech;
944
945 /* SMB2/SMB3 signing support */
946 int (*sign_calc)(struct smb_request *,
947 struct mbuf_chain *, uint8_t *);
948 void (*sign_fini)(struct smb_session *);
949
950 ksocket_t sock;
951
952 smb_slist_t s_req_list;
953 smb_llist_t s_xa_list;
954 smb_llist_t s_user_list;
955 smb_llist_t s_tree_list;
956 smb_idpool_t s_uid_pool;
957 smb_idpool_t s_tid_pool;
958 smb_txlst_t s_txlst;
959
960 volatile uint32_t s_tree_cnt;
961 volatile uint32_t s_file_cnt;
962 volatile uint32_t s_dir_cnt;
963
964 uint16_t cli_secmode;
965 uint16_t srv_secmode;
966 uint32_t sesskey;
967 uint32_t challenge_len;
968 unsigned char challenge_key[SMB_CHALLENGE_SZ];
969 int64_t activity_timestamp;
970 timeout_id_t s_auth_tmo;
971
972 /*
973 * Maximum negotiated buffer sizes between SMB client and server
974 * in SMB_SESSION_SETUP_ANDX
975 */
976 int cmd_max_bytes;
977 int reply_max_bytes;
978 uint16_t smb_msg_size;
979 uint16_t smb_max_mpx;
980 smb_srqueue_t *s_srqueue;
981 uint64_t start_time;
982
983 uint16_t smb31_enc_cipherid;
984 uint16_t smb31_preauth_hashid;
985 uint8_t smb31_preauth_hashval[SMB3_PREAUTH_HASHVAL_SZ];
986 uint8_t smb31_preauth_salt[32];
987
988 unsigned char MAC_key[44];
989 char ip_addr_str[INET6_ADDRSTRLEN];
990 uint8_t clnt_uuid[16];
991 char workstation[SMB_PI_MAX_HOST];
992 } smb_session_t;
993
994 /*
995 * The "user" object.
996 *
997 * Note that smb_user_t object here corresponds to what MS-SMB2 calls
998 * a "session". (Our smb_session_t is something else -- see above).
999 */
1000
1001 #define SMB_USER_MAGIC 0x55534552 /* 'USER' */
1002 #define SMB_USER_VALID(u) \
1003 ASSERT(((u) != NULL) && ((u)->u_magic == SMB_USER_MAGIC))
1004
1005 /* These flags are all <= 0x00000010 */
1006 #define SMB_USER_FLAG_GUEST SMB_ATF_GUEST
1007 #define SMB_USER_FLAG_ANON SMB_ATF_ANON
|