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