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

92 Commits

Author SHA1 Message Date
Michael Brown 78178608e9 [settings] Remove temporary name buffer parameter from parse_setting_name()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-18 15:58:05 +01:00
Michael Brown 3880ebeb18 [settings] Avoid potentially large stack allocations
Avoid potentially large stack allocations in fetchf_setting() and
storef_setting().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-18 15:50:02 +01:00
Michael Brown 063645118c [settings] Clarify usage of the term "named setting"
There are currently two conflicting usages of the term "named setting"
within iPXE: one refers to predefined settings (such as show up in the
"config" UI), the other refers to settings identified by a name (such
as "net0.dhcp/ip").

Split these usages into the term "predefined setting" and "named
setting" to avoid ambiguity.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-18 15:50:02 +01:00
Robin Smidsrød 7016164056 [settings] Add "version" builtin setting
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-13 22:15:51 +02:00
Michael Brown 66ea458125 [settings] Make "netX" settings block function as a symbolic link
Add a facility for settings blocks to act as symbolic links to other
settings blocks, and reimplement the "netX" virtual settings block
using this facility.

The primary advantage of this approach is that unscoped settings such
as ${mac} and ${filename} will now reflect the settings obtained from
the most recently opened network device: in most cases, this will mean
the settings obtained from the most recent DHCP attempt.  This should
improve conformance to the principle of least astonishment.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-13 15:11:45 +02:00
Michael Brown 3dbcce51ea [settings] Add "busdevfn" setting type
Allow network device's "busloc" setting to be formatted as a PCI
bus:dev.fn address using e.g. ${net0/busloc:busdevfn}.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-12 22:38:19 +02:00
Michael Brown 9f3bbaca07 [settings] Add "hexraw" setting type
Originally-implemented-by: Jeppe Toustrup <ipxe@tenzer.dk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-12 15:14:36 +02:00
Michael Brown 7774ceed2f [settings] Use hex_decode() to parse hex settings
Use hex_decode() to parse "hex" and "hexhyp" settings.  Note that this
parser is stricter than the old parser; it now requires exactly two
hex digits for each byte.  (The old parser was based upon strtoul()
and so would allow leading whitespace and a leading plus or minus
sign.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-12 15:14:36 +02:00
Michael Brown 15d2f947f5 [settings] Eliminate settings "tag magic"
Create an explicit concept of "settings scope" and eliminate the magic
values used for numerical setting tags.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-01 19:52:12 +01:00
Michael Brown 0e2ba15a58 [settings] Expose build architecture and platform via settings
Expose the build architecture (e.g. "i386" or "x86_64") via
${buildarch} and the firmware platform (e.g. "pcbios" or "efi") via
${platform}.  These settings directly expose the ARCH and PLATFORM
variables from the Makefile.

Note that the build architecture reflects the architecture for which
iPXE was compiled, not the architecture on which iPXE is currently
running.  The "cpuid" command can be used to detect a 64-bit system at
runtime.

Requested-by: James A. Peltier <jpeltier@sfu.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-06 11:33:34 +01:00
Michael Brown c86790df5c [settings] Add fetchf_named_setting_copy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-24 20:42:42 -07:00
Michael Brown 5ad445fd0b [settings] Treat an empty formatted value as meaning "delete setting"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-15 18:32:16 +01:00
Michael Brown 1c2b6d29ea [settings] Expose find_child_settings()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-15 18:32:16 +01:00
Michael Brown 25ec56e0ec [settings] Use a generic setting's own type as its default type
When fetching a named setting using a name that does not explicitly
specify a type, default to using the type stored when the setting was
created, rather than always defaulting to "string".  This allows the
behaviour of user-defined settings to match the behaviour of
predefined settings (which have a sensible default type).

For example:

  set server:ipv4 192.168.0.1
  echo ${server}

will now print "192.168.0.1", rather than trying to print out the raw
IPv4 address bytes as a string.

The downside of this change is that existing tricks for printing
special characters within scripts may require (backwards-compatible)
modification.  For example, the "clear screen" sequence:

  set esc:hex 1b
  set cls ${esc}[2J
  echo ${cls}

will now have to become

  set esc:hex 1b
  set cls ${esc:string}[2J  # Must now explicitly specify ":string"
  echo ${cls}

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-09-10 14:25:04 +01:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown c5c257788f [settings] Expose exit status of failed command via ${errno}
Allow scripts to report errors in more detail by exposing the most
recent error via the ${errno} setting.  For example:

    chain ${filename} || goto failed
    ...
    :failed
    imgfree http://192.168.0.1/ipxe_error.php?error=${errno}

Note that ${errno} is valid only immediately after executing a failed
command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-12 15:46:24 +01:00
Michael Brown 7ea6764031 [settings] Move "domain" setting from dns.c to settings.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-20 14:39:03 +01:00
Michael Brown 31e60de676 [settings] Add fetch_setting_copy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-19 16:10:07 +01:00
Michael Brown 52e5ddce68 [tftp] Allow builds without TFTP support
Allow TFTP to be configured out by moving the next-server setting
definition (which is used by autoboot.c) from tftp.c to settings.c.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-17 11:50:11 +01:00
Michael Brown 831b16adde [settings] Split fetching and storing out of setting type handlers
Refactor setting type handlers to parse and format values, rather than
storing and fetching formatted values.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-17 10:46:50 +01:00
Michael Brown 02a6f46c09 [settings] Match terminology in online documentation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 21:21:12 +00:00
Michael Brown 071b4000d9 [settings] Avoid memory leak when unregistering autovivified settings blocks
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 20:17:24 +00:00
Michael Brown 8482451812 [settings] Impose a fixed order on settings
Improve the appearance of the "config" user interface by ensuring that
settings appear in some kind of logical order.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 11:57:29 +00:00
Michael Brown b36882be34 [settings] Fix setting expansion
Commit 5fbd020 ("[settings] Display canonical setting name in output
of "show" command") introduced a regression causing all setting
expansions (e.g. "${net0/mac}") to expand to an empty string.

Fix by returning the formatted value length from
fetchf_named_setting(), as expected by the caller.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 10:08:16 +00:00
Michael Brown 247ac80556 [settings] Display canonical setting name in "config" user interface
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 21:26:05 +00:00
Michael Brown 5fbd0207b2 [settings] Display canonical setting name in output of "show" command
Enable the "show" command to display the full, canonicalised name of
the fetched setting.  For example:

  iPXE> show mac
  net0/mac:hex = 52:54:00:12:34:56

  iPXE> dhcp && show ip
  DHCP (net0 52:54:00:12:34:56)... ok
  net0.dhcp/ip:ipv4 = 10.0.0.168

  iPXE> show net0/6
  net0.dhcp/dns:ipv4 = 10.0.0.6

Inspired-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 20:13:50 +00:00
Michael Brown ba8dd80487 [settings] Provide fetch_setting_origin()
Inspired-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 19:55:06 +00:00
Glenn Brown f732fa28c8 [settings] Expose settings_name()
Expose settings_name(), shrink the unnecessarily large static buffer,
properly name root settings block, and simplify.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 19:55:05 +00:00
Michael Brown f5fd4dec3b [settings] Formalise notion of setting applicability
Expose a function setting_applies() to allow a caller to determine
whether or not a particular setting is applicable to a particular
settings block.

Restrict DHCP-backed settings blocks to accepting only DHCP-based
settings.

Restrict network device settings blocks to accepting only DHCP-based
settings and network device-specific settings such as "mac".

Inspired-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 19:54:58 +00:00
Michael Brown 48a4001152 [settings] Make fetch_string_setting_copy() easier to use
Most callers of functions in the fetch_setting() family treat any
errors as meaning "non-existent setting".  In the case of
fetch_string_setting_copy(), an existent setting can still result in
an error due to memory allocation failure.

Allow the caller to distinguish between a non-existent setting and an
error in allocating memory for the copy, by returning success (and a
NULL buffer pointer) for a non-existent setting.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-03 20:03:08 +00:00
Michael Brown 09695f7be9 [settings] Avoid fetch_string_setting_copy() leaving an uninitialised pointer
For consistency with other functions in the fetch_setting() family,
ensure that fetch_string_setting_copy() always initialises the pointer
to the fetched setting even if fetching fails.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-03 17:13:44 +00:00
Michael Brown 990cbb8f2c [settings] Generalise expand_command() to expand_settings()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-28 00:16:18 +00:00
Michael Brown cb838cc419 [settings] Add fetch_ipv4_array_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-09 15:34:12 +00:00
Michael Brown 67b45186a5 [settings] Apply settings block name in register_settings()
Pass the settings block name as a parameter to register_settings(),
rather than defining it with settings_init() (and then possibly
changing it by directly manipulating settings->name).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-01 16:35:00 +00:00
Michael Brown 312ae024d8 [settings] Add "hexhyp" setting type
Provide a "hexhyp" setting type, which functions identically to the
"hex" setting type except that it uses a hyphen instead of a colon as
the byte delimiter.

For example, if ${mac} expands to "52:54:00:12:34:56", then
${mac:hexhyp} will expand to "52-54-00-12-34-56".

Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-13 00:28:26 +00:00
Piotr Jaroszyński 380d7c8d45 [settings] Export find_setting()
Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-17 14:39:10 +01:00
Piotr Jaroszyński 519a4be189 [settings] Unregister the children when unregistering the parent
The DHCP settings registered as a child of the netdevice settings are
not unregistered anywhere.  This prevents the netdevice from being
freed on shutdown.

Fix by automatically unregistering any child settings when the parent
settings are unregistered.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-07-15 20:31:53 +01:00
Michael Brown 8406115834 [build] Rename gPXE to iPXE
Access to the gpxe.org and etherboot.org domains and associated
resources has been revoked by the registrant of the domain.  Work
around this problem by renaming project from gPXE to iPXE, and
updating URLs to match.

Also update README, LOG and COPYRIGHTS to remove obsolete information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19 23:43:39 +01:00
Stefan Hajnoczi 1548189ffa [proto] Remove unsupported NFS protocol
The NFS protocol code came from legacy Etherboot and was never updated
to work as a gPXE protocol.  There has been no demand for this protocol,
so this patch removes it.

I have an unfinished NFSv3 over TCP implementation for gPXE that can be
used as the base for new work, should we want to resurrect this
protocol.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-31 19:21:00 -05:00
Joshua Oreman 3d9dd93a14 [uri] Decode/encode URIs when parsing/unparsing
Currently, handling of URI escapes is ad-hoc; escaped strings are
stored as-is in the URI structure, and it is up to the individual
protocol to unescape as necessary. This is error-prone and expensive
in terms of code size. Modify this behavior by unescaping in
parse_uri() and escaping in unparse_uri() those fields that typically
handle URI escapes (hostname, user, password, path, query, fragment),
and allowing unparse_uri() to accept a subset of fields to print so
it can be easily used to generate e.g. the escaped HTTP path?query
request.

Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-20 18:14:28 -05:00
Joshua Oreman ef9d1a32c6 [settings] Add automagic "netX" settings block for last opened netdev
A script loaded via autoboot may want to get some of the settings (MAC
address, IP address, et cetera) for the interface via which it was
loaded, in order to pass them to the operating system. Previously such
a script had no way to determine what to put in the X of ${netX/foo}.

Solve this problem by transparently forwarding accesses to the real
settings associated with the most recently opened network device,
so scripts in this situation can say literally ${netX/foo} and get
the foo setting they want.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-20 17:52:02 -05:00
Shao Miller 68973f1c49 [settings] Fix setting_cmp() to handle nameless settings
setting_cmp() compares by option tag and then by name.  Empty names
will always match, which gives us a false positive.

Fix by explicitly checking for empty names.

Modified-by: Michael Brown <mcb30@etherboot.org>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-06-13 12:04:08 +01:00
Michael Brown 3c06277bbb [settings] Allow for arbitrarily-named settings
This provides a mechanism for using arbitrarily-named variables within
gPXE, using the existing syntax for settings.
2009-05-26 11:05:58 +01:00
Michael Brown c5a88ed553 [settings] Fix erroneous bit-masking in fetch_uintz_setting() 2009-05-20 08:55:48 +01:00
Michael Brown c44a193d0d [legal] Add a selection of FILE_LICENCE declarations
Add FILE_LICENCE declarations to almost all files that make up the
various standard builds of gPXE.
2009-05-18 08:33:25 +01:00
Michael Brown 5bd32315d0 [settings] Fix broken assertion in fetch_string_setting_copy()
Reported-by: Stefan Hajnoczi <stefanha@gmail.com>
2009-03-26 09:50:52 +00:00
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