FreeBSD/Linux Kernel Cross Reference
sys/netsmb/smb_rq.h
1 /* $NetBSD: smb_rq.h,v 1.10 2004/02/24 15:22:01 wiz Exp $ */
2
3 /*
4 * Copyright (c) 2000-2001, Boris Popov
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Boris Popov.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * FreeBSD: src/sys/netsmb/smb_rq.h,v 1.1 2001/04/10 07:59:06 bp Exp
35 */
36 #ifndef _NETSMB_SMB_RQ_H_
37 #define _NETSMB_SMB_RQ_H_
38
39 #ifndef MB_MSYSTEM
40 #include <netsmb/mchain.h>
41 #endif
42
43 #define SMBR_ALLOCED 0x0001 /* structure was malloced */
44 #define SMBR_SENT 0x0002 /* request successfully transmitted */
45 #define SMBR_REXMIT 0x0004 /* request should be retransmitted */
46 #define SMBR_INTR 0x0008 /* request interrupted */
47 #define SMBR_RESTART 0x0010 /* request should be repeated if possible */
48 #define SMBR_NORESTART 0x0020 /* request is not restartable */
49 #define SMBR_MULTIPACKET 0x0040 /* multiple packets can be sent and received */
50 #define SMBR_INTERNAL 0x0080 /* request is internal to smbrqd */
51 #define SMBR_XLOCK 0x0100 /* request locked and can't be moved */
52 #define SMBR_XLOCKWANT 0x0200 /* waiter on XLOCK */
53 #define SMBR_NOWAIT 0x0400 /* don't wait for reply */
54
55 #define SMBT2_ALLSENT 0x0001 /* all data and params are sent */
56 #define SMBT2_ALLRECV 0x0002 /* all data and params are received */
57 #define SMBT2_ALLOCED 0x0004
58 #define SMBT2_RESTART 0x0008
59 #define SMBT2_NORESTART 0x0010
60
61 #define SMBRQ_SLOCK(rqp) smb_sl_lock(&(rqp)->sr_slock)
62 #define SMBRQ_SUNLOCK(rqp) smb_sl_unlock(&(rqp)->sr_slock)
63 #define SMBRQ_SLOCKPTR(rqp) (&(rqp)->sr_slock)
64
65 /* save 16bit 'what' to memory pointed out by 'where' in little-endian format */
66 #define SMBRQ_PUTLE16(where, what) \
67 (where)[0] = (what) & 0xff; \
68 (where)[1] = (what) >> 8
69
70 enum smbrq_state {
71 SMBRQ_NOTSENT, /* rq have data to send */
72 SMBRQ_SENT, /* send procedure completed */
73 SMBRQ_REPLYRECEIVED,
74 SMBRQ_NOTIFIED /* owner notified about completion */
75 };
76
77 struct smb_vc;
78 struct smb_t2rq;
79
80 struct smb_rq {
81 enum smbrq_state sr_state;
82 struct smb_vc * sr_vc; /* session */
83 struct smb_share * sr_share;
84 struct mbchain sr_rq;
85 u_int8_t * sr_wcount;
86 u_int8_t * sr_bcount;
87 struct mdchain sr_rp;
88 u_int sr_rpgen;
89 u_int sr_rplast;
90 struct smb_cred * sr_cred;
91 u_short sr_mid;
92 u_short sr_flags; /* SMBR_* */
93 struct callout sr_timo_ch; /* for timeout expiration */
94 int sr_timo; /* timeout in ticks, -1 notimo*/
95 int sr_sendcnt;
96 int sr_lerror;
97 u_int8_t * sr_rqtid;
98 u_int8_t * sr_rquid;
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 SIMPLEQ_ENTRY(smb_rq) sr_link;
105
106 void (*sr_recvcallback)(void *);
107 void *sr_recvarg;
108 };
109
110 struct smb_t2rq {
111 u_int16_t t2_setupcount;
112 u_int16_t * t2_setupdata;
113 u_int16_t t2_setup[2]; /* most of rqs has setupcount of 1 */
114 u_int8_t t2_maxscount; /* max setup words to return */
115 u_int16_t t2_maxpcount; /* max param bytes to return */
116 u_int16_t t2_maxdcount; /* max data bytes to return */
117 u_int16_t t2_fid; /* for T2 request */
118 char * t_name; /* for T request, should be zero for T2 */
119 int t2_flags; /* SMBT2_ */
120 struct mbchain t2_tparam; /* parameters to transmit */
121 struct mbchain t2_tdata; /* data to transmit */
122 struct mdchain t2_rparam; /* received parameters */
123 struct mdchain t2_rdata; /* received data */
124 struct smb_cred*t2_cred;
125 struct smb_connobj *t2_source;
126 struct smb_rq * t2_rq;
127 struct smb_vc * t2_vc;
128 };
129
130 int smb_rqinit(void);
131
132 int smb_rq_alloc(struct smb_connobj *layer, u_char cmd,
133 struct smb_cred *scred, struct smb_rq **rqpp);
134 void smb_rq_done(struct smb_rq *rqp);
135 int smb_rq_getrequest(struct smb_rq *rqp, struct mbchain **mbpp);
136 int smb_rq_getreply(struct smb_rq *rqp, struct mdchain **mbpp);
137 void smb_rq_wstart(struct smb_rq *rqp);
138 void smb_rq_wend(struct smb_rq *rqp);
139 void smb_rq_bstart(struct smb_rq *rqp);
140 void smb_rq_bend(struct smb_rq *rqp);
141 int smb_rq_intr(struct smb_rq *rqp);
142 int smb_rq_simple(struct smb_rq *rqp);
143 int smb_rq_enqueue(struct smb_rq *rqp);
144 int smb_rq_reply(struct smb_rq *rqp);
145 void smb_rq_setcallback(struct smb_rq *, void (*)(void *), void *);
146
147 int smb_t2_alloc(struct smb_connobj *layer, u_short setup, struct smb_cred *scred,
148 struct smb_t2rq **rqpp);
149 void smb_t2_done(struct smb_t2rq *t2p);
150 int smb_t2_request(struct smb_t2rq *t2p);
151
152 #endif /* !_NETSMB_SMB_RQ_H_ */
Cache object: e85c18436c482b2d2730e30fd7a21944
|