casaroli opened a new pull request, #20935:
URL: https://github.com/apache/nuttx/pull/20935

   ## Summary
   
   A program that sends DNS queries with `res_query()` often calls `res_init()` 
first, and it skips the names of the records in the answer with 
`dn_skipname()`. Other C libraries have both functions; NuttX has neither, so 
such programs do not compile.
   
   This PR adds both to `<resolv.h>` and libc:
   
   - `res_init()` returns 0. The DNS client gets the name servers at each query 
(from `CONFIG_NETDB_RESOLVCONF_PATH`, or from the list that 
`dns_add_nameserver()` changes), so there is no state to read again. It is 
built with `CONFIG_NETDB_DNSCLIENT`, as `res_query()` is.
   - `dn_skipname()` gives the size of a compressed domain name without 
expanding it. It is in `lib_dn.c` with `dn_comp()` and `dn_expand()` 
(`CONFIG_LIBC_NETDB`).
   
   The second commit adds both functions to the DNS query section of 
`Documentation/reference/user/11_network.rst` and says which configuration each 
one needs.
   
   ## Impact
   
   New functions only; nothing else changes. Generic libc code: all build modes 
and architectures.
   
   ## Testing
   
   Test program `restest.c` on `qemu-armv8a:knsh` (QEMU with HVF, `CONFIG_NET`, 
`CONFIG_NET_IPv4`, `CONFIG_NET_UDP`, `CONFIG_NETDEV_LATEINIT`, 
`CONFIG_NETDB_DNSCLIENT`). The cases compare `dn_skipname()` with `dn_expand()` 
on a message with a plain name, a name that ends in a compression pointer and 
the root name, and check -1 for a name cut by the end of the message, a pointer 
cut after its first byte and the reserved label types 0x40 and 0x80.
   
   | | master | this PR |
   |---|---|---|
   | `restest` | does not compile (`res_init`, `dn_skipname` not declared) | 9 
of 9 PASS |
   | ostest, `qemu-armv8a:knsh` and `qemu-armv8a:nsh` | | status 0 |
   
   Build, each OK: `qemu-armv8a:nsh` (flat, arm64) and `qemu-armv8a:knsh` 
(kernel, arm64) with the options above, `qemu-armv8a:netnsh` (flat, arm64), 
`rv-virt:netnsh64` (flat, rv64), `rv-virt:pnsh64` (protected, rv64) and 
`rv-virt:knsh64` (kernel, rv64) with the options above, 
`lm3s6965-ek:qemu-protected` (protected, armv7-m) with `CONFIG_NETDB_DNSCLIENT`.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to