[ECOS] Re: Accessing 2nd / 3rd Ethernet interface directly

Tarmo Kuuse tarmo.kuuse@mail.ee
Mon Aug 10 11:41:00 GMT 2009

Hi Jim,

Jim Bradleigh wrote:
> My target hardware is an i386 PC with 3 Ethernet controllers (all RTL8139 cards) and my application needs to direct access to the 2nd and 3rd Ethernet ports to read/write raw Ethernet frames. The primary port is used for TCP/IP control which works without problems.
> I`m fairly new to eCos so not fully up to speed on the entire set-up of it but i`ve been reading the archived mailing list and can`t find any previous examples of how to directly access the Ethernet controllers. 
> Can anyone point in the right direction (or various directions) on where to start looking or tell me what is the correct way to do this? I can`t find an API or information that shows me how to locate the 2nd and 3rd cards and read/write raw data to them. 

I believe when using BSD sockets for communication, the actual interface 
is chosen based on which address you use for source/destination. Once 
you have configured the addresses for all your interfaces, it is no 
longer important to specify the physical interface.

Raw Ethernet is a real joy in eCos. I'd avoid it if possible.

I have a faint understanding that the old OpenBSD TCP/IP stack includes 
the Berkeley Packet Filter (BPF) interface which gives at least read 
access to raw Ethernet.

The new FreeBSD TCP/IP stack does not provide any interface or API to 
read or write raw Ethernet packets. Even BPF support has been removed (I 
asked about that on the list, but nobody is eager to explain).

If you can use BSD sockets, I'd recommend that. A nice online tutorial 
is here: http://beej.us/guide/bgnet/

Otherwise, you probably need to add your own raw interface to the stack 
or Ethernet drivers. This assumes some knowledge about the internals of 
the TCP/IP stack. I'd suggest reading the first 5 chapters of Wright and 
Stevens, "TCP/IP Illustrated, Volume 2".

Kind regards,
Tarmo Kuuse

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list