#ifndef _NETSMB_SMB_RQ_H_
#define _NETSMB_SMB_RQ_H_
#include <netsmb/mchain.h>
#include <sys/queue.h>
#define SMBR_ALLOCED 0x0001
#define SMBR_SENT 0x0002
#define SMBR_REXMIT 0x0004
#define SMBR_INTR 0x0008
#define SMBR_RESTART 0x0010
#define SMBR_NORESTART 0x0020
#define SMBR_MULTIPACKET 0x0040
#define SMBR_INTERNAL 0x0080
#define SMBR_NOINTR_SEND 0x0100
#define SMBR_NOINTR_RECV 0x0200
#define SMBR_SENDWAIT 0x0400
#define SMBR_NORECONNECT 0x0800
#define SMBR_MOREDATA 0x8000
#define SMBR_COMPOUND_RQ 0x10000
#define SMBR_ASYNC 0x20000
#define SMBR_RECONNECTED 0x40000
#define SMBR_ENCRYPTED 0x80000
#define SMBT2_ALLSENT 0x0001
#define SMBT2_ALLRECV 0x0002
#define SMBT2_ALLOCED 0x0004
#define SMBT2_RESTART 0x0008
#define SMBT2_NORESTART 0x0010
#define SMBT2_MOREDATA 0x8000
#define SMBRQ_LOCK(rqp) mutex_enter(&(rqp)->sr_lock)
#define SMBRQ_UNLOCK(rqp) mutex_exit(&(rqp)->sr_lock)
enum smbrq_state {
SMBRQ_NOTSENT,
SMBRQ_SENT,
SMBRQ_REPLYRECEIVED,
SMBRQ_NOTIFIED
};
struct smb_vc;
struct smb_rq {
TAILQ_ENTRY(smb_rq) sr_link;
kmutex_t sr_lock;
kcondvar_t sr_cond;
enum smbrq_state sr_state;
struct smb_vc *sr_vc;
struct smb_share *sr_share;
struct _kthread *sr_owner;
uint32_t sr_seqno;
uint32_t sr_rseqno;
struct mbchain sr_rq;
uchar_t sr_cmd;
uint8_t sr_rqflags;
uint16_t sr_rqflags2;
uint16_t sr_rqtid;
uint32_t sr_pid;
uint16_t sr_rquid;
uint16_t sr_mid;
uchar_t *sr_wcount;
uchar_t *sr_bcount;
struct smb_rq *sr2_compound_next;
uint16_t sr2_command;
uint16_t sr2_totalcreditcharge;
uint16_t sr2_creditcharge;
uint16_t sr2_creditsrequested;
uint32_t sr2_rqflags;
uint32_t sr2_nextcmd;
uint64_t sr2_messageid;
uint64_t sr2_rqsessionid;
uint32_t sr2_rqtreeid;
struct mdchain sr_rp;
int sr_rpgen;
int sr_rplast;
int sr_flags;
int sr_rpsize;
struct smb_cred *sr_cred;
int sr_timo;
int sr_rexmit;
int sr_sendcnt;
struct timespec sr_timesent;
int sr_lerror;
uint8_t sr_errclass;
uint16_t sr_serror;
uint32_t sr_error;
uint8_t sr_rpflags;
uint16_t sr_rpflags2;
uint16_t sr_rptid;
uint16_t sr_rppid;
uint16_t sr_rpuid;
uint16_t sr_rpmid;
uint16_t sr2_rspcreditsgranted;
uint32_t sr2_rspflags;
uint32_t sr2_rspnextcmd;
uint32_t sr2_rsppid;
uint32_t sr2_rsptreeid;
uint64_t sr2_rspasyncid;
uint64_t sr2_rspsessionid;
};
typedef struct smb_rq smb_rq_t;
struct smb_t2rq {
kmutex_t t2_lock;
kcondvar_t t2_cond;
uint16_t t2_setupcount;
uint16_t *t2_setupdata;
uint16_t t2_setup[4];
uint8_t t2_maxscount;
uint16_t t2_maxpcount;
uint16_t t2_maxdcount;
uint16_t t2_fid;
char *t_name;
int t_name_len;
int t_name_maxlen;
int t2_flags;
struct mbchain t2_tparam;
struct mbchain t2_tdata;
struct mdchain t2_rparam;
struct mdchain t2_rdata;
struct smb_cred *t2_cred;
struct smb_connobj *t2_source;
struct smb_rq *t2_rq;
struct smb_vc *t2_vc;
struct smb_share *t2_share;
uint8_t t2_sr_errclass;
uint16_t t2_sr_serror;
uint32_t t2_sr_error;
uint16_t t2_sr_rpflags2;
};
typedef struct smb_t2rq smb_t2rq_t;
struct smb_ntrq {
kmutex_t nt_lock;
kcondvar_t nt_cond;
uint16_t nt_function;
uint8_t nt_maxscount;
uint32_t nt_maxpcount;
uint32_t nt_maxdcount;
int nt_flags;
struct mbchain nt_tsetup;
struct mbchain nt_tparam;
struct mbchain nt_tdata;
struct mdchain nt_rparam;
struct mdchain nt_rdata;
struct smb_cred *nt_cred;
struct smb_connobj *nt_source;
struct smb_rq *nt_rq;
struct smb_vc *nt_vc;
struct smb_share *nt_share;
uint32_t nt_sr_error;
uint16_t nt_sr_rpflags2;
};
typedef struct smb_ntrq smb_ntrq_t;
#define smb_rq_getrequest(RQ, MBPP) \
*(MBPP) = &(RQ)->sr_rq
#define smb_rq_getreply(RQ, MDPP) \
*(MDPP) = &(RQ)->sr_rp
void smb_rq_done(struct smb_rq *rqp);
int smb_rq_alloc(struct smb_connobj *layer, uchar_t cmd,
struct smb_cred *scred, struct smb_rq **rqpp);
int smb_rq_init(struct smb_rq *rqp, struct smb_connobj *layer,
uchar_t cmd, struct smb_cred *scred);
int smb_rq_getenv(struct smb_connobj *layer,
struct smb_vc **vcpp, struct smb_share **sspp);
void smb_rq_fillhdr(struct smb_rq *rqp);
void smb_rq_wstart(struct smb_rq *rqp);
void smb_rq_wend(struct smb_rq *rqp);
void smb_rq_bstart(struct smb_rq *rqp);
void smb_rq_bend(struct smb_rq *rqp);
int smb_rq_simple(struct smb_rq *rqp);
int smb_rq_simple_timed(struct smb_rq *rqp, int timeout);
int smb_rq_internal(struct smb_rq *rqp, int timeout);
int smb2_parse_smb1nego_resp(struct smb_rq *rqp);
int smb_t2_alloc(struct smb_connobj *layer, ushort_t setup,
struct smb_cred *scred, struct smb_t2rq **rqpp);
int smb_t2_init(struct smb_t2rq *rqp, struct smb_connobj *layer,
ushort_t *setup, int setupcnt, struct smb_cred *scred);
void smb_t2_done(struct smb_t2rq *t2p);
int smb_t2_request(struct smb_t2rq *t2p);
int smb_t2_xnp(struct smb_share *ssp, uint16_t fid,
struct mbchain *send_mb, struct mdchain *recv_md,
uint32_t *data_out_sz, uint32_t *more, struct smb_cred *scrp);
int smb_nt_alloc(struct smb_connobj *layer, ushort_t fn,
struct smb_cred *scred, struct smb_ntrq **rqpp);
int smb_nt_init(struct smb_ntrq *rqp, struct smb_connobj *layer,
ushort_t fn, struct smb_cred *scred);
void smb_nt_done(struct smb_ntrq *ntp);
int smb_nt_request(struct smb_ntrq *ntp);
#endif