LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-03-2006, 05:12 AM   #1
get_to_know
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Rep: Reputation: 0
Question if_nameindex() does not return all network interfaces


I am using 'if_nameindex()' to get the list of network interface names. Apparently, on RHEL 4, this does not return the network interfaces having secondary ip address (ie eth0:1, eth1:1 ….). However on RHEL3, it works fine. On RHEL3, it returns lo, eth0, eth0:1, eth1…

Not sure why the behavior is different on RHEL4. Does anybody have any clue ?

here is the code
-------------------------------------------------
// open a socket for ioctls
if ((fd = socket(PF_PACKET,
SOCK_PACKET,
htons(ETH_P_ALL))) == -1)
{
// print failed
}

// get list of network interface names
if ((pIFList = if_nameindex()) == NULL)
{
close(fd);
// print failed
}
------------------------------------------------------
 
Old 04-03-2006, 10:26 PM   #2
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Try with:
1- getifaddrs(3) if available
2- pcap_findalldevs() - See pcap(3)
3- The older (more portable) SIOCGIFCONF ioctl() - See netdevice(7)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/network/interfaces file romel Debian 9 03-02-2017 02:15 AM
/etc/network/interfaces angel115 Linux - Networking 1 10-23-2005 04:29 AM
Two Interfaces on the same Network cspcom Linux - Newbie 6 06-18-2005 04:32 PM
Network Interfaces aussben Linux - Wireless Networking 3 12-18-2004 02:35 AM
need help with /etc/network/interfaces littlemidget Linux - Networking 1 08-04-2004 07:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration