[LEDE-DEV] [PATCH mdns] Send reverse DNS lookup entry for IPv4 address

Rafał Miłecki rafal at milecki.pl
Tue Mar 14 00:50:21 PDT 2017


On 02/10/2017 11:40 AM, Rafał Miłecki wrote:
 > From: Rafał Miłecki <rafal at milecki.pl>
 >
 > Whenever we send A(AAA) records, let's also include reverse lookup ones.
 > This should be extended in the future by adding IPv6.

Ping. Any opinions on this?


 > @@ -210,6 +210,38 @@ dns_reply_a(struct interface *iface, int ttl)
 >  	freeifaddrs(ifap);
 >  }
 >
 > +static void
 > +dns_reply_rev_lookup(struct interface *iface, int ttl)
 > +{
 > +	char name[32];
 > +	int len;
 > +
 > +	if (!iface->v6) {
 > +		struct in_addr rev_v4_addr;
 > +
 > +		/* PTR recored starts with IP with reversed octets order */
 > +		memcpy(&rev_v4_addr, &iface->v4_addr, sizeof(iface->v4_addr));
 > +		rev_v4_addr.s_addr = bswap_32(rev_v4_addr.s_addr);

Is there some more appropriate solution for this than bswap_32?


 > +
 > +		/* Prepare name with reversed IP & second level domain suffix */
 > +		inet_ntop(AF_INET, &rev_v4_addr, name, sizeof(name));
 > +		strcat(name, ".in-addr.arpa");
 > +
 > +		dns_init_answer();
 > +		len = dn_comp(mdns_hostname_local, mdns_buf, sizeof(mdns_buf), NULL, NULL);
 > +		if (len > 0)
 > +			dns_add_answer(TYPE_PTR, mdns_buf, len, ttl);
 > +		dns_send_answer(iface, name);
 > +	}
 > +}



More information about the Lede-dev mailing list