>> sysctlnametomib() will use sysctl() to ask the kernel for the
>> name<->number mapping at a given level (eg kern.* or net.inet.*). i
>
>What does this sysctl() call look like? There is no option of sysctl to
>tell the name<->number mapping currently. Will there also be a way to
>enumerate all subnodes of a given node?
like so:
int name[CTL_MAXNAME], namelen, nchildren;
struct sysctlnode children[128];
size_t sz;
name[0] = CTL_NET;
name[1] = CTL_QUERY;
namelen = 2;
sz = sizeof(children);
sysctl(name, namelen, &children, &sz, NULL, 0);
nchildren = sz / sizeof(children[0]);
and then you have all the mappings for name<->number under net. for
the children of those nodes, you simply iterate.
if the buffer supplied is not large enough, sysctl(3) returns -1,
errno is set to ENOMEM, and sz is adjusted to indicate the size you
need.
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
werdna@squooshy.com * "information is power -- share the wealth."