RFC 1179

Line printer daemon protocol

๐Ÿ“… published August 1990, from ietf

RFC 1179: Line Printer Daemon Protocol ๐Ÿ–จ๏ธโœจ

Okay bestie, so this one is by L. McLaughlin III (the editor), from The Wollongong Group, for the Network Printing Working Group, dated August 1990. It's an informational memo, not an Internet standard ๐Ÿ’…. The title block doesn't list anything it obsoletes or updates, so there's no drama there ๐Ÿซถ.

Status of this Memo ๐Ÿ“œ

This RFC describes a print server protocol that's already super widely used on the Internet, the one line printer daemons (both clients and servers) use to talk to each other ๐Ÿฆ‹. It's for information only and does not specify an Internet standard. If you want the actual standardization state and status of this protocol, check the current edition of the "IAB Official Protocol Standards" ๐Ÿง. Distribution of this memo is unlimited ๐Ÿ’œ.

1. Introduction โœจ

The Berkeley versions of Unix(tm) come with line printer spooling, which is a whole crew of programs:

  • lpr (assign to queue)
  • lpq (display the queue)
  • lprm (remove from queue)
  • lpc (control the queue)

These programs talk to an autonomous process called the line printer daemon ๐Ÿค–. This RFC covers the protocols a line printer daemon client uses to control printing ๐Ÿ–จ๏ธ.

This memo is based almost entirely on the work of Robert Knight at Princeton University. I'm so grateful for his efforts in figuring out the UNIX lpr protocol and writing the earlier versions of this document ๐Ÿ™๐ŸŒธ.

2. Model of Printing Environment ๐ŸŽ€

A group of hosts asks a line printer daemon process running on a host for services ๐Ÿ’Œ. Those services are all about printing jobs. A printing job produces output from one file. Every job gets a unique job number between 0 and 999, inclusive ๐Ÿ”ข. Jobs are requested by users, and users have names. A user name may not start with a digit ๐Ÿ™…โ€โ™€๏ธ.

3. Specification of the Protocol ๐Ÿ“‹

The specification covers file formats for the control and data files, plus the messages the protocol uses ๐Ÿ“‚.

3.1 Message formats ๐Ÿ’ฌ

LPR is a TCP-based protocol ๐ŸŒ. A line printer daemon listens on port 515. The source port must be in the range 721 to 731, inclusive ๐Ÿ”’. A line printer daemon responds to commands sent to its port ๐Ÿ“ฌ.

Every command starts with a single octet code, which is a binary number representing the requested function ๐Ÿงš. That code is immediately followed by the ASCII name of the printer queue the function gets performed on ๐ŸŽฏ. If the command has other operands, they're separated from the printer queue name with white space. White space means ASCII space, horizontal tab, vertical tab, or form feed โœจ. The end of the command is marked with an ASCII line feed character ๐Ÿ“.

4. Diagram Conventions ๐Ÿ—บ๏ธ

The diagrams in the rest of this RFC all use these conventions, and they show the format of an octet stream sent to the server ๐ŸŒŠ. The outermost box is the whole stream, and each box inside it shows one portion of the stream ๐Ÿ“ฆ.

  • If the contents of a box are two decimal digits, use the binary 8 bit value those digits represent ๐Ÿ”ข.
  • If the contents are two uppercase letters, use the matching ASCII control character ๐ŸŽ›๏ธ.
  • The character SP can be read as white space. (See the previous section for the definition.) ๐Ÿซง
  • If the contents are a single letter, the ASCII code for that letter must be sent ๐Ÿ’….
  • Anything else is a mnemonic for what the field holds, and that field is a sequence of octets ๐Ÿงฉ.

5. Daemon commands ๐Ÿ‘‘

