History log of /freebsd-10-stable/lib/libstand/bootp.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 301056 31-May-2016 ian

MFC r297147, r297148, r297149, r297150, r297151:

Make both the loader and kernel use the interface-mtu option if the
dhcp server provides it. Made up of these (semi-)related changes...

[kernel...] If the dhcp server provides an interface-mtu option, parse
the value and set that mtu on the interface.

[libstand...]

Garbage collect the bswap routines from libstand, use sys/endian.h.

If the dhcp server delivers an interface-mtu option, parse it and store
the value in a new global intf_mtu for use by the application.

[loader...]

If the dhcp server provided an interface-mtu option, transcribe the value
to the boot.netif.mtu env var, which will be picked up by pre-existing code
in nfs_mountroot() and used to configure the interface accordingly.

PR: 187094


# 294343 19-Jan-2016 ian

MFC r292583:

Allow dhcp/bootp server-provided values to be overriden from environment
variables in loader(8) and other libstand applications.

Sometimes a dhcp server provides incorrect information along with the IP
address. It would be useful to have a way to override this with
locally-supplied information, such as command line parameters passed from a
prior-stage bootloader. This change allows pre-existing env vars to take
precedence over values delivered by the dhcp or bootp server.

The bootp/dhcp code in libstand automatically creates environment variables
from the data provided by the server (dhcp.root-path, dhcp.domain-name,
etc). It also transcribes the values to some global variables such as
'rootpath' and 'hostname'.

This change does two things:

When adding dhcp.* vars to the environment, don't replace existing
vars/values.

When setting the global vars rootpath and hostname, use the
dhcp.root-path and dhcp.host-name env var values if they exist.

This allows the platform-specific part of loader(8) to obtain override
values in some platform-specific way and store them in the environment
before opening the network device. The set of values that can be overriden
is currently limited to just string options. The values that are delivered
as binary data are things that probably shouldn't be overridden (IP,
netmask, gateway, etc).

The original patch this evolved from was submitted by martymac@

PR: 202098
Relnotes: Yes


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 229403 03-Jan-2012 ed

Replace index() and rindex() calls with strchr() and strrchr().

The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.


# 193189 31-May-2009 ed

Fix minor issues in libstand.

- Don't call tftp_makereq() with too many arguments.
- Don't forget to close one of the comments.

Submitted by: Pawel Worach


# 186799 05-Jan-2009 luigi

put a prefix on dhcp options to avoid clobbering, even by mistake,
existing environment variables.

MFC after: 2 weeks


# 185643 05-Dec-2008 luigi

Some libstand/bootp.c extension (written by Danny Braniss, slightly
revised/modified by me) to store dhcp options into kenv variables,
so the information is available to the boot loader and can be used
to customize the boot process.

The change is totally unintrusive, essentially made of a single
function to be called while parsing a dhcp response, and a couple
of tables to classify options. The values extracted from dhcp
options are stored in the kenv environment in one of these forms:

+ options whose name and type is known are saved as
dhcp.name = value (string, or number/ip addresses lists)

+ unknown options are assumed to be strings and saved as
dhcp.option-NNN = "value"

+ options listed as '__INDIR' and sent on the wire as e.g.
option unknown-252 "some.name=the actual value"
are saved as
some.name = "the actual value"

+ options listed as '__ILIST' and sent on the wire as e.g.
option unknown-249 "a.b=foo bar; c.d= 123; e.f=done"
are saved as multiple values
a.b="foo bar"
c.d="123"
e.f="done"

As you can see there is quite a bit of flexibility on what can
be passed to the loader or the kernel.

For the time being the vendor-specific table is mostly disabled,
because there is no standard set of options for FreeBSD, and I don't
know all the pxe-specific vendor options.

Also, applications using libstand may live in memory-constrained
environments, so it makes sense to keep these tables as small as
possible, especially considering that one can generate arbitrary
name=value pairs using site-specific options of type __INDIR or
__ILIST (there are 4 __ILIST and 5 __INDIR in the table, numbered
246..249 and 250..254).

Actually, considering that probably 75% of the standard dhcp options
are totally useless, it might make sense to remove them as well.

Submitted by: Danny Braniss
MFC after: 4 weeks


# 165906 08-Jan-2007 imp

Remove California Regent's clause 3, per letter


# 92913 21-Mar-2002 obrien

Remove 'register' keyword.


# 84221 30-Sep-2001 dillon

Add __FBSDID()s to libstand


# 66134 20-Sep-2000 ps

IN_CLASS*() macros assume host order and s_addr is network byte
order, so we must convert them to host order.


# 64527 11-Aug-2000 ps

Add support to send the string 'PXEClient' as the Vendor class
identifier to the DHCP server. Now you can check for this string
in your dhcp configuration to decide whether you will hand out a
lease to the client or not.


# 38452 20-Aug-1998 msmith

This commit was generated by cvs2svn to compensate for changes in r38451,
which included commits to RCS files with non-trunk default branches.


# 38451 20-Aug-1998 msmith

This is libstand; a support library for standalone executables (eg. bootstrap
modules).
Obtained from: NetBSD, with some architectural changes and many additions.