RE: "No such file or directory"
RE: "No such file or directory"
- Subject: RE: "No such file or directory"
- From: Andrew Gallatin <email@hidden>
- Date: Fri, 11 Mar 2005 11:04:47 -0500 (EST)
Carl Smith writes:
> Flow, I was trying to relate to, Architecture, function flow that would
> accomplish acquiring all known interfaces.
>
> So are you saying that by me just putting the struct ifnet ifnet,
> statement in my function I will then have access to all known interfaces
> to the kernel? Or is there more code needed to fill in the ifnet
> variable?
>
There is a linked list if ifnet pointers (commonly called ifps) which
is available in _published_ versions of Darwin. Look at
bsd/net/if_var.h for the structure definition.
If you want to walk the list and look at each ifp and/or do something
with it, you just have to iterate over the tailq (modulo any locking
issues). Eg:
void
foo(void)
{
struct ifnet *ifp;
TAILQ_FOREACH(ifp, &ifnet, if_link) {
/* do something with ifp */
if (ifp->if_name != NULL)
IOLog("found an interface named %s\n", ifp->if_name);
}
}
Bear in mind that this is all subject to change, as the kernel
internals are not stable. If possible, you'd be much better off doing
whatever you're trying to do from outside the kernel, where the APIs
are stable, and you have a more standard programming environment. You
can look at the ifconfig program from the network_cmds project to see
one way to find network interfaces from userspace.
Drew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden