#ifndef _NETSMB_SMB_LIB_H_
#define _NETSMB_SMB_LIB_H_
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/byteorder.h>
#include <netsmb/smbfs_api.h>
#include <netsmb/smb_dev.h>
extern const char smbutil_std_opts[];
#define STDPARAM_OPT smbutil_std_opts
#define SMB_ERRTYPE_MASK 0xf0000
#define SMB_SYS_ERROR 0x00000
#define SMB_RAP_ERROR 0x10000
#define SMB_NB_ERROR 0x20000
#define NTLM_HASH_SZ SMBIOC_HASH_SZ
#define NTLM_CHAL_SZ 8
struct smb_iod_ssn {
struct smbioc_ossn iod_ossn;
int iod_authflags;
uchar_t iod_nthash[NTLM_HASH_SZ];
uchar_t iod_lmhash[NTLM_HASH_SZ];
};
typedef struct smb_iod_ssn smb_iod_ssn_t;
struct smb_ctx {
int ct_flags;
int ct_dev_fd;
int ct_door_fd;
int ct_parsedlevel;
int ct_minlevel;
int ct_maxlevel;
char *ct_fullserver;
char *ct_srvaddr_s;
struct addrinfo *ct_addrinfo;
struct nb_ctx *ct_nb;
char *ct_locname;
int ct_minauth;
int ct_shtype_req;
char *ct_origshare;
char *ct_home;
char *ct_rpath;
void *ct_ssp_ctx;
smbioc_ssn_work_t ct_work;
smb_iod_ssn_t ct_iod_ssn;
uchar_t ct_clnonce[NTLM_CHAL_SZ];
uchar_t ct_srv_chal[NTLM_CHAL_SZ];
char ct_password[SMBIOC_MAX_NAME];
};
#define ct_ssn ct_iod_ssn.iod_ossn
#define ct_vopt ct_iod_ssn.iod_ossn.ssn_vopt
#define ct_minver ct_iod_ssn.iod_ossn.ssn_minver
#define ct_maxver ct_iod_ssn.iod_ossn.ssn_maxver
#define ct_owner ct_iod_ssn.iod_ossn.ssn_owner
#define ct_srvaddr ct_iod_ssn.iod_ossn.ssn_srvaddr
#define ct_domain ct_iod_ssn.iod_ossn.ssn_domain
#define ct_user ct_iod_ssn.iod_ossn.ssn_user
#define ct_srvname ct_iod_ssn.iod_ossn.ssn_srvname
#define ct_authflags ct_iod_ssn.iod_authflags
#define ct_nthash ct_iod_ssn.iod_nthash
#define ct_lmhash ct_iod_ssn.iod_lmhash
#define ct_vcflags ct_work.wk_vcflags
#define ct_ssnkey_len ct_work.wk_u_ssnkey_len
#define ct_ssnkey_buf ct_work.wk_u_ssnkey_buf.lp_ptr
#define SMBCF_NOPWD 0x0001
#define SMBCF_SRIGHTS 0x0002
#define SMBCF_LOCALE 0x0004
#define SMBCF_CMD_DOM 0x0010
#define SMBCF_CMD_USR 0x0020
#define SMBCF_CMD_PW 0x0040
#define SMBCF_RESOLVED 0x8000
#define SMBCF_KCBAD 0x00080000
#define SMBCF_KCFOUND 0x00100000
#define SMBCF_BROWSEOK 0x00200000
#define SMBCF_AUTHREQ 0x00400000
#define SMBCF_KCSAVE 0x00800000
#define SMBCF_KCDOMAIN 0x01000000
int smb_ctx_init(struct smb_ctx *);
void smb_ctx_done(struct smb_ctx *);
int smb_open_driver(void);
int nsmb_ioctl(int, int, void *);
int nsmb_close(int);
int smb_ctx_gethandle(struct smb_ctx *);
int smb_ctx_findvc(struct smb_ctx *);
int smb_ctx_newvc(struct smb_ctx *);
#define SMBIOD_RUNDIR "/var/run/smbiod"
#define SMBIOD_SVC_DOOR SMBIOD_RUNDIR "/.svc"
#define SMBIOD_USR_DOOR SMBIOD_RUNDIR "/%d"
#define SMBIOD_START 1
int smb_iod_cl_newvc(smb_ctx_t *ctx);
char *smb_iod_door_path(void);
int smb_iod_open_door(int *);
int smb_iod_connect(struct smb_ctx *);
int smb_iod_work(struct smb_ctx *);
int smb_open_rcfile(char *);
void smb_close_rcfile(void);
int smb_cf_minauth_from_str(char *);
int smb_cf_version_from_str(char *);
void smb_simplecrypt(char *dst, const char *src);
int smb_simpledecrypt(char *dst, const char *src);
int nls_setrecode(const char *, const char *);
int nls_setlocale(const char *);
char *nls_str_toext(char *, const char *);
char *nls_str_toloc(char *, const char *);
void *nls_mem_toext(void *, const void *, int);
void *nls_mem_toloc(void *, const void *, int);
char *nls_str_upper(char *, const char *);
char *nls_str_lower(char *, const char *);
char *smb_getprogname();
#define __progname smb_getprogname()
#endif