The verbs in the command names should be interpreted as statements made to the daemon. So "Print any waiting jobs" is basically an imperative sent to the line printer daemon it gets sent to ๐Ÿ’ช. A new connection must be made for each command given to the daemon ๐Ÿ”Œ. Every command gets its own fresh connection, no sharing, bestie ๐Ÿซถ.

5.1 01 - Print any waiting jobs ๐Ÿ–จ๏ธ

      +----+-------+----+
      | 01 | Queue | LF |
      +----+-------+----+
      Command code - 1
      Operand - Printer queue name

This command starts the printing process if it isn't already running ๐Ÿƒโ€โ™€๏ธ.

5.2 02 - Receive a printer job ๐Ÿ“ฅ

      +----+-------+----+
      | 02 | Queue | LF |
      +----+-------+----+
      Command code - 2
      Operand - Printer queue name

Receiving a job is controlled by a second level of commands, and it's so cute ๐Ÿฅน. The daemon gets these commands sent over the same connection. They're described in the next section (6) ๐Ÿ’–.

After this command is sent, the client must read an acknowledgement octet from the daemon โœ…. A positive acknowledgement is an octet of zero bits. A negative acknowledgement is an octet of any other pattern โŒ.

5.3 03 - Send queue state (short) ๐Ÿ“

      +----+-------+----+------+----+
      | 03 | Queue | SP | List | LF |
      +----+-------+----+------+----+
      Command code - 3
      Operand 1 - Printer queue name
      Other operands - User names or job numbers

If user names or job numbers (or both) are supplied, only the jobs for those users, or with those numbers, get sent ๐Ÿ”.

The response is an ASCII stream describing the printer queue ๐Ÿงพ. The stream keeps going until the connection closes. Lines end with ASCII LF control characters, and lines may also contain ASCII HT control characters ๐ŸŒธ.

5.4 04 - Send queue state (long) ๐Ÿ“š

      +----+-------+----+------+----+
      | 04 | Queue | SP | List | LF |
      +----+-------+----+------+----+
      Command code - 4
      Operand 1 - Printer queue name
      Other operands - User names or job numbers

Same deal as the short version. If user names or job numbers (or both) are supplied, only the jobs for those users, or with those numbers, get sent ๐Ÿ”.

The response is an ASCII stream describing the printer queue. The stream continues until the connection closes. Lines end with ASCII LF control characters, and lines may also contain ASCII HT control characters ๐Ÿ’….

5.5 05 - Remove jobs ๐Ÿ—‘๏ธ

      +----+-------+----+-------+----+------+----+
      | 05 | Queue | SP | Agent | SP | List | LF |
      +----+-------+----+-------+----+------+----+
      Command code - 5
      Operand 1 - Printer queue name
      Operand 2 - User name making request (the agent)
      Other operands - User names or job numbers

This command deletes the print jobs from the specified queue that are listed as the other operands ๐Ÿงน. If only the agent is given, the command deletes the currently active job โšก. Unless the agent is "root", it isn't possible to delete a job that isn't owned by the user ๐Ÿ”. Same goes for specifying user names instead of numbers. In other words, agent "root" can delete jobs by user name, but no other agents can ๐Ÿ‘‘. Main character energy for root, ngl ๐Ÿ˜ญ.

6. Receive job subcommands ๐Ÿ“ฆ

These commands are processed once the line printer daemon has been given the receive job command ๐ŸŽฌ. The daemon keeps processing commands until the connection is closed ๐Ÿ”.

After a subcommand is sent, the client must wait for an acknowledgement from the daemon โณ. A positive acknowledgement is an octet of zero bits. A negative acknowledgement is an octet of any other pattern ๐Ÿ™ƒ.

LPR clients SHOULD be able to send the receive data file and receive control file subcommands in either order ๐Ÿ”€. LPR servers MUST be able to receive the control file subcommand first, and SHOULD be able to receive the data file subcommand first ๐Ÿซง. Okay, that's the one spot where the strong words are doing their thing, so pay attention periodt ๐Ÿ’€.

