david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

46 Commits

Author SHA1 Message Date
Michael Brown 1266d7902b [tables] Redefine methods for accessing linker tables
Intel's C compiler (icc) chokes on the zero-length arrays that we
currently use as part of the mechanism for accessing linker table
entries.  Abstract away the zero-length arrays, to make a port to icc
easier.

Introduce macros such as for_each_table_entry() to simplify the common
case of iterating over all entries in a linker table.

Represent table names as #defined string constants rather than
unquoted literals; this avoids visual confusion between table names
and C variable or type names, and also allows us to force a
compilation error in the event of incorrect table names.
2009-03-13 02:06:30 +00:00
Michael Brown ec24672db7 [settings] Allow for autovivification of settings blocks
Allow for settings blocks to be created on demand.  This allows for
constructions such as

  set defaults/filename http://bootserver/bootfile
  set defaults/priority 0xff
  dhcp net0
  chain ${filename}

which will boot from the DHCP-provided filename, or from
"http://bootserver/bootfile" if the DHCP server does not provide a
filename.

(Note that "priority" gets interpreted as a signed integer, so setting
"defaults/priority" to 0xff will cause the "defaults" settings block
to have an effective priority of -1.)
2009-03-06 14:40:44 +00:00
Michael Brown bea828b9ed [settings] Allow store_setting() to access the root settings block 2009-02-17 11:57:31 +00:00
Michael Brown 4e6b62c946 [settings] Handle errors in fetchf_uristring()
fetchf_uristring() was failing to handle error values from
fetch_setting(), resulting in its attempting to allocate extremely
large temporary buffers on the stack (and so overrunning the stack and
locking up the machine).

Problem reported by Shao Miller <Shao.Miller@yrdsb.edu.on.ca>.
2009-02-12 09:16:53 +00:00
Michael Brown d2b0081740 [settings] Avoid duplicate settings block names
Automatically unregister any settings with the same name (and position
within the settings tree) as a newly registered settings block.

This functionality is generalised out from dhcp.c.
2009-01-31 07:32:20 +00:00
Michael Brown a128973ecb [settings] Add fetch_string_setting_copy() 2009-01-27 19:13:47 +00:00
Michael Brown ed196a3ed2 [settings] Ensure fetch_string_setting() returns a NUL-terminated string
This fixes a regression introduced in commit 612f4e7:

  [settings] Avoid returning uninitialised data on error in fetch_xxx_setting()

in which the memset() was moved from fetch_string_setting() to
fetch_setting(), in order that it would be useful for non-string
setting types.  However, this neglects to take into account the fact
that fetch_string_setting() shrinks its buffer by one byte (to allow
for the NUL) before calling fetch_setting().

