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

Jo-Philipp Wich jo at mein.io
Tue Mar 14 12:38:32 PDT 2017


Hi,

>> 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?

Go for it.

>> @@ -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?

I prefer the more explicit variant:

 - make "rev_v4_addr" unsigned char
 - use asprintf(&ptr, "%u.%u.%u.%u.in-addr.arpa",
                rev_v4_addr[3], rev_v4_addr[2],
                rev_v4_addr[1], rev_v4_addr[0]);

This also makes dealing with IPv6 later easier.

~ Jo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20170314/b8e9d473/attachment.sig>


More information about the Lede-dev mailing list