4bff34e37def8a90f9194d81bc345c52ba20086athurlow/*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Copyright (c) 2000-2001, Boris Popov
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * All rights reserved.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Redistribution and use in source and binary forms, with or without
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * modification, are permitted provided that the following conditions
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * are met:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 1. Redistributions of source code must retain the above copyright
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * notice, this list of conditions and the following disclaimer.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 2. Redistributions in binary form must reproduce the above copyright
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * notice, this list of conditions and the following disclaimer in the
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * documentation and/or other materials provided with the distribution.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 3. All advertising materials mentioning features or use of this software
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * must display the following acknowledgement:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * This product includes software developed by Boris Popov.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * 4. Neither the name of the author nor the names of any co-contributors
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * may be used to endorse or promote products derived from this software
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * without specific prior written permission.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * SUCH DAMAGE.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * $Id: smb_rq.h,v 1.9 2005/01/22 22:20:58 lindak Exp $
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross/*
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifndef _NETSMB_SMB_RQ_H_
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define _NETSMB_SMB_RQ_H_
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <netsmb/mchain.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <sys/queue.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_ALLOCED 0x0001 /* structure was malloced */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_SENT 0x0002 /* request successfully transmitted */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_REXMIT 0x0004 /* request should be retransmitted */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_INTR 0x0008 /* request interrupted */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_RESTART 0x0010 /* req should be repeated if possible */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_NORESTART 0x0020 /* request is not restartable */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_MULTIPACKET 0x0040 /* multiple pkts can be sent/received */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross#define SMBR_INTERNAL 0x0080 /* request enqueued by the IOD! */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_NOINTR_SEND 0x0100 /* no interrupt in send wait */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_NOINTR_RECV 0x0200 /* no interrupt in recv wait */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_SENDWAIT 0x0400 /* waiting for send to complete */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross#define SMBR_NORECONNECT 0x0800 /* do not reconnect for this */
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross/* SMBR_VCREF 0x4000 * took vc reference (obsolete) */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBR_MOREDATA 0x8000 /* our buffer was too small */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBT2_ALLSENT 0x0001 /* all data and params are sent */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBT2_ALLRECV 0x0002 /* all data and params are received */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBT2_ALLOCED 0x0004
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBT2_RESTART 0x0008
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBT2_NORESTART 0x0010
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBT2_MOREDATA 0x8000 /* our buffer was too small */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBRQ_LOCK(rqp) mutex_enter(&(rqp)->sr_lock)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#define SMBRQ_UNLOCK(rqp) mutex_exit(&(rqp)->sr_lock)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowenum smbrq_state {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow SMBRQ_NOTSENT, /* rq have data to send */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow SMBRQ_SENT, /* send procedure completed */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow SMBRQ_REPLYRECEIVED,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow SMBRQ_NOTIFIED /* owner notified about completion */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow};
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstruct smb_vc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstruct smb_rq {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow TAILQ_ENTRY(smb_rq) sr_link;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow kmutex_t sr_lock;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow kcondvar_t sr_cond;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow enum smbrq_state sr_state;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_vc *sr_vc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_share *sr_share;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct _kthread *sr_owner;
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross uint32_t sr_seqno; /* Seq. no. of request */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross uint32_t sr_rseqno; /* Seq. no. of reply */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mbchain sr_rq;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uchar_t sr_cmd;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint8_t sr_rqflags;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sr_rqflags2;
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross uint16_t sr_rqtid;
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross uint16_t sr_pid;
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross uint16_t sr_rquid;
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross uint16_t sr_mid;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uchar_t *sr_wcount;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uchar_t *sr_bcount;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mdchain sr_rp;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_rpgen;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_rplast;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_flags; /* SMBR_* */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_rpsize;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_cred *sr_cred;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_timo;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_rexmit; /* how many more retries. dflt 0 */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_sendcnt;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct timespec sr_timesent;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int sr_lerror;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint8_t sr_errclass;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sr_serror;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint32_t sr_error;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint8_t sr_rpflags;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sr_rpflags2;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sr_rptid;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sr_rppid;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sr_rpuid;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t sr_rpmid;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow};
4bff34e37def8a90f9194d81bc345c52ba20086athurlowtypedef struct smb_rq smb_rq_t;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstruct smb_t2rq {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow kmutex_t t2_lock;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow kcondvar_t t2_cond;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t t2_setupcount;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t *t2_setupdata;
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross uint16_t t2_setup[SMBIOC_T2RQ_MAXSETUP];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint8_t t2_maxscount; /* max setup words to return */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t t2_maxpcount; /* max param bytes to return */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t t2_maxdcount; /* max data bytes to return */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t t2_fid; /* for T2 request */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross char *t_name; /* for T, must be NULL for T2 */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross int t_name_len; /* t_name string length */
9c9af2590af49bb395bc8d2eace0f2d4ea16d165Gordon Ross int t_name_maxlen; /* t_name allocated size */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int t2_flags; /* SMBT2_ */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mbchain t2_tparam; /* parameters to transmit */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mbchain t2_tdata; /* data to transmit */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mdchain t2_rparam; /* received paramters */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mdchain t2_rdata; /* received data */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_cred *t2_cred;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_connobj *t2_source;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_rq *t2_rq;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_vc *t2_vc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_share *t2_share; /* for smb up/down */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* unmapped windows error detail */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint8_t t2_sr_errclass;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t t2_sr_serror;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint32_t t2_sr_error;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t t2_sr_rpflags2;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow};
4bff34e37def8a90f9194d81bc345c52ba20086athurlowtypedef struct smb_t2rq smb_t2rq_t;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstruct smb_ntrq {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow kmutex_t nt_lock;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow kcondvar_t nt_cond;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t nt_function;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint8_t nt_maxscount; /* max setup words to return */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint32_t nt_maxpcount; /* max param bytes to return */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint32_t nt_maxdcount; /* max data bytes to return */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int nt_flags; /* SMBT2_ */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mbchain nt_tsetup; /* setup to transmit */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mbchain nt_tparam; /* parameters to transmit */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mbchain nt_tdata; /* data to transmit */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mdchain nt_rparam; /* received paramters */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct mdchain nt_rdata; /* received data */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_cred *nt_cred;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_connobj *nt_source;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_rq *nt_rq;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_vc *nt_vc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_share *nt_share; /* for smb up/down */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* unmapped windows error details */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint32_t nt_sr_error;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uint16_t nt_sr_rpflags2;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow};
4bff34e37def8a90f9194d81bc345c52ba20086athurlowtypedef struct smb_ntrq smb_ntrq_t;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross#define smb_rq_getrequest(RQ, MBPP) \
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross *(MBPP) = &(RQ)->sr_rq
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross#define smb_rq_getreply(RQ, MDPP) \
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross *(MDPP) = &(RQ)->sr_rp
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossvoid smb_rq_done(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_rq_alloc(struct smb_connobj *layer, uchar_t cmd,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_cred *scred, struct smb_rq **rqpp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_rq_init(struct smb_rq *rqp, struct smb_connobj *layer,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow uchar_t cmd, struct smb_cred *scred);
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Ross
613a2f6ba31e891e3d947a356daf5e563d43c1ceGordon Rossvoid smb_rq_fillhdr(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowvoid smb_rq_wstart(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowvoid smb_rq_wend(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowvoid smb_rq_bstart(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowvoid smb_rq_bend(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_rq_intr(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_rq_simple(struct smb_rq *rqp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_rq_simple_timed(struct smb_rq *rqp, int timeout);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_t2_alloc(struct smb_connobj *layer, ushort_t setup,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_cred *scred, struct smb_t2rq **rqpp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_t2_init(struct smb_t2rq *rqp, struct smb_connobj *layer,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow ushort_t *setup, int setupcnt, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowvoid smb_t2_done(struct smb_t2rq *t2p);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_t2_request(struct smb_t2rq *t2p);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_nt_alloc(struct smb_connobj *layer, ushort_t fn,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow struct smb_cred *scred, struct smb_ntrq **rqpp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_nt_init(struct smb_ntrq *rqp, struct smb_connobj *layer,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow ushort_t fn, struct smb_cred *scred);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowvoid smb_nt_done(struct smb_ntrq *ntp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint smb_nt_request(struct smb_ntrq *ntp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* _NETSMB_SMB_RQ_H_ */