/*
* 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
* documentation and/or other materials provided with the distribution.
* 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.
*/
/*
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _PRIVATE_H
#define _PRIVATE_H
/*
* Private declarations for this library.
* Moved from smb_lib.h
*/
#include <inttypes.h>
#include <sys/byteorder.h>
#include <sys/ccompile.h>
#include <netsmb/mchain.h>
#include <netsmb/netbios.h>
extern void smbfs_dprint(const char *, const char *, ...)
__PRINTFLIKE(2);
#if defined(DEBUG) || defined(__lint)
#define DPRINT(...) smbfs_dprint(__func__, __VA_ARGS__)
#else
#define DPRINT(...) ((void)0)
#endif
/*
* Flags bits in ct_vcflags (copied from smb_conn.h)
* Pass these to the driver?
*/
#define SMBV_RECONNECTING 0x0002 /* conn in process of reconnection */
#define SMBV_LONGNAMES 0x0004 /* conn configured to use long names */
#define SMBV_ENCRYPT 0x0008 /* server demands encrypted password */
#define SMBV_WIN95 0x0010 /* used to apply bugfixes for this OS */
#define SMBV_NT4 0x0020 /* used when NT4 issues invalid resp */
#define SMBV_UNICODE 0x0040 /* conn configured to use Unicode */
#define SMBV_EXT_SEC 0x0080 /* conn to use extended security */
#define SMBV_WILL_SIGN 0x0100 /* negotiated signing */
/*
* request handling structures
*/
struct smb_rq {
struct smb_ctx *rq_ctx;
struct mbdata rq_rq;
struct mbdata rq_rp;
int rq_rpbufsz;
uint8_t rq_cmd;
uint8_t rq_hflags;
uint16_t rq_hflags2;
uint32_t rq_status;
uint16_t rq_uid;
uint16_t rq_tid;
uint16_t rq_mid;
uint32_t rq_seqno;
/* See rq_[bw]{start,end} functions */
char *rq_wcntp;
int rq_wcbase;
char *rq_bcntp;
int rq_bcbase;
};
typedef struct smb_rq smb_rq_t;
#define smbfs_rq_getrequest(rqp) (&(rqp)->rq_rq)
#define smbfs_rq_getreply(rqp) (&(rqp)->rq_rp)
int smbfs_rq_init(struct smb_ctx *, uchar_t, struct smb_rq **);
void smbfs_rq_done(struct smb_rq *);
void smbfs_rq_bstart(struct smb_rq *);
void smbfs_rq_bend(struct smb_rq *);
void smbfs_rq_wstart(struct smb_rq *);
void smbfs_rq_wend(struct smb_rq *);
int smbfs_rq_internal(struct smb_ctx *, struct smb_rq *);
int smbfs_rq_t2_request(int, int, uint16_t *, const char *,
int, void *, int, void *, int *, void *, int *, void *, int *);
void smbfs_rq_sign(struct smb_rq *);
int smbfs_rq_verify(struct smb_rq *);
/*
* This library extends the mchain.h function set a little.
*/
int smbfs_m_get(int, struct mbuf **);
int smbfs_m_lineup(struct mbuf *, struct mbuf **);
size_t smbfs_m_totlen(struct mbuf *);
void smbfs_m_freem(struct mbuf *);
int smbfs_mb_init(struct mbdata *);
void smbfs_mb_initm(struct mbdata *, struct mbuf *);
int smbfs_mb_init_sz(struct mbdata *, int);
int smbfs_mb_fit(struct mbdata *mbp, int size, char **pp);
void smbfs_mb_done(struct mbdata *);
void *smbfs_mb_reserve(mbchain_t *, int);
int smbfs_mb_put_mem(mbchain_t *, const void *, int, int);
int smbfs_mb_put_mbuf(mbchain_t *, mbuf_t *);
int smbfs_mb_put_uint8(mbchain_t *, uint8_t);
int smbfs_mb_put_uint16be(mbchain_t *, uint16_t);
int smbfs_mb_put_uint16le(mbchain_t *, uint16_t);
int smbfs_mb_put_uint32be(mbchain_t *, uint32_t);
int smbfs_mb_put_uint32le(mbchain_t *, uint32_t);
int smbfs_mb_put_uint64be(mbchain_t *, uint64_t);
int smbfs_mb_put_uint64le(mbchain_t *, uint64_t);
int smbfs_mb_put_string(struct mbdata *mbp, const char *s, int);
int smbfs_mb_put_astring(struct mbdata *mbp, const char *s);
int smbfs_md_get_mem(mdchain_t *, void *, int, int);
int smbfs_md_get_mbuf(mdchain_t *, int, mbuf_t **);
int smbfs_md_get_uint8(mdchain_t *, uint8_t *);
int smbfs_md_get_uint16be(mdchain_t *, uint16_t *);
int smbfs_md_get_uint16le(mdchain_t *, uint16_t *);
int smbfs_md_get_uint32be(mdchain_t *, uint32_t *);
int smbfs_md_get_uint32le(mdchain_t *, uint32_t *);
int smbfs_md_get_uint64be(mdchain_t *, uint64_t *);
int smbfs_md_get_uint64le(mdchain_t *, uint64_t *);
int smbfs_md_get_string(struct mbdata *, char **, int);
int smbfs_md_get_astring(struct mbdata *, char **);
int smbfs_md_get_ustring(struct mbdata *, char **);
/*
* Network stuff (NetBIOS and otherwise)
*/
struct nb_name;
struct sockaddr_nb;
extern int smb_recv_timeout; /* seconds */
void smbfs_dump_ctx(char *, struct smb_ctx *);
int smbfs_nb_ssn_request(struct smb_ctx *, char *);
int smbfs_nb_ssn_send(struct smb_ctx *, struct mbdata *);
int smbfs_nb_ssn_recv(struct smb_ctx *, struct mbdata *);
int smbfs_nb_name_encode(struct mbdata *, struct nb_name *);
int smbfs_nb_name_enc_len(const uchar_t *);
int smbfs_get_xti_err(int);
/*
* Private SMB stuff
*/
struct smb_bitname {
uint_t bn_bit;
char *bn_name;
};
typedef struct smb_bitname smb_bitname_t;
int smbfs_iod_cl_start(struct smb_ctx *);
/* SMB Negotiate API */
int smbfs_negprot(struct smb_ctx *, struct mbdata *);
/* SMB Session setup APIs */
int smbfs_ssnsetup_null(struct smb_ctx *);
int smbfs_ssnsetup_ntlm1(struct smb_ctx *);
int smbfs_ssnsetup_ntlm2(struct smb_ctx *);
int smbfs_ssnsetup_spnego(struct smb_ctx *, struct mbdata *);
int smbfs_ssnsetup(struct smb_ctx *, struct mbdata *, struct mbdata *,
uint32_t *, uint16_t *);
int smbfs_ssp_init_sec(struct smb_ctx *, struct mbdata *);
int smbfs_gss_init_sec(struct smb_ctx *, struct mbdata *);
boolean_t smbfs_gss_is_cred(struct smb_ctx *);
int smbfs_kinit(struct smb_ctx *, boolean_t);
void smbfs_time_local2NT(struct timeval *, int, uint64_t *);
int smbfs_getlocalname(char **);
int smbfs_get_authentication(struct smb_ctx *);
int smbfs_get_keychain(struct smb_ctx *);
#endif /* _PRIVATE_H */