r26316: Use contexts for conversion functions.
[samba.git] / source / 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 3 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, see <http://www.gnu.org/licenses/>.
19 */
20 /*
21    This file handles the parsing of transact2 requests
22 */
23
24 #include "includes.h"
25 #include "smb_server/smb_server.h"
26 #include "ntvfs/ntvfs.h"
27 #include "libcli/raw/libcliraw.h"
28 #include "librpc/gen_ndr/ndr_security.h"
29
30 /*
31   hold the state of a nttrans op while in progress. Needed to allow for async backend
32   functions.
33 */
34 struct nttrans_op {
35         struct smb_nttrans *trans;
36         NTSTATUS (*send_fn)(struct nttrans_op *);
37         void *op_info;
38 };
39
40
41 /* setup a nttrans reply, given the data and params sizes */
42 static NTSTATUS nttrans_setup_reply(struct nttrans_op *op, 
43                                     struct smb_nttrans *trans,
44                                     uint32_t param_size, uint32_t data_size,
45                                     uint8_t setup_count)
46 {
47         trans->out.setup_count = setup_count;
48         if (setup_count != 0) {
49                 trans->out.setup = talloc_zero_array(op, uint8_t, setup_count*2);
50                 NT_STATUS_HAVE_NO_MEMORY(trans->out.setup);
51         }
52         trans->out.params = data_blob_talloc(op, NULL, param_size);
53         if (param_size != 0) {
54                 NT_STATUS_HAVE_NO_MEMORY(trans->out.params.data);
55         }
56         trans->out.data = data_blob_talloc(op, NULL, data_size);
57         if (data_size != 0) {
58                 NT_STATUS_HAVE_NO_MEMORY(trans->out.data.data);
59         }
60         return NT_STATUS_OK;
61 }
62
63 /*
64   send a nttrans create reply
65 */
66 static NTSTATUS nttrans_create_send(struct nttrans_op *op)
67 {
68         union smb_open *io = talloc_get_type(op->op_info, union smb_open);
69         uint8_t *params;
70         NTSTATUS status;
71
72         status = nttrans_setup_reply(op, op->trans, 69, 0, 0);
73         NT_STATUS_NOT_OK_RETURN(status);
74         params = op->trans->out.params.data;
75
76         SSVAL(params,        0, io->ntcreatex.out.oplock_level);
77         smbsrv_push_fnum(params, 2, io->ntcreatex.out.file.ntvfs);
78         SIVAL(params,        4, io->ntcreatex.out.create_action);
79         SIVAL(params,        8, 0); /* ea error offset */
80         push_nttime(params, 12, io->ntcreatex.out.create_time);
81         push_nttime(params, 20, io->ntcreatex.out.access_time);
82         push_nttime(params, 28, io->ntcreatex.out.write_time);
83         push_nttime(params, 36, io->ntcreatex.out.change_time);
84         SIVAL(params,       44, io->ntcreatex.out.attrib);
85         SBVAL(params,       48, io->ntcreatex.out.alloc_size);
86         SBVAL(params,       56, io->ntcreatex.out.size);
87         SSVAL(params,       64, io->ntcreatex.out.file_type);
88         SSVAL(params,       66, io->ntcreatex.out.ipc_state);
89         SCVAL(params,       68, io->ntcreatex.out.is_directory);
90
91         return NT_STATUS_OK;
92 }
93
94 /* 
95    parse NTTRANS_CREATE request
96  */
97 static NTSTATUS nttrans_create(struct smbsrv_request *req, 
98                                struct nttrans_op *op)
99 {
100         struct smb_nttrans *trans = op->trans;
101         union smb_open *io;
102         uint16_t fname_len;
103         uint32_t sd_length, ea_length;
104         NTSTATUS status;
105         uint8_t *params;
106         enum ndr_err_code ndr_err;
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                 ndr_err = ndr_pull_struct_blob(&blob, io,
160                                                io->ntcreatex.in.sec_desc,
161                                                (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
162                 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
163                         return ndr_map_error2ntstatus(ndr_err);
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         enum ndr_err_code ndr_err;
201
202         status = nttrans_setup_reply(op, op->trans, 4, 0, 0);
203         NT_STATUS_NOT_OK_RETURN(status);
204         params = op->trans->out.params.data;
205
206         ndr_err = ndr_push_struct_blob(&op->trans->out.data, op,
207                                        io->query_secdesc.out.sd,
208                                        (ndr_push_flags_fn_t)ndr_push_security_descriptor);
209         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
210                 return ndr_map_error2ntstatus(ndr_err);
211         }
212
213         SIVAL(params, 0, op->trans->out.data.length);
214
215         return NT_STATUS_OK;
216 }
217
218 /* 
219    parse NTTRANS_QUERY_SEC_DESC request
220  */
221 static NTSTATUS nttrans_query_sec_desc(struct smbsrv_request *req, 
222                                        struct nttrans_op *op)
223 {
224         struct smb_nttrans *trans = op->trans;
225         union smb_fileinfo *io;
226
227         if (trans->in.params.length < 8) {
228                 return NT_STATUS_INVALID_PARAMETER;
229         }
230
231         /* parse the request */
232         io = talloc(op, union smb_fileinfo);
233         NT_STATUS_HAVE_NO_MEMORY(io);
234
235         io->query_secdesc.level            = RAW_FILEINFO_SEC_DESC;
236         io->query_secdesc.in.file.ntvfs    = smbsrv_pull_fnum(req, trans->in.params.data, 0);
237         io->query_secdesc.in.secinfo_flags = IVAL(trans->in.params.data, 4);
238
239         op->op_info = io;
240         op->send_fn = nttrans_query_sec_desc_send;
241
242         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(io->query_secdesc.in.file.ntvfs);
243         return ntvfs_qfileinfo(req->ntvfs, io);
244 }
245
246
247 /* 
248    parse NTTRANS_SET_SEC_DESC request
249  */
250 static NTSTATUS nttrans_set_sec_desc(struct smbsrv_request *req, 
251                                      struct nttrans_op *op)
252 {
253         struct smb_nttrans *trans = op->trans;
254         union smb_setfileinfo *io;
255         enum ndr_err_code ndr_err;
256
257         if (trans->in.params.length < 8) {
258                 return NT_STATUS_INVALID_PARAMETER;
259         }
260
261         /* parse the request */
262         io = talloc(req, union smb_setfileinfo);
263         NT_STATUS_HAVE_NO_MEMORY(io);
264
265         io->set_secdesc.level            = RAW_SFILEINFO_SEC_DESC;
266         io->set_secdesc.in.file.ntvfs    = smbsrv_pull_fnum(req, trans->in.params.data, 0);
267         io->set_secdesc.in.secinfo_flags = IVAL(trans->in.params.data, 4);
268
269         io->set_secdesc.in.sd = talloc(io, struct security_descriptor);
270         NT_STATUS_HAVE_NO_MEMORY(io->set_secdesc.in.sd);
271
272         ndr_err = ndr_pull_struct_blob(&trans->in.data, req,
273                                        io->set_secdesc.in.sd,
274                                        (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
275         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
276                 return ndr_map_error2ntstatus(ndr_err);
277         }
278
279         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(io->set_secdesc.in.file.ntvfs);
280         return ntvfs_setfileinfo(req->ntvfs, io);
281 }
282
283
284 /* parse NTTRANS_RENAME request
285  */
286 static NTSTATUS nttrans_rename(struct smbsrv_request *req, 
287                                struct nttrans_op *op)
288 {
289         return NT_STATUS_NOT_IMPLEMENTED;
290 }
291
292 /* 
293    parse NTTRANS_IOCTL send
294  */
295 static NTSTATUS nttrans_ioctl_send(struct nttrans_op *op)
296 {
297         union smb_ioctl *info = talloc_get_type(op->op_info, union smb_ioctl);
298         NTSTATUS status;
299
300         /* 
301          * we pass 0 as data_count here,
302          * because we reuse the DATA_BLOB from the smb_ioctl
303          * struct
304          */
305         status = nttrans_setup_reply(op, op->trans, 0, 0, 1);
306         NT_STATUS_NOT_OK_RETURN(status);
307
308         op->trans->out.setup[0]         = 0;
309         op->trans->out.data             = info->ntioctl.out.blob;
310
311         return NT_STATUS_OK;
312 }
313
314
315 /* 
316    parse NTTRANS_IOCTL request
317  */
318 static NTSTATUS nttrans_ioctl(struct smbsrv_request *req, 
319                               struct nttrans_op *op)
320 {
321         struct smb_nttrans *trans = op->trans;
322         union smb_ioctl *nt;
323
324         /* should have at least 4 setup words */
325         if (trans->in.setup_count != 4) {
326                 return NT_STATUS_INVALID_PARAMETER;
327         }
328
329         nt = talloc(op, union smb_ioctl);
330         NT_STATUS_HAVE_NO_MEMORY(nt);
331         
332         nt->ntioctl.level               = RAW_IOCTL_NTIOCTL;
333         nt->ntioctl.in.function         = IVAL(trans->in.setup, 0);
334         nt->ntioctl.in.file.ntvfs       = smbsrv_pull_fnum(req, (uint8_t *)trans->in.setup, 4);
335         nt->ntioctl.in.fsctl            = CVAL(trans->in.setup, 6);
336         nt->ntioctl.in.filter           = CVAL(trans->in.setup, 7);
337         nt->ntioctl.in.max_data         = trans->in.max_data;
338         nt->ntioctl.in.blob             = trans->in.data;
339
340         op->op_info = nt;
341         op->send_fn = nttrans_ioctl_send;
342
343         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(nt->ntioctl.in.file.ntvfs);
344         return ntvfs_ioctl(req->ntvfs, nt);
345 }
346
347
348 /* 
349    send NTTRANS_NOTIFY_CHANGE reply
350  */
351 static NTSTATUS nttrans_notify_change_send(struct nttrans_op *op)
352 {
353         union smb_notify *info = talloc_get_type(op->op_info, union smb_notify);
354         size_t size = 0;
355         int i;
356         NTSTATUS status;
357         uint8_t *p;
358 #define MAX_BYTES_PER_CHAR 3
359         
360         /* work out how big the reply buffer could be */
361         for (i=0;i<info->nttrans.out.num_changes;i++) {
362                 size += 12 + 3 + (1+strlen(info->nttrans.out.changes[i].name.s)) * MAX_BYTES_PER_CHAR;
363         }
364
365         status = nttrans_setup_reply(op, op->trans, size, 0, 0);
366         NT_STATUS_NOT_OK_RETURN(status);
367         p = op->trans->out.params.data;
368
369         /* construct the changes buffer */
370         for (i=0;i<info->nttrans.out.num_changes;i++) {
371                 uint32_t ofs;
372                 ssize_t len;
373
374                 SIVAL(p, 4, info->nttrans.out.changes[i].action);
375                 len = push_string(global_smb_iconv_convenience, p + 12, info->nttrans.out.changes[i].name.s, 
376                                   op->trans->out.params.length - 
377                                   (p+12 - op->trans->out.params.data), STR_UNICODE);
378                 SIVAL(p, 8, len);
379
380                 ofs = len + 12;
381
382                 if (ofs & 3) {
383                         int pad = 4 - (ofs & 3);
384                         memset(p+ofs, 0, pad);
385                         ofs += pad;
386                 }
387
388                 if (i == info->nttrans.out.num_changes-1) {
389                         SIVAL(p, 0, 0);
390                 } else {
391                         SIVAL(p, 0, ofs);
392                 }
393
394                 p += ofs;
395         }
396
397         op->trans->out.params.length = p - op->trans->out.params.data;
398
399         return NT_STATUS_OK;
400 }
401
402 /* 
403    parse NTTRANS_NOTIFY_CHANGE request
404  */
405 static NTSTATUS nttrans_notify_change(struct smbsrv_request *req, 
406                                       struct nttrans_op *op)
407 {
408         struct smb_nttrans *trans = op->trans;
409         union smb_notify *info;
410
411         /* should have at least 4 setup words */
412         if (trans->in.setup_count != 4) {
413                 return NT_STATUS_INVALID_PARAMETER;
414         }
415
416         info = talloc(op, union smb_notify);
417         NT_STATUS_HAVE_NO_MEMORY(info);
418
419         info->nttrans.level                     = RAW_NOTIFY_NTTRANS;
420         info->nttrans.in.completion_filter      = IVAL(trans->in.setup, 0);
421         info->nttrans.in.file.ntvfs             = smbsrv_pull_fnum(req, (uint8_t *)trans->in.setup, 4);
422         info->nttrans.in.recursive              = SVAL(trans->in.setup, 6);
423         info->nttrans.in.buffer_size            = trans->in.max_param;
424
425         op->op_info = info;
426         op->send_fn = nttrans_notify_change_send;
427
428         SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(info->nttrans.in.file.ntvfs);
429         return ntvfs_notify(req->ntvfs, info);
430 }
431
432 /*
433   backend for nttrans requests
434 */
435 static NTSTATUS nttrans_backend(struct smbsrv_request *req, 
436                                 struct nttrans_op *op)
437 {
438         /* the nttrans command is in function */
439         switch (op->trans->in.function) {
440         case NT_TRANSACT_CREATE:
441                 return nttrans_create(req, op);
442         case NT_TRANSACT_IOCTL:
443                 return nttrans_ioctl(req, op);
444         case NT_TRANSACT_RENAME:
445                 return nttrans_rename(req, op);
446         case NT_TRANSACT_QUERY_SECURITY_DESC:
447                 return nttrans_query_sec_desc(req, op);
448         case NT_TRANSACT_SET_SECURITY_DESC:
449                 return nttrans_set_sec_desc(req, op);
450         case NT_TRANSACT_NOTIFY_CHANGE:
451                 return nttrans_notify_change(req, op);
452         }
453
454         /* an unknown nttrans command */
455         return NT_STATUS_DOS(ERRSRV, ERRerror);
456 }
457
458
459 static void reply_nttrans_send(struct ntvfs_request *ntvfs)
460 {
461         struct smbsrv_request *req;
462         uint16_t params_left, data_left;
463         uint8_t *params, *data;
464         struct smb_nttrans *trans;
465         struct nttrans_op *op;
466
467         SMBSRV_CHECK_ASYNC_STATUS(op, struct nttrans_op);
468
469         trans = op->trans;
470
471         /* if this function needs work to form the nttrans reply buffer, then
472            call that now */
473         if (op->send_fn != NULL) {
474                 NTSTATUS status;
475                 status = op->send_fn(op);
476                 if (!NT_STATUS_IS_OK(status)) {
477                         smbsrv_send_error(req, status);
478                         return;
479                 }
480         }
481
482         smbsrv_setup_reply(req, 18 + trans->out.setup_count, 0);
483
484         /* note that we don't check the max_setup count (matching w2k3
485            behaviour) */
486
487         if (trans->out.params.length > trans->in.max_param) {
488                 smbsrv_setup_error(req, NT_STATUS_BUFFER_TOO_SMALL);
489                 trans->out.params.length = trans->in.max_param;
490         }
491         if (trans->out.data.length > trans->in.max_data) {
492                 smbsrv_setup_error(req, NT_STATUS_BUFFER_TOO_SMALL);
493                 trans->out.data.length = trans->in.max_data;
494         }
495
496         params_left = trans->out.params.length;
497         data_left   = trans->out.data.length;
498         params      = trans->out.params.data;
499         data        = trans->out.data.data;
500
501         /* we need to divide up the reply into chunks that fit into
502            the negotiated buffer size */
503         do {
504                 uint16_t this_data, this_param, max_bytes;
505                 uint_t align1 = 1, align2 = (params_left ? 2 : 0);
506                 struct smbsrv_request *this_req;
507
508                 max_bytes = req_max_data(req) - (align1 + align2);
509
510                 this_param = params_left;
511                 if (this_param > max_bytes) {
512                         this_param = max_bytes;
513                 }
514                 max_bytes -= this_param;
515
516                 this_data = data_left;
517                 if (this_data > max_bytes) {
518                         this_data = max_bytes;
519                 }
520
521                 /* don't destroy unless this is the last chunk */
522                 if (params_left - this_param != 0 || 
523                     data_left - this_data != 0) {
524                         this_req = smbsrv_setup_secondary_request(req);
525                 } else {
526                         this_req = req;
527                 }
528
529                 req_grow_data(req, this_param + this_data + (align1 + align2));
530
531                 SSVAL(this_req->out.vwv, 0, 0); /* reserved */
532                 SCVAL(this_req->out.vwv, 2, 0); /* reserved */
533                 SIVAL(this_req->out.vwv, 3, trans->out.params.length);
534                 SIVAL(this_req->out.vwv, 7, trans->out.data.length);
535
536                 SIVAL(this_req->out.vwv, 11, this_param);
537                 SIVAL(this_req->out.vwv, 15, align1 + PTR_DIFF(this_req->out.data, this_req->out.hdr));
538                 SIVAL(this_req->out.vwv, 19, PTR_DIFF(params, trans->out.params.data));
539
540                 SIVAL(this_req->out.vwv, 23, this_data);
541                 SIVAL(this_req->out.vwv, 27, align1 + align2 + 
542                       PTR_DIFF(this_req->out.data + this_param, this_req->out.hdr));
543                 SIVAL(this_req->out.vwv, 31, PTR_DIFF(data, trans->out.data.data));
544
545                 SCVAL(this_req->out.vwv, 35, trans->out.setup_count);
546                 memcpy((char *)(this_req->out.vwv) + VWV(18), trans->out.setup,
547                        sizeof(uint16_t) * trans->out.setup_count);
548                 memset(this_req->out.data, 0, align1);
549                 if (this_param != 0) {
550                         memcpy(this_req->out.data + align1, params, this_param);
551                 }
552                 memset(this_req->out.data+this_param+align1, 0, align2);
553                 if (this_data != 0) {
554                         memcpy(this_req->out.data+this_param+align1+align2, 
555                                data, this_data);
556                 }
557
558                 params_left -= this_param;
559                 data_left -= this_data;
560                 params += this_param;
561                 data += this_data;
562
563                 smbsrv_send_reply(this_req);
564         } while (params_left != 0 || data_left != 0);
565 }
566
567
568 /****************************************************************************
569  Reply to an SMBnttrans request
570 ****************************************************************************/
571 void smbsrv_reply_nttrans(struct smbsrv_request *req)
572 {
573         struct nttrans_op *op;
574         struct smb_nttrans *trans;
575         uint16_t param_ofs, data_ofs;
576         uint16_t param_count, data_count;
577         uint16_t param_total, data_total;
578
579         /* parse request */
580         if (req->in.wct < 19) {
581                 smbsrv_send_error(req, NT_STATUS_FOOBAR);
582                 return;
583         }
584
585         SMBSRV_TALLOC_IO_PTR(op, struct nttrans_op);
586         SMBSRV_SETUP_NTVFS_REQUEST(reply_nttrans_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
587
588         trans = talloc(op, struct smb_nttrans);
589         if (trans == NULL) {
590                 smbsrv_send_error(req, NT_STATUS_NO_MEMORY);
591                 return;
592         }
593
594         op->trans = trans;
595         op->op_info = NULL;
596         op->send_fn = NULL;
597
598         trans->in.max_setup  = CVAL(req->in.vwv, 0);
599         param_total          = IVAL(req->in.vwv, 3);
600         data_total           = IVAL(req->in.vwv, 7);
601         trans->in.max_param  = IVAL(req->in.vwv, 11);
602         trans->in.max_data   = IVAL(req->in.vwv, 15);
603         param_count          = IVAL(req->in.vwv, 19);
604         param_ofs            = IVAL(req->in.vwv, 23);
605         data_count           = IVAL(req->in.vwv, 27);
606         data_ofs             = IVAL(req->in.vwv, 31);
607         trans->in.setup_count= CVAL(req->in.vwv, 35);
608         trans->in.function   = SVAL(req->in.vwv, 36);
609
610         if (req->in.wct != 19 + trans->in.setup_count) {
611                 smbsrv_send_error(req, NT_STATUS_DOS(ERRSRV, ERRerror));
612                 return;
613         }
614
615         /* parse out the setup words */
616         trans->in.setup = talloc_array(req, uint8_t, trans->in.setup_count*2);
617         if (!trans->in.setup) {
618                 smbsrv_send_error(req, NT_STATUS_NO_MEMORY);
619                 return;
620         }
621         memcpy(trans->in.setup, (char *)(req->in.vwv) + VWV(19),
622                sizeof(uint16_t) * trans->in.setup_count);
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 }