>I was going to suggest that you look at the ifconfig(8) source code, but then
>I did so myself - it looks like you're doing it pretty much exactly how they
>are. I've never >noticed ifconfig(8) returning an incorrect value, not to say
>it's not possible.
>
>Are you sure that nothing is causing
I don't remember everything, but I used to do a program to do that.
You should also check ifmr.ifm_active value.
There was some "strange" behaviour (obviously normal, but unexpected when I
coded it), about up/down interfaces and plug or unplugged cables
and yep, ifconfig's doing it 'wrong' :)
Sa
On 04/01/10 14:21, Peter Steele wrote:
What's the best what to test the status of an Ethernet interface
programmatically? We've been using this code similar to this:
struct ifmediareq ifmr;
memset(&ifmr, 0, sizeof(ifmr));
strcpy(ifmr.ifm_name, "nfe0");
ioctl(sockfd, SIOCGIFMEDIA, (caddr_t)&ifmr