#ifndef _NETSMB_DEV_H_
#define _NETSMB_DEV_H_
#ifndef _KERNEL
#include <sys/types.h>
#endif
#include <sys/ioccom.h>
#include <netsmb/smb.h>
#define NSMB_NAME "nsmb"
#define NSMB_VERMAJ 1
#define NSMB_VERMIN 3006
#define NSMB_VERSION (NSMB_VERMAJ * 100000 + NSMB_VERMIN)
#define NSMBFL_OPEN 0x0001
#define SMBVOPT_CREATE 0x0001
#define SMBVOPT_PRIVATE 0x0002
#define SMBVOPT_SINGLESHARE 0x0004
#define SMBVOPT_PERMANENT 0x0010
#define SMBSOPT_CREATE 0x0001
#define SMBSOPT_PERMANENT 0x0010
#define SMBLK_CREATE 0x0001
struct smbioc_ossn {
int ioc_opt;
uint32_t ioc_svlen;
struct sockaddr*ioc_server;
uint32_t ioc_lolen;
struct sockaddr*ioc_local;
char ioc_srvname[SMB_MAXSRVNAMELEN + 1];
int ioc_timeout;
int ioc_retrycount;
char ioc_localcs[16];
char ioc_servercs[16];
char ioc_user[SMB_MAXUSERNAMELEN + 1];
char ioc_workgroup[SMB_MAXUSERNAMELEN + 1];
char ioc_password[SMB_MAXPASSWORDLEN + 1];
uid_t ioc_owner;
gid_t ioc_group;
mode_t ioc_mode;
mode_t ioc_rights;
};
struct smbioc_oshare {
int ioc_opt;
int ioc_stype;
char ioc_share[SMB_MAXSHARENAMELEN + 1];
char ioc_password[SMB_MAXPASSWORDLEN + 1];
uid_t ioc_owner;
gid_t ioc_group;
mode_t ioc_mode;
mode_t ioc_rights;
};
struct smbioc_rq {
u_char ioc_cmd;
u_char ioc_twc;
void * ioc_twords;
u_short ioc_tbc;
void * ioc_tbytes;
int ioc_rpbufsz;
char * ioc_rpbuf;
u_char ioc_rwc;
u_short ioc_rbc;
u_int8_t ioc_errclass;
u_int16_t ioc_serror;
u_int32_t ioc_error;
};
struct smbioc_t2rq {
u_int16_t ioc_setup[3];
int ioc_setupcnt;
char * ioc_name;
u_short ioc_tparamcnt;
void * ioc_tparam;
u_short ioc_tdatacnt;
void * ioc_tdata;
u_short ioc_rparamcnt;
void * ioc_rparam;
u_short ioc_rdatacnt;
void * ioc_rdata;
};
struct smbioc_flags {
int ioc_level;
int ioc_mask;
int ioc_flags;
};
struct smbioc_lookup {
int ioc_level;
int ioc_flags;
struct smbioc_ossn ioc_ssn;
struct smbioc_oshare ioc_sh;
};
struct smbioc_rw {
smbfh ioc_fh;
char * ioc_base;
off_t ioc_offset;
int ioc_cnt;
};
#define SMBIOC_OPENSESSION _IOW('n', 100, struct smbioc_ossn)
#define SMBIOC_OPENSHARE _IOW('n', 101, struct smbioc_oshare)
#define SMBIOC_REQUEST _IOWR('n', 102, struct smbioc_rq)
#define SMBIOC_T2RQ _IOWR('n', 103, struct smbioc_t2rq)
#define SMBIOC_SETFLAGS _IOW('n', 104, struct smbioc_flags)
#define SMBIOC_LOOKUP _IOW('n', 106, struct smbioc_lookup)
#define SMBIOC_READ _IOWR('n', 107, struct smbioc_rw)
#define SMBIOC_WRITE _IOWR('n', 108, struct smbioc_rw)
#ifdef _KERNEL
#define SMBST_CONNECTED 1
STAILQ_HEAD(smbrqh, smb_rq);
struct smb_dev {
struct cdev * dev;
int sd_opened;
int sd_level;
struct smb_vc * sd_vc;
struct smb_share *sd_share;
int sd_poll;
int sd_seq;
int sd_flags;
int refcount;
int usecount;
};
extern struct sx smb_lock;
#define SMB_LOCK() sx_xlock(&smb_lock)
#define SMB_UNLOCK() sx_unlock(&smb_lock)
#define SMB_LOCKASSERT() sx_assert(&smb_lock, SA_XLOCKED)
struct smb_cred;
void sdp_dtor(void *arg);
void sdp_trydestroy(struct smb_dev *dev);
int smb_usr_lookup(struct smbioc_lookup *dp, struct smb_cred *scred,
struct smb_vc **vcpp, struct smb_share **sspp);
int smb_usr_opensession(struct smbioc_ossn *data,
struct smb_cred *scred, struct smb_vc **vcpp);
int smb_usr_openshare(struct smb_vc *vcp, struct smbioc_oshare *data,
struct smb_cred *scred, struct smb_share **sspp);
int smb_usr_simplerequest(struct smb_share *ssp, struct smbioc_rq *data,
struct smb_cred *scred);
int smb_usr_t2request(struct smb_share *ssp, struct smbioc_t2rq *data,
struct smb_cred *scred);
int smb_dev2share(int fd, int mode, struct smb_cred *scred,
struct smb_share **sspp, struct smb_dev **ssdp);
#endif
#endif