xref: /freebsd/sys/netsmb/smb_dev.h (revision 34ae6c7541656dcbe96ac1ddad4d6ceec1251c9b)
1681a5bbeSBoris Popov /*
2681a5bbeSBoris Popov  * Copyright (c) 2000-2001 Boris Popov
3681a5bbeSBoris Popov  * All rights reserved.
4681a5bbeSBoris Popov  *
5681a5bbeSBoris Popov  * Redistribution and use in source and binary forms, with or without
6681a5bbeSBoris Popov  * modification, are permitted provided that the following conditions
7681a5bbeSBoris Popov  * are met:
8681a5bbeSBoris Popov  * 1. Redistributions of source code must retain the above copyright
9681a5bbeSBoris Popov  *    notice, this list of conditions and the following disclaimer.
10681a5bbeSBoris Popov  * 2. Redistributions in binary form must reproduce the above copyright
11681a5bbeSBoris Popov  *    notice, this list of conditions and the following disclaimer in the
12681a5bbeSBoris Popov  *    documentation and/or other materials provided with the distribution.
13681a5bbeSBoris Popov  * 3. All advertising materials mentioning features or use of this software
14681a5bbeSBoris Popov  *    must display the following acknowledgement:
15681a5bbeSBoris Popov  *    This product includes software developed by Boris Popov.
16681a5bbeSBoris Popov  * 4. Neither the name of the author nor the names of any co-contributors
17681a5bbeSBoris Popov  *    may be used to endorse or promote products derived from this software
18681a5bbeSBoris Popov  *    without specific prior written permission.
19681a5bbeSBoris Popov  *
20681a5bbeSBoris Popov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21681a5bbeSBoris Popov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22681a5bbeSBoris Popov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23681a5bbeSBoris Popov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24681a5bbeSBoris Popov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25681a5bbeSBoris Popov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26681a5bbeSBoris Popov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27681a5bbeSBoris Popov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28681a5bbeSBoris Popov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29681a5bbeSBoris Popov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30681a5bbeSBoris Popov  * SUCH DAMAGE.
31681a5bbeSBoris Popov  *
32681a5bbeSBoris Popov  * $FreeBSD$
33681a5bbeSBoris Popov  */
34681a5bbeSBoris Popov #ifndef _NETSMB_DEV_H_
35681a5bbeSBoris Popov #define _NETSMB_DEV_H_
36681a5bbeSBoris Popov 
3734ae6c75SBoris Popov #ifndef _KERNEL
3834ae6c75SBoris Popov #include <sys/types.h>
3934ae6c75SBoris Popov #endif
4034ae6c75SBoris Popov #include <sys/ioccom.h>
4134ae6c75SBoris Popov 
42cdcb16abSBoris Popov #include <netsmb/smb.h>
43cdcb16abSBoris Popov 
44681a5bbeSBoris Popov #define	NSMB_NAME		"nsmb"
45681a5bbeSBoris Popov #define	NSMB_MAJOR		144
46681a5bbeSBoris Popov 
47681a5bbeSBoris Popov #define NSMB_VERMAJ	1
48681a5bbeSBoris Popov #define NSMB_VERMIN	3006
49681a5bbeSBoris Popov #define NSMB_VERSION	(NSMB_VERMAJ * 100000 + NSMB_VERMIN)
50681a5bbeSBoris Popov 
51681a5bbeSBoris Popov #define NSMBFL_OPEN		0x0001
52681a5bbeSBoris Popov 
53681a5bbeSBoris Popov #define	SMBVOPT_CREATE		0x0001	/* create object if necessary */
54681a5bbeSBoris Popov #define	SMBVOPT_PRIVATE		0x0002	/* connection should be private */
5534ae6c75SBoris Popov #define	SMBVOPT_SINGLESHARE	0x0004	/* keep only one share at this VC */
56681a5bbeSBoris Popov #define	SMBVOPT_PERMANENT	0x0010	/* object will keep last reference */
57681a5bbeSBoris Popov 
58681a5bbeSBoris Popov #define	SMBSOPT_CREATE		0x0001	/* create object if necessary */
59681a5bbeSBoris Popov #define	SMBSOPT_PERMANENT	0x0010	/* object will keep last reference */
60681a5bbeSBoris Popov 
61681a5bbeSBoris Popov /*
62681a5bbeSBoris Popov  * SMBIOC_LOOKUP flags
63681a5bbeSBoris Popov  */
64681a5bbeSBoris Popov #define SMBLK_CREATE		0x0001
65681a5bbeSBoris Popov 
66681a5bbeSBoris Popov struct smbioc_ossn {
67681a5bbeSBoris Popov 	int		ioc_opt;
68681a5bbeSBoris Popov 	int		ioc_svlen;	/* size of ioc_server address */
69681a5bbeSBoris Popov 	struct sockaddr*ioc_server;
70681a5bbeSBoris Popov 	int		ioc_lolen;	/* size of ioc_local address */
71681a5bbeSBoris Popov 	struct sockaddr*ioc_local;
72681a5bbeSBoris Popov 	char		ioc_srvname[SMB_MAXSRVNAMELEN + 1];
73681a5bbeSBoris Popov 	int		ioc_timeout;
74681a5bbeSBoris Popov 	int		ioc_retrycount;	/* number of retries before giveup */
75681a5bbeSBoris Popov 	char		ioc_localcs[16];/* local charset */
76681a5bbeSBoris Popov 	char		ioc_servercs[16];/* server charset */
77681a5bbeSBoris Popov 	char		ioc_user[SMB_MAXUSERNAMELEN + 1];
78681a5bbeSBoris Popov 	char		ioc_workgroup[SMB_MAXUSERNAMELEN + 1];
79681a5bbeSBoris Popov 	char		ioc_password[SMB_MAXPASSWORDLEN + 1];
80681a5bbeSBoris Popov 	uid_t		ioc_owner;	/* proposed owner */
81681a5bbeSBoris Popov 	gid_t		ioc_group;	/* proposed group */
82681a5bbeSBoris Popov 	mode_t		ioc_mode;	/* desired access mode */
83681a5bbeSBoris Popov 	mode_t		ioc_rights;	/* SMBM_* */
84681a5bbeSBoris Popov };
85681a5bbeSBoris Popov 
86681a5bbeSBoris Popov struct smbioc_oshare {
87681a5bbeSBoris Popov 	int		ioc_opt;
88681a5bbeSBoris Popov 	int		ioc_stype;	/* share type */
89681a5bbeSBoris Popov 	char		ioc_share[SMB_MAXSHARENAMELEN + 1];
90681a5bbeSBoris Popov 	char		ioc_password[SMB_MAXPASSWORDLEN + 1];
91681a5bbeSBoris Popov 	uid_t		ioc_owner;	/* proposed owner of share */
92681a5bbeSBoris Popov 	gid_t		ioc_group;	/* proposed group of share */
93681a5bbeSBoris Popov 	mode_t		ioc_mode;	/* desired access mode to share */
94681a5bbeSBoris Popov 	mode_t		ioc_rights;	/* SMBM_* */
95681a5bbeSBoris Popov };
96681a5bbeSBoris Popov 
97681a5bbeSBoris Popov struct smbioc_rq {
98681a5bbeSBoris Popov 	u_char		ioc_cmd;
99681a5bbeSBoris Popov 	u_char		ioc_twc;
100681a5bbeSBoris Popov 	void *		ioc_twords;
101681a5bbeSBoris Popov 	u_short		ioc_tbc;
102681a5bbeSBoris Popov 	void *		ioc_tbytes;
103681a5bbeSBoris Popov 	int		ioc_rpbufsz;
104681a5bbeSBoris Popov 	char *		ioc_rpbuf;
105681a5bbeSBoris Popov 	u_char		ioc_rwc;
106681a5bbeSBoris Popov 	u_short		ioc_rbc;
107681a5bbeSBoris Popov 	u_int8_t	ioc_errclass;
108681a5bbeSBoris Popov 	u_int16_t	ioc_serror;
109681a5bbeSBoris Popov 	u_int32_t	ioc_error;
110681a5bbeSBoris Popov };
111681a5bbeSBoris Popov 
112681a5bbeSBoris Popov struct smbioc_t2rq {
113681a5bbeSBoris Popov 	u_int16_t	ioc_setup[3];
114681a5bbeSBoris Popov 	int		ioc_setupcnt;
115681a5bbeSBoris Popov 	char *		ioc_name;
116681a5bbeSBoris Popov 	u_short		ioc_tparamcnt;
117681a5bbeSBoris Popov 	void *		ioc_tparam;
118681a5bbeSBoris Popov 	u_short		ioc_tdatacnt;
119681a5bbeSBoris Popov 	void *		ioc_tdata;
120681a5bbeSBoris Popov 	u_short		ioc_rparamcnt;
121681a5bbeSBoris Popov 	void *		ioc_rparam;
122681a5bbeSBoris Popov 	u_short		ioc_rdatacnt;
123681a5bbeSBoris Popov 	void *		ioc_rdata;
124681a5bbeSBoris Popov };
125681a5bbeSBoris Popov 
126681a5bbeSBoris Popov struct smbioc_flags {
127681a5bbeSBoris Popov 	int		ioc_level;	/* 0 - session, 1 - share */
128681a5bbeSBoris Popov 	int		ioc_mask;
129681a5bbeSBoris Popov 	int		ioc_flags;
130681a5bbeSBoris Popov };
131681a5bbeSBoris Popov 
132681a5bbeSBoris Popov struct smbioc_lookup {
133681a5bbeSBoris Popov 	int		ioc_level;
134681a5bbeSBoris Popov 	int		ioc_flags;
135681a5bbeSBoris Popov 	struct smbioc_ossn	ioc_ssn;
136681a5bbeSBoris Popov 	struct smbioc_oshare	ioc_sh;
137681a5bbeSBoris Popov };
138681a5bbeSBoris Popov 
139681a5bbeSBoris Popov struct smbioc_rw {
140681a5bbeSBoris Popov 	smbfh	ioc_fh;
141681a5bbeSBoris Popov 	char *	ioc_base;
142681a5bbeSBoris Popov 	off_t	ioc_offset;
143681a5bbeSBoris Popov 	int	ioc_cnt;
144681a5bbeSBoris Popov };
145681a5bbeSBoris Popov 
146681a5bbeSBoris Popov /*
147681a5bbeSBoris Popov  * Device IOCTLs
148681a5bbeSBoris Popov  */
149681a5bbeSBoris Popov #define	SMBIOC_OPENSESSION	_IOW('n',  100, struct smbioc_ossn)
150681a5bbeSBoris Popov #define	SMBIOC_OPENSHARE	_IOW('n',  101, struct smbioc_oshare)
151681a5bbeSBoris Popov #define	SMBIOC_REQUEST		_IOWR('n', 102, struct smbioc_rq)
152681a5bbeSBoris Popov #define	SMBIOC_T2RQ		_IOWR('n', 103, struct smbioc_t2rq)
153681a5bbeSBoris Popov #define	SMBIOC_SETFLAGS		_IOW('n',  104, struct smbioc_flags)
154681a5bbeSBoris Popov #define	SMBIOC_LOOKUP		_IOW('n',  106, struct smbioc_lookup)
155681a5bbeSBoris Popov #define	SMBIOC_READ		_IOWR('n', 107, struct smbioc_rw)
156681a5bbeSBoris Popov #define	SMBIOC_WRITE		_IOWR('n', 108, struct smbioc_rw)
157681a5bbeSBoris Popov 
158681a5bbeSBoris Popov #ifdef _KERNEL
159681a5bbeSBoris Popov 
160681a5bbeSBoris Popov #define SMBST_CONNECTED	1
161681a5bbeSBoris Popov 
162681a5bbeSBoris Popov STAILQ_HEAD(smbrqh, smb_rq);
163681a5bbeSBoris Popov 
164681a5bbeSBoris Popov struct smb_dev {
165681a5bbeSBoris Popov 	int		sd_opened;
166681a5bbeSBoris Popov 	int		sd_level;
167681a5bbeSBoris Popov 	struct smb_vc * sd_vc;		/* reference to VC */
168681a5bbeSBoris Popov 	struct smb_share *sd_share;	/* reference to share if any */
169681a5bbeSBoris Popov 	int		sd_poll;
170681a5bbeSBoris Popov 	int		sd_seq;
171681a5bbeSBoris Popov /*	struct ifqueue	sd_rdqueue;
172681a5bbeSBoris Popov 	struct ifqueue	sd_wrqueue;
173681a5bbeSBoris Popov 	struct selinfo	sd_pollinfo;
174681a5bbeSBoris Popov 	struct smbrqh	sd_rqlist;
175681a5bbeSBoris Popov 	struct smbrqh	sd_rplist;
176681a5bbeSBoris Popov 	struct ucred 	*sd_owner;*/
177681a5bbeSBoris Popov 	int		sd_flags;
178681a5bbeSBoris Popov };
179681a5bbeSBoris Popov 
180681a5bbeSBoris Popov struct smb_cred;
181681a5bbeSBoris Popov /*
182681a5bbeSBoris Popov  * Compound user interface
183681a5bbeSBoris Popov  */
184681a5bbeSBoris Popov int  smb_usr_lookup(struct smbioc_lookup *dp, struct smb_cred *scred,
185681a5bbeSBoris Popov 	struct smb_vc **vcpp, struct smb_share **sspp);
186681a5bbeSBoris Popov int  smb_usr_opensession(struct smbioc_ossn *data,
187681a5bbeSBoris Popov 	struct smb_cred *scred,	struct smb_vc **vcpp);
188681a5bbeSBoris Popov int  smb_usr_openshare(struct smb_vc *vcp, struct smbioc_oshare *data,
189681a5bbeSBoris Popov 	struct smb_cred *scred, struct smb_share **sspp);
190681a5bbeSBoris Popov int  smb_usr_simplerequest(struct smb_share *ssp, struct smbioc_rq *data,
191681a5bbeSBoris Popov 	struct smb_cred *scred);
192681a5bbeSBoris Popov int  smb_usr_t2request(struct smb_share *ssp, struct smbioc_t2rq *data,
193681a5bbeSBoris Popov 	struct smb_cred *scred);
194681a5bbeSBoris Popov int  smb_dev2share(int fd, int mode, struct smb_cred *scred,
195681a5bbeSBoris Popov 	struct smb_share **sspp);
196681a5bbeSBoris Popov 
197681a5bbeSBoris Popov 
198681a5bbeSBoris Popov #endif /* _KERNEL */
199681a5bbeSBoris Popov 
200681a5bbeSBoris Popov #endif /* _NETSMB_DEV_H_ */
201