xref: /reactos/base/services/nfsd/nfs41_callback.h (revision c2c66aff)
1 /* NFSv4.1 client for Windows
2  * Copyright � 2012 The Regents of the University of Michigan
3  *
4  * Olga Kornievskaia <aglo@umich.edu>
5  * Casey Bodley <cbodley@umich.edu>
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * without any warranty; without even the implied warranty of merchantability
14  * or fitness for a particular purpose.  See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  */
21 
22 #ifndef __NFS41_CALLBACK_H__
23 #define __NFS41_CALLBACK_H__
24 
25 #include "wintirpc.h"
26 #include "rpc/rpc.h"
27 #include "nfs41_types.h"
28 
29 
30 enum nfs41_callback_proc {
31     CB_NULL                 = 0,
32     CB_COMPOUND             = 1,
33 };
34 
35 enum nfs41_callback_op {
36     OP_CB_GETATTR           = 3,
37     OP_CB_RECALL            = 4,
38     OP_CB_LAYOUTRECALL      = 5,
39     OP_CB_NOTIFY            = 6,
40     OP_CB_PUSH_DELEG        = 7,
41     OP_CB_RECALL_ANY        = 8,
42     OP_CB_RECALLABLE_OBJ_AVAIL = 9,
43     OP_CB_RECALL_SLOT       = 10,
44     OP_CB_SEQUENCE          = 11,
45     OP_CB_WANTS_CANCELLED   = 12,
46     OP_CB_NOTIFY_LOCK       = 13,
47     OP_CB_NOTIFY_DEVICEID   = 14,
48     OP_CB_ILLEGAL           = 10044
49 };
50 
51 int nfs41_handle_callback(void *, void *, void *);
52 
53 /* OP_CB_LAYOUTRECALL */
54 struct cb_recall_file {
55     nfs41_fh                fh;
56     uint64_t                offset;
57     uint64_t                length;
58     stateid4                stateid;
59 };
60 union cb_recall_file_args {
61     struct cb_recall_file   file;
62     nfs41_fsid              fsid;
63 };
64 struct cb_recall {
65 #ifdef __REACTOS__
66     uint32_t type;
67 #else
68     enum pnfs_return_type   type;
69 #endif
70     union cb_recall_file_args args;
71 };
72 struct cb_layoutrecall_args {
73 #ifdef __REACTOS__
74     uint32_t type;
75     uint32_t iomode;
76 #else
77     enum pnfs_return_type   type;
78     enum pnfs_iomode        iomode;
79 #endif
80     bool_t                  changed;
81     struct cb_recall        recall;
82 };
83 
84 struct cb_layoutrecall_res {
85     enum_t                  status;
86 };
87 
88 /* OP_CB_RECALL_SLOT */
89 struct cb_recall_slot_args {
90     uint32_t                target_highest_slotid;
91 };
92 
93 struct cb_recall_slot_res {
94     enum_t                  status;
95 };
96 
97 /* OP_CB_SEQUENCE */
98 struct cb_sequence_ref {
99     uint32_t                sequenceid;
100     uint32_t                slotid;
101 };
102 struct cb_sequence_ref_list {
103     char                    sessionid[NFS4_SESSIONID_SIZE];
104     struct cb_sequence_ref  *calls;
105     uint32_t                call_count;
106 };
107 struct cb_sequence_args {
108     char                    sessionid[NFS4_SESSIONID_SIZE];
109     uint32_t                sequenceid;
110     uint32_t                slotid;
111     uint32_t                highest_slotid;
112     bool_t                  cachethis;
113     struct cb_sequence_ref_list *ref_lists;
114     uint32_t                ref_list_count;
115 };
116 
117 struct cb_sequence_res_ok {
118     char                    sessionid[NFS4_SESSIONID_SIZE];
119     uint32_t                sequenceid;
120     uint32_t                slotid;
121     uint32_t                highest_slotid;
122     uint32_t                target_highest_slotid;
123 };
124 struct cb_sequence_res {
125     enum_t                  status;
126     struct cb_sequence_res_ok ok;
127 };
128 
129 /* OP_CB_GETATTR */
130 struct cb_getattr_args {
131     nfs41_fh                fh;
132     bitmap4                 attr_request;
133 };
134 
135 struct cb_getattr_res {
136     enum_t                  status;
137     nfs41_file_info         info;
138 };
139 
140 /* OP_CB_RECALL */
141 struct cb_recall_args {
142     stateid4                stateid;
143     bool_t                  truncate;
144     nfs41_fh                fh;
145 };
146 
147 struct cb_recall_res {
148     enum_t                  status;
149 };
150 
151 /* OP_CB_NOTIFY */
152 struct cb_notify_args {
153     uint32_t                target_highest_slotid;
154 };
155 
156 struct cb_notify_res {
157     enum_t                  status;
158 };
159 
160 /* OP_CB_PUSH_DELEG */
161 struct cb_push_deleg_args {
162     uint32_t                target_highest_slotid;
163 };
164 
165 struct cb_push_deleg_res {
166     enum_t                  status;
167 };
168 
169 /* OP_CB_RECALL_ANY */
170 struct cb_recall_any_args {
171     uint32_t                target_highest_slotid;
172 };
173 
174 struct cb_recall_any_res {
175     enum_t                  status;
176 };
177 
178 /* OP_CB_RECALLABLE_OBJ_AVAIL */
179 struct cb_recallable_obj_avail_args {
180     uint32_t                target_highest_slotid;
181 };
182 
183 struct cb_recallable_obj_avail_res {
184     enum_t                  status;
185 };
186 
187 /* OP_CB_WANTS_CANCELLED */
188 struct cb_wants_cancelled_args {
189     uint32_t                target_highest_slotid;
190 };
191 
192 struct cb_wants_cancelled_res {
193     enum_t                  status;
194 };
195 
196 /* OP_CB_NOTIFY_LOCK */
197 struct cb_notify_lock_args {
198     uint32_t                target_highest_slotid;
199 };
200 
201 struct cb_notify_lock_res {
202     enum_t                  status;
203 };
204 
205 /* OP_CB_NOTIFY_DEVICEID */
206 enum notify_deviceid_type4 {
207     NOTIFY_DEVICEID4_CHANGE = 1,
208     NOTIFY_DEVICEID4_DELETE = 2
209 };
210 struct notify_deviceid4 {
211     unsigned char           deviceid[16];
212     enum notify_deviceid_type4 type;
213 #ifdef __REACTOS__
214     uint32_t layouttype;
215 #else
216     enum pnfs_layout_type   layouttype;
217 #endif
218     bool_t                  immediate;
219 };
220 struct notify4 {
221     bitmap4                 mask;
222     char                    *list;
223     uint32_t                len;
224 };
225 struct cb_notify_deviceid_args {
226     struct notify4          *notify_list;
227     uint32_t                notify_count;
228     struct notify_deviceid4 *change_list;
229     uint32_t                change_count;
230 };
231 
232 struct cb_notify_deviceid_res {
233     enum_t                  status;
234 };
235 
236 /* CB_COMPOUND */
237 #define CB_COMPOUND_MAX_TAG         64
238 #define CB_COMPOUND_MAX_OPERATIONS  16
239 
240 union cb_op_args {
241     struct cb_layoutrecall_args layoutrecall;
242     struct cb_recall_slot_args recall_slot;
243     struct cb_sequence_args sequence;
244     struct cb_getattr_args  getattr;
245     struct cb_recall_args   recall;
246     struct cb_notify_deviceid_args notify_deviceid;
247 };
248 struct cb_argop {
249     enum_t                  opnum;
250     union cb_op_args        args;
251 };
252 struct cb_compound_tag {
253     char                    str[CB_COMPOUND_MAX_TAG];
254     uint32_t                len;
255 };
256 struct cb_compound_args {
257     struct cb_compound_tag  tag;
258     uint32_t                minorversion;
259     uint32_t                callback_ident; /* client MUST ignore */
260     struct cb_argop         *argarray;
261     uint32_t                argarray_count; /* <= CB_COMPOUND_MAX_OPERATIONS */
262 };
263 
264 union cb_op_res {
265     enum_t                  status; /* all results start with status */
266     struct cb_layoutrecall_res layoutrecall;
267     struct cb_recall_slot_res recall_slot;
268     struct cb_sequence_res  sequence;
269     struct cb_getattr_res   getattr;
270     struct cb_recall_res    recall;
271     struct cb_notify_deviceid_res notify_deviceid;
272 };
273 struct cb_resop {
274     enum_t                  opnum;
275     union cb_op_res         res;
276     bool_t                  xdr_ok;
277 };
278 struct cb_compound_res {
279     enum_t                  status;
280     struct cb_compound_tag  tag;
281     struct cb_resop         *resarray;
282     uint32_t                resarray_count; /* <= CB_COMPOUND_MAX_OPERATIONS */
283 };
284 
285 
286 /* callback_xdr.c */
287 bool_t proc_cb_compound_args(XDR *xdr, struct cb_compound_args *args);
288 bool_t proc_cb_compound_res(XDR *xdr, struct cb_compound_res *res);
289 
290 /* callback_server.c */
291 struct __nfs41_session;
292 void nfs41_callback_session_init(
293     IN struct __nfs41_session *session);
294 
295 #endif /* !__NFS41_CALLBACK_H__ */
296