xref: /onnv-gate/usr/src/uts/common/fs/smbsrv/smb_print.c (revision 5331:3047ad28a67b)
1*5331Samw /*
2*5331Samw  * CDDL HEADER START
3*5331Samw  *
4*5331Samw  * The contents of this file are subject to the terms of the
5*5331Samw  * Common Development and Distribution License (the "License").
6*5331Samw  * You may not use this file except in compliance with the License.
7*5331Samw  *
8*5331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5331Samw  * or http://www.opensolaris.org/os/licensing.
10*5331Samw  * See the License for the specific language governing permissions
11*5331Samw  * and limitations under the License.
12*5331Samw  *
13*5331Samw  * When distributing Covered Code, include this CDDL HEADER in each
14*5331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5331Samw  * If applicable, add the following below this CDDL HEADER, with the
16*5331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
17*5331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
18*5331Samw  *
19*5331Samw  * CDDL HEADER END
20*5331Samw  */
21*5331Samw /*
22*5331Samw  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*5331Samw  * Use is subject to license terms.
24*5331Samw  */
25*5331Samw 
26*5331Samw #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*5331Samw 
28*5331Samw /*
29*5331Samw  * SMB print interface.
30*5331Samw  */
31*5331Samw 
32*5331Samw #include <smbsrv/smb_incl.h>
33*5331Samw 
34*5331Samw 
35*5331Samw /*
36*5331Samw  * smb_com_open_print_file
37*5331Samw  *
38*5331Samw  * This message is sent to create a new printer file which will be deleted
39*5331Samw  * once it has been closed and printed.
40*5331Samw  *
41*5331Samw  * Client Request                     Description
42*5331Samw  * ================================== =================================
43*5331Samw  *
44*5331Samw  * UCHAR WordCount;                   Count of parameter words = 2
45*5331Samw  * USHORT SetupLength;                Length of printer setup data
46*5331Samw  * USHORT Mode;                       0 = Text mode (DOS expands TABs)
47*5331Samw  *                                     1 = Graphics mode
48*5331Samw  * USHORT ByteCount;                  Count of data bytes;  min = 2
49*5331Samw  * UCHAR BufferFormat;                0x04
50*5331Samw  * STRING IdentifierString[];         Identifier string
51*5331Samw  *
52*5331Samw  * Tid in the SMB header must refer to a printer resource type.
53*5331Samw  *
54*5331Samw  * SetupLength is the number of bytes in the first part of the resulting
55*5331Samw  * print spool file which contains printer-specific control strings.
56*5331Samw  *
57*5331Samw  * Mode can have the following values:
58*5331Samw  *
59*5331Samw  *      0     Text mode.  The server may optionally
60*5331Samw  *            expand tabs to a series of spaces.
61*5331Samw  *      1     Graphics mode.  No conversion of data
62*5331Samw  *            should be done by the server.
63*5331Samw  *
64*5331Samw  * IdentifierString can be used by the server to provide some sort of per-
65*5331Samw  * client identifying component to the print file.
66*5331Samw  *
67*5331Samw  * Server Response                    Description
68*5331Samw  * ================================== =================================
69*5331Samw  *
70*5331Samw  * UCHAR WordCount;                   Count of parameter words = 1
71*5331Samw  * USHORT Fid;                        File handle
72*5331Samw  * USHORT ByteCount;                  Count of data bytes = 0
73*5331Samw  *
74*5331Samw  * Fid is the returned handle which may be used by subsequent write and
75*5331Samw  * close operations.  When the file is finally closed, it will be sent to
76*5331Samw  * the spooler and printed.
77*5331Samw  *
78*5331Samw  * 4.5.1.1   Errors
79*5331Samw  *
80*5331Samw  * ERRDOS/ERRnoaccess
81*5331Samw  * ERRDOS/ERRnofids
82*5331Samw  * ERRSRV/ERRinvdevice
83*5331Samw  * ERRSRV/ERRbaduid
84*5331Samw  * ERRSRV/ERRqfull
85*5331Samw  * ERRSRV/ERRqtoobig
86*5331Samw  */
87*5331Samw int /*ARGSUSED*/
88*5331Samw smb_com_open_print_file(struct smb_request *sr)
89*5331Samw {
90*5331Samw 	return (SDRC_UNIMPLEMENTED);
91*5331Samw }
92*5331Samw 
93*5331Samw 
94*5331Samw /*
95*5331Samw  * smb_com_close_print_file
96*5331Samw  *
97*5331Samw  *
98*5331Samw  * This message invalidates the specified file handle and queues the file
99*5331Samw  * for printing.
100*5331Samw  *
101*5331Samw  *   Client Request                     Description
102*5331Samw  *   ================================== =================================
103*5331Samw  *
104*5331Samw  *   UCHAR WordCount;                   Count of parameter words = 1
105*5331Samw  *   USHORT Fid;                        File handle
106*5331Samw  *   USHORT ByteCount;                  Count of data bytes = 0
107*5331Samw  *
108*5331Samw  * Fid refers to a file previously created with SMB_COM_OPEN_PRINT_FILE.
109*5331Samw  * On successful completion of this request, the file is queued for
110*5331Samw  * printing by the server.
111*5331Samw  *
112*5331Samw  *   Server Response                    Description
113*5331Samw  *   ================================== =================================
114*5331Samw  *
115*5331Samw  *   UCHAR WordCount;                   Count of parameter words = 0
116*5331Samw  *   USHORT ByteCount;                  Count of data bytes = 0
117*5331Samw  *
118*5331Samw  * Servers which negotiate dialects of LANMAN1.0 and newer allow all the
119*5331Samw  * other types of Fid closing requests to invalidate the Fid and begin
120*5331Samw  * spooling.
121*5331Samw  */
122*5331Samw int /*ARGSUSED*/
123*5331Samw smb_com_close_print_file(struct smb_request *sr)
124*5331Samw {
125*5331Samw 	return (SDRC_UNIMPLEMENTED);
126*5331Samw }
127*5331Samw 
128*5331Samw 
129*5331Samw /*
130*5331Samw  * smb_com_get_print_queue
131*5331Samw  *
132*5331Samw  * This message obtains a list of the elements currently in the print queue
133*5331Samw  * on the server.
134*5331Samw  *
135*5331Samw  *   Client Request                     Description
136*5331Samw  *   ================================== =================================
137*5331Samw  *
138*5331Samw  *   UCHAR WordCount;                   Count of parameter words = 2
139*5331Samw  *   USHORT MaxCount;                   Max number of entries to return
140*5331Samw  *   USHORT StartIndex;                 First queue entry to return
141*5331Samw  *   USHORT ByteCount;                  Count of data bytes = 0
142*5331Samw  *
143*5331Samw  * StartIndex specifies the first entry in the queue to return.
144*5331Samw  *
145*5331Samw  * MaxCount specifies the maximum number of entries to return, this may be
146*5331Samw  * a positive or negative number.  A positive number requests a forward
147*5331Samw  * search, a negative number indicates a backward search.
148*5331Samw  *
149*5331Samw  *   Server Response                    Description
150*5331Samw  *   ================================== =================================
151*5331Samw  *
152*5331Samw  *   UCHAR WordCount;                   Count of parameter words = 2
153*5331Samw  *   USHORT Count;                      Number of entries returned
154*5331Samw  *   USHORT RestartIndex;               Index of entry after last
155*5331Samw  *                                       returned
156*5331Samw  *   USHORT ByteCount;                  Count of data bytes;  min = 3
157*5331Samw  *   UCHAR BufferFormat;                0x01 -- Data block
158*5331Samw  *   USHORT DataLength;                 Length of data
159*5331Samw  *   UCHAR Data[];                      Queue elements
160*5331Samw  *
161*5331Samw  * Count indicates how many entries were actually returned.  RestartIndex
162*5331Samw  * is the index of the entry following the last entry returned; it may be
163*5331Samw  * used as the StartIndex in a subsequent request to resume the queue
164*5331Samw  * listing.
165*5331Samw  *
166*5331Samw  * The format of each returned queue element is:
167*5331Samw  *
168*5331Samw  *   Queue Element Member             Description
169*5331Samw  *   ================================ ===================================
170*5331Samw  *
171*5331Samw  *   SMB_DATE FileDate;               Date file was queued
172*5331Samw  *   SMB_TIME FileTime;               Time file was queued
173*5331Samw  *   UCHAR Status;                    Entry status.  One of:
174*5331Samw  *                                     01 = held or stopped
175*5331Samw  *                                     02 = printing
176*5331Samw  *                                     03 = awaiting print
177*5331Samw  *                                     04 = in intercept
178*5331Samw  *                                     05 = file had error
179*5331Samw  *                                     06 = printer error
180*5331Samw  *                                     07-FF = reserved
181*5331Samw  *   USHORT SpoolFileNumber;          Assigned by the spooler
182*5331Samw  *   ULONG SpoolFileSize;             Number of bytes in spool file
183*5331Samw  *   UCHAR Reserved;
184*5331Samw  *   UCHAR SpoolFileName[16];         Client which created the spool file
185*5331Samw  *
186*5331Samw  * SMB_COM_GET_PRINT_QUEUE will return less than the requested number of
187*5331Samw  * elements only when the top or end of the queue is encountered.
188*5331Samw  *
189*5331Samw  * Support for this SMB is server optional.  In particular, no current
190*5331Samw  * Microsoft client software issues this request.
191*5331Samw  *
192*5331Samw  * 4.5.2.1   Errors
193*5331Samw  *
194*5331Samw  * ERRHRD/ERRnotready
195*5331Samw  * ERRHRD/ERRerror
196*5331Samw  * ERRSRV/ERRbaduid
197*5331Samw  */
198*5331Samw int
199*5331Samw smb_com_get_print_queue(struct smb_request *sr)
200*5331Samw {
201*5331Samw 	unsigned short max_count, start_ix;
202*5331Samw 
203*5331Samw 	if (smbsr_decode_vwv(sr, "ww", &max_count, &start_ix) != 0) {
204*5331Samw 		smbsr_decode_error(sr);
205*5331Samw 		/* NOTREACHED */
206*5331Samw 	}
207*5331Samw 
208*5331Samw 	smbsr_encode_result(sr, 2, 3, "bwwwbw", 2, 0, 0, 3, 1, 0);
209*5331Samw 	return (SDRC_NORMAL_REPLY);
210*5331Samw }
211*5331Samw 
212*5331Samw 
213*5331Samw /*
214*5331Samw  * smb_com_write_print_file
215*5331Samw  *
216*5331Samw  * This message is sent to write bytes into a print spool file.
217*5331Samw  *
218*5331Samw  * Client Request                     Description
219*5331Samw  * ================================== =================================
220*5331Samw  *
221*5331Samw  * UCHAR WordCount;                   Count of parameter words = 1
222*5331Samw  * USHORT Fid;                        File handle
223*5331Samw  * USHORT ByteCount;                  Count of data bytes;  min = 4
224*5331Samw  * UCHAR BufferFormat;                0x01 -- Data block
225*5331Samw  * USHORT DataLength;                 Length of data
226*5331Samw  * UCHAR Data[];                      Data
227*5331Samw  *
228*5331Samw  * Fid indicates the print spool file to be written, it must refer to a
229*5331Samw  * print spool file.
230*5331Samw  *
231*5331Samw  * ByteCount specifies the number of bytes to be written, and must be less
232*5331Samw  * than MaxBufferSize for the Tid specified.
233*5331Samw  *
234*5331Samw  * Data contains the bytes to append to the print spool file.  The first
235*5331Samw  * SetupLength bytes in the resulting print spool file contain printer
236*5331Samw  * setup data.  SetupLength is specified in the SMB_COM_OPEN_PRINT_FILE SMB
237*5331Samw  * request.
238*5331Samw  *
239*5331Samw  * Server Response                    Description
240*5331Samw  * ================================== =================================
241*5331Samw  *
242*5331Samw  * UCHAR WordCount;                   Count of parameter words = 0
243*5331Samw  * USHORT ByteCount;                  Count of data bytes = 0
244*5331Samw  *
245*5331Samw  * Servers which negotiate a protocol dialect of LANMAN1.0 or later also
246*5331Samw  * support the application of normal write requests to print spool files.
247*5331Samw  *
248*5331Samw  */
249*5331Samw int /*ARGSUSED*/
250*5331Samw smb_com_write_print_file(struct smb_request *sr)
251*5331Samw {
252*5331Samw 	return (SDRC_UNIMPLEMENTED);
253*5331Samw }
254