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