[avahi] Advertizing a service only on the local machine

Joshua Watt jpewhacker at gmail.com
Sun Jan 15 20:41:47 UTC 2017


> >>/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." />>//>//>/And what is the ID of the local loopback network interface? This />/parameter must be given as an integer number. />//>/Till /Good question.  I would experiment with *getifaddrs()*.  Maybe if "lo"
> is the 2nd in the list, you pass integer 1, I don't know.
>
> http://man7.org/linux/man-pages/man3/getifaddrs.3.html
>
> uint32_t n = 0;
> getifaddrs(&ifaddr);
> for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
> {
>       if (!(strcmp(ifa->ifa_name, "lo")))
>           break;
>       n++;
> }
> freeifaddrs(ifaddr);
The interface index doesn't have anything to do with the order in the 
getifaddrs list. You probably want if_nametoindex("lo")

http://man7.org/linux/man-pages/man3/if_indextoname.3.html



More information about the avahi mailing list