2 Unix SMB/CIFS implementation.
3 Main SMB reply routines
4 Copyright (C) Andrew Tridgell 1992-2003
5 Copyright (C) James J Myers 2003 <myersjj@samba.org>
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.
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.
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.
22 This file handles most of the reply_ calls that the server
23 makes to handle specific protocols
28 /* useful way of catching wct errors with file and line number */
29 #define REQ_CHECK_WCT(req, wcount) do { \
30 if ((req)->in.wct != (wcount)) { \
31 DEBUG(1,("Unexpected WCT %d at %s(%d) - expected %d\n", \
32 (req)->in.wct, __FILE__, __LINE__, wcount)); \
33 req_reply_dos_error(req, ERRSRV, ERRerror); \
37 /* check req->async.status and if not OK then send an error reply */
38 #define CHECK_ASYNC_STATUS do { \
39 if (!NT_STATUS_IS_OK(req->async.status)) { \
40 req_reply_error(req, req->async.status); \
44 /* useful wrapper for talloc with NO_MEMORY reply */
45 #define REQ_TALLOC(ptr, size) do { \
46 ptr = talloc(req, size); \
48 req_reply_error(req, NT_STATUS_NO_MEMORY); \
53 check if the backend wants to handle the request asynchronously.
54 if it wants it handled synchronously then call the send function
57 #define REQ_ASYNC_TAIL do { \
58 if (!(req->control_flags & REQ_CONTROL_ASYNC)) { \
59 req->async.send_fn(req); \
62 /* zero out some reserved fields in a reply */
63 #define REQ_VWV_RESERVED(start, count) memset(req->out.vwv + VWV(start), 0, (count)*2)
65 /****************************************************************************
66 Reply to a simple request (async send)
67 ****************************************************************************/
68 static void reply_simple_send(struct smbsrv_request *req)
72 req_setup_reply(req, 0, 0);
77 /****************************************************************************
79 ****************************************************************************/
80 void reply_tcon(struct smbsrv_request *req)
87 REQ_CHECK_WCT(req, 0);
89 con.tcon.level = RAW_TCON_TCON;
92 p += req_pull_ascii4(req, &con.tcon.in.service, p, STR_TERMINATE);
93 p += req_pull_ascii4(req, &con.tcon.in.password, p, STR_TERMINATE);
94 p += req_pull_ascii4(req, &con.tcon.in.dev, p, STR_TERMINATE);
96 if (!con.tcon.in.service || !con.tcon.in.password || !con.tcon.in.dev) {
97 req_reply_error(req, NT_STATUS_INVALID_PARAMETER);
102 status = tcon_backend(req, &con);
104 if (!NT_STATUS_IS_OK(status)) {
105 req_reply_error(req, status);
109 /* construct reply */
110 req_setup_reply(req, 2, 0);
112 SSVAL(req->out.vwv, VWV(0), con.tcon.out.max_xmit);
113 SSVAL(req->out.vwv, VWV(1), con.tcon.out.cnum);
114 SSVAL(req->out.hdr, HDR_TID, req->tcon->cnum);
120 /****************************************************************************
121 Reply to a tcon and X.
122 ****************************************************************************/
123 void reply_tcon_and_X(struct smbsrv_request *req)
130 con.tconx.level = RAW_TCON_TCONX;
133 REQ_CHECK_WCT(req, 4);
135 con.tconx.in.flags = SVAL(req->in.vwv, VWV(2));
136 passlen = SVAL(req->in.vwv, VWV(3));
140 if (!req_pull_blob(req, p, passlen, &con.tconx.in.password)) {
141 req_reply_error(req, NT_STATUS_ILL_FORMED_PASSWORD);
146 p += req_pull_string(req, &con.tconx.in.path, p, -1, STR_TERMINATE);
147 p += req_pull_string(req, &con.tconx.in.device, p, -1, STR_ASCII);
149 if (!con.tconx.in.path || !con.tconx.in.device) {
150 req_reply_error(req, NT_STATUS_BAD_DEVICE_TYPE);
155 status = tcon_backend(req, &con);
157 if (!NT_STATUS_IS_OK(status)) {
158 req_reply_error(req, status);
162 /* construct reply - two variants */
163 if (req->smb_conn->negotiate.protocol < PROTOCOL_NT1) {
164 req_setup_reply(req, 2, 0);
166 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
167 SSVAL(req->out.vwv, VWV(1), 0);
169 req_push_str(req, NULL, con.tconx.out.dev_type, -1, STR_TERMINATE|STR_ASCII);
171 req_setup_reply(req, 3, 0);
173 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
174 SSVAL(req->out.vwv, VWV(1), 0);
175 SSVAL(req->out.vwv, VWV(2), con.tconx.out.options);
177 req_push_str(req, NULL, con.tconx.out.dev_type, -1, STR_TERMINATE|STR_ASCII);
178 req_push_str(req, NULL, con.tconx.out.fs_type, -1, STR_TERMINATE);
181 /* set the incoming and outgoing tid to the just created one */
182 SSVAL(req->in.hdr, HDR_TID, con.tconx.out.cnum);
183 SSVAL(req->out.hdr,HDR_TID, con.tconx.out.cnum);
189 /****************************************************************************
190 Reply to an unknown request
191 ****************************************************************************/
192 void reply_unknown(struct smbsrv_request *req)
196 type = CVAL(req->in.hdr, HDR_COM);
198 DEBUG(0,("unknown command type %d (0x%X)\n", type, type));
200 req_reply_dos_error(req, ERRSRV, ERRunknownsmb);
204 /****************************************************************************
205 Reply to an ioctl (async reply)
206 ****************************************************************************/
207 static void reply_ioctl_send(struct smbsrv_request *req)
209 union smb_ioctl *io = req->async.private;
213 /* the +1 is for nicer alignment */
214 req_setup_reply(req, 8, io->ioctl.out.blob.length+1);
215 SSVAL(req->out.vwv, VWV(1), io->ioctl.out.blob.length);
216 SSVAL(req->out.vwv, VWV(5), io->ioctl.out.blob.length);
217 SSVAL(req->out.vwv, VWV(6), PTR_DIFF(req->out.data, req->out.hdr) + 1);
219 memcpy(req->out.data+1, io->ioctl.out.blob.data, io->ioctl.out.blob.length);
224 /****************************************************************************
226 ****************************************************************************/
227 void reply_ioctl(struct smbsrv_request *req)
232 REQ_CHECK_WCT(req, 3);
233 REQ_TALLOC(io, sizeof(*io));
235 io->ioctl.level = RAW_IOCTL_IOCTL;
236 io->ioctl.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
237 io->ioctl.in.request = IVAL(req->in.vwv, VWV(1));
239 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
240 req->async.send_fn = reply_ioctl_send;
241 req->async.private = io;
244 req->async.status = ntvfs_ioctl(req, io);
250 /****************************************************************************
252 ****************************************************************************/
253 void reply_chkpth(struct smbsrv_request *req)
255 struct smb_chkpath *io;
257 REQ_TALLOC(io, sizeof(*io));
259 req_pull_ascii4(req, &io->in.path, req->in.data, STR_TERMINATE);
261 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
262 req->async.send_fn = reply_simple_send;
264 req->async.status = ntvfs_chkpath(req, io);
269 /****************************************************************************
270 Reply to a getatr (async reply)
271 ****************************************************************************/
272 static void reply_getatr_send(struct smbsrv_request *req)
274 union smb_fileinfo *st = req->async.private;
278 /* construct reply */
279 req_setup_reply(req, 10, 0);
281 SSVAL(req->out.vwv, VWV(0), st->getattr.out.attrib);
282 srv_push_dos_date3(req->smb_conn, req->out.vwv, VWV(1), st->getattr.out.write_time);
283 SIVAL(req->out.vwv, VWV(3), st->getattr.out.size);
285 REQ_VWV_RESERVED(5, 5);
291 /****************************************************************************
293 ****************************************************************************/
294 void reply_getatr(struct smbsrv_request *req)
296 union smb_fileinfo *st;
298 REQ_TALLOC(st, sizeof(*st));
300 st->getattr.level = RAW_FILEINFO_GETATTR;
303 req_pull_ascii4(req, &st->getattr.in.fname, req->in.data, STR_TERMINATE);
304 if (!st->getattr.in.fname) {
305 req_reply_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
309 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
310 req->async.send_fn = reply_getatr_send;
311 req->async.private = st;
314 req->async.status = ntvfs_qpathinfo(req, st);
320 /****************************************************************************
322 ****************************************************************************/
323 void reply_setatr(struct smbsrv_request *req)
325 union smb_setfileinfo *st;
328 REQ_CHECK_WCT(req, 8);
329 REQ_TALLOC(st, sizeof(*st));
331 st->setattr.level = RAW_SFILEINFO_SETATTR;
332 st->setattr.in.attrib = SVAL(req->in.vwv, VWV(0));
333 st->setattr.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
335 req_pull_ascii4(req, &st->setattr.file.fname, req->in.data, STR_TERMINATE);
337 if (!st->setattr.file.fname) {
338 req_reply_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
342 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
343 req->async.send_fn = reply_simple_send;
346 req->async.status = ntvfs_setpathinfo(req, st);
352 /****************************************************************************
353 Reply to a dskattr (async reply)
354 ****************************************************************************/
355 static void reply_dskattr_send(struct smbsrv_request *req)
357 union smb_fsinfo *fs = req->async.private;
361 /* construct reply */
362 req_setup_reply(req, 5, 0);
364 SSVAL(req->out.vwv, VWV(0), fs->dskattr.out.units_total);
365 SSVAL(req->out.vwv, VWV(1), fs->dskattr.out.blocks_per_unit);
366 SSVAL(req->out.vwv, VWV(2), fs->dskattr.out.block_size);
367 SSVAL(req->out.vwv, VWV(3), fs->dskattr.out.units_free);
369 REQ_VWV_RESERVED(4, 1);
375 /****************************************************************************
377 ****************************************************************************/
378 void reply_dskattr(struct smbsrv_request *req)
380 union smb_fsinfo *fs;
382 REQ_TALLOC(fs, sizeof(*fs));
384 fs->dskattr.level = RAW_QFS_DSKATTR;
386 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
387 req->async.send_fn = reply_dskattr_send;
388 req->async.private = fs;
391 req->async.status = ntvfs_fsinfo(req, fs);
398 /****************************************************************************
399 Reply to an open (async reply)
400 ****************************************************************************/
401 static void reply_open_send(struct smbsrv_request *req)
403 union smb_open *oi = req->async.private;
407 /* construct reply */
408 req_setup_reply(req, 7, 0);
410 SSVAL(req->out.vwv, VWV(0), oi->open.out.fnum);
411 SSVAL(req->out.vwv, VWV(1), oi->open.out.attrib);
412 srv_push_dos_date3(req->smb_conn, req->out.vwv, VWV(2), oi->open.out.write_time);
413 SIVAL(req->out.vwv, VWV(4), oi->open.out.size);
414 SSVAL(req->out.vwv, VWV(6), oi->open.out.rmode);
419 /****************************************************************************
421 ****************************************************************************/
422 void reply_open(struct smbsrv_request *req)
427 REQ_CHECK_WCT(req, 2);
428 REQ_TALLOC(oi, sizeof(*oi));
430 oi->open.level = RAW_OPEN_OPEN;
431 oi->open.in.flags = SVAL(req->in.vwv, VWV(0));
432 oi->open.in.search_attrs = SVAL(req->in.vwv, VWV(1));
434 req_pull_ascii4(req, &oi->open.in.fname, req->in.data, STR_TERMINATE);
436 if (!oi->open.in.fname) {
437 req_reply_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
441 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
442 req->async.send_fn = reply_open_send;
443 req->async.private = oi;
446 req->async.status = ntvfs_open(req, oi);
452 /****************************************************************************
453 Reply to an open and X (async reply)
454 ****************************************************************************/
455 static void reply_open_and_X_send(struct smbsrv_request *req)
457 union smb_open *oi = req->async.private;
461 /* build the reply */
462 if (oi->openx.in.flags & OPENX_FLAGS_EXTENDED_RETURN) {
463 req_setup_reply(req, 19, 0);
465 req_setup_reply(req, 15, 0);
468 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
469 SSVAL(req->out.vwv, VWV(1), 0);
470 SSVAL(req->out.vwv, VWV(2), oi->openx.out.fnum);
471 SSVAL(req->out.vwv, VWV(3), oi->openx.out.attrib);
472 srv_push_dos_date3(req->smb_conn, req->out.vwv, VWV(4), oi->openx.out.write_time);
473 SIVAL(req->out.vwv, VWV(6), oi->openx.out.size);
474 SSVAL(req->out.vwv, VWV(8), oi->openx.out.access);
475 SSVAL(req->out.vwv, VWV(9), oi->openx.out.ftype);
476 SSVAL(req->out.vwv, VWV(10),oi->openx.out.devstate);
477 SSVAL(req->out.vwv, VWV(11),oi->openx.out.action);
478 SIVAL(req->out.vwv, VWV(12),oi->openx.out.unique_fid);
479 SSVAL(req->out.vwv, VWV(14),0); /* reserved */
480 if (oi->openx.in.flags & OPENX_FLAGS_EXTENDED_RETURN) {
481 SIVAL(req->out.vwv, VWV(15),oi->openx.out.access_mask);
482 REQ_VWV_RESERVED(17, 2);
489 /****************************************************************************
490 Reply to an open and X.
491 ****************************************************************************/
492 void reply_open_and_X(struct smbsrv_request *req)
496 /* parse the request */
497 REQ_CHECK_WCT(req, 15);
498 REQ_TALLOC(oi, sizeof(*oi));
500 oi->openx.level = RAW_OPEN_OPENX;
501 oi->openx.in.flags = SVAL(req->in.vwv, VWV(2));
502 oi->openx.in.open_mode = SVAL(req->in.vwv, VWV(3));
503 oi->openx.in.search_attrs = SVAL(req->in.vwv, VWV(4));
504 oi->openx.in.file_attrs = SVAL(req->in.vwv, VWV(5));
505 oi->openx.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(6));
506 oi->openx.in.open_func = SVAL(req->in.vwv, VWV(8));
507 oi->openx.in.size = IVAL(req->in.vwv, VWV(9));
508 oi->openx.in.timeout = IVAL(req->in.vwv, VWV(11));
510 req_pull_ascii4(req, &oi->openx.in.fname, req->in.data, STR_TERMINATE);
512 if (!oi->openx.in.fname) {
513 req_reply_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
517 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
518 req->async.send_fn = reply_open_and_X_send;
519 req->async.private = oi;
521 /* call the backend */
522 req->async.status = ntvfs_open(req, oi);
528 /****************************************************************************
529 Reply to a mknew or a create.
530 ****************************************************************************/
531 static void reply_mknew_send(struct smbsrv_request *req)
533 union smb_open *oi = req->async.private;
537 /* build the reply */
538 req_setup_reply(req, 1, 0);
540 SSVAL(req->out.vwv, VWV(0), oi->mknew.out.fnum);
546 /****************************************************************************
547 Reply to a mknew or a create.
548 ****************************************************************************/
549 void reply_mknew(struct smbsrv_request *req)
553 /* parse the request */
554 REQ_CHECK_WCT(req, 3);
555 REQ_TALLOC(oi, sizeof(*oi));
557 oi->mknew.level = RAW_OPEN_MKNEW;
558 oi->mknew.in.attrib = SVAL(req->in.vwv, VWV(0));
559 oi->mknew.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
561 req_pull_ascii4(req, &oi->mknew.in.fname, req->in.data, STR_TERMINATE);
563 if (!oi->mknew.in.fname) {
564 req_reply_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
568 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
569 req->async.send_fn = reply_mknew_send;
570 req->async.private = oi;
572 /* call the backend */
573 req->async.status = ntvfs_open(req, oi);
578 /****************************************************************************
579 Reply to a create temporary file (async reply)
580 ****************************************************************************/
581 static void reply_ctemp_send(struct smbsrv_request *req)
583 union smb_open *oi = req->async.private;
587 /* build the reply */
588 req_setup_reply(req, 1, 0);
590 SSVAL(req->out.vwv, VWV(0), oi->ctemp.out.fnum);
592 /* the returned filename is relative to the directory */
593 req_push_str(req, NULL, oi->ctemp.out.name, -1, STR_TERMINATE);
598 /****************************************************************************
599 Reply to a create temporary file.
600 ****************************************************************************/
601 void reply_ctemp(struct smbsrv_request *req)
605 /* parse the request */
606 REQ_CHECK_WCT(req, 3);
607 REQ_TALLOC(oi, sizeof(*oi));
609 oi->ctemp.level = RAW_OPEN_CTEMP;
610 oi->ctemp.in.attrib = SVAL(req->in.vwv, VWV(0));
611 oi->ctemp.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
613 /* the filename is actually a directory name, the server provides a filename
615 req_pull_ascii4(req, &oi->ctemp.in.directory, req->in.data, STR_TERMINATE);
617 if (!oi->ctemp.in.directory) {
618 req_reply_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
622 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
623 req->async.send_fn = reply_ctemp_send;
624 req->async.private = oi;
626 /* call the backend */
627 req->async.status = ntvfs_open(req, oi);
633 /****************************************************************************
635 ****************************************************************************/
636 void reply_unlink(struct smbsrv_request *req)
638 struct smb_unlink *unl;
640 /* parse the request */
641 REQ_CHECK_WCT(req, 1);
642 REQ_TALLOC(unl, sizeof(*unl));
644 unl->in.attrib = SVAL(req->in.vwv, VWV(0));
646 req_pull_ascii4(req, &unl->in.pattern, req->in.data, STR_TERMINATE);
648 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
649 req->async.send_fn = reply_simple_send;
652 req->async.status = ntvfs_unlink(req, unl);
658 /****************************************************************************
659 Reply to a readbraw (core+ protocol).
660 this is a strange packet because it doesn't use a standard SMB header in the reply,
661 only the 4 byte NBT header
662 This command must be replied to synchronously
663 ****************************************************************************/
664 void reply_readbraw(struct smbsrv_request *req)
669 io.readbraw.level = RAW_READ_READBRAW;
671 /* there are two variants, one with 10 and one with 8 command words */
672 if (req->in.wct < 8) {
676 io.readbraw.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
677 io.readbraw.in.offset = IVAL(req->in.vwv, VWV(1));
678 io.readbraw.in.maxcnt = SVAL(req->in.vwv, VWV(3));
679 io.readbraw.in.mincnt = SVAL(req->in.vwv, VWV(4));
680 io.readbraw.in.timeout = IVAL(req->in.vwv, VWV(5));
682 /* the 64 bit variant */
683 if (req->in.wct == 10) {
684 uint32_t offset_high = IVAL(req->in.vwv, VWV(8));
685 io.readbraw.in.offset |= (((SMB_OFF_T)offset_high) << 32);
688 /* before calling the backend we setup the raw buffer. This
689 * saves a copy later */
690 req->out.size = io.readbraw.in.maxcnt + NBT_HDR_SIZE;
691 req->out.buffer = talloc(req, req->out.size);
692 if (req->out.buffer == NULL) {
695 SIVAL(req->out.buffer, 0, 0); /* init NBT header */
697 /* tell the backend where to put the data */
698 io.readbraw.out.data = req->out.buffer + NBT_HDR_SIZE;
700 /* call the backend */
701 status = ntvfs_read(req, &io);
703 if (!NT_STATUS_IS_OK(status)) {
707 req->out.size = io.readbraw.out.nread + NBT_HDR_SIZE;
709 req_send_reply_nosign(req);
713 /* any failure in readbraw is equivalent to reading zero bytes */
715 req->out.buffer = talloc(req, req->out.size);
716 SIVAL(req->out.buffer, 0, 0); /* init NBT header */
718 req_send_reply_nosign(req);
722 /****************************************************************************
723 Reply to a lockread (async reply)
724 ****************************************************************************/
725 static void reply_lockread_send(struct smbsrv_request *req)
727 union smb_read *io = req->async.private;
732 io->lockread.out.nread = MIN(io->lockread.out.nread,
733 req_max_data(req) - 3);
734 req_grow_data(req, 3 + io->lockread.out.nread);
736 /* construct reply */
737 SSVAL(req->out.vwv, VWV(0), io->lockread.out.nread);
738 REQ_VWV_RESERVED(1, 4);
740 SCVAL(req->out.data, 0, SMB_DATA_BLOCK);
741 SSVAL(req->out.data, 1, io->lockread.out.nread);
747 /****************************************************************************
748 Reply to a lockread (core+ protocol).
749 note that the lock is a write lock, not a read lock!
750 ****************************************************************************/
751 void reply_lockread(struct smbsrv_request *req)
756 REQ_CHECK_WCT(req, 5);
757 REQ_TALLOC(io, sizeof(*io));
759 io->lockread.level = RAW_READ_LOCKREAD;
760 io->lockread.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
761 io->lockread.in.count = SVAL(req->in.vwv, VWV(1));
762 io->lockread.in.offset = IVAL(req->in.vwv, VWV(2));
763 io->lockread.in.remaining = SVAL(req->in.vwv, VWV(4));
765 /* setup the reply packet assuming the maximum possible read */
766 req_setup_reply(req, 5, 3 + io->lockread.in.count);
768 /* tell the backend where to put the data */
769 io->lockread.out.data = req->out.data + 3;
771 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
772 req->async.send_fn = reply_lockread_send;
773 req->async.private = io;
776 req->async.status = ntvfs_read(req, io);
783 /****************************************************************************
784 Reply to a read (async reply)
785 ****************************************************************************/
786 static void reply_read_send(struct smbsrv_request *req)
788 union smb_read *io = req->async.private;
793 io->read.out.nread = MIN(io->read.out.nread,
794 req_max_data(req) - 3);
795 req_grow_data(req, 3 + io->read.out.nread);
797 /* construct reply */
798 SSVAL(req->out.vwv, VWV(0), io->read.out.nread);
799 REQ_VWV_RESERVED(1, 4);
801 SCVAL(req->out.data, 0, SMB_DATA_BLOCK);
802 SSVAL(req->out.data, 1, io->read.out.nread);
807 /****************************************************************************
809 ****************************************************************************/
810 void reply_read(struct smbsrv_request *req)
815 REQ_CHECK_WCT(req, 5);
816 REQ_TALLOC(io, sizeof(*io));
818 io->read.level = RAW_READ_READ;
819 io->read.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
820 io->read.in.count = SVAL(req->in.vwv, VWV(1));
821 io->read.in.offset = IVAL(req->in.vwv, VWV(2));
822 io->read.in.remaining = SVAL(req->in.vwv, VWV(4));
824 /* setup the reply packet assuming the maximum possible read */
825 req_setup_reply(req, 5, 3 + io->read.in.count);
827 /* tell the backend where to put the data */
828 io->read.out.data = req->out.data + 3;
830 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
831 req->async.send_fn = reply_read_send;
832 req->async.private = io;
835 req->async.status = ntvfs_read(req, io);
842 /****************************************************************************
843 Reply to a read and X (async reply)
844 ****************************************************************************/
845 static void reply_read_and_X_send(struct smbsrv_request *req)
847 union smb_read *io = req->async.private;
851 /* readx reply packets can be over-sized */
852 req->control_flags |= REQ_CONTROL_LARGE;
853 if (io->readx.in.maxcnt != 0xFFFF &&
854 io->readx.in.mincnt != 0xFFFF) {
855 req_grow_data(req, 1 + io->readx.out.nread);
856 SCVAL(req->out.data, 0, 0); /* padding */
858 req_grow_data(req, io->readx.out.nread);
861 /* construct reply */
862 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
863 SSVAL(req->out.vwv, VWV(1), 0);
864 SSVAL(req->out.vwv, VWV(2), io->readx.out.remaining);
865 SSVAL(req->out.vwv, VWV(3), io->readx.out.compaction_mode);
866 REQ_VWV_RESERVED(4, 1);
867 SSVAL(req->out.vwv, VWV(5), io->readx.out.nread);
868 SSVAL(req->out.vwv, VWV(6), PTR_DIFF(io->readx.out.data, req->out.hdr));
869 REQ_VWV_RESERVED(7, 5);
874 /****************************************************************************
875 Reply to a read and X.
876 ****************************************************************************/
877 void reply_read_and_X(struct smbsrv_request *req)
882 if (req->in.wct != 12) {
883 REQ_CHECK_WCT(req, 10);
886 REQ_TALLOC(io, sizeof(*io));
888 io->readx.level = RAW_READ_READX;
889 io->readx.in.fnum = req_fnum(req, req->in.vwv, VWV(2));
890 io->readx.in.offset = IVAL(req->in.vwv, VWV(3));
891 io->readx.in.maxcnt = SVAL(req->in.vwv, VWV(5));
892 io->readx.in.mincnt = SVAL(req->in.vwv, VWV(6));
893 io->readx.in.remaining = SVAL(req->in.vwv, VWV(9));
895 /* the 64 bit variant */
896 if (req->in.wct == 12) {
897 uint32_t offset_high = IVAL(req->in.vwv, VWV(10));
898 io->readx.in.offset |= (((uint64_t)offset_high) << 32);
901 /* setup the reply packet assuming the maximum possible read */
902 req_setup_reply(req, 12, 1 + io->readx.in.maxcnt);
904 /* tell the backend where to put the data. Notice the pad byte. */
905 if (io->readx.in.maxcnt != 0xFFFF &&
906 io->readx.in.mincnt != 0xFFFF) {
907 io->readx.out.data = req->out.data + 1;
909 io->readx.out.data = req->out.data;
912 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
913 req->async.send_fn = reply_read_and_X_send;
914 req->async.private = io;
917 req->async.status = ntvfs_read(req, io);
923 /****************************************************************************
924 Reply to a writebraw (core+ or LANMAN1.0 protocol).
925 ****************************************************************************/
926 void reply_writebraw(struct smbsrv_request *req)
928 /* this one is damn complex - put it off for now */
929 req_reply_error(req, NT_STATUS_FOOBAR);
933 /****************************************************************************
934 Reply to a writeunlock (async reply)
935 ****************************************************************************/
936 static void reply_writeunlock_send(struct smbsrv_request *req)
938 union smb_write *io = req->async.private;
942 /* construct reply */
943 req_setup_reply(req, 1, 0);
945 SSVAL(req->out.vwv, VWV(0), io->writeunlock.out.nwritten);
950 /****************************************************************************
951 Reply to a writeunlock (core+).
952 ****************************************************************************/
953 void reply_writeunlock(struct smbsrv_request *req)
957 REQ_CHECK_WCT(req, 5);
958 REQ_TALLOC(io, sizeof(*io));
960 io->writeunlock.level = RAW_WRITE_WRITEUNLOCK;
961 io->writeunlock.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
962 io->writeunlock.in.count = SVAL(req->in.vwv, VWV(1));
963 io->writeunlock.in.offset = IVAL(req->in.vwv, VWV(2));
964 io->writeunlock.in.remaining = SVAL(req->in.vwv, VWV(4));
965 io->writeunlock.in.data = req->in.data + 3;
967 /* make sure they gave us the data they promised */
968 if (io->writeunlock.in.count+3 > req->in.data_size) {
969 req_reply_error(req, NT_STATUS_FOOBAR);
973 /* make sure the data block is big enough */
974 if (SVAL(req->in.data, 1) < io->writeunlock.in.count) {
975 req_reply_error(req, NT_STATUS_FOOBAR);
979 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
980 req->async.send_fn = reply_writeunlock_send;
981 req->async.private = io;
984 req->async.status = ntvfs_write(req, io);
991 /****************************************************************************
992 Reply to a write (async reply)
993 ****************************************************************************/
994 static void reply_write_send(struct smbsrv_request *req)
996 union smb_write *io = req->async.private;
1000 /* construct reply */
1001 req_setup_reply(req, 1, 0);
1003 SSVAL(req->out.vwv, VWV(0), io->write.out.nwritten);
1005 req_send_reply(req);
1008 /****************************************************************************
1010 ****************************************************************************/
1011 void reply_write(struct smbsrv_request *req)
1013 union smb_write *io;
1015 REQ_CHECK_WCT(req, 5);
1016 REQ_TALLOC(io, sizeof(*io));
1018 io->write.level = RAW_WRITE_WRITE;
1019 io->write.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1020 io->write.in.count = SVAL(req->in.vwv, VWV(1));
1021 io->write.in.offset = IVAL(req->in.vwv, VWV(2));
1022 io->write.in.remaining = SVAL(req->in.vwv, VWV(4));
1023 io->write.in.data = req->in.data + 3;
1025 /* make sure they gave us the data they promised */
1026 if (req_data_oob(req, io->write.in.data, io->write.in.count)) {
1027 req_reply_error(req, NT_STATUS_FOOBAR);
1031 /* make sure the data block is big enough */
1032 if (SVAL(req->in.data, 1) < io->write.in.count) {
1033 req_reply_error(req, NT_STATUS_FOOBAR);
1037 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1038 req->async.send_fn = reply_write_send;
1039 req->async.private = io;
1042 req->async.status = ntvfs_write(req, io);
1048 /****************************************************************************
1049 Reply to a write and X (async reply)
1050 ****************************************************************************/
1051 static void reply_write_and_X_send(struct smbsrv_request *req)
1053 union smb_write *io = req->async.private;
1057 /* construct reply */
1058 req_setup_reply(req, 6, 0);
1060 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
1061 SSVAL(req->out.vwv, VWV(1), 0);
1062 SSVAL(req->out.vwv, VWV(2), io->writex.out.nwritten & 0xFFFF);
1063 SSVAL(req->out.vwv, VWV(3), io->writex.out.remaining);
1064 SSVAL(req->out.vwv, VWV(4), io->writex.out.nwritten >> 16);
1065 REQ_VWV_RESERVED(5, 1);
1070 /****************************************************************************
1071 Reply to a write and X.
1072 ****************************************************************************/
1073 void reply_write_and_X(struct smbsrv_request *req)
1075 union smb_write *io;
1077 if (req->in.wct != 14) {
1078 REQ_CHECK_WCT(req, 12);
1081 REQ_TALLOC(io, sizeof(*io));
1083 io->writex.level = RAW_WRITE_WRITEX;
1084 io->writex.in.fnum = req_fnum(req, req->in.vwv, VWV(2));
1085 io->writex.in.offset = IVAL(req->in.vwv, VWV(3));
1086 io->writex.in.wmode = SVAL(req->in.vwv, VWV(7));
1087 io->writex.in.remaining = SVAL(req->in.vwv, VWV(8));
1088 io->writex.in.count = SVAL(req->in.vwv, VWV(10));
1089 io->writex.in.data = req->in.hdr + SVAL(req->in.vwv, VWV(11));
1091 if (req->in.wct == 14) {
1092 uint32_t offset_high = IVAL(req->in.vwv, VWV(12));
1093 uint16_t count_high = SVAL(req->in.vwv, VWV(9));
1094 io->writex.in.offset |= (((uint64_t)offset_high) << 32);
1095 io->writex.in.count |= ((uint32_t)count_high) << 16;
1098 /* make sure the data is in bounds */
1099 if (req_data_oob(req, io->writex.in.data, io->writex.in.count)) {
1100 req_reply_error(req, NT_STATUS_FOOBAR);
1104 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1105 req->async.send_fn = reply_write_and_X_send;
1106 req->async.private = io;
1109 req->async.status = ntvfs_write(req, io);
1115 /****************************************************************************
1116 Reply to a lseek (async reply)
1117 ****************************************************************************/
1118 static void reply_lseek_send(struct smbsrv_request *req)
1120 struct smb_seek *io = req->async.private;
1124 /* construct reply */
1125 req_setup_reply(req, 2, 0);
1127 SIVALS(req->out.vwv, VWV(0), io->out.offset);
1129 req_send_reply(req);
1132 /****************************************************************************
1134 ****************************************************************************/
1135 void reply_lseek(struct smbsrv_request *req)
1137 struct smb_seek *io;
1139 REQ_CHECK_WCT(req, 4);
1140 REQ_TALLOC(io, sizeof(*io));
1142 io->in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1143 io->in.mode = SVAL(req->in.vwv, VWV(1));
1144 io->in.offset = IVALS(req->in.vwv, VWV(2));
1146 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1147 req->async.send_fn = reply_lseek_send;
1148 req->async.private = io;
1151 req->async.status = ntvfs_seek(req, io);
1156 /****************************************************************************
1158 ****************************************************************************/
1159 void reply_flush(struct smbsrv_request *req)
1161 struct smb_flush *io;
1164 REQ_CHECK_WCT(req, 1);
1165 REQ_TALLOC(io, sizeof(*io));
1167 io->in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1169 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1170 req->async.send_fn = reply_simple_send;
1173 req->async.status = ntvfs_flush(req, io);
1179 /****************************************************************************
1180 Reply to a exit. This closes all files open by a smbpid
1181 ****************************************************************************/
1182 void reply_exit(struct smbsrv_request *req)
1185 struct smbsrv_tcon *tcon;
1186 REQ_CHECK_WCT(req, 0);
1188 for (tcon=req->smb_conn->tree.tcons;tcon;tcon=tcon->next) {
1190 status = ntvfs_exit(req);
1192 if (!NT_STATUS_IS_OK(status)) {
1193 req_reply_error(req, status);
1198 req_setup_reply(req, 0, 0);
1199 req_send_reply(req);
1203 /****************************************************************************
1206 Note that this has to deal with closing a directory opened by NT SMB's.
1207 ****************************************************************************/
1208 void reply_close(struct smbsrv_request *req)
1210 union smb_close *io;
1213 REQ_CHECK_WCT(req, 3);
1214 REQ_TALLOC(io, sizeof(*io));
1216 io->close.level = RAW_CLOSE_CLOSE;
1217 io->close.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1218 io->close.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
1220 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1221 req->async.send_fn = reply_simple_send;
1224 req->async.status = ntvfs_close(req, io);
1231 /****************************************************************************
1232 Reply to a writeclose (async reply)
1233 ****************************************************************************/
1234 static void reply_writeclose_send(struct smbsrv_request *req)
1236 union smb_write *io = req->async.private;
1240 /* construct reply */
1241 req_setup_reply(req, 1, 0);
1243 SSVAL(req->out.vwv, VWV(0), io->write.out.nwritten);
1245 req_send_reply(req);
1248 /****************************************************************************
1249 Reply to a writeclose (Core+ protocol).
1250 ****************************************************************************/
1251 void reply_writeclose(struct smbsrv_request *req)
1253 union smb_write *io;
1255 /* this one is pretty weird - the wct can be 6 or 12 */
1256 if (req->in.wct != 12) {
1257 REQ_CHECK_WCT(req, 6);
1260 REQ_TALLOC(io, sizeof(*io));
1262 io->writeclose.level = RAW_WRITE_WRITECLOSE;
1263 io->writeclose.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1264 io->writeclose.in.count = SVAL(req->in.vwv, VWV(1));
1265 io->writeclose.in.offset = IVAL(req->in.vwv, VWV(2));
1266 io->writeclose.in.mtime = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(4));
1267 io->writeclose.in.data = req->in.data + 1;
1269 /* make sure they gave us the data they promised */
1270 if (req_data_oob(req, io->writeclose.in.data, io->writeclose.in.count)) {
1271 req_reply_error(req, NT_STATUS_FOOBAR);
1275 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1276 req->async.send_fn = reply_writeclose_send;
1277 req->async.private = io;
1280 req->async.status = ntvfs_write(req, io);
1285 /****************************************************************************
1287 ****************************************************************************/
1288 void reply_lock(struct smbsrv_request *req)
1290 union smb_lock *lck;
1293 REQ_CHECK_WCT(req, 5);
1294 REQ_TALLOC(lck, sizeof(*lck));
1296 lck->lock.level = RAW_LOCK_LOCK;
1297 lck->lock.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1298 lck->lock.in.count = IVAL(req->in.vwv, VWV(1));
1299 lck->lock.in.offset = IVAL(req->in.vwv, VWV(3));
1301 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1302 req->async.send_fn = reply_simple_send;
1305 req->async.status = ntvfs_lock(req, lck);
1311 /****************************************************************************
1313 ****************************************************************************/
1314 void reply_unlock(struct smbsrv_request *req)
1316 union smb_lock *lck;
1319 REQ_CHECK_WCT(req, 5);
1320 REQ_TALLOC(lck, sizeof(*lck));
1322 lck->unlock.level = RAW_LOCK_UNLOCK;
1323 lck->unlock.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1324 lck->unlock.in.count = IVAL(req->in.vwv, VWV(1));
1325 lck->unlock.in.offset = IVAL(req->in.vwv, VWV(3));
1327 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1328 req->async.send_fn = reply_simple_send;
1331 req->async.status = ntvfs_lock(req, lck);
1337 /****************************************************************************
1339 ****************************************************************************/
1340 void reply_tdis(struct smbsrv_request *req)
1342 REQ_CHECK_WCT(req, 0);
1344 close_cnum(req->tcon);
1346 /* construct reply */
1347 req_setup_reply(req, 0, 0);
1349 req_send_reply(req);
1353 /****************************************************************************
1354 Reply to a echo. This is one of the few calls that is handled directly (the
1355 backends don't see it at all)
1356 ****************************************************************************/
1357 void reply_echo(struct smbsrv_request *req)
1362 REQ_CHECK_WCT(req, 0);
1364 count = SVAL(req->in.vwv, VWV(0));
1366 req_setup_reply(req, 1, req->in.data_size);
1368 memcpy(req->out.data, req->in.data, req->in.data_size);
1370 for (i=1; i <= count;i++) {
1372 talloc_increase_ref_count(req);
1375 SSVAL(req->out.vwv, VWV(0), i);
1376 req_send_reply(req);
1382 /****************************************************************************
1383 Reply to a printopen (async reply)
1384 ****************************************************************************/
1385 static void reply_printopen_send(struct smbsrv_request *req)
1387 union smb_open *oi = req->async.private;
1391 /* construct reply */
1392 req_setup_reply(req, 1, 0);
1394 SSVAL(req->out.vwv, VWV(0), oi->open.out.fnum);
1396 req_send_reply(req);
1399 /****************************************************************************
1400 Reply to a printopen.
1401 ****************************************************************************/
1402 void reply_printopen(struct smbsrv_request *req)
1407 REQ_CHECK_WCT(req, 2);
1408 REQ_TALLOC(oi, sizeof(*oi));
1410 oi->splopen.level = RAW_OPEN_SPLOPEN;
1411 oi->splopen.in.setup_length = SVAL(req->in.vwv, VWV(0));
1412 oi->splopen.in.mode = SVAL(req->in.vwv, VWV(1));
1414 req_pull_ascii4(req, &oi->splopen.in.ident, req->in.data, STR_TERMINATE);
1416 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1417 req->async.send_fn = reply_printopen_send;
1418 req->async.private = oi;
1421 req->async.status = ntvfs_open(req, oi);
1426 /****************************************************************************
1427 Reply to a printclose.
1428 ****************************************************************************/
1429 void reply_printclose(struct smbsrv_request *req)
1431 union smb_close *io;
1434 REQ_CHECK_WCT(req, 3);
1435 REQ_TALLOC(io, sizeof(*io));
1437 io->splclose.level = RAW_CLOSE_SPLCLOSE;
1438 io->splclose.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1440 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1441 req->async.send_fn = reply_simple_send;
1444 req->async.status = ntvfs_close(req, io);
1449 /****************************************************************************
1450 Reply to a printqueue.
1451 ****************************************************************************/
1452 void reply_printqueue_send(struct smbsrv_request *req)
1454 union smb_lpq *lpq = req->async.private;
1456 const uint_t el_size = 28;
1460 /* construct reply */
1461 req_setup_reply(req, 2, 0);
1463 /* truncate the returned list to fit in the negotiated buffer size */
1464 maxcount = (req_max_data(req) - 3) / el_size;
1465 if (maxcount < lpq->retq.out.count) {
1466 lpq->retq.out.count = maxcount;
1469 /* setup enough space in the reply */
1470 req_grow_data(req, 3 + el_size*lpq->retq.out.count);
1472 /* and fill it in */
1473 SSVAL(req->out.vwv, VWV(0), lpq->retq.out.count);
1474 SSVAL(req->out.vwv, VWV(1), lpq->retq.out.restart_idx);
1476 SCVAL(req->out.data, 0, SMB_DATA_BLOCK);
1477 SSVAL(req->out.data, 1, el_size*lpq->retq.out.count);
1479 req->out.ptr = req->out.data + 3;
1481 for (i=0;i<lpq->retq.out.count;i++) {
1482 srv_push_dos_date2(req->smb_conn, req->out.ptr, 0 , lpq->retq.out.queue[i].time);
1483 SCVAL(req->out.ptr, 4, lpq->retq.out.queue[i].status);
1484 SSVAL(req->out.ptr, 5, lpq->retq.out.queue[i].job);
1485 SIVAL(req->out.ptr, 7, lpq->retq.out.queue[i].size);
1486 SCVAL(req->out.ptr, 11, 0); /* reserved */
1487 req_push_str(req, req->out.ptr+12, lpq->retq.out.queue[i].user, 16, STR_ASCII);
1488 req->out.ptr += el_size;
1491 req_send_reply(req);
1494 /****************************************************************************
1495 Reply to a printqueue.
1496 ****************************************************************************/
1497 void reply_printqueue(struct smbsrv_request *req)
1502 REQ_CHECK_WCT(req, 2);
1503 REQ_TALLOC(lpq, sizeof(*lpq));
1505 lpq->retq.level = RAW_LPQ_RETQ;
1506 lpq->retq.in.maxcount = SVAL(req->in.vwv, VWV(0));
1507 lpq->retq.in.startidx = SVAL(req->in.vwv, VWV(1));
1509 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1510 req->async.send_fn = reply_printqueue_send;
1511 req->async.private = lpq;
1514 req->async.status = ntvfs_lpq(req, lpq);
1520 /****************************************************************************
1521 Reply to a printwrite.
1522 ****************************************************************************/
1523 void reply_printwrite(struct smbsrv_request *req)
1525 union smb_write *io;
1528 REQ_CHECK_WCT(req, 1);
1529 REQ_TALLOC(io, sizeof(*io));
1531 io->splwrite.level = RAW_WRITE_SPLWRITE;
1533 if (req->in.data_size < 3) {
1534 req_reply_error(req, NT_STATUS_FOOBAR);
1538 io->splwrite.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1539 io->splwrite.in.count = SVAL(req->in.data, 1);
1540 io->splwrite.in.data = req->in.data + 3;
1542 /* make sure they gave us the data they promised */
1543 if (req_data_oob(req, io->splwrite.in.data, io->splwrite.in.count)) {
1544 req_reply_error(req, NT_STATUS_FOOBAR);
1548 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1549 req->async.send_fn = reply_simple_send;
1552 req->async.status = ntvfs_write(req, io);
1558 /****************************************************************************
1560 ****************************************************************************/
1561 void reply_mkdir(struct smbsrv_request *req)
1563 union smb_mkdir *io;
1565 /* parse the request */
1566 REQ_CHECK_WCT(req, 0);
1567 REQ_TALLOC(io, sizeof(*io));
1569 io->generic.level = RAW_MKDIR_MKDIR;
1570 req_pull_ascii4(req, &io->mkdir.in.path, req->in.data, STR_TERMINATE);
1572 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1573 req->async.send_fn = reply_simple_send;
1576 req->async.status = ntvfs_mkdir(req, io);
1582 /****************************************************************************
1584 ****************************************************************************/
1585 void reply_rmdir(struct smbsrv_request *req)
1587 struct smb_rmdir *io;
1589 /* parse the request */
1590 REQ_CHECK_WCT(req, 0);
1591 REQ_TALLOC(io, sizeof(*io));
1593 req_pull_ascii4(req, &io->in.path, req->in.data, STR_TERMINATE);
1595 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1596 req->async.send_fn = reply_simple_send;
1599 req->async.status = ntvfs_rmdir(req, io);
1605 /****************************************************************************
1607 ****************************************************************************/
1608 void reply_mv(struct smbsrv_request *req)
1610 union smb_rename *io;
1613 /* parse the request */
1614 REQ_CHECK_WCT(req, 1);
1615 REQ_TALLOC(io, sizeof(*io));
1617 io->generic.level = RAW_RENAME_RENAME;
1618 io->rename.in.attrib = SVAL(req->in.vwv, VWV(0));
1621 p += req_pull_ascii4(req, &io->rename.in.pattern1, p, STR_TERMINATE);
1622 p += req_pull_ascii4(req, &io->rename.in.pattern2, p, STR_TERMINATE);
1624 if (!io->rename.in.pattern1 || !io->rename.in.pattern2) {
1625 req_reply_error(req, NT_STATUS_FOOBAR);
1629 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1630 req->async.send_fn = reply_simple_send;
1633 req->async.status = ntvfs_rename(req, io);
1639 /****************************************************************************
1640 Reply to an NT rename.
1641 ****************************************************************************/
1642 void reply_ntrename(struct smbsrv_request *req)
1644 union smb_rename *io;
1647 /* parse the request */
1648 REQ_CHECK_WCT(req, 4);
1649 REQ_TALLOC(io, sizeof(*io));
1651 io->generic.level = RAW_RENAME_NTRENAME;
1652 io->ntrename.in.attrib = SVAL(req->in.vwv, VWV(0));
1653 io->ntrename.in.flags = SVAL(req->in.vwv, VWV(1));
1654 io->ntrename.in.cluster_size = IVAL(req->in.vwv, VWV(2));
1657 p += req_pull_ascii4(req, &io->ntrename.in.old_name, p, STR_TERMINATE);
1658 p += req_pull_ascii4(req, &io->ntrename.in.new_name, p, STR_TERMINATE);
1660 if (!io->ntrename.in.old_name || !io->ntrename.in.new_name) {
1661 req_reply_error(req, NT_STATUS_FOOBAR);
1665 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1666 req->async.send_fn = reply_simple_send;
1669 req->async.status = ntvfs_rename(req, io);
1674 /****************************************************************************
1675 Reply to a file copy (async reply)
1676 ****************************************************************************/
1677 static void reply_copy_send(struct smbsrv_request *req)
1679 struct smb_copy *cp = req->async.private;
1683 /* build the reply */
1684 req_setup_reply(req, 1, 0);
1686 SSVAL(req->out.vwv, VWV(0), cp->out.count);
1688 req_send_reply(req);
1691 /****************************************************************************
1692 Reply to a file copy.
1693 ****************************************************************************/
1694 void reply_copy(struct smbsrv_request *req)
1696 struct smb_copy *cp;
1700 REQ_CHECK_WCT(req, 3);
1701 REQ_TALLOC(cp, sizeof(*cp));
1703 cp->in.tid2 = SVAL(req->in.vwv, VWV(0));
1704 cp->in.ofun = SVAL(req->in.vwv, VWV(1));
1705 cp->in.flags = SVAL(req->in.vwv, VWV(2));
1708 p += req_pull_ascii4(req, &cp->in.path1, p, STR_TERMINATE);
1709 p += req_pull_ascii4(req, &cp->in.path2, p, STR_TERMINATE);
1711 if (!cp->in.path1 || !cp->in.path2) {
1712 req_reply_error(req, NT_STATUS_FOOBAR);
1716 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1717 req->async.send_fn = reply_copy_send;
1718 req->async.private = cp;
1721 req->async.status = ntvfs_copy(req, cp);
1726 /****************************************************************************
1727 Reply to a lockingX request (async send)
1728 ****************************************************************************/
1729 static void reply_lockingX_send(struct smbsrv_request *req)
1731 union smb_lock *lck = req->async.private;
1735 /* if it was an oplock break ack then we only send a reply if
1736 there was an error */
1737 if (lck->lockx.in.ulock_cnt + lck->lockx.in.lock_cnt == 0) {
1742 /* construct reply */
1743 req_setup_reply(req, 2, 0);
1745 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
1746 SSVAL(req->out.vwv, VWV(1), 0);
1752 /****************************************************************************
1753 Reply to a lockingX request.
1754 ****************************************************************************/
1755 void reply_lockingX(struct smbsrv_request *req)
1757 union smb_lock *lck;
1758 uint_t total_locks, i;
1763 REQ_CHECK_WCT(req, 8);
1764 REQ_TALLOC(lck, sizeof(*lck));
1766 lck->lockx.level = RAW_LOCK_LOCKX;
1767 lck->lockx.in.fnum = req_fnum(req, req->in.vwv, VWV(2));
1768 lck->lockx.in.mode = SVAL(req->in.vwv, VWV(3));
1769 lck->lockx.in.timeout = IVAL(req->in.vwv, VWV(4));
1770 lck->lockx.in.ulock_cnt = SVAL(req->in.vwv, VWV(6));
1771 lck->lockx.in.lock_cnt = SVAL(req->in.vwv, VWV(7));
1773 total_locks = lck->lockx.in.ulock_cnt + lck->lockx.in.lock_cnt;
1775 /* there are two variants, one with 64 bit offsets and counts */
1776 if (lck->lockx.in.mode & LOCKING_ANDX_LARGE_FILES) {
1782 /* make sure we got the promised data */
1783 if (req_data_oob(req, req->in.data, total_locks * lck_size)) {
1784 req_reply_error(req, NT_STATUS_FOOBAR);
1788 /* allocate the locks array */
1790 REQ_TALLOC(lck->lockx.in.locks, total_locks * sizeof(lck->lockx.in.locks[0]));
1795 /* construct the locks array */
1796 for (i=0;i<total_locks;i++) {
1797 uint32_t ofs_high=0, count_high=0;
1799 lck->lockx.in.locks[i].pid = SVAL(p, 0);
1801 if (lck->lockx.in.mode & LOCKING_ANDX_LARGE_FILES) {
1802 ofs_high = IVAL(p, 4);
1803 lck->lockx.in.locks[i].offset = IVAL(p, 8);
1804 count_high = IVAL(p, 12);
1805 lck->lockx.in.locks[i].count = IVAL(p, 16);
1807 lck->lockx.in.locks[i].offset = IVAL(p, 2);
1808 lck->lockx.in.locks[i].count = IVAL(p, 6);
1810 if (ofs_high != 0 || count_high != 0) {
1811 lck->lockx.in.locks[i].count |= ((uint64_t)count_high) << 32;
1812 lck->lockx.in.locks[i].offset |= ((uint64_t)ofs_high) << 32;
1817 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1818 req->async.send_fn = reply_lockingX_send;
1819 req->async.private = lck;
1822 req->async.status = ntvfs_lock(req, lck);
1827 /****************************************************************************
1828 Reply to a SMBreadbmpx (read block multiplex) request.
1829 ****************************************************************************/
1830 void reply_readbmpx(struct smbsrv_request *req)
1832 /* tell the client to not use a multiplexed read - its too broken to use */
1833 req_reply_dos_error(req, ERRSRV, ERRuseSTD);
1837 /****************************************************************************
1838 Reply to a SMBsetattrE.
1839 ****************************************************************************/
1840 void reply_setattrE(struct smbsrv_request *req)
1842 union smb_setfileinfo *info;
1845 REQ_CHECK_WCT(req, 7);
1846 REQ_TALLOC(info, sizeof(*info));
1848 info->setattre.level = RAW_SFILEINFO_SETATTRE;
1849 info->setattre.file.fnum = req_fnum(req, req->in.vwv, VWV(0));
1850 info->setattre.in.create_time = srv_pull_dos_date2(req->smb_conn, req->in.vwv + VWV(1));
1851 info->setattre.in.access_time = srv_pull_dos_date2(req->smb_conn, req->in.vwv + VWV(3));
1852 info->setattre.in.write_time = srv_pull_dos_date2(req->smb_conn, req->in.vwv + VWV(5));
1854 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1855 req->async.send_fn = reply_simple_send;
1858 req->async.status = ntvfs_setfileinfo(req, info);
1864 /****************************************************************************
1865 Reply to a SMBwritebmpx (write block multiplex primary) request.
1866 ****************************************************************************/
1867 void reply_writebmpx(struct smbsrv_request *req)
1869 /* we will need to implement this one for OS/2, but right now I can't be bothered */
1870 req_reply_error(req, NT_STATUS_FOOBAR);
1874 /****************************************************************************
1875 Reply to a SMBwritebs (write block multiplex secondary) request.
1876 ****************************************************************************/
1877 void reply_writebs(struct smbsrv_request *req)
1879 /* see reply_writebmpx */
1880 req_reply_error(req, NT_STATUS_FOOBAR);
1885 /****************************************************************************
1886 Reply to a SMBgetattrE (async reply)
1887 ****************************************************************************/
1888 static void reply_getattrE_send(struct smbsrv_request *req)
1890 union smb_fileinfo *info = req->async.private;
1895 req_setup_reply(req, 11, 0);
1897 srv_push_dos_date2(req->smb_conn, req->out.vwv, VWV(0), info->getattre.out.create_time);
1898 srv_push_dos_date2(req->smb_conn, req->out.vwv, VWV(2), info->getattre.out.access_time);
1899 srv_push_dos_date2(req->smb_conn, req->out.vwv, VWV(4), info->getattre.out.write_time);
1900 SIVAL(req->out.vwv, VWV(6), info->getattre.out.size);
1901 SIVAL(req->out.vwv, VWV(8), info->getattre.out.alloc_size);
1902 SSVAL(req->out.vwv, VWV(10), info->getattre.out.attrib);
1904 req_send_reply(req);
1907 /****************************************************************************
1908 Reply to a SMBgetattrE.
1909 ****************************************************************************/
1910 void reply_getattrE(struct smbsrv_request *req)
1912 union smb_fileinfo *info;
1915 REQ_CHECK_WCT(req, 1);
1916 REQ_TALLOC(info, sizeof(*info));
1918 info->getattr.level = RAW_FILEINFO_GETATTRE;
1919 info->getattr.in.fnum = req_fnum(req, req->in.vwv, VWV(0));
1921 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
1922 req->async.send_fn = reply_getattrE_send;
1923 req->async.private = info;
1926 req->async.status = ntvfs_qfileinfo(req, info);
1932 /****************************************************************************
1933 reply to an old style session setup command
1934 ****************************************************************************/
1935 static void reply_sesssetup_old(struct smbsrv_request *req)
1938 union smb_sesssetup sess;
1942 sess.old.level = RAW_SESSSETUP_OLD;
1945 sess.old.in.bufsize = SVAL(req->in.vwv, VWV(2));
1946 sess.old.in.mpx_max = SVAL(req->in.vwv, VWV(3));
1947 sess.old.in.vc_num = SVAL(req->in.vwv, VWV(4));
1948 sess.old.in.sesskey = IVAL(req->in.vwv, VWV(5));
1949 passlen = SVAL(req->in.vwv, VWV(7));
1951 /* check the request isn't malformed */
1952 if (req_data_oob(req, req->in.data, passlen)) {
1953 req_reply_error(req, NT_STATUS_FOOBAR);
1958 if (!req_pull_blob(req, p, passlen, &sess.old.in.password)) {
1959 req_reply_error(req, NT_STATUS_FOOBAR);
1964 p += req_pull_string(req, &sess.old.in.user, p, -1, STR_TERMINATE);
1965 p += req_pull_string(req, &sess.old.in.domain, p, -1, STR_TERMINATE);
1966 p += req_pull_string(req, &sess.old.in.os, p, -1, STR_TERMINATE);
1967 p += req_pull_string(req, &sess.old.in.lanman, p, -1, STR_TERMINATE);
1969 /* call the generic handler */
1970 status = sesssetup_backend(req, &sess);
1972 if (!NT_STATUS_IS_OK(status)) {
1973 req_reply_error(req, status);
1977 /* construct reply */
1978 req_setup_reply(req, 3, 0);
1980 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
1981 SSVAL(req->out.vwv, VWV(1), 0);
1982 SSVAL(req->out.vwv, VWV(2), sess.old.out.action);
1984 SSVAL(req->out.hdr, HDR_UID, sess.old.out.vuid);
1990 /****************************************************************************
1991 reply to an NT1 style session setup command
1992 ****************************************************************************/
1993 static void reply_sesssetup_nt1(struct smbsrv_request *req)
1996 union smb_sesssetup sess;
1998 uint16_t passlen1, passlen2;
2000 sess.nt1.level = RAW_SESSSETUP_NT1;
2003 sess.nt1.in.bufsize = SVAL(req->in.vwv, VWV(2));
2004 sess.nt1.in.mpx_max = SVAL(req->in.vwv, VWV(3));
2005 sess.nt1.in.vc_num = SVAL(req->in.vwv, VWV(4));
2006 sess.nt1.in.sesskey = IVAL(req->in.vwv, VWV(5));
2007 passlen1 = SVAL(req->in.vwv, VWV(7));
2008 passlen2 = SVAL(req->in.vwv, VWV(8));
2009 sess.nt1.in.capabilities = IVAL(req->in.vwv, VWV(11));
2011 /* check the request isn't malformed */
2012 if (req_data_oob(req, req->in.data, passlen1) ||
2013 req_data_oob(req, req->in.data + passlen1, passlen2)) {
2014 req_reply_error(req, NT_STATUS_FOOBAR);
2019 if (!req_pull_blob(req, p, passlen1, &sess.nt1.in.password1)) {
2020 req_reply_error(req, NT_STATUS_FOOBAR);
2024 if (!req_pull_blob(req, p, passlen2, &sess.nt1.in.password2)) {
2025 req_reply_error(req, NT_STATUS_FOOBAR);
2030 p += req_pull_string(req, &sess.nt1.in.user, p, -1, STR_TERMINATE);
2031 p += req_pull_string(req, &sess.nt1.in.domain, p, -1, STR_TERMINATE);
2032 p += req_pull_string(req, &sess.nt1.in.os, p, -1, STR_TERMINATE);
2033 p += req_pull_string(req, &sess.nt1.in.lanman, p, -1, STR_TERMINATE);
2035 /* call the generic handler */
2036 status = sesssetup_backend(req, &sess);
2038 if (!NT_STATUS_IS_OK(status)) {
2039 req_reply_error(req, status);
2043 /* construct reply */
2044 req_setup_reply(req, 3, 0);
2046 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
2047 SSVAL(req->out.vwv, VWV(1), 0);
2048 SSVAL(req->out.vwv, VWV(2), sess.nt1.out.action);
2050 SSVAL(req->out.hdr, HDR_UID, sess.nt1.out.vuid);
2052 req_push_str(req, NULL, sess.nt1.out.os, -1, STR_TERMINATE);
2053 req_push_str(req, NULL, sess.nt1.out.lanman, -1, STR_TERMINATE);
2054 req_push_str(req, NULL, sess.nt1.out.domain, -1, STR_TERMINATE);
2060 /****************************************************************************
2061 reply to an SPNEGO style session setup command
2062 ****************************************************************************/
2063 static void reply_sesssetup_spnego(struct smbsrv_request *req)
2066 union smb_sesssetup sess;
2070 sess.spnego.level = RAW_SESSSETUP_SPNEGO;
2073 sess.spnego.in.bufsize = SVAL(req->in.vwv, VWV(2));
2074 sess.spnego.in.mpx_max = SVAL(req->in.vwv, VWV(3));
2075 sess.spnego.in.vc_num = SVAL(req->in.vwv, VWV(4));
2076 sess.spnego.in.sesskey = IVAL(req->in.vwv, VWV(5));
2077 blob_len = SVAL(req->in.vwv, VWV(7));
2078 sess.spnego.in.capabilities = IVAL(req->in.vwv, VWV(10));
2081 if (!req_pull_blob(req, p, blob_len, &sess.spnego.in.secblob)) {
2082 req_reply_error(req, NT_STATUS_FOOBAR);
2087 p += req_pull_string(req, &sess.spnego.in.os, p, -1, STR_TERMINATE);
2088 p += req_pull_string(req, &sess.spnego.in.lanman, p, -1, STR_TERMINATE);
2089 p += req_pull_string(req, &sess.spnego.in.domain, p, -1, STR_TERMINATE);
2091 /* call the generic handler */
2092 status = sesssetup_backend(req, &sess);
2094 if (!NT_STATUS_IS_OK(status) &&
2095 !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
2096 req_reply_error(req, status);
2100 /* construct reply */
2101 req_setup_reply(req, 4, sess.spnego.out.secblob.length);
2103 if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
2104 req_setup_error(req, status);
2107 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
2108 SSVAL(req->out.vwv, VWV(1), 0);
2109 SSVAL(req->out.vwv, VWV(2), sess.spnego.out.action);
2110 SSVAL(req->out.vwv, VWV(3), sess.spnego.out.secblob.length);
2112 SSVAL(req->out.hdr, HDR_UID, sess.spnego.out.vuid);
2114 memcpy(req->out.data, sess.spnego.out.secblob.data, sess.spnego.out.secblob.length);
2115 req_push_str(req, NULL, sess.spnego.out.os, -1, STR_TERMINATE);
2116 req_push_str(req, NULL, sess.spnego.out.lanman, -1, STR_TERMINATE);
2117 req_push_str(req, NULL, sess.spnego.out.domain, -1, STR_TERMINATE);
2123 /****************************************************************************
2124 reply to a session setup command
2125 ****************************************************************************/
2126 void reply_sesssetup(struct smbsrv_request *req)
2128 switch (req->in.wct) {
2130 /* a pre-NT1 call */
2131 reply_sesssetup_old(req);
2135 reply_sesssetup_nt1(req);
2139 reply_sesssetup_spnego(req);
2143 /* unsupported variant */
2144 req_reply_error(req, NT_STATUS_FOOBAR);
2147 /****************************************************************************
2148 Reply to a SMBulogoffX.
2149 ****************************************************************************/
2150 void reply_ulogoffX(struct smbsrv_request *req)
2152 struct smbsrv_tcon *tcon;
2156 vuid = SVAL(req->in.hdr, HDR_UID);
2158 /* in user level security we are supposed to close any files
2159 open by this user on all open tree connects */
2160 if ((vuid != 0) && (lp_security() != SEC_SHARE)) {
2161 for (tcon=req->smb_conn->tree.tcons;tcon;tcon=tcon->next) {
2163 status = ntvfs_logoff(req);
2165 if (!NT_STATUS_IS_OK(status)) {
2166 req_reply_error(req, status);
2172 smbsrv_invalidate_vuid(req->smb_conn, vuid);
2174 req_setup_reply(req, 2, 0);
2176 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
2177 SSVAL(req->out.vwv, VWV(1), 0);
2183 /****************************************************************************
2184 Reply to an SMBfindclose request
2185 ****************************************************************************/
2186 void reply_findclose(struct smbsrv_request *req)
2189 union smb_search_close io;
2191 io.findclose.level = RAW_FINDCLOSE_FINDCLOSE;
2194 REQ_CHECK_WCT(req, 1);
2196 io.findclose.in.handle = SVAL(req->in.vwv, VWV(0));
2199 status = ntvfs_search_close(req, &io);
2201 if (!NT_STATUS_IS_OK(status)) {
2202 req_reply_error(req, status);
2206 /* construct reply */
2207 req_setup_reply(req, 0, 0);
2209 req_send_reply(req);
2212 /****************************************************************************
2213 Reply to an SMBfindnclose request
2214 ****************************************************************************/
2215 void reply_findnclose(struct smbsrv_request *req)
2217 req_reply_error(req, NT_STATUS_FOOBAR);
2221 /****************************************************************************
2222 Reply to an SMBntcreateX request (async send)
2223 ****************************************************************************/
2224 static void reply_ntcreate_and_X_send(struct smbsrv_request *req)
2226 union smb_open *io = req->async.private;
2230 /* construct reply */
2231 req_setup_reply(req, 34, 0);
2233 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
2234 SSVAL(req->out.vwv, VWV(1), 0);
2235 SCVAL(req->out.vwv, VWV(2), io->ntcreatex.out.oplock_level);
2237 /* the rest of the parameters are not aligned! */
2238 SSVAL(req->out.vwv, 5, io->ntcreatex.out.fnum);
2239 SIVAL(req->out.vwv, 7, io->ntcreatex.out.create_action);
2240 push_nttime(req->out.vwv, 11, io->ntcreatex.out.create_time);
2241 push_nttime(req->out.vwv, 19, io->ntcreatex.out.access_time);
2242 push_nttime(req->out.vwv, 27, io->ntcreatex.out.write_time);
2243 push_nttime(req->out.vwv, 35, io->ntcreatex.out.change_time);
2244 SIVAL(req->out.vwv, 43, io->ntcreatex.out.attrib);
2245 SBVAL(req->out.vwv, 47, io->ntcreatex.out.alloc_size);
2246 SBVAL(req->out.vwv, 55, io->ntcreatex.out.size);
2247 SSVAL(req->out.vwv, 63, io->ntcreatex.out.file_type);
2248 SSVAL(req->out.vwv, 65, io->ntcreatex.out.ipc_state);
2249 SCVAL(req->out.vwv, 67, io->ntcreatex.out.is_directory);
2254 /****************************************************************************
2255 Reply to an SMBntcreateX request
2256 ****************************************************************************/
2257 void reply_ntcreate_and_X(struct smbsrv_request *req)
2262 /* parse the request */
2263 REQ_CHECK_WCT(req, 24);
2264 REQ_TALLOC(io, sizeof(*io));
2266 io->ntcreatex.level = RAW_OPEN_NTCREATEX;
2268 /* notice that the word parameters are not word aligned, so we don't use VWV() */
2269 fname_len = SVAL(req->in.vwv, 5);
2270 io->ntcreatex.in.flags = IVAL(req->in.vwv, 7);
2271 io->ntcreatex.in.root_fid = IVAL(req->in.vwv, 11);
2272 io->ntcreatex.in.access_mask = IVAL(req->in.vwv, 15);
2273 io->ntcreatex.in.alloc_size = BVAL(req->in.vwv, 19);
2274 io->ntcreatex.in.file_attr = IVAL(req->in.vwv, 27);
2275 io->ntcreatex.in.share_access = IVAL(req->in.vwv, 31);
2276 io->ntcreatex.in.open_disposition = IVAL(req->in.vwv, 35);
2277 io->ntcreatex.in.create_options = IVAL(req->in.vwv, 39);
2278 io->ntcreatex.in.impersonation = IVAL(req->in.vwv, 43);
2279 io->ntcreatex.in.security_flags = CVAL(req->in.vwv, 47);
2281 /* we need a neater way to handle this alignment */
2282 if ((req->flags2 & FLAGS2_UNICODE_STRINGS) &&
2283 ucs2_align(req->in.buffer, req->in.data, STR_TERMINATE|STR_UNICODE)) {
2287 req_pull_string(req, &io->ntcreatex.in.fname, req->in.data, fname_len, STR_TERMINATE);
2288 if (!io->ntcreatex.in.fname) {
2289 req_reply_error(req, NT_STATUS_FOOBAR);
2293 req->control_flags |= REQ_CONTROL_MAY_ASYNC;
2294 req->async.send_fn = reply_ntcreate_and_X_send;
2295 req->async.private = io;
2297 /* call the backend */
2298 req->async.status = ntvfs_open(req, io);
2304 /****************************************************************************
2305 Reply to an SMBntcancel request
2306 ****************************************************************************/
2307 void reply_ntcancel(struct smbsrv_request *req)
2309 req_reply_error(req, NT_STATUS_FOOBAR);
2312 /****************************************************************************
2313 Reply to an SMBsends request
2314 ****************************************************************************/
2315 void reply_sends(struct smbsrv_request *req)
2317 req_reply_error(req, NT_STATUS_FOOBAR);
2320 /****************************************************************************
2321 Reply to an SMBsendstrt request
2322 ****************************************************************************/
2323 void reply_sendstrt(struct smbsrv_request *req)
2325 req_reply_error(req, NT_STATUS_FOOBAR);
2328 /****************************************************************************
2329 Reply to an SMBsendend request
2330 ****************************************************************************/
2331 void reply_sendend(struct smbsrv_request *req)
2333 req_reply_error(req, NT_STATUS_FOOBAR);
2336 /****************************************************************************
2337 Reply to an SMBsendtxt request
2338 ****************************************************************************/
2339 void reply_sendtxt(struct smbsrv_request *req)
2341 req_reply_error(req, NT_STATUS_FOOBAR);
2346 /****************************************************************************
2347 Reply to a special message - a SMB packet with non zero NBT message type
2348 ****************************************************************************/
2349 void reply_special(struct smbsrv_request *req)
2354 msg_type = CVAL(req->in.buffer,0);
2359 case 0x81: /* session request */
2360 if (req->smb_conn->negotiate.done_nbt_session) {
2361 smbsrv_terminate_connection(req->smb_conn, "multiple session request not permitted");
2367 DEBUG(0,("REWRITE: not parsing netbios names in NBT session request!\n"));
2368 /* TODO: store the name for the session setup 'remote machine' code, as well as smbstatus */
2370 req->smb_conn->negotiate.done_nbt_session = True;
2372 req->out.buffer = buf;
2374 req_send_reply_nosign(req);
2377 case 0x89: /* session keepalive request
2378 (some old clients produce this?) */
2379 SCVAL(buf, 0, SMBkeepalive);
2381 req->out.buffer = buf;
2383 req_send_reply_nosign(req);
2387 /* session keepalive - swallow it */
2392 DEBUG(0,("Unexpected NBT session packet (%d)\n", msg_type));