4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Copyright (c) 2000-2001 Boris Popov
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * All rights reserved.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Redistribution and use in source and binary forms, with or without
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * modification, are permitted provided that the following conditions
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 1. Redistributions of source code must retain the above copyright
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * notice, this list of conditions and the following disclaimer.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 2. Redistributions in binary form must reproduce the above copyright
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * notice, this list of conditions and the following disclaimer in the
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * documentation and/or other materials provided with the distribution.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 3. All advertising materials mentioning features or use of this software
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * must display the following acknowledgement:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * This product includes software developed by Boris Popov.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 4. Neither the name of the author nor the names of any co-contributors
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * may be used to endorse or promote products derived from this software
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * without specific prior written permission.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * SUCH DAMAGE.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * $Id: smb_conn.h,v 1.32.42.1 2005/05/27 02:35:29 lindak Exp $
430b4c467020edf2445feb0c21db01c88b86243aGordon Ross * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Use is subject to license terms.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Credentials of user/process for processing in the connection procedures
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Common object flags
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Bits in vc_flags (a.k.a. vc_co.co_flags)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Many of these were duplicates of SMBVOPT_ flags
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * and we now keep those too instead of merging
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * them into vc_flags.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBV_WIN95 0x0010 /* used to apply bugfixes for this OS */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBV_NT4 0x0020 /* used when NT4 issues invalid resp */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross#define SMBV_UNICODE 0x0040 /* conn configured to use Unicode */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Note: the common "obj" level uses this GONE flag by
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * the name SMBO_GONE. Keep this alias as a reminder.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * bits in smb_share ss_flags (a.k.a. ss_co.co_flags)
02d09e03eb27f3a2dc299de704e45dae5173f43fGordon Ross#define SMBS_FST_FAT 0x0010 /* share FS Type is FAT */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Note: the common "obj" level uses this GONE flag by
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * the name SMBO_GONE. Keep this alias as a reminder.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/* This declares struct smb_rqhead */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_DEFRQTIMO 30 /* 30 for oplock revoke/writeback */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Connection object
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Common part of smb_vc, smb_share
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Locking: co_lock protects most
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * fields in this struct, except
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * as noted below:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* Note: must lock co_parent before child. */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* this.co_lock protects the co_children list */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Linkage in parent's list of children.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Must hold parent.co_lock to traverse.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* These two are set only at creation. */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * "Level" in the connection object hierarchy
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * Virtual Circuit to a server (really connection + session).
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * Yes, calling this a "Virtual Circuit" is confusining,
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * because it has nothing to do with the SMB notion of a
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * "Virtual Circuit".
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross struct smb_connobj vc_co; /* keep first! See CPTOVC */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross struct smb_tran_desc *vc_tdesc; /* transport ops. vector */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_rqhead iod_rqlist; /* list of outstanding reqs */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct _kthread *iod_thr; /* the IOD (reader) thread */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross /* This is copied in/out when IOD enters/returns */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross /* session identity, etc. */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross/* defines for members in vc_ssn */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross/* defines for members in vc_work */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_VC_LOCK(vcp) mutex_enter(&(vcp)->vc_lock)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_VC_UNLOCK(vcp) mutex_exit(&(vcp)->vc_lock)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_UNICODE_STRINGS(vcp) ((vcp)->vc_hflags2 & SMB_FLAGS2_UNICODE)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/* Bits in iod_flags */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * smb_share structure describes connection to the given SMB share (tree).
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Connection to share is always built on top of the VC.
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross struct smb_connobj ss_co; /* keep first! See CPTOSS */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_SS_LOCK(ssp) mutex_enter(&(ssp)->ss_lock)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_SS_UNLOCK(ssp) mutex_exit(&(ssp)->ss_lock)
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross#define CPTOVC(cp) ((struct smb_vc *)((void *)(cp)))
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross#define CPTOSS(cp) ((struct smb_share *)((void *)(cp)))
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Call-back operations vector, so the netsmb module
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * can notify smbfs about events affecting mounts.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Installed in netsmb after smbfs loads.
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross /* Called when the VC has disconnected. */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross /* Called when the VC has reconnected. */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross /* Called when the server becomes unresponsive. */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross /* Called when the server is responding again. */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/* Install the above vector, or pass NULL to clear it. */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * The driver per open instance object.
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross * Mostly used in: smb_dev.c, smb_usr.c
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross struct smb_share *sd_share; /* Reference to share if any */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_dev2share(int fd, struct smb_share **sspp);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_get_flags2(smb_dev_t *sdp, intptr_t arg, int flags);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_get_ssnkey(smb_dev_t *sdp, intptr_t arg, int flags);
430b4c467020edf2445feb0c21db01c88b86243aGordon Rossint smb_usr_dup_dev(smb_dev_t *sdp, intptr_t arg, int flags);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_simplerq(smb_dev_t *sdp, intptr_t arg, int flags, cred_t *cr);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_t2request(smb_dev_t *sdp, intptr_t arg, int flags, cred_t *cr);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_rw(smb_dev_t *sdp, int cmd, intptr_t arg, int flags, cred_t *cr);
430b4c467020edf2445feb0c21db01c88b86243aGordon Rossint smb_usr_ntcreate(smb_dev_t *, intptr_t, int, cred_t *);
430b4c467020edf2445feb0c21db01c88b86243aGordon Rossint smb_usr_printjob(smb_dev_t *, intptr_t, int, cred_t *);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_get_ssn(smb_dev_t *, int, intptr_t, int, cred_t *);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_get_tree(smb_dev_t *, int, intptr_t, int, cred_t *);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_iod_work(smb_dev_t *sdp, intptr_t arg, int flags, cred_t *cr);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_usr_iod_ioctl(smb_dev_t *sdp, int cmd, intptr_t arg, int flags);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * IOD functions
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Session level functions
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * VC level functions
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_vc_findcreate(smbioc_ossn_t *, smb_cred_t *, smb_vc_t **);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_vc_create(smbioc_ossn_t *ossn, smb_cred_t *scred, smb_vc_t **vcpp);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossvoid *smb_vc_getipaddr(smb_vc_t *vcp, int *ipvers);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rosstypedef void (*walk_share_func_t)(smb_share_t *);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossvoid smb_vc_walkshares(struct smb_vc *, walk_share_func_t);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * share level functions
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossint smb_share_findcreate(smbioc_tcon_t *, smb_vc_t *,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* _SMB_CONN_H */