r16980: - make struct smb_notify a union and add levels RAW_NOTIFY_NTTRANS,RAW_NOTIFY...
[jra/samba/.git] / source4 / smb_server / smb / nttrans.c
1 /* 
2    Unix SMB/CIFS implementation.
3    NT transaction handling
4    Copyright (C) Andrew Tridgell 2003
5    Copyright (C) James J Myers 2003 <myersjj@samba.org>
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 /*
22    This file handles the parsing of transact2 requests
23 */
24
25 #include "includes.h"
26 #include "smb_server/smb_server.h"
27 #include "ntvfs/ntvfs.h"
28 #include "libcli/raw/libcliraw.h"
29 #include "librpc/gen_ndr/ndr_security.h"
30
31 /*
32   hold the state of a nttrans op while in progress. Needed to allow for async backend
33   functions.
34 */
35 struct nttrans_op {
36         struct smb_nttrans *trans;
37         NTSTATUS (*send_fn)(struct nttrans_op *);
38         void *op_info;
39 };
40
41
42 /* setup a nttrans reply, given the data and params sizes */
43 static NTSTATUS nttrans_setup_reply(struct nttrans_op *op, 
44                                     struct smb_nttrans *trans,
45                                     uint32_t param_size, uint32_t data_size,
46                                     uint8_t setup_count)
47 {
48         trans->out.setup_count = setup_count;
49         if (setup_count != 0) {
50                 trans->out.setup = talloc_zero_array(op, uint16_t, setup_count);
51                 NT_STATUS_HAVE_NO_MEMORY(trans->out.setup);
52         }
53         trans->out.params = data_blob_talloc(op, NULL, param_size);
54         if (param_size != 0) {
55                 NT_STATUS_HAVE_NO_MEMORY(trans->out.params.data);
56         }
57         trans->out.data = data_blob_talloc(op, NULL, data_size);
58         if (data_size != 0) {
59                 NT_STATUS_HAVE_NO_MEMORY(trans->out.data.data);
60         }
61         return NT_STATUS_OK;
62 }
63
64 /*
65   send a nttrans create reply
66 */
67 static NTSTATUS nttrans_create_send(struct nttrans_op *op)
68 {
69         union smb_open *io = talloc_get_type(op->op_info, union smb_open);
70         uint8_t *params;
71         NTSTATUS status;
72
73         status = nttrans_setup_reply(op, op->trans, 69, 0, 0);
74         NT_STATUS_NOT_OK_RETURN(status);
75         params = op->trans->out.params.data;
76
77         SSVAL(params,        0, io->ntcreatex.out.oplock_level);
78         smbsrv_push_fnum(params, 2, io->ntcreatex.out.file.ntvfs);
79         SIVAL(params,        4, io->ntcreatex.out.create_action);
80         SIVAL(params,        8, 0); /* ea error offset */
81         push_nttime(params, 12, io->ntcreatex.out.create_time);
82         push_nttime(params, 20, io->ntcreatex.out.access_time);
83         push_nttime(params, 28, io->ntcreatex.out.write_time);
84         push_nttime(params, 36, io->ntcreatex.out.change_time);
85         SIVAL(params,       44, io->ntcreatex.out.attrib);
86         SBVAL(params,       48, io->ntcreatex.out.alloc_size);
87         SBVAL(params,       56, io->ntcreatex.out.size);
88         SSVAL(params,       64, io->ntcreatex.out.file_type);
89         SSVAL(params,       66, io->ntcreatex.out.ipc_state);
90         SCVAL(params,       68, io->ntcreatex.out.is_directory);
91
92         return NT_STATUS_OK;
93 }
94
95 /* 
96    parse NTTRANS_CREATE request
97  */
98 static NTSTATUS nttrans_create(struct smbsrv_request *req, 
99                                struct nttrans_op *op)
100 {
101         struct smb_nttrans *trans = op->trans;
102         union smb_open *io;
103         uint16_t fname_len;
104         uint32_t sd_length, ea_length;
105         NTSTATUS status;
106         uint8_t *params;
107
108         if (trans->in.params.length < 54) {
109                 return NT_STATUS_INVALID_PARAMETER;
110         }
111
112         /* parse the request */
113         io = talloc(op, union smb_open);
114         NT_STATUS_HAVE_NO_MEMORY(io);
115
116         io->ntcreatex.level = RAW_OPEN_NTTRANS_CREATE;
117
118         params = trans->in.params.data;
119
120         io->ntcreatex.in.flags            = IVAL(params,  0);
121         io->ntcreatex.in.root_fid         = IVAL(params,  4);
122         io->ntcreatex.in.access_mask      = IVAL(params,  8);
123         io->ntcreatex.in.alloc_size       = BVAL(params, 12);
124         io->ntcreatex.in.file_attr        = IVAL(params, 20);
125         io->ntcreatex.in.share_access     = IVAL(params, 24);
126         io->ntcreatex.in.open_disposition = IVAL(params, 28);
127         io->ntcreatex.in.create_options   = IVAL(params, 32);
128         sd_length                         = IVAL(params, 36);
129         ea_length                         = IVAL(params, 40);
130         fname_len                         = IVAL(params, 44);
131         io->ntcreatex.in.impersonation    = IVAL(params, 48);
132         io->ntcreatex.in.security_flags   = CVAL(params, 52);
133         io->ntcreatex.in.sec_desc         = NULL;
134         io->ntcreatex.in.ea_list          = NULL;
135
136         req_pull_string(req, &io->ntcreatex.in.fname, 
137                         params + 53, 
138                         MIN(fname_len+1, trans->in.params.length - 53),
139                         STR_NO_RANGE_CHECK | STR_TERMINATE);
140         if (!io->ntcreatex.in.fname) {
141                 return NT_STATUS_INVALID_PARAMETER;
142         }
143
144         if (sd_length > trans->in.data.length ||
145             ea_length > trans->in.data.length ||
146             (sd_length+ea_length) > trans->in.data.length) {
147                 return NT_STATUS_INVALID_PARAMETER;
148         }
149
150         /* this call has an optional security descriptor */
151         if (sd_length != 0) {
152                 DATA_BLOB blob;
153                 blob.data = trans->in.data.data;
154                 blob.length = sd_length;
155                 io->ntcreatex.in.sec_desc = talloc(io, struct security_descriptor);
156                 if (io->ntcreatex.in.sec_desc == NULL) {
157                         return NT_STATUS_NO_MEMORY;
158                 }
159                 status = ndr_pull_struct_blob(&blob, io, 
160                                               io->ntcreatex.in.sec_desc, 
161                                               (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
162                 if (!NT_STATUS_IS_OK(status)) {
163                         return status;
164                 }
165         }
166
167         /* and an optional ea_list */
168         if (ea_length > 4) {
169                 DATA_BLOB blob;
170                 blob.data = trans->in.data.data + sd_length;
171                 blob.length = ea_length;
172                 io->ntcreatex.in.ea_list = talloc(io, struct smb_ea_list);
173                 if (io->ntcreatex.in.ea_list == NULL) {
174                         return NT_STATUS_NO_MEMORY;
175                 }
176
177                 status = ea_pull_list_chained(&blob, io, 
178                                               &io->ntcreatex.in.ea_list->num_eas,
179                                               &io->ntcreatex.in.ea_list->eas);
180                 if (!NT_STATUS_IS_OK(status)) {
181                         return status;
182                 }
183         }
184
185         op->send_fn = nttrans_create_send;
186         op->op_info = io;
187
188         return ntvfs_open(req->ntvfs, io);
189 }
190
191
192 /* 
193    send NTTRANS_QUERY_SEC_DESC reply
194  */
195 static NTSTATUS nttrans_query_sec_desc_send(struct nttrans_op *op)
196 {
197         union smb_fileinfo *io = talloc_get_type(op->op_info, union smb_fileinfo);
198         uint8_t *params;
199         NTSTATUS status;
200
201         status = nttrans_setup_reply(op, op->trans, 4, 0, 0);
202         NT_STATUS_NOT_OK_RETURN(status);
203         params = op->trans->out.params.data;
204
205         status = ndr_push_struct_blob(&op->trans->out.data, op, 
206                                       io->query_secdesc.out.sd, 
207                                       (ndr_push_flags_fn_t)ndr_push_security_descriptor);
208         NT_STATUS_NOT_OK_RETURN(status);
209
210         SIVAL(params, 0, op->trans->out.data.length);
211
212         return NT_STATUS_OK;
213 }
214
215 /* 
216    parse NTTRANS_QUERY_SEC_DESC request
217  */
218 static NTSTATUS nttrans_query_sec_desc(struct smbsrv_request *req, 
219                                        struct nttrans_op *op)
220 {
221         struct smb_nttrans *trans = op->trans;
222         union smb_fileinfo *io;
223
224         if (trans->in.params.length < 8) {
225                 return NT_STATUS_INVALID_PARAMETER;
226         }
227
228         /* parse the request */
229         io = talloc(op, union smb_fileinfo);
230         NT_STATUS_HAVE_NO_MEMORY(io);
231
232         io->query_secdesc.level            = RAW_FILEINFO_SEC_DESC;
233         io->query_secdesc.in.file.ntvfs    = smbsrv_pull_fnum(req, trans->in.params.data, 0);
234         io->query_secdesc.in.secinfo_flags = IVAL(trans->in.params.data, 4);
235
236         op->op_info = io;
237         op->send_fn = nttrans_query_sec_desc_send;
238
239         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(io->query_secdesc.in.file.ntvfs);
240         return ntvfs_qfileinfo(req->ntvfs, io);
241 }
242
243
244 /* 
245    parse NTTRANS_SET_SEC_DESC request
246  */
247 static NTSTATUS nttrans_set_sec_desc(struct smbsrv_request *req, 
248                                      struct nttrans_op *op)
249 {
250         struct smb_nttrans *trans = op->trans;
251         union smb_setfileinfo *io;
252         NTSTATUS status;
253
254         if (trans->in.params.length < 8) {
255                 return NT_STATUS_INVALID_PARAMETER;
256         }
257
258         /* parse the request */
259         io = talloc(req, union smb_setfileinfo);
260         NT_STATUS_HAVE_NO_MEMORY(io);
261
262         io->set_secdesc.level            = RAW_SFILEINFO_SEC_DESC;
263         io->set_secdesc.in.file.ntvfs    = smbsrv_pull_fnum(req, trans->in.params.data, 0);
264         io->set_secdesc.in.secinfo_flags = IVAL(trans->in.params.data, 4);
265
266         io->set_secdesc.in.sd = talloc(io, struct security_descriptor);
267         NT_STATUS_HAVE_NO_MEMORY(io->set_secdesc.in.sd);
268
269         status = ndr_pull_struct_blob(&trans->in.data, req, 
270                                       io->set_secdesc.in.sd, 
271                                       (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
272         NT_STATUS_NOT_OK_RETURN(status);
273
274         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(io->set_secdesc.in.file.ntvfs);
275         return ntvfs_setfileinfo(req->ntvfs, io);
276 }
277
278
279 /* parse NTTRANS_RENAME request
280  */
281 static NTSTATUS nttrans_rename(struct smbsrv_request *req, 
282                                struct nttrans_op *op)
283 {
284         return NT_STATUS_NOT_IMPLEMENTED;
285 }
286
287 /* 
288    parse NTTRANS_IOCTL send
289  */
290 static NTSTATUS nttrans_ioctl_send(struct nttrans_op *op)
291 {
292         union smb_ioctl *info = talloc_get_type(op->op_info, union smb_ioctl);
293         NTSTATUS status;
294
295         /* 
296          * we pass 0 as data_count here,
297          * because we reuse the DATA_BLOB from the smb_ioctl
298          * struct
299          */
300         status = nttrans_setup_reply(op, op->trans, 0, 0, 1);
301         NT_STATUS_NOT_OK_RETURN(status);
302
303         op->trans->out.setup[0]         = 0;
304         op->trans->out.data             = info->ntioctl.out.blob;
305
306         return NT_STATUS_OK;
307 }
308
309
310 /* 
311    parse NTTRANS_IOCTL request
312  */
313 static NTSTATUS nttrans_ioctl(struct smbsrv_request *req, 
314                               struct nttrans_op *op)
315 {
316         struct smb_nttrans *trans = op->trans;
317         union smb_ioctl *nt;
318
319         /* should have at least 4 setup words */
320         if (trans->in.setup_count != 4) {
321                 return NT_STATUS_INVALID_PARAMETER;
322         }
323
324         nt = talloc(op, union smb_ioctl);
325         NT_STATUS_HAVE_NO_MEMORY(nt);
326         
327         nt->ntioctl.level               = RAW_IOCTL_NTIOCTL;
328         nt->ntioctl.in.function         = IVAL(trans->in.setup, 0);
329         nt->ntioctl.in.file.ntvfs       = smbsrv_pull_fnum(req, (uint8_t *)trans->in.setup, 4);
330         nt->ntioctl.in.fsctl            = CVAL(trans->in.setup, 6);
331         nt->ntioctl.in.filter           = CVAL(trans->in.setup, 7);
332         nt->ntioctl.in.max_data         = trans->in.max_data;
333         nt->ntioctl.in.blob             = trans->in.data;
334
335         op->op_info = nt;
336         op->send_fn = nttrans_ioctl_send;
337
338         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(nt->ntioctl.in.file.ntvfs);
339         return ntvfs_ioctl(req->ntvfs, nt);
340 }
341
342
343 /* 
344    send NTTRANS_NOTIFY_CHANGE reply
345  */
346 static NTSTATUS nttrans_notify_change_send(struct nttrans_op *op)
347 {
348         union smb_notify *info = talloc_get_type(op->op_info, union smb_notify);
349         size_t size = 0;
350         int i;
351         NTSTATUS status;
352         uint8_t *p;
353 #define MAX_BYTES_PER_CHAR 3
354         
355         /* work out how big the reply buffer could be */
356         for (i=0;i<info->nttrans.out.num_changes;i++) {
357                 size += 12 + 3 + (1+strlen(info->nttrans.out.changes[i].name.s)) * MAX_BYTES_PER_CHAR;
358         }
359
360         status = nttrans_setup_reply(op, op->trans, size, 0, 0);
361         NT_STATUS_NOT_OK_RETURN(status);
362         p = op->trans->out.params.data;
363
364         /* construct the changes buffer */
365         for (i=0;i<info->nttrans.out.num_changes;i++) {
366                 uint32_t ofs;
367                 ssize_t len;
368
369                 SIVAL(p, 4, info->nttrans.out.changes[i].action);
370                 len = push_string(p + 12, info->nttrans.out.changes[i].name.s, 
371                                   op->trans->out.params.length - 
372                                   (p+12 - op->trans->out.params.data), STR_UNICODE);
373                 SIVAL(p, 8, len);
374
375                 ofs = len + 12;
376
377                 if (ofs & 3) {
378                         int pad = 4 - (ofs & 3);
379                         memset(p+ofs, 0, pad);
380                         ofs += pad;
381                 }
382
383                 if (i == info->nttrans.out.num_changes-1) {
384                         SIVAL(p, 0, 0);
385                 } else {
386                         SIVAL(p, 0, ofs);
387                 }
388
389                 p += ofs;
390         }
391
392         op->trans->out.params.length = p - op->trans->out.params.data;
393
394         return NT_STATUS_OK;
395 }
396
397 /* 
398    parse NTTRANS_NOTIFY_CHANGE request
399  */
400 static NTSTATUS nttrans_notify_change(struct smbsrv_request *req, 
401                                       struct nttrans_op *op)
402 {
403         struct smb_nttrans *trans = op->trans;
404         union smb_notify *info;
405
406         /* should have at least 4 setup words */
407         if (trans->in.setup_count != 4) {
408                 return NT_STATUS_INVALID_PARAMETER;
409         }
410
411         info = talloc(op, union smb_notify);
412         NT_STATUS_HAVE_NO_MEMORY(info);
413
414         info->nttrans.level                     = RAW_NOTIFY_NTTRANS;
415         info->nttrans.in.completion_filter      = IVAL(trans->in.setup, 0);
416         info->nttrans.in.file.ntvfs             = smbsrv_pull_fnum(req, (uint8_t *)trans->in.setup, 4);
417         info->nttrans.in.recursive              = SVAL(trans->in.setup, 6);
418         info->nttrans.in.buffer_size            = trans->in.max_param;
419
420         op->op_info = info;
421         op->send_fn = nttrans_notify_change_send;
422
423         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(info->nttrans.in.file.ntvfs);
424         return ntvfs_notify(req->ntvfs, info);
425 }
426
427 /*
428   backend for nttrans requests
429 */
430 static NTSTATUS nttrans_backend(struct smbsrv_request *req, 
431                                 struct nttrans_op *op)
432 {
433         /* the nttrans command is in function */
434         switch (op->trans->in.function) {
435         case NT_TRANSACT_CREATE:
436                 return nttrans_create(req, op);
437         case NT_TRANSACT_IOCTL:
438                 return nttrans_ioctl(req, op);
439         case NT_TRANSACT_RENAME:
440                 return nttrans_rename(req, op);
441         case NT_TRANSACT_QUERY_SECURITY_DESC:
442                 return nttrans_query_sec_desc(req, op);
443         case NT_TRANSACT_SET_SECURITY_DESC:
444                 return nttrans_set_sec_desc(req, op);
445         case NT_TRANSACT_NOTIFY_CHANGE:
446                 return nttrans_notify_change(req, op);
447         }
448
449         /* an unknown nttrans command */
450         return NT_STATUS_DOS(ERRSRV, ERRerror);
451 }
452
453
454 static void reply_nttrans_send(struct ntvfs_request *ntvfs)
455 {
456         struct smbsrv_request *req;
457         uint16_t params_left, data_left;
458         uint8_t *params, *data;
459         struct smb_nttrans *trans;
460         struct nttrans_op *op;
461
462         SMBSRV_CHECK_ASYNC_STATUS(op, struct nttrans_op);
463
464         trans = op->trans;
465
466         /* if this function needs work to form the nttrans reply buffer, then
467            call that now */
468         if (op->send_fn != NULL) {
469                 NTSTATUS status;
470                 status = op->send_fn(op);
471                 if (!NT_STATUS_IS_OK(status)) {
472                         smbsrv_send_error(req, status);
473                         return;
474                 }
475         }
476
477         smbsrv_setup_reply(req, 18 + trans->out.setup_count, 0);
478
479         /* note that we don't check the max_setup count (matching w2k3
480            behaviour) */
481
482         if (trans->out.params.length > trans->in.max_param) {
483                 smbsrv_setup_error(req, NT_STATUS_BUFFER_TOO_SMALL);
484                 trans->out.params.length = trans->in.max_param;
485         }
486         if (trans->out.data.length > trans->in.max_data) {
487                 smbsrv_setup_error(req, NT_STATUS_BUFFER_TOO_SMALL);
488                 trans->out.data.length = trans->in.max_data;
489         }
490
491         params_left = trans->out.params.length;
492         data_left   = trans->out.data.length;
493         params      = trans->out.params.data;
494         data        = trans->out.data.data;
495
496         /* we need to divide up the reply into chunks that fit into
497            the negotiated buffer size */
498         do {
499                 uint16_t this_data, this_param, max_bytes;
500                 uint_t align1 = 1, align2 = (params_left ? 2 : 0);
501                 struct smbsrv_request *this_req;
502                 int i;
503
504                 max_bytes = req_max_data(req) - (align1 + align2);
505
506                 this_param = params_left;
507                 if (this_param > max_bytes) {
508                         this_param = max_bytes;
509                 }
510                 max_bytes -= this_param;
511
512                 this_data = data_left;
513                 if (this_data > max_bytes) {
514                         this_data = max_bytes;
515                 }
516
517                 /* don't destroy unless this is the last chunk */
518                 if (params_left - this_param != 0 || 
519                     data_left - this_data != 0) {
520                         this_req = smbsrv_setup_secondary_request(req);
521                 } else {
522                         this_req = req;
523                 }
524
525                 req_grow_data(req, this_param + this_data + (align1 + align2));
526
527                 SSVAL(this_req->out.vwv, 0, 0); /* reserved */
528                 SCVAL(this_req->out.vwv, 2, 0); /* reserved */
529                 SIVAL(this_req->out.vwv, 3, trans->out.params.length);
530                 SIVAL(this_req->out.vwv, 7, trans->out.data.length);
531
532                 SIVAL(this_req->out.vwv, 11, this_param);
533                 SIVAL(this_req->out.vwv, 15, align1 + PTR_DIFF(this_req->out.data, this_req->out.hdr));
534                 SIVAL(this_req->out.vwv, 19, PTR_DIFF(params, trans->out.params.data));
535
536                 SIVAL(this_req->out.vwv, 23, this_data);
537                 SIVAL(this_req->out.vwv, 27, align1 + align2 + 
538                       PTR_DIFF(this_req->out.data + this_param, this_req->out.hdr));
539                 SIVAL(this_req->out.vwv, 31, PTR_DIFF(data, trans->out.data.data));
540
541                 SCVAL(this_req->out.vwv, 35, trans->out.setup_count);
542                 for (i=0;i<trans->out.setup_count;i++) {
543                         SSVAL(this_req->out.vwv, VWV(18+i), trans->out.setup[i]);
544                 }
545
546                 memset(this_req->out.data, 0, align1);
547                 if (this_param != 0) {
548                         memcpy(this_req->out.data + align1, params, this_param);
549                 }
550                 memset(this_req->out.data+this_param+align1, 0, align2);
551                 if (this_data != 0) {
552                         memcpy(this_req->out.data+this_param+align1+align2, 
553                                data, this_data);
554                 }
555
556                 params_left -= this_param;
557                 data_left -= this_data;
558                 params += this_param;
559                 data += this_data;
560
561                 smbsrv_send_reply(this_req);
562         } while (params_left != 0 || data_left != 0);
563 }
564
565
566 /****************************************************************************
567  Reply to an SMBnttrans request
568 ****************************************************************************/
569 void smbsrv_reply_nttrans(struct smbsrv_request *req)
570 {
571         struct nttrans_op *op;
572         struct smb_nttrans *trans;
573         int i;
574         uint16_t param_ofs, data_ofs;
575         uint16_t param_count, data_count;
576         uint16_t param_total, data_total;
577
578         /* parse request */
579         if (req->in.wct < 19) {
580                 smbsrv_send_error(req, NT_STATUS_FOOBAR);
581                 return;
582         }
583
584         SMBSRV_TALLOC_IO_PTR(op, struct nttrans_op);
585         SMBSRV_SETUP_NTVFS_REQUEST(reply_nttrans_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
586
587         trans = talloc(op, struct smb_nttrans);
588         if (trans == NULL) {
589                 smbsrv_send_error(req, NT_STATUS_NO_MEMORY);
590                 return;
591         }
592
593         op->trans = trans;
594         op->op_info = NULL;
595         op->send_fn = NULL;
596
597         trans->in.max_setup  = CVAL(req->in.vwv, 0);
598         param_total          = IVAL(req->in.vwv, 3);
599         data_total           = IVAL(req->in.vwv, 7);
600         trans->in.max_param  = IVAL(req->in.vwv, 11);
601         trans->in.max_data   = IVAL(req->in.vwv, 15);
602         param_count          = IVAL(req->in.vwv, 19);
603         param_ofs            = IVAL(req->in.vwv, 23);
604         data_count           = IVAL(req->in.vwv, 27);
605         data_ofs             = IVAL(req->in.vwv, 31);
606         trans->in.setup_count= CVAL(req->in.vwv, 35);
607         trans->in.function   = SVAL(req->in.vwv, 36);
608
609         if (req->in.wct != 19 + trans->in.setup_count) {
610                 smbsrv_send_error(req, NT_STATUS_DOS(ERRSRV, ERRerror));
611                 return;
612         }
613
614         /* parse out the setup words */
615         trans->in.setup = talloc_array(req, uint16_t, trans->in.setup_count);
616         if (!trans->in.setup) {
617                 smbsrv_send_error(req, NT_STATUS_NO_MEMORY);
618                 return;
619         }
620         for (i=0;i<trans->in.setup_count;i++) {
621                 trans->in.setup[i] = SVAL(req->in.vwv, VWV(19+i));
622         }
623
624         if (!req_pull_blob(req, req->in.hdr + param_ofs, param_count, &trans->in.params) ||
625             !req_pull_blob(req, req->in.hdr + data_ofs, data_count, &trans->in.data)) {
626                 smbsrv_send_error(req, NT_STATUS_FOOBAR);
627                 return;
628         }
629
630         /* is it a partial request? if so, then send a 'send more' message */
631         if (param_total > param_count ||
632             data_total > data_count) {
633                 DEBUG(0,("REWRITE: not handling partial nttrans requests!\n"));
634                 smbsrv_send_error(req, NT_STATUS_FOOBAR);
635                 return;
636         }
637
638         ZERO_STRUCT(trans->out);
639         SMBSRV_CALL_NTVFS_BACKEND(nttrans_backend(req, op));
640 }
641
642
643 /****************************************************************************
644  Reply to an SMBnttranss request
645 ****************************************************************************/
646 void smbsrv_reply_nttranss(struct smbsrv_request *req)
647 {
648         smbsrv_send_error(req, NT_STATUS_FOOBAR);
649 }