186d7f5d3SJohn Marino /* 286d7f5d3SJohn Marino * Copyright (c) 2000-2001 Boris Popov 386d7f5d3SJohn Marino * All rights reserved. 486d7f5d3SJohn Marino * 586d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 686d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 786d7f5d3SJohn Marino * are met: 886d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 986d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 1086d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 1186d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the 1286d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution. 1386d7f5d3SJohn Marino * 3. All advertising materials mentioning features or use of this software 1486d7f5d3SJohn Marino * must display the following acknowledgement: 1586d7f5d3SJohn Marino * This product includes software developed by Boris Popov. 1686d7f5d3SJohn Marino * 4. Neither the name of the author nor the names of any co-contributors 1786d7f5d3SJohn Marino * may be used to endorse or promote products derived from this software 1886d7f5d3SJohn Marino * without specific prior written permission. 1986d7f5d3SJohn Marino * 2086d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2186d7f5d3SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2286d7f5d3SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2386d7f5d3SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2486d7f5d3SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2586d7f5d3SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2686d7f5d3SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2786d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2886d7f5d3SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2986d7f5d3SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3086d7f5d3SJohn Marino * SUCH DAMAGE. 3186d7f5d3SJohn Marino * 3286d7f5d3SJohn Marino * $FreeBSD: src/sys/netsmb/smb_dev.h,v 1.3.2.1 2001/05/22 08:32:33 bp Exp $ 3386d7f5d3SJohn Marino */ 3486d7f5d3SJohn Marino #ifndef _NETSMB_DEV_H_ 3586d7f5d3SJohn Marino #define _NETSMB_DEV_H_ 3686d7f5d3SJohn Marino 3786d7f5d3SJohn Marino #ifndef _KERNEL 3886d7f5d3SJohn Marino #include <sys/types.h> 3986d7f5d3SJohn Marino #endif 4086d7f5d3SJohn Marino #include <sys/ioccom.h> 4186d7f5d3SJohn Marino 4286d7f5d3SJohn Marino #include "smb.h" 4386d7f5d3SJohn Marino 4486d7f5d3SJohn Marino #define NSMB_NAME "nsmb" 4586d7f5d3SJohn Marino 4686d7f5d3SJohn Marino #define NSMB_VERMAJ 1 4786d7f5d3SJohn Marino #define NSMB_VERMIN 3006 4886d7f5d3SJohn Marino #define NSMB_VERSION (NSMB_VERMAJ * 100000 + NSMB_VERMIN) 4986d7f5d3SJohn Marino 5086d7f5d3SJohn Marino #define NSMBFL_OPEN 0x0001 5186d7f5d3SJohn Marino 5286d7f5d3SJohn Marino #define SMBVOPT_CREATE 0x0001 /* create object if necessary */ 5386d7f5d3SJohn Marino #define SMBVOPT_PRIVATE 0x0002 /* connection should be private */ 5486d7f5d3SJohn Marino #define SMBVOPT_SINGLESHARE 0x0004 /* keep only one share at this VC */ 5586d7f5d3SJohn Marino #define SMBVOPT_PERMANENT 0x0010 /* object will keep last reference */ 5686d7f5d3SJohn Marino 5786d7f5d3SJohn Marino #define SMBSOPT_CREATE 0x0001 /* create object if necessary */ 5886d7f5d3SJohn Marino #define SMBSOPT_PERMANENT 0x0010 /* object will keep last reference */ 5986d7f5d3SJohn Marino 6086d7f5d3SJohn Marino /* 6186d7f5d3SJohn Marino * SMBIOC_LOOKUP flags 6286d7f5d3SJohn Marino */ 6386d7f5d3SJohn Marino #define SMBLK_CREATE 0x0001 6486d7f5d3SJohn Marino 6586d7f5d3SJohn Marino struct smbioc_ossn { 6686d7f5d3SJohn Marino int ioc_opt; 6786d7f5d3SJohn Marino int ioc_svlen; /* size of ioc_server address */ 6886d7f5d3SJohn Marino struct sockaddr*ioc_server; 6986d7f5d3SJohn Marino int ioc_lolen; /* size of ioc_local address */ 7086d7f5d3SJohn Marino struct sockaddr*ioc_local; 7186d7f5d3SJohn Marino char ioc_srvname[SMB_MAXSRVNAMELEN + 1]; 7286d7f5d3SJohn Marino int ioc_timeout; 7386d7f5d3SJohn Marino int ioc_retrycount; /* number of retries before giveup */ 7486d7f5d3SJohn Marino char ioc_localcs[16];/* local charset */ 7586d7f5d3SJohn Marino char ioc_servercs[16];/* server charset */ 7686d7f5d3SJohn Marino char ioc_user[SMB_MAXUSERNAMELEN + 1]; 7786d7f5d3SJohn Marino char ioc_workgroup[SMB_MAXUSERNAMELEN + 1]; 7886d7f5d3SJohn Marino char ioc_password[SMB_MAXPASSWORDLEN + 1]; 7986d7f5d3SJohn Marino uid_t ioc_owner; /* proposed owner */ 8086d7f5d3SJohn Marino gid_t ioc_group; /* proposed group */ 8186d7f5d3SJohn Marino mode_t ioc_mode; /* desired access mode */ 8286d7f5d3SJohn Marino mode_t ioc_rights; /* SMBM_* */ 8386d7f5d3SJohn Marino }; 8486d7f5d3SJohn Marino 8586d7f5d3SJohn Marino struct smbioc_oshare { 8686d7f5d3SJohn Marino int ioc_opt; 8786d7f5d3SJohn Marino int ioc_stype; /* share type */ 8886d7f5d3SJohn Marino char ioc_share[SMB_MAXSHARENAMELEN + 1]; 8986d7f5d3SJohn Marino char ioc_password[SMB_MAXPASSWORDLEN + 1]; 9086d7f5d3SJohn Marino uid_t ioc_owner; /* proposed owner of share */ 9186d7f5d3SJohn Marino gid_t ioc_group; /* proposed group of share */ 9286d7f5d3SJohn Marino mode_t ioc_mode; /* desired access mode to share */ 9386d7f5d3SJohn Marino mode_t ioc_rights; /* SMBM_* */ 9486d7f5d3SJohn Marino }; 9586d7f5d3SJohn Marino 9686d7f5d3SJohn Marino struct smbioc_rq { 9786d7f5d3SJohn Marino u_char ioc_cmd; 9886d7f5d3SJohn Marino u_char ioc_twc; 9986d7f5d3SJohn Marino void * ioc_twords; 10086d7f5d3SJohn Marino u_short ioc_tbc; 10186d7f5d3SJohn Marino void * ioc_tbytes; 10286d7f5d3SJohn Marino int ioc_rpbufsz; 10386d7f5d3SJohn Marino char * ioc_rpbuf; 10486d7f5d3SJohn Marino u_char ioc_rwc; 10586d7f5d3SJohn Marino u_short ioc_rbc; 10686d7f5d3SJohn Marino u_int8_t ioc_errclass; 10786d7f5d3SJohn Marino u_int16_t ioc_serror; 10886d7f5d3SJohn Marino u_int32_t ioc_error; 10986d7f5d3SJohn Marino }; 11086d7f5d3SJohn Marino 11186d7f5d3SJohn Marino struct smbioc_t2rq { 11286d7f5d3SJohn Marino u_int16_t ioc_setup[3]; 11386d7f5d3SJohn Marino int ioc_setupcnt; 11486d7f5d3SJohn Marino char * ioc_name; 11586d7f5d3SJohn Marino u_short ioc_tparamcnt; 11686d7f5d3SJohn Marino void * ioc_tparam; 11786d7f5d3SJohn Marino u_short ioc_tdatacnt; 11886d7f5d3SJohn Marino void * ioc_tdata; 11986d7f5d3SJohn Marino u_short ioc_rparamcnt; 12086d7f5d3SJohn Marino void * ioc_rparam; 12186d7f5d3SJohn Marino u_short ioc_rdatacnt; 12286d7f5d3SJohn Marino void * ioc_rdata; 12386d7f5d3SJohn Marino }; 12486d7f5d3SJohn Marino 12586d7f5d3SJohn Marino struct smbioc_flags { 12686d7f5d3SJohn Marino int ioc_level; /* 0 - session, 1 - share */ 12786d7f5d3SJohn Marino int ioc_mask; 12886d7f5d3SJohn Marino int ioc_flags; 12986d7f5d3SJohn Marino }; 13086d7f5d3SJohn Marino 13186d7f5d3SJohn Marino struct smbioc_lookup { 13286d7f5d3SJohn Marino int ioc_level; 13386d7f5d3SJohn Marino int ioc_flags; 13486d7f5d3SJohn Marino struct smbioc_ossn ioc_ssn; 13586d7f5d3SJohn Marino struct smbioc_oshare ioc_sh; 13686d7f5d3SJohn Marino }; 13786d7f5d3SJohn Marino 13886d7f5d3SJohn Marino struct smbioc_rw { 13986d7f5d3SJohn Marino smbfh ioc_fh; 14086d7f5d3SJohn Marino char * ioc_base; 14186d7f5d3SJohn Marino off_t ioc_offset; 14286d7f5d3SJohn Marino int ioc_cnt; 14386d7f5d3SJohn Marino }; 14486d7f5d3SJohn Marino 14586d7f5d3SJohn Marino /* 14686d7f5d3SJohn Marino * Device IOCTLs 14786d7f5d3SJohn Marino */ 14886d7f5d3SJohn Marino #define SMBIOC_OPENSESSION _IOW('n', 100, struct smbioc_ossn) 14986d7f5d3SJohn Marino #define SMBIOC_OPENSHARE _IOW('n', 101, struct smbioc_oshare) 15086d7f5d3SJohn Marino #define SMBIOC_REQUEST _IOWR('n', 102, struct smbioc_rq) 15186d7f5d3SJohn Marino #define SMBIOC_T2RQ _IOWR('n', 103, struct smbioc_t2rq) 15286d7f5d3SJohn Marino #define SMBIOC_SETFLAGS _IOW('n', 104, struct smbioc_flags) 15386d7f5d3SJohn Marino #define SMBIOC_LOOKUP _IOW('n', 106, struct smbioc_lookup) 15486d7f5d3SJohn Marino #define SMBIOC_READ _IOWR('n', 107, struct smbioc_rw) 15586d7f5d3SJohn Marino #define SMBIOC_WRITE _IOWR('n', 108, struct smbioc_rw) 15686d7f5d3SJohn Marino 15786d7f5d3SJohn Marino #ifdef _KERNEL 15886d7f5d3SJohn Marino 15986d7f5d3SJohn Marino #define SMBST_CONNECTED 1 16086d7f5d3SJohn Marino 16186d7f5d3SJohn Marino STAILQ_HEAD(smbrqh, smb_rq); 16286d7f5d3SJohn Marino 16386d7f5d3SJohn Marino struct smb_dev { 16486d7f5d3SJohn Marino int sd_opened; 16586d7f5d3SJohn Marino int sd_level; 16686d7f5d3SJohn Marino struct smb_vc * sd_vc; /* reference to VC */ 16786d7f5d3SJohn Marino struct smb_share *sd_share; /* reference to share if any */ 16886d7f5d3SJohn Marino int sd_poll; 16986d7f5d3SJohn Marino int sd_seq; 17086d7f5d3SJohn Marino /* struct ifqueue sd_rdqueue; 17186d7f5d3SJohn Marino struct ifqueue sd_wrqueue; 17286d7f5d3SJohn Marino struct kqinfo sd_pollinfo; 17386d7f5d3SJohn Marino struct smbrqh sd_rqlist; 17486d7f5d3SJohn Marino struct smbrqh sd_rplist; 17586d7f5d3SJohn Marino struct ucred *sd_owner;*/ 17686d7f5d3SJohn Marino int sd_flags; 17786d7f5d3SJohn Marino }; 17886d7f5d3SJohn Marino 17986d7f5d3SJohn Marino struct smb_cred; 18086d7f5d3SJohn Marino /* 18186d7f5d3SJohn Marino * Compound user interface 18286d7f5d3SJohn Marino */ 18386d7f5d3SJohn Marino int smb_usr_lookup(struct smbioc_lookup *dp, struct smb_cred *scred, 18486d7f5d3SJohn Marino struct smb_vc **vcpp, struct smb_share **sspp); 18586d7f5d3SJohn Marino int smb_usr_opensession(struct smbioc_ossn *data, 18686d7f5d3SJohn Marino struct smb_cred *scred, struct smb_vc **vcpp); 18786d7f5d3SJohn Marino int smb_usr_openshare(struct smb_vc *vcp, struct smbioc_oshare *data, 18886d7f5d3SJohn Marino struct smb_cred *scred, struct smb_share **sspp); 18986d7f5d3SJohn Marino int smb_usr_simplerequest(struct smb_share *ssp, struct smbioc_rq *data, 19086d7f5d3SJohn Marino struct smb_cred *scred); 19186d7f5d3SJohn Marino int smb_usr_t2request(struct smb_share *ssp, struct smbioc_t2rq *data, 19286d7f5d3SJohn Marino struct smb_cred *scred); 19386d7f5d3SJohn Marino int smb_dev2share(int fd, int mode, struct smb_cred *scred, 19486d7f5d3SJohn Marino struct smb_share **sspp); 19586d7f5d3SJohn Marino 19686d7f5d3SJohn Marino 19786d7f5d3SJohn Marino #endif /* _KERNEL */ 19886d7f5d3SJohn Marino 19986d7f5d3SJohn Marino #endif /* _NETSMB_DEV_H_ */ 200