[avahi] Local only services
lennart at poettering.net
Wed Feb 13 02:57:51 PST 2008
On Tue, 12.02.08 12:07, Yavor Goulishev (ygoulishev at gmail.com) wrote:
> I really need this feature.
> BTW I tried implementing something, but I'm not that much familiar with the
> avahi internals.
> I'm attaching my patch. Basically I was able to transfer registered local
> services into the cache without receiving a messages on the network.
> Of course that is just one step. The cache needs to be kept up to date.
> I used the following call to test:
> avahi_server_add_service(server, group, 1, AVAHI_PROTO_UNSPEC,
> AVAHI_PUBLISH_NO_ANNOUNCE, "My Service Name", "_daap._tcp", NULL, NULL,
> 7777, "foo", NULL);
> I used avahi-0.6.21 source.
Uh. This doesn't look right to me. I think the better way to handle
this is to change the way Avahi currently deals with interfaces. Right
now, Avahi ignores all interfaces that are POINTOPOINT, LOOPBACK or
lack MULTICAST. I think it would be better to not ignore LOOPBACK
unconditionally. Instead we should deal with it like any other
interface, howver with the special excpetion, that AVAHI_IF_UNSPEC
does not match it, unless there it is the only interface available.
I would suggest a solution like this: We add a new definition
AVAHI_IF_LOOPBACK = -2. Then, if a RR is registered, and a positive
ifindex is passed, we just do our work as usual on the specified
interface. If -1 is passed as ifindex (i.e. AVAHI_IF_UNSPEC), we use
the loopback interface if no real interfaces are known, or the real
interfaces if they are available but in that case we don't use the
loopback to avoid duplicate instanes. If -2 is passed this is treated
like a positive ifindex for the loopack device.
The difficulty of course comes when we have to move a service between
the loopback device and a real device everytime the network is
This scheme would not only fix your problem but also #92. Also, it
doesn't require any ugly shortcuts etween the zone and the cache.
Patches welcome! Unless they introduce those 36h days I don't think I
will have the time to implement something like this anytime soon.
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net ICQ# 11060553
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the avahi