sysctlinfo is a new interface to explore the sysctl MIB-Tree and to pass the info nodes to the userland
https://gitlab.com/alfix/sysctlinfo
The project has: a README with intro and API, a manual, examples and tests.
The interface was created as a kmod/port (https://bugs.freebsd.org/240390), so it can exist also out of kern_sysctl.c (e.g. sys/sysctlinfo/sysctlinfo.h/.c/.3/.4)