6.1 01 - Abort job ๐Ÿ›‘

      Command code - 1
      +----+----+
      | 01 | LF |
      +----+----+

No operands should be supplied ๐Ÿ™…โ€โ™€๏ธ. This subcommand removes any files that were created during this "Receive job" command ๐Ÿ—‘๏ธ.

6.2 02 - Receive control file ๐Ÿ“„

      +----+-------+----+------+----+
      | 02 | Count | SP | Name | LF |
      +----+-------+----+------+----+
      Command code - 2
      Operand 1 - Number of bytes in control file
      Operand 2 - Name of control file

The control file must be an ASCII stream where the ends of lines are marked with ASCII LF ๐Ÿงพ. The total number of bytes in the stream is sent as the first operand ๐Ÿ”ข. The name of the control file is sent as the second operand ๐Ÿท๏ธ. The name should start with ASCII "cfA", followed by a three digit job number, followed by the host name that built the control file ๐Ÿง. Acknowledgement processing must occur as usual after the command is sent โœ….

The next "Operand 1" octets over the same TCP connection are the intended contents of the control file ๐ŸŽ. Once all of the contents have been delivered, an octet of zero bits gets sent to say the file is complete ๐Ÿซถ. A second level of acknowledgement processing must occur at this point ๐Ÿ”.

6.3 03 - Receive data file ๐Ÿ“ฆ

      +----+-------+----+------+----+
      | 03 | Count | SP | Name | LF |
      +----+-------+----+------+----+
      Command code - 3
      Operand 1 - Number of bytes in data file
      Operand 2 - Name of data file

The data file may contain any 8 bit values at all ๐ŸŒˆ. The total number of bytes in the stream may be sent as the first operand. Otherwise, that field should be cleared to 0 ๐Ÿงน. The name of the data file should start with ASCII "dfA". That should be followed by a three digit job number, and the job number should be followed by the host name that built the data file ๐Ÿท๏ธ. How the contents of the data file get interpreted depends on the contents of the matching control file ๐Ÿ”—. If a data file length has been specified, the next "Operand 1" octets over the same TCP connection are the intended contents of the data file ๐Ÿ’Œ. In that case, once all of the contents have been delivered, an octet of zero bits is sent to say the file is complete. A second level of acknowledgement processing must occur at this point ๐Ÿ”.

7. Control file lines ๐Ÿง 

This section covers the format of the lines in the control file sent to the line printer daemon ๐Ÿ“‘.

Each line of the control file is a single, printable ASCII character that stands for a function to be performed when the file gets printed ๐Ÿ–จ๏ธ. Command characters are case-sensitive, so c and C are not the same thing ๐Ÿ™ˆ. The rest of the line after the command character is that command's operand. No leading white space is permitted after the command character ๐Ÿšซ. The line ends with an ASCII new line ๐Ÿ“.

Commands with a lower case letter as the command code are used to specify an actual printing request ๐Ÿ–จ๏ธโœจ. Commands that use upper case describe parametric values or background conditions ๐ŸŽ›๏ธ.

Some commands must be included in every control file. These are 'H' (responsible host) and 'P' (responsible user) ๐Ÿ’–. There must also be at least one lower case command to produce any output ๐Ÿ–ค.

7.1 C - Class for banner page ๐ŸŽ€

      +---+-------+----+
      | C | Class | LF |
      +---+-------+----+
      Command code - 'C'
      Operand - Name of class for banner pages

This command sets the class name to be printed on the banner page ๐Ÿณ๏ธ. The name must be 31 or fewer octets. The name can be omitted, and if it is, the name of the host where the file gets printed is used ๐Ÿ–ฅ๏ธ. The class is conventionally used to show the host the printing job came from ๐ŸŒธ. It's ignored unless the print banner command ('L') is also used ๐Ÿ™ˆ.

7.2 H - Host name ๐Ÿ 

      +---+------+----+
      | H | Host | LF |
      +---+------+----+
      Command code - 'H'
      Operand - Name of host

This command specifies the name of the host that gets treated as the source of the print job ๐Ÿ“ฎ. The command must be included in the control file ๐Ÿซถ. The name of the host must be 31 or fewer octets ๐Ÿ”’.

7.3 I - Indent Printing ๐ŸŽ€

+---+-------+----+
| I | count | LF |
+---+-------+----+
Command code - 'I'
Operand - Indenting count

Okay bestie, the I command is giving indent ๐Ÿ’… For files printed with the f command, it sets the indent by the number of columns given. It's ignored by the other output generating commands, so they just vibe past it ๐Ÿซถ The indenting count operand has to be all decimal digits ๐Ÿ”ข

7.4 J - Job name for banner page ๐Ÿท๏ธ

+---+----------+----+
| J | Job name | LF |
+---+----------+----+
Command code - 'J'
Operand - Job name

This one sets the job name that shows up on the banner page ๐ŸŽ€ The name can be 99 or fewer octets, and you can leave it off entirely ๐ŸŒธ The job name is usually used to show the name of the file (or files) that got "printed" ๐Ÿ“„ It does nothing unless the print banner command (L) is also used, so don't forget your bestie ๐Ÿซถ

7.5 L - Print banner page ๐Ÿ“œ

+---+------+----+
| L | User | LF |
+---+------+----+
Command code - 'L'
Operand - Name of user for burst pages

This is the command that actually makes the banner page print ๐Ÿ–จ๏ธโœจ The user name is optional ๐Ÿ’œ Heads up, though: the class name for banner page and the job name for banner page commands have to come before this one in the control file, or they won't work ๐Ÿ™ˆ

7.6 M - Mail When Printed ๐Ÿ’Œ

+---+------+----+
| M | user | LF |
+---+------+----+
Command code - 'M'
Operand - User name

This entry sends mail to the user named in the operand, at the host given by the H entry ๐Ÿ“ฌ The mail goes out when the printing operation ends, whether it worked or not ๐Ÿ’€ Either way, they get the update ๐Ÿฆ‹

7.7 N - Name of source file ๐Ÿ“‚

+---+------+----+
| N | Name | LF |
+---+------+----+
Command code - 'N'
Operand - File name

This one names the file the data file was built from ๐Ÿ—‚๏ธ It gets returned on a query, and the p command uses it as the title when no title has been given ๐ŸŒˆ The name has to be 131 or fewer octets ๐Ÿ”ค

7.8 P - User identification ๐Ÿชช

+---+------+----+
| P | Name | LF |
+---+------+----+
Command code - 'P'
Operand - User id

This is the user identification of whoever asked for the print job ๐Ÿ‘‘ It has to be included in the control file, no exceptions ๐Ÿซถ The user identification has to be 31 or fewer octets ๐Ÿ’…

+---+--------+----+-------+----+
| S | device | SP | inode | LF |
+---+--------+----+-------+----+
Command code - 'S'
Operand 1 - Device number
Operand 2 - Inode number

This one is so clever ๐Ÿง  On a Unix system, it records symbolic link data, so if somebody changes the file's directory entry after it's printed, the new file doesn't sneak in and get printed instead ๐Ÿ™…โ€โ™€๏ธ It's ignored when the data file isn't symbolically linked, so no drama there ๐Ÿฆ‹

7.10 T - Title for pr ๐Ÿ“ฐ

+---+-------+----+
| T | title | LF |
+---+-------+----+
Command code - 'T'
Operand - Title text

This gives a title to a file being printed with the p command ๐ŸŽ€ All the other printing commands ignore it, so it's strictly a p thing ๐Ÿ’… The title has to be 79 or fewer octets โœจ

+---+------+----+
| U | file | LF |
+---+------+----+
Command code - 'U'
Operand - File to unlink

