xref: /dflybsd-src/sys/netproto/smb/smb_dev.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino /*
2*86d7f5d3SJohn Marino  * Copyright (c) 2000-2001 Boris Popov
3*86d7f5d3SJohn Marino  * All rights reserved.
4*86d7f5d3SJohn Marino  *
5*86d7f5d3SJohn Marino  * Redistribution and use in source and binary forms, with or without
6*86d7f5d3SJohn Marino  * modification, are permitted provided that the following conditions
7*86d7f5d3SJohn Marino  * are met:
8*86d7f5d3SJohn Marino  * 1. Redistributions of source code must retain the above copyright
9*86d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer.
10*86d7f5d3SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
11*86d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
12*86d7f5d3SJohn Marino  *    documentation and/or other materials provided with the distribution.
13*86d7f5d3SJohn Marino  * 3. All advertising materials mentioning features or use of this software
14*86d7f5d3SJohn Marino  *    must display the following acknowledgement:
15*86d7f5d3SJohn Marino  *    This product includes software developed by Boris Popov.
16*86d7f5d3SJohn Marino  * 4. Neither the name of the author nor the names of any co-contributors
17*86d7f5d3SJohn Marino  *    may be used to endorse or promote products derived from this software
18*86d7f5d3SJohn Marino  *    without specific prior written permission.
19*86d7f5d3SJohn Marino  *
20*86d7f5d3SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21*86d7f5d3SJohn Marino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*86d7f5d3SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*86d7f5d3SJohn Marino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24*86d7f5d3SJohn Marino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*86d7f5d3SJohn Marino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*86d7f5d3SJohn Marino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*86d7f5d3SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*86d7f5d3SJohn Marino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*86d7f5d3SJohn Marino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*86d7f5d3SJohn Marino  * SUCH DAMAGE.
31*86d7f5d3SJohn Marino  *
32*86d7f5d3SJohn Marino  * $FreeBSD: src/sys/netsmb/smb_dev.h,v 1.3.2.1 2001/05/22 08:32:33 bp Exp $
33*86d7f5d3SJohn Marino  */
34*86d7f5d3SJohn Marino #ifndef _NETSMB_DEV_H_
35*86d7f5d3SJohn Marino #define _NETSMB_DEV_H_
36*86d7f5d3SJohn Marino 
37*86d7f5d3SJohn Marino #ifndef _KERNEL
38*86d7f5d3SJohn Marino #include <sys/types.h>
39*86d7f5d3SJohn Marino #endif
40*86d7f5d3SJohn Marino #include <sys/ioccom.h>
41*86d7f5d3SJohn Marino 
42*86d7f5d3SJohn Marino #include "smb.h"
43*86d7f5d3SJohn Marino 
44*86d7f5d3SJohn Marino #define	NSMB_NAME		"nsmb"
45*86d7f5d3SJohn Marino 
46*86d7f5d3SJohn Marino #define NSMB_VERMAJ	1
47*86d7f5d3SJohn Marino #define NSMB_VERMIN	3006
48*86d7f5d3SJohn Marino #define NSMB_VERSION	(NSMB_VERMAJ * 100000 + NSMB_VERMIN)
49*86d7f5d3SJohn Marino 
50*86d7f5d3SJohn Marino #define NSMBFL_OPEN		0x0001
51*86d7f5d3SJohn Marino 
52*86d7f5d3SJohn Marino #define	SMBVOPT_CREATE		0x0001	/* create object if necessary */
53*86d7f5d3SJohn Marino #define	SMBVOPT_PRIVATE		0x0002	/* connection should be private */
54*86d7f5d3SJohn Marino #define	SMBVOPT_SINGLESHARE	0x0004	/* keep only one share at this VC */
55*86d7f5d3SJohn Marino #define	SMBVOPT_PERMANENT	0x0010	/* object will keep last reference */
56*86d7f5d3SJohn Marino 
57*86d7f5d3SJohn Marino #define	SMBSOPT_CREATE		0x0001	/* create object if necessary */
58*86d7f5d3SJohn Marino #define	SMBSOPT_PERMANENT	0x0010	/* object will keep last reference */
59*86d7f5d3SJohn Marino 
60*86d7f5d3SJohn Marino /*
61*86d7f5d3SJohn Marino  * SMBIOC_LOOKUP flags
62*86d7f5d3SJohn Marino  */
63*86d7f5d3SJohn Marino #define SMBLK_CREATE		0x0001
64*86d7f5d3SJohn Marino 
65*86d7f5d3SJohn Marino struct smbioc_ossn {
66*86d7f5d3SJohn Marino 	int		ioc_opt;
67*86d7f5d3SJohn Marino 	int		ioc_svlen;	/* size of ioc_server address */
68*86d7f5d3SJohn Marino 	struct sockaddr*ioc_server;
69*86d7f5d3SJohn Marino 	int		ioc_lolen;	/* size of ioc_local address */
70*86d7f5d3SJohn Marino 	struct sockaddr*ioc_local;
71*86d7f5d3SJohn Marino 	char		ioc_srvname[SMB_MAXSRVNAMELEN + 1];
72*86d7f5d3SJohn Marino 	int		ioc_timeout;
73*86d7f5d3SJohn Marino 	int		ioc_retrycount;	/* number of retries before giveup */
74*86d7f5d3SJohn Marino 	char		ioc_localcs[16];/* local charset */
75*86d7f5d3SJohn Marino 	char		ioc_servercs[16];/* server charset */
76*86d7f5d3SJohn Marino 	char		ioc_user[SMB_MAXUSERNAMELEN + 1];
77*86d7f5d3SJohn Marino 	char		ioc_workgroup[SMB_MAXUSERNAMELEN + 1];
78*86d7f5d3SJohn Marino 	char		ioc_password[SMB_MAXPASSWORDLEN + 1];
79*86d7f5d3SJohn Marino 	uid_t		ioc_owner;	/* proposed owner */
80*86d7f5d3SJohn Marino 	gid_t		ioc_group;	/* proposed group */
81*86d7f5d3SJohn Marino 	mode_t		ioc_mode;	/* desired access mode */
82*86d7f5d3SJohn Marino 	mode_t		ioc_rights;	/* SMBM_* */
83*86d7f5d3SJohn Marino };
84*86d7f5d3SJohn Marino 
85*86d7f5d3SJohn Marino struct smbioc_oshare {
86*86d7f5d3SJohn Marino 	int		ioc_opt;
87*86d7f5d3SJohn Marino 	int		ioc_stype;	/* share type */
88*86d7f5d3SJohn Marino 	char		ioc_share[SMB_MAXSHARENAMELEN + 1];
89*86d7f5d3SJohn Marino 	char		ioc_password[SMB_MAXPASSWORDLEN + 1];
90*86d7f5d3SJohn Marino 	uid_t		ioc_owner;	/* proposed owner of share */
91*86d7f5d3SJohn Marino 	gid_t		ioc_group;	/* proposed group of share */
92*86d7f5d3SJohn Marino 	mode_t		ioc_mode;	/* desired access mode to share */
93*86d7f5d3SJohn Marino 	mode_t		ioc_rights;	/* SMBM_* */
94*86d7f5d3SJohn Marino };
95*86d7f5d3SJohn Marino 
96*86d7f5d3SJohn Marino struct smbioc_rq {
97*86d7f5d3SJohn Marino 	u_char		ioc_cmd;
98*86d7f5d3SJohn Marino 	u_char		ioc_twc;
99*86d7f5d3SJohn Marino 	void *		ioc_twords;
100*86d7f5d3SJohn Marino 	u_short		ioc_tbc;
101*86d7f5d3SJohn Marino 	void *		ioc_tbytes;
102*86d7f5d3SJohn Marino 	int		ioc_rpbufsz;
103*86d7f5d3SJohn Marino 	char *		ioc_rpbuf;
104*86d7f5d3SJohn Marino 	u_char		ioc_rwc;
105*86d7f5d3SJohn Marino 	u_short		ioc_rbc;
106*86d7f5d3SJohn Marino 	u_int8_t	ioc_errclass;
107*86d7f5d3SJohn Marino 	u_int16_t	ioc_serror;
108*86d7f5d3SJohn Marino 	u_int32_t	ioc_error;
109*86d7f5d3SJohn Marino };
110*86d7f5d3SJohn Marino 
111*86d7f5d3SJohn Marino struct smbioc_t2rq {
112*86d7f5d3SJohn Marino 	u_int16_t	ioc_setup[3];
113*86d7f5d3SJohn Marino 	int		ioc_setupcnt;
114*86d7f5d3SJohn Marino 	char *		ioc_name;
115*86d7f5d3SJohn Marino 	u_short		ioc_tparamcnt;
116*86d7f5d3SJohn Marino 	void *		ioc_tparam;
117*86d7f5d3SJohn Marino 	u_short		ioc_tdatacnt;
118*86d7f5d3SJohn Marino 	void *		ioc_tdata;
119*86d7f5d3SJohn Marino 	u_short		ioc_rparamcnt;
120*86d7f5d3SJohn Marino 	void *		ioc_rparam;
121*86d7f5d3SJohn Marino 	u_short		ioc_rdatacnt;
122*86d7f5d3SJohn Marino 	void *		ioc_rdata;
123*86d7f5d3SJohn Marino };
124*86d7f5d3SJohn Marino 
125*86d7f5d3SJohn Marino struct smbioc_flags {
126*86d7f5d3SJohn Marino 	int		ioc_level;	/* 0 - session, 1 - share */
127*86d7f5d3SJohn Marino 	int		ioc_mask;
128*86d7f5d3SJohn Marino 	int		ioc_flags;
129*86d7f5d3SJohn Marino };
130*86d7f5d3SJohn Marino 
131*86d7f5d3SJohn Marino struct smbioc_lookup {
132*86d7f5d3SJohn Marino 	int		ioc_level;
133*86d7f5d3SJohn Marino 	int		ioc_flags;
134*86d7f5d3SJohn Marino 	struct smbioc_ossn	ioc_ssn;
135*86d7f5d3SJohn Marino 	struct smbioc_oshare	ioc_sh;
136*86d7f5d3SJohn Marino };
137*86d7f5d3SJohn Marino 
138*86d7f5d3SJohn Marino struct smbioc_rw {
139*86d7f5d3SJohn Marino 	smbfh	ioc_fh;
140*86d7f5d3SJohn Marino 	char *	ioc_base;
141*86d7f5d3SJohn Marino 	off_t	ioc_offset;
142*86d7f5d3SJohn Marino 	int	ioc_cnt;
143*86d7f5d3SJohn Marino };
144*86d7f5d3SJohn Marino 
145*86d7f5d3SJohn Marino /*
146*86d7f5d3SJohn Marino  * Device IOCTLs
147*86d7f5d3SJohn Marino  */
148*86d7f5d3SJohn Marino #define	SMBIOC_OPENSESSION	_IOW('n',  100, struct smbioc_ossn)
149*86d7f5d3SJohn Marino #define	SMBIOC_OPENSHARE	_IOW('n',  101, struct smbioc_oshare)
150*86d7f5d3SJohn Marino #define	SMBIOC_REQUEST		_IOWR('n', 102, struct smbioc_rq)
151*86d7f5d3SJohn Marino #define	SMBIOC_T2RQ		_IOWR('n', 103, struct smbioc_t2rq)
152*86d7f5d3SJohn Marino #define	SMBIOC_SETFLAGS		_IOW('n',  104, struct smbioc_flags)
153*86d7f5d3SJohn Marino #define	SMBIOC_LOOKUP		_IOW('n',  106, struct smbioc_lookup)
154*86d7f5d3SJohn Marino #define	SMBIOC_READ		_IOWR('n', 107, struct smbioc_rw)
155*86d7f5d3SJohn Marino #define	SMBIOC_WRITE		_IOWR('n', 108, struct smbioc_rw)
156*86d7f5d3SJohn Marino 
157*86d7f5d3SJohn Marino #ifdef _KERNEL
158*86d7f5d3SJohn Marino 
159*86d7f5d3SJohn Marino #define SMBST_CONNECTED	1
160*86d7f5d3SJohn Marino 
161*86d7f5d3SJohn Marino STAILQ_HEAD(smbrqh, smb_rq);
162*86d7f5d3SJohn Marino 
163*86d7f5d3SJohn Marino struct smb_dev {
164*86d7f5d3SJohn Marino 	int		sd_opened;
165*86d7f5d3SJohn Marino 	int		sd_level;
166*86d7f5d3SJohn Marino 	struct smb_vc * sd_vc;		/* reference to VC */
167*86d7f5d3SJohn Marino 	struct smb_share *sd_share;	/* reference to share if any */
168*86d7f5d3SJohn Marino 	int		sd_poll;
169*86d7f5d3SJohn Marino 	int		sd_seq;
170*86d7f5d3SJohn Marino /*	struct ifqueue	sd_rdqueue;
171*86d7f5d3SJohn Marino 	struct ifqueue	sd_wrqueue;
172*86d7f5d3SJohn Marino 	struct kqinfo	sd_pollinfo;
173*86d7f5d3SJohn Marino 	struct smbrqh	sd_rqlist;
174*86d7f5d3SJohn Marino 	struct smbrqh	sd_rplist;
175*86d7f5d3SJohn Marino 	struct ucred 	*sd_owner;*/
176*86d7f5d3SJohn Marino 	int		sd_flags;
177*86d7f5d3SJohn Marino };
178*86d7f5d3SJohn Marino 
179*86d7f5d3SJohn Marino struct smb_cred;
180*86d7f5d3SJohn Marino /*
181*86d7f5d3SJohn Marino  * Compound user interface
182*86d7f5d3SJohn Marino  */
183*86d7f5d3SJohn Marino int  smb_usr_lookup(struct smbioc_lookup *dp, struct smb_cred *scred,
184*86d7f5d3SJohn Marino 	struct smb_vc **vcpp, struct smb_share **sspp);
185*86d7f5d3SJohn Marino int  smb_usr_opensession(struct smbioc_ossn *data,
186*86d7f5d3SJohn Marino 	struct smb_cred *scred,	struct smb_vc **vcpp);
187*86d7f5d3SJohn Marino int  smb_usr_openshare(struct smb_vc *vcp, struct smbioc_oshare *data,
188*86d7f5d3SJohn Marino 	struct smb_cred *scred, struct smb_share **sspp);
189*86d7f5d3SJohn Marino int  smb_usr_simplerequest(struct smb_share *ssp, struct smbioc_rq *data,
190*86d7f5d3SJohn Marino 	struct smb_cred *scred);
191*86d7f5d3SJohn Marino int  smb_usr_t2request(struct smb_share *ssp, struct smbioc_t2rq *data,
192*86d7f5d3SJohn Marino 	struct smb_cred *scred);
193*86d7f5d3SJohn Marino int  smb_dev2share(int fd, int mode, struct smb_cred *scred,
194*86d7f5d3SJohn Marino 	struct smb_share **sspp);
195*86d7f5d3SJohn Marino 
196*86d7f5d3SJohn Marino 
197*86d7f5d3SJohn Marino #endif /* _KERNEL */
198*86d7f5d3SJohn Marino 
199*86d7f5d3SJohn Marino #endif /* _NETSMB_DEV_H_ */
200