summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* WIP: nm: Reduce complexity and use of magic numberscleanup/nmAlexander Amelkin2019-08-301-103/+146
| | | | | | | | | | The nm module has a lot of repeated code such as searching for a subcommand, or verification of command line arguments. It also extensively uses magic numbers for option processing. This commit improves code reuse, reduces complexity of code, and gets rid of at least some of magic numbers in the code. This is a work in progress on this branch.
* nm: Refactor to fix issues found by CodacyAlexander Amelkin2019-08-301-18/+19
| | | | | | | Some ternary operator precedence clarification, removal of useless variables, etc. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* nm: Refactor to reduce complexity of nm_suspend()Alexander Amelkin2019-08-301-33/+57
| | | | Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* dcmi: Refactor to simplify read length calculationAlexander Amelkin2019-08-301-20/+10
| | | | | | | | | | Multiple functions use a very complex equation employing division, modulo, and ternary conditionals to perform a very simple task of finding the minimum of two values. Replace all those equations with a call to __min() macro. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Refactor to reduce complexity of dict print funcsAlexander Amelkin2019-08-303-77/+53
| | | | | | | | | | | | | | | | | | | | | Dictionary print functions (print_valstr, print_valstr_2col, dcmi_print_strs) are used in various modules and are excessively complex. One of the reasons is support for loglevel -1, which means printing to STDOUT. Another reason is support in dcmi_print_strs() for so called 'horizontal printing' when only strings without descriptions are printed in one line with separators. Horizontal printing was in fact broken as dcmi_print_strs() was always called with loglevel set to LOG_ERR, which resulted in using lprintf() that adds a '\n' at the end of each printout. This commit: * Fixes horizontal printout for dcmi_print_strs(); * Reduces complexity of all three functions by introducing a macro helper called uprintf() that automatically chooses either printf() or lprintf() based on the selected loglevel; Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* nm: Refactor to get rid of magic numbers in cmdAlexander Amelkin2019-08-301-20/+35
| | | | | | Replace all magic numbers for nm commands with enum values. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* nm: Refactor error checkingAlexander Amelkin2019-08-302-35/+43
| | | | | | | | | | | | | | | | | | | | Make chk_nm_rsp() search for the codes really defined in the NM dictionary and not just check some arbitrary completion codes range. For all codes not defined in NM dictionary, print strings from the generic IPMI completion codes dictionary. Rename chk_nm_rsp() to is_nm_err() to better reflect the purpose of the function. Make it 'bool'. Use centralized exiting for the function. Also fix wording for invalid NM ID. End-user-impact: On invalid responses from the NM, instead of "A valid NM command was not returned!" accompanied by a single byte of data, the following message with full 3 bytes of data will now be printed: "No valid NM ID in response!" Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* nm: Refactor to get rid of magic completion codesAlexander Amelkin2019-08-302-16/+50
| | | | | | | Replace all magic numbers implied to mean NM completions codes with descriptive macro names. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* dcmi: Refactor macro namesAlexander Amelkin2019-08-302-33/+32
| | | | | | Make DCMI command macros more relevant and easy to read. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* nm: Refactor to reduce code duplicationAlexander Amelkin2019-08-302-47/+33
| | | | | | | Add nm_set_id() and nm_check_id() functions, use them and the existing htoipmi24() to reduce code duplication. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* nm: Fix coding styleAlexander Amelkin2019-08-292-177/+228
| | | | | | Fix whitespaces, line lengths, etc. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* nm: Separate code from dcmiAlexander Amelkin2019-08-296-1930/+2029
| | | | | | Move Node Manager related code to separate ipmi_nm.* files. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* intf: Add missing function declarationsAlexander Amelkin2019-08-294-14/+3
| | | | | | | | | | ipmi_intf.h was missing a couple of declarations for the functions used by fru, sdr and hpmfwupg modules. Add those declarations to ipmi_intf.h and remove local declarations. This fixes a couple of compilation warnings. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* doc: fix URL in READMESelivanov Pavel2019-08-291-1/+1
|
* event: Clean up event sending from a fileAlexander Amelkin2019-07-021-57/+16
| | | | | | | | | | | | | | | The ipmi_event_fromfile() function was massively repeating the code of ipmi_send_platform_event() and ipmi_event_msg_print(). This commit cleans up ipmi_event_fromfile() to simply call ipmi_send_platform_event() with all the prepared data read from the file. That function in its turn calls ipmi_event_msg_print(). This commit also replaces the dummy generator ID 2 that was printed to the user with a more relevant generator ID that will actually be sent by ipmi_send_platform_event(). Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* event: Clean up the event sending codeAlexander Amelkin2019-07-022-37/+65
| | | | | | Get rid of magic numbers, reduce code duplication Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* event: Fix event submission via SSIFAlexander Amelkin2019-07-023-19/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IPMI 2.0 specification is quite inconsistent about system interfaces. They have section 1.7.16 "System Interfaces" that clearly states that there are FOUR system interfaces (KCS, SMIC, BT and SSIF), but then they have section 1.7.31 saying that "It is mandatory to implement a system interface that is compatible with one of the **three** specified system interfaces" without specifying which three of the four interfaces are meant. Then in section 6 "IPMI Messaging interfaces" they again say that "As mentioned earlier, there are three System Interface implementations specified for the BMC: SMIC, KCS, and BT". Is all looks like during update from 1.5 to 2.0 they have updated section 1.7.16, but forgot to update Table 6-3, section 1.7.31 and section 6. Yet again, there is 'Get System Interface Capabilities' command that has a parameter 'System Interface Type' that can specify that SI is of SSIF type. All that have lead to a situation where some BMC manufacturers treated the specification as if it prohibited specifying media type 0xC (which is "System Interface") for system interfaces using SSIF (SMBus Sustem Interface), and so they specified an SMBUS media type for their system interface channels. As a result, ipmitool failed to properly send event data via such system interfaces as it treated them as non-system and didn't add the required Generator ID. To mitigate the inconsistency of IPMI specification and yet not ask BMC manufacturers to alter their code, thus increasing compatibility with legacy BMCs, this commit adds checking of current interface number. The system interface, according to Table 6-1 of IPMI Specification is required to have channel number 15 (0Fh). So with this commit the generator ID is added for any interfaces that are either marked as media type 0Ch 'System Interface' or have channel number 0Fh. Resolves ipmitool/ipmitool#111 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* make: Use DESTDIR to install IANA PEN databaseAndrey Kosteltsev2019-07-021-2/+2
| | | | | | | | | In order to support packaging, installation rules in Makefile have to obey the specified DESTDIR. That support was missing and is now added. Signed-off-by: Andrey Kosteltsev <a.kosteltsev@yadro.com> Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* lanplus: Fix embedded bridged responses handlingDawid Frycki2019-07-011-6/+3
| | | | | | Resolves ipmitool/ipmitool#141 Signed-off-by: Dawid Frycki <dawid.frycki@intel.com>
* Update .gitignoreAlexander Amelkin2019-06-251-0/+4
| | | | | | Ignore logs, ViM swap files, and patch rejects and originals. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* mc: Fix reporting of manufacturers > 64KAlexander Amelkin2019-06-182-11/+15
| | | | | | | | | | | | | | | If a manufacturer's IANA PEN (aka manufacturer ID) was above 65535, it wasn't reported properly. Luckily there are no such IDs so far, the biggest is 54077 as of 2019/06/18. There is, however, an ID 0xFFFFFE used by fake_ipmistack for debug purposes, and it was not reported correctly. This commit expands the value argument to string searching functions from 16-bit to 32-bit to allow for any possible IANA PEN. Fixes: 73d6af57827fc85e78c700ca1dff00b3dbc63948 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Add installation of enterprise-numbers databaseAlexander Amelkin2019-06-182-1/+46
| | | | | | | | | | | Download and install the IANA PEN database (enterprise-numbers). The download is performed using either wget or curl, and the database is installed into @IANADIR@. Resolves ipmitool/ipmitool#11 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Update documentation in regard to IANA PEN registryAlexander Amelkin2019-06-184-1/+26
| | | | | | | | | | Add information regarding IANA PEN registry locations into ipmitool and ipmievd man pages. The locations in man pages are automatically generated based on `configure` options. Partially resolves ipmitool/ipmitool#11 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Use configurable path to IANA PEN registryAlexander Amelkin2019-06-182-6/+42
| | | | | | | | | | | | Add support for IANADIR and IANAUSERDIR variables to configure to allow for customizable locations of system and user-supplied IANA PEN registry. Also make path building code portable to Windows. Partially resolves ipmitool/ipmitool#11 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Load IANA PEN registry from a fileAlexander Amelkin2019-06-186-96/+358
| | | | | | | | | | | | | | | | | | | | Previously, the OEM names dictionary was compiled in and updating it required rebuilding of `ipmitool`, thus taking a long time for newly registered OEMs to get supported by the tool. Building also required a direct internet connection to succeed. With this commit, the OEM enterprise dictionary is now loaded from either ${HOME}/.local/usr/share/misc/enterprise-numbers or from /usr/share/misc/enterprise-numbers (in that precedence). Those files can be downloaded from iana.org at http://www.iana.org/assignments/enterprise-numbers Partially resolves ipmitool/ipmitool#11 Fixes: 9d41136c9b7c7d392f1a3f3adeb6d7fe3bd3135e Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* dbus: Replace obsolete INCLUDES with AM_CPPFLAGSAlexander Amelkin2019-06-131-1/+1
| | | | | | The `INCLUDES` variable is obsolete, `AM_CPPFLAGS` is the new name. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* oem: name change from Newisys to Viking Enterprise Solutionsdan mcgee2019-06-113-10/+10
| | | | | | | | | | | Renamed the oem strings containing Newisys to Viking Enterprise Solutions. IANA 9237 Built and tested with AMI's IPMI stack LTS 12.01. Resolves ipmitool/ipmitool#124 Signed-off-by: dan mcgee <dan.mcgee@vikingenterprise.com> Signed-off-by: dan mcgee <dan.mcgee@sanmina.com>
* Fix default interface to behave as it did beforeVernon Mauery2019-06-101-2/+2
| | | | | | | | | | | | | | | | | Prior to 95038ba01b99153de870dde91406bdc1c7265217 the default interface was 'open' for builds where it was available and 'lan' otherwise. Due to a logic error in 95038ba01b99153de870dde91406bdc1c7265217, the default interface was always getting set to lan unless it was specified by the environment variable. This commit fixes the logic and sets the default to open if it is available and lan otherwise. Resolves ipmitool/ipmitool#128 Tested: ./configure # no options reports 'open' as default ./configure --enable-intf-open=no # reports lan as default ./configure --enable-intf-dbus DEFAULT_INTF=dbus # reports dbus Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
* man: Add documentation for chassis bootmboxAlexander Amelkin2019-06-101-0/+28
| | | | Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* man: Update the chassis bootparam sectionAlexander Amelkin2019-06-101-13/+43
| | | | Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* chassis: Add boot initiator mailbox supportAlexander Amelkin2019-06-101-37/+472
| | | | | | | | | | | | | | | Add `chassis bootmbox` command to set and get Boot Initiator Mailbox boot parameter (id 7) the easy way. The command allows for getting and setting the data both in hex and text modes, as well as properly decodes IANA Enterprise number for block 0. It can get/set the whole mailbox at once or operate on separate data blocks. This commit enhances the chassis_get_boot_param() function with extra arguments to re-use its code in handling of the added command. Documentation update will follow. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* chassis: Use command-specific completion code parserAlexander Amelkin2019-06-101-5/+28
| | | | | | | | | | Get/set system boot option commands have some command-specific completion codes that are now reported as "Unknown (0080)", etc. Use the previously introduced specific_val2str() to convert those specific error codes to human-readable strings. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Add support for command-specific completion codesAlexander Amelkin2019-06-102-12/+61
| | | | | | | | | | | | | | Some commands may return command-specific completion codes. Now they are all reported as 'Unknown'. Add helper functions to support such command-specific codes. Command handlers will need to define their own valstr arrays with completion code descriptions and then use specific_val2str() instead of generic val2str() to convert the completion code into a string. Also reduce code duplication in helper.c Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Add a helper htoipmi24() functionAlexander Amelkin2019-06-101-0/+7
| | | | | | | The function converts a host 32-bit integer into an IPMI 24-bit value (LSB first). Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Add a helper args2buf() functionAlexander Amelkin2019-06-102-0/+35
| | | | | | | | The function converts a set of command line arguments representing byte values into a byte buffer and verifies each individual value to be a valid data byte. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* man: Cleanup the manpage formatting tagsAlexander Amelkin2019-06-041-88/+0
| | | | | | | The manpage contained a lot of redundant .RS/.RE tag pairs with no content between the tags. This commits removes those. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* create_pen_list: only print if values are setVernon Mauery2019-05-291-1/+3
| | | | | | | | | | | On a failed download of the PEN list, the create_pen_list script improperly printed an invalid entry of { , "" } causing the build to fail. The last line print must check that it has something to print or it will print the wrong thing. Partially resolves ipmitool/ipmitool#11 Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
* chassis: Refactor to reduce code duplicationAlexander Amelkin2019-05-281-15/+26
| | | | | | | Move boot information acknowledgement clearing code into a helper funcion, call it instead of copy-pasted code. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* chassis: Refactor to reduce code duplicationAlexander Amelkin2019-05-281-100/+69
| | | | | | | | Get rid of repeated code that sets the set-in-progress parameter. Introduce chassis_bootparam_set_in_progress() function to do the job. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* sdr: Fix segfault on invalid unit typesAlexander Amelkin2019-05-272-26/+78
| | | | | | | | | | | The program would crash if the BMC returned an out of range (>90) unit type for a full sensor record. This commit adds a range check and also add support for IPMI 2.0 additional unit types 91 and 92 ("fatal error" and "grams"). Resolves ipmitool/ipmitool#118 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* vendor: Add YADRO TATLIN Storage Controller IDAlexander Amelkin2019-04-171-0/+1
| | | | Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* exchange-bmc-os-info: Remove dependency on ipmi.serviceCharles Rose2019-04-161-2/+3
| | | | | | | | | | | Resolves ipmitool/ipmitool#46 Most modern systems do not require ipmi.service to load the kernel modules. Checking for /dev/ipmi* would be sufficient. v2: Use Assert in place of Condition to explicitly fail based on AlexanderAmelkin's feedback. Signed-off-by: Charles Rose <charles.rose@dell.com>
* Add mechanism to configure to set the default interfaceVernon Mauery2019-04-163-5/+45
| | | | | | | | | | | | | | | | In some cases, the user may want to have a different default interface without the need to always specify it on the command line. Add a configure option that sets the default interface without the need to patch the code. Configure as: ./configure DEFAULT_INTF=name where name is an interface name that might be enabled with --enable-intf-<name>. The configure will enforce that the selected default interface is enabled. Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
* ci: Update INSTALL to reflect recent changesAlexander Amelkin2019-04-151-8/+24
| | | | Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* ci: Set up matrix builds with Travis CIAlexander Amelkin2019-04-151-8/+33
| | | | | | | Enable CI building for Xenial and Trusty, as well as for MacOS X 10.14 (Xcode 10.2). Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Enable Travis build of D-Bus interfaceVernon Mauery2019-04-151-2/+4
| | | | | | | | By default the D-Bus interface is not enabled, so in order to get it to build in Travis, it must be enabled explicitly. This installs the packages needed and sets the configure flag. Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
* add OpenBMC D-Bus interfaceVernon Mauery2019-04-155-2/+320
| | | | | | | | OpenBMC runs a D-Bus interface internally and has the option of compiling ipmitool so it can run natively on the BMC. This adds the D-Bus interface to ipmitool so it can be used with the OpenBMC project. Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Fix "ipmitool pef {status,info}" not printing final newlineVaclav Dolezal2019-04-011-0/+2
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* Remove unused includeAlexander Amelkin2019-03-041-1/+0
| | | | | | | | | The endian.h header is not used for anything and was earlier added by mistake. It however hampers building on some systems where it doesn't exist. Resolves ipmitool/ipmitool#101 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Fix IPMI DCMI message typoGeorge Keishing2019-02-211-4/+4
| | | | Signed-off-by: George Keishing <gkeishin@in.ibm.com>