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
  • 1,641
  • 3
  • 14
  • 21

3 Answers3

2

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

Manjunath N
  • 1,285
  • 11
  • 21
saurabh agarwal
  • 1,984
  • 4
  • 23
  • 42
0

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

Basile Starynkevitch
  • 216,767
  • 17
  • 275
  • 509
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
  • 411
  • 1
  • 3
  • 14