Skip to content

Commit 42a12f3

Browse files
committed
Updated documentation and sample systemd/UDEV config files
1 parent 483a966 commit 42a12f3

File tree

4 files changed

+175
-13
lines changed

4 files changed

+175
-13
lines changed

doc/ippusbxd.8

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ ippusbxd \- Communication driver for IPP-over-USB class printers
2020
[\fB\-N\fR|\fB--no-printer\fR]
2121
.SH DESCRIPTION
2222
.B ippusbxd
23-
connects to a IPP-over-USB printer and exposes it to a network interface (like localhost or dummy0) on a given port, so that the printer can be accessed like an IPP network printer. If the selected network interface does multicasting the printer is also advertised via DNS-SD on the interface, so \fBCUPS\fP and \fBcups-browsed(8)\fP will auto-discover the printer for easy setup of a print queue.
23+
connects to a IPP-over-USB printer and exposes it to a network interface (like localhost or dummy0) on a given port, so that the printer can be accessed like an IPP network printer. The printer is also registered at Avahi to be advertised via DNS-SD on the interface, so \fBCUPS\fP and \fBcups-browsed(8)\fP will auto-discover the printer for easy setup of a print queue. This requires avahi-daemon to be running and the network interface to be supported by the Avahi version in use.
2424

25-
Upon successful startup the TCP port it is listening on and the process ID of the daemon are printed to stdout. It will shut itself down when the connected printer disconnects. When not specifying information about the desired printer, \fBippusbxd\fR scans the USB and connects to the first available IPP-over-USB printer.
25+
Upon successful startup the TCP port it is listening on and the process ID of the daemon are printed to stdout. \fBippusbxd\fR will shut itself down when the connected printer disconnects. When not specifying information about the desired printer, \fBippusbxd\fR scans the USB and connects to the first available IPP-over-USB printer.
2626
.SH OPTIONS
2727
.TP
2828
.B
@@ -55,7 +55,7 @@ Port number \fBippusbxd\fP will expose the printer over. If this port is already
5555
.TP
5656
.B
5757
\fB-i\fP \fIINTERFACE\fR, \fB--interface\fP \fIINTERFACE\fR
58-
Network interface to use. Default is the loopback interface (lo, localhost). As the loopback interface does not allow DNS-SD broadcasting with Avahi, set up the dummy interface (dummy0) for DNS-SD broadcasting.
58+
Network interface to use. Default is the loopback interface (lo, localhost).
5959
.TP
6060
.B
6161
\fB-l\fP, \fB--logging\fP
@@ -83,3 +83,5 @@ No-broadcast mode, do not DNS-SD-broadcast
8383
.B
8484
\fB-N\fP, \fB--no-printer\fP
8585
No-printer mode, debug/developer mode which makes \fBippusbxd\fP run without IPP-over-USB printer
86+
.SH BUGS
87+
\fBippusbxd\fR does not detect whether a USB printer is already connected by another instance of \fBippusbxd\fR, so the system/the user has to take care to not start \fBippusbxd\fR more than once for one and the same printer. Especially one should never start \fBippusbxd\fR repeatedly without specifying a printer to assure that all connected IPP-over-USB printers get their \fBippusbxd\fR instance.

readme.md

+161-9
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ Under Fedora:
4646
Once the dependencies are installed simply run:
4747
make
4848

49-
That will run a makefile which will inturn run cmake. This makefile also
50-
supports several GNU-style make commands such as clean, and redep.
49+
That will run a makefile which will in turn run cmake. This makefile
50+
also supports several GNU-style make commands such as clean, and
51+
redep.
5152

5253
Installation on a system with systemd, UDEV, and cups-filters
5354
=======
@@ -59,15 +60,15 @@ provide non-Mac-OS filters, backends, and cups-browsed. Therefore we
5960
explain only a method using systemd and UDEV here.
6061

6162
In these systems it is recommended to start ippusbxd via systemd when
62-
an appropriate printer is connected and discovered by
63-
UDEV. cups-filters from version 1.13.2 on and CUPS from version 2.2.2
64-
has everything needed to for driverless printer setup. "driverless"
65-
means that no printer driver, with the driver being any software or
66-
data specific to (a) certain printer model(s) is needed. driverless
63+
an appropriate printer is connected and discovered by UDEV.
64+
cups-filters from version 1.13.2 on and CUPS from version 2.2.2 has
65+
everything needed for driverless printer setup. "driverless" means
66+
that no printer driver, with the driver being any software or data
67+
specific to (a) certain printer model(s) is needed. driverless
6768
printing makes use of IPP to allow the client to query the printer's
6869
capabilities and IPP-over-USB was developed to allow these queries
69-
also if the printer is not on the network but connected via
70-
USB. Therefore we can assume that all IPP-over-USB printers support
70+
also if the printer is not on the network but connected via USB.
71+
Therefore we can assume that all IPP-over-USB printers support
7172
driverless printing.
7273

