Chapter 141. Configuring IP Addresses
Each interface (“eth0” and “eth1”) has independent configuration of its setup. Each can be set up manually (in which case you must write code to do this), or by using BOOTP/DHCP, or explicitly, with configured values. If additional interfaces are added, these must be configured manually.
The configurable values are:
- IP address
- broadcast address
- server address.
Server address is the DHCP server if applicable, but in addition, many test cases use it as “the machine to talk to” in whatever manner the test exercises the protocol stack.
The initialization is invoked by calling the C routine:
Additionally, if the system is configured to support IPv6 then each interface may have an address assigned which is a composite of a 64 bit prefix and the 32 bit IPv4 address for that interface. The prefix is controlled by the CDL setting CYGHWR_NET_DRIVER_ETH0_IPV6_PREFIX for “eth0”, etc. This is a CDL booldata type, allowing this address to be suppressed if not desired.
Alternatively, the system can configure its IPv6 address using
router solicitation. When the CDL option
CYGOPT_NET_IPV6_ROUTING_THREAD is enabled,
init_all_network_interface will start a thread which sends out router solicit messages, process router advertisements and thus configure an IPv6 address to the interface.
Refer to the test cases,
for example usage, and the source files in
to see what that call does.
This assumes that the MAC address (also known as ESA or Ethernet Station Address) is already defined in the serial EEPROM or however the particular target implements this; support for setting the MAC address is hardware dependent.
DHCP support is active by default, and there are configuration options to control it. Firstly, in the top level of the “Networking” configuration tree, “Use full DHCP instead of BOOTP” enables DHCP, and it contains an option to have the system provide a thread to renew DHCP leases and manage lease expiry. Secondly, the individual interfaces “eth0” and “eth1” each have new options within the “Use BOOTP/DHCP to initialize ‘ethX’” to select whether to use DHCP rather than BOOTP.
You should not configure the network stack to use BOOTP/DHCP if you are using RedBoot, have configured it also to use BOOTP/DHCP, and are connected via GDB to it over the network. Otherwise the TCP/IP stacks in both RedBoot and the eCos application are likely to be given the same IP address, which will cause problems.
Note that you are completely at liberty to ignore this startup code and its
configuration in building your application.
is provided for three main purposes:
- For use by eCos's own test programs.
- As an easy “get you going” utility for newcomers to eCos.
- As readable example code from which further development might start.
If your application has different requirements for bringing up
available network interfaces, setting up routes, determining IP addresses
and the like from the defaults that the example code provides, you can
write your own initialization code to use whatever sequence of
calls carries out the desired setup. Analogously, in larger systems,
a sequence of “ifconfig” invocations is used; these mostly
ioctl() calls to manipulate the state of
the interface in question.
|2019-09-17||Open Publication License|