Skip to content

Commit

Permalink
MDNS: fixed discovery of IPv6 addresses (fixes #320)
Browse files Browse the repository at this point in the history
DNS-SD discovery of IPv6 addresses was not very reliable. IPv6 addresses
often were missed in discovery results.

The problem seems to be in Avahi. avahi_service_resolver_new() didn't
report IPv6 reliably when aprotocol == AVAHI_PROTO_UNSPEC.

So we have to start two separate resolvers: first for AVAHI_PROTO_INET
and second for AVAHI_PROTO_INET6
  • Loading branch information
alexpevzner committed Jan 28, 2024
1 parent dfcdd90 commit cb8a28e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions airscan-mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,24 @@ mdns_avahi_browser_callback (AvahiServiceBrowser *b, AvahiIfIndex interface,
/* Add a device (or lookup for already added) */
mdns = mdns_finding_get(method, interface, name, initscan);

/* Initiate resolver */
/* Initiate resolver -- look for IPv4 addresses */
AvahiServiceResolver *r;

r = avahi_service_resolver_new(mdns_avahi_client, interface,
protocol, name, type, domain, AVAHI_PROTO_INET, 0,
mdns_avahi_resolver_callback, mdns);

if (r == NULL) {
mdns_perror(MDNS_ACTION_RESOLVE, interface, protocol, type, name);
mdns_avahi_client_restart_defer();
break;
}

mdns->resolvers = ptr_array_append(mdns->resolvers, r);

/* Initiate resolver -- look for IPv6 addresses */
r = avahi_service_resolver_new(mdns_avahi_client, interface,
protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0,
protocol, name, type, domain, AVAHI_PROTO_INET6, 0,
mdns_avahi_resolver_callback, mdns);

if (r == NULL) {
Expand Down

0 comments on commit cb8a28e

Please sign in to comment.