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