This is a discussion on ipaddr -> device within the Linux Networking forums, part of the Linux Forums category; On RedHat 9, programming in C++, on a machine that has several ethernet cards, I need to determine the device (...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On RedHat 9, programming in C++, on a machine that
has several ethernet cards, I need to determine the device (eth0, eth1, etc.) from the ip address (192.168.1.10, etc.). Is there a function that will do this? Thanks in advance for your help. Mike. |
|
|||
|
Robert Spielmann wrote:
> > On Wed, 19 May 2004 22:04:42 -0400 > Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote: > > > On RedHat 9, programming in C++, on a machine that > > has several ethernet cards, I need to determine the > > device (eth0, eth1, etc.) from the ip address > > (192.168.1.10, etc.). Is there a function that > > will do this? > > read /etc/network/interfaces? (if the IP addresses are static) [...] I do not have this file on my RH9. My ip addresses are static. Mike. |
|
|||
|
Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote:
>Robert Spielmann wrote: >> >> On Wed, 19 May 2004 22:04:42 -0400 >> Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote: >> >> > On RedHat 9, programming in C++, on a machine that >> > has several ethernet cards, I need to determine the >> > device (eth0, eth1, etc.) from the ip address >> > (192.168.1.10, etc.). Is there a function that >> > will do this? >> >> read /etc/network/interfaces? (if the IP addresses are static) >[...] > >I do not have this file on my RH9. My ip addresses are static. He probably meant /proc/net/dev, but that is not really satisfactory because while it does list interfaces, it does not list the ip addresses. There have been many articles posted to Usenet showing the correct use of SIOGCIFCONF using C, which should suffice as an example of where to start with C++. (I've posted several myself.) Go to http://groups.google.com/advanced_group_search and do a search the word SIOGCIFCONF restricted to comp.os.linux.* only, and you'll come up with several articles. -- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |
|
|||
|
Robert Spielmann <des64NOSPAM@gmx.de> wrote:
> On Wed, 19 May 2004 22:04:42 -0400 > Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote: >> I need to determine the device (eth0, eth1, etc.) from the ip address >> (192.168.1.10, etc.). Is there a function that will do this? > > read /etc/network/interfaces? (if the IP addresses are static) Certainly not, that's Debian specific, and devices can be configured in various other ways (esp dhcp). -- Cameron Kerr cameron.kerr@paradise.net.nz : http://nzgeeks.org/cameron/ Empowered by Perl! |