Compare commits

..

5 Commits

Author SHA1 Message Date
cac593b83d ci: Add support for Ubuntu 20.04
- Add ubuntu-20.04 target
- Disable building of Solaris-specific `bmc` interface on Ubuntu
- Rename `ubuntu` matrix to `linux`

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-17 02:44:37 +03:00
8554e19e68 ci: Fix Ubuntu builds
GitHub machines sometimes aren't immediately updated after
Ubuntu repos update. That leads to failed CI builds due
to inability to install some packages.

Add a call to `apt update` to update the package database
before installing anything.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-17 02:10:48 +03:00
e6632dcf43 Fix compiler warning
Move #ifdef from the inside to the outside of assert()'s
to get rid of this compiler warning:

warning: embedding a directive within macro arguments has undefined
behavior [-Wembedded-directive]

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-17 01:59:03 +03:00
692a357808 Fix compiler warning
Drop some unused variables detected by the compiler

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-17 01:59:03 +03:00
87fc969e45 Fix compiler warning
Refactor plugin ipmi_intf structure initialization for some
plugins to stop the compiler complaining like this:

warning: use of GNU old-style field designator
extension [-Wgnu-designator]

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-17 01:59:03 +03:00
38 changed files with 300 additions and 846 deletions

View File

@ -1,37 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: AlexanderAmelkin
---
**Describe the bug**
A clear and concise description of what the bug is.
*Please **DO NOT** report ANYTHING about 1.8.18, it is outdated. Please first check your alleged bug with the latest code from the top of the master branch here.*
**IPMITOOL Version**
Make sure you're reporting a bug in the latest code taken from `master` branch here, NOT a bug
that you've found in some version that you've got from your OS vendor or any source other than this repository.
```none
$ ipmitool -V
<output here>
```
**To Reproduce**
Steps to reproduce the behavior:
1. Using hardware/BMC '...'
2. Run `ipmitool ...`
3. Observe the abnormal reply:
```none
abnormal output example
```
**Expected behavior**
A clear and concise description of what you expected to happen.
**Additional context**
Add any other context about the problem here.

View File

@ -11,7 +11,7 @@ jobs:
linux: linux:
strategy: strategy:
matrix: matrix:
os: [ ubuntu-18.04, ubuntu-20.04, ubuntu-22.04 ] os: [ ubuntu-16.04, ubuntu-18.04, ubuntu-20.04 ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: install dependencies - name: install dependencies
@ -53,11 +53,8 @@ jobs:
- name: make distcheck - name: make distcheck
run: make distcheck run: make distcheck
macos: macos-catalina:
strategy: runs-on: macos-10.15
matrix:
os: [ macos-10.15, macos-11, macos-12 ]
runs-on: ${{ matrix.os }}
steps: steps:
- name: install dependencies - name: install dependencies
@ -77,11 +74,9 @@ jobs:
- name: make distcheck - name: make distcheck
run: make distcheck run: make distcheck
windows: win-srv-2019:
strategy:
matrix: runs-on: windows-2019
os: [ windows-2019, windows-2022 ]
runs-on: ${{ matrix.os }}
steps: steps:
- name: install dependencies - name: install dependencies

235
ChangeLog
View File

@ -1,238 +1,3 @@
version 1.8.19 2022-08-31
* Cast type before the left shift
* sel: Fix the deasserted thresholds inequality
* man: Update the text for -C option
* chassis restart_cause: Add new causes
* sel: Remove redundant "Reserve SEL"
* zero initialize the recv structure on the stack
* zero initialize the recv structure on the stack
* ci: Add support for MacOS-11
* ci: Remove ubuntu-16.04 support
* sdr: Fix modifier unit
* Fix compile error
* Refactor bridging level detection to dedicated function
* Fix double bridge detection in get_max_(req|rsp)_data_size()
* ipmi_mc: Fix the IPM_DEV_FWREV1_MAJOR_MASK
* helper: Fix stderr file descriptor
* Fix codefactor-io / CodeFactor warnings
* Use /run instead of /var/run
* oem: Update product IDs for YADRO
* lan: Add processing of get/set specific CCs
* lan: Refactor pointer style
* doc: update lanplus doc to reflect default cipher suite change
* ekanalyzer: Fix internal use area off-by-one bug
* ekanalyzer frushow: Fix internal area size calc
* sel: Fix "power supply inactive" flag offset
* ci: Add support for Ubuntu 20.04
* ci: Fix Ubuntu builds
* Fix compiler warning
* Fix compiler warning
* Fix compiler warning
* ci: Update for GitHub Actions v2.274.2
* free: Fix implicit function declarations
* Use "#pragma once" for headers
* Remove unneeded execution bits from C source files and a header file
* Convert line endings to LF
* Fixed compiler warning.
* RPM support: fixed broken build due to use of headers from kernel
* imbapi: replace __FUNCTION__ to eleminate compiler warnings
* lanplus: remove unused variable
* hpmfwupg: Clean up / refactor
* fru: Fix crashes on 6-bit ASCII strings
* oem: Add product ID for YADRO VEGMAN
* configure.ac: add '--location' for curl to follow location
* configure.ac: replace '-#' by '--progress-bar' with curl
* Add version info to debug output
* doc, ci: Fix an error in package name for Windows
* doc: Fix a small typo in INSTALL
* RPM support: updated spec file changelog
* RPM support: simplified build process
* RPM support: fixed broken RPM build
* doc: Update INSTALL with Windows info
* ci: Add Windows/cygwin config
* doc: Update INSTALL for new CI
* ci: Add github workflow, drop travis
* Fix compatibility with OpenBSD and macOS
* dist: Fix dependencies and cleanup
* dist: Add missing ipmi_time.h header to packaging
* configure: Fix compatibility with non-bash systems
* Finalize refactoring of string comparisons
* channel: Refactor set_user_access option processing
* Refactor string comparisons
* sel: Fix OEM record definition example
* sdr: harden against bad records
* fru: fix memory leak in ipmi_spd_print_fru
* ipmi_sel_set_time: fix strptime() return check
* hpm: use portable __max() in hpmfwupg
* hpmfwupg: move variable definition to .c file
* sel: time: fix null pointer dereference in set
* fru, sdr: Fix id_string buffer overflows
* lanp: Fix buffer overflows in get_lan_param_select
* channel: Fix buffer overflow
* session: Fix buffer overflow in ipmi_get_session_info
* fru: Fix buffer overflow in ipmi_spd_print_fru
* fru: Fix buffer overflow vulnerabilities
* configure: Drop requirement for curses et. al libs
* configure: remove some duplicate code
* doc: Update INSTALL to fix installation errors
* ipmi_dcmi: fix typo in nm_policy_options initialization.
* Docs: Add info on packages to install on Ubuntu 16.04
* chassis: Refactor to get rid of strncmp()
* chassis: Refactor main for centralized exiting
* chassis: bootdev: Refactor more
* chassis: bootdev: Refactor to reduce nesting
* chassis: bootdev: Fix help message and its formatting
* chassis: bootparam/bootdev: Refactor for less magic
* oem: supermicro: Add product codes from IPMICFG
* doc: Update man page regarding `user set password`
* user: Cleanup/refactor ipmi_user_password()
* user: Improve password length handling
* user: Alter "set password" usage information
* intf: Add missing function declarations
* doc: fix URL in README
* event: Clean up event sending from a file
* event: Clean up the event sending code
* event: Fix event submission via SSIF
* make: Use DESTDIR to install IANA PEN database
* lanplus: Fix embedded bridged responses handling
* Update .gitignore
* mc: Fix reporting of manufacturers > 64K
* Add installation of enterprise-numbers database
* Update documentation in regard to IANA PEN registry
* Use configurable path to IANA PEN registry
* Load IANA PEN registry from a file
* dbus: Replace obsolete INCLUDES with AM_CPPFLAGS
* oem: name change from Newisys to Viking Enterprise Solutions
* Fix default interface to behave as it did before
* man: Add documentation for chassis bootmbox
* man: Update the chassis bootparam section
* chassis: Add boot initiator mailbox support
* chassis: Use command-specific completion code parser
* Add support for command-specific completion codes
* Add a helper htoipmi24() function
* Add a helper args2buf() function
* man: Cleanup the manpage formatting tags
* create_pen_list: only print if values are set
* chassis: Refactor to reduce code duplication
* chassis: Refactor to reduce code duplication
* sdr: Fix segfault on invalid unit types
* vendor: Add YADRO TATLIN Storage Controller ID
* exchange-bmc-os-info: Remove dependency on ipmi.service
* Add mechanism to configure to set the default interface
* ci: Update INSTALL to reflect recent changes
* ci: Set up matrix builds with Travis CI
* Enable Travis build of D-Bus interface
* add OpenBMC D-Bus interface
* Fix "ipmitool pef {status,info}" not printing final newline
* Remove unused include
* Fix IPMI DCMI message typo
* open: swap free() calls for free_n()
* open: checking received msg id against expectation
* open: fix whitespace
* Refactor free_n() function
* fru: swap free() calls for free_n()
* fru: Fix write chunk reduction code
* fru: add macro FRU_AREA macros
* fru: replace magic return codes with macros
* fru header: add return error codes specific to fru
* fru: fix ipmi_fru_picmg_ext_edit as bool
* fru: use bool with ipmi_fru_oemkontron_edit
* fru: change ipmi_fru_query_new_value to return bool
* fru: mark ipmi_fru_query_new_value as static
* fru: add fru_cc_rq2big helper method for code checks
* fru: cleanup ipmi_fru_upg_ekeying
* fru: use ipmi_cc defined maros for return codes
* fru: drop extraneous parentheses on negative returns
* fru: delete unused variable matchInstance
* fru: cleanup ipmi_fru_oemkontron_get
* fru: fixup array bounds checking
* hpm: Adhere to centralized exiting
* hpm: Minor refactoring
* hpm: Fix resource leak
* sol: Make interface timeout obey the -N option
* helper: add free_n method to handle clearing pointers
* cygwin: imb: Fix build error (wchar_t)
* lanplus: Fix segfault for truncated dcmi response
* Move led color static array to source file
* drop unused static arrays
* move static objects to source file
* cleanup all unused-parameter warnings
* use __UNUSED__ macro instead of gcc specific attribute
* implement __UNUSED__ macro for marking unused
* Add .dirstamp to .gitignore
* fru: Fix processing of unspecified board mfg. date
* [compiler-warnings-fixes] use correct fall through comment
* [compiler-warnings-fixes] ipmi_start_daemon: check return values
* [compiler-warnings-fixes] ipmi_sdr.c: remove unused function parameters
* lan: Fix processing disabled VLAN
* Make ipmitool respect system locale settings
* Fix strftime() non-literal argument warning
* Refactor timestamp handling
* doc: Update manpage with new contact info
* lanplus: Refactoring
* lanplus: Fix -C option processing
* lanplus: Auto-select 'best' cipher suite available
* lanplus: Fix compile with deprecated APIs disabled.
* doc: Update home page links
* doc: Update formatting of ipmitool man page
* sensor: Refactor ipmi_sensor_print_fc_threshold()
* sensor: Add support for csv output
* plugins: open: Properly enable event receiver (#35)
* lan: Refactoring: Remove unused function
* general: Get rid of some unused parameter warnings
* mc: guid: Implement encoding autodetection
* mc: guid: Fix timestamp decoding
* mc: guid: Add support for non-standard encodings
* mc: guid: Fix byte ordering to follow IPMI spec
* Refactoring: optimize pointer checks
* imb: Refactoring: remove duplicate code
* Refactoring: get rid of superfluous comparisons
* Refactoring. Improve code reuse ratio.
* general: Fix several misspellings
* mc: Fix compiler warnings
* general: Add array_byteswap() to helper
* lanplus: Make byteswapping generic
* framework: Update .gitignore
* framework: Switch to C11 standard with GNU extensions
* framework: ci: Add support for Travis CI
* oem: Add basic support for Quanta
* intf: Refactoring. Remove unused sendrsp()
* dummy: Add default dummy socket
* mc: Fix manufacturer ID masking
* Refactoring. Remove useless feature test macros.
* general: Make byteswapping arch-independent
* sel: Minor refactoring
* sdr: Refactor/optimize code. No functional changes.
* Add an option to display all dates in UTC
* mc: Code refactor to reduce copy-paste ratio
* mc: watchdog set: Refactor to reduce complexity
* mc: watchdog set: Fix intr setting
* mc: watchdog get: Update to match IPMI 2.0 spec
* mc: watchdog: Add `set` command
* framework: Make git ignore cscope.out
* plugins/open: Fix for interrupted select
* nm: Fix policy range (#12)
* Replace user_id masks with a macro (#8)
* fru: internaluse: Fix segmentation fault (#9)
* dcmi: Refactor
* ID:508 - Fix segfaults in dcmi command handlers
* vendor: Add YADRO VESNIN identification
* ID:491 - Fetch vendor IDs from IANA
* ID:472 - Fix The Most recent Addition/Erase date
* ID:480 - Call EVP_CIPHER_CTX_free() instead of EVP_CIPHER_CTX_cleanup()
* ID:480 - ipmitool coredumps in EVP_CIPHER_CTX_init
* Make git revision more descriptive
* ID:477 - fru: Fix decoding of non-text data in get_fru_area_str()
* ID:479 - ekanalyzer: fix processing of custom mfg. fields
* ID:478 - ekanalyzer: Fixed decoding of FRU fields
* Add some more configure/build/editor byproducts to .gitignore
* Add git hash and dirty mark to ipmitool version
* Prevent autoreconf from complaining about missing NEWS
* Add bootstrap support for Mac
* ID:474 - Compile fix on nonlinux systems
* ID:461 - Make compiler happier about changes related to OpenSSL 1.1
* ID:461 - OpenSSL 1.1 compatibility - "error: storage size of 'ctx' isn't known"
version 1.8.18 2016-10-08 version 1.8.18 2016-10-08
* Add mac2str() and str2mac() to print/parse MAC address * Add mac2str() and str2mac() to print/parse MAC address
* Change formatting, remove commented-out code in * Change formatting, remove commented-out code in

11
INSTALL
View File

@ -18,14 +18,11 @@ library and development headers are required. As of July 2020, the
project is tested automatically to build cleanly for the following project is tested automatically to build cleanly for the following
64-bit operating systems using GitHub Actions workflow: 64-bit operating systems using GitHub Actions workflow:
- Ubuntu 16.04 Xenial Xerus
- Ubuntu 18.04 Bionic Beaver - Ubuntu 18.04 Bionic Beaver
- Ubuntu 20.04 Focal Fossa - Ubuntu 20.04 Focal Fossa
- Ubuntu 22.04 Jammy Jellyfish
- MacOS X 10.15 Catalina - MacOS X 10.15 Catalina
- MacOS 11 Big Sur
- MacOS 12 Monterey
- Microsoft Windows Server 2019 - Microsoft Windows Server 2019
- Microsoft Windows Server 2022
It is also known to build successfully on Ubuntu 14.04 and Fedora 31, It is also known to build successfully on Ubuntu 14.04 and Fedora 31,
but that is not automatically verified. but that is not automatically verified.
@ -44,8 +41,8 @@ but that is not automatically verified.
$ sudo dnf install automake gcc git libtool make openssl-devel \ $ sudo dnf install automake gcc git libtool make openssl-devel \
readline-devel wget readline-devel wget
For MacOS with Xcode and homebrew installed, it is recommended to do the For MacOS X 10.15 with Xcode and homebrew installed, it is
following before building: recommended to do the following before building:
$ brew install automake openssl libtool freeipmi wget $ brew install automake openssl libtool freeipmi wget
$ export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" $ export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
@ -185,7 +182,7 @@ architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture. reconfiguring for another architecture.
On MacOS and later systems, you can create libraries and On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the "universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like compiler but only a single `-arch' option to the preprocessor. Like

View File

@ -28,7 +28,7 @@
# LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, # LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
# EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. # EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
DOCDIR = $(docdir) DOCDIR = $(datadir)/doc/$(PACKAGE)
DOCLIST = $(top_srcdir)/README $(top_srcdir)/COPYING $(top_srcdir)/AUTHORS $(top_srcdir)/ChangeLog DOCLIST = $(top_srcdir)/README $(top_srcdir)/COPYING $(top_srcdir)/AUTHORS $(top_srcdir)/ChangeLog
EXTRA_DIST = $(DOCLIST) bootstrap EXTRA_DIST = $(DOCLIST) bootstrap
@ -41,7 +41,7 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure configure-stamp \
$(distdir).tar.gz $(distdir).tar.bz2 $(distdir).tar.gz $(distdir).tar.bz2
SUBDIRS = lib src include doc contrib control SUBDIRS = lib src include doc contrib control
IANA_PEN = http://www.iana.org/assignments/enterprise-numbers.txt IANA_PEN = http://www.iana.org/assignments/enterprise-numbers
dist-hook: dist-hook:
cp control/ipmitool.spec $(distdir) cp control/ipmitool.spec $(distdir)

View File

@ -2,7 +2,7 @@ dnl
dnl autoconf for ipmitool dnl autoconf for ipmitool
dnl dnl
m4_define([git_suffix], m4_esyscmd_s(./csv-revision)) m4_define([git_suffix], m4_esyscmd_s(./csv-revision))
AC_INIT([ipmitool], [1.8.19git_suffix]) AC_INIT([ipmitool], [1.8.18git_suffix])
AC_CONFIG_SRCDIR([src/ipmitool.c]) AC_CONFIG_SRCDIR([src/ipmitool.c])
AC_CONFIG_COMMANDS_PRE([export prefix=$prefix]) AC_CONFIG_COMMANDS_PRE([export prefix=$prefix])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
@ -18,6 +18,8 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_CHECK_PROG([RPMBUILD], [rpmbuild], [rpmbuild], [rpm]) AC_CHECK_PROG([RPMBUILD], [rpmbuild], [rpmbuild], [rpm])
AC_CHECK_PROG([SED], [sed], [sed]) AC_CHECK_PROG([SED], [sed], [sed])
AC_CHECK_PROG([WGET], [wget], [wget])
AC_CHECK_PROG([CURL], [curl], [curl])
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h sys/ioctl.h sys/stat.h unistd.h paths.h]) AC_CHECK_HEADERS([stdlib.h string.h sys/ioctl.h sys/stat.h unistd.h paths.h])
@ -54,33 +56,21 @@ if test "x$exec_prefix" = "xNONE"; then
exec_prefix="$prefix" exec_prefix="$prefix"
fi fi
dnl allow enabling/disabling the fetching of the IANA PEN registry if test "x$WGET" = "x"; then
AC_ARG_ENABLE([registry-download], if test "x$CURL" = "x"; then
[AC_HELP_STRING([--enable-registry-download],
[download/install the IANA PEN registry [default=yes]])],
[xenable_registry_download=$enableval],
[xenable_registry_download=yes])
AM_CONDITIONAL([DOWNLOAD], [false])
if test "x$xenable_registry_download" = "xyes"; then
AC_CHECK_PROG([WGET], [wget], [wget])
AC_CHECK_PROG([CURL], [curl], [curl])
if test "x$WGET" = "x" && test "x$CURL" = "x"; then
AC_MSG_WARN([** Neither wget nor curl could be found.]) AC_MSG_WARN([** Neither wget nor curl could be found.])
AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !]) AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !])
else
AM_CONDITIONAL([DOWNLOAD], [true])
if test "x$WGET" != "x"; then
DOWNLOAD="$WGET -c -nd -O -"
else else
DOWNLOAD="$CURL --location --progress-bar" DOWNLOAD="$CURL --location --progress-bar"
AM_CONDITIONAL([DOWNLOAD], [true])
fi fi
fi else
DOWNLOAD="$WGET -c -nd -O -"
AM_CONDITIONAL([DOWNLOAD], [true])
fi fi
AC_MSG_WARN([** Download is: $DOWNLOAD]) AC_MSG_WARN([** Download is:])
AC_MSG_WARN($DOWNLOAD)
AC_SUBST(DOWNLOAD, $DOWNLOAD) AC_SUBST(DOWNLOAD, $DOWNLOAD)
dnl dnl
@ -634,11 +624,7 @@ AC_ARG_ENABLE([ipmishell],
dnl check for readline library to enable ipmi shell dnl check for readline library to enable ipmi shell
if test "x$xenable_ipmishell" = "xyes"; then if test "x$xenable_ipmishell" = "xyes"; then
PKG_PROG_PKG_CONFIG AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])
PKG_CHECK_MODULES([READLINE], [readline],
[LIBS="$LIBS $READLINE_LIBS" have_readline=yes],
[AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])]
)
if test "x$have_readline" != "xyes"; then if test "x$have_readline" != "xyes"; then
AC_MSG_ERROR([** Unable to find readline required by ipmishell.]) AC_MSG_ERROR([** Unable to find readline required by ipmishell.])
xenable_ipmishell=no xenable_ipmishell=no

View File

@ -27,9 +27,9 @@ TRAPD_BMC_CONF="${SNMPD_BMC_CONF_DIR}/snmptrapd.local.conf"
TRAPD_CONF="/etc/snmp/snmptrapd.conf" TRAPD_CONF="/etc/snmp/snmptrapd.conf"
LOCKFILE="/var/lock/subsys/bmc-snmp-proxy" LOCKFILE="/var/lock/subsys/bmc-snmp-proxy"
BMC_INFO="/run/bmc-info" BMC_INFO="/var/run/bmc-info"
IPMITOOL=$(which ipmitool) IPMITOOL=`which ipmitool`
#Default config #Default config
BMC_COMMUNITY="public" BMC_COMMUNITY="public"
@ -158,7 +158,7 @@ pick_alert_dest()
{ {
test_ip="$1" test_ip="$1"
# We have 4 IPv4 and 4 IPv6 alert dest. We will set IPv4 for now. # We have 4 IPv4 and 4 IPv6 alert dest. We will set IPv4 for now.
for ALERT_DEST in $(seq 1 4) for ALERT_DEST in `seq 1 4`
do do
temp_ip=$(${IPMITOOL} lan alert print ${CHANNEL} ${ALERT_DEST}\ temp_ip=$(${IPMITOOL} lan alert print ${CHANNEL} ${ALERT_DEST}\
2>/dev/null| sed -n "s#^Alert IP Address.*: ##p") 2>/dev/null| sed -n "s#^Alert IP Address.*: ##p")
@ -178,7 +178,7 @@ config_bmc_alert_dest()
{ {
# call with enable|disable # call with enable|disable
# Pick the first active LAN channel # Pick the first active LAN channel
for CHANNEL in $(seq 1 14) for CHANNEL in `seq 1 14`
do do
[ $(${IPMITOOL} -I open channel info ${CHANNEL} 2>/dev/null \ [ $(${IPMITOOL} -I open channel info ${CHANNEL} 2>/dev/null \
| grep -q "802\.3") ] || break | grep -q "802\.3") ] || break

View File

@ -5,7 +5,7 @@ After=exchange-bmc-os-info.service
Requires=exchange-bmc-os-info.service Requires=exchange-bmc-os-info.service
PartOf=exchange-bmc-os-info.service PartOf=exchange-bmc-os-info.service
ConditionPathExists=/run/bmc-info ConditionPathExists=/var/run/bmc-info
[Service] [Service]
Type=oneshot Type=oneshot

View File

@ -12,10 +12,10 @@
# Description: Script to set OS information in the BMC; fetch BMC IP/URL # Description: Script to set OS information in the BMC; fetch BMC IP/URL
# and set in the OS for use by other scripts/user. # and set in the OS for use by other scripts/user.
# #
# BMC IP and URL are made available in /run/bmc-info # BMC IP and URL are made available in /var/run/bmc-info
# #
# Example to launch BMC web-interface: # Example to launch BMC web-interface:
# # . /run/bmc-info # # . /var/run/bmc-info
# # xdg-open $BMC_URL # # xdg-open $BMC_URL
# #
# See here for details: # See here for details:
@ -42,7 +42,7 @@
############################################################################# #############################################################################
CONFIGFILE=/etc/sysconfig/exchange-bmc-os-info CONFIGFILE=/etc/sysconfig/exchange-bmc-os-info
IPMI_TOOL=/usr/bin/ipmitool IPMI_TOOL=/usr/bin/ipmitool
BMC_INFO=/run/bmc-info BMC_INFO=/var/run/bmc-info
# BMC Manufacturer ID used in 'oem_set_os_version' and 'oem_get_bmc_url' # BMC Manufacturer ID used in 'oem_set_os_version' and 'oem_get_bmc_url'
DELL="674" DELL="674"

View File

@ -22,7 +22,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="IPMI event daemon" DESC="IPMI event daemon"
NAME=ipmievd NAME=ipmievd
DAEMON=/usr/sbin/$NAME DAEMON=/usr/sbin/$NAME
PIDFILE=/run/$NAME.pid PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed. # Gracefully exit if the package has been removed.

View File

@ -174,7 +174,7 @@ Do NOT become a daemon, instead log all messages to stderr.
.TP .TP
\fIpidfile\fP=<\fBfilename\fR> \fIpidfile\fP=<\fBfilename\fR>
Save process ID to this file when in daemon mode. Defaults to Save process ID to this file when in daemon mode. Defaults to
/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device /var/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device
number -- defaults to 0). number -- defaults to 0).
.RE .RE
@ -197,7 +197,7 @@ Do NOT become a daemon, instead log all messages to stderr.
.TP .TP
\fIpidfile\fP=<\fBfilename\fR> \fIpidfile\fP=<\fBfilename\fR>
Save process ID to this file when in daemon mode. Defaults to Save process ID to this file when in daemon mode. Defaults to
/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device /var/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device
number -- defaults to 0). number -- defaults to 0).
.TP .TP
\fItimeout\fP=<\fBseconds\fR> \fItimeout\fP=<\fBseconds\fR>

