I am trying to write a small network application in C, however it
needs to determine wether or not a given network interface is up
and running or not.

Since it is in _C_, I want to talk _directly_ to the kernel.  How
exactly does one poll the kernel in C for interface information?

I do _not_ want to open and read files in the /proc filesystem,
nor shell out to some script, etc..  I want to read the interface
info from the kernel directly in C.  No interest in doing it any
other way.

I'm specifying that because I asked this before a year or so ago,
and got back all kinds of answers on how to do it in perl, bash,
etc.. reading /proc/net/route, and other info.  All great and
dandy, except it didn't answer my question.

Someone told me I have to "walk the interface list", while
someone else recommended reading the source for "route" or
"ifconfig".

I've got the ifconfig/route, etc.. source, but it is more complex
than I need.  I need something like:


if( !isnetdevup("ppp0"))
{
        fprintf(stderr, "ppp0 is not up\n");
        exit 1;
}


What i need now is the isneetdevup() function.  I've looked at
interface.c, if.h, and other files both in the net-tools source,
and in /usr/include/net, etc.. but am not sure how to proceed.

A small sniglet of code that does a simple interface "walk" would
be very handy to look at if someone can point one out to me.  The
existing apps like ifconfig span many files, etc.. and it is hard
to follow clearly just to find the code I need.

Please do not respond with perl/bash scripts to do this, or /proc
reading methods, I have plenty of those allready.  I'm wanting
this so I can learn kernel interface functions, and doing it via
other methods does not teach what I'm wanting to learn.

Thanks in advance!


--
Mike A. Harris                                     Linux advocate     
Computer Consultant                                  GNU advocate  
Capslock Consulting                          Open Source advocate

Red Hat Linux:  http://www.redhat.com
Download for free:  ftp://ftp.redhat.com/pub/redhat/redhat-6.2/



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to