Restore the memset() in fetch_string_setting(), so that the
terminating NUL is guaranteed to actually be a NUL.
2008-11-07 03:48:29 +00:00
Michael Brown 0a6c66a830 [settings] Add the notion of a "tag magic" to numbered settings
Settings can be constructed using a dotted-decimal notation, to allow
for access to unnamed settings.  The default interpretation is as a
DHCP option number (with encapsulated options represented as
"<encapsulating option>.<encapsulated option>".

In several contexts (e.g. SMBIOS, Phantom CLP), it is useful to
interpret the dotted-decimal notation as referring to non-DHCP
options.  In this case, it becomes necessary for these contexts to
ignore standard DHCP options, otherwise we end up trying to, for
example, retrieve the boot filename from SMBIOS.

Allow settings blocks to specify a "tag magic".  When dotted-decimal
notation is used to construct a setting, the tag magic value of the
originating settings block will be ORed in to the tag number.
Store/fetch methods can then check for the magic number before
interpreting arbitrarily-numbered settings.
2008-10-30 21:47:14 +00:00
Michael Brown 612f4e7a99 [settings] Avoid returning uninitialised data on error in fetch_xxx_setting()
Callers (e.g. usr/autoboot.c) may not check the return values from
fetch_xxx_setting(), assuming that in error cases the returned setting
value will be "empty" (for some sensible value of "empty").

In particular, if the DHCP server did not specify a next-server
address, this would result in gPXE using uninitialised data for the
TFTP server IP address.
2008-10-22 22:07:13 +01:00
Michael Brown 6936c40fef [settings] Allow for setting fetchers to fail in fetchf_hex() 2008-09-26 03:39:35 +01:00
Michael Brown 35b7658877 [settings] Add the uristring setting type
This allows settings to be expanded in a way that is safe to include
within a URI string, such as

  kernel http://10.0.0.1/boot.php?mf=${manufacturer:uristring}

where the ${manufacturer} setting may contain characters that are not
permitted (or have reserved purposes) within a URI.

Since whitespace characters will be URI-encoded (e.g. "%20" for a
space character), this also works around the problem that spaces
within an expanded setting would cause the shell to split command-line
arguments incorrectly.
2008-09-24 07:22:42 +01:00
Michael Brown 8f8f5acf09 [settings] Avoid overwriting the start of .text in fetch_string_setting()
fetch_string_setting() was subtracting one from the length of the
to-be-NUL-terminated buffer in order to obtain the length of the
unterminated buffer to be passed to fetch_setting().  This works
extremely well unless the length of the to-be-NUL-terminated buffer is
zero, at which point we end up giving fetch_setting() a buffer of
length -1UL, thereby inviting it to overwrite as much memory as it
wants...
2008-08-14 03:03:53 +01:00
Michael Brown feade5da6e [Settings] Expose SMBIOS via settings API
In particular, expose the system UUID as a setting ("smbios/uuid").
2008-03-28 15:35:06 +00:00
Michael Brown af466aedf1 [Settings] find_child_settings() accepts a NULL parent 2008-03-27 06:07:19 +00:00
Michael Brown 92d15eff30 [Settings] Remove assumption that all settings have DHCP tag values
Allow for settings to be described by something other than a DHCP option
tag if desirable.  Currently used only for the MAC address setting.

Separate out fake DHCP packet creation code from dhcp.c to fakedhcp.c.

Remove notion of settings from dhcppkt.c.

Rationalise dhcp.c to use settings API only for final registration of the
DHCP options, rather than using {store,fetch}_setting throughout.
2008-03-25 20:46:16 +00:00
Michael Brown 8f00c84828 [Settings] Add named setting for next-server
It's probably easier to have a named setting for next-server, rather
than to explain to people why they need to pretend it is option 175.3.
2008-03-24 00:48:06 +00:00
Michael Brown 23e077666b [Settings] copy_settings() should not fail if some settings are missing! 2008-03-23 23:28:21 +00:00
Michael Brown 65c0974d1f [Settings] Bugfix: store_setting() now applies changes even on root block 2008-03-22 00:40:33 +00:00
Michael Brown e5cea13e51 [Settings] Implement simple_settings backed with extensible DHCP options 2008-03-22 00:31:08 +00:00
Michael Brown a462c96ffc [Settings] DHCP is now working using the new settings API. 2008-03-21 22:55:59 +00:00
Michael Brown 8afb36c3bc [Settings] Migrate DHCP and NVO code to the new settings API (untested) 2008-03-21 22:15:31 +00:00
Michael Brown eae6ac3d0b [Settings] Convert code in src/usr to use settings API. 2008-03-20 23:42:11 +00:00
Michael Brown cf03304620 [Settings] Introduce settings applicators.
Convert DHCP option applicators in dns.c and iscsi.c to settings
applicators.

Kill off DHCP option applicators.
2008-03-20 23:15:48 +00:00
Michael Brown 260b93bb72 [Settings] Add settings hierarchy
Add the notion of the settings hierarchy, complete with
register/unregister routines.

Rename set->store and get->fetch to avoid naming conflicts with get/put
as used in reference counting.
2008-03-20 21:01:32 +00:00
Michael Brown a48b4d9948 [Settings] Start revamping the configuration settings API.
Add the concept of an abstract configuration setting, comprising a (DHCP)
tag value and an associated byte sequence.

Add the concept of a settings namespace.

Add functions for extracting string, IPv4 address, and signed and
unsigned integer values from configuration settings (analogous to
dhcp_snprintf(), dhcp_ipv4_option(), etc.).

Update functions for parsing and formatting named/typed options to work
with new settings API.

Update NVO commands and config UI to use new settings API.
2008-03-20 04:06:07 +00:00
Michael Brown af1c6b869c [Settings] Allow named settings to have their type specified explicitly
Allow setting names such as "ip:hex".
2008-03-18 15:51:03 +00:00
Michael Brown 03398e3389 [Settings] Allow encapsulated options to be specified as named settings
Allow encapsulated options to be specified as e.g. "175.3".  As a
side-effect, change the separator character for the type field from "." to
":"; for example, the IP address pseudo-option is now "175.3:ipv4".
2008-03-18 04:13:11 +00:00
Michael Brown e2613e8896 [Settings] Add int16, int32 and hex-string configuration setting types
Add parse and display routines for 16-bit and 32-bit integer configuration
settings.

Add parse and display routines for hex-string configuration settings.

Assume hex-string as a configuration setting type if no type is explicitly
specified.
2008-03-18 03:23:36 +00:00
Michael Brown 5a08b434c7 [Settings] show_setting() functions return snprintf()-style length.
show_setting() and related functions now return an "actual length" in the
style of snprintf().  This is to allow consumers to allocate buffers large
enough to hold the formatted setting.
2008-03-18 00:48:23 +00:00
Michael Brown 73b09ecba6 Use stdio.h instead of vsprintf.h 2007-01-19 01:13:12 +00:00
Michael Brown 77bb7b13a7 Having forced __table() to natural structure alignment, it now seems
that we *can* place arrays in tables, which means we can force the
order within a table without having to resort to explicitly numbered
sections on everything.
2007-01-10 05:08:05 +00:00
Michael Brown dad5274522 Add "name" field to struct device to allow human-readable hardware device
names.

Add "dev" pointer in struct net_device to tie network interfaces back to a
hardware device.

Force natural alignment of data types in __table() macros.  This seems to
prevent gcc from taking the unilateral decision to occasionally increase
their alignment (which screws up the table packing).
2007-01-10 04:22:09 +00:00
Michael Brown fbc7b4dfa8 Add iSCSI initiator IQN as a setting 2006-12-21 16:08:37 +00:00
Michael Brown 2b97d2ebc5 8-bit integers are 1 byte long, not 8... 2006-12-20 05:04:17 +00:00
Michael Brown b93ff48173 Added descriptive text for settings and setting types, and display it in
the option config UI.
2006-12-20 04:58:26 +00:00
Michael Brown 35edecac34 Move {show,set,clear}_setting() to {show,set,clear}_named_setting().
Introduce new {show,set,clear}_setting() that take a struct setting *
rather than a const char *.

set_setting() handles calling clear_setting() when appropriate, so that
individual setting types don't have to check for empty strings.
2006-12-20 04:20:13 +00:00
Michael Brown 4f506328ad Use -ENOSPC rather than -ENOMEM, to distinguish the cases "generic out of
memory" and "no space left for DHCP options"
2006-12-20 03:33:37 +00:00
Michael Brown 007ca97f25 Added clear_setting() 2006-12-12 15:49:46 +00:00
Michael Brown 69b9048e1a Added "priority" and "root-path" options 2006-12-08 16:30:14 +00:00
Michael Brown 2863d1a1de inet_aton() has a non-traditional return value 2006-12-06 20:44:29 +00:00
Michael Brown d041d74054 Tied NVO commands into the human-interactable settings code that I
completely forgot I'd written ages ago.
2006-12-05 02:40:03 +00:00
Michael Brown 3c35a0b16d Added cmdl_show proof-of-concept 2006-08-11 18:40:27 +00:00
Michael Brown dd9399f527 Added "hostname" and "ip" as sample settings 2006-08-11 18:29:20 +00:00
Michael Brown fe774fe356 Added ipv4 configuration type 2006-08-11 18:22:41 +00:00
Michael Brown 7029fb8eff Add string configuration type 2006-08-11 18:16:57 +00:00
Michael Brown db46972349 Added basic infrastructure for manipulating settings. 2006-08-11 18:00:22 +00:00