|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FreeBSD TCP/IP Stack port for eCos
|
FreeBSD TCP/IP Stack port for eCos
|
|
|
TCP/IP Networking for eCos
|
TCP/IP Networking for eCos
|
now provides a complete
|
now provides a complete
|
TCP/IP networking stack,
|
TCP/IP networking stack,
|
based on a recent snapshot of the FreeBSD code, released by the
|
based on a recent snapshot of the FreeBSD code, released by the
|
KAME project.
|
KAME project.
|
The networking support is
|
The networking support is
|
fully featured and well tested within the eCos environment.
|
fully featured and well tested within the eCos environment.
|
|
|
|
|
|
|
|
|
Networking Stack Features
|
Networking Stack Features
|
Since this networking package is based on BSD code, it is
|
Since this networking package is based on BSD code, it is
|
very complete and robust. The eCos implementation includes support
|
very complete and robust. The eCos implementation includes support
|
for the following protocols:
|
for the following protocols:
|
|
|
IPv4
|
IPv4
|
UDP
|
UDP
|
TCP
|
TCP
|
ICMP
|
ICMP
|
raw packet interface
|
raw packet interface
|
Multi-cast addressing
|
Multi-cast addressing
|
IPv6 (including UDP, ICP, ICMP)
|
IPv6 (including UDP, ICP, ICMP)
|
|
|
These additional features are also present in the package,
|
These additional features are also present in the package,
|
but are not supported:
|
but are not supported:
|
|
|
Berkeley Packet Filter
|
Berkeley Packet Filter
|
Uni-cast support
|
Uni-cast support
|
Multi-cast routing
|
Multi-cast routing
|
|
|
|
|
|
|
Freebsd TCP/IP stack port
|
Freebsd TCP/IP stack port
|
This document describes how to get started with the Freebsd
|
This document describes how to get started with the Freebsd
|
TCP/IP network stack.
|
TCP/IP network stack.
|
|
|
Targets
|
Targets
|
A number of ethernet devices may be supported. The default configuration
|
A number of ethernet devices may be supported. The default configuration
|
supports two instances of the interface by default,
|
supports two instances of the interface by default,
|
and you will need to write your own driver instantiation code,
|
and you will need to write your own driver instantiation code,
|
and supplemental startup and initialization code,
|
and supplemental startup and initialization code,
|
if you should add additional ones.
|
if you should add additional ones.
|
The target for your board will normally be supplied with an
|
The target for your board will normally be supplied with an
|
ethernet driver, in which case including the network stack and
|
ethernet driver, in which case including the network stack and
|
generic ethernet driver package to your build will automatically
|
generic ethernet driver package to your build will automatically
|
enable usage of the ethernet device driver.
|
enable usage of the ethernet device driver.
|
If your target is not supplied with an ethernet
|
If your target is not supplied with an ethernet
|
driver, you will need to use loopback (see
|
driver, you will need to use loopback (see
|
).
|
).
|
|
|
|
|
Building the Network Stack
|
Building the Network Stack
|
Using the Build->Packages dialog,
|
Using the Build->Packages dialog,
|
add the packages “Networking”,
|
add the packages “Networking”,
|
“Freebsd TCP/IP Stack”
|
“Freebsd TCP/IP Stack”
|
and “Common Ethernet Support”
|
and “Common Ethernet Support”
|
to your configuration. Their package names
|
to your configuration. Their package names
|
are CYGPKG_NET, CYGPKG_NET_FREEBSD_STACK and CYGPKG_NET_ETH_DRIVERS
|
are CYGPKG_NET, CYGPKG_NET_FREEBSD_STACK and CYGPKG_NET_ETH_DRIVERS
|
respectively.
|
respectively.
|
A short-cut way to do this is by
|
A short-cut way to do this is by
|
using the “net” template
|
using the “net” template
|
if it is available for your platform.
|
if it is available for your platform.
|
The platform-specific ethernet device driver for your platform
|
The platform-specific ethernet device driver for your platform
|
will be added as part of the target selection (in the
|
will be added as part of the target selection (in the
|
Build->Templates “Hardware” item),
|
Build->Templates “Hardware” item),
|
along with the
|
along with the
|
PCI I/O subsystem (if relevent) and the appropriate serial device driver.
|
PCI I/O subsystem (if relevent) and the appropriate serial device driver.
|
|
|
For example, the PowerPC MBX target selection adds the package
|
For example, the PowerPC MBX target selection adds the package
|
PKG_NET_QUICC_ETH_DRIVERS,
|
PKG_NET_QUICC_ETH_DRIVERS,
|
and the Cirrus Logic EDB7xxx target selection adds the package
|
and the Cirrus Logic EDB7xxx target selection adds the package
|
CYGPKG_NET_EDB7XXX_ETH_DRIVERS.
|
CYGPKG_NET_EDB7XXX_ETH_DRIVERS.
|
After this, eCos and its tests can be built exactly as usual.
|
After this, eCos and its tests can be built exactly as usual.
|
|
|
By default, most of the network tests are not built. This
|
By default, most of the network tests are not built. This
|
is because some of them require manual intervention, i.e. they are
|
is because some of them require manual intervention, i.e. they are
|
to be run “by hand”, and are not suitable for
|
to be run “by hand”, and are not suitable for
|
automated testing. To build the full set of network tests, set
|
automated testing. To build the full set of network tests, set
|
the configuration option CYGPKG_NET_BUILD_TESTS “Build
|
the configuration option CYGPKG_NET_BUILD_TESTS “Build
|
networking tests (demo programs)” within “Networking
|
networking tests (demo programs)” within “Networking
|
support build options”.
|
support build options”.
|
|
|
|
|
|
|
|
|
APIs
|
APIs
|
|
|
Standard networking
|
Standard networking
|
The APIs for the standard networking calls such as
|
The APIs for the standard networking calls such as
|
socket(), recv() and so on, are
|
socket(), recv() and so on, are
|
in header files relative to the top-level
|
in header files relative to the top-level
|
include directory, within the standard subdirectories as conventionally
|
include directory, within the standard subdirectories as conventionally
|
found in /usr/include. For example:
|
found in /usr/include. For example:
|
|
|
install/include/arpa/tftp.h
|
install/include/arpa/tftp.h
|
install/include/netinet/tcpip.h
|
install/include/netinet/tcpip.h
|
install/include/sys/socket.h
|
install/include/sys/socket.h
|
install/include/sys/socketvar.h
|
install/include/sys/socketvar.h
|
install/include/sys/sockio.h
|
install/include/sys/sockio.h
|
|
|
|
|
|
|
|
|
Enhanced Select()
|
Enhanced Select()
|
The network stack supports an extension to the standard select
|
The network stack supports an extension to the standard select
|
semantics which allows all threads that are waiting to be restarted
|
semantics which allows all threads that are waiting to be restarted
|
even if the select conditions are not satisfied.
|
even if the select conditions are not satisfied.
|
The standard select() API:
|
The standard select() API:
|
int
|
int
|
select(int nfd,
|
select(int nfd,
|
fd_set *in, fd_set *out, fd_set *ex,
|
fd_set *in, fd_set *out, fd_set *ex,
|
struct timeval *tv);
|
struct timeval *tv);
|
does not support the restart.
|
does not support the restart.
|
The additional API:
|
The additional API:
|
int
|
int
|
cyg_select_with_abort(int nfd,
|
cyg_select_with_abort(int nfd,
|
fd_set *in, fd_set *out, fd_set *ex,
|
fd_set *in, fd_set *out, fd_set *ex,
|
struct timeval *tv)
|
struct timeval *tv)
|
|
|
behaves exactly as select() with the additional feature that
|
behaves exactly as select() with the additional feature that
|
a call to
|
a call to
|
|
|
void cyg_select_abort(void)
|
void cyg_select_abort(void)
|
|
|
will cause all threads waiting in any
|
will cause all threads waiting in any
|
cyg_select_with_abort() call
|
cyg_select_with_abort() call
|
to cease waiting and continue execution.
|
to cease waiting and continue execution.
|
|
|
|
|
|
|
|
|
|
|