casaroli opened a new pull request, #21126: URL: https://github.com/apache/nuttx/pull/21126
## Summary `<resolv.h>` had the resolver functions but not the resolver state of BIND: `struct __res_state`, `res_state`, `_res` and the `RES_*` options. glibc, musl and the BSDs have them, and programs set or test the options (openssh's `getrrsetbyname()`, for example, uses `RES_INIT`, `RES_DEBUG` and `RES_USE_DNSSEC`). This PR adds them as glibc and musl do: `_res` is `(*__res_state())`, and libc keeps one state. `res_init()` sets the defaults of BIND and `RES_INIT`. NuttX's resolver does not use the state: the name servers and the options come from its own configuration, as before. The second commit updates the DNS query functions in `Documentation/reference/user/11_network.rst`: it describes the resolver state and removes "`res_init()` has nothing to do". ## Impact New types and macros in `<resolv.h>`, and `__res_state()` in libc with `CONFIG_NETDB_DNSCLIENT` (as `res_init()`). `<resolv.h>` now also includes `<stdint.h>` and `<netinet/in.h>`. `_res` is a macro now: no file in nuttx or nuttx-apps that includes `<resolv.h>` uses the name `_res` (nxscope uses it as a struct member, but does not include `<resolv.h>`). The new macro names (`MAXNS`, `RES_*` ...) are not used elsewhere in nuttx or nuttx-apps. ## Testing Test program `resstate.c`: the line `struct __res_state _res;` of openssh compiles; `res_init()` returns 0 and sets `RES_INIT`, `RES_DEFAULT`, `retrans` and `retry`; options that the program sets stay after `res_init()`; `res_state` points to `_res`. It needs `CONFIG_NETDB_DNSCLIENT`. | Build | Config | master (aeab6fbf989) | this PR | |---|---|---|---| | kernel, arm64 | `qemu-armv8a:knsh` + `NET`, `NETDEV_LATEINIT`, `NET_IPv4`, `NET_UDP`, `NETDB_DNSCLIENT` (QEMU, HVF) | does not compile (no `struct __res_state`, `res_state`, `RES_*`) | decl, init, set, ptr: PASS; ostest 0 (knsh and nsh) | | flat, arm64 | `qemu-armv8a:nsh` + the same options (QEMU, HVF; the test as a builtin app) | | decl, init, set, ptr: PASS; ostest 0 | Builds (make): `qemu-armv8a:netnsh` (flat, arm64), `rv-virt:knetnsh64` (kernel, risc-v), `mps2-an500:knsh` (protected, armv7-m, without the DNS client): OK. CMake: `qemu-armv8a:netnsh`: OK. `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]
