1 2 3 4 5 6 7Network Printing Working Group L. McLaughlin III, Editor 8Request for Comments: 1179 The Wollongong Group 9 August 1990 10 11 12 Line Printer Daemon Protocol 13 14Status of this Memo 15 16 This RFC describes an existing print server protocol widely used on 17 the Internet for communicating between line printer daemons (both 18 clients and servers). This memo is for informational purposes only, 19 and does not specify an Internet standard. Please refer to the 20 current edition of the "IAB Official Protocol Standards" for the 21 standardization state and status of this protocol. Distribution of 22 this memo is unlimited. 23 241. Introduction 25 26 The Berkeley versions of the Unix(tm) operating system provide line 27 printer spooling with a collection of programs: lpr (assign to 28 queue), lpq (display the queue), lprm (remove from queue), and lpc 29 (control the queue). These programs interact with an autonomous 30 process called the line printer daemon. This RFC describes the 31 protocols with which a line printer daemon client may control 32 printing. 33 34 This memo is based almost entirely on the work of Robert Knight at 35 Princeton University. I gratefully acknowledge his efforts in 36 deciphering the UNIX lpr protocol and producing earlier versions of 37 this document. 38 392. Model of Printing Environment 40 41 A group of hosts request services from a line printer daemon process 42 running on a host. The services provided by the process are related 43 to printing jobs. A printing job produces output from one file. 44 Each job will have a unique job number which is between 0 and 999, 45 inclusive. The jobs are requested by users which have names. These 46 user names may not start with a digit. 47 483. Specification of the Protocol 49 50 The specification includes file formats for the control and data 51 files as well as messages used by the protocol. 52 53 54 55 56 57 58McLaughlin [Page 1] 59 60RFC 1179 LPR August 1990 61 62 633.1 Message formats 64 65 LPR is a a TCP-based protocol. The port on which a line printer 66 daemon listens is 515. The source port must be in the range 721 to 67 731, inclusive. A line printer daemon responds to commands send to 68 its port. All commands begin with a single octet code, which is a 69 binary number which represents the requested function. The code is 70 immediately followed by the ASCII name of the printer queue name on 71 which the function is to be performed. If there are other operands 72 to the command, they are separated from the printer queue name with 73 white space (ASCII space, horizontal tab, vertical tab, and form 74 feed). The end of the command is indicated with an ASCII line feed 75 character. 76 774. Diagram Conventions 78 79 The diagrams in the rest of this RFC use these conventions. These 80 diagrams show the format of an octet stream sent to the server. The 81 outermost box represents this stream. Each box within the outermost 82 one shows one portion of the stream. If the contents of the box is 83 two decimal digits, this indicates that the binary 8 bit value is to 84 be used. If the contents is two uppercase letters, this indicates 85 that the corresponding ASCII control character is to be used. An 86 exception to this is that the character SP can be interpreted as 87 white space. (See the preceding section for a definition.) If the 88 contents is a single letter, the ASCII code for this letter must be 89 sent. Otherwise, the contents are intended to be mnemonic of the 90 contents of the field which is a sequence of octets. 91 925. Daemon commands 93 94 The verbs in the command names should be interpreted as statements 95 made to the daemon. Thus, the command "Print any waiting jobs" is an 96 imperative to the line printer daemon to which it is sent. A new 97 connection must be made for each command to be given to the daemon. 98 995.1 01 - Print any waiting jobs 100 101 +----+-------+----+ 102 | 01 | Queue | LF | 103 +----+-------+----+ 104 Command code - 1 105 Operand - Printer queue name 106 107 This command starts the printing process if it not already running. 108 109 110 111 112 113 114McLaughlin [Page 2] 115 116RFC 1179 LPR August 1990 117 118 1195.2 02 - Receive a printer job 120 121 +----+-------+----+ 122 | 02 | Queue | LF | 123 +----+-------+----+ 124 Command code - 2 125 Operand - Printer queue name 126 127 Receiving a job is controlled by a second level of commands. The 128 daemon is given commands by sending them over the same connection. 129 The commands are described in the next section (6). 130 131 After this command is sent, the client must read an acknowledgement 132 octet from the daemon. A positive acknowledgement is an octet of 133 zero bits. A negative acknowledgement is an octet of any other 134 pattern. 135 1365.3 03 - Send queue state (short) 137 138 +----+-------+----+------+----+ 139 | 03 | Queue | SP | List | LF | 140 +----+-------+----+------+----+ 141 Command code - 3 142 Operand 1 - Printer queue name 143 Other operands - User names or job numbers 144 145 If the user names or job numbers or both are supplied then only those 146 jobs for those users or with those numbers will be sent. 147 148 The response is an ASCII stream which describes the printer queue. 149 The stream continues until the connection closes. Ends of lines are 150 indicated with ASCII LF control characters. The lines may also 151 contain ASCII HT control characters. 152 1535.4 04 - Send queue state (long) 154 155 +----+-------+----+------+----+ 156 | 04 | Queue | SP | List | LF | 157 +----+-------+----+------+----+ 158 Command code - 4 159 Operand 1 - Printer queue name 160 Other operands - User names or job numbers 161 162 If the user names or job numbers or both are supplied then only those 163 jobs for those users or with those numbers will be sent. 164 165 The response is an ASCII stream which describes the printer queue. 166 The stream continues until the connection closes. Ends of lines are 167 168 169 170McLaughlin [Page 3] 171 172RFC 1179 LPR August 1990 173 174 175 indicated with ASCII LF control characters. The lines may also 176 contain ASCII HT control characters. 177 1785.5 05 - Remove jobs 179 180 +----+-------+----+-------+----+------+----+ 181 | 05 | Queue | SP | Agent | SP | List | LF | 182 +----+-------+----+-------+----+------+----+ 183 Command code - 5 184 Operand 1 - Printer queue name 185 Operand 2 - User name making request (the agent) 186 Other operands - User names or job numbers 187 188 This command deletes the print jobs from the specified queue which 189 are listed as the other operands. If only the agent is given, the 190 command is to delete the currently active job. Unless the agent is 191 "root", it is not possible to delete a job which is not owned by the 192 user. This is also the case for specifying user names instead of 193 numbers. That is, agent "root" can delete jobs by user name but no 194 other agents can. 195 1966. Receive job subcommands 197 198 These commands are processed when the line printer daemon has 199 been given the receive job command. The daemon will continue to 200 process commands until the connection is closed. 201 202 After a subcommand is sent, the client must wait for an 203 acknowledgement from the daemon. A positive acknowledgement is an 204 octet of zero bits. A negative acknowledgement is an octet of any 205 other pattern. 206 207 LPR clients SHOULD be able to sent the receive data file and receive 208 control file subcommands in either order. LPR servers MUST be able 209 to receive the control file subcommand first and SHOULD be able to 210 receive the data file subcommand first. 211 2126.1 01 - Abort job 213 214 Command code - 1 215 +----+----+ 216 | 01 | LF | 217 +----+----+ 218 219 No operands should be supplied. This subcommand will remove any 220 files which have been created during this "Receive job" command. 221 222 223 224 225 226McLaughlin [Page 4] 227 228RFC 1179 LPR August 1990 229 230 2316.2 02 - Receive control file 232 233 +----+-------+----+------+----+ 234 | 02 | Count | SP | Name | LF | 235 +----+-------+----+------+----+ 236 Command code - 2 237 Operand 1 - Number of bytes in control file 238 Operand 2 - Name of control file 239 240 The control file must be an ASCII stream with the ends of lines 241 indicated by ASCII LF. The total number of bytes in the stream is 242 sent as the first operand. The name of the control file is sent as 243 the second. It should start with ASCII "cfA", followed by a three 244 digit job number, followed by the host name which has constructed the 245 control file. Acknowledgement processing must occur as usual after 246 the command is sent. 247 248 The next "Operand 1" octets over the same TCP connection are the 249 intended contents of the control file. Once all of the contents have 250 been delivered, an octet of zero bits is sent as an indication that 251 the file being sent is complete. A second level of acknowledgement 252 processing must occur at this point. 253 2546.3 03 - Receive data file 255 256 +----+-------+----+------+----+ 257 | 03 | Count | SP | Name | LF | 258 +----+-------+----+------+----+ 259 Command code - 3 260 Operand 1 - Number of bytes in data file 261 Operand 2 - Name of data file 262 263 The data file may contain any 8 bit values at all. The total number 264 of bytes in the stream may be sent as the first operand, otherwise 265 the field should be cleared to 0. The name of the data file should 266 start with ASCII "dfA". This should be followed by a three digit job 267 number. The job number should be followed by the host name which has 268 constructed the data file. Interpretation of the contents of the 269 data file is determined by the contents of the corresponding control 270 file. If a data file length has been specified, the next "Operand 1" 271 octets over the same TCP connection are the intended contents of the 272 data file. In this case, once all of the contents have been 273 delivered, an octet of zero bits is sent as an indication that the 274 file being sent is complete. A second level of acknowledgement 275 processing must occur at this point. 276 277 278 279 280 281 282McLaughlin [Page 5] 283 284RFC 1179 LPR August 1990 285 286 2877. Control file lines 288 289 This section discusses the format of the lines in the control file 290 which is sent to the line printer daemon. 291 292 Each line of the control file consists of a single, printable ASCII 293 character which represents a function to be performed when the file 294 is printed. Interpretation of these command characters are case- 295 sensitive. The rest of the line after the command character is the 296 command's operand. No leading white space is permitted after the 297 command character. The line ends with an ASCII new line. 298 299 Those commands which have a lower case letter as a command code are 300 used to specify an actual printing request. The commands which use 301 upper case are used to describe parametric values or background 302 conditions. 303 304 Some commands must be included in every control file. These are 'H' 305 (responsible host) and 'P' (responsible user). Additionally, there 306 must be at least one lower case command to produce any output. 307 3087.1 C - Class for banner page 309 310 +---+-------+----+ 311 | C | Class | LF | 312 +---+-------+----+ 313 Command code - 'C' 314 Operand - Name of class for banner pages 315 316 This command sets the class name to be printed on the banner page. 317 The name must be 31 or fewer octets. The name can be omitted. If it 318 is, the name of the host on which the file is printed will be used. 319 The class is conventionally used to display the host from which the 320 printing job originated. It will be ignored unless the print banner 321 command ('L') is also used. 322 3237.2 H - Host name 324 325 +---+------+----+ 326 | H | Host | LF | 327 +---+------+----+ 328 Command code - 'H' 329 Operand - Name of host 330 331 This command specifies the name of the host which is to be treated as 332 the source of the print job. The command must be included in the 333 control file. The name of the host must be 31 or fewer octets. 334 335 336 337 338McLaughlin [Page 6] 339 340RFC 1179 LPR August 1990 341 342 3437.3 I - Indent Printing 344 345 +---+-------+----+ 346 | I | count | LF | 347 +---+-------+----+ 348 Command code - 'I' 349 Operand - Indenting count 350 351 This command specifies that, for files which are printed with the 352 'f', of columns given. (It is ignored for other output generating 353 commands.) The identing count operand must be all decimal digits. 354 3557.4 J - Job name for banner page 356 357 +---+----------+----+ 358 | J | Job name | LF | 359 +---+----------+----+ 360 Command code - 'J' 361 Operand - Job name 362 363 This command sets the job name to be printed on the banner page. The 364 name of the job must be 99 or fewer octets. It can be omitted. The 365 job name is conventionally used to display the name of the file or 366 files which were "printed". It will be ignored unless the print 367 banner command ('L') is also used. 368 3697.5 L - Print banner page 370 371 +---+------+----+ 372 | L | User | LF | 373 +---+------+----+ 374 Command code - 'L' 375 Operand - Name of user for burst pages 376 377 This command causes the banner page to be printed. The user name can 378 be omitted. The class name for banner page and job name for banner 379 page commands must precede this command in the control file to be 380 effective. 381 3827.6 M - Mail When Printed 383 384 +---+------+----+ 385 | M | user | LF | 386 +---+------+----+ 387 Command code - 'M' 388 Operand - User name 389 390 This entry causes mail to be sent to the user given as the operand at 391 392 393 394McLaughlin [Page 7] 395 396RFC 1179 LPR August 1990 397 398 399 the host specified by the 'H' entry when the printing operation ends 400 (successfully or unsuccessfully). 401 4027.7 N - Name of source file 403 404 +---+------+----+ 405 | N | Name | LF | 406 +---+------+----+ 407 Command code - 'N' 408 Operand - File name 409 410 This command specifies the name of the file from which the data file 411 was constructed. It is returned on a query and used in printing with 412 the 'p' command when no title has been given. It must be 131 or 413 fewer octets. 414 4157.8 P - User identification 416 417 +---+------+----+ 418 | P | Name | LF | 419 +---+------+----+ 420 Command code - 'P' 421 Operand - User id 422 423 This command specifies the user identification of the entity 424 requesting the printing job. This command must be included in the 425 control file. The user identification must be 31 or fewer octets. 426 4277.9 S - Symbolic link data 428 429 +---+--------+----+-------+----+ 430 | S | device | SP | inode | LF | 431 +---+--------+----+-------+----+ 432 Command code - 'S' 433 Operand 1 - Device number 434 Operand 2 - Inode number 435 436 This command is used to record symbolic link data on a Unix system so 437 that changing a file's directory entry after a file is printed will 438 not print the new file. It is ignored if the data file is not 439 symbolically linked. 440 441 442 443 444 445 446 447 448 449 450McLaughlin [Page 8] 451 452RFC 1179 LPR August 1990 453 454 4557.10 T - Title for pr 456 457 +---+-------+----+ 458 | T | title | LF | 459 +---+-------+----+ 460 Command code - 'T' 461 Operand - Title text 462 463 This command provides a title for a file which is to be printed with 464 either the 'p' command. (It is ignored by all of the other printing 465 commands.) The title must be 79 or fewer octets. 466 4677.11 U - Unlink data file 468 469 +---+------+----+ 470 | U | file | LF | 471 +---+------+----+ 472 Command code - 'U' 473 Operand - File to unlink 474 475 This command indicates that the specified file is no longer needed. 476 This should only be used for data files. 477 4787.12 W - Width of output 479 480 +---+-------+----+ 481 | W | width | LF | 482 +---+-------+----+ 483 Command code - 'W' 484 Operand - Width count 485 486 This command limits the output to the specified number of columns for 487 the 'f', 'l', and 'p' commands. (It is ignored for other output 488 generating commands.) The width count operand must be all decimal 489 digits. It may be silently reduced to some lower value. The default 490 value for the width is 132. 491 4927.13 1 - troff R font 493 494 +---+------+----+ 495 | 1 | file | LF | 496 +---+------+----+ 497 Command code - '1' 498 Operand - File name 499 500 This command specifies the file name for the troff R font. [1] This 501 is the font which is printed using Times Roman by default. 502 503 504 505 506McLaughlin [Page 9] 507 508RFC 1179 LPR August 1990 509 510 5117.14 2 - troff I font 512 513 +---+------+----+ 514 | 2 | file | LF | 515 +---+------+----+ 516 Command code - '2' 517 Operand - File name 518 519 This command specifies the file name for the troff I font. [1] This 520 is the font which is printed using Times Italic by default. 521 5227.15 3 - troff B font 523 524 +---+------+----+ 525 | 3 | file | LF | 526 +---+------+----+ 527 Command code - '3' 528 Operand - File name 529 530 This command specifies the file name for the troff B font. [1] This 531 is the font which is printed using Times Bold by default. 532 5337.16 4 - troff S font 534 535 +---+------+----+ 536 | 4 | file | LF | 537 +---+------+----+ 538 Command code - '4' 539 Operand - File name 540 541 This command specifies the file name for the troff S font. [1] This 542 is the font which is printed using Special Mathematical Font by 543 default. 544 5457.17 c - Plot CIF file 546 547 +---+------+----+ 548 | c | file | LF | 549 +---+------+----+ 550 Command code - 'c' 551 Operand - File to plot 552 553 This command causes the data file to be plotted, treating the data as 554 CIF (CalTech Intermediate Form) graphics language. [2] 555 556 557 558 559 560 561 562McLaughlin [Page 10] 563 564RFC 1179 LPR August 1990 565 566 5677.18 d - Print DVI file 568 569 +---+------+----+ 570 | d | file | LF | 571 +---+------+----+ 572 Command code - 'd' 573 Operand - File to print 574 575 This command causes the data file to be printed, treating the data as 576 DVI (TeX output). [3] 577 5787.19 f - Print formatted file 579 580 +---+------+----+ 581 | f | file | LF | 582 +---+------+----+ 583 Command code - 'f' 584 Operand - File to print 585 586 This command cause the data file to be printed as a plain text file, 587 providing page breaks as necessary. Any ASCII control characters 588 which are not in the following list are discarded: HT, CR, FF, LF, 589 and BS. 590 5917.20 g - Plot file 592 593 +---+------+----+ 594 | g | file | LF | 595 +---+------+----+ 596 Command code - 'g' 597 Operand - File to plot 598 599 This command causes the data file to be plotted, treating the data as 600 output from the Berkeley Unix plot library. [1] 601 6027.21 k - Reserved for use by Kerberized LPR clients and servers. 603 6047.22 l - Print file leaving control characters 605 606 +---+------+----+ 607 | l | file | LF | 608 +---+------+----+ 609 Command code - 'l' (lower case L) 610 Operand - File to print 611 612 This command causes the specified data file to printed without 613 filtering the control characters (as is done with the 'f' command). 614 615 616 617 618McLaughlin [Page 11] 619 620RFC 1179 LPR August 1990 621 622 6237.23 n - Print ditroff output file 624 625 +---+------+----+ 626 | n | file | LF | 627 +---+------+----+ 628 Command code - 'n' 629 Operand - File to print 630 631 This command prints the data file to be printed, treating the data as 632 ditroff output. [4] 633 6347.24 o - Print Postscript output file 635 636 +---+------+----+ 637 | o | file | LF | 638 +---+------+----+ 639 Command code - 'o' 640 Operand - File to print 641 642 This command prints the data file to be printed, treating the data as 643 standard Postscript input. 644 6457.25 p - Print file with 'pr' format 646 647 +---+------+----+ 648 | p | file | LF | 649 +---+------+----+ 650 Command code - 'p' 651 Operand - File to print 652 653 This command causes the data file to be printed with a heading, page 654 numbers, and pagination. The heading should include the date and 655 time that printing was started, the title, and a page number 656 identifier followed by the page number. The title is the name of 657 file as specified by the 'N' command, unless the 'T' command (title) 658 has been given. After a page of text has been printed, a new page is 659 started with a new page number. (There is no way to specify the 660 length of the page.) 661 6627.26 r - File to print with FORTRAN carriage control 663 664 +---+------+----+ 665 | r | file | LF | 666 +---+------+----+ 667 Command code - 'r' 668 Operand - File to print 669 670 This command causes the data file to be printed, interpreting the 671 672 673 674McLaughlin [Page 12] 675 676RFC 1179 LPR August 1990 677 678 679 first column of each line as FORTRAN carriage control. The FORTRAN 680 standard limits this to blank, "1", "0", and "+" carriage controls. 681 Most FORTRAN programmers also expect "-" (triple space) to work as 682 well. 683 6847.27 t - Print troff output file 685 686 +---+------+----+ 687 | t | file | LF | 688 +---+------+----+ 689 Command code - 't' 690 Operand - File to print 691 692 This command prints the data file as Graphic Systems C/A/T 693 phototypesetter input. [5] This is the standard output of the Unix 694 "troff" command. 695 6967.28 v - Print raster file 697 698 +---+------+----+ 699 | v | file | LF | 700 +---+------+----+ 701 Command code - 'v' 702 Operand - File to print 703 704 This command prints a Sun raster format file. [6] 705 7067.29 z - Reserved for future use with the Palladium print system. 707 708REFERENCES and BIBLIOGRAPHY 709 710 [1] Computer Science Research Group, "UNIX Programmer's Reference 711 Manual", USENIX, 1986. 712 713 [2] Hon and Sequin, "A Guide to LSI Implementation", XEROX PARC, 714 1980. 715 716 [3] Knuth, D., "TeX The Program". 717 718 [4] Kernighan, B., "A Typesetter-independent TROFF". 719 720 [5] "Model C/A/T Phototypesetter", Graphic Systems, Inc. Hudson, N.H. 721 722 [6] Sun Microsystems, "Pixrect Reference Manual", Sun Microsystems, 723 Mountain View, CA, 1988. 724 725 726 727 728 729 730McLaughlin [Page 13] 731 732RFC 1179 LPR August 1990 733 734 735Security Considerations 736 737 Security issues are not discussed in this memo. 738 739Author's Address 740 741 Leo J. McLaughlin III 742 The Wollongong Group 743 1129 San Antonio Road 744 Palo Alto, CA 94303 745 746 Phone: 415-962-7100 747 748 EMail: ljm@twg.com 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786McLaughlin [Page 14] 787