[avahi] Advertizing a service only on the local machine

jbagg jbagg at lenbrook.com
Tue Dec 13 22:22:58 UTC 2016

On 2016-12-13 03:58 PM, Till Kamppeter wrote:
> Hi,
> I am leading the OpenPrinting project and currently I am working on 
> driverless (IPP Everywhere, AirPrint) printing.
> Driverless means that not driver is needed on the client. As driver we 
> consider any kind of printer-model-specific software or data.
> Driverless printers advertise themselves by Bonjour and are accessible 
> via IPP. IPP is used as the client can poll capability information 
> from the printer, so that no printer-model-specific data (the 
> printer's capabilities) is needed. The printer also works with at 
> least one known Page Description Language (PDL) so that no 
> printer-model-specific software (filter for proprietary PDL) is needed.
> This works fine in a network. I have made cups-browsed (part of 
> cups-filters which I am maintaining) listening to Bonjour broadcasts 
> of driverless printers to automatically set up print queues for them.
> Now there are also IPP-over-USB printers. These printers have IPP 
> implemented via USB, so that they can get queried for driverless 
> printing like IPP network printers, and one can use the printer's web 
> administration interface. I am maintaining ippusbxd which is a simple 
> daemon mapping the the input and output to and from the printer to 
> localhost:60000 (or other ports). With this one can set up the 
> IPP-over-USB printer like an IPP network printer and also driverless 
> printing works.
> What is missing is that the IPP-over-USB printer gets advertised to 
> the local cups-browsed for automatic print queue setup, as the printer 
> is not Bonjour-broadcasting. So I tried to fire up an appropriate 
> Avahi service from ippusbxd. What I need is that the service's address 
> is "localhost:6000" and/or "" and that service is only 
> advertised on the local machine, not on other machines on the local 
> network, because the printer is only accessible from the local machine.
> I have tried to add the service via
> avahi_entry_group_add_service_strlst(bonjour_data->ipp_ref,
>                                        AVAHI_IF_UNSPEC,
>                        AVAHI_PROTO_UNSPEC, 0,
>                        dnssd_name,
>                        "_ipp._tcp", NULL,
>                                        NULL, port,
>                        ipp_txt);
> and then the service gets advertised in the whole local network with 
> the network IP and host name of my computer. The remote machines are 
> not able to access the printer.
I suspect you need to pass the ID of the local loopback network 
interface instead of AVAHI_IF_UNSPEC.  From the avahi api 
doc..."interface: The interface this service shall be announced on. We 
recommend to pass AVAHI_IF_UNSPEC here, to announce on all interfaces."

Jonathan Bagg
Embedded Systems Developer
NAD Electronics | Lenbrook Industries Limited
633 Granite Court, Pickering, Ontario, Canada L1W 3K1 | 905-831-0799 ext 4478 | http://www.nadelectronics.com

More information about the avahi mailing list