summaryrefslogtreecommitdiffstats
path: root/src/core/settings.c
Commit message (Collapse)AuthorAgeFilesLines
* [settings] Extend numerical setting tags to 64 bitsMichael Brown2017-05-221-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow use of a non-default EFI SAN boot filenameMichael Brown2017-04-121-0/+9
| | | | | | | | | | | | | | | | | | | | | | | Some older operating systems (e.g. RHEL6) use a non-default filename on the root disk and rely on setting an EFI variable to point to the bootloader. This does not work when performing a SAN boot on a machine where the EFI variable is not present. Fix by allowing a non-default filename to be specified via the "sanboot --filename" option or the "san-filename" setting. For example: sanboot --filename \efi\redhat\grub.efi \ iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6 or option ipxe.san-filename code 188 = string; option ipxe.san-filename "\\efi\\redhat\\grub.efi"; option root-path "iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6"; Originally-implemented-by: Vishvananda Ishaya Abrams <vish.ishaya@oracle.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dhcp] Allow vendor class to be changed in DHCP requestsMichael Brown2017-03-201-0/+9
| | | | | | | Allow the DHCPv4 vendor class to be specified via the "vendor-class" setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "unixtime" builtin setting to expose the current timeMichael Brown2017-01-261-0/+33
| | | | | | | | | | | Expose the current wall-clock time (in seconds since the Epoch), since this is often useful in captured boot logs and can also be useful when checking unexpected X.509 certificate validation failures. Use a :uint32 setting to avoid Y2K38 rollover, thereby ensuring that this will eventually be somebody else's problem. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow settings blocks to specify a sibling orderingMichael Brown2016-07-191-0/+2
| | | | | | | Allow settings blocks to provide an explicit default ordering between siblings, with lower precedence than the existing ${priority} setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Correctly mortalise autovivified child settings blocksMichael Brown2016-07-191-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ipv6] Rename ipv6_scope to dhcpv6_scopeMichael Brown2016-07-161-1/+1
| | | | | | | | The settings scope ipv6_scope refers specifically to IPv6 settings that have a corresponding DHCPv6 option. Rename to dhcpv6_scope to more accurately reflect this purpose. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Support systems with multiple PCI root bridgesMichael Brown2016-06-091-2/+11
| | | | | | | | | Extend the 16-bit PCI bus:dev.fn address to a 32-bit seg:bus:dev.fn address, assuming a segment value of zero in contexts where multiple segments are unsupported by the underlying data structures (e.g. in the iBFT or BOFM tables). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Extend numerical setting tags to "unsigned long"Michael Brown2016-05-201-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Re-add "uristring" setting typeMichael Brown2015-08-251-5/+33
| | | | | | | | | | | | | | | | | | | | Commit 09b057c ("[settings] Remove "uristring" setting type") removed support for URI-encoded settings via the "uristring" setting type, on the basis that such encoding was no longer necessary to avoid problems with the command line parser. Other valid use cases for the "uristring" setting type do exist: for example, a password containing a '/' character expanded via chain http://username:${password:uristring}@server.name/boot.php Restore the existence of the "uristring" setting, avoiding the potentially large stack allocations that were used in the old code prior to commit 09b057c ("[settings] Remove "uristring" setting type"). Requested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "base64" setting typeMichael Brown2015-04-241-0/+41
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [base16] Add buffer size parameter to base16_encode() and base16_decode()Michael Brown2015-04-241-32/+6Star
| | | | | | | | | | | | | | The current API for Base16 (and Base64) encoding requires the caller to always provide sufficient buffer space. This prevents the use of the generic encoding/decoding functionality in some situations, such as in formatting the hex setting types. Implement a generic hex_encode() (based on the existing format_hex_setting()), implement base16_encode() and base16_decode() in terms of the more generic hex_encode() and hex_decode(), and update all callers to provide the additional buffer length parameter. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Rewrite unrelicensable portions of settings.cMichael Brown2015-03-031-6/+13
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Use list_first_entry() when unregistering child settingsMichael Brown2015-03-031-2/+2
| | | | | | | | | Unregistering a child settings block can have almost arbitrary effects, due to the call to apply_settings(). Avoid potentially dereferencing a stale pointer by using list_first_entry() rather than list_for_each_entry_safe() to iterate over the list of child settings. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove "uristring" setting typeMichael Brown2014-02-271-49/+5Star
| | | | | | | | | | | | | | Commit b5f5f73 ("[cmdline] Expand settings within each command-line token individually") effectively rendered the "uristring" setting type obsolete, since strings containing whitespace no longer break the command line parser. The concept of the "uristring" type is not well defined, since URI escaping rules depend on which portion of a URI is being escaped. Remove the "uristring" type, converting it into an alias for the "string" setting type so as to avoid breaking existing scripts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Merge SETTING_IPv4 and SETTING_IPv6Michael Brown2013-12-051-1/+1
| | | | | | | Allow for equivalent IPv4 and IPv6 settings (which requires equivalent settings to be adjacent within the settings list). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow for multiple definitions of each predefined settingMichael Brown2013-12-051-4/+30
| | | | | | | | | | Allow for multiple setting definitions with the same name but different scopes and tags. For example, allow for a "filename" setting with default scope and tag value 67 (for DHCPv4) and a corresponding "filename" setting with IPv6 scope and tag value 59 (for DHCPv6). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Force settings into alphabetical order within sectionsMichael Brown2013-12-051-13/+14
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add fetch_ipv6_setting()Michael Brown2013-12-051-0/+38
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow for IPv6 setting types in non-IPv6 buildsMichael Brown2013-12-051-24/+55
| | | | | | | | | Allow for the existence of references to IPv6 setting types without dragging in the whole IPv6 stack, by placing the definition of setting_type_ipv6 in core/settings.c and providing weak stub methods for parse_ipv6_setting() and format_ipv6_setting(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Explicitly separate the concept of a completed fetched settingMichael Brown2013-12-051-187/+253
| | | | | | | | | | The fetch_setting() family of functions may currently modify the definition of the specified setting (e.g. to add missing type information). Clean up this interface by requiring callers to provide an explicit buffer to contain the completed definition of the fetched setting, if required. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Move user-class setting from dhcp.c to settings.cMichael Brown2013-11-141-0/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Make built-in settings a linker tableMichael Brown2013-08-271-46/+46
| | | | | | | Allow for configurable provision of built-in settings by placing them in a linker table rather than an array. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow numeric_setting_value() to handle long setting valuesMichael Brown2013-08-121-4/+4
| | | | | | | | | | | Allow numeric_setting_value() to handle e.g. the byte sequence 00:00:00:00:12:34:56:78 by returning -ERANGE only if the value actually overflows the return type. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Introduce the generalised concept of a numeric settingMichael Brown2013-08-011-175/+412
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove now-unused fetchf_named_setting() and storef_named_setting()Michael Brown2013-07-221-114/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove now-unused store_named_setting()Michael Brown2013-07-191-35/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Eliminate call to fetchf_named_setting() in expand_settings()Michael Brown2013-07-191-22/+25
| | | | | | | | | | Use parse_setting_name() and fetchf_setting_copy() in expand_settings(), to eliminate the call to fetchf_named_setting(). This change also eliminates the potentially large stack-allocated buffer in expand_settings(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add fetchf_setting_copy()Michael Brown2013-07-191-2/+39
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Change "not-found" semantics of fetch_setting_copy()Michael Brown2013-07-191-14/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | | fetch_settings_copy() currently returns success and a NULL data pointer to indicate a non-existent setting. This is intended to allow the caller to differentiate between a non-existent setting and an error in allocating memory for the copy of the setting. The underlying settings blocks' fetch() methods provide no way to perform an existence check separate from an attempt to fetch the setting. A "non-existent setting" therefore means simply a setting for which an error was encountered when attempting to fetch from every settings block within the subtree. Since any underlying error within a settings block (e.g. a GuestRPC failure when attempting to retrieve a VMware GuestInfo setting) will produce the effect of a "non-existent setting", it seems somewhat meaningless to give special treatment to memory allocation errors within fetch_setting_copy(). Remove the special treatment and simplify the semantics of fetch_setting_copy() by directly passing through any underlying error (including non-existence) encountered while fetching the setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Expose parse_setting_name()Michael Brown2013-07-191-11/+5Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove default_type parameter from parse_setting_name()Michael Brown2013-07-191-9/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove temporary name buffer parameter from parse_setting_name()Michael Brown2013-07-181-22/+40
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Avoid potentially large stack allocationsMichael Brown2013-07-181-26/+43
| | | | | | | Avoid potentially large stack allocations in fetchf_setting() and storef_setting(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Clarify usage of the term "named setting"Michael Brown2013-07-181-10/+10
| | | | | | | | | | | | 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>
* [settings] Add "version" builtin settingRobin Smidsrød2013-07-131-0/+22
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Make "netX" settings block function as a symbolic linkMichael Brown2013-07-131-23/+50
| | | | | | | | | | | | | | 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>
* [settings] Add "busdevfn" setting typeMichael Brown2013-07-121-0/+47
| | | | | | | 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>
* [settings] Add "hexraw" setting typeMichael Brown2013-07-121-0/+35
| | | | | Originally-implemented-by: Jeppe Toustrup <ipxe@tenzer.dk> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Use hex_decode() to parse hex settingsMichael Brown2013-07-121-32/+29Star
| | | | | | | | | | 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>
* [settings] Eliminate settings "tag magic"Michael Brown2013-05-011-33/+11Star
| | | | | | | 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>
* [settings] Expose build architecture and platform via settingsMichael Brown2013-04-061-15/+85
| | | | | | | | | | | | | | | 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>
* [settings] Add fetchf_named_setting_copy()Michael Brown2012-10-251-0/+39
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Treat an empty formatted value as meaning "delete setting"Michael Brown2012-10-151-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Expose find_child_settings()Michael Brown2012-10-151-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Use a generic setting's own type as its default typeMichael Brown2012-09-101-5/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [legal] Update FSF mailing address in GPL licence textsMichael Brown2012-07-201-1/+2
| | | | | Suggested-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Expose exit status of failed command via ${errno}Michael Brown2012-07-121-0/+120
| | | | | | | | | | | | | | | 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>
* [settings] Move "domain" setting from dns.c to settings.cMichael Brown2012-06-201-0/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add fetch_setting_copy()Michael Brown2012-04-191-0/+40
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>