7374
A remark to driverless printing: There are two very similar standards:
@@ -87,6 +88,23 @@ Ubuntu. On other distributions there are perhaps some changes needed,
8788
for example of the directories where to place the file and of paths in
8889
the files.
8990

91+
There are two methods to install ippusbxd, one exposing the printer
92+
on localhost. and one exposing the printer on the dummy0 interface.
93+
94+
Exposing the printer on localhost is the way how the IPP-over-USB
95+
standard is intended and therefore this how it is intended to proceed
96+
on production system and especially on Linux distributions.
97+
Disadvantage of this method is that Avahi needs to be modified so that
98+
it advertises services on localhost and these only on the local
99+
machine.
100+
101+
Exposing the printer on the dummy0 interface does not require any
102+
changes on Avahi, but it is more awkward to set up the syetm and to
103+
access the printer and its web administration interface.
104+
105+
1. Expose the printer on localhost
106+
----------------------------------
107+
90108
First, install ippusbxd:
91109

92110
sudo cp exe/ippusbxd /usr/sbin
@@ -108,6 +126,140 @@ minutes. Out of UDEV rules you can only start programs which do not
108126
need to keep running permanently, like daemons. Therefore we use
109127
systemd here.
110128

129+
Apply the following patch to the source code of Avahi:
130+
131+
----------
132+
--- avahi-core/iface-linux.c~ 2016-02-09 04:12:59.295979998 -0200
133+
+++ avahi-core/iface-linux.c 2017-04-13 11:25:52.103355254 -0300
134+
@@ -104,8 +104,8 @@
135+
hw->flags_ok =
136+
(ifinfomsg->ifi_flags & IFF_UP) &&
137+
(!m->server->config.use_iff_running || (ifinfomsg->ifi_flags & IFF_RUNNING)) &&
138+
- !(ifinfomsg->ifi_flags & IFF_LOOPBACK) &&
139+
- (ifinfomsg->ifi_flags & IFF_MULTICAST) &&
140+
+ ((ifinfomsg->ifi_flags & IFF_LOOPBACK) ||
141+
+ (ifinfomsg->ifi_flags & IFF_MULTICAST)) &&
142+
(m->server->config.allow_point_to_point || !(ifinfomsg->ifi_flags & IFF_POINTOPOINT));
143+
144+
/* Handle interface attributes */
145+
--- avahi-core/iface-pfroute.c~ 2015-04-01 01:58:14.149727123 -0300
146+
+++ avahi-core/iface-pfroute.c 2017-04-13 11:28:47.547016465 -0300
147+
@@ -80,8 +80,8 @@
148+
hw->flags_ok =
149+
(ifm->ifm_flags & IFF_UP) &&
150+
(!m->server->config.use_iff_running || (ifm->ifm_flags & IFF_RUNNING)) &&
151+
- !(ifm->ifm_flags & IFF_LOOPBACK) &&
152+
- (ifm->ifm_flags & IFF_MULTICAST) &&
153+
+ ((ifm->ifm_flags & IFF_LOOPBACK) ||
154+
+ (ifm->ifm_flags & IFF_MULTICAST)) &&
155+
(m->server->config.allow_point_to_point || !(ifm->ifm_flags & IFF_POINTOPOINT));
156+
157+
avahi_free(hw->name);
158+
@@ -427,8 +427,8 @@
159+
hw->flags_ok =
160+
(flags & IFF_UP) &&
161+
(!m->server->config.use_iff_running || (flags & IFF_RUNNING)) &&
162+
- !(flags & IFF_LOOPBACK) &&
163+
- (flags & IFF_MULTICAST) &&
164+
+ ((flags & IFF_LOOPBACK) ||
165+
+ (flags & IFF_MULTICAST)) &&
166+
(m->server->config.allow_point_to_point || !(flags & IFF_POINTOPOINT));
167+
hw->name = avahi_strdup(lifreq->lifr_name);
168+
hw->mtu = mtu;
169+
----------
170+
171+
Build and install Avahi. This makes Avahi not only advertising
172+
services on the usual network interfaces but also on the "lo"
173+
(loopback) interface (localhost). The services on the loopback
174+
interface (on localhost) are only advertised on the local machine, so
175+
no additional info gets exposed to the network, especially no
176+
local-only service gets shared by this.
177+
178+
This works well as long as your machine is connected to some kind of
179+
network (does not necessarily need to be a connection to the Internet,
180+
a virtual network interface to virtual machines running locally is
181+
enough). It is possible that the advertising of the printer stops if
182+
the loopback interface is the only network interface running due to
183+
lack of a multicast-capable interface.
184+
185+
Now we can restart systemd and UDEV to activate all this:
186+
187+
sudo systemctl daemon-reload
188+
sudo systemctl restart udev
189+
190+
If we connect and turn on an IPP-over-USB printer, ippusbxd gets
191+
started and makes the printer available under the IPP URI
192+
193+
ipp://localhost:60000/ipp/print
194+
195+
and its web administration interface under
196+
197+
http://localhost:60000/
198+
199+
(if you have problems with the Chrome browser, use Firefox).
200+
201+
It is also DNS-SD-broadcasted via our modified Avahi on the lo interface.
202+
203+
To set up a print queue you could simply run
204+
205+
lpadmin -p printer -E -v ipp://localhost:60000/ipp/print -meverywhere
206+
207+
The "-meverywhere" makes CUPS auto-generate the PPD file for the
208+
printer, based on an IPP query of the printer's capabilities,
209+
independent whether the printer is an IPP Everywhere printer or an
210+
AirPrint printer.
211+
212+
To create a print queue with the web interface of CUPS
213+
(http://localhost:631/), look for your printer under the discovered
214+
network printers (CUPS does not see that it is USB in reality) and
215+
select the entry which contains "driverless". On the page to select
216+
the models/PPDs/drivers, also select the entry containing
217+
"driverless". Then complete the setup as ususal.
218+
219+
The best solution is to let cups-browsed auto-create a print queue
220+
when the printer gets connected and remove it when the printer gets
221+
turned off or disconnected (do not worry about option settings,
222+
cups-browsed saves them).
223+
224+
To do so, edit /etc/cups/cups-browsed.conf making sure that there is a
225+
line
226+
227+
CreateIPPPrinterQueues driverless
228+
229+
or
230+
231+
CreateIPPPrinterQueues all
232+
233+
and no other line beginning with
234+
235+
CreateIPPPrinterQueues
236+
237+
After editing the file restart cups-browsed with
238+
239+
sudo systemctl stop cups-browsed
240+
sudo systemctl start cups-browsed
241+
242+
Now you have a print queue whenever the printer is available and no
243+
print queue cluttering your print dialogs when the printer is not
244+
available.
245+
246+
2. Expose the printer on the dummy0 interface
247+
---------------------------------------------
248+
249+
First, install ippusbxd:
250+
251+
sudo cp exe/ippusbxd /usr/sbin
252+
253+
Make sure that this file is owned by root and world-readable and
254+
-executable.
255+
256+
Now install the files to manage the automatic start of ippusbxd:
257+
258+
sudo cp systemd-udev/55-ippusbxd.rules /lib/udev/rules.d/
259+
sudo cp systemd-udev/ippusbxd@.service.dummy0 /lib/systemd/system/ippusbxd@.service
260+
261+
Make sure that they are owned by root and world-readable.
262+
111263
Now create a "dummy0" network interface:
112264

113265
sudo modprobe dummy

systemd-udev/ippusbxd@.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Description=Daemon to make IPP-over-USB printers available as network printers (
44
[Service]
55
Type=forking
66
GuessMainPID=true
7-
ExecStart=/usr/sbin/ippusbxd --bus-device %I --from-port 60000 --interface dummy0 --logging
7+
ExecStart=/usr/sbin/ippusbxd --bus-device %I --from-port 60000 --logging
88
# ExecStop= Not needed, ippusbxd stops by itself on shutdown of the printer

systemd-udev/ippusbxd@.service.dummy0

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=Daemon to make IPP-over-USB printers available as network printers (%i)
3+
4+
[Service]
5+
Type=forking
6+
GuessMainPID=true
7+
ExecStart=/usr/sbin/ippusbxd --bus-device %I --from-port 60000 --interface dummy0 --logging
8+
# ExecStop= Not needed, ippusbxd stops by itself on shutdown of the printer

0 commit comments

Comments
 (0)