xref: /onnv-gate/usr/src/uts/common/fs/smbsrv/smb_print.c (revision 6030:6bebab7d43d5)
15331Samw /*
25331Samw  * CDDL HEADER START
35331Samw  *
45331Samw  * The contents of this file are subject to the terms of the
55331Samw  * Common Development and Distribution License (the "License").
65331Samw  * You may not use this file except in compliance with the License.
75331Samw  *
85331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331Samw  * or http://www.opensolaris.org/os/licensing.
105331Samw  * See the License for the specific language governing permissions
115331Samw  * and limitations under the License.
125331Samw  *
135331Samw  * When distributing Covered Code, include this CDDL HEADER in each
145331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331Samw  * If applicable, add the following below this CDDL HEADER, with the
165331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
175331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
185331Samw  *
195331Samw  * CDDL HEADER END
205331Samw  */
215331Samw /*
22*6030Sjb150015  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
235331Samw  * Use is subject to license terms.
245331Samw  */
255331Samw 
265331Samw #pragma ident	"%Z%%M%	%I%	%E% SMI"
275331Samw 
285331Samw /*
295331Samw  * SMB print interface.
305331Samw  */
315331Samw 
325331Samw #include <smbsrv/smb_incl.h>
335331Samw 
345331Samw 
355331Samw /*
365331Samw  * smb_com_open_print_file
375331Samw  *
385331Samw  * This message is sent to create a new printer file which will be deleted
395331Samw  * once it has been closed and printed.
405331Samw  *
415331Samw  * Client Request                     Description
425331Samw  * ================================== =================================
435331Samw  *
445331Samw  * UCHAR WordCount;                   Count of parameter words = 2
455331Samw  * USHORT SetupLength;                Length of printer setup data
465331Samw  * USHORT Mode;                       0 = Text mode (DOS expands TABs)
475331Samw  *                                     1 = Graphics mode
485331Samw  * USHORT ByteCount;                  Count of data bytes;  min = 2
495331Samw  * UCHAR BufferFormat;                0x04
505331Samw  * STRING IdentifierString[];         Identifier string
515331Samw  *
525331Samw  * Tid in the SMB header must refer to a printer resource type.
535331Samw  *
545331Samw  * SetupLength is the number of bytes in the first part of the resulting
555331Samw  * print spool file which contains printer-specific control strings.
565331Samw  *
575331Samw  * Mode can have the following values:
585331Samw  *
595331Samw  *      0     Text mode.  The server may optionally
605331Samw  *            expand tabs to a series of spaces.
615331Samw  *      1     Graphics mode.  No conversion of data
625331Samw  *            should be done by the server.
635331Samw  *
645331Samw  * IdentifierString can be used by the server to provide some sort of per-
655331Samw  * client identifying component to the print file.
665331Samw  *
675331Samw  * Server Response                    Description
685331Samw  * ================================== =================================
695331Samw  *
705331Samw  * UCHAR WordCount;                   Count of parameter words = 1
715331Samw  * USHORT Fid;                        File handle
725331Samw  * USHORT ByteCount;                  Count of data bytes = 0
735331Samw  *
745331Samw  * Fid is the returned handle which may be used by subsequent write and
755331Samw  * close operations.  When the file is finally closed, it will be sent to
765331Samw  * the spooler and printed.
775331Samw  *
785331Samw  * 4.5.1.1   Errors
795331Samw  *
805331Samw  * ERRDOS/ERRnoaccess
815331Samw  * ERRDOS/ERRnofids
825331Samw  * ERRSRV/ERRinvdevice
835331Samw  * ERRSRV/ERRbaduid
845331Samw  * ERRSRV/ERRqfull
855331Samw  * ERRSRV/ERRqtoobig
865331Samw  */
87*6030Sjb150015 smb_sdrc_t /*ARGSUSED*/
885331Samw smb_com_open_print_file(struct smb_request *sr)
895331Samw {
905331Samw 	return (SDRC_UNIMPLEMENTED);
915331Samw }
925331Samw 
935331Samw 
945331Samw /*
955331Samw  * smb_com_close_print_file
965331Samw  *
975331Samw  *
985331Samw  * This message invalidates the specified file handle and queues the file
995331Samw  * for printing.
1005331Samw  *
1015331Samw  *   Client Request                     Description
1025331Samw  *   ================================== =================================
1035331Samw  *
1045331Samw  *   UCHAR WordCount;                   Count of parameter words = 1
1055331Samw  *   USHORT Fid;                        File handle
1065331Samw  *   USHORT ByteCount;                  Count of data bytes = 0
1075331Samw  *
1085331Samw  * Fid refers to a file previously created with SMB_COM_OPEN_PRINT_FILE.
1095331Samw  * On successful completion of this request, the file is queued for
1105331Samw  * printing by the server.
1115331Samw  *
1125331Samw  *   Server Response                    Description
1135331Samw  *   ================================== =================================
1145331Samw  *
1155331Samw  *   UCHAR WordCount;                   Count of parameter words = 0
1165331Samw  *   USHORT ByteCount;                  Count of data bytes = 0
1175331Samw  *
1185331Samw  * Servers which negotiate dialects of LANMAN1.0 and newer allow all the
1195331Samw  * other types of Fid closing requests to invalidate the Fid and begin
1205331Samw  * spooling.
1215331Samw  */
122*6030Sjb150015 smb_sdrc_t /*ARGSUSED*/
1235331Samw smb_com_close_print_file(struct smb_request *sr)
1245331Samw {
1255331Samw 	return (SDRC_UNIMPLEMENTED);
1265331Samw }
1275331Samw 
1285331Samw 
1295331Samw /*
1305331Samw  * smb_com_get_print_queue
1315331Samw  *
1325331Samw  * This message obtains a list of the elements currently in the print queue
1335331Samw  * on the server.
1345331Samw  *
1355331Samw  *   Client Request                     Description
1365331Samw  *   ================================== =================================
1375331Samw  *
1385331Samw  *   UCHAR WordCount;                   Count of parameter words = 2
1395331Samw  *   USHORT MaxCount;                   Max number of entries to return
1405331Samw  *   USHORT StartIndex;                 First queue entry to return
1415331Samw  *   USHORT ByteCount;                  Count of data bytes = 0
1425331Samw  *
1435331Samw  * StartIndex specifies the first entry in the queue to return.
1445331Samw  *
1455331Samw  * MaxCount specifies the maximum number of entries to return, this may be
1465331Samw  * a positive or negative number.  A positive number requests a forward
1475331Samw  * search, a negative number indicates a backward search.
1485331Samw  *
1495331Samw  *   Server Response                    Description
1505331Samw  *   ================================== =================================
1515331Samw  *
1525331Samw  *   UCHAR WordCount;                   Count of parameter words = 2
1535331Samw  *   USHORT Count;                      Number of entries returned
1545331Samw  *   USHORT RestartIndex;               Index of entry after last
1555331Samw  *                                       returned
1565331Samw  *   USHORT ByteCount;                  Count of data bytes;  min = 3
1575331Samw  *   UCHAR BufferFormat;                0x01 -- Data block
1585331Samw  *   USHORT DataLength;                 Length of data
1595331Samw  *   UCHAR Data[];                      Queue elements
1605331Samw  *
1615331Samw  * Count indicates how many entries were actually returned.  RestartIndex
1625331Samw  * is the index of the entry following the last entry returned; it may be
1635331Samw  * used as the StartIndex in a subsequent request to resume the queue
1645331Samw  * listing.
1655331Samw  *
1665331Samw  * The format of each returned queue element is:
1675331Samw  *
1685331Samw  *   Queue Element Member             Description
1695331Samw  *   ================================ ===================================
1705331Samw  *
1715331Samw  *   SMB_DATE FileDate;               Date file was queued
1725331Samw  *   SMB_TIME FileTime;               Time file was queued
1735331Samw  *   UCHAR Status;                    Entry status.  One of:
1745331Samw  *                                     01 = held or stopped
1755331Samw  *                                     02 = printing
1765331Samw  *                                     03 = awaiting print
1775331Samw  *                                     04 = in intercept
1785331Samw  *                                     05 = file had error
1795331Samw  *                                     06 = printer error
1805331Samw  *                                     07-FF = reserved
1815331Samw  *   USHORT SpoolFileNumber;          Assigned by the spooler
1825331Samw  *   ULONG SpoolFileSize;             Number of bytes in spool file
1835331Samw  *   UCHAR Reserved;
1845331Samw  *   UCHAR SpoolFileName[16];         Client which created the spool file
1855331Samw  *
1865331Samw  * SMB_COM_GET_PRINT_QUEUE will return less than the requested number of
1875331Samw  * elements only when the top or end of the queue is encountered.
1885331Samw  *
1895331Samw  * Support for this SMB is server optional.  In particular, no current
1905331Samw  * Microsoft client software issues this request.
1915331Samw  *
1925331Samw  * 4.5.2.1   Errors
1935331Samw  *
1945331Samw  * ERRHRD/ERRnotready
1955331Samw  * ERRHRD/ERRerror
1965331Samw  * ERRSRV/ERRbaduid
1975331Samw  */
198*6030Sjb150015 smb_sdrc_t
1995331Samw smb_com_get_print_queue(struct smb_request *sr)
2005331Samw {
2015331Samw 	unsigned short max_count, start_ix;
2025331Samw 
203*6030Sjb150015 	if (smbsr_decode_vwv(sr, "ww", &max_count, &start_ix) != 0)
204*6030Sjb150015 		return (SDRC_ERROR_REPLY);
2055331Samw 
206*6030Sjb150015 	if (smbsr_encode_result(sr, 2, 3, "bwwwbw", 2, 0, 0, 3, 1, 0))
207*6030Sjb150015 		return (SDRC_ERROR_REPLY);
208*6030Sjb150015 
2095331Samw 	return (SDRC_NORMAL_REPLY);
2105331Samw }
2115331Samw 
2125331Samw 
2135331Samw /*
2145331Samw  * smb_com_write_print_file
2155331Samw  *
2165331Samw  * This message is sent to write bytes into a print spool file.
2175331Samw  *
2185331Samw  * Client Request                     Description
2195331Samw  * ================================== =================================
2205331Samw  *
2215331Samw  * UCHAR WordCount;                   Count of parameter words = 1
2225331Samw  * USHORT Fid;                        File handle
2235331Samw  * USHORT ByteCount;                  Count of data bytes;  min = 4
2245331Samw  * UCHAR BufferFormat;                0x01 -- Data block
2255331Samw  * USHORT DataLength;                 Length of data
2265331Samw  * UCHAR Data[];                      Data
2275331Samw  *
2285331Samw  * Fid indicates the print spool file to be written, it must refer to a
2295331Samw  * print spool file.
2305331Samw  *
2315331Samw  * ByteCount specifies the number of bytes to be written, and must be less
2325331Samw  * than MaxBufferSize for the Tid specified.
2335331Samw  *
2345331Samw  * Data contains the bytes to append to the print spool file.  The first
2355331Samw  * SetupLength bytes in the resulting print spool file contain printer
2365331Samw  * setup data.  SetupLength is specified in the SMB_COM_OPEN_PRINT_FILE SMB
2375331Samw  * request.
2385331Samw  *
2395331Samw  * Server Response                    Description
2405331Samw  * ================================== =================================
2415331Samw  *
2425331Samw  * UCHAR WordCount;                   Count of parameter words = 0
2435331Samw  * USHORT ByteCount;                  Count of data bytes = 0
2445331Samw  *
2455331Samw  * Servers which negotiate a protocol dialect of LANMAN1.0 or later also
2465331Samw  * support the application of normal write requests to print spool files.
2475331Samw  *
2485331Samw  */
249*6030Sjb150015 smb_sdrc_t /*ARGSUSED*/
2505331Samw smb_com_write_print_file(struct smb_request *sr)
2515331Samw {
2525331Samw 	return (SDRC_UNIMPLEMENTED);
2535331Samw }
254