smbfs_lib.h revision 2
/*
* 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_lib.h,v 1.21.82.2 2005/06/02 00:55:39 lindak Exp $
*/
/*
*/
#ifndef _NETSMB_SMB_LIB_H_
#define _NETSMB_SMB_LIB_H_
/*
* Internal interface exported to our commands in:
*/
#include <sys/byteorder.h>
#include <paths.h>
#include <libnvpair.h>
#include <netsmb/libsmbfs.h>
/*
* bits to indicate the source of error
*/
#define SMB_ERRTYPE_MASK 0xf0000
#define SMB_SYS_ERROR 0x00000
#define SMB_RAP_ERROR 0x10000
#define SMB_NB_ERROR 0x20000
/*
* The driver needs to know this, so it's
* defined by smb_dev.h
*/
#define NTLM_HASH_SZ SMBIOC_HASH_SZ
/*
* This is what goes across the door call to the IOD
* when asking for a new connection.
*
* iod_ntstatus can be set to either NT_STATUS_UNSUCCESSFUL (for
* internal errors) or NT status returned by remote server upon
* SmbSessionSetup failure.
* Other fields are used for encoding the SmbSessionSetup request.
*/
struct smb_iod_ssn {
struct smbioc_ossn iod_ossn;
int iod_authflags; /* SMB_AT_x */
char iod_realm[SMBIOC_MAX_NAME];
/* Kerberos cred. cache res. name? */
};
typedef struct smb_iod_ssn smb_iod_ssn_t;
/*
* This is the return values of the door call to the IOD
* when asking for a new connection.
*/
typedef struct smb_iod_ssn_retval
{
int r_err; /* errno or user-defined error */
/*
* SMB work context. Used to store all values which are necessary
* to establish connection to an SMB server.
*/
struct smb_ctx {
int ct_flags; /* SMBCF_ */
int ct_dev_fd; /* device handle */
int ct_door_fd; /* to smbiod */
int ct_parsedlevel;
int ct_minlevel;
int ct_maxlevel;
char *ct_fullserver; /* orig. server name from cmd line */
char *ct_srvaddr_s; /* hostname or IP address of server */
char *ct_locname; /* local (machine) name */
/* smbioc_oshare_t ct_sh; XXX */
int ct_shtype_req; /* share type wanted */
char *ct_origshare;
char *ct_rpath; /* remote file name */
/* Connection setup SMB stuff. */
/* Strings from the SMB negotiate response. */
char *ct_srv_OS;
char *ct_srv_LM;
/* NTLM auth. stuff */
char ct_password[SMBIOC_MAX_NAME];
/* See ssp.c */
void *ct_ssp_ctx;
};
/*
* Short-hand for some of the substruct fields above
*/
/*
* Bits in smb_ctx_t.ct_flags
*/
typedef struct smbfs_passwd {
/*
* Context management
*/
int smbfs_ctx_init(struct smb_ctx *);
void smbfs_ctx_done(struct smb_ctx *);
int smbfs_open_driver(void);
int smbfs_ctx_gethandle(struct smb_ctx *);
int smbfs_ctx_findvc(struct smb_ctx *);
int smbfs_ctx_newvc(struct smb_ctx *);
/*
* I/O daemon stuff
*/
#define SMBIOD_PWDFILE "/var/smb/smbfspasswd"
#define SMBIOD_START 1
#define SMBIOD_PWDFILE_ADD 2
#define SMBIOD_PWDFILE_DEL 3
#define SMBIOD_PWDFILE_DELALL 4
char *smbfs_iod_door_path(void);
int smbfs_iod_open_door(int *);
int smbfs_iod_connect(struct smb_ctx *);
int smbfs_iod_work(struct smb_ctx *);
int smbfs_iod_start(void);
int smbfs_iod_pwdadd(smbfs_passwd_t *);
int smbfs_iod_pwddel(smbfs_passwd_t *);
int smbfs_pwd_add(smbfs_passwd_t *);
int smbfs_pwd_loadkeychain(void);
/* SMBFS client credential cache functions */
#define SMBFS_CCACHE_PREFIX "ccache"
typedef enum {
SMBFS_CCACHE_CLNT_DEFAULT = 0, /* /tmp/krbrcc_<uid> */
SMBFS_CCACHE_CLNT_SMBFS, /* /var/run/smbiod/ccache */
typedef enum {
SMBFS_CCACHE_SRV_USER, /* /var/run/smb/user_ccache */
/*
* Other stuff
*/
char *smbfs_nls_str_upper(char *, const char *);
#endif /* _NETSMB_SMB_LIB_H_ */