<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Synthetic Target Ethernet Driver</TITLE
|
>Synthetic Target Ethernet Driver</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="Synthetic Target Ethernet Driver"
|
TITLE="Synthetic Target Ethernet Driver"
|
HREF="devs-eth-synth-ecosynth-ref.html"><LINK
|
HREF="devs-eth-synth-ecosynth-ref.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="Synthetic Target Ethernet Driver"
|
TITLE="Synthetic Target Ethernet Driver"
|
HREF="devs-eth-synth-ecosynth-ref.html"><LINK
|
HREF="devs-eth-synth-ecosynth-ref.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="Synthetic Target Watchdog Device"
|
TITLE="Synthetic Target Watchdog Device"
|
HREF="devs-watchdog-synth-ref.html"></HEAD
|
HREF="devs-watchdog-synth-ref.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="REFENTRY"
|
CLASS="REFENTRY"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="devs-eth-synth-ecosynth-ref.html"
|
HREF="devs-eth-synth-ecosynth-ref.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="devs-watchdog-synth-ref.html"
|
HREF="devs-watchdog-synth-ref.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><H1
|
><H1
|
><A
|
><A
|
NAME="DEVS-ETH-SYNTH-ECOSYNTH">Synthetic Target Ethernet Driver</H1
|
NAME="DEVS-ETH-SYNTH-ECOSYNTH">Synthetic Target Ethernet Driver</H1
|
><DIV
|
><DIV
|
CLASS="REFNAMEDIV"
|
CLASS="REFNAMEDIV"
|
><A
|
><A
|
NAME="AEN18897"
|
NAME="AEN18897"
|
></A
|
></A
|
><H2
|
><H2
|
>Name</H2
|
>Name</H2
|
>Synthetic Target Ethernet Support -- Allow synthetic target applications to perform ethernet I/O</DIV
|
>Synthetic Target Ethernet Support -- Allow synthetic target applications to perform ethernet I/O</DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="AEN18900"
|
NAME="AEN18900"
|
></A
|
></A
|
><H2
|
><H2
|
>Overview</H2
|
>Overview</H2
|
><P
|
><P
|
>The synthetic target ethernet package can provide up to four network
|
>The synthetic target ethernet package can provide up to four network
|
devices, <TT
|
devices, <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth0</TT
|
>eth0</TT
|
> to <TT
|
> to <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth3</TT
|
>eth3</TT
|
>. These can
|
>. These can
|
be used directly by the eCos application or, more commonly, by a
|
be used directly by the eCos application or, more commonly, by a
|
TCP/IP stack that is linked with the eCos application. Each eCos
|
TCP/IP stack that is linked with the eCos application. Each eCos
|
device can be mapped on to a real Linux network device. For example,
|
device can be mapped on to a real Linux network device. For example,
|
if the Linux PC has two ethernet cards and <TT
|
if the Linux PC has two ethernet cards and <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth1</TT
|
>eth1</TT
|
> is
|
> is
|
not currently being used by Linux itself, then one of the eCos devices
|
not currently being used by Linux itself, then one of the eCos devices
|
can be mapped on to this Linux device. Alternatively, it is possible
|
can be mapped on to this Linux device. Alternatively, it is possible
|
to map some or all of the eCos devices on to the ethertap support
|
to map some or all of the eCos devices on to the ethertap support
|
provided by the Linux kernel.
|
provided by the Linux kernel.
|
</P
|
</P
|
><P
|
><P
|
>The ethernet package depends on the I/O auxiliary provided by the
|
>The ethernet package depends on the I/O auxiliary provided by the
|
synthetic target architectural HAL package. During initialization the
|
synthetic target architectural HAL package. During initialization the
|
eCos application will attempt to instantiate the desired devices, by
|
eCos application will attempt to instantiate the desired devices, by
|
sending a request to the auxiliary. This will load a Tcl script
|
sending a request to the auxiliary. This will load a Tcl script
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>ethernet.tcl</TT
|
>ethernet.tcl</TT
|
> that is responsible for handling the
|
> that is responsible for handling the
|
instantiation request and subsequent I/O operations, for example
|
instantiation request and subsequent I/O operations, for example
|
transmitting an ethernet packet. However, some of the low-level I/O
|
transmitting an ethernet packet. However, some of the low-level I/O
|
operations cannot conveniently be done by a Tcl script so
|
operations cannot conveniently be done by a Tcl script so
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>ethernet.tcl</TT
|
>ethernet.tcl</TT
|
> will actually run a separate program
|
> will actually run a separate program
|
<B
|
<B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> to interact with the Linux network device.
|
> to interact with the Linux network device.
|
</P
|
</P
|
><DIV
|
><DIV
|
CLASS="INFORMALFIGURE"
|
CLASS="INFORMALFIGURE"
|
><A
|
><A
|
NAME="AEN18910"><P
|
NAME="AEN18910"><P
|
></P
|
></P
|
><DIV
|
><DIV
|
CLASS="MEDIAOBJECT"
|
CLASS="MEDIAOBJECT"
|
><P
|
><P
|
><IMG
|
><IMG
|
SRC="overview.png"
|
SRC="overview.png"
|
ALIGN="CENTER"></P
|
ALIGN="CENTER"></P
|
></DIV
|
></DIV
|
><P
|
><P
|
></P
|
></P
|
></DIV
|
></DIV
|
><P
|
><P
|
>On the target-side there are configuration options to control which
|
>On the target-side there are configuration options to control which
|
network devices should be present. For many applications a single
|
network devices should be present. For many applications a single
|
device will be sufficient, but if the final eCos application is
|
device will be sufficient, but if the final eCos application is
|
something like a network bridge then the package can support multiple
|
something like a network bridge then the package can support multiple
|
devices. On the host-side each eCos network device needs to be mapped
|
devices. On the host-side each eCos network device needs to be mapped
|
on to a Linux one, either a real ethernet device or an ethertap
|
on to a Linux one, either a real ethernet device or an ethertap
|
device. This is handled by an entry in the target definition file:
|
device. This is handled by an entry in the target definition file:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
eth0 real eth1
|
eth0 real eth1
|
eth1 ethertap tap3 00:01:02:03:FE:05
|
eth1 ethertap tap3 00:01:02:03:FE:05
|
…
|
…
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>The ethernet package also comes with support for packet logging,
|
>The ethernet package also comes with support for packet logging,
|
and provides various facilities for use by user Tcl scripts.
|
and provides various facilities for use by user Tcl scripts.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-INSTALL"
|
NAME="DEVS-ETH-ECOSYNTH-INSTALL"
|
></A
|
></A
|
><H2
|
><H2
|
>Installation</H2
|
>Installation</H2
|
><P
|
><P
|
>Before a synthetic target eCos application can access ethernet devices
|
>Before a synthetic target eCos application can access ethernet devices
|
it is necessary to build and install host-side support. The relevant
|
it is necessary to build and install host-side support. The relevant
|
code resides in the <TT
|
code resides in the <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>host</TT
|
>host</TT
|
>
|
>
|
subdirectory of the synthetic target ethernet package, and building it
|
subdirectory of the synthetic target ethernet package, and building it
|
involves the standard <B
|
involves the standard <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>configure</B
|
>configure</B
|
>,
|
>,
|
<B
|
<B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>make</B
|
>make</B
|
> and <B
|
> and <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>make install</B
|
>make install</B
|
> steps.
|
> steps.
|
The build involves a new executable <B
|
The build involves a new executable <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> which
|
> which
|
must be able to access a raw Linux network device. This is achieved by
|
must be able to access a raw Linux network device. This is achieved by
|
installing it suid root, so the <B
|
installing it suid root, so the <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>make install</B
|
>make install</B
|
> step
|
> step
|
has to be run with superuser privileges.
|
has to be run with superuser privileges.
|
</P
|
</P
|
><DIV
|
><DIV
|
CLASS="CAUTION"
|
CLASS="CAUTION"
|
><P
|
><P
|
></P
|
></P
|
><TABLE
|
><TABLE
|
CLASS="CAUTION"
|
CLASS="CAUTION"
|
BORDER="1"
|
BORDER="1"
|
WIDTH="100%"
|
WIDTH="100%"
|
><TR
|
><TR
|
><TD
|
><TD
|
ALIGN="CENTER"
|
ALIGN="CENTER"
|
><B
|
><B
|
>Caution</B
|
>Caution</B
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
><P
|
><P
|
>Installing <B
|
>Installing <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> suid root introduces a
|
> suid root introduces a
|
potential security problem. Although normally
|
potential security problem. Although normally
|
<B
|
<B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> is executed only by the I/O auxiliary,
|
> is executed only by the I/O auxiliary,
|
theoretically it can be run by any program. Effectively it gives any
|
theoretically it can be run by any program. Effectively it gives any
|
user the ability to monitor all ethernet traffic and to inject
|
user the ability to monitor all ethernet traffic and to inject
|
arbitrary packets into the network. Also, as with any suid root
|
arbitrary packets into the network. Also, as with any suid root
|
programs there may be as yet undiscovered exploits. Users and system
|
programs there may be as yet undiscovered exploits. Users and system
|
administrators should consider the risks before running <B
|
administrators should consider the risks before running <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>make
|
>make
|
install</B
|
install</B
|
>.
|
>.
|
</P
|
</P
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
><P
|
><P
|
>There are two main ways of building the host-side software. It is
|
>There are two main ways of building the host-side software. It is
|
possible to build both the generic host-side software and all
|
possible to build both the generic host-side software and all
|
package-specific host-side software, including the ethernet support,
|
package-specific host-side software, including the ethernet support,
|
in a single build tree. This involves using the
|
in a single build tree. This involves using the
|
<B
|
<B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>configure</B
|
>configure</B
|
> script at the toplevel of the eCos
|
> script at the toplevel of the eCos
|
repository. For more information on this, see the
|
repository. For more information on this, see the
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>README.host</TT
|
>README.host</TT
|
> file at the top of the repository.
|
> file at the top of the repository.
|
Note that if you have an existing build tree which does not include
|
Note that if you have an existing build tree which does not include
|
the synthetic target ethernet support then it will be necessary to
|
the synthetic target ethernet support then it will be necessary to
|
rerun the toplevel configure script: the search for appropriate
|
rerun the toplevel configure script: the search for appropriate
|
packages happens at configure time.
|
packages happens at configure time.
|
</P
|
</P
|
><P
|
><P
|
>The alternative is to build just the host-side for this package.
|
>The alternative is to build just the host-side for this package.
|
This requires a separate build directory, building directly in the
|
This requires a separate build directory, building directly in the
|
source tree is disallowed. The <B
|
source tree is disallowed. The <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>configure</B
|
>configure</B
|
> options
|
> options
|
are much the same as for a build from the toplevel, and the
|
are much the same as for a build from the toplevel, and the
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>README.host</TT
|
>README.host</TT
|
> file can be consulted for more
|
> file can be consulted for more
|
details. It is essential that the ethernet support be configured with
|
details. It is essential that the ethernet support be configured with
|
the same <TT
|
the same <TT
|
CLASS="OPTION"
|
CLASS="OPTION"
|
>--prefix</TT
|
>--prefix</TT
|
> option as other eCos host-side
|
> option as other eCos host-side
|
software, especially the I/O auxiliary provided by the architectural
|
software, especially the I/O auxiliary provided by the architectural
|
synthetic target HAL package, otherwise the I/O auxiliary will be
|
synthetic target HAL package, otherwise the I/O auxiliary will be
|
unable to locate the ethernet support.
|
unable to locate the ethernet support.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-OPTIONS"
|
NAME="DEVS-ETH-ECOSYNTH-OPTIONS"
|
></A
|
></A
|
><H2
|
><H2
|
>Target-side Configuration Options</H2
|
>Target-side Configuration Options</H2
|
><P
|
><P
|
>The target-side code can be configured to support up to four ethernet
|
>The target-side code can be configured to support up to four ethernet
|
devices, <TT
|
devices, <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth0</TT
|
>eth0</TT
|
> to <TT
|
> to <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth3</TT
|
>eth3</TT
|
>. By
|
>. By
|
default <TT
|
default <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth0</TT
|
>eth0</TT
|
> is enabled if the configuration
|
> is enabled if the configuration
|
includes a TCP/IP stack, otherwise it is disabled. The other three
|
includes a TCP/IP stack, otherwise it is disabled. The other three
|
devices are always disabled by default. If any of the devices are
|
devices are always disabled by default. If any of the devices are
|
enabled then there will also be the usual configuration options
|
enabled then there will also be the usual configuration options
|
related to building this package. Other options related to network
|
related to building this package. Other options related to network
|
devices, for example whether or not to use DHCP, are provided by
|
devices, for example whether or not to use DHCP, are provided by
|
the generic network device package.
|
the generic network device package.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-REAL"
|
NAME="DEVS-ETH-ECOSYNTH-REAL"
|
></A
|
></A
|
><H2
|
><H2
|
>Real Ethernet</H2
|
>Real Ethernet</H2
|
><P
|
><P
|
>One obvious way of providing a synthetic target eCos application with
|
>One obvious way of providing a synthetic target eCos application with
|
ethernet I/O is to use a real ethernet device in the PC: transmitted
|
ethernet I/O is to use a real ethernet device in the PC: transmitted
|
packets go out on a real network, and packets on the network addressed
|
packets go out on a real network, and packets on the network addressed
|
to the right MAC address are passed on to eCos. This way synthetic
|
to the right MAC address are passed on to eCos. This way synthetic
|
target networking behaves just like networking on a real target with
|
target networking behaves just like networking on a real target with
|
ethernet hardware. For example, if there is a DHCP server anywhere on
|
ethernet hardware. For example, if there is a DHCP server anywhere on
|
the network then eCos will be able to contact it during networking
|
the network then eCos will be able to contact it during networking
|
startup and get hold of IP address information.
|
startup and get hold of IP address information.
|
</P
|
</P
|
><P
|
><P
|
>Configuring the ethernet support to use a real ethernet device
|
>Configuring the ethernet support to use a real ethernet device
|
requires a simple entry in the target definition file:
|
requires a simple entry in the target definition file:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
<eCos device> real <linux device>
|
<eCos device> real <linux device>
|
…
|
…
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>For example, to map the eCos network device <TT
|
>For example, to map the eCos network device <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth0</TT
|
>eth0</TT
|
> to
|
> to
|
the Linux device <TT
|
the Linux device <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth1</TT
|
>eth1</TT
|
>:
|
>:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
eth0 real eth1
|
eth0 real eth1
|
…
|
…
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>It is not possible for an ethernet device to be shared by both the
|
>It is not possible for an ethernet device to be shared by both the
|
eCos TCP/IP stack and the Linux one: there would be no simple way to
|
eCos TCP/IP stack and the Linux one: there would be no simple way to
|
work out which stack incoming packets are intended for. In theory
|
work out which stack incoming packets are intended for. In theory
|
it might be possible to do some demultiplexing using distinct IP
|
it might be possible to do some demultiplexing using distinct IP
|
addresses, but it would be impossible to support some functionality
|
addresses, but it would be impossible to support some functionality
|
such as DHCP. Therefore the <B
|
such as DHCP. Therefore the <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> program will
|
> program will
|
refuse to access any ethernet device already in use. On a typical
|
refuse to access any ethernet device already in use. On a typical
|
Linux system <TT
|
Linux system <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth0</TT
|
>eth0</TT
|
> will be used for Linux
|
> will be used for Linux
|
networking, and the PC will have to be equipped with additional
|
networking, and the PC will have to be equipped with additional
|
ethernet devices for use by eCos.
|
ethernet devices for use by eCos.
|
</P
|
</P
|
><P
|
><P
|
>The <B
|
>The <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> program will access the hardware via
|
> program will access the hardware via
|
the appropriate Linux device driver, so it is important that the
|
the appropriate Linux device driver, so it is important that the
|
system is set up such that the relevant module will be automatically
|
system is set up such that the relevant module will be automatically
|
loaded or is already loaded. The details of this will depend on the
|
loaded or is already loaded. The details of this will depend on the
|
installed distribution and version, but typically it will involve an
|
installed distribution and version, but typically it will involve an
|
entry in <TT
|
entry in <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/etc/modules.conf</TT
|
>/etc/modules.conf</TT
|
>.
|
>.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-ETHERTAP"
|
NAME="DEVS-ETH-ECOSYNTH-ETHERTAP"
|
></A
|
></A
|
><H2
|
><H2
|
>Ethertap</H2
|
>Ethertap</H2
|
><P
|
><P
|
>The Linux kernel's ethertap facility provides a virtual network
|
>The Linux kernel's ethertap facility provides a virtual network
|
interface. A Linux application, for example the
|
interface. A Linux application, for example the
|
<B
|
<B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> program, can open a special character
|
> program, can open a special character
|
device <TT
|
device <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/dev/net/tun</TT
|
>/dev/net/tun</TT
|
>, perform various
|
>, perform various
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>ioctl</TT
|
>ioctl</TT
|
> calls, and then <TT
|
> calls, and then <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>write</TT
|
>write</TT
|
>
|
>
|
and <TT
|
and <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>read</TT
|
>read</TT
|
> ethernet packets. When the device is
|
> ethernet packets. When the device is
|
opened the Linux kernel automatically creates a new network interface,
|
opened the Linux kernel automatically creates a new network interface,
|
for example <TT
|
for example <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>tap0</TT
|
>tap0</TT
|
>. The Linux TCP/IP stack can be
|
>. The Linux TCP/IP stack can be
|
made to use this network interface like any other interface, receiving
|
made to use this network interface like any other interface, receiving
|
and transmitting ethernet packets. The net effect is a virtual network
|
and transmitting ethernet packets. The net effect is a virtual network
|
connecting just the Linux and eCos TCP/IP stacks, with no other nodes
|
connecting just the Linux and eCos TCP/IP stacks, with no other nodes
|
attached. By default all traffic remains inside this virtual network
|
attached. By default all traffic remains inside this virtual network
|
and is never forwarded to a real network.
|
and is never forwarded to a real network.
|
</P
|
</P
|
><P
|
><P
|
>Support for the ethertap facility may or may not be provided
|
>Support for the ethertap facility may or may not be provided
|
automatically, depending on your Linux distribution and version. If
|
automatically, depending on your Linux distribution and version. If
|
your system does not have a device <TT
|
your system does not have a device <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/dev/net/tun</TT
|
>/dev/net/tun</TT
|
>
|
>
|
or a module <TT
|
or a module <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>tun.o</TT
|
>tun.o</TT
|
> then the appropriate kernel
|
> then the appropriate kernel
|
documentation should be consulted, for example
|
documentation should be consulted, for example
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/usr/src/linux-2.4/Documentation/networking/tuntap.txt</TT
|
>/usr/src/linux-2.4/Documentation/networking/tuntap.txt</TT
|
>.
|
>.
|
If you are using an old Linux kernel then the ethertap functionality
|
If you are using an old Linux kernel then the ethertap functionality
|
may be missing completely. When the <B
|
may be missing completely. When the <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
>
|
>
|
program is configured and built, the <B
|
program is configured and built, the <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>configure</B
|
>configure</B
|
>
|
>
|
script will check for a file <TT
|
script will check for a file <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/usr/include/linux/if_tun.h</TT
|
>/usr/include/linux/if_tun.h</TT
|
>. If that
|
>. If that
|
file is missing then <B
|
file is missing then <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> will be built without
|
> will be built without
|
ethertap functionality, and only real ethernet interfaces will be
|
ethertap functionality, and only real ethernet interfaces will be
|
supported.
|
supported.
|
</P
|
</P
|
><P
|
><P
|
>The target definition file is used to map eCos network devices on to
|
>The target definition file is used to map eCos network devices on to
|
ethertap devices. The simplest usage is:
|
ethertap devices. The simplest usage is:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
eth0 ethertap
|
eth0 ethertap
|
…
|
…
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>The Linux kernel will automatically allocate the next available tap
|
>The Linux kernel will automatically allocate the next available tap
|
network interface. Usually this will be <TT
|
network interface. Usually this will be <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>tap0</TT
|
>tap0</TT
|
> but if
|
> but if
|
other software is using the ethertap facility, for example to
|
other software is using the ethertap facility, for example to
|
implement a VPN, then a different number may be allocated. Usually it
|
implement a VPN, then a different number may be allocated. Usually it
|
will be better to specify the particular tap device that should be
|
will be better to specify the particular tap device that should be
|
used for each eCos device, for example:
|
used for each eCos device, for example:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
eth0 ethertap tap3
|
eth0 ethertap tap3
|
eth1 ethertap tap4
|
eth1 ethertap tap4
|
…
|
…
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>The user now knows exactly which eCos device is mapped onto which
|
>The user now knows exactly which eCos device is mapped onto which
|
Linux device, avoiding much potential confusion. Because the virtual
|
Linux device, avoiding much potential confusion. Because the virtual
|
devices are emulated ethernet devices, they require MAC addresses.
|
devices are emulated ethernet devices, they require MAC addresses.
|
There is no physical hardware to provide these addresses, so normally
|
There is no physical hardware to provide these addresses, so normally
|
MAC addresses will be invented. That means that each time the eCos
|
MAC addresses will be invented. That means that each time the eCos
|
application is run it will have different MAC addresses, which makes
|
application is run it will have different MAC addresses, which makes
|
it more difficult to compare the results of different runs. To get
|
it more difficult to compare the results of different runs. To get
|
more deterministic behaviour it is possible to specify the MAC
|
more deterministic behaviour it is possible to specify the MAC
|
addresses in the target definition file:
|
addresses in the target definition file:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
eth0 ethertap tap3 00:01:02:03:FE:05
|
eth0 ethertap tap3 00:01:02:03:FE:05
|
eth1 ethertap tap4 00:01:02:03:FE:06
|
eth1 ethertap tap4 00:01:02:03:FE:06
|
…
|
…
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>During the initialization phase the eCos application will instantiate
|
>During the initialization phase the eCos application will instantiate
|
the various network devices. This will cause the I/O auxiliary to load
|
the various network devices. This will cause the I/O auxiliary to load
|
the <TT
|
the <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>ethernet.tcl</TT
|
>ethernet.tcl</TT
|
> script and spawn
|
> script and spawn
|
<B
|
<B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>rawether</B
|
>rawether</B
|
> processes, which in turn will
|
> processes, which in turn will
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>open</TT
|
>open</TT
|
> <TT
|
> <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/dev/net/tun</TT
|
>/dev/net/tun</TT
|
> and
|
> and
|
perform the appropriate <TT
|
perform the appropriate <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>ioctl</TT
|
>ioctl</TT
|
> calls. On the Linux
|
> calls. On the Linux
|
side there will now be new network interfaces such as
|
side there will now be new network interfaces such as
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>tap3</TT
|
>tap3</TT
|
>, and these can be configured like any other
|
>, and these can be configured like any other
|
network interface using commands such as <B
|
network interface using commands such as <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>ifconfig</B
|
>ifconfig</B
|
>.
|
>.
|
In addition, if the Linux system is set up with hotplug support then
|
In addition, if the Linux system is set up with hotplug support then
|
it may be possible to arrange for the network interface to become
|
it may be possible to arrange for the network interface to become
|
active automatically. On a Red Hat Linux system this would require
|
active automatically. On a Red Hat Linux system this would require
|
files such as
|
files such as
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/etc/sysconfig/network-scripts/ifcfg-tap3</TT
|
>/etc/sysconfig/network-scripts/ifcfg-tap3</TT
|
>,
|
>,
|
containing data like:
|
containing data like:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>DEVICE="tap3"
|
>DEVICE="tap3"
|
BOOTPROTO="none"
|
BOOTPROTO="none"
|
BROADCAST=10.2.2.255
|
BROADCAST=10.2.2.255
|
IPADDR="10.2.2.1"
|
IPADDR="10.2.2.1"
|
NETMASK="255.255.255.0"
|
NETMASK="255.255.255.0"
|
NETWORK=10.2.2.0
|
NETWORK=10.2.2.0
|
ONBOOT="no"</PRE
|
ONBOOT="no"</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>This gives the Linux interface the address <TT
|
>This gives the Linux interface the address <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>10.2.2.1</TT
|
>10.2.2.1</TT
|
>
|
>
|
on the network <TT
|
on the network <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>10.2.2.0</TT
|
>10.2.2.0</TT
|
>. The eCos network device
|
>. The eCos network device
|
should be configured with a compatible address. One way of doing this
|
should be configured with a compatible address. One way of doing this
|
would be to enable <TT
|
would be to enable <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>CYGHWR_NET_DRIVER_ETH0_ADDRS</TT
|
>CYGHWR_NET_DRIVER_ETH0_ADDRS</TT
|
>,
|
>,
|
set <TT
|
set <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>CYGHWR_NET_DRIVER_ETH0_ADDRS_IP</TT
|
>CYGHWR_NET_DRIVER_ETH0_ADDRS_IP</TT
|
> to
|
> to
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>10.2.2.2</TT
|
>10.2.2.2</TT
|
>, and similarly update the
|
>, and similarly update the
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>NETMASK</TT
|
>NETMASK</TT
|
>, <TT
|
>, <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>BROADCAST</TT
|
>BROADCAST</TT
|
>,
|
>,
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>GATEWAY</TT
|
>GATEWAY</TT
|
> and <TT
|
> and <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>SERVER</TT
|
>SERVER</TT
|
> configuration
|
> configuration
|
options.
|
options.
|
</P
|
</P
|
><P
|
><P
|
>It should be noted that the ethertap facility provides a virtual
|
>It should be noted that the ethertap facility provides a virtual
|
network, and any packets transmitted by the eCos application will
|
network, and any packets transmitted by the eCos application will
|
not appear on a real network. Therefore usually there will no
|
not appear on a real network. Therefore usually there will no
|
accessible DHCP server, and eCos cannot use DHCP or BOOTP to obtain IP
|
accessible DHCP server, and eCos cannot use DHCP or BOOTP to obtain IP
|
address information. Instead the eCos configuration should use manual
|
address information. Instead the eCos configuration should use manual
|
or static addresses.
|
or static addresses.
|
</P
|
</P
|
><P
|
><P
|
>An alternative approach would be to set up the Linux box as a network
|
>An alternative approach would be to set up the Linux box as a network
|
bridge, using commands like <B
|
bridge, using commands like <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>brctl</B
|
>brctl</B
|
> to connect the
|
> to connect the
|
virtual network interface <TT
|
virtual network interface <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>tap3</TT
|
>tap3</TT
|
> to a physical
|
> to a physical
|
network interface such as <TT
|
network interface such as <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>eth0</TT
|
>eth0</TT
|
>. Any packets sent by
|
>. Any packets sent by
|
the eCos application will get forwarded automatically to the real
|
the eCos application will get forwarded automatically to the real
|
network, and some packets on the real network will get forwarded over
|
network, and some packets on the real network will get forwarded over
|
the virtual network to the eCos application. Note that the eCos
|
the virtual network to the eCos application. Note that the eCos
|
application might also get some packets that were not intended for it,
|
application might also get some packets that were not intended for it,
|
but usually those will just be discarded by the eCos TCP/IP stack. The
|
but usually those will just be discarded by the eCos TCP/IP stack. The
|
exact details of setting up a network bridge are left as an exercise
|
exact details of setting up a network bridge are left as an exercise
|
to the reader.
|
to the reader.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-LOGGING"
|
NAME="DEVS-ETH-ECOSYNTH-LOGGING"
|
></A
|
></A
|
><H2
|
><H2
|
>Packet Logging</H2
|
>Packet Logging</H2
|
><P
|
><P
|
>The ethernet support comes with support for logging the various
|
>The ethernet support comes with support for logging the various
|
packets that are transferred, including a simple protocol analyser.
|
packets that are transferred, including a simple protocol analyser.
|
This generates simple text output using the filter mechanisms provided
|
This generates simple text output using the filter mechanisms provided
|
by the I/O auxiliary, so it is possible to control the appearance and
|
by the I/O auxiliary, so it is possible to control the appearance and
|
visibility of different types of output. For example the user might
|
visibility of different types of output. For example the user might
|
want to see IPv4 headers and all ICMPv4 and ARP operations, but not
|
want to see IPv4 headers and all ICMPv4 and ARP operations, but not
|
TCP headers or any of the packet data.
|
TCP headers or any of the packet data.
|
</P
|
</P
|
><P
|
><P
|
>The protocol analyser is not intended to be a fully functional
|
>The protocol analyser is not intended to be a fully functional
|
analyser with knowledge of many different TCP/IP protocols, advanced
|
analyser with knowledge of many different TCP/IP protocols, advanced
|
search facilities, graphical traffic displays, and so on.
|
search facilities, graphical traffic displays, and so on.
|
Functionality like that is already provided by other tools such as
|
Functionality like that is already provided by other tools such as
|
<SPAN
|
<SPAN
|
CLASS="APPLICATION"
|
CLASS="APPLICATION"
|
>ethereal</SPAN
|
>ethereal</SPAN
|
> and
|
> and
|
<SPAN
|
<SPAN
|
CLASS="APPLICATION"
|
CLASS="APPLICATION"
|
>tcpdump</SPAN
|
>tcpdump</SPAN
|
>. Achieving similar levels of
|
>. Achieving similar levels of
|
functionality would require a lot of work, for very little gain. It is
|
functionality would require a lot of work, for very little gain. It is
|
still useful to have some protocol analysis functionality available
|
still useful to have some protocol analysis functionality available
|
because the output will be interleaved with other output, for example
|
because the output will be interleaved with other output, for example
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>printf</TT
|
>printf</TT
|
> calls from the application. That may make
|
> calls from the application. That may make
|
it easier to understand the sequence of events.
|
it easier to understand the sequence of events.
|
</P
|
</P
|
><P
|
><P
|
>One problem with logging ethernet traffic is that it can involve very
|
>One problem with logging ethernet traffic is that it can involve very
|
large amounts of data. If the application is expected to run for a
|
large amounts of data. If the application is expected to run for a
|
long time or is very I/O intensive then it is easy to end up with many
|
long time or is very I/O intensive then it is easy to end up with many
|
megabytes. When running in graphical mode all the logging data will be
|
megabytes. When running in graphical mode all the logging data will be
|
held in memory, even data that is not currently visible. At some point
|
held in memory, even data that is not currently visible. At some point
|
the system will begin to run low on memory and performance will
|
the system will begin to run low on memory and performance will
|
suffer. To avoid problems, the ethernet script maintains a flag that
|
suffer. To avoid problems, the ethernet script maintains a flag that
|
controls whether or not packet logging is active. The default is to
|
controls whether or not packet logging is active. The default is to
|
run with logging disabled, but this can be changed in the target
|
run with logging disabled, but this can be changed in the target
|
definition file:
|
definition file:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
…
|
…
|
logging 1
|
logging 1
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>The ethernet script will add a toolbar button that allows this flag to
|
>The ethernet script will add a toolbar button that allows this flag to
|
be changed at run-time, allowing the user to capture traffic for
|
be changed at run-time, allowing the user to capture traffic for
|
certain periods of time while the application continues running.
|
certain periods of time while the application continues running.
|
</P
|
</P
|
><P
|
><P
|
>The target definition file can contain the following entries for the
|
>The target definition file can contain the following entries for the
|
various packet logging filters:
|
various packet logging filters:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
…
|
…
|
filter ether -hide 0 -background LightBlue -foreground "#000080"
|
filter ether -hide 0 -background LightBlue -foreground "#000080"
|
filter arp -hide 0 -background LightBlue -foreground "#000050"
|
filter arp -hide 0 -background LightBlue -foreground "#000050"
|
filter ipv4 -hide 0 -background LightBlue -foreground "#000040"
|
filter ipv4 -hide 0 -background LightBlue -foreground "#000040"
|
filter ipv6 -hide 1 -background LightBlue -foreground "#000040"
|
filter ipv6 -hide 1 -background LightBlue -foreground "#000040"
|
filter icmpv4 -hide 0 -background LightBlue -foreground "#000070"
|
filter icmpv4 -hide 0 -background LightBlue -foreground "#000070"
|
filter icmpv6 -hide 1 -background LightBlue -foreground "#000070"
|
filter icmpv6 -hide 1 -background LightBlue -foreground "#000070"
|
filter udp -hide 0 -background LightBlue -foreground "#000030"
|
filter udp -hide 0 -background LightBlue -foreground "#000030"
|
filter tcp -hide 0 -background LightBlue -foreground "#000020"
|
filter tcp -hide 0 -background LightBlue -foreground "#000020"
|
filter hexdata -hide 1 -background LightBlue -foreground "#000080"
|
filter hexdata -hide 1 -background LightBlue -foreground "#000080"
|
filter asciidata -hide 1 -background LightBlue -foreground "#000080"
|
filter asciidata -hide 1 -background LightBlue -foreground "#000080"
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>All output will show the eCos network device, for example
|
>All output will show the eCos network device, for example
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>eth0</TT
|
>eth0</TT
|
>, and the direction relative to the eCos
|
>, and the direction relative to the eCos
|
application. Some of the filters will show packet headers, for example
|
application. Some of the filters will show packet headers, for example
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>ether</TT
|
>ether</TT
|
> gives details of the ethernet packet header
|
> gives details of the ethernet packet header
|
and <TT
|
and <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>tcp</TT
|
>tcp</TT
|
> gives information about TCP headers such as
|
> gives information about TCP headers such as
|
whether or not the SYN flag is set. The TCP and UDP filters will also
|
whether or not the SYN flag is set. The TCP and UDP filters will also
|
show source and destination addresses, using numerical addresses and
|
show source and destination addresses, using numerical addresses and
|
if possible host names. However, host names will only be shown if the
|
if possible host names. However, host names will only be shown if the
|
host appears in <TT
|
host appears in <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/etc/hosts</TT
|
>/etc/hosts</TT
|
>: doing full DNS
|
>: doing full DNS
|
lookups while the data is being captured would add significantly to
|
lookups while the data is being captured would add significantly to
|
complexity and overhead. The <TT
|
complexity and overhead. The <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>hexdata</TT
|
>hexdata</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>asciidata</TT
|
>asciidata</TT
|
> filters show the remainder of the packets
|
> filters show the remainder of the packets
|
after the ethernet, IP and TCP or UDP headers have been stripped.
|
after the ethernet, IP and TCP or UDP headers have been stripped.
|
</P
|
</P
|
><P
|
><P
|
>Some of the filters will provide raw dumps of some of the packet data.
|
>Some of the filters will provide raw dumps of some of the packet data.
|
Showing up to 1500 bytes of data for each packet would be expensive,
|
Showing up to 1500 bytes of data for each packet would be expensive,
|
and often the most interesting information is near the start of the
|
and often the most interesting information is near the start of the
|
packet. Therefore it is possible to set a limit on the number of bytes
|
packet. Therefore it is possible to set a limit on the number of bytes
|
that will be shown using the target definition file. The default limit
|
that will be shown using the target definition file. The default limit
|
is 64 bytes.
|
is 64 bytes.
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>synth_device ethernet {
|
>synth_device ethernet {
|
…
|
…
|
max_show 128
|
max_show 128
|
}</PRE
|
}</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-GUI"
|
NAME="DEVS-ETH-ECOSYNTH-GUI"
|
></A
|
></A
|
><H2
|
><H2
|
>User Interface Additions</H2
|
>User Interface Additions</H2
|
><P
|
><P
|
>When running in graphical mode the ethernet script extends the user
|
>When running in graphical mode the ethernet script extends the user
|
interface in two ways: a button is added to the toolbar so that users
|
interface in two ways: a button is added to the toolbar so that users
|
can enable or disable packet logging; and an entry is added to the
|
can enable or disable packet logging; and an entry is added to the
|
<SPAN
|
<SPAN
|
CLASS="GUIMENU"
|
CLASS="GUIMENU"
|
>Help</SPAN
|
>Help</SPAN
|
> menu for the ethernet-specific documentation.
|
> menu for the ethernet-specific documentation.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-ARGS"
|
NAME="DEVS-ETH-ECOSYNTH-ARGS"
|
></A
|
></A
|
><H2
|
><H2
|
>Command Line Arguments</H2
|
>Command Line Arguments</H2
|
><P
|
><P
|
>The synthetic target ethernet support does not use any command line
|
>The synthetic target ethernet support does not use any command line
|
arguments. All configuration is handled through the target definition
|
arguments. All configuration is handled through the target definition
|
file.
|
file.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-HOOKS"
|
NAME="DEVS-ETH-ECOSYNTH-HOOKS"
|
></A
|
></A
|
><H2
|
><H2
|
>Hooks</H2
|
>Hooks</H2
|
><P
|
><P
|
>The ethernet support defines two hooks that can be used by other
|
>The ethernet support defines two hooks that can be used by other
|
scripts, especially user scripts: <TT
|
scripts, especially user scripts: <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>ethernet_tx</TT
|
>ethernet_tx</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>ethernet_rx</TT
|
>ethernet_rx</TT
|
>. The tx hook is called whenever eCos
|
>. The tx hook is called whenever eCos
|
tries to transmit a packet. The rx hook is called whenever an incoming
|
tries to transmit a packet. The rx hook is called whenever an incoming
|
packet is passed to the eCos application. Note that this may be a
|
packet is passed to the eCos application. Note that this may be a
|
little bit after the packet was actually received by the I/O auxiliary
|
little bit after the packet was actually received by the I/O auxiliary
|
since it can buffer some packets. Both hooks are called with two
|
since it can buffer some packets. Both hooks are called with two
|
arguments, the name of the network device and the packet being
|
arguments, the name of the network device and the packet being
|
transferred. Typical usage might look like:
|
transferred. Typical usage might look like:
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
> proc my_tx_hook { arg_list } {
|
> proc my_tx_hook { arg_list } {
|
set dev [lindex $arg_list 0]
|
set dev [lindex $arg_list 0]
|
incr ::my_ethernet_tx_packets($dev)
|
incr ::my_ethernet_tx_packets($dev)
|
incr ::my_ethernet_tx_bytes($dev) [string length [lindex $arg_list 1]]
|
incr ::my_ethernet_tx_bytes($dev) [string length [lindex $arg_list 1]]
|
}
|
}
|
proc my_rx_hook { arg_list } {
|
proc my_rx_hook { arg_list } {
|
set dev [lindex $arg_list 0]
|
set dev [lindex $arg_list 0]
|
incr ::my_ethernet_rx_packets($dev)
|
incr ::my_ethernet_rx_packets($dev)
|
incr ::my_ethernet_rx_bytes($dev) [string length [lindex $arg_list 1]]
|
incr ::my_ethernet_rx_bytes($dev) [string length [lindex $arg_list 1]]
|
}
|
}
|
synth::hook_add "ethernet_tx" my_tx_hook
|
synth::hook_add "ethernet_tx" my_tx_hook
|
synth::hook_add "ethernet_rx" my_rx_hook</PRE
|
synth::hook_add "ethernet_rx" my_rx_hook</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>The global arrays <TT
|
>The global arrays <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>my_ethernet_tx_packets</TT
|
>my_ethernet_tx_packets</TT
|
> etc. will
|
> etc. will
|
now be updated whenever there is ethernet traffic. Other code,
|
now be updated whenever there is ethernet traffic. Other code,
|
probably running at regular intervals by use of the Tcl
|
probably running at regular intervals by use of the Tcl
|
<B
|
<B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>after</B
|
>after</B
|
> procedure, can then use this information to
|
> procedure, can then use this information to
|
update a graphical monitor of some sort.
|
update a graphical monitor of some sort.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="DEVS-ETH-ECOSYNTH-TCL"
|
NAME="DEVS-ETH-ECOSYNTH-TCL"
|
></A
|
></A
|
><H2
|
><H2
|
>Additional Tcl Procedures</H2
|
>Additional Tcl Procedures</H2
|
><P
|
><P
|
>The ethernet support provides one additional Tcl procedure that can be
|
>The ethernet support provides one additional Tcl procedure that can be
|
used by other scripts;
|
used by other scripts;
|
</P
|
</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>ethernet::devices_get_list </PRE
|
>ethernet::devices_get_list </PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>This procedure returns a list of the ethernet devices that have been
|
>This procedure returns a list of the ethernet devices that have been
|
instantiated, for example <TT
|
instantiated, for example <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>{eth0 eth1}</TT
|
>{eth0 eth1}</TT
|
>.
|
>.
|
</P
|
</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="devs-eth-synth-ecosynth-ref.html"
|
HREF="devs-eth-synth-ecosynth-ref.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="devs-watchdog-synth-ref.html"
|
HREF="devs-watchdog-synth-ref.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>Synthetic Target Ethernet Driver</TD
|
>Synthetic Target Ethernet Driver</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="devs-eth-synth-ecosynth-ref.html"
|
HREF="devs-eth-synth-ecosynth-ref.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>Synthetic Target Watchdog Device</TD
|
>Synthetic Target Watchdog Device</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|