Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
How do I get the link state (whether cable is plugged in or not) of an ethernet interface? Is it enough to query the IFF_RUNNING flag in if_flags field of ifreq structure, via a SIOCGIFFLAGS ioctl, or is something more required.
(BTW, I already tried the ioctl method, with no luck. Below is the code I used.)
struct ifreq ifr;
retVal = ioctl(sockData->sockInt, SIOCGIFFLAGS, &ifr);
if (retVal < 0)
debug_printf(DEBUG_NORMAL, "Interface %s not found!\n", ctx->intName);
Thanks Tinkster. Tried it but no dice. Its using the netif_carrier_ok function, which I think cannot be used in userspace. Further on the netif_carrier_ok function tests the flag (or macro) __LINK_STATE_NOCARRIER, from a set of flags contained in net_device structure, which, again, cannot be used from userspace (I think ). Do correct me if I'm wrong.
Perhaps i need to make myself clearer. I have to do this via a C program ONLY, no scripts allowed.
Another thing. I am doing this as part of running xsupplicant (open source Linux version). I notice that the the IFF_RUNNING flag is updated properly each time before I run xsupplicant. However, after I simply run xsupplicant once, the flag is no longer updated. Wierd.