View File

@ -97,14 +97,9 @@ This is not available with all commands.
.TP .TP
\fB\-C\fR <\fIciphersuite\fP> \fB\-C\fR <\fIciphersuite\fP>
The remote server authentication, integrity, and encryption algorithms The remote server authentication, integrity, and encryption algorithms
to use for IPMIv2.0 \fIlanplus\fP connections. See table 22\-20 in the to use for IPMIv2.0 \fIlanplus\fP connections. See table 22\-19 in the
IPMI v2.0 specification. The default is 17 which specifies RAKP\-HMAC\-SHA256 IPMIv2.0 specification. The default is 3 which specifies RAKP\-HMAC\-SHA1
authentication, HMAC\-SHA256\-128 integrity, and AES\-CBC\-128 encryption algorithms. authentication, HMAC\-SHA1\-96 integrity, and AES\-CBC\-128 encryption algorithms.
NOTE: In
.BR ipmitool
1.8.18 and earlier the default was 3, which was insecure and was not supported
by some more recent BMC implementations.
.TP .TP
\fB\-d \fIN\fP\fR \fB\-d \fIN\fP\fR
Use device number N to specify the /dev/ipmiN (or Use device number N to specify the /dev/ipmiN (or
@ -3747,9 +3742,9 @@ those available for the \fIlan\fP interface.
The \fB\-C\fR option allows you specify the authentication, integrity, The \fB\-C\fR option allows you specify the authentication, integrity,
and encryption algorithms to use for for \fIlanplus\fP session based and encryption algorithms to use for for \fIlanplus\fP session based
on the cipher suite ID found in the IPMIv2.0 specification in table on the cipher suite ID found in the IPMIv2.0 specification in table
22\-20. The default cipher suite is \fI17\fP which specifies 22\-19. The default cipher suite is \fI3\fP which specifies
RAKP\-HMAC\-SHA256 authentication, HMAC\-SHA256\-128 integrity, and RAKP\-HMAC\-SHA1 authentication, HMAC\-SHA1\-96 integrity, and AES\-CBC\-128
AES\-CBC\-128 encryption algorightms. encryption algorightms.
.SH "FREE INTERFACE" .SH "FREE INTERFACE"
.LP .LP

View File

@ -152,7 +152,7 @@ static inline uint16_t ipmi16toh(void *ipmi16)
uint8_t *ipmi = (uint8_t *)ipmi16; uint8_t *ipmi = (uint8_t *)ipmi16;
uint16_t h; uint16_t h;
h = (uint16_t)ipmi[1] << 8; /* MSB */ h = ipmi[1] << 8; /* MSB */
h |= ipmi[0]; /* LSB */ h |= ipmi[0]; /* LSB */
return h; return h;
@ -169,7 +169,7 @@ static inline uint32_t ipmi24toh(void *ipmi24)
uint8_t *ipmi = (uint8_t *)ipmi24; uint8_t *ipmi = (uint8_t *)ipmi24;
uint32_t h = 0; uint32_t h = 0;
h = (uint32_t)ipmi[2] << 16; /* MSB */ h = ipmi[2] << 16; /* MSB */
h |= ipmi[1] << 8; h |= ipmi[1] << 8;
h |= ipmi[0]; /* LSB */ h |= ipmi[0]; /* LSB */
@ -188,7 +188,7 @@ static inline uint32_t ipmi32toh(void *ipmi32)
uint8_t *ipmi = ipmi32; uint8_t *ipmi = ipmi32;
uint32_t h; uint32_t h;
h = (uint32_t)ipmi[3] << 24; /* MSB */ h = ipmi[3] << 24; /* MSB */
h |= ipmi[2] << 16; h |= ipmi[2] << 16;
h |= ipmi[1] << 8; h |= ipmi[1] << 8;
h |= ipmi[0]; /* LSB */ h |= ipmi[0]; /* LSB */

View File

@ -89,16 +89,10 @@ struct channel_info_t {
uint8_t aux_info[2]; uint8_t aux_info[2];
}; };
/* (22.23) Get Channel Access */
/* (22.22 / 22.23) Set/Get Channel Access */
typedef enum {
ALERTING_ENABLED = 0,
ALERTING_DISABLED = (1 << 5) /* See Table 22 */
} alerting_t;
struct channel_access_t { struct channel_access_t {
uint8_t access_mode; uint8_t access_mode;
alerting_t alerting; uint8_t alerting;
uint8_t channel; uint8_t channel;
uint8_t per_message_auth; uint8_t per_message_auth;
uint8_t privilege_limit; uint8_t privilege_limit;

View File

@ -343,6 +343,10 @@ typedef struct _power_headroom
uint16_t peakheadroom; uint16_t peakheadroom;
} __attribute__ ((packed)) POWER_HEADROOM; } __attribute__ ((packed)) POWER_HEADROOM;
struct vFlashstr {
uint8_t val;
const char * str;
};
typedef struct ipmi_vFlash_extended_info typedef struct ipmi_vFlash_extended_info
{ {
uint8_t vflashcompcode; uint8_t vflashcompcode;

View File

@ -127,7 +127,6 @@ struct fru_area_product {
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
#endif #endif
/* See Table 16-1 of "IPMI FRU Information Storage Specification" */
struct fru_multirec_header { struct fru_multirec_header {
#define FRU_RECORD_TYPE_POWER_SUPPLY_INFORMATION 0x00 #define FRU_RECORD_TYPE_POWER_SUPPLY_INFORMATION 0x00
#define FRU_RECORD_TYPE_DC_OUTPUT 0x01 #define FRU_RECORD_TYPE_DC_OUTPUT 0x01
@ -137,8 +136,6 @@ struct fru_multirec_header {
#define FRU_RECORD_TYPE_EXTENDED_COMPATIBILITY 0x05 #define FRU_RECORD_TYPE_EXTENDED_COMPATIBILITY 0x05
#define FRU_RECORD_TYPE_OEM_EXTENSION 0xc0 #define FRU_RECORD_TYPE_OEM_EXTENSION 0xc0
uint8_t type; uint8_t type;
#define FRU_RECORD_FORMAT_EOL_MASK 0x80
#define FRU_RECORD_FORMAT_VER_MASK 0x0F
uint8_t format; uint8_t format;
uint8_t len; uint8_t len;
uint8_t record_checksum; uint8_t record_checksum;
@ -244,43 +241,6 @@ struct fru_multirec_dcload {
#pragma pack(0) #pragma pack(0)
#endif #endif
#ifdef HAVE_PRAGMA_PACK
#pragma pack(push, 1)
#endif
/*
* In accordance with Table 18-7 of "IPMI Platform Management FRU Information
* Storage Definition v1.0"
*/
struct fru_multirec_mgmt {
#define FRU_MULTIREC_MGMT_SUBTYPE_MIN 0x01
#define FRU_MULTIREC_MGMT_SUBTYPE_MAX 0x07
uint8_t subtype;
#define FRU_MULTIREC_MGMT_SYSURL 0x01
#define FRU_MULTIREC_MGMT_CMPURL 0x04
#define FRU_MULTIREC_MGMT_URL_MINLEN 16
#define FRU_MULTIREC_MGMT_URL_MAXLEN 256
#define FRU_MULTIREC_MGMT_SYSNAME 0x02
#define FRU_MULTIREC_MGMT_CMPNAME 0x05
#define FRU_MULTIREC_MGMT_NAME_MINLEN 8
#define FRU_MULTIREC_MGMT_NAME_MAXLEN 64
#define FRU_MULTIREC_MGMT_SYSPINGADDR 0x03
#define FRU_MULTIREC_MGMT_CMPPINGADDR 0x06
#define FRU_MULTIREC_MGMT_PINGADDR_MINLEN 8
#define FRU_MULTIREC_MGMT_PINGADDR_MAXLEN 64
#define FRU_MULTIREC_MGMT_UUID 0x07
#define FRU_MULTIREC_MGMT_UUID_LEN 16
#define FRU_MULTIREC_MGMT_DATA_MAXLEN FRU_MULTIREC_MGMT_URL_MAXLEN
uint8_t data[];
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(pop)
#endif
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
#endif #endif

View File

@ -242,7 +242,6 @@ struct ipmi_intf {
uint16_t ipmi_intf_get_max_request_data_size(struct ipmi_intf *intf); uint16_t ipmi_intf_get_max_request_data_size(struct ipmi_intf *intf);
uint16_t ipmi_intf_get_max_response_data_size(struct ipmi_intf *intf); uint16_t ipmi_intf_get_max_response_data_size(struct ipmi_intf *intf);
uint8_t ipmi_intf_get_bridging_level(const struct ipmi_intf *intf);
struct ipmi_intf * ipmi_intf_load(char * name); struct ipmi_intf * ipmi_intf_load(char * name);
void ipmi_intf_print(struct ipmi_intf_support * intflist); void ipmi_intf_print(struct ipmi_intf_support * intflist);

View File

@ -83,7 +83,7 @@ struct ipm_devid_rsp {
#define IPM_DEV_DEVICE_ID_REV_MASK (0x0F) /* BCD-enoded */ #define IPM_DEV_DEVICE_ID_REV_MASK (0x0F) /* BCD-enoded */
#define IPM_DEV_FWREV1_AVAIL_MASK (0x80) /* 0 = normal operation */ #define IPM_DEV_FWREV1_AVAIL_MASK (0x80) /* 0 = normal operation */
#define IPM_DEV_FWREV1_MAJOR_MASK (0x7f) /* Major rev, BCD-encoded */ #define IPM_DEV_FWREV1_MAJOR_MASK (0x3f) /* Major rev, BCD-encoded */
#define IPM_DEV_IPMI_VER_MAJOR_MASK (0x0F) /* Major rev, BCD-encoded */ #define IPM_DEV_IPMI_VER_MAJOR_MASK (0x0F) /* Major rev, BCD-encoded */
#define IPM_DEV_IPMI_VER_MINOR_MASK (0xF0) /* Minor rev, BCD-encoded */ #define IPM_DEV_IPMI_VER_MINOR_MASK (0xF0) /* Minor rev, BCD-encoded */
@ -211,21 +211,6 @@ typedef struct {
parsed_guid_t ipmi_parse_guid(void *guid, ipmi_guid_mode_t guid_mode); parsed_guid_t ipmi_parse_guid(void *guid, ipmi_guid_mode_t guid_mode);
/**
* Convert a binary GUID/UUID to a canonical hex string form.
* If the version/encoding of the source data is unknown,
* dump the source data as a simple hex string.
*
* @param[out] str The string representation of GUID
* @param[in] data The source binary GUID data
* @param[in] mode The conversion mode, use GUID_AUTO for automatic detection
*
* @returns The parsed GUID structure
*/
parsed_guid_t
ipmi_guid2str(char *str, const void *data, ipmi_guid_mode_t mode);
#define GUID_STR_MAXLEN 36 /* 8+4+4+4+12 bytes plus the dashes */
int _ipmi_mc_get_guid(struct ipmi_intf *intf, ipmi_guid_t *guid); int _ipmi_mc_get_guid(struct ipmi_intf *intf, ipmi_guid_t *guid);
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK

View File

@ -256,7 +256,7 @@ static const struct ipmi_event_sensor_types sensor_specific_event_types[] = {
{ 0x08, 0x06, 0x03, "Config Error: Power Supply Rating Mismatch" }, { 0x08, 0x06, 0x03, "Config Error: Power Supply Rating Mismatch" },
{ 0x08, 0x06, 0x04, "Config Error: Voltage Rating Mismatch" }, { 0x08, 0x06, 0x04, "Config Error: Voltage Rating Mismatch" },
{ 0x08, 0x06, 0xff, "Config Error" }, { 0x08, 0x06, 0xff, "Config Error" },
{ 0x08, 0x07, 0xff, "Power Supply Inactive" }, { 0x08, 0x06, 0xff, "Power Supply Inactive" },
/* Power Unit */ /* Power Unit */
{ 0x09, 0x00, 0xff, "Power off/down" }, { 0x09, 0x00, 0xff, "Power off/down" },
{ 0x09, 0x01, 0xff, "Power cycle" }, { 0x09, 0x01, 0xff, "Power cycle" },

View File

@ -49,13 +49,12 @@ extern const struct valstr ipmi_authtype_vals[];
extern const struct valstr ipmi_channel_protocol_vals[]; extern const struct valstr ipmi_channel_protocol_vals[];
extern const struct valstr ipmi_channel_medium_vals[]; extern const struct valstr ipmi_channel_medium_vals[];
extern const struct valstr ipmi_chassis_power_control_vals[]; extern const struct valstr ipmi_chassis_power_control_vals[];
extern const struct valstr ipmi_chassis_restart_cause_vals[];
extern const struct valstr ipmi_auth_algorithms[]; extern const struct valstr ipmi_auth_algorithms[];
extern const struct valstr ipmi_integrity_algorithms[]; extern const struct valstr ipmi_integrity_algorithms[];
extern const struct valstr ipmi_encryption_algorithms[]; extern const struct valstr ipmi_encryption_algorithms[];
extern const struct valstr ipmi_user_enable_status_vals[]; extern const struct valstr ipmi_user_enable_status_vals[];
extern const struct valstr *ipmi_oem_info; extern const struct valstr *ipmi_oem_info;
void ipmi_oem_info_init(); int ipmi_oem_info_init();
void ipmi_oem_info_free(); void ipmi_oem_info_free();
extern const struct valstr picmg_frucontrol_vals[]; extern const struct valstr picmg_frucontrol_vals[];

View File

@ -54,7 +54,7 @@
#ifdef HAVE_PATHS_H #ifdef HAVE_PATHS_H
# include <paths.h> # include <paths.h>
#else #else
# define _PATH_RUN "/run/" # define _PATH_VARRUN "/var/run/"
#endif #endif
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -935,7 +935,7 @@ ipmi_start_daemon(struct ipmi_intf *intf)
exit(1); exit(1);
} }
ret = dup(fd); ret = dup(fd);
if (ret != STDERR_FILENO) { if (ret != STDOUT_FILENO) {
lprintf(LOG_ERR, "failed to reset stderr: %s (%d)", strerror(errno), errno); lprintf(LOG_ERR, "failed to reset stderr: %s (%d)", strerror(errno), errno);
exit(1); exit(1);
} }

View File

@ -378,8 +378,42 @@ ipmi_chassis_restart_cause(struct ipmi_intf * intf)
return -1; return -1;
} }
printf("System restart cause: %s\n", printf("System restart cause: ");
val2str(rsp->data[0] & 0xf, ipmi_chassis_restart_cause_vals));
switch (rsp->data[0] & 0xf) {
case 0:
printf("unknown\n");
break;
case 1:
printf("chassis power control command\n");
break;
case 2:
printf("reset via pushbutton\n");
break;
case 3:
printf("power-up via pushbutton\n");
break;
case 4:
printf("watchdog expired\n");
break;
case 5:
printf("OEM\n");
break;
case 6:
printf("power-up due to always-restore power policy\n");
break;
case 7:
printf("power-up due to restore-previous power policy\n");
break;
case 8:
printf("reset via PEF\n");
break;
case 9:
printf("power-cycle via PEF\n");
break;
default:
printf("invalid\n");
}
return 0; return 0;
} }

View File

@ -115,7 +115,7 @@ char NIC_Selection_Mode_String_12g[] [50] = {
"shared with failover all loms" "shared with failover all loms"
}; };
const struct valstr vFlash_completion_code_vals[] = { const struct vFlashstr vFlash_completion_code_vals[] = {
{0x00, "SUCCESS"}, {0x00, "SUCCESS"},
{0x01, "NO_SD_CARD"}, {0x01, "NO_SD_CARD"},
{0x63, "UNKNOWN_ERROR"}, {0x63, "UNKNOWN_ERROR"},
@ -232,6 +232,8 @@ static void ipmi_powermonitor_usage(void);
/* vFlash Function prototypes */ /* vFlash Function prototypes */
static int ipmi_delloem_vFlash_main(struct ipmi_intf *intf, int argc, static int ipmi_delloem_vFlash_main(struct ipmi_intf *intf, int argc,
char **argv); char **argv);
const char *get_vFlash_compcode_str(uint8_t vflashcompcode,
const struct vFlashstr *vs);
static int ipmi_get_sd_card_info(struct ipmi_intf *intf); static int ipmi_get_sd_card_info(struct ipmi_intf *intf);
static int ipmi_delloem_vFlash_process(struct ipmi_intf *intf, int current_arg, static int ipmi_delloem_vFlash_process(struct ipmi_intf *intf, int current_arg,
char **argv); char **argv);
@ -3754,6 +3756,28 @@ ipmi_delloem_vFlash_main(struct ipmi_intf * intf, int __UNUSED__(argc), char **
rc = ipmi_delloem_vFlash_process(intf, current_arg, argv); rc = ipmi_delloem_vFlash_process(intf, current_arg, argv);
return rc; return rc;
} }
/*
* Function Name: get_vFlash_compcode_str
*
* Description: This function maps the vFlash completion code
* to a string
* Input : vFlash completion code and static array of codes vs strings
* Output: -
* Return: returns the mapped string
*/
const char *
get_vFlash_compcode_str(uint8_t vflashcompcode, const struct vFlashstr *vs)
{
static char un_str[32];
int i;
for (i = 0; vs[i].str; i++) {
if (vs[i].val == vflashcompcode)
return vs[i].str;
}
memset(un_str, 0, 32);
snprintf(un_str, 32, "Unknown (0x%02X)", vflashcompcode);
return un_str;
}
/* /*
* Function Name: ipmi_get_sd_card_info * Function Name: ipmi_get_sd_card_info
* *
@ -3798,7 +3822,7 @@ ipmi_get_sd_card_info(struct ipmi_intf * intf) {
return -1; return -1;
} else if (sdcardinfoblock->vflashcompcode != 0x00) { } else if (sdcardinfoblock->vflashcompcode != 0x00) {
lprintf(LOG_ERR, "Error in getting SD Card Extended Information (%s)", lprintf(LOG_ERR, "Error in getting SD Card Extended Information (%s)",
val2str(sdcardinfoblock->vflashcompcode, get_vFlash_compcode_str(sdcardinfoblock->vflashcompcode,
vFlash_completion_code_vals)); vFlash_completion_code_vals));
return -1; return -1;
} }

View File

@ -43,8 +43,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
#define NO_MORE_INFO_FIELD 0xc1 #define NO_MORE_INFO_FIELD 0xc1
#define TYPE_CODE 0xc0 /*Language code*/ #define TYPE_CODE 0xc0 /*Language code*/
@ -2445,8 +2443,6 @@ ipmi_ek_display_fru_header_detail(char *filename)
if (header.offset.internal != 0) { if (header.offset.internal != 0) {
unsigned char format_version; unsigned char format_version;
unsigned long len = 0; unsigned long len = 0;
uint8_t *area_offset;
uint8_t next_offset = UINT8_MAX;
printf("%s\n", EQUAL_LINE_LIMITER); printf("%s\n", EQUAL_LINE_LIMITER);
printf("FRU Internal Use Info\n"); printf("FRU Internal Use Info\n");
@ -2460,46 +2456,12 @@ ipmi_ek_display_fru_header_detail(char *filename)
} }
printf("Format Version: %d\n", (format_version & 0x0f)); printf("Format Version: %d\n", (format_version & 0x0f));
/* Internal use area doesn't contain the size byte. if (header.offset.chassis > 0) {
* We need to calculate its size by finding the area len = (header.offset.chassis * FACTOR_OFFSET)
* that is next. Areas may not follow the same order - (header.offset.internal * FACTOR_OFFSET);
* as their offsets listed in the header, so we need } else {
* to find the area that is physically next to the len = (header.offset.board * FACTOR_OFFSET)
* internal use area. - (header.offset.internal * FACTOR_OFFSET);
*/
for (area_offset = &header.offset.internal + 1;
area_offset <= &header.offset.multi;
++area_offset)
{
/* If the area is closer to us than the previously
* checked one, make it our best candidate
*/
if (*area_offset < next_offset
&& *area_offset > header.offset.internal)
{
next_offset = *area_offset;
}
}
/* If there was at least one area after internal use one,
* then we must have found it and can use it to calculate
* length. Otherwise, everything till the end of file is
* internal use area expect for the last (checksum) byte.
*/
if (next_offset < UINT8_MAX) {
len = (next_offset - header.offset.internal) * FACTOR_OFFSET;
--len; /* First byte of internal use area is version and we've
already read it */
}
else {
struct stat fs;
long curpos = ftell(input_file);
if (curpos < 0 || 0 > fstat(fileno(input_file), &fs)) {
lprintf(LOG_ERR, "Failed to determine FRU file size");
fclose(input_file);
return -1;
}
len = fs.st_size - curpos - 1; /* Last byte is checksum */
} }
printf("Length: %ld\n", len); printf("Length: %ld\n", len);
printf("Data dump:\n"); printf("Data dump:\n");

View File

@ -42,7 +42,6 @@
#include <ipmitool/ipmi_time.h> #include <ipmitool/ipmi_time.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
@ -141,50 +140,6 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
uint32_t offset, uint32_t length, uint8_t *frubuf); uint32_t offset, uint32_t length, uint8_t *frubuf);
void free_fru_bloc(t_ipmi_fru_bloc *bloc); void free_fru_bloc(t_ipmi_fru_bloc *bloc);
/**
* Caclculate the simple FRU checksum as per IPMI FRU specification.
* Works both for the whole FRU image and for separate areas.
*
* @param[in] area Pointer to the start of checksummed area,
* the area must end with the checksum byte
* @param[in[ len Length of the checksummed area, including
* the trailing checksum byte
* @returns The calculated checksum byte
*/
static
uint8_t fru_calc_checksum(void *area, size_t len)
{
uint8_t checksum = 0;
uint8_t * data = area;
size_t i;
for (i = 0; i < len - 1; i++)
checksum += data[i];
return -checksum;
}
/**
* Check if FRU checksum is valid. Works both on the
* whole FRU image and on separate areas.
*
* @param[in] area Pointer to the start of checksummed area,
* the area must end with the checksum byte
* @param[in[ len Length of the checksummed area, including
* the trailing checksum byte
* @returns The boolean state of checksum validity
* @retval true Checksum is valid
* @retval false Checsum in invalid
*/
static
bool fru_checksum_is_valid(void *area, size_t len)
{
uint8_t * data = area;
/* Checksum is valid when the stored checksum equals calculated */
return data[len - 1] == fru_calc_checksum(area, len);
}
/* get_fru_area_str - Parse FRU area string from raw data /* get_fru_area_str - Parse FRU area string from raw data
* *
* @data: raw FRU data * @data: raw FRU data
@ -1092,12 +1047,6 @@ fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
} }
} }
/* Check area checksum */
printf(" Chassis Area Checksum : %s\n",
fru_checksum_is_valid(fru_data, fru_len)
? "OK"
: "INVALID");
free_n(&fru_data); free_n(&fru_data);
} }
@ -1209,12 +1158,6 @@ fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru,
break; break;
} }
/* Check area checksum */
printf(" Board Area Checksum : %s\n",
fru_checksum_is_valid(fru_data, fru_len)
? "OK"
: "INVALID");
free_n(&fru_data); free_n(&fru_data);
} }
@ -1337,35 +1280,9 @@ fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
break; break;
} }
/* Check area checksum */
printf(" Product Area Checksum : %s\n",
fru_checksum_is_valid(fru_data, fru_len)
? "OK"
: "INVALID");
free_n(&fru_data); free_n(&fru_data);
} }
/**
* Take n bytes from src and convert them into hex doublets in dst
*
* The function is invoked from a place where the dst is known to
* have enough space to accomodate the hex string representation
* of a UUID.
*
* @param[out] dst The destination buffer (at least 33 bytes long)
* @param[in] src The source binary data
* @param[in] n The length of the source data, for compatibility
* with strncpy() on calls from fru_area_print_multirec()
*/
static
char *
uuidstrncpy(char *dst, const char *src, size_t n)
{
(void)ipmi_guid2str(dst, src, GUID_AUTO);
return dst;
}
/* fru_area_print_multirec - Print FRU Multi Record Area /* fru_area_print_multirec - Print FRU Multi Record Area
* *
* @intf: ipmi interface * @intf: ipmi interface
@ -1550,86 +1467,8 @@ fru_area_print_multirec(struct ipmi_intf * intf, struct fru_info * fru,
} }
} }
break; break;
case FRU_RECORD_TYPE_MANAGEMENT_ACCESS:
{
struct fru_multirec_mgmt *mmh =
(struct fru_multirect_mgmt *)
&fru_data[sizeof(struct fru_multirec_header)];
size_t datalen = h->len - sizeof(*mmh);
struct {
unsigned char *name;
size_t minlen;
size_t maxlen;
char * (*convert)(char *, const char *, size_t);
} subtypes[FRU_MULTIREC_MGMT_SUBTYPE_MAX + 1] = {
[FRU_MULTIREC_MGMT_SYSURL] = {
"System Management URL",
FRU_MULTIREC_MGMT_URL_MINLEN,
FRU_MULTIREC_MGMT_URL_MAXLEN,
strncpy
},
[FRU_MULTIREC_MGMT_SYSNAME] = {
"System Name",
FRU_MULTIREC_MGMT_NAME_MINLEN,
FRU_MULTIREC_MGMT_NAME_MAXLEN,
strncpy
},
[FRU_MULTIREC_MGMT_SYSPINGADDR] = {
"System Ping Address",
FRU_MULTIREC_MGMT_PINGADDR_MINLEN,
FRU_MULTIREC_MGMT_PINGADDR_MAXLEN,
strncpy
},
[FRU_MULTIREC_MGMT_CMPURL] = {
"Component Management URL",
FRU_MULTIREC_MGMT_URL_MINLEN,
FRU_MULTIREC_MGMT_URL_MAXLEN,
strncpy
},
[FRU_MULTIREC_MGMT_CMPNAME] = {
"Component Name",
FRU_MULTIREC_MGMT_NAME_MINLEN,
FRU_MULTIREC_MGMT_NAME_MAXLEN,
strncpy
},
[FRU_MULTIREC_MGMT_CMPPINGADDR] = {
"Component Ping Address",
FRU_MULTIREC_MGMT_PINGADDR_MINLEN,
FRU_MULTIREC_MGMT_PINGADDR_MAXLEN,
strncpy
},
[FRU_MULTIREC_MGMT_UUID] = {
"System Unique ID",
FRU_MULTIREC_MGMT_UUID_LEN,
FRU_MULTIREC_MGMT_UUID_LEN,
uuidstrncpy
} }
}; } while (!(h->format & 0x80));
unsigned char string[FRU_MULTIREC_MGMT_DATA_MAXLEN + 1] = { 0 };
if (mmh->subtype < FRU_MULTIREC_MGMT_SUBTYPE_MIN ||
mmh->subtype > FRU_MULTIREC_MGMT_SUBTYPE_MAX)
{
lprintf(LOG_WARN, "Unsupported subtype 0x%02x found for "
"multi-record area management record\n",
mmh->subtype);
break;
}
if (datalen < subtypes[mmh->subtype].minlen ||
datalen > subtypes[mmh->subtype].maxlen)
{
lprintf(LOG_WARN,
"Wrong data length %zu, must be %zu < X < %zu\n",
datalen,
subtypes[mmh->subtype].minlen,
subtypes[mmh->subtype].maxlen);
}
subtypes[mmh->subtype].convert(string, mmh->data, datalen);
printf(" %-22s: %s\n", subtypes[mmh->subtype].name, string);
}
}
} while (!(h->format & FRU_RECORD_FORMAT_EOL_MASK));
lprintf(LOG_DEBUG ,"Multi-Record area ends at: %i (%xh)", last_off, last_off); lprintf(LOG_DEBUG ,"Multi-Record area ends at: %i (%xh)", last_off, last_off);

View File

@ -61,7 +61,7 @@ static struct lan_param {
int cmd; int cmd;
int size; int size;
char desc[24]; char desc[24];
uint8_t *data; uint8_t * data;
int data_len; int data_len;
} ipmi_lan_params[] = { } ipmi_lan_params[] = {
{ IPMI_LANP_SET_IN_PROGRESS, 1, "Set in Progress", NULL, 0 }, { IPMI_LANP_SET_IN_PROGRESS, 1, "Set in Progress", NULL, 0 },
@ -100,19 +100,6 @@ static struct lan_param {
{ -1, -1, "", NULL, -1 } { -1, -1, "", NULL, -1 }
}; };
static const struct valstr set_lan_cc_vals[] = {
{ 0x80, "Unsupported parameter" },
{ 0x81, "Attempt to set 'in progress' while not in 'complete' state" },
{ 0x82, "Parameter is read-only" },
{ 0x83, "Parameter is wrote-only" },
{ 0x00, NULL }
};
static const struct valstr get_lan_cc_vals[] = {
{ 0x80, "Unsupported parameter" },
{ 0x00, NULL }
};
static void print_lan_alert_print_usage(void); static void print_lan_alert_print_usage(void);
static void print_lan_alert_set_usage(void); static void print_lan_alert_set_usage(void);
static void print_lan_set_usage(void); static void print_lan_set_usage(void);
@ -136,7 +123,7 @@ static void print_lan_usage(void);
* @chan: channel number to check * @chan: channel number to check
*/ */
static int static int
is_lan_channel(struct ipmi_intf *intf, uint8_t chan) is_lan_channel(struct ipmi_intf * intf, uint8_t chan)
{ {
uint8_t medium; uint8_t medium;
@ -161,7 +148,7 @@ is_lan_channel(struct ipmi_intf *intf, uint8_t chan)
* @start: channel number to start searching from * @start: channel number to start searching from
*/ */
uint8_t uint8_t
find_lan_channel(struct ipmi_intf *intf, uint8_t start) find_lan_channel(struct ipmi_intf * intf, uint8_t start)
{ {
uint8_t chan = 0; uint8_t chan = 0;
@ -187,11 +174,10 @@ find_lan_channel(struct ipmi_intf *intf, uint8_t start)
* @select: lan parameter set selector * @select: lan parameter set selector
*/ */
static struct lan_param * static struct lan_param *
get_lan_param_select(struct ipmi_intf *intf, uint8_t chan, int param, int select) get_lan_param_select(struct ipmi_intf * intf, uint8_t chan, int param, int select)
{ {
struct lan_param *p = NULL; struct lan_param * p = NULL;
struct lan_param *rc = NULL; struct ipmi_rs * rsp;
struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
int i = 0; int i = 0;
uint8_t msg_data[4]; uint8_t msg_data[4];
@ -205,7 +191,7 @@ get_lan_param_select(struct ipmi_intf *intf, uint8_t chan, int param, int select
if (!p) { if (!p) {
lprintf(LOG_INFO, "Get LAN Parameter failed: Unknown parameter."); lprintf(LOG_INFO, "Get LAN Parameter failed: Unknown parameter.");
return rc; return NULL;
} }
msg_data[0] = chan; msg_data[0] = chan;
@ -222,7 +208,7 @@ get_lan_param_select(struct ipmi_intf *intf, uint8_t chan, int param, int select
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (!rsp) {
lprintf(LOG_INFO, "Get LAN Parameter '%s' command failed", p->desc); lprintf(LOG_INFO, "Get LAN Parameter '%s' command failed", p->desc);
return rc; return NULL;
} }
switch (rsp->ccode) switch (rsp->ccode)
@ -233,18 +219,19 @@ get_lan_param_select(struct ipmi_intf *intf, uint8_t chan, int param, int select
case 0x80: /* parameter not supported */ case 0x80: /* parameter not supported */
case 0xc9: /* parameter out of range */ case 0xc9: /* parameter out of range */
case 0xcc: /* invalid data field in request */ case 0xcc: /* invalid data field in request */
/* We treat them as valid but empty response */
/* these completion codes usually mean parameter not supported */
lprintf(LOG_INFO, "Get LAN Parameter '%s' command failed: %s",
p->desc, val2str(rsp->ccode, completion_code_vals));
p->data = NULL; p->data = NULL;
p->data_len = 0; p->data_len = 0;
rc = p; return p;
/* fall through */
default: default:
/* other completion codes are treated as error */ /* other completion codes are treated as error */
lprintf(LOG_INFO, "Get LAN Parameter '%s' command failed: %s", lprintf(LOG_INFO, "Get LAN Parameter '%s' command failed: %s",
p->desc, p->desc, val2str(rsp->ccode, completion_code_vals));
specific_val2str(rsp->ccode,
get_lan_cc_vals,
completion_code_vals));
return NULL; return NULL;
} }
@ -267,7 +254,7 @@ get_lan_param_select(struct ipmi_intf *intf, uint8_t chan, int param, int select
* @param: lan parameter id * @param: lan parameter id
*/ */
static struct lan_param * static struct lan_param *
get_lan_param(struct ipmi_intf *intf, uint8_t chan, int param) get_lan_param(struct ipmi_intf * intf, uint8_t chan, int param)
{ {
return get_lan_param_select(intf, chan, param, 0); return get_lan_param_select(intf, chan, param, 0);
} }
@ -288,10 +275,10 @@ get_lan_param(struct ipmi_intf *intf, uint8_t chan, int param)
* @len: length of lan parameter data * @len: length of lan parameter data
*/ */
static int static int
set_lan_param_wait(struct ipmi_intf *intf, uint8_t chan, set_lan_param_wait(struct ipmi_intf * intf, uint8_t chan,
int param, uint8_t *data, int len) int param, uint8_t * data, int len)
{ {
struct lan_param *p; struct lan_param * p;
int retry = 10; /* 10 retries */ int retry = 10; /* 10 retries */
lprintf(LOG_DEBUG, "Waiting for Set LAN Parameter to complete..."); lprintf(LOG_DEBUG, "Waiting for Set LAN Parameter to complete...");
@ -347,10 +334,10 @@ set_lan_param_wait(struct ipmi_intf *intf, uint8_t chan,
* @wait: whether to wait for write completion * @wait: whether to wait for write completion
*/ */
static int static int
__set_lan_param(struct ipmi_intf *intf, uint8_t chan, __set_lan_param(struct ipmi_intf * intf, uint8_t chan,
int param, uint8_t *data, int len, int wait) int param, uint8_t * data, int len, int wait)
{ {
struct ipmi_rs *rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
uint8_t msg_data[32]; uint8_t msg_data[32];
@ -374,9 +361,7 @@ __set_lan_param(struct ipmi_intf *intf, uint8_t chan,
} }
if (rsp->ccode && wait) { if (rsp->ccode && wait) {
lprintf(LOG_DEBUG, "Warning: Set LAN Parameter failed: %s", lprintf(LOG_DEBUG, "Warning: Set LAN Parameter failed: %s",
specific_val2str(rsp->ccode, val2str(rsp->ccode, completion_code_vals));
set_lan_cc_vals,
completion_code_vals));
if (rsp->ccode == 0xcc) { if (rsp->ccode == 0xcc) {
/* retry hack for invalid data field ccode */ /* retry hack for invalid data field ccode */
int retry = 10; /* 10 retries */ int retry = 10; /* 10 retries */
@ -414,9 +399,9 @@ __set_lan_param(struct ipmi_intf *intf, uint8_t chan,
* @chan: ipmi channel * @chan: ipmi channel
*/ */
static int static int
ipmi_lanp_lock_state(struct ipmi_intf *intf, uint8_t chan) ipmi_lanp_lock_state(struct ipmi_intf * intf, uint8_t chan)
{ {
struct lan_param *p; struct lan_param * p;
p = get_lan_param(intf, chan, IPMI_LANP_SET_IN_PROGRESS); p = get_lan_param(intf, chan, IPMI_LANP_SET_IN_PROGRESS);
if (!p) if (!p)
return -1; return -1;
@ -437,7 +422,7 @@ ipmi_lanp_lock_state(struct ipmi_intf *intf, uint8_t chan)
* @chan: ipmi channel * @chan: ipmi channel
*/ */
static void static void
ipmi_lanp_lock(struct ipmi_intf *intf, uint8_t chan) ipmi_lanp_lock(struct ipmi_intf * intf, uint8_t chan)
{ {
uint8_t val = IPMI_LANP_WRITE_LOCK; uint8_t val = IPMI_LANP_WRITE_LOCK;
int retry = 3; int retry = 3;
@ -467,7 +452,7 @@ ipmi_lanp_lock(struct ipmi_intf *intf, uint8_t chan)
* @chan: ipmi channel * @chan: ipmi channel
*/ */
static void static void
ipmi_lanp_unlock(struct ipmi_intf *intf, uint8_t chan) ipmi_lanp_unlock(struct ipmi_intf * intf, uint8_t chan)
{ {
uint8_t val = IPMI_LANP_WRITE_COMMIT; uint8_t val = IPMI_LANP_WRITE_COMMIT;
int rc; int rc;
@ -492,8 +477,8 @@ ipmi_lanp_unlock(struct ipmi_intf *intf, uint8_t chan)
* @len: length of lan parameter data * @len: length of lan parameter data
*/ */
static int static int
set_lan_param(struct ipmi_intf *intf, uint8_t chan, set_lan_param(struct ipmi_intf * intf, uint8_t chan,
int param, uint8_t *data, int len) int param, uint8_t * data, int len)
{ {
int rc; int rc;
ipmi_lanp_lock(intf, chan); ipmi_lanp_lock(intf, chan);
@ -513,8 +498,8 @@ set_lan_param(struct ipmi_intf *intf, uint8_t chan,
* @len: length of lan parameter data * @len: length of lan parameter data
*/ */
static int static int
set_lan_param_nowait(struct ipmi_intf *intf, uint8_t chan, set_lan_param_nowait(struct ipmi_intf * intf, uint8_t chan,
int param, uint8_t *data, int len) int param, uint8_t * data, int len)
{ {
int rc; int rc;
ipmi_lanp_lock(intf, chan); ipmi_lanp_lock(intf, chan);
@ -524,7 +509,7 @@ set_lan_param_nowait(struct ipmi_intf *intf, uint8_t chan,
} }
static int static int
lan_set_arp_interval(struct ipmi_intf *intf, uint8_t chan, uint8_t ival) lan_set_arp_interval(struct ipmi_intf * intf, uint8_t chan, uint8_t ival)
{ {
struct lan_param *lp; struct lan_param *lp;
uint8_t interval = 0; uint8_t interval = 0;
@ -554,7 +539,7 @@ lan_set_arp_interval(struct ipmi_intf *intf, uint8_t chan, uint8_t ival)
} }
static int static int
lan_set_arp_generate(struct ipmi_intf *intf, lan_set_arp_generate(struct ipmi_intf * intf,
uint8_t chan, uint8_t ctl) uint8_t chan, uint8_t ctl)
{ {
struct lan_param *lp; struct lan_param *lp;
@ -578,7 +563,7 @@ lan_set_arp_generate(struct ipmi_intf *intf,
} }
static int static int
lan_set_arp_respond(struct ipmi_intf *intf, lan_set_arp_respond(struct ipmi_intf * intf,
uint8_t chan, uint8_t ctl) uint8_t chan, uint8_t ctl)
{ {
struct lan_param *lp; struct lan_param *lp;
@ -630,9 +615,9 @@ static char priv_level_to_char(unsigned char priv_level)
static int static int
ipmi_lan_print(struct ipmi_intf *intf, uint8_t chan) ipmi_lan_print(struct ipmi_intf * intf, uint8_t chan)
{ {
struct lan_param *p; struct lan_param * p;
if (chan < 1 || chan > IPMI_CHANNEL_NUMBER_MAX) { if (chan < 1 || chan > IPMI_CHANNEL_NUMBER_MAX) {
lprintf(LOG_ERR, "Invalid Channel %d", chan); lprintf(LOG_ERR, "Invalid Channel %d", chan);
@ -918,12 +903,12 @@ ipmi_lan_print(struct ipmi_intf *intf, uint8_t chan)
/* Configure Authentication Types */ /* Configure Authentication Types */
/* TODO - probably some code duplication going on ??? */ /* TODO - probably some code duplication going on ??? */
static int static int
ipmi_lan_set_auth(struct ipmi_intf *intf, uint8_t chan, char *level, char *types) ipmi_lan_set_auth(struct ipmi_intf * intf, uint8_t chan, char * level, char * types)
{ {
uint8_t data[5]; uint8_t data[5];
uint8_t authtype = 0; uint8_t authtype = 0;
char *p; char * p;
struct lan_param *lp; struct lan_param * lp;
if (!level || !types) if (!level || !types)
return -1; return -1;
@ -1026,10 +1011,10 @@ ipmi_set_alert_enable(struct ipmi_intf *intf, uint8_t channel, uint8_t enable)
channel); channel);
return (-1); return (-1);
} }
if (enable) { if (enable != 0) {
channel_access.alerting = ALERTING_ENABLED; channel_access.alerting = 1;
} else { } else {
channel_access.alerting = ALERTING_DISABLED; channel_access.alerting = 0;
} }
/* non-volatile */ /* non-volatile */
ccode = _ipmi_set_channel_access(intf, channel_access, 1, 0); ccode = _ipmi_set_channel_access(intf, channel_access, 1, 0);
@ -1159,7 +1144,7 @@ ipmi_set_user_access(struct ipmi_intf *intf, uint8_t channel, uint8_t user_id)
static int static int
get_cmdline_cipher_suite_priv_data(char *arg, uint8_t *buf) get_cmdline_cipher_suite_priv_data(char * arg, uint8_t * buf)
{ {
int i, ret = 0; int i, ret = 0;
@ -1236,7 +1221,7 @@ get_cmdline_cipher_suite_priv_data(char *arg, uint8_t *buf)
static int static int
get_cmdline_ipaddr(char *arg, uint8_t *buf) get_cmdline_ipaddr(char * arg, uint8_t * buf)
{ {
uint32_t ip1, ip2, ip3, ip4; uint32_t ip1, ip2, ip3, ip4;
if (sscanf(arg, if (sscanf(arg,
@ -1388,7 +1373,7 @@ get_cmdline_bad_pass_thresh(char *argv[], uint8_t *buf)
} }
static int static int
ipmi_lan_set(struct ipmi_intf *intf, int argc, char **argv) ipmi_lan_set(struct ipmi_intf * intf, int argc, char ** argv)
{ {
uint8_t data[32]; uint8_t data[32];
uint8_t chan; uint8_t chan;
@ -1744,9 +1729,9 @@ ipmi_lan_set(struct ipmi_intf *intf, int argc, char **argv)
static int static int
is_alert_destination(struct ipmi_intf *intf, uint8_t channel, uint8_t alert) is_alert_destination(struct ipmi_intf * intf, uint8_t channel, uint8_t alert)
{ {
struct lan_param *p; struct lan_param * p;
p = get_lan_param(intf, channel, IPMI_LANP_NUM_DEST); p = get_lan_param(intf, channel, IPMI_LANP_NUM_DEST);
if (!p) if (!p)
@ -1761,7 +1746,7 @@ is_alert_destination(struct ipmi_intf *intf, uint8_t channel, uint8_t alert)
} }
static int static int
ipmi_lan_alert_print(struct ipmi_intf *intf, uint8_t channel, uint8_t alert) ipmi_lan_alert_print(struct ipmi_intf * intf, uint8_t channel, uint8_t alert)
{ {
# define PTYPE_LEN 4 # define PTYPE_LEN 4
# define PADDR_LEN 13 # define PADDR_LEN 13
@ -1835,10 +1820,10 @@ ipmi_lan_alert_print(struct ipmi_intf *intf, uint8_t channel, uint8_t alert)
} }
static int static int
ipmi_lan_alert_print_all(struct ipmi_intf *intf, uint8_t channel) ipmi_lan_alert_print_all(struct ipmi_intf * intf, uint8_t channel)
{ {
int j, ndest; int j, ndest;
struct lan_param *p; struct lan_param * p;
p = get_lan_param(intf, channel, IPMI_LANP_NUM_DEST); p = get_lan_param(intf, channel, IPMI_LANP_NUM_DEST);
if (!p) if (!p)
@ -1855,10 +1840,10 @@ ipmi_lan_alert_print_all(struct ipmi_intf *intf, uint8_t channel)
} }
static int static int
ipmi_lan_alert_set(struct ipmi_intf *intf, uint8_t chan, uint8_t alert, ipmi_lan_alert_set(struct ipmi_intf * intf, uint8_t chan, uint8_t alert,
int argc, char **argv) int argc, char ** argv)
{ {
struct lan_param *p; struct lan_param * p;
uint8_t data[32], temp[32]; uint8_t data[32], temp[32];
int rc = 0; int rc = 0;
@ -2028,7 +2013,7 @@ ipmi_lan_alert_set(struct ipmi_intf *intf, uint8_t chan, uint8_t alert,
} }
static int static int
ipmi_lan_alert(struct ipmi_intf *intf, int argc, char **argv) ipmi_lan_alert(struct ipmi_intf * intf, int argc, char ** argv)
{ {
uint8_t alert; uint8_t alert;
uint8_t channel = 1; uint8_t channel = 1;
@ -2120,10 +2105,10 @@ ipmi_lan_alert(struct ipmi_intf *intf, int argc, char **argv)
static int static int
ipmi_lan_stats_get(struct ipmi_intf *intf, uint8_t chan) ipmi_lan_stats_get(struct ipmi_intf * intf, uint8_t chan)
{ {
int rc = 0; int rc = 0;
struct ipmi_rs *rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
uint8_t msg_data[2]; uint8_t msg_data[2];
uint16_t statsTemp; uint16_t statsTemp;
@ -2152,9 +2137,7 @@ ipmi_lan_stats_get(struct ipmi_intf *intf, uint8_t chan)
if (rsp->ccode) { if (rsp->ccode) {
lprintf(LOG_ERR, "Get LAN Stats command failed: %s", lprintf(LOG_ERR, "Get LAN Stats command failed: %s",
specific_val2str(rsp->ccode, val2str(rsp->ccode, completion_code_vals));
get_lan_cc_vals,
completion_code_vals));
return (-1); return (-1);
} }
@ -2200,10 +2183,10 @@ ipmi_lan_stats_get(struct ipmi_intf *intf, uint8_t chan)
static int static int
ipmi_lan_stats_clear(struct ipmi_intf *intf, uint8_t chan) ipmi_lan_stats_clear(struct ipmi_intf * intf, uint8_t chan)
{ {
int rc = 0; int rc = 0;
struct ipmi_rs *rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
uint8_t msg_data[2]; uint8_t msg_data[2];
@ -2230,9 +2213,7 @@ ipmi_lan_stats_clear(struct ipmi_intf *intf, uint8_t chan)
if (rsp->ccode) { if (rsp->ccode) {
lprintf(LOG_INFO, "Get LAN Stats command failed: %s", lprintf(LOG_INFO, "Get LAN Stats command failed: %s",
specific_val2str(rsp->ccode, val2str(rsp->ccode, completion_code_vals));
get_lan_cc_vals,
completion_code_vals));
return (-1); return (-1);
} }
@ -2492,7 +2473,7 @@ print_lan_usage(void)
int int
ipmi_lanp_main(struct ipmi_intf *intf, int argc, char **argv) ipmi_lanp_main(struct ipmi_intf * intf, int argc, char ** argv)
{ {
int rc = 0; int rc = 0;
uint8_t chan = 0; uint8_t chan = 0;

View File

@ -853,7 +853,10 @@ ipmi_main(int argc, char ** argv,
} }
/* load the IANA PEN registry */ /* load the IANA PEN registry */
ipmi_oem_info_init(); if (ipmi_oem_info_init()) {
lprintf(LOG_ERR, "Failed to initialize the OEM info dictionary");
goto out_free;
}
/* run OEM setup if found */ /* run OEM setup if found */
if (oemtype && if (oemtype &&

View File

@ -696,27 +696,6 @@ out:
return parsed_guid; return parsed_guid;
} }
parsed_guid_t
ipmi_guid2str(char *str, const void *data, ipmi_guid_mode_t mode)
{
parsed_guid_t guid;
guid = ipmi_parse_guid(data, mode);
if (GUID_DUMP == guid.mode) {
sprintf(str, "%s", buf2str(data, sizeof(ipmi_guid_t)));
return guid;
}
sprintf(str, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
(int)guid.time_low,
(int)guid.time_mid,
(int)guid.time_hi_and_version,
(int)guid.clock_seq_and_rsvd,
(int)guid.node[0], (int)guid.node[1], (int)guid.node[2],
(int)guid.node[3], (int)guid.node[4], (int)guid.node[5]);
return guid;
}
/* ipmi_mc_print_guid - print-out given BMC GUID /* ipmi_mc_print_guid - print-out given BMC GUID
* *
* @param[in] intf - The IPMI interface to request GUID from * @param[in] intf - The IPMI interface to request GUID from
@ -761,11 +740,24 @@ ipmi_mc_print_guid(struct ipmi_intf *intf, ipmi_guid_mode_t guid_mode)
printf("System GUID : "); printf("System GUID : ");
char buf[GUID_STR_MAXLEN + 1]; guid = ipmi_parse_guid(guid_data, guid_mode);
guid = ipmi_guid2str(buf, guid_data, guid_mode); if (GUID_DUMP == guid.mode) {
printf("%s\n", buf); size_t i;
for (i = 0; i < sizeof(guid_data); ++i) {
printf("%02X", guid_data[i]);
}
printf("\n");
return 0;
}
printf("%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x\n",
(int)guid.time_low,
(int)guid.time_mid,
(int)guid.time_hi_and_version,
guid.clock_seq_and_rsvd,
guid.node[0], guid.node[1], guid.node[2],
guid.node[3], guid.node[4], guid.node[5]);
/* Print the GUID properties */
if (GUID_AUTO == guid_mode) { if (GUID_AUTO == guid_mode) {
/* ipmi_parse_guid() returns only valid modes in guid.ver */ /* ipmi_parse_guid() returns only valid modes in guid.ver */
printf("GUID Encoding : %s", guid_mode_str[guid.mode]); printf("GUID Encoding : %s", guid_mode_str[guid.mode]);

View File

@ -258,7 +258,7 @@ ipmi_sdr_get_unit_string(bool pct, uint8_t relation,
} }
if (modifier <= UNIT_TYPE_MAX) { if (modifier <= UNIT_TYPE_MAX) {
modstr = unit_desc[modifier]; modstr = unit_desc[base];
} }
else { else {
modstr = "invalid"; modstr = "invalid";

View File

@ -1955,20 +1955,8 @@ ipmi_sel_print_std_entry(struct ipmi_intf * intf, struct sel_event_record * evt)
(trigger_reading==(int)trigger_reading) ? 0 : 2, (trigger_reading==(int)trigger_reading) ? 0 : 2,
trigger_reading); trigger_reading);
if (threshold_reading_provided) { if (threshold_reading_provided) {
/* According to Table 29-6, Event Data byte 1 contains,
* among other info, the offset from the Threshold type
* code. According to Table 42-2, all even offsets
* are 'going low', and all odd offsets are 'going high'
*/
bool going_high =
(evt->sel_type.standard_type.event_data[0]
& EVENT_OFFSET_MASK) % 2;
if (evt->sel_type.standard_type.event_dir) {
/* Event is de-asserted so the inequality is reversed */
going_high = !going_high;
}
printf(" %s Threshold %.*f %s", printf(" %s Threshold %.*f %s",
going_high ? ">" : "<", ((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
(threshold_reading==(int)threshold_reading) ? 0 : 2, (threshold_reading==(int)threshold_reading) ? 0 : 2,
threshold_reading, threshold_reading,
ipmi_sdr_get_unit_string(sdr->record.common->unit.pct, ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
@ -2285,6 +2273,21 @@ __ipmi_sel_savelist_entries(struct ipmi_intf * intf, int count, const char * sav
return 0; return 0;
} }
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_STORAGE;
req.msg.cmd = IPMI_CMD_RESERVE_SEL;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
lprintf(LOG_ERR, "Reserve SEL command failed");
return -1;
}
if (rsp->ccode) {
lprintf(LOG_ERR, "Reserve SEL command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (count < 0) { if (count < 0) {
/** Show only the most recent 'count' records. */ /** Show only the most recent 'count' records. */
int i; int i;
@ -2920,6 +2923,11 @@ ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv)
return (-1); return (-1);
} }
if (ipmi_sel_reserve(intf) == 0) {
lprintf(LOG_ERR, "Unable to reserve SEL");
return (-1);
}
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (str2ushort(argv[i], &id) != 0) { if (str2ushort(argv[i], &id) != 0) {
lprintf(LOG_ERR, "Given SEL ID '%s' is invalid.", lprintf(LOG_ERR, "Given SEL ID '%s' is invalid.",

View File

@ -928,9 +928,8 @@ const struct oemvalstr ipmi_oem_product_info[] = {
{ IPMI_OEM_SUPERMICRO, 0xF580, "X8ST3" }, { IPMI_OEM_SUPERMICRO, 0xF580, "X8ST3" },
/* YADRO */ /* YADRO */
{ IPMI_OEM_YADRO, 0x0001, "VESNIN BMC" }, { IPMI_OEM_YADRO, 0x0001, "VESNIN BMC" },
{ IPMI_OEM_YADRO, 0x000A, "TATLIN.UNIFIED Storage Controller BMC" }, { IPMI_OEM_YADRO, 0x000A, "TATLIN Storage Controller BMC" },
{ IPMI_OEM_YADRO, 0x0014, "VEGMAN Series BMC" }, { IPMI_OEM_YADRO, 0x0014, "VEGMAN BMC" },
{ IPMI_OEM_YADRO, 0x0015, "TATLIN.ARCHIVE/xS BMC" },
{ 0xffffff , 0xffff , NULL }, { 0xffffff , 0xffff , NULL },
}; };
@ -1265,25 +1264,6 @@ const struct valstr ipmi_chassis_power_control_vals[] = {
{ 0x00, NULL }, { 0x00, NULL },
}; };
/*
* See Table 28-11, Get System Restart Cause Command
*/
const struct valstr ipmi_chassis_restart_cause_vals[] = {
{ 0x0, "unknown" },
{ 0x1, "chassis power control command" },
{ 0x2, "reset via pushbutton" },
{ 0x3, "power-up via pushbutton" },
{ 0x4, "watchdog expired" },
{ 0x5, "OEM" },
{ 0x6, "power-up due to always-restore power policy" },
{ 0x7, "power-up due to restore-previous power policy" },
{ 0x8, "reset via PEF" },
{ 0x9, "power-cycle via PEF" },
{ 0xa, "soft reset" },
{ 0xb, "power-up via RTC wakeup" },
{ 0xFF, NULL },
};
const struct valstr ipmi_auth_algorithms[] = { const struct valstr ipmi_auth_algorithms[] = {
{ IPMI_AUTH_RAKP_NONE, "none" }, { IPMI_AUTH_RAKP_NONE, "none" },
{ IPMI_AUTH_RAKP_HMAC_SHA1, "hmac_sha1" }, { IPMI_AUTH_RAKP_HMAC_SHA1, "hmac_sha1" },
@ -1719,30 +1699,39 @@ out:
return rc; return rc;
} }
void ipmi_oem_info_init() int ipmi_oem_info_init()
{ {
oem_valstr_list_t terminator = { { -1, NULL}, NULL }; /* Terminator */ oem_valstr_list_t terminator = { { -1, NULL}, NULL }; /* Terminator */
oem_valstr_list_t *oemlist = &terminator; oem_valstr_list_t *oemlist = &terminator;
bool free_strings = true; bool free_strings = true;
int count; size_t count;
int rc = -4;
lprintf(LOG_INFO, "Loading IANA PEN Registry..."); lprintf(LOG_INFO, "Loading IANA PEN Registry...");
if (ipmi_oem_info) { if (ipmi_oem_info) {
lprintf(LOG_INFO, "IANA PEN Registry is already loaded"); lprintf(LOG_INFO, "IANA PEN Registry is already loaded");
rc = 0;
goto out; goto out;
} }
if ((count = oem_info_list_load(&oemlist)) < 1) { if (!(count = oem_info_list_load(&oemlist))) {
lprintf(LOG_WARN, "Failed to load entries from IANA PEN Registry"); /*
count = 0; * We can't identify OEMs without a loaded registry.
* Set the pointer to dummy and return.
*/
ipmi_oem_info = ipmi_oem_info_dummy;
goto out;
} }
/* In the array was allocated, don't free the strings at cleanup */ /* In the array was allocated, don't free the strings at cleanup */
free_strings = !oem_info_init_from_list(oemlist, count); free_strings = !oem_info_init_from_list(oemlist, count);
rc = IPMI_CC_OK;
out: out:
oem_info_list_free(&oemlist, free_strings); oem_info_list_free(&oemlist, free_strings);
return rc;
} }
void ipmi_oem_info_free() void ipmi_oem_info_free()

View File

@ -54,8 +54,8 @@
# include <paths.h> # include <paths.h>
#endif #endif
#ifndef _PATH_RUN #ifndef _PATH_VARRUN
# define _PATH_RUN "/run/" # define _PATH_VARRUN "/var/run/"
#endif #endif
#ifdef IPMI_INTF_OPEN #ifdef IPMI_INTF_OPEN
@ -82,7 +82,7 @@
#include <ipmitool/ipmi_main.h> #include <ipmitool/ipmi_main.h>
#define WARNING_THRESHOLD 80 #define WARNING_THRESHOLD 80
#define DEFAULT_PIDFILE _PATH_RUN "ipmievd.pid" #define DEFAULT_PIDFILE _PATH_VARRUN "ipmievd.pid"
char pidfile[64]; char pidfile[64];
/* global variables */ /* global variables */
@ -422,7 +422,7 @@ static int
openipmi_read(struct ipmi_event_intf * eintf) openipmi_read(struct ipmi_event_intf * eintf)
{ {
struct ipmi_addr addr; struct ipmi_addr addr;
struct ipmi_recv recv = {}; struct ipmi_recv recv;
uint8_t data[80]; uint8_t data[80];
int rv; int rv;

View File

@ -502,14 +502,13 @@ uint16_t
ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf) ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf)
{ {
int16_t size; int16_t size;
uint8_t bridging_level = ipmi_intf_get_bridging_level(intf);
size = intf->max_request_data_size; size = intf->max_request_data_size;
/* check if request size is not specified */ /* check if request size is not specified */
if (!size) { if (!size) {
/* /*
* The IPMB standard overall message length for non-bridging * The IPMB standard overall message length for <EFBFBD>non -bridging<EFBFBD>
* messages is specified as 32 bytes, maximum, including slave * messages is specified as 32 bytes, maximum, including slave
* address. This sets the upper limit for typical IPMI messages. * address. This sets the upper limit for typical IPMI messages.
* With the exception of messages used for bridging messages to * With the exception of messages used for bridging messages to
@ -522,14 +521,14 @@ ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf)
size = IPMI_DEFAULT_PAYLOAD_SIZE; size = IPMI_DEFAULT_PAYLOAD_SIZE;
/* check if message is forwarded */ /* check if message is forwarded */
if (bridging_level) { if (intf->target_addr && intf->target_addr != intf->my_addr) {
/* add Send Message request size */ /* add Send Message request size */
size += 8; size += 8;
} }
} }
/* check if message is forwarded */ /* check if message is forwarded */
if (bridging_level) { if (intf->target_addr && intf->target_addr != intf->my_addr) {
/* subtract send message request size */ /* subtract send message request size */
size -= 8; size -= 8;
@ -542,7 +541,7 @@ ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf)
} }
/* check for double bridging */ /* check for double bridging */
if (bridging_level == 2) { if (intf->transit_addr && intf->transit_addr != intf->target_addr) {
/* subtract inner send message request size */ /* subtract inner send message request size */
size -= 8; size -= 8;
} }
@ -560,14 +559,13 @@ uint16_t
ipmi_intf_get_max_response_data_size(struct ipmi_intf * intf) ipmi_intf_get_max_response_data_size(struct ipmi_intf * intf)
{ {
int16_t size; int16_t size;
uint8_t bridging_level = ipmi_intf_get_bridging_level(intf);
size = intf->max_response_data_size; size = intf->max_response_data_size;
/* check if response size is not specified */ /* check if response size is not specified */
if (!size) { if (!size) {
/* /*
* The IPMB standard overall message length for non-bridging * The IPMB standard overall message length for <EFBFBD>non -bridging<EFBFBD>
* messages is specified as 32 bytes, maximum, including slave * messages is specified as 32 bytes, maximum, including slave
* address. This sets the upper limit for typical IPMI messages. * address. This sets the upper limit for typical IPMI messages.
* With the exception of messages used for bridging messages to * With the exception of messages used for bridging messages to
@ -580,14 +578,14 @@ ipmi_intf_get_max_response_data_size(struct ipmi_intf * intf)
size = IPMI_DEFAULT_PAYLOAD_SIZE; /* response length with subtracted header and checksum byte */ size = IPMI_DEFAULT_PAYLOAD_SIZE; /* response length with subtracted header and checksum byte */
/* check if message is forwarded */ /* check if message is forwarded */
if (bridging_level) { if (intf->target_addr && intf->target_addr != intf->my_addr) {
/* add Send Message header size */ /* add Send Message header size */
size += 7; size += 7;
} }
} }
/* check if message is forwarded */ /* check if message is forwarded */
if (bridging_level) { if (intf->target_addr && intf->target_addr != intf->my_addr) {
/* /*
* Some IPMI controllers like PICMG AMC Carriers embed responses * Some IPMI controllers like PICMG AMC Carriers embed responses
* to the forwarded messages into the Send Message response. * to the forwarded messages into the Send Message response.
@ -605,7 +603,7 @@ ipmi_intf_get_max_response_data_size(struct ipmi_intf * intf)
} }
/* check for double bridging */ /* check for double bridging */
if (bridging_level == 2) { if (intf->transit_addr && intf->transit_addr != intf->target_addr) {
/* subtract inner send message header size */ /* subtract inner send message header size */
size -= 8; size -= 8;
} }
@ -619,25 +617,6 @@ ipmi_intf_get_max_response_data_size(struct ipmi_intf * intf)
return size; return size;
} }
uint8_t
ipmi_intf_get_bridging_level(const struct ipmi_intf *intf)
{
uint8_t bridging_level;
if (intf->target_addr && (intf->target_addr != intf->my_addr)) {
if (intf->transit_addr &&
(intf->transit_addr != intf->target_addr || intf->transit_channel != intf->target_channel)) {
bridging_level = 2;
} else {
bridging_level = 1;
}
} else {
bridging_level = 0;
}
return bridging_level;
}
void void
ipmi_intf_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size) ipmi_intf_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size)
{ {

View File

@ -1727,7 +1727,6 @@ ipmi_lanplus_build_v2x_msg(
*/ */
if (session->v2_data.session_state == LANPLUS_STATE_ACTIVE) if (session->v2_data.session_state == LANPLUS_STATE_ACTIVE)
{ {
uint16_t old_payload_length = payload->payload_length;
/* Payload len is adjusted as necessary by lanplus_encrypt_payload */ /* Payload len is adjusted as necessary by lanplus_encrypt_payload */
lanplus_encrypt_payload(session->v2_data.crypt_alg, /* input */ lanplus_encrypt_payload(session->v2_data.crypt_alg, /* input */
session->v2_data.k2, /* input */ session->v2_data.k2, /* input */
@ -1736,24 +1735,6 @@ ipmi_lanplus_build_v2x_msg(
msg + IPMI_LANPLUS_OFFSET_PAYLOAD, /* output */ msg + IPMI_LANPLUS_OFFSET_PAYLOAD, /* output */
&(payload->payload_length)); /* output */ &(payload->payload_length)); /* output */
if (old_payload_length != payload->payload_length)
{
len =
IPMI_LANPLUS_OFFSET_PAYLOAD +
payload->payload_length +
IPMI_MAX_INTEGRITY_PAD_SIZE +
IPMI_LANPLUS_PAD_LENGTH_SIZE +
IPMI_LANPLUS_NEXT_HEADER_SIZE +
IPMI_MAX_AUTH_CODE_SIZE;
uint8_t * new_msg = realloc(msg, len);
if (!new_msg) {
free(msg);
lprintf(LOG_ERR, "ipmitool: realloc failure");
return;
}
msg = new_msg;
}
} }
/* Now we know the payload length */ /* Now we know the payload length */

View File

@ -86,8 +86,6 @@
#define IPMI_LANPLUS_OFFSET_PAYLOAD_SIZE 0x0E #define IPMI_LANPLUS_OFFSET_PAYLOAD_SIZE 0x0E
#define IPMI_LANPLUS_OFFSET_PAYLOAD 0x10 #define IPMI_LANPLUS_OFFSET_PAYLOAD 0x10
#define IPMI_LANPLUS_PAD_LENGTH_SIZE 1
#define IPMI_LANPLUS_NEXT_HEADER_SIZE 1
#define IPMI_GET_CHANNEL_AUTH_CAP 0x38 #define IPMI_GET_CHANNEL_AUTH_CAP 0x38

View File

@ -170,7 +170,7 @@ static
struct ipmi_rs * struct ipmi_rs *
ipmi_openipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req) ipmi_openipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
{ {
struct ipmi_recv recv = {}; struct ipmi_recv recv;
struct ipmi_addr addr; struct ipmi_addr addr;
struct ipmi_system_interface_addr bmc_addr = { struct ipmi_system_interface_addr bmc_addr = {
.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE, .addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE,

View File

@ -612,7 +612,18 @@ serial_bm_build_msg(const struct ipmi_intf * intf,
uint8_t * data = msg, seq; uint8_t * data = msg, seq;
struct ipmb_msg_hdr * hdr = (struct ipmb_msg_hdr *) msg; struct ipmb_msg_hdr * hdr = (struct ipmb_msg_hdr *) msg;
struct ipmi_send_message_rq * inner_rq = NULL, * outer_rq = NULL; struct ipmi_send_message_rq * inner_rq = NULL, * outer_rq = NULL;
int bridging_level = ipmi_intf_get_bridging_level(intf); int bridging_level;
/* acquire bridging level */
if (intf->target_addr && intf->target_addr != intf->my_addr) {
if (intf->transit_addr != 0) {
bridging_level = 2;
} else {
bridging_level = 1;
}
} else {
bridging_level = 0;
}
/* check overall packet length */ /* check overall packet length */
if(req->msg.data_len + 7 + bridging_level * 8 > max_len) { if(req->msg.data_len + 7 + bridging_level * 8 > max_len) {

View File

@ -473,7 +473,18 @@ serial_term_build_msg(const struct ipmi_intf * intf,
struct serial_term_hdr * term_hdr = (struct serial_term_hdr *) msg; struct serial_term_hdr * term_hdr = (struct serial_term_hdr *) msg;
struct ipmi_send_message_rq * outer_rq = NULL; struct ipmi_send_message_rq * outer_rq = NULL;
struct ipmi_send_message_rq * inner_rq = NULL; struct ipmi_send_message_rq * inner_rq = NULL;
int bridging_level = ipmi_intf_get_bridging_level(intf); int bridging_level;
/* acquire bridging level */
if (intf->target_addr && intf->target_addr != intf->my_addr) {
if (intf->transit_addr != 0) {
bridging_level = 2;
} else {
bridging_level = 1;
}
} else {
bridging_level = 0;
}
/* check overall packet length */ /* check overall packet length */
if(req->msg.data_len + 3 + bridging_level * 8 > max_len) { if(req->msg.data_len + 3 + bridging_level * 8 > max_len) {
@ -624,7 +635,7 @@ serial_term_send_msg(struct ipmi_intf * intf, uint8_t * msg, int msg_len)
/* body */ /* body */
for (i = 0; i < msg_len; i++) { for (i = 0; i < msg_len; i++) {
buf += sprintf((char*) buf, "%02x", msg[i]); buf += sprintf( buf, "%02x", msg[i]);
} }
/* stop character */ /* stop character */