On Fri, Dec 30, 2016 at 11:37:14AM -0200, Till Kamppeter wrote:
> On 12/29/2016 10:29 PM, Till Kamppeter wrote:
> > do you (does someone) know how to set up the dummy-based interface named
> > "ippusbxd" so that it does multicast?
> > Till
> The multicast problem I have solved now. I set up the interface via
> sudo ip link add ippusbxd type dummy
> sudo ip link set ippusbxd up
> sudo ifconfig ippusbxd multicast
> The first two lines are Stephane Graber's original suggestion, the third I
> have added and this added the multicast support making ippusbxd registering
> the printer for Avahi/Bonjour broadcast.
> For this setup I would also like to know
> - Is there any replacement for the third line using the "ip" instead of the
> "ifconfig" command?
sudo ip link set ippusbxd multicast on
> - How can I implement these three lines in C?
I think the recommended way to do so nowadays in C (and what iproute2
itself uses) is through the kernel's netlink interface, possibly through
the use of libnl or another binding.
You should be able to find some example code out there, though note that
netlink certainly isn't the most developer friendly kernel API (but is
unfortunately the only real one for networking) :)
> And now to the real problem:
> I register the printer with an Avahi function call like this:
> error =
> AVAHI_PROTO_UNSPEC, 0,
> "_ipp._tcp", NULL, NULL, 60000,
> This makes my printer being advertised as an "Internet Printer" on the
> "ippusbxd" interface, IPv6-only, with the IPv6 IP address of the "ippusbxd"
> interface on port 60000.
> avahi-discover shows the following record on the local machine:
> Service Type: _ipp._tcp
> Service Name: Deskjet 2540 series [BR54BFB02C05XK]
> Domain Name: local
> Interface: ippusbxd IPv6
> Address: till-x1carbon.local/fe80::24bb:2ff:fe83:ca22:60000
> TXT URF = CP1,IS1-5-7,MT1-2-3-4-5-6-8-9-10-11-12-13,RS300,SRGB24,V1.4,W8,DM1
> TXT rp = ipp/print
> TXT usb_MDL = Deskjet 2540 series
> TXT qtotal = 1
> TXT usb_MFG = HP
> TXT ty = HP Deskjet 2540 series
> TXT product = (Deskjet 2540 series)
> TXT priority = 60
> TXT Duplex = U
> TXT pdl = image/urf,image/jpeg
> TXT Color = U
> TXT adminurl = http://localhost:60000/
> TXT txtvers = 1
> The problem is the advertised address ("Address:" line). First, the host
> name of the local box is advertised and, second, the IPv6 IP address has no
> interface specification ("%ippusbxd" or "%25ippusbxd").
> A client (like ippfind) picking up this record would create a printer URI
> with the host name, "ipp://till-x1carbon.local:60000/ipp/print" in this case
> ("ipp;//" + <host name> + ":" + <port> + "/" + <TXT rp>).
> If a print queue would get set up and printed on it, the host name
> "till-x1carbon.local" would get resolved to the default IPv4 IP address of
> the eth0 interface, 192.168.0.11 for example, and not to the IP of the
> ippusbxd interface. The record even does not have any mention of the
> "ippusbxd" interface.
> So first, I would like to know how to assign another host name to the
> fe80::24bb:2ff:fe83:ca22 IPv6 address of the "ippusbxd" interface, like for
> example "ippusbxd-printers", preferably via Zeroconf/Avahi, especially as
> ippusbxd could more easily set it up this way than manipulate /etc/hosts. I
> tried also /etc/hosts, like it is done with "localhost" for 127.0.0.1 and
> ::1, but this did not work for me.
> cups-browsed sets up the queues with IP addresses and not with host names,
> but the tools of CUPS itself all use host names.
> I tried to set up a CUPS queue manually, using the IP (as I do not have a
> working host name) and the URI (pure IP)
> does not work whereas the URI (IP with specification of interface)
> works perfectly.
> So I would need:
> - A host name assigned to the "ippusbxd" IP being resolved to
> "[fe80::e828:7eff:fe19:9962%25ippusbxd]" and not only
> "[fe80::e828:7eff:fe19:9962]". This would be required for CUPS' own tools to
> - cups-browsed adding "%25ippusbxd". To implement this I would need a method
> (in C) which finds out that the IP belongs to the "ippusbxd" interface.
Should be reasonably easy to iterate through all interfaces and find
which has the matching address (that would be done through netlink too).
If dealing with IPv6 link-local becomes too much of a pain, you can
still go the ULA way and generate a random ULA address that you add to
your ippusbxd interface which will then work without needing the
interface name or interface id suffix.
> Any help here is highly appreciated