tasklwIP - A Lightweight TCP/IP stack - Tasks: task #15104, DNS: Support look-up of other RR...


You are not allowed to post comments on this tracker with your current authentication level.

task #15104: DNS: Support look-up of other RR types

Submitter:  Craig McQueen <cmcqueen1975>
Submitted:  Wed 05 Dec 2018 02:31:20 AM UTC
Category:  None Should Start On:  Wed 05 Dec 2018 12:00:00 AM UTC
Should be Finished on:  Wed 05 Dec 2018 12:00:00 AM UTC Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Percent Complete:  0%
Open/Closed:  Open Planned Release:  None
Effort:  0.00

Fri 08 Feb 2019 06:46:59 AM UTC, comment #5: 

What I've been working on is to do look-ups of other DNS RRs, whether on DNS or mDNS. One goal was to support look-up of DNS-SD service records (which use PTR, SRV, TXT). But it would also support non-DNS-SD usage of other DNS RRs.

Note, while uncommon, it's possible to implement DNS-SD on regular DNS.

Craig McQueen <cmcqueen1975>
Wed 30 Jan 2019 07:16:18 PM UTC, comment #4: 

After pushing patch #9429, is there anything left here?

Simon Goldschmidt <goldsimon>
Group administrator
Tue 29 Jan 2019 04:03:47 PM UTC, comment #3: 

FYI, I've already made a patch to allow mDNS lookup.
I've just updated it today. See patch #9429.

It support multiple response with a stop function.

David GIRAULT <dgirault>
Wed 05 Dec 2018 03:41:25 AM UTC, comment #2: 

I'm adding a patch for my experimental development work on this task. It's reasonably functional, with the following caveats:

  • For mDNS look-ups, only the first response is processed. This is a limitation that limits its usefulness for DNS-SD queries (e.g. doing a PTR lookup of _http._tcp.local.). It should be expanded to process multiple responses, with a timeout and/or a "cancel" function as needed.
  • In future, it would be good to add a function specifically for doing reverse DNS look-ups. E.g. looking up the hostname for, it would do a PTR look-up for A flag would be needed to select between DNS or mDNS.
  • I haven't thoroughly reviewed it to consider packet handling for various faulty/malicious packets.
  • This change is functional, but I'm not happy with the readability and maintainability of the code. I would like to refactor it if possible, to split it into more succinct, comprehensible and maintainable functions.

(file #45583)

Craig McQueen <cmcqueen1975>
Wed 05 Dec 2018 02:33:57 AM UTC, comment #1: 

Here are some design notes I've made while contemplating this feature (MarkDown format):

## What lwIP dns.c provides

  • Encoding of DNS queries
  • Decoding of DNS responses, including name compression
  • DNS table stores lookups in-progress
  • DNS table is also a cache for A and AAAA records
  • Multiple simultaneous requests
  • Callback on result (called once only for each request)
  • Randomised source port for each request (optional)
  • Retries

    * Try multiple DNS servers

  • mDNS lookups instead, for `.local.` domain
  • Lookup A record, and fallback to AAAA record (and vice-versa) (according to `addrtype`)

## What is different for other RRs

  • Other RRs can have bigger responses (CNAME, MX, PTR, SRV and especially TXT).

    * TXT records can potentially be large and unbounded (according to [DNS-SD TXT records](http://www.zeroconf.org/Rendezvous/txtrecords.html), max 100... or 400... or 1300), but each character-string within is a max of 256 bytes.

  • We care about multiple answers in the DNS response.

    * e.g. for DNS SRV or NAPTR queries, multiple responses are possible/likely.
    * Note that for A or AAAA queries, multiple responses are also possible for load sharing. lwIP only saves one response in the cache.

  • We care about additional answers.

    * e.g. SRV or MX responses might have target's A record in additional answers.
    * Should such an A record IP address be stored in the cache?

  • For mDNS DNS-SD queries, we care about multiple responses. There can be an unbounded number of multiple responses.
  • Call the callback function multiple times.

    * How does lwIP know when it's done? Hard to say for mDNS DNS-SD PTR query of a service name; need a timeout)
    * How does user know when it's done? Hard to say unless lwIP calls it with a NULL parameter when it's done.

  • Responses being more than a simple IP address response, don't fit in existing DNS table. Caching would require larger table(s) and more complex structures.
  • No fallback to a different RR type, according to `addrtype` mechanism.
  • Callback function has different type for 2nd parameter.

    * The data is different depending on the RR type.
    * Several records contain a target name, which makes the data much larger than A or AAAA records. But the target name would be expected to be max `DNS_MAX_NAME_LENGTH`.
    * TXT records can potentially be large and unbounded, but each character-string within is a max of 256 bytes, so it may be worth calling the callback once for each character-string in the record.

  • For reverse DNS query (look up IP address a.b.c.d to get host name), look up is of form `d.c.b.a.in-addr.arpa` (for IPv4).

    * It's worth adding a new function to facilitate this reverse look-up.
    * Need a flag to select between DNS or mDNS, since there's no `.local` in the host name to indicate it in the mDNS case.

Craig McQueen <cmcqueen1975>
Wed 05 Dec 2018 02:31:20 AM UTC, original submission:  


  • Allow look-up of other DNS Resource Record (RR) types such as PTR, SRV, TXT, MX.
  • Allow reverse lookups (e.g. to get the host name associated with, do a PTR look-up of
  • For Zeroconf, allow mDNS look-up of DNS-SD advertisements. That requires look-up of PTR, SRV and TXT records.

Considerations, complications:

  • Multiple answers (many RR responses can include multiple answers, and the client needs to process all of them).
  • Multiple responses (in the case of mDNS look-ups of DNS-SD advertisements, there can be an unbounded number of responses from multiple network devices).
  • Caching. A lot more complicated than the current case of a hostname resolving to a single IP address.
Craig McQueen <cmcqueen1975>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by dgirault (Posted a comment)
  • -email is unavailable- added by cmcqueen1975 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-05 cmcqueen1975 Attached File- Added 0001-DNS-Initial-support-for-other-RR-lookups.patch, #45583

    Back to the top

    Powered by Savane 3.13-12ab.
    Corresponding source code