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