smb_conn.h revision 9c9af2590af49bb395bc8d2eace0f2d4ea16d165
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 $
1b34bc4aa5ecbd590d45845d21c8478049df6dcfbs * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Use is subject to license terms.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Credentials of user/process for processing in the connection procedures
4bff34e37def8a90f9194d81bc345c52ba20086athurlowtypedef struct smb_cred {
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.
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross * Careful here: In smb_smb_negotiate, we clear ALL OF
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross * vc_flags except: SMBV_GONE, SMBV_RECONNECTING
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross#define SMBV_RECONNECTING 0x0002 /* conn in process of reconnection */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBV_LONGNAMES 0x0004 /* conn configured to use long names */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBV_ENCRYPT 0x0008 /* server demands encrypted password */
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 */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross#define SMBV_EXT_SEC 0x0080 /* conn to use extended security */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross#define SMBV_WILL_SIGN 0x0100 /* negotiated signing */
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)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * ^ This partition can't handle dates before 1980. It's probably a FAT
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * partition but could be some other ancient FS type
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBS_RESUMEKEYS 0x0010 /* must use resume keys */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Note: the common "obj" level uses this GONE flag by
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * the name SMBO_GONE. Keep this alias as a reminder.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Negotiated protocol parameters
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sv_maxmux; /* max number of outstanding rq's */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * network IO daemon states
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * really connection states.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow SMBIOD_ST_NOTCONN, /* no connect request was made */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow SMBIOD_ST_RECONNECT, /* a [re]connect attempt is in progress */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow SMBIOD_ST_DEAD /* connection broken, transport is down */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Info structures
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. */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Virtual Circuit (session) to a server.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * This is the most (over)complicated part of SMB protocol.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * For the user security level (usl), each session with different remote
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * user name has its own VC.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * It is unclear however, should share security level (ssl) allow additional
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * VCs, because user name is not used and can be the same. On other hand,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * multiple VCs allows us to create separate sessions to server on a per
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * user basis.
4bff34e37def8a90f9194d81bc345c52ba20086athurlowtypedef struct smb_vc {
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross uint32_t vc_seqno; /* my next sequence number - */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross /* - serialized by iod_rqlock */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow void *vc_toserver; /* local charset to server one */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int vc_number; /* number of this VC from client side */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t vc_smbuid; /* auth. session ID from server */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint8_t vc_hflags; /* or'ed with flags in the smb header */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t vc_hflags2; /* or'ed with flags in the smb header */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_cred vc_scred; /* used in reconnect procedure */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* Authentication tokens */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * These members used to be in struct smbiod,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * which has been eliminated.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_rqhead iod_rqlist; /* list of outstanding reqs */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct _kthread *iod_thr; /* the IOD (reader) thread */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint_t iod_rqwaiting; /* count of waiting requests */
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.
4bff34e37def8a90f9194d81bc345c52ba20086athurlowtypedef struct smb_share {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_SS_LOCK(ssp) mutex_enter(&(ssp)->ss_lock)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMB_SS_UNLOCK(ssp) mutex_exit(&(ssp)->ss_lock)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * This is used internally to pass all the info about
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * some VC that an ioctl caller is looking for.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * This is used internally to pass all the info about
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * some share that an ioctl caller is looking for.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Call-back operations vector, so the netsmb module
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * can notify smbfs about events affecting mounts.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Installed in netsmb after smbfs loads.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/* #define NEED_SMBFS_CALLBACKS 1 */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowtypedef struct smb_fscb {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/* Install the above vector, or pass NULL to clear it. */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* NEED_SMBFS_CALLBACKS */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * IOD functions
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Session level functions
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_sm_tcon(struct smb_sharespec *shspec, struct smb_cred *scred,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * VC level functions
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_vc_setup(struct smb_vcspec *vcspec, struct smb_cred *scred,
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_vc_negotiate(struct smb_vc *vcp, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_vc_ssnsetup(struct smb_vc *vcp, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *shspec,
4bff34e37def8a90f9194d81bc345c52ba20086athurlowvoid *smb_vc_getipaddr(struct smb_vc *vcp, int *ipvers);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * share level functions
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec,
4bff34e37def8a90f9194d81bc345c52ba20086athurlowconst char *smb_share_getpass(struct smb_share *ssp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * SMB protocol level functions
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_smb_negotiate(struct smb_vc *vcp, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_smb_ssnsetup(struct smb_vc *vcp, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_smb_ssnclose(struct smb_vc *vcp, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_smb_treeconnect(struct smb_share *ssp, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_smb_treedisconnect(struct smb_share *ssp, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_smb_echo(struct smb_vc *vcp, struct smb_cred *scred, int timo);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_smb_checkdir(struct smb_share *ssp, void *dnp,
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_rwuio(struct smb_share *ssp, uint16_t fid, uio_rw_t rw,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* _SMB_CONN_H */