Compare commits

..

No commits in common. "master" and "IPMITOOL_1_8_18" have entirely different histories.

148 changed files with 6734 additions and 11839 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

@ -1,120 +0,0 @@
# vi: set et ts=2 sw=2 :
name: build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
linux:
strategy:
matrix:
os: [ ubuntu-18.04, ubuntu-20.04, ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
steps:
- name: install dependencies
run: |
sudo apt install \
automake \
gcc \
git \
libssl-dev \
libtool \
make \
wget
- name: install extra libraries
# This build job tries to verify as much of ipmitool code
# as possible, hence these libraries. They aren't usually
# needed for normal user builds:
run: |
sudo apt update
sudo apt install \
libsystemd-dev \
libreadline-dev \
libfreeipmi-dev \
libusb-dev
- uses: actions/checkout@v2
- name: bootstrap
run: ./bootstrap
- name: configure
run: |
# For Linux, build as many extra interfaces as possible
# to verify the code
./configure --enable-intf-dummy \
--enable-intf-dbus \
--enable-intf-usb \
--enable-intf-free
- name: make
run: make
- name: make check
run: make check
- name: make distcheck
run: make distcheck
macos:
strategy:
matrix:
os: [ macos-10.15, macos-11, macos-12 ]
runs-on: ${{ matrix.os }}
steps:
- name: install dependencies
run: brew install automake openssl libtool freeipmi wget
- uses: actions/checkout@v2
- name: bootstrap
run: ./bootstrap
- name: configure
run: |
./configure --enable-intf-dummy \
LDFLAGS=-L/usr/local/opt/openssl@1.1/lib \
CFLAGS=-I/usr/local/opt/openssl@1.1/include
- name: make
run: make
- name: make check
run: make check
- name: make distcheck
run: make distcheck
windows:
strategy:
matrix:
os: [ windows-2019, windows-2022 ]
runs-on: ${{ matrix.os }}
steps:
- name: install dependencies
run: |-
choco install cygwin -y
choco install cyg-get -y
# Line continuation in PowerShell is backtick. Weird as Windows.
cyg-get gcc-g++ `
make `
automake `
autoconf `
m4 `
libtool `
libncurses-devel `
libreadline-devel `
libssl-devel `
dos2unix `
wget
echo "C:/tools/cygwin/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:/tools/cygwin/usr/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: actions/checkout@v2
- name: convert line ends
# checkout action on Windows apparently converts line ends
# so we have to convert them back because cygwin bash can't
# can't handle Windows line ends
run: dos2unix bootstrap configure.ac csv-revision
- name: bootstrap
run: bash -c "./bootstrap"
- name: configure
run: bash -c "./configure"
- name: make
run: make
- name: make check
run: make check
- name: make distcheck
run: make distcheck

27
.gitignore vendored
View File

@ -1,39 +1,12 @@
.deps
.dirstamp
.libs
.*.swp
*.log
*.rej
*.orig
*.o
*.lo
*.la
*.*~
Makefile
Makefile.in Makefile.in
aclocal.m4 aclocal.m4
autom4te.cache autom4te.cache
compile compile
config.guess config.guess
config.h
config.h.in config.h.in
config.log
config.status
config.sub config.sub
configure configure
depcomp depcomp
install-sh install-sh
ltmain.sh ltmain.sh
libtool
missing missing
stamp-h1
control/ipmitool.spec
control/pkginfo
control/prototype
control/rpmmacros
src/ipmievd
src/ipmitool
doc/ipmievd.8
doc/ipmitool.1
cscope.out
tags

269
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
@ -882,7 +647,7 @@ version 1.8.11 released 2009-02-25
* Patch ID 1990560 to get readings from non-linear analog sensors * Patch ID 1990560 to get readings from non-linear analog sensors
* Add support for SOL payload status command * Add support for SOL payload status command
* SOL set parameter range checking added * SOL set parameter range checking added
* Fixed SOL activate options usage * Fixed SOL activate options usage
* Fixed crashes when parsing 'sol payload' and 'tsol' cmds (#216967) * Fixed crashes when parsing 'sol payload' and 'tsol' cmds (#216967)
* Added retries to SOL keepalive * Added retries to SOL keepalive
* Fixed wrong mask values for Front Panel disable/enable status * Fixed wrong mask values for Front Panel disable/enable status
@ -898,14 +663,14 @@ version 1.8.11 released 2009-02-25
* Fix occasional SDR dump segfault; #1793076 * Fix occasional SDR dump segfault; #1793076
* Allow ipmitool sel delete to accept hex list entry numbers * Allow ipmitool sel delete to accept hex list entry numbers
* Fix SEL total space reporting. * Fix SEL total space reporting.
* Fix for garbage sensor threshold values reported when none * Fix for garbage sensor threshold values reported when none
returned. Tracker Bug #863748 returned. Tracker Bug #863748
* ipmievd change to Monitor %used in SEL buffer and log warnings when * ipmievd change to Monitor %used in SEL buffer and log warnings when
the buffer is 80% and 100% full the buffer is 80% and 100% full
version 1.8.10 released 2008-08-08 version 1.8.10 released 2008-08-08
* Added support for BULL IANA number. * Added support for BULL IANA number.
* Fixed contrib build so the oem_ibm_sel_map file gets included in * Fixed contrib build so the oem_ibm_sel_map file gets included in
rpm builds again. rpm builds again.
* Added support for Debian packages to be built from CVS * Added support for Debian packages to be built from CVS
* Fix for sdr and sel timestamp reporting issues * Fix for sdr and sel timestamp reporting issues
@ -914,11 +679,11 @@ version 1.8.10 released 2008-08-08
* Change ipmi_chassis_status() to non-static so it can be used * Change ipmi_chassis_status() to non-static so it can be used
externally externally
* Added retries to SOL keepalive * Added retries to SOL keepalive
* Fix to stop sensor list command from reporting a failure due * Fix to stop sensor list command from reporting a failure due
to missing sensor to missing sensor
* Fix bug in sdr free space reporting * Fix bug in sdr free space reporting
* Add support for IANA number to vendor name conversion for many * Add support for IANA number to vendor name conversion for many
vendors vendors
* Fix segfault bug in lan set command * Fix segfault bug in lan set command
* Fix bug in population of raw i2c wdata buffer * Fix bug in population of raw i2c wdata buffer
* Fix bug in ipmb sensor reading * Fix bug in ipmb sensor reading
@ -932,7 +697,7 @@ version 1.8.10 released 2008-08-08
* Add more JEDEC support info for DIMMs; decrease request size * Add more JEDEC support info for DIMMs; decrease request size
for DIMM FRU info to 16 bytes at a time to allow more for DIMM FRU info to 16 bytes at a time to allow more
DIMM FRUs to respond. DIMM FRUs to respond.
* Fix to change hpmfwupg to version 1.02; fix to reduce hpmfwupg * Fix to change hpmfwupg to version 1.02; fix to reduce hpmfwupg
buffer length more aggressively when no response from iol buffer length more aggressively when no response from iol
* Fix HPM firmware activation via IOL; fake a timeout after IOL * Fix HPM firmware activation via IOL; fake a timeout after IOL
session re-open to force get upgrade status retry; session re-open to force get upgrade status retry;
@ -941,11 +706,11 @@ version 1.8.10 released 2008-08-08
* Fix for oemval2str size * Fix for oemval2str size
* Add support for product name resolution in mc info * Add support for product name resolution in mc info
* Fix FRU display format * Fix FRU display format
* Added PICMG ekeying analyzer module support (ekanalyzer); * Added PICMG ekeying analyzer module support (ekanalyzer);
display point to point physical connectivity and power display point to point physical connectivity and power
supply information between carriers and AMC modules; supply information between carriers and AMC modules;
display matched results of ekeying match between an display matched results of ekeying match between an
on-carrier device and AMC module or between 2 AMC modules on-carrier device and AMC module or between 2 AMC modules
* Fix AMC GUID display support * Fix AMC GUID display support
* Improved amcportstate operations * Improved amcportstate operations
* Added resolution for new sensor types * Added resolution for new sensor types
@ -958,8 +723,8 @@ version 1.8.10 released 2008-08-08
* Added SPD support for parms: channel number, max read size * Added SPD support for parms: channel number, max read size
* Add SDR support for adding SDR records from a dumped file, * Add SDR support for adding SDR records from a dumped file,
clearing SDR, adding partial SDR records clearing SDR, adding partial SDR records
* Add updates and fixes to hpmfwupg: upload block size to 32 bytes * Add updates and fixes to hpmfwupg: upload block size to 32 bytes
for KCS, handle long response option, implement rollback for KCS, handle long response option, implement rollback
override, garbage output fix override, garbage output fix
* Add double bridge lan support , fix bridging issue * Add double bridge lan support , fix bridging issue
* Add HPM support to pre-check which components need to be skipped * Add HPM support to pre-check which components need to be skipped
@ -993,7 +758,7 @@ version 1.8.9 released 2007-03-06
* Added edit support for AMC activation "Maximum Internal Current" * Added edit support for AMC activation "Maximum Internal Current"
* Fix bug generating garbage on the screen when handling GetDeviceId * Fix bug generating garbage on the screen when handling GetDeviceId
and sol traffic occurs and sol traffic occurs
* Added ability to map OEM sensor types to OEM description string using * Added ability to map OEM sensor types to OEM description string using
IANA number; moved IANA number table IANA number; moved IANA number table
* Fix lan set access command to use value already saved within * Fix lan set access command to use value already saved within
parameters for PEF and authentication parameters for PEF and authentication
@ -1011,13 +776,13 @@ version 1.8.9 released 2007-03-06
* Fix SOL set errors when commit-write not supported * Fix SOL set errors when commit-write not supported
* Fix reset of session timeout for lanplus interface * Fix reset of session timeout for lanplus interface
* Fixed lan interface accessibility timeout handling * Fixed lan interface accessibility timeout handling
* Fix bug with Function Get Channel Cipher Suites command when * Fix bug with Function Get Channel Cipher Suites command when
more than 1 page used. more than 1 page used.
* Fix missing firmware firewall top-level command * Fix missing firmware firewall top-level command
* Fix bug in SOL keepalive functionality * Fix bug in SOL keepalive functionality
* Fix SOLv2 NACK and retry handling for Intel ESB2 BMC * Fix SOLv2 NACK and retry handling for Intel ESB2 BMC
* Added ipmi_sel_get_oem_sensor* APIs * Added ipmi_sel_get_oem_sensor* APIs
* Added HPM.1 support * Added HPM.1 support
* Fix segfault when incorrect oem option supplied * Fix segfault when incorrect oem option supplied
* Fix bus problem with spd command * Fix bus problem with spd command
* Fix segfault in SOL when remote BMC does not return packet * Fix segfault in SOL when remote BMC does not return packet
@ -1031,7 +796,7 @@ version 1.8.9 released 2007-03-06
* Add freeipmi interface support * Add freeipmi interface support
* Add remote spd printing * Add remote spd printing
* Add better detection of linux/compiler.h to config * Add better detection of linux/compiler.h to config
* Makefile changes to fix makedistcheck, etc. * Makefile changes to fix makedistcheck, etc.
version 1.8.8 version 1.8.8
* Fix segfaults in sensor data repository list * Fix segfaults in sensor data repository list

79
INSTALL
View File

@ -9,78 +9,17 @@ are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is, notice and this notice are preserved. This file is offered as-is,
without warranty of any kind. without warranty of any kind.
Prerequisites
=============
This project requires at least gcc 4.8.1 as it uses some GNU
extensions and some C11 features. For `lanplus` interface the OpenSSL
library and development headers are required. As of July 2020, the
project is tested automatically to build cleanly for the following
64-bit operating systems using GitHub Actions workflow:
- Ubuntu 18.04 Bionic Beaver
- Ubuntu 20.04 Focal Fossa
- Ubuntu 22.04 Jammy Jellyfish
- MacOS X 10.15 Catalina
- MacOS 11 Big Sur
- MacOS 12 Monterey
- Microsoft Windows Server 2019
- Microsoft Windows Server 2022
It is also known to build successfully on Ubuntu 14.04 and Fedora 31,
but that is not automatically verified.
For Ubuntu 14.04+ it is recommended to do the following before building:
$ sudo apt install automake gcc git libreadline-dev libssl-dev \
libtool make wget
For Ubuntu 20.04+ you will also need this:
$ sudo apt install musl-dev
For Fedora 31 it is recommended to do the following before building:
$ sudo dnf install automake gcc git libtool make openssl-devel \
readline-devel wget
For MacOS with Xcode and homebrew installed, it is recommended to do the
following before building:
$ brew install automake openssl libtool freeipmi wget
$ export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
To prepare for building in Windows it is recommended to use Chocolatey
and do the following using PowerShell:
PS C:\ipmitool> choco install cygwin -y
PS C:\ipmitool> choco install cyg-get -y
PS C:\ipmitool> cyg-get gcc-g++ make automake autoconf `
# m4 libtool libncurses-devel libreadline-devel libssl-devel `
# dos2unix wget
PS C:\ipmitool> $env:path="C:\tools\cygwin\usr\bin;$env:path"
PS C:\ipmitool> $env:path="C:\tools\cygwin\bin;$env:path"
PS C:\ipmitool> dos2unix bootstrap configure.ac csv-revision
Basic Installation Basic Installation
================== ==================
Briefly, the followong shell command should configure, build, and Briefly, the shell command `./configure && make && make install'
install this package: should configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
./bootstrap && ./configure && make && sudo make install instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
For Windows the above command must be run inside a cygwin bash below. The lack of an optional feature in a given package is not
shell. necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The following more-detailed instructions are generic; see the
`README' file for instructions specific to this package. Some
packages provide this `INSTALL' file but do not implement all of the
features documented below. The lack of an optional feature in a given
package is not necessarily a bug. More recommendations for GNU
packages can be found in *note Makefile Conventions:
(standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses various system-dependent variables used during compilation. It uses
@ -185,7 +124,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,49 +41,15 @@ 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
dist-hook: dist-hook:
cp control/ipmitool.spec $(distdir) cp control/ipmitool.spec $(distdir)
.PHONY: install-pen-database uninstall-pen-database install-data-local:
.INTERMEDIATE: %.o %.la enterprise-numbers
if DOWNLOAD
enterprise-numbers:
@echo Downloading IANA PEN database...
@$(DOWNLOAD) "$(IANA_PEN)" > tmpfile.$$PPID || {\
echo "FAILED to download the IANA PEN database"; \
rm tmpfile.$$PPID; \
false; \
}
@mv tmpfile.$$PPID $@
install-pen-database: enterprise-numbers
mkdir -m 755 -p $(DESTDIR)$(IANADIR)
$(INSTALL_DATA) $< $(DESTDIR)$(IANADIR)/
uninstall-pen-database:
-rm -rf $(DESTDIR)$(IANADIR)/enterprise-numbers
else
install-pen-database:
@echo "*** NOT installing the IANA PEN database."
@echo "*** Don't know how to download it."
uninstall-pen-database:
@echo "*** NOT uninstalling the IANA PEN database."
@echo "*** It was installed manually (if ever)."
endif
install-data-local: install-pen-database
mkdir -p $(DESTDIR)$(DOCDIR) mkdir -p $(DESTDIR)$(DOCDIR)
$(INSTALL_DATA) $(DOCLIST) $(DESTDIR)$(DOCDIR) $(INSTALL_DATA) $(DOCLIST) $(DESTDIR)$(DOCDIR)
uninstall-local: uninstall-pen-database uninstall-local:
-rm -rf $(DESTDIR)$(DOCDIR) -rm -rf $(DESTDIR)$(DOCDIR)
.PHONY: pkg .PHONY: pkg
@ -101,8 +67,12 @@ SRCDIR = ${shell cd $(top_srcdir) ; pwd | sed -e 's,^[^:\\/]:[\\/],/,'}
RPMDIR = $(BUILDDIR)/rpmbuild RPMDIR = $(BUILDDIR)/rpmbuild
.PHONY: rpm .PHONY: rpm
rpm: dist rpm: control/ipmitool.spec dist
@RPMBUILD@ -ta --define "_topdir $(RPMDIR)" $(distdir).tar.gz mkdir -p $(RPMDIR)/{BUILD,RPMS,SRPMS,SOURCES,SPECS,tmp}
cp control/ipmitool.spec $(RPMDIR)/SPECS
BUILDDIR=$(RPMDIR) CONFIGDIR=$(BUILDDIR)/control \
@RPMBUILD@ -ba --rcfile $(SRCDIR)/control/rpmrc \
$(RPMDIR)/SPECS/ipmitool.spec
.PHONY: clean-rpm .PHONY: clean-rpm
clean-rpm: clean-rpm:

15
README
View File

@ -42,8 +42,8 @@ Requirements
============ ============
Obviously the largest requirement is hardware with a service processor Obviously the largest requirement is hardware with a service processor
that supports the IPMI specification. Many x86-based servers are now that supports the IPMI specification. Many x86-based servers are now
coming with IPMI support, check with your preferred hardware vendor comming with IPMI support, check with your preferred hardware vendor
about available products. about available prodcuts.
Once you are certain you have the required hardware, you then need to Once you are certain you have the required hardware, you then need to
decide how you want to access the BMC. The most common case involve decide how you want to access the BMC. The most common case involve
@ -126,7 +126,7 @@ hardware will come with a utility (often a DOS bootable CD) for configuring
enabling the LAN interface as well. enabling the LAN interface as well.
In order to support the IPMIv2.0 interface you must have an OpenSSL library In order to support the IPMIv2.0 interface you must have an OpenSSL library
with the required encryption functions. Recent distributions should have with the required encrytion functions. Recent distributions should have
no problems. The IPMIv1.5 interface will attempt to use OpenSSL for MD5 no problems. The IPMIv1.5 interface will attempt to use OpenSSL for MD5
hash function at compile time but if that is not found it will use an hash function at compile time but if that is not found it will use an
internal library. internal library.
@ -396,13 +396,16 @@ ipmievd: Memory Sensor 01 - Correctable ECC
Resources Resources
========= =========
IPMItool homepage IPMItool homepage
http://github.com/ipmitool/ipmitool http://ipmitool.sourceforge.net
IPMItool manpage IPMItool manpage
https://github.com/ipmitool/ipmitool/blob/master/doc/ipmitool.1.in http://ipmitool.sourceforge.net/manpage.html
IPMItool overview paper from Linux.conf.au 2004
http://ipmitool.sourceforge.net/lca2004_ipmitool.pdf
Intelligent Platform Management Interface specification Intelligent Platform Management Interface specification
https://www.intel.com/content/www/us/en/servers/ipmi/ipmi-home.html http://www.intel.com/design/servers/ipmi/spec.htm
OpenIPMI project: Linux IPMI kernel driver and userland library OpenIPMI project: Linux IPMI kernel driver and userland library
http://openipmi.sourceforge.net http://openipmi.sourceforge.net

View File

@ -31,15 +31,7 @@
# EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. # EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
aclocal aclocal
libtoolize --automake --copy
case `uname` in
Darwin*)
glibtoolize --automake --copy
;;
*)
libtoolize --automake --copy
;;
esac
autoheader autoheader
automake --foreign --add-missing --copy automake --foreign --add-missing --copy

View File

@ -1,12 +1,10 @@
dnl dnl
dnl autoconf for ipmitool dnl autoconf for ipmitool
dnl dnl
m4_define([git_suffix], m4_esyscmd_s(./csv-revision)) AC_INIT([ipmitool], [1.8.18-csv])
AC_INIT([ipmitool], [1.8.19git_suffix])
AC_CONFIG_SRCDIR([src/ipmitool.c]) AC_CONFIG_SRCDIR([src/ipmitool.c])
AC_CONFIG_COMMANDS_PRE([export prefix=$prefix])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([foreign]) AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
AC_PREREQ(2.50) AC_PREREQ(2.50)
AC_SUBST(ac_configure_args) AC_SUBST(ac_configure_args)
@ -34,7 +32,7 @@ AC_CHECK_FUNCS([alarm gethostbyname getaddrinfo getifaddrs socket select])
AC_CHECK_FUNCS([memmove memset strchr strdup strerror]) AC_CHECK_FUNCS([memmove memset strchr strdup strerror])
AC_CHECK_FUNCS([getpassphrase]) AC_CHECK_FUNCS([getpassphrase])
CFLAGS="$CFLAGS -Wall -Wextra -std=gnu11 -pedantic -Wformat -Wformat-nonliteral" CFLAGS="$CFLAGS -Wall -Wextra -std=gnu99 -pedantic -Wformat -Wformat-nonliteral"
AM_PROG_LIBTOOL AM_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --silent" LIBTOOL="$LIBTOOL --silent"
@ -54,42 +52,12 @@ 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
AC_ARG_ENABLE([registry-download],
[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([** 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
DOWNLOAD="$CURL --location --progress-bar"
fi
fi
fi
AC_MSG_WARN([** Download is: $DOWNLOAD])
AC_SUBST(DOWNLOAD, $DOWNLOAD)
dnl dnl
dnl set default option values dnl set default option values
dnl dnl
xenable_all_options=yes xenable_all_options=yes
xenable_intf_bmc=no xenable_intf_bmc=no
xenable_intf_dbus=no
xenable_intf_dummy=no xenable_intf_dummy=no
xenable_intf_imb=yes xenable_intf_imb=yes
xenable_intf_lipmi=yes xenable_intf_lipmi=yes
@ -222,14 +190,6 @@ AC_CHECK_LIB([crypto], [MD2_Init],
fi], fi],
[], [-lcrypto]) [], [-lcrypto])
dnl check for libsystemd in case dbus-intf is requested
AC_CHECK_LIB([systemd], [sd_bus_default],
[
LIBS="$LIBS -lsystemd"
have_systemd=yes
],
[ have_systemd=no],[])
dnl enable IPMIv1.5 LAN interface dnl enable IPMIv1.5 LAN interface
AC_ARG_ENABLE([intf-lan], AC_ARG_ENABLE([intf-lan],
[AC_HELP_STRING([--enable-intf-lan], [AC_HELP_STRING([--enable-intf-lan],
@ -593,25 +553,6 @@ if test "x$xenable_intf_bmc" = "xyes"; then
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB bmc/libintf_bmc.la" IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB bmc/libintf_bmc.la"
fi fi
dnl enable IPMI dbus interface
AC_ARG_ENABLE([intf-dbus],
[AC_HELP_STRING([--enable-intf-dbus],
[enable IPMI dbus interface [default=no]])],
[xenable_intf_dbus=$enableval],
[xenable_intf_dbus=no])
if test "x$xenable_intf_dbus" != "xno"; then
if test "x$have_systemd" != "xyes"; then
AC_MSG_ERROR([** Unable to find libsystemd required by dbus-intf.])
xenable_intf_dbus=no
fi
fi
if test "x$xenable_intf_dbus" = "xyes"; then
AC_DEFINE(IPMI_INTF_DBUS, [1], [Define to 1 to enable dbus interface.])
AC_SUBST(INTF_DBUS, [dbus])
AC_SUBST(INTF_DBUS_LIB, [libintf_dbus.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB dbus/libintf_dbus.la"
fi
dnl enable Dummy interface for testing dnl enable Dummy interface for testing
AC_ARG_ENABLE([intf-dummy], AC_ARG_ENABLE([intf-dummy],
[AC_HELP_STRING([--enable-intf-dummy], [AC_HELP_STRING([--enable-intf-dummy],
@ -626,22 +567,30 @@ fi
AC_SUBST(IPMITOOL_INTF_LIB) AC_SUBST(IPMITOOL_INTF_LIB)
if test "x$xenable_ipmishell" = "xyes"; then
AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses readline termcap])
AC_SEARCH_LIBS([initscr], [ncurses curses], [have_curses=yes])
AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])
if test "x$have_curses" != "xyes" || test "x$have_readline" != "xyes"; then
xenable_ipmishell=no
fi
fi
dnl check for readline library to enable ipmi shell
AC_ARG_ENABLE([ipmishell], AC_ARG_ENABLE([ipmishell],
[AC_HELP_STRING([--enable-ipmishell], [AC_HELP_STRING([--enable-ipmishell],
[enable IPMI shell interface [default=auto]])], [enable IPMI shell interface [default=auto]])],
[xenable_ipmishell=$enableval], [xenable_ipmishell=$enableval],
[]) [])
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([tgetent], [tinfo ncurses curses readline termcap])
PKG_CHECK_MODULES([READLINE], [readline], AC_SEARCH_LIBS([initscr], [ncurses curses], [have_curses=yes])
[LIBS="$LIBS $READLINE_LIBS" have_readline=yes], AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])
[AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])] if test "x$have_curses" != "xyes"; then
) AC_MSG_ERROR([** Unable to find curses required by ipmishell.])
fi
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
fi fi
AC_DEFINE(HAVE_READLINE, [1], [Define to 1 if readline present.]) AC_DEFINE(HAVE_READLINE, [1], [Define to 1 if readline present.])
fi fi
@ -693,50 +642,6 @@ AC_TRY_COMPILE([],[
[Define to 1 if you need to use #pragma pack instead of __attribute__ ((packed))])] [Define to 1 if you need to use #pragma pack instead of __attribute__ ((packed))])]
) )
dnl if no environment variable is set, set the default value for the default intf
if test "${xenable_intf_open}" = "yes"; then
DEFAULT_INTF_NO_ENV=open
else dnl macOS does not build open interface, it defaults to lan
DEFAULT_INTF_NO_ENV=lan
fi
dnl allow for a default interface to be set on configure
AC_ARG_VAR(DEFAULT_INTF, [Set the default interface to use (default='open' if available, 'lan' otherwise)])
dnl set the default value for the default interface environment variable
if test "x${DEFAULT_INTF}" = "x"; then
echo "DEFAULT_INTF not found in environment; setting to ${DEFAULT_INTF_NO_ENV}"
DEFAULT_INTF=${DEFAULT_INTF_NO_ENV}
fi
if test "x"`eval "echo \\\${xenable_intf_${DEFAULT_INTF}}"` != "xyes"; then
AC_MSG_ERROR([** Cannot set ${DEFAULT_INTF} as default; intf-${DEFAULT_INTF} is not enabled.])
fi
AC_ARG_VAR(IANADIR, [Configure the path to IANA PEN dictionary (default=DATAROOTDIR/misc)])
AC_ARG_VAR(IANAUSERDIR, [Configure the path to IANA PEN dictionary wihtin the user's HOME directory (default=.local/usr/share/misc)])
if test "x${IANADIR}" = "x"; then
IANADIR=`eval echo "${datarootdir}/misc"`
echo Set IANA PEN dictionary search path to ${IANADIR}
fi
if test "x${IANAUSERDIR}" = "x"; then
IANAUSERDIR=".local/usr/share/misc"
echo Set user\'s IANA PEN dictionary search path to ${IANAUSERDIR}
fi
AH_TEMPLATE([IANADIR],[The path to system IANA PEN dictionary])
AC_DEFINE_UNQUOTED(IANADIR, "`eval "echo ${IANADIR}"`", [])
AH_TEMPLATE([IANAUSERDIR],[The subpath to user IANA PEN dictionary within the user's HOME])
AC_DEFINE_UNQUOTED(IANAUSERDIR, "`eval "echo ${IANAUSERDIR}"`", [])
AH_TEMPLATE([PATH_SEPARATOR], [The path separator string])
#if defined _WIN32 || defined __CYGWIN__
AC_DEFINE(PATH_SEPARATOR, "\\")
#else
AC_DEFINE(PATH_SEPARATOR, "/")
#endif
dnl Generate files for build dnl Generate files for build
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
@ -745,6 +650,7 @@ AC_CONFIG_FILES([Makefile
control/Makefile control/Makefile
control/pkginfo control/pkginfo
control/prototype control/prototype
control/rpmmacros
control/ipmitool.spec control/ipmitool.spec
lib/Makefile lib/Makefile
include/Makefile include/Makefile
@ -757,27 +663,23 @@ AC_CONFIG_FILES([Makefile
src/plugins/free/Makefile src/plugins/free/Makefile
src/plugins/imb/Makefile src/plugins/imb/Makefile
src/plugins/bmc/Makefile src/plugins/bmc/Makefile
src/plugins/dbus/Makefile
src/plugins/usb/Makefile src/plugins/usb/Makefile
src/plugins/lipmi/Makefile src/plugins/lipmi/Makefile
src/plugins/serial/Makefile src/plugins/serial/Makefile
src/plugins/dummy/Makefile src/plugins/dummy/Makefile])
doc/ipmitool.1
doc/ipmievd.8])
AC_OUTPUT AC_OUTPUT
AC_MSG_RESULT([]) AC_MSG_RESULT([])
AC_MSG_RESULT([ipmitool $VERSION]) AC_MSG_RESULT([ipmitool $VERSION])
AC_MSG_RESULT([]) AC_MSG_RESULT([])
AC_MSG_RESULT([Interfaces (default=$DEFAULT_INTF)]) AC_MSG_RESULT([Interfaces])
AC_MSG_RESULT([ lan : $xenable_intf_lan]) AC_MSG_RESULT([ lan : $xenable_intf_lan])
AC_MSG_RESULT([ lanplus : $xenable_intf_lanplus]) AC_MSG_RESULT([ lanplus : $xenable_intf_lanplus])
AC_MSG_RESULT([ open : $xenable_intf_open]) AC_MSG_RESULT([ open : $xenable_intf_open])
AC_MSG_RESULT([ free : $xenable_intf_free]) AC_MSG_RESULT([ free : $xenable_intf_free])
AC_MSG_RESULT([ imb : $xenable_intf_imb]) AC_MSG_RESULT([ imb : $xenable_intf_imb])
AC_MSG_RESULT([ bmc : $xenable_intf_bmc]) AC_MSG_RESULT([ bmc : $xenable_intf_bmc])
AC_MSG_RESULT([ dbus : $xenable_intf_dbus])
AC_MSG_RESULT([ usb : $xenable_intf_usb]) AC_MSG_RESULT([ usb : $xenable_intf_usb])
AC_MSG_RESULT([ lipmi : $xenable_intf_lipmi]) AC_MSG_RESULT([ lipmi : $xenable_intf_lipmi])
AC_MSG_RESULT([ serial : $xenable_intf_serial]) AC_MSG_RESULT([ serial : $xenable_intf_serial])

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

@ -1,8 +1,7 @@
[Unit] [Unit]
Description=Exchange Information between BMC and OS Description=Exchange Information between BMC and OS
After=network.target After=ipmi.service network.target
AssertFileIsExecutable=/usr/bin/ipmitool Requires=ipmi.service
AssertPathExistsGlob=/dev/ipmi*
[Service] [Service]
Type=oneshot Type=oneshot

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

@ -1,4 +1,4 @@
"0xC1","XX","XX","XX","XX","XX","XX","XX","0x01","0x00","Chassis Number","R","R","0x00","CPU shutdown - Potential cause 'triple fault' a software address problem" "0xC1","XX","XX","XX","XX","XX","XX","XX","0x01","0x00","Chassis Number","R","R","0x00","CPU shutdown - Potential cause "triple fault" a software address problem"
"0xC1","XX","XX","XX","XX","XX","XX","XX","0x02","0x01","Chassis Number","Failed Memory Card","Spare Memory Card","0x00","Memory Mirrored Failover Occurred - System running from mirrored memory image" "0xC1","XX","XX","XX","XX","XX","XX","XX","0x02","0x01","Chassis Number","Failed Memory Card","Spare Memory Card","0x00","Memory Mirrored Failover Occurred - System running from mirrored memory image"
"0xC1","XX","XX","XX","XX","XX","XX","XX","0x02","0x04","Chassis Number","Memory Card","Completion Code (0x00=Success)","0x00","Memory hot replace event" "0xC1","XX","XX","XX","XX","XX","XX","XX","0x02","0x04","Chassis Number","Memory Card","Completion Code (0x00=Success)","0x00","Memory hot replace event"
"0xC1","XX","XX","XX","XX","XX","XX","XX","0x02","0x05","Chassis Number","Memory Card","Memory Size (in 512MB units)","0x00","Memory hot add event" "0xC1","XX","XX","XX","XX","XX","XX","XX","0x02","0x05","Chassis Number","Memory Card","Memory Size (in 512MB units)","0x00","Memory hot add event"

View File

@ -31,7 +31,7 @@
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = pkginfo.in prototype.in \ EXTRA_DIST = pkginfo.in prototype.in \
ipmitool.spec.in ipmitool.spec.in rpmmacros.in rpmrc
dist-hook: pkginfo prototype dist-hook: pkginfo prototype rpmmacros

View File

@ -1,13 +1,10 @@
%define debug_package %{nil}
Name: ipmitool Name: ipmitool
Summary: ipmitool - Utility for IPMI control Summary: ipmitool - Utility for IPMI control
Version: @VERSION@ Version: @VERSION@
Release: @RPM_RELEASE@%{?_distro:.%{_distro}} Release: @RPM_RELEASE@%{?_distro:.%{_distro}}
License: BSD License: BSD
Group: Utilities Group: Utilities
#Packager: PackagerName <packager@example.com> Packager: Jim Mankovich <jmank@hp.com>
Distribution: GitHub Build
Source: %{name}-%{version}.tar.gz Source: %{name}-%{version}.tar.gz
Buildroot: /var/tmp/ipmitool-root Buildroot: /var/tmp/ipmitool-root
@ -34,7 +31,7 @@ fi
%setup %setup
%build %build
./configure \ ./configure --with-kerneldir \
--with-rpm-distro=@DISTRO@ \ --with-rpm-distro=@DISTRO@ \
--prefix=%{_prefix} \ --prefix=%{_prefix} \
--bindir=%{_bindir} \ --bindir=%{_bindir} \
@ -59,632 +56,11 @@ fi
%attr(755,root,root) %{_bindir}/* %attr(755,root,root) %{_bindir}/*
%attr(755,root,root) %{_sbindir}/* %attr(755,root,root) %{_sbindir}/*
%{_datadir}/ipmitool/* %{_datadir}/ipmitool/*
%{_datadir}/misc/*
%{_mandir}/man*/* %{_mandir}/man*/*
%doc %{_datadir}/doc/ipmitool %doc %{_datadir}/doc/ipmitool
%changelog %changelog
* Sat Oct 8 2016 <gilles.buloz@kontron.com> 1.8.18-1
- Add mac2str() and str2mac() to print/parse MAC address
- Change formatting, remove commented-out code in
src/plugins/imb/imbapi.c
- Export find_lan_channel() as global
- Expose _ipmi_get_channel_info()
- Extend buf2str to allow separator
- Fix indentation of #define in src/plugins/imb/imbapi.c
- Fix missing `goto out_free;` when ipmi_parse_hex() returns (-1)
- Fix warning for buf2str argument
- ID 408 - fix sel list last X listing
- ID: 38 - Protocol violating SOL retries when talking to
SIMSO-HTC
- ID: 459 - Fix reading FRU on Artesyn (Emerson) shelf manager,
MF105.
- ID: 464 - ipmievd crash fix in log_event
- ID:230 - check return value of malloc() in lib/ipmi_ekanalyzer.c
- ID:261 - Fix err. output consistency for % ipmitool chassis
INV_PARAM;
- ID:287 - Fix print-out of DDR3 SDRAM Serial Number
- ID:287 - Remove trailing white-spaces from dimm_spd.c
- ID:289 - bmx-snmp-proxy: PEF alerting does not work for
multiple destinations
- ID:312 - BREAKING CHANGE - Re-design of PEF user interface
- ID:312 - Fix bitmask in _ipmi_set_pef_policy_entry()
- ID:335 - Check return value of fseek(), prevent segfault
- ID:335 - Check return value of fseek(), prevent segfault
- ID:355 - Comment out statement without effect in lib/ipmi_sel.c
- ID:355 - Fix 'missing initializer' in struct lan_param
- ID:355 - Fix ``warning: ISO C forbids zero-size array 'data'''
- ID:355 - Fix different pointer type in lib/ipmi_picmg.c
- ID:355 - Fix missing struct initializers in lib/ipmi_firewall.c
- ID:355 - Fix printf format in lib/ipmi_sunoem.c
- ID:355 - Fix printf() related warnings in lib/ipmi_delloem.c
- ID:355 - Fix signedness warnings in lib/ipmi_sdr.c
- ID:355 - Fix statements without effect in lib/ipmi_ekanalyzer.c
- ID:355 - Move section_id from ipmi_fru. to ipmi_fru.c
- ID:355 - Replace DEBUG() macro with lprintf(LOG_DEBUG, ...)
- ID:375 - Add lan6 subcommand to handle IPv6 LAN parameters
- ID:400 - Add support for VITA-specific sensor types and events.
- ID:441 - Add support for HMAC_MD5 and HMAC_SHA256
- ID:443 - Disable USB driver by default on non-Linux systems
- ID:444 - Cleanup of defaults in configure.ac
- ID:445 - Fix of compilation on FreeBSD
- ID:446 - Fix broken firewall reset iterator
- ID:447 - Fix access beyond array limits in serial_terminal
- ID:449 - ipmitool close console session for sol deactivate
command
- ID:451 - Modify the memory ecc error display of SEL for new
supermicro motherboards.
- ID:452 - Add PICMG extension 5.x for PICMG extension check
- ID:454 - Add support for PICMG 3.1 R2.0 Link Types and Link
Classes.
- ID:456 - Unable to disable the VLAN ID using ipmitool
- ID:457 - Display User ID enable/disable status
- ID:463 - Removal of Nokia Siemens Networks
- ID:465 - Supermicro memory ecc Modify the memory ecc error
display of SEL for new supermicro boards.
- Moved ipmi_parse_hex() to helper.c
- Re-work ipmi_mc_get_guid() and turn it into reusable code
- Revert "ID:335 - Check return value of fseek(), prevent segfault"
- Rewrite code with the notion that Kg is binary data, not string
* Sun May 1 2016 <gilles.buloz@kontron.com> 1.8.17-1
- Add INSTALL and NEWS, mandated by autoconf
- Added missing ipmi_sel_supermicro.h to template Makefile.am
- Check rsp->data_len in ipmi_sel_get_info()
- Fix "redirecting incorrect #include <sys/poll.h> to <poll.h>"
warning with musl libc
- Fix automake compatibility warnings
- Fix implicit declaration of function
'get_nic_selection_mode_12g' in lib/ipmi_delloem.c
- Fix implicit declaration of function 'ipmi_get_oem' in
src/plugins/imb/imb.c
- Fix implicit declaration of function 'ipmi_get_oem' in
src/plugins/lanplus/lanplus.c
- Fix implicit declaration of function 'ipmi_get_oem' in
src/plugins/open/open.c
- Fix implicit declarations of functions 'HpmfwupgPreUpgradeCheck'
and 'ipmi_intf_get_max_request_data_size' in lib/ipmi_hpmfwupg.c
- Fix implicit declarations of functions
'ipmi_intf_set_max_request_data_size' and
'ipmi_intf_set_max_response_data_size' in lib/hpm2.c
- Fix implicit function declaration of
ipmi_intf_get_max_response_data_size in lib/ipmi_sdr.c
- Fix several implicit declarations of functions in
lib/ipmi_main.c
- Fix several implicit function declarations in lib/ipmi_fru.c
- Fix warning: suggest parentheses around '+' inside '<<'
in lib/ipmi_main.c
- Fix warning: suggest parentheses around arithmetic in operand of
'|' in include/ipmitool/hpm2
- Get rid of old INCLUDES macro, use AM_CPPFLAGS instead.
- ID 440 - Fix 'unknown type name fd_set error.
- ID 440 - remove obsolete headers from lib/ipmi_sunoem.c
- ID:322 - let 'ekanalyzer frushow' run without a working
IPMI target
- ID:355 - Add #include <strings.h> to lib/ipmi_sel.c
- ID:355 - Add macros and #include and reduce number of warnings
- ID:355 - Change CFLAG -std=c99 to -std=gnu99
- ID:355 - Move Super Micro stuff into dedicated header file
- ID:355 - Remove declared, but not used variables
- ID:404 - Edit FRU information update problem
- ID:405 - Use meaningful Generator ID for "ipmitool sel add"
- ID:407 - Avoid assert on mismatched session ID
- ID:409 - Fix IPv6 socket creation on Windows/Cygwin.
- ID:410 - Disable USB interface for Windows/Cygwin by default.
- ID:410 - Enable/disable USB interface by "auto"
- ID:411 - Fix HPM.2 revision check for R1.1 and subsequent
specification revisions.
- ID:412 - Check errors when setting a user password.
- ID:413 - Print new line chne character when setting user
privilege.
- ID:414 - ekanalyzer frushow fails to show 'Product Info'
correctly
- ID:417 - Fix some typos
- ID:418 - Fix Compiling under Mac OS X
- ID:419 - List dummy.h in Makefile.am, so it gets included in
a release tarball
- ID:421 - Fix memleak for sol output
- ID:423 - Don't assume internal use area is present in ekanalyzer
- ID:424 - Update dimm_spd.c with data from the latest JEDEC List
- ID:425 - Disable USB interface for OS X/darwin
- ID:426 - Fallback to run-time detection of PAGESIZE if
compile-time detection is not supported
- ID:426 - Include sys/socket.h instead of asm/socket.h
- ID:426 - Include wchar.h instead of defining wchar_t ourselves
- ID:427 - Cleanup comment in ipmi_sdr_get_header()
- ID:427 - The first two bytes of dumped raw SDR data is wrong.
- ID:428 - Update IANA numbers / Product Name for IBM and ADLINK
- ID:430 - Change Nokia Siemens Networks to Nokia Solutions
and Networks
- ID:431 - Fix correct interpretation of led states
- ID:437 - sel: Fix "sel time set <time>"
- Make bootstrap script part of dist packages
- Remove #if 0 code aka not-compiled-in
- Remove trailing white-spaces in lib/log.c
- git-ignore autoconf-generated files
* Sun Nov 22 2015 <gilles.buloz@kontron.com> 1.8.16-1
- Add _ipmi_get_channel_access() and _ipmi_get_channel_info()
- Add _ipmi_get_user_access() and _ipmi_set_user_access()
- Add _ipmi_get_user_name()
- Add _ipmi_set_channel_access() function
- Add _ipmi_set_user_password() function
- Add limits check in get_cmdline_macaddr()
- Change expression in ipmi_pef_get_info() in order to silence Coverity
- Change expression in ipmi_pef_list_policies() in order to silence Coverity
- Code cleanup in ipmi_user_main()
- Create ask_password() and re-use code
- Delete dead code from ipmi_sunoem_echo() - CID#1261338
- Don't output pidfile before parsing command line arguments
- Don't use tmp variable since it's not necessary in ipmi_user_test()
- Fix 'user help' output
- Fix Assign instead of compare in KfwumGetDeviceInfo() - CID#1149034
- Fix Identical code for different branches in ipmi_tsol_main() -
CID#1261346
- Fix big parameter passed by value in ipmi_sel_oem_match() - CID#1261347
- Fix dead code in ipmi_firewall_reset() - CID#1261342
- Fix eval logic in ipmi_user_priv()
- Fix file descriptor leak in ipmi_exec_main() - CID#1149040
- Fix identical code for diff branches in DellOEM - CID#1261326
- Fix memory leak in get_supermicro_evt_desc()
- Fix memory leak in ipmi_ek_display_board_info_area() - CID#1149051
- Fix missing return in ipmi_kontronoem_main() - CID#1261317
- Fix of previous commit - memset() expects pointer
- Fix out-of-bound-reads in get_supermicro_evt_desc()
- Fix resource leak in fru_area_print_board() - CDI#1149048
- Fix resource leak in fru_area_print_chassis() - CID#1149047
- Fix resource leak in fru_area_print_product() - CID#1149046
- Fix resource leak in ipmi_kontron_set_serial_number() - CID#1149041
- Fix typo vlan->VLAN in ipmi_lan_set_vlan_id() and
ipmi_lan_set_vlan_priority()
- Fix uninitialized struct in ipmi_fru_upg_ekeying() - CID#1149065
- Fix user input validation in Channel and User sub-commands
- Fix wrong size argument in ipmi_sdr_list_cache_fromfile() - CID#1149056
- Fix/remove pointer cast in _ipmi_set_user_access()
- Hook functions in ipmi_user to _ipmi_set_user_password()
- Hook ipmi_get_channel_info() to _ipmi_get_*()
- Hook ipmi_get_channel_medium() to new _ipmi_get_*() functions
- Hook ipmi_lan_set_password() to _ipmi_set_user_password()
- Hook ipmi_print_user_list() and friends to _ipmi_* functions
- Hook ipmi_set_alert_enable() to _ipmi_*()
- Hook ipmi_set_user_access() to _ipmi_set_user_access()
- Hook ipmi_user_priv() to _ipmi_set_user_access()
- ID:307 - Intel I82751 super pass through mode fixup
- ID:355 - Fix compiler warnings for Dummy Interface
- ID:380 - raw commands override retry and timeout values
- ID:319 - Interface safe re-open
- ID:320 - Add VITA 46.11 support
- ID:333 - Set read timeout to 15s in OpenIPMI interface
- ID:336 - ipmitool does not fall back to IPv4 for IPMI v2 / RMCP+ sessions
- ID:343 - Print actual sensor thresholds in 'sensors' comand
- ID:343 - Remove AC_FUNC_MALLOC
- ID:344 - Fix HPM.2 long message support
- ID:345 - Do not do several close session retries when catching SIGINT
- ID:346 - lib/ipmi_sdradd.c ipmi_sdr_read_record has a file descriptor leak
- ID:347 - Incorrect reserved channel number
- ID:348 - Add support for the "System Firmware Version"
- ID:349 - user set password - add option to choose 16/20 byte password
- ID:354 - Replace obsolete u_int with uint32_t in dimm_spd.c
- ID:354 - Replace obsolete u_int[0-9]+_t with standardized types in Free
iface
- ID:354 - forcefully switch to C99 and more strict CFLAGS
- ID:354 - replace/drop caddr_t in IMB
- ID:354 - struct member h_addr has been replaced
- ID:354 - uint8_t >= 0 is always true, don't test it
- ID:355 - Fix Enumeration value not handled in ipmi_get_event_desc()
- ID:355 - Fix ``ISO C forbids omitting the middle term of a ?: expression''
- ID:355 - Fix ``obsolete use of designated initializer with ¿:¿'' warning
- ID:355 - Fix comparison of unsigned expression
- ID:355 - Fix compiler warnings
- ID:355 - Fix compiler warnings in dimm_spd.c
- ID:355 - Fix couple compiler warnings in ipmi_lanp.h
- ID:355 - Fix formatting warning in get_cmdline_ipaddr()
- ID:355 - Fix zero-length format string warning in
get_supermicro_evt_desc()
- ID:355 - Remove defined but unused variable in _set_command_enables()
- ID:355 - remove unused variables from ipmi_dcmi.c
- ID:357 - out-of-bound access in DDR4 code ID:356 - DIMM4 Die Count is
unreachable
- ID:357 - out-of-bound access in DDR4 code
- ID:358 - check data length in else branch of ipmi_spd_print()
- ID:361 - Add a OEM IANA information
- ID:363 - Node Manager feature patch.
- ID:363 - fix Coverity issues in NM implementation
- ID:364 - Fix for serial-basic interface bridging
- ID:365 - Fix for ipmitool crash when using serial-terminal interface
- ID:366 - Properly clean LAN and LAN+ interfaces on close
- ID:367 - Fix building of non-bridged LAN interface commands
- ID:368 - Fix handling of bridging-related parameters
- ID:369 - Fix lanplus interface bridging and response matching
- ID:370 - add anonymous union support in CFLAGS for older gcc
- ID:371 - add ericsson oem
- ID:373 - Fix compilation of IMB on Windows
- ID:374 - Check/set LED Duration correctly
- ID:376 - Add means to configure "Bad Password Threshold"
- ID:381 - Script to log installation status as SEL events
- ID:382 - Fix memcpy() params in HpmFwupgActionUploadFirmware()
- ID:383 - Fix compile-time error in src/plugins/lan/lan.c
- ID:384 - Fix compilation under cygwin64
- ID:388 - Fix Error message always printed if BMC does not support VITA
- ID:388 - Handle ccode 0xCC as well in VITA discovery
- ID:388 - Turn all messages into LOG_INFO in VITA discovery
- ID:389 - Add on of Advantech IANA number
- ID:390 - Support for new Communication Interface (USB Medium)
- ID:391 - changing data_len from 17 to 16 according to ipmi spec 22.29,
first byte is completion code
- ID:392 - _ipmi_get_user_name() work-around for some BMCs
- ID:393 - ipmitool man page addition for Node Manager support.
- ID:394 - close fp if isn't NULL and set it NULL afterwards in USB plugin
- ID:394 - plugins/usb: Fix probe for SCSI devices
- ID:395 - Fix fru string without resizing it
- ID:396 - Fixed invalid length check in picmg led cap command.
- ID:397 - Fixed picmg policy set command.
- ID:398 - Fixed channel setaccess command.
- ID:399 - Fixed channel getciphers command.
- ID:401 - Fixed 30 second delay when activating SOL on 'dumb' Intel MACs.
- ID:402 - Misguiding error print-out when using some 'lan' commands.
- Init user_access_t struct in ipmi_user_priv()
- Make user User Privilege Limit is within range
- Node Manager Feature, correct 1268194 missing break.
- Output pidfile only in verbose mode
- Print error message to STDERR in ipmi_channel.c
- Re-work 'channel getaccess' and 'channel setaccess'
- Re-work ccode eval in ipmi_get_channel_medium()
- Remove commented-out code in ipmi_picmg_clk_set() - CID#1261339
- Remove dead code - rsp can't be NULL at this point - CID#1149005
- Remove dead code in fru_area_print_board() - CID#1149001
- Remove dead code in fru_area_print_chassis() - CID#1149000
- Remove dead code in fru_area_print_product() - CID#1148999
- Remove dead(duplicate) code from ipmi_sol_main() - CID#1148996
- Remove get_channel_access_rsp and get_channel_info_rsp structs
- Remove ipmi_user_set_password()
- Remove length checks in get_supermicro_evt_desc()
- Remove redundant user-input conversion from ipmi_sel_delete()
- Remove trailing white-spaces in ipmi_user.c
- Remove trailing white-spaces in ipmi_user.c
- Remove trailing white-spaces in src/plugins/dummy/dummy.c
- Remove unused variable from ipmi_get_channel_cipher_suites()
- Replace deprecated bzero() with memset()
- Replace s6_addr16 with s6_addr since Mac OS X does not have it
- Rewrite ipmi_set_channel_access()
- Split ipmi_user_main() into smaller functions
- ipmi_print_user_summary() to utilize _ipmi_get_user_access()
- ipmitool delloem: ipmitool delloem extension always return success - fix
it
* Mon Nov 24 2014 <gilles.buloz@kontron.com> 1.8.15-1
- ID: 340 - ipmitool sol session improperly closes on packet retry
- ID: 277 - support for hostnames longer than 64 chars
- ID: 313 - ipmitool doesn't support hostname long than 64 symbols
- ID: 277 - Minor issue with ipmi_intf_session_set_hostname()
- ID: 247 - 'sensor thresh' help output is wrong
- ID: 324 - conflicting declaration write_fru_area()
- ID: 337 - Add support for 13G Dell PowerEdge
- ID: 325 - DDR4 DIMM Decoding Logic
- ID: 328 - HPM.2 fixes
- ID: 329 - hpm.1 upgrade fixes
- ID: 103 - picmg discover messages should be DEBUG, not INFO
- ID: 331 - Passwords provided in file (-f option) truncated on space
- ID: 318 - ipmi_tsol.c: fix buffer overflow
- ID: 306 - "fru print" command prints the FRU #0 twice
- ID: 305 - HPM.1 deferred activation support fixup
- ID: 317 - ipmi_fwum.c: fix typo
- ID: 315 - buildsystem: configure.in is deprecated
- ID: 316 - Directory debian is outdated
- ID: 103 - 'lib/ipmi_ekanalyzer.c' needs a re-work
- ID: 46 - SEL OEM record corner case
* Mon May 5 2014 <gilles.buloz@kontron.com> 1.8.14-1
- ID: 299 - openipmi plugin writes zero to wrong byte
- ID: 301 - Add OS/Hypervisor installation status events
- ID: 298 - fix LANplus retry
- ID: 295 - inform user if SOL session disconnected
- ID: 297 - don't print-out SEL entry if ID not present
- ID: 296 - Fix PSD size decoding
- ID: 293 - Use of uninitialized variable in ipmi_main()
- ID: 278 - Error in sol looptest
- ID: 290 - ipmi_sol.c needs a clean-up
- ID: 85 - Supermicro memory ECC error display
- ID: 290 - ipmi_sol.c needs a clean-up
- ID: 286 - Open session retries hit assert in ipmi_lanplus_send_payload
- ID: 285 - Fix SEGV in ipmi_lanplus_open_session
- ID: 284 - Fix SEGV in ipmi_main
- ID: 283 - ipmi_intf_socket_connect fails with IPv4 hosts
- ID: 46 - ipmi_fwum needs some re-work
- ID: 50 - ipmi_hpmfwupg needs a clean up
- ID: 279 - ipmitool sdr list broken
- ID: 44 - dummy interface support - fake-ipmistack project
- ID: 48 - Remove hard-coded FRU inventory access length restriction
- ID: 276 - HPM.1 upgrade combined patch
- ID: 90 - Add options to chassis bootparam set bootflag
- ID: 292 -Properly handle plugin non-zero target adddress with -t
- Numerous Fixes based on running Coverity
- Use TIOCFLUSH if TCFLSH is missing to get the serial plugin building on
Hurd.
- Disable imb and open plugins by default on Hurd. The platform lack
the required kernel support.
- Change serial plugin to only try to disable the IUCLC serial line flag on
platforms supporting it. Fixes build problem on Hurd and FreeBSD.
- PA: 83 - Revised IPv6 patch
- FR: 24 - Exchange OS Name Hostname BMC URL during startup
- ID: 304 - Incorect byteswap in SOL maximum payload
- ID: 303 - Fix build error in HPM.2 code
- ID: 300 - new sunoem functionality
- ID: 144 - Fix 'dcmi power set_limit action <value>'
- ID: 302 - HPM.2 long message support
- ID: 309 - Add new SEL entries for ipmi 2.0 rev 1.1
- ID: 280 - man page cleanup
- ID: 311 - man page update for new sunoem commands
* Mon Sep 9 2013 <gilles.buloz@kontron.com> 1.8.13-1
- ID: 3611905 - Direct Serial Basic/Terminal Mode Interface drivers
- ID: 3577766 - configure's knobs and switches don't work
- ID: 3611253 - do not override OS-default values for interfaces
- ID: 65 - Fixes for configure.in for cross compilation
- ID: 3571153 - OpenIPMI/ipmievd fails to compile on Solaris
- numerous ipmitool man page updates
- ID: 3611226 - Bridging support for PICMG Platforms
- Add support for getsysinfo/setsysinfo commands to ipmi mc
- Cleanup Dell OEM code to use new sysinfo interface
- ID: 93 - str-to-int conversion is weak
- ID: 3582307 - ipmi_fru - ipmi_fru_main() return codes
- ID: 3582310 - ipmi_fru - ipmi_fru_main() - misuse of printf()
- ID: 3576213 - ipmi_fru - unused variable
- ID: 3578276 - ipmi_fru - free() on freed memory possible
- ID: 3578275 - ipmi_fru - memory leaks
- ID: 3528271 - ipmi_fru - possible *flow via FRUID
- ID: 3578277 - ipmi_fru - possible NULL pointer
- ID: 3612372 - Recognize Broadcom IANA number and BCM5725 product
- ID: 3608758 - add IPMI_NETFN_OEM
- ID: 143 - Reversed 'channel authcap' capabilities
Fixes reversed IPMIv1.5/2.0 'channel authcap' capabilities
- ID: 3587318 - "dcmi discover" is not DCMI 1.5 compatible
- ID: 3608757 - ipmi_fru - various fixes
- ID: 3598203 - 'mc getsysinfo|setsysinfo' needs a bit of re-work
- ID: 3597782 - ipmi_mc - sysinfo_param() has two consecutive returns
- ID: 3597781 - 'mc getsysinfo|setsysinfo' help has typos
- ID: 3608763 - ipmi_sdr - code cleanup & output display cleanup
- ID: 3610286 - ipmi_sdr - ipmi_sdr_print_type - incorrect eval
- ID: 3600930 - ipmi_sdr - code cleanup
- ID: 3602439 - ipmi_sdr - memory leaks
- ID: 3595199 - ipmi_sdr - Add support for 'ipmitool sdr <list|elist> help'
- ID: 3592773 - 'ipmitool sdr info'; prints incorrect info
- ID: 3592770 - 'ipmitool sdr list|elist INV_INPUT' return code
- ID: 3577159 - ipmi_sdr - uint32_t cast to uint8_t and back
- ID: 3528368 - ipmi_sdr - possible int *flow
- ID: 226 - ipmi_sdradd - typo
- ID: 258 - ipmi_sdradd - error printed on STDOUT
- Fixed ipmievd start under systemd.
- ID: 3608760 - Add bswap.h to ipmi_chassis.c and ipmi_pef.c
- ID: 3564701 - ipmitool 1.8.12 doesn't build on big endian architectures
- ID: 3600907 - defined value for "Chassis may not support Force Identify"
- ID: 256 - ipmitool could crash when IPv6 address is returned
- ID: 211 - 'lib/ipmi_dcmi.c' - typo & error printed on STDOUT
- ID: 3612237 - If DCMI command fails, incorrect completion code is printed
- ID: 3608149 - ipmitool - set pointer to NULL after free()
- ID: 3603419 - DCMI - waste of resources
- ID: 3600908 - DMCI - crash in ipmi_print_sensor_info(), NULL ref
- ID: 3609985 - delloem : Wrong MAC returned when flex addressing is enabled
- ID: 113 - delloem exec file won't handle more than one command
- ID: 28 - delloem - clean up the code
- ID: 3608261 - delloem - code formatting
- ID: 3528247 - delloem - fix possible *int flows
- ID: 3600910 - delloem - code cleanup
- ID: 3576211 - delloem - unused variable
- ID: 3578022 - delloem - fix typos
- ID: 263 - ipmi_ek* - cleanup
- ID: 3308765 - ipmi_ek* - cleanup
- ID: 3586228 - ipmi_ek* - ipmi_ekanalyzer_usage() rework
- ID: 3528388 - ipmi_ek* - a typo in error message
- ID: 3576212 - ipmi_event - better rsp handling
- ID: 3607393 - ipmi_event - redundant '\n' in error message
- ID: 153 - ipmi_firewall - printf() used instead of lprintf()
- ID: 3608003 - ipmi_fru - atol() should be replaced with str2*()
- ID: 3600911 - ipmi_fru - fix multiple increments in args to printf
- ID: 3600914 - no more crash on no response. allow more send/recv loops of waiting.
- ID: 70 - Fixes and updates for ipmitool hpm
- ID: 3528308 - ipmi_hpmfwupg - possible int *flow
- ID: 3608762 - ipmi_hpmfwup - Fixed help messages for hpm command
- ID: 3607981 - ipmi_lanp - replace atoi() calls
- ID: 3607320 - ipmi_lanp - possible NULL reference
- ID: 3600926 - ipmi_lanp - code cleanup
- ID: 3613575 - memory leak - ipmi_password_file_read()
- ID: 3522740 - reading password from file is limited to 16byte passwords
- ID: 3613605 - ipmi_main - call free() on pointer to static data
- ID: 3608761 - ipmi_main - PICMG Get Device Locator was never run
- ID: 3577155 - ipmi_main' - memory leaks
- ID: 239 - typo in 'mc selftest', add details
- ID: 3597471 - ipmi_mc - needs a bit of re-work - rc, inv. options
- ID: 3597468 - ipmi_mc - print_mc_usage() prints to STDOUT
- ID: 3597469 - 'mc watchdog off' prints on STDERR, should be STDOUT
- ID: 3597470 - 'mc watchdog reset' prints on STDERR, should be STDOUT
- ID: 3611254 - OEM handle for Intel 82751 in SPT mode
- ID: 3600927 - change eval order of input param in ipmi_oem_setup()
- ID: 3600928 - ipmi_pef - code cleanup
- ID: 3592732 - ipmi_picmg.c - printf() misuse
- ID: 3528310 - ipmi_picmg.c - NULL reference
- ID: 3528347 - ipmi_raw.c - possible int *flow
- ID: 3587913 - Command % ipmitool raw help; returns 1
- Added code to support sensors on other luns (On behalf of Kontron Germany)
- ID: 3611912 - Add missing newlines when cvs output is specified
- ID: 244 - ipmi_sel - "0.0" displayed for unspecified threshold values
- ID: 3612371 - Typo in impi_sel debug output
- ID: 3016359 - ipmi_sel - Get SEL Alloc Information is incorrect
- ID: 3568976 - 'sel set time' behaviour is inconsistent
- ID: 3528371 - ipmi_sensor - possible int *flow
- ID: 3601265 - 'ipmitool sensor get' leaks memory
- ID: 3601106 - 'ipmitool sensor get NACname' output incorrect/inconsistent
- ID: 3608007 - ipmi_session - typo in error message
- ID: 101 - ipmi_sol - possible int *flow
- ID: 3600933 - ipmi_sol - use of deprecated bzero()
- ID: 3609472 - ipmi_sol - Add the instance to the SOL commands
- ID: 3588726 - 'ipmitool sol payload status ...;'segfaults on no rsp
- ID: 3522731 - ipmi_sol - ipmi_get_sol_info() returns always 0
- ID: 3613042 - add missing Entity IDs
- ID: 3611306 - ipmi_tsol - fix always fail in case of error
- ID: 259 - ipmi_user - memory leak
- ID: 260 - ipmi_user - replace atoi() call
- ID: 2871903 - ipmitool user priv incorrectly sets Link Auth
- ID: 3600960 - check the copy of password exists
- ID: 3609473 - Add assertion/deassertion to threshold events
- ID: 104 - ipmishell - possible int *flow
- ID: 262 - 'set' segfaults when no IPMI inf present
- ID: 257 ipmitool exec segfaults if invalid input given
- ID: 254 - Fix retry of authentication capabilities retrieval
- ID: 3611303 - lan - error check is missing braces
- ID: 253 - Fix lanplus retransmission
- ID: 212 - 'lib/ipmi_dcmi.c' - possible int *flow
- ID: 264 - incorrect array index in get_lan_param_select()
- ID: 269 - Fixes for configure.in for cross compilation
- ID: 267 - Corruption in "lan alert print" output
- ID: 41 - ipmi_sel_interpret() - clean up formatting, indentation
- ID: 242 - Incorrect DCMI Power Reading "IPMI timestamp" interpretation
- ID: 229 - 'lib/ipmi_ekanalyzer.c' - a typo ``Too few argument!''
- ID: 266 - file descriptor leak in ipmi_fwum and ipmi_ekanalyzer
- ID: 99 - 'lib/ipmi_sel.c' - possible int *flow
- ID: 222 - 'lib/ipmi_sdr.c' - a typo 'Not Reading' -> 'No Reading'
- ID: 35 - Script to setup redirection of SNMP to/from BMC
- ID: 273 - Reduce SOL Input buffer size by SOL header size
* Thu Aug 9 2012 <gilles.buloz@kontron.com> 1.8.12-1
- Added IPMB dual bridge support (no need for driver support)
- Enable compiler warnings and resolve all compiler warning so that
ipmitool compiles and links with no warning or error messages
- add ipmishell line to configure
- fail configure when no curses or readline is found
- support sensor bridging in free interface
- applied fix for issue #2865160 (AIX build)
- Document the ipmitool dcmi commands in the ipmitool man page
- Document that some commands are blocked by OpenIPMI. ID 2962306
- Document the -N and -R options per tracker ID 3489643
- fix manpage misdocumentation on cipher suite privilige configuration
- Add build support for Dell OEM commands
- Add new Dell OEM commands and update man page
- added hpm and fwum in man page
- man page update for fwum and hpm commands
- Added documentation for 'ime' operating mode, used to update Intel ME.
- add new -Y option to prompt user to enter kgkey
- Add DCMI module (Data Center Management Interface)
- fixed oem/iana data type to allow 24 bits definition
- Fixed AMC point-to-point record parsing in FRU
- Fixed detection of packing support in GCC
- Added packing support detection magic on all packed structures
in project
- Dell specific mac sub command is updated to support the latest 12G
Dell servers. Support for virtual mac is also implemented.
- Use consistent netfn/cmd for getsysinfo command
- Add Dell OEM network commands
- Resolve incorect Board Mfg Data due to incorrect date constant
- Update ipmi_fru.h to SMBIOS spec 2.6.1 - ID 2916398
- Support for analog readings in discrete sensors on HP platforms.
- Change device id mask (IPM_DEV_DEVICE_ID_REV_MASK) 0x07 for 0x0F.
As per in IPMI spec V2:
- Added PICMG clock e-keying and bused resource control identifiers
- Added PICMG major version (ATCA/AMC/uTCA) identifiers
- Correct Threshold/Discrete Sensor Display - Patch Tracker ID 3508759
- Sensor units now handle percentage units - ID 3014014
- Fixes ID 3421347 Sensor list command should use channel field from SDR
- Added packing directive for ARM cross compile with GCC 3.4.5,
otherwise the sdr structures gets padded and the pointer cast
result in incorrect alignement
- Added 'sdr fill sensors nosats' support to speed up SDR discovery
- Added SDR name display during discovery (with -v)
- Added support for sensor types - Processor related sensor
type 0x07, system incharectorization 0x20, Memory sensor type.
- Give more description for SEL which is generated for Uncorrectable
ECC and errors with respect to each Memory Bank,Card or DIMM.
The Sensor type supporting this are 0x0C and 0x10.
- Add more details about Version Change event (source of
firmware update)
- enhanced PICMG fru control
- Integrated Andy Wray's DDR3 SPD parser patch
- Adds function str2uint() to convert from string to uint32_t with
checks for valid input.
- Fix possible buffer overflow in buf2str()
- Fixes ID 3485004 - misuse of strtol()
- Replaces calls to strtol() with str2uchar() calls and adds error
messages if invalid input is given.
- Don't overwite the iflags bits prior to setting the boot parameters.
This fixes ipmitool so that
chassis bootdev bios clear-cmos=yes
will correctly clear the bios cmos.
- Clarify DCMI get limit activation (add if activate or not).
- Bug fixes for delloem lan command. This includes the support for 12G
Dell license and 12G LAN Specific command.
- delloem commands should not be executed before parsing command line.
- Fix stack overflow in delloem setled
- Fix delloem powermonitor on big-endian platforms.
- ipmitool delloem powermonitor command should convert data from
network-format to the native one, otherwise it shows garbage
on ppc/ppc64 platform.
- Add ipmi_getsysinfo command
- Add support for drive backplane SetLED functionality
- Fix for Platform Event Message incorrect Generator ID
- Fix fru print so that it will display FRU info from satellite
controllers.
- Add support for AMC type 17h record.
- Fix in fru edit. It is now possible to edit field 0 of sections
- New FRU get OEM record command
- fixed segfault for fru edit when "field id" is not supported and
added user feedback for string substitution(success or failure)
- Improvement to hpm upgrade during activation. This resolves issue
where activation seems to have failed because ipmitool received
an unsupported completion code.
- hpm Fixes for multi-platform support.
- hpm Fix for timeouts during firmware rollback. If completion code
is C3, wait till timeout has expired before reporting it.
- hpm During manual rollback, code now gets target capabilities
instead of using a default timeout of 60 seconds.
- Added firmware auxilliary bytes to hpm outputs
- hpm Add support for BIG Buffer (Use when -z option is used)
- Fix the case where ipmitool loses the iol connection during the upload
block process. Once IPMITool was successfully sent the first
byte, IPMITool will not resize the block size.
- Fix the problem when we try to upgrade specific component and the
component is already updated,
- updated HPM firmware agent to version 1.04
- Fix exit code to return zero on '-o list' or '-o help' option
- limit length of user name and password that can be supplied by user.
Password is limited to 16 bytes, resp. 20 bytes, for LAN, resp.
LAN+, interface. User name is limited to 16 bytes, no interface
limitations. ID 3184687, ID 3001519
- Add retry / timeout options for LAN
- Changed default cipher suite to 1 instead of 3 for iol20
- added fix for tracker ID 2849300 "Incorrect Firmware Revision"
- avoid reopening the interface when already opened
- Remove message for unsupported PEF capabilities that return valid
CC (80h)
- Added OEM byte (47) to verbose output
- Add option to provide a list when filling sdr repository
- SDR discovery speedups
- Added support for Dell specific sensors
- Fix segmentation fault on unrecognize OEM events.
- changed SEL timestamp formatting for 'preinit' SEL entries, allowing
the number of seconds to be displayed.
- Added sensor raw data in verbose mode. Useful for OEM sensor type.
- Add sensor hysteresis (positive & negative) to the following command
ipmitool sensor -v
- Fixes bug ID 3484936 - missing user input validation
- Add missing RMCP+ auth type strings
- Add new Kontron Product in ipmi_strings for product ID. Kontron
KTC5520/EATX Server Motherboard with integrated iBMC/KVM/VM
added identification support for Kontron AT8050 ATCA board
- Constrain setting of the username to no greater than 16 characters
per the IPMI specification. ID 3001519
- Constrain User ID between 1 and 63. ID 3519225
- Fixes ID 3485340 - user input not handled in 'lib/ipmi_user.c'
- Fixes ignorance of existing daemon PID file which results in PID being
overwritten. Adds proper umask() before writing PID file.
- applied fix for ID 2865111 (AIX build)
- Fix a proplem when using bridged IPMI commands on the lanplus
interface (-I lanplus with -b -t or -m switches) resulting in
"Close Session command failure".
- Add fix with usage of CFh (duplicate request). Usefull for
slow commands
- Fix issue with sequence number. (Speed up transfer)
* Wed Feb 25 2009 <pere@hungry.com> 1.8.11-1 * Wed Feb 25 2009 <pere@hungry.com> 1.8.11-1
- Fix new GCC compilation issues in regards to Packing - Fix new GCC compilation issues in regards to Packing
- Fix Tracker bug #1642710 - ipmi_kcs_drv being loaded/unloaded - Fix Tracker bug #1642710 - ipmi_kcs_drv being loaded/unloaded
@ -881,7 +257,7 @@ fi
- Make ipmievd generate pidfile - Make ipmievd generate pidfile
- Add initscripts for ipmievd - Add initscripts for ipmievd
* Tue Jan 17 2006 <duncan@iceblink.org> 1.8.6-1 * Mon Jan 17 2006 <duncan@iceblink.org> 1.8.6-1
- Fix memory corruption when sending encrypted SOL traffic - Fix memory corruption when sending encrypted SOL traffic
- Add keepalive timer to IPMIv2 SOL sessions - Add keepalive timer to IPMIv2 SOL sessions
@ -949,7 +325,7 @@ fi
- new "shell" and "exec" commands - new "shell" and "exec" commands
- lots of other contributed patches - lots of other contributed patches
* Thu May 27 2004 <duncan@iceblink.org> 1.5.9-1 * Sat May 27 2004 <duncan@iceblink.org> 1.5.9-1
- Add ability to get a particular sensor by name - Add ability to get a particular sensor by name
- Add ability to set a particular sensor threshold - Add ability to set a particular sensor threshold
- Add support for displaying V2 channel authentication levels - Add support for displaying V2 channel authentication levels
@ -983,7 +359,7 @@ fi
- Fix SEL event decoding for generic events - Fix SEL event decoding for generic events
- Handle empty SEL gracefully when doing "sel list" - Handle empty SEL gracefully when doing "sel list"
- Fix sdr handling of sensors that do not return a reading - Fix sdr handling of sensors that do not return a reading
- Fix for CSV display of sensor readings/units from Fredrik Öhrn - Fix for CSV display of sensor readings/units from Fredrik Öhrn
* Tue Nov 25 2003 <duncan@iceblink.org> 1.5.5-1 * Tue Nov 25 2003 <duncan@iceblink.org> 1.5.5-1
- Add -U option for setting LAN username - Add -U option for setting LAN username

12
control/rpmmacros.in Normal file
View File

@ -0,0 +1,12 @@
%_topdir %(echo $BUILDDIR)
%_sourcedir %{_topdir}/..
%_specdir %{_sourcedir}
%_tmppath %{_topdir}/tmp
%_builddir %{_topdir}/BUILD
%_buildroot %{_topdir}/%{_tmppath}/%{name}-%{version}-root
%_rpmdir %{_topdir}/RPMS
%_srcrpmdir %{_topdir}/SRPMS
%_distro @DISTRO@
%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%packager jmank@hp.com
%distribution Sourceforge Build

8
control/rpmrc Normal file
View File

@ -0,0 +1,8 @@
macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/etc/rpm/macros.specspo:/etc/rpm/macros:/etc/rpm/%{_target}/macros:%(echo $CONFIGDIR)/rpmmacros
buildarchtranslate: athlon: i386
buildarchtranslate: i686: i386
buildarchtranslate: i586: i386
buildarchtranslate: i486: i386
buildarchtranslate: i386: i386

View File

@ -1,10 +0,0 @@
#!/bin/sh
git describe --first-parent --tags 2>/dev/null | (
IFS=- read tag rev hash
if [ $? ] && [ -n "$rev" ]; then
echo .$rev.$hash
elif [ -d .git ]; then
echo .0.gsnapshot
fi
)

View File

@ -145,7 +145,7 @@ placed at the end of commands to get option usage help.
> ipmievd help > ipmievd help
.br .br
Commands: Commands:
open Use OpenIPMI for asynchronous notification of events open Use OpenIPMI for asyncronous notification of events
sel Poll SEL for notification of events sel Poll SEL for notification of events
.TP .TP
@ -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>
@ -217,16 +217,6 @@ Reading Sensors...
.br .br
Waiting for Events... Waiting for Events...
.br .br
.SH FILES
.TP
.B @IANADIR@/enterprise-numbers
system IANA PEN registry taken from http://www.iana.org/assignments/enterprise-numbers
.TP
.B ~/@IANAUSERDIR@/enterprise-numbers
user's override for the system IANA PEN registry, this file if it exists is loaded instead
of the system registry (see above).
.SH "AUTHOR" .SH "AUTHOR"
Duncan Laurie <duncan@iceblink.org> Duncan Laurie <duncan@iceblink.org>
.SH "SEE ALSO" .SH "SEE ALSO"

View File

@ -3,13 +3,12 @@
ipmitool \- utility for controlling IPMI\-enabled devices ipmitool \- utility for controlling IPMI\-enabled devices
.SH "SYNOPSIS" .SH "SYNOPSIS"
.BR ipmitool ipmitool [ <options> ] <command> [ <sub-commands and sub-options> ]
[ <options> ] <command> [ <sub-commands and sub-options> ]
<options> := [ <general-options> | <conditional-opts> ] <options> := [ <general-options> | <conditional-opts> ]
.br
Any recognized option is accepted. Conditional options may be ignored or it's Any recognized option is accepted. Conditional options may be ignored or it's usage postponed until shell or exec processes relevant command.
usage postponed until shell or exec processes relevant command. .br
<general\-options> := [ \-h | \-V | \-v | \-I <interface> | \-H <address> | <general\-options> := [ \-h | \-V | \-v | \-I <interface> | \-H <address> |
\-d <N> | \-p <port> | \-c | \-U <username> | \-d <N> | \-p <port> | \-c | \-U <username> |
@ -67,9 +66,8 @@ called \fIOpenIPMI\fP and it is included in standard distributions.
On Solaris this driver is called \fIBMC\fP and is included in Solaris 10. On Solaris this driver is called \fIBMC\fP and is included in Solaris 10.
Management of a remote station requires the IPMI\-over\-LAN interface to be Management of a remote station requires the IPMI\-over\-LAN interface to be
enabled and configured. Depending on the particular requirements of each enabled and configured. Depending on the particular requirements of each
system it may be possible to enable the LAN interface using system it may be possible to enable the LAN interface using ipmitool over
.BR ipmitool the system interface.
over the system interface.
.SH "OPTIONS" .SH "OPTIONS"
.TP .TP
\fB\-a\fR \fB\-a\fR
@ -97,14 +95,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
@ -219,7 +212,7 @@ Increase verbose output level. This option may be specified
multiple times to increase the level of debug output. If given multiple times to increase the level of debug output. If given
three times you will get hexdumps of all incoming and three times you will get hexdumps of all incoming and
outgoing packets. Using it five times provides details outgoing packets. Using it five times provides details
on request and expected reply processing. The \fIhpm\fP commands on request and expected reply procesing. The \fIhpm\fP commands
\fItargetcap\fP \fIcompprop\fP \fIabort\fP \fIupgstatus\fP \fItargetcap\fP \fIcompprop\fP \fIabort\fP \fIupgstatus\fP
\fIrollback\fP \fIrollbackstatus\fP \fIselftestresult\fP increases \fIrollback\fP \fIrollbackstatus\fP \fIselftestresult\fP increases
the verbosity level the verbosity level
@ -241,9 +234,8 @@ Prompt for the Kg key for IPMIv2.0 authentication.
Change Size of Communication Channel. (OEM) Change Size of Communication Channel. (OEM)
.LP .LP
If no password method is specified then If no password method is specified then ipmitool will prompt the
.BR ipmitool user for a password. If no password is entered at the prompt,
will prompt the user for a password. If no password is entered at the prompt,
the remote server password will default to NULL. the remote server password will default to NULL.
.SH "SECURITY" .SH "SECURITY"
There are several security issues be be considered before enabling the There are several security issues be be considered before enabling the
@ -264,23 +256,19 @@ system. It is thus recommended that IPMI password management only be done
over IPMIv2.0 \fIlanplus\fP interface or the system interface on the over IPMIv2.0 \fIlanplus\fP interface or the system interface on the
local station. local station.
For IPMI v1.5, the maximum password length is 16 characters; longer For IPMI v1.5, the maximum password length is 16 characters.
passwords might be truncated or rejected by the server, or rejected Passwords longer than 16 characters will be truncated.
by
.BR ipmitool .
For IPMI v2.0, the maximum password length is 20 characters; longer
passwords will be rejected by
.BR ipmitool .
For IPMI v2.0, the maximum password length is 20 characters;
longer passwords are truncated.
.SH "COMMANDS" .SH "COMMANDS"
.TP .TP
\fIhelp\fP \fIhelp\fP
This can be used to get command\-line help on This can be used to get command\-line help on ipmitool
.BR ipmitool commands. It may also be placed at the end of commands
commands. It may also be placed at the end of commands to get option usage help. to get option usage help.
> ipmitool help ipmitool help
.br .br
Commands: Commands:
bmc Deprecated. Use mc bmc Deprecated. Use mc
@ -393,23 +381,39 @@ application (ipmi or sol) on the given channel.
\fIstatus\fP \fIstatus\fP
Status information related to power, buttons, cooling, drives and faults. Status information related to power, buttons, cooling, drives and faults.
.RS
.RE
.TP .TP
\fIpower\fP \fIpower\fP
.RS .RS
.TP .TP
\fIstatus\fP \fIstatus\fP
.RS
.RE
.TP .TP
\fIon\fP \fIon\fP
.RS
.RE
.TP .TP
\fIoff\fP \fIoff\fP
.RS
.RE
.TP .TP
\fIcycle\fP \fIcycle\fP
.RS
.RE
.TP .TP
\fIreset\fP \fIreset\fP
.RS
.RE
.TP .TP
\fIdiag\fP \fIdiag\fP
.RS
.RE
.TP .TP
\fIsoft\fP \fIsoft\fP
.RS
.RE
.RE .RE
.TP .TP
\fIidentify\fP [<seconds>|force] \fIidentify\fP [<seconds>|force]
@ -421,6 +425,8 @@ Default is 15 seconds.
0 - Off 0 - Off
.br .br
force - To turn on indefinitely force - To turn on indefinitely
.RS
.RE
.TP .TP
\fIpolicy\fP \fIpolicy\fP
@ -430,22 +436,34 @@ What to do when power is restored.
\fIlist\fP \fIlist\fP
Show available options. Show available options.
.RS
.RE
.TP .TP
\fIalways-on\fP \fIalways-on\fP
.RS
.RE
.TP .TP
\fIprevious\fP \fIprevious\fP
.RS
.RE
.TP .TP
\fIalways-off\fP \fIalways-off\fP
.RS
.RE
.RE .RE
.TP .TP
\fIrestart_cause\fP \fIrestart_cause\fP
Last restart cause. Last restart cause.
.RS
.RE
.TP .TP
\fIpoh\fP \fIpoh\fP
Get power on hours. Get power on hours.
.RS
.RE
.TP .TP
\fIbootdev\fP \fIbootdev\fP
.RS .RS
@ -453,123 +471,95 @@ Get power on hours.
\fInone\fP \fInone\fP
Do not change boot device order. Do not change boot device order.
.RS
.RE
.TP .TP
\fIpxe\fP \fIpxe\fP
Force PXE boot. Force PXE boot.
.RS
.RE
.TP .TP
\fIdisk\fP \fIdisk\fP
Force boot from default Hard-drive. Force boot from default Hard-drive.
.RS
.RE
.TP .TP
\fIsafe\fP \fIsafe\fP
Force boot from default Hard-drive, request Safe Mode. Force boot from default Hard-drive, request Safe Mode.
.RS
.RE
.TP .TP
\fIdiag\fP \fIdiag\fP
Force boot from Diagnostic Partition. Force boot from Diagnostic Partition.
.RS
.RE
.TP .TP
\fIcdrom\fP \fIcdrom\fP
Force boot from CD/DVD. Force boot from CD/DVD.
.RS
.RE
.TP .TP
\fIbios\fP \fIbios\fP
Force boot into BIOS Setup. Force boot into BIOS Setup.
.RS
.RE
.TP .TP
\fIfloppy\fP \fIfloppy\fP
Force boot from Floppy/primary removable media. Force boot from Floppy/primary removable media.
.RE
.TP
\fIbootmbox\fP \fIget\fP [text] [block <\fBblock#\fP>]
Read the Boot Initiator Mailbox in hex dump or in text mode.
By default the whole mailbox is read. If block number is specified,
that particular block is read. For block 0 or when the whole
mailbox is read, the Boot Initiator IANA Enterprise Number and
the corresponding enterprise name are printed.
.TP
\fIbootmbox\fP \fIset\fP text [block <\fBblock#\fP>] <\fBIANA_PEN\fP> "<\fBdata_string\fP>"
Write the specified <block> or the entire Boot Initiator Mailbox in text mode.
It is required to specify a decimal IANA Enterprise Number recognized
by the boot initiator on the target system. Refer to your target system
manufacturer for details. The rest of the arguments are a text string.
When single block write is requested, the total length of <data> may not
exceed 13 bytes for block 0, or 16 bytes otherwise.
.TP
\fIbootmbox\fP \fIset\fP [block <\fBblock#\fP>] <\fBIANA_PEN\fP> <\fBdata_byte\fP> [<\fBdata_byte\fP> ...]
Same as above, but the arguments after IANA PEN are separate
data byte values separated by spaces.
.TP
\fIbootparam\fP \fIget\fP <\fBopt_id\fR> [<\fBopt_param\fR>]
Get value of system boot option number <\fBopt_id\fR>. Some boot
options (e.g. option 7) can also take an optional numeric parameter.
.TP
\fIbootparam\fP \fIset\fP bootflag <\fBdevice\fR> [options=...]
Set a boot flag. Valid devices are:
.RS .RS
.IP \fIforce_pxe\fP .RE
.RE
.TP
\fIbootparam\fP
.RS
.TP
\fIforce_pxe\fP
Force PXE boot Force PXE boot
.IP \fIforce_disk\fP .RS
.RE
.TP
\fIforce_disk\fP
Force boot from default Hard-drive Force boot from default Hard-drive
.IP \fIforce_safe\fP .RS
.RE
.TP
\fIforce_safe\fP
Force boot from default Hard-drive, request Safe Mode Force boot from default Hard-drive, request Safe Mode
.IP \fIforce_diag\fP .RS
.RE
.TP
\fIforce_diag\fP
Force boot from Diagnostic Partition Force boot from Diagnostic Partition
.IP \fIforce_cdrom\fP .RS
.RE
.TP
\fIforce_cdrom\fP
Force boot from CD/DVD Force boot from CD/DVD
.IP \fIforce_bios\fP .RS
.RE
.TP
\fIforce_bios\fP
Force boot into BIOS Setup Force boot into BIOS Setup
.RS
.PP .RE
Valid options are:
.IP \fIPEF\fP
Clear valid bit on reset/power cycle cause by PEF
.IP \fItimeout\fP
Automatically clear boot flag valid bit on timeout
.IP \fIwatchdog\fP
Clear valid bit on reset/power cycle cause by watchdog
.IP \fIreset\fP
Clear valid bit on push button reset/soft reset
.IP \fIpower\fP
Clear valid bit on power up via power push button or wake event
.RE .RE
.TP .TP
\fIselftest\fP \fIselftest\fP
.RS
Get the chassis self-test results .RE
.RE .RE
.TP .TP
\fIdcmi\fP \fIdcmi\fP
@ -964,6 +954,8 @@ Shows Extended SD Card information.
\fIecho\fP \fIecho\fP
For echoing lines to stdout in scripts. For echoing lines to stdout in scripts.
.RS
.RE
.TP .TP
\fIekanalyzer\fP <\fBcommand\fR> <\fBxx=filename1\fR> <\fBxx=filename2\fR> [<\fBrc=filename3\fR>] \fB...\fR \fIekanalyzer\fP <\fBcommand\fR> <\fBxx=filename1\fR> <\fBxx=filename2\fR> [<\fBrc=filename3\fR>] \fB...\fR
.RS .RS
@ -1223,13 +1215,12 @@ Get a list of all the possible Sensor States and pre-defined Sensor State
Shortcuts available for a particular sensor. \fBsensorid\fR is the character Shortcuts available for a particular sensor. \fBsensorid\fR is the character
string representation of the sensor and must be enclosed in double quotes string representation of the sensor and must be enclosed in double quotes
if it includes white space. Several different commands including if it includes white space. Several different commands including
.BR ipmitool \fIipmitool sensor list\fP may be used to obtain a list that includes
\fIsensor list\fP may be used to obtain a list that includes
the \fBsensorid\fR strings representing the sensors on a given system. the \fBsensorid\fR strings representing the sensors on a given system.
.RS .RS
.PP .PP
> ipmitool \-I open event "PS 2T Fan Fault" list > ipmitool \-I open event "PS 2T Fan Fault" list
.br .br
Finding sensor PS 2T Fan Fault... ok Finding sensor PS 2T Fan Fault... ok
.br .br
Sensor States: Sensor States:
@ -1286,9 +1277,7 @@ Finding sensor PS 2T Fan Fault... ok
\fIexec\fP <\fBfilename\fR> \fIexec\fP <\fBfilename\fR>
.RS .RS
Execute Execute ipmitool commands from \fIfilename\fR. Each line is a
.BR ipmitool
commands from \fIfilename\fR. Each line is a
complete command. The syntax of the commands are defined by the complete command. The syntax of the commands are defined by the
COMMANDS section in this manpage. Each line may have an optional COMMANDS section in this manpage. Each line may have an optional
comment at the end of the line, delimited with a `#' symbol. comment at the end of the line, delimited with a `#' symbol.
@ -1515,14 +1504,20 @@ Show firmware upgrade log.
\fIlist\fP \fIlist\fP
List All Generic Device Locators. List All Generic Device Locators.
.RS
.RE
.TP .TP
\fIread\fP <\fBsdr name\fR> <\fBfile\fR> \fIread\fP <\fBsdr name\fR> <\fBfile\fR>
Read to file eeprom specify by Generic Device Locators. Read to file eeprom specify by Generic Device Locators.
.RS
.RE
.TP .TP
\fIwrite\fP <\fBsdr name\fR> <\fBfile\fR> \fIwrite\fP <\fBsdr name\fR> <\fBfile\fR>
Write from file eeprom specify by Generic Device Locators Write from file eeprom specify by Generic Device Locators
.RS
.RE
.RE .RE
.TP .TP
\fIhpm\fP \fIhpm\fP
@ -1697,9 +1692,7 @@ user, operator, admin, oem.
\fIactivate\fP \fIactivate\fP
.br .br
Causes Causes ipmitool to enter Intel IPMI v1.5 Serial Over LAN mode. An RMCP+
.BR ipmitool
to enter Intel IPMI v1.5 Serial Over LAN mode. An RMCP+
connection is made to the BMC, the terminal is set to raw mode, and user connection is made to the BMC, the terminal is set to raw mode, and user
input is sent to the serial console on the remote server. On exit, input is sent to the serial console on the remote server. On exit,
the SOL payload mode is deactivated and the terminal is reset to its the SOL payload mode is deactivated and the terminal is reset to its
@ -1711,9 +1704,9 @@ Special escape sequences are provided to control the SOL session:
.TP .TP
\fI~.\fP Terminate connection \fI~.\fP Terminate connection
.TP .TP
\fI~^Z\fP Suspend \fBipmitool\fR \fI~^Z\fP Suspend ipmitool
.TP .TP
\fI~^X\fP Suspend \fBipmitool\fR, but don't restore tty on restart \fI~^X\fP Suspend ipmitool, but don't restore tty on restart
.TP .TP
\fI~B\fP Send break \fI~B\fP Send break
.TP .TP
@ -1751,8 +1744,7 @@ Select the next boot order on the Kontron CP6012.
.RS .RS
These commands will allow you to configure IPMI LAN channels These commands will allow you to configure IPMI LAN channels
with network information so they can be used with the with network information so they can be used with the ipmitool
..BR ipmitool
\fIlan\fP and \fIlanplus\fP interfaces. \fINOTE\fR: To \fIlan\fP and \fIlanplus\fP interfaces. \fINOTE\fR: To
determine on which channel the LAN interface is located, issue determine on which channel the LAN interface is located, issue
the `channel info \fInumber\fR' command until you come across the `channel info \fInumber\fR' command until you come across
@ -2025,74 +2017,9 @@ The default will clear statistics on the first found LAN channel.
Instructs the BMC to perform a warm or cold reset. Instructs the BMC to perform a warm or cold reset.
.TP .TP
\fIguid\fP [\fBsmbios\fR|\fBrfc4122\fR|\fBipmi\fR|\fBdump\fR] \fIguid\fP
Display the Management Controller Globally Unique IDentifier. Display the Management Controller Globally Unique IDentifier.
.RS
.TP
\fIauto\fP
.br
This is the default behavior for
.BR ipmitool (1).
Try to automatically detect the encoding based on the value of the
version field and (for version 1) the timestamp. The version is
considered valid if it is 1 through 5, and the timestamp is valid
if the year is past or equal to UNIX Epoch (1970) and is before or
equal to the current year.
If multiple encodings happen to have valid version fields, then
precedence takes the one with version 1 and a valid timestamp. If
neither one has that, then the precedence order is as follows:
\fIsmbios\fP, \fIipmi\fP, \fIrfc4122\fP.
If neither encoding yields a valid version field, then
.BR ipmitool (1)
defaults to \fIdump\fP mode.
If this option is in use, then
.BR ipmitool (1)
will also print out the detected encoding and warn
regarding IPMI specification violation if the encoding isn't \fIipmi\fP.
.TP
\fIsmbios\fP
.br
Decode GUID as if it was sent by BMC as prescribed by SMBIOS specification.
\fBNOTE:\fR This is a violation of IPMI specification, but many BMC implementations do
it this way. If your BMC's GUID is shown correctly using this option, you
may want to inform your BMC manufacturer that they have a bug.
.TP
\fIipmi\fP
.br
Decode GUID according to IPMI specification. It MUST show the correct GUID.
If it doesn't, try other options and inform your BMC manufacturer of the bug.
.TP
\fIrfc4122\fP or \fIrfc\fP
.br
Decode GUID as if it was sent by BMC as prescribed by RFC4122 specification.
\fBNOTE:\fR This is a violation of IPMI specification.
If your BMC's GUID is shown correctly using this option, you
may want to inform your BMC manufacturer that they have a bug.
.TP
\fIdump\fP
.br
Dump as hex the data received from BMC in response to Get Device GUID command.
No decoding or interpretation is performed. First received byte is dumped first.
.RE
.TP .TP
\fIinfo\fP \fIinfo\fP
.br .br
@ -2959,9 +2886,7 @@ A list of all entity ids can be found in the IPMI specifications.
Dumps raw SDR data to a file. This data file can then be used as Dumps raw SDR data to a file. This data file can then be used as
a local SDR cache of the remote managed system with the \fI\-S <file>\fP a local SDR cache of the remote managed system with the \fI\-S <file>\fP
option on the option on the ipmitool command line. This can greatly improve performance
.BR ipmitool
command line. This can greatly improve performance
over system interface or remote LAN. over system interface or remote LAN.
.TP .TP
\fIfill\fP \fIsensors\fP \fIfill\fP \fIsensors\fP
@ -3044,9 +2969,7 @@ Print information on the specified SEL Record entry.
\fIsave\fP <\fBfile\fR> \fIsave\fP <\fBfile\fR>
Save SEL records to a text file that can be fed back into the Save SEL records to a text file that can be fed back into the
\fIevent file\fP \fIevent file\fP ipmitool command. This can be useful for
.BR ipmitool
command. This can be useful for
testing Event generation by building an appropriate Platform testing Event generation by building an appropriate Platform
Event Message file based on existing events. Please see the Event Message file based on existing events. Please see the
available help for the 'event file ...' command for a description of available help for the 'event file ...' command for a description of
@ -3055,16 +2978,12 @@ the format of this file.
\fIwriteraw\fP <\fBfile\fR> \fIwriteraw\fP <\fBfile\fR>
Save SEL records to a file in raw, binary format. This file can Save SEL records to a file in raw, binary format. This file can
be fed back to the \fIsel readraw\fP be fed back to the \fIsel readraw\fP ipmitool command for viewing.
.BR ipmitool
command for viewing.
.TP .TP
\fIreadraw\fP <\fBfile\fR> \fIreadraw\fP <\fBfile\fR>
Read and display SEL records from a binary file. Such a file can Read and display SEL records from a binary file. Such a file can
be created using the \fIsel writeraw\fP be created using the \fIsel writeraw\fP ipmitool command.
.BR ipmitool
command.
.TP .TP
\fItime\fP \fItime\fP
.RS .RS
@ -3149,34 +3068,50 @@ or by using the keyword `all' to specify all sessions.
\fIhostname\fP <\fBhost\fR> \fIhostname\fP <\fBhost\fR>
Session hostname. Session hostname.
.RS
.RE
.TP .TP
\fIusername\fP <\fBuser\fR> \fIusername\fP <\fBuser\fR>
Session username. Session username.
.RS
.RE
.TP .TP
\fIpassword\fP <\fBpass\fR> \fIpassword\fP <\fBpass\fR>
Session password. Session password.
.RS
.RE
.TP .TP
\fIprivlvl\fP <\fBlevel\fR> \fIprivlvl\fP <\fBlevel\fR>
Session privilege level force. Session privilege level force.
.RS
.RE
.TP .TP
\fIauthtype\fP <\fBtype\fR> \fIauthtype\fP <\fBtype\fR>
Authentication type force. Authentication type force.
.RS
.RE
.TP .TP
\fIlocaladdr\fP <\fBaddr\fR> \fIlocaladdr\fP <\fBaddr\fR>
Local IPMB address. Local IPMB address.
.RS
.RE
.TP .TP
\fItargetaddr\fP <\fBaddr\fR> \fItargetaddr\fP <\fBaddr\fR>
Remote target IPMB address. Remote target IPMB address.
.RS
.RE
.TP .TP
\fIport\fP <\fBport\fR> \fIport\fP <\fBport\fR>
Remote RMCP port. Remote RMCP port.
.RS
.RE
.TP .TP
\fIcsv\fP [\fBlevel\fR] \fIcsv\fP [\fBlevel\fR]
@ -3184,21 +3119,22 @@ Enable output in comma separated format.
Affects following commands: Affects following commands:
\fIuser\fP, \fIchannel\fP, \fIisol\fP, \fIsunoem\fP, \fIuser\fP, \fIchannel\fP, \fIisol\fP, \fIsunoem\fP,
\fIsol\fP, \fIsensor\fP, \fIsdr\fP, \fIsel\fP, \fIsession\fP. \fIsol\fP, \fIsensor\fP, \fIsdr\fP, \fIsel\fP, \fIsession\fP.
.RS
.RE
.TP .TP
\fIverbose\fP [\fBverbose\fR] \fIverbose\fP [\fBverbose\fR]
Verbosity level. Verbosity level.
.RS
.RE
.RE .RE
.TP .TP
\fIshell\fP \fIshell\fP
.RS .RS
This command will launch an interactive shell which you can use This command will launch an interactive shell which you can use
to send multiple to send multiple ipmitool commands to a BMC and see the responses.
.BR ipmitool This can be useful instead of running the full ipmitool command each
commands to a BMC and see the responses. This can be useful instead of time. Some commands will make use of a Sensor Data Record cache
running the full
.BR ipmitool
command each time. Some commands will make use of a Sensor Data Record cache
and you will see marked improvement in speed if these commands and you will see marked improvement in speed if these commands
are able to reuse the same cache in a shell session. LAN sessions are able to reuse the same cache in a shell session. LAN sessions
will send a periodic keepalive command to keep the IPMI session will send a periodic keepalive command to keep the IPMI session
@ -3274,9 +3210,7 @@ by the IPMI over serial channel.
\fIactivate\fP [\fIusesolkeepalive\fP | \fInokeepalive\fP] [\fIinstance=<number>\fP] \fIactivate\fP [\fIusesolkeepalive\fP | \fInokeepalive\fP] [\fIinstance=<number>\fP]
.br .br
Causes Causes ipmitool to enter Serial Over LAN
.BR ipmitool
to enter Serial Over LAN
mode, and is only available when using the lanplus mode, and is only available when using the lanplus
interface. An RMCP+ connection is made to the BMC, interface. An RMCP+ connection is made to the BMC,
the terminal is set to raw mode, and user input is the terminal is set to raw mode, and user input is
@ -3535,13 +3469,12 @@ Displays a list of user information for all defined userids.
Sets the username associated with the given userid. Sets the username associated with the given userid.
.TP .TP
\fIpassword\fP <\fBuserid\fR> [<\fBpassword\fR> [<\fB16|20\fR>]] \fIpassword\fP <\fBuserid\fR> [<\fBpassword\fR>]
.br .br
Sets the password for the given userid. If no password is given, Sets the password for the given userid. If no password is given,
the password is cleared (set to the NULL password). Be careful when the password is cleared (set to the NULL password). Be careful when
removing passwords from administrator\-level accounts. If specified, removing passwords from administrator\-level accounts.
16 or 20 determines the maximum password length.
.RE .RE
.TP .TP
\fIdisable\fP <\fBuserid\fR> \fIdisable\fP <\fBuserid\fR>
@ -3567,9 +3500,7 @@ Determine whether a password has been stored as 16 or 20 bytes.
.RE .RE
.SH "OPEN INTERFACE" .SH "OPEN INTERFACE"
The The ipmitool \fIopen\fP interface utilizes the OpenIPMI
.BR ipmitool
\fIopen\fP interface utilizes the OpenIPMI
kernel device driver. This driver is present in all modern kernel device driver. This driver is present in all modern
2.4 and all 2.6 kernels and it should be present in recent 2.4 and all 2.6 kernels and it should be present in recent
Linux distribution kernels. There are also IPMI driver Linux distribution kernels. There are also IPMI driver
@ -3578,9 +3509,7 @@ the OpenIPMI homepage.
The required kernel modules is different for 2.4 and 2.6 The required kernel modules is different for 2.4 and 2.6
kernels. The following kernel modules must be loaded on kernels. The following kernel modules must be loaded on
a 2.4\-based kernel in order for a 2.4\-based kernel in order for ipmitool to work:
.BR ipmitool
to work:
.TP .TP
.B ipmi_msghandler .B ipmi_msghandler
Incoming and outgoing message handler for IPMI interfaces. Incoming and outgoing message handler for IPMI interfaces.
@ -3592,9 +3521,7 @@ An IPMI Keyboard Controller Style (KCS) interface driver for the message handler
Linux character device interface for the message handler. Linux character device interface for the message handler.
.LP .LP
The following kernel modules must be loaded on The following kernel modules must be loaded on
a 2.6\-based kernel in order for a 2.6\-based kernel in order for ipmitool to work:
.BR ipmitool
to work:
.TP .TP
.B ipmi_msghandler .B ipmi_msghandler
Incoming and outgoing message handler for IPMI interfaces. Incoming and outgoing message handler for IPMI interfaces.
@ -3622,22 +3549,19 @@ entry with:
.I mknod /dev/ipmi0 c 254 0 .I mknod /dev/ipmi0 c 254 0
.BR ipmitool ipmitool includes some sample initialization scripts that
includes some sample initialization scripts that
can perform this task automatically at start\-up. can perform this task automatically at start\-up.
In order to have In order to have ipmitool use the OpenIPMI device interface
.BR ipmitool
use the OpenIPMI device interface
you can specify it on the command line: you can specify it on the command line:
.PP .PP
> ipmitool \fB\-I\fR \fIopen\fP <\fIcommand\fP> ipmitool \fB\-I\fR \fIopen\fP <\fIcommand\fP>
.SH "BMC INTERFACE" .SH "BMC INTERFACE"
The ipmitool bmc interface utilizes the \fIbmc\fP device driver as The ipmitool bmc interface utilizes the \fIbmc\fP device driver as
provided by Solaris 10 and higher. In order to force ipmitool to make provided by Solaris 10 and higher. In order to force ipmitool to make
use of this interface you can specify it on the command line: use of this interface you can specify it on the command line:
.PP .PP
> ipmitool \fB\-I\fR \fIbmc\fP <\fIcommand\fP> ipmitool \fB\-I\fR \fIbmc\fP <\fIcommand\fP>
The following files are associated with the bmc driver: The following files are associated with the bmc driver:
@ -3651,18 +3575,13 @@ The following files are associated with the bmc driver:
.B /dev/bmc .B /dev/bmc
Character device node used to communicate with the bmc driver. Character device node used to communicate with the bmc driver.
.SH "LIPMI INTERFACE" .SH "LIPMI INTERFACE"
The The ipmitool \fIlipmi\fP interface uses the Solaris 9 IPMI kernel device driver.
.BR ipmitool
\fIlipmi\fP interface uses the Solaris 9 IPMI kernel device driver.
It has been superceeded by the \fIbmc\fP interface on Solaris 10. You can tell It has been superceeded by the \fIbmc\fP interface on Solaris 10. You can tell
.BR ipmitool ipmitool to use this interface by specifying it on the command line.
to use this interface by specifying it on the command line.
> ipmitool \fB\-I\fR \fIlipmi\fP <\fIexpression\fP> ipmitool \fB\-I\fR \fIlipmi\fP <\fIexpression\fP>
.SH "LAN INTERFACE" .SH "LAN INTERFACE"
The The ipmitool \fIlan\fP interface communicates with the BMC
.BR ipmitool
\fIlan\fP interface communicates with the BMC
over an Ethernet LAN connection using UDP under IPv4. UDP over an Ethernet LAN connection using UDP under IPv4. UDP
datagrams are formatted to contain IPMI request/response datagrams are formatted to contain IPMI request/response
messages with a IPMI session headers and RMCP headers. messages with a IPMI session headers and RMCP headers.
@ -3675,24 +3594,20 @@ datagrams to port 623.
The LAN interface is an authentication multi\-session connection; The LAN interface is an authentication multi\-session connection;
messages delivered to the BMC can (and should) be authenticated messages delivered to the BMC can (and should) be authenticated
with a challenge/response protocol with either straight with a challenge/response protocol with either straight
password/key or MD5 message\-digest algorithm. password/key or MD5 message\-digest algorithm. ipmitool will
.BR ipmitool attempt to connect with administrator privilege level as this
will attempt to connect with administrator privilege level as this
is required to perform chassis power functions. is required to perform chassis power functions.
You can tell You can tell ipmitool to use the lan interface with the
.BR ipmitool
to use the lan interface with the
\fB\-I\fR \fIlan\fP option: \fB\-I\fR \fIlan\fP option:
.PP .PP
> ipmitool \fB\-I\fR \fIlan\fP \fB\-H\fR <\fIhostname\fP> ipmitool \fB\-I\fR \fIlan\fP \fB\-H\fR <\fIhostname\fP>
[\fB\-U\fR <\fIusername\fP>] [\fB\-P\fR <\fIpassword\fP>] <\fIcommand\fP> [\fB\-U\fR <\fIusername\fP>] [\fB\-P\fR <\fIpassword\fP>] <\fIcommand\fP>
A hostname must be given on the command line in order to use the A hostname must be given on the command line in order to use the
lan interface with \fBipmitool\fR. The password field is optional; lan interface with ipmitool. The password field is optional;
if you do not provide a password on the command line, if you do not provide a password on the command line, ipmitool
.BR ipmitool
will attempt to connect without authentication. If you specify a will attempt to connect without authentication. If you specify a
password it will use MD5 authentication if supported by the BMC password it will use MD5 authentication if supported by the BMC
and straight password/key otherwise, unless overridden with a and straight password/key otherwise, unless overridden with a
@ -3705,78 +3620,63 @@ interface uses the RMCP+ protocol as described in the IPMI v2.0
specification. RMCP+ allows for improved authentication and data specification. RMCP+ allows for improved authentication and data
integrity checks, as well as encryption and the ability to carry integrity checks, as well as encryption and the ability to carry
multiple types of payloads. Generic Serial Over LAN support multiple types of payloads. Generic Serial Over LAN support
requires RMCP+, so the requires RMCP+, so the ipmitool \fIsol activate\fP command
.BR ipmitool
\fIsol activate\fP command
requires the use of the \fIlanplus\fP interface. requires the use of the \fIlanplus\fP interface.
RMCP+ session establishment uses a symmetric challenge\-response RMCP+ session establishment uses a symmetric challenge\-response
protocol called RAKP (\fBRemote Authenticated Key\-Exchange Protocol\fR) protocol called RAKP (\fBRemote Authenticated Key\-Exchange Protocol\fR)
which allows the negotiation of many options. which allows the negotiation of many options. ipmitool does not
.BR ipmitool
does not
yet allow the user to specify the value of every option, defaulting yet allow the user to specify the value of every option, defaulting
to the most obvious settings marked as required in the v2.0 to the most obvious settings marked as required in the v2.0
specification. Authentication and integrity HMACS are produced with specification. Authentication and integrity HMACS are produced with
SHA1, and encryption is performed with AES\-CBC\-128. Role\-level logins SHA1, and encryption is performed with AES\-CBC\-128. Role\-level logins
are not yet supported. are not yet supported.
.BR ipmitool ipmitool must be linked with the \fIOpenSSL\fP library in order to
must be linked with the \fIOpenSSL\fP library in order to
perform the encryption functions and support the \fIlanplus\fP perform the encryption functions and support the \fIlanplus\fP
interface. If the required packages are not found it will not be interface. If the required packages are not found it will not be
compiled in and supported. compiled in and supported.
You can tell You can tell ipmitool to use the lanplus interface with the
.BR ipmitool
to use the lanplus interface with the
\fB\-I\fR \fIlanplus\fP option: \fB\-I\fR \fIlanplus\fP option:
.PP .PP
> ipmitool \fB\-I\fR \fIlanplus\fP ipmitool \fB\-I\fR \fIlanplus\fP
\fB\-H\fR <\fIhostname\fP> \fB\-H\fR <\fIhostname\fP>
[\fB\-U\fR <\fIusername\fP>] [\fB\-U\fR <\fIusername\fP>]
[\fB\-P\fR <\fIpassword\fP>] [\fB\-P\fR <\fIpassword\fP>]
<\fIcommand\fP> <\fIcommand\fP>
A hostname must be given on the command line in order to use the A hostname must be given on the command line in order to use the
lan interface with \fBipmitool\fR. With the exception of the \fB\-A\fR and lan interface with ipmitool. With the exception of the \fB\-A\fR and
\fB\-C\fR options the rest of the command line options are identical to \fB\-C\fR options the rest of the command line options are identical to
those available for the \fIlan\fP interface. 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
The The ipmitool \fIfree\fP interface utilizes the FreeIPMI libfreeipmi
.BR ipmitool
\fIfree\fP interface utilizes the FreeIPMI libfreeipmi
drivers. drivers.
.LP .LP
You can tell You can tell ipmitool to use the FreeIPMI interface with the \-I option:
.BR ipmitool
to use the FreeIPMI interface with the \-I option:
.PP .PP
> ipmitool \fB\-I\fR \fIfree\fP <\fIcommand\fP> ipmitool \fB\-I\fR \fIfree\fP <\fIcommand\fP>
.SH "IMB INTERFACE" .SH "IMB INTERFACE"
.LP .LP
The The ipmitool \fIimb\fP interface supports the Intel IMB (Intel
.BR ipmitool
\fIimb\fP interface supports the Intel IMB (Intel
Inter-module Bus) Interface through the /dev/imb device. Inter-module Bus) Interface through the /dev/imb device.
.LP .LP
You can tell You can tell ipmitool to use the IMB interface with the \-I option:
.BR ipmitool
to use the IMB interface with the \-I option:
.PP .PP
> ipmitool \fB\-I\fR \fIimb\fP <\fIcommand\fP> ipmitool \fB\-I\fR \fIimb\fP <\fIcommand\fP>
.SH "EXAMPLES" .SH "EXAMPLES"
.TP .TP
@ -3827,29 +3727,13 @@ Chassis Power is on
> ipmitool \-I lan \-H 1.2.3.4 \-f passfile chassis power on > ipmitool \-I lan \-H 1.2.3.4 \-f passfile chassis power on
.br .br
Chassis Power Control: Up/On Chassis Power Control: Up/On
.SH FILES .SH "AUTHOR"
.TP Duncan Laurie <duncan@iceblink.org>
.B @IANADIR@/enterprise-numbers
system IANA PEN registry taken from http://www.iana.org/assignments/enterprise-numbers
.TP
.B ~/@IANAUSERDIR@/enterprise-numbers
user's override for the system IANA PEN registry, this file if it exists is loaded instead
of the system registry (see above).
.SH "AUTHORS"
Originally written by Duncan Laurie <duncan@iceblink.org>.
.br
Numerous contributors over time.
.SH "BUGS"
Any bugs found in \fIipmitool\fP please report via \fIGitHub\fP issue system at
https://github.com/ipmitool/ipmitool/issues
.SH "SEE ALSO" .SH "SEE ALSO"
.TP .TP
IPMItool Homepage IPMItool Homepage
http://github.com/ipmitool/ipmitool http://ipmitool.sourceforge.net
.TP .TP
Intelligent Platform Management Interface Specification Intelligent Platform Management Interface Specification
http://www.intel.com/design/servers/ipmi http://www.intel.com/design/servers/ipmi

View File

@ -39,5 +39,4 @@ noinst_HEADERS = log.h bswap.h hpm2.h helper.h ipmi.h ipmi_cc.h ipmi_intf.h \
ipmi_fwum.h ipmi_main.h ipmi_tsol.h ipmi_firewall.h \ ipmi_fwum.h ipmi_main.h ipmi_tsol.h ipmi_firewall.h \
ipmi_kontronoem.h ipmi_ekanalyzer.h ipmi_gendev.h ipmi_ime.h \ ipmi_kontronoem.h ipmi_ekanalyzer.h ipmi_gendev.h ipmi_ime.h \
ipmi_delloem.h ipmi_dcmi.h ipmi_vita.h ipmi_sel_supermicro.h \ ipmi_delloem.h ipmi_dcmi.h ipmi_vita.h ipmi_sel_supermicro.h \
ipmi_cfgp.h ipmi_lanp6.h ipmi_quantaoem.h ipmi_time.h ipmi_cfgp.h ipmi_lanp6.h

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_BSWAP_H
#define IPMI_BSWAP_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -48,3 +49,5 @@
# define BSWAP_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) |\ # define BSWAP_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) |\
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#endif #endif
#endif /* IPMI_BSWAP_H */

View File

@ -30,16 +30,13 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_HELPER_H
#define IPMI_HELPER_H
#include <sys/types.h> #include <sys/types.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> /* For free() */
#include <stdbool.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
@ -53,12 +50,6 @@
#define tboolean int #define tboolean int
#endif #endif
#ifdef __GNUC__
#define __UNUSED__(x) x __attribute__((unused))
#else
#define __UNUSED__(x) x
#endif
/* IPMI spec. - UID 0 reserved, 63 maximum UID which can be used */ /* IPMI spec. - UID 0 reserved, 63 maximum UID which can be used */
#ifndef IPMI_UID_MIN #ifndef IPMI_UID_MIN
# define IPMI_UID_MIN 1 # define IPMI_UID_MIN 1
@ -70,7 +61,7 @@
struct ipmi_intf; struct ipmi_intf;
struct valstr { struct valstr {
uint32_t val; uint16_t val;
const char * str; const char * str;
}; };
struct oemvalstr { struct oemvalstr {
@ -79,12 +70,8 @@ struct oemvalstr {
const char * str; const char * str;
}; };
const char * const char * val2str(uint16_t val, const struct valstr * vs);
specific_val2str(uint32_t val, const char * oemval2str(uint32_t oem,uint16_t val, const struct oemvalstr * vs);
const struct valstr *specific,
const struct valstr *generic);
const char *val2str(uint32_t val, const struct valstr * vs);
const char *oemval2str(uint32_t oem, uint32_t val, const struct oemvalstr * vs);
int str2double(const char * str, double * double_ptr); int str2double(const char * str, double * double_ptr);
int str2long(const char * str, int64_t * lng_ptr); int str2long(const char * str, int64_t * lng_ptr);
@ -96,8 +83,6 @@ int str2ushort(const char * str, uint16_t * ushrt_ptr);
int str2char(const char * str, int8_t * chr_ptr); int str2char(const char * str, int8_t * chr_ptr);
int str2uchar(const char * str, uint8_t * uchr_ptr); int str2uchar(const char * str, uint8_t * uchr_ptr);
bool args2buf(int argc, char *argv[], uint8_t *out, size_t len);
int eval_ccode(const int ccode); int eval_ccode(const int ccode);
int is_fru_id(const char *argv_ptr, uint8_t *fru_id_ptr); int is_fru_id(const char *argv_ptr, uint8_t *fru_id_ptr);
@ -105,11 +90,7 @@ int is_ipmi_channel_num(const char *argv_ptr, uint8_t *channel_ptr);
int is_ipmi_user_id(const char *argv_ptr, uint8_t *ipmi_uid_ptr); int is_ipmi_user_id(const char *argv_ptr, uint8_t *ipmi_uid_ptr);
int is_ipmi_user_priv_limit(const char *argv_ptr, uint8_t *ipmi_priv_limit_ptr); int is_ipmi_user_priv_limit(const char *argv_ptr, uint8_t *ipmi_priv_limit_ptr);
uint32_t str2val32(const char *str, const struct valstr *vs); uint16_t str2val(const char * str, const struct valstr * vs);
static inline uint16_t str2val(const char *str, const struct valstr *vs)
{
return (uint16_t)str2val32(str, vs);
}
void print_valstr(const struct valstr * vs, const char * title, int loglevel); void print_valstr(const struct valstr * vs, const char * title, int loglevel);
void print_valstr_2col(const struct valstr * vs, const char * title, int loglevel); void print_valstr_2col(const struct valstr * vs, const char * title, int loglevel);
@ -128,86 +109,6 @@ FILE * ipmi_open_file(const char * file, int rw);
void ipmi_start_daemon(struct ipmi_intf *intf); void ipmi_start_daemon(struct ipmi_intf *intf);
uint16_t ipmi_get_oem_id(struct ipmi_intf *intf); uint16_t ipmi_get_oem_id(struct ipmi_intf *intf);
#define IS_SET(v, b) ((v) & (1 << (b)))
/**
* Free the memory and clear the pointer.
* @param[in] ptr - a pointer to your pointer to free.
*/
static inline void free_n(void *ptr) {
void **pptr = (void **)ptr;
if (pptr && *pptr) {
free(*pptr);
*pptr = NULL;
}
}
/* le16toh(), hto16le(), et. al. don't exist for Windows or Apple */
/* For portability, let's simply define our own versions here */
/* IPMI is always little-endian */
static inline uint16_t ipmi16toh(void *ipmi16)
{
uint8_t *ipmi = (uint8_t *)ipmi16;
uint16_t h;
h = (uint16_t)ipmi[1] << 8; /* MSB */
h |= ipmi[0]; /* LSB */
return h;
}
static inline void htoipmi16(uint16_t h, uint8_t *ipmi)
{
ipmi[0] = h & 0xFF; /* LSB */
ipmi[1] = h >> 8; /* MSB */
}
static inline uint32_t ipmi24toh(void *ipmi24)
{
uint8_t *ipmi = (uint8_t *)ipmi24;
uint32_t h = 0;
h = (uint32_t)ipmi[2] << 16; /* MSB */
h |= ipmi[1] << 8;
h |= ipmi[0]; /* LSB */
return h;
}
static inline void htoipmi24(uint32_t h, uint8_t *ipmi)
{
ipmi[0] = h & 0xFF; /* LSB */
ipmi[1] = (h >> 8) & 0xFF;
ipmi[2] = (h >> 16) & 0xFF; /* MSB */
}
static inline uint32_t ipmi32toh(void *ipmi32)
{
uint8_t *ipmi = ipmi32;
uint32_t h;
h = (uint32_t)ipmi[3] << 24; /* MSB */
h |= ipmi[2] << 16;
h |= ipmi[1] << 8;
h |= ipmi[0]; /* LSB */
return h;
}
static inline void htoipmi32(uint32_t h, uint8_t *ipmi)
{
ipmi[0] = h & 0xFF; /* LSB */
ipmi[1] = (h >> 8) & 0xFF;
ipmi[2] = (h >> 16) & 0xFF;
ipmi[3] = (h >> 24) & 0xFF; /* MSB */
}
uint8_t *array_byteswap(uint8_t *buffer, size_t length);
uint8_t *array_ntoh(uint8_t *buffer, size_t length);
uint8_t *array_letoh(uint8_t *buffer, size_t length);
#define ipmi_open_file_read(file) ipmi_open_file(file, 0) #define ipmi_open_file_read(file) ipmi_open_file(file, 0)
#define ipmi_open_file_write(file) ipmi_open_file(file, 1) #define ipmi_open_file_write(file) ipmi_open_file(file, 1)
@ -226,3 +127,5 @@ uint8_t *array_letoh(uint8_t *buffer, size_t length);
#ifndef __maxlen #ifndef __maxlen
# define __maxlen(a, b) ({ int x=strlen(a); int y=strlen(b); (x > y) ? x : y;}) # define __maxlen(a, b) ({ int x=strlen(a); int y=strlen(b); (x > y) ? x : y;})
#endif #endif
#endif /* IPMI_HELPER_H */

View File

@ -30,8 +30,6 @@
* EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once
#include <stdint.h> #include <stdint.h>
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_H
#define IPMI_H
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -258,8 +259,6 @@ struct ipmi_rs {
typedef enum IPMI_OEM { typedef enum IPMI_OEM {
IPMI_OEM_UNKNOWN = 0, IPMI_OEM_UNKNOWN = 0,
IPMI_OEM_DEBUG = 0xFFFFFE, /* Hoping IANA won't hit this soon */
IPMI_OEM_RESERVED = 0x0FFFFF, /* As per IPMI 2.0 specification */
/* 2 for [IBM] */ /* 2 for [IBM] */
IPMI_OEM_IBM_2 = 2, IPMI_OEM_IBM_2 = 2,
IPMI_OEM_HP = 11, IPMI_OEM_HP = 11,
@ -282,7 +281,7 @@ typedef enum IPMI_OEM {
IPMI_OEM_MAGNUM = 5593, IPMI_OEM_MAGNUM = 5593,
IPMI_OEM_TYAN = 6653, IPMI_OEM_TYAN = 6653,
IPMI_OEM_QUANTA = 7244, IPMI_OEM_QUANTA = 7244,
IPMI_OEM_VIKING = 9237, IPMI_OEM_NEWISYS = 9237,
IPMI_OEM_ADVANTECH = 10297, IPMI_OEM_ADVANTECH = 10297,
IPMI_OEM_FUJITSU_SIEMENS = 10368, IPMI_OEM_FUJITSU_SIEMENS = 10368,
IPMI_OEM_AVOCENT = 10418, IPMI_OEM_AVOCENT = 10418,
@ -301,8 +300,9 @@ typedef enum IPMI_OEM {
IPMI_OEM_ADLINK_24339 = 24339, IPMI_OEM_ADLINK_24339 = 24339,
IPMI_OEM_NOKIA_SOLUTIONS_AND_NETWORKS = 28458, IPMI_OEM_NOKIA_SOLUTIONS_AND_NETWORKS = 28458,
IPMI_OEM_VITA = 33196, IPMI_OEM_VITA = 33196,
IPMI_OEM_SUPERMICRO_47488 = 47488, IPMI_OEM_SUPERMICRO_47488 = 47488
IPMI_OEM_YADRO = 49769,
} IPMI_OEM; } IPMI_OEM;
extern const struct valstr completion_code_vals[]; extern const struct valstr completion_code_vals[];
#endif /* IPMI_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_CC_H
#define IPMI_CC_H
/* /*
Thu Jan 11 09:32:41 2007 Thu Jan 11 09:32:41 2007
@ -70,3 +71,6 @@
#define IPMI_CC_NOT_SUPPORTED_PRESENT_STATE 0xd5 #define IPMI_CC_NOT_SUPPORTED_PRESENT_STATE 0xd5
#define IPMI_CC_ILLEGAL_COMMAND_DISABLED 0xd6 #define IPMI_CC_ILLEGAL_COMMAND_DISABLED 0xd6
#define IPMI_CC_UNSPECIFIED_ERROR 0xff #define IPMI_CC_UNSPECIFIED_ERROR 0xff
#endif /*IPMI_CC_H*/

View File

@ -29,8 +29,8 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef IPMI_CFGP_H
#pragma once #define IPMI_CFGP_H
#include <stdio.h> #include <stdio.h>
@ -193,3 +193,5 @@ extern int ipmi_cfgp_save(struct ipmi_cfgp_ctx *ctx,
/* Print parameter data in user-friendly format. */ /* Print parameter data in user-friendly format. */
extern int ipmi_cfgp_print(struct ipmi_cfgp_ctx *ctx, extern int ipmi_cfgp_print(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, FILE *file); const struct ipmi_cfgp_sel *sel, FILE *file);
#endif /* IPMI_CFGP_H */

View File

@ -30,13 +30,13 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_CHANNEL_H
#define IPMI_CHANNEL_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#define IPMI_GET_CHANNEL_AUTH_CAP 0x38 #define IPMI_GET_CHANNEL_AUTH_CAP 0x38
@ -56,28 +56,6 @@
#define IPMI_CHANNEL_SESSION_MULTI 0x80 #define IPMI_CHANNEL_SESSION_MULTI 0x80
#define IPMI_CHANNEL_SESSION_BASED 0xC0 #define IPMI_CHANNEL_SESSION_BASED 0xC0
/* Fixed channel numbers as per Table 6-1 */
typedef enum {
CH_PRIMARY_IPMB,
CH_IMP_SPECIFIC_1,
CH_IMP_SPECIFIC_2,
CH_IMP_SPECIFIC_3,
CH_IMP_SPECIFIC_4,
CH_IMP_SPECIFIC_5,
CH_IMP_SPECIFIC_6,
CH_IMP_SPECIFIC_7,
CH_IMP_SPECIFIC_8,
CH_IMP_SPECIFIC_9,
CH_IMP_SPECIFIC_A,
CH_IMP_SPECIFIC_B,
CH_RSVD1,
CH_RSVD2,
CH_CURRENT,
CH_SYSTEM,
CH_TOTAL,
CH_UNKNOWN = UINT8_MAX
} ipmi_channel_num_t;
/* (22.24) Get Channel Info */ /* (22.24) Get Channel Info */
struct channel_info_t { struct channel_info_t {
uint8_t channel; uint8_t channel;
@ -89,66 +67,16 @@ 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;
uint8_t user_level_auth; uint8_t user_level_auth;
}; };
/*
* The Cipher Suite Record Format from table 22-18 of the IPMI v2.0 spec
*/
enum cipher_suite_format_tag {
STANDARD_CIPHER_SUITE = 0xc0,
OEM_CIPHER_SUITE = 0xc1,
};
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
struct std_cipher_suite_record_t {
uint8_t start_of_record;
uint8_t cipher_suite_id;
uint8_t auth_alg;
uint8_t integrity_alg;
uint8_t crypt_alg;
} ATTRIBUTE_PACKING;
struct oem_cipher_suite_record_t {
uint8_t start_of_record;
uint8_t cipher_suite_id;
uint8_t iana[3];
uint8_t auth_alg;
uint8_t integrity_alg;
uint8_t crypt_alg;
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
#define CIPHER_ALG_MASK 0x3f
#define MAX_CIPHER_SUITE_RECORD_OFFSET 0x40
#define MAX_CIPHER_SUITE_DATA_LEN 0x10
#define LIST_ALGORITHMS_BY_CIPHER_SUITE 0x80
/* Below is the theoretical maximum number of cipher suites that could be
* reported by a BMC. That is with the Get Channel Cipher Suites Command, at 16
* bytes at a time and 0x40 requests, it can report 1024 bytes, which is about
* 204 standard records or 128 OEM records. Really, we probably don't need more
* than about 20, which is the full set of standard records plus a few OEM
* records.
*/
#define MAX_CIPHER_SUITE_COUNT (MAX_CIPHER_SUITE_RECORD_OFFSET * \
MAX_CIPHER_SUITE_DATA_LEN / \
sizeof(struct std_cipher_suite_record_t))
/* /*
* The Get Authentication Capabilities response structure * The Get Authentication Capabilities response structure
* From table 22-15 of the IPMI v2.0 spec * From table 22-15 of the IPMI v2.0 spec
@ -201,24 +129,18 @@ struct get_channel_auth_cap_rsp {
#endif #endif
int _ipmi_get_channel_access(struct ipmi_intf *intf, int _ipmi_get_channel_access(struct ipmi_intf *intf,
struct channel_access_t *channel_access, struct channel_access_t *channel_access,
uint8_t get_volatile_settings); uint8_t get_volatile_settings);
int ipmi_get_channel_cipher_suites(struct ipmi_intf *intf,
const char *payload_type,
uint8_t channel,
struct cipher_suite_info *suites,
size_t *count);
int _ipmi_get_channel_info(struct ipmi_intf *intf, int _ipmi_get_channel_info(struct ipmi_intf *intf,
struct channel_info_t *channel_info); struct channel_info_t *channel_info);
int _ipmi_set_channel_access(struct ipmi_intf *intf, int _ipmi_set_channel_access(struct ipmi_intf *intf,
struct channel_access_t channel_access, struct channel_access_t channel_access, uint8_t access_option,
uint8_t access_option, uint8_t privilege_option);
uint8_t privilege_option);
uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel); uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel);
void ipmi_current_channel_info(struct ipmi_intf *intf, uint8_t ipmi_current_channel_medium(struct ipmi_intf * intf);
struct channel_info_t *chinfo);
int ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv);
int ipmi_get_channel_auth_cap(struct ipmi_intf * intf, int ipmi_get_channel_auth_cap(struct ipmi_intf * intf, uint8_t channel, uint8_t priv);
uint8_t channel, uint8_t priv);
int ipmi_get_channel_info(struct ipmi_intf * intf, uint8_t channel); int ipmi_get_channel_info(struct ipmi_intf * intf, uint8_t channel);
#endif /*IPMI_CHANNEL_H*/

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_CHASSIS_H
#define IPMI_CHASSIS_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -50,3 +51,5 @@ int ipmi_chassis_power_status(struct ipmi_intf * intf);
int ipmi_chassis_power_control(struct ipmi_intf * intf, uint8_t ctl); int ipmi_chassis_power_control(struct ipmi_intf * intf, uint8_t ctl);
int ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv);
int ipmi_power_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_power_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /*IPMI_CHASSIS_H*/

View File

@ -30,7 +30,9 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_CONSTANTS_H
#define IPMI_CONSTANTS_H
/* /*
* COMMANDS * COMMANDS
@ -72,7 +74,6 @@
#define IPMI_SESSION_PRIV_OPERATOR 0x3 #define IPMI_SESSION_PRIV_OPERATOR 0x3
#define IPMI_SESSION_PRIV_ADMIN 0x4 #define IPMI_SESSION_PRIV_ADMIN 0x4
#define IPMI_SESSION_PRIV_OEM 0x5 #define IPMI_SESSION_PRIV_OEM 0x5
#define IPMI_SESSION_PRIV_NOACCESS 0xF
#define IPMI_SET_IN_PROGRESS_SET_COMPLETE 0x00 #define IPMI_SET_IN_PROGRESS_SET_COMPLETE 0x00
#define IPMI_SET_IN_PROGRESS_IN_PROGRESS 0x01 #define IPMI_SET_IN_PROGRESS_IN_PROGRESS 0x01
@ -126,8 +127,10 @@
#define IPMI_INTEGRITY_MD5_128 0x03 #define IPMI_INTEGRITY_MD5_128 0x03
#define IPMI_INTEGRITY_HMAC_SHA256_128 0x04 #define IPMI_INTEGRITY_HMAC_SHA256_128 0x04
/* From table 13-19 of the IPMI v2 specification */ /* From table 13-19 of the IPMI v2 specfication */
#define IPMI_CRYPT_NONE 0x00 #define IPMI_CRYPT_NONE 0x00
#define IPMI_CRYPT_AES_CBC_128 0x01 #define IPMI_CRYPT_AES_CBC_128 0x01
#define IPMI_CRYPT_XRC4_128 0x02 #define IPMI_CRYPT_XRC4_128 0x02
#define IPMI_CRYPT_XRC4_40 0x03 #define IPMI_CRYPT_XRC4_40 0x03
#endif /*IPMI_CONSTANTS_H*/

View File

@ -16,7 +16,9 @@
* *
*/ */
#pragma once
#ifndef IPMI_DCMI_H
#define IPMI_DCMI_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -127,7 +129,7 @@ struct power_reading {
uint8_t state; uint8_t state;
} __attribute__ ((packed)); } __attribute__ ((packed));
/* make a struct for the return from the capabilities command */ /* make a struct for the return from the capabilites command */
struct capabilities { struct capabilities {
uint8_t grp_id; /* first byte: Group Extension ID */ uint8_t grp_id; /* first byte: Group Extension ID */
uint16_t conformance; uint16_t conformance;
@ -181,7 +183,7 @@ struct nm_discover {
uint8_t minor_rev; uint8_t minor_rev;
} __attribute__ ((packed)); } __attribute__ ((packed));
/* Node Manager get capabilities command */ /* Node Manager get capabilites command */
struct nm_capability { struct nm_capability {
uint8_t intel_id[3]; uint8_t intel_id[3];
uint8_t max_settings; uint8_t max_settings;
@ -234,7 +236,7 @@ struct nm_get_policy {
/* Node Manager set alert destination */ /* Node Manager set alert destination */
struct nm_set_alert { struct nm_set_alert {
uint8_t intel_id[3]; uint8_t intel_id[3];
uint8_t chan; /* 0:3 BMC chan, 4:6 reserved, bit 7=0 register alert receiver =1 invalidate */ uint8_t chan; /* 0:3 BMC chan, 4:6 reserved, bit 7=0 register alert reciever =1 invalidate */
uint8_t dest; /* lan destination */ uint8_t dest; /* lan destination */
uint8_t string; /* alert string selector */ uint8_t string; /* alert string selector */
} __attribute__ ((packed)); } __attribute__ ((packed));
@ -265,3 +267,4 @@ struct nm_suspend {
} __attribute__ ((packed)); } __attribute__ ((packed));
int ipmi_nm_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_nm_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /*IPMI_DCMI_H*/

View File

@ -26,8 +26,8 @@ POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/ *****************************************************************************/
#ifndef IPMI_DELLOEM_H
#pragma once #define IPMI_DELLOEM_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -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;
@ -362,3 +366,5 @@ typedef struct _SensorReadingType
}SensorReadingType; }SensorReadingType;
uint16_t compareinputwattage(IPMI_POWER_SUPPLY_INFO* powersupplyinfo, uint16_t inputwattage); uint16_t compareinputwattage(IPMI_POWER_SUPPLY_INFO* powersupplyinfo, uint16_t inputwattage);
int ipmi_delloem_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_delloem_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /*IPMI_DELLOEM_H*/

View File

@ -33,7 +33,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_EKANALYZER_H
#define IPMI_EKANALYZER_H
#include <inttypes.h> #include <inttypes.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -63,3 +64,5 @@
#define FRU_RADIAL_IPMB0_LINK_MAPPING 0x15 #define FRU_RADIAL_IPMB0_LINK_MAPPING 0x15
int ipmi_ekanalyzer_main(struct ipmi_intf *, int, char **); int ipmi_ekanalyzer_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_EKANALYZER_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_ENTITY_H
#define IPMI_ENTITY_H
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
@ -48,3 +49,5 @@ struct entity_id {
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(0) #pragma pack(0)
#endif #endif
#endif /* IPMI_ENTITY_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_EVENT_H
#define IPMI_EVENT_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -60,31 +61,6 @@ struct platform_event_msg {
#pragma pack(0) #pragma pack(0)
#endif #endif
/* See IPMI 2.0 Specification, Appendix G, Table G-1, "Event Commands" */
typedef enum {
IPMI_CMD_SET_EVENT_RCVR = 0,
IPMI_CMD_GET_EVENT_RCVR,
IPMI_CMD_PLATFORM_EVENT
} ipmi_event_cmd_t;
typedef enum {
PLATFORM_EVENT_DATA_LEN_NON_SI = sizeof(struct platform_event_msg),
PLATFORM_EVENT_DATA_LEN_SI, /* System interfaces require generator ID */
PLATFORM_EVENT_DATA_LEN_MAX = PLATFORM_EVENT_DATA_LEN_SI
} ipmi_platform_event_data_len_t;
/* See Table 5-4 */
typedef enum {
EVENT_SWID_BIOS_BASE = 0x00, /* BIOS */
EVENT_SWID_SMI_BASE = 0x10, /* SMI Handler */
EVENT_SWID_SMS_BASE = 0x20, /* System Management Software */
EVENT_SWID_OEM_BASE = 0x30, /* OEM */
EVENT_SWID_REMOTE_CONSOLE_BASE = 0x40, /* Remote Console SW */
EVENT_SWID_TERMINAL_MODE_BASE = 0x47 /* Terminal Mode RC SW */
} ipmi_event_swid_t;
#define EVENT_SWID(base, index) ((EVENT_SWID_##base##_BASE + index) & 0x7F)
/* See Figure 29-2, Table 32-1 */
#define EVENT_GENERATOR(base, index) (EVENT_SWID(base,index) << 1 | 1)
int ipmi_event_main(struct ipmi_intf *, int, char **); int ipmi_event_main(struct ipmi_intf *, int, char **);
#endif /*IPMI_EVENT_H*/

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_FIREWALL_H
#define IPMI_FIREWALL_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -101,3 +102,5 @@ static inline int bit_test(const unsigned char * bf, int n) {
static inline void bit_set(unsigned char * bf, int n, int v) { static inline void bit_set(unsigned char * bf, int n, int v) {
bf[n>>3] = (bf[n>>3] & ~(1<<(n%8))) | ((v?1:0)<<(n%8)); bf[n>>3] = (bf[n>>3] & ~(1<<(n%8))) | ((v?1:0)<<(n%8));
} }
#endif /*IPMI_FIREWALL_H */

View File

@ -30,19 +30,17 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_FRU_H
#define IPMI_FRU_H
#include <inttypes.h> #include <inttypes.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h> #include <ipmitool/ipmi_sdr.h>
#include <ipmitool/ipmi_time.h>
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#define FRU_END_OF_FIELDS 0xc1
#define GET_FRU_INFO 0x10 #define GET_FRU_INFO 0x10
#define GET_FRU_DATA 0x11 #define GET_FRU_DATA 0x11
#define SET_FRU_DATA 0x12 #define SET_FRU_DATA 0x12
@ -127,7 +125,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 +134,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;
@ -198,6 +193,9 @@ struct fru_multirec_powersupply {
#pragma pack(0) #pragma pack(0)
#endif #endif
static const char * combined_voltage_desc[] __attribute__((unused)) = {
"12 V", "-12 V", "5 V", "3.3 V"};
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
#endif #endif
@ -244,43 +242,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
@ -629,28 +590,20 @@ struct fru_picmgext_amc_link_desc_record {
#pragma pack(0) #pragma pack(0)
#endif #endif
/* IPMI Return codes for Get FRU Inventory Area and Write FRU Inventory Area */
/* PROTECTED_OFFSET Only expected on write command failures. */
#define IPMI_CC_FRU_WRITE_PROTECTED_OFFSET 0x80
#define IPMI_CC_FRU_DEVICE_BUSY 0x81
/* FRU Board manufacturing date */ /* FRU Board manufacturing date */
#define FRU_BOARD_DATE_UNSPEC 0 /* IPMI FRU Information Storage Definition static const uint64_t secs_from_1970_1996 = 820454400;
v1.0 rev 1.3, Table 11-1 */ static const char * chassis_type_desc[] __attribute__((unused)) = {
static inline time_t ipmi_fru2time_t(void *mfg_date) { "Unspecified", "Other", "Unknown",
const uint64_t secs_from_1970_1996 = 820454400; "Desktop", "Low Profile Desktop", "Pizza Box",
uint32_t fru_ts = ipmi24toh(mfg_date); "Mini Tower", "Tower",
time_t ts; "Portable", "LapTop", "Notebook", "Hand Held",
"Docking Station", "All in One", "Sub Notebook",
if (FRU_BOARD_DATE_UNSPEC == fru_ts) { "Space-saving", "Lunch Box", "Main Server Chassis",
ts = IPMI_TIME_UNSPECIFIED; "Expansion Chassis", "SubChassis", "Bus Expansion Chassis",
} "Peripheral Chassis", "RAID Chassis", "Rack Mount Chassis",
else { "Sealed-case PC", "Multi-system Chassis", "CompactPCI",
ts = fru_ts * 60 + secs_from_1970_1996; "AdvancedTCA", "Blade", "Blade Enclosure"
} };
return ts;
}
typedef struct ipmi_fru_bloc { typedef struct ipmi_fru_bloc {
struct ipmi_fru_bloc * next; struct ipmi_fru_bloc * next;
@ -661,4 +614,5 @@ typedef struct ipmi_fru_bloc {
int ipmi_fru_main(struct ipmi_intf *intf, int argc, char **argv); int ipmi_fru_main(struct ipmi_intf *intf, int argc, char **argv);
int ipmi_fru_print(struct ipmi_intf *intf, struct sdr_record_fru_locator *fru); int ipmi_fru_print(struct ipmi_intf *intf, struct sdr_record_fru_locator *fru);
char *get_fru_area_str(uint8_t *data, uint32_t *offset);
#endif /* IPMI_FRU_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_KFWUM_H
# define IPMI_KFWUM_H
#include <inttypes.h> #include <inttypes.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -238,3 +239,5 @@ struct KfwumFinishFirmwareDownloadReq {
# ifdef HAVE_PRAGMA_PACK # ifdef HAVE_PRAGMA_PACK
# pragma pack(0) # pragma pack(0)
# endif # endif
#endif /* IPMI_KFWUM_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_GENDEV_H
#define IPMI_GENDEV_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -43,3 +44,5 @@
#include <ipmitool/ipmi_entity.h> #include <ipmitool/ipmi_entity.h>
int ipmi_gendev_main(struct ipmi_intf *, int, char **); int ipmi_gendev_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_GENDEV_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_HPMFWUPG_H
#define IPMI_HPMFWUPG_H
#include <inttypes.h> #include <inttypes.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -71,6 +72,23 @@ int ipmi_hpmfwupg_main(struct ipmi_intf *, int, char **);
#define HPMFWUPG_FW_MISMATCH 0x83 #define HPMFWUPG_FW_MISMATCH 0x83
#define HPMFWUPG_ROLLBACK_DENIED 0x83 #define HPMFWUPG_ROLLBACK_DENIED 0x83
/*
* This error code is used as a temporary PATCH to
* the latest Open ipmi driver. This PATCH
* will be removed once a new Open IPMI driver is released.
* (Buggy version = 39)
*/
#define ENABLE_OPENIPMI_V39_PATCH
#ifdef ENABLE_OPENIPMI_V39_PATCH
# define RETRY_COUNT_MAX 3
static int errorCount;
# define HPMFWUPG_IS_RETRYABLE(error) \
((((error==0x83)||(error==0x82)||(error==0x80)) && (errorCount++<RETRY_COUNT_MAX))?TRUE:FALSE)
#else
# define HPMFWUPG_IS_RETRYABLE(error) FALSE
#endif
/* HPM FIRMWARE UPGRADE GENERAL DEFINITIONS */ /* HPM FIRMWARE UPGRADE GENERAL DEFINITIONS */
#define HPMFWUPG_PICMG_IDENTIFIER 0 #define HPMFWUPG_PICMG_IDENTIFIER 0
#define HPMFWUPG_VERSION_SIZE 6 #define HPMFWUPG_VERSION_SIZE 6
@ -782,6 +800,10 @@ typedef struct _VERSIONINFO {
char descString[HPMFWUPG_DESC_STRING_LENGTH + 1]; char descString[HPMFWUPG_DESC_STRING_LENGTH + 1];
}VERSIONINFO, *PVERSIONINFO; }VERSIONINFO, *PVERSIONINFO;
VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
#define TARGET_VER (0x01) #define TARGET_VER (0x01)
#define ROLLBACK_VER (0x02) #define ROLLBACK_VER (0x02)
#define IMAGE_VER (0x04) #define IMAGE_VER (0x04)
#endif /* IPMI_KFWUM_H */

5
include/ipmitool/ipmi_ime.h Normal file → Executable file
View File

@ -33,10 +33,13 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_IME_H
#define IPMI_IME_H
#include <inttypes.h> #include <inttypes.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
int ipmi_ime_main(struct ipmi_intf *, int, char **); int ipmi_ime_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_IME_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_INTF_H
#define IPMI_INTF_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_oem.h> #include <ipmitool/ipmi_oem.h>
@ -61,45 +62,13 @@ enum LANPLUS_SESSION_STATE {
#define IPMI_SIK_BUFFER_SIZE IPMI_MAX_MD_SIZE #define IPMI_SIK_BUFFER_SIZE IPMI_MAX_MD_SIZE
#define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */ #define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */
enum cipher_suite_ids {
IPMI_LANPLUS_CIPHER_SUITE_0 = 0,
IPMI_LANPLUS_CIPHER_SUITE_1 = 1,
IPMI_LANPLUS_CIPHER_SUITE_2 = 2,
IPMI_LANPLUS_CIPHER_SUITE_3 = 3,
IPMI_LANPLUS_CIPHER_SUITE_4 = 4,
IPMI_LANPLUS_CIPHER_SUITE_5 = 5,
IPMI_LANPLUS_CIPHER_SUITE_6 = 6,
IPMI_LANPLUS_CIPHER_SUITE_7 = 7,
IPMI_LANPLUS_CIPHER_SUITE_8 = 8,
IPMI_LANPLUS_CIPHER_SUITE_9 = 9,
IPMI_LANPLUS_CIPHER_SUITE_10 = 10,
IPMI_LANPLUS_CIPHER_SUITE_11 = 11,
IPMI_LANPLUS_CIPHER_SUITE_12 = 12,
IPMI_LANPLUS_CIPHER_SUITE_13 = 13,
IPMI_LANPLUS_CIPHER_SUITE_14 = 14,
#ifdef HAVE_CRYPTO_SHA256
IPMI_LANPLUS_CIPHER_SUITE_15 = 15,
IPMI_LANPLUS_CIPHER_SUITE_16 = 16,
IPMI_LANPLUS_CIPHER_SUITE_17 = 17,
#endif /* HAVE_CRYPTO_SHA256 */
IPMI_LANPLUS_CIPHER_SUITE_RESERVED = 0xff,
};
struct cipher_suite_info {
enum cipher_suite_ids cipher_suite_id;
uint8_t auth_alg;
uint8_t integrity_alg;
uint8_t crypt_alg;
uint32_t iana;
};
struct ipmi_session_params { struct ipmi_session_params {
char * hostname; char * hostname;
uint8_t username[17]; uint8_t username[17];
uint8_t authcode_set[IPMI_AUTHCODE_BUFFER_SIZE + 1]; uint8_t authcode_set[IPMI_AUTHCODE_BUFFER_SIZE + 1];
uint8_t authtype_set; uint8_t authtype_set;
uint8_t privlvl; uint8_t privlvl;
enum cipher_suite_ids cipher_suite_id; uint8_t cipher_suite_id;
char sol_escape_char; char sol_escape_char;
int password; int password;
int port; int port;
@ -150,7 +119,7 @@ struct ipmi_session {
uint32_t bmc_id; uint32_t bmc_id;
/* /*
* Values required for RAKP messages * Values required for RAKP mesages
*/ */
/* Random number generated byt the console */ /* Random number generated byt the console */
@ -232,6 +201,7 @@ struct ipmi_intf {
int (*open)(struct ipmi_intf * intf); int (*open)(struct ipmi_intf * intf);
void (*close)(struct ipmi_intf * intf); void (*close)(struct ipmi_intf * intf);
struct ipmi_rs *(*sendrecv)(struct ipmi_intf * intf, struct ipmi_rq * req); struct ipmi_rs *(*sendrecv)(struct ipmi_intf * intf, struct ipmi_rq * req);
int (*sendrsp)(struct ipmi_intf * intf, struct ipmi_rs * rsp);
struct ipmi_rs *(*recv_sol)(struct ipmi_intf * intf); struct ipmi_rs *(*recv_sol)(struct ipmi_intf * intf);
struct ipmi_rs *(*send_sol)(struct ipmi_intf * intf, struct ipmi_v2_payload * payload); struct ipmi_rs *(*send_sol)(struct ipmi_intf * intf, struct ipmi_v2_payload * payload);
int (*keepalive)(struct ipmi_intf * intf); int (*keepalive)(struct ipmi_intf * intf);
@ -240,10 +210,6 @@ struct ipmi_intf {
void (*set_max_response_data_size)(struct ipmi_intf * intf, uint16_t size); void (*set_max_response_data_size)(struct ipmi_intf * intf, uint16_t size);
}; };
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);
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);
@ -252,10 +218,7 @@ void ipmi_intf_session_set_username(struct ipmi_intf * intf, char * username);
void ipmi_intf_session_set_password(struct ipmi_intf * intf, char * password); void ipmi_intf_session_set_password(struct ipmi_intf * intf, char * password);
void ipmi_intf_session_set_privlvl(struct ipmi_intf * intf, uint8_t privlvl); void ipmi_intf_session_set_privlvl(struct ipmi_intf * intf, uint8_t privlvl);
void ipmi_intf_session_set_lookupbit(struct ipmi_intf * intf, uint8_t lookupbit); void ipmi_intf_session_set_lookupbit(struct ipmi_intf * intf, uint8_t lookupbit);
#ifdef IPMI_INTF_LANPLUS void ipmi_intf_session_set_cipher_suite_id(struct ipmi_intf * intf, uint8_t cipher_suite_id);
void ipmi_intf_session_set_cipher_suite_id(struct ipmi_intf * intf,
enum cipher_suite_ids cipher_suite_id);
#endif /* IPMI_INTF_LANPLUS */
void ipmi_intf_session_set_sol_escape_char(struct ipmi_intf * intf, char sol_escape_char); void ipmi_intf_session_set_sol_escape_char(struct ipmi_intf * intf, char sol_escape_char);
void ipmi_intf_session_set_kgkey(struct ipmi_intf *intf, const uint8_t *kgkey); void ipmi_intf_session_set_kgkey(struct ipmi_intf *intf, const uint8_t *kgkey);
void ipmi_intf_session_set_port(struct ipmi_intf * intf, int port); void ipmi_intf_session_set_port(struct ipmi_intf * intf, int port);
@ -268,3 +231,4 @@ void ipmi_cleanup(struct ipmi_intf * intf);
#if defined(IPMI_INTF_LAN) || defined (IPMI_INTF_LANPLUS) #if defined(IPMI_INTF_LAN) || defined (IPMI_INTF_LANPLUS)
int ipmi_intf_socket_connect(struct ipmi_intf * intf); int ipmi_intf_socket_connect(struct ipmi_intf * intf);
#endif #endif
#endif /* IPMI_INTF_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_ISOL_H
#define IPMI_ISOL_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -52,3 +53,5 @@ struct isol_config_parameters {
}; };
int ipmi_isol_main(struct ipmi_intf *, int, char **); int ipmi_isol_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_SOL_H */

View File

@ -1,43 +1,46 @@
/* /*
* Copyright (c) 2004 Kontron Canada, Inc. All Rights Reserved. * Copyright (c) 2004 Kontron Canada, Inc. All Rights Reserved.
* *
* Base on code from * Base on code from
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* Redistribution of source code must retain the above copyright * Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* Redistribution in binary form must reproduce the above copyright * Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* Neither the name of Sun Microsystems, Inc. or the names of * Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived * contributors may be used to endorse or promote products derived
* from this software without specific prior written permission. * from this software without specific prior written permission.
* *
* This software is provided "AS IS," without a warranty of any kind. * This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
* 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.
*/ */
#pragma once #ifndef IPMI_KONTRONOEM_H
#define IPMI_KONTRONOEM_H
#include <inttypes.h>
#include <ipmitool/ipmi.h> #include <inttypes.h>
#include <ipmitool/ipmi.h>
int ipmi_kontronoem_main(struct ipmi_intf *, int, char **);
int ipmi_kontronoem_set_large_buffer(struct ipmi_intf *, unsigned char size); int ipmi_kontronoem_main(struct ipmi_intf *, int, char **);
int ipmi_kontronoem_set_large_buffer(struct ipmi_intf *, unsigned char size);
#endif /* IPMI_KONTRONOEM_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_LANP_H
#define IPMI_LANP_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -49,13 +50,6 @@
#define IPMI_LANP_WRITE_LOCK 1 #define IPMI_LANP_WRITE_LOCK 1
#define IPMI_LANP_WRITE_COMMIT 2 #define IPMI_LANP_WRITE_COMMIT 2
#define IPMI_LANP_VLAN_ID_MAX 4094
#define IPMI_LANP_VLAN_ID_MIN 1
#define IPMI_LANP_VLAN_DISABLE 0 /* ID 0 = VLAN is disabled for the channel */
#define IPMI_LANP_IS_VLAN_VALID(x) \
((x) >= IPMI_LANP_VLAN_ID_MIN && (x) <= IPMI_LANP_VLAN_ID_MAX)
enum { enum {
IPMI_LANP_SET_IN_PROGRESS, IPMI_LANP_SET_IN_PROGRESS,
IPMI_LANP_AUTH_TYPE, IPMI_LANP_AUTH_TYPE,
@ -124,6 +118,51 @@ enum {
IPMI_LANP_CHAN_ACCESS_MODE=201, IPMI_LANP_CHAN_ACCESS_MODE=201,
}; };
static struct lan_param {
int cmd;
int size;
char desc[24];
uint8_t * data;
int data_len;
} ipmi_lan_params[] __attribute__((unused)) = {
{ IPMI_LANP_SET_IN_PROGRESS, 1, "Set in Progress", NULL, 0 },
{ IPMI_LANP_AUTH_TYPE, 1, "Auth Type Support", NULL, 0 },
{ IPMI_LANP_AUTH_TYPE_ENABLE, 5, "Auth Type Enable", NULL, 0 },
{ IPMI_LANP_IP_ADDR, 4, "IP Address", NULL, 0 },
{ IPMI_LANP_IP_ADDR_SRC, 1, "IP Address Source", NULL, 0 },
{ IPMI_LANP_MAC_ADDR, 6, "MAC Address", NULL, 0 }, /* 5 */
{ IPMI_LANP_SUBNET_MASK, 4, "Subnet Mask", NULL, 0 },
{ IPMI_LANP_IP_HEADER, 3, "IP Header", NULL, 0 },
{ IPMI_LANP_PRI_RMCP_PORT, 2, "Primary RMCP Port", NULL, 0 },
{ IPMI_LANP_SEC_RMCP_PORT, 2, "Secondary RMCP Port", NULL, 0 },
{ IPMI_LANP_BMC_ARP, 1, "BMC ARP Control", NULL, 0}, /* 10 */
{ IPMI_LANP_GRAT_ARP, 1, "Gratituous ARP Intrvl", NULL, 0 },
{ IPMI_LANP_DEF_GATEWAY_IP, 4, "Default Gateway IP", NULL, 0 },
{ IPMI_LANP_DEF_GATEWAY_MAC, 6, "Default Gateway MAC", NULL, 0 },
{ IPMI_LANP_BAK_GATEWAY_IP, 4, "Backup Gateway IP", NULL, 0 },
{ IPMI_LANP_BAK_GATEWAY_MAC, 6, "Backup Gateway MAC", NULL, 0 }, /* 15 */
{ IPMI_LANP_SNMP_STRING, 18, "SNMP Community String", NULL, 0 },
{ IPMI_LANP_NUM_DEST, 1, "Number of Destinations", NULL, 0 },
{ IPMI_LANP_DEST_TYPE, 4, "Destination Type", NULL, 0 },
{ IPMI_LANP_DEST_ADDR, 13, "Destination Addresses", NULL, 0 },
{ IPMI_LANP_VLAN_ID, 2, "802.1q VLAN ID", NULL, 0 }, /* 20 */
{ IPMI_LANP_VLAN_PRIORITY, 1, "802.1q VLAN Priority", NULL, 0 },
{ IPMI_LANP_RMCP_CIPHER_SUPPORT,1, "RMCP+ Cipher Suite Count", NULL, 0 },
{ IPMI_LANP_RMCP_CIPHERS, 16, "RMCP+ Cipher Suites", NULL, 0 },
{ IPMI_LANP_RMCP_PRIV_LEVELS, 9, "Cipher Suite Priv Max", NULL, 0 },
{ IPMI_LANP_BAD_PASS_THRESH, 6, "Bad Password Threshold", NULL, 0 },
{ IPMI_LANP_OEM_ALERT_STRING, 28, "OEM Alert String", NULL, 0 }, /* 25 */
{ IPMI_LANP_ALERT_RETRY, 1, "Alert Retry Algorithm", NULL, 0 },
{ IPMI_LANP_UTC_OFFSET, 3, "UTC Offset", NULL, 0 },
{ IPMI_LANP_DHCP_SERVER_IP, 4, "DHCP Server IP", NULL, 0 },
{ IPMI_LANP_DHCP_SERVER_MAC, 6, "DHDP Server MAC", NULL, 0},
{ IPMI_LANP_DHCP_ENABLE, 1, "DHCP Enable", NULL, 0 }, /* 30 */
{ IPMI_LANP_CHAN_ACCESS_MODE, 2, "Channel Access Mode", NULL, 0 },
{ -1, -1, "", NULL, -1 }
};
int ipmi_lanp_main(struct ipmi_intf *, int, char **); int ipmi_lanp_main(struct ipmi_intf *, int, char **);
uint8_t find_lan_channel(struct ipmi_intf *intf, uint8_t start); uint8_t find_lan_channel(struct ipmi_intf *intf, uint8_t start);
#endif /*IPMI_LANP_H*/

View File

@ -29,8 +29,8 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef IPMI_LANP6_H
#pragma once #define IPMI_LANP6_H
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>
@ -50,3 +50,5 @@ struct ipmi_lanp_priv {
struct ipmi_intf *intf; struct ipmi_intf *intf;
int channel; int channel;
}; };
#endif /* IPMI_LANP6_H */

View File

@ -30,10 +30,13 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_MAIN_H
#define IPMI_MAIN_H
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>
int ipmi_main(int argc, char ** argv, struct ipmi_cmd * cmdlist, struct ipmi_intf_support * intflist); int ipmi_main(int argc, char ** argv, struct ipmi_cmd * cmdlist, struct ipmi_intf_support * intflist);
void ipmi_cmd_print(struct ipmi_cmd * cmdlist); void ipmi_cmd_print(struct ipmi_cmd * cmdlist);
int ipmi_cmd_run(struct ipmi_intf * intf, char * name, int argc, char ** argv); int ipmi_cmd_run(struct ipmi_intf * intf, char * name, int argc, char ** argv);
#endif /* IPMI_MAIN_H */

View File

@ -30,19 +30,10 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_MC_H
#define IPMI_MC_H
#include <stdbool.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
#include <ipmitool/helper.h>
#include <ipmitool/ipmi_strings.h>
#define OEM_MFG_STRING(oem) val2str(IPM_DEV_MANUFACTURER_ID(oem),\
ipmi_oem_info)
#define OEM_PROD_STRING(oem, p) oemval2str(IPM_DEV_MANUFACTURER_ID(oem),\
ipmi16toh(p),\
ipmi_oem_product_info)
#define BMC_GET_DEVICE_ID 0x01 #define BMC_GET_DEVICE_ID 0x01
#define BMC_COLD_RESET 0x02 #define BMC_COLD_RESET 0x02
@ -83,7 +74,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 */
@ -93,140 +84,29 @@ struct ipm_devid_rsp {
#define IPM_DEV_IPMI_VERSION_MINOR(x) \ #define IPM_DEV_IPMI_VERSION_MINOR(x) \
((x & IPM_DEV_IPMI_VER_MINOR_MASK) >> IPM_DEV_IPMI_VER_MINOR_SHIFT) ((x & IPM_DEV_IPMI_VER_MINOR_MASK) >> IPM_DEV_IPMI_VER_MINOR_SHIFT)
#define IPM_DEV_MANUFACTURER_ID_RESERVED 0x0FFFFF #define IPM_DEV_MANUFACTURER_ID(x) \
#define IPM_DEV_MANUFACTURER_ID(x) ipmi24toh(x) ((uint32_t) ((x[2] & 0x0F) << 16 | x[1] << 8 | x[0]))
#define IPM_DEV_ADTL_SUPPORT_BITS (8) #define IPM_DEV_ADTL_SUPPORT_BITS (8)
/* There are lots of BMC implementations that don't follow the IPMI /* Structure follow the IPMI V.2 Rev 1.0
* specification for GUID encoding. Some send data encoded as in * See Table 20-10 */
* RFC4122, some follow SMBIOS specification. We support all users
* of those buggy implementations here.
*
* Most implementations like AMI MegaRAC do it the SMBIOS way.
* This is the legacy behavior we don't want to break yet.
* That's why the last real mode is GUID_SMBIOS. If automatic
* detection finds more than one possible candidate, and
* GUID_SMBIOS is one of them, then it will take precedence.
*
* For the same reason GUID_IPMI is right before GUID_SMBIOS.
* If both RFC4122 and IPMI encodings have a valid version
* field, then IPMI takes precedence.
*/
typedef enum {
/* Real modes, in reverse precedence order */
GUID_RFC4122,
GUID_IPMI,
GUID_SMBIOS,
GUID_REAL_MODES, /* Real mode count*/
/* Pseudo modes start here */
GUID_AUTO = GUID_REAL_MODES, /* Automatically detect mode */
GUID_DUMP, /* Just dump the data */
GUID_TOTAL_MODES
} ipmi_guid_mode_t;
#define GUID_NODE_SZ 6
#define GUID_VER_MASK 0x0F
#define GUID_VER_SHIFT 12
#define GUID_VERSION(t_hi) (((t_hi) >> GUID_VER_SHIFT) & GUID_VER_MASK)
#define GUID_TIME_HI(t_hi) ((t_hi) & ~(GUID_VER_MASK << GUID_VER_SHIFT))
typedef enum {
GUID_VERSION_UNKNOWN = 0, /* Not valid according to any specification */
/* The following are according to IPMI/SMBIOS/RFC4122 */
GUID_VERSION_TIME, /* Time-based, recommended for IPMI */
GUID_VERSION_DCE, /* DCE Security with POSIX UIDs, not for IPMI */
GUID_VERSION_MD5, /* Name-based, using MD5 */
GUID_VERSION_RND, /* Randomly generated */
GUID_VERSION_SHA1, /* Name-based, using SHA-1 */
GUID_VERSION_MAX = GUID_VERSION_SHA1, /* The maximum supported version */
GUID_VERSION_COUNT /* The number of supported versions */
} guid_version_t;
static inline bool is_guid_version_valid(guid_version_t ver)
{
return (ver > GUID_VERSION_UNKNOWN) && (ver <= GUID_VERSION_MAX);
}
/* The structure follows IPMI v2.0, rev 1.1
* See section 20.8 */
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
#endif #endif
typedef struct { struct ipmi_guid_t {
uint8_t node[GUID_NODE_SZ]; /* Byte 0 is LSB */ uint32_t time_low; /* timestamp low field */
union { uint16_t time_mid; /* timestamp middle field */
struct { uint16_t time_hi_and_version; /* timestamp high field and version number */
uint8_t clock_seq_low; /* clock sequence low field */ uint8_t clock_seq_hi_variant;/* clock sequence high field and variant */
uint8_t clock_seq_hi_and_rsvd;/* clock sequence high field */ uint8_t clock_seq_low; /* clock sequence low field */
}; uint8_t node[6]; /* node */
uint16_t clock_seq_and_rsvd; } ATTRIBUTE_PACKING;
};
uint16_t time_hi_and_version; /* timestamp high field and version number */
uint16_t time_mid; /* timestamp middle field */
uint32_t time_low; /* timestamp low field */
} ATTRIBUTE_PACKING ipmi_guid_t;
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(0) #pragma pack(0)
#endif #endif
/* The structure follows RFC4122 (section 4.1.2) int _ipmi_mc_get_guid(struct ipmi_intf *, struct ipmi_guid_t *);
* and SMBIOS v3.0.0 (section 7.2.1) */
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
typedef struct {
uint32_t time_low; /* timestamp low field */
uint16_t time_mid; /* timestamp middle field */
uint16_t time_hi_and_version; /* timestamp high field and version number */
union {
struct {
uint8_t clock_seq_hi_and_rsvd;/* clock sequence high field */
uint8_t clock_seq_low; /* clock sequence low field */
};
uint16_t clock_seq_and_rsvd;
};
uint8_t node[GUID_NODE_SZ]; /* Byte 0 is MSB */
} ATTRIBUTE_PACKING rfc_guid_t;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
/* Parsed GUID structure */
typedef struct {
uint8_t node[GUID_NODE_SZ]; /* MSB first */
/* These are architecture-specific for easy output with printf() */
uint16_t clock_seq_and_rsvd;
uint64_t time_hi_and_version;
uint64_t time_mid;
uint64_t time_low;
/* These are the parsed values */
time_t time;
ipmi_guid_mode_t mode;
guid_version_t ver; /* Version from time_hi_and_version, if valid */
} parsed_guid_t;
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);
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
@ -258,24 +138,14 @@ struct ipm_selftest_rsp {
#pragma pack(1) #pragma pack(1)
#endif #endif
struct ipm_get_watchdog_rsp { struct ipm_get_watchdog_rsp {
unsigned char use; unsigned char timer_use;
unsigned char intr_action; unsigned char timer_actions;
unsigned char pre_timeout; unsigned char pre_timeout;
unsigned char exp_flags; unsigned char timer_use_exp;
union { unsigned char initial_countdown_lsb;
struct { unsigned char initial_countdown_msb;
unsigned char initial_countdown_lsb; unsigned char present_countdown_lsb;
unsigned char initial_countdown_msb; unsigned char present_countdown_msb;
};
uint16_t init_cnt_le;
};
union {
struct {
unsigned char present_countdown_lsb;
unsigned char present_countdown_msb;
};
uint16_t pres_cnt_le;
};
} ATTRIBUTE_PACKING; } ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(0) #pragma pack(0)
@ -300,25 +170,6 @@ struct ipm_get_watchdog_rsp {
#define IPM_WATCHDOG_CLEAR_BIOS_POST 0x04 #define IPM_WATCHDOG_CLEAR_BIOS_POST 0x04
#define IPM_WATCHDOG_CLEAR_BIOS_FRB2 0x02 #define IPM_WATCHDOG_CLEAR_BIOS_FRB2 0x02
/* Use */
#define IPMI_WDT_USE_NOLOG_SHIFT 7
#define IPMI_WDT_USE_DONTSTOP_SHIFT 6 /* For 'set' */
#define IPMI_WDT_USE_RUNNING_SHIFT 6 /* For 'get' */
#define IPMI_WDT_USE_SHIFT 0
#define IPMI_WDT_USE_MASK 0x07
/* Pre-timeout interrupt type */
#define IPMI_WDT_INTR_SHIFT 4
#define IPMI_WDT_INTR_MASK 0x07 /* Apply to the intr value, not to the data byte */
/* Action */
#define IPMI_WDT_ACTION_SHIFT 0
#define IPMI_WDT_ACTION_MASK 0x07
#define IPMI_WDT_GET(b, s) (((b) >> (IPMI_WDT_##s##_SHIFT)) & (IPMI_WDT_##s##_MASK))
#define IS_WDT_BIT(b, s) IS_SET((b), IPMI_WDT_##s##_SHIFT)
/* IPMI 2.0 command for system information*/ /* IPMI 2.0 command for system information*/
#define IPMI_SET_SYS_INFO 0x58 #define IPMI_SET_SYS_INFO 0x58
#define IPMI_GET_SYS_INFO 0x59 #define IPMI_GET_SYS_INFO 0x59
@ -339,3 +190,5 @@ struct ipm_get_watchdog_rsp {
int ipmi_mc_getsysinfo(struct ipmi_intf * intf, int param, int block, int set, int ipmi_mc_getsysinfo(struct ipmi_intf * intf, int param, int block, int set,
int len, void *buffer); int len, void *buffer);
int ipmi_mc_setsysinfo(struct ipmi_intf * intf, int len, void *buffer); int ipmi_mc_setsysinfo(struct ipmi_intf * intf, int len, void *buffer);
#endif /*IPMI_MC_H */

View File

@ -28,7 +28,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_OEM_H
#define IPMI_OEM_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -42,3 +43,5 @@ struct ipmi_oem_handle {
void ipmi_oem_print(void); void ipmi_oem_print(void);
int ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype); int ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype);
int ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype); int ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype);
#endif /*IPMI_OEM_H*/

View File

@ -30,7 +30,8 @@
* EVEN IF DELL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF DELL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_PEF_H
#define IPMI_PEF_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -110,6 +111,224 @@ struct bit_desc_map { /* description text container */
struct desc_map desc_maps[128]; struct desc_map desc_maps[128];
}; };
static struct bit_desc_map
pef_b2s_actions __attribute__((unused)) = {
BIT_DESC_MAP_ALL,
{ {"Alert", PEF_ACTION_ALERT},
{"Power-off", PEF_ACTION_POWER_DOWN},
{"Reset", PEF_ACTION_RESET},
{"Power-cycle", PEF_ACTION_POWER_CYCLE},
{"OEM-defined", PEF_ACTION_OEM},
{"Diagnostic-interrupt", PEF_ACTION_DIAGNOSTIC_INTERRUPT},
{NULL}
} };
static struct bit_desc_map
pef_b2s_severities __attribute__((unused)) = {
BIT_DESC_MAP_ANY,
{ {"Non-recoverable", PEF_SEVERITY_NON_RECOVERABLE},
{"Critical", PEF_SEVERITY_CRITICAL},
{"Warning", PEF_SEVERITY_WARNING},
{"OK", PEF_SEVERITY_OK},
{"Information", PEF_SEVERITY_INFORMATION},
{"Monitor", PEF_SEVERITY_MONITOR},
{NULL}
} };
static struct bit_desc_map
pef_b2s_sensortypes __attribute__((unused)) = {
BIT_DESC_MAP_LIST,
{ {"Any", 255},
{"Temperature", 1},
{"Voltage", 2},
{"Current", 3},
{"Fan", 4},
{"Chassis Intrusion", 5},
{"Platform security breach", 6},
{"Processor", 7},
{"Power supply", 8},
{"Power Unit", 9},
{"Cooling device", 10},
{"Other (units-based)", 11},
{"Memory", 12},
{"Drive Slot", 13},
{"POST memory resize", 14},
{"POST error", 15},
{"Logging disabled", 16},
{"Watchdog 1", 17},
{"System event", 18},
{"Critical Interrupt", 19},
{"Button", 20},
{"Module/board", 21},
{"uController/coprocessor", 22},
{"Add-in card", 23},
{"Chassis", 24},
{"Chipset", 25},
{"Other (FRU)", 26},
{"Cable/interconnect", 27},
{"Terminator", 28},
{"System boot", 29},
{"Boot error", 30},
{"OS boot", 31},
{"OS critical stop", 32},
{"Slot/connector", 33},
{"ACPI power state", 34},
{"Watchdog 2", 35},
{"Platform alert", 36},
{"Entity presence", 37},
{"Monitor ASIC/IC", 38},
{"LAN", 39},
{"Management subsytem health",40},
{"Battery", 41},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_1 = {
BIT_DESC_MAP_LIST,
{ {"<LNC", 0}, /* '<' : getting worse */
{">LNC", 1}, /* '>' : getting better */
{"<LC", 2},
{">LC", 3},
{"<LNR", 4},
{">LNR", 5},
{">UNC", 6},
{"<UNC", 7},
{">UC", 8},
{"<UC", 9},
{">UNR", 10},
{"<UNR", 11},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_2 = {
BIT_DESC_MAP_LIST,
{ {"transition to idle", 0},
{"transition to active", 1},
{"transition to busy", 2},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_3 = {
BIT_DESC_MAP_LIST,
{ {"state deasserted", 0},
{"state asserted", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_4 = {
BIT_DESC_MAP_LIST,
{ {"predictive failure deasserted", 0},
{"predictive failure asserted", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_5 = {
BIT_DESC_MAP_LIST,
{ {"limit not exceeded", 0},
{"limit exceeded", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_6 = {
BIT_DESC_MAP_LIST,
{ {"performance met", 0},
{"performance lags", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_7 = {
BIT_DESC_MAP_LIST,
{ {"ok", 0},
{"<warn", 1}, /* '<' : getting worse */
{"<fail", 2},
{"<dead", 3},
{">warn", 4}, /* '>' : getting better */
{">fail", 5},
{"dead", 6},
{"monitor", 7},
{"informational", 8},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_8 = {
BIT_DESC_MAP_LIST,
{ {"device removed/absent", 0},
{"device inserted/present", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_9 = {
BIT_DESC_MAP_LIST,
{ {"device disabled", 0},
{"device enabled", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_10 = {
BIT_DESC_MAP_LIST,
{ {"transition to running", 0},
{"transition to in test", 1},
{"transition to power off", 2},
{"transition to online", 3},
{"transition to offline", 4},
{"transition to off duty", 5},
{"transition to degraded", 6},
{"transition to power save", 7},
{"install error", 8},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_11 = {
BIT_DESC_MAP_LIST,
{ {"fully redundant", 0},
{"redundancy lost", 1},
{"redundancy degraded", 2},
{"<non-redundant/sufficient", 3}, /* '<' : getting worse */
{">non-redundant/sufficient", 4}, /* '>' : getting better */
{"non-redundant/insufficient", 5},
{"<redundancy degraded", 6},
{">redundancy degraded", 7},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_12 = {
BIT_DESC_MAP_LIST,
{ {"D0 power state", 0},
{"D1 power state", 1},
{"D2 power state", 2},
{"D3 power state", 3},
{NULL}
} };
static struct bit_desc_map *
pef_b2s_generic_ER[] __attribute__((unused)) = {
&pef_b2s_gentype_1,
&pef_b2s_gentype_2,
&pef_b2s_gentype_3,
&pef_b2s_gentype_4,
&pef_b2s_gentype_5,
&pef_b2s_gentype_6,
&pef_b2s_gentype_7,
&pef_b2s_gentype_8,
&pef_b2s_gentype_9,
&pef_b2s_gentype_10,
&pef_b2s_gentype_11,
&pef_b2s_gentype_12,
};
#define PEF_B2S_GENERIC_ER_ENTRIES \
(sizeof(pef_b2s_generic_ER) / sizeof(pef_b2s_generic_ER[0]))
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
@ -137,6 +356,46 @@ struct pef_policy_entry {
#pragma pack(0) #pragma pack(0)
#endif #endif
static struct bit_desc_map
pef_b2s_policies __attribute__((unused)) = {
BIT_DESC_MAP_LIST,
{ {"Match-always", PEF_POLICY_FLAGS_MATCH_ALWAYS},
{"Try-next-entry", PEF_POLICY_FLAGS_PREV_OK_SKIP},
{"Try-next-set", PEF_POLICY_FLAGS_PREV_OK_NEXT_POLICY_SET},
{"Try-next-channel", PEF_POLICY_FLAGS_PREV_OK_NEXT_CHANNEL_IN_SET},
{"Try-next-destination", PEF_POLICY_FLAGS_PREV_OK_NEXT_DESTINATION_IN_SET},
{NULL}
} };
static struct bit_desc_map
pef_b2s_ch_medium __attribute__((unused)) = {
#define PEF_CH_MEDIUM_TYPE_IPMB 1
#define PEF_CH_MEDIUM_TYPE_ICMB_10 2
#define PEF_CH_MEDIUM_TYPE_ICMB_09 3
#define PEF_CH_MEDIUM_TYPE_LAN 4
#define PEF_CH_MEDIUM_TYPE_SERIAL 5
#define PEF_CH_MEDIUM_TYPE_XLAN 6
#define PEF_CH_MEDIUM_TYPE_PCI_SMBUS 7
#define PEF_CH_MEDIUM_TYPE_SMBUS_V1X 8
#define PEF_CH_MEDIUM_TYPE_SMBUS_V2X 9
#define PEF_CH_MEDIUM_TYPE_USB_V1X 10
#define PEF_CH_MEDIUM_TYPE_USB_V2X 11
#define PEF_CH_MEDIUM_TYPE_SYSTEM 12
BIT_DESC_MAP_LIST,
{ {"IPMB (I2C)", PEF_CH_MEDIUM_TYPE_IPMB},
{"ICMB v1.0", PEF_CH_MEDIUM_TYPE_ICMB_10},
{"ICMB v0.9", PEF_CH_MEDIUM_TYPE_ICMB_09},
{"802.3 LAN", PEF_CH_MEDIUM_TYPE_LAN},
{"Serial/Modem (RS-232)", PEF_CH_MEDIUM_TYPE_SERIAL},
{"Other LAN", PEF_CH_MEDIUM_TYPE_XLAN},
{"PCI SMBus", PEF_CH_MEDIUM_TYPE_PCI_SMBUS},
{"SMBus v1.0/1.1", PEF_CH_MEDIUM_TYPE_SMBUS_V1X},
{"SMBus v2.0", PEF_CH_MEDIUM_TYPE_SMBUS_V2X},
{"USB 1.x", PEF_CH_MEDIUM_TYPE_USB_V1X},
{"USB 2.x", PEF_CH_MEDIUM_TYPE_USB_V2X},
{"System I/F (KCS,SMIC,BT)", PEF_CH_MEDIUM_TYPE_SYSTEM},
{NULL}
} };
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
@ -191,6 +450,15 @@ struct pef_cfgparm_control {
#pragma pack(0) #pragma pack(0)
#endif #endif
static struct bit_desc_map
pef_b2s_control __attribute__((unused)) = {
BIT_DESC_MAP_ALL,
{ {"PEF", PEF_CONTROL_ENABLE},
{"PEF event messages", PEF_CONTROL_ENABLE_EVENT_MESSAGES},
{"PEF startup delay", PEF_CONTROL_ENABLE_STARTUP_DELAY},
{"Alert startup delay", PEF_CONTROL_ENABLE_ALERT_STARTUP_DELAY},
{NULL}
} };
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
@ -388,6 +656,15 @@ struct pef_lan_cfgparm_dest_type {
#pragma pack(0) #pragma pack(0)
#endif #endif
static struct bit_desc_map
pef_b2s_lan_desttype __attribute__((unused)) = {
BIT_DESC_MAP_LIST,
{ {"Acknowledged", PEF_LAN_DEST_TYPE_ACK},
{"PET", PEF_LAN_DEST_TYPE_PET},
{"OEM 1", PEF_LAN_DEST_TYPE_OEM_1},
{"OEM 2", PEF_LAN_DEST_TYPE_OEM_2},
{NULL}
} };
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
@ -478,6 +755,18 @@ struct pef_serial_cfgparm_dest_info {
#pragma pack(0) #pragma pack(0)
#endif #endif
static struct bit_desc_map
pef_b2s_serial_desttype __attribute__((unused)) = {
BIT_DESC_MAP_LIST,
{ {"Acknowledged", PEF_SERIAL_DEST_TYPE_ACK},
{"TAP page", PEF_SERIAL_DEST_TYPE_TAP},
{"PPP PET", PEF_SERIAL_DEST_TYPE_PPP},
{"Basic callback", PEF_SERIAL_DEST_TYPE_BASIC_CALLBACK},
{"PPP callback", PEF_SERIAL_DEST_TYPE_PPP_CALLBACK},
{"OEM 1", PEF_SERIAL_DEST_TYPE_OEM_1},
{"OEM 2", PEF_SERIAL_DEST_TYPE_OEM_2},
{NULL}
} };
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK
#pragma pack(1) #pragma pack(1)
@ -546,6 +835,14 @@ struct pef_serial_cfgparm_tap_svc_settings {
#pragma pack(0) #pragma pack(0)
#endif #endif
static struct bit_desc_map
pef_b2s_tap_svc_confirm __attribute__((unused)) = {
BIT_DESC_MAP_LIST,
{ {"ACK", PEF_SERIAL_TAP_CONFIRMATION_ACK_AFTER_ETX},
{"211+ACK", PEF_SERIAL_TAP_CONFIRMATION_211_ACK_AFTER_ETX},
{"{211|213}+ACK", PEF_SERIAL_TAP_CONFIRMATION_21X_ACK_AFTER_ETX},
{NULL}
} };
#if 0 /* FYI : config parm groupings */ #if 0 /* FYI : config parm groupings */
struct pef_config_parms { /* PEF */ struct pef_config_parms { /* PEF */
@ -666,3 +963,5 @@ void ipmi_pef_print_2xd(const char * text, uint8_t u1, uint8_t u2);
void ipmi_pef_print_str(const char * text, const char * val); void ipmi_pef_print_str(const char * text, const char * val);
int ipmi_pef_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_pef_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /* IPMI_PEF_H */

View File

@ -3,7 +3,8 @@
(C) Kontron (C) Kontron
*/ */
#pragma once #ifndef _IPMI_PICMG_H_
#define _IPMI_PICMG_H_
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -11,7 +12,6 @@
#define PICMG_CPCI_MAJOR_VERSION 1 #define PICMG_CPCI_MAJOR_VERSION 1
#define PICMG_ATCA_MAJOR_VERSION 2 #define PICMG_ATCA_MAJOR_VERSION 2
#define PICMG_AMC_MAJOR_VERSION 4 #define PICMG_AMC_MAJOR_VERSION 4
#define PICMG_UTCA_MAJOR_VERSION 5
/* PICMG commands */ /* PICMG commands */
#define PICMG_GET_PICMG_PROPERTIES_CMD 0x00 #define PICMG_GET_PICMG_PROPERTIES_CMD 0x00
@ -91,7 +91,95 @@ typedef enum picmg_busres_resource_id {
PICMG_BUSRES_SYNC_CLOCK_GROUP_3 PICMG_BUSRES_SYNC_CLOCK_GROUP_3
} t_picmg_busres_resource_id; } t_picmg_busres_resource_id;
const char *picmg_led_color_str(int color); /* the LED color capabilities */
static const char* led_color_str[] __attribute__((unused)) = {
"reserved",
"BLUE",
"RED",
"GREEN",
"AMBER",
"ORANGE",
"WHITE",
"reserved"
};
static const char* amc_link_type_str[] __attribute__((unused)) = {
"RESERVED",
"RESERVED1",
"PCI EXPRESS",
"ADVANCED SWITCHING1",
"ADVANCED SWITCHING2",
"ETHERNET",
"RAPIDIO",
"STORAGE",
};
static const char* amc_link_type_ext_str[][16] __attribute__((unused)) = {
/* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED */
{
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED1 */
{
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_PCI_EXPRESS */
{
"Gen 1 - NSSC",
"Gen 1 - SSC",
"Gen 2 - NSSC",
"Gen 2 - SSC",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING1 */
{
"Gen 1 - NSSC",
"Gen 1 - SSC",
"Gen 2 - NSSC",
"Gen 2 - SSC",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING2 */
{
"Gen 1 - NSSC",
"Gen 1 - SSC",
"Gen 2 - NSSC",
"Gen 2 - SSC",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET */
{
"1000BASE-BX (SerDES Gigabit)",
"10GBASE-BX410 Gigabit XAUI",
"", "",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_RAPIDIO */
{
"1.25 Gbaud transmission rate",
"2.5 Gbaud transmission rate",
"3.125 Gbaud transmission rate",
"", "", "", "", "",
"", "", "", "", "", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE */
{
"Fibre Channel",
"Serial ATA",
"Serial Attached SCSI",
"", "", "", "", "",
"", "", "", "", "", "", "", ""
}
};
struct sAmcPortState { struct sAmcPortState {
#ifndef WORDS_BIGENDIAN #ifndef WORDS_BIGENDIAN
@ -119,3 +207,5 @@ struct sAmcPortState {
int ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv); int ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv);
uint8_t picmg_discover(struct ipmi_intf *intf); uint8_t picmg_discover(struct ipmi_intf *intf);
uint8_t ipmi_picmg_ipmb_address(struct ipmi_intf *intf); uint8_t ipmi_picmg_ipmb_address(struct ipmi_intf *intf);
#endif

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2018 Quanta Computer Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Quanta Computer Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
* Quanta Computer Inc. AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
* Quanta Computer Inc. OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
* 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.
*/
#pragma once
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
#define OEM_QCT_NETFN 0x36
#define OEM_QCT_GET_INFO 0x65
typedef enum
{
OEM_QCT_PLATFORM_UNKNOWN = 0,
OEM_QCT_PLATFORM_GRANTLEY,
OEM_QCT_PLATFORM_PURLEY
} qct_platform_t;
qct_platform_t oem_qct_get_platform_id(struct ipmi_intf *intf);
char *oem_qct_get_evt_desc(struct ipmi_intf *intf, struct sel_event_record *rec);

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_RAW_H
#define IPMI_RAW_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -39,3 +40,5 @@ struct ipmi_rs * ipmi_master_write_read(struct ipmi_intf * intf, uint8_t bus, ui
uint8_t * wdata, uint8_t wsize, uint8_t rsize); uint8_t * wdata, uint8_t wsize, uint8_t rsize);
int ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv);
int ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv); int ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /* IPMI_RAW_H */

View File

@ -30,13 +30,13 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_SDR_H
#define IPMI_SDR_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
#include <math.h> #include <math.h>
#include <ipmitool/bswap.h> #include <ipmitool/bswap.h>
@ -381,29 +381,6 @@ struct sdr_record_common_sensor {
struct sdr_record_mask mask; struct sdr_record_mask mask;
/* IPMI 2.0, Table 43-1, byte 21[7:6] Analog (numeric) Data Format */
#define SDR_UNIT_FMT_UNSIGNED 0 /* unsigned */
#define SDR_UNIT_FMT_1S_COMPL 1 /* 1's complement (signed) */
#define SDR_UNIT_FMT_2S_COMPL 2 /* 2's complement (signed) */
#define SDR_UNIT_FMT_NA 3 /* does not return analog (numeric) reading */
/* IPMI 2.0, Table 43-1, byte 21[5:3] Rate */
#define SDR_UNIT_RATE_NONE 0 /* none */
#define SDR_UNIT_RATE_MICROSEC 1 /* per us */
#define SDR_UNIT_RATE_MILLISEC 2 /* per ms */
#define SDR_UNIT_RATE_SEC 3 /* per s */
#define SDR_UNIT_RATE_MIN 4 /* per min */
#define SDR_UNIT_RATE_HR 5 /* per hour */
#define SDR_UNIT_RATE_DAY 6 /* per day */
#define SDR_UNIT_RATE_RSVD 7 /* reserved */
/* IPMI 2.0, Table 43-1, byte 21[2:1] Modifier Unit */
#define SDR_UNIT_MOD_NONE 0 /* none */
#define SDR_UNIT_MOD_DIV 1 /* Basic Unit / Modifier Unit */
#define SDR_UNIT_MOD_MUL 2 /* Basic Unit * Mofifier Unit */
#define SDR_UNIT_MOD_RSVD 3 /* Reserved */
/* IPMI 2.0, Table 43-1, byte 21[0] Percentage */
#define SDR_UNIT_PCT_NO 0
#define SDR_UNIT_PCT_YES 1
struct { struct {
#if WORDS_BIGENDIAN #if WORDS_BIGENDIAN
uint8_t analog:2; uint8_t analog:2;
@ -417,8 +394,8 @@ struct sdr_record_common_sensor {
uint8_t analog:2; uint8_t analog:2;
#endif #endif
struct { struct {
uint8_t base; /* Base unit type code per IPMI 2.0 Table 43-15 */ uint8_t base;
uint8_t modifier; /* Modifier unit type code per Table 43-15 */ uint8_t modifier;
} ATTRIBUTE_PACKING type; } ATTRIBUTE_PACKING type;
} ATTRIBUTE_PACKING unit; } ATTRIBUTE_PACKING unit;
} ATTRIBUTE_PACKING; } ATTRIBUTE_PACKING;
@ -796,7 +773,50 @@ struct sdr_record_list {
#pragma pack(0) #pragma pack(0)
#endif #endif
/* unit description codes (IPMI v1.5 section 37.16) */
#define UNIT_MAX 0x90
static const char *unit_desc[] __attribute__ ((unused)) = {
"unspecified",
"degrees C", "degrees F", "degrees K",
"Volts", "Amps", "Watts", "Joules",
"Coulombs", "VA", "Nits",
"lumen", "lux", "Candela",
"kPa", "PSI", "Newton",
"CFM", "RPM", "Hz",
"microsecond", "millisecond", "second", "minute", "hour",
"day", "week", "mil", "inches", "feet", "cu in", "cu feet",
"mm", "cm", "m", "cu cm", "cu m", "liters", "fluid ounce",
"radians", "steradians", "revolutions", "cycles",
"gravities", "ounce", "pound", "ft-lb", "oz-in", "gauss",
"gilberts", "henry", "millihenry", "farad", "microfarad",
"ohms", "siemens", "mole", "becquerel", "PPM", "reserved",
"Decibels", "DbA", "DbC", "gray", "sievert",
"color temp deg K", "bit", "kilobit", "megabit", "gigabit",
"byte", "kilobyte", "megabyte", "gigabyte", "word", "dword",
"qword", "line", "hit", "miss", "retry", "reset",
"overflow", "underrun", "collision", "packets", "messages",
"characters", "error", "correctable error", "uncorrectable error",};
/* sensor type codes (IPMI v1.5 table 36.3)
/ Updated to v2.0 Table 42-3, Sensor Type Codes */
#define SENSOR_TYPE_MAX 0x2C #define SENSOR_TYPE_MAX 0x2C
static const char *sensor_type_desc[] __attribute__ ((unused)) = {
"reserved",
"Temperature", "Voltage", "Current", "Fan",
"Physical Security", "Platform Security", "Processor",
"Power Supply", "Power Unit", "Cooling Device", "Other",
"Memory", "Drive Slot / Bay", "POST Memory Resize",
"System Firmwares", "Event Logging Disabled", "Watchdog1",
"System Event", "Critical Interrupt", "Button",
"Module / Board", "Microcontroller", "Add-in Card",
"Chassis", "Chip Set", "Other FRU", "Cable / Interconnect",
"Terminator", "System Boot Initiated", "Boot Error",
"OS Boot", "OS Critical Stop", "Slot / Connector",
"System ACPI Power State", "Watchdog2", "Platform Alert",
"Entity Presence", "Monitor ASIC", "LAN",
"Management Subsys Health", "Battery", "Session Audit",
"Version Change", "FRU State" };
struct sensor_reading { struct sensor_reading {
char s_id[17]; /* name of the sensor */ char s_id[17]; /* name of the sensor */
@ -844,10 +864,11 @@ struct sdr_get_rs *ipmi_sdr_get_next_header(struct ipmi_intf *intf,
struct ipmi_sdr_iterator *i); struct ipmi_sdr_iterator *i);
uint8_t *ipmi_sdr_get_record(struct ipmi_intf *intf, struct sdr_get_rs *header, uint8_t *ipmi_sdr_get_record(struct ipmi_intf *intf, struct sdr_get_rs *header,
struct ipmi_sdr_iterator *i); struct ipmi_sdr_iterator *i);
void ipmi_sdr_end(struct ipmi_sdr_iterator *i); void ipmi_sdr_end(struct ipmi_intf *intf, struct ipmi_sdr_iterator *i);
int ipmi_sdr_print_sdr(struct ipmi_intf *intf, uint8_t type); int ipmi_sdr_print_sdr(struct ipmi_intf *intf, uint8_t type);
int ipmi_sdr_print_name_from_rawentry(uint16_t id, uint8_t type,uint8_t * raw); int ipmi_sdr_print_name_from_rawentry(struct ipmi_intf *intf,uint16_t id,
uint8_t type,uint8_t * raw);
int ipmi_sdr_print_rawentry(struct ipmi_intf *intf, uint8_t type, uint8_t * raw, int ipmi_sdr_print_rawentry(struct ipmi_intf *intf, uint8_t type, uint8_t * raw,
int len); int len);
int ipmi_sdr_print_listentry(struct ipmi_intf *intf, int ipmi_sdr_print_listentry(struct ipmi_intf *intf,
@ -856,8 +877,8 @@ void ipmi_sdr_print_sensor_hysteresis(struct sdr_record_common_sensor *sensor,
struct sdr_record_full_sensor *full, struct sdr_record_full_sensor *full,
uint8_t hysteresis_value, uint8_t hysteresis_value,
const char *hdrstr); const char *hdrstr);
const char *ipmi_sdr_get_unit_string(bool pct, uint8_t type, const char *ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type,
uint8_t base, uint8_t modifier); uint8_t base, uint8_t modifier);
struct sensor_reading * struct sensor_reading *
ipmi_sdr_read_sensor_value(struct ipmi_intf *intf, ipmi_sdr_read_sensor_value(struct ipmi_intf *intf,
struct sdr_record_common_sensor *sensor, struct sdr_record_common_sensor *sensor,
@ -891,9 +912,15 @@ int ipmi_sdr_get_reservation(struct ipmi_intf *intf, int use_builtin,
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf, int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf,
struct sdr_record_eventonly_sensor *sensor); struct sdr_record_eventonly_sensor *sensor);
int ipmi_sdr_print_sensor_generic_locator(struct sdr_record_generic_locator *fru); int ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf,
int ipmi_sdr_print_sensor_fru_locator(struct sdr_record_fru_locator *fru); struct sdr_record_generic_locator
int ipmi_sdr_print_sensor_mc_locator(struct sdr_record_mc_locator *mc); *fru);
int ipmi_sdr_print_sensor_fru_locator(struct ipmi_intf *intf,
struct sdr_record_fru_locator *fru);
int ipmi_sdr_print_sensor_mc_locator(struct ipmi_intf *intf,
struct sdr_record_mc_locator *mc);
int ipmi_sdr_print_sensor_entity_assoc(struct ipmi_intf *intf,
struct sdr_record_entity_assoc *assoc);
struct sdr_record_list *ipmi_sdr_find_sdr_byentity(struct ipmi_intf *intf, struct sdr_record_list *ipmi_sdr_find_sdr_byentity(struct ipmi_intf *intf,
struct entity_id *entity); struct entity_id *entity);
@ -906,8 +933,8 @@ struct sdr_record_list *ipmi_sdr_find_sdr_byid(struct ipmi_intf *intf,
struct sdr_record_list *ipmi_sdr_find_sdr_bytype(struct ipmi_intf *intf, struct sdr_record_list *ipmi_sdr_find_sdr_bytype(struct ipmi_intf *intf,
uint8_t type); uint8_t type);
int ipmi_sdr_list_cache(struct ipmi_intf *intf); int ipmi_sdr_list_cache(struct ipmi_intf *intf);
int ipmi_sdr_list_cache_fromfile(const char *ifile); int ipmi_sdr_list_cache_fromfile(struct ipmi_intf *intf, const char *ifile);
void ipmi_sdr_list_empty(void); void ipmi_sdr_list_empty(struct ipmi_intf *intf);
int ipmi_sdr_print_info(struct ipmi_intf *intf); int ipmi_sdr_print_info(struct ipmi_intf *intf);
void ipmi_sdr_print_discrete_state(struct ipmi_intf *intf, void ipmi_sdr_print_discrete_state(struct ipmi_intf *intf,
const char *desc, uint8_t sensor_type, const char *desc, uint8_t sensor_type,
@ -925,3 +952,5 @@ int ipmi_sdr_print_sensor_event_enable(struct ipmi_intf *intf,
uint8_t sensor_num, uint8_t sensor_type, uint8_t sensor_num, uint8_t sensor_type,
uint8_t event_type, int numeric_fmt, uint8_t event_type, int numeric_fmt,
uint8_t target, uint8_t lun, uint8_t channel); uint8_t target, uint8_t lun, uint8_t channel);
#endif /* IPMI_SDR_H */

View File

@ -27,8 +27,9 @@
* 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.
*/ */
#pragma once #ifndef IPMI_SDRADD_H
#define IPMI_SDRADD_H
/* /*
* Methods to add SDRs to repository from built-in sensors or files * Methods to add SDRs to repository from built-in sensors or files
@ -41,3 +42,5 @@ ipmi_sdr_add_from_file(struct ipmi_intf *intf, const char *ifile);
int int
ipmi_sdr_add_from_list(struct ipmi_intf *intf, const char *rangeList); ipmi_sdr_add_from_list(struct ipmi_intf *intf, const char *rangeList);
#endif /* IPMI_SDRADD_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_SEL_H
#define IPMI_SEL_H
#include <inttypes.h> #include <inttypes.h>
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -256,7 +257,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" },
@ -578,8 +579,8 @@ static const struct ipmi_event_sensor_types sensor_specific_event_types[] = {
{ 0xF1, 0x00, 0xff, "IPMB-A disabled, IPMB-B disabled" }, { 0xF1, 0x00, 0xff, "IPMB-A disabled, IPMB-B disabled" },
{ 0xF1, 0x01, 0xff, "IPMB-A enabled, IPMB-B disabled" }, { 0xF1, 0x01, 0xff, "IPMB-A enabled, IPMB-B disabled" },
{ 0xF1, 0x02, 0xff, "IPMB-A disabled, IPMB-B enabled" }, { 0xF1, 0x02, 0xff, "IPMB-A disabled, IPMB-B enabled" },
{ 0xF1, 0x03, 0xff, "IPMB-A enabled, IPMB-B enabled" }, { 0xF1, 0x03, 0xff, "IPMB-A enabled, IPMP-B enabled" },
/* PICMG Module Hot Swap */ /* PICNG Moduke Hot Swap */
{ 0xF2, 0x00, 0xff, "Module Handle Closed" }, { 0xF2, 0x00, 0xff, "Module Handle Closed" },
{ 0xF2, 0x01, 0xff, "Module Handle Opened" }, { 0xF2, 0x01, 0xff, "Module Handle Opened" },
{ 0xF2, 0x02, 0xff, "Quiesced" }, { 0xF2, 0x02, 0xff, "Quiesced" },
@ -598,7 +599,7 @@ static const struct ipmi_event_sensor_types vita_sensor_event_types[] = {
{ 0xF1, 0x00, 0xFF, "IPMB-A disabled, IPMB-B disabled" }, { 0xF1, 0x00, 0xFF, "IPMB-A disabled, IPMB-B disabled" },
{ 0xF1, 0x01, 0xFF, "IPMB-A enabled, IPMB-B disabled" }, { 0xF1, 0x01, 0xFF, "IPMB-A enabled, IPMB-B disabled" },
{ 0xF1, 0x02, 0xFF, "IPMB-A disabled, IPMB-B enabled" }, { 0xF1, 0x02, 0xFF, "IPMB-A disabled, IPMB-B enabled" },
{ 0xF1, 0x03, 0xFF, "IPMB-A enabled, IPMB-B enabled" }, { 0xF1, 0x03, 0xFF, "IPMB-A enabled, IPMP-B enabled" },
/* VITA FRU Temperature */ /* VITA FRU Temperature */
{ 0xF3, 0x00, 0xff, "At or below Lower Non-critical" }, { 0xF3, 0x00, 0xff, "At or below Lower Non-critical" },
{ 0xF3, 0x01, 0xff, "At or below Lower Critical" }, { 0xF3, 0x01, 0xff, "At or below Lower Critical" },
@ -678,7 +679,7 @@ void ipmi_sel_print_extended_entry_verbose(struct ipmi_intf * intf, struct sel_e
void ipmi_get_event_desc(struct ipmi_intf * intf, struct sel_event_record * rec, char ** desc); void ipmi_get_event_desc(struct ipmi_intf * intf, struct sel_event_record * rec, char ** desc);
const char * ipmi_get_sensor_type(struct ipmi_intf *intf, uint8_t code); const char * ipmi_get_sensor_type(struct ipmi_intf *intf, uint8_t code);
uint16_t ipmi_sel_get_std_entry(struct ipmi_intf * intf, uint16_t id, struct sel_event_record * evt); uint16_t ipmi_sel_get_std_entry(struct ipmi_intf * intf, uint16_t id, struct sel_event_record * evt);
char * get_viking_evt_desc(struct ipmi_intf * intf, struct sel_event_record * rec); char * get_newisys_evt_desc(struct ipmi_intf * intf, struct sel_event_record * rec);
IPMI_OEM ipmi_get_oem(struct ipmi_intf * intf); IPMI_OEM ipmi_get_oem(struct ipmi_intf * intf);
char * ipmi_get_oem_desc(struct ipmi_intf * intf, struct sel_event_record * rec); char * ipmi_get_oem_desc(struct ipmi_intf * intf, struct sel_event_record * rec);
int ipmi_sel_oem_init(const char * filename); int ipmi_sel_oem_init(const char * filename);
@ -686,3 +687,5 @@ const struct ipmi_event_sensor_types *
ipmi_get_first_event_sensor_type(struct ipmi_intf *intf, uint8_t sensor_type, uint8_t event_type); ipmi_get_first_event_sensor_type(struct ipmi_intf *intf, uint8_t sensor_type, uint8_t event_type);
const struct ipmi_event_sensor_types * const struct ipmi_event_sensor_types *
ipmi_get_next_event_sensor_type(const struct ipmi_event_sensor_types *evt); ipmi_get_next_event_sensor_type(const struct ipmi_event_sensor_types *evt);
#endif /* IPMI_SEL_H */

View File

@ -30,7 +30,9 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once
#ifndef IPMI_SEL_SUPERMICRO_H
# define IPMI_SEL_SUPERMICRO_H
static uint16_t supermicro_x11[] = { static uint16_t supermicro_x11[] = {
0x0958, 0x0955, 0x0953, 0x0952, 0x0941, 0x093A, 0x0939, 0x0938, 0x0937, 0x0930, 0x0927, 0x091D, 0x0958, 0x0955, 0x0953, 0x0952, 0x0941, 0x093A, 0x0939, 0x0938, 0x0937, 0x0930, 0x0927, 0x091D,
@ -149,3 +151,5 @@ static uint16_t supermicro_older[] = {
0x0944, 0x0945, 0x0947, 0x0948, 0x0949, 0x094A, 0x094B, 0x094C, 0x094D, 0x094E, 0x0954, 0x0956, 0x0944, 0x0945, 0x0947, 0x0948, 0x0949, 0x094A, 0x094B, 0x094C, 0x094D, 0x094E, 0x0954, 0x0956,
0x0957, 0x0959, 0xFFFF 0x0957, 0x0959, 0xFFFF
}; };
#endif /* IPMI_SEL_SUPERMICRO_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_SENSOR_H
#define IPMI_SENSOR_H
#include <math.h> #include <math.h>
#include <ipmitool/bswap.h> #include <ipmitool/bswap.h>
@ -85,3 +86,4 @@ struct sensor_set_thresh_rq {
int ipmi_sensor_main(struct ipmi_intf *, int, char **); int ipmi_sensor_main(struct ipmi_intf *, int, char **);
int ipmi_sensor_print_fc(struct ipmi_intf *, struct sdr_record_common_sensor *, uint8_t); int ipmi_sensor_print_fc(struct ipmi_intf *, struct sdr_record_common_sensor *, uint8_t);
int ipmi_sensor_get_sensor_reading_factors( struct ipmi_intf * intf, struct sdr_record_full_sensor * sensor, uint8_t reading); int ipmi_sensor_get_sensor_reading_factors( struct ipmi_intf * intf, struct sdr_record_full_sensor * sensor, uint8_t reading);
#endif /* IPMI_SENSOR_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_SESSION_H
#define IPMI_SESSION_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -126,3 +127,5 @@ struct get_session_info_rsp
int ipmi_session_main(struct ipmi_intf *, int, char **); int ipmi_session_main(struct ipmi_intf *, int, char **);
#endif /*IPMI_CHANNEL_H*/

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_SOL_H
#define IPMI_SOL_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -91,13 +92,17 @@ struct activate_payload_rsp {
* function will return -1 if value is not valid, or * function will return -1 if value is not valid, or
* will return 0 if valid. * will return 0 if valid.
*/ */
int ipmi_sol_set_param_isvalid_uint8_t(const char *strval, int ipmi_sol_set_param_isvalid_uint8_t( const char *strval,
const char *name, const char *name,
uint8_t minval, int base,
uint8_t maxval, uint8_t minval,
uint8_t *out_value); uint8_t maxval,
uint8_t *out_value);
int ipmi_sol_main(struct ipmi_intf *, int, char **); int ipmi_sol_main(struct ipmi_intf *, int, char **);
int ipmi_get_sol_info(struct ipmi_intf *intf, int ipmi_get_sol_info(struct ipmi_intf * intf,
uint8_t channel, uint8_t channel,
struct sol_config_parameters *params); struct sol_config_parameters * params);
#endif /* IPMI_SOL_H */

View File

@ -30,12 +30,11 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_STRINGS_H
#define IPMI_STRINGS_H
#include <ipmitool/helper.h> #include <ipmitool/helper.h>
#define CC_STRING(cc) val2str(cc, completion_code_vals)
extern const struct valstr completion_code_vals[]; extern const struct valstr completion_code_vals[];
extern const struct valstr entity_id_vals[]; extern const struct valstr entity_id_vals[];
extern const struct valstr entity_device_type_vals[]; extern const struct valstr entity_device_type_vals[];
@ -49,14 +48,11 @@ 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_oem_info[];
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;
void ipmi_oem_info_init();
void ipmi_oem_info_free();
extern const struct valstr picmg_frucontrol_vals[]; extern const struct valstr picmg_frucontrol_vals[];
extern const struct valstr picmg_clk_family_vals[]; extern const struct valstr picmg_clk_family_vals[];
@ -75,3 +71,5 @@ extern const struct oemvalstr picmg_busres_shmc_status_vals[];
extern const struct oemvalstr ipmi_oem_product_info[]; extern const struct oemvalstr ipmi_oem_product_info[];
extern const char *ipmi_generic_sensor_type_vals[]; extern const char *ipmi_generic_sensor_type_vals[];
extern const struct oemvalstr ipmi_oem_sensor_type_vals[]; extern const struct oemvalstr ipmi_oem_sensor_type_vals[];
#endif /*IPMI_STRINGS_H*/

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_SUNOEM_H
#define IPMI_SUNOEM_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -67,3 +68,6 @@ typedef enum {
} sunoem_ec_t; } sunoem_ec_t;
int ipmi_sunoem_main(struct ipmi_intf *, int, char **); int ipmi_sunoem_main(struct ipmi_intf *, int, char **);
#endif /*IPMI_SUNOEM_H*/

View File

@ -1,90 +0,0 @@
/*
* Copyright (c) 2018 Alexander Amelkin. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder, nor the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
* THE COPYRIGHT HOLDER AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
* THE COPYRIGHT HOLDER OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
* PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
* THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS
* SOFTWARE, EVEN IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGES.
*/
#pragma once
#include <time.h>
#include <stdbool.h>
extern bool time_in_utc;
/* Special values according to IPMI v2.0, rev. 1.1, section 37.1 */
#define IPMI_TIME_UNSPECIFIED 0xFFFFFFFFu
#define IPMI_TIME_INIT_DONE 0x20000000u
#define SECONDS_A_DAY (24 * 60 * 60)
/*
* Check whether the timestamp is in seconds since Epoch or since
* the system startup.
*/
static inline bool ipmi_timestamp_is_special(time_t ts)
{
return (ts < IPMI_TIME_INIT_DONE);
}
/*
* Check whether the timestamp is valid at all
*/
static inline bool ipmi_timestamp_is_valid(time_t ts)
{
return (ts != IPMI_TIME_UNSPECIFIED);
}
/*
* Just 26 characters are required for asctime_r(), plus timezone info.
* However just to be safe locale-wise and assuming that in no locale
* the date/time string exceeds the 'standard' legacy terminal width,
* the buffer size is set here to 80.
*/
#define IPMI_ASCTIME_SZ 80
typedef char ipmi_datebuf_t[IPMI_ASCTIME_SZ];
/*
* These are ipmitool-specific versions that take
* in account the command line options
*/
char *ipmi_asctime_r(time_t stamp, ipmi_datebuf_t outbuf);
size_t ipmi_strftime(char *s, size_t max, const char *format, time_t stamp)
__attribute__((format(strftime, 3, 0)));
/* These return pointers to static arrays and aren't thread safe */
char *ipmi_timestamp_fmt(uint32_t stamp, const char *fmt)
__attribute__((format(strftime, 2, 0)));
char *ipmi_timestamp_string(uint32_t stamp); /* Day Mon DD HH:MM:SS YYYY ZZZ */
char *ipmi_timestamp_numeric(uint32_t stamp); /* MM/DD/YYYY HH:MM:SS ZZZ */
char *ipmi_timestamp_date(uint32_t stamp); /* MM/DD/YYYY ZZZ */
char *ipmi_timestamp_time(uint32_t stamp); /* HH:MM:SS ZZZ */
/* Subtract the UTC offset from local time_t */
time_t ipmi_localtime2utc(time_t local);

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_TSOL_H
#define IPMI_TSOL_H
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -41,3 +42,5 @@
#define IPMI_TSOL_DEF_PORT 6230 #define IPMI_TSOL_DEF_PORT 6230
int ipmi_tsol_main(struct ipmi_intf *, int, char **); int ipmi_tsol_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_TSOL_H */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMI_USER_H
#define IPMI_USER_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include <config.h>
@ -47,9 +48,6 @@
#define IPMI_USER_ENABLE_DISABLED 0x80 #define IPMI_USER_ENABLE_DISABLED 0x80
#define IPMI_USER_ENABLE_RESERVED 0xC0 #define IPMI_USER_ENABLE_RESERVED 0xC0
#define IPMI_UID_MASK 0x3F /* The user_id is 6-bit and is usually in bits [5:0] */
#define IPMI_UID(id) ((id) & IPMI_UID_MASK)
/* (22.27) Get and (22.26) Set User Access */ /* (22.27) Get and (22.26) Set User Access */
struct user_access_t { struct user_access_t {
uint8_t callin_callback; uint8_t callin_callback;
@ -81,3 +79,5 @@ int _ipmi_set_user_access(struct ipmi_intf *intf,
int _ipmi_set_user_password(struct ipmi_intf *intf, int _ipmi_set_user_password(struct ipmi_intf *intf,
uint8_t user_id, uint8_t operation, uint8_t user_id, uint8_t operation,
const char *password, uint8_t is_twenty_byte); const char *password, uint8_t is_twenty_byte);
#endif /* IPMI_USER_H */

View File

@ -2,7 +2,8 @@
* Copyright (c) Pigeon Point Systems. All right reserved * Copyright (c) Pigeon Point Systems. All right reserved
*/ */
#pragma once #ifndef _IPMI_VITA_H_
#define _IPMI_VITA_H_
/* VITA 46.11 commands */ /* VITA 46.11 commands */
#define VITA_GET_VSO_CAPABILITIES_CMD 0x00 #define VITA_GET_VSO_CAPABILITIES_CMD 0x00
@ -44,3 +45,5 @@ ipmi_vita_ipmb_address(struct ipmi_intf *intf);
extern int extern int
ipmi_vita_main(struct ipmi_intf * intf, int argc, char ** argv); ipmi_vita_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /* _IPMI_VITA_H_ */

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/ */
#pragma once #ifndef IPMITOOL_LOG_H
#define IPMITOOL_LOG_H
#include <syslog.h> #include <syslog.h>
@ -53,6 +54,10 @@
void log_init(const char * name, int isdaemon, int verbose); void log_init(const char * name, int isdaemon, int verbose);
void log_halt(void); void log_halt(void);
void log_level_set(int verbose); void log_level_set(int level);
int log_level_get(void);
void lprintf(int level, const char * format, ...); void lprintf(int level, const char * format, ...);
void lperror(int level, const char * format, ...); void lperror(int level, const char * format, ...);
#endif /*IPMITOOL_LOG_H*/

View File

@ -41,7 +41,8 @@ libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_pef.c \
ipmi_main.c ipmi_tsol.c ipmi_firewall.c ipmi_kontronoem.c \ ipmi_main.c ipmi_tsol.c ipmi_firewall.c ipmi_kontronoem.c \
ipmi_hpmfwupg.c ipmi_sdradd.c ipmi_ekanalyzer.c ipmi_gendev.c \ ipmi_hpmfwupg.c ipmi_sdradd.c ipmi_ekanalyzer.c ipmi_gendev.c \
ipmi_ime.c ipmi_delloem.c ipmi_dcmi.c hpm2.c ipmi_vita.c \ ipmi_ime.c ipmi_delloem.c ipmi_dcmi.c hpm2.c ipmi_vita.c \
ipmi_lanp6.c ipmi_cfgp.c ipmi_quantaoem.c ipmi_time.c ipmi_lanp6.c ipmi_cfgp.c \
../src/plugins/lan/md5.c ../src/plugins/lan/md5.h
libipmitool_la_LDFLAGS = -export-dynamic libipmitool_la_LDFLAGS = -export-dynamic
libipmitool_la_LIBADD = -lm libipmitool_la_LIBADD = -lm

View File

@ -1620,10 +1620,8 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
struct fru_info fru; struct fru_info fru;
uint8_t *spd_data = NULL; uint8_t *spd_data, msg_data[4];
uint8_t msg_data[4]; int len, offset;
uint32_t len, offset;
int rc = -1;
msg_data[0] = id; msg_data[0] = id;
@ -1634,14 +1632,14 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf(" Device not present (No Response)\n"); printf(" Device not present (No Response)\n");
goto end; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
printf(" Device not present (%s)\n", printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
goto end; return -1;
} }
fru.size = (rsp->data[1] << 8) | rsp->data[0]; fru.size = (rsp->data[1] << 8) | rsp->data[0];
@ -1653,15 +1651,15 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
if (fru.size < 1) { if (fru.size < 1) {
lprintf(LOG_ERR, " Invalid FRU size %d", fru.size); lprintf(LOG_ERR, " Invalid FRU size %d", fru.size);
goto end; return -1;
} }
spd_data = malloc(fru.size); spd_data = malloc(fru.size);
if (!spd_data) { if (spd_data == NULL) {
printf(" Unable to malloc memory for spd array of size=%d\n", printf(" Unable to malloc memory for spd array of size=%d\n",
fru.size); fru.size);
goto end; return -1;
} }
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
@ -1679,39 +1677,34 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
msg_data[3] = FRU_DATA_RQST_SIZE; msg_data[3] = FRU_DATA_RQST_SIZE;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf(" Device not present (No Response)\n"); printf(" Device not present (No Response)\n");
goto end; free(spd_data);
spd_data = NULL;
return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
printf(" Device not present (%s)\n", printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
free(spd_data);
spd_data = NULL;
/* Timeouts are acceptable. No DIMM in the socket */ /* Timeouts are acceptable. No DIMM in the socket */
if (rsp->ccode == 0xc3) if (rsp->ccode == 0xc3)
rc = 1; return 1;
goto end; return -1;
} }
len = rsp->data[0]; len = rsp->data[0];
if(rsp->data_len < 1
|| len > rsp->data_len - 1
|| len > fru.size - offset)
{
printf(" Not enough buffer size");
goto end;
}
memcpy(&spd_data[offset], rsp->data + 1, len); memcpy(&spd_data[offset], rsp->data + 1, len);
offset += len; offset += len;
} while (offset < fru.size); } while (offset < fru.size);
/* now print spd info */ /* now print spd info */
ipmi_spd_print(spd_data, offset); ipmi_spd_print(spd_data, offset);
rc = 0; free(spd_data);
spd_data = NULL;
end: return 0;
free_n(&spd_data);
return rc;
} }

View File

@ -29,6 +29,12 @@
* 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.
*/ */
#define _POSIX_SOURCE
#define /* glibc 2.19 and earlier */ _BSD_SOURCE || \
/* Since glibc 2.20 */_DEFAULT_SOURCE || \
_XOPEN_SOURCE >= 500 || \
_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || \
/* Since glibc 2.10: */ _POSIX_C_SOURCE >= 200112L \
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -54,7 +60,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>
@ -94,7 +100,7 @@ buf2str_extended(const uint8_t *buf, int len, const char *sep)
int left; int left;
int sep_len; int sep_len;
if (!buf) { if (buf == NULL) {
snprintf(str, sizeof(str), "<NULL>"); snprintf(str, sizeof(str), "<NULL>");
return (const char *)str; return (const char *)str;
} }
@ -174,7 +180,7 @@ ipmi_parse_hex(const char *str, uint8_t *out, int size)
} }
len /= 2; /* out bytes */ len /= 2; /* out bytes */
if (!out) { if (out == NULL) {
return -2; return -2;
} }
@ -228,50 +234,6 @@ void printbuf(const uint8_t * buf, int len, const char * desc)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
/*
* Unconditionally reverse the order of arbitrarily long strings of bytes
*/
uint8_t *array_byteswap(uint8_t *buffer, size_t length)
{
size_t i;
uint8_t temp;
size_t max = length - 1;
for (i = 0; i < length / 2; ++i) {
temp = buffer[i];
buffer[i] = buffer[max - i];
buffer[max - i] = temp;
}
return buffer;
}
/* Convert data array from network (big-endian) to host byte order */
uint8_t *array_ntoh(uint8_t *buffer, size_t length)
{
#if WORDS_BIGENDIAN
/* Big-endian host doesn't need conversion from big-endian network */
(void)length; /* Silence the compiler */
return buffer;
#else
/* Little-endian host needs conversion from big-endian network */
return array_byteswap(buffer, length);
#endif
}
/* Convert data array from little-endian to host byte order */
uint8_t *array_letoh(uint8_t *buffer, size_t length)
{
#if WORDS_BIGENDIAN
/* Big-endian host needs conversion from little-endian IPMI */
return array_byteswap(buffer, length);
#else
/* Little-endian host doesn't need conversion from little-endian IPMI */
(void)length; /* Silence the compiler */
return buffer;
#endif
}
/* str2mac - parse-out MAC address from given string and store it /* str2mac - parse-out MAC address from given string and store it
* into buffer. * into buffer.
* *
@ -319,77 +281,29 @@ mac2str(const uint8_t *buf)
return buf2str_extended(buf, 6, ":"); return buf2str_extended(buf, 6, ":");
} }
/** const char * val2str(uint16_t val, const struct valstr *vs)
* Find the index of value in a valstr array
*
* @param[in] val The value to search for
* @param[in] vs The valstr array to search in
* @return >=0 The index into \p vs
* @return -1 Error: value \p val was not found in \p vs
*/
static
inline
off_t find_val_idx(uint32_t val, const struct valstr *vs)
{
if (vs) {
for (off_t i = 0; vs[i].str; ++i) {
if (vs[i].val == val) {
return i;
}
}
}
return -1;
}
/**
* Generate a statically allocated 'Unknown' string for the provided value.
* The function is not thread-safe (as most of ipmitool).
*
* @param[in] val The value to put into the string
* @returns A pointer to a statically allocated string
*/
static
inline
const char *unknown_val_str(uint32_t val)
{ {
static char un_str[32]; static char un_str[32];
int i;
for (i = 0; vs[i].str != NULL; i++) {
if (vs[i].val == val)
return vs[i].str;
}
memset(un_str, 0, 32); memset(un_str, 0, 32);
snprintf(un_str, 32, "Unknown (0x%02X)", val); snprintf(un_str, 32, "Unknown (0x%02X)", val);
return un_str; return un_str;
} }
const char * const char * oemval2str(uint32_t oem, uint16_t val,
specific_val2str(uint32_t val, const struct oemvalstr *vs)
const struct valstr *specific,
const struct valstr *generic)
{ {
static char un_str[32];
int i; int i;
if (0 <= (i = find_val_idx(val, specific))) { for (i = 0; vs[i].oem != 0xffffff && vs[i].str != NULL; i++) {
return specific[i].str;
}
if (0 <= (i = find_val_idx(val, generic))) {
return generic[i].str;
}
return unknown_val_str(val);
}
const char *val2str(uint32_t val, const struct valstr *vs)
{
return specific_val2str(val, NULL, vs);
}
const char *oemval2str(uint32_t oem, uint32_t val,
const struct oemvalstr *vs)
{
int i;
for (i = 0; vs[i].oem != 0xffffff && vs[i].str; i++) {
/* FIXME: for now on we assume PICMG capability on all IANAs */ /* FIXME: for now on we assume PICMG capability on all IANAs */
if ( (vs[i].oem == oem || vs[i].oem == IPMI_OEM_PICMG) && if ( (vs[i].oem == oem || vs[i].oem == IPMI_OEM_PICMG) &&
vs[i].val == val ) { vs[i].val == val ) {
@ -397,7 +311,10 @@ const char *oemval2str(uint32_t oem, uint32_t val,
} }
} }
return unknown_val_str(val); memset(un_str, 0, 32);
snprintf(un_str, 32, "Unknown (0x%X)", val);
return un_str;
} }
/* str2double - safely convert string to double /* str2double - safely convert string to double
@ -642,12 +559,12 @@ int str2uchar(const char * str, uint8_t * uchr_ptr)
return 0; return 0;
} /* str2uchar(...) */ } /* str2uchar(...) */
uint32_t str2val32(const char *str, const struct valstr *vs) uint16_t str2val(const char *str, const struct valstr *vs)
{ {
int i; int i;
for (i = 0; vs[i].str; i++) { for (i = 0; vs[i].str != NULL; i++) {
if (strcasecmp(vs[i].str, str) == 0) if (strncasecmp(vs[i].str, str, __maxlen(str, vs[i].str)) == 0)
return vs[i].val; return vs[i].val;
} }
@ -665,10 +582,10 @@ print_valstr(const struct valstr * vs, const char * title, int loglevel)
{ {
int i; int i;
if (!vs) if (vs == NULL)
return; return;
if (title) { if (title != NULL) {
if (loglevel < 0) if (loglevel < 0)
printf("\n%s:\n\n", title); printf("\n%s:\n\n", title);
else else
@ -683,7 +600,7 @@ print_valstr(const struct valstr * vs, const char * title, int loglevel)
lprintf(loglevel, "=============================================="); lprintf(loglevel, "==============================================");
} }
for (i = 0; vs[i].str; i++) { for (i = 0; vs[i].str != NULL; i++) {
if (loglevel < 0) { if (loglevel < 0) {
if (vs[i].val < 256) if (vs[i].val < 256)
printf(" %d\t0x%02x\t%s\n", vs[i].val, vs[i].val, vs[i].str); printf(" %d\t0x%02x\t%s\n", vs[i].val, vs[i].val, vs[i].str);
@ -714,18 +631,18 @@ print_valstr_2col(const struct valstr * vs, const char * title, int loglevel)
{ {
int i; int i;
if (!vs) if (vs == NULL)
return; return;
if (title) { if (title != NULL) {
if (loglevel < 0) if (loglevel < 0)
printf("\n%s:\n\n", title); printf("\n%s:\n\n", title);
else else
lprintf(loglevel, "\n%s:\n", title); lprintf(loglevel, "\n%s:\n", title);
} }
for (i = 0; vs[i].str; i++) { for (i = 0; vs[i].str != NULL; i++) {
if (!vs[i+1].str) { if (vs[i+1].str == NULL) {
/* last one */ /* last one */
if (loglevel < 0) { if (loglevel < 0) {
printf(" %4d %-32s\n", vs[i].val, vs[i].str); printf(" %4d %-32s\n", vs[i].val, vs[i].str);
@ -779,12 +696,12 @@ ipmi_open_file(const char * file, int rw)
struct stat st1, st2; struct stat st1, st2;
FILE * fp; FILE * fp;
/* verify existence */ /* verify existance */
if (lstat(file, &st1) < 0) { if (lstat(file, &st1) < 0) {
if (rw) { if (rw) {
/* does not exist, ok to create */ /* does not exist, ok to create */
fp = fopen(file, "w"); fp = fopen(file, "w");
if (!fp) { if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s " lperror(LOG_ERR, "Unable to open file %s "
"for write", file); "for write", file);
return NULL; return NULL;
@ -801,7 +718,7 @@ ipmi_open_file(const char * file, int rw)
if (!rw) { if (!rw) {
/* on read skip the extra checks */ /* on read skip the extra checks */
fp = fopen(file, "r"); fp = fopen(file, "r");
if (!fp) { if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s", file); lperror(LOG_ERR, "Unable to open file %s", file);
return NULL; return NULL;
} }
@ -824,7 +741,7 @@ ipmi_open_file(const char * file, int rw)
} }
fp = fopen(file, rw ? "w+" : "r"); fp = fopen(file, rw ? "w+" : "r");
if (!fp) { if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s", file); lperror(LOG_ERR, "Unable to open file %s", file);
return NULL; return NULL;
} }
@ -868,7 +785,6 @@ ipmi_start_daemon(struct ipmi_intf *intf)
{ {
pid_t pid; pid_t pid;
int fd; int fd;
int ret;
#ifdef SIGHUP #ifdef SIGHUP
sigset_t sighup; sigset_t sighup;
#endif #endif
@ -912,11 +828,7 @@ ipmi_start_daemon(struct ipmi_intf *intf)
exit(0); exit(0);
#endif #endif
ret = chdir("/"); chdir("/");
if (ret) {
lprintf(LOG_ERR, "chdir failed: %s (%d)", strerror(errno), errno);
exit(1);
}
umask(0); umask(0);
for (fd=0; fd<64; fd++) { for (fd=0; fd<64; fd++) {
@ -925,20 +837,9 @@ ipmi_start_daemon(struct ipmi_intf *intf)
} }
fd = open("/dev/null", O_RDWR); fd = open("/dev/null", O_RDWR);
if (fd != STDIN_FILENO) { assert(0 == fd);
lprintf(LOG_ERR, "failed to reset stdin: %s (%d)", strerror(errno), errno); dup(fd);
exit(1); dup(fd);
}
ret = dup(fd);
if (ret != STDOUT_FILENO) {
lprintf(LOG_ERR, "failed to reset stdout: %s (%d)", strerror(errno), errno);
exit(1);
}
ret = dup(fd);
if (ret != STDERR_FILENO) {
lprintf(LOG_ERR, "failed to reset stderr: %s (%d)", strerror(errno), errno);
exit(1);
}
} }
/* eval_ccode - evaluate return value of _ipmi_* functions and print error error /* eval_ccode - evaluate return value of _ipmi_* functions and print error error
@ -951,7 +852,7 @@ ipmi_start_daemon(struct ipmi_intf *intf)
int int
eval_ccode(const int ccode) eval_ccode(const int ccode)
{ {
if (!ccode) { if (ccode == 0) {
return 0; return 0;
} else if (ccode < 0) { } else if (ccode < 0) {
switch (ccode) { switch (ccode) {
@ -1111,11 +1012,11 @@ ipmi_get_oem_id(struct ipmi_intf *intf)
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Board ID command failed"); lprintf(LOG_ERR, "Get Board ID command failed");
return 0; return 0;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Board ID command failed: %#x %s", lprintf(LOG_ERR, "Get Board ID command failed: %#x %s",
rsp->ccode, val2str(rsp->ccode, completion_code_vals)); rsp->ccode, val2str(rsp->ccode, completion_code_vals));
return 0; return 0;
@ -1125,35 +1026,3 @@ ipmi_get_oem_id(struct ipmi_intf *intf)
return oem_id; return oem_id;
} }
/** Parse command line arguments as numeric byte values (dec or hex)
* and store them in a \p len sized buffer \p out.
*
* @param[in] argc Number of arguments
* @param[in] argv Array of arguments
* @param[out] out The output buffer
* @param[in] len Length of the output buffer in bytes (no null-termination
* is assumed, the input data is treated as raw byte values,
* not as a string.
*
* @returns A success status indicator
* @return false Error
* @return true Success
*/
bool
args2buf(int argc, char *argv[], uint8_t *out, size_t len)
{
size_t i;
for (i = 0; i < len && i < (size_t)argc; ++i) {
uint8_t byte;
if (str2uchar(argv[i], &byte)) {
lprintf(LOG_ERR, "Bad byte value: %s", argv[i]);
return false;
}
out[i] = byte;
}
return true;
}

View File

@ -30,11 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_MALLOC_H #include <malloc.h>
# include <malloc.h>
#else
# include <stdlib.h>
#endif
#include <string.h> #include <string.h>
#include <ipmitool/helper.h> #include <ipmitool/helper.h>
@ -53,7 +49,7 @@ ipmi_cfgp_init(struct ipmi_cfgp_ctx *ctx, const struct ipmi_cfgp *set,
unsigned int count, const char *cmdname, unsigned int count, const char *cmdname,
ipmi_cfgp_handler_t handler, void *priv) ipmi_cfgp_handler_t handler, void *priv)
{ {
if (!ctx || !set || !handler || !cmdname) { if (ctx == NULL || set == NULL || handler == NULL || !cmdname) {
return -1; return -1;
} }
@ -78,7 +74,7 @@ ipmi_cfgp_uninit(struct ipmi_cfgp_ctx *ctx)
{ {
struct ipmi_cfgp_data *d; struct ipmi_cfgp_data *d;
if (!ctx) { if (ctx == NULL) {
return -1; return -1;
} }
@ -127,7 +123,7 @@ ipmi_cfgp_parse_sel(struct ipmi_cfgp_ctx *ctx,
{ {
const struct ipmi_cfgp *p; const struct ipmi_cfgp *p;
if (!ctx || !argv || !sel) { if (ctx == NULL || argv == NULL || sel == NULL) {
return -1; return -1;
} }
@ -141,7 +137,7 @@ ipmi_cfgp_parse_sel(struct ipmi_cfgp_ctx *ctx,
} }
p = lookup_cfgp(ctx, argv[0]); p = lookup_cfgp(ctx, argv[0]);
if (!p) { if (p == NULL) {
lprintf(LOG_ERR, "invalid parameter"); lprintf(LOG_ERR, "invalid parameter");
return -1; return -1;
} }
@ -205,11 +201,11 @@ cfgp_add_data(struct ipmi_cfgp_ctx *ctx, struct ipmi_cfgp_data *data)
static void static void
cfgp_usage(const struct ipmi_cfgp *p, int write) cfgp_usage(const struct ipmi_cfgp *p, int write)
{ {
if (!p->name) { if (p->name == NULL) {
return; return;
} }
if (write && !p->format) { if (write && p->format == NULL) {
return; return;
} }
@ -231,7 +227,7 @@ ipmi_cfgp_usage(const struct ipmi_cfgp *set, int count, int write)
const struct ipmi_cfgp *p; const struct ipmi_cfgp *p;
int i; int i;
if (!set) { if (set == NULL) {
return; return;
} }
@ -267,7 +263,7 @@ ipmi_cfgp_parse_data(struct ipmi_cfgp_ctx *ctx,
struct ipmi_cfgp_data *data; struct ipmi_cfgp_data *data;
struct ipmi_cfgp_action action; struct ipmi_cfgp_action action;
if (!ctx || !sel || !argv) { if (ctx == NULL || sel == NULL || argv == NULL) {
return -1; return -1;
} }
@ -294,7 +290,7 @@ ipmi_cfgp_parse_data(struct ipmi_cfgp_ctx *ctx,
} }
data = malloc(sizeof(struct ipmi_cfgp_data) + p->size); data = malloc(sizeof(struct ipmi_cfgp_data) + p->size);
if (!data) { if (data == NULL) {
return -1; return -1;
} }
@ -374,7 +370,7 @@ cfgp_get_param(struct ipmi_cfgp_ctx *ctx, const struct ipmi_cfgp *p,
do { do {
data = malloc(sizeof(struct ipmi_cfgp_data) + p->size); data = malloc(sizeof(struct ipmi_cfgp_data) + p->size);
if (!data) { if (data == NULL) {
return -1; return -1;
} }
@ -426,7 +422,7 @@ ipmi_cfgp_get(struct ipmi_cfgp_ctx *ctx, const struct ipmi_cfgp_sel *sel)
int i; int i;
int ret; int ret;
if (!ctx || !sel) { if (ctx == NULL || sel == NULL) {
return -1; return -1;
} }
@ -465,7 +461,7 @@ cfgp_do_action(struct ipmi_cfgp_ctx *ctx, int action_type,
struct ipmi_cfgp_action action; struct ipmi_cfgp_action action;
int ret; int ret;
if (!ctx || !sel) { if (ctx == NULL || sel == NULL) {
return -1; return -1;
} }
@ -474,7 +470,7 @@ cfgp_do_action(struct ipmi_cfgp_ctx *ctx, int action_type,
action.argv = NULL; action.argv = NULL;
action.file = file; action.file = file;
for (data = ctx->v; data; data = data->next) { for (data = ctx->v; data != NULL; data = data->next) {
if (sel->param != -1 && sel->param != data->sel.param) { if (sel->param != -1 && sel->param != data->sel.param) {
continue; continue;
} }
@ -527,7 +523,7 @@ int
ipmi_cfgp_save(struct ipmi_cfgp_ctx *ctx, ipmi_cfgp_save(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, FILE *file) const struct ipmi_cfgp_sel *sel, FILE *file)
{ {
if (!file) { if (file == NULL) {
return -1; return -1;
} }
@ -538,7 +534,7 @@ int
ipmi_cfgp_print(struct ipmi_cfgp_ctx *ctx, ipmi_cfgp_print(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, FILE *file) const struct ipmi_cfgp_sel *sel, FILE *file)
{ {
if (!file) { if (file == NULL) {
return -1; return -1;
} }

View File

@ -75,7 +75,7 @@ _ipmi_get_channel_access(struct ipmi_intf *intf,
struct ipmi_rq req = {0}; struct ipmi_rq req = {0};
uint8_t data[2]; uint8_t data[2];
if (!channel_access) { if (channel_access == NULL) {
return (-3); return (-3);
} }
data[0] = channel_access->channel & 0x0F; data[0] = channel_access->channel & 0x0F;
@ -87,9 +87,9 @@ _ipmi_get_channel_access(struct ipmi_intf *intf,
req.msg.data_len = 2; req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 2) { } else if (rsp->data_len != 2) {
return (-2); return (-2);
@ -118,7 +118,7 @@ _ipmi_get_channel_info(struct ipmi_intf *intf,
struct ipmi_rq req = {0}; struct ipmi_rq req = {0};
uint8_t data[1]; uint8_t data[1];
if (!channel_info) { if (channel_info == NULL) {
return (-3); return (-3);
} }
data[0] = channel_info->channel & 0x0F; data[0] = channel_info->channel & 0x0F;
@ -128,9 +128,9 @@ _ipmi_get_channel_info(struct ipmi_intf *intf,
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 9) { } else if (rsp->data_len != 9) {
return (-2); return (-2);
@ -202,7 +202,7 @@ _ipmi_set_channel_access(struct ipmi_intf *intf,
req.msg.data_len = 3; req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} }
return rsp->ccode; return rsp->ccode;
@ -225,7 +225,7 @@ iana_string(uint32_t iana)
* ipmi_1_5_authtypes * ipmi_1_5_authtypes
* *
* Create a string describing the supported authentication types as * Create a string describing the supported authentication types as
* specified by the parameter n * specificed by the parameter n
*/ */
static const char * static const char *
ipmi_1_5_authtypes(uint8_t n) ipmi_1_5_authtypes(uint8_t n)
@ -244,28 +244,10 @@ ipmi_1_5_authtypes(uint8_t n)
return supportedTypes; return supportedTypes;
} }
void uint8_t
ipmi_current_channel_info(struct ipmi_intf *intf, ipmi_current_channel_medium(struct ipmi_intf *intf)
struct channel_info_t *chinfo)
{ {
int ccode = 0; return ipmi_get_channel_medium(intf, 0xE);
chinfo->channel = CH_CURRENT;
ccode = _ipmi_get_channel_info(intf, chinfo);
if (ccode) {
if (ccode != IPMI_CC_INV_DATA_FIELD_IN_REQ) {
if (ccode > 0) {
lprintf(LOG_ERR, "Get Channel Info command failed: %s",
val2str(ccode, completion_code_vals));
}
else {
eval_ccode(ccode);
}
}
chinfo->channel = CH_UNKNOWN;
chinfo->medium = IPMI_CHANNEL_MEDIUM_RESERVED;
}
return;
} }
/** /**
@ -294,7 +276,7 @@ ipmi_get_channel_auth_cap(struct ipmi_intf *intf, uint8_t channel, uint8_t priv)
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp || rsp->ccode) { if ((rsp == NULL) || (rsp->ccode > 0)) {
/* /*
* It's very possible that this failed because we asked for IPMI v2 data * It's very possible that this failed because we asked for IPMI v2 data
* Ask again, without requesting IPMI v2 data * Ask again, without requesting IPMI v2 data
@ -302,11 +284,11 @@ ipmi_get_channel_auth_cap(struct ipmi_intf *intf, uint8_t channel, uint8_t priv)
msg_data[0] &= 0x7F; msg_data[0] &= 0x7F;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Authentication Capabilities"); lprintf(LOG_ERR, "Unable to Get Channel Authentication Capabilities");
return (-1); return (-1);
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Authentication Capabilities failed: %s", lprintf(LOG_ERR, "Get Channel Authentication Capabilities failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return (-1); return (-1);
@ -360,152 +342,58 @@ ipmi_get_channel_auth_cap(struct ipmi_intf *intf, uint8_t channel, uint8_t priv)
return 0; return 0;
} }
static inline size_t parse_cipher_suite(uint8_t *cipher_suite_data, static int
size_t data_len, ipmi_get_channel_cipher_suites(struct ipmi_intf *intf, const char *payload_type,
uint32_t *iana, uint8_t channel)
uint8_t *auth_alg,
uint8_t *integrity_alg,
uint8_t *crypt_alg,
enum cipher_suite_ids *cipher_suite_id)
{
size_t size = 0;
const char *incomplete = "Incomplete data record in cipher suite data";
if (*cipher_suite_data == STANDARD_CIPHER_SUITE) {
struct std_cipher_suite_record_t *record =
(struct std_cipher_suite_record_t*)cipher_suite_data;
/* Verify that we have at least a full record left; id + 3 algs */
if (data_len < sizeof(*record)) {
lprintf(LOG_INFO, "%s", incomplete);
goto out;
}
/* IANA code remains default (0) */
*cipher_suite_id = record->cipher_suite_id;
*auth_alg = CIPHER_ALG_MASK & record->auth_alg;
*integrity_alg = CIPHER_ALG_MASK & record->integrity_alg;
*crypt_alg = CIPHER_ALG_MASK & record->crypt_alg;
size = sizeof(*record);
} else if (*cipher_suite_data == OEM_CIPHER_SUITE) {
/* OEM record type */
struct oem_cipher_suite_record_t *record =
(struct oem_cipher_suite_record_t*)cipher_suite_data;
/* Verify that we have at least a full record left
* id + iana + 3 algs
*/
if (data_len < sizeof(*record)) {
lprintf(LOG_INFO, "%s", incomplete);
goto out;
}
/* Grab the IANA */
*iana = ipmi24toh(record->iana);
*cipher_suite_id = record->cipher_suite_id;
*auth_alg = CIPHER_ALG_MASK & record->auth_alg;
*integrity_alg = CIPHER_ALG_MASK & record->integrity_alg;
*crypt_alg = CIPHER_ALG_MASK & record->crypt_alg;
size = sizeof(*record);
} else {
lprintf(LOG_INFO, "Bad start of record byte in cipher suite data "
"(value %x)", *cipher_suite_data);
}
out:
return size;
}
static size_t
parse_channel_cipher_suite_data(uint8_t *cipher_suite_data, size_t data_len,
struct cipher_suite_info* suites,
size_t nr_suites)
{
size_t count = 0;
size_t offset = 0;
/* Default everything to zeroes */
memset(suites, 0, sizeof(*suites) * nr_suites);
while (offset < data_len && count < nr_suites) {
size_t suite_size;
/* Set non-zero defaults */
suites[count].auth_alg = IPMI_AUTH_RAKP_NONE;
suites[count].integrity_alg = IPMI_INTEGRITY_NONE;
suites[count].crypt_alg = IPMI_CRYPT_NONE;
/* Update fields from cipher suite data */
suite_size = parse_cipher_suite(cipher_suite_data + offset,
data_len - offset,
&suites[count].iana,
&suites[count].auth_alg,
&suites[count].integrity_alg,
&suites[count].crypt_alg,
&suites[count].cipher_suite_id);
if (!suite_size) {
lprintf(LOG_INFO,
"Failed to parse cipher suite data at offset %d",
offset);
break;
}
offset += suite_size;
count++;
}
return count;
}
int
ipmi_get_channel_cipher_suites(struct ipmi_intf *intf,
const char *payload_type,
uint8_t channel,
struct cipher_suite_info *suites,
size_t *count)
{ {
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
uint8_t rqdata[3]; uint8_t rqdata[3];
uint32_t iana;
uint8_t auth_alg, integrity_alg, crypt_alg;
uint8_t cipher_suite_id;
uint8_t list_index = 0; uint8_t list_index = 0;
/* 0x40 sets * 16 bytes per set */ /* 0x40 sets * 16 bytes per set */
uint8_t cipher_suite_data[MAX_CIPHER_SUITE_RECORD_OFFSET * uint8_t cipher_suite_data[1024];
MAX_CIPHER_SUITE_DATA_LEN]; uint16_t offset = 0;
size_t offset = 0; /* how much was returned, total */
size_t nr_suites = 0; uint16_t cipher_suite_data_length = 0;
if (!suites || !count || !*count)
return -1;
nr_suites = *count;
*count = 0;
memset(cipher_suite_data, 0, sizeof(cipher_suite_data)); memset(cipher_suite_data, 0, sizeof(cipher_suite_data));
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = IPMI_GET_CHANNEL_CIPHER_SUITES; req.msg.cmd = IPMI_GET_CHANNEL_CIPHER_SUITES;
req.msg.data = rqdata; req.msg.data = rqdata;
req.msg.data_len = sizeof(rqdata); req.msg.data_len = 3;
rqdata[0] = channel; rqdata[0] = channel;
rqdata[1] = strcmp(payload_type, "ipmi") ? 1 : 0; rqdata[1] = ((strncmp(payload_type, "ipmi", 4) == 0)? 0: 1);
/* Always ask for cipher suite format */
rqdata[2] = 0x80;
do { rsp = intf->sendrecv(intf, &req);
/* Always ask for cipher suite format */ if (rsp == NULL) {
rqdata[2] = LIST_ALGORITHMS_BY_CIPHER_SUITE | list_index; lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
rsp = intf->sendrecv(intf, &req); return -1;
if (!rsp) { }
lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites"); if (rsp->ccode > 0) {
return -1; lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
} val2str(rsp->ccode, completion_code_vals));
if (rsp->ccode return -1;
|| rsp->data_len < 1 }
|| rsp->data_len > sizeof(uint8_t) + MAX_CIPHER_SUITE_DATA_LEN)
{
lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s", /*
val2str(rsp->ccode, completion_code_vals)); * Grab the returned channel number once. We assume it's the same
return -1; * in future calls.
} */
if (rsp->data_len >= 1) {
channel = rsp->data[0];
}
while ((rsp->data_len > 1) && (rsp->data_len == 17) && (list_index < 0x3F)) {
/* /*
* We got back cipher suite data -- store it. * We got back cipher suite data -- store it.
* printf("copying data to offset %d\n", offset); * printf("copying data to offset %d\n", offset);
@ -513,49 +401,116 @@ ipmi_get_channel_cipher_suites(struct ipmi_intf *intf,
*/ */
memcpy(cipher_suite_data + offset, rsp->data + 1, rsp->data_len - 1); memcpy(cipher_suite_data + offset, rsp->data + 1, rsp->data_len - 1);
offset += rsp->data_len - 1; offset += rsp->data_len - 1;
/* /*
* Increment our list for the next call * Increment our list for the next call
*/ */
++list_index; ++list_index;
} while ((rsp->data_len == (sizeof(uint8_t) + MAX_CIPHER_SUITE_DATA_LEN)) rqdata[2] = (rqdata[2] & 0x80) + list_index;
&& (list_index < MAX_CIPHER_SUITE_RECORD_OFFSET));
*count = parse_channel_cipher_suite_data(cipher_suite_data, offset, suites, rsp = intf->sendrecv(intf, &req);
nr_suites); if (rsp == NULL) {
return 0; lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
} return -1;
}
static int if (rsp->ccode > 0) {
ipmi_print_channel_cipher_suites(struct ipmi_intf *intf, lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
const char *payload_type, val2str(rsp->ccode, completion_code_vals));
uint8_t channel) return -1;
{ }
int rc;
size_t i = 0;
struct cipher_suite_info suites[MAX_CIPHER_SUITE_COUNT];
size_t nr_suites = sizeof(*suites);
const char *header_str =
"ID IANA Auth Alg Integrity Alg Confidentiality Alg";
rc = ipmi_get_channel_cipher_suites(intf, payload_type, channel,
suites, &nr_suites);
if (rc < 0)
return rc;
if (!csv_output) {
printf("%s\n", header_str);
} }
for (i = 0; i < nr_suites; i++) {
/* Copy last chunk */
if(rsp->data_len > 1) {
/*
* We got back cipher suite data -- store it.
* printf("copying data to offset %d\n", offset);
* printbuf(rsp->data + 1, rsp->data_len - 1, "this is the data");
*/
memcpy(cipher_suite_data + offset, rsp->data + 1, rsp->data_len - 1);
offset += rsp->data_len - 1;
}
/* We can chomp on all our data now. */
cipher_suite_data_length = offset;
offset = 0;
if (! csv_output) {
printf("ID IANA Auth Alg Integrity Alg Confidentiality Alg\n");
}
while (offset < cipher_suite_data_length) {
if (cipher_suite_data[offset++] == 0xC0) {
/* standard type */
iana = 0;
/* Verify that we have at least a full record left; id + 3 algs */
if ((cipher_suite_data_length - offset) < 4) {
lprintf(LOG_ERR, "Incomplete data record in cipher suite data");
return -1;
}
cipher_suite_id = cipher_suite_data[offset++];
} else if (cipher_suite_data[offset++] == 0xC1) {
/* OEM record type */
/* Verify that we have at least a full record left
* id + iana + 3 algs
*/
if ((cipher_suite_data_length - offset) < 4) {
lprintf(LOG_ERR, "Incomplete data record in cipher suite data");
return -1;
}
cipher_suite_id = cipher_suite_data[offset++];
/* Grab the IANA */
iana =
cipher_suite_data[offset] |
(cipher_suite_data[offset + 1] << 8) |
(cipher_suite_data[offset + 2] << 16);
offset += 3;
} else {
lprintf(LOG_ERR, "Bad start of record byte in cipher suite data");
return -1;
}
/*
* Grab the algorithms for this cipher suite. I guess we can't be
* sure of what order they'll come in. Also, I suppose we default
* to the NONE algorithm if one were absent. This part of the spec is
* poorly written -- I have read the errata document. For now, I'm only
* allowing one algorithm per type (auth, integrity, crypt) because I
* don't I understand how it could be otherwise.
*/
auth_alg = IPMI_AUTH_RAKP_NONE;
integrity_alg = IPMI_INTEGRITY_NONE;
crypt_alg = IPMI_CRYPT_NONE;
while (((cipher_suite_data[offset] & 0xC0) != 0xC0) &&
((cipher_suite_data_length - offset) > 0))
{
switch (cipher_suite_data[offset] & 0xC0)
{
case 0x00:
/* Authentication algorithm specifier */
auth_alg = cipher_suite_data[offset++] & 0x3F;
break;
case 0x40:
/* Interity algorithm specifier */
integrity_alg = cipher_suite_data[offset++] & 0x3F;
break;
case 0x80:
/* Confidentiality algorithm specifier */
crypt_alg = cipher_suite_data[offset++] & 0x3F;
break;
}
}
/* We have everything we need to spit out a cipher suite record */ /* We have everything we need to spit out a cipher suite record */
printf(csv_output ? "%d,%s,%s,%s,%s\n" printf((csv_output? "%d,%s,%s,%s,%s\n" :
: "%-4d %-7s %-15s %-15s %-15s\n", "%-4d %-7s %-15s %-15s %-15s\n"),
suites[i].cipher_suite_id, cipher_suite_id,
iana_string(suites[i].iana), iana_string(iana),
val2str(suites[i].auth_alg, ipmi_auth_algorithms), val2str(auth_alg, ipmi_auth_algorithms),
val2str(suites[i].integrity_alg, ipmi_integrity_algorithms), val2str(integrity_alg, ipmi_integrity_algorithms),
val2str(suites[i].crypt_alg, ipmi_encryption_algorithms)); val2str(crypt_alg, ipmi_encryption_algorithms));
} }
return 0; return 0;
} }
@ -693,9 +648,8 @@ ipmi_get_channel_info(struct ipmi_intf *intf, uint8_t channel)
* *
* @channel - IPMI Channel * @channel - IPMI Channel
* *
* @returns IPMI Channel Medium * returns - IPMI Channel Medium, IPMI_CHANNEL_MEDIUM_RESERVED if ccode > 0,
* @retval IPMI_CHANNEL_MEDIUM_RESERVED if ccode was not IPMI_CC_OK * 0 on error.
* @retval 0 on error
*/ */
uint8_t uint8_t
ipmi_get_channel_medium(struct ipmi_intf *intf, uint8_t channel) ipmi_get_channel_medium(struct ipmi_intf *intf, uint8_t channel)
@ -705,16 +659,13 @@ ipmi_get_channel_medium(struct ipmi_intf *intf, uint8_t channel)
channel_info.channel = channel; channel_info.channel = channel;
ccode = _ipmi_get_channel_info(intf, &channel_info); ccode = _ipmi_get_channel_info(intf, &channel_info);
if (ccode) { if (ccode == 0xCC) {
if (ccode != IPMI_CC_INV_DATA_FIELD_IN_REQ) { return IPMI_CHANNEL_MEDIUM_RESERVED;
if (ccode > 0) { } else if (ccode < 0 && eval_ccode(ccode) != 0) {
lprintf(LOG_ERR, "Get Channel Info command failed: %s", return 0;
val2str(ccode, completion_code_vals)); } else if (ccode > 0) {
} lprintf(LOG_ERR, "Get Channel Info command failed: %s",
else { val2str(ccode, completion_code_vals));
eval_ccode(ccode);
}
}
return IPMI_CHANNEL_MEDIUM_RESERVED; return IPMI_CHANNEL_MEDIUM_RESERVED;
} }
lprintf(LOG_DEBUG, "Channel type: %s", lprintf(LOG_DEBUG, "Channel type: %s",
@ -803,27 +754,9 @@ ipmi_set_user_access(struct ipmi_intf *intf, int argc, char **argv)
int ccode = 0; int ccode = 0;
int i = 0; int i = 0;
uint8_t channel = 0; uint8_t channel = 0;
uint8_t priv = 0;
uint8_t user_id = 0; uint8_t user_id = 0;
struct { if (argc > 0 && strncmp(argv[0], "help", 4) == 0) {
const char *option;
enum {
UA_INTEGER, /* direct integer value */
UA_BOOLEAN, /* off/disable = false, on/enable = true */
UA_BOOLEAN_INVERSE /* off/disable = true, on/enable = false */
} type;
uint8_t *val;
uint8_t min; /* minimum value for UA_INTEGER options */
uint8_t max; /* maximum value for UA_INTEGER options */
} options[] = {
{ "callin=", UA_BOOLEAN_INVERSE, &user_access.callin_callback, 0, 0},
{ "link=", UA_BOOLEAN, &user_access.link_auth, 0, 0},
{ "ipmi=", UA_BOOLEAN, &user_access.ipmi_messaging, 0, 0},
{ "privilege=", UA_INTEGER, &user_access.privilege_limit
, IPMI_SESSION_PRIV_CALLBACK
, IPMI_SESSION_PRIV_NOACCESS },
};
if (argc > 0 && !strcmp(argv[0], "help")) {
printf_channel_usage(); printf_channel_usage();
return 0; return 0;
} else if (argc < 3) { } else if (argc < 3) {
@ -845,46 +778,33 @@ ipmi_set_user_access(struct ipmi_intf *intf, int argc, char **argv)
return (-1); return (-1);
} }
for (i = 2; i < argc; i ++) { for (i = 2; i < argc; i ++) {
size_t j; if (strncmp(argv[i], "callin=", 7) == 0) {
for (j = 0; j < ARRAY_SIZE(options); ++j) { if (strncmp(argv[i] + 7, "off", 3) == 0) {
const char *opt = argv[i]; user_access.callin_callback = 1;
const int optlen = strlen(options[j].option); } else {
if (!strncmp(opt, options[j].option, optlen)) { user_access.callin_callback = 0;
const char *optval = opt + optlen;
uint16_t val;
if (UA_INTEGER != options[j].type) {
bool boolval = (UA_BOOLEAN_INVERSE == options[j].type)
? false
: true;
*options[j].val = boolval;
if (!strcmp(optval, "off")
|| !strcmp(optval, "disable")
|| !strcmp(optval, "no"))
{
boolval = !boolval;
}
} else if (UINT8_MAX
!= (val = str2val(optval, ipmi_privlvl_vals)))
{
*options[j].val = (uint8_t)val;
} else if (str2uchar(optval, options[j].val)) {
lprintf(LOG_ERR
, "Numeric [%hhu-%hhu] value expected, "
"but '%s' given."
, options[j].min
, options[j].max
, optval);
return (-1);
}
lprintf(LOG_DEBUG
, "Option %s=%hhu"
, options[j].option
, *options[j].val);
break;
} }
} } else if (strncmp(argv[i], "link=", 5) == 0) {
if (ARRAY_SIZE(options) == j) { if (strncmp(argv[i] + 5, "off", 3) == 0) {
user_access.link_auth = 0;
} else {
user_access.link_auth = 1;
}
} else if (strncmp(argv[i], "ipmi=", 5) == 0) {
if (strncmp(argv[i] + 5, "off", 3) == 0) {
user_access.ipmi_messaging = 0;
} else {
user_access.ipmi_messaging = 1;
}
} else if (strncmp(argv[i], "privilege=", 10) == 0) {
if (str2uchar(argv[i] + 10, &priv) != 0) {
lprintf(LOG_ERR,
"Numeric value expected, but '%s' given.",
argv[i] + 10);
return (-1);
}
user_access.privilege_limit = priv;
} else {
lprintf(LOG_ERR, "Invalid option: %s\n", argv[i]); lprintf(LOG_ERR, "Invalid option: %s\n", argv[i]);
return (-1); return (-1);
} }
@ -911,10 +831,10 @@ ipmi_channel_main(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
printf_channel_usage(); printf_channel_usage();
return (-1); return (-1);
} else if (!strcmp(argv[0], "help")) { } else if (strncmp(argv[0], "help", 4) == 0) {
printf_channel_usage(); printf_channel_usage();
return 0; return 0;
} else if (!strcmp(argv[0], "authcap")) { } else if (strncmp(argv[0], "authcap", 7) == 0) {
if (argc != 3) { if (argc != 3) {
printf_channel_usage(); printf_channel_usage();
return (-1); return (-1);
@ -924,7 +844,7 @@ ipmi_channel_main(struct ipmi_intf *intf, int argc, char **argv)
return (-1); return (-1);
} }
retval = ipmi_get_channel_auth_cap(intf, channel, priv); retval = ipmi_get_channel_auth_cap(intf, channel, priv);
} else if (!strcmp(argv[0], "getaccess")) { } else if (strncmp(argv[0], "getaccess", 10) == 0) {
uint8_t user_id = 0; uint8_t user_id = 0;
if ((argc < 2) || (argc > 3)) { if ((argc < 2) || (argc > 3)) {
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
@ -940,9 +860,9 @@ ipmi_channel_main(struct ipmi_intf *intf, int argc, char **argv)
} }
} }
retval = ipmi_get_user_access(intf, channel, user_id); retval = ipmi_get_user_access(intf, channel, user_id);
} else if (!strcmp(argv[0], "setaccess")) { } else if (strncmp(argv[0], "setaccess", 9) == 0) {
return ipmi_set_user_access(intf, (argc - 1), &(argv[1])); return ipmi_set_user_access(intf, (argc - 1), &(argv[1]));
} else if (!strcmp(argv[0], "info")) { } else if (strncmp(argv[0], "info", 4) == 0) {
channel = 0xE; channel = 0xE;
if (argc > 2) { if (argc > 2) {
printf_channel_usage(); printf_channel_usage();
@ -954,11 +874,11 @@ ipmi_channel_main(struct ipmi_intf *intf, int argc, char **argv)
} }
} }
retval = ipmi_get_channel_info(intf, channel); retval = ipmi_get_channel_info(intf, channel);
} else if (!strcmp(argv[0], "getciphers")) { } else if (strncmp(argv[0], "getciphers", 10) == 0) {
/* channel getciphers <ipmi|sol> [channel] */ /* channel getciphers <ipmi|sol> [channel] */
channel = 0xE; channel = 0xE;
if ((argc < 2) || (argc > 3) || if ((argc < 2) || (argc > 3) ||
(strcmp(argv[1], "ipmi") && strcmp(argv[1], "sol"))) { (strncmp(argv[1], "ipmi", 4) && strncmp(argv[1], "sol", 3))) {
printf_channel_usage(); printf_channel_usage();
return (-1); return (-1);
} }
@ -967,9 +887,9 @@ ipmi_channel_main(struct ipmi_intf *intf, int argc, char **argv)
return (-1); return (-1);
} }
} }
retval = ipmi_print_channel_cipher_suites(intf, retval = ipmi_get_channel_cipher_suites(intf,
argv[1], /* ipmi | sol */ argv[1], /* ipmi | sol */
channel); channel);
} else { } else {
lprintf(LOG_ERR, "Invalid CHANNEL command: %s\n", argv[0]); lprintf(LOG_ERR, "Invalid CHANNEL command: %s\n", argv[0]);
printf_channel_usage(); printf_channel_usage();

File diff suppressed because it is too large Load Diff

1257
lib/ipmi_dcmi.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -37,14 +37,10 @@
#include <ipmitool/log.h> #include <ipmitool/log.h>
#include <ipmitool/helper.h> #include <ipmitool/helper.h>
#include <ipmitool/ipmi_strings.h> #include <ipmitool/ipmi_strings.h>
#include <ipmitool/ipmi_fru.h>
#include <ipmitool/ipmi_time.h>
#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*/
@ -197,7 +193,7 @@ struct ipmi_ek_amc_p2p_connectivity_record{
struct fru_picmgext_amc_channel_desc_record * ch_desc; struct fru_picmgext_amc_channel_desc_record * ch_desc;
unsigned char link_desc_count; unsigned char link_desc_count;
struct fru_picmgext_amc_link_desc_record * link_desc; struct fru_picmgext_amc_link_desc_record * link_desc;
int * matching_result; /*For link descriptor comparison*/ int * matching_result; /*For link descriptor comparision*/
}; };
/***************************************************************************** /*****************************************************************************
@ -220,7 +216,8 @@ static void ipmi_ek_add_record2list( struct ipmi_ek_multi_header ** record,
struct ipmi_ek_multi_header ** list_last ); struct ipmi_ek_multi_header ** list_last );
static void ipmi_ek_display_record( struct ipmi_ek_multi_header * record, static void ipmi_ek_display_record( struct ipmi_ek_multi_header * record,
struct ipmi_ek_multi_header * list_head); struct ipmi_ek_multi_header * list_head,
struct ipmi_ek_multi_header * list_last );
static void ipmi_ek_remove_record_from_list( static void ipmi_ek_remove_record_from_list(
struct ipmi_ek_multi_header * record, struct ipmi_ek_multi_header * record,
@ -237,7 +234,7 @@ static int ipmi_ekanalyzer_fru_file2structure( char * filename,
*****************************************************************************/ *****************************************************************************/
static int ipmi_ek_matching_process( int * file_type, int index1, int index2, static int ipmi_ek_matching_process( int * file_type, int index1, int index2,
struct ipmi_ek_multi_header ** list_head, struct ipmi_ek_multi_header ** list_head,
char * opt, struct ipmi_ek_multi_header ** list_last, char * opt,
struct ipmi_ek_multi_header * pphysical ); struct ipmi_ek_multi_header * pphysical );
static int ipmi_ek_get_resource_descriptor( int port_count, int index, static int ipmi_ek_get_resource_descriptor( int port_count, int index,
@ -453,11 +450,11 @@ ipmi_ek_get_file_type(char *argument)
* *
* Global: None * Global: None
* *
* Return: OK_STATUS as success or ERROR_STATUS as error * Return: OK_STATUS as succes or ERROR_STATUS as error
* *
***************************************************************************/ ***************************************************************************/
int int
ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv) ipmi_ekanalyzer_main(struct ipmi_intf *intf, int argc, char **argv)
{ {
int rc = ERROR_STATUS; int rc = ERROR_STATUS;
int file_type[MAX_FILE_NUMBER]; int file_type[MAX_FILE_NUMBER];
@ -478,12 +475,11 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
return (-1); return (-1);
} }
if (!strcmp(argv[argument_offset], "help")) { if (strcmp(argv[argument_offset], "help") == 0) {
ipmi_ekanalyzer_usage(); ipmi_ekanalyzer_usage();
return 0; return 0;
} else if (!strcmp(argv[argument_offset], "frushow") } else if ((strcmp(argv[argument_offset], "frushow") == 0)
&& (argc > (MIN_ARGUMENT-1))) && (argc > (MIN_ARGUMENT-1))) {
{
for (type_offset = 0; type_offset < (argc-1); type_offset++ ) { for (type_offset = 0; type_offset < (argc-1); type_offset++ ) {
argument_offset++; argument_offset++;
file_type[type_offset] = ipmi_ek_get_file_type(argv[argument_offset]); file_type[type_offset] = ipmi_ek_get_file_type(argv[argument_offset]);
@ -499,7 +495,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
*/ */
filename[type_offset] = malloc(strlen(argv[argument_offset]) filename[type_offset] = malloc(strlen(argv[argument_offset])
+ 1 - SIZE_OF_FILE_TYPE); + 1 - SIZE_OF_FILE_TYPE);
if (!filename[type_offset]) { if (filename[type_offset] == NULL) {
lprintf(LOG_ERR, "malloc failure"); lprintf(LOG_ERR, "malloc failure");
return (-1); return (-1);
} }
@ -515,9 +511,9 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
/* Convert from binary data into multi record structure */ /* Convert from binary data into multi record structure */
rc = ipmi_ekanalyzer_fru_file2structure (filename[type_offset], rc = ipmi_ekanalyzer_fru_file2structure (filename[type_offset],
&list_head, &list_record, &list_last ); &list_head, &list_record, &list_last );
ipmi_ek_display_record(list_record, list_head); ipmi_ek_display_record(list_record, list_head, list_last);
/* Remove record of list */ /* Remove record of list */
while (list_head) { while (list_head != NULL) {
ipmi_ek_remove_record_from_list(list_head, ipmi_ek_remove_record_from_list(list_head,
&list_head,&list_last ); &list_head,&list_last );
if (verbose > 1) { if (verbose > 1) {
@ -528,9 +524,8 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
free(filename[type_offset]); free(filename[type_offset]);
filename[type_offset] = NULL; filename[type_offset] = NULL;
} }
} else if (!strcmp(argv[argument_offset], "print") } else if ((strcmp(argv[argument_offset], "print") == 0)
|| !strcmp(argv[argument_offset], "summary")) || (strcmp(argv[argument_offset], "summary") == 0)) {
{
/* Display help text for corresponding command /* Display help text for corresponding command
* if not enough parameters were given. * if not enough parameters were given.
*/ */
@ -542,7 +537,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
int filename_size=0; int filename_size=0;
if (argc < MIN_ARGUMENT) { if (argc < MIN_ARGUMENT) {
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
if (!strcmp(argv[argument_offset], "print")) { if (strcmp(argv[argument_offset], "print") == 0) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
" ekanalyzer print [carrier/power/all]" " ekanalyzer print [carrier/power/all]"
" <xx=frufile> <xx=frufile> [xx=frufile]"); " <xx=frufile> <xx=frufile> [xx=frufile]");
@ -554,20 +549,18 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
return ERROR_STATUS; return ERROR_STATUS;
} }
argument_offset++; argument_offset++;
if (!strcmp(argv[argument_offset], "carrier") if ((strcmp(argv[argument_offset], "carrier") == 0)
|| !strcmp(argv[argument_offset], "power") || (strcmp(argv[argument_offset], "power") == 0)
|| !strcmp(argv[argument_offset], "all")) || (strcmp(argv[argument_offset], "all") == 0)) {
{
option = argv[argument_offset]; option = argv[argument_offset];
index ++; index ++;
argc--; argc--;
} else if (!strcmp(argv[argument_offset], "match") } else if ((strcmp(argv[argument_offset], "match") == 0)
|| !strcmp(argv[argument_offset], "unmatch")) || ( strcmp(argv[argument_offset], "unmatch") == 0)) {
{
option = argv[argument_offset]; option = argv[argument_offset];
index ++; index ++;
argc--; argc--;
} else if ('=' == argv[argument_offset][2]) { } else if ( strncmp(&argv[argument_offset][2], "=", 1) == 0) {
/* since the command line must receive xx=filename, /* since the command line must receive xx=filename,
* so the position of "=" sign is 2 * so the position of "=" sign is 2
*/ */
@ -580,7 +573,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
option = "invalid"; option = "invalid";
printf("Invalid option '%s'\n", argv[argument_offset]); printf("Invalid option '%s'\n", argv[argument_offset]);
argument_offset--; argument_offset--;
if (!strcmp(argv[0], "print")) { if (strcmp(argv[0], "print") == 0) {
lprintf (LOG_ERR, lprintf (LOG_ERR,
" ekanalyzer print [carrier/power/all]" " ekanalyzer print [carrier/power/all]"
" <xx=frufile> <xx=frufile> [xx=frufile]"); " <xx=frufile> <xx=frufile> [xx=frufile]");
@ -591,12 +584,12 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
} }
rc = ERROR_STATUS; rc = ERROR_STATUS;
} }
if (strcmp(option, "invalid")) { if (strcmp(option, "invalid") != 0) {
int i=0; int i=0;
for (i = 0; i < (argc-1); i++) { for (i = 0; i < (argc-1); i++) {
file_type[i] = ipmi_ek_get_file_type (argv[index]); file_type[i] = ipmi_ek_get_file_type (argv[index]);
if (file_type[i] == ERROR_STATUS) { if (file_type[i] == ERROR_STATUS) {
/* display the first 2 characters (file type) of argument */ /* display the first 2 charactors (file type) of argument */
lprintf(LOG_ERR, "Invalid file type: %c%c\n", lprintf(LOG_ERR, "Invalid file type: %c%c\n",
argv[index][0], argv[index][0],
argv[index][1]); argv[index][1]);
@ -610,7 +603,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
filename_size = strlen(argv[index]) - SIZE_OF_FILE_TYPE + 1; filename_size = strlen(argv[index]) - SIZE_OF_FILE_TYPE + 1;
if (filename_size > 0) { if (filename_size > 0) {
filename[i] = malloc( filename_size ); filename[i] = malloc( filename_size );
if (filename[i]) { if (filename[i] != NULL) {
strcpy(filename[i], &argv[index][SIZE_OF_FILE_TYPE]); strcpy(filename[i], &argv[index][SIZE_OF_FILE_TYPE]);
} else { } else {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
@ -630,7 +623,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
printf("file name: %s\n", filename[i]); printf("file name: %s\n", filename[i]);
} }
} }
if (!strcmp(argv[0], "print")) { if (strcmp(argv[0], "print") == 0) {
rc = ipmi_ekanalyzer_print((argc-1), rc = ipmi_ekanalyzer_print((argc-1),
option, filename, file_type); option, filename, file_type);
} else { } else {
@ -638,7 +631,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
option, filename, file_type); option, filename, file_type);
} }
for (i = 0; i < (argc-1); i++) { for (i = 0; i < (argc-1); i++) {
if (filename[i]) { if (filename[i] != NULL) {
free(filename[i]); free(filename[i]);
filename[i] = NULL; filename[i] = NULL;
} }
@ -681,7 +674,7 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
{ {
int return_value = OK_STATUS; int return_value = OK_STATUS;
/* Display carrier topology */ /* Display carrier topology */
if (!strcmp(opt, "carrier") || !strcmp(opt, "default")) { if ((strcmp(opt, "carrier") == 0) || (strcmp(opt, "default") == 0)) {
tboolean found_flag = FALSE; tboolean found_flag = FALSE;
int index = 0; int index = 0;
int index_name[argc]; int index_name[argc];
@ -721,9 +714,8 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
*/ */
tboolean first_data = TRUE; tboolean first_data = TRUE;
for (list_record[i] = list_head[i]; for (list_record[i] = list_head[i];
list_record[i]; list_record[i] != NULL;
list_record[i] = list_record[i]->next) list_record[i] = list_record[i]->next) {
{
if (list_record[i]->data[PICMG_ID_OFFSET] == FRU_AMC_CARRIER_P2P) { if (list_record[i]->data[PICMG_ID_OFFSET] == FRU_AMC_CARRIER_P2P) {
if (first_data) { if (first_data) {
printf("%s\n", STAR_LINE_LIMITER); printf("%s\n", STAR_LINE_LIMITER);
@ -732,7 +724,7 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
} }
return_value = ipmi_ek_display_carrier_connectivity(list_record[i]); return_value = ipmi_ek_display_carrier_connectivity(list_record[i]);
} else if (list_record[i]->data[PICMG_ID_OFFSET] == FRU_AMC_CARRIER_INFO) { } else if (list_record[i]->data[PICMG_ID_OFFSET] == FRU_AMC_CARRIER_INFO) {
/*See AMC.0 specification Table3-3 for more detail*/ /*See AMC.0 specification Table3-3 for mor detail*/
#define COUNT_OFFSET 6 #define COUNT_OFFSET 6
if (first_data) { if (first_data) {
printf("From Carrier file: %s\n", filename[index_name[i]]); printf("From Carrier file: %s\n", filename[index_name[i]]);
@ -745,7 +737,7 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
} }
/*Destroy the list of record*/ /*Destroy the list of record*/
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
while (list_head[i]) { while (list_head[i] != NULL) {
ipmi_ek_remove_record_from_list(list_head[i], ipmi_ek_remove_record_from_list(list_head[i],
&list_head[i], &list_last[i]); &list_head[i], &list_last[i]);
} }
@ -757,10 +749,10 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
} }
} }
} }
} else if (!strcmp(opt, "power")) { } else if (strcmp(opt, "power") == 0) {
printf("Print power information\n"); printf("Print power information\n");
return_value = ipmi_ek_display_power(argc, opt, filename, file_type); return_value = ipmi_ek_display_power(argc, opt, filename, file_type);
} else if (!strcmp(opt, "all")) { } else if (strcmp(opt, "all") == 0) {
printf("Print all information\n"); printf("Print all information\n");
return_value = ipmi_ek_display_power(argc, opt, filename, file_type); return_value = ipmi_ek_display_power(argc, opt, filename, file_type);
} else { } else {
@ -795,7 +787,7 @@ ipmi_ek_display_carrier_connectivity(struct ipmi_ek_multi_header *record)
int offset = START_DATA_OFFSET; int offset = START_DATA_OFFSET;
struct fru_picmgext_carrier_p2p_record rsc_desc; struct fru_picmgext_carrier_p2p_record rsc_desc;
struct fru_picmgext_carrier_p2p_descriptor *port_desc; struct fru_picmgext_carrier_p2p_descriptor *port_desc;
if (!record) { if (record == NULL) {
lprintf(LOG_ERR, "P2P connectivity record is invalid\n"); lprintf(LOG_ERR, "P2P connectivity record is invalid\n");
return ERROR_STATUS; return ERROR_STATUS;
} }
@ -923,14 +915,14 @@ ipmi_ek_display_power( int argc, char * opt, char ** filename, int * file_type )
return_value = ipmi_ekanalyzer_fru_file2structure( filename[num_file], return_value = ipmi_ekanalyzer_fru_file2structure( filename[num_file],
&list_head[num_file], &list_record[num_file], &list_last[num_file]); &list_head[num_file], &list_record[num_file], &list_last[num_file]);
if (list_head[num_file]){ if ( list_head[num_file] != NULL ){
for ( list_record[num_file] = list_head[num_file]; for ( list_record[num_file] = list_head[num_file];
list_record[num_file]; list_record[num_file] != NULL;
list_record[num_file] = list_record[num_file]->next) list_record[num_file] = list_record[num_file]->next
{ ){
if (!strcmp(opt, "all") if ( ( strcmp(opt, "all") == 0 )
&& file_type[num_file] == ON_CARRIER_FRU_FILE) && ( file_type[num_file] == ON_CARRIER_FRU_FILE )
{ ){
if ( list_record[num_file]->data[PICMG_ID_OFFSET] if ( list_record[num_file]->data[PICMG_ID_OFFSET]
== ==
FRU_AMC_CARRIER_P2P FRU_AMC_CARRIER_P2P
@ -997,7 +989,7 @@ ipmi_ek_display_power( int argc, char * opt, char ** filename, int * file_type )
return_value = OK_STATUS; return_value = OK_STATUS;
/*Destroy the list of record*/ /*Destroy the list of record*/
for ( index = 0; index < argc; index++ ){ for ( index = 0; index < argc; index++ ){
while (list_head[index]) { while ( list_head[index] != NULL ){
ipmi_ek_remove_record_from_list ( list_head[index], ipmi_ek_remove_record_from_list ( list_head[index],
&list_head[index],&list_last[index] ); &list_head[index],&list_last[index] );
} }
@ -1089,7 +1081,7 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
{ {
tboolean return_value = FALSE; tboolean return_value = FALSE;
if (!strcmp(opt, "carrier") || !strcmp(opt, "power")) { if ( (strcmp(opt, "carrier") == 0 ) || (strcmp(opt, "power") == 0) ){
lprintf(LOG_ERR, " ekanalyzer summary [match/ unmatch/ all]"\ lprintf(LOG_ERR, " ekanalyzer summary [match/ unmatch/ all]"\
" <xx=frufile> <xx=frufile> [xx=frufile]"); " <xx=frufile> <xx=frufile> [xx=frufile]");
return_value = ERROR_STATUS; return_value = ERROR_STATUS;
@ -1160,13 +1152,13 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
/*Get Carrier p2p connectivity record for physical check*/ /*Get Carrier p2p connectivity record for physical check*/
for (num_file=0; num_file < argc; num_file++){ for (num_file=0; num_file < argc; num_file++){
if (file_type[num_file] == ON_CARRIER_FRU_FILE ){ if (file_type[num_file] == ON_CARRIER_FRU_FILE ){
for (pcarrier_p2p = list_head[num_file]; for ( pcarrier_p2p=list_head[num_file];
pcarrier_p2p; pcarrier_p2p != NULL ;
pcarrier_p2p = pcarrier_p2p->next) pcarrier_p2p = pcarrier_p2p->next
{ ){
if (FRU_AMC_CARRIER_P2P == if ( pcarrier_p2p->data[PICMG_ID_OFFSET]
pcarrier_p2p->data[PICMG_ID_OFFSET]) == FRU_AMC_CARRIER_P2P
{ ){
break; break;
} }
} }
@ -1193,14 +1185,14 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
} }
return_value = ipmi_ek_matching_process( file_type, return_value = ipmi_ek_matching_process( file_type,
match_pair, num_file, list_head, match_pair, num_file, list_head,
opt, pcarrier_p2p); list_last, opt, pcarrier_p2p);
} }
} }
} }
match_pair ++; match_pair ++;
} }
for( num_file=0; num_file < argc; num_file++ ){ for( num_file=0; num_file < argc; num_file++ ){
if (list_head[num_file]) { if (list_head[num_file] != NULL ){
ipmi_ek_remove_record_from_list( list_head[num_file], ipmi_ek_remove_record_from_list( list_head[num_file],
&list_record[num_file], &list_last[num_file]); &list_record[num_file], &list_last[num_file]);
} }
@ -1229,6 +1221,8 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
* index2: position of the second record in the list of the record * index2: position of the second record in the list of the record
* ipmi_ek_multi_header ** list_head: pointer to the header of a * ipmi_ek_multi_header ** list_head: pointer to the header of a
* linked list that contain FRU multi record * linked list that contain FRU multi record
* ipmi_ek_multi_header ** list_last: pointer to the tale of a
* linked list that contain FRU multi record
* opt: string that contain display option such as "match", "unmatch", or * opt: string that contain display option such as "match", "unmatch", or
* "all". * "all".
* pphysical: a pointer that contain a carrier p2p connectivity record * pphysical: a pointer that contain a carrier p2p connectivity record
@ -1244,7 +1238,7 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
***************************************************************************/ ***************************************************************************/
static int ipmi_ek_matching_process( int * file_type, int index1, int index2, static int ipmi_ek_matching_process( int * file_type, int index1, int index2,
struct ipmi_ek_multi_header ** list_head, struct ipmi_ek_multi_header ** list_head,
char * opt, struct ipmi_ek_multi_header ** list_last, char * opt,
struct ipmi_ek_multi_header * pphysical ) struct ipmi_ek_multi_header * pphysical )
{ {
int result = ERROR_STATUS; int result = ERROR_STATUS;
@ -1260,13 +1254,13 @@ static int ipmi_ek_matching_process( int * file_type, int index1, int index2,
index2 = index_temp; /*index2 indcate an AMC*/ index2 = index_temp; /*index2 indcate an AMC*/
} }
/*Calculate record size for Carrier file*/ /*Calculate record size for Carrier file*/
for (record = list_head[index1]; record; record = record->next ){ for ( record=list_head[index1]; record != NULL;record = record->next ){
if ( record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){ if ( record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){
num_amc_record2++; num_amc_record2++;
} }
} }
/*Calculate record size for amc file*/ /*Calculate record size for amc file*/
for (record = list_head[index2]; record; record = record->next){ for ( record=list_head[index2]; record != NULL;record = record->next){
if ( record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){ if ( record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){
num_amc_record1++; num_amc_record1++;
} }
@ -1284,17 +1278,17 @@ static int ipmi_ek_matching_process( int * file_type, int index1, int index2,
amc_record2 = malloc ( num_amc_record2 * \ amc_record2 = malloc ( num_amc_record2 * \
sizeof(struct ipmi_ek_amc_p2p_connectivity_record)); sizeof(struct ipmi_ek_amc_p2p_connectivity_record));
for (record = list_head[index2]; record; record = record->next) { for (record=list_head[index2]; record != NULL;record = record->next){
if ( record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){ if ( record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){
result = ipmi_ek_create_amc_p2p_record( record, result = ipmi_ek_create_amc_p2p_record( record,
&amc_record1[index_record1] ); &amc_record1[index_record1] );
if (result != ERROR_STATUS){ if (result != ERROR_STATUS){
struct ipmi_ek_multi_header * current_record = NULL; struct ipmi_ek_multi_header * current_record = NULL;
for (current_record=list_head[index1]; for ( current_record=list_head[index1];
current_record; current_record != NULL ;
current_record = current_record->next) current_record = current_record->next
{ ){
if ( current_record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){ if ( current_record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){
result = ipmi_ek_create_amc_p2p_record( current_record, result = ipmi_ek_create_amc_p2p_record( current_record,
&amc_record2[index_record2] ); &amc_record2[index_record2] );
@ -1364,7 +1358,7 @@ ipmi_ek_check_physical_connectivity(
{ {
int return_status = OK_STATUS; int return_status = OK_STATUS;
if (!record){ if ( record == NULL ){
printf("NO Carrier p2p connectivity !\n"); printf("NO Carrier p2p connectivity !\n");
return_status = ERROR_STATUS; return_status = ERROR_STATUS;
} }
@ -1429,7 +1423,7 @@ ipmi_ek_check_physical_connectivity(
rsc_desc.p2p_count ); rsc_desc.p2p_count );
} }
if (port_desc && return_status != ERROR_STATUS) { if ( (port_desc != NULL) && (return_status != ERROR_STATUS) ){
int j=0; int j=0;
for ( j = 0; j < rsc_desc.p2p_count; j++ ){ for ( j = 0; j < rsc_desc.p2p_count; j++ ){
@ -1456,7 +1450,7 @@ ipmi_ek_check_physical_connectivity(
(filetype1 ==(port_desc[j].remote_resource_id &0x0f)) (filetype1 ==(port_desc[j].remote_resource_id &0x0f))
) )
){ ){
if (strcmp(option, "unmatch")){ if ( ! (strcmp(option, "unmatch") == 0) ){
printf("%s port %d ==> %s port %d\n", printf("%s port %d ==> %s port %d\n",
val2str(filetype2, ipmi_ekanalyzer_module_type), val2str(filetype2, ipmi_ekanalyzer_module_type),
record1.ch_desc[index1].lane0port, record1.ch_desc[index1].lane0port,
@ -1479,7 +1473,7 @@ ipmi_ek_check_physical_connectivity(
&& &&
(filetype2 == (port_desc[j].remote_resource_id & 0x0f)) (filetype2 == (port_desc[j].remote_resource_id & 0x0f))
){ ){
if (strcmp(option, "unmatch")){ if ( ! (strcmp(option, "unmatch") == 0) ){
printf("%s port %d ==> %s port %d\n", printf("%s port %d ==> %s port %d\n",
val2str(filetype2, ipmi_ekanalyzer_module_type), val2str(filetype2, ipmi_ekanalyzer_module_type),
record1.ch_desc[index1].lane0port, record1.ch_desc[index1].lane0port,
@ -1493,7 +1487,7 @@ ipmi_ek_check_physical_connectivity(
&& &&
(record2.rsc_id == (port_desc[j].remote_resource_id)) (record2.rsc_id == (port_desc[j].remote_resource_id))
){ ){
if (strcmp(option, "unmatch")){ if ( ! (strcmp(option, "unmatch") == 0) ){
printf("%s port %d ==> %s %x port %d\n", printf("%s port %d ==> %s %x port %d\n",
val2str(filetype2, ipmi_ekanalyzer_module_type), val2str(filetype2, ipmi_ekanalyzer_module_type),
record1.ch_desc[index1].lane0port, record1.ch_desc[index1].lane0port,
@ -1529,7 +1523,7 @@ ipmi_ek_check_physical_connectivity(
} }
return_status = ERROR_STATUS; return_status = ERROR_STATUS;
} }
if (port_desc) { if (port_desc != NULL){
free(port_desc); free(port_desc);
port_desc = NULL; port_desc = NULL;
} }
@ -1609,10 +1603,10 @@ ipmi_ek_compare_link( struct ipmi_ek_multi_header * physic_record,
physic_record, file_type1, file_type2, opt ); physic_record, file_type1, file_type2, opt );
if ( result == OK_STATUS ){ if ( result == OK_STATUS ){
/*Display the result if option = match or all*/ /*Display the result if option = match or all*/
if (!strcmp(opt, "match") if ( (strcmp( opt, "match" ) == 0)
|| !strcmp(opt, "all") || (strcmp( opt, "all" ) == 0)
|| !strcmp(opt, "default")) || (strcmp( opt, "default" ) == 0)
{ ){
tboolean isOEMtype = FALSE; tboolean isOEMtype = FALSE;
printf(" Matching Result\n"); printf(" Matching Result\n");
isOEMtype = ipmi_ek_display_link_descriptor( file_type1, isOEMtype = ipmi_ek_display_link_descriptor( file_type1,
@ -1669,10 +1663,10 @@ ipmi_ek_compare_link( struct ipmi_ek_multi_header * physic_record,
record1, index_ch_desc1, record2, index_ch_desc2, record1, index_ch_desc1, record2, index_ch_desc2,
physic_record, file_type1, file_type2, opt ); physic_record, file_type1, file_type2, opt );
if ( result == OK_STATUS ){ if ( result == OK_STATUS ){
if (!strcmp( opt, "match" ) if ( (strcmp( opt, "match" ) == 0)
|| !strcmp(opt, "all") || (strcmp( opt, "all" ) == 0)
|| !strcmp(opt, "default")) || (strcmp( opt, "default" ) == 0)
{ ){
tboolean isOEMtype = FALSE; tboolean isOEMtype = FALSE;
printf(" Matching Result\n"); printf(" Matching Result\n");
isOEMtype = ipmi_ek_display_link_descriptor( file_type1, isOEMtype = ipmi_ek_display_link_descriptor( file_type1,
@ -1700,7 +1694,7 @@ ipmi_ek_compare_link( struct ipmi_ek_multi_header * physic_record,
} }
} }
if (!strcmp(opt, "unmatch") || !strcmp(opt, "all")) { if ( (strcmp(opt, "unmatch") == 0) || (strcmp(opt, "all") == 0) ){
int isOEMtype = FALSE; int isOEMtype = FALSE;
printf(" Unmatching result\n"); printf(" Unmatching result\n");
for (index1 = 0; index1 < record1.link_desc_count; index1++){ for (index1 = 0; index1 < record1.link_desc_count; index1++){
@ -1945,12 +1939,12 @@ ipmi_ek_compare_link_descriptor(
* *
* Function name: ipmi_ek_compare_asym * Function name: ipmi_ek_compare_asym
* *
* Description: This function compares 2 asymmetric match of 2 * Description: This function compares 2 asymetric match of 2
* amc link descriptors * amc link descriptors
* *
* Restriction: None * Restriction: None
* *
* Input: asym[COMPARE_CANDIDATE]: Contain 2 asymmetric match for comparison * Input: asym[COMPARE_CANDIDATE]: Contain 2 asymetric match for comparison
* *
* Output: None * Output: None
* *
@ -2061,7 +2055,7 @@ ipmi_ek_compare_number_of_enable_port(
* destination (its value = "To"). ( it is set to "" if it is not * destination (its value = "To"). ( it is set to "" if it is not
* a source nor destination * a source nor destination
* link_desc: AMC link descriptor * link_desc: AMC link descriptor
* asym: asymmetric match * asym: asymetric match
* *
* Output: None * Output: None
* *
@ -2214,7 +2208,7 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int index_oem = 0; int index_oem = 0;
amc_record->oem_guid = malloc(amc_record->guid_count * \ amc_record->oem_guid = malloc(amc_record->guid_count * \
sizeof(struct fru_picmgext_guid)); sizeof(struct fru_picmgext_guid));
if (!amc_record->oem_guid) { if (amc_record->oem_guid == NULL) {
return ERROR_STATUS; return ERROR_STATUS;
} }
for (index_oem = 0; index_oem < amc_record->guid_count; for (index_oem = 0; index_oem < amc_record->guid_count;
@ -2244,7 +2238,7 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int ch_index = 0; int ch_index = 0;
amc_record->ch_desc = malloc((amc_record->ch_count) * \ amc_record->ch_desc = malloc((amc_record->ch_count) * \
sizeof(struct fru_picmgext_amc_channel_desc_record)); sizeof(struct fru_picmgext_amc_channel_desc_record));
if (!amc_record->ch_desc) { if (amc_record->ch_desc == NULL) {
return ERROR_STATUS; return ERROR_STATUS;
} }
for (ch_index = 0; ch_index < amc_record->ch_count; for (ch_index = 0; ch_index < amc_record->ch_count;
@ -2270,7 +2264,7 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int i=0; int i=0;
amc_record->link_desc = malloc(amc_record->link_desc_count * \ amc_record->link_desc = malloc(amc_record->link_desc_count * \
sizeof(struct fru_picmgext_amc_link_desc_record)); sizeof(struct fru_picmgext_amc_link_desc_record));
if (!amc_record->link_desc) { if (amc_record->link_desc == NULL) {
return ERROR_STATUS; return ERROR_STATUS;
} }
for (i = 0; i< amc_record->link_desc_count; i++) { for (i = 0; i< amc_record->link_desc_count; i++) {
@ -2353,7 +2347,7 @@ ipmi_ek_get_resource_descriptor(int port_count, int index,
* *
* Global: None * Global: None
* *
* Return: Return OK_STATUS on success, ERROR_STATUS on error * Return: Return OK_STATUS on sucess, ERROR_STATUS on error
* *
***************************************************************************/ ***************************************************************************/
static int static int
@ -2364,7 +2358,7 @@ ipmi_ek_display_fru_header(char *filename)
int ret = 0; int ret = 0;
input_file = fopen(filename, "r"); input_file = fopen(filename, "r");
if (!input_file) { if (input_file == NULL) {
lprintf(LOG_ERR, "File '%s' not found.", filename); lprintf(LOG_ERR, "File '%s' not found.", filename);
return (ERROR_STATUS); return (ERROR_STATUS);
} }
@ -2419,7 +2413,7 @@ ipmi_ek_display_fru_header_detail(char *filename)
FILE *input_file; FILE *input_file;
size_t file_offset = 0; size_t file_offset = 0;
struct fru_header header; struct fru_header header;
time_t ts; time_t tval;
int ret = 0; int ret = 0;
unsigned char data = 0; unsigned char data = 0;
unsigned char lan_code = 0; unsigned char lan_code = 0;
@ -2427,7 +2421,7 @@ ipmi_ek_display_fru_header_detail(char *filename)
unsigned int board_length = 0; unsigned int board_length = 0;
input_file = fopen(filename, "r"); input_file = fopen(filename, "r");
if (!input_file) { if (input_file == NULL) {
lprintf(LOG_ERR, "File '%s' not found.", filename); lprintf(LOG_ERR, "File '%s' not found.", filename);
return (-1); return (-1);
} }
@ -2445,8 +2439,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 +2452,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");
@ -2583,40 +2541,33 @@ ipmi_ek_display_fru_header_detail(char *filename)
fclose(input_file); fclose(input_file);
return (-1); return (-1);
} }
tval = ((mfg_date[2] << 16) + (mfg_date[1] << 8)
ts = ipmi_fru2time_t(mfg_date); + (mfg_date[0]));
printf("Board Mfg Date: %ld, %s\n", tval = tval * 60;
(IPMI_TIME_UNSPECIFIED == ts) tval = tval + secs_from_1970_1996;
? FRU_BOARD_DATE_UNSPEC printf("Board Mfg Date: %ld, %s", tval,
: ts, asctime(localtime(&tval)));
ipmi_timestamp_numeric(ts));
board_length -= SIZE_MFG_DATE; board_length -= SIZE_MFG_DATE;
/* Board Mfg */ /* Board Mfg */
file_offset = ipmi_ek_display_board_info_area( file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Manufacture Data", &board_length); input_file, "Board Manufacture Data", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET); ret = fseek(input_file, file_offset, SEEK_SET);
/* Board Product */ /* Board Product */
file_offset = ipmi_ek_display_board_info_area( file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Product Name", &board_length); input_file, "Board Product Name", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET); ret = fseek(input_file, file_offset, SEEK_SET);
/* Board Serial */ /* Board Serial */
file_offset = ipmi_ek_display_board_info_area( file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Serial Number", &board_length); input_file, "Board Serial Number", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET); ret = fseek(input_file, file_offset, SEEK_SET);
/* Board Part */ /* Board Part */
file_offset = ipmi_ek_display_board_info_area( file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Part Number", &board_length); input_file, "Board Part Number", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET); ret = fseek(input_file, file_offset, SEEK_SET);
/* FRU file ID */ /* FRU file ID */
file_offset = ipmi_ek_display_board_info_area( file_offset = ipmi_ek_display_board_info_area(
input_file, "FRU File ID", &board_length); input_file, "FRU File ID", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET); ret = fseek(input_file, file_offset, SEEK_SET);
/* Additional Custom Mfg. */ /* Additional Custom Mfg. */
file_offset = ipmi_ek_display_board_info_area( file_offset = ipmi_ek_display_board_info_area(
input_file, "Custom", &board_length); input_file, "Custom", &board_length);
@ -2663,7 +2614,7 @@ ipmi_ek_display_chassis_info_area(FILE *input_file, long offset)
unsigned char ch_type = 0; unsigned char ch_type = 0;
unsigned int len; unsigned int len;
if (!input_file) { if (input_file == NULL) {
lprintf(LOG_ERR, "No file stream to read."); lprintf(LOG_ERR, "No file stream to read.");
return (-1); return (-1);
} }
@ -2745,18 +2696,12 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
int ret = 0; int ret = 0;
unsigned char len = 0; unsigned char len = 0;
unsigned int size_board = 0; unsigned int size_board = 0;
int custom_fields = 0; if (input_file == NULL || board_type == NULL
if (!input_file || !board_type || !board_length) { || board_length == NULL) {
return (size_t)(-1); return (size_t)(-1);
} }
file_offset = ftell(input_file); file_offset = ftell(input_file);
/*
* TODO: This whole file's code is extremely dirty and wicked.
* Must eventually switch to using ipmi_fru.c code or some
* specialized FRU library.
*/
/* Board length*/ /* Board length*/
ret = fread(&len, 1, 1, input_file); ret = fread(&len, 1, 1, input_file);
if ((ret != 1) || ferror(input_file)) { if ((ret != 1) || ferror(input_file)) {
@ -2765,22 +2710,21 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
} }
(*board_length)--; (*board_length)--;
/* Bit 5:0 of Board Mfg type represent length */ /* Bit 5:0 of Board Mfg type represent legnth */
size_board = (len & 0x3f); size_board = (len & 0x3f);
if (size_board == 0) { if (size_board == 0) {
printf("%s: None\n", board_type); printf("%s: None\n", board_type);
goto out; goto out;
} }
if (strcmp(board_type, "Custom")) { if (strncmp(board_type, "Custom", 6 ) != 0) {
unsigned char *data, *str; unsigned char *data;
unsigned int i = 0; unsigned int i = 0;
data = malloc(size_board + 1); /* Make room for type/length field */ data = malloc(size_board);
if (!data) { if (data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return (size_t)(-1); return (size_t)(-1);
} }
data[0] = len; /* Save the type/length byte in 'data' */ ret = fread(data, size_board, 1, input_file);
ret = fread(data + 1, size_board, 1, input_file);
if ((ret != 1) || ferror(input_file)) { if ((ret != 1) || ferror(input_file)) {
lprintf(LOG_ERR, "Invalid board type size!"); lprintf(LOG_ERR, "Invalid board type size!");
free(data); free(data);
@ -2789,11 +2733,17 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
} }
printf("%s type: 0x%02x\n", board_type, len); printf("%s type: 0x%02x\n", board_type, len);
printf("%s: ", board_type); printf("%s: ", board_type);
i = 0; for (i = 0; i < size_board; i++) {
str = (unsigned char *)get_fru_area_str(data, &i); if ((len & TYPE_CODE) == TYPE_CODE) {
printf("%s\n", str); printf("%c", data[i]);
free(str); } else {
str = NULL; /* other than language code (binary, BCD,
* ASCII 6 bit...) is not supported
*/
printf("%02x", data[i]);
}
}
printf("\n");
free(data); free(data);
data = NULL; data = NULL;
(*board_length) -= size_board; (*board_length) -= size_board;
@ -2806,12 +2756,7 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
/* take the rest of data in the area minus 1 byte of /* take the rest of data in the area minus 1 byte of
* checksum * checksum
*/ */
if (custom_fields) { printf("Additional Custom Mfg. length: 0x%02x\n", len);
printf("End of Custom Mfg. fields (0x%02x)\n", len);
} else {
printf("No Additional Custom Mfg. fields (0x%02x)\n", len);
}
padding = (*board_length) - 1; padding = (*board_length) - 1;
if ((padding > 0) && (!feof(input_file))) { if ((padding > 0) && (!feof(input_file))) {
printf("Unused space: %d (bytes)\n", padding); printf("Unused space: %d (bytes)\n", padding);
@ -2825,47 +2770,36 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
printf("Checksum: 0x%02x\n", checksum); printf("Checksum: 0x%02x\n", checksum);
goto out; goto out;
} }
custom_fields++;
printf("Additional Custom Mfg. length: 0x%02x\n", len); printf("Additional Custom Mfg. length: 0x%02x\n", len);
if ((size_board > 0) && (size_board < (*board_length))) { if ((size_board > 0) && (size_board < (*board_length))) {
unsigned char *additional_data, *str; unsigned char * additional_data = NULL;
unsigned int i = 0; unsigned int i = 0;
additional_data = malloc(size_board + 1); /* Make room for type/length field */ additional_data = malloc(size_board);
if (!additional_data) { if (additional_data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return (size_t)(-1); return (size_t)(-1);
} }
additional_data[0] = len; ret = fread(additional_data, size_board, 1, input_file);
ret = fread(additional_data + 1, size_board, 1, input_file);
if ((ret != 1) || ferror(input_file)) { if ((ret != 1) || ferror(input_file)) {
lprintf(LOG_ERR, "Invalid Additional Data!"); lprintf(LOG_ERR, "Invalid Additional Data!");
if (additional_data) { if (additional_data != NULL) {
free(additional_data); free(additional_data);
additional_data = NULL; additional_data = NULL;
} }
goto out; goto out;
} }
printf("Additional Custom Mfg. Data: "); printf("Additional Custom Mfg. Data: %02x",
i = 0; additional_data[0]);
str = (unsigned char *)get_fru_area_str(additional_data, &i); for (i = 1; i < size_board; i++) {
printf("%s\n", str); printf("-%02x", additional_data[i]);
free(str); }
str = NULL; printf("\n");
free(additional_data); free(additional_data);
additional_data = NULL; additional_data = NULL;
(*board_length) -= size_board; (*board_length) -= size_board;
ret = fread(&len, 1, 1, input_file);
if ((ret != 1) || ferror(input_file)) {
lprintf(LOG_ERR, "Invalid Length!");
goto out;
}
(*board_length)--;
size_board = (len & 0x3f);
} }
else { else {
printf("ERROR: File has insufficient data (%d bytes) for the " printf("No Additional Custom Mfg. %d\n", *board_length);
"Additional Custom Mfg. field\n", *board_length);
goto out; goto out;
} }
} }
@ -2904,7 +2838,7 @@ ipmi_ek_display_product_info_area(FILE *input_file, long offset)
unsigned char data = 0; unsigned char data = 0;
unsigned int len = 0; unsigned int len = 0;
if (!input_file) { if (input_file == NULL) {
lprintf(LOG_ERR, "No file stream to read."); lprintf(LOG_ERR, "No file stream to read.");
return (-1); return (-1);
} }
@ -2990,6 +2924,7 @@ ipmi_ek_display_product_info_area(FILE *input_file, long offset)
* *
* Input: record: a pointer to current record * Input: record: a pointer to current record
* list_head: a pointer to header of the list * list_head: a pointer to header of the list
* list_last: a pointer to tale of the list
* *
* Output: None * Output: None
* *
@ -3000,16 +2935,17 @@ ipmi_ek_display_product_info_area(FILE *input_file, long offset)
***************************************************************************/ ***************************************************************************/
static void static void
ipmi_ek_display_record(struct ipmi_ek_multi_header *record, ipmi_ek_display_record(struct ipmi_ek_multi_header *record,
struct ipmi_ek_multi_header *list_head) struct ipmi_ek_multi_header *list_head,
struct ipmi_ek_multi_header *list_last)
{ {
if (!list_head) { if (list_head == NULL) {
printf("***empty list***\n"); printf("***empty list***\n");
return; return;
} }
printf("%s\n", EQUAL_LINE_LIMITER); printf("%s\n", EQUAL_LINE_LIMITER);
printf("FRU Multi Info area\n"); printf("FRU Multi Info area\n");
printf("%s\n", EQUAL_LINE_LIMITER); printf("%s\n", EQUAL_LINE_LIMITER);
for (record = list_head; record; record = record->next) { for (record = list_head; record != NULL; record = record->next) {
printf("Record Type ID: 0x%02x\n", record->header.type); printf("Record Type ID: 0x%02x\n", record->header.type);
printf("Record Format version: 0x%02x\n", printf("Record Format version: 0x%02x\n",
record->header.format); record->header.format);
@ -3462,7 +3398,7 @@ ipmi_ek_display_board_p2p_record(struct ipmi_ek_multi_header *record)
printf("ShMC Cross-connect (two-pair)\n"); printf("ShMC Cross-connect (two-pair)\n");
break; break;
default: default:
printf("Unknown\n"); printf("Unknwon\n");
break; break;
} }
} else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET) { } else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET) {
@ -3477,17 +3413,17 @@ ipmi_ek_display_board_p2p_record(struct ipmi_ek_multi_header *record)
printf("FC-PI\n"); printf("FC-PI\n");
break; break;
default: default:
printf("Unknown\n"); printf("Unknwon\n");
break; break;
} }
} else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND) { } else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND) {
printf("Unknown\n"); printf("Unknwon\n");
} else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR) { } else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR) {
printf("Unknown\n"); printf("Unknwon\n");
} else if (d->type == FRU_PICMGEXT_LINK_TYPE_PCIE) { } else if (d->type == FRU_PICMGEXT_LINK_TYPE_PCIE) {
printf("Unknown\n"); printf("Unknwon\n");
} else { } else {
printf("Unknown\n"); printf("Unknwon\n");
} }
printf("\tLink Type:\t\t0x%02x - ", d->type); printf("\tLink Type:\t\t0x%02x - ", d->type);
if (d->type == 0 || d->type == 0xff) { if (d->type == 0 || d->type == 0xff) {
@ -4071,7 +4007,7 @@ ipmi_ek_display_clock_config_record(struct ipmi_ek_multi_header *record)
* *
* Restriction: None * Restriction: None
* *
* Input/Output: filename1: name of the file that contain FRU binary data * Input/Ouput: filename1: name of the file that contain FRU binary data
* record: a pointer to current record * record: a pointer to current record
* list_head: a pointer to header of the list * list_head: a pointer to header of the list
* list_last: a pointer to tale of the list * list_last: a pointer to tale of the list
@ -4095,7 +4031,7 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
int ret = 0; int ret = 0;
input_file = fopen(filename, "r"); input_file = fopen(filename, "r");
if (!input_file) { if (input_file == NULL) {
lprintf(LOG_ERR, "File: '%s' is not found", filename); lprintf(LOG_ERR, "File: '%s' is not found", filename);
return ERROR_STATUS; return ERROR_STATUS;
} }
@ -4122,7 +4058,7 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
fseek(input_file, multi_offset, SEEK_SET); fseek(input_file, multi_offset, SEEK_SET);
while (!feof(input_file)) { while (!feof(input_file)) {
*list_record = malloc(sizeof(struct ipmi_ek_multi_header)); *list_record = malloc(sizeof(struct ipmi_ek_multi_header));
if (!(*list_record)) { if (*list_record == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return ERROR_STATUS; return ERROR_STATUS;
} }
@ -4140,7 +4076,7 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
continue; continue;
} }
(*list_record)->data = malloc((*list_record)->header.len); (*list_record)->data = malloc((*list_record)->header.len);
if (!(*list_record)->data) { if ((*list_record)->data == NULL) {
lprintf(LOG_ERR, "Failed to allocation memory size %d\n", lprintf(LOG_ERR, "Failed to allocation memory size %d\n",
(*list_record)->header.len); (*list_record)->header.len);
record_count++; record_count++;
@ -4185,7 +4121,7 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
* *
* Function name: ipmi_ek_add_record2list * Function name: ipmi_ek_add_record2list
* *
* Description: this function adds a single FRU multi record to a linked list of * Description: this function adds a sigle FRU multi record to a linked list of
* FRU multi record. * FRU multi record.
* *
* Restriction: None * Restriction: None
@ -4204,18 +4140,18 @@ ipmi_ek_add_record2list(struct ipmi_ek_multi_header **record,
struct ipmi_ek_multi_header **list_head, struct ipmi_ek_multi_header **list_head,
struct ipmi_ek_multi_header **list_last) struct ipmi_ek_multi_header **list_last)
{ {
if (*list_head) { if (*list_head == NULL) {
(*list_last)->next = *record;
(*record)->prev = *list_last;
if (verbose > 2) {
printf("Add 1 record to list\n");
}
} else {
*list_head = *record; *list_head = *record;
(*record)->prev = NULL; (*record)->prev = NULL;
if (verbose > 2) { if (verbose > 2) {
printf("Adding first record to list\n"); printf("Adding first record to list\n");
} }
} else {
(*list_last)->next = *record;
(*record)->prev = *list_last;
if (verbose > 2) {
printf("Add 1 record to list\n");
}
} }
*list_last = *record; *list_last = *record;
(*record)->next = NULL; (*record)->next = NULL;
@ -4225,7 +4161,7 @@ ipmi_ek_add_record2list(struct ipmi_ek_multi_header **record,
* *
* Function name: ipmi_ek_remove_record_from_list * Function name: ipmi_ek_remove_record_from_list
* *
* Description: this function removes a single FRU multi record from a linked * Description: this function removes a sigle FRU multi record from a linked
* list of FRU multi record. * list of FRU multi record.
* *
* Restriction: None * Restriction: None
@ -4244,12 +4180,12 @@ ipmi_ek_remove_record_from_list(struct ipmi_ek_multi_header *record,
struct ipmi_ek_multi_header **list_head, struct ipmi_ek_multi_header **list_head,
struct ipmi_ek_multi_header **list_last) struct ipmi_ek_multi_header **list_last)
{ {
if (!record->prev) { if (record->prev == NULL) {
*list_head = record->next; *list_head = record->next;
} else { } else {
record->prev->next = record->next; record->prev->next = record->next;
} }
if (!record->next) { if (record->next == NULL) {
(*list_last) = record->prev; (*list_last) = record->prev;
} else { } else {
record->next->prev = record->prev; record->next->prev = record->prev;

View File

@ -29,6 +29,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.
*/ */
#define _BSD_SOURCE
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -52,14 +53,6 @@
#include <ipmitool/ipmi_event.h> #include <ipmitool/ipmi_event.h>
#include <ipmitool/ipmi_sdr.h> #include <ipmitool/ipmi_sdr.h>
static
inline
bool
is_system(const struct channel_info_t *chinfo)
{
return (IPMI_CHANNEL_MEDIUM_SYSTEM == chinfo->medium
|| CH_SYSTEM == chinfo->channel);
}
static void static void
ipmi_event_msg_print(struct ipmi_intf * intf, struct platform_event_msg * pmsg) ipmi_event_msg_print(struct ipmi_intf * intf, struct platform_event_msg * pmsg)
@ -69,8 +62,7 @@ ipmi_event_msg_print(struct ipmi_intf * intf, struct platform_event_msg * pmsg)
memset(&sel_event, 0, sizeof(struct sel_event_record)); memset(&sel_event, 0, sizeof(struct sel_event_record));
sel_event.record_id = 0; sel_event.record_id = 0;
htoipmi16(EVENT_GENERATOR(SMS, 0), sel_event.sel_type.standard_type.gen_id = 2;
(void *)&sel_event.sel_type.standard_type.gen_id);
sel_event.sel_type.standard_type.evm_rev = pmsg->evm_rev; sel_event.sel_type.standard_type.evm_rev = pmsg->evm_rev;
sel_event.sel_type.standard_type.sensor_type = pmsg->sensor_type; sel_event.sel_type.standard_type.sensor_type = pmsg->sensor_type;
@ -92,42 +84,36 @@ ipmi_send_platform_event(struct ipmi_intf * intf, struct platform_event_msg * em
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
uint8_t rqdata[PLATFORM_EVENT_DATA_LEN_MAX]; uint8_t rqdata[8];
uint8_t *rqdata_start = rqdata; uint8_t chmed;
struct channel_info_t chinfo;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
memset(rqdata, 0, sizeof(rqdata)); memset(rqdata, 0, 8);
req.msg.netfn = IPMI_NETFN_SE; req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_PLATFORM_EVENT; req.msg.cmd = 0x02;
req.msg.data = rqdata; req.msg.data = rqdata;
req.msg.data_len = PLATFORM_EVENT_DATA_LEN_NON_SI;
ipmi_current_channel_info(intf, &chinfo); chmed = ipmi_current_channel_medium(intf);
if (chinfo.channel == CH_UNKNOWN) { if (chmed == IPMI_CHANNEL_MEDIUM_SYSTEM) {
lprintf(LOG_ERR, "Failed to send the platform event " /* system interface, need extra generator ID */
"via an unknown channel"); req.msg.data_len = 8;
return -3; rqdata[0] = 0x41; // As per Fig. 29-2 and Table 5-4
memcpy(rqdata+1, emsg, sizeof(struct platform_event_msg));
} }
else {
if (is_system(&chinfo)) { req.msg.data_len = 7;
/* system interface, need extra generator ID, see Fig. 29-2 */ memcpy(rqdata, emsg, sizeof(struct platform_event_msg));
req.msg.data_len = PLATFORM_EVENT_DATA_LEN_SI;
rqdata[0] = EVENT_GENERATOR(SMS, 0);
rqdata_start++;
} }
memcpy(rqdata_start, emsg, sizeof(struct platform_event_msg));
ipmi_event_msg_print(intf, emsg); ipmi_event_msg_print(intf, emsg);
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Platform Event Message command failed"); lprintf(LOG_ERR, "Platform Event Message command failed");
return -1; return -1;
} }
else if (rsp->ccode) { else if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Platform Event Message command failed: %s", lprintf(LOG_ERR, "Platform Event Message command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -225,14 +211,14 @@ ipmi_event_find_offset(struct ipmi_intf *intf, uint8_t sensor_type, uint8_t even
{ {
const struct ipmi_event_sensor_types *evt; const struct ipmi_event_sensor_types *evt;
if (!desc || sensor_type == 0 || event_type == 0) { if (desc == NULL || sensor_type == 0 || event_type == 0) {
return 0x00; return 0x00;
} }
for (evt = ipmi_get_first_event_sensor_type(intf, sensor_type, event_type); for (evt = ipmi_get_first_event_sensor_type(intf, sensor_type, event_type);
evt; evt = ipmi_get_next_event_sensor_type(evt)) { evt != NULL; evt = ipmi_get_next_event_sensor_type(evt)) {
if (evt->desc && if (evt->desc != NULL &&
strcasecmp(desc, evt->desc) == 0) { strncasecmp(desc, evt->desc, __maxlen(desc, evt->desc)) == 0) {
return evt->offset; return evt->offset;
} }
} }
@ -260,7 +246,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
int off; int off;
uint8_t target, lun, channel; uint8_t target, lun, channel;
if (!id) { if (id == NULL) {
lprintf(LOG_ERR, "No sensor ID supplied"); lprintf(LOG_ERR, "No sensor ID supplied");
return -1; return -1;
} }
@ -268,11 +254,11 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
memset(&emsg, 0, sizeof(struct platform_event_msg)); memset(&emsg, 0, sizeof(struct platform_event_msg));
emsg.evm_rev = 0x04; emsg.evm_rev = 0x04;
if (!evdir) if (evdir == NULL)
emsg.event_dir = EVENT_DIR_ASSERT; emsg.event_dir = EVENT_DIR_ASSERT;
else if (!strcmp(evdir, "assert")) else if (strncasecmp(evdir, "assert", 6) == 0)
emsg.event_dir = EVENT_DIR_ASSERT; emsg.event_dir = EVENT_DIR_ASSERT;
else if (!strcmp(evdir, "deassert")) else if (strncasecmp(evdir, "deassert", 8) == 0)
emsg.event_dir = EVENT_DIR_DEASSERT; emsg.event_dir = EVENT_DIR_DEASSERT;
else { else {
lprintf(LOG_ERR, "Invalid event direction %s. Must be 'assert' or 'deassert'", evdir); lprintf(LOG_ERR, "Invalid event direction %s. Must be 'assert' or 'deassert'", evdir);
@ -281,7 +267,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
printf("Finding sensor %s... ", id); printf("Finding sensor %s... ", id);
sdr = ipmi_sdr_find_sdr_byid(intf, id); sdr = ipmi_sdr_find_sdr_byid(intf, id);
if (!sdr) { if (sdr == NULL) {
printf("not found!\n"); printf("not found!\n");
return -1; return -1;
} }
@ -318,7 +304,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
int hilo = 0; int hilo = 0;
off = 1; off = 1;
if (!state || !strcmp(state, "list")) { if (state == NULL || strncasecmp(state, "list", 4) == 0) {
printf("Sensor States:\n"); printf("Sensor States:\n");
printf(" lnr : Lower Non-Recoverable \n"); printf(" lnr : Lower Non-Recoverable \n");
printf(" lcr : Lower Critical\n"); printf(" lcr : Lower Critical\n");
@ -329,12 +315,12 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
return -1; return -1;
} }
if (0 != strcmp(state, "lnr") && if (0 != strncasecmp(state, "lnr", 3) &&
0 != strcmp(state, "lcr") && 0 != strncasecmp(state, "lcr", 3) &&
0 != strcmp(state, "lnc") && 0 != strncasecmp(state, "lnc", 3) &&
0 != strcmp(state, "unc") && 0 != strncasecmp(state, "unc", 3) &&
0 != strcmp(state, "ucr") && 0 != strncasecmp(state, "ucr", 3) &&
0 != strcmp(state, "unr")) 0 != strncasecmp(state, "unr", 3))
{ {
lprintf(LOG_ERR, "Invalid threshold identifier %s", state); lprintf(LOG_ERR, "Invalid threshold identifier %s", state);
return -1; return -1;
@ -363,11 +349,11 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
rsp = ipmi_sdr_get_sensor_thresholds(intf, emsg.sensor_num, rsp = ipmi_sdr_get_sensor_thresholds(intf, emsg.sensor_num,
target, lun, channel); target, lun, channel);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Command Get Sensor Thresholds failed: invalid response."); "Command Get Sensor Thresholds failed: invalid response.");
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
lprintf(LOG_ERR, "Command Get Sensor Thresholds failed: %s", lprintf(LOG_ERR, "Command Get Sensor Thresholds failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return (-1); return (-1);
@ -378,7 +364,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
rsp = ipmi_sdr_get_sensor_hysteresis(intf, emsg.sensor_num, rsp = ipmi_sdr_get_sensor_hysteresis(intf, emsg.sensor_num,
target, lun, channel); target, lun, channel);
if (rsp && !rsp->ccode) if (rsp != NULL && rsp->ccode == 0)
off = dir ? rsp->data[0] : rsp->data[1]; off = dir ? rsp->data[0] : rsp->data[1];
if (off <= 0) if (off <= 0)
off = 1; off = 1;
@ -415,7 +401,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
/* /*
* print list of available states for this sensor * print list of available states for this sensor
*/ */
if (!state || strcasecmp(state, "list") == 0) { if (state == NULL || strncasecmp(state, "list", 4) == 0) {
print_sensor_states(intf, emsg.sensor_type, emsg.event_type); print_sensor_states(intf, emsg.sensor_type, emsg.event_type);
printf("Sensor State Shortcuts:\n"); printf("Sensor State Shortcuts:\n");
for (x = 0; x < sizeof(digi_on)/sizeof(*digi_on); x++) { for (x = 0; x < sizeof(digi_on)/sizeof(*digi_on); x++) {
@ -426,12 +412,12 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
off = 0; off = 0;
for (x = 0; x < sizeof(digi_on)/sizeof(*digi_on); x++) { for (x = 0; x < sizeof(digi_on)/sizeof(*digi_on); x++) {
if (strcasecmp(state, digi_on[x]) == 0) { if (strncasecmp(state, digi_on[x], strlen(digi_on[x])) == 0) {
emsg.event_data[0] = 1; emsg.event_data[0] = 1;
off = 1; off = 1;
break; break;
} }
else if (strcasecmp(state, digi_off[x]) == 0) { else if (strncasecmp(state, digi_off[x], strlen(digi_off[x])) == 0) {
emsg.event_data[0] = 0; emsg.event_data[0] = 0;
off = 1; off = 1;
break; break;
@ -455,7 +441,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
/* /*
* print list of available states for this sensor * print list of available states for this sensor
*/ */
if (!state || strcasecmp(state, "list") == 0) { if (state == NULL || strncasecmp(state, "list", 4) == 0) {
print_sensor_states(intf, emsg.sensor_type, emsg.event_type); print_sensor_states(intf, emsg.sensor_type, emsg.event_type);
return 0; return 0;
} }
@ -475,7 +461,7 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
/* /*
* print list of available states for this sensor * print list of available states for this sensor
*/ */
if (!state || strcasecmp(state, "list") == 0) { if (state == NULL || strncasecmp(state, "list", 4) == 0) {
print_sensor_states(intf, emsg.sensor_type, emsg.event_type); print_sensor_states(intf, emsg.sensor_type, emsg.event_type);
return 0; return 0;
} }
@ -499,30 +485,43 @@ static int
ipmi_event_fromfile(struct ipmi_intf * intf, char * file) ipmi_event_fromfile(struct ipmi_intf * intf, char * file)
{ {
FILE * fp; FILE * fp;
/* For ease of filling in from file data */ struct ipmi_rs * rsp;
union { struct ipmi_rq req;
struct platform_event_msg emsg; struct sel_event_record sel_event;
uint8_t bytes[sizeof(struct platform_event_msg)]; uint8_t rqdata[8];
} __attribute__ ((packed)) rqdata;
char buf[1024]; char buf[1024];
char * ptr, * tok; char * ptr, * tok;
int i, j;
uint8_t chmed;
int rc = 0; int rc = 0;
if (!file) if (file == NULL)
return -1; return -1;
memset(rqdata, 0, 8);
/* setup Platform Event Message command */
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = 0x02;
req.msg.data = rqdata;
req.msg.data_len = 7;
chmed = ipmi_current_channel_medium(intf);
if (chmed == IPMI_CHANNEL_MEDIUM_SYSTEM) {
/* system interface, need extra generator ID */
rqdata[0] = 0x41; // As per Fig. 29-2 and Table 5-4
req.msg.data_len = 8;
}
fp = ipmi_open_file_read(file); fp = ipmi_open_file_read(file);
if (!fp) if (fp == NULL)
return -1; return -1;
while (feof(fp) == 0) { while (feof(fp) == 0) {
size_t count = 0; if (fgets(buf, 1024, fp) == NULL)
if (!fgets(buf, 1024, fp))
continue; continue;
/* Each line is a new event */
memset(&rqdata, 0, sizeof(rqdata));
/* clip off optional comment tail indicated by # */ /* clip off optional comment tail indicated by # */
ptr = strchr(buf, '#'); ptr = strchr(buf, '#');
if (ptr) if (ptr)
@ -542,28 +541,49 @@ ipmi_event_fromfile(struct ipmi_intf * intf, char * file)
/* parse the event, 7 bytes with optional comment */ /* parse the event, 7 bytes with optional comment */
/* 0x00 0x00 0x00 0x00 0x00 0x00 0x00 # event */ /* 0x00 0x00 0x00 0x00 0x00 0x00 0x00 # event */
i = 0;
tok = strtok(ptr, " "); tok = strtok(ptr, " ");
while (tok) { while (tok) {
if (count == sizeof(struct platform_event_msg)) if (i == 7)
break; break;
if (0 > str2uchar(tok, &rqdata.bytes[count])) { j = i++;
lprintf(LOG_ERR, "Invalid token in file: [%s]", tok); if (chmed == IPMI_CHANNEL_MEDIUM_SYSTEM)
rc = -1; j++;
break; rqdata[j] = (uint8_t)strtol(tok, NULL, 0);
}
tok = strtok(NULL, " "); tok = strtok(NULL, " ");
++count;
} }
if (count < sizeof(struct platform_event_msg)) { if (i < 7) {
lprintf(LOG_ERR, "Invalid Event: %s", lprintf(LOG_ERR, "Invalid Event: %s",
buf2str(rqdata.bytes, sizeof(rqdata.bytes))); buf2str(rqdata, sizeof(rqdata)));
continue; continue;
} }
/* Now actually send it, failures will be logged by the sender */ memset(&sel_event, 0, sizeof(struct sel_event_record));
rc = ipmi_send_platform_event(intf, &rqdata.emsg); sel_event.record_id = 0;
if (IPMI_CC_OK != rc) sel_event.sel_type.standard_type.gen_id = 2;
break;
j = (chmed == IPMI_CHANNEL_MEDIUM_SYSTEM) ? 1 : 0;
sel_event.sel_type.standard_type.evm_rev = rqdata[j++];
sel_event.sel_type.standard_type.sensor_type = rqdata[j++];
sel_event.sel_type.standard_type.sensor_num = rqdata[j++];
sel_event.sel_type.standard_type.event_type = rqdata[j] & 0x7f;
sel_event.sel_type.standard_type.event_dir = (rqdata[j++] & 0x80) >> 7;
sel_event.sel_type.standard_type.event_data[0] = rqdata[j++];
sel_event.sel_type.standard_type.event_data[1] = rqdata[j++];
sel_event.sel_type.standard_type.event_data[2] = rqdata[j++];
ipmi_sel_print_std_entry(intf, &sel_event);
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Platform Event Message command failed");
rc = -1;
}
else if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Platform Event Message command failed: %s",
val2str(rsp->ccode, completion_code_vals));
rc = -1;
}
} }
fclose(fp); fclose(fp);
@ -596,11 +616,11 @@ ipmi_event_main(struct ipmi_intf * intf, int argc, char ** argv)
{ {
int rc = 0; int rc = 0;
if (argc == 0 || !strcmp(argv[0], "help")) { if (argc == 0 || strncmp(argv[0], "help", 4) == 0) {
ipmi_event_usage(); ipmi_event_usage();
return 0; return 0;
} }
if (!strcmp(argv[0], "file")) { if (strncmp(argv[0], "file", 4) == 0) {
if (argc < 2) { if (argc < 2) {
ipmi_event_usage(); ipmi_event_usage();
return 0; return 0;

View File

@ -128,7 +128,7 @@ ipmi_firewall_parse_args(int argc, char ** argv, struct ipmi_function_params * p
return -1; return -1;
} }
for (i=0; i<argc; i++) { for (i=0; i<argc; i++) {
if (!strcmp(argv[i], "channel") && (++i < argc)) { if (strncmp(argv[i], "channel", 7) == 0 && (++i < argc)) {
uint8_t channel_tmp = 0; uint8_t channel_tmp = 0;
if (is_ipmi_channel_num(argv[i], &channel_tmp) != 0) { if (is_ipmi_channel_num(argv[i], &channel_tmp) != 0) {
conv_err = 1; conv_err = 1;
@ -137,31 +137,31 @@ ipmi_firewall_parse_args(int argc, char ** argv, struct ipmi_function_params * p
p->channel = channel_tmp; p->channel = channel_tmp;
} }
} }
else if (!strcmp(argv[i], "lun") && (++i < argc)) { else if (strncmp(argv[i], "lun", 3) == 0 && (++i < argc)) {
if (str2int(argv[i], &(p->lun)) != 0) { if (str2int(argv[i], &(p->lun)) != 0) {
lprintf(LOG_ERR, "Given lun '%s' is invalid.", argv[i]); lprintf(LOG_ERR, "Given lun '%s' is invalid.", argv[i]);
conv_err = 1; conv_err = 1;
break; break;
} }
} }
else if (!strcmp(argv[i], "force")) { else if (strncmp(argv[i], "force", 5) == 0) {
p->force = 1; p->force = 1;
} }
else if (!strcmp(argv[i], "netfn") && (++i < argc)) { else if (strncmp(argv[i], "netfn", 5) == 0 && (++i < argc)) {
if (str2int(argv[i], &(p->netfn)) != 0) { if (str2int(argv[i], &(p->netfn)) != 0) {
lprintf(LOG_ERR, "Given netfn '%s' is invalid.", argv[i]); lprintf(LOG_ERR, "Given netfn '%s' is invalid.", argv[i]);
conv_err = 1; conv_err = 1;
break; break;
} }
} }
else if (!strcmp(argv[i], "command") && (++i < argc)) { else if (strncmp(argv[i], "command", 7) == 0 && (++i < argc)) {
if (str2int(argv[i], &(p->command)) != 0) { if (str2int(argv[i], &(p->command)) != 0) {
lprintf(LOG_ERR, "Given command '%s' is invalid.", argv[i]); lprintf(LOG_ERR, "Given command '%s' is invalid.", argv[i]);
conv_err = 1; conv_err = 1;
break; break;
} }
} }
else if (!strcmp(argv[i], "subfn") && (++i < argc)) { else if (strncmp(argv[i], "subfn", 5) == 0 && (++i < argc)) {
if (str2int(argv[i], &(p->subfn)) != 0) { if (str2int(argv[i], &(p->subfn)) != 0) {
lprintf(LOG_ERR, "Given subfn '%s' is invalid.", argv[i]); lprintf(LOG_ERR, "Given subfn '%s' is invalid.", argv[i]);
conv_err = 1; conv_err = 1;
@ -235,11 +235,11 @@ _get_netfn_support(struct ipmi_intf * intf, int channel, unsigned char * lun, un
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get NetFn Support command failed"); lprintf(LOG_ERR, "Get NetFn Support command failed");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get NetFn Support command failed: %s", lprintf(LOG_ERR, "Get NetFn Support command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -289,11 +289,11 @@ _get_command_support(struct ipmi_intf * intf,
req.msg.data_len = 3; req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=0) command failed: %s", lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=0) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -316,11 +316,11 @@ _get_command_support(struct ipmi_intf * intf,
req.msg.data_len = 3; req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=1) command failed: %s", lprintf(LOG_ERR, "Get Command Support (LUN=%d, NetFn=%d, op=1) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -368,11 +368,11 @@ _get_command_configurable(struct ipmi_intf * intf,
req.msg.data_len = 3; req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=0) command failed: %s", lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=0) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -395,11 +395,11 @@ _get_command_configurable(struct ipmi_intf * intf,
req.msg.data_len = 3; req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=1) command failed: %s", lprintf(LOG_ERR, "Get Configurable Command (LUN=%d, NetFn=%d, op=1) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -447,11 +447,11 @@ _get_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 3; req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=0) command failed: %s", lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=0) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -474,11 +474,11 @@ _get_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 3; req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=1) command failed: %s", lprintf(LOG_ERR, "Get Command Enables (LUN=%d, NetFn=%d, op=1) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -558,11 +558,11 @@ _set_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 19; req.msg.data_len = 19;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=0) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=0) command failed: %s", lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=0) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -579,11 +579,11 @@ _set_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 19; req.msg.data_len = 19;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn); lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=1) command failed", p->lun, p->netfn);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=1) command failed: %s", lprintf(LOG_ERR, "Set Command Enables (LUN=%d, NetFn=%d, op=1) command failed: %s",
p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -625,11 +625,11 @@ _get_subfn_support(struct ipmi_intf * intf,
req.msg.data_len = 4; req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Command Sub-function Support (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command); lprintf(LOG_ERR, "Get Command Sub-function Support (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Command Sub-function Support (LUN=%d, NetFn=%d, command=%d) command failed: %s", lprintf(LOG_ERR, "Get Command Sub-function Support (LUN=%d, NetFn=%d, command=%d) command failed: %s",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -672,11 +672,11 @@ _get_subfn_configurable(struct ipmi_intf * intf,
req.msg.data_len = 4; req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Configurable Command Sub-function (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command); lprintf(LOG_ERR, "Get Configurable Command Sub-function (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Configurable Command Sub-function (LUN=%d, NetFn=%d, command=%d) command failed: %s", lprintf(LOG_ERR, "Get Configurable Command Sub-function (LUN=%d, NetFn=%d, command=%d) command failed: %s",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -719,11 +719,11 @@ _get_subfn_enables(struct ipmi_intf * intf,
req.msg.data_len = 4; req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command); lprintf(LOG_ERR, "Get Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed: %s", lprintf(LOG_ERR, "Get Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed: %s",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -787,11 +787,11 @@ _set_subfn_enables(struct ipmi_intf * intf,
req.msg.data_len = 8; req.msg.data_len = 8;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Set Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command); lprintf(LOG_ERR, "Set Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed", p->lun, p->netfn, p->command);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed: %s", lprintf(LOG_ERR, "Set Command Sub-function Enables (LUN=%d, NetFn=%d, command=%d) command failed: %s",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals)); p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -888,7 +888,7 @@ static int _gather_info(struct ipmi_intf * intf, struct ipmi_function_params * p
/* ipmi_firewall_info - print out info for firewall functions /* ipmi_firewall_info - print out info for firewall functions
* *
* @intf: ipmi interface * @intf: ipmi inteface
* @argc: argument count * @argc: argument count
* @argv: argument list * @argv: argument list
* *
@ -903,7 +903,7 @@ ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
struct bmc_fn_support * bmc_fn_support; struct bmc_fn_support * bmc_fn_support;
unsigned int l, n, c; unsigned int l, n, c;
if ((argc > 0 && !strcmp(argv[0], "help")) || ipmi_firewall_parse_args(argc, argv, &p) < 0) if ((argc > 0 && strncmp(argv[0], "help", 4) == 0) || ipmi_firewall_parse_args(argc, argv, &p) < 0)
{ {
printf_firewall_info_usage(); printf_firewall_info_usage();
return 0; return 0;
@ -1001,7 +1001,7 @@ ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
/* ipmi_firewall_enable_disable - enable/disable BMC functions /* ipmi_firewall_enable_disable - enable/disable BMC functions
* *
* @intf: ipmi interface * @intf: ipmi inteface
* @enable: whether to enable or disable * @enable: whether to enable or disable
* @argc: argument count * @argc: argument count
* @argv: argument list * @argv: argument list
@ -1018,7 +1018,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
unsigned int l, n, c; unsigned int l, n, c;
unsigned char enables[MAX_COMMAND_BYTES]; unsigned char enables[MAX_COMMAND_BYTES];
if (argc < 1 || !strcmp(argv[0], "help")) { if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
char * s1 = enable?"en":"dis"; char * s1 = enable?"en":"dis";
char * s2 = enable?"":" [force]"; char * s2 = enable?"":" [force]";
printf("%sable [channel H] lun L netfn N%s\n", s1, s2); printf("%sable [channel H] lun L netfn N%s\n", s1, s2);
@ -1055,7 +1055,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
c = p.command; c = p.command;
if (p.subfn >= 0) { if (p.subfn >= 0) {
// firewall (en|dis)able [channel c] lun l netfn n command m subfn s // firewall (en|dis)able [channel c] lun l netfn n command m subfn s
// (en|dis)able this sub-function for this command on this lun/netfn pair // (en|dis)able this sub-function for this commnad on this lun/netfn pair
memcpy(enables, memcpy(enables,
bmc_fn_support->lun[l].netfn[n].command[c].subfn_enable, bmc_fn_support->lun[l].netfn[n].command[c].subfn_enable,
MAX_SUBFN_BYTES); MAX_SUBFN_BYTES);
@ -1065,7 +1065,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
} else if (p.command >= 0) { } else if (p.command >= 0) {
// firewall (en|dis)able [channel c] lun l netfn n command m // firewall (en|dis)able [channel c] lun l netfn n command m
// (en|dis)able all subfn and command for this command on this lun/netfn pair // (en|dis)able all subfn and command for this commnad on this lun/netfn pair
memset(enables, enable?0xff:0, MAX_SUBFN_BYTES); memset(enables, enable?0xff:0, MAX_SUBFN_BYTES);
ret = _set_subfn_enables(intf, &p, ret = _set_subfn_enables(intf, &p,
&bmc_fn_support->lun[l].netfn[n].command[c], enables); &bmc_fn_support->lun[l].netfn[n].command[c], enables);
@ -1076,14 +1076,14 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
&bmc_fn_support->lun[l].netfn[n], enables, p.force); &bmc_fn_support->lun[l].netfn[n], enables, p.force);
} else if (p.netfn >= 0) { } else if (p.netfn >= 0) {
// firewall (en|dis)able [channel c] lun l netfn n // firewall (en|dis)able [channel c] lun l netfn n
// (en|dis)able all command on this lun/netfn pair // (en|dis)able all commnads on this lun/netfn pair
memset(enables, enable?0xff:0, sizeof(enables)); memset(enables, enable?0xff:0, sizeof(enables));
ret = _set_command_enables(intf, &p, ret = _set_command_enables(intf, &p,
&bmc_fn_support->lun[l].netfn[n], enables, p.force); &bmc_fn_support->lun[l].netfn[n], enables, p.force);
/* /*
} else if (p.lun >= 0) { } else if (p.lun >= 0) {
// firewall (en|dis)able [channel c] lun l // firewall (en|dis)able [channel c] lun l
// (en|dis)able all command on all netfn pairs for this lun // (en|dis)able all commnads on all netfn pairs for this lun
*/ */
} }
free(bmc_fn_support); free(bmc_fn_support);
@ -1093,7 +1093,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
/* ipmi_firewall_reset - reset firmware firewall to enable everything /* ipmi_firewall_reset - reset firmware firewall to enable everything
* *
* @intf: ipmi interface * @intf: ipmi inteface
* @argc: argument count * @argc: argument count
* @argv: argument list * @argv: argument list
* *
@ -1113,7 +1113,7 @@ ipmi_firewall_reset(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
printf_firewall_usage(); printf_firewall_usage();
return (-1); return (-1);
} else if (argc > 0 && !strcmp(argv[0], "help")) { } else if (argc > 0 && strncmp(argv[0], "help", 4) == 0) {
printf_firewall_usage(); printf_firewall_usage();
return 0; return 0;
} }
@ -1171,19 +1171,19 @@ ipmi_firewall_main(struct ipmi_intf * intf, int argc, char ** argv)
{ {
int rc = 0; int rc = 0;
if (argc < 1 || !strcmp(argv[0], "help")) { if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
printf_firewall_usage(); printf_firewall_usage();
} }
else if (!strcmp(argv[0], "info")) { else if (strncmp(argv[0], "info", 4) == 0) {
rc = ipmi_firewall_info(intf, argc-1, &(argv[1])); rc = ipmi_firewall_info(intf, argc-1, &(argv[1]));
} }
else if (!strcmp(argv[0], "enable")) { else if (strncmp(argv[0], "enable", 6) == 0) {
rc = ipmi_firewall_enable_disable(intf, 1, argc-1, &(argv[1])); rc = ipmi_firewall_enable_disable(intf, 1, argc-1, &(argv[1]));
} }
else if (!strcmp(argv[0], "disable")) { else if (strncmp(argv[0], "disable", 7) == 0) {
rc = ipmi_firewall_enable_disable(intf, 0, argc-1, &(argv[1])); rc = ipmi_firewall_enable_disable(intf, 0, argc-1, &(argv[1]));
} }
else if (!strcmp(argv[0], "reset")) { else if (strncmp(argv[0], "reset", 5) == 0) {
rc = ipmi_firewall_reset(intf, argc-1, &(argv[1])); rc = ipmi_firewall_reset(intf, argc-1, &(argv[1]));
} }
else { else {

File diff suppressed because it is too large Load Diff

View File

@ -151,16 +151,16 @@ ipmi_fwum_main(struct ipmi_intf *intf, int argc, char **argv)
printf_kfwum_help(); printf_kfwum_help();
return (-1); return (-1);
} }
if (!strcmp(argv[0], "help")) { if (strncmp(argv[0], "help", 4) == 0) {
printf_kfwum_help(); printf_kfwum_help();
rc = 0; rc = 0;
} else if (!strcmp(argv[0], "info")) { } else if (strncmp(argv[0], "info", 4) == 0) {
rc = ipmi_fwum_info(intf); rc = ipmi_fwum_info(intf);
} else if (!strcmp(argv[0], "status")) { } else if (strncmp(argv[0], "status", 6) == 0) {
rc = ipmi_fwum_status(intf); rc = ipmi_fwum_status(intf);
} else if (!strcmp(argv[0], "rollback")) { } else if (strncmp(argv[0], "rollback", 8) == 0) {
rc = KfwumManualRollback(intf); rc = KfwumManualRollback(intf);
} else if (!strcmp(argv[0], "download")) { } else if (strncmp(argv[0], "download", 8) == 0) {
if ((argc < 2) || (strlen(argv[1]) < 1)) { if ((argc < 2) || (strlen(argv[1]) < 1)) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Path and file name must be specified."); "Path and file name must be specified.");
@ -168,14 +168,14 @@ ipmi_fwum_main(struct ipmi_intf *intf, int argc, char **argv)
} }
printf("Firmware File Name : %s\n", argv[1]); printf("Firmware File Name : %s\n", argv[1]);
rc = ipmi_fwum_fwupgrade(intf, argv[1], 0); rc = ipmi_fwum_fwupgrade(intf, argv[1], 0);
} else if (!strcmp(argv[0], "upgrade")) { } else if (strncmp(argv[0], "upgrade", 7) == 0) {
if ((argc >= 2) && (strlen(argv[1]) > 0)) { if ((argc >= 2) && (strlen(argv[1]) > 0)) {
printf("Upgrading using file name %s\n", argv[1]); printf("Upgrading using file name %s\n", argv[1]);
rc = ipmi_fwum_fwupgrade(intf, argv[1], 1); rc = ipmi_fwum_fwupgrade(intf, argv[1], 1);
} else { } else {
rc = KfwumStartFirmwareUpgrade(intf); rc = KfwumStartFirmwareUpgrade(intf);
} }
} else if (!strcmp(argv[0], "tracelog")) { } else if (strncmp(argv[0], "tracelog", 8) == 0) {
rc = KfwumGetTraceLog(intf); rc = KfwumGetTraceLog(intf);
} else { } else {
lprintf(LOG_ERR, "Invalid KFWUM command: %s", argv[0]); lprintf(LOG_ERR, "Invalid KFWUM command: %s", argv[0]);
@ -258,7 +258,7 @@ ipmi_fwum_fwupgrade(struct ipmi_intf *intf, char *file, int action)
unsigned short padding; unsigned short padding;
unsigned long fsize = 0; unsigned long fsize = 0;
unsigned char not_used; unsigned char not_used;
if (!file) { if (file == NULL) {
lprintf(LOG_ERR, "No file given."); lprintf(LOG_ERR, "No file given.");
return (-1); return (-1);
} }
@ -312,7 +312,7 @@ KfwumGetFileSize(const char *pFileName, unsigned long *pFileSize)
{ {
FILE *pFileHandle = NULL; FILE *pFileHandle = NULL;
pFileHandle = fopen(pFileName, "rb"); pFileHandle = fopen(pFileName, "rb");
if (!pFileHandle) { if (pFileHandle == NULL) {
return (-1); return (-1);
} }
if (fseek(pFileHandle, 0L , SEEK_END) == 0) { if (fseek(pFileHandle, 0L , SEEK_END) == 0) {
@ -342,7 +342,7 @@ KfwumSetupBuffersFromFile(const char *pFileName, unsigned long fileSize)
int qty = 0; int qty = 0;
pFileHandle = fopen(pFileName, "rb"); pFileHandle = fopen(pFileName, "rb");
if (!pFileHandle) { if (pFileHandle == NULL) {
lprintf(LOG_ERR, "Failed to open '%s' for reading.", lprintf(LOG_ERR, "Failed to open '%s' for reading.",
pFileName); pFileName);
return (-1); return (-1);
@ -454,7 +454,7 @@ KfwumGetInfo(struct ipmi_intf *intf, unsigned char output,
if (!rsp) { if (!rsp) {
lprintf(LOG_ERR, "Error in FWUM Firmware Get Info Command."); lprintf(LOG_ERR, "Error in FWUM Firmware Get Info Command.");
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
lprintf(LOG_ERR, "FWUM Firmware Get Info returned %x", lprintf(LOG_ERR, "FWUM Firmware Get Info returned %x",
rsp->ccode); rsp->ccode);
return (-1); return (-1);
@ -479,7 +479,7 @@ KfwumGetInfo(struct ipmi_intf *intf, unsigned char output,
printf("Number Of Memory Bank : %u\n", pGetInfo->numBank); printf("Number Of Memory Bank : %u\n", pGetInfo->numBank);
} }
*pNumBank = pGetInfo->numBank; *pNumBank = pGetInfo->numBank;
/* Determine which type of download to use: */ /* Determine wich type of download to use: */
/* Old FWUM or Old IPMC fw (data_len < 7) /* Old FWUM or Old IPMC fw (data_len < 7)
* --> Address with small buffer size * --> Address with small buffer size
*/ */
@ -501,14 +501,14 @@ KfwumGetInfo(struct ipmi_intf *intf, unsigned char output,
printf("Protocol Revision :"); printf("Protocol Revision :");
printf(" > 5 optimizing buffers\n"); printf(" > 5 optimizing buffers\n");
} }
if (strstr(intf->name,"lan")) { if (strstr(intf->name,"lan") != NULL) {
/* also covers lanplus */ /* also covers lanplus */
save_fw_nfo.bufferSize = KFWUM_SMALL_BUFFER; save_fw_nfo.bufferSize = KFWUM_SMALL_BUFFER;
if (verbose) { if (verbose) {
printf("IOL payload size : %d\n", printf("IOL payload size : %d\n",
save_fw_nfo.bufferSize); save_fw_nfo.bufferSize);
} }
} else if (strstr(intf->name,"open") } else if ((strstr(intf->name,"open")!= NULL)
&& intf->target_addr != IPMI_BMC_SLAVE_ADDR && intf->target_addr != IPMI_BMC_SLAVE_ADDR
&& (intf->target_addr != intf->my_addr)) { && (intf->target_addr != intf->my_addr)) {
save_fw_nfo.bufferSize = KFWUM_SMALL_BUFFER; save_fw_nfo.bufferSize = KFWUM_SMALL_BUFFER;
@ -549,10 +549,10 @@ KfwumGetDeviceInfo(struct ipmi_intf *intf, unsigned char output,
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get Device Id Command"); lprintf(LOG_ERR, "Error in Get Device Id Command");
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
lprintf(LOG_ERR, "Get Device Id returned %x", lprintf(LOG_ERR, "Get Device Id returned %x",
rsp->ccode); rsp->ccode);
return (-1); return (-1);
@ -598,19 +598,19 @@ KfwumGetStatus(struct ipmi_intf * intf)
if (verbose) { if (verbose) {
printf(" Getting Status!\n"); printf(" Getting Status!\n");
} }
/* Retrieve the number of bank */ /* Retreive the number of bank */
rc = KfwumGetInfo(intf, 0, &numBank); rc = KfwumGetInfo(intf, 0, &numBank);
for(counter = 0; for(counter = 0;
(counter < numBank) && (rc == 0); (counter < numBank) && (rc == 0);
counter ++) { counter ++) {
/* Retrieve the status of each bank */ /* Retreive the status of each bank */
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_FIRMWARE; req.msg.netfn = IPMI_NETFN_FIRMWARE;
req.msg.cmd = KFWUM_CMD_ID_GET_FIRMWARE_STATUS; req.msg.cmd = KFWUM_CMD_ID_GET_FIRMWARE_STATUS;
req.msg.data = &counter; req.msg.data = &counter;
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error in FWUM Firmware Get Status Command."); "Error in FWUM Firmware Get Status Command.");
rc = (-1); rc = (-1);
@ -668,10 +668,10 @@ KfwumManualRollback(struct ipmi_intf *intf)
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error in FWUM Manual Rollback Command."); lprintf(LOG_ERR, "Error in FWUM Manual Rollback Command.");
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error in FWUM Manual Rollback Command returned %x", "Error in FWUM Manual Rollback Command returned %x",
rsp->ccode); rsp->ccode);
@ -707,7 +707,7 @@ KfwumStartFirmwareImage(struct ipmi_intf *intf, unsigned long length,
req.msg.data_len = 6; req.msg.data_len = 6;
} }
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error in FWUM Firmware Start Firmware Image Download Command."); "Error in FWUM Firmware Start Firmware Image Download Command.");
return (-1); return (-1);
@ -755,13 +755,13 @@ KfwumSaveFirmwareImage(struct ipmi_intf *intf, unsigned char sequenceNumber,
/* + 1 => sequenceNumber*/ /* + 1 => sequenceNumber*/
} }
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error in FWUM Firmware Save Firmware Image Download Command."); "Error in FWUM Firmware Save Firmware Image Download Command.");
/* We don't receive "C7" on errors with IOL, /* We don't receive "C7" on errors with IOL,
* instead we receive nothing * instead we receive nothing
*/ */
if (strstr(intf->name, "lan")) { if (strstr(intf->name, "lan") != NULL) {
no_rsp++; no_rsp++;
if (no_rsp < FWUM_SAVE_FIRMWARE_NO_RESPONSE_LIMIT) { if (no_rsp < FWUM_SAVE_FIRMWARE_NO_RESPONSE_LIMIT) {
*pInBufLength -= 1; *pInBufLength -= 1;
@ -772,7 +772,7 @@ KfwumSaveFirmwareImage(struct ipmi_intf *intf, unsigned char sequenceNumber,
*pInBufLength = 0; *pInBufLength = 0;
break; break;
} /* For other interface keep trying */ } /* For other interface keep trying */
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
if (rsp->ccode == 0xc0) { if (rsp->ccode == 0xc0) {
sleep(1); sleep(1);
} else if ((rsp->ccode == 0xc7) } else if ((rsp->ccode == 0xc7)
@ -836,9 +836,9 @@ KfwumFinishFirmwareImage(struct ipmi_intf *intf, tKFWUM_InFirmwareInfo firmInfo)
/* Infinite loop if BMC doesn't reply or replies 0xc0 every time. */ /* Infinite loop if BMC doesn't reply or replies 0xc0 every time. */
do { do {
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
} while (!rsp || rsp->ccode == 0xc0); } while (rsp == NULL || rsp->ccode == 0xc0);
if (rsp->ccode) { if (rsp->ccode != 0) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"FWUM Firmware Finish Firmware Image Download returned %x", "FWUM Firmware Finish Firmware Image Download returned %x",
rsp->ccode); rsp->ccode);
@ -917,7 +917,7 @@ KfwumStartFirmwareUpgrade(struct ipmi_intf *intf)
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error in FWUM Firmware Start Firmware Upgrade Command"); "Error in FWUM Firmware Start Firmware Upgrade Command");
rc = (-1); rc = (-1);
@ -950,7 +950,7 @@ KfwumGetTraceLog(struct ipmi_intf *intf)
(chunkIdx < TRACE_LOG_CHUNK_COUNT) (chunkIdx < TRACE_LOG_CHUNK_COUNT)
&& (rc == 0); && (rc == 0);
chunkIdx++) { chunkIdx++) {
/* Retrieve each log chunk and print it */ /* Retreive each log chunk and print it */
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_FIRMWARE; req.msg.netfn = IPMI_NETFN_FIRMWARE;
req.msg.cmd = KFWUM_CMD_ID_GET_TRACE_LOG; req.msg.cmd = KFWUM_CMD_ID_GET_TRACE_LOG;
@ -958,7 +958,7 @@ KfwumGetTraceLog(struct ipmi_intf *intf)
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error in FWUM Firmware Get Trace Log Command"); "Error in FWUM Firmware Get Trace Log Command");
rc = (-1); rc = (-1);
@ -971,7 +971,7 @@ KfwumGetTraceLog(struct ipmi_intf *intf)
break; break;
} }
for (cmdIdx=0; cmdIdx < TRACE_LOG_CHUNK_SIZE; cmdIdx++) { for (cmdIdx=0; cmdIdx < TRACE_LOG_CHUNK_SIZE; cmdIdx++) {
/* Don't display commands with an invalid state */ /* Don't diplay commands with an invalid state */
if ((rsp->data[TRACE_LOG_ATT_COUNT * cmdIdx + 1] != 0) if ((rsp->data[TRACE_LOG_ATT_COUNT * cmdIdx + 1] != 0)
&& (rsp->data[TRACE_LOG_ATT_COUNT * cmdIdx] < KFWUM_CMD_ID_STD_MAX_CMD)) { && (rsp->data[TRACE_LOG_ATT_COUNT * cmdIdx] < KFWUM_CMD_ID_STD_MAX_CMD)) {
printf(" Cmd ID: %17s -- CmdState: %10s -- CompCode: %2x\n", printf(" Cmd ID: %17s -- CmdState: %10s -- CompCode: %2x\n",
@ -1001,7 +1001,7 @@ KfwumGetInfoFromFirmware(unsigned char *pBuf, unsigned long bufSize,
} }
offset = IN_FIRMWARE_INFO_OFFSET_LOCATION; offset = IN_FIRMWARE_INFO_OFFSET_LOCATION;
/* Now, fill the structure with read information */ /* Now, fill the structure with read informations */
pInfo->checksum = (unsigned short)KWUM_GET_BYTE_AT_OFFSET(pBuf, pInfo->checksum = (unsigned short)KWUM_GET_BYTE_AT_OFFSET(pBuf,
offset + 0 + IN_FIRMWARE_INFO_OFFSET_CHECKSUM ) << 8; offset + 0 + IN_FIRMWARE_INFO_OFFSET_CHECKSUM ) << 8;

View File

@ -71,6 +71,7 @@ typedef struct gendev_eeprom_info
static int static int
ipmi_gendev_get_eeprom_size( ipmi_gendev_get_eeprom_size(
struct ipmi_intf *intf,
struct sdr_record_generic_locator *dev, struct sdr_record_generic_locator *dev,
t_gendev_eeprom_info *info t_gendev_eeprom_info *info
) )
@ -87,7 +88,8 @@ ipmi_gendev_get_eeprom_size(
lprintf(LOG_ERR, "DevType : %x", dev->dev_type); lprintf(LOG_ERR, "DevType : %x", dev->dev_type);
lprintf(LOG_ERR, "DevType Mod: %x", dev->dev_type_modifier); lprintf(LOG_ERR, "DevType Mod: %x", dev->dev_type_modifier);
*/ */
if (info) { if( info != NULL)
{
switch(dev->dev_type) switch(dev->dev_type)
{ {
case 0x08: // 24C01 case 0x08: // 24C01
@ -190,7 +192,7 @@ ipmi_gendev_read_file(
int eeprom_size; int eeprom_size;
t_gendev_eeprom_info eeprom_info; t_gendev_eeprom_info eeprom_info;
eeprom_size = ipmi_gendev_get_eeprom_size(dev, &eeprom_info); eeprom_size = ipmi_gendev_get_eeprom_size(intf, dev, &eeprom_info);
if(eeprom_size > 0) if(eeprom_size > 0)
{ {
@ -278,7 +280,8 @@ ipmi_gendev_read_file(
msize msize
); );
if (rsp) { if (rsp != NULL)
{
retryCounter = GENDEV_RETRY_COUNT; retryCounter = GENDEV_RETRY_COUNT;
rc = 0; rc = 0;
} }
@ -361,7 +364,7 @@ ipmi_gendev_write_file(
int eeprom_size; int eeprom_size;
t_gendev_eeprom_info eeprom_info; t_gendev_eeprom_info eeprom_info;
eeprom_size = ipmi_gendev_get_eeprom_size(dev, &eeprom_info); eeprom_size = ipmi_gendev_get_eeprom_size(intf, dev, &eeprom_info);
if(eeprom_size > 0) if(eeprom_size > 0)
{ {
@ -373,7 +376,7 @@ ipmi_gendev_write_file(
if(fp) if(fp)
{ {
/* Retrieve file length, check if it's fits the Eeprom Size */ /* Retreive file length, check if it's fits the Eeprom Size */
fseek(fp, 0 ,SEEK_END); fseek(fp, 0 ,SEEK_END);
fileLength = ftell(fp); fileLength = ftell(fp);
@ -454,6 +457,8 @@ ipmi_gendev_write_file(
break; break;
} }
for( for(
retryCounter = 0; retryCounter = 0;
retryCounter<GENDEV_RETRY_COUNT; retryCounter<GENDEV_RETRY_COUNT;
@ -471,7 +476,8 @@ ipmi_gendev_write_file(
i2caddr+= (((eeprom_info.size) % address_span_size) * 2); i2caddr+= (((eeprom_info.size) % address_span_size) * 2);
rsp = ipmi_master_write_read(intf, i2cbus, i2caddr, (uint8_t *) wrByte, eeprom_info.address_length+msize, 0); rsp = ipmi_master_write_read(intf, i2cbus, i2caddr, (uint8_t *) wrByte, eeprom_info.address_length+msize, 0);
if (rsp) { if (rsp != NULL)
{
retryCounter = GENDEV_RETRY_COUNT; retryCounter = GENDEV_RETRY_COUNT;
rc = 0; rc = 0;
} }
@ -489,7 +495,8 @@ ipmi_gendev_write_file(
} }
} }
if (!rc) { if( rc == 0 )
{
static uint8_t previousCompleted = 101; static uint8_t previousCompleted = 101;
percentCompleted = ((counter * 100) / eeprom_info.size ); percentCompleted = ((counter * 100) / eeprom_info.size );
@ -541,7 +548,11 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "Rx gendev command: %s", argv[0]); lprintf(LOG_ERR, "Rx gendev command: %s", argv[0]);
if (!argc || !strcmp(argv[0], "help")) if (
(argc == 0)
||
(strncmp(argv[0], "help", 4) == 0)
)
{ {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"SDR Commands: list read write"); "SDR Commands: list read write");
@ -551,12 +562,18 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
" read <sdr name> <file> Read to file eeprom specify by Generic Device Locators"); " read <sdr name> <file> Read to file eeprom specify by Generic Device Locators");
lprintf(LOG_ERR, lprintf(LOG_ERR,
" write <sdr name> <file> Write from file eeprom specify by Generic Device Locators"); " write <sdr name> <file> Write from file eeprom specify by Generic Device Locators");
} else if (!strcmp(argv[0], "list")) { }
rc = ipmi_sdr_print_sdr(intf, SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR); else if ( strncmp(argv[0], "list", 4) == 0)
} else if (!strcmp(argv[0], "read")) { {
rc = ipmi_sdr_print_sdr(intf,
SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR);
}
else if (strncmp(argv[0], "read", 4) == 0)
{
if (argc < 3) if (argc < 3)
lprintf(LOG_ERR, "usage: gendev read <gendev> <filename>"); lprintf(LOG_ERR, "usage: gendev read <gendev> <filename>");
else { else
{
struct sdr_record_list *sdr; struct sdr_record_list *sdr;
lprintf(LOG_ERR, "Gendev read sdr name : %s", argv[1]); lprintf(LOG_ERR, "Gendev read sdr name : %s", argv[1]);
@ -565,12 +582,14 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
/* lookup by sensor name */ /* lookup by sensor name */
sdr = ipmi_sdr_find_sdr_byid(intf, argv[1]); sdr = ipmi_sdr_find_sdr_byid(intf, argv[1]);
if (!sdr) { if (sdr == NULL)
{
lprintf(LOG_ERR, "Sensor data record not found!"); lprintf(LOG_ERR, "Sensor data record not found!");
return -1; return -1;
} }
if (sdr->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR) { if (sdr->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR)
{
lprintf(LOG_ERR, "Target SDR is not a generic device locator"); lprintf(LOG_ERR, "Target SDR is not a generic device locator");
return -1; return -1;
} }
@ -579,10 +598,13 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
ipmi_gendev_read_file(intf, sdr->record.genloc, argv[2]); ipmi_gendev_read_file(intf, sdr->record.genloc, argv[2]);
} }
} else if (!strcmp(argv[0], "write")) { }
else if (strncmp(argv[0], "write", 5) == 0)
{
if (argc < 3) if (argc < 3)
lprintf(LOG_ERR, "usage: gendev write <gendev> <filename>"); lprintf(LOG_ERR, "usage: gendev write <gendev> <filename>");
else { else
{
struct sdr_record_list *sdr; struct sdr_record_list *sdr;
lprintf(LOG_ERR, "Gendev write sdr name : %s", argv[1]); lprintf(LOG_ERR, "Gendev write sdr name : %s", argv[1]);
@ -591,20 +613,25 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
/* lookup by sensor name */ /* lookup by sensor name */
sdr = ipmi_sdr_find_sdr_byid(intf, argv[1]); sdr = ipmi_sdr_find_sdr_byid(intf, argv[1]);
if (!sdr) { if (sdr == NULL)
{
lprintf(LOG_ERR, "Sensor data record not found!"); lprintf(LOG_ERR, "Sensor data record not found!");
return -1; return -1;
} }
if (sdr->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR) { if (sdr->type != SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR)
{
lprintf(LOG_ERR, "Target SDR is not a generic device locator"); lprintf(LOG_ERR, "Target SDR is not a generic device locator");
return -1; return -1;
} }
lprintf(LOG_ERR, "Gendev write file name: %s", argv[2]); lprintf(LOG_ERR, "Gendev write file name: %s", argv[2]);
ipmi_gendev_write_file(intf, sdr->record.genloc, argv[2]); ipmi_gendev_write_file(intf, sdr->record.genloc, argv[2]);
} }
} else { }
else
{
lprintf(LOG_ERR, "Invalid gendev command: %s", argv[0]); lprintf(LOG_ERR, "Invalid gendev command: %s", argv[0]);
rc = -1; rc = -1;
} }

View File

@ -1,7 +1,6 @@
/* /*
* Copyright (c) 2006 Kontron Canada, Inc. All Rights Reserved. * Copyright (c) 2006 Kontron Canada, Inc. All Rights Reserved.
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2020 Joyent, Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -31,6 +30,10 @@
* 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.
*/ */
#define _BSD_SOURCE || \
(_XOPEN_SOURCE >= 500 || \
_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \
!(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
#include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_mc.h> #include <ipmitool/ipmi_mc.h>
@ -49,27 +52,12 @@
# include <config.h> # include <config.h>
#endif #endif
/* /* From src/plugins/ipmi_intf.c: */
* This error code is used as a temporary PATCH to uint16_t
* the latest Open ipmi driver. This PATCH ipmi_intf_get_max_request_data_size(struct ipmi_intf * intf);
* will be removed once a new Open IPMI driver is released.
* (Buggy version = 39)
*/
#define ENABLE_OPENIPMI_V39_PATCH
#ifdef ENABLE_OPENIPMI_V39_PATCH
# define RETRY_COUNT_MAX 3
static int errorCount;
# define HPMFWUPG_IS_RETRYABLE(error) \
((((error==0x83)||(error==0x82)||(error==0x80)) && (errorCount++<RETRY_COUNT_MAX))?TRUE:FALSE)
#else
# define HPMFWUPG_IS_RETRYABLE(error) FALSE
#endif
extern int verbose; extern int verbose;
VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
int HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename,
int activate, int, int); int activate, int, int);
int HpmfwupgValidateImageIntegrity(struct HpmfwupgUpgradeCtx *pFwupgCtx); int HpmfwupgValidateImageIntegrity(struct HpmfwupgUpgradeCtx *pFwupgCtx);
@ -129,7 +117,7 @@ int HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
int option, int option,
int *pFlagColdReset); int *pFlagColdReset);
int int
HpmfwupgPreUpgradeCheck( HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf,
struct HpmfwupgUpgradeCtx *pFwupgCtx, struct HpmfwupgUpgradeCtx *pFwupgCtx,
int componentMask, int option); int componentMask, int option);
@ -519,9 +507,10 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
lprintf(LOG_NOTICE, "\nPerforming upgrade stage:"); lprintf(LOG_NOTICE, "\nPerforming upgrade stage:");
} }
if (option & VIEW_MODE) { if (option & VIEW_MODE) {
rc = HpmfwupgPreUpgradeCheck(&fwupgCtx,componentMask, VIEW_MODE); rc = HpmfwupgPreUpgradeCheck(intf,
&fwupgCtx,componentMask, VIEW_MODE);
} else { } else {
rc = HpmfwupgPreUpgradeCheck(&fwupgCtx, rc = HpmfwupgPreUpgradeCheck(intf, &fwupgCtx,
componentMask, option); componentMask, option);
if (rc == HPMFWUPG_SUCCESS) { if (rc == HPMFWUPG_SUCCESS) {
if (verbose) { if (verbose) {
@ -545,7 +534,7 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
} }
if (rc == HPMFWUPG_SUCCESS) { if (rc == HPMFWUPG_SUCCESS) {
if (option & VIEW_MODE) { if (option & VIEW_MODE) {
/* Don't display anything here in case we are just viewing it */ /* Dont display anything here in case we are just viewing it */
lprintf(LOG_NOTICE," "); lprintf(LOG_NOTICE," ");
} else if (option & COMPARE_MODE) { } else if (option & COMPARE_MODE) {
lprintf(LOG_NOTICE, lprintf(LOG_NOTICE,
@ -555,7 +544,7 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
"\nFirmware upgrade procedure successful\n"); "\nFirmware upgrade procedure successful\n");
} }
} else if (option & VIEW_MODE) { } else if (option & VIEW_MODE) {
/* Don't display anything here in case we are just viewing it */ /* Dont display anything here in case we are just viewing it */
lprintf(LOG_NOTICE," "); lprintf(LOG_NOTICE," ");
} else if (option & COMPARE_MODE) { } else if (option & COMPARE_MODE) {
lprintf(LOG_NOTICE, lprintf(LOG_NOTICE,
@ -664,7 +653,7 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
if (rc != HPMFWUPG_SUCCESS) { if (rc != HPMFWUPG_SUCCESS) {
/* Giving one more chance to user to check whether its OK to continue even if the /* Giving one more chance to user to check whether its OK to continue even if the
* product ID does not match. This is helpful as sometimes we just want to update * product ID does not match. This is helpful as sometimes we just want to update
* and don't care whether we have a different product Id. If the user says NO then * and dont care whether we have a different product Id. If the user says NO then
* we need to just bail out from here * we need to just bail out from here
*/ */
if (!((option & FORCE_MODE) || (option & VIEW_MODE))) { if (!((option & FORCE_MODE) || (option & VIEW_MODE))) {
@ -736,7 +725,7 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
"\n Some components present in the image file are not supported by the IPMC"); "\n Some components present in the image file are not supported by the IPMC");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
/* Make sure the upgrade is desirable right now */ /* Make sure the upgrade is desirable rigth now */
if (pFwupgCtx->targetCap.GlobalCapabilities.bitField.fwUpgUndesirable == 1) { if (pFwupgCtx->targetCap.GlobalCapabilities.bitField.fwUpgUndesirable == 1) {
lprintf(LOG_NOTICE, "\n Upgrade undesirable at this moment"); lprintf(LOG_NOTICE, "\n Upgrade undesirable at this moment");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
@ -845,7 +834,7 @@ HpmfwupgValidateActionRecordChecksum(struct HpmfwupgActionRecord *pActionRecord)
* is same as target version. * is same as target version.
*/ */
int int
HpmfwupgPreUpgradeCheck( HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf,
struct HpmfwupgUpgradeCtx *pFwupgCtx, struct HpmfwupgUpgradeCtx *pFwupgCtx,
int componentMask, int option) int componentMask, int option)
{ {
@ -1224,7 +1213,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
if (rc == HPMFWUPG_UPLOAD_BLOCK_LENGTH && !bufLengthIsSet) { if (rc == HPMFWUPG_UPLOAD_BLOCK_LENGTH && !bufLengthIsSet) {
rc = HPMFWUPG_SUCCESS; rc = HPMFWUPG_SUCCESS;
/* Retry with a smaller buffer length */ /* Retry with a smaller buffer length */
if (strstr(intf->name,"lan") && bufLength > 8) { if (strstr(intf->name,"lan") != NULL && bufLength > 8) {
bufLength-= 8; bufLength-= 8;
lprintf(LOG_INFO, lprintf(LOG_INFO,
"Trying reduced buffer length: %d", "Trying reduced buffer length: %d",
@ -1315,7 +1304,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
HpmDisplayUpgrade(1,0,0,0); HpmDisplayUpgrade(1,0,0,0);
if ((option & COMPARE_MODE) if ((option & COMPARE_MODE)
&& !pFwupgCtx->genCompProp[pFwupgCtx->componentId].GeneralCompProperties.bitfield.comparisonSupport) { && !pFwupgCtx->genCompProp[pFwupgCtx->componentId].GeneralCompProperties.bitfield.comparisonSupport) {
printf("| |Comparison isn't supported for given component. |\n"); printf("| |Comparison isn't supported for given compenent. |\n");
} }
*pImagePtr = pDataInitial + firmwareLength; *pImagePtr = pDataInitial + firmwareLength;
} }
@ -1401,26 +1390,27 @@ int
HpmfwupgGetBufferFromFile(char *imageFilename, HpmfwupgGetBufferFromFile(char *imageFilename,
struct HpmfwupgUpgradeCtx *pFwupgCtx) struct HpmfwupgUpgradeCtx *pFwupgCtx)
{ {
int rc = HPMFWUPG_ERROR; int rc = HPMFWUPG_SUCCESS;
int ret = 0; int ret = 0;
FILE *pImageFile = fopen(imageFilename, "rb"); FILE *pImageFile = fopen(imageFilename, "rb");
if (!pImageFile) { if (pImageFile == NULL) {
lprintf(LOG_ERR, "Cannot open image file '%s'", lprintf(LOG_ERR, "Cannot open image file '%s'",
imageFilename); imageFilename);
goto ret_no_close; return HPMFWUPG_ERROR;
} }
/* Get the raw data in file */ /* Get the raw data in file */
ret = fseek(pImageFile, 0, SEEK_END); ret = fseek(pImageFile, 0, SEEK_END);
if (ret != 0) { if (ret != 0) {
lprintf(LOG_ERR, "Failed to seek in the image file '%s'", lprintf(LOG_ERR, "Failed to seek in the image file '%s'",
imageFilename); imageFilename);
goto ret_close; return HPMFWUPG_ERROR;
} }
pFwupgCtx->imageSize = ftell(pImageFile); pFwupgCtx->imageSize = ftell(pImageFile);
pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize); pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize);
if (!pFwupgCtx->pImageData) { if (pFwupgCtx->pImageData == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
goto ret_close; fclose(pImageFile);
return HPMFWUPG_ERROR;
} }
rewind(pImageFile); rewind(pImageFile);
ret = fread(pFwupgCtx->pImageData, ret = fread(pFwupgCtx->pImageData,
@ -1432,14 +1422,9 @@ HpmfwupgGetBufferFromFile(char *imageFilename,
"Failed to read file %s size %d", "Failed to read file %s size %d",
imageFilename, imageFilename,
pFwupgCtx->imageSize); pFwupgCtx->imageSize);
goto ret_close; rc = HPMFWUPG_ERROR;
} }
rc = HPMFWUPG_SUCCESS;
ret_close:
fclose(pImageFile); fclose(pImageFile);
ret_no_close:
return rc; return rc;
} }
@ -1453,11 +1438,11 @@ HpmfwupgGetDeviceId(struct ipmi_intf *intf, struct ipm_devid_rsp *pGetDevId)
req.msg.cmd = BMC_GET_DEVICE_ID; req.msg.cmd = BMC_GET_DEVICE_ID;
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = HpmfwupgSendCmd(intf, req, NULL); rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error getting device ID."); lprintf(LOG_ERR, "Error getting device ID.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode != 0x00) {
lprintf(LOG_ERR, "Error getting device ID."); lprintf(LOG_ERR, "Error getting device ID.");
lprintf(LOG_ERR, "compcode=0x%x: %s", lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode, rsp->ccode,
@ -1481,12 +1466,12 @@ HpmfwupgGetTargetUpgCapabilities(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req; req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgGetTargetUpgCapabilitiesReq); req.msg.data_len = sizeof(struct HpmfwupgGetTargetUpgCapabilitiesReq);
rsp = HpmfwupgSendCmd(intf, req, NULL); rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error getting target upgrade capabilities."); "Error getting target upgrade capabilities.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode != 0x00) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"Error getting target upgrade capabilities, ccode: 0x%x: %s", "Error getting target upgrade capabilities, ccode: 0x%x: %s",
rsp->ccode, rsp->ccode,
@ -1522,7 +1507,7 @@ HpmfwupgGetTargetUpgCapabilities(struct ipmi_intf *intf,
pCtx->resp.GlobalCapabilities.bitField.autRollbackOverride ? 'y' : 'n'); pCtx->resp.GlobalCapabilities.bitField.autRollbackOverride ? 'y' : 'n');
lprintf(LOG_NOTICE, "IPMC degraded...........[%c] ", lprintf(LOG_NOTICE, "IPMC degraded...........[%c] ",
pCtx->resp.GlobalCapabilities.bitField.ipmcDegradedDurinUpg ? 'y' : 'n'); pCtx->resp.GlobalCapabilities.bitField.ipmcDegradedDurinUpg ? 'y' : 'n');
lprintf(LOG_NOTICE, "Deferred activation.....[%c] ", lprintf(LOG_NOTICE, "Defered activation......[%c] ",
pCtx->resp.GlobalCapabilities.bitField.deferActivation ? 'y' : 'n'); pCtx->resp.GlobalCapabilities.bitField.deferActivation ? 'y' : 'n');
lprintf(LOG_NOTICE, "Service affected........[%c] ", lprintf(LOG_NOTICE, "Service affected........[%c] ",
pCtx->resp.GlobalCapabilities.bitField.servAffectDuringUpg ? 'y' : 'n'); pCtx->resp.GlobalCapabilities.bitField.servAffectDuringUpg ? 'y' : 'n');
@ -1558,12 +1543,12 @@ HpmfwupgGetComponentProperties(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req; req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgGetComponentPropertiesReq); req.msg.data_len = sizeof(struct HpmfwupgGetComponentPropertiesReq);
rsp = HpmfwupgSendCmd(intf, req, NULL); rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_NOTICE, lprintf(LOG_NOTICE,
"Error getting component properties\n"); "Error getting component properties\n");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode != 0x00) {
lprintf(LOG_NOTICE, lprintf(LOG_NOTICE,
"Error getting component properties"); "Error getting component properties");
lprintf(LOG_NOTICE, lprintf(LOG_NOTICE,
@ -1684,11 +1669,11 @@ HpmfwupgAbortUpgrade(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req; req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgAbortUpgradeReq); req.msg.data_len = sizeof(struct HpmfwupgAbortUpgradeReq);
rsp = HpmfwupgSendCmd(intf, req, NULL); rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error - aborting upgrade."); lprintf(LOG_ERR, "Error - aborting upgrade.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode != 0x00) {
lprintf(LOG_ERR, "Error aborting upgrade"); lprintf(LOG_ERR, "Error aborting upgrade");
lprintf(LOG_ERR, "compcode=0x%x: %s", lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode, rsp->ccode,
@ -1713,14 +1698,14 @@ HpmfwupgInitiateUpgradeAction(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req; req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgInitiateUpgradeActionReq); req.msg.data_len = sizeof(struct HpmfwupgInitiateUpgradeActionReq);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx); rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error initiating upgrade action."); lprintf(LOG_ERR, "Error initiating upgrade action.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
/* Long duration command handling */ /* Long duration command handling */
if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) { if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) {
rc = HpmfwupgWaitLongDurationCmd(intf, pFwupgCtx); rc = HpmfwupgWaitLongDurationCmd(intf, pFwupgCtx);
} else if (rsp->ccode) { } else if (rsp->ccode != 0x00) {
lprintf(LOG_NOTICE,"Error initiating upgrade action"); lprintf(LOG_NOTICE,"Error initiating upgrade action");
lprintf(LOG_NOTICE, "compcode=0x%x: %s", lprintf(LOG_NOTICE, "compcode=0x%x: %s",
rsp->ccode, rsp->ccode,
@ -1747,7 +1732,7 @@ HpmfwupgUploadFirmwareBlock(struct ipmi_intf *intf,
/* 2 is the size of the upload struct - data */ /* 2 is the size of the upload struct - data */
req.msg.data_len = 2 + count; req.msg.data_len = 2 + count;
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx); rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_NOTICE, "Error uploading firmware block."); lprintf(LOG_NOTICE, "Error uploading firmware block.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
@ -1783,7 +1768,7 @@ HpmfwupgUploadFirmwareBlock(struct ipmi_intf *intf,
/* Long duration command handling */ /* Long duration command handling */
if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) { if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) {
rc = HpmfwupgWaitLongDurationCmd(intf, pFwupgCtx); rc = HpmfwupgWaitLongDurationCmd(intf, pFwupgCtx);
} else if (rsp->ccode) { } else if (rsp->ccode != 0x00) {
/* PATCH --> This validation is to handle retryables errors codes on IPMB bus. /* PATCH --> This validation is to handle retryables errors codes on IPMB bus.
* This will be fixed in the next release of open ipmi and this * This will be fixed in the next release of open ipmi and this
* check will have to be removed. (Buggy version = 39) * check will have to be removed. (Buggy version = 39)
@ -1824,7 +1809,7 @@ HpmfwupgFinishFirmwareUpload(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req; req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgFinishFirmwareUploadReq); req.msg.data_len = sizeof(struct HpmfwupgFinishFirmwareUploadReq);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx); rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error fininshing firmware upload."); lprintf(LOG_ERR, "Error fininshing firmware upload.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
@ -1861,7 +1846,7 @@ HpmfwupgActivateFirmware(struct ipmi_intf *intf,
req.msg.data_len = sizeof(struct HpmfwupgActivateFirmwareReq) req.msg.data_len = sizeof(struct HpmfwupgActivateFirmwareReq)
- (!pCtx->req.rollback_override ? 1 : 0); - (!pCtx->req.rollback_override ? 1 : 0);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx); rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error activating firmware."); lprintf(LOG_ERR, "Error activating firmware.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
@ -1962,7 +1947,7 @@ HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req; req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgManualFirmwareRollbackReq); req.msg.data_len = sizeof(struct HpmfwupgManualFirmwareRollbackReq);
rsp = HpmfwupgSendCmd(intf, req, &fwupgCtx); rsp = HpmfwupgSendCmd(intf, req, &fwupgCtx);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error sending manual rollback."); lprintf(LOG_ERR, "Error sending manual rollback.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
@ -1973,7 +1958,7 @@ HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf,
printf("Waiting firmware rollback..."); printf("Waiting firmware rollback...");
fflush(stdout); fflush(stdout);
rc = HpmfwupgQueryRollbackStatus(intf, &resCmd, &fwupgCtx); rc = HpmfwupgQueryRollbackStatus(intf, &resCmd, &fwupgCtx);
} else if (rsp->ccode) { } else if ( rsp->ccode != 0x00 ) {
lprintf(LOG_ERR, "Error sending manual rollback"); lprintf(LOG_ERR, "Error sending manual rollback");
lprintf(LOG_ERR, "compcode=0x%x: %s", lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode, rsp->ccode,
@ -2000,7 +1985,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req; req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgQueryRollbackStatusReq); req.msg.data_len = sizeof(struct HpmfwupgQueryRollbackStatusReq);
/* If we are not in upgrade context, we use default timeout values */ /* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) { if (pFwupgCtx != NULL) {
struct HpmfwupgImageHeader *pImageHeader; struct HpmfwupgImageHeader *pImageHeader;
if (pFwupgCtx->pImageData) { if (pFwupgCtx->pImageData) {
pImageHeader = (struct HpmfwupgImageHeader*)pFwupgCtx->pImageData; pImageHeader = (struct HpmfwupgImageHeader*)pFwupgCtx->pImageData;
@ -2009,7 +1994,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
rollbackTimeout = 0; rollbackTimeout = 0;
} }
/* Use the greater of the two timeouts (header and target caps) */ /* Use the greater of the two timeouts (header and target caps) */
rollbackTimeout = __max(rollbackTimeout, rollbackTimeout = MAX(rollbackTimeout,
pFwupgCtx->targetCap.rollbackTimeout) * 5; pFwupgCtx->targetCap.rollbackTimeout) * 5;
} else { } else {
rollbackTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT; rollbackTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2036,7 +2021,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
&& ((rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) && ((rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS)
|| (rsp->ccode == IPMI_CC_TIMEOUT)) || (rsp->ccode == IPMI_CC_TIMEOUT))
&& (timeoutSec2 - timeoutSec1 < rollbackTimeout)); && (timeoutSec2 - timeoutSec1 < rollbackTimeout));
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error getting upgrade status."); lprintf(LOG_ERR, "Error getting upgrade status.");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
@ -2080,11 +2065,11 @@ HpmfwupgQuerySelftestResult(struct ipmi_intf *intf, struct HpmfwupgQuerySelftest
unsigned int timeoutSec1, timeoutSec2; unsigned int timeoutSec1, timeoutSec2;
pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER; pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER;
/* If we are not in upgrade context, we use default timeout values */ /* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) { if (pFwupgCtx != NULL) {
/* Getting selftest timeout from new image */ /* Getting selftest timeout from new image */
struct HpmfwupgImageHeader *pImageHeader = (struct HpmfwupgImageHeader*) struct HpmfwupgImageHeader *pImageHeader = (struct HpmfwupgImageHeader*)
pFwupgCtx->pImageData; pFwupgCtx->pImageData;
selfTestTimeout = __max(pImageHeader->selfTestTimeout, selfTestTimeout = MAX(pImageHeader->selfTestTimeout,
pFwupgCtx->targetCap.selftestTimeout) * 5; pFwupgCtx->targetCap.selftestTimeout) * 5;
} else { } else {
selfTestTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT; selfTestTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2116,7 +2101,7 @@ HpmfwupgQuerySelftestResult(struct ipmi_intf *intf, struct HpmfwupgQuerySelftest
} while (rsp } while (rsp
&& (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) && (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS)
&& (timeoutSec2 - timeoutSec1 < selfTestTimeout)); && (timeoutSec2 - timeoutSec1 < selfTestTimeout));
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_NOTICE, "Error getting upgrade status\n"); lprintf(LOG_NOTICE, "Error getting upgrade status\n");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
@ -2150,14 +2135,14 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
unsigned int timeoutSec1, timeoutSec2; unsigned int timeoutSec1, timeoutSec2;
unsigned char retry = 0; unsigned char retry = 0;
/* If we are not in upgrade context, we use default timeout values */ /* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) { if (pFwupgCtx != NULL) {
inaccessTimeout = pFwupgCtx->targetCap.inaccessTimeout*5; inaccessTimeout = pFwupgCtx->targetCap.inaccessTimeout*5;
upgradeTimeout = pFwupgCtx->targetCap.upgradeTimeout*5; upgradeTimeout = pFwupgCtx->targetCap.upgradeTimeout*5;
} else { } else {
/* keeping the inaccessTimeout to 60 seconds results in almost 2900 retries /* keeping the inaccessTimeout to 60 seconds results in almost 2900 retries
* So if the target is not available it will be retrying the command for 2900 * So if the target is not available it will be retrying the command for 2900
* times which is not efficient -So reducing the Timeout to 5 seconds which is * times which is not effecient -So reducing the Timout to 5 seconds which is
* almost 200 retries if it continuously receives 0xC3 as completion code. * almost 200 retries if it continuously recieves 0xC3 as completion code.
*/ */
inaccessTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT; inaccessTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT; upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2166,10 +2151,10 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
do { do {
static unsigned char isValidSize = FALSE; static unsigned char isValidSize = FALSE;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
#define HPM_LAN_PACKET_RESIZE_LIMIT 6 #define HPM_LAN_PACKET_RESIZE_LIMIT 6
/* also covers lanplus */ /* also covers lanplus */
if (strstr(intf->name, "lan")) { if (strstr(intf->name, "lan") != NULL) {
static int errorCount=0; static int errorCount=0;
static struct ipmi_rs fakeRsp; static struct ipmi_rs fakeRsp;
lprintf(LOG_DEBUG, lprintf(LOG_DEBUG,
@ -2234,7 +2219,7 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
} }
} }
/* Handle inaccessibility timeout (rsp = NULL if IOL) */ /* Handle inaccessibility timeout (rsp = NULL if IOL) */
if (!rsp || rsp->ccode == 0xff || rsp->ccode == 0xc3 || rsp->ccode == 0xd3) { if (rsp == NULL || rsp->ccode == 0xff || rsp->ccode == 0xc3 || rsp->ccode == 0xd3) {
if (inaccessTimeoutCounter < inaccessTimeout) { if (inaccessTimeoutCounter < inaccessTimeout) {
timeoutSec2 = time(NULL); timeoutSec2 = time(NULL);
if (timeoutSec2 > timeoutSec1) { if (timeoutSec2 > timeoutSec1) {
@ -2287,14 +2272,14 @@ HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf,
unsigned int timeoutSec1, timeoutSec2; unsigned int timeoutSec1, timeoutSec2;
struct HpmfwupgGetUpgradeStatusCtx upgStatusCmd; struct HpmfwupgGetUpgradeStatusCtx upgStatusCmd;
/* If we are not in upgrade context, we use default timeout values */ /* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) { if (pFwupgCtx != NULL) {
upgradeTimeout = (unsigned int)(pFwupgCtx->targetCap.upgradeTimeout*5); upgradeTimeout = (unsigned int)(pFwupgCtx->targetCap.upgradeTimeout*5);
if (verbose) { if (verbose) {
printf("Use File Upgrade Capabilities: %i seconds\n", printf("Use File Upgrade Capabilities: %i seconds\n",
upgradeTimeout); upgradeTimeout);
} }
} else { } else {
/* Try to retrieve from Caps */ /* Try to retreive from Caps */
struct HpmfwupgGetTargetUpgCapabilitiesCtx targetCapCmd; struct HpmfwupgGetTargetUpgCapabilitiesCtx targetCapCmd;
if(HpmfwupgGetTargetUpgCapabilities(intf, &targetCapCmd) != HPMFWUPG_SUCCESS) { if(HpmfwupgGetTargetUpgCapabilities(intf, &targetCapCmd) != HPMFWUPG_SUCCESS) {
upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT; upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2310,9 +2295,13 @@ HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf,
} }
} }
} }
/* Poll upgrade status until completion or timeout*/ if (rc == HPMFWUPG_SUCCESS) {
timeoutSec2 = timeoutSec1 = time(NULL); /* Poll upgrade status until completion or timeout*/
rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd, pFwupgCtx, 1); timeoutSec1 = time(NULL);
timeoutSec2 = time(NULL);
rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd,
pFwupgCtx, 1);
}
while ( while (
/* With KCS: Cover the case where we sometime /* With KCS: Cover the case where we sometime
* receive d5 (on the first get status) from * receive d5 (on the first get status) from
@ -2475,12 +2464,12 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
HpmfwupgPrintUsage(); HpmfwupgPrintUsage();
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
if (!strcmp(argv[0], "help")) { if (strcmp(argv[0], "help") == 0) {
HpmfwupgPrintUsage(); HpmfwupgPrintUsage();
return HPMFWUPG_SUCCESS; return HPMFWUPG_SUCCESS;
} else if (!strcmp(argv[0], "check")) { } else if ((strcmp(argv[0], "check") == 0)) {
/* hpm check */ /* hpm check */
if (!argv[1]) { if (argv[1] == NULL) {
rc = HpmfwupgTargetCheck(intf,VIEW_MODE); rc = HpmfwupgTargetCheck(intf,VIEW_MODE);
} else { } else {
/* hpm check <filename> */ /* hpm check <filename> */
@ -2490,18 +2479,18 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
0, VIEW_MODE); 0, VIEW_MODE);
} }
} }
} else if (!strcmp(argv[0], "upgrade")) { } else if (strcmp(argv[0], "upgrade") == 0) {
int i =0; int i =0;
for (i=1; i< argc ; i++) { for (i=1; i< argc ; i++) {
if (!strcmp(argv[i],"activate")) { if (strcmp(argv[i],"activate") == 0) {
activateFlag = 1; activateFlag = 1;
} }
/* hpm upgrade <filename> force */ /* hpm upgrade <filename> force */
if (!strcmp(argv[i],"force")) { if (strcmp(argv[i],"force") == 0) {
option |= FORCE_MODE; option |= FORCE_MODE;
} }
/* hpm upgrade <filename> component <comp Id> */ /* hpm upgrade <filename> component <comp Id> */
if (!strcmp(argv[i],"component")) { if (strcmp(argv[i],"component") == 0) {
if (i+1 < argc) { if (i+1 < argc) {
/* Error Checking */ /* Error Checking */
if (str2int(argv[i+1], &componentId) != 0 if (str2int(argv[i+1], &componentId) != 0
@ -2530,7 +2519,7 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
} }
if (!strcmp(argv[i],"debug")) { if (strcmp(argv[i],"debug") == 0) {
option |= DEBUG_MODE; option |= DEBUG_MODE;
} }
} }
@ -2540,11 +2529,11 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
rc = HpmfwupgUpgrade(intf, argv[1], activateFlag, rc = HpmfwupgUpgrade(intf, argv[1], activateFlag,
componentMask, option); componentMask, option);
} }
} else if (!strcmp(argv[0], "compare")) { } else if (strcmp(argv[0], "compare") == 0) {
int i = 0; int i = 0;
for (i=1; i< argc; i++) { for (i=1; i< argc; i++) {
/* hpm compare <file> [component x...] */ /* hpm compare <file> [component x...] */
if (!strcmp(argv[i],"component")) { if (strcmp(argv[i],"component") == 0) {
if (i+1 < argc) { if (i+1 < argc) {
/* Error Checking */ /* Error Checking */
if (str2int(argv[i+1], &componentId) != 0 if (str2int(argv[i+1], &componentId) != 0
@ -2573,7 +2562,7 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
"No component Id provided\n"); "No component Id provided\n");
return HPMFWUPG_ERROR; return HPMFWUPG_ERROR;
} }
} else if (!strcmp(argv[i],"debug")) { } else if (strcmp(argv[i],"debug") == 0) {
option|= DEBUG_MODE; option|= DEBUG_MODE;
} }
} }
@ -2583,19 +2572,19 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
rc = HpmfwupgUpgrade(intf, argv[1], 0, rc = HpmfwupgUpgrade(intf, argv[1], 0,
componentMask, option); componentMask, option);
} }
} else if (argc >= 1 && !strcmp(argv[0], "activate")) { } else if ((argc >= 1) && (strcmp(argv[0], "activate") == 0)) {
struct HpmfwupgActivateFirmwareCtx cmdCtx; struct HpmfwupgActivateFirmwareCtx cmdCtx;
if (argc == 2 && !strcmp(argv[1], "norollback")) { if ((argc == 2) && (strcmp(argv[1], "norollback") == 0)) {
cmdCtx.req.rollback_override = 1; cmdCtx.req.rollback_override = 1;
} else { } else {
cmdCtx.req.rollback_override = 0; cmdCtx.req.rollback_override = 0;
} }
rc = HpmfwupgActivateFirmware(intf, &cmdCtx, NULL); rc = HpmfwupgActivateFirmware(intf, &cmdCtx, NULL);
} else if (argc == 1 && !strcmp(argv[0], "targetcap")) { } else if ((argc == 1) && (strcmp(argv[0], "targetcap") == 0)) {
struct HpmfwupgGetTargetUpgCapabilitiesCtx cmdCtx; struct HpmfwupgGetTargetUpgCapabilitiesCtx cmdCtx;
verbose++; verbose++;
rc = HpmfwupgGetTargetUpgCapabilities(intf, &cmdCtx); rc = HpmfwupgGetTargetUpgCapabilities(intf, &cmdCtx);
} else if (argc == 3 && !strcmp(argv[0], "compprop")) { } else if ((argc == 3) && (strcmp(argv[0], "compprop") == 0)) {
struct HpmfwupgGetComponentPropertiesCtx cmdCtx; struct HpmfwupgGetComponentPropertiesCtx cmdCtx;
if (str2uchar(argv[1], &(cmdCtx.req.componentId)) != 0 if (str2uchar(argv[1], &(cmdCtx.req.componentId)) != 0
|| cmdCtx.req.componentId > 7) { || cmdCtx.req.componentId > 7) {
@ -2617,23 +2606,23 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
} }
verbose++; verbose++;
rc = HpmfwupgGetComponentProperties(intf, &cmdCtx); rc = HpmfwupgGetComponentProperties(intf, &cmdCtx);
} else if (argc == 1 && !strcmp(argv[0], "abort")) { } else if ((argc == 1) && (strcmp(argv[0], "abort") == 0)) {
struct HpmfwupgAbortUpgradeCtx cmdCtx; struct HpmfwupgAbortUpgradeCtx cmdCtx;
verbose++; verbose++;
rc = HpmfwupgAbortUpgrade(intf, &cmdCtx); rc = HpmfwupgAbortUpgrade(intf, &cmdCtx);
} else if (argc == 1 && !strcmp(argv[0], "upgstatus")) { } else if ((argc == 1) && (strcmp(argv[0], "upgstatus") == 0)) {
struct HpmfwupgGetUpgradeStatusCtx cmdCtx; struct HpmfwupgGetUpgradeStatusCtx cmdCtx;
verbose++; verbose++;
rc = HpmfwupgGetUpgradeStatus(intf, &cmdCtx, NULL, 0); rc = HpmfwupgGetUpgradeStatus(intf, &cmdCtx, NULL, 0);
} else if (argc == 1 && !strcmp(argv[0], "rollback")) { } else if ((argc == 1) && (strcmp(argv[0], "rollback") == 0)) {
struct HpmfwupgManualFirmwareRollbackCtx cmdCtx; struct HpmfwupgManualFirmwareRollbackCtx cmdCtx;
verbose++; verbose++;
rc = HpmfwupgManualFirmwareRollback(intf, &cmdCtx); rc = HpmfwupgManualFirmwareRollback(intf, &cmdCtx);
} else if (argc == 1 && !strcmp(argv[0], "rollbackstatus")) { } else if ((argc == 1) && (strcmp(argv[0], "rollbackstatus") == 0)) {
struct HpmfwupgQueryRollbackStatusCtx cmdCtx; struct HpmfwupgQueryRollbackStatusCtx cmdCtx;
verbose++; verbose++;
rc = HpmfwupgQueryRollbackStatus(intf, &cmdCtx, NULL); rc = HpmfwupgQueryRollbackStatus(intf, &cmdCtx, NULL);
} else if (argc == 1 && !strcmp(argv[0], "selftestresult")) { } else if ((argc == 1) && (strcmp(argv[0], "selftestresult") == 0)) {
struct HpmfwupgQuerySelftestResultCtx cmdCtx; struct HpmfwupgQuerySelftestResultCtx cmdCtx;
verbose++; verbose++;
rc = HpmfwupgQuerySelftestResult(intf, &cmdCtx, NULL); rc = HpmfwupgQuerySelftestResult(intf, &cmdCtx, NULL);

90
lib/ipmi_ime.c Normal file → Executable file
View File

@ -202,11 +202,11 @@ static int ImeGetInfo(struct ipmi_intf *intf)
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Get Device ID command failed"); lprintf(LOG_ERR, "Get Device ID command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Device ID command failed: %s", lprintf(LOG_ERR, "Get Device ID command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -240,7 +240,8 @@ static int ImeGetInfo(struct ipmi_intf *intf)
{ {
rc = IME_SUCCESS; rc = IME_SUCCESS;
printf("Manufacturer Name : %s\n", printf("Manufacturer Name : %s\n",
OEM_MFG_STRING(devid->manufacturer_id)); val2str( (long)IPM_DEV_MANUFACTURER_ID(devid->manufacturer_id),
ipmi_oem_info) );
printf("Product ID : %u (0x%02x%02x)\n", printf("Product ID : %u (0x%02x%02x)\n",
buf2short((uint8_t *)(devid->product_id)), buf2short((uint8_t *)(devid->product_id)),
@ -250,7 +251,7 @@ static int ImeGetInfo(struct ipmi_intf *intf)
(devid->product_id[1]<<8)+devid->product_id[0], (devid->product_id[1]<<8)+devid->product_id[0],
ipmi_oem_product_info); ipmi_oem_product_info);
if (product) if (product!=NULL)
{ {
printf("Product Name : %s\n", product); printf("Product Name : %s\n", product);
} }
@ -356,7 +357,12 @@ static int ImeUpgrade(struct ipmi_intf *intf, char* imageFilename)
rc = ImeImageCtxFromFile(imageFilename, &imgCtx); rc = ImeImageCtxFromFile(imageFilename, &imgCtx);
if (rc == IME_ERROR || !imgCtx.pData || !imgCtx.size) { if(
(rc == IME_ERROR) ||
(imgCtx.pData == NULL) ||
(imgCtx.size == 0)
)
{
return IME_ERROR; return IME_ERROR;
} }
@ -504,11 +510,11 @@ static int ImeUpdatePrepare(struct ipmi_intf *intf)
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed"); lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s", lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -539,11 +545,11 @@ static int ImeUpdateOpenArea(struct ipmi_intf *intf)
req.msg.data_len = 2; req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "UpdateOpenArea command failed"); lprintf(LOG_ERR, "UpdateOpenArea command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdateOpenArea command failed: %s", lprintf(LOG_ERR, "UpdateOpenArea command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -579,11 +585,11 @@ static int ImeUpdateWriteArea(
req.msg.data_len = length + 1; req.msg.data_len = length + 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "UpdateWriteArea command failed"); lprintf(LOG_ERR, "UpdateWriteArea command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdateWriteArea command failed: %s", lprintf(LOG_ERR, "UpdateWriteArea command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
if( rsp->ccode == 0x80) // restart operation if( rsp->ccode == 0x80) // restart operation
@ -626,11 +632,11 @@ static int ImeUpdateCloseArea(
req.msg.data_len = length; req.msg.data_len = length;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "UpdateCloseArea command failed"); lprintf(LOG_ERR, "UpdateCloseArea command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdateCloseArea command failed: %s", lprintf(LOG_ERR, "UpdateCloseArea command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -660,11 +666,11 @@ static int ImeUpdateGetStatus(struct ipmi_intf *intf, tImeStatus *pStatus )
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed"); lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s", lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -733,11 +739,11 @@ static int ImeUpdateGetCapabilities(struct ipmi_intf *intf, tImeCaps *pCaps )
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed"); lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s", lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -773,11 +779,11 @@ static int ImeUpdateRegisterUpdate(struct ipmi_intf *intf, tImeUpdateType type)
req.msg.data_len = 2; req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed"); lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed: %s", lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -804,11 +810,11 @@ static int ImeUpdateShowStatus(struct ipmi_intf *intf)
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed"); lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR; return IME_ERROR;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s", lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return IME_ERROR; return IME_ERROR;
@ -873,13 +879,15 @@ static int ImeImageCtxFromFile(
{ {
int rc = IME_SUCCESS; int rc = IME_SUCCESS;
FILE* pImageFile = fopen(imageFilename, "rb"); FILE* pImageFile = fopen(imageFilename, "rb");
if (!pImageFile) { if ( pImageFile == NULL )
{
lprintf(LOG_NOTICE,"Cannot open image file %s", imageFilename); lprintf(LOG_NOTICE,"Cannot open image file %s", imageFilename);
rc = IME_ERROR; rc = IME_ERROR;
} }
if (rc == IME_SUCCESS) { if ( rc == IME_SUCCESS )
{
/* Get the raw data in file */ /* Get the raw data in file */
fseek(pImageFile, 0, SEEK_END); fseek(pImageFile, 0, SEEK_END);
pImageCtx->size = ftell(pImageFile); pImageCtx->size = ftell(pImageFile);
@ -893,26 +901,32 @@ static int ImeImageCtxFromFile(
pImageCtx->pData = malloc(sizeof(unsigned char)*pImageCtx->size); pImageCtx->pData = malloc(sizeof(unsigned char)*pImageCtx->size);
rewind(pImageFile); rewind(pImageFile);
if (!pImageCtx->pData if ( pImageCtx->pData != NULL )
|| pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char), {
pImageCtx->size, pImageFile)) if (pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char),
pImageCtx->size, pImageFile))
rc = IME_ERROR;
}
else
{ {
rc = IME_ERROR; rc = IME_ERROR;
} }
} }
// Calculate checksum CRC8 // Calculate checksum CRC8
if ( rc == IME_SUCCESS ) if ( rc == IME_SUCCESS )
{ {
pImageCtx->crc8 = ImeCrc8(pImageCtx->size, pImageCtx->pData); pImageCtx->crc8 = ImeCrc8(pImageCtx->size, pImageCtx->pData);
} }
if (pImageFile) {
if( pImageFile != NULL)
{
fclose(pImageFile); fclose(pImageFile);
} }
return rc; return rc;
} }
static uint8_t ImeCrc8( uint32_t length, uint8_t * pBuf ) static uint8_t ImeCrc8( uint32_t length, uint8_t * pBuf )
{ {
@ -988,13 +1002,16 @@ int ipmi_ime_main(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_DEBUG,"ipmi_ime_main()"); lprintf(LOG_DEBUG,"ipmi_ime_main()");
if (!argc || !strcmp(argv[0], "help")) { if ( (argc == 0) || (strcmp(argv[0], "help") == 0) )
{
ImePrintUsage(); ImePrintUsage();
} }
else if (!strcmp(argv[0], "info")) { else if ( (argc == 0) || (strcmp(argv[0], "info") == 0) )
{
rc = ImeGetInfo(intf); rc = ImeGetInfo(intf);
} }
else if (!strcmp(argv[0], "update")) { else if ( strcmp(argv[0], "update") == 0)
{
if(argc == 2) if(argc == 2)
{ {
lprintf(LOG_NOTICE,"Update using file: %s", argv[1]); lprintf(LOG_NOTICE,"Update using file: %s", argv[1]);
@ -1006,7 +1023,8 @@ int ipmi_ime_main(struct ipmi_intf * intf, int argc, char ** argv)
rc = IME_ERROR; rc = IME_ERROR;
} }
} }
else if (!strcmp(argv[0], "rollback")) { else if ( (argc == 0) || (strcmp(argv[0], "rollback") == 0) )
{
rc = ImeManualRollback(intf); rc = ImeManualRollback(intf);
} }
else else

View File

@ -29,6 +29,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.
*/ */
#define _XOPEN_SOURCE
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -83,7 +84,7 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */ data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command"); lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1; return -1;
} }
@ -91,7 +92,7 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
lprintf(LOG_ERR, "IPMI v1.5 Serial Over Lan (ISOL) not supported!"); lprintf(LOG_ERR, "IPMI v1.5 Serial Over Lan (ISOL) not supported!");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s", lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -107,11 +108,11 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */ data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command"); lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s", lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -127,11 +128,11 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */ data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command"); lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s", lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -192,12 +193,12 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/* /*
* enabled * enabled
*/ */
if (!strcmp(param, "enabled")) if (strcmp(param, "enabled") == 0)
{ {
data[1] = ISOL_ENABLE_PARAM; data[1] = ISOL_ENABLE_PARAM;
if (!strcmp(value, "true")) if (strcmp(value, "true") == 0)
data[2] = 0x01; data[2] = 0x01;
else if (!strcmp(value, "false")) else if (strcmp(value, "false") == 0)
data[2] = 0x00; data[2] = 0x00;
else { else {
lprintf(LOG_ERR, "Invalid value %s for parameter %s", lprintf(LOG_ERR, "Invalid value %s for parameter %s",
@ -210,7 +211,7 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/* /*
* privilege-level * privilege-level
*/ */
else if (!strcmp(param, "privilege-level")) else if (strcmp(param, "privilege-level") == 0)
{ {
data[1] = ISOL_AUTHENTICATION_PARAM; data[1] = ISOL_AUTHENTICATION_PARAM;
if (! strcmp(value, "user")) if (! strcmp(value, "user"))
@ -235,22 +236,22 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/* /*
* bit-rate * bit-rate
*/ */
else if (!strcmp(param, "bit-rate")) else if (strcmp(param, "bit-rate") == 0)
{ {
data[1] = ISOL_BAUD_RATE_PARAM; data[1] = ISOL_BAUD_RATE_PARAM;
if (!strcmp(value, "9.6")) { if (strncmp(value, "9.6", 3) == 0) {
data[2] = 0x06; data[2] = 0x06;
} }
else if (!strcmp(value, "19.2")) { else if (strncmp(value, "19.2", 4) == 0) {
data[2] = 0x07; data[2] = 0x07;
} }
else if (!strcmp(value, "38.4")) { else if (strncmp(value, "38.4", 4) == 0) {
data[2] = 0x08; data[2] = 0x08;
} }
else if (!strcmp(value, "57.6")) { else if (strncmp(value, "57.6", 4) == 0) {
data[2] = 0x09; data[2] = 0x09;
} }
else if (!strcmp(value, "115.2")) { else if (strncmp(value, "115.2", 5) == 0) {
data[2] = 0x0A; data[2] = 0x0A;
} }
else { else {
@ -271,11 +272,11 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
*/ */
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error setting ISOL parameter '%s'", param); lprintf(LOG_ERR, "Error setting ISOL parameter '%s'", param);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error setting ISOL parameter '%s': %s", lprintf(LOG_ERR, "Error setting ISOL parameter '%s': %s",
param, val2str(rsp->ccode, completion_code_vals)); param, val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -428,11 +429,11 @@ ipmi_isol_deactivate(struct ipmi_intf * intf)
data[5] = 0x00; data[5] = 0x00;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error deactivating ISOL"); lprintf(LOG_ERR, "Error deactivating ISOL");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error deactivating ISOL: %s", lprintf(LOG_ERR, "Error deactivating ISOL: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -572,7 +573,7 @@ ipmi_isol_red_pill(struct ipmi_intf * intf)
int timedout = 0; int timedout = 0;
buffer = (char*)malloc(buffer_size); buffer = (char*)malloc(buffer_size);
if (!buffer) { if (buffer == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1; return -1;
} }
@ -790,20 +791,20 @@ int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
/* /*
* Help * Help
*/ */
if (!argc || !strcmp(argv[0], "help")) if (!argc || !strncmp(argv[0], "help", 4))
print_isol_usage(); print_isol_usage();
/* /*
* Info * Info
*/ */
else if (!strcmp(argv[0], "info")) { else if (!strncmp(argv[0], "info", 4)) {
ret = ipmi_print_isol_info(intf); ret = ipmi_print_isol_info(intf);
} }
/* /*
* Set a parameter value * Set a parameter value
*/ */
else if (!strcmp(argv[0], "set")) { else if (!strncmp(argv[0], "set", 3)) {
if (argc < 3) { if (argc < 3) {
print_isol_set_usage(); print_isol_set_usage();
return -1; return -1;
@ -814,7 +815,7 @@ int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
/* /*
* Activate * Activate
*/ */
else if (!strcmp(argv[0], "activate")) { else if (!strncmp(argv[0], "activate", 8)) {
ret = ipmi_isol_activate(intf); ret = ipmi_isol_activate(intf);
} }

View File

@ -60,7 +60,8 @@ static void ipmi_kontron_help(void);
static int ipmi_kontron_set_serial_number(struct ipmi_intf *intf); static int ipmi_kontron_set_serial_number(struct ipmi_intf *intf);
static int ipmi_kontron_set_mfg_date (struct ipmi_intf *intf); static int ipmi_kontron_set_mfg_date (struct ipmi_intf *intf);
static void ipmi_kontron_nextboot_help(void); static void ipmi_kontron_nextboot_help(void);
static int ipmi_kontron_nextboot_set(struct ipmi_intf *intf, char **argv); static int ipmi_kontron_nextboot_set(struct ipmi_intf *intf, int argc,
char **argv);
static int ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf, static int ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf,
unsigned char channel, unsigned char size); unsigned char channel, unsigned char size);
@ -75,38 +76,38 @@ ipmi_kontronoem_main(struct ipmi_intf *intf, int argc, char **argv)
ipmi_kontron_help(); ipmi_kontron_help();
return (-1); return (-1);
} }
if (!strcmp(argv[0], "help")) { if (strncmp(argv[0], "help", 4) == 0) {
ipmi_kontron_help(); ipmi_kontron_help();
rc = 0; rc = 0;
} else if (!strcmp(argv[0], "setsn")) { } else if (!strncmp(argv[0], "setsn", 5)) {
if (argc < 1) { if (argc < 1) {
printf("fru setsn\n"); printf("fru setsn\n");
return (-1); return (-1);
} }
if (ipmi_kontron_set_serial_number(intf) > 0) { if (ipmi_kontron_set_serial_number(intf) > 0) {
printf("FRU serial number set successfully\n"); printf("FRU serial number setted successfully\n");
} else { } else {
printf("FRU serial number set failed\n"); printf("FRU serial number set failed\n");
rc = (-1); rc = (-1);
} }
} else if (!strcmp(argv[0], "setmfgdate")) { } else if (!strncmp(argv[0], "setmfgdate", 10)) {
if (argc < 1) { if (argc < 1) {
printf("fru setmfgdate\n"); printf("fru setmfgdate\n");
return (-1); return (-1);
} }
if (ipmi_kontron_set_mfg_date(intf) > 0) { if (ipmi_kontron_set_mfg_date(intf) > 0) {
printf("FRU manufacturing date set successfully\n"); printf("FRU manufacturing date setted successfully\n");
} else { } else {
printf("FRU manufacturing date set failed\n"); printf("FRU manufacturing date set failed\n");
rc = (-1); rc = (-1);
} }
} else if (!strcmp(argv[0], "nextboot")) { } else if (!strncmp(argv[0], "nextboot", 8)) {
if (argc < 2) { if (argc < 2) {
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
ipmi_kontron_nextboot_help(); ipmi_kontron_nextboot_help();
return (-1); return (-1);
} }
rc = ipmi_kontron_nextboot_set(intf, (argv + 1)); rc = ipmi_kontron_nextboot_set(intf, (argc - 1), (argv + 1));
if (rc == 0) { if (rc == 0) {
printf("Nextboot set successfully\n"); printf("Nextboot set successfully\n");
} else { } else {
@ -187,10 +188,10 @@ ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf,
req.msg.data_len = 2; req.msg.data_len = 2;
req.msg.lun = 0x00; req.msg.lun = 0x00;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf("Cannot send large buffer command\n"); printf("Cannot send large buffer command\n");
return(-1); return(-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf("Invalid length for the selected interface (%s) %d\n", printf("Invalid length for the selected interface (%s) %d\n",
val2str(rsp->ccode, completion_code_vals), rsp->ccode); val2str(rsp->ccode, completion_code_vals), rsp->ccode);
return(-1); return(-1);
@ -242,16 +243,16 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Set Lun, necessary for this oem command */ /* Set Lun, necessary for this oem command */
req.msg.lun = 0x03; req.msg.lun = 0x03;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf(" Device not present (No Response)\n"); printf(" Device not present (No Response)\n");
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf(" This option is not implemented for this board\n"); printf(" This option is not implemented for this board\n");
return (-1); return (-1);
} }
sn_size = rsp->data_len; sn_size = rsp->data_len;
sn = malloc(sn_size + 1); sn = malloc(sn_size + 1);
if (!sn) { if (sn == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return (-1); return (-1);
} }
@ -268,12 +269,12 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
req.msg.data = msg_data; req.msg.data = msg_data;
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf(" Device not present (No Response)\n"); printf(" Device not present (No Response)\n");
free(sn); free(sn);
sn = NULL; sn = NULL;
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n", printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
free(sn); free(sn);
@ -301,12 +302,12 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
req.msg.data = msg_data; req.msg.data = msg_data;
req.msg.data_len = 4; req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf(" Device not present (No Response)\n"); printf(" Device not present (No Response)\n");
free(sn); free(sn);
sn = NULL; sn = NULL;
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n", printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
free(sn); free(sn);
@ -327,7 +328,7 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Set the Board Section */ /* Set the Board Section */
board_sec_len = (header.offset.product * 8) - (header.offset.board * 8); board_sec_len = (header.offset.product * 8) - (header.offset.board * 8);
fru_data = malloc(fru.size); fru_data = malloc(fru.size);
if (!fru_data) { if (fru_data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
free(sn); free(sn);
sn = NULL; sn = NULL;
@ -345,20 +346,20 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Position at Board Manufacturer */ /* Position at Board Manufacturer */
fru_data_offset = (header.offset.board * 8) + 6; fru_data_offset = (header.offset.board * 8) + 6;
fru_area = get_fru_area_str(fru_data, &fru_data_offset); fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) { if (fru_area != NULL) {
free(fru_area); free(fru_area);
fru_area = NULL; fru_area = NULL;
} }
/* Position at Board Product Name */ /* Position at Board Product Name */
fru_area = get_fru_area_str(fru_data, &fru_data_offset); fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) { if (fru_area != NULL) {
free(fru_area); free(fru_area);
fru_area = NULL; fru_area = NULL;
} }
fru_data_offset_tmp = fru_data_offset; fru_data_offset_tmp = fru_data_offset;
/* Position at Serial Number */ /* Position at Serial Number */
fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp); fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp);
if (!fru_area) { if (fru_area == NULL) {
lprintf(LOG_ERR, "Failed to read FRU Area string."); lprintf(LOG_ERR, "Failed to read FRU Area string.");
free(fru_data); free(fru_data);
fru_data = NULL; fru_data = NULL;
@ -419,32 +420,32 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Position at Product Manufacturer */ /* Position at Product Manufacturer */
fru_data_offset = (header.offset.product * 8) + 3; fru_data_offset = (header.offset.product * 8) + 3;
fru_area = get_fru_area_str(fru_data, &fru_data_offset); fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) { if (fru_area != NULL) {
free(fru_area); free(fru_area);
fru_area = NULL; fru_area = NULL;
} }
/* Position at Product Name */ /* Position at Product Name */
fru_area = get_fru_area_str(fru_data, &fru_data_offset); fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) { if (fru_area != NULL) {
free(fru_area); free(fru_area);
fru_area = NULL; fru_area = NULL;
} }
/* Position at Product Part */ /* Position at Product Part */
fru_area = get_fru_area_str(fru_data, &fru_data_offset); fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) { if (fru_area != NULL) {
free(fru_area); free(fru_area);
fru_area = NULL; fru_area = NULL;
} }
/* Position at Product Version */ /* Position at Product Version */
fru_area = get_fru_area_str(fru_data, &fru_data_offset); fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) { if (fru_area != NULL) {
free(fru_area); free(fru_area);
fru_area = NULL; fru_area = NULL;
} }
fru_data_offset_tmp = fru_data_offset; fru_data_offset_tmp = fru_data_offset;
/* Position at Serial Number */ /* Position at Serial Number */
fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp); fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp);
if (!fru_area) { if (fru_area == NULL) {
lprintf(LOG_ERR, "Failed to read FRU Area string."); lprintf(LOG_ERR, "Failed to read FRU Area string.");
free(sn); free(sn);
sn = NULL; sn = NULL;
@ -531,10 +532,10 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
/* Set Lun temporary, necessary for this oem command */ /* Set Lun temporary, necessary for this oem command */
req.msg.lun = 0x03; req.msg.lun = 0x03;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf("Device not present (No Response)\n"); printf("Device not present (No Response)\n");
return(-1); return(-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf("This option is not implemented for this board\n"); printf("This option is not implemented for this board\n");
return(-1); return(-1);
} }
@ -553,10 +554,10 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
req.msg.data = msg_data; req.msg.data = msg_data;
req.msg.data_len = 1; req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf(" Device not present (No Response)\n"); printf(" Device not present (No Response)\n");
return(-1); return(-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n", printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return(-1); return(-1);
@ -581,10 +582,10 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
req.msg.data = msg_data; req.msg.data = msg_data;
req.msg.data_len = 4; req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf(" Device not present (No Response)\n"); printf(" Device not present (No Response)\n");
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n", printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return (-1); return (-1);
@ -600,7 +601,7 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
} }
board_sec_len = (header.offset.product * 8) - (header.offset.board * 8); board_sec_len = (header.offset.product * 8) - (header.offset.board * 8);
fru_data = malloc(fru.size); fru_data = malloc(fru.size);
if (!fru_data) { if(fru_data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return(-1); return(-1);
} }
@ -655,7 +656,7 @@ ipmi_kontron_nextboot_help(void)
* returns 1 if successful * returns 1 if successful
*/ */
static int static int
ipmi_kontron_nextboot_set(struct ipmi_intf *intf, char **argv) ipmi_kontron_nextboot_set(struct ipmi_intf *intf, int argc, char **argv)
{ {
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -671,7 +672,7 @@ ipmi_kontron_nextboot_set(struct ipmi_intf *intf, char **argv)
msg_data[5] = 0xFF; msg_data[5] = 0xFF;
msg_data[6] = 0xFF; /* any */ msg_data[6] = 0xFF; /* any */
for (i = 0; bootdev[i] != 0; i++) { for (i = 0; bootdev[i] != 0; i++) {
if (!strcmp(argv[0], bootdev[i])) { if (strcmp(argv[0], bootdev[i]) == 0) {
msg_data[5] = i; msg_data[5] = i;
break; break;
} }
@ -689,10 +690,10 @@ ipmi_kontron_nextboot_set(struct ipmi_intf *intf, char **argv)
/* Set Lun temporary, necessary for this oem command */ /* Set Lun temporary, necessary for this oem command */
req.msg.lun = 0x03; req.msg.lun = 0x03;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
printf("Device not present (No Response)\n"); printf("Device not present (No Response)\n");
return(-1); return(-1);
} else if (rsp->ccode) { } else if (rsp->ccode > 0) {
printf("Device not present (%s)\n", printf("Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return (-1); return (-1);

File diff suppressed because it is too large Load Diff

View File

@ -333,7 +333,7 @@ ipmi_lanp_err(const struct ipmi_rs *rsp, const struct ipmi_lanp *p,
int log_level = LOG_ERR; int log_level = LOG_ERR;
int err; int err;
if (!rsp) { if (rsp == NULL) {
reason = "No response"; reason = "No response";
err = -1; err = -1;
} else { } else {
@ -354,7 +354,7 @@ ipmi_lanp_err(const struct ipmi_rs *rsp, const struct ipmi_lanp *p,
reason = val2str(rsp->ccode, lanp_cc_vals); reason = val2str(rsp->ccode, lanp_cc_vals);
} }
if (!reason) { if (reason == NULL) {
/* print completion code value */ /* print completion code value */
snprintf(cc_msg, sizeof(cc_msg), "CC=%02x", rsp->ccode); snprintf(cc_msg, sizeof(cc_msg), "CC=%02x", rsp->ccode);
reason = cc_msg; reason = cc_msg;
@ -403,7 +403,7 @@ ipmi_get_dynamic_oem_lanp(void *priv, const struct ipmi_lanp *param,
param->name, set_selector, block_selector); param->name, set_selector, block_selector);
rsp = lp->intf->sendrecv(lp->intf, &req); rsp = lp->intf->sendrecv(lp->intf, &req);
if (!rsp || rsp->ccode) { if (rsp == NULL || rsp->ccode) {
return ipmi_lanp_err(rsp, param, "get", quiet); return ipmi_lanp_err(rsp, param, "get", quiet);
} }
@ -467,7 +467,7 @@ ipmi_set_dynamic_oem_lanp(void *priv, const struct ipmi_lanp *param,
lprintf(LOG_INFO, "Setting parameter '%s'", param->name); lprintf(LOG_INFO, "Setting parameter '%s'", param->name);
rsp = lp->intf->sendrecv(lp->intf, &req); rsp = lp->intf->sendrecv(lp->intf, &req);
if (!rsp || rsp->ccode) { if (rsp == NULL || rsp->ccode) {
return ipmi_lanp_err(rsp, param, "set", 0); return ipmi_lanp_err(rsp, param, "set", 0);
} }
@ -1027,7 +1027,9 @@ static void lanp_print_usage(int cmd)
printf("\n available parameters:\n"); printf("\n available parameters:\n");
/* 'save' shall use 'write' filter, since it outputs a block /* 'save' shall use 'write' filter, since it outputs a block
* of 'set's */ * of 'set's */
ipmi_cfgp_usage(lan_cfgp, ARRAY_SIZE(lan_cfgp), cmd != LANP_CMD_PRINT); ipmi_cfgp_usage(lan_cfgp,
sizeof(lan_cfgp)/sizeof(lan_cfgp[0]),
cmd != LANP_CMD_PRINT);
} }
} }
@ -1159,8 +1161,8 @@ ipmi_lan6_main(struct ipmi_intf *intf, int argc, char **argv)
*/ */
ipmi_cfgp_init(&ctx, lan_cfgp, ipmi_cfgp_init(&ctx, lan_cfgp,
ARRAY_SIZE(lan_cfgp), "lan6 set nolock", sizeof(lan_cfgp)/sizeof(lan_cfgp[0]), "lan6 set nolock",
lanp_ip6_cfgp, &lp); lanp_ip6_cfgp, &lp);
ret = ipmi_cfgp_parse_sel(&ctx, argc, (const char **)argv, &sel); ret = ipmi_cfgp_parse_sel(&ctx, argc, (const char **)argv, &sel);
if (ret == -1) { if (ret == -1) {

View File

@ -29,6 +29,11 @@
* 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.
*/ */
#define _XOPEN_SOURCE 700
#define _BSD_SOURCE || \
(_XOPEN_SOURCE >= 500 || \
_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \
!(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -42,7 +47,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <ctype.h> #include <ctype.h>
#include <locale.h>
#include <ipmitool/helper.h> #include <ipmitool/helper.h>
#include <ipmitool/log.h> #include <ipmitool/log.h>
@ -66,20 +70,18 @@
#include <ipmitool/ipmi_user.h> #include <ipmitool/ipmi_user.h>
#include <ipmitool/ipmi_raw.h> #include <ipmitool/ipmi_raw.h>
#include <ipmitool/ipmi_pef.h> #include <ipmitool/ipmi_pef.h>
#include <ipmitool/ipmi_time.h>
#include <ipmitool/ipmi_oem.h> #include <ipmitool/ipmi_oem.h>
#include <ipmitool/ipmi_ekanalyzer.h> #include <ipmitool/ipmi_ekanalyzer.h>
#include <ipmitool/ipmi_picmg.h> #include <ipmitool/ipmi_picmg.h>
#include <ipmitool/ipmi_kontronoem.h> #include <ipmitool/ipmi_kontronoem.h>
#include <ipmitool/ipmi_vita.h> #include <ipmitool/ipmi_vita.h>
#include <ipmitool/ipmi_quantaoem.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#ifdef ENABLE_ALL_OPTIONS #ifdef ENABLE_ALL_OPTIONS
# define OPTION_STRING "I:46hVvcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:z:S:l:b:B:e:k:y:O:R:N:D:Z" # define OPTION_STRING "I:46hVvcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:z:S:l:b:B:e:k:y:O:R:N:D:"
#else #else
# define OPTION_STRING "I:46hVvcH:f:U:p:d:S:D:" # define OPTION_STRING "I:46hVvcH:f:U:p:d:S:D:"
#endif #endif
@ -88,6 +90,8 @@
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);
extern int verbose;
extern int csv_output;
extern const struct valstr ipmi_privlvl_vals[]; extern const struct valstr ipmi_privlvl_vals[];
extern const struct valstr ipmi_authtype_session_vals[]; extern const struct valstr ipmi_authtype_session_vals[];
@ -109,14 +113,14 @@ ipmi_password_file_read(char * filename)
int l; int l;
pass = malloc(21); pass = malloc(21);
if (!pass) { if (pass == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return NULL; return NULL;
} }
memset(pass, 0, 21); memset(pass, 0, 21);
fp = ipmi_open_file_read((const char *)filename); fp = ipmi_open_file_read((const char *)filename);
if (!fp) { if (fp == NULL) {
lprintf(LOG_ERR, "Unable to open password file %s", lprintf(LOG_ERR, "Unable to open password file %s",
filename); filename);
free(pass); free(pass);
@ -124,7 +128,7 @@ ipmi_password_file_read(char * filename)
} }
/* read in id */ /* read in id */
if (!fgets(pass, 21, fp)) { if (fgets(pass, 21, fp) == NULL) {
lprintf(LOG_ERR, "Unable to read password from file %s", lprintf(LOG_ERR, "Unable to read password from file %s",
filename); filename);
free(pass); free(pass);
@ -153,10 +157,10 @@ ipmi_cmd_print(struct ipmi_cmd * cmdlist)
struct ipmi_cmd * cmd; struct ipmi_cmd * cmd;
int hdr = 0; int hdr = 0;
if (!cmdlist) if (cmdlist == NULL)
return; return;
for (cmd=cmdlist; cmd->func; cmd++) { for (cmd=cmdlist; cmd->func != NULL; cmd++) {
if (!cmd->desc) if (cmd->desc == NULL)
continue; continue;
if (hdr == 0) { if (hdr == 0) {
lprintf(LOG_NOTICE, "Commands:"); lprintf(LOG_NOTICE, "Commands:");
@ -178,7 +182,7 @@ ipmi_cmd_print(struct ipmi_cmd * cmdlist)
* @argc: command argument count * @argc: command argument count
* @argv: command argument list * @argv: command argument list
* *
* returns value from func() of that command if found * returns value from func() of that commnad if found
* returns -1 if command is not found * returns -1 if command is not found
*/ */
int int
@ -187,25 +191,25 @@ ipmi_cmd_run(struct ipmi_intf * intf, char * name, int argc, char ** argv)
struct ipmi_cmd * cmd = intf->cmdlist; struct ipmi_cmd * cmd = intf->cmdlist;
/* hook to run a default command if nothing specified */ /* hook to run a default command if nothing specified */
if (!name) { if (name == NULL) {
if (!cmd->func || !cmd->name) if (cmd->func == NULL || cmd->name == NULL)
return -1; return -1;
else if (strncmp(cmd->name, "default", 7) == 0)
if (!strcmp(cmd->name, "default"))
return cmd->func(intf, 0, NULL); return cmd->func(intf, 0, NULL);
else {
lprintf(LOG_ERR, "No command provided!"); lprintf(LOG_ERR, "No command provided!");
ipmi_cmd_print(intf->cmdlist); ipmi_cmd_print(intf->cmdlist);
return -1; return -1;
}
} }
for (cmd=intf->cmdlist; cmd->func; cmd++) { for (cmd=intf->cmdlist; cmd->func != NULL; cmd++) {
if (!strcmp(name, cmd->name)) if (strncmp(name, cmd->name, __maxlen(cmd->name, name)) == 0)
break; break;
} }
if (!cmd->func) { if (cmd->func == NULL) {
cmd = intf->cmdlist; cmd = intf->cmdlist;
if (!strcmp(cmd->name, "default")) if (strncmp(cmd->name, "default", 7) == 0)
return cmd->func(intf, argc+1, argv-1); return cmd->func(intf, argc+1, argv-1);
lprintf(LOG_ERR, "Invalid command: %s", name); lprintf(LOG_ERR, "Invalid command: %s", name);
@ -259,13 +263,12 @@ ipmi_option_usage(const char * progname, struct ipmi_cmd * cmdlist, struct ipmi_
lprintf(LOG_NOTICE, " -O seloem Use file for OEM SEL event descriptions"); lprintf(LOG_NOTICE, " -O seloem Use file for OEM SEL event descriptions");
lprintf(LOG_NOTICE, " -N seconds Specify timeout for lan [default=2] / lanplus [default=1] interface"); lprintf(LOG_NOTICE, " -N seconds Specify timeout for lan [default=2] / lanplus [default=1] interface");
lprintf(LOG_NOTICE, " -R retry Set the number of retries for lan/lanplus interface [default=4]"); lprintf(LOG_NOTICE, " -R retry Set the number of retries for lan/lanplus interface [default=4]");
lprintf(LOG_NOTICE, " -Z Display all dates in UTC");
#endif #endif
lprintf(LOG_NOTICE, ""); lprintf(LOG_NOTICE, "");
ipmi_intf_print(intflist); ipmi_intf_print(intflist);
if (cmdlist) if (cmdlist != NULL)
ipmi_cmd_print(cmdlist); ipmi_cmd_print(cmdlist);
} }
/* ipmi_catch_sigint - Handle the interrupt signal (Ctrl-C), close the /* ipmi_catch_sigint - Handle the interrupt signal (Ctrl-C), close the
@ -278,7 +281,7 @@ ipmi_option_usage(const char * progname, struct ipmi_cmd * cmdlist, struct ipmi_
*/ */
void ipmi_catch_sigint() void ipmi_catch_sigint()
{ {
if (ipmi_main_intf) { if (ipmi_main_intf != NULL) {
printf("\nSIGN INT: Close Interface %s\n",ipmi_main_intf->desc); printf("\nSIGN INT: Close Interface %s\n",ipmi_main_intf->desc);
/* reduce retry count to a single retry */ /* reduce retry count to a single retry */
ipmi_main_intf->ssn_params.retry = 1; ipmi_main_intf->ssn_params.retry = 1;
@ -320,7 +323,6 @@ ipmi_main(int argc, char ** argv,
uint8_t target_addr = 0; uint8_t target_addr = 0;
uint8_t target_channel = 0; uint8_t target_channel = 0;
uint8_t u8tmp = 0;
uint8_t transit_addr = 0; uint8_t transit_addr = 0;
uint8_t transit_channel = 0; uint8_t transit_channel = 0;
uint8_t target_lun = 0; uint8_t target_lun = 0;
@ -345,29 +347,19 @@ ipmi_main(int argc, char ** argv,
char * seloem = NULL; char * seloem = NULL;
int port = 0; int port = 0;
int devnum = 0; int devnum = 0;
#ifdef IPMI_INTF_LANPLUS int cipher_suite_id = 3; /* See table 22-19 of the IPMIv2 spec */
/* lookup best cipher suite available */
enum cipher_suite_ids cipher_suite_id = IPMI_LANPLUS_CIPHER_SUITE_RESERVED;
#endif /* IPMI_INTF_LANPLUS */
int argflag, i, found; int argflag, i, found;
int rc = -1; int rc = -1;
int ai_family = AF_UNSPEC; int ai_family = AF_UNSPEC;
char sol_escape_char = SOL_ESCAPE_CHARACTER_DEFAULT; char sol_escape_char = SOL_ESCAPE_CHARACTER_DEFAULT;
char * devfile = NULL; char * devfile = NULL;
/* Set program locale according to system settings */
setlocale(LC_ALL, "");
/* save program name */ /* save program name */
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = ((!progname) ? argv[0] : progname+1); progname = ((progname == NULL) ? argv[0] : progname+1);
signal(SIGINT, ipmi_catch_sigint); signal(SIGINT, ipmi_catch_sigint);
memset(kgkey, 0, sizeof(kgkey)); memset(kgkey, 0, sizeof(kgkey));
/* setup log */
log_init(progname, 0, 0);
while ((argflag = getopt(argc, (char **)argv, OPTION_STRING)) != -1) while ((argflag = getopt(argc, (char **)argv, OPTION_STRING)) != -1)
{ {
switch (argflag) { switch (argflag) {
@ -377,18 +369,17 @@ ipmi_main(int argc, char ** argv,
intfname = NULL; intfname = NULL;
} }
intfname = strdup(optarg); intfname = strdup(optarg);
if (!intfname) { if (intfname == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
if (intflist) { if (intflist != NULL) {
found = 0; found = 0;
for (sup=intflist; sup->name; sup++) { for (sup=intflist; sup->name != NULL; sup++) {
if (!strcmp(sup->name, intfname) if (strncmp(sup->name, intfname, strlen(intfname)) == 0 &&
&& sup->supported) strncmp(sup->name, intfname, strlen(sup->name)) == 0 &&
{ sup->supported == 1)
found = 1; found = 1;
}
} }
if (!found) { if (!found) {
lprintf(LOG_ERR, "Interface %s not supported", intfname); lprintf(LOG_ERR, "Interface %s not supported", intfname);
@ -434,25 +425,22 @@ ipmi_main(int argc, char ** argv,
goto out_free; goto out_free;
} }
break; break;
#ifdef IPMI_INTF_LANPLUS
case 'C': case 'C':
/* Cipher Suite ID is a byte as per IPMI specification */ if (str2int(optarg, &cipher_suite_id) != 0) {
if (str2uchar(optarg, &u8tmp) != 0) { lprintf(LOG_ERR, "Invalid parameter given or out of range for '-C'.");
lprintf(LOG_ERR, "Invalid parameter given or out of "
"range [0-255] for '-C'.");
rc = -1; rc = -1;
goto out_free; goto out_free;
} }
cipher_suite_id = u8tmp; /* add check Cipher is -gt 0 */
break; if (cipher_suite_id < 0) {
#endif /* IPMI_INTF_LANPLUS */ lprintf(LOG_ERR, "Cipher suite ID %i is invalid.", cipher_suite_id);
case 'v': rc = -1;
log_level_set(++verbose); goto out_free;
if (verbose == 2) {
/* add version info to debug output */
lprintf(LOG_DEBUG, "%s version %s\n", progname, VERSION);
} }
break; break;
case 'v':
verbose++;
break;
case 'c': case 'c':
csv_output = 1; csv_output = 1;
break; break;
@ -462,7 +450,7 @@ ipmi_main(int argc, char ** argv,
hostname = NULL; hostname = NULL;
} }
hostname = strdup(optarg); hostname = strdup(optarg);
if (!hostname) { if (hostname == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -473,7 +461,7 @@ ipmi_main(int argc, char ** argv,
password = NULL; password = NULL;
} }
password = ipmi_password_file_read(optarg); password = ipmi_password_file_read(optarg);
if (!password) if (password == NULL)
lprintf(LOG_ERR, "Unable to read password " lprintf(LOG_ERR, "Unable to read password "
"from file %s", optarg); "from file %s", optarg);
break; break;
@ -483,14 +471,14 @@ ipmi_main(int argc, char ** argv,
#else #else
tmp_pass = getpass("Password: "); tmp_pass = getpass("Password: ");
#endif #endif
if (tmp_pass) { if (tmp_pass != NULL) {
if (password) { if (password) {
free(password); free(password);
password = NULL; password = NULL;
} }
password = strdup(tmp_pass); password = strdup(tmp_pass);
tmp_pass = NULL; tmp_pass = NULL;
if (!password) { if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -530,7 +518,7 @@ ipmi_main(int argc, char ** argv,
#else #else
tmp_pass = getpass("Key: "); tmp_pass = getpass("Key: ");
#endif #endif
if (tmp_pass) { if (tmp_pass != NULL) {
memset(kgkey, 0, sizeof(kgkey)); memset(kgkey, 0, sizeof(kgkey));
strncpy((char *)kgkey, tmp_pass, strncpy((char *)kgkey, tmp_pass,
sizeof(kgkey) - 1); sizeof(kgkey) - 1);
@ -547,7 +535,7 @@ ipmi_main(int argc, char ** argv,
goto out_free; goto out_free;
} }
username = strdup(optarg); username = strdup(optarg);
if (!username) { if (username == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -558,7 +546,7 @@ ipmi_main(int argc, char ** argv,
sdrcache = NULL; sdrcache = NULL;
} }
sdrcache = strdup(optarg); sdrcache = strdup(optarg);
if (!sdrcache) { if (sdrcache == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -570,7 +558,7 @@ ipmi_main(int argc, char ** argv,
free(devfile); free(devfile);
} }
devfile = strdup(optarg); devfile = strdup(optarg);
if (!devfile) { if (devfile == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -614,13 +602,12 @@ ipmi_main(int argc, char ** argv,
oemtype = NULL; oemtype = NULL;
} }
oemtype = strdup(optarg); oemtype = strdup(optarg);
if (!oemtype) { if (oemtype == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
if (!strcmp(oemtype, "list") if (strncmp(oemtype, "list", 4) == 0 ||
|| !strcmp(oemtype, "help")) strncmp(oemtype, "help", 4) == 0) {
{
ipmi_oem_print(); ipmi_oem_print();
rc = 0; rc = 0;
goto out_free; goto out_free;
@ -648,7 +635,7 @@ ipmi_main(int argc, char ** argv,
password = NULL; password = NULL;
} }
password = strdup(optarg); password = strdup(optarg);
if (!password) { if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -664,7 +651,7 @@ ipmi_main(int argc, char ** argv,
password = NULL; password = NULL;
} }
password = strdup(tmp_env); password = strdup(tmp_env);
if (!password) { if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -675,7 +662,7 @@ ipmi_main(int argc, char ** argv,
password = NULL; password = NULL;
} }
password = strdup(tmp_env); password = strdup(tmp_env);
if (!password) { if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -749,7 +736,7 @@ ipmi_main(int argc, char ** argv,
seloem = NULL; seloem = NULL;
} }
seloem = strdup(optarg); seloem = strdup(optarg);
if (!seloem) { if (seloem == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -776,9 +763,6 @@ ipmi_main(int argc, char ** argv,
goto out_free; goto out_free;
} }
break; break;
case 'Z':
time_in_utc = 1;
break;
#endif #endif
default: default:
ipmi_option_usage(progname, cmdlist, intflist); ipmi_option_usage(progname, cmdlist, intflist);
@ -787,9 +771,8 @@ ipmi_main(int argc, char ** argv,
} }
/* check for command before doing anything */ /* check for command before doing anything */
if (argc-optind > 0 if (argc-optind > 0 &&
&& !strcmp(argv[optind], "help")) strncmp(argv[optind], "help", 4) == 0) {
{
ipmi_cmd_print(cmdlist); ipmi_cmd_print(cmdlist);
rc = 0; rc = 0;
goto out_free; goto out_free;
@ -803,17 +786,17 @@ ipmi_main(int argc, char ** argv,
* and the authtype was not explicitly set to NONE * and the authtype was not explicitly set to NONE
* then prompt the user. * then prompt the user.
*/ */
if (hostname && !password && if (hostname != NULL && password == NULL &&
(authtype != IPMI_SESSION_AUTHTYPE_NONE || authtype < 0)) { (authtype != IPMI_SESSION_AUTHTYPE_NONE || authtype < 0)) {
#ifdef HAVE_GETPASSPHRASE #ifdef HAVE_GETPASSPHRASE
tmp_pass = getpassphrase("Password: "); tmp_pass = getpassphrase("Password: ");
#else #else
tmp_pass = getpass("Password: "); tmp_pass = getpass("Password: ");
#endif #endif
if (tmp_pass) { if (tmp_pass != NULL) {
password = strdup(tmp_pass); password = strdup(tmp_pass);
tmp_pass = NULL; tmp_pass = NULL;
if (!password) { if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
@ -825,49 +808,49 @@ ipmi_main(int argc, char ** argv,
* otherwise the default is hardcoded * otherwise the default is hardcoded
* to use the first entry in the list * to use the first entry in the list
*/ */
if (!intfname && hostname) { if (intfname == NULL && hostname != NULL) {
intfname = strdup("lan"); intfname = strdup("lan");
if (!intfname) { if (intfname == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname); lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free; goto out_free;
} }
} }
if (password && intfname) { if (password != NULL && intfname != NULL) {
if (!strcmp(intfname, "lan") && strlen(password) > 16) { if (strcmp(intfname, "lan") == 0 && strlen(password) > 16) {
lprintf(LOG_ERR, "%s: password is longer than 16 bytes.", intfname); lprintf(LOG_ERR, "%s: password is longer than 16 bytes.", intfname);
rc = -1; rc = -1;
goto out_free; goto out_free;
} else if (!strcmp(intfname, "lanplus") && strlen(password) > 20) { } else if (strcmp(intfname, "lanplus") == 0 && strlen(password) > 20) {
lprintf(LOG_ERR, "%s: password is longer than 20 bytes.", intfname); lprintf(LOG_ERR, "%s: password is longer than 20 bytes.", intfname);
rc = -1; rc = -1;
goto out_free; goto out_free;
} }
} } /* if (password != NULL && intfname != NULL) */
/* load interface */ /* load interface */
ipmi_main_intf = ipmi_intf_load(intfname); ipmi_main_intf = ipmi_intf_load(intfname);
if (!ipmi_main_intf) { if (ipmi_main_intf == NULL) {
lprintf(LOG_ERR, "Error loading interface %s", intfname); lprintf(LOG_ERR, "Error loading interface %s", intfname);
goto out_free; goto out_free;
} }
/* load the IANA PEN registry */ /* setup log */
ipmi_oem_info_init(); log_init(progname, 0, verbose);
/* run OEM setup if found */ /* run OEM setup if found */
if (oemtype && if (oemtype != NULL &&
ipmi_oem_setup(ipmi_main_intf, oemtype) < 0) { ipmi_oem_setup(ipmi_main_intf, oemtype) < 0) {
lprintf(LOG_ERR, "OEM setup for \"%s\" failed", oemtype); lprintf(LOG_ERR, "OEM setup for \"%s\" failed", oemtype);
goto out_free; goto out_free;
} }
/* set session variables */ /* set session variables */
if (hostname) if (hostname != NULL)
ipmi_intf_session_set_hostname(ipmi_main_intf, hostname); ipmi_intf_session_set_hostname(ipmi_main_intf, hostname);
if (username) if (username != NULL)
ipmi_intf_session_set_username(ipmi_main_intf, username); ipmi_intf_session_set_username(ipmi_main_intf, username);
if (password) if (password != NULL)
ipmi_intf_session_set_password(ipmi_main_intf, password); ipmi_intf_session_set_password(ipmi_main_intf, password);
ipmi_intf_session_set_kgkey(ipmi_main_intf, kgkey); ipmi_intf_session_set_kgkey(ipmi_main_intf, kgkey);
if (port > 0) if (port > 0)
@ -887,9 +870,7 @@ ipmi_main(int argc, char ** argv,
ipmi_intf_session_set_lookupbit(ipmi_main_intf, lookupbit); ipmi_intf_session_set_lookupbit(ipmi_main_intf, lookupbit);
ipmi_intf_session_set_sol_escape_char(ipmi_main_intf, sol_escape_char); ipmi_intf_session_set_sol_escape_char(ipmi_main_intf, sol_escape_char);
#ifdef IPMI_INTF_LANPLUS
ipmi_intf_session_set_cipher_suite_id(ipmi_main_intf, cipher_suite_id); ipmi_intf_session_set_cipher_suite_id(ipmi_main_intf, cipher_suite_id);
#endif /* IPMI_INTF_LANPLUS */
ipmi_main_intf->devnum = devnum; ipmi_main_intf->devnum = devnum;
@ -899,7 +880,7 @@ ipmi_main(int argc, char ** argv,
ipmi_main_intf->ai_family = ai_family; ipmi_main_intf->ai_family = ai_family;
/* Open the interface with the specified or default IPMB address */ /* Open the interface with the specified or default IPMB address */
ipmi_main_intf->my_addr = arg_addr ? arg_addr : IPMI_BMC_SLAVE_ADDR; ipmi_main_intf->my_addr = arg_addr ? arg_addr : IPMI_BMC_SLAVE_ADDR;
if (ipmi_main_intf->open) { if (ipmi_main_intf->open != NULL) {
if (ipmi_main_intf->open(ipmi_main_intf) < 0) { if (ipmi_main_intf->open(ipmi_main_intf) < 0) {
goto out_free; goto out_free;
} }
@ -994,11 +975,11 @@ ipmi_main(int argc, char ** argv,
ipmi_main_intf->target_ipmb_addr); ipmi_main_intf->target_ipmb_addr);
/* parse local SDR cache if given */ /* parse local SDR cache if given */
if (sdrcache) { if (sdrcache != NULL) {
ipmi_sdr_list_cache_fromfile(sdrcache); ipmi_sdr_list_cache_fromfile(ipmi_main_intf, sdrcache);
} }
/* Parse SEL OEM file if given */ /* Parse SEL OEM file if given */
if (seloem) { if (seloem != NULL) {
ipmi_sel_oem_init(seloem); ipmi_sel_oem_init(seloem);
} }
@ -1035,37 +1016,37 @@ ipmi_main(int argc, char ** argv,
ipmi_cleanup(ipmi_main_intf); ipmi_cleanup(ipmi_main_intf);
/* call interface close function if available */ /* call interface close function if available */
if (ipmi_main_intf->opened && ipmi_main_intf->close) if (ipmi_main_intf->opened > 0 && ipmi_main_intf->close != NULL)
ipmi_main_intf->close(ipmi_main_intf); ipmi_main_intf->close(ipmi_main_intf);
out_free: out_free:
log_halt(); log_halt();
if (intfname) { if (intfname != NULL) {
free(intfname); free(intfname);
intfname = NULL; intfname = NULL;
} }
if (hostname) { if (hostname != NULL) {
free(hostname); free(hostname);
hostname = NULL; hostname = NULL;
} }
if (username) { if (username != NULL) {
free(username); free(username);
username = NULL; username = NULL;
} }
if (password) { if (password != NULL) {
free(password); free(password);
password = NULL; password = NULL;
} }
if (oemtype) { if (oemtype != NULL) {
free(oemtype); free(oemtype);
oemtype = NULL; oemtype = NULL;
} }
if (seloem) { if (seloem != NULL) {
free(seloem); free(seloem);
seloem = NULL; seloem = NULL;
} }
if (sdrcache) { if (sdrcache != NULL) {
free(sdrcache); free(sdrcache);
sdrcache = NULL; sdrcache = NULL;
} }
@ -1074,8 +1055,6 @@ ipmi_main(int argc, char ** argv,
devfile = NULL; devfile = NULL;
} }
ipmi_oem_info_free();
return rc; return rc;
} }

File diff suppressed because it is too large Load Diff

View File

@ -37,9 +37,8 @@
#include <ipmitool/helper.h> #include <ipmitool/helper.h>
#include <ipmitool/ipmi_sel.h> #include <ipmitool/ipmi_sel.h>
static int ipmi_oem_supermicro(struct ipmi_intf *intf); static int ipmi_oem_supermicro(struct ipmi_intf * intf);
static int ipmi_oem_ibm(struct ipmi_intf *intf); static int ipmi_oem_ibm(struct ipmi_intf * intf);
static int ipmi_oem_quanta(struct ipmi_intf *intf);
static struct ipmi_oem_handle ipmi_oem_list[] = { static struct ipmi_oem_handle ipmi_oem_list[] = {
{ {
@ -72,49 +71,36 @@ static struct ipmi_oem_handle ipmi_oem_list[] = {
.name = "kontron", .name = "kontron",
.desc = "Kontron OEM big buffer support" .desc = "Kontron OEM big buffer support"
}, },
{
.name = "quanta",
.desc = "Quanta IPMIv1.5 BMC with OEM LAN authentication support",
.setup = ipmi_oem_quanta,
},
{ 0 } { 0 }
}; };
/* Supermicro IPMIv2 BMCs use OEM authtype */ /* Supermicro IPMIv2 BMCs use OEM authtype */
static int static int
ipmi_oem_supermicro(struct ipmi_intf *intf) ipmi_oem_supermicro(struct ipmi_intf * intf)
{ {
ipmi_intf_session_set_authtype(intf, IPMI_SESSION_AUTHTYPE_OEM); ipmi_intf_session_set_authtype(intf, IPMI_SESSION_AUTHTYPE_OEM);
return 0; return 0;
} }
static int static int
ipmi_oem_ibm(struct ipmi_intf *__UNUSED__(intf)) ipmi_oem_ibm(struct ipmi_intf * intf)
{ {
char *filename = getenv("IPMI_OEM_IBM_DATAFILE"); char * filename;
if (!filename) { if ((filename = getenv("IPMI_OEM_IBM_DATAFILE")) == NULL) {
lprintf(LOG_ERR, "Unable to read IPMI_OEM_IBM_DATAFILE from environment"); lprintf(LOG_ERR, "Unable to read IPMI_OEM_IBM_DATAFILE from environment");
return -1; return -1;
} }
return ipmi_sel_oem_init((const char *)filename); return ipmi_sel_oem_init((const char *)filename);
} }
/* Quanta IPMIv2 BMCs use OEM authtype */
static int
ipmi_oem_quanta(struct ipmi_intf *intf)
{
ipmi_intf_session_set_authtype(intf, IPMI_SESSION_AUTHTYPE_OEM);
return 0;
}
/* ipmi_oem_print - print list of OEM handles /* ipmi_oem_print - print list of OEM handles
*/ */
void void
ipmi_oem_print(void) ipmi_oem_print(void)
{ {
struct ipmi_oem_handle *oem; struct ipmi_oem_handle * oem;
lprintf(LOG_NOTICE, "\nOEM Support:"); lprintf(LOG_NOTICE, "\nOEM Support:");
for (oem=ipmi_oem_list; oem->name && oem->desc; oem++) { for (oem=ipmi_oem_list; oem->name != NULL && oem->desc != NULL; oem++) {
lprintf(LOG_NOTICE, "\t%-12s %s", oem->name, oem->desc); lprintf(LOG_NOTICE, "\t%-12s %s", oem->name, oem->desc);
} }
lprintf(LOG_NOTICE, ""); lprintf(LOG_NOTICE, "");
@ -134,27 +120,26 @@ ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype)
struct ipmi_oem_handle * oem; struct ipmi_oem_handle * oem;
int rc = 0; int rc = 0;
if (!oemtype if (oemtype == NULL ||
|| !strcmp(oemtype, "help") strncmp(oemtype, "help", 4) == 0 ||
|| !strcmp(oemtype, "list")) strncmp(oemtype, "list", 4) == 0) {
{
ipmi_oem_print(); ipmi_oem_print();
return -1; return -1;
} }
for (oem=ipmi_oem_list; oem->name; oem++) { for (oem=ipmi_oem_list; oem->name != NULL; oem++) {
if (!strcmp(oemtype, oem->name)) if (strncmp(oemtype, oem->name, strlen(oem->name)) == 0)
break; break;
} }
if (!oem->name) if (oem->name == NULL)
return -1; return -1;
/* save pointer for later use */ /* save pointer for later use */
intf->oem = oem; intf->oem = oem;
/* run optional setup function if it is defined */ /* run optional setup function if it is defined */
if (oem->setup) { if (oem->setup != NULL) {
lprintf(LOG_DEBUG, "Running OEM setup for \"%s\"", oem->desc); lprintf(LOG_DEBUG, "Running OEM setup for \"%s\"", oem->desc);
rc = oem->setup(intf); rc = oem->setup(intf);
} }
@ -173,10 +158,10 @@ ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype)
int int
ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype) ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype)
{ {
if (!intf->oem) if (intf->oem == NULL)
return 0; return 0;
if (!strcmp(intf->oem->name, oemtype)) if (strncmp(intf->oem->name, oemtype, strlen(oemtype)) == 0)
return 1; return 1;
return 0; return 0;

View File

@ -42,7 +42,6 @@
#include <ipmitool/ipmi_mc.h> #include <ipmitool/ipmi_mc.h>
#include <ipmitool/ipmi_pef.h> #include <ipmitool/ipmi_pef.h>
#include <ipmitool/ipmi_sel.h> #include <ipmitool/ipmi_sel.h>
#include <ipmitool/ipmi_time.h>
#include <ipmitool/log.h> #include <ipmitool/log.h>
extern int verbose; extern int verbose;
@ -79,307 +78,6 @@ static const char * pef_flag_fmts[][3] = {
}; };
static const char * listitem[] = {" | %s", ",%s", "%s"}; static const char * listitem[] = {" | %s", ",%s", "%s"};
static struct bit_desc_map
pef_b2s_actions = {
BIT_DESC_MAP_ALL,
{ {"Alert", PEF_ACTION_ALERT},
{"Power-off", PEF_ACTION_POWER_DOWN},
{"Reset", PEF_ACTION_RESET},
{"Power-cycle", PEF_ACTION_POWER_CYCLE},
{"OEM-defined", PEF_ACTION_OEM},
{"Diagnostic-interrupt", PEF_ACTION_DIAGNOSTIC_INTERRUPT},
{NULL}
} };
static struct bit_desc_map
pef_b2s_severities = {
BIT_DESC_MAP_ANY,
{ {"Non-recoverable", PEF_SEVERITY_NON_RECOVERABLE},
{"Critical", PEF_SEVERITY_CRITICAL},
{"Warning", PEF_SEVERITY_WARNING},
{"OK", PEF_SEVERITY_OK},
{"Information", PEF_SEVERITY_INFORMATION},
{"Monitor", PEF_SEVERITY_MONITOR},
{NULL}
} };
static struct bit_desc_map
pef_b2s_sensortypes = {
BIT_DESC_MAP_LIST,
{ {"Any", 255},
{"Temperature", 1},
{"Voltage", 2},
{"Current", 3},
{"Fan", 4},
{"Chassis Intrusion", 5},
{"Platform security breach", 6},
{"Processor", 7},
{"Power supply", 8},
{"Power Unit", 9},
{"Cooling device", 10},
{"Other (units-based)", 11},
{"Memory", 12},
{"Drive Slot", 13},
{"POST memory resize", 14},
{"POST error", 15},
{"Logging disabled", 16},
{"Watchdog 1", 17},
{"System event", 18},
{"Critical Interrupt", 19},
{"Button", 20},
{"Module/board", 21},
{"uController/coprocessor", 22},
{"Add-in card", 23},
{"Chassis", 24},
{"Chipset", 25},
{"Other (FRU)", 26},
{"Cable/interconnect", 27},
{"Terminator", 28},
{"System boot", 29},
{"Boot error", 30},
{"OS boot", 31},
{"OS critical stop", 32},
{"Slot/connector", 33},
{"ACPI power state", 34},
{"Watchdog 2", 35},
{"Platform alert", 36},
{"Entity presence", 37},
{"Monitor ASIC/IC", 38},
{"LAN", 39},
{"Management subsystem health", 40},
{"Battery", 41},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_1 = {
BIT_DESC_MAP_LIST,
{ {"<LNC", 0}, /* '<' : getting worse */
{">LNC", 1}, /* '>' : getting better */
{"<LC", 2},
{">LC", 3},
{"<LNR", 4},
{">LNR", 5},
{">UNC", 6},
{"<UNC", 7},
{">UC", 8},
{"<UC", 9},
{">UNR", 10},
{"<UNR", 11},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_2 = {
BIT_DESC_MAP_LIST,
{ {"transition to idle", 0},
{"transition to active", 1},
{"transition to busy", 2},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_3 = {
BIT_DESC_MAP_LIST,
{ {"state deasserted", 0},
{"state asserted", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_4 = {
BIT_DESC_MAP_LIST,
{ {"predictive failure deasserted", 0},
{"predictive failure asserted", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_5 = {
BIT_DESC_MAP_LIST,
{ {"limit not exceeded", 0},
{"limit exceeded", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_6 = {
BIT_DESC_MAP_LIST,
{ {"performance met", 0},
{"performance lags", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_7 = {
BIT_DESC_MAP_LIST,
{ {"ok", 0},
{"<warn", 1}, /* '<' : getting worse */
{"<fail", 2},
{"<dead", 3},
{">warn", 4}, /* '>' : getting better */
{">fail", 5},
{"dead", 6},
{"monitor", 7},
{"informational", 8},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_8 = {
BIT_DESC_MAP_LIST,
{ {"device removed/absent", 0},
{"device inserted/present", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_9 = {
BIT_DESC_MAP_LIST,
{ {"device disabled", 0},
{"device enabled", 1},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_10 = {
BIT_DESC_MAP_LIST,
{ {"transition to running", 0},
{"transition to in test", 1},
{"transition to power off", 2},
{"transition to online", 3},
{"transition to offline", 4},
{"transition to off duty", 5},
{"transition to degraded", 6},
{"transition to power save", 7},
{"install error", 8},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_11 = {
BIT_DESC_MAP_LIST,
{ {"fully redundant", 0},
{"redundancy lost", 1},
{"redundancy degraded", 2},
{"<non-redundant/sufficient", 3}, /* '<' : getting worse */
{">non-redundant/sufficient", 4}, /* '>' : getting better */
{"non-redundant/insufficient", 5},
{"<redundancy degraded", 6},
{">redundancy degraded", 7},
{NULL}
} };
static struct bit_desc_map
pef_b2s_gentype_12 = {
BIT_DESC_MAP_LIST,
{ {"D0 power state", 0},
{"D1 power state", 1},
{"D2 power state", 2},
{"D3 power state", 3},
{NULL}
} };
static struct bit_desc_map *
pef_b2s_generic_ER[] = {
&pef_b2s_gentype_1,
&pef_b2s_gentype_2,
&pef_b2s_gentype_3,
&pef_b2s_gentype_4,
&pef_b2s_gentype_5,
&pef_b2s_gentype_6,
&pef_b2s_gentype_7,
&pef_b2s_gentype_8,
&pef_b2s_gentype_9,
&pef_b2s_gentype_10,
&pef_b2s_gentype_11,
&pef_b2s_gentype_12,
};
#define PEF_B2S_GENERIC_ER_ENTRIES ARRAY_SIZE(pef_b2s_generic_ER)
static struct bit_desc_map
pef_b2s_policies = {
BIT_DESC_MAP_LIST,
{ {"Match-always", PEF_POLICY_FLAGS_MATCH_ALWAYS},
{"Try-next-entry", PEF_POLICY_FLAGS_PREV_OK_SKIP},
{"Try-next-set", PEF_POLICY_FLAGS_PREV_OK_NEXT_POLICY_SET},
{"Try-next-channel", PEF_POLICY_FLAGS_PREV_OK_NEXT_CHANNEL_IN_SET},
{"Try-next-destination", PEF_POLICY_FLAGS_PREV_OK_NEXT_DESTINATION_IN_SET},
{NULL}
} };
static struct bit_desc_map
pef_b2s_ch_medium = {
#define PEF_CH_MEDIUM_TYPE_IPMB 1
#define PEF_CH_MEDIUM_TYPE_ICMB_10 2
#define PEF_CH_MEDIUM_TYPE_ICMB_09 3
#define PEF_CH_MEDIUM_TYPE_LAN 4
#define PEF_CH_MEDIUM_TYPE_SERIAL 5
#define PEF_CH_MEDIUM_TYPE_XLAN 6
#define PEF_CH_MEDIUM_TYPE_PCI_SMBUS 7
#define PEF_CH_MEDIUM_TYPE_SMBUS_V1X 8
#define PEF_CH_MEDIUM_TYPE_SMBUS_V2X 9
#define PEF_CH_MEDIUM_TYPE_USB_V1X 10
#define PEF_CH_MEDIUM_TYPE_USB_V2X 11
#define PEF_CH_MEDIUM_TYPE_SYSTEM 12
BIT_DESC_MAP_LIST,
{ {"IPMB (I2C)", PEF_CH_MEDIUM_TYPE_IPMB},
{"ICMB v1.0", PEF_CH_MEDIUM_TYPE_ICMB_10},
{"ICMB v0.9", PEF_CH_MEDIUM_TYPE_ICMB_09},
{"802.3 LAN", PEF_CH_MEDIUM_TYPE_LAN},
{"Serial/Modem (RS-232)", PEF_CH_MEDIUM_TYPE_SERIAL},
{"Other LAN", PEF_CH_MEDIUM_TYPE_XLAN},
{"PCI SMBus", PEF_CH_MEDIUM_TYPE_PCI_SMBUS},
{"SMBus v1.0/1.1", PEF_CH_MEDIUM_TYPE_SMBUS_V1X},
{"SMBus v2.0", PEF_CH_MEDIUM_TYPE_SMBUS_V2X},
{"USB 1.x", PEF_CH_MEDIUM_TYPE_USB_V1X},
{"USB 2.x", PEF_CH_MEDIUM_TYPE_USB_V2X},
{"System I/F (KCS,SMIC,BT)", PEF_CH_MEDIUM_TYPE_SYSTEM},
{NULL}
} };
static struct bit_desc_map
pef_b2s_control = {
BIT_DESC_MAP_ALL,
{ {"PEF", PEF_CONTROL_ENABLE},
{"PEF event messages", PEF_CONTROL_ENABLE_EVENT_MESSAGES},
{"PEF startup delay", PEF_CONTROL_ENABLE_STARTUP_DELAY},
{"Alert startup delay", PEF_CONTROL_ENABLE_ALERT_STARTUP_DELAY},
{NULL}
} };
static struct bit_desc_map
pef_b2s_lan_desttype = {
BIT_DESC_MAP_LIST,
{ {"Acknowledged", PEF_LAN_DEST_TYPE_ACK},
{"PET", PEF_LAN_DEST_TYPE_PET},
{"OEM 1", PEF_LAN_DEST_TYPE_OEM_1},
{"OEM 2", PEF_LAN_DEST_TYPE_OEM_2},
{NULL}
} };
static struct bit_desc_map
pef_b2s_serial_desttype = {
BIT_DESC_MAP_LIST,
{ {"Acknowledged", PEF_SERIAL_DEST_TYPE_ACK},
{"TAP page", PEF_SERIAL_DEST_TYPE_TAP},
{"PPP PET", PEF_SERIAL_DEST_TYPE_PPP},
{"Basic callback", PEF_SERIAL_DEST_TYPE_BASIC_CALLBACK},
{"PPP callback", PEF_SERIAL_DEST_TYPE_PPP_CALLBACK},
{"OEM 1", PEF_SERIAL_DEST_TYPE_OEM_1},
{"OEM 2", PEF_SERIAL_DEST_TYPE_OEM_2},
{NULL}
} };
static struct bit_desc_map
pef_b2s_tap_svc_confirm = {
BIT_DESC_MAP_LIST,
{ {"ACK", PEF_SERIAL_TAP_CONFIRMATION_ACK_AFTER_ETX},
{"211+ACK", PEF_SERIAL_TAP_CONFIRMATION_211_ACK_AFTER_ETX},
{"{211|213}+ACK", PEF_SERIAL_TAP_CONFIRMATION_21X_ACK_AFTER_ETX},
{NULL}
} };
static int ipmi_pef2_list_filters(struct ipmi_intf *); static int ipmi_pef2_list_filters(struct ipmi_intf *);
const char * const char *
@ -495,7 +193,7 @@ ipmi_pef_print_1xd(const char * text, uint32_t val)
static int static int
ipmi_pef_print_guid(uint8_t *guid) ipmi_pef_print_guid(uint8_t *guid)
{ {
if (!guid) { if (guid == NULL) {
return (-1); return (-1);
} }
@ -549,7 +247,7 @@ _ipmi_get_pef_capabilities(struct ipmi_intf *intf,
{ {
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
if (!pcap) { if (pcap == NULL) {
return (-3); return (-3);
} }
@ -559,9 +257,9 @@ _ipmi_get_pef_capabilities(struct ipmi_intf *intf,
req.msg.cmd = IPMI_CMD_GET_PEF_CAPABILITIES; req.msg.cmd = IPMI_CMD_GET_PEF_CAPABILITIES;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 3) { } else if (rsp->data_len != 3) {
return (-2); return (-2);
@ -589,7 +287,7 @@ _ipmi_get_pef_filter_entry(struct ipmi_intf *intf, uint8_t filter_id,
uint8_t data[3]; uint8_t data[3];
uint8_t data_len = 3 * sizeof(uint8_t); uint8_t data_len = 3 * sizeof(uint8_t);
int dest_size; int dest_size;
if (!filter_entry) { if (filter_entry == NULL) {
return (-3); return (-3);
} }
@ -605,9 +303,9 @@ _ipmi_get_pef_filter_entry(struct ipmi_intf *intf, uint8_t filter_id,
req.msg.data = (uint8_t *)&data; req.msg.data = (uint8_t *)&data;
req.msg.data_len = data_len; req.msg.data_len = data_len;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 22 || (rsp->data_len - 1) != dest_size) { } else if (rsp->data_len != 22 || (rsp->data_len - 1) != dest_size) {
return (-2); return (-2);
@ -633,7 +331,7 @@ _ipmi_get_pef_filter_entry_cfg(struct ipmi_intf *intf, uint8_t filter_id,
uint8_t data[3]; uint8_t data[3];
uint8_t data_len = 3 * sizeof(uint8_t); uint8_t data_len = 3 * sizeof(uint8_t);
int dest_size; int dest_size;
if (!filter_cfg) { if (filter_cfg == NULL) {
return (-3); return (-3);
} }
@ -649,9 +347,9 @@ _ipmi_get_pef_filter_entry_cfg(struct ipmi_intf *intf, uint8_t filter_id,
req.msg.data = (uint8_t *)&data; req.msg.data = (uint8_t *)&data;
req.msg.data_len = data_len; req.msg.data_len = data_len;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 3 || (rsp->data_len - 1) != dest_size) { } else if (rsp->data_len != 3 || (rsp->data_len - 1) != dest_size) {
return (-2); return (-2);
@ -677,7 +375,7 @@ _ipmi_get_pef_policy_entry(struct ipmi_intf *intf, uint8_t policy_id,
uint8_t data[3]; uint8_t data[3];
uint8_t data_len = 3 * sizeof(uint8_t); uint8_t data_len = 3 * sizeof(uint8_t);
int dest_size; int dest_size;
if (!policy_entry) { if (policy_entry == NULL) {
return (-3); return (-3);
} }
@ -693,9 +391,9 @@ _ipmi_get_pef_policy_entry(struct ipmi_intf *intf, uint8_t policy_id,
req.msg.data = (uint8_t *)&data; req.msg.data = (uint8_t *)&data;
req.msg.data_len = data_len; req.msg.data_len = data_len;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 5 || (rsp->data_len - 1) != dest_size) { } else if (rsp->data_len != 5 || (rsp->data_len - 1) != dest_size) {
return (-2); return (-2);
@ -718,7 +416,7 @@ _ipmi_get_pef_filter_table_size(struct ipmi_intf *intf, uint8_t *table_size)
struct ipmi_rq req; struct ipmi_rq req;
struct pef_cfgparm_selector psel; struct pef_cfgparm_selector psel;
if (!table_size) { if (table_size == NULL) {
return (-3); return (-3);
} }
@ -732,9 +430,9 @@ _ipmi_get_pef_filter_table_size(struct ipmi_intf *intf, uint8_t *table_size)
req.msg.data = (uint8_t *)&psel; req.msg.data = (uint8_t *)&psel;
req.msg.data_len = sizeof(psel); req.msg.data_len = sizeof(psel);
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 2) { } else if (rsp->data_len != 2) {
return (-2); return (-2);
@ -757,7 +455,7 @@ _ipmi_get_pef_policy_table_size(struct ipmi_intf *intf, uint8_t *table_size)
struct ipmi_rq req; struct ipmi_rq req;
struct pef_cfgparm_selector psel; struct pef_cfgparm_selector psel;
if (!table_size) { if (table_size == NULL) {
return (-3); return (-3);
} }
@ -771,9 +469,9 @@ _ipmi_get_pef_policy_table_size(struct ipmi_intf *intf, uint8_t *table_size)
req.msg.data = (uint8_t *)&psel; req.msg.data = (uint8_t *)&psel;
req.msg.data_len = sizeof(psel); req.msg.data_len = sizeof(psel);
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 2) { } else if (rsp->data_len != 2) {
return (-2); return (-2);
@ -796,7 +494,7 @@ _ipmi_get_pef_system_guid(struct ipmi_intf *intf,
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
struct pef_cfgparm_selector psel; struct pef_cfgparm_selector psel;
if (!system_guid) { if (system_guid == NULL) {
return (-3); return (-3);
} }
@ -810,9 +508,9 @@ _ipmi_get_pef_system_guid(struct ipmi_intf *intf,
req.msg.data_len = sizeof(psel); req.msg.data_len = sizeof(psel);
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} else if (rsp->data_len != 18 } else if (rsp->data_len != 18
|| (rsp->data_len - 2) != sizeof(system_guid->guid)) { || (rsp->data_len - 2) != sizeof(system_guid->guid)) {
@ -839,7 +537,7 @@ _ipmi_set_pef_filter_entry_cfg(struct ipmi_intf *intf, uint8_t filter_id,
struct ipmi_rq req; struct ipmi_rq req;
uint8_t data[3]; uint8_t data[3];
uint8_t data_len = 3 * sizeof(uint8_t); uint8_t data_len = 3 * sizeof(uint8_t);
if (!filter_cfg) { if (filter_cfg == NULL) {
return (-3); return (-3);
} }
@ -855,9 +553,9 @@ _ipmi_set_pef_filter_entry_cfg(struct ipmi_intf *intf, uint8_t filter_id,
data[2] = filter_cfg->cfg; data[2] = filter_cfg->cfg;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} }
return 0; return 0;
@ -878,7 +576,7 @@ _ipmi_set_pef_policy_entry(struct ipmi_intf *intf, uint8_t policy_id,
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
struct pef_cfgparm_set_policy_table_entry payload; struct pef_cfgparm_set_policy_table_entry payload;
if (!policy_entry) { if (policy_entry == NULL) {
return (-3); return (-3);
} }
@ -895,17 +593,16 @@ _ipmi_set_pef_policy_entry(struct ipmi_intf *intf, uint8_t policy_id,
sizeof(policy_entry->entry)); sizeof(policy_entry->entry));
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
return (-1); return (-1);
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
return rsp->ccode; return rsp->ccode;
} }
return 0; return 0;
} }
static void static void
ipmi_pef_print_oem_lan_dest(struct ipmi_intf *intf, ipmi_pef_print_oem_lan_dest(struct ipmi_intf *intf, uint8_t ch, uint8_t dest)
uint8_t dest)
{ {
char address[128]; char address[128];
int len; int len;
@ -1168,7 +865,7 @@ ipmi_pef_print_serial_dest(struct ipmi_intf *intf, uint8_t ch, uint8_t dest)
if (!dest || tbl_size == 0) /* Page alerting not supported */ if (!dest || tbl_size == 0) /* Page alerting not supported */
return; return;
if (dest > tbl_size) { if (dest > tbl_size) {
ipmi_pef_print_oem_lan_dest(intf, dest - tbl_size); ipmi_pef_print_oem_lan_dest(intf, ch, dest - tbl_size);
return; return;
} }
@ -1206,7 +903,7 @@ ipmi_pef_print_serial_dest(struct ipmi_intf *intf, uint8_t ch, uint8_t dest)
} }
static void static void
ipmi_pef_print_dest(uint8_t dest) ipmi_pef_print_dest(struct ipmi_intf * intf, uint8_t ch, uint8_t dest)
{ /* { /*
// print generic alert destination info // print generic alert destination info
*/ */
@ -1398,13 +1095,13 @@ ipmi_pef2_filter(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
ipmi_pef2_filter_help(); ipmi_pef2_filter_help();
rc = (-1); rc = (-1);
} else if (!strcmp(argv[0], "help")) { } else if (!strncmp(argv[0], "help\0", 5)) {
ipmi_pef2_filter_help(); ipmi_pef2_filter_help();
rc = 0; rc = 0;
} else if (!strcmp(argv[0], "list")) { } else if (!strncmp(argv[0], "list\0", 5)) {
rc = ipmi_pef2_list_filters(intf); rc = ipmi_pef2_list_filters(intf);
} else if (!strcmp(argv[0], "enable") } else if (!strncmp(argv[0], "enable\0", 7)
||(!strcmp(argv[0], "disable"))) { ||(!strncmp(argv[0], "disable\0", 8))) {
uint8_t enable; uint8_t enable;
uint8_t filter_id; uint8_t filter_id;
if (argc != 2) { if (argc != 2) {
@ -1420,16 +1117,16 @@ ipmi_pef2_filter(struct ipmi_intf *intf, int argc, char **argv)
"Valid range is <1..255>."); "Valid range is <1..255>.");
return (-1); return (-1);
} }
if (!strcmp(argv[0], "enable")) { if (!strncmp(argv[0], "enable\0", 7)) {
enable = 1; enable = 1;
} else { } else {
enable = 0; enable = 0;
} }
rc = ipmi_pef2_filter_enable(intf, enable, filter_id); rc = ipmi_pef2_filter_enable(intf, enable, filter_id);
} else if (!strcmp(argv[0], "create")) { } else if (!strncmp(argv[0], "create\0", 7)) {
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;
} else if (!strcmp(argv[0], "delete")) { } else if (!strncmp(argv[0], "delete\0", 7)) {
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;
} else { } else {
@ -1446,7 +1143,7 @@ ipmi_pef2_get_info(struct ipmi_intf *intf)
{ {
struct pef_capabilities pcap; struct pef_capabilities pcap;
struct pef_cfgparm_system_guid psys_guid; struct pef_cfgparm_system_guid psys_guid;
ipmi_guid_t guid; struct ipmi_guid_t guid;
int rc; int rc;
uint8_t *guid_ptr = NULL; uint8_t *guid_ptr = NULL;
uint8_t policy_table_size; uint8_t policy_table_size;
@ -1486,7 +1183,6 @@ ipmi_pef2_get_info(struct ipmi_intf *intf)
ipmi_pef_print_guid(guid_ptr); ipmi_pef_print_guid(guid_ptr);
} }
ipmi_pef_print_flags(&pef_b2s_actions, P_SUPP, pcap.actions); ipmi_pef_print_flags(&pef_b2s_actions, P_SUPP, pcap.actions);
putchar('\n');
return 0; return 0;
} }
@ -1497,6 +1193,8 @@ ipmi_pef2_get_status(struct ipmi_intf *intf)
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
struct pef_cfgparm_selector psel; struct pef_cfgparm_selector psel;
char tbuf[40];
uint32_t timei;
time_t ts; time_t ts;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
@ -1508,9 +1206,15 @@ ipmi_pef2_get_status(struct ipmi_intf *intf)
"Last S/W processed ID"); "Last S/W processed ID");
return (-1); return (-1);
} }
memcpy(&timei, rsp->data, sizeof(timei));
#if WORDS_BIGENDIAN
timei = BSWAP_32(timei);
#endif
ts = (time_t)timei;
ts = ipmi32toh(rsp->data); strftime(tbuf, sizeof(tbuf), "%m/%d/%Y %H:%M:%S", gmtime(&ts));
ipmi_pef_print_str("Last SEL addition", ipmi_timestamp_numeric(ts));
ipmi_pef_print_str("Last SEL addition", tbuf);
ipmi_pef_print_2xd("Last SEL record ID", rsp->data[5], rsp->data[4]); ipmi_pef_print_2xd("Last SEL record ID", rsp->data[5], rsp->data[4]);
ipmi_pef_print_2xd("Last S/W processed ID", rsp->data[7], rsp->data[6]); ipmi_pef_print_2xd("Last S/W processed ID", rsp->data[7], rsp->data[6]);
ipmi_pef_print_2xd("Last BMC processed ID", rsp->data[9], rsp->data[8]); ipmi_pef_print_2xd("Last BMC processed ID", rsp->data[9], rsp->data[8]);
@ -1538,7 +1242,6 @@ ipmi_pef2_get_status(struct ipmi_intf *intf)
return (-1); return (-1);
} }
ipmi_pef_print_flags(&pef_b2s_actions, P_ACTV, rsp->data[1]); ipmi_pef_print_flags(&pef_b2s_actions, P_ACTV, rsp->data[1]);
putchar('\n');
return 0; return 0;
} }
@ -1634,7 +1337,7 @@ ipmi_pef2_list_policies(struct ipmi_intf *intf)
dest); dest);
break; break;
default: default:
ipmi_pef_print_dest(dest); ipmi_pef_print_dest(intf, channel_info.channel, dest);
break; break;
} }
printf("\n"); printf("\n");
@ -1721,13 +1424,13 @@ ipmi_pef2_policy(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
ipmi_pef2_policy_help(); ipmi_pef2_policy_help();
rc = (-1); rc = (-1);
} else if (!strcmp(argv[0], "help")) { } else if (!strncmp(argv[0], "help\0", 5)) {
ipmi_pef2_policy_help(); ipmi_pef2_policy_help();
rc = 0; rc = 0;
} else if (!strcmp(argv[0], "list")) { } else if (!strncmp(argv[0], "list\0", 5)) {
rc = ipmi_pef2_list_policies(intf); rc = ipmi_pef2_list_policies(intf);
} else if (!strcmp(argv[0], "enable") } else if (!strncmp(argv[0], "enable\0", 7)
|| !strcmp(argv[0], "disable")) { || !strncmp(argv[0], "disable\0", 8)) {
uint8_t enable; uint8_t enable;
uint8_t policy_id; uint8_t policy_id;
if (argc != 2) { if (argc != 2) {
@ -1742,16 +1445,16 @@ ipmi_pef2_policy(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "PEF Policy ID out of range. Valid range is <1..127>."); lprintf(LOG_ERR, "PEF Policy ID out of range. Valid range is <1..127>.");
return (-1); return (-1);
} }
if (!strcmp(argv[0], "enable")) { if (!strncmp(argv[0], "enable\0", 7)) {
enable = 1; enable = 1;
} else { } else {
enable = 0; enable = 0;
} }
rc = ipmi_pef2_policy_enable(intf, enable, policy_id); rc = ipmi_pef2_policy_enable(intf, enable, policy_id);
} else if (!strcmp(argv[0], "create")) { } else if (!strncmp(argv[0], "create\0", 7)) {
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;
} else if (!strcmp(argv[0], "delete")) { } else if (!strncmp(argv[0], "delete\0", 7)) {
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;
} else { } else {
@ -1812,30 +1515,30 @@ int ipmi_pef_main(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
ipmi_pef2_help(); ipmi_pef2_help();
rc = (-1); rc = (-1);
} else if (!strcmp(argv[0], "help")) { } else if (!strncmp(argv[0], "help\0", 5)) {
ipmi_pef2_help(); ipmi_pef2_help();
rc = 0; rc = 0;
} else if (!strcmp(argv[0], "capabilities")) { } else if (!strncmp(argv[0], "capabilities\0", 13)) {
/* rc = ipmi_pef2_get_capabilities(intf); */ /* rc = ipmi_pef2_get_capabilities(intf); */
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;
} else if (!strcmp(argv[0], "event")) { } else if (!strncmp(argv[0], "event\0", 6)) {
/* rc = ipmi_pef2_event(intf, (argc - 1), ++argv); */ /* rc = ipmi_pef2_event(intf, (argc - 1), ++argv); */
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;
} else if (!strcmp(argv[0], "filter")) { } else if (!strncmp(argv[0], "filter\0", 7)) {
rc = ipmi_pef2_filter(intf, (argc - 1), ++argv); rc = ipmi_pef2_filter(intf, (argc - 1), ++argv);
} else if (!strcmp(argv[0], "info")) { } else if (!strncmp(argv[0], "info\0", 5)) {
rc = ipmi_pef2_get_info(intf); rc = ipmi_pef2_get_info(intf);
} else if (!strcmp(argv[0], "pet")) { } else if (!strncmp(argv[0], "pet\0", 4)) {
/* rc = ipmi_pef2_pet(intf, (argc - 1), ++argv); */ /* rc = ipmi_pef2_pet(intf, (argc - 1), ++argv); */
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;
} else if (!strcmp(argv[0], "policy")) { } else if (!strncmp(argv[0], "policy\0", 7)) {
rc = ipmi_pef2_policy(intf, (argc - 1), ++argv); rc = ipmi_pef2_policy(intf, (argc - 1), ++argv);
} else if (!strcmp(argv[0], "status")) { } else if (!strncmp(argv[0], "status\0", 7)) {
rc = ipmi_pef2_get_status(intf); rc = ipmi_pef2_get_status(intf);
} else if (!strcmp(argv[0], "timer")) { } else if (!strncmp(argv[0], "timer\0", 6)) {
/* rc = ipmi_pef2_timer(intf, (argc - 1), ++argv); */ /* rc = ipmi_pef2_timer(intf, (argc - 1), ++argv); */
lprintf(LOG_ERR, "Not implemented."); lprintf(LOG_ERR, "Not implemented.");
rc = 1; rc = 1;

View File

@ -37,6 +37,11 @@
#include <ipmitool/ipmi_strings.h> #include <ipmitool/ipmi_strings.h>
#include <ipmitool/log.h> #include <ipmitool/log.h>
#define PICMG_EXTENSION_ATCA_MAJOR_VERSION 2
#define PICMG_EXTENSION_AMC0_MAJOR_VERSION 4
#define PICMG_EXTENSION_UTCA_MAJOR_VERSION 5
#define PICMG_EKEY_MODE_QUERY 0 #define PICMG_EKEY_MODE_QUERY 0
#define PICMG_EKEY_MODE_PRINT_ALL 1 #define PICMG_EKEY_MODE_PRINT_ALL 1
#define PICMG_EKEY_MODE_PRINT_ENABLED 2 #define PICMG_EKEY_MODE_PRINT_ENABLED 2
@ -62,84 +67,7 @@ typedef enum picmg_card_type {
PICMG_CARD_TYPE_RESERVED PICMG_CARD_TYPE_RESERVED
} t_picmg_card_type ; } t_picmg_card_type ;
static const char* amc_link_type_str[] = { /* This is the version of the PICMG Extenstion */
"RESERVED",
"RESERVED1",
"PCI EXPRESS",
"ADVANCED SWITCHING1",
"ADVANCED SWITCHING2",
"ETHERNET",
"RAPIDIO",
"STORAGE",
};
static const char* amc_link_type_ext_str[][16] = {
/* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED */
{
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED1 */
{
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_PCI_EXPRESS */
{
"Gen 1 - NSSC",
"Gen 1 - SSC",
"Gen 2 - NSSC",
"Gen 2 - SSC",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING1 */
{
"Gen 1 - NSSC",
"Gen 1 - SSC",
"Gen 2 - NSSC",
"Gen 2 - SSC",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING2 */
{
"Gen 1 - NSSC",
"Gen 1 - SSC",
"Gen 2 - NSSC",
"Gen 2 - SSC",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET */
{
"1000BASE-BX (SerDES Gigabit)",
"10GBASE-BX410 Gigabit XAUI",
"", "",
"", "", "", "",
"", "", "", "",
"", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_RAPIDIO */
{
"1.25 Gbaud transmission rate",
"2.5 Gbaud transmission rate",
"3.125 Gbaud transmission rate",
"", "", "", "", "",
"", "", "", "", "", "", "", ""
},
/* FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE */
{
"Fibre Channel",
"Serial ATA",
"Serial Attached SCSI",
"", "", "", "", "",
"", "", "", "", "", "", "", ""
}
};
/* This is the version of the PICMG Extension */
static t_picmg_card_type PicmgCardType = PICMG_CARD_TYPE_RESERVED; static t_picmg_card_type PicmgCardType = PICMG_CARD_TYPE_RESERVED;
void void
@ -202,28 +130,6 @@ struct sAmcAddrMap {
{0x88, "reserved", 0}, {0x88, "reserved", 0},
}; };
/* the LED color capabilities */
static const char *led_color_str[] = {
"reserved",
"BLUE",
"RED",
"GREEN",
"AMBER",
"ORANGE",
"WHITE",
"reserved"
};
const char *
picmg_led_color_str(int color)
{
if (color < 0 || (size_t)color >= ARRAY_SIZE(led_color_str)) {
return "invalid";
}
return led_color_str[color];
}
/* is_amc_channel - wrapper to convert user input into integer /* is_amc_channel - wrapper to convert user input into integer
* AMC Channel range seems to be <0..255>, bits [7:0] * AMC Channel range seems to be <0..255>, bits [7:0]
* *
@ -245,7 +151,7 @@ is_amc_channel(const char *argv_ptr, uint8_t *amc_chan_ptr)
return (-1); return (-1);
} }
/* is_amc_dev - wrapper to convert user input into integer. /* is_amc_dev - wrapper to convert user input into integer.
* AMC Dev ID limits are unknown. * AMC Dev ID limits are uknown.
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
* @amc_dev_ptr: pointer where to store result * @amc_dev_ptr: pointer where to store result
@ -266,7 +172,7 @@ is_amc_dev(const char *argv_ptr, int32_t *amc_dev_ptr)
return (-1); return (-1);
} }
/* is_amc_intf - wrapper to convert user input into integer. /* is_amc_intf - wrapper to convert user input into integer.
* AMC Interface (ID) limits are unknown. * AMC Interface (ID) limits are uknown.
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
* @amc_intf_ptr: pointer where to store result * @amc_intf_ptr: pointer where to store result
@ -287,7 +193,7 @@ is_amc_intf(const char *argv_ptr, int32_t *amc_intf_ptr)
return (-1); return (-1);
} }
/* is_amc_port - wrapper to convert user input into integer. /* is_amc_port - wrapper to convert user input into integer.
* AMC Port limits are unknown. * AMC Port limits are uknown.
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
* @amc_port_ptr: pointer where to store result * @amc_port_ptr: pointer where to store result
@ -307,7 +213,7 @@ is_amc_port(const char *argv_ptr, int32_t *amc_port_ptr)
return (-1); return (-1);
} }
/* is_clk_acc - wrapper to convert user input into integer. /* is_clk_acc - wrapper to convert user input into integer.
* Clock Accuracy limits are unknown[1byte by spec]. * Clock Accuracy limits are uknown[1byte by spec].
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
* @clk_acc_ptr: pointer where to store result * @clk_acc_ptr: pointer where to store result
@ -328,7 +234,7 @@ is_clk_acc(const char *argv_ptr, uint8_t *clk_acc_ptr)
return (-1); return (-1);
} }
/* is_clk_family - wrapper to convert user input into integer. /* is_clk_family - wrapper to convert user input into integer.
* Clock Family limits are unknown[1byte by spec]. * Clock Family limits are uknown[1byte by spec].
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
* @clk_family_ptr: pointer where to store result * @clk_family_ptr: pointer where to store result
@ -349,7 +255,7 @@ is_clk_family(const char *argv_ptr, uint8_t *clk_family_ptr)
return (-1); return (-1);
} }
/* is_clk_freq - wrapper to convert user input into integer. /* is_clk_freq - wrapper to convert user input into integer.
* Clock Frequency limits are unknown, but specification says * Clock Frequency limits are uknown, but specification says
* 3Bytes + 1B checksum * 3Bytes + 1B checksum
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
@ -371,7 +277,7 @@ is_clk_freq(const char *argv_ptr, uint32_t *clk_freq_ptr)
return (-1); return (-1);
} }
/* is_clk_id - wrapper to convert user input into integer. /* is_clk_id - wrapper to convert user input into integer.
* Clock ID limits are unknown, however it's 1B by specification and I've * Clock ID limits are uknown, however it's 1B by specification and I've
* found two ranges: <1..5> or <0..15> * found two ranges: <1..5> or <0..15>
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
@ -392,7 +298,7 @@ is_clk_id(const char *argv_ptr, uint8_t *clk_id_ptr)
return (-1); return (-1);
} }
/* is_clk_index - wrapper to convert user input into integer. /* is_clk_index - wrapper to convert user input into integer.
* Clock Index limits are unknown[1B by spec] * Clock Index limits are uknown[1B by spec]
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
* @clk_index_ptr: pointer where to store result * @clk_index_ptr: pointer where to store result
@ -412,7 +318,7 @@ is_clk_index(const char *argv_ptr, uint8_t *clk_index_ptr)
return (-1); return (-1);
} }
/* is_clk_resid - wrapper to convert user input into integer. /* is_clk_resid - wrapper to convert user input into integer.
* Clock Resource Index(?) limits are unknown, but maximum seems to be 15. * Clock Resource Index(?) limits are uknown, but maximum seems to be 15.
* *
* @argv_ptr: source string to convert from; usually argv * @argv_ptr: source string to convert from; usually argv
* @clk_resid_ptr: pointer where to store result * @clk_resid_ptr: pointer where to store result
@ -755,7 +661,7 @@ ipmi_picmg_properties(struct ipmi_intf * intf, int show )
#define PICMG_FRU_ACTIVATE (unsigned char) 0x01 #define PICMG_FRU_ACTIVATE (unsigned char) 0x01
int int
ipmi_picmg_fru_activation(struct ipmi_intf * intf, char ** argv, unsigned char state) ipmi_picmg_fru_activation(struct ipmi_intf * intf, int argc, char ** argv, unsigned char state)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -789,7 +695,7 @@ ipmi_picmg_fru_activation(struct ipmi_intf * intf, char ** argv, unsigned char s
int int
ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, char ** argv) ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -828,7 +734,7 @@ ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, char ** argv)
} }
int int
ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf, char ** argv) ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -1123,7 +1029,7 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf, int32_t device,
/* Removed endianness check here, probably not required /* Removed endianness check here, probably not required
as we don't use bitfields */ as we dont use bitfields */
port = d->linkInfo[0] & 0x0F; port = d->linkInfo[0] & 0x0F;
type = ((d->linkInfo[0] & 0xF0) >> 4 )|(d->linkInfo[1] & 0x0F ); type = ((d->linkInfo[0] & 0xF0) >> 4 )|(d->linkInfo[1] & 0x0F );
ext = ((d->linkInfo[1] & 0xF0) >> 4 ); ext = ((d->linkInfo[1] & 0xF0) >> 4 );
@ -1252,7 +1158,7 @@ ipmi_picmg_amc_portstate_set(struct ipmi_intf * intf, uint8_t channel,
int int
ipmi_picmg_get_led_properties(struct ipmi_intf * intf, char ** argv) ipmi_picmg_get_led_properties(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -1291,7 +1197,7 @@ ipmi_picmg_get_led_properties(struct ipmi_intf * intf, char ** argv)
} }
int int
ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, char ** argv) ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, int argc, char ** argv)
{ {
int i; int i;
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
@ -1328,20 +1234,20 @@ ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, char ** argv)
printf("LED Color Capabilities: "); printf("LED Color Capabilities: ");
for ( i=0 ; i<8 ; i++ ) { for ( i=0 ; i<8 ; i++ ) {
if ( rsp->data[1] & (0x01 << i) ) { if ( rsp->data[1] & (0x01 << i) ) {
printf("%s, ", picmg_led_color_str(i)); printf("%s, ", led_color_str[ i ]);
} }
} }
printf("\n"); printf("\n");
printf("Default LED Color in\n"); printf("Default LED Color in\n");
printf(" LOCAL control: %s\n", picmg_led_color_str(rsp->data[2])); printf(" LOCAL control: %s\n", led_color_str[ rsp->data[2] ] );
printf(" OVERRIDE state: %s\n", picmg_led_color_str(rsp->data[3])); printf(" OVERRIDE state: %s\n", led_color_str[ rsp->data[3] ] );
return 0; return 0;
} }
int int
ipmi_picmg_get_led_state(struct ipmi_intf * intf, char ** argv) ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -1402,9 +1308,7 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, char ** argv)
} }
printf(" Local Control On-Duration: %x\n", rsp->data[3] ); printf(" Local Control On-Duration: %x\n", rsp->data[3] );
printf(" Local Control Color: %x [%s]\n", printf(" Local Control Color: %x [%s]\n", rsp->data[4], led_color_str[ rsp->data[4] ]);
rsp->data[4],
picmg_led_color_str(rsp->data[4]));
/* override state or lamp test */ /* override state or lamp test */
if (rsp->data[1] & 0x02) { if (rsp->data[1] & 0x02) {
@ -1418,9 +1322,7 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, char ** argv)
} }
printf(" Override On-Duration: %x\n", rsp->data[6] ); printf(" Override On-Duration: %x\n", rsp->data[6] );
printf(" Override Color: %x [%s]\n", printf(" Override Color: %x [%s]\n", rsp->data[7], led_color_str[ rsp->data[7] ]);
rsp->data[7],
picmg_led_color_str(rsp->data[7]));
} }
@ -1432,7 +1334,7 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, char ** argv)
} }
int int
ipmi_picmg_set_led_state(struct ipmi_intf * intf, char ** argv) ipmi_picmg_set_led_state(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -1508,7 +1410,7 @@ ipmi_picmg_set_led_state(struct ipmi_intf * intf, char ** argv)
} }
int int
ipmi_picmg_get_power_level(struct ipmi_intf * intf, char ** argv) ipmi_picmg_get_power_level(struct ipmi_intf * intf, int argc, char ** argv)
{ {
int i; int i;
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
@ -1559,7 +1461,7 @@ ipmi_picmg_get_power_level(struct ipmi_intf * intf, char ** argv)
} }
int int
ipmi_picmg_set_power_level(struct ipmi_intf * intf, char ** argv) ipmi_picmg_set_power_level(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -1663,7 +1565,7 @@ ipmi_picmg_bused_resource(struct ipmi_intf * intf, t_picmg_bused_resource_mode m
} }
int int
ipmi_picmg_fru_control(struct ipmi_intf * intf, char ** argv) ipmi_picmg_fru_control(struct ipmi_intf * intf, int argc, char ** argv)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -1752,7 +1654,7 @@ ipmi_picmg_clk_get(struct ipmi_intf * intf, uint8_t clk_id, int8_t clk_res,
return -1; return -1;
} }
if (!rsp->ccode) { if (rsp->ccode == 0 ) {
enabled = (rsp->data[1]&0x8)!=0; enabled = (rsp->data[1]&0x8)!=0;
direction = (rsp->data[1]&0x4)!=0; direction = (rsp->data[1]&0x4)!=0;
@ -1883,24 +1785,24 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
int rc = 0; int rc = 0;
int showProperties = 0; int showProperties = 0;
if (!argc || !strcmp(argv[0], "help")) { if (argc == 0 || (!strncmp(argv[0], "help", 4))) {
ipmi_picmg_help(); ipmi_picmg_help();
return 0; return 0;
} }
/* Get PICMG properties is called to obtain version information */ /* Get PICMG properties is called to obtain version information */
if (!strcmp(argv[0], "properties")) { if (argc !=0 && !strncmp(argv[0], "properties", 10)) {
showProperties =1; showProperties =1;
} }
rc = ipmi_picmg_properties(intf,showProperties); rc = ipmi_picmg_properties(intf,showProperties);
/* address info command */ /* address info command */
if (!strcmp(argv[0], "addrinfo")) { if (!strncmp(argv[0], "addrinfo", 8)) {
rc = ipmi_picmg_getaddr(intf, argc-1, &argv[1]); rc = ipmi_picmg_getaddr(intf, argc-1, &argv[1]);
} }
else if (!strcmp(argv[0], "busres")) { else if (!strncmp(argv[0], "busres", 6)) {
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "summary")) { if (!strncmp(argv[1], "summary", 7)) {
ipmi_picmg_bused_resource(intf, PICMG_BUSED_RESOURCE_SUMMARY ); ipmi_picmg_bused_resource(intf, PICMG_BUSED_RESOURCE_SUMMARY );
} }
} else { } else {
@ -1908,9 +1810,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
/* fru control command */ /* fru control command */
else if (!strcmp(argv[0], "frucontrol")) { else if (!strncmp(argv[0], "frucontrol", 10)) {
if (argc > 2) { if (argc > 2) {
rc = ipmi_picmg_fru_control(intf, &(argv[1])); rc = ipmi_picmg_fru_control(intf, argc-1, &(argv[1]));
} }
else { else {
lprintf(LOG_NOTICE, "usage: frucontrol <FRU-ID> <OPTION>"); lprintf(LOG_NOTICE, "usage: frucontrol <FRU-ID> <OPTION>");
@ -1928,9 +1830,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
/* fru activation command */ /* fru activation command */
else if (!strcmp(argv[0], "activate")) { else if (!strncmp(argv[0], "activate", 8)) {
if (argc > 1) { if (argc > 1) {
rc = ipmi_picmg_fru_activation(intf, &(argv[1]), PICMG_FRU_ACTIVATE); rc = ipmi_picmg_fru_activation(intf, argc-1, &(argv[1]), PICMG_FRU_ACTIVATE);
} }
else { else {
lprintf(LOG_ERR, "Specify the FRU to activate."); lprintf(LOG_ERR, "Specify the FRU to activate.");
@ -1939,9 +1841,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
/* fru deactivation command */ /* fru deactivation command */
else if (!strcmp(argv[0], "deactivate")) { else if (!strncmp(argv[0], "deactivate", 10)) {
if (argc > 1) { if (argc > 1) {
rc = ipmi_picmg_fru_activation(intf, &(argv[1]), PICMG_FRU_DEACTIVATE); rc = ipmi_picmg_fru_activation(intf, argc-1, &(argv[1]), PICMG_FRU_DEACTIVATE);
}else { }else {
lprintf(LOG_ERR, "Specify the FRU to deactivate."); lprintf(LOG_ERR, "Specify the FRU to deactivate.");
return -1; return -1;
@ -1949,17 +1851,17 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
/* activation policy command */ /* activation policy command */
else if (!strcmp(argv[0], "policy")) { else if (!strncmp(argv[0], "policy", 6)) {
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "get")) { if (!strncmp(argv[1], "get", 3)) {
if (argc > 2) { if (argc > 2) {
rc = ipmi_picmg_fru_activation_policy_get(intf, &(argv[2])); rc = ipmi_picmg_fru_activation_policy_get(intf, argc-1, &(argv[2]));
} else { } else {
lprintf(LOG_NOTICE, "usage: get <fruid>"); lprintf(LOG_NOTICE, "usage: get <fruid>");
} }
} else if (!strcmp(argv[1], "set")) { } else if (!strncmp(argv[1], "set", 3)) {
if (argc > 4) { if (argc > 4) {
rc = ipmi_picmg_fru_activation_policy_set(intf, &(argv[2])); rc = ipmi_picmg_fru_activation_policy_set(intf, argc-1, &(argv[2]));
} else { } else {
lprintf(LOG_NOTICE, "usage: set <fruid> <lockmask> <lock>"); lprintf(LOG_NOTICE, "usage: set <fruid> <lockmask> <lock>");
lprintf(LOG_NOTICE, lprintf(LOG_NOTICE,
@ -1982,18 +1884,18 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
/* portstate command */ /* portstate command */
else if (!strcmp(argv[0], "portstate")) { else if (!strncmp(argv[0], "portstate", 9)) {
lprintf(LOG_DEBUG,"PICMG: portstate API"); lprintf(LOG_DEBUG,"PICMG: portstate API");
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "get")) { if (!strncmp(argv[1], "get", 3)) {
int32_t iface; int32_t iface;
uint8_t channel = 0; uint8_t channel = 0;
lprintf(LOG_DEBUG,"PICMG: get"); lprintf(LOG_DEBUG,"PICMG: get");
if(!strcmp(argv[1], "getall")) { if(!strncmp(argv[1], "getall", 6)) {
for(iface=0;iface<=PICMG_EKEY_MAX_INTERFACE;iface++) { for(iface=0;iface<=PICMG_EKEY_MAX_INTERFACE;iface++) {
for(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) { for(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) {
if(!(( iface == FRU_PICMGEXT_DESIGN_IF_FABRIC ) && if(!(( iface == FRU_PICMGEXT_DESIGN_IF_FABRIC ) &&
@ -2005,7 +1907,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
} }
else if(!strcmp(argv[1], "getgranted")) { else if(!strncmp(argv[1], "getgranted", 10)) {
for(iface=0;iface<=PICMG_EKEY_MAX_INTERFACE;iface++) { for(iface=0;iface<=PICMG_EKEY_MAX_INTERFACE;iface++) {
for(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) { for(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) {
rc = ipmi_picmg_portstate_get(intf,iface,channel, rc = ipmi_picmg_portstate_get(intf,iface,channel,
@ -2013,7 +1915,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
} }
else if(!strcmp(argv[1], "getdenied")){ else if(!strncmp(argv[1], "getdenied", 9)){
for(iface=0;iface<=PICMG_EKEY_MAX_INTERFACE;iface++) { for(iface=0;iface<=PICMG_EKEY_MAX_INTERFACE;iface++) {
for(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) { for(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) {
rc = ipmi_picmg_portstate_get(intf,iface,channel, rc = ipmi_picmg_portstate_get(intf,iface,channel,
@ -2036,7 +1938,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_NOTICE, "<intf> <chn>|getall|getgranted|getdenied"); lprintf(LOG_NOTICE, "<intf> <chn>|getall|getgranted|getdenied");
} }
} }
else if (!strcmp(argv[1], "set")) { else if (!strncmp(argv[1], "set", 3)) {
if (argc == 9) { if (argc == 9) {
int32_t interface = 0; int32_t interface = 0;
int32_t port = 0; int32_t port = 0;
@ -2079,18 +1981,18 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
/* amc portstate command */ /* amc portstate command */
else if (!strcmp(argv[0], "amcportstate")) { else if (!strncmp(argv[0], "amcportstate", 12)) {
lprintf(LOG_DEBUG,"PICMG: amcportstate API"); lprintf(LOG_DEBUG,"PICMG: amcportstate API");
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "get")){ if (!strncmp(argv[1], "get", 3)){
int32_t device; int32_t device;
uint8_t channel; uint8_t channel;
lprintf(LOG_DEBUG,"PICMG: get"); lprintf(LOG_DEBUG,"PICMG: get");
if(!strcmp(argv[1], "getall")){ if(!strncmp(argv[1], "getall", 6)){
int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE; int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE;
if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){ if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){
maxDevice = 0; maxDevice = 0;
@ -2102,7 +2004,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
} }
else if(!strcmp(argv[1], "getgranted")){ else if(!strncmp(argv[1], "getgranted", 10)){
int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE; int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE;
if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){ if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){
maxDevice = 0; maxDevice = 0;
@ -2114,7 +2016,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
} }
else if(!strcmp(argv[1], "getdenied")){ else if(!strncmp(argv[1], "getdenied", 9)){
int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE; int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE;
if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){ if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){
maxDevice = 0; maxDevice = 0;
@ -2147,7 +2049,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_NOTICE, "<chn> <device>|getall|getgranted|getdenied"); lprintf(LOG_NOTICE, "<chn> <device>|getall|getgranted|getdenied");
} }
} }
else if (!strcmp(argv[1], "set")) { else if (!strncmp(argv[1], "set", 3)) {
if (argc > 7) { if (argc > 7) {
int32_t device = -1; int32_t device = -1;
int32_t port = 0; int32_t port = 0;
@ -2194,35 +2096,35 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
/* ATCA led commands */ /* ATCA led commands */
else if (!strcmp(argv[0], "led")) { else if (!strncmp(argv[0], "led", 3)) {
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "prop")) { if (!strncmp(argv[1], "prop", 4)) {
if (argc > 2) { if (argc > 2) {
rc = ipmi_picmg_get_led_properties(intf, &(argv[2])); rc = ipmi_picmg_get_led_properties(intf, argc-1, &(argv[2]));
} }
else { else {
lprintf(LOG_NOTICE, "led prop <FRU-ID>"); lprintf(LOG_NOTICE, "led prop <FRU-ID>");
} }
} }
else if (!strcmp(argv[1], "cap")) { else if (!strncmp(argv[1], "cap", 3)) {
if (argc > 3) { if (argc > 3) {
rc = ipmi_picmg_get_led_capabilities(intf, &(argv[2])); rc = ipmi_picmg_get_led_capabilities(intf, argc-1, &(argv[2]));
} }
else { else {
lprintf(LOG_NOTICE, "led cap <FRU-ID> <LED-ID>"); lprintf(LOG_NOTICE, "led cap <FRU-ID> <LED-ID>");
} }
} }
else if (!strcmp(argv[1], "get")) { else if (!strncmp(argv[1], "get", 3)) {
if (argc > 3) { if (argc > 3) {
rc = ipmi_picmg_get_led_state(intf, &(argv[2])); rc = ipmi_picmg_get_led_state(intf, argc-1, &(argv[2]));
} }
else { else {
lprintf(LOG_NOTICE, "led get <FRU-ID> <LED-ID>"); lprintf(LOG_NOTICE, "led get <FRU-ID> <LED-ID>");
} }
} }
else if (!strcmp(argv[1], "set")) { else if (!strncmp(argv[1], "set", 3)) {
if (argc > 6) { if (argc > 6) {
rc = ipmi_picmg_set_led_state(intf, &(argv[2])); rc = ipmi_picmg_set_led_state(intf, argc-1, &(argv[2]));
} }
else { else {
lprintf(LOG_NOTICE, lprintf(LOG_NOTICE,
@ -2262,11 +2164,11 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
/* power commands */ /* power commands */
else if (!strcmp(argv[0], "power")) { else if (!strncmp(argv[0], "power", 5)) {
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "get")) { if (!strncmp(argv[1], "get", 3)) {
if (argc > 3) { if (argc > 3) {
rc = ipmi_picmg_get_power_level(intf, &(argv[2])); rc = ipmi_picmg_get_power_level(intf, argc-1, &(argv[2]));
} }
else { else {
lprintf(LOG_NOTICE, "power get <FRU-ID> <type>"); lprintf(LOG_NOTICE, "power get <FRU-ID> <type>");
@ -2279,9 +2181,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
return -1; return -1;
} }
} }
else if (!strcmp(argv[1], "set")) { else if (!strncmp(argv[1], "set", 3)) {
if (argc > 4) { if (argc > 4) {
rc = ipmi_picmg_set_power_level(intf, &(argv[2])); rc = ipmi_picmg_set_power_level(intf, argc-1, &(argv[2]));
} }
else { else {
lprintf(LOG_NOTICE, "power set <FRU-ID> <level> <present-desired>"); lprintf(LOG_NOTICE, "power set <FRU-ID> <level> <present-desired>");
@ -2306,9 +2208,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
return -1; return -1;
} }
}/* clk commands*/ }/* clk commands*/
else if (!strcmp(argv[0], "clk")) { else if (!strncmp(argv[0], "clk", 3)) {
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "get")) { if (!strncmp(argv[1], "get", 3)) {
int8_t clk_res = -1; int8_t clk_res = -1;
uint8_t clk_id; uint8_t clk_id;
uint8_t max_res = 15; uint8_t max_res = 15;
@ -2317,7 +2219,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
max_res = 0; max_res = 0;
} }
if(!strcmp(argv[1], "getall")) { if(!strncmp(argv[1], "getall", 6)) {
if( verbose ) { printf("Getting all clock state\n") ;} if( verbose ) { printf("Getting all clock state\n") ;}
for(clk_res=0;clk_res<=max_res;clk_res++) { for(clk_res=0;clk_res<=max_res;clk_res++) {
for(clk_id=0;clk_id<=15;clk_id++) { for(clk_id=0;clk_id<=15;clk_id++) {
@ -2326,7 +2228,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
} }
else if(!strcmp(argv[1], "getdenied")) { else if(!strncmp(argv[1], "getdenied", 6)) {
if( verbose ) { printf("Getting disabled clocks\n") ;} if( verbose ) { printf("Getting disabled clocks\n") ;}
for(clk_res=0;clk_res<=max_res;clk_res++) { for(clk_res=0;clk_res<=max_res;clk_res++) {
for(clk_id=0;clk_id<=15;clk_id++) { for(clk_id=0;clk_id<=15;clk_id++) {
@ -2335,7 +2237,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
} }
} }
} }
else if(!strcmp(argv[1], "getgranted")) { else if(!strncmp(argv[1], "getgranted", 6)) {
if( verbose ) { printf("Getting enabled clocks\n") ;} if( verbose ) { printf("Getting enabled clocks\n") ;}
for(clk_res=0;clk_res<=max_res;clk_res++) { for(clk_res=0;clk_res<=max_res;clk_res++) {
for(clk_id=0;clk_id<=15;clk_id++) { for(clk_id=0;clk_id<=15;clk_id++) {
@ -2364,7 +2266,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
return -1; return -1;
} }
} }
else if (!strcmp(argv[1], "set")) { else if (!strncmp(argv[1], "set", 3)) {
if (argc > 7) { if (argc > 7) {
rc = ipmi_picmg_clk_set(intf, argc-1, &(argv[2])); rc = ipmi_picmg_clk_set(intf, argc-1, &(argv[2]));
} }
@ -2428,7 +2330,7 @@ ipmi_picmg_ipmb_address(struct ipmi_intf *intf) {
uint8_t uint8_t
picmg_discover(struct ipmi_intf *intf) { picmg_discover(struct ipmi_intf *intf) {
/* Check if PICMG extension is available to use the function /* Check if PICMG extension is available to use the function
* GetDeviceLocator to retrieve i2c address PICMG hack to set * GetDeviceLocator to retreive i2c address PICMG hack to set
* right IPMB address, If extension is not supported, should * right IPMB address, If extension is not supported, should
* not give any problems * not give any problems
* PICMG Extension Version 2.0 (PICMG 3.0 Revision 1.0 ATCA) to * PICMG Extension Version 2.0 (PICMG 3.0 Revision 1.0 ATCA) to
@ -2451,13 +2353,13 @@ picmg_discover(struct ipmi_intf *intf) {
req.msg.data_len = 1; req.msg.data_len = 1;
msg_data = 0; msg_data = 0;
lprintf(LOG_DEBUG, "Running Get PICMG Properties my_addr %#x, transit %#x, target %#x", lprintf(LOG_INFO, "Running Get PICMG Properties my_addr %#x, transit %#x, target %#x",
intf->my_addr, intf->transit_addr, intf->target_addr); intf->my_addr, intf->transit_addr, intf->target_addr);
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_DEBUG,"No response from Get PICMG Properties"); lprintf(LOG_INFO,"No response from Get PICMG Properties");
} else if (rsp->ccode) { } else if (rsp->ccode != 0) {
lprintf(LOG_DEBUG,"Error response %#x from Get PICMG Properties", lprintf(LOG_INFO,"Error response %#x from Get PICMG Properities",
rsp->ccode); rsp->ccode);
} else if (rsp->data_len < 4) { } else if (rsp->data_len < 4) {
lprintf(LOG_INFO,"Invalid Get PICMG Properties response length %d", lprintf(LOG_INFO,"Invalid Get PICMG Properties response length %d",
@ -2465,14 +2367,14 @@ picmg_discover(struct ipmi_intf *intf) {
} else if (rsp->data[0] != 0) { } else if (rsp->data[0] != 0) {
lprintf(LOG_INFO,"Invalid Get PICMG Properties group extension %#x", lprintf(LOG_INFO,"Invalid Get PICMG Properties group extension %#x",
rsp->data[0]); rsp->data[0]);
} else if ((rsp->data[1] & 0x0F) != PICMG_ATCA_MAJOR_VERSION } else if ((rsp->data[1] & 0x0F) != PICMG_EXTENSION_ATCA_MAJOR_VERSION
&& (rsp->data[1] & 0x0F) != PICMG_AMC_MAJOR_VERSION && (rsp->data[1] & 0x0F) != PICMG_EXTENSION_AMC0_MAJOR_VERSION
&& (rsp->data[1] & 0x0F) != PICMG_UTCA_MAJOR_VERSION) { && (rsp->data[1] & 0x0F) != PICMG_EXTENSION_UTCA_MAJOR_VERSION) {
lprintf(LOG_INFO,"Unknown PICMG Extension Version %d.%d", lprintf(LOG_INFO,"Unknown PICMG Extension Version %d.%d",
(rsp->data[1] & 0x0F), (rsp->data[1] >> 4)); (rsp->data[1] & 0x0F), (rsp->data[1] >> 4));
} else { } else {
picmg_avail = 1; picmg_avail = 1;
lprintf(LOG_DEBUG, "Discovered PICMG Extension Version %d.%d", lprintf(LOG_INFO, "Discovered PICMG Extension Version %d.%d",
(rsp->data[1] & 0x0f), (rsp->data[1] >> 4)); (rsp->data[1] & 0x0f), (rsp->data[1] >> 4));
} }

View File

@ -1,184 +0,0 @@
/*
* Copyright (c) 2018 Quanta Computer Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Quanta Computer Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
* Quanta Computer Inc. AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
* Quanta Computer Inc. OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
* 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.
*/
#define _XOPEN_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include <ctype.h>
#include <sys/time.h>
#include <limits.h>
#include <fcntl.h>
#include <sys/select.h>
#include <termios.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_mc.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi_sel.h>
#include <ipmitool/ipmi_sdr.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/ipmi_channel.h>
#include <ipmitool/ipmi_quantaoem.h>
#include <ipmitool/ipmi_raw.h>
/* Max Size of the description String to be displyed for the Each sel entry */
#define SIZE_OF_DESC 128
#define CPU_SHIFT 6
#define CPU_MASK 0X03
#define CPU_NUM(x) (((x) >> CPU_SHIFT) & CPU_MASK)
#define CHANNEL_BASE 0x41
#define CHANNEL_SHIFT 3
#define CHANNEL_MASK 0x07
#define CHANNEL_OFFSET(x) (((x) >> CHANNEL_SHIFT) & CHANNEL_MASK)
#define CHANNEL_NUM(x) (CHANNEL_BASE + CHANNEL_OFFSET(x))
#define DIMM_MASK 0x07
#define DIMM_NUM(x) ((x) & DIMM_MASK)
#define GET_PLATFORM_ID_DATA_SIZE 4
// Magic code to check if it's valid command
#define QCT_MAGIC_1 0x4C
#define QCT_MAGIC_2 0x1C
#define QCT_MAGIC_3 0x00
#define QCT_MAGIC_4 0x02
qct_platform_t
oem_qct_get_platform_id(struct ipmi_intf *intf)
{
/* Execute a Get platform ID command to determine the board */
struct ipmi_rs *rsp;
struct ipmi_rq req;
qct_platform_t platform_id;
uint8_t msg_data[GET_PLATFORM_ID_DATA_SIZE];
/* Ask for IPMI v2 data as well */
msg_data[0] = QCT_MAGIC_1;
msg_data[1] = QCT_MAGIC_2;
msg_data[2] = QCT_MAGIC_3;
msg_data[3] = QCT_MAGIC_4;
memset(&req, 0, sizeof(req));
req.msg.netfn = OEM_QCT_NETFN;
req.msg.cmd = OEM_QCT_GET_INFO;
req.msg.data = msg_data;
req.msg.data_len = sizeof(msg_data);
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
lprintf(LOG_ERR, "Get Platform ID command failed");
return 0;
}
if (rsp->ccode) {
lprintf(LOG_ERR, "Get Platform ID command failed: %#x %s",
rsp->ccode, val2str(rsp->ccode, completion_code_vals));
return 0;
}
platform_id = rsp->data[0];
lprintf(LOG_DEBUG,"Platform ID: %hhx", rsp->data[0]);
return platform_id;
}
char *
oem_qct_get_evt_desc(struct ipmi_intf *intf, struct sel_event_record *rec)
{
struct ipmi_rs *rsp;
struct ipmi_rq req;
char *desc = NULL;
int data;
int sensor_type;
qct_platform_t platform_id;
/* Get the OEM event Bytes of the SEL Records byte 15 to data */
data = rec->sel_type.standard_type.event_data[2];
/* Check for the Standard Event type == 0x6F */
if (rec->sel_type.standard_type.event_type != 0x6F) {
goto out;
}
/* Allocate mem for the Description string */
desc = malloc(SIZE_OF_DESC);
if (!desc) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out;
}
memset(desc, 0, SIZE_OF_DESC);
sensor_type = rec->sel_type.standard_type.sensor_type;
switch (sensor_type) {
case SENSOR_TYPE_MEMORY:
memset(&req, 0, sizeof (req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.lun = 0;
req.msg.cmd = BMC_GET_DEVICE_ID;
req.msg.data = NULL;
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
lprintf(LOG_ERR, " Error getting system info");
goto out;
} else if (rsp->ccode) {
lprintf(LOG_ERR, " Error getting system info: %s",
val2str(rsp->ccode, completion_code_vals));
goto out;
}
/* check the platform type */
platform_id = oem_qct_get_platform_id(intf);
if (OEM_QCT_PLATFORM_PURLEY == platform_id) {
snprintf(desc, SIZE_OF_DESC, "CPU%d_%c%d",
CPU_NUM(data),
CHANNEL_NUM(data),
DIMM_NUM(data));
}
break;
default:
goto out;
}
return desc;
out:
if (desc) {
free(desc);
desc = NULL;
}
return desc;
}

View File

@ -101,11 +101,11 @@ ipmi_master_write_read(struct ipmi_intf * intf, uint8_t bus, uint8_t addr,
} }
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "I2C Master Write-Read command failed"); lprintf(LOG_ERR, "I2C Master Write-Read command failed");
return NULL; return NULL;
} }
else if (rsp->ccode) { else if (rsp->ccode > 0) {
switch (rsp->ccode) { switch (rsp->ccode) {
case 0x81: case 0x81:
lprintf(LOG_ERR, "I2C Master Write-Read command failed: Lost Arbitration"); lprintf(LOG_ERR, "I2C Master Write-Read command failed: Lost Arbitration");
@ -145,7 +145,7 @@ ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv)
memset(spd_data, 0, RAW_SPD_SIZE); memset(spd_data, 0, RAW_SPD_SIZE);
if (argc < 2 || !strcmp(argv[0], "help")) { if (argc < 2 || strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "usage: spd <i2cbus> <i2caddr> [channel] [maxread]"); lprintf(LOG_NOTICE, "usage: spd <i2cbus> <i2caddr> [channel] [maxread]");
return 0; return 0;
} }
@ -171,7 +171,7 @@ ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv)
for (i = 0; i < RAW_SPD_SIZE; i+= msize) { for (i = 0; i < RAW_SPD_SIZE; i+= msize) {
rsp = ipmi_master_write_read(intf, i2cbus, i2caddr, rsp = ipmi_master_write_read(intf, i2cbus, i2caddr,
(uint8_t *)&i, 1, msize ); (uint8_t *)&i, 1, msize );
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read"); lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read");
return -1; return -1;
} }
@ -190,9 +190,6 @@ static void rawi2c_usage(void)
lprintf(LOG_NOTICE, " chan=0 is default, bus= must be specified to use chan="); lprintf(LOG_NOTICE, " chan=0 is default, bus= must be specified to use chan=");
} }
#define BUS_KW "bus="
#define CHAN_KW "chan="
int int
ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv) ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
{ {
@ -206,25 +203,25 @@ ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
int i = 0; int i = 0;
/* handle bus= argument */ /* handle bus= argument */
if (argc > 2 && !strncmp(argv[0], BUS_KW, strlen(BUS_KW))) { if (argc > 2 && strncmp(argv[0], "bus=", 4) == 0) {
i = 1; i = 1;
if (!strcmp(argv[0], BUS_KW "public")) if (strncmp(argv[0], "bus=public", 10) == 0)
bus = 0; bus = 0;
else if (sscanf(argv[0], BUS_KW "%u", &rbus) == 1) else if (sscanf(argv[0], "bus=%u", &rbus) == 1)
bus = ((rbus & 7) << 1) | 1; bus = ((rbus & 7) << 1) | 1;
else else
bus = 0; bus = 0;
/* handle channel= argument /* handle channel= argument
* the bus= argument must be supplied first on command line */ * the bus= argument must be supplied first on command line */
if (argc > 3 && !strncmp(argv[1], CHAN_KW, strlen(CHAN_KW))) { if (argc > 3 && strncmp(argv[1], "chan=", 5) == 0) {
i = 2; i = 2;
if (sscanf(argv[1], CHAN_KW "%u", &rbus) == 1) if (sscanf(argv[1], "chan=%u", &rbus) == 1)
bus |= rbus << 4; bus |= rbus << 4;
} }
} }
if ((argc - i) < 2 || !strcmp(argv[0], "help")) { if ((argc-i) < 2 || strncmp(argv[0], "help", 4) == 0) {
rawi2c_usage(); rawi2c_usage();
return 0; return 0;
} }
@ -262,7 +259,7 @@ ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
printbuf(wdata, wsize, "WRITE DATA"); printbuf(wdata, wsize, "WRITE DATA");
rsp = ipmi_master_write_read(intf, bus, i2caddr, wdata, wsize, rsize); rsp = ipmi_master_write_read(intf, bus, i2caddr, wdata, wsize, rsize);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read"); lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read");
return -1; return -1;
} }
@ -325,7 +322,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
int i; int i;
uint8_t data[256]; uint8_t data[256];
if (argc == 1 && !strcmp(argv[0], "help")) { if (argc == 1 && strncmp(argv[0], "help", 4) == 0) {
ipmi_raw_help(); ipmi_raw_help();
return 0; return 0;
} }
@ -382,13 +379,13 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to send RAW command " lprintf(LOG_ERR, "Unable to send RAW command "
"(channel=0x%x netfn=0x%x lun=0x%x cmd=0x%x)", "(channel=0x%x netfn=0x%x lun=0x%x cmd=0x%x)",
intf->target_channel & 0x0f, req.msg.netfn, req.msg.lun, req.msg.cmd); intf->target_channel & 0x0f, req.msg.netfn, req.msg.lun, req.msg.cmd);
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Unable to send RAW command " lprintf(LOG_ERR, "Unable to send RAW command "
"(channel=0x%x netfn=0x%x lun=0x%x cmd=0x%x rsp=0x%x): %s", "(channel=0x%x netfn=0x%x lun=0x%x cmd=0x%x rsp=0x%x): %s",
intf->target_channel & 0x0f, req.msg.netfn, req.msg.lun, req.msg.cmd, rsp->ccode, intf->target_channel & 0x0f, req.msg.netfn, req.msg.lun, req.msg.cmd, rsp->ccode,
@ -420,7 +417,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
*/ */
int int
is_valid_param(const char *input_param, uint8_t *uchr_ptr, const char *label) { is_valid_param(const char *input_param, uint8_t *uchr_ptr, const char *label) {
if (!input_param || !label) { if (input_param == NULL || label == NULL) {
lprintf(LOG_ERROR, "ERROR: NULL pointer passed."); lprintf(LOG_ERROR, "ERROR: NULL pointer passed.");
return (-1); return (-1);
} }

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,7 @@ partial_send(struct ipmi_intf *intf, struct ipmi_rq *req, uint16_t *id)
{ {
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
rsp = intf->sendrecv(intf, req); rsp = intf->sendrecv(intf, req);
if (!rsp) { if (rsp == NULL) {
return -1; return -1;
} }
@ -115,7 +115,7 @@ ipmi_sdr_add_record(struct ipmi_intf *intf, struct sdr_record_list *sdrr)
} }
sdr_rq = (struct sdr_add_rq *)malloc(sizeof(*sdr_rq) + sdr_max_write_len); sdr_rq = (struct sdr_add_rq *)malloc(sizeof(*sdr_rq) + sdr_max_write_len);
if (!sdr_rq) { if (sdr_rq == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1; return -1;
} }
@ -202,11 +202,11 @@ ipmi_sdr_repo_clear(struct ipmi_intf *intf)
for (try = 0; try < 5; try++) { for (try = 0; try < 5; try++) {
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to clear SDRR"); lprintf(LOG_ERR, "Unable to clear SDRR");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Unable to clear SDRR: %s", lprintf(LOG_ERR, "Unable to clear SDRR: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -248,11 +248,11 @@ sdrr_get_records(struct ipmi_intf *intf, struct ipmi_sdr_iterator *itr,
queue->head = NULL; queue->head = NULL;
queue->tail = NULL; queue->tail = NULL;
while ((header = ipmi_sdr_get_next_header(intf, itr))) { while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL) {
struct sdr_record_list *sdrr; struct sdr_record_list *sdrr;
sdrr = malloc(sizeof (struct sdr_record_list)); sdrr = malloc(sizeof (struct sdr_record_list));
if (!sdrr) { if (sdrr == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1; return -1;
} }
@ -263,10 +263,10 @@ sdrr_get_records(struct ipmi_intf *intf, struct ipmi_sdr_iterator *itr,
sdrr->type = header->type; sdrr->type = header->type;
sdrr->length = header->length; sdrr->length = header->length;
sdrr->raw = ipmi_sdr_get_record(intf, header, itr); sdrr->raw = ipmi_sdr_get_record(intf, header, itr);
(void)ipmi_sdr_print_name_from_rawentry(sdrr->id, sdrr->type,sdrr->raw); (void)ipmi_sdr_print_name_from_rawentry(intf, sdrr->id, sdrr->type,sdrr->raw);
/* put in the record queue */ /* put in the record queue */
if (!queue->head) if (queue->head == NULL)
queue->head = sdrr; queue->head = sdrr;
else else
queue->tail->next = sdrr; queue->tail->next = sdrr;
@ -295,12 +295,12 @@ sdr_copy_to_sdrr(struct ipmi_intf *intf, int use_builtin,
printf("Load SDRs from 0x%x\n", from_addr); printf("Load SDRs from 0x%x\n", from_addr);
rc = sdrr_get_records(intf, itr, &sdrr_queue); rc = sdrr_get_records(intf, itr, &sdrr_queue);
ipmi_sdr_end(itr); ipmi_sdr_end(intf, itr);
/* ... */ /* ... */
/* write the SDRs to the destination SDR Repository */ /* write the SDRs to the destination SDR Repository */
intf->target_addr = to_addr; intf->target_addr = to_addr;
for (sdrr = sdrr_queue.head; sdrr; sdrr = sdrr_next) { for (sdrr = sdrr_queue.head; sdrr != NULL; sdrr = sdrr_next) {
sdrr_next = sdrr->next; sdrr_next = sdrr->next;
rc = ipmi_sdr_add_record(intf, sdrr); rc = ipmi_sdr_add_record(intf, sdrr);
if(rc < 0){ if(rc < 0){
@ -433,7 +433,7 @@ int ipmi_parse_range_list(const char *rangeList, unsigned char * pHexList)
do do
{ {
if(nextString) if(nextString != NULL)
{ {
(*nextString)= 0; (*nextString)= 0;
nextString ++; nextString ++;
@ -446,7 +446,8 @@ int ipmi_parse_range_list(const char *rangeList, unsigned char * pHexList)
/* At this point, it is a single entry or a range */ /* At this point, it is a single entry or a range */
rangeString = strstr( inProcessString, "-" ); rangeString = strstr( inProcessString, "-" );
if (!rangeString) { if(rangeString == NULL)
{
unsigned char decValue = 0; unsigned char decValue = 0;
/* Single entry */ /* Single entry */
@ -596,7 +597,7 @@ ipmi_sdr_read_records(const char *filename, struct sdrr_queue *queue)
lprintf(LOG_DEBUG, "binHdr[4] (length) = 0x%02x", binHdr[4]); lprintf(LOG_DEBUG, "binHdr[4] (length) = 0x%02x", binHdr[4]);
sdrr = malloc(sizeof(*sdrr)); sdrr = malloc(sizeof(*sdrr));
if (!sdrr) { if (sdrr == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
rc = -1; rc = -1;
break; break;
@ -606,8 +607,7 @@ ipmi_sdr_read_records(const char *filename, struct sdrr_queue *queue)
sdrr->type = binHdr[3]; sdrr->type = binHdr[3];
sdrr->length = binHdr[4]; sdrr->length = binHdr[4];
sdrr->raw = malloc(sdrr->length); if ((sdrr->raw = malloc(sdrr->length)) == NULL) {
if (!sdrr->raw) {
lprintf(LOG_ERR, "ipmitool: malloc failure"); lprintf(LOG_ERR, "ipmitool: malloc failure");
free(sdrr); free(sdrr);
sdrr = NULL; sdrr = NULL;
@ -626,7 +626,7 @@ ipmi_sdr_read_records(const char *filename, struct sdrr_queue *queue)
} }
/* put in the record queue */ /* put in the record queue */
if (!queue->head) if (queue->head == NULL)
queue->head = sdrr; queue->head = sdrr;
else else
queue->tail->next = sdrr; queue->tail->next = sdrr;
@ -654,7 +654,7 @@ ipmi_sdr_add_from_file(struct ipmi_intf *intf, const char *ifile)
} }
/* write the SDRs to the SDR Repository */ /* write the SDRs to the SDR Repository */
for (sdrr = sdrr_queue.head; sdrr; sdrr = sdrr_next) { for (sdrr = sdrr_queue.head; sdrr != NULL; sdrr = sdrr_next) {
sdrr_next = sdrr->next; sdrr_next = sdrr->next;
rc = ipmi_sdr_add_record(intf, sdrr); rc = ipmi_sdr_add_record(intf, sdrr);
if(rc < 0){ if(rc < 0){

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ ipmi_sensor_get_sensor_reading_factors(
char id[17]; char id[17];
if (!intf || !sensor) if (intf == NULL || sensor == NULL)
return -1; return -1;
memset(id, 0, sizeof(id)); memset(id, 0, sizeof(id));
@ -80,7 +80,7 @@ ipmi_sensor_get_sensor_reading_factors(
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error updating reading factor for sensor %s (#%02x)", lprintf(LOG_ERR, "Error updating reading factor for sensor %s (#%02x)",
id, sensor->cmn.keys.sensor_num); id, sensor->cmn.keys.sensor_num);
return -1; return -1;
@ -164,30 +164,12 @@ ipmi_sensor_print_fc_discrete(struct ipmi_intf *intf,
sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr_record_type, 3); sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr_record_type, 3);
if (!sr) { if (sr == NULL) {
return -1; return -1;
} }
if (csv_output) { if (csv_output) {
printf("%s", sr->s_id); /* NOT IMPLEMENTED */
if (sr->s_reading_valid) {
if (sr->s_has_analog_value) {
/* don't show discrete component */
printf(",%s,%s,%s",
sr->s_a_str, sr->s_a_units, "ok");
} else {
printf(",0x%x,%s,0x%02x%02x",
sr->s_reading, "discrete",
sr->s_data2, sr->s_data3);
}
} else {
printf(",%s,%s,%s",
"na", "discrete", "na");
}
printf(",%s,%s,%s,%s,%s,%s",
"na", "na", "na", "na", "na", "na");
printf("\n");
} else { } else {
if (verbose == 0) { if (verbose == 0) {
/* output format /* output format
@ -260,184 +242,6 @@ print_thresh_setting(struct sdr_record_full_sensor *full,
} }
} }
static void
dump_sensor_fc_thredshold_csv(
int thresh_available,
const char *thresh_status,
struct ipmi_rs *rsp,
struct sensor_reading *sr)
{
printf("%s", sr->s_id);
if (sr->s_reading_valid) {
if (sr->s_has_analog_value)
printf(",%.3f,%s,%s",
sr->s_a_val, sr->s_a_units, thresh_status);
else
printf(",0x%x,%s,%s",
sr->s_reading, sr->s_a_units, thresh_status);
} else {
printf(",%s,%s,%s",
"na", sr->s_a_units, "na");
}
if (thresh_available && sr->full) {
#define PTS(bit, dataidx) { \
print_thresh_setting(sr->full, rsp->data[0] & (bit), \
rsp->data[(dataidx)], ",", "%.3f", "0x%x", "%s"); \
}
PTS(LOWER_NON_RECOV_SPECIFIED, 3);
PTS(LOWER_CRIT_SPECIFIED, 2);
PTS(LOWER_NON_CRIT_SPECIFIED, 1);
PTS(UPPER_NON_CRIT_SPECIFIED, 4);
PTS(UPPER_CRIT_SPECIFIED, 5);
PTS(UPPER_NON_RECOV_SPECIFIED, 6);
#undef PTS
} else {
printf(",%s,%s,%s,%s,%s,%s",
"na", "na", "na", "na", "na", "na");
}
printf("\n");
}
/* output format
* id value units status thresholds....
*/
static void
dump_sensor_fc_thredshold(
int thresh_available,
const char *thresh_status,
struct ipmi_rs *rsp,
struct sensor_reading *sr)
{
printf("%-16s ", sr->s_id);
if (sr->s_reading_valid) {
if (sr->s_has_analog_value)
printf("| %-10.3f | %-10s | %-6s",
sr->s_a_val, sr->s_a_units, thresh_status);
else
printf("| 0x%-8x | %-10s | %-6s",
sr->s_reading, sr->s_a_units, thresh_status);
} else {
printf("| %-10s | %-10s | %-6s",
"na", sr->s_a_units, "na");
}
if (thresh_available && sr->full) {
#define PTS(bit, dataidx) { \
print_thresh_setting(sr->full, rsp->data[0] & (bit), \
rsp->data[(dataidx)], "| ", "%-10.3f", "0x%-8x", "%-10s"); \
}
PTS(LOWER_NON_RECOV_SPECIFIED, 3);
PTS(LOWER_CRIT_SPECIFIED, 2);
PTS(LOWER_NON_CRIT_SPECIFIED, 1);
PTS(UPPER_NON_CRIT_SPECIFIED, 4);
PTS(UPPER_CRIT_SPECIFIED, 5);
PTS(UPPER_NON_RECOV_SPECIFIED, 6);
#undef PTS
} else {
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
"na", "na", "na", "na", "na", "na");
}
printf("\n");
}
static void
dump_sensor_fc_thredshold_verbose(
int thresh_available,
const char *thresh_status,
struct ipmi_intf *intf,
struct sdr_record_common_sensor *sensor,
struct ipmi_rs *rsp,
struct sensor_reading *sr)
{
printf("Sensor ID : %s (0x%x)\n",
sr->s_id, sensor->keys.sensor_num);
printf(" Entity ID : %d.%d\n",
sensor->entity.id, sensor->entity.instance);
printf(" Sensor Type (Threshold) : %s\n",
ipmi_get_sensor_type(intf, sensor->sensor.type));
printf(" Sensor Reading : ");
if (sr->s_reading_valid) {
if (sr->full) {
uint16_t raw_tol = __TO_TOL(sr->full->mtol);
if (sr->s_has_analog_value) {
double tol =
sdr_convert_sensor_tolerance(sr->full,
raw_tol);
printf("%.*f (+/- %.*f) %s\n",
(sr->s_a_val == (int)
sr->s_a_val) ? 0 : 3,
sr->s_a_val,
(tol == (int) tol) ? 0 : 3, tol,
sr->s_a_units);
} else {
printf("0x%x (+/- 0x%x) %s\n",
sr->s_reading,
raw_tol,
sr->s_a_units);
}
} else {
printf("0x%x %s\n",
sr->s_reading, sr->s_a_units);
}
printf(" Status : %s\n", thresh_status);
if (thresh_available) {
if (sr->full) {
#define PTS(bit, dataidx, str) { \
print_thresh_setting(sr->full, rsp->data[0] & (bit), \
rsp->data[(dataidx)], \
(str), "%.3f\n", "0x%x\n", "%s\n"); \
}
PTS(LOWER_NON_RECOV_SPECIFIED, 3, " Lower Non-Recoverable : ");
PTS(LOWER_CRIT_SPECIFIED, 2, " Lower Critical : ");
PTS(LOWER_NON_CRIT_SPECIFIED, 1, " Lower Non-Critical : ");
PTS(UPPER_NON_CRIT_SPECIFIED, 4, " Upper Non-Critical : ");
PTS(UPPER_CRIT_SPECIFIED, 5, " Upper Critical : ");
PTS(UPPER_NON_RECOV_SPECIFIED, 6, " Upper Non-Recoverable : ");
#undef PTS
}
ipmi_sdr_print_sensor_hysteresis(sensor, sr->full,
sr->full ? sr->full->threshold.hysteresis.positive :
sr->compact->threshold.hysteresis.positive,
"Positive Hysteresis");
ipmi_sdr_print_sensor_hysteresis(sensor, sr->full,
sr->full ? sr->full->threshold.hysteresis.negative :
sr->compact->threshold.hysteresis.negative,
"Negative Hysteresis");
} else {
printf(" Sensor Threshold Settings not available\n");
}
} else {
printf(" Unable to read sensor: Device Not Present\n\n");
}
ipmi_sdr_print_sensor_event_status(intf,
sensor->keys.
sensor_num,
sensor->sensor.type,
sensor->event_type,
ANALOG_SENSOR,
sensor->keys.owner_id,
sensor->keys.lun,
sensor->keys.channel);
ipmi_sdr_print_sensor_event_enable(intf,
sensor->keys.
sensor_num,
sensor->sensor.type,
sensor->event_type,
ANALOG_SENSOR,
sensor->keys.owner_id,
sensor->keys.lun,
sensor->keys.channel);
printf("\n");
}
static int static int
ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf, ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf,
struct sdr_record_common_sensor *sensor, struct sdr_record_common_sensor *sensor,
@ -449,7 +253,7 @@ ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf,
sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr_record_type, 3); sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr_record_type, 3);
if (!sr) { if (sr == NULL) {
return -1; return -1;
} }
@ -462,17 +266,137 @@ ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf,
sensor->keys.sensor_num, sensor->keys.owner_id, sensor->keys.sensor_num, sensor->keys.owner_id,
sensor->keys.lun, sensor->keys.channel); sensor->keys.lun, sensor->keys.channel);
if (!rsp || rsp->ccode || !rsp->data_len) if ((rsp == NULL) || (rsp->ccode > 0) || (rsp->data_len == 0))
thresh_available = 0; thresh_available = 0;
if (csv_output) { if (csv_output) {
dump_sensor_fc_thredshold_csv(thresh_available, thresh_status, rsp, sr); /* NOT IMPLEMENTED */
} else { } else {
if (verbose == 0) { if (verbose == 0) {
dump_sensor_fc_thredshold(thresh_available, thresh_status, rsp, sr); /* output format
* id value units status thresholds....
*/
printf("%-16s ", sr->s_id);
if (sr->s_reading_valid) {
if (sr->s_has_analog_value)
printf("| %-10.3f | %-10s | %-6s",
sr->s_a_val, sr->s_a_units, thresh_status);
else
printf("| 0x%-8x | %-10s | %-6s",
sr->s_reading, sr->s_a_units, thresh_status);
} else {
printf("| %-10s | %-10s | %-6s",
"na", sr->s_a_units, "na");
}
if (thresh_available && sr->full) {
#define PTS(bit, dataidx) { \
print_thresh_setting(sr->full, rsp->data[0] & (bit), \
rsp->data[(dataidx)], "| ", "%-10.3f", "0x-8x", "%-10s"); \
}
PTS(LOWER_NON_RECOV_SPECIFIED, 3);
PTS(LOWER_CRIT_SPECIFIED, 2);
PTS(LOWER_NON_CRIT_SPECIFIED, 1);
PTS(UPPER_NON_CRIT_SPECIFIED, 4);
PTS(UPPER_CRIT_SPECIFIED, 5);
PTS(UPPER_NON_RECOV_SPECIFIED, 6);
#undef PTS
} else {
printf
("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
"na", "na", "na", "na", "na", "na");
}
printf("\n");
} else { } else {
dump_sensor_fc_thredshold_verbose(thresh_available, thresh_status, printf("Sensor ID : %s (0x%x)\n",
intf, sensor, rsp, sr); sr->s_id, sensor->keys.sensor_num);
printf(" Entity ID : %d.%d\n",
sensor->entity.id, sensor->entity.instance);
printf(" Sensor Type (Threshold) : %s\n",
ipmi_get_sensor_type(intf, sensor->sensor.
type));
printf(" Sensor Reading : ");
if (sr->s_reading_valid) {
if (sr->full) {
uint16_t raw_tol = __TO_TOL(sr->full->mtol);
if (sr->s_has_analog_value) {
double tol =
sdr_convert_sensor_tolerance(sr->full,
raw_tol);
printf("%.*f (+/- %.*f) %s\n",
(sr->s_a_val == (int)
sr->s_a_val) ? 0 : 3,
sr->s_a_val,
(tol == (int) tol) ? 0 : 3, tol,
sr->s_a_units);
} else {
printf("0x%x (+/- 0x%x) %s\n",
sr->s_reading,
raw_tol,
sr->s_a_units);
}
} else {
printf("0x%x %s\n", sr->s_reading,
sr->s_a_units);
}
printf(" Status : %s\n", thresh_status);
if (thresh_available) {
if (sr->full) {
#define PTS(bit, dataidx, str) { \
print_thresh_setting(sr->full, rsp->data[0] & (bit), \
rsp->data[(dataidx)], \
(str), "%.3f\n", "0x%x\n", "%s\n"); \
}
PTS(LOWER_NON_RECOV_SPECIFIED, 3, " Lower Non-Recoverable : ");
PTS(LOWER_CRIT_SPECIFIED, 2, " Lower Critical : ");
PTS(LOWER_NON_CRIT_SPECIFIED, 1, " Lower Non-Critical : ");
PTS(UPPER_NON_CRIT_SPECIFIED, 4, " Upper Non-Critical : ");
PTS(UPPER_CRIT_SPECIFIED, 5, " Upper Critical : ");
PTS(UPPER_NON_RECOV_SPECIFIED, 6, " Upper Non-Recoverable : ");
#undef PTS
}
ipmi_sdr_print_sensor_hysteresis(sensor, sr->full,
sr->full ? sr->full->threshold.hysteresis.positive :
sr->compact->threshold.hysteresis.positive,
"Positive Hysteresis");
ipmi_sdr_print_sensor_hysteresis(sensor, sr->full,
sr->full ? sr->full->threshold.hysteresis.negative :
sr->compact->threshold.hysteresis.negative,
"Negative Hysteresis");
} else {
printf(" Sensor Threshold Settings not available\n");
}
} else {
printf(" Unable to read sensor: Device Not Present\n\n");
}
ipmi_sdr_print_sensor_event_status(intf,
sensor->keys.
sensor_num,
sensor->sensor.type,
sensor->event_type,
ANALOG_SENSOR,
sensor->keys.owner_id,
sensor->keys.lun,
sensor->keys.channel);
ipmi_sdr_print_sensor_event_enable(intf,
sensor->keys.
sensor_num,
sensor->sensor.type,
sensor->event_type,
ANALOG_SENSOR,
sensor->keys.owner_id,
sensor->keys.lun,
sensor->keys.channel);
printf("\n");
} }
} }
@ -500,16 +424,16 @@ ipmi_sensor_list(struct ipmi_intf *intf)
lprintf(LOG_DEBUG, "Querying SDR for sensor list"); lprintf(LOG_DEBUG, "Querying SDR for sensor list");
itr = ipmi_sdr_start(intf, 0); itr = ipmi_sdr_start(intf, 0);
if (!itr) { if (itr == NULL) {
lprintf(LOG_ERR, "Unable to open SDR for reading"); lprintf(LOG_ERR, "Unable to open SDR for reading");
return -1; return -1;
} }
while ((header = ipmi_sdr_get_next_header(intf, itr))) { while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL) {
uint8_t *rec; uint8_t *rec;
rec = ipmi_sdr_get_record(intf, header, itr); rec = ipmi_sdr_get_record(intf, header, itr);
if (!rec) { if (rec == NULL) {
lprintf(LOG_DEBUG, "rec == NULL"); lprintf(LOG_DEBUG, "rec == NULL");
continue; continue;
} }
@ -532,7 +456,7 @@ ipmi_sensor_list(struct ipmi_intf *intf)
/* rc = (r == 0) ? rc : r; */ /* rc = (r == 0) ? rc : r; */
} }
ipmi_sdr_end(itr); ipmi_sdr_end(intf, itr);
return rc; return rc;
} }
@ -557,11 +481,11 @@ __ipmi_sensor_set_threshold(struct ipmi_intf *intf,
rsp = ipmi_sensor_set_sensor_thresholds(intf, num, mask, setting, rsp = ipmi_sensor_set_sensor_thresholds(intf, num, mask, setting,
target, lun, channel); target, lun, channel);
if (!rsp) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error setting threshold"); lprintf(LOG_ERR, "Error setting threshold");
return -1; return -1;
} }
if (rsp->ccode) { if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error setting threshold: %s", lprintf(LOG_ERR, "Error setting threshold: %s",
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; return -1;
@ -605,7 +529,7 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
struct sdr_record_list *sdr; struct sdr_record_list *sdr;
if (argc < 3 || !strcmp(argv[0], "help")) { if (argc < 3 || strncmp(argv[0], "help", 4) == 0) {
print_sensor_thresh_usage(); print_sensor_thresh_usage();
return 0; return 0;
} }
@ -613,7 +537,7 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
id = argv[0]; id = argv[0];
thresh = argv[1]; thresh = argv[1];
if (!strcmp(thresh, "upper")) { if (strncmp(thresh, "upper", 5) == 0) {
if (argc < 5) { if (argc < 5) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"usage: sensor thresh <id> upper <unc> <ucr> <unr>"); "usage: sensor thresh <id> upper <unc> <ucr> <unr>");
@ -635,7 +559,7 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
argv[4]); argv[4]);
return (-1); return (-1);
} }
} else if (!strcmp(thresh, "lower")) { } else if (strncmp(thresh, "lower", 5) == 0) {
if (argc < 5) { if (argc < 5) {
lprintf(LOG_ERR, lprintf(LOG_ERR,
"usage: sensor thresh <id> lower <lnr> <lcr> <lnc>"); "usage: sensor thresh <id> lower <lnr> <lcr> <lnc>");
@ -658,17 +582,17 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
return (-1); return (-1);
} }
} else { } else {
if (!strcmp(thresh, "unr")) if (strncmp(thresh, "unr", 3) == 0)
settingMask = UPPER_NON_RECOV_SPECIFIED; settingMask = UPPER_NON_RECOV_SPECIFIED;
else if (!strcmp(thresh, "ucr")) else if (strncmp(thresh, "ucr", 3) == 0)
settingMask = UPPER_CRIT_SPECIFIED; settingMask = UPPER_CRIT_SPECIFIED;
else if (!strcmp(thresh, "unc")) else if (strncmp(thresh, "unc", 3) == 0)
settingMask = UPPER_NON_CRIT_SPECIFIED; settingMask = UPPER_NON_CRIT_SPECIFIED;
else if (!strcmp(thresh, "lnc")) else if (strncmp(thresh, "lnc", 3) == 0)
settingMask = LOWER_NON_CRIT_SPECIFIED; settingMask = LOWER_NON_CRIT_SPECIFIED;
else if (!strcmp(thresh, "lcr")) else if (strncmp(thresh, "lcr", 3) == 0)
settingMask = LOWER_CRIT_SPECIFIED; settingMask = LOWER_CRIT_SPECIFIED;
else if (!strcmp(thresh, "lnr")) else if (strncmp(thresh, "lnr", 3) == 0)
settingMask = LOWER_NON_RECOV_SPECIFIED; settingMask = LOWER_NON_RECOV_SPECIFIED;
else { else {
lprintf(LOG_ERR, lprintf(LOG_ERR,
@ -688,7 +612,7 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
/* lookup by sensor name */ /* lookup by sensor name */
sdr = ipmi_sdr_find_sdr_byid(intf, id); sdr = ipmi_sdr_find_sdr_byid(intf, id);
if (!sdr) { if (sdr == NULL) {
lprintf(LOG_ERR, "Sensor data record not found!"); lprintf(LOG_ERR, "Sensor data record not found!");
return -1; return -1;
} }
@ -797,7 +721,7 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
sdr->record.common->keys.owner_id, sdr->record.common->keys.owner_id,
sdr->record.common->keys.lun, sdr->record.common->keys.lun,
sdr->record.common->keys.channel); sdr->record.common->keys.channel);
if (!rsp || rsp->ccode) { if ((rsp == NULL) || (rsp->ccode > 0)) {
lprintf(LOG_ERR, "Sensor data record not found!"); lprintf(LOG_ERR, "Sensor data record not found!");
return -1; return -1;
} }
@ -886,7 +810,7 @@ ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv)
struct sdr_record_list *sdr; struct sdr_record_list *sdr;
int i, rc=0; int i, rc=0;
if (argc < 1 || !strcmp(argv[0], "help")) { if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "sensor reading <id> ... [id]"); lprintf(LOG_NOTICE, "sensor reading <id> ... [id]");
lprintf(LOG_NOTICE, " id : name of desired sensor"); lprintf(LOG_NOTICE, " id : name of desired sensor");
return -1; return -1;
@ -894,7 +818,7 @@ ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv)
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]); sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]);
if (!sdr) { if (sdr == NULL) {
lprintf(LOG_ERR, "Sensor \"%s\" not found!", lprintf(LOG_ERR, "Sensor \"%s\" not found!",
argv[i]); argv[i]);
rc = -1; rc = -1;
@ -909,7 +833,7 @@ ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv)
struct sdr_record_common_sensor *sensor = sdr->record.common; struct sdr_record_common_sensor *sensor = sdr->record.common;
sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr->type, 3); sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr->type, 3);
if (!sr) { if (sr == NULL) {
rc = -1; rc = -1;
continue; continue;
} }
@ -950,7 +874,7 @@ ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "Not enough parameters given."); lprintf(LOG_ERR, "Not enough parameters given.");
print_sensor_get_usage(); print_sensor_get_usage();
return (-1); return (-1);
} else if (!strcmp(argv[0], "help")) { } else if (strcmp(argv[0], "help") == 0) {
print_sensor_get_usage(); print_sensor_get_usage();
return 0; return 0;
} }
@ -958,7 +882,7 @@ ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv)
/* lookup by sensor name */ /* lookup by sensor name */
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]); sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]);
if (!sdr) { if (sdr == NULL) {
lprintf(LOG_ERR, "Sensor data record \"%s\" not found!", lprintf(LOG_ERR, "Sensor data record \"%s\" not found!",
argv[i]); argv[i]);
rc = -1; rc = -1;
@ -995,15 +919,15 @@ ipmi_sensor_main(struct ipmi_intf *intf, int argc, char **argv)
if (argc == 0) { if (argc == 0) {
rc = ipmi_sensor_list(intf); rc = ipmi_sensor_list(intf);
} else if (!strcmp(argv[0], "help")) { } else if (strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "Sensor Commands: list thresh get reading"); lprintf(LOG_NOTICE, "Sensor Commands: list thresh get reading");
} else if (!strcmp(argv[0], "list")) { } else if (strncmp(argv[0], "list", 4) == 0) {
rc = ipmi_sensor_list(intf); rc = ipmi_sensor_list(intf);
} else if (!strcmp(argv[0], "thresh")) { } else if (strncmp(argv[0], "thresh", 5) == 0) {
rc = ipmi_sensor_set_threshold(intf, argc - 1, &argv[1]); rc = ipmi_sensor_set_threshold(intf, argc - 1, &argv[1]);
} else if (!strcmp(argv[0], "get")) { } else if (strncmp(argv[0], "get", 3) == 0) {
rc = ipmi_sensor_get(intf, argc - 1, &argv[1]); rc = ipmi_sensor_get(intf, argc - 1, &argv[1]);
} else if (!strcmp(argv[0], "reading")) { } else if (strncmp(argv[0], "reading", 7) == 0) {
rc = ipmi_sensor_get_reading(intf, argc - 1, &argv[1]); rc = ipmi_sensor_get_reading(intf, argc - 1, &argv[1]);
} else { } else {
lprintf(LOG_ERR, "Invalid sensor command: %s", argv[0]); lprintf(LOG_ERR, "Invalid sensor command: %s", argv[0]);

Some files were not shown because too many files have changed in this diff Show More