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 /* 226030Sjb150015 * 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*6139Sjb150015 smb_sdrc_t 88*6139Sjb150015 smb_pre_open_print_file(smb_request_t *sr) 89*6139Sjb150015 { 90*6139Sjb150015 DTRACE_SMB_1(op__OpenPrintFile__start, smb_request_t *, sr); 91*6139Sjb150015 return (SDRC_SUCCESS); 92*6139Sjb150015 } 93*6139Sjb150015 94*6139Sjb150015 void 95*6139Sjb150015 smb_post_open_print_file(smb_request_t *sr) 96*6139Sjb150015 { 97*6139Sjb150015 DTRACE_SMB_1(op__OpenPrintFile__done, smb_request_t *, sr); 98*6139Sjb150015 } 99*6139Sjb150015 1006030Sjb150015 smb_sdrc_t /*ARGSUSED*/ 101*6139Sjb150015 smb_com_open_print_file(smb_request_t *sr) 1025331Samw { 103*6139Sjb150015 return (SDRC_NOT_IMPLEMENTED); 1045331Samw } 1055331Samw 1065331Samw 1075331Samw /* 1085331Samw * smb_com_close_print_file 1095331Samw * 1105331Samw * 1115331Samw * This message invalidates the specified file handle and queues the file 1125331Samw * for printing. 1135331Samw * 1145331Samw * Client Request Description 1155331Samw * ================================== ================================= 1165331Samw * 1175331Samw * UCHAR WordCount; Count of parameter words = 1 1185331Samw * USHORT Fid; File handle 1195331Samw * USHORT ByteCount; Count of data bytes = 0 1205331Samw * 1215331Samw * Fid refers to a file previously created with SMB_COM_OPEN_PRINT_FILE. 1225331Samw * On successful completion of this request, the file is queued for 1235331Samw * printing by the server. 1245331Samw * 1255331Samw * Server Response Description 1265331Samw * ================================== ================================= 1275331Samw * 1285331Samw * UCHAR WordCount; Count of parameter words = 0 1295331Samw * USHORT ByteCount; Count of data bytes = 0 1305331Samw * 1315331Samw * Servers which negotiate dialects of LANMAN1.0 and newer allow all the 1325331Samw * other types of Fid closing requests to invalidate the Fid and begin 1335331Samw * spooling. 1345331Samw */ 135*6139Sjb150015 smb_sdrc_t 136*6139Sjb150015 smb_pre_close_print_file(smb_request_t *sr) 137*6139Sjb150015 { 138*6139Sjb150015 DTRACE_SMB_1(op__ClosePrintFile__start, smb_request_t *, sr); 139*6139Sjb150015 return (SDRC_SUCCESS); 140*6139Sjb150015 } 141*6139Sjb150015 142*6139Sjb150015 void 143*6139Sjb150015 smb_post_close_print_file(smb_request_t *sr) 144*6139Sjb150015 { 145*6139Sjb150015 DTRACE_SMB_1(op__ClosePrintFile__done, smb_request_t *, sr); 146*6139Sjb150015 } 147*6139Sjb150015 1486030Sjb150015 smb_sdrc_t /*ARGSUSED*/ 149*6139Sjb150015 smb_com_close_print_file(smb_request_t *sr) 1505331Samw { 151*6139Sjb150015 return (SDRC_NOT_IMPLEMENTED); 1525331Samw } 1535331Samw 1545331Samw 1555331Samw /* 1565331Samw * smb_com_get_print_queue 1575331Samw * 1585331Samw * This message obtains a list of the elements currently in the print queue 1595331Samw * on the server. 1605331Samw * 1615331Samw * Client Request Description 1625331Samw * ================================== ================================= 1635331Samw * 1645331Samw * UCHAR WordCount; Count of parameter words = 2 1655331Samw * USHORT MaxCount; Max number of entries to return 1665331Samw * USHORT StartIndex; First queue entry to return 1675331Samw * USHORT ByteCount; Count of data bytes = 0 1685331Samw * 1695331Samw * StartIndex specifies the first entry in the queue to return. 1705331Samw * 1715331Samw * MaxCount specifies the maximum number of entries to return, this may be 1725331Samw * a positive or negative number. A positive number requests a forward 1735331Samw * search, a negative number indicates a backward search. 1745331Samw * 1755331Samw * Server Response Description 1765331Samw * ================================== ================================= 1775331Samw * 1785331Samw * UCHAR WordCount; Count of parameter words = 2 1795331Samw * USHORT Count; Number of entries returned 1805331Samw * USHORT RestartIndex; Index of entry after last 1815331Samw * returned 1825331Samw * USHORT ByteCount; Count of data bytes; min = 3 1835331Samw * UCHAR BufferFormat; 0x01 -- Data block 1845331Samw * USHORT DataLength; Length of data 1855331Samw * UCHAR Data[]; Queue elements 1865331Samw * 1875331Samw * Count indicates how many entries were actually returned. RestartIndex 1885331Samw * is the index of the entry following the last entry returned; it may be 1895331Samw * used as the StartIndex in a subsequent request to resume the queue 1905331Samw * listing. 1915331Samw * 1925331Samw * The format of each returned queue element is: 1935331Samw * 1945331Samw * Queue Element Member Description 1955331Samw * ================================ =================================== 1965331Samw * 1975331Samw * SMB_DATE FileDate; Date file was queued 1985331Samw * SMB_TIME FileTime; Time file was queued 1995331Samw * UCHAR Status; Entry status. One of: 2005331Samw * 01 = held or stopped 2015331Samw * 02 = printing 2025331Samw * 03 = awaiting print 2035331Samw * 04 = in intercept 2045331Samw * 05 = file had error 2055331Samw * 06 = printer error 2065331Samw * 07-FF = reserved 2075331Samw * USHORT SpoolFileNumber; Assigned by the spooler 2085331Samw * ULONG SpoolFileSize; Number of bytes in spool file 2095331Samw * UCHAR Reserved; 2105331Samw * UCHAR SpoolFileName[16]; Client which created the spool file 2115331Samw * 2125331Samw * SMB_COM_GET_PRINT_QUEUE will return less than the requested number of 2135331Samw * elements only when the top or end of the queue is encountered. 2145331Samw * 2155331Samw * Support for this SMB is server optional. In particular, no current 2165331Samw * Microsoft client software issues this request. 2175331Samw * 2185331Samw * 4.5.2.1 Errors 2195331Samw * 2205331Samw * ERRHRD/ERRnotready 2215331Samw * ERRHRD/ERRerror 2225331Samw * ERRSRV/ERRbaduid 2235331Samw */ 2246030Sjb150015 smb_sdrc_t 225*6139Sjb150015 smb_pre_get_print_queue(smb_request_t *sr) 226*6139Sjb150015 { 227*6139Sjb150015 DTRACE_SMB_1(op__GetPrintQueue__start, smb_request_t *, sr); 228*6139Sjb150015 return (SDRC_SUCCESS); 229*6139Sjb150015 } 230*6139Sjb150015 231*6139Sjb150015 void 232*6139Sjb150015 smb_post_get_print_queue(smb_request_t *sr) 233*6139Sjb150015 { 234*6139Sjb150015 DTRACE_SMB_1(op__GetPrintQueue__done, smb_request_t *, sr); 235*6139Sjb150015 } 236*6139Sjb150015 237*6139Sjb150015 smb_sdrc_t 238*6139Sjb150015 smb_com_get_print_queue(smb_request_t *sr) 2395331Samw { 2405331Samw unsigned short max_count, start_ix; 2415331Samw 2426030Sjb150015 if (smbsr_decode_vwv(sr, "ww", &max_count, &start_ix) != 0) 243*6139Sjb150015 return (SDRC_ERROR); 2445331Samw 2456030Sjb150015 if (smbsr_encode_result(sr, 2, 3, "bwwwbw", 2, 0, 0, 3, 1, 0)) 246*6139Sjb150015 return (SDRC_ERROR); 2476030Sjb150015 248*6139Sjb150015 return (SDRC_SUCCESS); 2495331Samw } 2505331Samw 2515331Samw 2525331Samw /* 2535331Samw * smb_com_write_print_file 2545331Samw * 2555331Samw * This message is sent to write bytes into a print spool file. 2565331Samw * 2575331Samw * Client Request Description 2585331Samw * ================================== ================================= 2595331Samw * 2605331Samw * UCHAR WordCount; Count of parameter words = 1 2615331Samw * USHORT Fid; File handle 2625331Samw * USHORT ByteCount; Count of data bytes; min = 4 2635331Samw * UCHAR BufferFormat; 0x01 -- Data block 2645331Samw * USHORT DataLength; Length of data 2655331Samw * UCHAR Data[]; Data 2665331Samw * 2675331Samw * Fid indicates the print spool file to be written, it must refer to a 2685331Samw * print spool file. 2695331Samw * 2705331Samw * ByteCount specifies the number of bytes to be written, and must be less 2715331Samw * than MaxBufferSize for the Tid specified. 2725331Samw * 2735331Samw * Data contains the bytes to append to the print spool file. The first 2745331Samw * SetupLength bytes in the resulting print spool file contain printer 2755331Samw * setup data. SetupLength is specified in the SMB_COM_OPEN_PRINT_FILE SMB 2765331Samw * request. 2775331Samw * 2785331Samw * Server Response Description 2795331Samw * ================================== ================================= 2805331Samw * 2815331Samw * UCHAR WordCount; Count of parameter words = 0 2825331Samw * USHORT ByteCount; Count of data bytes = 0 2835331Samw * 2845331Samw * Servers which negotiate a protocol dialect of LANMAN1.0 or later also 2855331Samw * support the application of normal write requests to print spool files. 2865331Samw * 2875331Samw */ 288*6139Sjb150015 smb_sdrc_t 289*6139Sjb150015 smb_pre_write_print_file(smb_request_t *sr) 2905331Samw { 291*6139Sjb150015 DTRACE_SMB_1(op__WritePrintFile__start, smb_request_t *, sr); 292*6139Sjb150015 return (SDRC_SUCCESS); 2935331Samw } 294*6139Sjb150015 295*6139Sjb150015 void 296*6139Sjb150015 smb_post_write_print_file(smb_request_t *sr) 297*6139Sjb150015 { 298*6139Sjb150015 DTRACE_SMB_1(op__WritePrintFile__done, smb_request_t *, sr); 299*6139Sjb150015 } 300*6139Sjb150015 301*6139Sjb150015 smb_sdrc_t /*ARGSUSED*/ 302*6139Sjb150015 smb_com_write_print_file(smb_request_t *sr) 303*6139Sjb150015 { 304*6139Sjb150015 return (SDRC_NOT_IMPLEMENTED); 305*6139Sjb150015 } 306