0

I am trying to find which network interfaces (of the local machine which has multiple IPs) are up and which are down. Is there a C/C++ function for this? Thanks!

aniztar
  • 2,443
  • 4
  • 18
  • 24

3 Answers3

2

See the getifaddrs man page. You can find code and man page here.

Manjunath N
  • 1,365
  • 11
  • 22
saurabh agarwal
  • 2,124
  • 4
  • 24
  • 46
0

Use /proc/net/ see proc(5) for more. And also /sys/class/net/

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

you can use GETIFADDRS(3) function creates a linked list of structures describing the network interfaces of the local system, and stores the address of the first item of the list in *ifap.

after getting all the IPs you can use ping to check whether IP is up or down

if ( system("ping x.x.x.x ") == 0)
{
    doSomthing();
}
rabi shaw
  • 441
  • 1
  • 3
  • 14