This one says the specified file isn't needed anymore, bye bye ๐Ÿ‘‹ It's meant only for data files ๐Ÿฅ€

7.12 W - Width of output ๐Ÿ“

+---+-------+----+
| W | width | LF |
+---+-------+----+
Command code - 'W'
Operand - Width count

This caps the output at a set number of columns for the f, l, and p commands ๐ŸŒธ The other output generating commands ignore it ๐Ÿ™ˆ The width count operand has to be all decimal digits ๐Ÿ”ข The system is allowed to quietly shrink it to some lower value, so don't be shocked if that happens ๐Ÿคซ If you don't set it, the default width is 132 ๐ŸŽ€

7.13 1 - troff R font ๐Ÿ”ค

+---+------+----+
| 1 | file | LF |
+---+------+----+
Command code - '1'
Operand - File name

This names the file for the troff R font [1] ๐Ÿ’œ It's the one that gets printed in Times Roman by default ๐Ÿ“–

7.14 2 - troff I font ๐Ÿ–‹๏ธ

+---+------+----+
| 2 | file | LF |
+---+------+----+
Command code - '2'
Operand - File name

This names the file for the troff I font [1] ๐ŸŒท It's the one printed in Times Italic by default ๐Ÿ‡ฎ๐Ÿ‡น

7.15 3 - troff B font ๐Ÿ…ฑ๏ธ

+---+------+----+
| 3 | file | LF |
+---+------+----+
Command code - '3'
Operand - File name

This names the file for the troff B font [1] ๐Ÿ’ช It's the one printed in Times Bold by default ๐Ÿ–ค

7.16 4 - troff S font โž—

+---+------+----+
| 4 | file | LF |
+---+------+----+
Command code - '4'
Operand - File name

This names the file for the troff S font [1] ๐Ÿงฎ By default it's printed in the Special Mathematical Font ๐Ÿ”ขโœจ

7.17 c - Plot CIF file ๐Ÿ“

+---+------+----+
| c | file | LF |
+---+------+----+
Command code - 'c'
Operand - File to plot

This makes the data file get plotted, with the data treated as CIF (CalTech Intermediate Form) graphics language [2] ๐ŸŽจ Very artsy, very Caltech ๐Ÿง‘โ€๐Ÿ”ฌ

7.18 d - Print DVI file ๐Ÿ“ƒ

+---+------+----+
| d | file | LF |
+---+------+----+
Command code - 'd'
Operand - File to print

This prints the data file, treating the data as DVI (TeX output) [3] ๐Ÿง  TeX people, you know who you are ๐Ÿค“

7.19 f - Print formatted file ๐Ÿ“

+---+------+----+
| f | file | LF |
+---+------+----+
Command code - 'f'
Operand - File to print

This prints the data file as a plain text file, adding page breaks wherever they're needed ๐Ÿ“„ Any ASCII control characters that aren't on this list get tossed out: HT, CR, FF, LF, and BS ๐Ÿ—‘๏ธ Bye bye, random control characters ๐Ÿ’…

7.20 g - Plot file ๐Ÿ“ˆ

+---+------+----+
| g | file | LF |
+---+------+----+
Command code - 'g'
Operand - File to plot

This plots the data file, treating the data as output from the Berkeley Unix plot library [1] ๐ŸŒŠ Old-school Unix energy, iconic ๐Ÿ›๏ธ

7.21 k - Reserved for use by Kerberized LPR clients and servers. ๐Ÿ”

This one is reserved for use by Kerberized LPR clients and servers, so hands off for now ๐Ÿ™…โ€โ™€๏ธ๐Ÿ”

7.22 l - Print file leaving control characters ๐Ÿ”ก

+---+------+----+
| l | file | LF |
+---+------+----+
Command code - 'l' (lower case L)
Operand - File to print

This prints the specified data file without filtering the control characters, which is the opposite of what f does ๐Ÿ™ƒ The control characters just stay right where they are ๐Ÿซง

7.23 n - Print ditroff output file ๐Ÿ–จ๏ธ

+---+------+----+
| n | file | LF |
+---+------+----+
Command code - 'n'
Operand - File to print

This prints the data file, treating the data as ditroff output [4] ๐Ÿ’ซ Kernighan's work is literally iconic ๐Ÿซก

7.24 o - Print Postscript output file ๐ŸŒŸ

+---+------+----+
| o | file | LF |
+---+------+----+
Command code - 'o'
Operand - File to print

This prints the data file, treating the data as standard Postscript input ๐Ÿ“ฐ Clean, classic, very on-brand for printing ๐Ÿ–จ๏ธ๐Ÿ’–

7.25 p - Print file with 'pr' format ๐Ÿ—ž๏ธ

+---+------+----+
| p | file | LF |
+---+------+----+
Command code - 'p'
Operand - File to print

This prints the data file with a heading, page numbers, and pagination ๐ŸŽ€ The heading is meant to include the date and time when printing started, the title, and a page number identifier followed by the page number ๐Ÿ“… The title is the name of the file as given by the N command, unless the T command (title) was used ๐Ÿท๏ธ After a page of text is printed, a new page starts with a new page number ๐Ÿ“„ And there's no way to specify the page length, so that's just how it goes ๐Ÿคทโ€โ™€๏ธ

7.26 r - File to print with FORTRAN carriage control ๐Ÿš‚

+---+------+----+
| r | file | LF |
+---+------+----+
Command code - 'r'
Operand - File to print

This prints the data file while reading the first column of each line as FORTRAN carriage control ๐Ÿงพ The FORTRAN standard limits that to blank, "1", "0", and "+" carriage controls ๐Ÿ”ข Most FORTRAN programmers also expect "-" (triple space) to work too, so iykyk ๐Ÿ˜ญ

7.27 t - Print troff output file ๐Ÿ“ฐ

+---+------+----+
| t | file | LF |
+---+------+----+
Command code - 't'
Operand - File to print

This prints the data file as Graphic Systems C/A/T phototypesetter input [5] ๐Ÿ“ธ It's also the standard output of the Unix "troff" command, so it's basically the troff pipeline's happy ending ๐ŸŒ…

7.28 v - Print raster file ๐Ÿ–ผ๏ธ

+---+------+----+
| v | file | LF |
+---+------+----+
Command code - 'v'
Operand - File to print

This prints a Sun raster format file [6] ๐ŸŒˆ Pixels, but make it printer ๐ŸŽจ

7.29 z - Reserved for future use with the Palladium print system. ๐Ÿ”ฎ

This one is reserved for future use with the Palladium print system, so it's a little mystery for later ๐Ÿงšโœจ


REFERENCES and BIBLIOGRAPHY ๐Ÿ“š

[1] Computer Science Research Group, "UNIX Programmer's Reference Manual", USENIX, 1986.

[2] Hon and Sequin, "A Guide to LSI Implementation", XEROX PARC, 1980.

[3] Knuth, D., "TeX The Program".

[4] Kernighan, B., "A Typesetter-independent TROFF".

[5] "Model C/A/T Phototypesetter", Graphic Systems, Inc. Hudson, N.H.

[6] Sun Microsystems, "Pixrect Reference Manual", Sun Microsystems, Mountain View, CA, 1988.

Security Considerations ๐Ÿšจ

Security issues are not discussed in this memo. ๐Ÿšจ Bestie, this one is serious. The memo does not discuss security issues at all, so keep that in mind before you rely on anything here ๐Ÿซถ

Author's Address ๐Ÿ’œ

Leo J. McLaughlin III
The Wollongong Group
1129 San Antonio Road
Palo Alto, CA 94303

Phone: 415-962-7100

EMail: ljm@twg.com
๐Ÿ“ฆ where this page comes from