xref: /titanic_51/usr/src/uts/common/smbsrv/smb_ioctl.h (revision 4f60987df4dcaa54a88b596f861fbf4f3382c65e)
1 /*
2  * CDDL HEADER START
3  *
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMB_IOCTL_H_
27 #define	_SMB_IOCTL_H_
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <smbsrv/smbinfo.h>
36 
37 #define	SMB_IOC_VERSION		0x534D4201	/* SMB1 */
38 
39 #define	SMB_IOC_BASE		(('S' << 16) | ('B' << 8))
40 
41 #define	SMB_IOC_CONFIG		_IOW(SMB_IOC_BASE, 1, int)
42 #define	SMB_IOC_START		_IOW(SMB_IOC_BASE, 2, int)
43 #define	SMB_IOC_NBT_LISTEN	_IOW(SMB_IOC_BASE, 3, int)
44 #define	SMB_IOC_TCP_LISTEN	_IOW(SMB_IOC_BASE, 4, int)
45 #define	SMB_IOC_NBT_RECEIVE	_IOW(SMB_IOC_BASE, 5, int)
46 #define	SMB_IOC_TCP_RECEIVE	_IOW(SMB_IOC_BASE, 6, int)
47 #define	SMB_IOC_GMTOFF		_IOW(SMB_IOC_BASE, 7, int)
48 #define	SMB_IOC_SHARE		_IOW(SMB_IOC_BASE, 8, int)
49 #define	SMB_IOC_UNSHARE		_IOW(SMB_IOC_BASE, 9, int)
50 #define	SMB_IOC_NUMOPEN		_IOW(SMB_IOC_BASE, 10, int)
51 #define	SMB_IOC_SVCENUM		_IOW(SMB_IOC_BASE, 11, int)
52 #define	SMB_IOC_FILE_CLOSE	_IOW(SMB_IOC_BASE, 12, int)
53 #define	SMB_IOC_SESSION_CLOSE	_IOW(SMB_IOC_BASE, 13, int)
54 #define	SMB_IOC_STOP		_IOW(SMB_IOC_BASE, 14, int)
55 #define	SMB_IOC_EVENT		_IOW(SMB_IOC_BASE, 15, int)
56 
57 typedef struct smb_ioc_header {
58 	uint32_t	version;
59 	uint32_t	crc;
60 	uint32_t	len;
61 	int		cmd;
62 } smb_ioc_header_t;
63 
64 typedef	struct {
65 	smb_ioc_header_t hdr;
66 	int32_t 	offset;
67 } smb_ioc_gmt_t;
68 
69 typedef struct smb_ioc_share {
70 	smb_ioc_header_t hdr;
71 	char		path[MAXPATHLEN];
72 	char		name[MAXNAMELEN];
73 } smb_ioc_share_t;
74 
75 typedef	struct smb_ioc_listen {
76 	smb_ioc_header_t hdr;
77 	int		error;
78 } smb_ioc_listen_t;
79 
80 typedef	struct smb_ioc_start {
81 	smb_ioc_header_t hdr;
82 	int		opipe;
83 	int		lmshrd;
84 	int		udoor;
85 } smb_ioc_start_t;
86 
87 typedef	struct smb_ioc_event {
88 	smb_ioc_header_t hdr;
89 	uint32_t	txid;
90 } smb_ioc_event_t;
91 
92 typedef	struct smb_ioc_opennum {
93 	smb_ioc_header_t hdr;
94 	uint32_t	open_users;
95 	uint32_t	open_trees;
96 	uint32_t	open_files;
97 	uint32_t	qualtype;
98 	char		qualifier[MAXNAMELEN];
99 } smb_ioc_opennum_t;
100 
101 /*
102  * For enumeration, user and session are synonymous, as are
103  * connection and tree.
104  */
105 #define	SMB_SVCENUM_TYPE_USER	0x55534552	/* 'USER' */
106 #define	SMB_SVCENUM_TYPE_TREE	0x54524545	/* 'TREE' */
107 #define	SMB_SVCENUM_TYPE_FILE	0x46494C45	/* 'FILE' */
108 #define	SMB_SVCENUM_TYPE_SHARE	0x53484152	/* 'SHAR' */
109 
110 typedef struct smb_svcenum {
111 	uint32_t	se_type;	/* object type to enumerate */
112 	uint32_t	se_level;	/* level of detail being requested */
113 	uint32_t	se_prefmaxlen;	/* client max size buffer preference */
114 	uint32_t	se_resume;	/* client resume handle */
115 	uint32_t	se_bavail;	/* remaining buffer space in bytes */
116 	uint32_t	se_bused;	/* consumed buffer space in bytes */
117 	uint32_t	se_ntotal;	/* total number of objects */
118 	uint32_t	se_nlimit;	/* max number of objects to return */
119 	uint32_t	se_nitems;	/* number of objects in buf */
120 	uint32_t	se_nskip;	/* number of objects to skip */
121 	uint32_t	se_status;	/* enumeration status */
122 	uint32_t	se_buflen;	/* length of the buffer in bytes */
123 	uint8_t		se_buf[1];	/* buffer to hold enumeration data */
124 } smb_svcenum_t;
125 
126 typedef	struct smb_ioc_svcenum {
127 	smb_ioc_header_t hdr;
128 	smb_svcenum_t	svcenum;
129 } smb_ioc_svcenum_t;
130 
131 typedef struct smb_ioc_session {
132 	smb_ioc_header_t hdr;
133 	char		client[MAXNAMELEN];
134 	char		username[MAXNAMELEN];
135 } smb_ioc_session_t;
136 
137 typedef	struct smb_ioc_fileid {
138 	smb_ioc_header_t hdr;
139 	uint32_t	uniqid;
140 } smb_ioc_fileid_t;
141 
142 typedef struct smb_ioc_cfg {
143 	smb_ioc_header_t hdr;
144 	uint32_t	maxworkers;
145 	uint32_t	maxconnections;
146 	uint32_t	keepalive;
147 	int32_t		restrict_anon;
148 	int32_t		signing_enable;
149 	int32_t		signing_required;
150 	int32_t		oplock_enable;
151 	int32_t		sync_enable;
152 	int32_t		secmode;
153 	int32_t		ipv6_enable;
154 	char		nbdomain[NETBIOS_NAME_SZ];
155 	char		fqdn[SMB_PI_MAX_DOMAIN];
156 	char		hostname[SMB_PI_MAX_HOST];
157 	char		system_comment[SMB_PI_MAX_COMMENT];
158 } smb_ioc_cfg_t;
159 
160 typedef union smb_ioc {
161 	smb_ioc_header_t	ioc_hdr;
162 	smb_ioc_gmt_t		ioc_gmt;
163 	smb_ioc_cfg_t		ioc_cfg;
164 	smb_ioc_start_t		ioc_start;
165 	smb_ioc_event_t		ioc_event;
166 	smb_ioc_listen_t	ioc_listen;
167 	smb_ioc_opennum_t	ioc_opennum;
168 	smb_ioc_svcenum_t	ioc_svcenum;
169 	smb_ioc_session_t	ioc_session;
170 	smb_ioc_fileid_t	ioc_fileid;
171 	smb_ioc_share_t		ioc_share;
172 } smb_ioc_t;
173 
174 uint32_t smb_crc_gen(uint8_t *, size_t);
175 
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 #endif /* _SMB_IOCTL_H_ */
181