]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/netsmb/smb_rq.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / netsmb / smb_rq.h
1 /*-
2  * Copyright (c) 2000-2001 Boris Popov
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 #ifndef _NETSMB_SMB_RQ_H_
29 #define _NETSMB_SMB_RQ_H_
30
31 #ifndef MB_MSYSTEM
32 #include <sys/mchain.h>
33 #endif
34
35 #define SMBR_ALLOCED            0x0001  /* structure was malloced */
36 #define SMBR_SENT               0x0002  /* request successfully transmitted */
37 #define SMBR_REXMIT             0x0004  /* request should be retransmitted */
38 #define SMBR_INTR               0x0008  /* request interrupted */
39 #define SMBR_RESTART            0x0010  /* request should be repeated if possible */
40 #define SMBR_NORESTART          0x0020  /* request is not restartable */
41 #define SMBR_MULTIPACKET        0x0040  /* multiple packets can be sent and received */
42 #define SMBR_INTERNAL           0x0080  /* request is internal to smbrqd */
43 #define SMBR_XLOCK              0x0100  /* request locked and can't be moved */
44 #define SMBR_XLOCKWANT          0x0200  /* waiter on XLOCK */
45
46 #define SMBT2_ALLSENT           0x0001  /* all data and params are sent */
47 #define SMBT2_ALLRECV           0x0002  /* all data and params are received */
48 #define SMBT2_ALLOCED           0x0004
49 #define SMBT2_RESTART           0x0008
50 #define SMBT2_NORESTART         0x0010
51 #define SMBT2_SECONDARY         0x0020  /* secondary request */
52
53 #define SMBRQ_SLOCK(rqp)        smb_sl_lock(&(rqp)->sr_slock)
54 #define SMBRQ_SUNLOCK(rqp)      smb_sl_unlock(&(rqp)->sr_slock)
55 #define SMBRQ_SLOCKPTR(rqp)     (&(rqp)->sr_slock)
56
57
58 enum smbrq_state {
59         SMBRQ_NOTSENT,          /* rq have data to send */
60         SMBRQ_SENT,             /* send procedure completed */
61         SMBRQ_REPLYRECEIVED,
62         SMBRQ_NOTIFIED          /* owner notified about completion */
63 };
64
65 struct smb_vc;
66 struct smb_t2rq;
67
68 struct smb_rq {
69         enum smbrq_state        sr_state;
70         struct smb_vc *         sr_vc;
71         struct smb_share*       sr_share;
72         u_short                 sr_mid;
73         u_int32_t               sr_seqno;
74         u_int32_t               sr_rseqno;
75         struct mbchain          sr_rq;
76         u_int8_t                sr_rqflags;
77         u_int16_t               sr_rqflags2;
78         u_char *                sr_wcount;
79         void *                  sr_bcount;      /* Points to 2-byte buffer. */
80         struct mdchain          sr_rp;
81         int                     sr_rpgen;
82         int                     sr_rplast;
83         int                     sr_flags;       /* SMBR_* */
84         int                     sr_rpsize;
85         struct smb_cred *       sr_cred;
86         int                     sr_timo;
87         int                     sr_rexmit;
88         int                     sr_sendcnt;
89         struct timespec         sr_timesent;
90         int                     sr_lerror;
91         u_int8_t *              sr_rqsig;
92         void *                  sr_rqtid;       /* Points to 2-byte buffer. */
93         void *                  sr_rquid;       /* Points to 2-byte buffer. */
94         u_int8_t                sr_errclass;
95         u_int16_t               sr_serror;
96         u_int32_t               sr_error;
97         u_int8_t                sr_rpflags;
98         u_int16_t               sr_rpflags2;
99         u_int16_t               sr_rptid;
100         u_int16_t               sr_rppid;
101         u_int16_t               sr_rpuid;
102         u_int16_t               sr_rpmid;
103         struct smb_slock        sr_slock;       /* short term locks */
104         struct smb_t2rq *       sr_t2;
105         TAILQ_ENTRY(smb_rq)     sr_link;
106 };
107
108 struct smb_t2rq {
109         u_int16_t       t2_setupcount;
110         u_int16_t *     t2_setupdata;
111         u_int16_t       t2_setup[2];    /* most of rqs has setupcount of 1 */
112         u_int8_t        t2_maxscount;   /* max setup words to return */
113         u_int16_t       t2_maxpcount;   /* max param bytes to return */
114         u_int16_t       t2_maxdcount;   /* max data bytes to return */
115         u_int16_t       t2_fid;         /* for T2 request */
116         char *          t_name;         /* for T request, should be zero for T2 */
117         int             t2_flags;       /* SMBT2_ */
118         struct mbchain  t2_tparam;      /* parameters to transmit */
119         struct mbchain  t2_tdata;       /* data to transmit */
120         struct mdchain  t2_rparam;      /* received parameters */
121         struct mdchain  t2_rdata;       /* received data */
122         struct smb_cred*t2_cred;
123         struct smb_connobj *t2_source;
124         struct smb_rq * t2_rq;
125         struct smb_vc * t2_vc;
126 };
127
128 int  smb_rq_alloc(struct smb_connobj *layer, u_char cmd,
129         struct smb_cred *scred, struct smb_rq **rqpp);
130 int  smb_rq_init(struct smb_rq *rqp, struct smb_connobj *layer, u_char cmd,
131         struct smb_cred *scred);
132 void smb_rq_done(struct smb_rq *rqp);
133 int  smb_rq_getrequest(struct smb_rq *rqp, struct mbchain **mbpp);
134 int  smb_rq_getreply(struct smb_rq *rqp, struct mdchain **mbpp);
135 void smb_rq_wstart(struct smb_rq *rqp);
136 void smb_rq_wend(struct smb_rq *rqp);
137 void smb_rq_bstart(struct smb_rq *rqp);
138 void smb_rq_bend(struct smb_rq *rqp);
139 int  smb_rq_intr(struct smb_rq *rqp);
140 int  smb_rq_simple(struct smb_rq *rqp);
141
142 int  smb_t2_alloc(struct smb_connobj *layer, u_short setup, struct smb_cred *scred,
143         struct smb_t2rq **rqpp);
144 int  smb_t2_init(struct smb_t2rq *rqp, struct smb_connobj *layer, u_short setup,
145         struct smb_cred *scred);
146 void smb_t2_done(struct smb_t2rq *t2p);
147 int  smb_t2_request(struct smb_t2rq *t2p);
148
149 #endif /* !_NETSMB_SMB_RQ_H_ */