2N/A/*
2N/A * Copyright (c) 2000-2001 Boris Popov
2N/A * All rights reserved.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions
2N/A * are met:
2N/A * 1. Redistributions of source code must retain the above copyright
2N/A * notice, this list of conditions and the following disclaimer.
2N/A * 2. Redistributions in binary form must reproduce the above copyright
2N/A * notice, this list of conditions and the following disclaimer in the
2N/A * documentation and/or other materials provided with the distribution.
2N/A * 3. All advertising materials mentioning features or use of this software
2N/A * must display the following acknowledgement:
2N/A * This product includes software developed by Boris Popov.
2N/A * 4. Neither the name of the author nor the names of any co-contributors
2N/A * may be used to endorse or promote products derived from this software
2N/A * without specific prior written permission.
2N/A *
2N/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2N/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2N/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2N/A * SUCH DAMAGE.
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _PRIVATE_H
2N/A#define _PRIVATE_H
2N/A
2N/A/*
2N/A * Private declarations for this library.
2N/A * Moved from smb_lib.h
2N/A */
2N/A
2N/A#include <inttypes.h>
2N/A#include <sys/byteorder.h>
2N/A#include <sys/ccompile.h>
2N/A
2N/A#include <netsmb/mchain.h>
2N/A#include <netsmb/netbios.h>
2N/A
2N/Aextern void smbfs_dprint(const char *, const char *, ...)
2N/A __PRINTFLIKE(2);
2N/A
2N/A#if defined(DEBUG) || defined(__lint)
2N/A#define DPRINT(...) smbfs_dprint(__func__, __VA_ARGS__)
2N/A#else
2N/A#define DPRINT(...) ((void)0)
2N/A#endif
2N/A
2N/A/*
2N/A * Flags bits in ct_vcflags (copied from smb_conn.h)
2N/A * Pass these to the driver?
2N/A */
2N/A#define SMBV_RECONNECTING 0x0002 /* conn in process of reconnection */
2N/A#define SMBV_LONGNAMES 0x0004 /* conn configured to use long names */
2N/A#define SMBV_ENCRYPT 0x0008 /* server demands encrypted password */
2N/A#define SMBV_WIN95 0x0010 /* used to apply bugfixes for this OS */
2N/A#define SMBV_NT4 0x0020 /* used when NT4 issues invalid resp */
2N/A#define SMBV_UNICODE 0x0040 /* conn configured to use Unicode */
2N/A#define SMBV_EXT_SEC 0x0080 /* conn to use extended security */
2N/A#define SMBV_WILL_SIGN 0x0100 /* negotiated signing */
2N/A
2N/A/*
2N/A * request handling structures
2N/A */
2N/Astruct smb_rq {
2N/A struct smb_ctx *rq_ctx;
2N/A struct mbdata rq_rq;
2N/A struct mbdata rq_rp;
2N/A int rq_rpbufsz;
2N/A uint8_t rq_cmd;
2N/A uint8_t rq_hflags;
2N/A uint16_t rq_hflags2;
2N/A uint32_t rq_status;
2N/A uint16_t rq_uid;
2N/A uint16_t rq_tid;
2N/A uint16_t rq_mid;
2N/A uint32_t rq_seqno;
2N/A /* See rq_[bw]{start,end} functions */
2N/A char *rq_wcntp;
2N/A int rq_wcbase;
2N/A char *rq_bcntp;
2N/A int rq_bcbase;
2N/A};
2N/Atypedef struct smb_rq smb_rq_t;
2N/A
2N/A#define smbfs_rq_getrequest(rqp) (&(rqp)->rq_rq)
2N/A#define smbfs_rq_getreply(rqp) (&(rqp)->rq_rp)
2N/A
2N/Aint smbfs_rq_init(struct smb_ctx *, uchar_t, struct smb_rq **);
2N/Avoid smbfs_rq_done(struct smb_rq *);
2N/Avoid smbfs_rq_bstart(struct smb_rq *);
2N/Avoid smbfs_rq_bend(struct smb_rq *);
2N/Avoid smbfs_rq_wstart(struct smb_rq *);
2N/Avoid smbfs_rq_wend(struct smb_rq *);
2N/Aint smbfs_rq_internal(struct smb_ctx *, struct smb_rq *);
2N/Aint smbfs_rq_t2_request(int, int, uint16_t *, const char *,
2N/A int, void *, int, void *, int *, void *, int *, void *, int *);
2N/A
2N/Avoid smbfs_rq_sign(struct smb_rq *);
2N/Aint smbfs_rq_verify(struct smb_rq *);
2N/A
2N/A/*
2N/A * This library extends the mchain.h function set a little.
2N/A */
2N/Aint smbfs_m_get(int, struct mbuf **);
2N/Aint smbfs_m_lineup(struct mbuf *, struct mbuf **);
2N/Asize_t smbfs_m_totlen(struct mbuf *);
2N/Avoid smbfs_m_freem(struct mbuf *);
2N/A
2N/Aint smbfs_mb_init(struct mbdata *);
2N/Avoid smbfs_mb_initm(struct mbdata *, struct mbuf *);
2N/Aint smbfs_mb_init_sz(struct mbdata *, int);
2N/Aint smbfs_mb_fit(struct mbdata *mbp, int size, char **pp);
2N/Avoid smbfs_mb_done(struct mbdata *);
2N/Avoid *smbfs_mb_reserve(mbchain_t *, int);
2N/A
2N/Aint smbfs_mb_put_mem(mbchain_t *, const void *, int, int);
2N/Aint smbfs_mb_put_mbuf(mbchain_t *, mbuf_t *);
2N/Aint smbfs_mb_put_uint8(mbchain_t *, uint8_t);
2N/Aint smbfs_mb_put_uint16be(mbchain_t *, uint16_t);
2N/Aint smbfs_mb_put_uint16le(mbchain_t *, uint16_t);
2N/Aint smbfs_mb_put_uint32be(mbchain_t *, uint32_t);
2N/Aint smbfs_mb_put_uint32le(mbchain_t *, uint32_t);
2N/Aint smbfs_mb_put_uint64be(mbchain_t *, uint64_t);
2N/Aint smbfs_mb_put_uint64le(mbchain_t *, uint64_t);
2N/A
2N/Aint smbfs_mb_put_string(struct mbdata *mbp, const char *s, int);
2N/Aint smbfs_mb_put_astring(struct mbdata *mbp, const char *s);
2N/A
2N/Aint smbfs_md_get_mem(mdchain_t *, void *, int, int);
2N/Aint smbfs_md_get_mbuf(mdchain_t *, int, mbuf_t **);
2N/A
2N/Aint smbfs_md_get_uint8(mdchain_t *, uint8_t *);
2N/Aint smbfs_md_get_uint16be(mdchain_t *, uint16_t *);
2N/Aint smbfs_md_get_uint16le(mdchain_t *, uint16_t *);
2N/Aint smbfs_md_get_uint32be(mdchain_t *, uint32_t *);
2N/Aint smbfs_md_get_uint32le(mdchain_t *, uint32_t *);
2N/Aint smbfs_md_get_uint64be(mdchain_t *, uint64_t *);
2N/Aint smbfs_md_get_uint64le(mdchain_t *, uint64_t *);
2N/A
2N/Aint smbfs_md_get_string(struct mbdata *, char **, int);
2N/Aint smbfs_md_get_astring(struct mbdata *, char **);
2N/Aint smbfs_md_get_ustring(struct mbdata *, char **);
2N/A
2N/A/*
2N/A * Network stuff (NetBIOS and otherwise)
2N/A */
2N/Astruct nb_name;
2N/Astruct sockaddr_nb;
2N/A
2N/Aextern int smb_recv_timeout; /* seconds */
2N/A
2N/Avoid smbfs_dump_ctx(char *, struct smb_ctx *);
2N/A
2N/Aint smbfs_nb_ssn_request(struct smb_ctx *, char *);
2N/Aint smbfs_nb_ssn_send(struct smb_ctx *, struct mbdata *);
2N/Aint smbfs_nb_ssn_recv(struct smb_ctx *, struct mbdata *);
2N/A
2N/Aint smbfs_nb_name_encode(struct mbdata *, struct nb_name *);
2N/Aint smbfs_nb_name_enc_len(const uchar_t *);
2N/A
2N/Aint smbfs_get_xti_err(int);
2N/A
2N/A/*
2N/A * Private SMB stuff
2N/A */
2N/A
2N/Astruct smb_bitname {
2N/A uint_t bn_bit;
2N/A char *bn_name;
2N/A};
2N/Atypedef struct smb_bitname smb_bitname_t;
2N/A
2N/Aint smbfs_iod_cl_start(struct smb_ctx *);
2N/A
2N/A/* SMB Negotiate API */
2N/Aint smbfs_negprot(struct smb_ctx *, struct mbdata *);
2N/A
2N/A/* SMB Session setup APIs */
2N/Aint smbfs_ssnsetup_null(struct smb_ctx *);
2N/Aint smbfs_ssnsetup_ntlm1(struct smb_ctx *);
2N/Aint smbfs_ssnsetup_ntlm2(struct smb_ctx *);
2N/Aint smbfs_ssnsetup_spnego(struct smb_ctx *, struct mbdata *);
2N/Aint smbfs_ssnsetup(struct smb_ctx *, struct mbdata *, struct mbdata *,
2N/A uint32_t *, uint16_t *);
2N/Aint smbfs_ssp_init_sec(struct smb_ctx *, struct mbdata *);
2N/Aint smbfs_gss_init_sec(struct smb_ctx *, struct mbdata *);
2N/Aboolean_t smbfs_gss_is_cred(struct smb_ctx *);
2N/Aint smbfs_kinit(struct smb_ctx *, boolean_t);
2N/A
2N/Avoid smbfs_time_local2NT(struct timeval *, int, uint64_t *);
2N/A
2N/Aint smbfs_getlocalname(char **);
2N/Aint smbfs_get_authentication(struct smb_ctx *);
2N/Aint smbfs_get_keychain(struct smb_ctx *);
2N/A
2N/A#endif /* _PRIVATE_H */