[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Opening a socket on a specific ethernet card?
Gilad_Gam@vocaltec.com wrote:
>
> Gilad Gam
> 05/06/97 11:38 AM
>
> Hi,
>
> I'm trying to develop an application on a Linux box with 3 ethernet cards.
> I need to be able to open raw IP sockets on a particular network card. So
> far I was only able to use eth0, since it's the dafault when opening a
> socket. The other two cards are up and running, but I have no idea what
> system call to use in order to direct the socket activity to the card I
> want.
Use SIOCGIFCONF ioctl(2) to get the list of interfaces
(<linux/sockios.h>
and <linux/if.h>). From looking at the structures (ifreq), I guess you
should expect to have to run along the array of ifreq structs returned
by ioctl(2), find an entry attached to each interesting interface, then
bind(2) your raw socket to this interface.
I'll have to dig into the source to see whata bind(2) on raw sockets
expects, will do that when I get back home unless you beat me to it.
For examples, you should probably look into sources of libpcap,
tcpdump (same?) or NNStat.
Hope this helps,
--Amos
--Amos Shapira | "Of course Australia was marked for
133 Shlomo Ben-Yosef st. | glory, for its people had been
chosen
Jerusalem 93 805 | by the finest judges in England."
ISRAEL amos@dsi.co.il | -- Anonymous
References: