smb_conn.h revision 613a2f6ba31e891e3d947a356daf5e563d43c1ce
/*
* Copyright (c) 2000-2001 Boris Popov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Boris Popov.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: smb_conn.h,v 1.32.42.1 2005/05/27 02:35:29 lindak Exp $
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SMB_CONN_H
#define _SMB_CONN_H
#include <sys/dditypes.h>
/*
*/
typedef struct smb_cred {
} smb_cred_t;
/*
* Common object flags
*/
#define SMBO_GONE 0x1000000
/*
* Bits in vc_flags (a.k.a. vc_co.co_flags)
* Many of these were duplicates of SMBVOPT_ flags
* and we now keep those too instead of merging
* them into vc_flags.
*/
/*
* Note: the common "obj" level uses this GONE flag by
* the name SMBO_GONE. Keep this alias as a reminder.
*/
/*
* bits in smb_share ss_flags (a.k.a. ss_co.co_flags)
*/
#define SMBS_RECONNECTING 0x0002
#define SMBS_CONNECTED 0x0004
#define SMBS_TCON_WAIT 0x0008
#define SMBS_1980 0x0010
/*
* ^ This partition can't handle dates before 1980. It's probably a FAT
* partition but could be some other ancient FS type
*/
/*
* Note: the common "obj" level uses this GONE flag by
* the name SMBO_GONE. Keep this alias as a reminder.
*/
struct smb_rq;
/* This declares struct smb_rqhead */
#define SMB_NBTIMO 15
#define SMBWRTTIMO 60
#define SMBSSNSETUPTIMO 60
#define SMBNOREPLYWAIT (0)
/*
* Connection object
*/
/*
* Common part of smb_vc, smb_share
* Locking: co_lock protects most
* fields in this struct, except
* as noted below:
*/
struct smb_connobj {
int co_level; /* SMBL_ */
int co_flags;
int co_usecount;
/* Note: must lock co_parent before child. */
struct smb_connobj *co_parent;
/* this.co_lock protects the co_children list */
/*
* Linkage in parent's list of children.
* Must hold parent.co_lock to traverse.
*/
/* These two are set only at creation. */
void (*co_gone)(struct smb_connobj *);
void (*co_free)(struct smb_connobj *);
};
typedef struct smb_connobj smb_connobj_t;
/*
* "Level" in the connection object hierarchy
*/
#define SMBL_SM 0
#define SMBL_VC 1
#define SMBL_SHARE 2
/*
* Virtual Circuit to a server (really connection + session).
* Yes, calling this a "Virtual Circuit" is confusining,
* because it has nothing to do with the SMB notion of a
* "Virtual Circuit".
*/
typedef struct smb_vc {
enum smbiod_state vc_state;
int vc_genid; /* "generation" ID */
int vc_mackeylen; /* length of MAC key */
void *vc_tdata; /* transport control block */
int iod_flags; /* see SMBIOD_* below */
int iod_newrq; /* send needed (iod_rqlock) */
int iod_muxfull; /* maxmux limit reached */
/* session identity, etc. */
} smb_vc_t;
/* defines for members in vc_ssn */
/* defines for members in vc_work */
/* Bits in iod_flags */
#define SMBIOD_RUNNING 0x0001
#define SMBIOD_SHUTDOWN 0x0002
/*
* smb_share structure describes connection to the given SMB share (tree).
* Connection to share is always built on top of the VC.
*/
typedef struct smb_share {
int ss_conn_waiters;
int ss_vcgenid; /* check VC generation ID */
} smb_share_t;
/*
* Call-back operations vector, so the netsmb module
* can notify smbfs about events affecting mounts.
* Installed in netsmb after smbfs loads.
*/
typedef struct smb_fscb {
/* Called when the VC has disconnected. */
void (*fscb_disconn)(smb_share_t *);
/* Called when the VC has reconnected. */
void (*fscb_connect)(smb_share_t *);
/* Called when the server becomes unresponsive. */
void (*fscb_down)(smb_share_t *);
/* Called when the server is responding again. */
void (*fscb_up)(smb_share_t *);
} smb_fscb_t;
/* Install the above vector, or pass NULL to clear it. */
int smb_fscb_set(smb_fscb_t *);
/*
* The driver per open instance object.
*/
typedef struct smb_dev {
int sd_opened; /* Opened or not */
int sd_level; /* Future use */
int sd_vcgenid; /* Generation of share or VC */
int sd_poll; /* Future use */
int sd_flags; /* State of connection */
#define NSMBFL_OPEN 0x0001
#define NSMBFL_IOD 0x0002
void *sd_devfs; /* Dont know how to use this. but */
} smb_dev_t;
extern const uint32_t nsmb_version;
/*
*/
/*
*/
/*
* IOD functions
*/
void smb_iod_sendall(smb_vc_t *);
int smb_iod_recvall(smb_vc_t *);
int smb_iod_vc_idle(smb_vc_t *);
int smb_iod_vc_rcfail(smb_vc_t *);
int smb_iod_reconnect(smb_vc_t *);
/*
* Session level functions
*/
int smb_sm_init(void);
int smb_sm_idle(void);
void smb_sm_done(void);
/*
* VC level functions
*/
typedef void (*walk_share_func_t)(smb_share_t *);
/*
* share level functions
*/
smb_share_t **, smb_cred_t *);
/*
* SMB protocol level functions
*/
#endif /* _SMB_CONN_H */