summaryrefslogtreecommitdiff
path: root/include/ipmitool
Commit message (Collapse)AuthorAgeFilesLines
* lan: channel: Fix set alert on/offAlexander Amelkin2023-01-121-2/+8
| | | | | | | | | | | | | | | | | | From IPMI Spec, Chapter 22.22 Set Channel Access Command Table 22, Set Channel Access Command Byte#2, Bit#5 is "PEF Alerting Enable/Disable" And the bit value: 0b = enable PEF Alerting 1b = disable PEF Alerting on this channel In current code, alert "on" set Bit#5 to 1 and alert "off" set Bit#5 to 0, it's straightforward but just opposite of IPMI spec bit definition. Resolves ipmitool/ipmitool#247 Reported-by: Ryan Fang <Ryan.Fang@quantatw.com> Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Do not require the IANA PEN registry fileVincent Fazio2023-01-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Previously, ipmitool would fail to run if the local copy of the IANA PEN registry could not be parsed. When the registry is not available the manufacturer will be "Unknown" but ipmitool will otherwise function so should not be considered fatal. Also, fix an issue with improperly handling the `oem_info_list_load` return value. Previously, in `ipmi_oem_info_init`, if `oem_info_list_load` returned a negative value due to the registry file not existing, an improper count would cause `oem_info_init_from_list` to aallocate a list that didn't encompass the full header/tail list. IANA PEN registry open failed: No such file or directory Allocating 3 entries [ 1] 16777214 | A Debug Assisting Company, Ltd. [ 0] 1048575 | Unspecified Now, use a signed int and ensure a valid count of loaded OEMs is used. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
* delloem: Fix the unalign bug in arm64SliderLu2023-01-091-4/+0
| | | | | | | | | For computers using the arm64 of the Apple chip, the link requires strict alignment of pointers in 32-bit form. Replace the struct vFlashstr to valstr. Replace the Function get_vFlash_compcode_str to val2str. Resolves ipmitool/ipmitool#332 Signed-off-by: SliderLu <314238828@qq.com>
* fru: Add decoder for multirec system mgmt recordsAlexander Amelkin2022-12-062-0/+55
| | | | | | | | | | | * Add a decoder for System Management records in the Multirecord area * Refactor GUID/UUID decoding: Use the same code for `mc guid` and for `fru print` to decode the GUID and System Unique ID in System Management records in the Multirecord Area. * Fix some type errors in calls to printf/sprintf in GUID decoder Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Cast type before the left shiftTom Tung2022-08-281-3/+3
| | | | | | | | | | | | | | | | Building ipmitool with UBSAN and I got: ``` ... xxx/ipmitool/include/ipmitool/helper.h:191:14: runtime error: left shift of 160 by 24 places cannot be represented in type 'int' #0 0x55bddaa56f11 in ipmi32toh xxx/ipmitool/include/ipmitool/helper.h:191:14 ``` Tested: with this, I tested ipmitool again and the issue disappeared. Resolved: ipmitool/ipmitool#352 Signed-off-by: Tom Tung <shes050117@gmail.com>
* chassis restart_cause: Add new causesAlexander Amelkin2022-03-091-0/+1
| | | | | | | | | Add 'soft reset' and 'power-up by RTC wakeup' causes from IPMI 2.0 spec. Resolves ipmitool/ipmitool#329 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Refactor bridging level detection to dedicated functionPatrick Huesmann2021-09-151-0/+1
| | | | Signed-off-by: Patrick Huesmann <info@patrick-huesmann.de>
* ipmi_mc: Fix the IPM_DEV_FWREV1_MAJOR_MASKLei YU2021-07-141-1/+1
| | | | | | | | | | | The IPM_DEV_FWREV1_MAJOR_MASK was incorrectly defined as 0x3F. The spec indicates that the major firmware revision has 0~6 valid bits, so the mask shall be 0x7F. Tested: Verify a BMC that has a major version that is large than 0x3F, and ipmitool shows the correct major version. Signed-off-by: Lei YU <yulei.sh@bytedance.com>
* sel: Fix "power supply inactive" flag offsetAlexander Amelkin2021-04-271-1/+1
| | | | | | | | | There was a wrong offset for the "Power Supply Inactive" flag, hence the trigger on this event type could not be set. Resolves ipmitool/ipmitool#280 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Use "#pragma once" for headersBing-Hua Wang2021-04-0846-186/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the header guard names in ipmitool duplicated with the ones in freeipmi. * ipmitool/ipmi_fru.h and freeipmi/fru/ipmi-fru.h both uses IPMI_FRU_H * ipmitool/ipmi_sdr.h and freeipmi/sdr/ipmi-sdr.h both uses IPMI_SDR_H * ipmitool/ipmi_sel.h and freeipmi/sel/ipmi-sel.h both uses IPMI_SEL_H This is problematic as including the 1st will prevent the 2nd from being included, leading to the loss of any declarations, inline definitions, or other "#includes" in the 2nd header. For example, including ipmitool/ipmi_sel.h and freeipmi/freeipmi.h fails to build. $ cat test.c #include <ipmitool/ipmi_sel.h> #include <freeipmi/freeipmi.h> $ gcc test.c -I${HOME}/src/oss/ipmitool/include In file included from /usr/include/freeipmi/freeipmi.h:90, from test.c:2: /usr/include/freeipmi/sdr/oem/ipmi-sdr-oem-intel-node-manager.h:48:44: error: unknown type name 'ipmi_sdr_ctx_t'; did you mean 'ipmi_fru_ctx_t'? 48 | int ipmi_sdr_oem_parse_intel_node_manager (ipmi_sdr_ctx_t ctx, | ^~~~~~~~~~~~~~ | ipmi_fru_ctx_t Remove header guards and use "#pragma once" instead. In this way, we don't have to do manual management to avoid name clashes. * src/plugins/lan/md5.h is left as is being an external header originally. * src/plugins/imb/imbapi.h is a convoluted header consisting of multiple header guards. Let's just add "#pragma once" and leave header guards as is for now. Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
* Remove unneeded execution bits from C source files and a header fileBing-Hua Wang2021-04-081-0/+0
| | | | Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
* Convert line endings to LFBing-Hua Wang2021-04-081-46/+46
| | | | | | | | | | | | The following commands is used on Linux to convert line endings to LF. git config core.autocrlf input git add --renormalize . git config --unset core.autocrlf It turns out there was only ipmi_kontronoem.h not using LF. Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
* hpmfwupg: Clean up / refactorAlexander Amelkin2020-10-011-19/+0
| | | | | | | | | | - Drop a useless `extern` definition - Remove static variable `errorCount` from header, move it to the c file where it is actually used if needed Related to ipmitool/ipmitool#220 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* log: refix 16f937a1: Add missing header changesAlexander Amelkin2020-07-211-2/+1
| | | | Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* dist: Add missing ipmi_time.h header to packagingAlexander Amelkin2020-06-301-1/+2
| | | | Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* channel: Refactor set_user_access option processingAlexander Amelkin2020-06-101-0/+1
| | | | | | | | Reduce code duplication by extracting option names, types, and value ranges into a separate structure, and rewriting the option parsing code without mixing it with the data. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* hpmfwupg: move variable definition to .c fileVaclav Dolezal2020-02-131-1/+1
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* intf: Add missing function declarationsAlexander Amelkin2019-08-291-0/+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>
* event: Clean up the event sending codeAlexander Amelkin2019-07-021-0/+27
| | | | | | 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-021-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* mc: Fix reporting of manufacturers > 64KAlexander Amelkin2019-06-181-4/+8
| | | | | | | | | | | | | | | 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>
* Load IANA PEN registry from a fileAlexander Amelkin2019-06-181-1/+3
| | | | | | | | | | | | | | | | | | | | 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>
* oem: name change from Newisys to Viking Enterprise Solutionsdan mcgee2019-06-112-2/+2
| | | | | | | | | | | 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>
* Add support for command-specific completion codesAlexander Amelkin2019-06-101-0/+4
| | | | | | | | | | | | | | 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-101-0/+3
| | | | | | | | 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>
* sdr: Fix segfault on invalid unit typesAlexander Amelkin2019-05-271-4/+28
| | | | | | | | | | | 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>
* Refactor free_n() functionAlexander Amelkin2019-02-201-4/+7
| | | | | | | | Make the argument to free_n() compatible with any pointers, thus reducing the number of compilation warnings. End-user-impact: None Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* fru header: add return error codes specific to fruPatrick Venture2019-02-131-0/+5
| | | | | | | Add two special return codes specific to the IPMI FRU commands. Signed-off-by: Patrick Venture <venture@google.com>
* fru: fixup array bounds checkingPatrick Venture2019-02-131-0/+2
| | | | | | | | | | | | Fixup the following array bounds checking bugs: [lib/ipmi_fru.c:1003]: (style) Array index 'i' is used before limits check. [lib/ipmi_fru.c:1127]: (style) Array index 'i' is used before limits check. [lib/ipmi_fru.c:1262]: (style) Array index 'i' is used before limits check. Signed-off-by: Patrick Venture <venture@google.com>
* helper: add free_n method to handle clearing pointersPatrick Venture2018-12-241-0/+11
| | | | | | | | | | free_n() will free the memory and clear the pointer, which will reduce the probability a developer will forget to clear the pointer after freeing. Resolves: #79 Signed-off-by: Patrick Venture <venture@google.com>
* Move led color static array to source fileAlexander Amelkin2018-11-231-12/+1
| | | | | | | | | | Move led color static array from header to ipmi_picmg module and introduce `picmg_led_color_str()` function for use in ipmi_vita module. Partially resolves ipmitool/ipmitool#13 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* move static objects to source filePatrick Venture2018-11-235-473/+0
| | | | | | | | | Move static objects declared in headers to the source files where they're used. Partially resolves ipmitool/ipmitool#13 Signed-off-by: Patrick Venture <venture@google.com>
* cleanup all unused-parameter warningsPatrick Venture2018-11-232-10/+9
| | | | | | | | | Cleanup all unused-parameter warnings. Each warning was examined to verify it wasn't simply a case of a build macro difference. Partially resolves ipmitool/ipmitool#13 Signed-off-by: Patrick Venture <venture@google.com>
* use __UNUSED__ macro instead of gcc specific attributePatrick Venture2018-11-235-18/+18
| | | | | | | | | Use __UNUSED__ macro defined in helper.h instead of the gcc-specific attribute unused macro. Partially resolves ipmitool/ipmitool#13 Signed-off-by: Patrick Venture <venture@google.com>
* implement __UNUSED__ macro for marking unusedPatrick Venture2018-11-231-0/+6
| | | | | | | | Implement __UNUSED__ macro for marking symbols unused safely. Partially resolves ipmitool/ipmitool#13 Signed-off-by: Patrick Venture <venture@google.com>
* fru: Fix processing of unspecified board mfg. dateAlexander Amelkin2018-11-161-1/+14
| | | | | | | | | | | | | FRU board mfg. date uses a different value for 'unspecified' timestamp than the general IPMI specification. This commit makes ekanalyzer and fru commands process unspecified FRU dates properly, displaying 'Unspecified' instead of 'Mon Jan 1 03:00:00 1996'. Resolves ipmitool/ipmitool#57 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* [compiler-warnings-fixes] ipmi_sdr.c: remove unused function parametersVernon Mauery2018-11-111-14/+7
| | | | | | | | | | Several functions were passed a struct ipmi_intf* even though it was unused. This removes the unused parameters and changes calls and signatures. Partially resolves ipmitool/ipmitool#13 Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
* lan: Fix processing disabled VLANAlexander Amelkin2018-11-111-0/+7
| | | | | | | | | | | Before this fix `ipmitool` would complain that VLAN ID is out of range when trying to disable an already disabled VLAN on a lan channel. With this fix it will properly report that VLAN is already disabled. Resolves ipmitool/ipmitool#55 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Fix strftime() non-literal argument warningAlexander Amelkin2018-11-071-2/+4
| | | | | | | | | | | | | | | | There is a bug in gcc since 4.3.2 and still not fixed in 8.1.0. Even if __attribute__((format(strftime... is specified for a wrapper function around strftime, gcc still complains about strftime being called from the wrapper with a "non-literal" format argument. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438 This commit adds 'ugly hacks' from that discussion to call strftime() from strftime-formatted wrappers and silence the warnings. Partially resolves ipmitool/ipmitool#23 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Refactor timestamp handlingAlexander Amelkin2018-11-073-2/+95
| | | | | | | | | | | | Handle all date/time stamps uniformly, taking in account the host endianness. Respect the local time zone and the '-Z' option for all ipmitool commands. Unify the date and time formatting. Add correct handling of IPMI timestamps 'since system startup' and for 'unspecified' timestamps. Partially resolves ipmitool/ipmitool#23 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* lanplus: RefactoringAlexander Amelkin2018-11-012-11/+16
| | | | | | | Some minor formatting corrections. Also introduced a new helper function to reduce nesting level. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* lanplus: Auto-select 'best' cipher suite availableVernon Mauery2018-11-012-2/+84
| | | | | | | | | | | | | | | | | | | | | Based on current crypto alogrithms, one could rank cipher suites along these lines: 17 > 3 >> all the rest 17 and 3 are the only cipher suites that implement any sort of confidentiality alogorithm that is secure. In addition, any hmac-md5 or md5 integrity algorithm used in integrity is weak at best and dangerous for authentication. This could possibly be enabled in a simpler mechanism by simply checking for 17 and then choosing it before falling back to 3, but the way this is implemented, it makes it easy to change the list of acceptable algorithms from two to three or more items. Resolves ipmitool/ipmitool#29 Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
* strings: Refix 329ebdff: Enlarge data typeAlexander Amelkin2018-08-211-1/+1
| | | | | | | Make val in valstr 32-bit to accomodate the values added by commit 329ebdff. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* mc: guid: Implement encoding autodetectionAlexander Amelkin2018-08-211-8/+47
| | | | | | | | | | | | | | With this commit the GUID encoding is now by default detected automatically based on the validity of the version field, and the timestamp (for time-based version 1 GUIDs). The version is considered valid if it is 1 through 5. The timestamp is considered valid if the year is past UNIX Epoch and before the current year. Resolves ipmitool/ipmitool#25 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* mc: guid: Fix timestamp decodingAlexander Amelkin2018-08-211-0/+19
| | | | | | | | | | | | | | | | | | | | | | | Before this commit the 'Timestamp' line was always printed for all versions of GUID, even for non-time-based ones. Plus, only the time_low field was used, and it was used as if it contained seconds since UNIX Epoch, which it didn't. In fact this field along with other time_* fields constitute a single 60-bit value representing the count of 100ns intervals since adoption of Gregorial calendar (00:00:00.00 15 Oct 1582). For non-time-based versions of GUID, the time_* fields do not represent any time at all. So, after this commit, the timestamp will be properly decoded for time-based GUID version 1 only. For other versions the 'Timestamp' line will not be displayed. A line showing the GUID version will be added to the output. Partially resolves ipmitool/ipmitool#25 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* mc: guid: Add support for non-standard encodingsAlexander Amelkin2018-08-211-9/+44
| | | | | | | | | | | | | | | | | | | | There are lots of BMC implementations that violate the IPMI specification in regard to GUID encoding and instead encode GUIDs according to either RFC4122 or SMBIOS specifications. This commit restores the default behavior of `mc guid` to SMBIOS-based decoding and adds options to allow for decoding according to IPMI or RFC4122 specifications. It also allows to simply dump the received GUID as is without any parsing. It is possible that in future versions `ipmitool` will change default behavior to 'ipmi' instead of 'smbios'. Partially resolves ipmitool/ipmitool#25 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* mc: guid: Fix byte ordering to follow IPMI specAlexander Amelkin2018-08-211-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Before this commit the bytes for the GUID 'node' part were displayed in reverse order as if they were reported by BMC according to SMBIOS specification, not accordint to IPMI. The field order in guid_t was also specified according to RFC4122/SMBIOS, which is the reverse of IPMI specification. It has now been fixed. The time_low field of GUID was taken directly, without taking in account the ipmitool host endianness. It is now properly converted from IPMI little-endian to host byte order. Other GUID fields are also properly converted now. As of now, ipmitool does not generally work properly when built for a big-endian target, but that's out of scope of this commit. Please note that this commit most probably breaks the output of `ipmitool mc guid` with most existing BMC implementations, but that's just an indication of them being broken. A follow-up commit will re-add support for the broken behavior. Partially resolves ipmitool/ipmitool#25 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Refactoring. Improve code reuse ratio.Alexander Amelkin2018-08-142-2/+3
| | | | | | | | | | | Add ARRAY_SIZE() macro. Use the new macro in all places where array size is calculated by means of sizeof(array)/sizeof(array[0]). Fix minor bugs and warnings in the affected code. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* general: Fix several misspellingsThorsten Horstmann2018-08-064-6/+6
| | | | | | Fix misspellings found by codespell in code comments, console output and documentation. Resolves ipmitool/ipmitool#28