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