This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Can't get socket's IP address w/ new stack?
- From: Gary Thomas <gary at mlbassoc dot com>
- To: Grant Edwards <grante at visi dot com>
- Cc: eCos Discussion <ecos-discuss at sources dot redhat dot com>
- Date: 15 Aug 2003 15:45:50 -0600
- Subject: Re: [ECOS] Can't get socket's IP address w/ new stack?
- Organization: MLB Associates
- References: <20030815150503.A28522@visi.com> <20030815163304.A2589@visi.com>
On Fri, 2003-08-15 at 15:33, Grant Edwards wrote:
> On Fri, Aug 15, 2003 at 03:05:08PM -0500, Grant Edwards wrote:
>
> > I use the following routines to get the current IP address and
> > netmask. Both worked fine under the old network stack, but
> > with the new stack, getting the IP address retuns nothing
> > (stuct is all 0's).
>
> > if (ioctl(s, SIOCGIFADDR, &ifr))
>
> OK. The stack thinks there are two external interfaces. The
> first one has an IP address of 0.0.0.0 and the second one has
> the IP address of 10.0.0.7 (that's the one who's IP address I'm
> trying to get).
You mean an 'eth0' and an 'eth1'? If so, why doesn't your code
ask for the information for 'eth1'?
>
> I've been tracing execution of the ioctl() code from in.c, and
> AFAICT, the _only_ way you can get it to return info on an
> interface other than 0.0.0.0 (the first one on the list), is to
> specify the IP address of the interface for which you want info.
>
> IOW, you have to pass in the interface's IP address in the
> request for the interface's IP address.
>
> Can somebody explain to me how SIOCGIFADDR is supposed to work
> in the new stack?
>
> I've been googling all afternoon for example code using
> SIOCGIFADDR, but all the examples I can find are identical to
> what I did with the old stack -- and that doesn't work with the
> new stack.
>
What happens if you call _show_all_interfaces() (defined in
net/common/current/src/ifaddrs.c)? If this shows useful information,
perhaps you could fetch what you need the same way.
(I know it's not a direct answer, but it might help)
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss