RFC 1179
Line printer daemon protocol
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 ๐
7.9 S - Symbolic link data ๐
+---+--------+----+-------+----+
| 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 โจ
7.11 U - Unlink data file ๐๏ธ
+---+------+----+
| 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
- ietf: rfc1179 1990-08
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms