public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Nick Barnes <Nick.Barnes@pobox.com>
To: ecos-discuss@sourceware.cygnus.com
Subject: [ECOS] Notes on static configuration of an eCos network interface
Date: Mon, 17 Jul 2000 05:45:00 -0000	[thread overview]
Message-ID: <25482.963837944@raven.ravenbrook.com> (raw)

Notes on static configuration of an eCos network interface

1. Static interface configuration

A simple single-interface static configuration looks like this:

- IP address;
- subnet mask;
- broadcast address;
- default router IP address.

On occasion, there may be more than one router on the subnet, and in
that case there may be multiple routes (destination/mask/router
triplets).

In any case, these correspond to the following information in a BOOTP
message:

IP address:      ciaddr, or yiaddr if ciaddr was 0
subnet mask:     TAG_SUBNET_MASK
broadcast:       TAG_IP_BROADCAST
router address:  TAG_GATEWAY
multiple routes: TAG_IP_STATIC_ROUTES

The siaddr and giaddr fields of a BOOTP message are irrelevant to
configuring a network interface: they are used for talking to the
BOOTP server (e.g. for TFTPing a kernel).

2. Using the eCos config tool

Currently, the config tool defines the following five fields (for
eth0):

CYGHWR_NET_DRIVER_ETH0_ADDRS_IP
CYGHWR_NET_DRIVER_ETH0_ADDRS_NETMASK
CYGHWR_NET_DRIVER_ETH0_ADDRS_BROADCAST
CYGHWR_NET_DRIVER_ETH0_ADDRS_GATEWAY
CYGHWR_NET_DRIVER_ETH0_ADDRS_SERVER

Note that the "SERVER" field is meaningless on a non-bootp system.
Note that there's no way of setting up multiple static routes.

3. Building a BOOTP record

Then build_bootp_record() in network_support.c builds a bootp record
from this information as follows:

ciaddr = yiaddr = IP            ; good
siaddr = SERVER                 ; irrelevant
giaddr = GATEWAY                ; irrelevant
TAG_SUBNET_MASK : NETMASK       ; good
TAG_IP_BROADCAST : BROADCAST    ; good

Note that the GATEWAY field is plugged into giaddr, which tells the
BOOTP client what BOOTP gateway was used to talk to the BOOTP server
(named by SERVER).  This field is irrelevant for a non-bootp system.
So the "GATEWAY" config information is effectively thrown away.

I added code last week to add this to the bootp record:

TAG_GATEWAY : GATEWAY           ; if you add the code I posted last week

4. Initializing the interface

Then init_net() in bootp_support.c uses this bootp record to set up
the interface as follows:

SIOCSIFADDR, yiaddr                               ; good
SIOCSIFNETMASK, TAG_SUBNET_MASK                   ; good
SIOCSIFBRDADDR, TAG_IP_BROADCAST                  ; good
SIOCADDRT, yiaddr & netmask, netmask, TAG_GATEWAY ; bogus

This last line is bogus because the destination field (yiaddr &
netmask) is just the local subnet.  An interface configured like this
can't send packets outside the local subnet.  Suppose that the local
machine is 192.168.42.42/24, and the gateway is 192.168.42.69.  Then
this last gateway line sets up the following route:

route add 192.168.42.0 192.168.42.69 -netmask 255.255.255.0

That is, packets to the local subnet should be routed via the router.

In fact, to specify a default route, you should have a zero mask, and
can have a zero destination as well:

SIOCADDRT, 0, 0, TAG_GATEWAY                     ; better!

5. Recommendations

5.1. Config tool

Assuming the simple situation, with a default router and without
multiple static routes.  Then the config tool should be set up to
allow the specification of:

- IP address;           (as at present)
- subnet mask;          (as at present)
- broadcast address;    (as at present)
- router IP address.    ("gateway" at present)

and _not_ "server", which is a meaningless idea in the absence of
BOOTP.

5.2. building a BOOTP record:

build_bootp_record() shouldn't bother setting siaddr or giaddr, but
should put this information into the BOOTP record:

ciaddr = yiaddr = IP
TAG_SUBNET_MASK : NETMASK
TAG_IP_BROADCAST : BROADCAST
TAG_GATEWAY : GATEWAY

5.3. initializing the interface:

init_net() should initialize the interface as follows:

SIOCSIFADDR, yiaddr
SIOCSIFNETMASK, TAG_SUBNET_MASK
SIOCSIFBRDADDR, TAG_IP_BROADCAST
SIOCADDRT, 0, 0, TAG_GATEWAY

5.4. multiple static routes

The config tool, build_bootp_record() and init_net() should be
extended to allow the specification of multiple static routes, through
TAG_IP_STATIC_ROUTES.

5.5. DNS

A DNS resolver should be added and supported through
TAG_DOMAIN_SERVER.

Nick B

--
FreeBSD 2.2.8-RELEASE: up 15 days, 18:35
last reboot Sat Jul 1 19:26 (lightning strike)

             reply	other threads:[~2000-07-17  5:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-17  5:45 Nick Barnes [this message]
2000-07-17  6:59 ` Bart Veer
2000-07-17  7:07   ` [ECOS] Notes on static configuration of an eCos network inte Gary Thomas
2000-07-18  5:52   ` [ECOS] Notes on static configuration of an eCos network interface Nick Barnes
2000-07-18  8:03     ` Grant Edwards
2000-07-17  8:52 ` Grant Edwards
2000-07-17  9:03   ` [ECOS] Notes on static configuration of an eCos network inte Gary Thomas
2000-07-17  9:28     ` Andrew Lunn
2000-07-17  9:40       ` Grant Edwards
2000-07-17  9:47         ` Andrew Lunn
2000-07-17  9:29     ` Grant Edwards
2000-07-17  9:45       ` Gary Thomas
2000-07-17 10:01         ` Grant Edwards
2000-07-17  9:45   ` [ECOS] Notes on static configuration of an eCos network interface Hugo 'NOx' Tyson
2000-07-20  7:00 ` Hugo 'NOx' Tyson
2000-07-20  9:57   ` Bart Veer
2000-07-20 11:00     ` Hugo 'NOx' Tyson
2000-07-20 11:19       ` Bart Veer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25482.963837944@raven.ravenbrook.com \
    --to=nick.barnes@pobox.com \
    --cc=ecos-discuss@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).