14bff34e3Sthurlow /* 24bff34e3Sthurlow * Copyright (c) 2000-2001 Boris Popov 34bff34e3Sthurlow * All rights reserved. 44bff34e3Sthurlow * 54bff34e3Sthurlow * Redistribution and use in source and binary forms, with or without 64bff34e3Sthurlow * modification, are permitted provided that the following conditions 74bff34e3Sthurlow * are met: 84bff34e3Sthurlow * 1. Redistributions of source code must retain the above copyright 94bff34e3Sthurlow * notice, this list of conditions and the following disclaimer. 104bff34e3Sthurlow * 2. Redistributions in binary form must reproduce the above copyright 114bff34e3Sthurlow * notice, this list of conditions and the following disclaimer in the 124bff34e3Sthurlow * documentation and/or other materials provided with the distribution. 134bff34e3Sthurlow * 3. All advertising materials mentioning features or use of this software 144bff34e3Sthurlow * must display the following acknowledgement: 154bff34e3Sthurlow * This product includes software developed by Boris Popov. 164bff34e3Sthurlow * 4. Neither the name of the author nor the names of any co-contributors 174bff34e3Sthurlow * may be used to endorse or promote products derived from this software 184bff34e3Sthurlow * without specific prior written permission. 194bff34e3Sthurlow * 204bff34e3Sthurlow * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 214bff34e3Sthurlow * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224bff34e3Sthurlow * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234bff34e3Sthurlow * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 244bff34e3Sthurlow * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254bff34e3Sthurlow * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264bff34e3Sthurlow * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274bff34e3Sthurlow * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284bff34e3Sthurlow * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294bff34e3Sthurlow * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304bff34e3Sthurlow * SUCH DAMAGE. 314bff34e3Sthurlow * 324bff34e3Sthurlow * $Id: smb_conn.h,v 1.32.42.1 2005/05/27 02:35:29 lindak Exp $ 334bff34e3Sthurlow */ 344bff34e3Sthurlow 354bff34e3Sthurlow /* 361b34bc4aSbs * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 374bff34e3Sthurlow * Use is subject to license terms. 384bff34e3Sthurlow */ 394bff34e3Sthurlow 404bff34e3Sthurlow #ifndef _SMB_CONN_H 414bff34e3Sthurlow #define _SMB_CONN_H 424bff34e3Sthurlow 434bff34e3Sthurlow #include <sys/t_lock.h> 444bff34e3Sthurlow #include <sys/queue.h> /* for SLIST below */ 454bff34e3Sthurlow #include <sys/uio.h> 464bff34e3Sthurlow #include <netsmb/smb_dev.h> 474bff34e3Sthurlow 484bff34e3Sthurlow #ifndef _KERNEL 494bff34e3Sthurlow #error "Not _KERNEL?" 504bff34e3Sthurlow #endif 514bff34e3Sthurlow 524bff34e3Sthurlow /* 534bff34e3Sthurlow * Credentials of user/process for processing in the connection procedures 544bff34e3Sthurlow */ 554bff34e3Sthurlow typedef struct smb_cred { 564bff34e3Sthurlow pid_t vc_pid; 574bff34e3Sthurlow cred_t *vc_ucred; 584bff34e3Sthurlow } smb_cred_t; 594bff34e3Sthurlow 604bff34e3Sthurlow /* 614bff34e3Sthurlow * Common object flags 624bff34e3Sthurlow */ 634bff34e3Sthurlow #define SMBO_GONE 0x1000000 644bff34e3Sthurlow 654bff34e3Sthurlow /* 664bff34e3Sthurlow * Bits in vc_flags (a.k.a. vc_co.co_flags) 674bff34e3Sthurlow * Many of these were duplicates of SMBVOPT_ flags 684bff34e3Sthurlow * and we now keep those too instead of merging 694bff34e3Sthurlow * them into vc_flags. 70*9c9af259SGordon Ross * 71*9c9af259SGordon Ross * Careful here: In smb_smb_negotiate, we clear ALL OF 72*9c9af259SGordon Ross * vc_flags except: SMBV_GONE, SMBV_RECONNECTING 734bff34e3Sthurlow */ 744bff34e3Sthurlow 75*9c9af259SGordon Ross #define SMBV_RECONNECTING 0x0002 /* conn in process of reconnection */ 764bff34e3Sthurlow #define SMBV_LONGNAMES 0x0004 /* conn configured to use long names */ 774bff34e3Sthurlow #define SMBV_ENCRYPT 0x0008 /* server demands encrypted password */ 784bff34e3Sthurlow #define SMBV_WIN95 0x0010 /* used to apply bugfixes for this OS */ 794bff34e3Sthurlow #define SMBV_NT4 0x0020 /* used when NT4 issues invalid resp */ 80*9c9af259SGordon Ross #define SMBV_UNICODE 0x0040 /* conn configured to use Unicode */ 81*9c9af259SGordon Ross #define SMBV_EXT_SEC 0x0080 /* conn to use extended security */ 82*9c9af259SGordon Ross #define SMBV_WILL_SIGN 0x0100 /* negotiated signing */ 834bff34e3Sthurlow 844bff34e3Sthurlow /* 854bff34e3Sthurlow * Note: the common "obj" level uses this GONE flag by 864bff34e3Sthurlow * the name SMBO_GONE. Keep this alias as a reminder. 874bff34e3Sthurlow */ 884bff34e3Sthurlow #define SMBV_GONE SMBO_GONE 894bff34e3Sthurlow 904bff34e3Sthurlow /* 914bff34e3Sthurlow * bits in smb_share ss_flags (a.k.a. ss_co.co_flags) 924bff34e3Sthurlow */ 934bff34e3Sthurlow #define SMBS_RECONNECTING 0x0002 944bff34e3Sthurlow #define SMBS_CONNECTED 0x0004 954bff34e3Sthurlow #define SMBS_TCON_WAIT 0x0008 964bff34e3Sthurlow #define SMBS_1980 0x0010 974bff34e3Sthurlow /* 984bff34e3Sthurlow * ^ This partition can't handle dates before 1980. It's probably a FAT 994bff34e3Sthurlow * partition but could be some other ancient FS type 1004bff34e3Sthurlow */ 1014bff34e3Sthurlow #define SMBS_RESUMEKEYS 0x0010 /* must use resume keys */ 1024bff34e3Sthurlow /* 1034bff34e3Sthurlow * Note: the common "obj" level uses this GONE flag by 1044bff34e3Sthurlow * the name SMBO_GONE. Keep this alias as a reminder. 1054bff34e3Sthurlow */ 1064bff34e3Sthurlow #define SMBS_GONE SMBO_GONE 1074bff34e3Sthurlow 1084bff34e3Sthurlow /* 1094bff34e3Sthurlow * Negotiated protocol parameters 1104bff34e3Sthurlow */ 1114bff34e3Sthurlow struct smb_sopt { 1124bff34e3Sthurlow int sv_proto; 1134bff34e3Sthurlow int16_t sv_tz; /* offset in min relative to UTC */ 1144bff34e3Sthurlow uint32_t sv_maxtx; /* maximum transmit buf size */ 1154bff34e3Sthurlow uchar_t sv_sm; /* security mode */ 1164bff34e3Sthurlow uint16_t sv_maxmux; /* max number of outstanding rq's */ 1174bff34e3Sthurlow uint16_t sv_maxvcs; /* max number of VCs */ 1184bff34e3Sthurlow uint16_t sv_rawmode; 1194bff34e3Sthurlow uint32_t sv_maxraw; /* maximum raw-buffer size */ 1204bff34e3Sthurlow uint32_t sv_skey; /* session key */ 1214bff34e3Sthurlow uint32_t sv_caps; /* capabilites SMB_CAP_ */ 1224bff34e3Sthurlow }; 1234bff34e3Sthurlow typedef struct smb_sopt smb_sopt_t; 1244bff34e3Sthurlow 1254bff34e3Sthurlow /* 1264bff34e3Sthurlow * network IO daemon states 1274bff34e3Sthurlow * really connection states. 1284bff34e3Sthurlow */ 1294bff34e3Sthurlow enum smbiod_state { 1304bff34e3Sthurlow SMBIOD_ST_NOTCONN, /* no connect request was made */ 1314bff34e3Sthurlow SMBIOD_ST_RECONNECT, /* a [re]connect attempt is in progress */ 1324bff34e3Sthurlow SMBIOD_ST_TRANACTIVE, /* transport level is up */ 1334bff34e3Sthurlow SMBIOD_ST_NEGOACTIVE, /* completed negotiation */ 1344bff34e3Sthurlow SMBIOD_ST_SSNSETUP, /* started (a) session setup */ 1354bff34e3Sthurlow SMBIOD_ST_VCACTIVE, /* session established */ 1364bff34e3Sthurlow SMBIOD_ST_DEAD /* connection broken, transport is down */ 1374bff34e3Sthurlow }; 1384bff34e3Sthurlow 1394bff34e3Sthurlow 1404bff34e3Sthurlow /* 1414bff34e3Sthurlow * Info structures 1424bff34e3Sthurlow */ 1434bff34e3Sthurlow #define SMB_INFO_NONE 0 1444bff34e3Sthurlow #define SMB_INFO_VC 2 1454bff34e3Sthurlow #define SMB_INFO_SHARE 3 1464bff34e3Sthurlow 1474bff34e3Sthurlow struct smb_vc_info { 1484bff34e3Sthurlow int itype; 1494bff34e3Sthurlow int usecount; 1504bff34e3Sthurlow uid_t uid; /* user id of connection */ 1514bff34e3Sthurlow gid_t gid; /* group of connection */ 1524bff34e3Sthurlow mode_t mode; /* access mode */ 1534bff34e3Sthurlow int flags; 1544bff34e3Sthurlow enum smbiod_state iodstate; 1554bff34e3Sthurlow struct smb_sopt sopt; 1564bff34e3Sthurlow char srvname[SMB_MAXSRVNAMELEN+1]; 1574bff34e3Sthurlow char vcname[128]; 1584bff34e3Sthurlow }; 1594bff34e3Sthurlow typedef struct smb_vc_info smb_vc_info_t; 1604bff34e3Sthurlow 1614bff34e3Sthurlow struct smb_share_info { 1624bff34e3Sthurlow int itype; 1634bff34e3Sthurlow int usecount; 1644bff34e3Sthurlow ushort_t tid; /* TID */ 1654bff34e3Sthurlow int type; /* share type */ 1664bff34e3Sthurlow uid_t uid; /* user id of connection */ 1674bff34e3Sthurlow gid_t gid; /* group of connection */ 1684bff34e3Sthurlow mode_t mode; /* access mode */ 1694bff34e3Sthurlow int flags; 1704bff34e3Sthurlow char sname[128]; 1714bff34e3Sthurlow }; 1724bff34e3Sthurlow typedef struct smb_share_info smb_share_info_t; 1734bff34e3Sthurlow 1744bff34e3Sthurlow struct smb_rq; 1754bff34e3Sthurlow /* This declares struct smb_rqhead */ 1764bff34e3Sthurlow TAILQ_HEAD(smb_rqhead, smb_rq); 1774bff34e3Sthurlow 1784bff34e3Sthurlow #define SMB_NBTIMO 15 1794bff34e3Sthurlow #define SMB_DEFRQTIMO 30 /* 30 for oplock revoke/writeback */ 1804bff34e3Sthurlow #define SMBWRTTIMO 60 1814bff34e3Sthurlow #define SMBSSNSETUPTIMO 60 1824bff34e3Sthurlow #define SMBNOREPLYWAIT (0) 1834bff34e3Sthurlow 1844bff34e3Sthurlow #define SMB_DIALECT(vcp) ((vcp)->vc_sopt.sv_proto) 1854bff34e3Sthurlow 1864bff34e3Sthurlow /* 1874bff34e3Sthurlow * Connection object 1884bff34e3Sthurlow */ 1894bff34e3Sthurlow 1904bff34e3Sthurlow #define SMB_CO_LOCK(cp) mutex_enter(&(cp)->co_lock) 1914bff34e3Sthurlow #define SMB_CO_UNLOCK(cp) mutex_exit(&(cp)->co_lock) 1924bff34e3Sthurlow 1934bff34e3Sthurlow /* 1944bff34e3Sthurlow * Common part of smb_vc, smb_share 1954bff34e3Sthurlow * Locking: co_lock protects most 1964bff34e3Sthurlow * fields in this struct, except 1974bff34e3Sthurlow * as noted below: 1984bff34e3Sthurlow */ 1994bff34e3Sthurlow struct smb_connobj { 2004bff34e3Sthurlow kmutex_t co_lock; 2014bff34e3Sthurlow int co_level; /* SMBL_ */ 2024bff34e3Sthurlow int co_flags; 2034bff34e3Sthurlow int co_usecount; 2044bff34e3Sthurlow 2054bff34e3Sthurlow /* Note: must lock co_parent before child. */ 2064bff34e3Sthurlow struct smb_connobj *co_parent; 2074bff34e3Sthurlow 2084bff34e3Sthurlow /* this.co_lock protects the co_children list */ 2094bff34e3Sthurlow SLIST_HEAD(, smb_connobj) co_children; 2104bff34e3Sthurlow 2114bff34e3Sthurlow /* 2124bff34e3Sthurlow * Linkage in parent's list of children. 2134bff34e3Sthurlow * Must hold parent.co_lock to traverse. 2144bff34e3Sthurlow */ 2154bff34e3Sthurlow SLIST_ENTRY(smb_connobj) co_next; 2164bff34e3Sthurlow 2174bff34e3Sthurlow /* These two are set only at creation. */ 2184bff34e3Sthurlow void (*co_gone)(struct smb_connobj *); 2194bff34e3Sthurlow void (*co_free)(struct smb_connobj *); 2204bff34e3Sthurlow }; 2214bff34e3Sthurlow typedef struct smb_connobj smb_connobj_t; 2224bff34e3Sthurlow 2234bff34e3Sthurlow /* 2244bff34e3Sthurlow * Virtual Circuit (session) to a server. 2254bff34e3Sthurlow * This is the most (over)complicated part of SMB protocol. 2264bff34e3Sthurlow * For the user security level (usl), each session with different remote 2274bff34e3Sthurlow * user name has its own VC. 2284bff34e3Sthurlow * It is unclear however, should share security level (ssl) allow additional 2294bff34e3Sthurlow * VCs, because user name is not used and can be the same. On other hand, 2304bff34e3Sthurlow * multiple VCs allows us to create separate sessions to server on a per 2314bff34e3Sthurlow * user basis. 2324bff34e3Sthurlow */ 2334bff34e3Sthurlow 2344bff34e3Sthurlow typedef struct smb_vc { 2354bff34e3Sthurlow struct smb_connobj vc_co; 2364bff34e3Sthurlow enum smbiod_state vc_state; 2374bff34e3Sthurlow kcondvar_t vc_statechg; 2384bff34e3Sthurlow ksema_t vc_sendlock; 2394bff34e3Sthurlow 2404bff34e3Sthurlow zoneid_t vc_zoneid; 2414bff34e3Sthurlow char *vc_srvname; 2424bff34e3Sthurlow struct sockaddr *vc_paddr; /* server addr */ 2434bff34e3Sthurlow struct sockaddr *vc_laddr; /* local addr, if any */ 2444bff34e3Sthurlow char *vc_domain; /* domain that defines username */ 2454bff34e3Sthurlow char *vc_username; 2464bff34e3Sthurlow char *vc_pass; /* password for usl case */ 2474bff34e3Sthurlow uchar_t vc_lmhash[SMB_PWH_MAX]; 2484bff34e3Sthurlow uchar_t vc_nthash[SMB_PWH_MAX]; 249*9c9af259SGordon Ross uint8_t *vc_mackey; /* MAC key */ 250*9c9af259SGordon Ross int vc_mackeylen; /* length of MAC key */ 251*9c9af259SGordon Ross uint32_t vc_seqno; /* my next sequence number - */ 252*9c9af259SGordon Ross /* - serialized by iod_rqlock */ 2534bff34e3Sthurlow uint_t vc_timo; /* default request timeout */ 2544bff34e3Sthurlow int vc_maxvcs; /* maximum number of VC per conn */ 2554bff34e3Sthurlow 2564bff34e3Sthurlow void *vc_tolower; /* local charset */ 2574bff34e3Sthurlow void *vc_toupper; /* local charset */ 2584bff34e3Sthurlow void *vc_toserver; /* local charset to server one */ 2594bff34e3Sthurlow void *vc_tolocal; /* server charset to local one */ 2604bff34e3Sthurlow int vc_number; /* number of this VC from client side */ 2614bff34e3Sthurlow int vc_genid; /* "generation ID" of this VC */ 2624bff34e3Sthurlow uid_t vc_uid; /* user id of connection */ 2634bff34e3Sthurlow gid_t vc_grp; /* group of connection */ 2644bff34e3Sthurlow mode_t vc_mode; /* access mode */ 2654bff34e3Sthurlow uint16_t vc_smbuid; /* auth. session ID from server */ 2664bff34e3Sthurlow 2674bff34e3Sthurlow uint8_t vc_hflags; /* or'ed with flags in the smb header */ 2684bff34e3Sthurlow uint16_t vc_hflags2; /* or'ed with flags in the smb header */ 2694bff34e3Sthurlow void *vc_tdata; /* transport control block */ 2704bff34e3Sthurlow struct smb_tran_desc *vc_tdesc; 2714bff34e3Sthurlow int vc_chlen; /* actual challenge length */ 2724bff34e3Sthurlow uchar_t vc_challenge[SMB_MAXCHALLENGELEN]; 273*9c9af259SGordon Ross uint16_t vc_mid; /* multiplex id */ 2744bff34e3Sthurlow int vc_vopt; /* local options SMBVOPT_ */ 2754bff34e3Sthurlow struct smb_sopt vc_sopt; /* server options */ 2764bff34e3Sthurlow struct smb_cred vc_scred; /* used in reconnect procedure */ 2774bff34e3Sthurlow int vc_txmax; /* max tx/rx packet size */ 2784bff34e3Sthurlow int vc_rxmax; /* max readx data size */ 2794bff34e3Sthurlow int vc_wxmax; /* max writex data size */ 2804bff34e3Sthurlow 2814bff34e3Sthurlow /* Authentication tokens */ 2824bff34e3Sthurlow size_t vc_intoklen; 2834bff34e3Sthurlow caddr_t vc_intok; 2844bff34e3Sthurlow size_t vc_outtoklen; 2854bff34e3Sthurlow caddr_t vc_outtok; 2864bff34e3Sthurlow size_t vc_negtoklen; 2874bff34e3Sthurlow caddr_t vc_negtok; 2884bff34e3Sthurlow 2894bff34e3Sthurlow /* 2904bff34e3Sthurlow * These members used to be in struct smbiod, 2914bff34e3Sthurlow * which has been eliminated. 2924bff34e3Sthurlow */ 2934bff34e3Sthurlow krwlock_t iod_rqlock; /* iod_rqlist */ 2944bff34e3Sthurlow struct smb_rqhead iod_rqlist; /* list of outstanding reqs */ 2954bff34e3Sthurlow struct _kthread *iod_thr; /* the IOD (reader) thread */ 2964bff34e3Sthurlow kcondvar_t iod_exit; /* IOD thread termination */ 2974bff34e3Sthurlow int iod_flags; /* see SMBIOD_* below */ 2984bff34e3Sthurlow int iod_newrq; /* send needed (iod_rqlock) */ 2994bff34e3Sthurlow int iod_muxfull; /* maxmux limit reached */ 3004bff34e3Sthurlow uint_t iod_rqwaiting; /* count of waiting requests */ 3014bff34e3Sthurlow } smb_vc_t; 3024bff34e3Sthurlow 3034bff34e3Sthurlow #define vc_lock vc_co.co_lock 3044bff34e3Sthurlow #define vc_flags vc_co.co_flags 3054bff34e3Sthurlow #define vc_maxmux vc_sopt.sv_maxmux 3064bff34e3Sthurlow 3074bff34e3Sthurlow #define SMB_VC_LOCK(vcp) mutex_enter(&(vcp)->vc_lock) 3084bff34e3Sthurlow #define SMB_VC_UNLOCK(vcp) mutex_exit(&(vcp)->vc_lock) 3094bff34e3Sthurlow 3104bff34e3Sthurlow #define SMB_UNICODE_STRINGS(vcp) ((vcp)->vc_hflags2 & SMB_FLAGS2_UNICODE) 3114bff34e3Sthurlow 3124bff34e3Sthurlow /* Bits in iod_flags */ 3134bff34e3Sthurlow #define SMBIOD_RUNNING 0x0001 3144bff34e3Sthurlow #define SMBIOD_SHUTDOWN 0x0002 3154bff34e3Sthurlow 3164bff34e3Sthurlow /* 3174bff34e3Sthurlow * smb_share structure describes connection to the given SMB share (tree). 3184bff34e3Sthurlow * Connection to share is always built on top of the VC. 3194bff34e3Sthurlow */ 3204bff34e3Sthurlow 3214bff34e3Sthurlow typedef struct smb_share { 3224bff34e3Sthurlow struct smb_connobj ss_co; 3234bff34e3Sthurlow kcondvar_t ss_conn_done; /* wait for reconnect */ 3244bff34e3Sthurlow int ss_conn_waiters; 3254bff34e3Sthurlow char *ss_name; 3264bff34e3Sthurlow char *ss_pass; /* share password, can be null */ 3274bff34e3Sthurlow char *ss_fsname; 3284bff34e3Sthurlow void *ss_mount; /* used for smb up/down */ 3294bff34e3Sthurlow uint16_t ss_tid; /* TID */ 3304bff34e3Sthurlow int ss_type; /* share type */ 3314bff34e3Sthurlow mode_t ss_mode; /* access mode */ 3324bff34e3Sthurlow int ss_vcgenid; /* check VC generation ID */ 3334bff34e3Sthurlow uint32_t ss_maxfilenamelen; 3344bff34e3Sthurlow int ss_sopt; /* local options SMBSOPT_ */ 3354bff34e3Sthurlow } smb_share_t; 3364bff34e3Sthurlow 3374bff34e3Sthurlow #define ss_lock ss_co.co_lock 3384bff34e3Sthurlow #define ss_flags ss_co.co_flags 3394bff34e3Sthurlow 3404bff34e3Sthurlow #define SMB_SS_LOCK(ssp) mutex_enter(&(ssp)->ss_lock) 3414bff34e3Sthurlow #define SMB_SS_UNLOCK(ssp) mutex_exit(&(ssp)->ss_lock) 3424bff34e3Sthurlow 3434bff34e3Sthurlow #define CPTOVC(cp) ((struct smb_vc *)(cp)) 3444bff34e3Sthurlow #define VCTOCP(vcp) (&(vcp)->vc_co) 3454bff34e3Sthurlow 3464bff34e3Sthurlow #define CPTOSS(cp) ((struct smb_share *)(cp)) 3474bff34e3Sthurlow #define SSTOVC(ssp) CPTOVC(((ssp)->ss_co.co_parent)) 3484bff34e3Sthurlow #define SSTOCP(ssp) (&(ssp)->ss_co) 3494bff34e3Sthurlow 3504bff34e3Sthurlow /* 3514bff34e3Sthurlow * This is used internally to pass all the info about 3524bff34e3Sthurlow * some VC that an ioctl caller is looking for. 3534bff34e3Sthurlow */ 3544bff34e3Sthurlow struct smb_vcspec { 3554bff34e3Sthurlow char *srvname; 3564bff34e3Sthurlow struct sockaddr *sap; 3574bff34e3Sthurlow struct sockaddr *lap; 3584bff34e3Sthurlow int optflags; 3594bff34e3Sthurlow char *domain; 3604bff34e3Sthurlow char *username; 3614bff34e3Sthurlow char *pass; 3624bff34e3Sthurlow uid_t owner; 3634bff34e3Sthurlow gid_t group; 3644bff34e3Sthurlow mode_t mode; 3654bff34e3Sthurlow mode_t rights; 3664bff34e3Sthurlow char *localcs; 3674bff34e3Sthurlow char *servercs; 3684bff34e3Sthurlow size_t toklen; 3694bff34e3Sthurlow caddr_t tok; 3704bff34e3Sthurlow }; 3714bff34e3Sthurlow typedef struct smb_vcspec smb_vcspec_t; 3724bff34e3Sthurlow 3734bff34e3Sthurlow /* 3744bff34e3Sthurlow * This is used internally to pass all the info about 3754bff34e3Sthurlow * some share that an ioctl caller is looking for. 3764bff34e3Sthurlow */ 3774bff34e3Sthurlow struct smb_sharespec { 3784bff34e3Sthurlow char *name; 3794bff34e3Sthurlow char *pass; 3804bff34e3Sthurlow mode_t mode; 3814bff34e3Sthurlow mode_t rights; 3824bff34e3Sthurlow uid_t owner; 3834bff34e3Sthurlow gid_t group; 3844bff34e3Sthurlow int stype; 3854bff34e3Sthurlow int optflags; 3864bff34e3Sthurlow }; 3874bff34e3Sthurlow typedef struct smb_sharespec smb_sharespec_t; 3884bff34e3Sthurlow 3894bff34e3Sthurlow 3904bff34e3Sthurlow /* 3914bff34e3Sthurlow * Call-back operations vector, so the netsmb module 3924bff34e3Sthurlow * can notify smbfs about events affecting mounts. 3934bff34e3Sthurlow * Installed in netsmb after smbfs loads. 3944bff34e3Sthurlow */ 3954bff34e3Sthurlow /* #define NEED_SMBFS_CALLBACKS 1 */ 3964bff34e3Sthurlow #ifdef NEED_SMBFS_CALLBACKS 3974bff34e3Sthurlow typedef struct smb_fscb { 3984bff34e3Sthurlow void (*fscb_dead)(smb_share_t *); 3994bff34e3Sthurlow void (*fscb_down)(smb_share_t *); 4004bff34e3Sthurlow void (*fscb_up)(smb_share_t *); 4014bff34e3Sthurlow } smb_fscb_t; 4024bff34e3Sthurlow /* Install the above vector, or pass NULL to clear it. */ 4034bff34e3Sthurlow int smb_fscb_set(smb_fscb_t *); 4044bff34e3Sthurlow #endif /* NEED_SMBFS_CALLBACKS */ 4054bff34e3Sthurlow 4064bff34e3Sthurlow /* 4074bff34e3Sthurlow * IOD functions 4084bff34e3Sthurlow */ 4094bff34e3Sthurlow int smb_iod_create(struct smb_vc *vcp); 4104bff34e3Sthurlow int smb_iod_destroy(struct smb_vc *vcp); 4114bff34e3Sthurlow int smb_iod_connect(struct smb_vc *vcp); 4124bff34e3Sthurlow int smb_iod_disconnect(struct smb_vc *vcp); 4134bff34e3Sthurlow int smb_iod_addrq(struct smb_rq *rqp); 4144bff34e3Sthurlow int smb_iod_multirq(struct smb_rq *rqp); 4154bff34e3Sthurlow int smb_iod_waitrq(struct smb_rq *rqp); 4164bff34e3Sthurlow int smb_iod_removerq(struct smb_rq *rqp); 4174bff34e3Sthurlow void smb_iod_shutdown_share(struct smb_share *ssp); 4184bff34e3Sthurlow void smb_iod_notify_down(struct smb_vc *vcp); 4194bff34e3Sthurlow void smb_iod_notify_up(struct smb_vc *vcp); 4204bff34e3Sthurlow 4214bff34e3Sthurlow /* 4224bff34e3Sthurlow * Session level functions 4234bff34e3Sthurlow */ 4244bff34e3Sthurlow int smb_sm_init(void); 4254bff34e3Sthurlow int smb_sm_idle(void); 4264bff34e3Sthurlow void smb_sm_done(void); 4274bff34e3Sthurlow 4281b34bc4aSbs int smb_sm_findvc(struct smb_vcspec *vcspec, 4291b34bc4aSbs struct smb_cred *scred, struct smb_vc **vcpp); 4304bff34e3Sthurlow int smb_sm_negotiate(struct smb_vcspec *vcspec, 4314bff34e3Sthurlow struct smb_cred *scred, struct smb_vc **vcpp); 4324bff34e3Sthurlow int smb_sm_ssnsetup(struct smb_vcspec *vcspec, 4334bff34e3Sthurlow struct smb_cred *scred, struct smb_vc *vcp); 4344bff34e3Sthurlow int smb_sm_tcon(struct smb_sharespec *shspec, struct smb_cred *scred, 4354bff34e3Sthurlow struct smb_vc *vcp, struct smb_share **sspp); 4364bff34e3Sthurlow 4374bff34e3Sthurlow /* 4384bff34e3Sthurlow * VC level functions 4394bff34e3Sthurlow */ 4404bff34e3Sthurlow int smb_vc_setup(struct smb_vcspec *vcspec, struct smb_cred *scred, 4414bff34e3Sthurlow struct smb_vc *vcp, int is_ss); 4424bff34e3Sthurlow int smb_vc_create(struct smb_vcspec *vcspec, 4434bff34e3Sthurlow struct smb_cred *scred, struct smb_vc **vcpp); 4444bff34e3Sthurlow int smb_vc_negotiate(struct smb_vc *vcp, struct smb_cred *scred); 4454bff34e3Sthurlow int smb_vc_ssnsetup(struct smb_vc *vcp, struct smb_cred *scred); 4464bff34e3Sthurlow void smb_vc_hold(struct smb_vc *vcp); 4474bff34e3Sthurlow void smb_vc_rele(struct smb_vc *vcp); 4484bff34e3Sthurlow void smb_vc_kill(struct smb_vc *vcp); 4494bff34e3Sthurlow int smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *shspec, 4504bff34e3Sthurlow struct smb_cred *scred, struct smb_share **sspp); 4514bff34e3Sthurlow const char *smb_vc_getpass(struct smb_vc *vcp); 4524bff34e3Sthurlow uint16_t smb_vc_nextmid(struct smb_vc *vcp); 4534bff34e3Sthurlow void *smb_vc_getipaddr(struct smb_vc *vcp, int *ipvers); 4544bff34e3Sthurlow 4554bff34e3Sthurlow /* 4564bff34e3Sthurlow * share level functions 4574bff34e3Sthurlow */ 4584bff34e3Sthurlow int smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, 4594bff34e3Sthurlow struct smb_cred *scred, struct smb_share **sspp); 4604bff34e3Sthurlow 4614bff34e3Sthurlow void smb_share_hold(struct smb_share *ssp); 4624bff34e3Sthurlow void smb_share_rele(struct smb_share *ssp); 4634bff34e3Sthurlow void smb_share_kill(struct smb_share *ssp); 4644bff34e3Sthurlow 4654bff34e3Sthurlow void smb_share_invalidate(struct smb_share *ssp); 4664bff34e3Sthurlow int smb_share_tcon(struct smb_share *ssp); 4674bff34e3Sthurlow int smb_share_valid(struct smb_share *ssp); 4684bff34e3Sthurlow const char *smb_share_getpass(struct smb_share *ssp); 4694bff34e3Sthurlow int smb_share_count(void); 4704bff34e3Sthurlow 4714bff34e3Sthurlow /* 4724bff34e3Sthurlow * SMB protocol level functions 4734bff34e3Sthurlow */ 4744bff34e3Sthurlow int smb_smb_negotiate(struct smb_vc *vcp, struct smb_cred *scred); 4754bff34e3Sthurlow int smb_smb_ssnsetup(struct smb_vc *vcp, struct smb_cred *scred); 4764bff34e3Sthurlow int smb_smb_ssnclose(struct smb_vc *vcp, struct smb_cred *scred); 4774bff34e3Sthurlow int smb_smb_treeconnect(struct smb_share *ssp, struct smb_cred *scred); 4784bff34e3Sthurlow int smb_smb_treedisconnect(struct smb_share *ssp, struct smb_cred *scred); 4794bff34e3Sthurlow int smb_smb_echo(struct smb_vc *vcp, struct smb_cred *scred, int timo); 4804bff34e3Sthurlow #ifdef APPLE 4814bff34e3Sthurlow int smb_smb_checkdir(struct smb_share *ssp, void *dnp, 4824bff34e3Sthurlow char *name, int nmlen, struct smb_cred *scred); 4834bff34e3Sthurlow #endif 4844bff34e3Sthurlow int smb_rwuio(struct smb_share *ssp, uint16_t fid, uio_rw_t rw, 4854bff34e3Sthurlow uio_t *uiop, struct smb_cred *scred, int timo); 4864bff34e3Sthurlow 4874bff34e3Sthurlow #endif /* _SMB_CONN_H */ 488