Compare commits

..

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

164 changed files with 12523 additions and 25947 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

39
.gitignore vendored
View File

@ -1,39 +0,0 @@
.deps
.dirstamp
.libs
.*.swp
*.log
*.rej
*.orig
*.o
*.lo
*.la
*.*~
Makefile
Makefile.in
aclocal.m4
autom4te.cache
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
ltmain.sh
libtool
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

558
ChangeLog
View File

@ -1,527 +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
* 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
version 1.8.17 2016-05-01
* 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
version 1.8.16 2015-11-22
* 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
version 1.8.15 2014-11-24
* ID: 340 - ipmitool sol session improperly closes on packet retry
* ID: 277 - support for hostnames longer than 64 chars
@ -882,7 +358,7 @@ version 1.8.11 released 2009-02-25
* Patch ID 1990560 to get readings from non-linear analog sensors
* Add support for SOL payload status command
* 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)
* Added retries to SOL keepalive
* Fixed wrong mask values for Front Panel disable/enable status
@ -898,14 +374,14 @@ version 1.8.11 released 2009-02-25
* Fix occasional SDR dump segfault; #1793076
* Allow ipmitool sel delete to accept hex list entry numbers
* 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
* ipmievd change to Monitor %used in SEL buffer and log warnings when
the buffer is 80% and 100% full
version 1.8.10 released 2008-08-08
* 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.
* Added support for Debian packages to be built from CVS
* Fix for sdr and sel timestamp reporting issues
@ -914,11 +390,11 @@ version 1.8.10 released 2008-08-08
* Change ipmi_chassis_status() to non-static so it can be used
externally
* 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
* Fix bug in sdr free space reporting
* Add support for IANA number to vendor name conversion for many
vendors
vendors
* Fix segfault bug in lan set command
* Fix bug in population of raw i2c wdata buffer
* Fix bug in ipmb sensor reading
@ -932,7 +408,7 @@ version 1.8.10 released 2008-08-08
* Add more JEDEC support info for DIMMs; decrease request size
for DIMM FRU info to 16 bytes at a time to allow more
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
* Fix HPM firmware activation via IOL; fake a timeout after IOL
session re-open to force get upgrade status retry;
@ -941,11 +417,11 @@ version 1.8.10 released 2008-08-08
* Fix for oemval2str size
* Add support for product name resolution in mc info
* Fix FRU display format
* Added PICMG ekeying analyzer module support (ekanalyzer);
display point to point physical connectivity and power
supply information between carriers and AMC modules;
display matched results of ekeying match between an
on-carrier device and AMC module or between 2 AMC modules
* Added PICMG ekeying analyzer module support (ekanalyzer);
display point to point physical connectivity and power
supply information between carriers and AMC modules;
display matched results of ekeying match between an
on-carrier device and AMC module or between 2 AMC modules
* Fix AMC GUID display support
* Improved amcportstate operations
* Added resolution for new sensor types
@ -958,8 +434,8 @@ version 1.8.10 released 2008-08-08
* Added SPD support for parms: channel number, max read size
* Add SDR support for adding SDR records from a dumped file,
clearing SDR, adding partial SDR records
* Add updates and fixes to hpmfwupg: upload block size to 32 bytes
for KCS, handle long response option, implement rollback
* Add updates and fixes to hpmfwupg: upload block size to 32 bytes
for KCS, handle long response option, implement rollback
override, garbage output fix
* Add double bridge lan support , fix bridging issue
* Add HPM support to pre-check which components need to be skipped
@ -993,7 +469,7 @@ version 1.8.9 released 2007-03-06
* Added edit support for AMC activation "Maximum Internal Current"
* Fix bug generating garbage on the screen when handling GetDeviceId
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
* Fix lan set access command to use value already saved within
parameters for PEF and authentication
@ -1011,13 +487,13 @@ version 1.8.9 released 2007-03-06
* Fix SOL set errors when commit-write not supported
* Fix reset of session timeout for lanplus interface
* 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.
* Fix missing firmware firewall top-level command
* Fix bug in SOL keepalive functionality
* Fix SOLv2 NACK and retry handling for Intel ESB2 BMC
* Added ipmi_sel_get_oem_sensor* APIs
* Added HPM.1 support
* Added HPM.1 support
* Fix segfault when incorrect oem option supplied
* Fix bus problem with spd command
* Fix segfault in SOL when remote BMC does not return packet
@ -1031,7 +507,7 @@ version 1.8.9 released 2007-03-06
* Add freeipmi interface support
* Add remote spd printing
* 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
* Fix segfaults in sensor data repository list

431
INSTALL
View File

@ -1,431 +0,0 @@
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
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
==================
Briefly, the followong shell command should configure, build, and
install this package:
./bootstrap && ./configure && make && sudo make install
For Windows the above command must be run inside a cygwin bash
shell.
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
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved. Use GNU `make'
instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf limitation. Until the limitation is lifted, you can use
this workaround:
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@ -28,10 +28,10 @@
# 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.
DOCDIR = $(docdir)
DOCDIR = $(datadir)/doc/$(PACKAGE)
DOCLIST = $(top_srcdir)/README $(top_srcdir)/COPYING $(top_srcdir)/AUTHORS $(top_srcdir)/ChangeLog
EXTRA_DIST = $(DOCLIST) bootstrap
EXTRA_DIST = $(DOCLIST)
AUTOMAKE_OPTIONS = dist-bzip2
@ -41,49 +41,15 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure configure-stamp \
$(distdir).tar.gz $(distdir).tar.bz2
SUBDIRS = lib src include doc contrib control
IANA_PEN = http://www.iana.org/assignments/enterprise-numbers.txt
dist-hook:
cp control/ipmitool.spec $(distdir)
.PHONY: install-pen-database uninstall-pen-database
.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
install-data-local:
mkdir -p $(DESTDIR)$(DOCDIR)
$(INSTALL_DATA) $(DOCLIST) $(DESTDIR)$(DOCDIR)
uninstall-local: uninstall-pen-database
uninstall-local:
-rm -rf $(DESTDIR)$(DOCDIR)
.PHONY: pkg
@ -101,8 +67,12 @@ SRCDIR = ${shell cd $(top_srcdir) ; pwd | sed -e 's,^[^:\\/]:[\\/],/,'}
RPMDIR = $(BUILDDIR)/rpmbuild
.PHONY: rpm
rpm: dist
@RPMBUILD@ -ta --define "_topdir $(RPMDIR)" $(distdir).tar.gz
rpm: control/ipmitool.spec dist
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
clean-rpm:

0
NEWS
View File

17
README
View File

@ -24,7 +24,7 @@ Background
==========
I originally wrote ipmitool while between projects and employeed at Sun
Microsystems. Sun had just embarked on a new line of general-purpose x86
servers that included an OEM Intel board with an IPMIv1.5 BMC on board.
servers that inclued an OEM Intel board with an IPMIv1.5 BMC on board.
It started with an idea that remote chassis power control would be a handy
feature for my systems in the lab and from there it grew into a multi-
purpose tool that lots of people found useful. I decided to release it
@ -42,8 +42,8 @@ Requirements
============
Obviously the largest requirement is hardware with a service processor
that supports the IPMI specification. Many x86-based servers are now
coming with IPMI support, check with your preferred hardware vendor
about available products.
comming with IPMI support, check with your preferred hardware vendor
about available prodcuts.
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
@ -126,7 +126,7 @@ hardware will come with a utility (often a DOS bootable CD) for configuring
enabling the LAN interface as well.
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
hash function at compile time but if that is not found it will use an
internal library.
@ -396,13 +396,16 @@ ipmievd: Memory Sensor 01 - Correctable ECC
Resources
=========
IPMItool homepage
http://github.com/ipmitool/ipmitool
http://ipmitool.sourceforge.net
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
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
http://openipmi.sourceforge.net

View File

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

View File

@ -1,13 +1,11 @@
dnl
dnl autoconf for ipmitool
dnl
m4_define([git_suffix], m4_esyscmd_s(./csv-revision))
AC_INIT([ipmitool], [1.8.19git_suffix])
AC_CONFIG_SRCDIR([src/ipmitool.c])
AC_CONFIG_COMMANDS_PRE([export prefix=$prefix])
AC_INIT([src/ipmitool.c])
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([foreign])
AM_INIT_AUTOMAKE([ipmitool], [1.8.15-cvs])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_SRCDIR([src/ipmitool.c])
AC_PREREQ(2.50)
AC_SUBST(ac_configure_args)
@ -28,13 +26,14 @@ AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
AC_FUNC_MALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRTOD
AC_CHECK_FUNCS([alarm gethostbyname getaddrinfo getifaddrs socket select])
AC_CHECK_FUNCS([memmove memset strchr strdup strerror])
AC_CHECK_FUNCS([getpassphrase])
CFLAGS="$CFLAGS -Wall -Wextra -std=gnu11 -pedantic -Wformat -Wformat-nonliteral"
CFLAGS="$CFLAGS -fno-strict-aliasing -Wreturn-type"
AM_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --silent"
@ -54,48 +53,17 @@ if test "x$exec_prefix" = "xNONE"; then
exec_prefix="$prefix"
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 set default option values
dnl
xenable_all_options=yes
xenable_intf_bmc=no
xenable_intf_dbus=no
xenable_intf_dummy=no
xenable_intf_imb=yes
xenable_intf_lipmi=yes
xenable_intf_open=yes
xenable_intf_lipmi=yes
#xenable_intf_serial=yes
xenable_intf_usb=no
xenable_intf_dummy=no
xenable_all_options=yes
xenable_ipmishell=yes
dnl set some things so we build with GNU tools on Solaris
@ -120,29 +88,31 @@ solaris*)
xenable_intf_imb=no
xenable_intf_open=no
xenable_intf_lipmi=no
xenable_intf_bmc=no
;;
*darwin*|aix*)
# disable the linux and solaris-specific interfaces
xenable_intf_imb=no
xenable_intf_open=no
xenable_intf_lipmi=no
xenable_intf_bmc=no
xenable_ipmishell=no
;;
*freebsd*)
xenable_intf_imb=no
xenable_intf_lipmi=no
CFLAGS="$CFLAGS -D__BSD_VISIBLE"
xenable_intf_bmc=no
;;
*netbsd*)
xenable_intf_imb=no
xenable_intf_lipmi=no
xenable_intf_bmc=no
xenable_intf_open=no
;;
gnu*)
# disable the linux and solaris-specific interfaces on Hurd
xenable_intf_imb=no
xenable_intf_open=no
xenable_intf_usb=yes
;;
esac
@ -161,24 +131,6 @@ if test "x$xenable_all_options" = "xyes" || test "x$xenable_solaris_opt" = "xyes
AC_DEFINE(ENABLE_ALL_OPTIONS, [1], [Define to 1 to enable all command line options.])
fi
dnl Determine anonymous union/structure support in GCC
AC_TRY_COMPILE([
#include <stdio.h>
], [
struct test {
union {
int a;
unsigned int b;
};
} test;
printf("a is %d", test.a);
], ac_need_fms_extension=no, ac_need_fms_extension=yes)
if test "x$ac_need_fms_extension" = "xyes"; then
CFLAGS="$CFLAGS -fms-extensions"
AC_SUBST(CFLAGS)
fi
dnl check for OpenSSL functionality
AC_ARG_ENABLE([internal-md5],
[AC_HELP_STRING([--enable-internal-md5],
@ -192,16 +144,6 @@ AC_CHECK_LIB([crypto], [EVP_aes_128_cbc],
fi],
[have_crypto=no], [-lcrypto])
AC_CHECK_LIB([crypto], [EVP_sha256],
[if test "x$xenable_internal_sha256" != "xyes"; then
if test "x$have_crypto" != "xyes"; then
LIBS="$LIBS -lcrypto"
have_sha256=yes
fi
AC_DEFINE(HAVE_CRYPTO_SHA256, [1], [Define to 1 if libcrypto supports SHA256.])
fi],
[], [-lcrypto])
AC_CHECK_LIB([crypto], [MD5_Init],
[if test "x$xenable_internal_md5" != "xyes"; then
if test "x$have_crypto" != "xyes"; then
@ -222,14 +164,6 @@ AC_CHECK_LIB([crypto], [MD2_Init],
fi],
[], [-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
AC_ARG_ENABLE([intf-lan],
[AC_HELP_STRING([--enable-intf-lan],
@ -246,22 +180,6 @@ if test "x$xenable_intf_lan" = "xyes"; then
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lan/libintf_lan.la"
fi
dnl enable IPMI USB interface
AC_ARG_ENABLE([intf-usb],
[AC_HELP_STRING([--enable-intf-usb],
[enable IPMI USB interface [default=auto]])],
[xenable_intf_usb=$enableval],
[xenable_intf_usb=$xenable_intf_usb])
if test "x$xenable_intf_usb" = "xstatic" || test "x$xenable_intf_usb" = "xplugin"; then
xenable_intf_usb=yes
fi
if test "x$xenable_intf_usb" = "xyes"; then
AC_DEFINE(IPMI_INTF_USB, [1], [Define to 1 to enable USB interface.])
AC_SUBST(INTF_USB, [usb])
AC_SUBST(INTF_USB_LIB, [libintf_usb.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB usb/libintf_usb.la"
fi
dnl enable IPMIv2.0 RMCP+ LAN interface
AC_ARG_ENABLE([intf-lanplus],
[AC_HELP_STRING([--enable-intf-lanplus],
@ -593,25 +511,6 @@ if test "x$xenable_intf_bmc" = "xyes"; then
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB bmc/libintf_bmc.la"
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
AC_ARG_ENABLE([intf-dummy],
[AC_HELP_STRING([--enable-intf-dummy],
@ -626,22 +525,30 @@ fi
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_HELP_STRING([--enable-ipmishell],
[enable IPMI shell interface [default=auto]])],
[xenable_ipmishell=$enableval],
[])
dnl check for readline library to enable ipmi shell
if test "x$xenable_ipmishell" = "xyes"; then
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([READLINE], [readline],
[LIBS="$LIBS $READLINE_LIBS" have_readline=yes],
[AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])]
)
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"; then
AC_MSG_ERROR([** Unable to find curses required by ipmishell.])
fi
if test "x$have_readline" != "xyes"; then
AC_MSG_ERROR([** Unable to find readline required by ipmishell.])
xenable_ipmishell=no
fi
AC_DEFINE(HAVE_READLINE, [1], [Define to 1 if readline present.])
fi
@ -693,50 +600,6 @@ AC_TRY_COMPILE([],[
[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
AC_CONFIG_FILES([Makefile
@ -745,6 +608,7 @@ AC_CONFIG_FILES([Makefile
control/Makefile
control/pkginfo
control/prototype
control/rpmmacros
control/ipmitool.spec
lib/Makefile
include/Makefile
@ -757,28 +621,22 @@ AC_CONFIG_FILES([Makefile
src/plugins/free/Makefile
src/plugins/imb/Makefile
src/plugins/bmc/Makefile
src/plugins/dbus/Makefile
src/plugins/usb/Makefile
src/plugins/lipmi/Makefile
src/plugins/serial/Makefile
src/plugins/dummy/Makefile
doc/ipmitool.1
doc/ipmievd.8])
src/plugins/dummy/Makefile])
AC_OUTPUT
AC_MSG_RESULT([])
AC_MSG_RESULT([ipmitool $VERSION])
AC_MSG_RESULT([])
AC_MSG_RESULT([Interfaces (default=$DEFAULT_INTF)])
AC_MSG_RESULT([Interfaces])
AC_MSG_RESULT([ lan : $xenable_intf_lan])
AC_MSG_RESULT([ lanplus : $xenable_intf_lanplus])
AC_MSG_RESULT([ open : $xenable_intf_open])
AC_MSG_RESULT([ free : $xenable_intf_free])
AC_MSG_RESULT([ imb : $xenable_intf_imb])
AC_MSG_RESULT([ bmc : $xenable_intf_bmc])
AC_MSG_RESULT([ dbus : $xenable_intf_dbus])
AC_MSG_RESULT([ usb : $xenable_intf_usb])
AC_MSG_RESULT([ lipmi : $xenable_intf_lipmi])
AC_MSG_RESULT([ serial : $xenable_intf_serial])
AC_MSG_RESULT([ dummy : $xenable_intf_dummy])

View File

@ -35,7 +35,7 @@ dist_pkgdata_DATA = oem_ibm_sel_map
EXTRA_DIST = README \
bmclanconf ipmi.init.basic ipmi.init.redhat \
exchange-bmc-os-info.init.redhat exchange-bmc-os-info.service.redhat \
exchange-bmc-os-info.sysconf log_bmc.sh\
exchange-bmc-os-info.sysconf \
ipmievd.init.redhat ipmievd.init.suse ipmievd.init.debian \
collect_data.sh create_rrds.sh create_webpage_compact.sh create_webpage.sh \
bmc-snmp-proxy bmc-snmp-proxy.service bmc-snmp-proxy.sysconf

View File

@ -3,7 +3,7 @@
#
# bmc-snmp-proxy: Set SNMP proxy to BMC (Baseboard Management Controller)
#
# version: 0.62
# version: 0.6
#
# Authors: Charles Rose <charles_rose@dell.com>
# Jordan Hargrave <jordan_hargrave@dell.com>
@ -20,16 +20,16 @@
SYSCONF_DIR="/etc/sysconfig"
CONFIG="${SYSCONF_DIR}/bmc-snmp-proxy"
SNMPD_BMC_CONF_DIR="/etc/snmp/bmc"
SNMPD_BMC_CONF="${SNMPD_BMC_CONF_DIR}/snmpd.local.conf"
TRAPD_BMC_CONF="${SNMPD_BMC_CONF_DIR}/snmptrapd.local.conf"
SNMPD_LOCAL_CONF_DIR="/etc/snmp/bmc"
SNMPD_LOCAL_CONF="${SNMPD_LOCAL_CONF_DIR}/snmpd.local.conf"
TRAPD_LOCAL_CONF="${SNMPD_LOCAL_CONF_DIR}/snmptrapd.local.conf"
TRAPD_CONF="/etc/snmp/snmptrapd.conf"
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
BMC_COMMUNITY="public"
@ -57,16 +57,14 @@ bmc_info_exists()
else
RETVAL=2
fi
return $RETVAL
}
check_snmp()
{
if [ ! -d /etc/snmp ] || [ ! -x /usr/sbin/snmpd ]; then
if [ ! -d /etc/snmp ] && [ ! -x /usr/sbin/snmpd ]; then
RETVAL=12
fi
return $RETVAL
}
@ -79,12 +77,11 @@ write_snmp_conf()
printf "###############################################\n"
printf "# Automatically created by %s #\n" "${SCRIPT_NAME}"
printf "###############################################\n"
printf "#view bmcview included %s 80\n" "${BMC_OID}"
printf "#com2sec -Cn bmc_ctx bmc_sec default bmc_cmty\n"
printf "#group bmc_grp v1 bmc_sec\n"
printf "#access bmc_grp bmc_ctx any noauth exact bmcview none none\n"
printf "#proxy -Cn bmc_ctx -v 1 %s\n" "${PROXY_TOKEN}"
printf "proxy -v 1 %s\n" "${PROXY_TOKEN}"
printf "view bmcview included %s 80\n" "${BMC_OID}"
printf "com2sec -Cn bmc_ctx bmc_sec default bmc_cmty\n"
printf "group bmc_grp v1 bmc_sec\n"
printf "access bmc_grp bmc_ctx any noauth exact bmcview none none\n"
printf "proxy -Cn bmc_ctx -v 1 %s\n" "${PROXY_TOKEN}"
printf "###############################################\n"
}
@ -95,7 +92,6 @@ valid_ip()
printf -- "%s" "${1}"| grep -Eq \
"^${octet}\\.${octet}\\.${octet}\\.${octet}$"
return $?
}
@ -116,38 +112,37 @@ set_snmp_proxy()
if check_vars; then
PROXY_TOKEN="-c ${BMC_COMMUNITY} ${BMC_IPv4} ${BMC_OID}"
if [ -d ${SNMPD_BMC_CONF_DIR} ]; then
write_snmp_conf > ${SNMPD_BMC_CONF} || RETVAL=4
if [ ! -d ${SNMPD_LOCAL_CONF_DIR} ] && \
mkdir ${SNMPD_LOCAL_CONF_DIR}; then
write_snmp_conf > ${SNMPD_LOCAL_CONF}
[ $? -ne 0 ] && RETVAL=4
fi
else
RETVAL=3
fi
}
set_snmpd_conf_path()
{
if [ ! -d ${SNMPD_BMC_CONF_DIR} ]; then
mkdir ${SNMPD_BMC_CONF_DIR} || RETVAL=7
fi
# We need SNMPCONFPATH set for both snmpd and snmptrapd
for sysconf in ${SYSCONF_DIR}/snmp*d;
for SYSCONF in ${SYSCONF_DIR}/snmp*d;
do
if ! grep -q "^SNMPCONFPATH.*${SNMPD_BMC_CONF_DIR}" \
"${sysconf}" > /dev/null 2>&1; then
printf "SNMPCONFPATH=/etc/snmp:%s\n" \
"${SNMPD_BMC_CONF_DIR}" >> ${sysconf} || \
RETVAL=7
if grep -q "${SNMPD_LOCAL_CONF_DIR}" "${SYSCONF}" > \
/dev/null 2>&1; then
continue
else
printf "SNMPCONFPATH=%s\n" "${SNMPD_LOCAL_CONF_DIR}" \
>> ${SYSCONF} || RETVAL=7
fi
done
return $RETVAL
}
disable_snmp_proxy()
{
if [ -f ${SNMPD_BMC_CONF} ]; then
rm -f ${SNMPD_BMC_CONF} || RETVAL=5
if [ -f ${SNMPD_LOCAL_CONF} ]; then
rm -f ${SNMPD_LOCAL_CONF}
[ $? -ne 0 ] && RETVAL=5
fi
}
#############################################################################
@ -157,8 +152,7 @@ disable_snmp_proxy()
pick_alert_dest()
{
test_ip="$1"
# 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
temp_ip=$(${IPMITOOL} lan alert print ${CHANNEL} ${ALERT_DEST}\
2>/dev/null| sed -n "s#^Alert IP Address.*: ##p")
@ -171,14 +165,14 @@ pick_alert_dest()
set_alert_dest_ip()
{
${IPMITOOL} lan alert set ${CHANNEL} ${ALERT_DEST} ipaddr ${1} \
retry 4 type pet >/dev/null 2>&1 || RETVAL=8
retry 4 type pet >/dev/null 2>&1
[ $? -ne 0 ] && RETVAL=8
}
config_bmc_alert_dest()
bmc_alert_dest()
{
# call with enable|disable
# Pick the first active LAN channel
for CHANNEL in $(seq 1 14)
for CHANNEL in `seq 1 14`
do
[ $(${IPMITOOL} -I open channel info ${CHANNEL} 2>/dev/null \
| grep -q "802\.3") ] || break
@ -186,12 +180,12 @@ config_bmc_alert_dest()
# If TRAPD_IP is already set as an alert dest,
if pick_alert_dest "${TRAPD_IP}"; then
# disable: reset it if we are called with disable
[ "${1}" = "disable" ] && \
# reset: reset it if we are called with reset
[ "${1}" = "reset" ] && \
set_alert_dest_ip "0.0.0.0"
# else, find the next free alert dest,
elif pick_alert_dest "0.0.0.0"; then
[ "${1}" = "disable" ] && \
[ "${1}" = "reset" ] && \
return $RETVAL
# set: the TRAPD_IP
set_alert_dest_ip "${TRAPD_IP}"
@ -199,54 +193,42 @@ config_bmc_alert_dest()
# No free alert destinations
RETVAL=9
fi
return $RETVAL
}
set_ipmi_pef()
set_ipmi_alert()
{
# Needs ipmitool-1.8.13 + patches
${IPMITOOL} pef policy set ${ALERT_DEST} "${1}" >/dev/null 2>&1 || \
RETVAL=10
${IPMITOOL} lan set ${CHANNEL} alert "${1}" >/dev/null 2>&1
[ $? -ne 0 ] && RETVAL=10
}
get_host_ip()
{
# Get host's IP that the BMC can reach. This is at best a hack.
# Get host's IP that the BMC can reach.
IFACE=$(/usr/sbin/ip -o -f inet address |awk '!/: lo/ {print $2}')
for dev in ${IFACE}
do
temp_ping=$(ping -c 1 -I ${dev} ${BMC_IPv4})
[ $? -ne 0 ] && continue
printf -- "%s" "$temp_ping"| awk 'NR==1{print $5}' && break
ping -c 1 -I ${dev} ${BMC_IPv4} > /dev/null 2>&1
done
}
config_bmc_alert()
{
# Do two things
# Set/Reset TRAP IP in BMC
# Enable/Disable PEF alerting in BMC for TRAP
# Get Host's IP that the BMC can send traps to
TRAPD_IP=$(get_host_ip)
# Set Host's IP as the alert destination in the BMC
valid_ip ${TRAPD_IP} && config_bmc_alert_dest "${ACTION}"
valid_ip ${TRAPD_IP} && bmc_alert_dest "${ACTION}"
# Enable/Disable alerting on the LAN channel
[ $RETVAL -eq 0 ] && set_ipmi_pef "${ACTION}"
return $RETVAL
# Enable alerting on the LAN channel
[ $RETVAL -eq 0 ] && set_ipmi_alert "${ACTION}"
}
write_trapd_conf()
{
printf "###############################################\n"
printf "# Automatically created by %s #\n" "${SCRIPT_NAME}"
printf "forward default %s\n" "${FORWARD_HOST}"
printf "forward %s %s\n" "${BMC_OID}*" "${FORWARD_HOST}"
printf "###############################################\n"
}
@ -254,9 +236,10 @@ config_trapd()
{
# Proceed only if snmptrapd is available on the system
if [ -f ${TRAPD_CONF} ]; then
write_trapd_conf > ${TRAPD_BMC_CONF} || RETVAL=11
write_trapd_conf > ${TRAPD_LOCAL_CONF}
[ $? -ne 0 ] && RETVAL=11
else
RETVAL=11
return 1
fi
}
@ -266,7 +249,6 @@ trap_sink_exists()
# multiple
FORWARD_HOST=$(awk '/^trap.*sink/{print $2}; /^informsink/{print $2}' \
/etc/snmp/snmpd*conf | head -1)
if [ -z "${FORWARD_HOST}" ]; then
# there is no trapsink setup.
return 1
@ -279,20 +261,19 @@ trap_sink_exists()
trap_forward()
{
NO_TRAP=0
ACTION=${1} # enable or disable
ACTION=${1} # set or reset
if [ "${ACTION}" = "enable" ]; then
if [ "${ACTION}" = "set" ]; then
# Get trapd config,
if trap_sink_exists; then
config_bmc_alert && config_trapd
config_trapd && config_bmc_alert
else
# exit silently if there is no sink
NO_TRAP=1
fi
else
if [ -f ${TRAPD_BMC_CONF} ]; then
rm -f ${TRAPD_BMC_CONF} >/dev/null 2>&1
config_bmc_alert
if [ -f ${TRAPD_LOCAL_CONF} ]; then
rm -f ${TRAPD_LOCAL_CONF} >/dev/null 2>&1
else
NO_TRAP=1
fi
@ -307,6 +288,7 @@ service_reload()
service $1 reload
[ $? -ne 0 ] && RETVAL=6
fi
return
}
#############################################################################
@ -314,12 +296,11 @@ start()
{
if bmc_info_exists && check_snmp; then
touch ${LOCKFILE}
set_snmpd_conf_path && set_snmp_proxy
[ $RETVAL -eq 0 ] && service_reload snmpd
if [ "${TRAP_FORWARD}" = "yes" ]; then
trap_forward "enable"
trap_forward "set"
[ $RETVAL -eq 0 ] && [ $NO_TRAP -eq 0 ] && \
service_reload snmptrapd
fi
@ -335,11 +316,10 @@ stop()
[ $RETVAL -eq 0 ] && service_reload snmpd
if [ "${TRAP_FORWARD}" = "yes" ]; then
trap_forward "disable"
trap_forward "reset"
[ $RETVAL -eq 0 ] && [ $NO_TRAP -eq 0 ] && \
service_reload snmptrapd
fi
rm -f ${LOCKFILE}
fi
}
@ -349,13 +329,12 @@ status()
{
eval_gettext "${SCRIPT_NAME}: snmp proxy to BMC is "
# Checking for lockfile is better.
#if grep -q "^proxy" "${SNMPD_BMC_CONF}" > /dev/null 2>&1 ; then
#if grep -q "^proxy" "${SNMPD_LOCAL_CONF}" > /dev/null 2>&1 ; then
if [ -f ${LOCKFILE} ]; then
eval_gettext "set"
else
eval_gettext "not set"
fi
echo
RETVAL=0
}
@ -381,10 +360,10 @@ case "$RETVAL" in
0|1) ;;
2) eval_gettext "${SCRIPT_NAME}: failed to read ${BMC_INFO} " 1>&2 ;;
3) eval_gettext "${SCRIPT_NAME}: failed to get proxy config." 1>&2 ;;
4) eval_gettext "${SCRIPT_NAME}: failed to set ${SNMPD_BMC_CONF}." 1>&2 ;;
4) eval_gettext "${SCRIPT_NAME}: failed to set ${SNMPD_LOCAL_CONF}." 1>&2 ;;
5) eval_gettext "${SCRIPT_NAME}: failed to disable snmp proxy." 1>&2 ;;
6) eval_gettext "${SCRIPT_NAME}: failed to reload snmpd." 1>&2 ;;
7) eval_gettext "${SCRIPT_NAME}: failed to set snmpd config." 1>&2 ;;
7) eval_gettext "${SCRIPT_NAME}: failed to update ${SYSCONF}." 1>&2 ;;
8) eval_gettext "${SCRIPT_NAME}: failed to set IPMI alert dest." 1>&2 ;;
9) eval_gettext "${SCRIPT_NAME}: no free IPMI alert dest." 1>&2 ;;
10) eval_gettext "${SCRIPT_NAME}: failed to set IPMI PEF." 1>&2 ;;
@ -396,7 +375,6 @@ esac
if [ ${RETVAL} -gt 1 ]; then
eval_gettext " Return code: ${RETVAL}"; echo
fi
exit ${RETVAL}
#############################################################################
# end of file

View File

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

View File

@ -12,10 +12,10 @@
# Description: Script to set OS information in the BMC; fetch BMC IP/URL
# 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:
# # . /run/bmc-info
# # . /var/run/bmc-info
# # xdg-open $BMC_URL
#
# See here for details:
@ -42,7 +42,7 @@
#############################################################################
CONFIGFILE=/etc/sysconfig/exchange-bmc-os-info
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'
DELL="674"

View File

@ -1,8 +1,7 @@
[Unit]
Description=Exchange Information between BMC and OS
After=network.target
AssertFileIsExecutable=/usr/bin/ipmitool
AssertPathExistsGlob=/dev/ipmi*
After=ipmi.service network.target
Requires=ipmi.service
[Service]
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"
NAME=ipmievd
DAEMON=/usr/sbin/$NAME
PIDFILE=/run/$NAME.pid
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.

View File

@ -1,88 +0,0 @@
#!/bin/sh
#############################################################################
#
# log_bmc.sh: Add SEL entries to indicate OS Boot/Install status.
#
# version: 0.1
#
# Authors: Charles Rose <charles_rose@dell.com>
# Jordan Hargrave <jordan_hargrave@dell.com>
#
# Description: Script to log OS boot/install status to the BMC. Primarily
# meant for use in automated installs and start up scripts.
# Will provide administrators with OS boot/install status in
# BMC and aid with debugging.
#
# Example usage:
# # ./log_bmc.sh inst_start
# # ipmitool sel list
# b | 05/07/2014 | 12:07:32 | OS Boot | Installation started
#
# See here for details:
# https://fedoraproject.org/wiki/Features/AgentFreeManagement
#
#############################################################################
IPMI_CMD="/usr/bin/ipmitool"
#############################################################################
# SEL Event types from ipmi_sel.h
OS_STOP="0x20"
OS_BOOT="0x1f"
# SEL Event data from ipmi_sel.h
GRACEFUL_SHUTDOWN="0x03" # OS Stop/Shutdown: Installation started
BOOT_COMPLETED="0x01" # OS Boot: Installation started
INSTALL_STARTED="0x07" # OS Boot: Installation started
INSTALL_COMPLETED="0x08" # OS Boot: Installation completed
INSTALL_ABORTED="0x09" # OS Boot: Installation aborted
INSTALL_FAILED="0x0a" # OS Boot: Installation failed
##########################################################################
# check for ipmi functionality.
check_ipmi()
{
# ensures presence of ipmitool and /dev/ipmi*
${IPMI_CMD} mc info > /dev/null 2>&1
[ $? -ne 0 ] && RETVAL=2
}
# Write out the events to SEL
ipmi_sel_add()
{
# Refer ipmitool(1) event for details on format.
printf "0x04 %s 0x00 0x6f %s 0x00 0x00" ${type} ${status} > \
${tmpfile} && \
${IPMI_CMD} sel add ${tmpfile} > /dev/null 2>&1
[ $? -ne 0 ] && RETVAL=3
}
### Main
# Most of the status is for this event type
tmpfile=$(/usr/bin/mktemp)
RETVAL=0
type=${OS_BOOT}
case ${1} in
os_shutdown) type=${OS_STOP}; status=${GRACEFUL_SHUTDOWN} ;;
os_boot) status=${BOOT_COMPLETED} ;;
inst_start) status=${INSTALL_STARTED} ;;
inst_complete) status=${INSTALL_COMPLETED} ;;
inst_abort) status=${INSTALL_ABORTED} ;;
inst_fail) status=${INSTALL_FAILED} ;;
*) RETVAL=1 ;;
esac
[ ${RETVAL} -eq 0 ] && check_ipmi
[ ${RETVAL} -eq 0 ] && ipmi_sel_add ${status}
case ${RETVAL} in
0) ;;
1) printf -- %s\\n "Usage: $0 <os_boot|os_shutdown|inst_start|inst_complete|inst_abort|inst_fail>" ;;
2) printf -- %s\\n "failed to communicate with BMC." ;;
3) printf -- %s\\n "error adding ipmi sel entry." ;;
esac
[ -f ${tmpfile} ] && rm -f ${tmpfile} > /dev/null 2>&1
exit ${RETVAL}
### End

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","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"

View File

@ -31,7 +31,7 @@
MAINTAINERCLEANFILES = Makefile.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
Summary: ipmitool - Utility for IPMI control
Version: @VERSION@
Release: @RPM_RELEASE@%{?_distro:.%{_distro}}
License: BSD
Group: Utilities
#Packager: PackagerName <packager@example.com>
Distribution: GitHub Build
Packager: Jim Mankovich <jmank@hp.com>
Source: %{name}-%{version}.tar.gz
Buildroot: /var/tmp/ipmitool-root
@ -34,7 +31,7 @@ fi
%setup
%build
./configure \
./configure --with-kerneldir \
--with-rpm-distro=@DISTRO@ \
--prefix=%{_prefix} \
--bindir=%{_bindir} \
@ -59,632 +56,11 @@ fi
%attr(755,root,root) %{_bindir}/*
%attr(755,root,root) %{_sbindir}/*
%{_datadir}/ipmitool/*
%{_datadir}/misc/*
%{_mandir}/man*/*
%doc %{_datadir}/doc/ipmitool
%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
- Fix new GCC compilation issues in regards to Packing
- Fix Tracker bug #1642710 - ipmi_kcs_drv being loaded/unloaded
@ -881,7 +257,7 @@ fi
- Make ipmievd generate pidfile
- 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
- Add keepalive timer to IPMIv2 SOL sessions
@ -949,7 +325,7 @@ fi
- new "shell" and "exec" commands
- 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 set a particular sensor threshold
- Add support for displaying V2 channel authentication levels
@ -983,7 +359,7 @@ fi
- Fix SEL event decoding for generic events
- Handle empty SEL gracefully when doing "sel list"
- 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
- 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
.br
Commands:
open Use OpenIPMI for asynchronous notification of events
open Use OpenIPMI for asyncronous notification of events
sel Poll SEL for notification of events
.TP
@ -174,7 +174,7 @@ Do NOT become a daemon, instead log all messages to stderr.
.TP
\fIpidfile\fP=<\fBfilename\fR>
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).
.RE
@ -197,7 +197,7 @@ Do NOT become a daemon, instead log all messages to stderr.
.TP
\fIpidfile\fP=<\fBfilename\fR>
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).
.TP
\fItimeout\fP=<\fBseconds\fR>
@ -217,16 +217,6 @@ Reading Sensors...
.br
Waiting for Events...
.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"
Duncan Laurie <duncan@iceblink.org>
.SH "SEE ALSO"

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,5 @@ noinst_HEADERS = log.h bswap.h hpm2.h helper.h ipmi.h ipmi_cc.h ipmi_intf.h \
ipmi_oem.h ipmi_sdradd.h ipmi_isol.h ipmi_sunoem.h ipmi_picmg.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_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_delloem.h ipmi_dcmi.h

View File

@ -30,7 +30,8 @@
* 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
# include <config.h>
@ -48,3 +49,5 @@
# define BSWAP_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) |\
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#endif
#endif /* IPMI_BSWAP_H */

View File

@ -30,16 +30,13 @@
* 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 <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h> /* For free() */
#include <stdbool.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#ifndef TRUE
#define TRUE 1
@ -53,12 +50,6 @@
#define tboolean int
#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 */
#ifndef IPMI_UID_MIN
# define IPMI_UID_MIN 1
@ -70,7 +61,7 @@
struct ipmi_intf;
struct valstr {
uint32_t val;
uint16_t val;
const char * str;
};
struct oemvalstr {
@ -79,12 +70,8 @@ struct oemvalstr {
const char * str;
};
const char *
specific_val2str(uint32_t val,
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);
const char * val2str(uint16_t val, const struct valstr * vs);
const char * oemval2str(uint32_t oem,uint16_t val, const struct oemvalstr * vs);
int str2double(const char * str, double * double_ptr);
int str2long(const char * str, int64_t * lng_ptr);
@ -96,118 +83,24 @@ int str2ushort(const char * str, uint16_t * ushrt_ptr);
int str2char(const char * str, int8_t * chr_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 is_fru_id(const char *argv_ptr, uint8_t *fru_id_ptr);
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_priv_limit(const char *argv_ptr, uint8_t *ipmi_priv_limit_ptr);
uint32_t str2val32(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);
}
uint16_t str2val(const char * str, const struct valstr * vs);
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);
uint16_t buf2short(uint8_t * buf);
uint32_t buf2long(uint8_t * buf);
#define BUF2STR_MAXIMUM_OUTPUT_SIZE (3*1024 + 1)
const char * buf2str_extended(const uint8_t *buf, int len, const char *sep);
const char * buf2str(const uint8_t *buf, int len);
int str2mac(const char *arg, uint8_t *buf);
const char * mac2str(const uint8_t *buf);
int ipmi_parse_hex(const char *str, uint8_t *out, int size);
const char * buf2str(uint8_t * buf, int len);
void printbuf(const uint8_t * buf, int len, const char * desc);
uint8_t ipmi_csum(uint8_t * d, int s);
FILE * ipmi_open_file(const char * file, int rw);
void ipmi_start_daemon(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_write(file) ipmi_open_file(file, 1)
@ -226,3 +119,5 @@ uint8_t *array_letoh(uint8_t *buffer, size_t length);
#ifndef __maxlen
# define __maxlen(a, b) ({ int x=strlen(a); int y=strlen(b); (x > y) ? x : y;})
#endif
#endif /* IPMI_HELPER_H */

View File

@ -30,8 +30,6 @@
* EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#pragma once
#include <stdint.h>
#include <ipmitool/ipmi_intf.h>
@ -45,7 +43,7 @@
* MSN = present revision,
* LSN = oldest revision parameter is
* backward compatible with. */
#define LAN_PARAM_REV(x, y) (((x) << 4) | ((y) & 0xF))
#define LAN_PARAM_REV(x, y) ((x) << 4 | (y) & 0xF)
/* HPM.2 capabilities */
#define HPM2_CAPS_SOL_EXTENSION 0x01

View File

@ -30,7 +30,8 @@
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#pragma once
#ifndef IPMI_H
#define IPMI_H
#include <stdlib.h>
#include <stdio.h>
@ -45,7 +46,6 @@
#endif
#define IPMI_BUF_SIZE 1024
#define IPMI_MAX_MD_SIZE 0x20
#if HAVE_PRAGMA_PACK
#define ATTRIBUTE_PACKING
@ -211,13 +211,13 @@ struct ipmi_rs {
uint32_t console_id;
uint8_t bmc_rand[16]; /* Random number generated by the BMC */
uint8_t bmc_guid[16];
uint8_t key_exchange_auth_code[IPMI_MAX_MD_SIZE];
uint8_t key_exchange_auth_code[20];
} rakp2_message;
struct {
uint8_t message_tag;
uint8_t rakp_return_code;
uint32_t console_id;
uint8_t integrity_check_value[IPMI_MAX_MD_SIZE];
uint8_t integrity_check_value[20];
} rakp4_message;
struct {
uint8_t packet_sequence_number;
@ -251,17 +251,8 @@ struct ipmi_rs {
/* These values are IANA numbers */
/************************************************************************
* Add ID String for IANA Enterprise Number of IBM & ADLINK
* https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers
************************************************************************/
typedef enum IPMI_OEM {
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] */
IPMI_OEM_IBM_2 = 2,
IPMI_OEM_HP = 11,
IPMI_OEM_SUN = 42,
IPMI_OEM_NOKIA = 94,
@ -269,7 +260,6 @@ typedef enum IPMI_OEM {
IPMI_OEM_HITACHI_116 = 116,
IPMI_OEM_NEC = 119,
IPMI_OEM_TOSHIBA = 186,
IPMI_OEM_ERICSSON = 193,
IPMI_OEM_INTEL = 343,
IPMI_OEM_TATUNG = 373,
IPMI_OEM_HITACHI_399 = 399,
@ -277,13 +267,9 @@ typedef enum IPMI_OEM {
IPMI_OEM_LMC = 2168,
IPMI_OEM_RADISYS = 4337,
IPMI_OEM_BROADCOM = 4413,
/* 4769 for [IBM Corporation] */
IPMI_OEM_IBM_4769 = 4769,
IPMI_OEM_MAGNUM = 5593,
IPMI_OEM_TYAN = 6653,
IPMI_OEM_QUANTA = 7244,
IPMI_OEM_VIKING = 9237,
IPMI_OEM_ADVANTECH = 10297,
IPMI_OEM_NEWISYS = 9237,
IPMI_OEM_FUJITSU_SIEMENS = 10368,
IPMI_OEM_AVOCENT = 10418,
IPMI_OEM_PEPPERCON = 10437,
@ -294,15 +280,11 @@ typedef enum IPMI_OEM {
IPMI_OEM_RARITAN = 13742,
IPMI_OEM_KONTRON = 15000,
IPMI_OEM_PPS = 16394,
/* 20301 for [IBM eServer X] */
IPMI_OEM_IBM_20301 = 20301,
IPMI_OEM_AMI = 20974,
/* 24339 for [ADLINK TECHNOLOGY INC.] */
IPMI_OEM_ADLINK_24339 = 24339,
IPMI_OEM_NOKIA_SOLUTIONS_AND_NETWORKS = 28458,
IPMI_OEM_VITA = 33196,
IPMI_OEM_SUPERMICRO_47488 = 47488,
IPMI_OEM_YADRO = 49769,
IPMI_OEM_NOKIA_SIEMENS_NETWORKS = 28458,
IPMI_OEM_SUPERMICRO_47488 = 47488
} IPMI_OEM;
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.
*/
#pragma once
#ifndef IPMI_CC_H
#define IPMI_CC_H
/*
Thu Jan 11 09:32:41 2007
@ -70,3 +71,6 @@
#define IPMI_CC_NOT_SUPPORTED_PRESENT_STATE 0xd5
#define IPMI_CC_ILLEGAL_COMMAND_DISABLED 0xd6
#define IPMI_CC_UNSPECIFIED_ERROR 0xff
#endif /*IPMI_CC_H*/

View File

@ -1,195 +0,0 @@
/*
* Copyright (c) 2016 Pentair Technical Products. All right 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 Pentair Technical Products 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* PENTAIR TECHNICAL SOLUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <stdio.h>
/* Forward declarations. */
struct ipmi_cfgp;
struct ipmi_cfgp_ctx;
/*
* Action types.
*/
enum {
/* parse dumped parameter data */
CFGP_PARSE,
/* get parameter from BMC */
CFGP_GET,
/* set parameter to BMC */
CFGP_SET,
/* output parameter data in form that can be parsed back */
CFGP_SAVE,
/* print parameter in user-friendly format */
CFGP_PRINT
};
/*
* Action-specific information.
*/
struct ipmi_cfgp_action {
/* Action type. */
int type;
/* Set selector. */
int set;
/* Block selector. */
int block;
/* No error output needed. */
int quiet;
/* Number of command line arguments (only for parse action). */
int argc;
/* Command line arguments (only for parse action). */
const char **argv;
/* Output file (only for dump/print actions). */
FILE *file;
};
/*
* Access types.
*/
enum {
CFGP_RDWR,
CFGP_RDONLY,
CFGP_WRONLY,
CFGP_RESERVED
};
/*
* Configuration parameter descriptor.
*/
struct ipmi_cfgp {
/* Parameter name. */
const char *name;
/* Parameter format description. */
const char *format;
/* Various parameter traits. */
unsigned int size; /* block size */
unsigned int access:2; /* read-write/read-only/write-only */
unsigned int is_set:1; /* takes non-zero set selectors */
unsigned int first_set:1; /* 1 = 1-based set selector */
unsigned int has_blocks:1; /* takes non-zero block selectors */
unsigned int first_block:1; /* 1 = 1-based block selector */
/* Parameter-specific data. */
int specific;
};
/* Parameter callback. */
typedef int (*ipmi_cfgp_handler_t)(void *priv,
const struct ipmi_cfgp *p, const struct ipmi_cfgp_action *action,
unsigned char *data);
/*
* Parameter selector.
*/
struct ipmi_cfgp_sel {
int param;
int set;
int block;
};
/*
* Configuration parameter data.
*/
struct ipmi_cfgp_data {
struct ipmi_cfgp_data *next;
struct ipmi_cfgp_sel sel;
unsigned char data[];
};
/*
* Configuration parameter operation context.
*/
struct ipmi_cfgp_ctx {
/* Set of parameters. */
const struct ipmi_cfgp *set;
/* Descriptor count. */
int count;
/* Parameter action handler. */
ipmi_cfgp_handler_t handler;
/* ipmitool cmd name */
const char *cmdname;
/* List of parameter values. */
struct ipmi_cfgp_data *v;
/* Private data. */
void *priv;
};
/* Initialize configuration context. */
extern int ipmi_cfgp_init(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp *set, unsigned int count,
const char *cmdname,
ipmi_cfgp_handler_t handler, void *priv);
/* Uninitialize context, free allocated memory. */
extern int ipmi_cfgp_uninit(struct ipmi_cfgp_ctx *ctx);
/* Print parameter usage. */
void ipmi_cfgp_usage(const struct ipmi_cfgp *set, int count, int write);
/* Parse parameter selector from command line. */
extern int ipmi_cfgp_parse_sel(struct ipmi_cfgp_ctx *ctx,
int argc, const char **argv, struct ipmi_cfgp_sel *sel);
/* Parse parameter data from command line. */
extern int ipmi_cfgp_parse_data(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, int argc, const char **argv);
/* Get parameter data from BMC. */
extern int ipmi_cfgp_get(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel);
/* Set parameter data to BMC. */
extern int ipmi_cfgp_set(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel);
/* Write parameter data to file. */
extern int ipmi_cfgp_save(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, FILE *file);
/* Print parameter data in user-friendly format. */
extern int ipmi_cfgp_print(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, FILE *file);

View File

@ -30,17 +30,16 @@
* 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
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#define IPMI_GET_CHANNEL_AUTH_CAP 0x38
#define IPMI_SET_CHANNEL_ACCESS 0x40
#define IPMI_GET_CHANNEL_ACCESS 0x41
#define IPMI_GET_CHANNEL_INFO 0x42
#define IPMI_SET_USER_ACCESS 0x43
@ -50,104 +49,6 @@
#define IPMI_SET_USER_PASSWORD 0x47
#define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54
/* These are for channel_info_t.session_support */
#define IPMI_CHANNEL_SESSION_LESS 0x00
#define IPMI_CHANNEL_SESSION_SINGLE 0x40
#define IPMI_CHANNEL_SESSION_MULTI 0x80
#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 */
struct channel_info_t {
uint8_t channel;
uint8_t medium;
uint8_t protocol;
uint8_t session_support;
uint8_t active_sessions;
uint8_t vendor_id[3];
uint8_t aux_info[2];
};
/* (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 {
uint8_t access_mode;
alerting_t alerting;
uint8_t channel;
uint8_t per_message_auth;
uint8_t privilege_limit;
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
@ -200,25 +101,158 @@ struct get_channel_auth_cap_rsp {
#pragma pack(0)
#endif
int _ipmi_get_channel_access(struct ipmi_intf *intf,
struct channel_access_t *channel_access,
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,
struct channel_info_t *channel_info);
int _ipmi_set_channel_access(struct ipmi_intf *intf,
struct channel_access_t channel_access,
uint8_t access_option,
uint8_t privilege_option);
/*
* The Get Channel Info response structure
* From table 22-29 of the IPMI v2.0 spec
*/
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
struct get_channel_info_rsp {
#if WORDS_BIGENDIAN
uint8_t __reserved1 : 4;
uint8_t channel_number : 4; /* channel number */
#else
uint8_t channel_number : 4; /* channel number */
uint8_t __reserved1 : 4;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved2 : 1;
uint8_t channel_medium : 7; /* Channel medium type per table 6-3 */
#else
uint8_t channel_medium : 7; /* Channel medium type per table 6-3 */
uint8_t __reserved2 : 1;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved3 : 3;
uint8_t channel_protocol : 5; /* Channel protocol per table 6-2 */
#else
uint8_t channel_protocol : 5; /* Channel protocol per table 6-2 */
uint8_t __reserved3 : 3;
#endif
#if WORDS_BIGENDIAN
uint8_t session_support : 2; /* Description of session support */
uint8_t active_sessions : 6; /* Count of active sessions */
#else
uint8_t active_sessions : 6; /* Count of active sessions */
uint8_t session_support : 2; /* Description of session support */
#endif
uint8_t vendor_id[3]; /* For OEM that specified the protocol */
uint8_t aux_info[2]; /* Not used*/
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
/*
* The Get Channel Access response structure
* From table 22-28 of the IPMI v2.0 spec
*/
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
struct get_channel_access_rsp {
#if WORDS_BIGENDIAN
uint8_t __reserved1 : 2;
uint8_t alerting : 1;
uint8_t per_message_auth : 1;
uint8_t user_level_auth : 1;
uint8_t access_mode : 3;
#else
uint8_t access_mode : 3;
uint8_t user_level_auth : 1;
uint8_t per_message_auth : 1;
uint8_t alerting : 1;
uint8_t __reserved1 : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved2 : 4;
uint8_t channel_priv_limit : 4; /* Channel privilege level limit */
#else
uint8_t channel_priv_limit : 4; /* Channel privilege level limit */
uint8_t __reserved2 : 4;
#endif
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
struct get_user_access_rsp {
#if WORDS_BIGENDIAN
uint8_t __reserved1 : 2;
uint8_t max_user_ids : 6;
uint8_t __reserved2 : 2;
uint8_t enabled_user_ids : 6;
uint8_t __reserved3 : 2;
uint8_t fixed_user_ids : 6;
uint8_t __reserved4 : 1;
uint8_t callin_callback : 1;
uint8_t link_auth : 1;
uint8_t ipmi_messaging : 1;
uint8_t privilege_limit : 4;
#else
uint8_t max_user_ids : 6;
uint8_t __reserved1 : 2;
uint8_t enabled_user_ids : 6;
uint8_t __reserved2 : 2;
uint8_t fixed_user_ids : 6;
uint8_t __reserved3 : 2;
uint8_t privilege_limit : 4;
uint8_t ipmi_messaging : 1;
uint8_t link_auth : 1;
uint8_t callin_callback : 1;
uint8_t __reserved4 : 1;
#endif
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
struct set_user_access_data {
#if WORDS_BIGENDIAN
uint8_t change_bits : 1;
uint8_t callin_callback : 1;
uint8_t link_auth : 1;
uint8_t ipmi_messaging : 1;
uint8_t channel : 4;
uint8_t __reserved1 : 2;
uint8_t user_id : 6;
uint8_t __reserved2 : 4;
uint8_t privilege_limit : 4;
uint8_t __reserved3 : 4;
uint8_t session_limit : 4;
#else
uint8_t channel : 4;
uint8_t ipmi_messaging : 1;
uint8_t link_auth : 1;
uint8_t callin_callback : 1;
uint8_t change_bits : 1;
uint8_t user_id : 6;
uint8_t __reserved1 : 2;
uint8_t privilege_limit : 4;
uint8_t __reserved2 : 4;
uint8_t session_limit : 4;
uint8_t __reserved3 : 4;
#endif
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel);
void ipmi_current_channel_info(struct ipmi_intf *intf,
struct channel_info_t *chinfo);
uint8_t ipmi_current_channel_medium(struct ipmi_intf * intf);
int ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv);
int ipmi_get_channel_auth_cap(struct ipmi_intf * intf,
uint8_t channel, uint8_t priv);
int ipmi_get_channel_auth_cap(struct ipmi_intf * intf, uint8_t channel, uint8_t priv);
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.
*/
#pragma once
#ifndef IPMI_CHASSIS_H
#define IPMI_CHASSIS_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_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.
*/
#pragma once
#ifndef IPMI_CONSTANTS_H
#define IPMI_CONSTANTS_H
/*
* COMMANDS
@ -72,7 +74,6 @@
#define IPMI_SESSION_PRIV_OPERATOR 0x3
#define IPMI_SESSION_PRIV_ADMIN 0x4
#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_IN_PROGRESS 0x01
@ -117,17 +118,17 @@
#define IPMI_AUTH_RAKP_NONE 0x00
#define IPMI_AUTH_RAKP_HMAC_SHA1 0x01
#define IPMI_AUTH_RAKP_HMAC_MD5 0x02
#define IPMI_AUTH_RAKP_HMAC_SHA256 0x03
/* From table 13-18 of the IPMI v2 specification */
#define IPMI_INTEGRITY_NONE 0x00
#define IPMI_INTEGRITY_HMAC_SHA1_96 0x01
#define IPMI_INTEGRITY_HMAC_MD5_128 0x02
#define IPMI_INTEGRITY_MD5_128 0x03
#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_AES_CBC_128 0x01
#define IPMI_CRYPT_XRC4_128 0x02
#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>
@ -50,53 +52,6 @@
#define GOOD_PWR_GLIMIT_CCODE(ccode) ((ccode = ((ccode == 0x80) ? 0 : ccode)))
#define GOOD_ASSET_TAG_CCODE(ccode) ((ccode = (((ccode == 0x80) || (ccode == 0x81) || (ccode == 0x82) || (ccode == 0x83)) ? 0 : ccode)))
/* External Node Manager Configuration and Control Commands per spec 2.0 */
#define IPMI_NM_POLICY_CTL 0xC0
#define IPMI_NM_SET_POLICY 0xC1
#define IPMI_NM_GET_POLICY 0xC2
#define IPMI_NM_SET_ALERT_TH 0xC3
#define IPMI_NM_GET_ALERT_TH 0xC4
#define IPMI_NM_SET_SUSPEND 0xC5
#define IPMI_NM_GET_SUSPEND 0xC6
#define IPMI_NM_RESET_STATS 0xC7
#define IPMI_NM_GET_STATS 0xC8
#define IPMI_NM_GET_CAP 0xC9
#define IPMI_NM_GET_VERSION 0xCA
#define IPMI_NM_SET_POWER 0xCB
#define IPMI_NM_SET_ALERT_DS 0xCE
#define IPMI_NM_GET_ALERT_DS 0xCF
#define IPMI_NM_LIMITING 0xF2
/* Node Manager Policy Control Flags */
#define IPMI_NM_GLOBAL_ENABLE 0x01
#define IPMI_NM_DOMAIN_ENABLE 0x02
#define IPMI_NM_PER_POLICY_ENABLE 0x04
/* Node Manager Set Policy Enable */
#define IPMI_NM_POLICY_ENABLE 0x10
/* Node Manager Policy Trigger Codes */
#define IPMI_NM_NO_POLICY_TRIG 0x00
#define IPMI_NM_TEMP_TRIGGER 0x01
#define IPMI_NM_NO_READ_TRIG 0x02
#define IPMI_NM_RESET_TRIGGER 0x03
#define IPMI_NM_BOOT_TRIGGER 0x04
/* Policy Exception Actions flags */
#define IPMI_NM_POLICY_ALERT 0x01
#define IPMI_NM_POLICY_SHUT 0x02
/* Power Correction codes for Policy action */
#define IPMI_NM_PWR_AUTO_CORR 0x00
#define IPMI_NM_PWR_SOFT_CORR 0x01
#define IPMI_NM_PWR_AGGR_CORR 0x02
/* Set Threshold message size */
#define IPMI_NM_SET_THRESH_LEN 12
/* Number of Suspend Periods */
#define IPMI_NM_SUSPEND_PERIOD_MAX 5
struct dcmi_cmd {
uint16_t val;
@ -127,7 +82,7 @@ struct power_reading {
uint8_t state;
} __attribute__ ((packed));
/* make a struct for the return from the capabilities command */
/* make a struct for the return from the capabilites command */
struct capabilities {
uint8_t grp_id; /* first byte: Group Extension ID */
uint16_t conformance;
@ -171,97 +126,4 @@ struct thermal_limit {
int ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char ** argv);
/* Node Manager discover command */
struct nm_discover {
uint8_t intel_id[3]; /* Always returns 000157 */
uint8_t nm_version;
uint8_t ipmi_version;
uint8_t patch_version;
uint8_t major_rev;
uint8_t minor_rev;
} __attribute__ ((packed));
/* Node Manager get capabilities command */
struct nm_capability {
uint8_t intel_id[3];
uint8_t max_settings;
uint16_t max_value; /* max power/thermal/time after reset */
uint16_t min_value; /* min "" */
uint32_t min_corr; /* min correction time inmillesecs */
uint32_t max_corr;
uint16_t min_stats;
uint16_t max_stats;
uint8_t scope;
} __attribute__ ((packed));
/* Node Manager get statistics command */
struct nm_statistics {
uint8_t intel_id[3];
uint16_t curr_value;
uint16_t min_value;
uint16_t max_value;
uint16_t ave_value;
uint32_t time_stamp;
uint32_t stat_period;
uint8_t id_state;
} __attribute__ ((packed));
/* Node Manager set policy */
struct nm_policy {
uint8_t intel_id[3];
uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
uint8_t policy_id;
uint8_t policy_type; /* 0:3 trigger type 4 = action 5:6 correction */
uint8_t policy_exception; /* exception actions */
uint16_t policy_limits;
uint32_t corr_time;
uint16_t trigger_limit;
uint16_t stats_period;
} __attribute__ ((packed));
/* Node Maager get policy */
struct nm_get_policy {
uint8_t intel_id[3];
uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
uint8_t policy_type; /* 0:3 trigger type 4 = action 5:6 correction */
uint8_t policy_exception; /* exception actions */
uint16_t policy_limits;
uint32_t corr_time;
uint16_t trigger_limit;
uint16_t stats_period;
} __attribute__ ((packed));
/* Node Manager set alert destination */
struct nm_set_alert {
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 dest; /* lan destination */
uint8_t string; /* alert string selector */
} __attribute__ ((packed));
/* Node Manager set alert threshold */
struct nm_thresh {
uint8_t intel_id[3];
uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
uint8_t policy_id;
uint8_t count;
uint16_t thresholds[3];
} __attribute__ ((packed));
/* Node Manager suspend period struct */
struct nm_period {
uint8_t start;
uint8_t stop;
uint8_t repeat;
} __attribute__ ((packed));
/* Node Manager set suspend period */
struct nm_suspend {
uint8_t intel_id[3];
uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
uint8_t policy_id;
uint8_t count;
struct nm_period period[IPMI_NM_SUSPEND_PERIOD_MAX];
} __attribute__ ((packed));
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.
*****************************************************************************/
#pragma once
#ifndef IPMI_DELLOEM_H
#define IPMI_DELLOEM_H
#if HAVE_CONFIG_H
# include <config.h>
@ -343,6 +343,10 @@ typedef struct _power_headroom
uint16_t peakheadroom;
} __attribute__ ((packed)) POWER_HEADROOM;
struct vFlashstr {
uint8_t val;
const char * str;
};
typedef struct ipmi_vFlash_extended_info
{
uint8_t vflashcompcode;
@ -362,3 +366,5 @@ typedef struct _SensorReadingType
}SensorReadingType;
uint16_t compareinputwattage(IPMI_POWER_SUPPLY_INFO* powersupplyinfo, uint16_t inputwattage);
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.
*/
#pragma once
#ifndef IPMI_EKANALYZER_H
#define IPMI_EKANALYZER_H
#include <inttypes.h>
#include <ipmitool/ipmi.h>
@ -63,3 +64,5 @@
#define FRU_RADIAL_IPMB0_LINK_MAPPING 0x15
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.
*/
#pragma once
#ifndef IPMI_ENTITY_H
#define IPMI_ENTITY_H
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
@ -48,3 +49,5 @@ struct entity_id {
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
#endif /* IPMI_ENTITY_H */

View File

@ -30,7 +30,8 @@
* 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
# include <config.h>
@ -60,31 +61,6 @@ struct platform_event_msg {
#pragma pack(0)
#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 **);
#endif /*IPMI_EVENT_H*/

View File

@ -30,7 +30,8 @@
* 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>
@ -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) {
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.
*/
#pragma once
#ifndef IPMI_FRU_H
#define IPMI_FRU_H
#include <inttypes.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
#include <ipmitool/ipmi_time.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#define FRU_END_OF_FIELDS 0xc1
#define GET_FRU_INFO 0x10
#define GET_FRU_DATA 0x11
#define SET_FRU_DATA 0x12
@ -127,7 +125,6 @@ struct fru_area_product {
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
/* See Table 16-1 of "IPMI FRU Information Storage Specification" */
struct fru_multirec_header {
#define FRU_RECORD_TYPE_POWER_SUPPLY_INFORMATION 0x00
#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_OEM_EXTENSION 0xc0
uint8_t type;
#define FRU_RECORD_FORMAT_EOL_MASK 0x80
#define FRU_RECORD_FORMAT_VER_MASK 0x0F
uint8_t format;
uint8_t len;
uint8_t record_checksum;
@ -198,6 +193,9 @@ struct fru_multirec_powersupply {
#pragma pack(0)
#endif
static const char * combined_voltage_desc[] __attribute__((unused)) = {
"12 V", "-12 V", "5 V", "3.3 V"};
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
@ -244,43 +242,6 @@ struct fru_multirec_dcload {
#pragma pack(0)
#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
#pragma pack(1)
#endif
@ -336,24 +297,22 @@ struct fru_picmgext_link_desc {
unsigned int desig_channel:6;
unsigned int desig_if:2;
unsigned int desig_port:4;
#define FRU_PICMGEXT_LINK_TYPE_BASE 0x01
#define FRU_PICMGEXT_LINK_TYPE_BASE 0x01
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET 0x02
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND 0x03
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR 0x04
#define FRU_PICMGEXT_LINK_TYPE_PCIE 0x05
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET_10GBD 0x32
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR 0x04
#define FRU_PICMGEXT_LINK_TYPE_PCIE 0x05
unsigned int type:8;
unsigned int ext:4;
unsigned int grouping:8;
#else
unsigned int grouping:8;
unsigned int ext:4;
#define FRU_PICMGEXT_LINK_TYPE_BASE 0x01
#define FRU_PICMGEXT_LINK_TYPE_BASE 0x01
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET 0x02
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND 0x03
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR 0x04
#define FRU_PICMGEXT_LINK_TYPE_PCIE 0x05
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET_10GBD 0x32
#define FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR 0x04
#define FRU_PICMGEXT_LINK_TYPE_PCIE 0x05
unsigned int type:8;
unsigned int desig_port:4;
unsigned int desig_if:2;
@ -629,28 +588,20 @@ struct fru_picmgext_amc_link_desc_record {
#pragma pack(0)
#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 */
#define FRU_BOARD_DATE_UNSPEC 0 /* IPMI FRU Information Storage Definition
v1.0 rev 1.3, Table 11-1 */
static inline time_t ipmi_fru2time_t(void *mfg_date) {
const uint64_t secs_from_1970_1996 = 820454400;
uint32_t fru_ts = ipmi24toh(mfg_date);
time_t ts;
if (FRU_BOARD_DATE_UNSPEC == fru_ts) {
ts = IPMI_TIME_UNSPECIFIED;
}
else {
ts = fru_ts * 60 + secs_from_1970_1996;
}
return ts;
}
static const uint64_t secs_from_1970_1996 = 820454400;
static const char * chassis_type_desc[] __attribute__((unused)) = {
"Unspecified", "Other", "Unknown",
"Desktop", "Low Profile Desktop", "Pizza Box",
"Mini Tower", "Tower",
"Portable", "LapTop", "Notebook", "Hand Held",
"Docking Station", "All in One", "Sub Notebook",
"Space-saving", "Lunch Box", "Main Server Chassis",
"Expansion Chassis", "SubChassis", "Bus Expansion Chassis",
"Peripheral Chassis", "RAID Chassis", "Rack Mount Chassis",
"Sealed-case PC", "Multi-system Chassis", "CompactPCI",
"AdvancedTCA", "Blade", "Blade Enclosure"
};
typedef struct ipmi_fru_bloc {
struct ipmi_fru_bloc * next;
@ -659,6 +610,14 @@ typedef struct ipmi_fru_bloc {
uint8_t blocId[32];
} t_ipmi_fru_bloc;
static const char *section_id[4] = {
"Internal Use Section",
"Chassis Section",
"Board Section",
"Product Section"
};
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);
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.
*/
#pragma once
#ifndef IPMI_KFWUM_H
# define IPMI_KFWUM_H
#include <inttypes.h>
#include <ipmitool/ipmi.h>
@ -238,3 +239,5 @@ struct KfwumFinishFirmwareDownloadReq {
# ifdef HAVE_PRAGMA_PACK
# pragma pack(0)
# endif
#endif /* IPMI_KFWUM_H */

View File

@ -30,7 +30,8 @@
* 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
# include <config.h>
@ -43,3 +44,5 @@
#include <ipmitool/ipmi_entity.h>
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.
*/
#pragma once
#ifndef IPMI_HPMFWUPG_H
#define IPMI_HPMFWUPG_H
#include <inttypes.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_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 */
#define HPMFWUPG_PICMG_IDENTIFIER 0
#define HPMFWUPG_VERSION_SIZE 6
@ -419,7 +437,7 @@ struct HpmfwupgInitiateUpgradeActionCtx {
struct HpmfwupgUploadFirmwareBlockReq {
unsigned char picmgId;
unsigned char blockNumber;
unsigned char data[];
unsigned char data[0];
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
# pragma pack(0)
@ -782,6 +800,10 @@ typedef struct _VERSIONINFO {
char descString[HPMFWUPG_DESC_STRING_LENGTH + 1];
}VERSIONINFO, *PVERSIONINFO;
VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
#define TARGET_VER (0x01)
#define ROLLBACK_VER (0x02)
#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.
*/
#pragma once
#ifndef IPMI_IME_H
#define IPMI_IME_H
#include <inttypes.h>
#include <ipmitool/ipmi.h>
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.
*/
#pragma once
#ifndef IPMI_INTF_H
#define IPMI_INTF_H
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_oem.h>
@ -58,78 +59,39 @@ enum LANPLUS_SESSION_STATE {
#define IPMI_AUTHCODE_BUFFER_SIZE 20
#define IPMI_SIK_BUFFER_SIZE IPMI_MAX_MD_SIZE
#define IPMI_SIK_BUFFER_SIZE 20
#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 {
char * hostname;
struct ipmi_session {
char *hostname; /* Numeric IP adress or DNS name - see RFC 1034/RFC 1035 */
uint8_t username[17];
uint8_t authcode_set[IPMI_AUTHCODE_BUFFER_SIZE + 1];
uint8_t authcode[IPMI_AUTHCODE_BUFFER_SIZE + 1];
uint8_t challenge[16];
uint8_t authtype;
uint8_t authtype_set;
uint8_t privlvl;
enum cipher_suite_ids cipher_suite_id;
char sol_escape_char;
int password;
int port;
int retry;
uint32_t timeout;
uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */
uint8_t lookupbit;
};
#define IPMI_AUTHSTATUS_PER_MSG_DISABLED 0x10
#define IPMI_AUTHSTATUS_PER_USER_DISABLED 0x08
#define IPMI_AUTHSTATUS_NONNULL_USERS_ENABLED 0x04
#define IPMI_AUTHSTATUS_NULL_USERS_ENABLED 0x02
#define IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED 0x01
struct ipmi_session {
uint8_t authstatus;
uint8_t authextra;
uint8_t privlvl;
uint8_t cipher_suite_id;
char sol_escape_char;
int password;
int port;
int active;
int retry;
uint32_t session_id;
uint32_t in_seq;
uint32_t out_seq;
uint8_t authcode[IPMI_AUTHCODE_BUFFER_SIZE + 1];
uint8_t challenge[16];
uint8_t authtype;
uint8_t authstatus;
uint8_t authextra;
uint32_t timeout;
struct sockaddr_storage addr;
socklen_t addrlen;
int ai_family; /* Protocol family for socket. */
/*
* This struct holds state data specific to IPMI v2 / RMCP+ sessions
@ -145,12 +107,13 @@ struct ipmi_session {
uint8_t integrity_alg;
uint8_t crypt_alg;
uint8_t max_priv_level;
uint8_t lookupbit;
uint32_t console_id;
uint32_t bmc_id;
/*
* Values required for RAKP messages
* Values required for RAKP mesages
*/
/* Random number generated byt the console */
@ -162,13 +125,10 @@ struct ipmi_session {
uint8_t requested_role; /* As sent in the RAKP 1 message */
uint8_t rakp2_return_code;
uint8_t sik[IPMI_SIK_BUFFER_SIZE]; /* Session integrity key */
uint8_t sik_len; /* Session Integrity key length */
uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */
uint8_t k1[IPMI_MAX_MD_SIZE]; /* Used for Integrity checking? */
uint8_t k1_len; /* K1 key length */
uint8_t k2[IPMI_MAX_MD_SIZE]; /* First 16 bytes used for AES */
uint8_t k2_len; /* K2 key length */
uint8_t sik[IPMI_SIK_BUFFER_SIZE]; /* Session integrity key */
uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */
uint8_t k1[20]; /* Used for Integrity checking? */
uint8_t k2[20]; /* First 16 bytes used for AES */
} v2_data;
@ -208,11 +168,8 @@ struct ipmi_intf {
int abort;
int noanswer;
int picmg_avail;
int vita_avail;
IPMI_OEM manufacturer_id;
int ai_family;
struct ipmi_session_params ssn_params;
struct ipmi_session * session;
struct ipmi_oem_handle * oem;
struct ipmi_cmd * cmdlist;
@ -232,6 +189,7 @@ struct ipmi_intf {
int (*open)(struct ipmi_intf * intf);
void (*close)(struct ipmi_intf * intf);
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 *(*send_sol)(struct ipmi_intf * intf, struct ipmi_v2_payload * payload);
int (*keepalive)(struct ipmi_intf * intf);
@ -240,10 +198,6 @@ struct ipmi_intf {
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);
void ipmi_intf_print(struct ipmi_intf_support * intflist);
@ -252,12 +206,9 @@ 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_privlvl(struct ipmi_intf * intf, uint8_t privlvl);
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,
enum cipher_suite_ids cipher_suite_id);
#endif /* 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_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, char * kgkey);
void ipmi_intf_session_set_port(struct ipmi_intf * intf, int port);
void ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype);
void ipmi_intf_session_set_timeout(struct ipmi_intf * intf, uint32_t timeout);
@ -268,3 +219,4 @@ void ipmi_cleanup(struct ipmi_intf * intf);
#if defined(IPMI_INTF_LAN) || defined (IPMI_INTF_LANPLUS)
int ipmi_intf_socket_connect(struct ipmi_intf * intf);
#endif
#endif /* IPMI_INTF_H */

View File

@ -30,7 +30,8 @@
* 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>
@ -52,3 +53,5 @@ struct isol_config_parameters {
};
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.
*
* Base on code from
* Copyright (c) 2003 Sun Microsystems, 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 Sun Microsystems, 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.
* SUN MICROSYSTEMS, INC. ("SUN") 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
* SUN 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
#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);
/*
* Copyright (c) 2004 Kontron Canada, Inc. All Rights Reserved.
*
* Base on code from
* Copyright (c) 2003 Sun Microsystems, 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 Sun Microsystems, 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.
* SUN MICROSYSTEMS, INC. ("SUN") 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
* SUN 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.
*/
#ifndef IPMI_KONTRONOEM_H
#define IPMI_KONTRONOEM_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);
#endif /* IPMI_KONTRONOEM_H */

View File

@ -30,7 +30,8 @@
* 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>
@ -49,13 +50,6 @@
#define IPMI_LANP_WRITE_LOCK 1
#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 {
IPMI_LANP_SET_IN_PROGRESS,
IPMI_LANP_AUTH_TYPE,
@ -82,39 +76,6 @@ enum {
IPMI_LANP_RMCP_CIPHER_SUPPORT,
IPMI_LANP_RMCP_CIPHERS,
IPMI_LANP_RMCP_PRIV_LEVELS,
IPMI_LANP_VLAN_TAGS,
IPMI_LANP_BAD_PASS_THRESH,
IPMI_LANP_IP6_SUPPORT=50,
IPMI_LANP_IP6_ENABLES,
IPMI_LANP_IP6_TRAFFIC_CLASS,
IPMI_LANP_IP6_STATIC_HOPS,
IPMI_LANP_IP6_FLOW_LABEL,
IPMI_LANP_IP6_STATUS,
IPMI_LANP_IP6_STATIC_ADDR,
IPMI_LANP_IP6_STATIC_DUID_STG,
IPMI_LANP_IP6_STATIC_DUID,
IPMI_LANP_IP6_DYNAMIC_ADDR,
IPMI_LANP_IP6_DYNAMIC_DUID_STG,
IPMI_LANP_IP6_DYNAMIC_DUID,
IPMI_LANP_IP6_DHCP6_CFG_SUP,
IPMI_LANP_IP6_DHCP6_CFG,
IPMI_LANP_IP6_ROUTER_CFG,
IPMI_LANP_IP6_STATIC_RTR1_ADDR,
IPMI_LANP_IP6_STATIC_RTR1_MAC,
IPMI_LANP_IP6_STATIC_RTR1_PFX_LEN,
IPMI_LANP_IP6_STATIC_RTR1_PFX,
IPMI_LANP_IP6_STATIC_RTR2_ADDR,
IPMI_LANP_IP6_STATIC_RTR2_MAC,
IPMI_LANP_IP6_STATIC_RTR2_PFX_LEN,
IPMI_LANP_IP6_STATIC_RTR2_PFX,
IPMI_LANP_IP6_NUM_DYNAMIC_RTRS,
IPMI_LANP_IP6_DYNAMIC_RTR_ADDR,
IPMI_LANP_IP6_DYNAMIC_RTR_MAC,
IPMI_LANP_IP6_DYNAMIC_RTR_PFX_LEN,
IPMI_LANP_IP6_DYNAMIC_RTR_PFX,
IPMI_LANP_IP6_DYNAMIC_HOPS,
IPMI_LANP_IP6_NDSLAAC_CFG_SUP,
IPMI_LANP_IP6_NDSLAAC_CFG,
IPMI_LANP_OEM_ALERT_STRING=96,
IPMI_LANP_ALERT_RETRY=97,
IPMI_LANP_UTC_OFFSET=98,
@ -124,6 +85,48 @@ enum {
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" },
{ IPMI_LANP_AUTH_TYPE, 1, "Auth Type Support" },
{ IPMI_LANP_AUTH_TYPE_ENABLE, 5, "Auth Type Enable" },
{ IPMI_LANP_IP_ADDR, 4, "IP Address" },
{ IPMI_LANP_IP_ADDR_SRC, 1, "IP Address Source" },
{ IPMI_LANP_MAC_ADDR, 6, "MAC Address" }, /* 5 */
{ IPMI_LANP_SUBNET_MASK, 4, "Subnet Mask" },
{ IPMI_LANP_IP_HEADER, 3, "IP Header" },
{ IPMI_LANP_PRI_RMCP_PORT, 2, "Primary RMCP Port" },
{ IPMI_LANP_SEC_RMCP_PORT, 2, "Secondary RMCP Port" },
{ IPMI_LANP_BMC_ARP, 1, "BMC ARP Control" }, /* 10 */
{ IPMI_LANP_GRAT_ARP, 1, "Gratituous ARP Intrvl" },
{ IPMI_LANP_DEF_GATEWAY_IP, 4, "Default Gateway IP" },
{ IPMI_LANP_DEF_GATEWAY_MAC, 6, "Default Gateway MAC" },
{ IPMI_LANP_BAK_GATEWAY_IP, 4, "Backup Gateway IP" },
{ IPMI_LANP_BAK_GATEWAY_MAC, 6, "Backup Gateway MAC" }, /* 15 */
{ IPMI_LANP_SNMP_STRING, 18, "SNMP Community String" },
{ IPMI_LANP_NUM_DEST, 1, "Number of Destinations"},
{ IPMI_LANP_DEST_TYPE, 4, "Destination Type" },
{ IPMI_LANP_DEST_ADDR, 13, "Destination Addresses" },
{ IPMI_LANP_VLAN_ID, 2, "802.1q VLAN ID" }, /* 20 */
{ IPMI_LANP_VLAN_PRIORITY, 1, "802.1q VLAN Priority" },
{ IPMI_LANP_RMCP_CIPHER_SUPPORT,1, "RMCP+ Cipher Suite Count" },
{ IPMI_LANP_RMCP_CIPHERS, 16, "RMCP+ Cipher Suites" },
{ IPMI_LANP_RMCP_PRIV_LEVELS, 9, "Cipher Suite Priv Max" },
{ IPMI_LANP_OEM_ALERT_STRING, 28, "OEM Alert String" }, /* 25 */
{ IPMI_LANP_ALERT_RETRY, 1, "Alert Retry Algorithm" },
{ IPMI_LANP_UTC_OFFSET, 3, "UTC Offset" },
{ IPMI_LANP_DHCP_SERVER_IP, 4, "DHCP Server IP" },
{ IPMI_LANP_DHCP_SERVER_MAC, 6, "DHDP Server MAC" },
{ IPMI_LANP_DHCP_ENABLE, 1, "DHCP Enable" }, /* 30 */
{ IPMI_LANP_CHAN_ACCESS_MODE, 2, "Channel Access Mode" },
{ -1 }
};
int ipmi_lanp_main(struct ipmi_intf *, int, char **);
uint8_t find_lan_channel(struct ipmi_intf *intf, uint8_t start);
#endif /*IPMI_LANP_H*/

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2016 Pentair Technical Products. All right 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 Pentair Technical Products 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* PENTAIR TECHNICAL SOLUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <ipmitool/ipmi_intf.h>
/*
* LAN configuration parameter.
*/
struct ipmi_lanp {
int selector;
const char *name;
int size;
};
/*
* Private data for LAN configuration.
*/
struct ipmi_lanp_priv {
struct ipmi_intf *intf;
int channel;
};

View File

@ -30,10 +30,13 @@
* 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>
int ipmi_main(int argc, char ** argv, struct ipmi_cmd * cmdlist, struct ipmi_intf_support * intflist);
void ipmi_cmd_print(struct ipmi_cmd * cmdlist);
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.
*/
#pragma once
#include <stdbool.h>
#ifndef IPMI_MC_H
#define IPMI_MC_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_COLD_RESET 0x02
@ -83,7 +74,7 @@ struct ipm_devid_rsp {
#define IPM_DEV_DEVICE_ID_REV_MASK (0x0F) /* BCD-enoded */
#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_MINOR_MASK (0xF0) /* Minor rev, BCD-encoded */
@ -93,141 +84,11 @@ struct ipm_devid_rsp {
#define IPM_DEV_IPMI_VERSION_MINOR(x) \
((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) ipmi24toh(x)
#define IPM_DEV_MANUFACTURER_ID(x) \
((uint32_t) ((x[2] & 0x0F) << 16 | x[1] << 8 | x[0]))
#define IPM_DEV_ADTL_SUPPORT_BITS (8)
/* There are lots of BMC implementations that don't follow the IPMI
* specification for GUID encoding. Some send data encoded as in
* 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
#pragma pack(1)
#endif
typedef struct {
uint8_t node[GUID_NODE_SZ]; /* Byte 0 is LSB */
union {
struct {
uint8_t clock_seq_low; /* clock sequence low field */
uint8_t clock_seq_hi_and_rsvd;/* clock sequence high field */
};
uint16_t clock_seq_and_rsvd;
};
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
#pragma pack(0)
#endif
/* The structure follows RFC4122 (section 4.1.2)
* 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
#pragma pack(1)
#endif
@ -258,24 +119,14 @@ struct ipm_selftest_rsp {
#pragma pack(1)
#endif
struct ipm_get_watchdog_rsp {
unsigned char use;
unsigned char intr_action;
unsigned char timer_use;
unsigned char timer_actions;
unsigned char pre_timeout;
unsigned char exp_flags;
union {
struct {
unsigned char initial_countdown_lsb;
unsigned char initial_countdown_msb;
};
uint16_t init_cnt_le;
};
union {
struct {
unsigned char present_countdown_lsb;
unsigned char present_countdown_msb;
};
uint16_t pres_cnt_le;
};
unsigned char timer_use_exp;
unsigned char initial_countdown_lsb;
unsigned char initial_countdown_msb;
unsigned char present_countdown_lsb;
unsigned char present_countdown_msb;
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
@ -300,42 +151,20 @@ struct ipm_get_watchdog_rsp {
#define IPM_WATCHDOG_CLEAR_BIOS_POST 0x04
#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*/
#define IPMI_SET_SYS_INFO 0x58
#define IPMI_GET_SYS_INFO 0x59
#define IPMI_SYSINFO_SET0_SIZE 14
#define IPMI_SYSINFO_SETN_SIZE 16
/* System Information "Parameter selector" values: */
#define IPMI_SYSINFO_SET_STATE 0x00
#define IPMI_SYSINFO_SYSTEM_FW_VERSION 0x01
#define IPMI_SYSINFO_HOSTNAME 0x02
#define IPMI_SYSINFO_PRIMARY_OS_NAME 0x03
#define IPMI_SYSINFO_OS_NAME 0x04
#define IPMI_SYSINFO_DELL_OS_VERSION 0xe4
#define IPMI_SYSINFO_DELL_URL 0xde
#define IPMI_SYSINFO_DELL_IPV6_COUNT 0xe6
#define IPMI_SYSINFO_DELL_IPV6_DESTADDR 0xf0
int ipmi_mc_getsysinfo(struct ipmi_intf * intf, int param, int block, int set,
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.
*/
#pragma once
#ifndef IPMI_OEM_H
#define IPMI_OEM_H
#include <ipmitool/ipmi.h>
@ -42,3 +43,5 @@ struct ipmi_oem_handle {
void ipmi_oem_print(void);
int ipmi_oem_setup(struct ipmi_intf * intf, 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.
*/
#pragma once
#ifndef IPMI_PEF_H
#define IPMI_PEF_H
#include <ipmitool/ipmi.h>
@ -39,7 +40,7 @@
struct pef_capabilities { /* "get pef capabilities" response */
uint8_t version;
uint8_t actions; /* mapped by PEF_ACTION_xxx */
uint8_t event_filter_count;
uint8_t tblsize;
};
typedef enum {
@ -110,6 +111,224 @@ struct bit_desc_map { /* description text container */
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
#pragma pack(1)
@ -117,7 +336,6 @@ struct bit_desc_map { /* description text container */
struct pef_policy_entry {
#define PEF_POLICY_ID_MASK 0xf0
#define PEF_POLICY_ID_SHIFT 4
#define PEF_POLICY_DISABLED 0xF7
#define PEF_POLICY_ENABLED 0x08
#define PEF_POLICY_FLAGS_MASK 0x07
#define PEF_POLICY_FLAGS_MATCH_ALWAYS 0
@ -137,6 +355,46 @@ struct pef_policy_entry {
#pragma pack(0)
#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
#pragma pack(1)
@ -191,6 +449,15 @@ struct pef_cfgparm_control {
#pragma pack(0)
#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
#pragma pack(1)
@ -243,9 +510,7 @@ struct pef_cfgparm_filter_table_size {
#pragma pack(1)
#endif
struct pef_cfgparm_filter_table_entry {
# define PEF_FILTER_DISABLED 0x7F
# define PEF_FILTER_ENABLED 0x80
# define PEF_FILTER_TABLE_ID_MASK 0x7F
#define PEF_FILTER_TABLE_ID_MASK 0x7f
uint8_t data1;
struct pef_table_entry entry;
} ATTRIBUTE_PACKING;
@ -257,8 +522,8 @@ struct pef_cfgparm_filter_table_entry {
#pragma pack(1)
#endif
struct pef_cfgparm_filter_table_data_1 {
uint8_t id;
uint8_t cfg;
uint8_t data1;
uint8_t data2;
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
@ -388,6 +653,15 @@ struct pef_lan_cfgparm_dest_type {
#pragma pack(0)
#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
#pragma pack(1)
@ -478,6 +752,18 @@ struct pef_serial_cfgparm_dest_info {
#pragma pack(0)
#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
#pragma pack(1)
@ -546,6 +832,14 @@ struct pef_serial_cfgparm_tap_svc_settings {
#pragma pack(0)
#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 */
struct pef_config_parms { /* PEF */
@ -642,7 +936,6 @@ struct pef_serial_cfgparm_tap_svc_settings {
#endif
#define IPMI_CMD_GET_PEF_CAPABILITIES 0x10
#define IPMI_CMD_SET_PEF_CONFIG_PARMS 0x12
#define IPMI_CMD_GET_PEF_CONFIG_PARMS 0x13
#define IPMI_CMD_GET_LAST_PROCESSED_EVT_ID 0x15
#define IPMI_CMD_GET_SYSTEM_GUID 0x37
@ -650,13 +943,6 @@ struct pef_serial_cfgparm_tap_svc_settings {
#define IPMI_CMD_LAN_GET_CONFIG 0x02
#define IPMI_CMD_SERIAL_GET_CONFIG 0x11
struct pef_cfgparm_set_policy_table_entry
{
uint8_t param_selector;
uint8_t policy_id;
struct pef_policy_entry entry;
} ATTRIBUTE_PACKING;
const char * ipmi_pef_bit_desc(struct bit_desc_map * map, uint32_t val);
void ipmi_pef_print_flags(struct bit_desc_map * map, flg_e type, uint32_t val);
void ipmi_pef_print_dec(const char * text, uint32_t val);
@ -666,3 +952,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);
int ipmi_pef_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /* IPMI_PEF_H */

View File

@ -3,7 +3,8 @@
(C) Kontron
*/
#pragma once
#ifndef _IPMI_PICMG_H_
#define _IPMI_PICMG_H_
#include <ipmitool/ipmi.h>
@ -11,7 +12,6 @@
#define PICMG_CPCI_MAJOR_VERSION 1
#define PICMG_ATCA_MAJOR_VERSION 2
#define PICMG_AMC_MAJOR_VERSION 4
#define PICMG_UTCA_MAJOR_VERSION 5
/* PICMG commands */
#define PICMG_GET_PICMG_PROPERTIES_CMD 0x00
@ -91,7 +91,95 @@ typedef enum picmg_busres_resource_id {
PICMG_BUSRES_SYNC_CLOCK_GROUP_3
} 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 {
#ifndef WORDS_BIGENDIAN
@ -119,3 +207,5 @@ struct sAmcPortState {
int ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv);
uint8_t picmg_discover(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.
*/
#pragma once
#ifndef IPMI_RAW_H
#define IPMI_RAW_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);
int ipmi_rawi2c_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.
*/
#pragma once
#ifndef IPMI_SDR_H
#define IPMI_SDR_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdbool.h>
#include <inttypes.h>
#include <math.h>
#include <ipmitool/bswap.h>
@ -381,29 +381,6 @@ struct sdr_record_common_sensor {
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 {
#if WORDS_BIGENDIAN
uint8_t analog:2;
@ -417,8 +394,8 @@ struct sdr_record_common_sensor {
uint8_t analog:2;
#endif
struct {
uint8_t base; /* Base unit type code per IPMI 2.0 Table 43-15 */
uint8_t modifier; /* Modifier unit type code per Table 43-15 */
uint8_t base;
uint8_t modifier;
} ATTRIBUTE_PACKING type;
} ATTRIBUTE_PACKING unit;
} ATTRIBUTE_PACKING;
@ -796,7 +773,50 @@ struct sdr_record_list {
#pragma pack(0)
#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
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 {
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);
uint8_t *ipmi_sdr_get_record(struct ipmi_intf *intf, struct sdr_get_rs *header,
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_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 len);
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,
uint8_t hysteresis_value,
const char *hdrstr);
const char *ipmi_sdr_get_unit_string(bool pct, uint8_t type,
uint8_t base, uint8_t modifier);
const char *ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type,
uint8_t base, uint8_t modifier);
struct sensor_reading *
ipmi_sdr_read_sensor_value(struct ipmi_intf *intf,
struct sdr_record_common_sensor *sensor,
@ -886,14 +907,21 @@ struct ipmi_rs *ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf,
struct ipmi_rs *ipmi_sdr_get_sensor_hysteresis(struct ipmi_intf *intf,
uint8_t sensor,
uint8_t target, uint8_t lun, uint8_t channel);
const char *ipmi_sdr_get_sensor_type_desc(const uint8_t type);
int ipmi_sdr_get_reservation(struct ipmi_intf *intf, int use_builtin,
uint16_t * reserve_id);
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf,
struct sdr_record_eventonly_sensor *sensor);
int ipmi_sdr_print_sensor_generic_locator(struct sdr_record_generic_locator *fru);
int ipmi_sdr_print_sensor_fru_locator(struct sdr_record_fru_locator *fru);
int ipmi_sdr_print_sensor_mc_locator(struct sdr_record_mc_locator *mc);
int ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf,
struct sdr_record_generic_locator
*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 entity_id *entity);
@ -906,15 +934,13 @@ 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,
uint8_t type);
int ipmi_sdr_list_cache(struct ipmi_intf *intf);
int ipmi_sdr_list_cache_fromfile(const char *ifile);
void ipmi_sdr_list_empty(void);
int ipmi_sdr_list_cache_fromfile(struct ipmi_intf *intf, const char *ifile);
void ipmi_sdr_list_empty(struct ipmi_intf *intf);
int ipmi_sdr_print_info(struct ipmi_intf *intf);
void ipmi_sdr_print_discrete_state(struct ipmi_intf *intf,
const char *desc, uint8_t sensor_type,
uint8_t event_type, uint8_t state1,
uint8_t state2);
void ipmi_sdr_print_discrete_state_mini(struct ipmi_intf *intf,
const char *header, const char *separator,
void ipmi_sdr_print_discrete_state(const char *desc, uint8_t sensor_type,
uint8_t event_type, uint8_t state1,
uint8_t state2);
void ipmi_sdr_print_discrete_state_mini(const char *header, const char *separator,
uint8_t sensor_type, uint8_t event_type,
uint8_t state1, uint8_t state2);
int ipmi_sdr_print_sensor_event_status(struct ipmi_intf *intf,
@ -925,3 +951,5 @@ int ipmi_sdr_print_sensor_event_enable(struct ipmi_intf *intf,
uint8_t sensor_num, uint8_t sensor_type,
uint8_t event_type, int numeric_fmt,
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,
* 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
@ -41,3 +42,5 @@ ipmi_sdr_add_from_file(struct ipmi_intf *intf, const char *ifile);
int
ipmi_sdr_add_from_list(struct ipmi_intf *intf, const char *rangeList);
#endif /* IPMI_SDRADD_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,151 +0,0 @@
/*
* Copyright (c) 2003 Sun Microsystems, 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 Sun Microsystems, 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.
* SUN MICROSYSTEMS, INC. ("SUN") 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
* SUN 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
static uint16_t supermicro_x11[] = {
0x0958, 0x0955, 0x0953, 0x0952, 0x0941, 0x093A, 0x0939, 0x0938, 0x0937, 0x0930, 0x0927, 0x091D,
0x091C, 0x0917, 0x090D, 0x0909, 0x0907, 0x0901, 0x089F, 0x089C, 0x089B, 0x089A, 0x0898, 0x0896,
0x0895, 0x0894, 0x0891, 0x0890, 0x0888, 0x0886, 0x0885, 0x0884, 0xFFFF
};
static uint16_t supermicro_b11[] = {
0xFFFF
};
static uint16_t supermicro_b2[] = {
0x0951, 0x094E, 0x0931, 0x092E, 0x092A, 0x0928, 0x0908, 0xFFFF
};
static uint16_t supermicro_x10OBi[] = {
0x0923, 0xFFFF
};
static uint16_t supermicro_x10QRH[] = {
0x0872, 0xFFFF
};
static uint16_t supermicro_x10QBL[] = {
0x0853, 0xFFFF
};
static uint16_t supermicro_brickland[] = {
0x0726, 0x083A, 0xFFFF
};
static uint16_t supermicro_x9dal[] = {
0x0635, 0xFFFF
};
static uint16_t supermicro_x9db[] = {
0x0733, 0x0722, 0x0703, 0x0721, 0x0716, 0x0637, 0xFFFF
};
static uint16_t supermicro_x9sb[] = {
0x0651, 0xFFFF
};
static uint16_t supermicro_x9[] = {
0x0635, 0x0733, 0x0722, 0x0703, 0x0721, 0x0716, 0x0637, 0x0651, 0xFFFF
};
static uint16_t supermicro_romely[] = {
0x0841, 0x0732, 0x0731, 0x0730, 0x0727, 0x0725, 0x0724, 0x0723, 0x0720, 0x0718, 0x0717, 0x0715,
0x0713, 0x0711, 0x070E, 0x070A, 0x0709, 0x0708, 0x0706, 0x0705, 0x0704, 0x0702, 0x0701, 0x0700,
0x066F, 0x066E, 0x066D, 0x0669, 0x0667, 0x0666, 0x0665, 0x0664, 0x0662, 0x0660, 0x0636, 0x0630,
0x062F, 0x062C, 0x0628, 0x0626, 0x0827, 0x070F, 0x0707, 0x0840, 0x0729, 0x0719, 0x0712, 0x070D,
0x066C, 0x066A, 0x0625, 0x0714, 0x0710, 0x070C, 0x070B, 0x0668, 0x0663, 0x0661, 0x062B, 0x062A,
0x0629, 0x093E, 0x0932, 0x092D, 0x092B, 0x0924, 0x0922, 0x0921, 0x091E, 0x0919, 0x0916, 0x089D,
0x0899, 0x0893, 0x0892, 0x0882, 0x0881, 0x0880, 0x087F, 0x087D, 0x0879, 0x0877, 0x086F, 0x086E,
0x086D, 0x086C, 0x086B, 0x085C, 0x085B, 0x084B, 0x0865, 0x0864, 0x0860, 0x0859, 0x0858, 0x0857,
0x0854, 0x0852, 0x0845, 0x0844, 0x0843, 0x0842, 0x083B, 0x0838, 0x0837, 0x0836, 0x0835, 0x0834,
0x0833, 0x0832, 0x0831, 0x0830, 0x0826, 0x0825, 0x0824, 0x0822, 0x0821, 0x0819, 0x0818, 0x0817,
0x0816, 0x0815, 0x0814, 0x0728, 0x0813, 0x0812, 0x0810, 0x0807, 0x0806, 0x0805, 0x0804, 0x0803,
0x0802, 0x0801, 0x0889, 0x0861, 0x083E, 0x0846, 0x0946, 0x0950, 0xFFFF
};
static uint16_t supermicro_b8[] = {
0x000A, 0x061c, 0x0620, 0x0101, 0x061f, 0x0612, 0x061e, 0xFFFF
};
static uint16_t supermicro_h8[] = {
0xa111, 0x0408, 0x0811, 0x1411, 0x0911, 0x1211, 0x1011, 0xcd11, 0x1111, 0xbe11, 0xce11, 0xbd11,
0xbc11, 0xa911, 0xaa11, 0xcb11, 0xad11, 0xa811, 0xac11, 0xaf11, 0xa511, 0xa011, 0x1611, 0x2511,
0xbf11, 0x1511, 0x2211, 0x2411, 0x1911, 0xab11, 0xd011, 0xae11, 0xca11, 0x0409, 0xa211, 0xa311,
0x1311, 0xba11, 0xa711, 0xd111, 0x1711, 0xcf11, 0x2011, 0x1811, 0xFFFF
};
static uint16_t supermicro_p8[] = {
0x5980, 0x6280, 0x6480, 0x7380, 0x7480, 0x0933, 0x094F, 0xFFFF
};
static uint16_t supermicro_x8[] = {
0xa880, 0x0403, 0x0100, 0x0601, 0x0001, 0x0404, 0x0606, 0x0608, 0x0632, 0x0400, 0x0401, 0x0006,
0x040a, 0xf280, 0x060f, 0x0609, 0x0008, 0x0613, 0x061b, 0x0007, 0x0600, 0x060c, 0x060d, 0x0614,
0x0003, 0x040b, 0x0621, 0x0610, 0x0638, 0xf380, 0x060b, 0x040d, 0x0605, 0x062d, 0x060e, 0x061a,
0xf580, 0x062e, 0x0009, 0xFFFF
};
static uint16_t supermicro_X8[] = {
0x000A, 0x061c, 0x0620, 0x0101, 0x061f, 0x0612, 0x061e, 0xa111, 0x0408, 0x0811, 0x1411, 0x0911,
0x1211, 0x1011, 0xcd11, 0x1111, 0xbe11, 0xce11, 0xbd11, 0xbc11, 0xa911, 0xaa11, 0xcb11, 0xad11,
0xa811, 0xac11, 0xaf11, 0xa511, 0xa011, 0x1611, 0x2511, 0xbf11, 0x1511, 0x2211, 0x2411, 0x1911,
0xab11, 0xd011, 0xae11, 0xca11, 0x0409, 0xa211, 0xa311, 0x1311, 0xba11, 0xa711, 0xd111, 0x1711,
0xcf11, 0x2011, 0x1811, 0x5980, 0x6280, 0x6480, 0x7380, 0x7480, 0x0933, 0x094F, 0xa880, 0x0403,
0x0100, 0x0601, 0x0001, 0x0404, 0x0606, 0x0608, 0x0632, 0x0400, 0x0401, 0x0006, 0x040a, 0xf280,
0x060f, 0x0609, 0x0008, 0x0613, 0x061b, 0x0007, 0x0600, 0x060c, 0x060d, 0x0614, 0x0003, 0x040b,
0x0621, 0x0610, 0x0638, 0xf380, 0x060b, 0x040d, 0x0605, 0x062d, 0x060e, 0x061a, 0xf580, 0x062e,
0x0009, 0xFFFF
};
static uint16_t supermicro_older[] = {
0x8080, 0x8180, 0x8280, 0x8480, 0x8580, 0x8680, 0x8780, 0x8880, 0x8980, 0x9080, 0x9180, 0x9280,
0x9380, 0x9480, 0x9580, 0x9680, 0x9780, 0xA080, 0x9880, 0x9980, 0xB080, 0xB180, 0xB280, 0xB380,
0xB480, 0xA280, 0xB580, 0xB680, 0xA580, 0xB780, 0xD180, 0xA380, 0xA480, 0xD680, 0xBA80, 0xD280,
0x2111, 0xD380, 0xBC80, 0xBD80, 0xBE80, 0xC080, 0xC180, 0xAA80, 0xBE80, 0xBF80, 0xAB80, 0xD480,
0xD580, 0xAF80, 0xAE80, 0xC280, 0xAC80, 0xD080, 0xDA80, 0xDB80, 0xDC80, 0xDD80, 0xA680, 0xDE80,
0xAA80, 0xDF80, 0xBB80, 0xA780, 0xF080, 0xF180, 0xB880, 0xC380, 0xB780, 0x2311, 0xA980, 0xF480,
0xB980, 0x0002, 0xba80, 0x0602, 0x0603, 0x0604, 0x0607, 0x0410, 0xA611, 0x060A, 0x0611, 0xBB11,
0x061D, 0x0622, 0x0623, 0x0624, 0x0627, 0x0631, 0x0633, 0x0634, 0x0690, 0x0691, 0x0640, 0x0641,
0x0642, 0x066B, 0x0743, 0x0644, 0x0645, 0x0645, 0x0646, 0x0647, 0x0648, 0x0647, 0x0650, 0x0652,
0x0653, 0x0654, 0x0655, 0x0808, 0x0809, 0x0656, 0x0657, 0x0658, 0x0659, 0x0820, 0x0820, 0x0734,
0x0823, 0x0828, 0x0829, 0x0839, 0x083C, 0x083D, 0x083F, 0x0847, 0x0848, 0x0849, 0x0850, 0x0851,
0x0855, 0x0856, 0x0862, 0x0863, 0x0866, 0x0867, 0x0868, 0x0869, 0x084A, 0x084C, 0x084D, 0x084F,
0x085A, 0x085D, 0x085E, 0x085F, 0x086A, 0x0870, 0x0873, 0x0874, 0x0875, 0x0876, 0x0878, 0x087A,
0x087B, 0x087C, 0x087E, 0x0883, 0x0887, 0x088A, 0x088B, 0x088C, 0x088D, 0x088E, 0x088F, 0x0897,
0x089E, 0x0902, 0x0903, 0x0904, 0x0905, 0x0906, 0x090A, 0x090B, 0x090C, 0x090E, 0x090F, 0x0910,
0x0912, 0x0913, 0x0914, 0x0915, 0x0918, 0x091A, 0x091B, 0x091F, 0x0920, 0x0925, 0x0926, 0x0929,
0x092C, 0x092F, 0x0934, 0x0935, 0x0936, 0x093B, 0x093C, 0x093D, 0x093F, 0x0940, 0x0942, 0x0943,
0x0944, 0x0945, 0x0947, 0x0948, 0x0949, 0x094A, 0x094B, 0x094C, 0x094D, 0x094E, 0x0954, 0x0956,
0x0957, 0x0959, 0xFFFF
};

View File

@ -30,7 +30,8 @@
* 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 <ipmitool/bswap.h>
@ -85,3 +86,4 @@ struct sensor_set_thresh_rq {
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_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.
*/
#pragma once
#ifndef IPMI_SESSION_H
#define IPMI_SESSION_H
#if HAVE_CONFIG_H
# include <config.h>
@ -126,3 +127,5 @@ struct get_session_info_rsp
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.
*/
#pragma once
#ifndef IPMI_SOL_H
#define IPMI_SOL_H
#include <ipmitool/ipmi.h>
@ -63,7 +64,7 @@ struct sol_config_parameters {
/*
* The ACTIVATE PAYLOAD command response structure
* The ACTIVATE PAYLOAD command reponse structure
* From table 24-2 of the IPMI v2.0 spec
*/
#ifdef PRAGMA_PACK
@ -91,13 +92,17 @@ struct activate_payload_rsp {
* function will return -1 if value is not valid, or
* will return 0 if valid.
*/
int ipmi_sol_set_param_isvalid_uint8_t(const char *strval,
const char *name,
uint8_t minval,
uint8_t maxval,
uint8_t *out_value);
int ipmi_sol_set_param_isvalid_uint8_t( const char *strval,
const char *name,
int base,
uint8_t minval,
uint8_t maxval,
uint8_t *out_value);
int ipmi_sol_main(struct ipmi_intf *, int, char **);
int ipmi_get_sol_info(struct ipmi_intf *intf,
uint8_t channel,
struct sol_config_parameters *params);
int ipmi_get_sol_info(struct ipmi_intf * intf,
uint8_t channel,
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.
*/
#pragma once
#ifndef IPMI_STRINGS_H
#define IPMI_STRINGS_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 entity_id_vals[];
extern const struct valstr entity_device_type_vals[];
@ -49,14 +48,10 @@ extern const struct valstr ipmi_authtype_vals[];
extern const struct valstr ipmi_channel_protocol_vals[];
extern const struct valstr ipmi_channel_medium_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_integrity_algorithms[];
extern const struct valstr ipmi_encryption_algorithms[];
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 ipmi_oem_info[];
extern const struct valstr picmg_frucontrol_vals[];
extern const struct valstr picmg_clk_family_vals[];
@ -73,5 +68,8 @@ extern const struct oemvalstr picmg_busres_shmc_status_vals[];
/* these are similar, expect that the lookup takes the IANA number
as first parameter */
extern const struct oemvalstr ipmi_oem_product_info[];
extern const char *ipmi_generic_sensor_type_vals[];
extern const struct oemvalstr ipmi_oem_sensor_type_vals[];
extern const struct oemvalstr ipmi_oem_sdr_type_vals[];
#endif /*IPMI_STRINGS_H*/

View File

@ -30,7 +30,8 @@
* 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
# include <config.h>
@ -67,3 +68,6 @@ typedef enum {
} sunoem_ec_t;
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.
*/
#pragma once
#ifndef IPMI_TSOL_H
#define IPMI_TSOL_H
#include <ipmitool/ipmi.h>
@ -41,3 +42,5 @@
#define IPMI_TSOL_DEF_PORT 6230
int ipmi_tsol_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_TSOL_H */

View File

@ -30,54 +30,66 @@
* 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
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
#define IPMI_PASSWORD_DISABLE_USER 0x00
#define IPMI_PASSWORD_ENABLE_USER 0x01
#define IPMI_PASSWORD_SET_PASSWORD 0x02
#define IPMI_PASSWORD_TEST_PASSWORD 0x03
#define IPMI_USER_ENABLE_UNSPECIFIED 0x00
#define IPMI_USER_ENABLE_ENABLED 0x40
#define IPMI_USER_ENABLE_DISABLED 0x80
#define IPMI_USER_ENABLE_RESERVED 0xC0
/*
* The GET USER ACCESS response from table 22-32 of the IPMI v2.0 spec
*/
struct user_access_rsp {
#if WORDS_BIGENDIAN
uint8_t __reserved1 : 2;
uint8_t maximum_ids : 6;
#else
uint8_t maximum_ids : 6;
uint8_t __reserved1 : 2;
#endif
#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)
#if WORDS_BIGENDIAN
uint8_t __reserved2 : 2;
uint8_t enabled_user_count : 6;
#else
uint8_t enabled_user_count : 6;
uint8_t __reserved2 : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved3 : 2;
uint8_t fixed_name_count : 6;
#else
uint8_t fixed_name_count : 6;
uint8_t __reserved3 : 2;
#endif
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved4 : 1;
uint8_t no_callin_access : 1;
uint8_t link_auth_access : 1;
uint8_t ipmi_messaging_access : 1;
uint8_t channel_privilege_limit : 4;
#else
uint8_t channel_privilege_limit : 4;
uint8_t ipmi_messaging_access : 1;
uint8_t link_auth_access : 1;
uint8_t no_callin_access : 1;
uint8_t __reserved4 : 1;
#endif
} ATTRIBUTE_PACKING;
#ifdef HAVE_PRAGMA_PACK
#pragma pack(0)
#endif
/* (22.27) Get and (22.26) Set User Access */
struct user_access_t {
uint8_t callin_callback;
uint8_t channel;
uint8_t enabled_user_ids;
uint8_t enable_status;
uint8_t fixed_user_ids;
uint8_t ipmi_messaging;
uint8_t link_auth;
uint8_t max_user_ids;
uint8_t privilege_limit;
uint8_t session_limit;
uint8_t user_id;
};
/* (22.29) Get User Name */
struct user_name_t {
uint8_t user_id;
uint8_t user_name[17];
};
int ipmi_user_main(struct ipmi_intf *, int, char **);
int _ipmi_get_user_access(struct ipmi_intf *intf,
struct user_access_t *user_access_rsp);
int _ipmi_get_user_name(struct ipmi_intf *intf, struct user_name_t *user_name);
int _ipmi_set_user_access(struct ipmi_intf *intf,
struct user_access_t *user_access_req,
uint8_t change_priv_limit_only);
int _ipmi_set_user_password(struct ipmi_intf *intf,
uint8_t user_id, uint8_t operation,
const char *password, uint8_t is_twenty_byte);
#endif /* IPMI_USER_H */

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) Pigeon Point Systems. All right reserved
*/
#pragma once
/* VITA 46.11 commands */
#define VITA_GET_VSO_CAPABILITIES_CMD 0x00
#define VITA_FRU_CONTROL_CMD 0x04
#define VITA_GET_FRU_LED_PROPERTIES_CMD 0x05
#define VITA_GET_LED_COLOR_CAPABILITIES_CMD 0x06
#define VITA_SET_FRU_LED_STATE_CMD 0x07
#define VITA_GET_FRU_LED_STATE_CMD 0x08
#define VITA_SET_FRU_STATE_POLICY_BITS_CMD 0x0A
#define VITA_GET_FRU_STATE_POLICY_BITS_CMD 0x0B
#define VITA_SET_FRU_ACTIVATION_CMD 0x0C
#define VITA_GET_FRU_ADDRESS_INFO_CMD 0x40
/* VITA 46.11 site types */
#define VITA_FRONT_VPX_MODULE 0x00
#define VITA_POWER_ENTRY 0x01
#define VITA_CHASSIS_FRU 0x02
#define VITA_DEDICATED_CHMC 0x03
#define VITA_FAN_TRAY 0x04
#define VITA_FAN_TRAY_FILTER 0x05
#define VITA_ALARM_PANEL 0x06
#define VITA_XMC 0x07
#define VITA_VPX_RTM 0x09
#define VITA_FRONT_VME_MODULE 0x0A
#define VITA_FRONT_VXS_MODULE 0x0B
#define VITA_POWER_SUPPLY 0x0C
#define VITA_FRONT_VITA62_MODULE 0x0D
#define VITA_71_MODULE 0x0E
#define VITA_FMC 0x0F
#define GROUP_EXT_VITA 0x03
extern uint8_t
vita_discover(struct ipmi_intf *intf);
extern uint8_t
ipmi_vita_ipmb_address(struct ipmi_intf *intf);
extern int
ipmi_vita_main(struct ipmi_intf * intf, int argc, char ** argv);

View File

@ -30,7 +30,8 @@
* 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>
@ -53,6 +54,10 @@
void log_init(const char * name, int isdaemon, int verbose);
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 lperror(int level, const char * format, ...);
#endif /*IPMITOOL_LOG_H*/

View File

@ -28,8 +28,7 @@
# 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.
AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS = -I$(top_srcdir)/include
INCLUDES = -I$(top_srcdir)/include
MAINTAINERCLEANFILES = Makefile.in
noinst_LTLIBRARIES = libipmitool.la
@ -40,8 +39,8 @@ libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_pef.c \
ipmi_oem.c ipmi_isol.c ipmi_sunoem.c ipmi_fwum.c ipmi_picmg.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_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_ime.c ipmi_delloem.c ipmi_dcmi.c hpm2.c \
../src/plugins/lan/md5.c ../src/plugins/lan/md5.h
libipmitool_la_LDFLAGS = -export-dynamic
libipmitool_la_LIBADD = -lm

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,6 @@
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>
#if HAVE_CONFIG_H
# include <config.h>
@ -54,7 +53,7 @@
#ifdef HAVE_PATHS_H
# include <paths.h>
#else
# define _PATH_RUN "/run/"
# define _PATH_VARRUN "/var/run/"
#endif
#include <ipmitool/ipmi.h>
@ -74,141 +73,24 @@ uint16_t buf2short(uint8_t * buf)
return (uint16_t)(buf[1] << 8 | buf[0]);
}
/* buf2str_extended - convert sequence of bytes to hexadecimal string with
* optional separator
*
* @param buf - data to convert
* @param len - size of data
* @param sep - optional separator (can be NULL)
*
* @returns buf representation in hex, possibly truncated to fit
* allocated static memory
*/
const char *
buf2str_extended(const uint8_t *buf, int len, const char *sep)
const char * buf2str(uint8_t * buf, int len)
{
static char str[BUF2STR_MAXIMUM_OUTPUT_SIZE];
char *cur;
static char str[2049];
int i;
int sz;
int left;
int sep_len;
if (!buf) {
snprintf(str, sizeof(str), "<NULL>");
return (const char *)str;
}
cur = str;
left = sizeof(str);
if (sep) {
sep_len = strlen(sep);
} else {
sep_len = 0;
}
for (i = 0; i < len; i++) {
/* may return more than 2, depending on locale */
sz = snprintf(cur, left, "%2.2x", buf[i]);
if (sz >= left) {
/* buffer overflow, truncate */
break;
}
cur += sz;
left -= sz;
/* do not write separator after last byte */
if (sep && i != (len - 1)) {
if (sep_len >= left) {
break;
}
strncpy(cur, sep, left - sz);
cur += sep_len;
left -= sep_len;
}
}
*cur = '\0';
if (len <= 0 || len > 1024)
return NULL;
memset(str, 0, 2049);
for (i=0; i<len; i++)
sprintf(str+i+i, "%2.2x", buf[i]);
str[len*2] = '\0';
return (const char *)str;
}
const char *
buf2str(const uint8_t *buf, int len)
{
return buf2str_extended(buf, len, NULL);
}
/* ipmi_parse_hex - convert hexadecimal numbers to ascii string
* Input string must be composed of two-characer
* hexadecimal numbers.
* There is no separator between the numbers. Each number
* results in one byte of the converted string.
*
* Example: ipmi_parse_hex("50415353574F5244")
* returns 'PASSWORD'
*
* @param str: input string. It must contain only even number
* of '0'-'9','a'-'f' and 'A-F' characters.
* @param out: pointer to output data
* @param size: size of the output buffer
* @returns 0 for empty input string
* -1 for string with odd length
* -2 if out is NULL
* -3 if there is non-hexadecimal char in string
* >0 length of resulting binary data even if it is > size
*/
int
ipmi_parse_hex(const char *str, uint8_t *out, int size)
{
const char *p;
uint8_t *q;
uint8_t d = 0;
uint8_t b = 0;
int shift = 4;
int len;
len = strlen(str);
if (len == 0) {
return 0;
}
if (len % 2 != 0) {
return -1;
}
len /= 2; /* out bytes */
if (!out) {
return -2;
}
for (p = str, q = out; *p; p++) {
if (!isxdigit(*p)) {
return -3;
}
if (*p < 'A') {
/* it must be 0-9 */
d = *p - '0';
} else {
/* it's A-F or a-f */
/* convert to lowercase and to 10-15 */
d = (*p | 0x20) - 'a' + 10;
}
if (q < (out + size)) {
/* there is space, store */
b += d << shift;
if (shift) {
shift = 0;
} else {
shift = 4;
*q = b;
b = 0;
q++;
}
}
}
return len;
}
void printbuf(const uint8_t * buf, int len, const char * desc)
{
int i;
@ -228,168 +110,29 @@ void printbuf(const uint8_t * buf, int len, const char * desc)
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
* into buffer.
*
* @arg: string to be parsed.
* @buf: buffer of 6 to hold parsed MAC address.
*
* returns zero on success, (-1) on error and error message is printed-out.
*/
int
str2mac(const char *arg, uint8_t *buf)
{
unsigned int m1 = 0;
unsigned int m2 = 0;
unsigned int m3 = 0;
unsigned int m4 = 0;
unsigned int m5 = 0;
unsigned int m6 = 0;
if (sscanf(arg, "%02x:%02x:%02x:%02x:%02x:%02x",
&m1, &m2, &m3, &m4, &m5, &m6) != 6) {
lprintf(LOG_ERR, "Invalid MAC address: %s", arg);
return -1;
}
if (m1 > UINT8_MAX || m2 > UINT8_MAX
|| m3 > UINT8_MAX || m4 > UINT8_MAX
|| m5 > UINT8_MAX || m6 > UINT8_MAX) {
lprintf(LOG_ERR, "Invalid MAC address: %s", arg);
return -1;
}
buf[0] = (uint8_t)m1;
buf[1] = (uint8_t)m2;
buf[2] = (uint8_t)m3;
buf[3] = (uint8_t)m4;
buf[4] = (uint8_t)m5;
buf[5] = (uint8_t)m6;
return 0;
}
/* mac2str -- return MAC address as a string
*
* @buf: buffer of 6 to hold parsed MAC address.
*/
const char *
mac2str(const uint8_t *buf)
{
return buf2str_extended(buf, 6, ":");
}
/**
* 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)
const char * val2str(uint16_t val, const struct valstr *vs)
{
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);
snprintf(un_str, 32, "Unknown (0x%02X)", val);
return un_str;
}
const char *
specific_val2str(uint32_t val,
const struct valstr *specific,
const struct valstr *generic)
const char * oemval2str(uint32_t oem, uint16_t val,
const struct oemvalstr *vs)
{
static char un_str[32];
int i;
if (0 <= (i = find_val_idx(val, specific))) {
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++) {
for (i = 0; vs[i].oem != 0xffffff && vs[i].str != NULL; i++) {
/* FIXME: for now on we assume PICMG capability on all IANAs */
if ( (vs[i].oem == oem || vs[i].oem == IPMI_OEM_PICMG) &&
vs[i].val == val ) {
@ -397,7 +140,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
@ -642,12 +388,12 @@ int str2uchar(const char * str, uint8_t * uchr_ptr)
return 0;
} /* str2uchar(...) */
uint32_t str2val32(const char *str, const struct valstr *vs)
uint16_t str2val(const char *str, const struct valstr *vs)
{
int i;
for (i = 0; vs[i].str; i++) {
if (strcasecmp(vs[i].str, str) == 0)
for (i = 0; vs[i].str != NULL; i++) {
if (strncasecmp(vs[i].str, str, __maxlen(str, vs[i].str)) == 0)
return vs[i].val;
}
@ -665,10 +411,10 @@ print_valstr(const struct valstr * vs, const char * title, int loglevel)
{
int i;
if (!vs)
if (vs == NULL)
return;
if (title) {
if (title != NULL) {
if (loglevel < 0)
printf("\n%s:\n\n", title);
else
@ -683,7 +429,7 @@ print_valstr(const struct valstr * vs, const char * title, int loglevel)
lprintf(loglevel, "==============================================");
}
for (i = 0; vs[i].str; i++) {
for (i = 0; vs[i].str != NULL; i++) {
if (loglevel < 0) {
if (vs[i].val < 256)
printf(" %d\t0x%02x\t%s\n", vs[i].val, vs[i].val, vs[i].str);
@ -714,18 +460,18 @@ print_valstr_2col(const struct valstr * vs, const char * title, int loglevel)
{
int i;
if (!vs)
if (vs == NULL)
return;
if (title) {
if (title != NULL) {
if (loglevel < 0)
printf("\n%s:\n\n", title);
else
lprintf(loglevel, "\n%s:\n", title);
}
for (i = 0; vs[i].str; i++) {
if (!vs[i+1].str) {
for (i = 0; vs[i].str != NULL; i++) {
if (vs[i+1].str == NULL) {
/* last one */
if (loglevel < 0) {
printf(" %4d %-32s\n", vs[i].val, vs[i].str);
@ -779,12 +525,12 @@ ipmi_open_file(const char * file, int rw)
struct stat st1, st2;
FILE * fp;
/* verify existence */
/* verify existance */
if (lstat(file, &st1) < 0) {
if (rw) {
/* does not exist, ok to create */
fp = fopen(file, "w");
if (!fp) {
if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s "
"for write", file);
return NULL;
@ -801,7 +547,7 @@ ipmi_open_file(const char * file, int rw)
if (!rw) {
/* on read skip the extra checks */
fp = fopen(file, "r");
if (!fp) {
if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s", file);
return NULL;
}
@ -824,7 +570,7 @@ ipmi_open_file(const char * file, int rw)
}
fp = fopen(file, rw ? "w+" : "r");
if (!fp) {
if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s", file);
return NULL;
}
@ -868,7 +614,6 @@ ipmi_start_daemon(struct ipmi_intf *intf)
{
pid_t pid;
int fd;
int ret;
#ifdef SIGHUP
sigset_t sighup;
#endif
@ -912,11 +657,7 @@ ipmi_start_daemon(struct ipmi_intf *intf)
exit(0);
#endif
ret = chdir("/");
if (ret) {
lprintf(LOG_ERR, "chdir failed: %s (%d)", strerror(errno), errno);
exit(1);
}
chdir("/");
umask(0);
for (fd=0; fd<64; fd++) {
@ -925,57 +666,9 @@ ipmi_start_daemon(struct ipmi_intf *intf)
}
fd = open("/dev/null", O_RDWR);
if (fd != STDIN_FILENO) {
lprintf(LOG_ERR, "failed to reset stdin: %s (%d)", strerror(errno), errno);
exit(1);
}
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
* message, if conditions are met.
*
* @ccode - return value of _ipmi_* function.
*
* returns - 0 if ccode is 0, otherwise (-1) and error might get printed-out.
*/
int
eval_ccode(const int ccode)
{
if (!ccode) {
return 0;
} else if (ccode < 0) {
switch (ccode) {
case (-1):
lprintf(LOG_ERR, "IPMI response is NULL.");
break;
case (-2):
lprintf(LOG_ERR, "Unexpected data length received.");
break;
case (-3):
lprintf(LOG_ERR, "Invalid function parameter.");
break;
case (-4):
lprintf(LOG_ERR, "ipmitool: malloc failure.");
break;
default:
break;
}
return (-1);
} else {
lprintf(LOG_ERR, "IPMI command failed: %s",
val2str(ccode, completion_code_vals));
return (-1);
}
assert(0 == fd);
dup(fd);
dup(fd);
}
/* is_fru_id - wrapper for str-2-int FRU ID conversion. Message is printed
@ -1007,9 +700,9 @@ is_fru_id(const char *argv_ptr, uint8_t *fru_id_ptr)
/* is_ipmi_channel_num - wrapper for str-2-int Channel conversion. Message is
* printed on error.
*
* 6.3 Channel Numbers, p. 49, IPMIv2 spec. rev1.1
* Valid channel numbers are: <0x0..0xB>, <0xE-0xF>
* Reserved channel numbers: <0xC-0xD>
* 6.3 Channel Numbers, p. 45, IPMIv2 spec.
* Valid channel numbers are: <0..7>, <E-F>
* Reserved channel numbers: <8-D>
*
* @argv_ptr: source string to convert from; usually argv
* @channel_ptr: pointer where to store result
@ -1026,14 +719,14 @@ is_ipmi_channel_num(const char *argv_ptr, uint8_t *channel_ptr)
return (-1);
}
if ((str2uchar(argv_ptr, channel_ptr) == 0)
&& (*channel_ptr <= 0xB
&& ((*channel_ptr >= 0x0 && *channel_ptr <= 0x7)
|| (*channel_ptr >= 0xE && *channel_ptr <= 0xF))) {
return 0;
}
lprintf(LOG_ERR,
"Given Channel number '%s' is either invalid or out of range.",
argv_ptr);
lprintf(LOG_ERR, "Channel number must be from ranges: <0x0..0xB>, <0xE..0xF>");
lprintf(LOG_ERR, "Channel number must be from ranges: <0..7>, <0xE..0xF>");
return (-1);
}
@ -1067,36 +760,6 @@ is_ipmi_user_id(const char *argv_ptr, uint8_t *ipmi_uid_ptr)
return (-1);
}
/* is_ipmi_user_priv_limit - check whether given value is valid User Privilege
* Limit, eg. IPMI v2 spec, 22.27 Get User Access Command.
*
* @priv_limit: User Privilege Limit
*
* returns 0 if Priv Limit is valid
* returns (-1) when Priv Limit is invalid
*/
int
is_ipmi_user_priv_limit(const char *argv_ptr, uint8_t *ipmi_priv_limit_ptr)
{
if (!argv_ptr || !ipmi_priv_limit_ptr) {
lprintf(LOG_ERR,
"is_ipmi_user_priv_limit(): invalid argument(s).");
return (-1);
}
if ((str2uchar(argv_ptr, ipmi_priv_limit_ptr) != 0)
|| ((*ipmi_priv_limit_ptr < 0x01
|| *ipmi_priv_limit_ptr > 0x05)
&& *ipmi_priv_limit_ptr != 0x0F)) {
lprintf(LOG_ERR,
"Given Privilege Limit '%s' is invalid.",
argv_ptr);
lprintf(LOG_ERR,
"Privilege Limit is limited to <0x1..0x5> and <0xF>.");
return (-1);
}
return 0;
}
uint16_t
ipmi_get_oem_id(struct ipmi_intf *intf)
{
@ -1111,11 +774,11 @@ ipmi_get_oem_id(struct ipmi_intf *intf)
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Get Board ID command failed");
return 0;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Board ID command failed: %#x %s",
rsp->ccode, val2str(rsp->ccode, completion_code_vals));
return 0;
@ -1125,35 +788,3 @@ ipmi_get_oem_id(struct ipmi_intf *intf)
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

@ -36,12 +36,6 @@
#include <ipmitool/log.h>
#include <ipmitool/bswap.h>
/* From src/plugins/ipmi_intf.c: */
void
ipmi_intf_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size);
void
ipmi_intf_set_max_response_data_size(struct ipmi_intf * intf, uint16_t size);
#if HAVE_PRAGMA_PACK
# pragma pack(push, 1)
#endif
@ -134,7 +128,7 @@ int hpm2_get_capabilities(struct ipmi_intf * intf,
#endif
/* check HPM.2 revision */
if (caps->hpm2_revision_id == 0) {
if (caps->hpm2_revision_id != HPM2_REVISION) {
lprintf(LOG_NOTICE, "Bad HPM.2 revision, rev=%d",
caps->hpm2_revision_id);
return -1;
@ -219,8 +213,8 @@ int hpm2_get_lan_channel_capabilities(struct ipmi_intf * intf,
/* send */
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
lprintf(LOG_NOTICE, "Error sending request.");
if (rsp) {
lprintf(LOG_NOTICE, "Error sending request");
return -1;
}

View File

@ -1,546 +0,0 @@
/*
* Copyright (c) 2016 Pentair Technical Products. All right 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 Pentair Technical Products 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* PENTAIR TECHNICAL SOLUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#else
# include <stdlib.h>
#endif
#include <string.h>
#include <ipmitool/helper.h>
#include <ipmitool/ipmi_cfgp.h>
#include <ipmitool/log.h>
/* ipmi_cfgp_init initialize configuration parameter context
* @param ctx context to initialize
* @param set array of parameter descriptors
* @param count amount of descriptors supplied
* @param handler function to do real job on parameters from the set
* @param priv private data for the handler
*/
int
ipmi_cfgp_init(struct ipmi_cfgp_ctx *ctx, const struct ipmi_cfgp *set,
unsigned int count, const char *cmdname,
ipmi_cfgp_handler_t handler, void *priv)
{
if (!ctx || !set || !handler || !cmdname) {
return -1;
}
memset(ctx, 0, sizeof(struct ipmi_cfgp_ctx));
ctx->set = set;
ctx->count = count;
ctx->cmdname = cmdname;
ctx->handler = handler;
ctx->priv = priv;
return 0;
}
/* ipmi_cfgp_uninit destroy data list attached to context
* @param ctx parameter context to clear
* @returns 0 -- list destroyed
* -1 -- ctx is NULL
*/
int
ipmi_cfgp_uninit(struct ipmi_cfgp_ctx *ctx)
{
struct ipmi_cfgp_data *d;
if (!ctx) {
return -1;
}
while (ctx->v) {
d = ctx->v;
ctx->v = d->next;
free(d);
d = NULL;
}
return 0;
}
/* lookup_cfgp -- find a parameter in a set*/
static const struct ipmi_cfgp *
lookup_cfgp(const struct ipmi_cfgp_ctx *ctx, const char *name)
{
const struct ipmi_cfgp *p;
int i;
for (i = 0; i < ctx->count; i++) {
p = &ctx->set[i];
if (p->name && !strcasecmp(p->name, name)) {
return p;
}
}
return NULL;
}
/* ipmi_cfgp_parse_sel parse parameter selector
* (parameter ID, set selector, block selector) from cmdline.
*
* @param ctx configuration parameter context to use
* @param argc elements left in argv
* @param argv array of arguments
* @param sel where to store parsed selector
*
* @returns >=0 number of argv elements used
* <0 error
*/
int
ipmi_cfgp_parse_sel(struct ipmi_cfgp_ctx *ctx,
int argc, const char **argv, struct ipmi_cfgp_sel *sel)
{
const struct ipmi_cfgp *p;
if (!ctx || !argv || !sel) {
return -1;
}
sel->param = -1;
sel->set = -1;
sel->block = -1;
if (argc == 0) {
/* no parameter specified, good for print, save */
return 0;
}
p = lookup_cfgp(ctx, argv[0]);
if (!p) {
lprintf(LOG_ERR, "invalid parameter");
return -1;
}
sel->param = p - ctx->set;
sel->set = p->is_set ? -1 : 0;
sel->block = p->has_blocks ? -1 : 0;
if (argc == 1 || !p->is_set) {
/* No set and block selector applicable or specified */
return 1;
}
if (str2int(argv[1], &sel->set)
|| sel->set < 0
|| (sel->set == 0 && p->first_set)) {
lprintf(LOG_ERR, "invalid set selector");
return -1;
}
if (argc == 2 || !p->has_blocks) {
/* No block selector applicable or specified */
return 2;
}
if (str2int(argv[2], &sel->block)
|| sel->block < 0
|| (sel->block == 0 && p->first_block)) {
lprintf(LOG_ERR, "invalid block selector");
return -1;
}
return 3;
}
/* cfgp_add_data adds block of data to list in the configuration
* parameter context
*
* @param ctx context to add data to
* @param data parameter data
*/
static void
cfgp_add_data(struct ipmi_cfgp_ctx *ctx, struct ipmi_cfgp_data *data)
{
struct ipmi_cfgp_data **pprev = &ctx->v;
data->next = NULL;
while (*pprev) {
pprev = &(*pprev)->next;
}
*pprev = data;
}
/* cfgp_usage prints format for configuration parameter
*
* @param p configuration parameter descriptor
* @param write 0 if no value is expected, !=0 otherwise
*/
static void
cfgp_usage(const struct ipmi_cfgp *p, int write)
{
if (!p->name) {
return;
}
if (write && !p->format) {
return;
}
printf(" %s%s%s %s\n",
p->name, p->is_set ? " <set_sel>" : "",
p->has_blocks ? " <block_sel>" : "",
write ? p->format : "");
}
/* ipmi_cfgp_usage prints format for configuration parameter set
*
* @param set configuration parameter descriptor array
* @param count number of elements in set
* @param write 0 if no value is expected, !=0 otherwise
*/
void
ipmi_cfgp_usage(const struct ipmi_cfgp *set, int count, int write)
{
const struct ipmi_cfgp *p;
int i;
if (!set) {
return;
}
for (i = 0; i < count; i++) {
p = &set[i];
if (write && p->access == CFGP_RDONLY) {
continue;
}
if (!write && p->access == CFGP_WRONLY) {
continue;
}
cfgp_usage(p, write);
}
}
/* ipmi_cfgp_parse_data parse parameter data from command line into context
* @param ctx context to add data
* @param sel parameter selector
* @param argc number of elements in argv
* @param argv array of unparsed arguments
*
* @returns 0 on success
* <0 on error
*/
int
ipmi_cfgp_parse_data(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, int argc, const char **argv)
{
const struct ipmi_cfgp *p;
struct ipmi_cfgp_data *data;
struct ipmi_cfgp_action action;
if (!ctx || !sel || !argv) {
return -1;
}
if (sel->param == -1 || sel->param >= ctx->count) {
lprintf(LOG_ERR, "invalid parameter, must be one of:");
ipmi_cfgp_usage(ctx->set, ctx->count, 1);
return -1;
}
if (sel->set == -1) {
lprintf(LOG_ERR, "set selector is not specified");
return -1;
}
if (sel->block == -1) {
lprintf(LOG_ERR, "block selector is not specified");
return -1;
}
p = &ctx->set[sel->param];
if (p->size == 0) {
return -1;
}
data = malloc(sizeof(struct ipmi_cfgp_data) + p->size);
if (!data) {
return -1;
}
memset(data, 0, sizeof(struct ipmi_cfgp_data) + p->size);
action.type = CFGP_PARSE;
action.set = sel->set;
action.block = sel->block;
action.argc = argc;
action.argv = argv;
action.file = NULL;
if (ctx->handler(ctx->priv, p, &action, data->data) != 0) {
ipmi_cfgp_usage(p, 1, 1);
free(data);
data = NULL;
return -1;
}
data->sel = *sel;
cfgp_add_data(ctx, data);
return 0;
}
/* cfgp_get_param -- get parameter data from MC into data list within context
*
* @param ctx context
* @param p parameter descriptor
* @param set parameter set selector, can be -1 to scan all set selectors
* @param block parameter block selector, can be -1 to get all blocks
* @param quiet set to non-zero to continue on errors
* (required for -1 to work)
* @returns 0 on success, non-zero otherwise
*/
static int
cfgp_get_param(struct ipmi_cfgp_ctx *ctx, const struct ipmi_cfgp *p,
int set, int block, int quiet)
{
struct ipmi_cfgp_data *data;
struct ipmi_cfgp_action action;
int cset;
int cblock;
int ret;
if (p->size == 0) {
return -1;
}
action.type = CFGP_GET;
action.argc = 0;
action.argv = NULL;
action.file = NULL;
if (set == -1 && !p->is_set) {
set = 0;
}
if (block == -1 && !p->has_blocks) {
block = 0;
}
if (set == -1) {
cset = p->first_set;
} else {
cset = set;
}
action.quiet = quiet;
do {
if (block == -1) {
cblock = p->first_block;
} else {
cblock = block;
}
do {
data = malloc(sizeof(struct ipmi_cfgp_data) + p->size);
if (!data) {
return -1;
}
memset(data, 0, sizeof(struct ipmi_cfgp_data) + p->size);
action.set = cset;
action.block = cblock;
ret = ctx->handler(ctx->priv, p, &action, data->data);
if (ret != 0) {
free(data);
data = NULL;
if (!action.quiet) {
return ret;
}
break;
}
data->sel.param = p - ctx->set;
data->sel.set = cset;
data->sel.block = cblock;
cfgp_add_data(ctx, data);
cblock++;
action.quiet = 1;
} while (block == -1);
if (ret != 0 && cblock == p->first_block) {
break;
}
cset++;
} while (set == -1);
return 0;
}
/* ipmi_cfgp_get -- get parameters data from MC into data list within context
*
* @param ctx context
* @param sel parameter selector
* @returns 0 on success, non-zero otherwise
*/
int
ipmi_cfgp_get(struct ipmi_cfgp_ctx *ctx, const struct ipmi_cfgp_sel *sel)
{
int i;
int ret;
if (!ctx || !sel) {
return -1;
}
if (sel->param != -1) {
if (sel->param >= ctx->count) {
return -1;
}
ret = cfgp_get_param(ctx, &ctx->set[sel->param],
sel->set, sel->block, 0);
if (ret) {
return -1;
}
return 0;
}
for (i = 0; i < ctx->count; i++) {
if (ctx->set[i].access == CFGP_WRONLY) {
continue;
}
if (cfgp_get_param(ctx, &ctx->set[i], sel->set, sel->block, 1)) {
return -1;
}
}
return 0;
}
static int
cfgp_do_action(struct ipmi_cfgp_ctx *ctx, int action_type,
const struct ipmi_cfgp_sel *sel, FILE *file, int filter)
{
const struct ipmi_cfgp *p;
struct ipmi_cfgp_data *data;
struct ipmi_cfgp_action action;
int ret;
if (!ctx || !sel) {
return -1;
}
action.type = action_type;
action.argc = 0;
action.argv = NULL;
action.file = file;
for (data = ctx->v; data; data = data->next) {
if (sel->param != -1 && sel->param != data->sel.param) {
continue;
}
if (sel->set != -1 && sel->set != data->sel.set) {
continue;
}
if (sel->block != -1 && sel->block != data->sel.block) {
continue;
}
if (ctx->set[data->sel.param].access == filter) {
continue;
}
p = &ctx->set[data->sel.param];
action.set = data->sel.set;
action.block = data->sel.block;
if (action_type == CFGP_SAVE) {
fprintf(file, "%s %s ", ctx->cmdname, p->name);
if (p->is_set) {
fprintf(file, "%d ", data->sel.set);
}
if (p->has_blocks) {
fprintf(file, "%d ", data->sel.block);
}
}
ret = ctx->handler(ctx->priv, p, &action, data->data);
if (action_type == CFGP_SAVE) {
fputc('\n', file);
}
if (ret != 0) {
return -1;
}
}
return 0;
}
int
ipmi_cfgp_set(struct ipmi_cfgp_ctx *ctx, const struct ipmi_cfgp_sel *sel)
{
return cfgp_do_action(ctx, CFGP_SET, sel, NULL, CFGP_RDONLY);
}
int
ipmi_cfgp_save(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, FILE *file)
{
if (!file) {
return -1;
}
return cfgp_do_action(ctx, CFGP_SAVE, sel, file, CFGP_RDONLY);
}
int
ipmi_cfgp_print(struct ipmi_cfgp_ctx *ctx,
const struct ipmi_cfgp_sel *sel, FILE *file)
{
if (!file) {
return -1;
}
return cfgp_do_action(ctx, CFGP_PRINT, sel, file, CFGP_RESERVED);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2894
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/helper.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/ipmi_fru.h>
#include <ipmitool/ipmi_time.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
#define NO_MORE_INFO_FIELD 0xc1
#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;
unsigned char link_desc_count;
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 );
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(
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,
struct ipmi_ek_multi_header ** list_head,
char * opt,
struct ipmi_ek_multi_header ** list_last, char * opt,
struct ipmi_ek_multi_header * pphysical );
static int ipmi_ek_get_resource_descriptor( int port_count, int index,
@ -402,6 +399,7 @@ ipmi_ekanalyzer_usage(void)
static int
ipmi_ek_get_file_type(char *argument)
{
int index_name=0;
int filetype = ERROR_STATUS;
if (strlen(argument) <= MIN_ARGUMENT) {
return filetype;
@ -453,14 +451,15 @@ ipmi_ek_get_file_type(char *argument)
*
* Global: None
*
* Return: OK_STATUS as success or ERROR_STATUS as error
* Return: OK_STATUS as succes or ERROR_STATUS as error
*
***************************************************************************/
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 file_type[MAX_FILE_NUMBER];
int tmp_ret = 0;
char *filename[MAX_FILE_NUMBER];
unsigned int argument_offset = 0;
unsigned int type_offset = 0;
@ -478,12 +477,11 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
return (-1);
}
if (!strcmp(argv[argument_offset], "help")) {
if (strcmp(argv[argument_offset], "help") == 0) {
ipmi_ekanalyzer_usage();
return 0;
} else if (!strcmp(argv[argument_offset], "frushow")
&& (argc > (MIN_ARGUMENT-1)))
{
} else if ((strcmp(argv[argument_offset], "frushow") == 0)
&& (argc > (MIN_ARGUMENT-1))) {
for (type_offset = 0; type_offset < (argc-1); type_offset++ ) {
argument_offset++;
file_type[type_offset] = ipmi_ek_get_file_type(argv[argument_offset]);
@ -499,7 +497,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
*/
filename[type_offset] = malloc(strlen(argv[argument_offset])
+ 1 - SIZE_OF_FILE_TYPE);
if (!filename[type_offset]) {
if (filename[type_offset] == NULL) {
lprintf(LOG_ERR, "malloc failure");
return (-1);
}
@ -511,13 +509,13 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
rc = ipmi_ek_display_fru_header (filename[type_offset]);
if (rc != ERROR_STATUS) {
/* Display FRU header info in detail record */
rc = ipmi_ek_display_fru_header_detail(filename[type_offset]);
tmp_ret = ipmi_ek_display_fru_header_detail(filename[type_offset]);
/* Convert from binary data into multi record structure */
rc = ipmi_ekanalyzer_fru_file2structure (filename[type_offset],
&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 */
while (list_head) {
while (list_head != NULL) {
ipmi_ek_remove_record_from_list(list_head,
&list_head,&list_last );
if (verbose > 1) {
@ -528,9 +526,8 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
free(filename[type_offset]);
filename[type_offset] = NULL;
}
} else if (!strcmp(argv[argument_offset], "print")
|| !strcmp(argv[argument_offset], "summary"))
{
} else if ((strcmp(argv[argument_offset], "print") == 0)
|| (strcmp(argv[argument_offset], "summary") == 0)) {
/* Display help text for corresponding command
* if not enough parameters were given.
*/
@ -542,7 +539,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
int filename_size=0;
if (argc < MIN_ARGUMENT) {
lprintf(LOG_ERR, "Not enough parameters given.");
if (!strcmp(argv[argument_offset], "print")) {
if (strcmp(argv[argument_offset], "print") == 0) {
lprintf(LOG_ERR,
" ekanalyzer print [carrier/power/all]"
" <xx=frufile> <xx=frufile> [xx=frufile]");
@ -554,20 +551,18 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
return ERROR_STATUS;
}
argument_offset++;
if (!strcmp(argv[argument_offset], "carrier")
|| !strcmp(argv[argument_offset], "power")
|| !strcmp(argv[argument_offset], "all"))
{
if ((strcmp(argv[argument_offset], "carrier") == 0)
|| (strcmp(argv[argument_offset], "power") == 0)
|| (strcmp(argv[argument_offset], "all") == 0)) {
option = argv[argument_offset];
index ++;
argc--;
} else if (!strcmp(argv[argument_offset], "match")
|| !strcmp(argv[argument_offset], "unmatch"))
{
} else if ((strcmp(argv[argument_offset], "match") == 0)
|| ( strcmp(argv[argument_offset], "unmatch") == 0)) {
option = argv[argument_offset];
index ++;
argc--;
} else if ('=' == argv[argument_offset][2]) {
} else if ( strncmp(&argv[argument_offset][2], "=", 1) == 0) {
/* since the command line must receive xx=filename,
* so the position of "=" sign is 2
*/
@ -580,7 +575,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
option = "invalid";
printf("Invalid option '%s'\n", argv[argument_offset]);
argument_offset--;
if (!strcmp(argv[0], "print")) {
if (strcmp(argv[0], "print") == 0) {
lprintf (LOG_ERR,
" ekanalyzer print [carrier/power/all]"
" <xx=frufile> <xx=frufile> [xx=frufile]");
@ -591,12 +586,12 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
}
rc = ERROR_STATUS;
}
if (strcmp(option, "invalid")) {
if (strcmp(option, "invalid") != 0) {
int i=0;
for (i = 0; i < (argc-1); i++) {
file_type[i] = ipmi_ek_get_file_type (argv[index]);
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",
argv[index][0],
argv[index][1]);
@ -609,13 +604,10 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
*/
filename_size = strlen(argv[index]) - SIZE_OF_FILE_TYPE + 1;
if (filename_size > 0) {
/* TODO - check malloc() retval */
filename[i] = malloc( filename_size );
if (filename[i]) {
if (filename[i] != NULL) {
strcpy(filename[i], &argv[index][SIZE_OF_FILE_TYPE]);
} else {
lprintf(LOG_ERR, "ipmitool: malloc failure");
rc = ERROR_STATUS;
break;
}
}
rc = OK_STATUS;
@ -630,7 +622,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
printf("file name: %s\n", filename[i]);
}
}
if (!strcmp(argv[0], "print")) {
if (strcmp(argv[0], "print") == 0) {
rc = ipmi_ekanalyzer_print((argc-1),
option, filename, file_type);
} else {
@ -638,7 +630,7 @@ ipmi_ekanalyzer_main(struct ipmi_intf *__UNUSED__(intf), int argc, char **argv)
option, filename, file_type);
}
for (i = 0; i < (argc-1); i++) {
if (filename[i]) {
if (filename[i] != NULL) {
free(filename[i]);
filename[i] = NULL;
}
@ -681,7 +673,7 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
{
int return_value = OK_STATUS;
/* Display carrier topology */
if (!strcmp(opt, "carrier") || !strcmp(opt, "default")) {
if ((strcmp(opt, "carrier") == 0) || (strcmp(opt, "default") == 0)) {
tboolean found_flag = FALSE;
int index = 0;
int index_name[argc];
@ -721,9 +713,8 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
*/
tboolean first_data = TRUE;
for (list_record[i] = list_head[i];
list_record[i];
list_record[i] = list_record[i]->next)
{
list_record[i] != NULL;
list_record[i] = list_record[i]->next) {
if (list_record[i]->data[PICMG_ID_OFFSET] == FRU_AMC_CARRIER_P2P) {
if (first_data) {
printf("%s\n", STAR_LINE_LIMITER);
@ -732,7 +723,7 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
}
return_value = ipmi_ek_display_carrier_connectivity(list_record[i]);
} 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
if (first_data) {
printf("From Carrier file: %s\n", filename[index_name[i]]);
@ -745,7 +736,7 @@ ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type)
}
/*Destroy the list of record*/
for (i = 0; i < argc; i++) {
while (list_head[i]) {
while (list_head[i] != NULL) {
ipmi_ek_remove_record_from_list(list_head[i],
&list_head[i], &list_last[i]);
}
@ -757,10 +748,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");
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");
return_value = ipmi_ek_display_power(argc, opt, filename, file_type);
} else {
@ -795,7 +786,7 @@ ipmi_ek_display_carrier_connectivity(struct ipmi_ek_multi_header *record)
int offset = START_DATA_OFFSET;
struct fru_picmgext_carrier_p2p_record rsc_desc;
struct fru_picmgext_carrier_p2p_descriptor *port_desc;
if (!record) {
if (record == NULL) {
lprintf(LOG_ERR, "P2P connectivity record is invalid\n");
return ERROR_STATUS;
}
@ -923,14 +914,14 @@ ipmi_ek_display_power( int argc, char * opt, char ** filename, int * file_type )
return_value = ipmi_ekanalyzer_fru_file2structure( filename[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];
list_record[num_file];
list_record[num_file] = list_record[num_file]->next)
{
if (!strcmp(opt, "all")
&& file_type[num_file] == ON_CARRIER_FRU_FILE)
{
list_record[num_file] != NULL;
list_record[num_file] = list_record[num_file]->next
){
if ( ( strcmp(opt, "all") == 0 )
&& ( file_type[num_file] == ON_CARRIER_FRU_FILE )
){
if ( list_record[num_file]->data[PICMG_ID_OFFSET]
==
FRU_AMC_CARRIER_P2P
@ -997,7 +988,7 @@ ipmi_ek_display_power( int argc, char * opt, char ** filename, int * file_type )
return_value = OK_STATUS;
/*Destroy the list of record*/
for ( index = 0; index < argc; index++ ){
while (list_head[index]) {
while ( list_head[index] != NULL ){
ipmi_ek_remove_record_from_list ( list_head[index],
&list_head[index],&list_last[index] );
}
@ -1089,7 +1080,7 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
{
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]"\
" <xx=frufile> <xx=frufile> [xx=frufile]");
return_value = ERROR_STATUS;
@ -1160,13 +1151,13 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
/*Get Carrier p2p connectivity record for physical check*/
for (num_file=0; num_file < argc; num_file++){
if (file_type[num_file] == ON_CARRIER_FRU_FILE ){
for (pcarrier_p2p = list_head[num_file];
pcarrier_p2p;
pcarrier_p2p = pcarrier_p2p->next)
{
if (FRU_AMC_CARRIER_P2P ==
pcarrier_p2p->data[PICMG_ID_OFFSET])
{
for ( pcarrier_p2p=list_head[num_file];
pcarrier_p2p != NULL ;
pcarrier_p2p = pcarrier_p2p->next
){
if ( pcarrier_p2p->data[PICMG_ID_OFFSET]
== FRU_AMC_CARRIER_P2P
){
break;
}
}
@ -1193,14 +1184,14 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
}
return_value = ipmi_ek_matching_process( file_type,
match_pair, num_file, list_head,
opt, pcarrier_p2p);
list_last, opt, pcarrier_p2p);
}
}
}
match_pair ++;
}
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],
&list_record[num_file], &list_last[num_file]);
}
@ -1229,6 +1220,8 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
* index2: position of the second record in the list of the record
* ipmi_ek_multi_header ** list_head: pointer to the header of a
* 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
* "all".
* pphysical: a pointer that contain a carrier p2p connectivity record
@ -1244,7 +1237,7 @@ ipmi_ekanalyzer_ekeying_match( int argc, char * opt,
***************************************************************************/
static int ipmi_ek_matching_process( int * file_type, int index1, int index2,
struct ipmi_ek_multi_header ** list_head,
char * opt,
struct ipmi_ek_multi_header ** list_last, char * opt,
struct ipmi_ek_multi_header * pphysical )
{
int result = ERROR_STATUS;
@ -1260,13 +1253,13 @@ static int ipmi_ek_matching_process( int * file_type, int index1, int index2,
index2 = index_temp; /*index2 indcate an AMC*/
}
/*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 ){
num_amc_record2++;
}
}
/*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 ){
num_amc_record1++;
}
@ -1284,17 +1277,17 @@ static int ipmi_ek_matching_process( int * file_type, int index1, int index2,
amc_record2 = malloc ( num_amc_record2 * \
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 ){
result = ipmi_ek_create_amc_p2p_record( record,
&amc_record1[index_record1] );
if (result != ERROR_STATUS){
struct ipmi_ek_multi_header * current_record = NULL;
for (current_record=list_head[index1];
current_record;
current_record = current_record->next)
{
for ( current_record=list_head[index1];
current_record != NULL ;
current_record = current_record->next
){
if ( current_record->data[PICMG_ID_OFFSET] == FRU_AMC_P2P ){
result = ipmi_ek_create_amc_p2p_record( current_record,
&amc_record2[index_record2] );
@ -1364,7 +1357,7 @@ ipmi_ek_check_physical_connectivity(
{
int return_status = OK_STATUS;
if (!record){
if ( record == NULL ){
printf("NO Carrier p2p connectivity !\n");
return_status = ERROR_STATUS;
}
@ -1429,7 +1422,7 @@ ipmi_ek_check_physical_connectivity(
rsc_desc.p2p_count );
}
if (port_desc && return_status != ERROR_STATUS) {
if ( (port_desc != NULL) && (return_status != ERROR_STATUS) ){
int j=0;
for ( j = 0; j < rsc_desc.p2p_count; j++ ){
@ -1456,7 +1449,7 @@ ipmi_ek_check_physical_connectivity(
(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",
val2str(filetype2, ipmi_ekanalyzer_module_type),
record1.ch_desc[index1].lane0port,
@ -1479,7 +1472,7 @@ ipmi_ek_check_physical_connectivity(
&&
(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",
val2str(filetype2, ipmi_ekanalyzer_module_type),
record1.ch_desc[index1].lane0port,
@ -1493,7 +1486,7 @@ ipmi_ek_check_physical_connectivity(
&&
(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",
val2str(filetype2, ipmi_ekanalyzer_module_type),
record1.ch_desc[index1].lane0port,
@ -1529,7 +1522,7 @@ ipmi_ek_check_physical_connectivity(
}
return_status = ERROR_STATUS;
}
if (port_desc) {
if (port_desc != NULL){
free(port_desc);
port_desc = NULL;
}
@ -1609,10 +1602,10 @@ ipmi_ek_compare_link( struct ipmi_ek_multi_header * physic_record,
physic_record, file_type1, file_type2, opt );
if ( result == OK_STATUS ){
/*Display the result if option = match or all*/
if (!strcmp(opt, "match")
|| !strcmp(opt, "all")
|| !strcmp(opt, "default"))
{
if ( (strcmp( opt, "match" ) == 0)
|| (strcmp( opt, "all" ) == 0)
|| (strcmp( opt, "default" ) == 0)
){
tboolean isOEMtype = FALSE;
printf(" Matching Result\n");
isOEMtype = ipmi_ek_display_link_descriptor( file_type1,
@ -1669,10 +1662,10 @@ ipmi_ek_compare_link( struct ipmi_ek_multi_header * physic_record,
record1, index_ch_desc1, record2, index_ch_desc2,
physic_record, file_type1, file_type2, opt );
if ( result == OK_STATUS ){
if (!strcmp( opt, "match" )
|| !strcmp(opt, "all")
|| !strcmp(opt, "default"))
{
if ( (strcmp( opt, "match" ) == 0)
|| (strcmp( opt, "all" ) == 0)
|| (strcmp( opt, "default" ) == 0)
){
tboolean isOEMtype = FALSE;
printf(" Matching Result\n");
isOEMtype = ipmi_ek_display_link_descriptor( file_type1,
@ -1700,7 +1693,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;
printf(" Unmatching result\n");
for (index1 = 0; index1 < record1.link_desc_count; index1++){
@ -1945,12 +1938,12 @@ ipmi_ek_compare_link_descriptor(
*
* 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
*
* Restriction: None
*
* Input: asym[COMPARE_CANDIDATE]: Contain 2 asymmetric match for comparison
* Input: asym[COMPARE_CANDIDATE]: Contain 2 asymetric match for comparison
*
* Output: None
*
@ -2061,7 +2054,7 @@ ipmi_ek_compare_number_of_enable_port(
* destination (its value = "To"). ( it is set to "" if it is not
* a source nor destination
* link_desc: AMC link descriptor
* asym: asymmetric match
* asym: asymetric match
*
* Output: None
*
@ -2214,9 +2207,6 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int index_oem = 0;
amc_record->oem_guid = malloc(amc_record->guid_count * \
sizeof(struct fru_picmgext_guid));
if (!amc_record->oem_guid) {
return ERROR_STATUS;
}
for (index_oem = 0; index_oem < amc_record->guid_count;
index_oem++) {
memcpy(&amc_record->oem_guid[index_oem].guid,
@ -2244,9 +2234,6 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int ch_index = 0;
amc_record->ch_desc = malloc((amc_record->ch_count) * \
sizeof(struct fru_picmgext_amc_channel_desc_record));
if (!amc_record->ch_desc) {
return ERROR_STATUS;
}
for (ch_index = 0; ch_index < amc_record->ch_count;
ch_index++) {
unsigned int data;
@ -2270,9 +2257,6 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record,
int i=0;
amc_record->link_desc = malloc(amc_record->link_desc_count * \
sizeof(struct fru_picmgext_amc_link_desc_record));
if (!amc_record->link_desc) {
return ERROR_STATUS;
}
for (i = 0; i< amc_record->link_desc_count; i++) {
unsigned int data[2];
struct fru_picmgext_amc_link_desc_record *src, *dst;
@ -2353,7 +2337,7 @@ ipmi_ek_get_resource_descriptor(int port_count, int index,
*
* Global: None
*
* Return: Return OK_STATUS on success, ERROR_STATUS on error
* Return: Return OK_STATUS on sucess, ERROR_STATUS on error
*
***************************************************************************/
static int
@ -2364,7 +2348,7 @@ ipmi_ek_display_fru_header(char *filename)
int ret = 0;
input_file = fopen(filename, "r");
if (!input_file) {
if (input_file == NULL) {
lprintf(LOG_ERR, "File '%s' not found.", filename);
return (ERROR_STATUS);
}
@ -2419,7 +2403,7 @@ ipmi_ek_display_fru_header_detail(char *filename)
FILE *input_file;
size_t file_offset = 0;
struct fru_header header;
time_t ts;
time_t tval;
int ret = 0;
unsigned char data = 0;
unsigned char lan_code = 0;
@ -2427,7 +2411,7 @@ ipmi_ek_display_fru_header_detail(char *filename)
unsigned int board_length = 0;
input_file = fopen(filename, "r");
if (!input_file) {
if (input_file == NULL) {
lprintf(LOG_ERR, "File '%s' not found.", filename);
return (-1);
}
@ -2442,11 +2426,9 @@ ipmi_ek_display_fru_header_detail(char *filename)
return (-1);
}
/*** Display FRU Internal Use Info ***/
if (header.offset.internal != 0) {
if (!feof(input_file)) {
unsigned char format_version;
unsigned long len = 0;
uint8_t *area_offset;
uint8_t next_offset = UINT8_MAX;
printf("%s\n", EQUAL_LINE_LIMITER);
printf("FRU Internal Use Info\n");
@ -2460,46 +2442,12 @@ ipmi_ek_display_fru_header_detail(char *filename)
}
printf("Format Version: %d\n", (format_version & 0x0f));
/* Internal use area doesn't contain the size byte.
* We need to calculate its size by finding the area
* that is next. Areas may not follow the same order
* as their offsets listed in the header, so we need
* to find the area that is physically next to the
* internal use area.
*/
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 */
if (header.offset.chassis > 0) {
len = (header.offset.chassis * FACTOR_OFFSET)
- (header.offset.internal * FACTOR_OFFSET);
} else {
len = (header.offset.board * FACTOR_OFFSET)
- (header.offset.internal * FACTOR_OFFSET);
}
printf("Length: %ld\n", len);
printf("Data dump:\n");
@ -2583,40 +2531,33 @@ ipmi_ek_display_fru_header_detail(char *filename)
fclose(input_file);
return (-1);
}
ts = ipmi_fru2time_t(mfg_date);
printf("Board Mfg Date: %ld, %s\n",
(IPMI_TIME_UNSPECIFIED == ts)
? FRU_BOARD_DATE_UNSPEC
: ts,
ipmi_timestamp_numeric(ts));
tval = ((mfg_date[2] << 16) + (mfg_date[1] << 8)
+ (mfg_date[0]));
tval = tval * 60;
tval = tval + secs_from_1970_1996;
printf("Board Mfg Date: %ld, %s", tval,
asctime(localtime(&tval)));
board_length -= SIZE_MFG_DATE;
/* Board Mfg */
file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Manufacture Data", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET);
/* Board Product */
file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Product Name", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET);
/* Board Serial */
file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Serial Number", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET);
/* Board Part */
file_offset = ipmi_ek_display_board_info_area(
input_file, "Board Part Number", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET);
/* FRU file ID */
file_offset = ipmi_ek_display_board_info_area(
input_file, "FRU File ID", &board_length);
ret = fseek(input_file, file_offset, SEEK_SET);
/* Additional Custom Mfg. */
file_offset = ipmi_ek_display_board_info_area(
input_file, "Custom", &board_length);
@ -2663,7 +2604,7 @@ ipmi_ek_display_chassis_info_area(FILE *input_file, long offset)
unsigned char ch_type = 0;
unsigned int len;
if (!input_file) {
if (input_file == NULL) {
lprintf(LOG_ERR, "No file stream to read.");
return (-1);
}
@ -2745,18 +2686,12 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
int ret = 0;
unsigned char len = 0;
unsigned int size_board = 0;
int custom_fields = 0;
if (!input_file || !board_type || !board_length) {
if (input_file == NULL || board_type == NULL
|| board_length == NULL) {
return (size_t)(-1);
}
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*/
ret = fread(&len, 1, 1, input_file);
if ((ret != 1) || ferror(input_file)) {
@ -2765,22 +2700,21 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
}
(*board_length)--;
/* Bit 5:0 of Board Mfg type represent length */
/* Bit 5:0 of Board Mfg type represent legnth */
size_board = (len & 0x3f);
if (size_board == 0) {
printf("%s: None\n", board_type);
goto out;
}
if (strcmp(board_type, "Custom")) {
unsigned char *data, *str;
if (strncmp(board_type, "Custom", 6 ) != 0) {
unsigned char *data;
unsigned int i = 0;
data = malloc(size_board + 1); /* Make room for type/length field */
if (!data) {
data = malloc(size_board);
if (data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return (size_t)(-1);
}
data[0] = len; /* Save the type/length byte in 'data' */
ret = fread(data + 1, size_board, 1, input_file);
ret = fread(data, size_board, 1, input_file);
if ((ret != 1) || ferror(input_file)) {
lprintf(LOG_ERR, "Invalid board type size!");
free(data);
@ -2789,11 +2723,17 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
}
printf("%s type: 0x%02x\n", board_type, len);
printf("%s: ", board_type);
i = 0;
str = (unsigned char *)get_fru_area_str(data, &i);
printf("%s\n", str);
free(str);
str = NULL;
for (i = 0; i < size_board; i++) {
if ((len & TYPE_CODE) == TYPE_CODE) {
printf("%c", data[i]);
} else {
/* other than language code (binary, BCD,
* ASCII 6 bit...) is not supported
*/
printf("%02x", data[i]);
}
}
printf("\n");
free(data);
data = NULL;
(*board_length) -= size_board;
@ -2806,12 +2746,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
* checksum
*/
if (custom_fields) {
printf("End of Custom Mfg. fields (0x%02x)\n", len);
} else {
printf("No Additional Custom Mfg. fields (0x%02x)\n", len);
}
printf("Additional Custom Mfg. length: 0x%02x\n", len);
padding = (*board_length) - 1;
if ((padding > 0) && (!feof(input_file))) {
printf("Unused space: %d (bytes)\n", padding);
@ -2825,47 +2760,33 @@ ipmi_ek_display_board_info_area(FILE *input_file, char *board_type,
printf("Checksum: 0x%02x\n", checksum);
goto out;
}
custom_fields++;
printf("Additional Custom Mfg. length: 0x%02x\n", len);
if ((size_board > 0) && (size_board < (*board_length))) {
unsigned char *additional_data, *str;
unsigned char * additional_data = NULL;
unsigned int i = 0;
additional_data = malloc(size_board + 1); /* Make room for type/length field */
if (!additional_data) {
additional_data = malloc(size_board);
if (additional_data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return (size_t)(-1);
}
additional_data[0] = len;
ret = fread(additional_data + 1, size_board, 1, input_file);
ret = fread(additional_data, size_board, 1, input_file);
if ((ret != 1) || ferror(input_file)) {
lprintf(LOG_ERR, "Invalid Additional Data!");
if (additional_data) {
free(additional_data);
additional_data = NULL;
}
goto out;
}
printf("Additional Custom Mfg. Data: ");
i = 0;
str = (unsigned char *)get_fru_area_str(additional_data, &i);
printf("%s\n", str);
free(str);
str = NULL;
printf("Additional Custom Mfg. Data: %02x",
additional_data[0]);
for (i = 1; i < size_board; i++) {
printf("-%02x", additional_data[i]);
}
printf("\n");
free(additional_data);
additional_data = NULL;
(*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 {
printf("ERROR: File has insufficient data (%d bytes) for the "
"Additional Custom Mfg. field\n", *board_length);
printf("No Additional Custom Mfg. %d\n", *board_length);
goto out;
}
}
@ -2904,7 +2825,7 @@ ipmi_ek_display_product_info_area(FILE *input_file, long offset)
unsigned char data = 0;
unsigned int len = 0;
if (!input_file) {
if (input_file == NULL) {
lprintf(LOG_ERR, "No file stream to read.");
return (-1);
}
@ -2944,6 +2865,7 @@ ipmi_ek_display_product_info_area(FILE *input_file, long offset)
return (-1);
}
fread(&data, 1, 1, input_file);
printf("Language Code: %d\n", data);
len--;
/* Product Mfg */
@ -2990,6 +2912,7 @@ ipmi_ek_display_product_info_area(FILE *input_file, long offset)
*
* Input: record: a pointer to current record
* list_head: a pointer to header of the list
* list_last: a pointer to tale of the list
*
* Output: None
*
@ -3000,16 +2923,17 @@ ipmi_ek_display_product_info_area(FILE *input_file, long offset)
***************************************************************************/
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)
{
if (!list_head) {
if (list_head == NULL) {
printf("***empty list***\n");
return;
}
printf("%s\n", EQUAL_LINE_LIMITER);
printf("FRU Multi Info area\n");
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 Format version: 0x%02x\n",
record->header.format);
@ -3438,7 +3362,7 @@ ipmi_ek_display_board_p2p_record(struct ipmi_ek_multi_header *record)
printf("\n");
offset += sizeof(struct fru_picmgext_guid);
}
for (offset = offset;
for (offset;
offset < record->header.len;
offset += sizeof(struct fru_picmgext_link_desc)) {
/* to solve little endian/big endian problem */
@ -3462,7 +3386,7 @@ ipmi_ek_display_board_p2p_record(struct ipmi_ek_multi_header *record)
printf("ShMC Cross-connect (two-pair)\n");
break;
default:
printf("Unknown\n");
printf("Unknwon\n");
break;
}
} else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET) {
@ -3477,17 +3401,17 @@ ipmi_ek_display_board_p2p_record(struct ipmi_ek_multi_header *record)
printf("FC-PI\n");
break;
default:
printf("Unknown\n");
printf("Unknwon\n");
break;
}
} 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) {
printf("Unknown\n");
printf("Unknwon\n");
} else if (d->type == FRU_PICMGEXT_LINK_TYPE_PCIE) {
printf("Unknown\n");
printf("Unknwon\n");
} else {
printf("Unknown\n");
printf("Unknwon\n");
}
printf("\tLink Type:\t\t0x%02x - ", d->type);
if (d->type == 0 || d->type == 0xff) {
@ -3597,7 +3521,7 @@ ipmi_ek_display_radial_ipmb0_record(struct ipmi_ek_multi_header *record)
if (record->data[offset] < 1) {
return;
}
for (offset = offset; offset < record->header.len;) {
for (offset; offset < record->header.len;) {
unsigned char entry_count = 0;
printf(" IPMB-0 Hub Descriptor\n");
printf("\tHardware Address: 0x%02x\n",
@ -4071,7 +3995,7 @@ ipmi_ek_display_clock_config_record(struct ipmi_ek_multi_header *record)
*
* 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
* list_head: a pointer to header of the list
* list_last: a pointer to tale of the list
@ -4095,7 +4019,7 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
int ret = 0;
input_file = fopen(filename, "r");
if (!input_file) {
if (input_file == NULL) {
lprintf(LOG_ERR, "File: '%s' is not found", filename);
return ERROR_STATUS;
}
@ -4121,18 +4045,14 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
fseek(input_file, multi_offset, SEEK_SET);
while (!feof(input_file)) {
/* TODO - check malloc() */
*list_record = malloc(sizeof(struct ipmi_ek_multi_header));
if (!(*list_record)) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return ERROR_STATUS;
}
ret = fread(&(*list_record)->header, START_DATA_OFFSET, 1,
input_file);
if ((ret != 1) || ferror(input_file)) {
free(*list_record);
*list_record = NULL;
fclose(input_file);
/* TODO - no free?! */
lprintf(LOG_ERR, "Invalid Header!");
fclose(input_file);
return ERROR_STATUS;
}
if ((*list_record)->header.len == 0) {
@ -4140,7 +4060,7 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
continue;
}
(*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",
(*list_record)->header.len);
record_count++;
@ -4185,7 +4105,7 @@ ipmi_ekanalyzer_fru_file2structure(char *filename,
*
* 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.
*
* Restriction: None
@ -4204,18 +4124,18 @@ ipmi_ek_add_record2list(struct ipmi_ek_multi_header **record,
struct ipmi_ek_multi_header **list_head,
struct ipmi_ek_multi_header **list_last)
{
if (*list_head) {
(*list_last)->next = *record;
(*record)->prev = *list_last;
if (verbose > 2) {
printf("Add 1 record to list\n");
}
} else {
if (*list_head == NULL) {
*list_head = *record;
(*record)->prev = NULL;
if (verbose > 2) {
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;
(*record)->next = NULL;
@ -4225,7 +4145,7 @@ ipmi_ek_add_record2list(struct ipmi_ek_multi_header **record,
*
* 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.
*
* Restriction: None
@ -4244,12 +4164,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_last)
{
if (!record->prev) {
if (record->prev == NULL) {
*list_head = record->next;
} else {
record->prev->next = record->next;
}
if (!record->next) {
if (record->next == NULL) {
(*list_last) = record->prev;
} else {
record->next->prev = record->prev;

View File

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

View File

@ -128,7 +128,7 @@ ipmi_firewall_parse_args(int argc, char ** argv, struct ipmi_function_params * p
return -1;
}
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;
if (is_ipmi_channel_num(argv[i], &channel_tmp) != 0) {
conv_err = 1;
@ -137,31 +137,31 @@ ipmi_firewall_parse_args(int argc, char ** argv, struct ipmi_function_params * p
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) {
lprintf(LOG_ERR, "Given lun '%s' is invalid.", argv[i]);
conv_err = 1;
break;
}
}
else if (!strcmp(argv[i], "force")) {
else if (strncmp(argv[i], "force", 5) == 0) {
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) {
lprintf(LOG_ERR, "Given netfn '%s' is invalid.", argv[i]);
conv_err = 1;
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) {
lprintf(LOG_ERR, "Given command '%s' is invalid.", argv[i]);
conv_err = 1;
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) {
lprintf(LOG_ERR, "Given subfn '%s' is invalid.", argv[i]);
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;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Get NetFn Support command failed");
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get NetFn Support command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@ -289,11 +289,11 @@ _get_command_support(struct ipmi_intf * intf,
req.msg.data_len = 3;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
@ -316,11 +316,11 @@ _get_command_support(struct ipmi_intf * intf,
req.msg.data_len = 3;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
@ -368,11 +368,11 @@ _get_command_configurable(struct ipmi_intf * intf,
req.msg.data_len = 3;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
@ -395,11 +395,11 @@ _get_command_configurable(struct ipmi_intf * intf,
req.msg.data_len = 3;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
@ -447,11 +447,11 @@ _get_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 3;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
@ -474,11 +474,11 @@ _get_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 3;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
@ -512,7 +512,7 @@ _set_command_enables(struct ipmi_intf * intf,
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
unsigned char rqdata[19];
unsigned char * d, rqdata[19];
unsigned int c;
if (!p || !lnfn) {
@ -558,16 +558,18 @@ _set_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 19;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
}
d = rsp->data;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_SET_COMMAND_ENABLES;
@ -579,16 +581,17 @@ _set_command_enables(struct ipmi_intf * intf,
req.msg.data_len = 19;
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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
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));
return -1;
}
d = rsp->data;
return 0;
}
@ -625,11 +628,11 @@ _get_subfn_support(struct ipmi_intf * intf,
req.msg.data_len = 4;
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);
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",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1;
@ -672,11 +675,11 @@ _get_subfn_configurable(struct ipmi_intf * intf,
req.msg.data_len = 4;
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);
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",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1;
@ -719,11 +722,11 @@ _get_subfn_enables(struct ipmi_intf * intf,
req.msg.data_len = 4;
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);
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",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1;
@ -787,11 +790,11 @@ _set_subfn_enables(struct ipmi_intf * intf,
req.msg.data_len = 8;
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);
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",
p->lun, p->netfn, p->command, val2str(rsp->ccode, completion_code_vals));
return -1;
@ -888,7 +891,7 @@ static int _gather_info(struct ipmi_intf * intf, struct ipmi_function_params * p
/* ipmi_firewall_info - print out info for firewall functions
*
* @intf: ipmi interface
* @intf: ipmi inteface
* @argc: argument count
* @argv: argument list
*
@ -899,11 +902,11 @@ static int
ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
{
int ret = 0;
struct ipmi_function_params p = {0xe, -1, -1, -1, -1, 0};
struct ipmi_function_params p = {0xe, -1, -1, -1, -1};
struct bmc_fn_support * bmc_fn_support;
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();
return 0;
@ -1001,7 +1004,7 @@ ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
/* ipmi_firewall_enable_disable - enable/disable BMC functions
*
* @intf: ipmi interface
* @intf: ipmi inteface
* @enable: whether to enable or disable
* @argc: argument count
* @argv: argument list
@ -1012,13 +1015,12 @@ ipmi_firewall_info(struct ipmi_intf * intf, int argc, char ** argv)
static int
ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char ** argv)
{
struct ipmi_function_params p = {0xe, -1, -1, -1, -1, 0};
struct ipmi_function_params p = {0xe, -1, -1, -1, -1};
struct bmc_fn_support * bmc_fn_support;
int ret;
unsigned int l, n, c;
unsigned int l, n, c, ret;
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 * s2 = enable?"":" [force]";
printf("%sable [channel H] lun L netfn N%s\n", s1, s2);
@ -1055,7 +1057,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
c = p.command;
if (p.subfn >= 0) {
// 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,
bmc_fn_support->lun[l].netfn[n].command[c].subfn_enable,
MAX_SUBFN_BYTES);
@ -1065,7 +1067,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
} else if (p.command >= 0) {
// 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);
ret = _set_subfn_enables(intf, &p,
&bmc_fn_support->lun[l].netfn[n].command[c], enables);
@ -1076,14 +1078,14 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
&bmc_fn_support->lun[l].netfn[n], enables, p.force);
} else if (p.netfn >= 0) {
// 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));
ret = _set_command_enables(intf, &p,
&bmc_fn_support->lun[l].netfn[n], enables, p.force);
/*
} else if (p.lun >= 0) {
// 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);
@ -1093,7 +1095,7 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
/* ipmi_firewall_reset - reset firmware firewall to enable everything
*
* @intf: ipmi interface
* @intf: ipmi inteface
* @argc: argument count
* @argv: argument list
*
@ -1103,17 +1105,12 @@ ipmi_firewall_enable_disable(struct ipmi_intf * intf, int enable, int argc, char
static int
ipmi_firewall_reset(struct ipmi_intf * intf, int argc, char ** argv)
{
struct ipmi_function_params p = {0xe, -1, -1, -1, -1, 0};
struct ipmi_function_params p = {0xe, -1, -1, -1, -1};
struct bmc_fn_support * bmc_fn_support;
int ret;
unsigned int l, n, c;
unsigned int l, n, c, ret;
unsigned char enables[MAX_COMMAND_BYTES];
if (argc < 1) {
lprintf(LOG_ERR, "Not enough parameters given.");
printf_firewall_usage();
return (-1);
} else if (argc > 0 && !strcmp(argv[0], "help")) {
if (argc > 0 || (argc > 0 && strncmp(argv[0], "help", 4) == 0)) {
printf_firewall_usage();
return 0;
}
@ -1135,8 +1132,8 @@ ipmi_firewall_reset(struct ipmi_intf * intf, int argc, char ** argv)
for (l=0; l<MAX_LUN; l++) {
p.lun = l;
for (n=0; n<MAX_NETFN_PAIR; n++) {
p.netfn = n*2;
for (n=0; n<MAX_NETFN; n+=2) {
p.netfn = n;
for (c=0; c<MAX_COMMAND; c++) {
p.command = c;
printf("reset lun %d, netfn %d, command %d, subfn\n", l, n, c);
@ -1171,19 +1168,19 @@ ipmi_firewall_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int rc = 0;
if (argc < 1 || !strcmp(argv[0], "help")) {
if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
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]));
}
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]));
}
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]));
}
else if (!strcmp(argv[0], "reset")) {
else if (strncmp(argv[0], "reset", 5) == 0) {
rc = ipmi_firewall_reset(intf, argc-1, &(argv[1]));
}
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();
return (-1);
}
if (!strcmp(argv[0], "help")) {
if (strncmp(argv[0], "help", 4) == 0) {
printf_kfwum_help();
rc = 0;
} else if (!strcmp(argv[0], "info")) {
} else if (strncmp(argv[0], "info", 4) == 0) {
rc = ipmi_fwum_info(intf);
} else if (!strcmp(argv[0], "status")) {
} else if (strncmp(argv[0], "status", 6) == 0) {
rc = ipmi_fwum_status(intf);
} else if (!strcmp(argv[0], "rollback")) {
} else if (strncmp(argv[0], "rollback", 8) == 0) {
rc = KfwumManualRollback(intf);
} else if (!strcmp(argv[0], "download")) {
} else if (strncmp(argv[0], "download", 8) == 0) {
if ((argc < 2) || (strlen(argv[1]) < 1)) {
lprintf(LOG_ERR,
"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]);
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)) {
printf("Upgrading using file name %s\n", argv[1]);
rc = ipmi_fwum_fwupgrade(intf, argv[1], 1);
} else {
rc = KfwumStartFirmwareUpgrade(intf);
}
} else if (!strcmp(argv[0], "tracelog")) {
} else if (strncmp(argv[0], "tracelog", 8) == 0) {
rc = KfwumGetTraceLog(intf);
} else {
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 long fsize = 0;
unsigned char not_used;
if (!file) {
if (file == NULL) {
lprintf(LOG_ERR, "No file given.");
return (-1);
}
@ -312,7 +312,7 @@ KfwumGetFileSize(const char *pFileName, unsigned long *pFileSize)
{
FILE *pFileHandle = NULL;
pFileHandle = fopen(pFileName, "rb");
if (!pFileHandle) {
if (pFileHandle == NULL) {
return (-1);
}
if (fseek(pFileHandle, 0L , SEEK_END) == 0) {
@ -342,7 +342,7 @@ KfwumSetupBuffersFromFile(const char *pFileName, unsigned long fileSize)
int qty = 0;
pFileHandle = fopen(pFileName, "rb");
if (!pFileHandle) {
if (pFileHandle == NULL) {
lprintf(LOG_ERR, "Failed to open '%s' for reading.",
pFileName);
return (-1);
@ -454,7 +454,7 @@ KfwumGetInfo(struct ipmi_intf *intf, unsigned char output,
if (!rsp) {
lprintf(LOG_ERR, "Error in FWUM Firmware Get Info Command.");
return (-1);
} else if (rsp->ccode) {
} else if (rsp->ccode != 0) {
lprintf(LOG_ERR, "FWUM Firmware Get Info returned %x",
rsp->ccode);
return (-1);
@ -479,7 +479,7 @@ KfwumGetInfo(struct ipmi_intf *intf, unsigned char output,
printf("Number Of Memory Bank : %u\n", 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)
* --> Address with small buffer size
*/
@ -501,14 +501,14 @@ KfwumGetInfo(struct ipmi_intf *intf, unsigned char output,
printf("Protocol Revision :");
printf(" > 5 optimizing buffers\n");
}
if (strstr(intf->name,"lan")) {
if (strstr(intf->name,"lan") != NULL) {
/* also covers lanplus */
save_fw_nfo.bufferSize = KFWUM_SMALL_BUFFER;
if (verbose) {
printf("IOL payload size : %d\n",
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 != intf->my_addr)) {
save_fw_nfo.bufferSize = KFWUM_SMALL_BUFFER;
@ -549,10 +549,10 @@ KfwumGetDeviceInfo(struct ipmi_intf *intf, unsigned char output,
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get Device Id Command");
return (-1);
} else if (rsp->ccode) {
} else if (rsp->ccode != 0) {
lprintf(LOG_ERR, "Get Device Id returned %x",
rsp->ccode);
return (-1);
@ -571,7 +571,7 @@ KfwumGetDeviceInfo(struct ipmi_intf *intf, unsigned char output,
pGetDevId->fw_rev1, pGetDevId->fw_rev2 >> 4,
pGetDevId->fw_rev2 & 0x0f);
if (((pBoardInfo->iana == IPMI_OEM_KONTRON)
&& (pBoardInfo->boardId == KFWUM_BOARD_KONTRON_5002))) {
&& (pBoardInfo->boardId = KFWUM_BOARD_KONTRON_5002))) {
printf(" SDR %u", pGetDevId->aux_fw_rev[0]);
}
printf("\n");
@ -598,19 +598,19 @@ KfwumGetStatus(struct ipmi_intf * intf)
if (verbose) {
printf(" Getting Status!\n");
}
/* Retrieve the number of bank */
/* Retreive the number of bank */
rc = KfwumGetInfo(intf, 0, &numBank);
for(counter = 0;
(counter < numBank) && (rc == 0);
counter ++) {
/* Retrieve the status of each bank */
/* Retreive the status of each bank */
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_FIRMWARE;
req.msg.cmd = KFWUM_CMD_ID_GET_FIRMWARE_STATUS;
req.msg.data = &counter;
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR,
"Error in FWUM Firmware Get Status Command.");
rc = (-1);
@ -668,10 +668,10 @@ KfwumManualRollback(struct ipmi_intf *intf)
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in FWUM Manual Rollback Command.");
return (-1);
} else if (rsp->ccode) {
} else if (rsp->ccode != 0) {
lprintf(LOG_ERR,
"Error in FWUM Manual Rollback Command returned %x",
rsp->ccode);
@ -707,7 +707,7 @@ KfwumStartFirmwareImage(struct ipmi_intf *intf, unsigned long length,
req.msg.data_len = 6;
}
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR,
"Error in FWUM Firmware Start Firmware Image Download Command.");
return (-1);
@ -755,13 +755,13 @@ KfwumSaveFirmwareImage(struct ipmi_intf *intf, unsigned char sequenceNumber,
/* + 1 => sequenceNumber*/
}
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR,
"Error in FWUM Firmware Save Firmware Image Download Command.");
/* We don't receive "C7" on errors with IOL,
* instead we receive nothing
*/
if (strstr(intf->name, "lan")) {
if (strstr(intf->name, "lan") != NULL) {
no_rsp++;
if (no_rsp < FWUM_SAVE_FIRMWARE_NO_RESPONSE_LIMIT) {
*pInBufLength -= 1;
@ -772,7 +772,7 @@ KfwumSaveFirmwareImage(struct ipmi_intf *intf, unsigned char sequenceNumber,
*pInBufLength = 0;
break;
} /* For other interface keep trying */
} else if (rsp->ccode) {
} else if (rsp->ccode != 0) {
if (rsp->ccode == 0xc0) {
sleep(1);
} else if ((rsp->ccode == 0xc7)
@ -836,9 +836,12 @@ KfwumFinishFirmwareImage(struct ipmi_intf *intf, tKFWUM_InFirmwareInfo firmInfo)
/* Infinite loop if BMC doesn't reply or replies 0xc0 every time. */
do {
rsp = intf->sendrecv(intf, &req);
} while (!rsp || rsp->ccode == 0xc0);
if (rsp->ccode) {
} while (rsp == NULL || rsp->ccode == 0xc0);
if (!rsp) {
lprintf(LOG_ERR,
"Error in FWUM Firmware Finish Firmware Image Download Command.");
return (-1);
} else if (rsp->ccode != 0) {
lprintf(LOG_ERR,
"FWUM Firmware Finish Firmware Image Download returned %x",
rsp->ccode);
@ -858,6 +861,7 @@ KfwumUploadFirmware(struct ipmi_intf *intf, unsigned char *pBuffer,
unsigned long lastAddress = 0;
unsigned char sequenceNumber = 0;
unsigned char retry = FWUM_MAX_UPLOAD_RETRY;
unsigned char isLengthValid = 1;
do {
writeSize = save_fw_nfo.bufferSize - save_fw_nfo.overheadSize;
/* Reach the end */
@ -917,7 +921,7 @@ KfwumStartFirmwareUpgrade(struct ipmi_intf *intf)
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR,
"Error in FWUM Firmware Start Firmware Upgrade Command");
rc = (-1);
@ -950,7 +954,7 @@ KfwumGetTraceLog(struct ipmi_intf *intf)
(chunkIdx < TRACE_LOG_CHUNK_COUNT)
&& (rc == 0);
chunkIdx++) {
/* Retrieve each log chunk and print it */
/* Retreive each log chunk and print it */
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_FIRMWARE;
req.msg.cmd = KFWUM_CMD_ID_GET_TRACE_LOG;
@ -958,7 +962,7 @@ KfwumGetTraceLog(struct ipmi_intf *intf)
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR,
"Error in FWUM Firmware Get Trace Log Command");
rc = (-1);
@ -971,7 +975,7 @@ KfwumGetTraceLog(struct ipmi_intf *intf)
break;
}
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)
&& (rsp->data[TRACE_LOG_ATT_COUNT * cmdIdx] < KFWUM_CMD_ID_STD_MAX_CMD)) {
printf(" Cmd ID: %17s -- CmdState: %10s -- CompCode: %2x\n",
@ -1001,7 +1005,7 @@ KfwumGetInfoFromFirmware(unsigned char *pBuf, unsigned long bufSize,
}
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,
offset + 0 + IN_FIRMWARE_INFO_OFFSET_CHECKSUM ) << 8;

View File

@ -71,6 +71,7 @@ typedef struct gendev_eeprom_info
static int
ipmi_gendev_get_eeprom_size(
struct ipmi_intf *intf,
struct sdr_record_generic_locator *dev,
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 Mod: %x", dev->dev_type_modifier);
*/
if (info) {
if( info != NULL)
{
switch(dev->dev_type)
{
case 0x08: // 24C01
@ -190,7 +192,7 @@ ipmi_gendev_read_file(
int eeprom_size;
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)
{
@ -278,7 +280,8 @@ ipmi_gendev_read_file(
msize
);
if (rsp) {
if (rsp != NULL)
{
retryCounter = GENDEV_RETRY_COUNT;
rc = 0;
}
@ -361,7 +364,7 @@ ipmi_gendev_write_file(
int eeprom_size;
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)
{
@ -373,7 +376,7 @@ ipmi_gendev_write_file(
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);
fileLength = ftell(fp);
@ -454,6 +457,8 @@ ipmi_gendev_write_file(
break;
}
for(
retryCounter = 0;
retryCounter<GENDEV_RETRY_COUNT;
@ -471,7 +476,8 @@ ipmi_gendev_write_file(
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);
if (rsp) {
if (rsp != NULL)
{
retryCounter = GENDEV_RETRY_COUNT;
rc = 0;
}
@ -489,7 +495,8 @@ ipmi_gendev_write_file(
}
}
if (!rc) {
if( rc == 0 )
{
static uint8_t previousCompleted = 101;
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]);
if (!argc || !strcmp(argv[0], "help"))
if (
(argc == 0)
||
(strncmp(argv[0], "help", 4) == 0)
)
{
lprintf(LOG_ERR,
"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");
lprintf(LOG_ERR,
" 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 (!strcmp(argv[0], "read")) {
}
else if ( strncmp(argv[0], "list", 4) == 0)
{
rc = ipmi_sdr_print_sdr(intf,
SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR);
}
else if (strncmp(argv[0], "read", 4) == 0)
{
if (argc < 3)
lprintf(LOG_ERR, "usage: gendev read <gendev> <filename>");
else {
else
{
struct sdr_record_list *sdr;
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 */
sdr = ipmi_sdr_find_sdr_byid(intf, argv[1]);
if (!sdr) {
if (sdr == NULL)
{
lprintf(LOG_ERR, "Sensor data record not found!");
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");
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]);
}
} else if (!strcmp(argv[0], "write")) {
}
else if (strncmp(argv[0], "write", 5) == 0)
{
if (argc < 3)
lprintf(LOG_ERR, "usage: gendev write <gendev> <filename>");
else {
else
{
struct sdr_record_list *sdr;
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 */
sdr = ipmi_sdr_find_sdr_byid(intf, argv[1]);
if (!sdr) {
if (sdr == NULL)
{
lprintf(LOG_ERR, "Sensor data record not found!");
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");
return -1;
}
lprintf(LOG_ERR, "Gendev write file name: %s", argv[2]);
ipmi_gendev_write_file(intf, sdr->record.genloc, argv[2]);
}
} else {
}
else
{
lprintf(LOG_ERR, "Invalid gendev command: %s", argv[0]);
rc = -1;
}

View File

@ -1,7 +1,6 @@
/*
* Copyright (c) 2006 Kontron Canada, 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
* modification, are permitted provided that the following conditions
@ -39,37 +38,16 @@
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/log.h>
#include "../src/plugins/lan/md5.h"
#include <ctype.h>
#include <stdio.h>
#include <time.h>
#include <sys/param.h>
#include <unistd.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
/*
* 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
extern int verbose;
VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
int HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename,
int activate, int, int);
int HpmfwupgValidateImageIntegrity(struct HpmfwupgUpgradeCtx *pFwupgCtx);
@ -128,10 +106,6 @@ int HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
struct ipmi_intf *intf,
int option,
int *pFlagColdReset);
int
HpmfwupgPreUpgradeCheck(
struct HpmfwupgUpgradeCtx *pFwupgCtx,
int componentMask, int option);
/* HpmGetuserInput - get input from user
*
@ -320,6 +294,7 @@ HpmfwupgTargetCheck(struct ipmi_intf *intf, int option)
struct HpmfwupgGetTargetUpgCapabilitiesCtx targetCapCmd;
int rc = HPMFWUPG_SUCCESS;
int componentId = 0;
int flagColdReset = FALSE;
struct ipm_devid_rsp devIdrsp;
struct HpmfwupgGetComponentPropertiesCtx getCompProp;
int mode = 0;
@ -456,6 +431,13 @@ HpmfwupgTargetCheck(struct ipmi_intf *intf, int option)
gVersionInfo[componentId].deferredAux[2] = 0xff;
gVersionInfo[componentId].deferredAux[3] = 0xff;
}
if (gVersionInfo[componentId].coldResetRequired) {
/*
* If any of the component indicates that the Payload Cold reset is required
* then set the flag
*/
flagColdReset = TRUE;
}
if (option & VIEW_MODE) {
HpmDisplayVersion(mode,
&gVersionInfo[componentId],
@ -519,9 +501,10 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
lprintf(LOG_NOTICE, "\nPerforming upgrade stage:");
}
if (option & VIEW_MODE) {
rc = HpmfwupgPreUpgradeCheck(&fwupgCtx,componentMask, VIEW_MODE);
rc = HpmfwupgPreUpgradeCheck(intf,
&fwupgCtx,componentMask, VIEW_MODE);
} else {
rc = HpmfwupgPreUpgradeCheck(&fwupgCtx,
rc = HpmfwupgPreUpgradeCheck(intf, &fwupgCtx,
componentMask, option);
if (rc == HPMFWUPG_SUCCESS) {
if (verbose) {
@ -545,7 +528,7 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
}
if (rc == HPMFWUPG_SUCCESS) {
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," ");
} else if (option & COMPARE_MODE) {
lprintf(LOG_NOTICE,
@ -555,7 +538,7 @@ HpmfwupgUpgrade(struct ipmi_intf *intf, char *imageFilename, int activate,
"\nFirmware upgrade procedure successful\n");
}
} 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," ");
} else if (option & COMPARE_MODE) {
lprintf(LOG_NOTICE,
@ -664,7 +647,7 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
if (rc != HPMFWUPG_SUCCESS) {
/* 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
* 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
*/
if (!((option & FORCE_MODE) || (option & VIEW_MODE))) {
@ -736,7 +719,7 @@ HpmfwupgPreparationStage(struct ipmi_intf *intf,
"\n Some components present in the image file are not supported by the IPMC");
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) {
lprintf(LOG_NOTICE, "\n Upgrade undesirable at this moment");
return HPMFWUPG_ERROR;
@ -845,7 +828,7 @@ HpmfwupgValidateActionRecordChecksum(struct HpmfwupgActionRecord *pActionRecord)
* is same as target version.
*/
int
HpmfwupgPreUpgradeCheck(
HpmfwupgPreUpgradeCheck(struct ipmi_intf *intf,
struct HpmfwupgUpgradeCtx *pFwupgCtx,
int componentMask, int option)
{
@ -1013,11 +996,15 @@ HpmfwupgUpgradeStage(struct ipmi_intf *intf,
struct HpmfwupgActionRecord* pActionRecord;
int rc = HPMFWUPG_SUCCESS;
unsigned char *pImagePtr;
unsigned int actionsSize;
int flagColdReset = FALSE;
time_t start,end;
/* Put pointer after image header */
pImagePtr = (unsigned char*)
(pFwupgCtx->pImageData + sizeof(struct HpmfwupgImageHeader) +
pImageHeader->oemDataLength + sizeof(unsigned char)/*checksum*/);
/* Deternime actions size */
actionsSize = pFwupgCtx->imageSize - sizeof(struct HpmfwupgImageHeader);
if (!(option & VIEW_MODE)) {
HpmDisplayUpgradeHeader();
}
@ -1213,7 +1200,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
} else {
count = (unsigned short)((pDataTemp+lengthOfBlock) - pData);
}
memcpy(&uploadCmd.req->data, pData, count);
memcpy(&uploadCmd.req->data, pData, bufLength);
imageOffset = 0x00;
blockLength = 0x00;
numTxPkts++;
@ -1224,7 +1211,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
if (rc == HPMFWUPG_UPLOAD_BLOCK_LENGTH && !bufLengthIsSet) {
rc = HPMFWUPG_SUCCESS;
/* Retry with a smaller buffer length */
if (strstr(intf->name,"lan") && bufLength > 8) {
if (strstr(intf->name,"lan") != NULL && bufLength > 8) {
bufLength-= 8;
lprintf(LOG_INFO,
"Trying reduced buffer length: %d",
@ -1315,7 +1302,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components,
HpmDisplayUpgrade(1,0,0,0);
if ((option & COMPARE_MODE)
&& !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;
}
@ -1401,26 +1388,22 @@ int
HpmfwupgGetBufferFromFile(char *imageFilename,
struct HpmfwupgUpgradeCtx *pFwupgCtx)
{
int rc = HPMFWUPG_ERROR;
int rc = HPMFWUPG_SUCCESS;
int ret = 0;
FILE *pImageFile = fopen(imageFilename, "rb");
if (!pImageFile) {
if (pImageFile == NULL) {
lprintf(LOG_ERR, "Cannot open image file '%s'",
imageFilename);
goto ret_no_close;
return HPMFWUPG_ERROR;
}
/* Get the raw data in file */
ret = fseek(pImageFile, 0, SEEK_END);
if (ret != 0) {
lprintf(LOG_ERR, "Failed to seek in the image file '%s'",
imageFilename);
goto ret_close;
}
fseek(pImageFile, 0, SEEK_END);
pFwupgCtx->imageSize = ftell(pImageFile);
pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize);
if (!pFwupgCtx->pImageData) {
if (pFwupgCtx->pImageData == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto ret_close;
fclose(pImageFile);
return HPMFWUPG_ERROR;
}
rewind(pImageFile);
ret = fread(pFwupgCtx->pImageData,
@ -1432,14 +1415,9 @@ HpmfwupgGetBufferFromFile(char *imageFilename,
"Failed to read file %s size %d",
imageFilename,
pFwupgCtx->imageSize);
goto ret_close;
rc = HPMFWUPG_ERROR;
}
rc = HPMFWUPG_SUCCESS;
ret_close:
fclose(pImageFile);
ret_no_close:
return rc;
}
@ -1453,11 +1431,11 @@ HpmfwupgGetDeviceId(struct ipmi_intf *intf, struct ipm_devid_rsp *pGetDevId)
req.msg.cmd = BMC_GET_DEVICE_ID;
req.msg.data_len = 0;
rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error getting device ID.");
return HPMFWUPG_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode != 0x00) {
lprintf(LOG_ERR, "Error getting device ID.");
lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode,
@ -1481,12 +1459,12 @@ HpmfwupgGetTargetUpgCapabilities(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgGetTargetUpgCapabilitiesReq);
rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR,
"Error getting target upgrade capabilities.");
return HPMFWUPG_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode != 0x00) {
lprintf(LOG_ERR,
"Error getting target upgrade capabilities, ccode: 0x%x: %s",
rsp->ccode,
@ -1522,7 +1500,7 @@ HpmfwupgGetTargetUpgCapabilities(struct ipmi_intf *intf,
pCtx->resp.GlobalCapabilities.bitField.autRollbackOverride ? 'y' : 'n');
lprintf(LOG_NOTICE, "IPMC degraded...........[%c] ",
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');
lprintf(LOG_NOTICE, "Service affected........[%c] ",
pCtx->resp.GlobalCapabilities.bitField.servAffectDuringUpg ? 'y' : 'n');
@ -1558,12 +1536,12 @@ HpmfwupgGetComponentProperties(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgGetComponentPropertiesReq);
rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_NOTICE,
"Error getting component properties\n");
return HPMFWUPG_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode != 0x00) {
lprintf(LOG_NOTICE,
"Error getting component properties");
lprintf(LOG_NOTICE,
@ -1684,11 +1662,11 @@ HpmfwupgAbortUpgrade(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgAbortUpgradeReq);
rsp = HpmfwupgSendCmd(intf, req, NULL);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error - aborting upgrade.");
return HPMFWUPG_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode != 0x00) {
lprintf(LOG_ERR, "Error aborting upgrade");
lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode,
@ -1713,14 +1691,14 @@ HpmfwupgInitiateUpgradeAction(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgInitiateUpgradeActionReq);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error initiating upgrade action.");
return HPMFWUPG_ERROR;
}
/* Long duration command handling */
if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) {
rc = HpmfwupgWaitLongDurationCmd(intf, pFwupgCtx);
} else if (rsp->ccode) {
} else if (rsp->ccode != 0x00) {
lprintf(LOG_NOTICE,"Error initiating upgrade action");
lprintf(LOG_NOTICE, "compcode=0x%x: %s",
rsp->ccode,
@ -1747,7 +1725,7 @@ HpmfwupgUploadFirmwareBlock(struct ipmi_intf *intf,
/* 2 is the size of the upload struct - data */
req.msg.data_len = 2 + count;
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_NOTICE, "Error uploading firmware block.");
return HPMFWUPG_ERROR;
}
@ -1783,7 +1761,7 @@ HpmfwupgUploadFirmwareBlock(struct ipmi_intf *intf,
/* Long duration command handling */
if (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS) {
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.
* This will be fixed in the next release of open ipmi and this
* check will have to be removed. (Buggy version = 39)
@ -1824,7 +1802,7 @@ HpmfwupgFinishFirmwareUpload(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgFinishFirmwareUploadReq);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error fininshing firmware upload.");
return HPMFWUPG_ERROR;
}
@ -1861,7 +1839,7 @@ HpmfwupgActivateFirmware(struct ipmi_intf *intf,
req.msg.data_len = sizeof(struct HpmfwupgActivateFirmwareReq)
- (!pCtx->req.rollback_override ? 1 : 0);
rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error activating firmware.");
return HPMFWUPG_ERROR;
}
@ -1891,6 +1869,7 @@ HpmfwupgGetUpgradeStatus(struct ipmi_intf *intf,
struct HpmfwupgUpgradeCtx *pFwupgCtx,
int silent)
{
int rc = HPMFWUPG_SUCCESS;
struct ipmi_rs *rsp;
struct ipmi_rq req;
pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER;
@ -1962,7 +1941,7 @@ HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgManualFirmwareRollbackReq);
rsp = HpmfwupgSendCmd(intf, req, &fwupgCtx);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error sending manual rollback.");
return HPMFWUPG_ERROR;
}
@ -1973,7 +1952,7 @@ HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf,
printf("Waiting firmware rollback...");
fflush(stdout);
rc = HpmfwupgQueryRollbackStatus(intf, &resCmd, &fwupgCtx);
} else if (rsp->ccode) {
} else if ( rsp->ccode != 0x00 ) {
lprintf(LOG_ERR, "Error sending manual rollback");
lprintf(LOG_ERR, "compcode=0x%x: %s",
rsp->ccode,
@ -2000,7 +1979,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
req.msg.data = (unsigned char*)&pCtx->req;
req.msg.data_len = sizeof(struct HpmfwupgQueryRollbackStatusReq);
/* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) {
if (pFwupgCtx != NULL) {
struct HpmfwupgImageHeader *pImageHeader;
if (pFwupgCtx->pImageData) {
pImageHeader = (struct HpmfwupgImageHeader*)pFwupgCtx->pImageData;
@ -2009,7 +1988,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
rollbackTimeout = 0;
}
/* Use the greater of the two timeouts (header and target caps) */
rollbackTimeout = __max(rollbackTimeout,
rollbackTimeout = MAX(rollbackTimeout,
pFwupgCtx->targetCap.rollbackTimeout) * 5;
} else {
rollbackTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2036,7 +2015,7 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
&& ((rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS)
|| (rsp->ccode == IPMI_CC_TIMEOUT))
&& (timeoutSec2 - timeoutSec1 < rollbackTimeout));
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error getting upgrade status.");
return HPMFWUPG_ERROR;
}
@ -2044,13 +2023,13 @@ HpmfwupgQueryRollbackStatus(struct ipmi_intf *intf,
memcpy(&pCtx->resp, rsp->data,
sizeof(struct HpmfwupgQueryRollbackStatusResp));
if (pCtx->resp.rollbackComp.ComponentBits.byte != 0) {
/* Rollback occurred */
/* Rollback occured */
lprintf(LOG_NOTICE,
"Rollback occurred on component mask: 0x%02x",
"Rollback occured on component mask: 0x%02x",
pCtx->resp.rollbackComp.ComponentBits.byte);
} else {
lprintf(LOG_NOTICE,
"No Firmware rollback occurred");
"No Firmware rollback occured");
}
} else if (rsp->ccode == 0x81) {
lprintf(LOG_ERR,
@ -2080,11 +2059,11 @@ HpmfwupgQuerySelftestResult(struct ipmi_intf *intf, struct HpmfwupgQuerySelftest
unsigned int timeoutSec1, timeoutSec2;
pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER;
/* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) {
if (pFwupgCtx != NULL) {
/* Getting selftest timeout from new image */
struct HpmfwupgImageHeader *pImageHeader = (struct HpmfwupgImageHeader*)
pFwupgCtx->pImageData;
selfTestTimeout = __max(pImageHeader->selfTestTimeout,
selfTestTimeout = MAX(pImageHeader->selfTestTimeout,
pFwupgCtx->targetCap.selftestTimeout) * 5;
} else {
selfTestTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2116,7 +2095,7 @@ HpmfwupgQuerySelftestResult(struct ipmi_intf *intf, struct HpmfwupgQuerySelftest
} while (rsp
&& (rsp->ccode == HPMFWUPG_COMMAND_IN_PROGRESS)
&& (timeoutSec2 - timeoutSec1 < selfTestTimeout));
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_NOTICE, "Error getting upgrade status\n");
return HPMFWUPG_ERROR;
}
@ -2150,14 +2129,14 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
unsigned int timeoutSec1, timeoutSec2;
unsigned char retry = 0;
/* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) {
if (pFwupgCtx != NULL) {
inaccessTimeout = pFwupgCtx->targetCap.inaccessTimeout*5;
upgradeTimeout = pFwupgCtx->targetCap.upgradeTimeout*5;
} else {
/* 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
* times which is not efficient -So reducing the Timeout to 5 seconds which is
* almost 200 retries if it continuously receives 0xC3 as completion code.
* times which is not effecient -So reducing the Timout to 5 seconds which is
* almost 200 retries if it continuously recieves 0xC3 as completion code.
*/
inaccessTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2166,10 +2145,10 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
do {
static unsigned char isValidSize = FALSE;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
#define HPM_LAN_PACKET_RESIZE_LIMIT 6
/* also covers lanplus */
if (strstr(intf->name, "lan")) {
if (strstr(intf->name, "lan") != NULL) {
static int errorCount=0;
static struct ipmi_rs fakeRsp;
lprintf(LOG_DEBUG,
@ -2217,15 +2196,18 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
lprintf(LOG_DEBUG, "HPM: try to re-open IOL session");
{
/* force session re-open */
intf->abort = 1;
intf->close(intf);
intf->opened = 0;
intf->session->authtype = IPMI_SESSION_AUTHTYPE_NONE;
intf->session->session_id = 0;
intf->session->in_seq = 0;
intf->session->out_seq = 0;
intf->session->active = 0;
intf->session->retry = 10;
while (intf->open(intf) == HPMFWUPG_ERROR
&& inaccessTimeoutCounter < inaccessTimeout) {
inaccessTimeoutCounter += (time(NULL) - timeoutSec1);
timeoutSec1 = time(NULL);
}
/* Fake timeout to retry command */
fakeRsp.ccode = 0xc3;
rsp = &fakeRsp;
@ -2234,7 +2216,7 @@ HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
}
}
/* 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) {
timeoutSec2 = time(NULL);
if (timeoutSec2 > timeoutSec1) {
@ -2287,14 +2269,14 @@ HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf,
unsigned int timeoutSec1, timeoutSec2;
struct HpmfwupgGetUpgradeStatusCtx upgStatusCmd;
/* If we are not in upgrade context, we use default timeout values */
if (pFwupgCtx) {
if (pFwupgCtx != NULL) {
upgradeTimeout = (unsigned int)(pFwupgCtx->targetCap.upgradeTimeout*5);
if (verbose) {
printf("Use File Upgrade Capabilities: %i seconds\n",
upgradeTimeout);
}
} else {
/* Try to retrieve from Caps */
/* Try to retreive from Caps */
struct HpmfwupgGetTargetUpgCapabilitiesCtx targetCapCmd;
if(HpmfwupgGetTargetUpgCapabilities(intf, &targetCapCmd) != HPMFWUPG_SUCCESS) {
upgradeTimeout = HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT;
@ -2310,9 +2292,13 @@ HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf,
}
}
}
/* Poll upgrade status until completion or timeout*/
timeoutSec2 = timeoutSec1 = time(NULL);
rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd, pFwupgCtx, 1);
if (rc == HPMFWUPG_SUCCESS) {
/* Poll upgrade status until completion or timeout*/
timeoutSec1 = time(NULL);
timeoutSec2 = time(NULL);
rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd,
pFwupgCtx, 1);
}
while (
/* With KCS: Cover the case where we sometime
* receive d5 (on the first get status) from
@ -2475,12 +2461,12 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
HpmfwupgPrintUsage();
return HPMFWUPG_ERROR;
}
if (!strcmp(argv[0], "help")) {
if (strcmp(argv[0], "help") == 0) {
HpmfwupgPrintUsage();
return HPMFWUPG_SUCCESS;
} else if (!strcmp(argv[0], "check")) {
} else if ((strcmp(argv[0], "check") == 0)) {
/* hpm check */
if (!argv[1]) {
if (argv[1] == NULL) {
rc = HpmfwupgTargetCheck(intf,VIEW_MODE);
} else {
/* hpm check <filename> */
@ -2490,18 +2476,18 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
0, VIEW_MODE);
}
}
} else if (!strcmp(argv[0], "upgrade")) {
} else if (strcmp(argv[0], "upgrade") == 0) {
int i =0;
for (i=1; i< argc ; i++) {
if (!strcmp(argv[i],"activate")) {
if (strcmp(argv[i],"activate") == 0) {
activateFlag = 1;
}
/* hpm upgrade <filename> force */
if (!strcmp(argv[i],"force")) {
if (strcmp(argv[i],"force") == 0) {
option |= FORCE_MODE;
}
/* hpm upgrade <filename> component <comp Id> */
if (!strcmp(argv[i],"component")) {
if (strcmp(argv[i],"component") == 0) {
if (i+1 < argc) {
/* Error Checking */
if (str2int(argv[i+1], &componentId) != 0
@ -2530,7 +2516,7 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
return HPMFWUPG_ERROR;
}
}
if (!strcmp(argv[i],"debug")) {
if (strcmp(argv[i],"debug") == 0) {
option |= DEBUG_MODE;
}
}
@ -2540,11 +2526,11 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
rc = HpmfwupgUpgrade(intf, argv[1], activateFlag,
componentMask, option);
}
} else if (!strcmp(argv[0], "compare")) {
} else if (strcmp(argv[0], "compare") == 0) {
int i = 0;
for (i=1; i< argc; i++) {
/* hpm compare <file> [component x...] */
if (!strcmp(argv[i],"component")) {
if (strcmp(argv[i],"component") == 0) {
if (i+1 < argc) {
/* Error Checking */
if (str2int(argv[i+1], &componentId) != 0
@ -2573,7 +2559,7 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
"No component Id provided\n");
return HPMFWUPG_ERROR;
}
} else if (!strcmp(argv[i],"debug")) {
} else if (strcmp(argv[i],"debug") == 0) {
option|= DEBUG_MODE;
}
}
@ -2583,19 +2569,19 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
rc = HpmfwupgUpgrade(intf, argv[1], 0,
componentMask, option);
}
} else if (argc >= 1 && !strcmp(argv[0], "activate")) {
} else if ((argc >= 1) && (strcmp(argv[0], "activate") == 0)) {
struct HpmfwupgActivateFirmwareCtx cmdCtx;
if (argc == 2 && !strcmp(argv[1], "norollback")) {
if ((argc == 2) && (strcmp(argv[1], "norollback") == 0)) {
cmdCtx.req.rollback_override = 1;
} else {
cmdCtx.req.rollback_override = 0;
}
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;
verbose++;
rc = HpmfwupgGetTargetUpgCapabilities(intf, &cmdCtx);
} else if (argc == 3 && !strcmp(argv[0], "compprop")) {
} else if ((argc == 3) && (strcmp(argv[0], "compprop") == 0)) {
struct HpmfwupgGetComponentPropertiesCtx cmdCtx;
if (str2uchar(argv[1], &(cmdCtx.req.componentId)) != 0
|| cmdCtx.req.componentId > 7) {
@ -2617,23 +2603,23 @@ ipmi_hpmfwupg_main(struct ipmi_intf *intf, int argc, char **argv)
}
verbose++;
rc = HpmfwupgGetComponentProperties(intf, &cmdCtx);
} else if (argc == 1 && !strcmp(argv[0], "abort")) {
} else if ((argc == 1) && (strcmp(argv[0], "abort") == 0)) {
struct HpmfwupgAbortUpgradeCtx cmdCtx;
verbose++;
rc = HpmfwupgAbortUpgrade(intf, &cmdCtx);
} else if (argc == 1 && !strcmp(argv[0], "upgstatus")) {
} else if ((argc == 1) && (strcmp(argv[0], "upgstatus") == 0)) {
struct HpmfwupgGetUpgradeStatusCtx cmdCtx;
verbose++;
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;
verbose++;
rc = HpmfwupgManualFirmwareRollback(intf, &cmdCtx);
} else if (argc == 1 && !strcmp(argv[0], "rollbackstatus")) {
} else if ((argc == 1) && (strcmp(argv[0], "rollbackstatus") == 0)) {
struct HpmfwupgQueryRollbackStatusCtx cmdCtx;
verbose++;
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;
verbose++;
rc = HpmfwupgQuerySelftestResult(intf, &cmdCtx, NULL);

95
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;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Get Device ID command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Device ID command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -240,7 +240,8 @@ static int ImeGetInfo(struct ipmi_intf *intf)
{
rc = IME_SUCCESS;
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",
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],
ipmi_oem_product_info);
if (product)
if (product!=NULL)
{
printf("Product Name : %s\n", product);
}
@ -356,7 +357,12 @@ static int ImeUpgrade(struct ipmi_intf *intf, char* imageFilename)
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;
}
@ -424,9 +430,12 @@ static int ImeUpgrade(struct ipmi_intf *intf, char* imageFilename)
if(currentPercent != shownPercent)
{
uint16_t timeElapsedSecond;
uint16_t timeRemainingSecond;
shownPercent = currentPercent;
printf("Percent: %02i, ", shownPercent);
time(&current);
timeElapsedSecond = (current-start) + ((current-start)%60);
printf("Elapsed time %02ld:%02ld\r",((current-start)/60), ((current-start)%60));
fflush(stdout);
@ -504,11 +513,11 @@ static int ImeUpdatePrepare(struct ipmi_intf *intf)
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -539,11 +548,11 @@ static int ImeUpdateOpenArea(struct ipmi_intf *intf)
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "UpdateOpenArea command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdateOpenArea command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -579,11 +588,11 @@ static int ImeUpdateWriteArea(
req.msg.data_len = length + 1;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "UpdateWriteArea command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdateWriteArea command failed: %s",
val2str(rsp->ccode, completion_code_vals));
if( rsp->ccode == 0x80) // restart operation
@ -626,11 +635,11 @@ static int ImeUpdateCloseArea(
req.msg.data_len = length;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "UpdateCloseArea command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdateCloseArea command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -660,11 +669,11 @@ static int ImeUpdateGetStatus(struct ipmi_intf *intf, tImeStatus *pStatus )
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -733,11 +742,11 @@ static int ImeUpdateGetCapabilities(struct ipmi_intf *intf, tImeCaps *pCaps )
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -773,11 +782,11 @@ static int ImeUpdateRegisterUpdate(struct ipmi_intf *intf, tImeUpdateType type)
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "ImeUpdateRegisterUpdate command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -804,11 +813,11 @@ static int ImeUpdateShowStatus(struct ipmi_intf *intf)
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "UpdatePrepare command failed");
return IME_ERROR;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "UpdatePrepare command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return IME_ERROR;
@ -873,13 +882,15 @@ static int ImeImageCtxFromFile(
{
int rc = IME_SUCCESS;
FILE* pImageFile = fopen(imageFilename, "rb");
if (!pImageFile) {
if ( pImageFile == NULL )
{
lprintf(LOG_NOTICE,"Cannot open image file %s", imageFilename);
rc = IME_ERROR;
}
if (rc == IME_SUCCESS) {
if ( rc == IME_SUCCESS )
{
/* Get the raw data in file */
fseek(pImageFile, 0, SEEK_END);
pImageCtx->size = ftell(pImageFile);
@ -893,26 +904,32 @@ static int ImeImageCtxFromFile(
pImageCtx->pData = malloc(sizeof(unsigned char)*pImageCtx->size);
rewind(pImageFile);
if (!pImageCtx->pData
|| pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char),
pImageCtx->size, pImageFile))
if ( pImageCtx->pData != NULL )
{
if (pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char),
pImageCtx->size, pImageFile))
rc = IME_ERROR;
}
else
{
rc = IME_ERROR;
}
}
// Calculate checksum CRC8
if ( rc == IME_SUCCESS )
{
pImageCtx->crc8 = ImeCrc8(pImageCtx->size, pImageCtx->pData);
}
if (pImageFile) {
if( pImageFile != NULL)
{
fclose(pImageFile);
}
return rc;
}
}
static uint8_t ImeCrc8( uint32_t length, uint8_t * pBuf )
{
@ -948,6 +965,8 @@ static int ImeManualRollback(struct ipmi_intf *intf)
{
int rc = IME_SUCCESS;
tImeStatus imeStatus;
time_t start,end,current;
rc = ImeUpdateRegisterUpdate(intf, IME_UPDTYPE_MANUAL_ROLLBACK);
ImeUpdateGetStatus(intf,&imeStatus);
@ -988,13 +1007,16 @@ int ipmi_ime_main(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_DEBUG,"ipmi_ime_main()");
if (!argc || !strcmp(argv[0], "help")) {
if ( (argc == 0) || (strcmp(argv[0], "help") == 0) )
{
ImePrintUsage();
}
else if (!strcmp(argv[0], "info")) {
else if ( (argc == 0) || (strcmp(argv[0], "info") == 0) )
{
rc = ImeGetInfo(intf);
}
else if (!strcmp(argv[0], "update")) {
else if ( strcmp(argv[0], "update") == 0)
{
if(argc == 2)
{
lprintf(LOG_NOTICE,"Update using file: %s", argv[1]);
@ -1006,7 +1028,8 @@ int ipmi_ime_main(struct ipmi_intf * intf, int argc, char ** argv)
rc = IME_ERROR;
}
}
else if (!strcmp(argv[0], "rollback")) {
else if ( (argc == 0) || (strcmp(argv[0], "rollback") == 0) )
{
rc = ImeManualRollback(intf);
}
else

View File

@ -83,7 +83,7 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1;
}
@ -91,7 +91,7 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
lprintf(LOG_ERR, "IPMI v1.5 Serial Over Lan (ISOL) not supported!");
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@ -107,11 +107,11 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@ -127,11 +127,11 @@ static int ipmi_get_isol_info(struct ipmi_intf * intf,
data[3] = 0x00; /* selector */
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@ -192,12 +192,12 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/*
* enabled
*/
if (!strcmp(param, "enabled"))
if (strcmp(param, "enabled") == 0)
{
data[1] = ISOL_ENABLE_PARAM;
if (!strcmp(value, "true"))
if (strcmp(value, "true") == 0)
data[2] = 0x01;
else if (!strcmp(value, "false"))
else if (strcmp(value, "false") == 0)
data[2] = 0x00;
else {
lprintf(LOG_ERR, "Invalid value %s for parameter %s",
@ -210,7 +210,7 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/*
* privilege-level
*/
else if (!strcmp(param, "privilege-level"))
else if (strcmp(param, "privilege-level") == 0)
{
data[1] = ISOL_AUTHENTICATION_PARAM;
if (! strcmp(value, "user"))
@ -235,22 +235,22 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
/*
* bit-rate
*/
else if (!strcmp(param, "bit-rate"))
else if (strcmp(param, "bit-rate") == 0)
{
data[1] = ISOL_BAUD_RATE_PARAM;
if (!strcmp(value, "9.6")) {
if (strncmp(value, "9.6", 3) == 0) {
data[2] = 0x06;
}
else if (!strcmp(value, "19.2")) {
else if (strncmp(value, "19.2", 4) == 0) {
data[2] = 0x07;
}
else if (!strcmp(value, "38.4")) {
else if (strncmp(value, "38.4", 4) == 0) {
data[2] = 0x08;
}
else if (!strcmp(value, "57.6")) {
else if (strncmp(value, "57.6", 4) == 0) {
data[2] = 0x09;
}
else if (!strcmp(value, "115.2")) {
else if (strncmp(value, "115.2", 5) == 0) {
data[2] = 0x0A;
}
else {
@ -271,11 +271,11 @@ static int ipmi_isol_set_param(struct ipmi_intf * intf,
*/
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error setting ISOL parameter '%s'", param);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error setting ISOL parameter '%s': %s",
param, val2str(rsp->ccode, completion_code_vals));
return -1;
@ -413,6 +413,7 @@ ipmi_isol_deactivate(struct ipmi_intf * intf)
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t data[6];
struct isol_config_parameters params;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_ISOL;
@ -428,11 +429,11 @@ ipmi_isol_deactivate(struct ipmi_intf * intf)
data[5] = 0x00;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Error deactivating ISOL");
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error deactivating ISOL: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
@ -572,7 +573,7 @@ ipmi_isol_red_pill(struct ipmi_intf * intf)
int timedout = 0;
buffer = (char*)malloc(buffer_size);
if (!buffer) {
if (buffer == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1;
}
@ -790,20 +791,20 @@ int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
/*
* Help
*/
if (!argc || !strcmp(argv[0], "help"))
if (!argc || !strncmp(argv[0], "help", 4))
print_isol_usage();
/*
* Info
*/
else if (!strcmp(argv[0], "info")) {
else if (!strncmp(argv[0], "info", 4)) {
ret = ipmi_print_isol_info(intf);
}
/*
* Set a parameter value
*/
else if (!strcmp(argv[0], "set")) {
else if (!strncmp(argv[0], "set", 3)) {
if (argc < 3) {
print_isol_set_usage();
return -1;
@ -814,7 +815,7 @@ int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
/*
* Activate
*/
else if (!strcmp(argv[0], "activate")) {
else if (!strncmp(argv[0], "activate", 8)) {
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_mfg_date (struct ipmi_intf *intf);
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,
unsigned char channel, unsigned char size);
@ -75,38 +76,38 @@ ipmi_kontronoem_main(struct ipmi_intf *intf, int argc, char **argv)
ipmi_kontron_help();
return (-1);
}
if (!strcmp(argv[0], "help")) {
if (strncmp(argv[0], "help", 4) == 0) {
ipmi_kontron_help();
rc = 0;
} else if (!strcmp(argv[0], "setsn")) {
} else if (!strncmp(argv[0], "setsn", 5)) {
if (argc < 1) {
printf("fru setsn\n");
return (-1);
}
if (ipmi_kontron_set_serial_number(intf) > 0) {
printf("FRU serial number set successfully\n");
printf("FRU serial number setted successfully\n");
} else {
printf("FRU serial number set failed\n");
rc = (-1);
}
} else if (!strcmp(argv[0], "setmfgdate")) {
} else if (!strncmp(argv[0], "setmfgdate", 10)) {
if (argc < 1) {
printf("fru setmfgdate\n");
return (-1);
}
if (ipmi_kontron_set_mfg_date(intf) > 0) {
printf("FRU manufacturing date set successfully\n");
printf("FRU manufacturing date setted successfully\n");
} else {
printf("FRU manufacturing date set failed\n");
rc = (-1);
}
} else if (!strcmp(argv[0], "nextboot")) {
} else if (!strncmp(argv[0], "nextboot", 8)) {
if (argc < 2) {
lprintf(LOG_ERR, "Not enough parameters given.");
ipmi_kontron_nextboot_help();
return (-1);
rc = (-1);
}
rc = ipmi_kontron_nextboot_set(intf, (argv + 1));
rc = ipmi_kontron_nextboot_set(intf, (argc - 1), (argv + 1));
if (rc == 0) {
printf("Nextboot set successfully\n");
} else {
@ -175,6 +176,7 @@ ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf,
struct ipmi_rs *rsp;
struct ipmi_rq req;
uint8_t msg_data[2];
int i;
memset(msg_data, 0, sizeof(msg_data));
/* channel =~ 0x0e => Currently running interface */
msg_data[0] = channel;
@ -187,10 +189,10 @@ ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf,
req.msg.data_len = 2;
req.msg.lun = 0x00;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf("Cannot send large buffer command\n");
return(-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf("Invalid length for the selected interface (%s) %d\n",
val2str(rsp->ccode, completion_code_vals), rsp->ccode);
return(-1);
@ -242,16 +244,16 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Set Lun, necessary for this oem command */
req.msg.lun = 0x03;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf(" Device not present (No Response)\n");
return (-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf(" This option is not implemented for this board\n");
return (-1);
}
sn_size = rsp->data_len;
sn = malloc(sn_size + 1);
if (!sn) {
if (sn == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return (-1);
}
@ -268,12 +270,12 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
req.msg.data = msg_data;
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf(" Device not present (No Response)\n");
free(sn);
sn = NULL;
return (-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals));
free(sn);
@ -301,12 +303,12 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
req.msg.data = msg_data;
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf(" Device not present (No Response)\n");
free(sn);
sn = NULL;
return (-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals));
free(sn);
@ -327,7 +329,7 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Set the Board Section */
board_sec_len = (header.offset.product * 8) - (header.offset.board * 8);
fru_data = malloc(fru.size);
if (!fru_data) {
if (fru_data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
free(sn);
sn = NULL;
@ -345,28 +347,11 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
/* Position at Board Manufacturer */
fru_data_offset = (header.offset.board * 8) + 6;
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) {
free(fru_area);
fru_area = NULL;
}
/* Position at Board Product Name */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) {
free(fru_area);
fru_area = NULL;
}
fru_data_offset_tmp = fru_data_offset;
/* Position at Serial Number */
fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp);
if (!fru_area) {
lprintf(LOG_ERR, "Failed to read FRU Area string.");
free(fru_data);
fru_data = NULL;
free(sn);
sn = NULL;
return (-1);
}
fru_data_offset++;
if (strlen(fru_area) != sn_size) {
printf("The length of the serial number in the FRU Board Area is wrong.\n");
@ -374,12 +359,7 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
free(fru_area);
fru_area = NULL;
return(-1);
} else {
free(fru_area);
fru_area = NULL;
}
/* Copy the new serial number in the board section saved in memory*/
memcpy(fru_data + fru_data_offset, sn, sn_size);
@ -400,8 +380,6 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
free(fru_area);
fru_area = NULL;
return(-1);
}
/* Set the Product Section */
@ -412,54 +390,26 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
free(fru_area);
fru_area = NULL;
return(-1);
}
/* Position at Product Manufacturer */
fru_data_offset = (header.offset.product * 8) + 3;
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) {
free(fru_area);
fru_area = NULL;
}
/* Position at Product Name */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) {
free(fru_area);
fru_area = NULL;
}
/* Position at Product Part */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) {
free(fru_area);
fru_area = NULL;
}
/* Position at Product Version */
fru_area = get_fru_area_str(fru_data, &fru_data_offset);
if (fru_area) {
free(fru_area);
fru_area = NULL;
}
fru_data_offset_tmp = fru_data_offset;
/* Position at Serial Number */
fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp);
if (!fru_area) {
lprintf(LOG_ERR, "Failed to read FRU Area string.");
free(sn);
sn = NULL;
free(fru_data);
fru_data = NULL;
return (-1);
}
fru_data_offset ++;
if (strlen(fru_area) != sn_size) {
free(sn);
sn = NULL;
free(fru_data);
fru_data = NULL;
free(fru_area);
fru_area = NULL;
printf("The length of the serial number in the FRU Product Area is wrong.\n");
return(-1);
}
@ -482,16 +432,12 @@ ipmi_kontron_set_serial_number(struct ipmi_intf *intf)
sn = NULL;
free(fru_data);
fru_data = NULL;
free(fru_area);
fru_area = NULL;
return -1;
}
free(sn);
sn = NULL;
free(fru_data);
fru_data = NULL;
free(fru_area);
fru_area = NULL;
return(1);
}
@ -531,10 +477,10 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
/* Set Lun temporary, necessary for this oem command */
req.msg.lun = 0x03;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf("Device not present (No Response)\n");
return(-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf("This option is not implemented for this board\n");
return(-1);
}
@ -553,10 +499,10 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
req.msg.data = msg_data;
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf(" Device not present (No Response)\n");
return(-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals));
return(-1);
@ -581,10 +527,10 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
req.msg.data = msg_data;
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf(" Device not present (No Response)\n");
return (-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals));
return (-1);
@ -600,7 +546,7 @@ ipmi_kontron_set_mfg_date (struct ipmi_intf *intf)
}
board_sec_len = (header.offset.product * 8) - (header.offset.board * 8);
fru_data = malloc(fru.size);
if (!fru_data) {
if(fru_data == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return(-1);
}
@ -655,7 +601,7 @@ ipmi_kontron_nextboot_help(void)
* returns 1 if successful
*/
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_rq req;
@ -671,7 +617,7 @@ ipmi_kontron_nextboot_set(struct ipmi_intf *intf, char **argv)
msg_data[5] = 0xFF;
msg_data[6] = 0xFF; /* any */
for (i = 0; bootdev[i] != 0; i++) {
if (!strcmp(argv[0], bootdev[i])) {
if (strcmp(argv[0], bootdev[i]) == 0) {
msg_data[5] = i;
break;
}
@ -689,10 +635,10 @@ ipmi_kontron_nextboot_set(struct ipmi_intf *intf, char **argv)
/* Set Lun temporary, necessary for this oem command */
req.msg.lun = 0x03;
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
printf("Device not present (No Response)\n");
return(-1);
} else if (rsp->ccode) {
} else if (rsp->ccode > 0) {
printf("Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals));
return (-1);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,21 @@
/*
* Copyright (c) 2003 Sun Microsystems, 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 Sun Microsystems, 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
@ -42,7 +42,6 @@
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <locale.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
@ -66,28 +65,22 @@
#include <ipmitool/ipmi_user.h>
#include <ipmitool/ipmi_raw.h>
#include <ipmitool/ipmi_pef.h>
#include <ipmitool/ipmi_time.h>
#include <ipmitool/ipmi_oem.h>
#include <ipmitool/ipmi_ekanalyzer.h>
#include <ipmitool/ipmi_picmg.h>
#include <ipmitool/ipmi_kontronoem.h>
#include <ipmitool/ipmi_vita.h>
#include <ipmitool/ipmi_quantaoem.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#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:hVvcgsEKYao: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
# define OPTION_STRING "I:46hVvcH:f:U:p:d:S:D:"
# define OPTION_STRING "I:hVvcH:f:U:p:d:S:D:"
#endif
/* From src/plugins/ipmi_intf.c: */
void
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_authtype_session_vals[];
@ -109,14 +102,14 @@ ipmi_password_file_read(char * filename)
int l;
pass = malloc(21);
if (!pass) {
if (pass == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return NULL;
}
memset(pass, 0, 21);
fp = ipmi_open_file_read((const char *)filename);
if (!fp) {
if (fp == NULL) {
lprintf(LOG_ERR, "Unable to open password file %s",
filename);
free(pass);
@ -124,7 +117,7 @@ ipmi_password_file_read(char * filename)
}
/* read in id */
if (!fgets(pass, 21, fp)) {
if (fgets(pass, 21, fp) == NULL) {
lprintf(LOG_ERR, "Unable to read password from file %s",
filename);
free(pass);
@ -153,10 +146,10 @@ ipmi_cmd_print(struct ipmi_cmd * cmdlist)
struct ipmi_cmd * cmd;
int hdr = 0;
if (!cmdlist)
if (cmdlist == NULL)
return;
for (cmd=cmdlist; cmd->func; cmd++) {
if (!cmd->desc)
for (cmd=cmdlist; cmd->func != NULL; cmd++) {
if (cmd->desc == NULL)
continue;
if (hdr == 0) {
lprintf(LOG_NOTICE, "Commands:");
@ -178,7 +171,7 @@ ipmi_cmd_print(struct ipmi_cmd * cmdlist)
* @argc: command argument count
* @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
*/
int
@ -187,25 +180,25 @@ ipmi_cmd_run(struct ipmi_intf * intf, char * name, int argc, char ** argv)
struct ipmi_cmd * cmd = intf->cmdlist;
/* hook to run a default command if nothing specified */
if (!name) {
if (!cmd->func || !cmd->name)
if (name == NULL) {
if (cmd->func == NULL || cmd->name == NULL)
return -1;
if (!strcmp(cmd->name, "default"))
else if (strncmp(cmd->name, "default", 7) == 0)
return cmd->func(intf, 0, NULL);
lprintf(LOG_ERR, "No command provided!");
ipmi_cmd_print(intf->cmdlist);
return -1;
else {
lprintf(LOG_ERR, "No command provided!");
ipmi_cmd_print(intf->cmdlist);
return -1;
}
}
for (cmd=intf->cmdlist; cmd->func; cmd++) {
if (!strcmp(name, cmd->name))
for (cmd=intf->cmdlist; cmd->func != NULL; cmd++) {
if (strncmp(name, cmd->name, __maxlen(cmd->name, name)) == 0)
break;
}
if (!cmd->func) {
if (cmd->func == NULL) {
cmd = intf->cmdlist;
if (!strcmp(cmd->name, "default"))
if (strncmp(cmd->name, "default", 7) == 0)
return cmd->func(intf, argc+1, argv-1);
lprintf(LOG_ERR, "Invalid command: %s", name);
@ -234,8 +227,6 @@ ipmi_option_usage(const char * progname, struct ipmi_cmd * cmdlist, struct ipmi_
lprintf(LOG_NOTICE, " -S sdr Use local file for remote SDR cache");
lprintf(LOG_NOTICE, " -D tty:b[:s] Specify the serial device, baud rate to use");
lprintf(LOG_NOTICE, " and, optionally, specify that interface is the system one");
lprintf(LOG_NOTICE, " -4 Use only IPv4");
lprintf(LOG_NOTICE, " -6 Use only IPv6");
#ifdef ENABLE_ALL_OPTIONS
lprintf(LOG_NOTICE, " -a Prompt for remote password");
lprintf(LOG_NOTICE, " -Y Prompt for the Kg key for IPMIv2 authentication");
@ -259,13 +250,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, " -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, " -Z Display all dates in UTC");
#endif
lprintf(LOG_NOTICE, "");
ipmi_intf_print(intflist);
if (cmdlist)
if (cmdlist != NULL)
ipmi_cmd_print(cmdlist);
}
/* ipmi_catch_sigint - Handle the interrupt signal (Ctrl-C), close the
@ -273,31 +263,79 @@ ipmi_option_usage(const char * progname, struct ipmi_cmd * cmdlist, struct ipmi_
*
* This insures that the IOL session gets freed
* for other callers.
*
*
* returns -1
*/
void ipmi_catch_sigint()
{
if (ipmi_main_intf) {
if (ipmi_main_intf != NULL) {
printf("\nSIGN INT: Close Interface %s\n",ipmi_main_intf->desc);
/* reduce retry count to a single retry */
ipmi_main_intf->ssn_params.retry = 1;
/* close interface */
ipmi_main_intf->close(ipmi_main_intf);
}
exit(-1);
}
static uint8_t
ipmi_acquire_ipmb_address(struct ipmi_intf * intf)
/* ipmi_parse_hex - convert hexadecimal numbers to ascii string
* Input string must be composed of two-characer hexadecimal numbers.
* There is no separator between the numbers. Each number results in one character
* of the converted string.
*
* Example: ipmi_parse_hex("50415353574F5244") returns 'PASSWORD'
*
* @param str: input string. It must contain only even number of '0'-'9','a'-'f' and 'A-F' characters.
* @returns converted ascii string
* @returns NULL on error
*/
static unsigned char *
ipmi_parse_hex(const char *str)
{
if (intf->picmg_avail) {
return ipmi_picmg_ipmb_address(intf);
} else if (intf->vita_avail) {
return ipmi_vita_ipmb_address(intf);
} else {
return 0;
}
const char * p;
unsigned char * out, *q;
unsigned char b = 0;
int shift = 4;
if (strlen(str) == 0)
return NULL;
if (strlen(str) % 2 != 0) {
lprintf(LOG_ERR, "Number of hex_kg characters is not even");
return NULL;
}
if (strlen(str) > (IPMI_KG_BUFFER_SIZE-1)*2) {
lprintf(LOG_ERR, "Kg key is too long");
return NULL;
}
out = calloc(IPMI_KG_BUFFER_SIZE, sizeof(unsigned char));
if (out == NULL) {
lprintf(LOG_ERR, "malloc failure");
return NULL;
}
for (p = str, q = out; *p; p++) {
if (!isxdigit(*p)) {
lprintf(LOG_ERR, "Kg_hex is not hexadecimal number");
free(out);
out = NULL;
return NULL;
}
if (*p < 'A') /* it must be 0-9 */
b = *p - '0';
else /* it's A-F or a-f */
b = (*p | 0x20) - 'a' + 10; /* convert to lowercase and to 10-15 */
*q = *q + b << shift;
if (shift)
shift = 0;
else {
shift = 4;
q++;
}
}
return out;
}
/* ipmi_parse_options - helper function to handle parsing command line options
@ -320,7 +358,6 @@ ipmi_main(int argc, char ** argv,
uint8_t target_addr = 0;
uint8_t target_channel = 0;
uint8_t u8tmp = 0;
uint8_t transit_addr = 0;
uint8_t transit_channel = 0;
uint8_t target_lun = 0;
@ -341,32 +378,20 @@ ipmi_main(int argc, char ** argv,
char * progname = NULL;
char * oemtype = NULL;
char * sdrcache = NULL;
uint8_t kgkey[IPMI_KG_BUFFER_SIZE];
unsigned char * kgkey = NULL;
char * seloem = NULL;
int port = 0;
int devnum = 0;
#ifdef IPMI_INTF_LANPLUS
/* lookup best cipher suite available */
enum cipher_suite_ids cipher_suite_id = IPMI_LANPLUS_CIPHER_SUITE_RESERVED;
#endif /* IPMI_INTF_LANPLUS */
int cipher_suite_id = 3; /* See table 22-19 of the IPMIv2 spec */
int argflag, i, found;
int rc = -1;
int ai_family = AF_UNSPEC;
char sol_escape_char = SOL_ESCAPE_CHARACTER_DEFAULT;
char * devfile = NULL;
/* Set program locale according to system settings */
setlocale(LC_ALL, "");
/* save program name */
progname = strrchr(argv[0], '/');
progname = ((!progname) ? argv[0] : progname+1);
progname = ((progname == NULL) ? argv[0] : progname+1);
signal(SIGINT, ipmi_catch_sigint);
memset(kgkey, 0, sizeof(kgkey));
/* setup log */
log_init(progname, 0, 0);
while ((argflag = getopt(argc, (char **)argv, OPTION_STRING)) != -1)
{
@ -377,18 +402,17 @@ ipmi_main(int argc, char ** argv,
intfname = NULL;
}
intfname = strdup(optarg);
if (!intfname) {
if (intfname == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
if (intflist) {
if (intflist != NULL) {
found = 0;
for (sup=intflist; sup->name; sup++) {
if (!strcmp(sup->name, intfname)
&& sup->supported)
{
for (sup=intflist; sup->name != NULL; sup++) {
if (strncmp(sup->name, intfname, strlen(intfname)) == 0 &&
strncmp(sup->name, intfname, strlen(sup->name)) == 0 &&
sup->supported == 1)
found = 1;
}
}
if (!found) {
lprintf(LOG_ERR, "Interface %s not supported", intfname);
@ -434,25 +458,22 @@ ipmi_main(int argc, char ** argv,
goto out_free;
}
break;
#ifdef IPMI_INTF_LANPLUS
case 'C':
/* Cipher Suite ID is a byte as per IPMI specification */
if (str2uchar(optarg, &u8tmp) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of "
"range [0-255] for '-C'.");
if (str2int(optarg, &cipher_suite_id) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-C'.");
rc = -1;
goto out_free;
}
cipher_suite_id = u8tmp;
break;
#endif /* IPMI_INTF_LANPLUS */
case 'v':
log_level_set(++verbose);
if (verbose == 2) {
/* add version info to debug output */
lprintf(LOG_DEBUG, "%s version %s\n", progname, VERSION);
/* add check Cipher is -gt 0 */
if (cipher_suite_id < 0) {
lprintf(LOG_ERR, "Cipher suite ID %i is invalid.", cipher_suite_id);
rc = -1;
goto out_free;
}
break;
case 'v':
verbose++;
break;
case 'c':
csv_output = 1;
break;
@ -462,7 +483,7 @@ ipmi_main(int argc, char ** argv,
hostname = NULL;
}
hostname = strdup(optarg);
if (!hostname) {
if (hostname == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -473,7 +494,7 @@ ipmi_main(int argc, char ** argv,
password = NULL;
}
password = ipmi_password_file_read(optarg);
if (!password)
if (password == NULL)
lprintf(LOG_ERR, "Unable to read password "
"from file %s", optarg);
break;
@ -483,44 +504,52 @@ ipmi_main(int argc, char ** argv,
#else
tmp_pass = getpass("Password: ");
#endif
if (tmp_pass) {
if (tmp_pass != NULL) {
if (password) {
free(password);
password = NULL;
}
password = strdup(tmp_pass);
tmp_pass = NULL;
if (!password) {
if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
}
break;
case 'k':
memset(kgkey, 0, sizeof(kgkey));
strncpy((char *)kgkey, optarg, sizeof(kgkey) - 1);
if (kgkey) {
free(kgkey);
kgkey = NULL;
}
kgkey = strdup(optarg);
if (kgkey == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
break;
case 'K':
if ((tmp_env = getenv("IPMI_KGKEY"))) {
memset(kgkey, 0, sizeof(kgkey));
strncpy((char *)kgkey, tmp_env,
sizeof(kgkey) - 1);
if (kgkey) {
free(kgkey);
kgkey = NULL;
}
kgkey = strdup(tmp_env);
if (kgkey == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
} else {
lprintf(LOG_WARN, "Unable to read kgkey from environment");
}
break;
case 'y':
memset(kgkey, 0, sizeof(kgkey));
rc = ipmi_parse_hex(optarg, kgkey, sizeof(kgkey) - 1);
if (rc == -1) {
lprintf(LOG_ERR, "Number of Kg key characters is not even");
goto out_free;
} else if (rc == -3) {
lprintf(LOG_ERR, "Kg key is not hexadecimal number");
goto out_free;
} else if (rc > (IPMI_KG_BUFFER_SIZE-1)) {
lprintf(LOG_ERR, "Kg key is too long");
if (kgkey) {
free(kgkey);
kgkey = NULL;
}
kgkey = ipmi_parse_hex(optarg);
if (kgkey == NULL) {
goto out_free;
}
break;
@ -530,11 +559,17 @@ ipmi_main(int argc, char ** argv,
#else
tmp_pass = getpass("Key: ");
#endif
if (tmp_pass) {
memset(kgkey, 0, sizeof(kgkey));
strncpy((char *)kgkey, tmp_pass,
sizeof(kgkey) - 1);
if (tmp_pass != NULL) {
if (kgkey) {
free(kgkey);
kgkey = NULL;
}
kgkey = strdup(tmp_pass);
tmp_pass = NULL;
if (kgkey == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
}
break;
case 'U':
@ -547,7 +582,7 @@ ipmi_main(int argc, char ** argv,
goto out_free;
}
username = strdup(optarg);
if (!username) {
if (username == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -558,7 +593,7 @@ ipmi_main(int argc, char ** argv,
sdrcache = NULL;
}
sdrcache = strdup(optarg);
if (!sdrcache) {
if (sdrcache == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -570,43 +605,11 @@ ipmi_main(int argc, char ** argv,
free(devfile);
}
devfile = strdup(optarg);
if (!devfile) {
if (devfile == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
break;
case '4':
/* IPv4 only */
if (ai_family == AF_UNSPEC) {
ai_family = AF_INET;
} else {
if (ai_family == AF_INET6) {
lprintf(LOG_ERR,
"Parameter is mutually exclusive with -6.");
} else {
lprintf(LOG_ERR,
"Multiple -4 parameters given.");
}
rc = (-1);
goto out_free;
}
break;
case '6':
/* IPv6 only */
if (ai_family == AF_UNSPEC) {
ai_family = AF_INET6;
} else {
if (ai_family == AF_INET) {
lprintf(LOG_ERR,
"Parameter is mutually exclusive with -4.");
} else {
lprintf(LOG_ERR,
"Multiple -6 parameters given.");
}
rc = (-1);
goto out_free;
}
break;
#ifdef ENABLE_ALL_OPTIONS
case 'o':
if (oemtype) {
@ -614,13 +617,12 @@ ipmi_main(int argc, char ** argv,
oemtype = NULL;
}
oemtype = strdup(optarg);
if (!oemtype) {
if (oemtype == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
if (!strcmp(oemtype, "list")
|| !strcmp(oemtype, "help"))
{
if (strncmp(oemtype, "list", 4) == 0 ||
strncmp(oemtype, "help", 4) == 0) {
ipmi_oem_print();
rc = 0;
goto out_free;
@ -648,7 +650,7 @@ ipmi_main(int argc, char ** argv,
password = NULL;
}
password = strdup(optarg);
if (!password) {
if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -664,7 +666,7 @@ ipmi_main(int argc, char ** argv,
password = NULL;
}
password = strdup(tmp_env);
if (!password) {
if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -675,7 +677,7 @@ ipmi_main(int argc, char ** argv,
password = NULL;
}
password = strdup(tmp_env);
if (!password) {
if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -749,7 +751,7 @@ ipmi_main(int argc, char ** argv,
seloem = NULL;
}
seloem = strdup(optarg);
if (!seloem) {
if (seloem == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -776,9 +778,6 @@ ipmi_main(int argc, char ** argv,
goto out_free;
}
break;
case 'Z':
time_in_utc = 1;
break;
#endif
default:
ipmi_option_usage(progname, cmdlist, intflist);
@ -787,9 +786,8 @@ ipmi_main(int argc, char ** argv,
}
/* check for command before doing anything */
if (argc-optind > 0
&& !strcmp(argv[optind], "help"))
{
if (argc-optind > 0 &&
strncmp(argv[optind], "help", 4) == 0) {
ipmi_cmd_print(cmdlist);
rc = 0;
goto out_free;
@ -803,17 +801,17 @@ ipmi_main(int argc, char ** argv,
* and the authtype was not explicitly set to NONE
* then prompt the user.
*/
if (hostname && !password &&
if (hostname != NULL && password == NULL &&
(authtype != IPMI_SESSION_AUTHTYPE_NONE || authtype < 0)) {
#ifdef HAVE_GETPASSPHRASE
tmp_pass = getpassphrase("Password: ");
#else
tmp_pass = getpass("Password: ");
#endif
if (tmp_pass) {
if (tmp_pass != NULL) {
password = strdup(tmp_pass);
tmp_pass = NULL;
if (!password) {
if (password == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
@ -825,51 +823,52 @@ ipmi_main(int argc, char ** argv,
* otherwise the default is hardcoded
* to use the first entry in the list
*/
if (!intfname && hostname) {
if (intfname == NULL && hostname != NULL) {
intfname = strdup("lan");
if (!intfname) {
if (intfname == NULL) {
lprintf(LOG_ERR, "%s: malloc failure", progname);
goto out_free;
}
}
if (password && intfname) {
if (!strcmp(intfname, "lan") && strlen(password) > 16) {
if (password != NULL && intfname != NULL) {
if (strcmp(intfname, "lan") == 0 && strlen(password) > 16) {
lprintf(LOG_ERR, "%s: password is longer than 16 bytes.", intfname);
rc = -1;
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);
rc = -1;
goto out_free;
}
}
} /* if (password != NULL && intfname != NULL) */
/* load interface */
ipmi_main_intf = ipmi_intf_load(intfname);
if (!ipmi_main_intf) {
if (ipmi_main_intf == NULL) {
lprintf(LOG_ERR, "Error loading interface %s", intfname);
goto out_free;
}
/* load the IANA PEN registry */
ipmi_oem_info_init();
/* setup log */
log_init(progname, 0, verbose);
/* run OEM setup if found */
if (oemtype &&
if (oemtype != NULL &&
ipmi_oem_setup(ipmi_main_intf, oemtype) < 0) {
lprintf(LOG_ERR, "OEM setup for \"%s\" failed", oemtype);
goto out_free;
}
/* set session variables */
if (hostname)
if (hostname != NULL)
ipmi_intf_session_set_hostname(ipmi_main_intf, hostname);
if (username)
if (username != NULL)
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_kgkey(ipmi_main_intf, kgkey);
if (kgkey != NULL)
ipmi_intf_session_set_kgkey(ipmi_main_intf, kgkey);
if (port > 0)
ipmi_intf_session_set_port(ipmi_main_intf, port);
if (authtype >= 0)
@ -887,43 +886,29 @@ ipmi_main(int argc, char ** argv,
ipmi_intf_session_set_lookupbit(ipmi_main_intf, lookupbit);
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);
#endif /* IPMI_INTF_LANPLUS */
ipmi_main_intf->devnum = devnum;
/* setup device file if given */
ipmi_main_intf->devfile = devfile;
ipmi_main_intf->ai_family = ai_family;
/* Open the interface with the specified or default IPMB address */
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) {
goto out_free;
}
}
if (!ipmi_oem_active(ipmi_main_intf, "i82571spt")) {
/*
* Attempt picmg/vita discovery of the actual interface
* address, unless the users specified an address.
* Address specification always overrides discovery
*/
if (picmg_discover(ipmi_main_intf)) {
ipmi_main_intf->picmg_avail = 1;
} else if (vita_discover(ipmi_main_intf)) {
ipmi_main_intf->vita_avail = 1;
}
}
if (arg_addr) {
addr = arg_addr;
} else if (!ipmi_oem_active(ipmi_main_intf, "i82571spt")) {
lprintf(LOG_DEBUG, "Acquire IPMB address");
addr = ipmi_acquire_ipmb_address(ipmi_main_intf);
lprintf(LOG_INFO, "Discovered IPMB address 0x%x", addr);
/*
* Attempt picmg discovery of the actual interface address unless
* the users specified an address.
* Address specification always overrides discovery
*/
if (picmg_discover(ipmi_main_intf) && !arg_addr) {
lprintf(LOG_DEBUG, "Running PICMG Get Address Info");
addr = ipmi_picmg_ipmb_address(ipmi_main_intf);
lprintf(LOG_INFO, "Discovered IPMB-0 address 0x%x", addr);
}
/*
@ -931,44 +916,41 @@ ipmi_main(int argc, char ** argv,
* used for open, Set the discovered IPMB address as my address if the
* interface supports it.
*/
if (addr != 0 && addr != ipmi_main_intf->my_addr) {
if (ipmi_main_intf->set_my_addr) {
/*
* Some interfaces need special handling
* when changing local address
*/
(void)ipmi_main_intf->set_my_addr(ipmi_main_intf, addr);
}
/* set local address */
ipmi_main_intf->my_addr = addr;
if (addr != 0 && addr != ipmi_main_intf->my_addr &&
ipmi_main_intf->set_my_addr) {
/*
* Only set the interface address on interfaces which support
* it
*/
(void) ipmi_main_intf->set_my_addr(ipmi_main_intf, addr);
}
ipmi_main_intf->target_addr = ipmi_main_intf->my_addr;
/* If bridging addresses are specified, handle them */
if (transit_addr > 0 || target_addr > 0) {
if (target_addr > 0) {
ipmi_main_intf->target_addr = target_addr;
ipmi_main_intf->target_lun = target_lun ;
ipmi_main_intf->target_channel = target_channel ;
}
if (transit_addr > 0) {
/* sanity check, transit makes no sense without a target */
if ((transit_addr != 0 || transit_channel != 0) &&
target_addr == 0) {
ipmi_main_intf->target_addr == 0) {
lprintf(LOG_ERR,
"Transit address/channel %#x/%#x ignored. "
"Target address must be specified!",
transit_addr, transit_channel);
goto out_free;
}
ipmi_main_intf->target_addr = target_addr;
ipmi_main_intf->target_channel = target_channel ;
ipmi_main_intf->transit_addr = transit_addr;
ipmi_main_intf->transit_channel = transit_channel;
}
if (ipmi_main_intf->target_addr > 0) {
/* must be admin level to do this over lan */
ipmi_intf_session_set_privlvl(ipmi_main_intf, IPMI_SESSION_PRIV_ADMIN);
/* Get the ipmb address of the targeted entity */
ipmi_main_intf->target_ipmb_addr =
ipmi_acquire_ipmb_address(ipmi_main_intf);
ipmi_picmg_ipmb_address(ipmi_main_intf);
lprintf(LOG_DEBUG, "Specified addressing Target %#x:%#x Transit %#x:%#x",
ipmi_main_intf->target_addr,
ipmi_main_intf->target_channel,
@ -980,9 +962,6 @@ ipmi_main(int argc, char ** argv,
}
}
/* set target LUN (for RAW command) */
ipmi_main_intf->target_lun = target_lun ;
lprintf(LOG_DEBUG, "Interface address: my_addr %#x "
"transit %#x:%#x target %#x:%#x "
"ipmb_target %#x\n",
@ -994,11 +973,11 @@ ipmi_main(int argc, char ** argv,
ipmi_main_intf->target_ipmb_addr);
/* parse local SDR cache if given */
if (sdrcache) {
ipmi_sdr_list_cache_fromfile(sdrcache);
if (sdrcache != NULL) {
ipmi_sdr_list_cache_fromfile(ipmi_main_intf, sdrcache);
}
/* Parse SEL OEM file if given */
if (seloem) {
if (seloem != NULL) {
ipmi_sel_oem_init(seloem);
}
@ -1035,37 +1014,41 @@ ipmi_main(int argc, char ** argv,
ipmi_cleanup(ipmi_main_intf);
/* 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);
out_free:
log_halt();
if (intfname) {
if (intfname != NULL) {
free(intfname);
intfname = NULL;
}
if (hostname) {
if (hostname != NULL) {
free(hostname);
hostname = NULL;
}
if (username) {
if (username != NULL) {
free(username);
username = NULL;
}
if (password) {
if (password != NULL) {
free(password);
password = NULL;
}
if (oemtype) {
if (oemtype != NULL) {
free(oemtype);
oemtype = NULL;
}
if (seloem) {
if (seloem != NULL) {
free(seloem);
seloem = NULL;
}
if (sdrcache) {
if (kgkey != NULL) {
free(kgkey);
kgkey = NULL;
}
if (sdrcache != NULL) {
free(sdrcache);
sdrcache = NULL;
}
@ -1074,8 +1057,6 @@ ipmi_main(int argc, char ** argv,
devfile = NULL;
}
ipmi_oem_info_free();
return rc;
}

File diff suppressed because it is too large Load Diff

View File

@ -37,84 +37,70 @@
#include <ipmitool/helper.h>
#include <ipmitool/ipmi_sel.h>
static int ipmi_oem_supermicro(struct ipmi_intf *intf);
static int ipmi_oem_ibm(struct ipmi_intf *intf);
static int ipmi_oem_quanta(struct ipmi_intf *intf);
static int ipmi_oem_supermicro(struct ipmi_intf * intf);
static int ipmi_oem_ibm(struct ipmi_intf * intf);
static struct ipmi_oem_handle ipmi_oem_list[] = {
{
.name = "supermicro",
.desc = "Supermicro IPMIv1.5 BMC with OEM LAN authentication support",
.setup = ipmi_oem_supermicro,
name: "supermicro",
desc: "Supermicro IPMIv1.5 BMC with OEM LAN authentication support",
setup: ipmi_oem_supermicro,
},
{
.name = "intelwv2",
.desc = "Intel SE7501WV2 IPMIv1.5 BMC with extra LAN communication support",
name: "intelwv2",
desc: "Intel SE7501WV2 IPMIv1.5 BMC with extra LAN communication support",
},
{
.name = "intelplus",
.desc = "Intel IPMI 2.0 BMC with RMCP+ communication support",
name: "intelplus",
desc: "Intel IPMI 2.0 BMC with RMCP+ communication support",
},
{
.name = "icts",
.desc = "IPMI 2.0 ICTS compliance support",
name: "icts",
desc: "IPMI 2.0 ICTS compliance support",
},
{
.name = "ibm",
.desc = "IBM OEM support",
.setup = ipmi_oem_ibm,
name: "ibm",
desc: "IBM OEM support",
setup: ipmi_oem_ibm,
},
{
.name = "i82571spt",
.desc = "Intel 82571 MAC with integrated RMCP+ support in super pass-through mode",
name: "i82571spt",
desc: "Intel 82571 MAC with integrated RMCP+ support in super pass-through mode",
},
{
.name = "kontron",
.desc = "Kontron OEM big buffer support"
},
{
.name = "quanta",
.desc = "Quanta IPMIv1.5 BMC with OEM LAN authentication support",
.setup = ipmi_oem_quanta,
name: "kontron",
desc: "Kontron OEM big buffer support"
},
{ 0 }
};
/* Supermicro IPMIv2 BMCs use OEM authtype */
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);
return 0;
}
static int
ipmi_oem_ibm(struct ipmi_intf *__UNUSED__(intf))
ipmi_oem_ibm(struct ipmi_intf * intf)
{
char *filename = getenv("IPMI_OEM_IBM_DATAFILE");
if (!filename) {
char * filename;
if ((filename = getenv("IPMI_OEM_IBM_DATAFILE")) == NULL) {
lprintf(LOG_ERR, "Unable to read IPMI_OEM_IBM_DATAFILE from environment");
return -1;
}
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
*/
void
ipmi_oem_print(void)
{
struct ipmi_oem_handle *oem;
struct ipmi_oem_handle * oem;
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, "");
@ -134,27 +120,26 @@ ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype)
struct ipmi_oem_handle * oem;
int rc = 0;
if (!oemtype
|| !strcmp(oemtype, "help")
|| !strcmp(oemtype, "list"))
{
if (oemtype == NULL ||
strncmp(oemtype, "help", 4) == 0 ||
strncmp(oemtype, "list", 4) == 0) {
ipmi_oem_print();
return -1;
}
for (oem=ipmi_oem_list; oem->name; oem++) {
if (!strcmp(oemtype, oem->name))
for (oem=ipmi_oem_list; oem->name != NULL; oem++) {
if (strncmp(oemtype, oem->name, strlen(oem->name)) == 0)
break;
}
if (!oem->name)
if (oem->name == NULL)
return -1;
/* save pointer for later use */
intf->oem = oem;
/* 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);
rc = oem->setup(intf);
}
@ -173,10 +158,10 @@ ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype)
int
ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype)
{
if (!intf->oem)
if (intf->oem == NULL)
return 0;
if (!strcmp(intf->oem->name, oemtype))
if (strncmp(intf->oem->name, oemtype, strlen(oemtype)) == 0)
return 1;
return 0;

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,11 @@
#include <ipmitool/ipmi_strings.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_PRINT_ALL 1
#define PICMG_EKEY_MODE_PRINT_ENABLED 2
@ -62,84 +67,7 @@ typedef enum picmg_card_type {
PICMG_CARD_TYPE_RESERVED
} t_picmg_card_type ;
static const char* amc_link_type_str[] = {
"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 */
/* This is the version of the PICMG Extenstion */
static t_picmg_card_type PicmgCardType = PICMG_CARD_TYPE_RESERVED;
void
@ -202,28 +130,6 @@ struct sAmcAddrMap {
{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
* 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);
}
/* 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
* @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);
}
/* 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
* @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);
}
/* 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
* @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);
}
/* 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
* @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);
}
/* 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
* @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);
}
/* 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
*
* @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);
}
/* 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>
*
* @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);
}
/* 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
* @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);
}
/* 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
* @clk_resid_ptr: pointer where to store result
@ -511,6 +417,27 @@ is_led_color(const char *argv_ptr, uint8_t *led_color_ptr)
lprintf(LOG_ERR, "LED Color must be from ranges: <1..6>, <0xE..0xF>");
return (-1);
}
/* is_led_duration - wrapper to convert user input into integer.
* LED duration range is <1..127>
*
* @argv_ptr: source string to convert from; usually argv
* @enable_ptr: pointer where to store result
* returns: zero on success, other values mean error
*/
int
is_led_duration(const char *argv_ptr, uint8_t *led_duration_ptr)
{
if (!argv_ptr || !led_duration_ptr) {
lprintf(LOG_ERR, "is_led_duration(): invalid argument(s).");
return (-1);
}
if (str2uchar(argv_ptr, led_duration_ptr) == 0
&& *led_duration_ptr > 0 && *led_duration_ptr <= 127) {
return 0;
}
lprintf(LOG_ERR, "Given LED Duration '%s' is invalid", argv_ptr);
return (-1);
}
/* is_led_function - wrapper to convert user input into integer.
* LED functions, however, might differ by OEM:
* - 0x00 - off override
@ -755,7 +682,7 @@ ipmi_picmg_properties(struct ipmi_intf * intf, int show )
#define PICMG_FRU_ACTIVATE (unsigned char) 0x01
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_rq req;
@ -789,7 +716,7 @@ ipmi_picmg_fru_activation(struct ipmi_intf * intf, char ** argv, unsigned char s
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_rq req;
@ -828,7 +755,7 @@ ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, char ** argv)
}
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_rq req;
@ -845,19 +772,21 @@ ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf, char ** argv)
if (is_fru_id(argv[0], &msg_data[1]) != 0) {
return (-1);
}
if (str2uchar(argv[1], &msg_data[2]) != 0 || msg_data[2] > 3) {
if (str2uchar(argv[1], &msg_data[2]) != 0 || msg_data[2] > 1) {
/* FRU Lock Mask */
lprintf(LOG_ERR, "Given FRU Lock Mask '%s' is invalid.",
argv[1]);
return (-1);
}
if (str2uchar(argv[2], &msg_data[3]) != 0 || msg_data[3] > 3) {
if (str2uchar(argv[2], &msg_data[3]) != 0 || msg_data[3] > 1) {
/* FRU Act Policy */
lprintf(LOG_ERR,
"Given FRU Activation Policy '%s' is invalid.",
argv[2]);
return (-1);
}
msg_data[2]&= 0x03;
msg_data[3]&= 0x03;
rsp = intf->sendrecv(intf, &req);
@ -1123,7 +1052,7 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf, int32_t device,
/* Removed endianness check here, probably not required
as we don't use bitfields */
as we dont use bitfields */
port = d->linkInfo[0] & 0x0F;
type = ((d->linkInfo[0] & 0xF0) >> 4 )|(d->linkInfo[1] & 0x0F );
ext = ((d->linkInfo[1] & 0xF0) >> 4 );
@ -1252,7 +1181,7 @@ ipmi_picmg_amc_portstate_set(struct ipmi_intf * intf, uint8_t channel,
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_rq req;
@ -1291,7 +1220,7 @@ ipmi_picmg_get_led_properties(struct ipmi_intf * intf, char ** argv)
}
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;
struct ipmi_rs * rsp;
@ -1328,20 +1257,20 @@ ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, char ** argv)
printf("LED Color Capabilities: ");
for ( i=0 ; i<8 ; i++ ) {
if ( rsp->data[1] & (0x01 << i) ) {
printf("%s, ", picmg_led_color_str(i));
printf("%s, ", led_color_str[ i ]);
}
}
printf("\n");
printf("Default LED Color in\n");
printf(" LOCAL control: %s\n", picmg_led_color_str(rsp->data[2]));
printf(" OVERRIDE state: %s\n", picmg_led_color_str(rsp->data[3]));
printf(" LOCAL control: %s\n", led_color_str[ rsp->data[2] ] );
printf(" OVERRIDE state: %s\n", led_color_str[ rsp->data[3] ] );
return 0;
}
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_rq req;
@ -1374,57 +1303,49 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, char ** argv)
}
printf("LED states: %x ", rsp->data[1] );
if (!(rsp->data[1] & 0x1)) {
printf("[NO LOCAL CONTROL]\n");
return 0;
}
printf("[LOCAL CONTROL");
if (rsp->data[1] & 0x2) {
printf("|OVERRIDE");
}
if (rsp->data[1] & 0x4) {
printf("|LAMPTEST");
}
printf("]\n");
if (rsp->data[1] == 0x1)
printf("[LOCAL CONTROL]\n");
else if (rsp->data[1] == 0x2)
printf("[OVERRIDE]\n");
else if (rsp->data[1] == 0x4)
printf("[LAMPTEST]\n");
else
printf("\n");
printf(" Local Control function: %x ", rsp->data[2] );
if (rsp->data[2] == 0x0) {
if (rsp->data[2] == 0x0)
printf("[OFF]\n");
} else if (rsp->data[2] == 0xff) {
else if (rsp->data[2] == 0xff)
printf("[ON]\n");
} else {
else
printf("[BLINKING]\n");
}
printf(" Local Control On-Duration: %x\n", rsp->data[3] );
printf(" Local Control Color: %x [%s]\n",
rsp->data[4],
picmg_led_color_str(rsp->data[4]));
printf(" Local Control Color: %x [%s]\n", rsp->data[4], led_color_str[ rsp->data[4] ]);
/* override state or lamp test */
if (rsp->data[1] & 0x02) {
if (rsp->data[1] == 0x02) {
printf(" Override function: %x ", rsp->data[5] );
if (rsp->data[2] == 0x0) {
if (rsp->data[2] == 0x0)
printf("[OFF]\n");
} else if (rsp->data[2] == 0xff) {
else if (rsp->data[2] == 0xff)
printf("[ON]\n");
} else {
else
printf("[BLINKING]\n");
}
printf(" Override On-Duration: %x\n", rsp->data[6] );
printf(" Override Color: %x [%s]\n",
rsp->data[7],
picmg_led_color_str(rsp->data[7]));
printf(" Override Color: %x [%s]\n", rsp->data[7], led_color_str[ rsp->data[7] ]);
}
if (rsp->data[1] & 0x04) {
}else if (rsp->data[1] == 0x06) {
printf(" Override function: %x ", rsp->data[5] );
if (rsp->data[2] == 0x0)
printf("[OFF]\n");
else if (rsp->data[2] == 0xff)
printf("[ON]\n");
else
printf("[BLINKING]\n");
printf(" Override On-Duration: %x\n", rsp->data[6] );
printf(" Override Color: %x [%s]\n", rsp->data[7], led_color_str[ rsp->data[7] ]);
printf(" Lamp test duration: %x\n", rsp->data[8] );
}
@ -1432,7 +1353,7 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, char ** argv)
}
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_rq req;
@ -1442,55 +1363,19 @@ ipmi_picmg_set_led_state(struct ipmi_intf * intf, char ** argv)
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_PICMG;
req.msg.cmd = PICMG_SET_FRU_LED_STATE_CMD;
req.msg.data = msg_data;
req.msg.cmd = PICMG_SET_FRU_LED_STATE_CMD;
req.msg.data = msg_data;
req.msg.data_len = 6;
msg_data[0] = 0x00; /* PICMG identifier */
if (is_fru_id(argv[0], &msg_data[1]) != 0
|| is_led_id(argv[1], &msg_data[2]) != 0
|| is_led_function(argv[2], &msg_data[3]) != 0
|| is_led_duration(argv[3], &msg_data[4]) != 0
|| is_led_color(argv[4], &msg_data[5]) != 0) {
return (-1);
}
/* Validating the LED duration is not as simple as the other arguments, as
* the range of valid durations depends on the LED function. From the spec:
*
* ``On-duration: LED on-time in tens of milliseconds if (1 <= Byte 4 <= FAh)
* Lamp Test time in hundreds of milliseconds if (Byte 4 = FBh). Lamp Test
* time value must be less than 128. Other values when Byte 4 = FBh are
* reserved. Otherwise, this field is ignored and shall be set to 0h.''
*
* If we're doing a lamp test, then the allowed values are 0 -> 127.
* Otherwise, the allowed values are 0 -> 255. However, if the function is
* not a lamp test (0xFB) and outside the range 0x01 -> 0xFA then the value
* should be set to 0.
*
* Start by checking we have a parameter.
*/
if (!argv[3]) {
lprintf(LOG_ERR, "LED Duration: invalid argument(s).");
return (-1);
}
/* Next check we have a number. */
if (str2uchar(argv[3], &msg_data[4]) != 0) {
lprintf(LOG_ERR, "Given LED Duration '%s' is invalid", argv[3]);
return (-1);
}
/* If we have a lamp test, ensure it's not too long a duration. */
if (msg_data[3] == 0xFB && msg_data[4] > 127) {
lprintf(LOG_ERR, "Given LED Duration '%s' is invalid", argv[3]);
return (-1);
}
/* If we're outside the range that allows durations, set the duration to 0.
* Warn the user that we're doing this.
*/
if (msg_data[4] != 0 && (msg_data[3] == 0 || msg_data[3] > 0xFB)) {
lprintf(LOG_WARN, "Setting LED Duration '%s' to '0'", argv[3]);
msg_data[4] = 0;
}
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
@ -1508,7 +1393,7 @@ ipmi_picmg_set_led_state(struct ipmi_intf * intf, char ** argv)
}
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;
struct ipmi_rs * rsp;
@ -1559,7 +1444,7 @@ ipmi_picmg_get_power_level(struct ipmi_intf * intf, char ** argv)
}
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_rq req;
@ -1663,7 +1548,7 @@ ipmi_picmg_bused_resource(struct ipmi_intf * intf, t_picmg_bused_resource_mode m
}
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_rq req;
@ -1752,7 +1637,7 @@ ipmi_picmg_clk_get(struct ipmi_intf * intf, uint8_t clk_id, int8_t clk_res,
return -1;
}
if (!rsp->ccode) {
if (rsp->ccode == 0 ) {
enabled = (rsp->data[1]&0x8)!=0;
direction = (rsp->data[1]&0x4)!=0;
@ -1860,8 +1745,18 @@ ipmi_picmg_clk_set(struct ipmi_intf * intf, int argc, char ** argv)
}
}
#if 1
printf("## ID: %d\n", msg_data[1]);
printf("## index: %d\n", msg_data[2]);
printf("## setting: 0x%02x\n", msg_data[3]);
printf("## family: %d\n", msg_data[4]);
printf("## acc: %d\n", msg_data[5]);
printf("## freq: %ld\n", freq );
printf("## res: %d\n", msg_data[10]);
#endif
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
lprintf(LOG_ERR, "No valid response received.");
return -1;
@ -1883,24 +1778,24 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
int rc = 0;
int showProperties = 0;
if (!argc || !strcmp(argv[0], "help")) {
if (argc == 0 || (!strncmp(argv[0], "help", 4))) {
ipmi_picmg_help();
return 0;
}
/* Get PICMG properties is called to obtain version information */
if (!strcmp(argv[0], "properties")) {
if (argc !=0 && !strncmp(argv[0], "properties", 10)) {
showProperties =1;
}
rc = ipmi_picmg_properties(intf,showProperties);
/* address info command */
if (!strcmp(argv[0], "addrinfo")) {
if (!strncmp(argv[0], "addrinfo", 8)) {
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 (!strcmp(argv[1], "summary")) {
if (!strncmp(argv[1], "summary", 7)) {
ipmi_picmg_bused_resource(intf, PICMG_BUSED_RESOURCE_SUMMARY );
}
} else {
@ -1908,9 +1803,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
/* fru control command */
else if (!strcmp(argv[0], "frucontrol")) {
else if (!strncmp(argv[0], "frucontrol", 10)) {
if (argc > 2) {
rc = ipmi_picmg_fru_control(intf, &(argv[1]));
rc = ipmi_picmg_fru_control(intf, argc-1, &(argv[1]));
}
else {
lprintf(LOG_NOTICE, "usage: frucontrol <FRU-ID> <OPTION>");
@ -1928,9 +1823,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
/* fru activation command */
else if (!strcmp(argv[0], "activate")) {
else if (!strncmp(argv[0], "activate", 8)) {
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 {
lprintf(LOG_ERR, "Specify the FRU to activate.");
@ -1939,9 +1834,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
/* fru deactivation command */
else if (!strcmp(argv[0], "deactivate")) {
else if (!strncmp(argv[0], "deactivate", 10)) {
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 {
lprintf(LOG_ERR, "Specify the FRU to deactivate.");
return -1;
@ -1949,17 +1844,17 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
/* activation policy command */
else if (!strcmp(argv[0], "policy")) {
else if (!strncmp(argv[0], "policy", 6)) {
if (argc > 1) {
if (!strcmp(argv[1], "get")) {
if (!strncmp(argv[1], "get", 3)) {
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 {
lprintf(LOG_NOTICE, "usage: get <fruid>");
}
} else if (!strcmp(argv[1], "set")) {
} else if (!strncmp(argv[1], "set", 3)) {
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 {
lprintf(LOG_NOTICE, "usage: set <fruid> <lockmask> <lock>");
lprintf(LOG_NOTICE,
@ -1982,18 +1877,18 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
/* portstate command */
else if (!strcmp(argv[0], "portstate")) {
else if (!strncmp(argv[0], "portstate", 9)) {
lprintf(LOG_DEBUG,"PICMG: portstate API");
if (argc > 1) {
if (!strcmp(argv[1], "get")) {
if (!strncmp(argv[1], "get", 3)) {
int32_t iface;
uint8_t channel = 0;
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(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) {
if(!(( iface == FRU_PICMGEXT_DESIGN_IF_FABRIC ) &&
@ -2005,7 +1900,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(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) {
rc = ipmi_picmg_portstate_get(intf,iface,channel,
@ -2013,7 +1908,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(channel=1;channel<=PICMG_EKEY_MAX_CHANNEL;channel++) {
rc = ipmi_picmg_portstate_get(intf,iface,channel,
@ -2036,7 +1931,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_NOTICE, "<intf> <chn>|getall|getgranted|getdenied");
}
}
else if (!strcmp(argv[1], "set")) {
else if (!strncmp(argv[1], "set", 3)) {
if (argc == 9) {
int32_t interface = 0;
int32_t port = 0;
@ -2079,18 +1974,18 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
/* amc portstate command */
else if (!strcmp(argv[0], "amcportstate")) {
else if (!strncmp(argv[0], "amcportstate", 12)) {
lprintf(LOG_DEBUG,"PICMG: amcportstate API");
if (argc > 1) {
if (!strcmp(argv[1], "get")){
if (!strncmp(argv[1], "get", 3)){
int32_t device;
uint8_t channel;
lprintf(LOG_DEBUG,"PICMG: get");
if(!strcmp(argv[1], "getall")){
if(!strncmp(argv[1], "getall", 6)){
int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE;
if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){
maxDevice = 0;
@ -2102,7 +1997,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;
if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){
maxDevice = 0;
@ -2114,7 +2009,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;
if( PicmgCardType != PICMG_CARD_TYPE_ATCA ){
maxDevice = 0;
@ -2147,7 +2042,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_NOTICE, "<chn> <device>|getall|getgranted|getdenied");
}
}
else if (!strcmp(argv[1], "set")) {
else if (!strncmp(argv[1], "set", 3)) {
if (argc > 7) {
int32_t device = -1;
int32_t port = 0;
@ -2194,35 +2089,35 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
/* ATCA led commands */
else if (!strcmp(argv[0], "led")) {
else if (!strncmp(argv[0], "led", 3)) {
if (argc > 1) {
if (!strcmp(argv[1], "prop")) {
if (!strncmp(argv[1], "prop", 4)) {
if (argc > 2) {
rc = ipmi_picmg_get_led_properties(intf, &(argv[2]));
rc = ipmi_picmg_get_led_properties(intf, argc-1, &(argv[2]));
}
else {
lprintf(LOG_NOTICE, "led prop <FRU-ID>");
}
}
else if (!strcmp(argv[1], "cap")) {
else if (!strncmp(argv[1], "cap", 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 {
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) {
rc = ipmi_picmg_get_led_state(intf, &(argv[2]));
rc = ipmi_picmg_get_led_state(intf, argc-1, &(argv[2]));
}
else {
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) {
rc = ipmi_picmg_set_led_state(intf, &(argv[2]));
rc = ipmi_picmg_set_led_state(intf, argc-1, &(argv[2]));
}
else {
lprintf(LOG_NOTICE,
@ -2242,8 +2137,8 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_NOTICE,
" 252: LED restore to local control");
lprintf(LOG_NOTICE, " 255: LED ON override");
lprintf(LOG_NOTICE, " <duration> 0 - 127: LED Lamp Test duration");
lprintf(LOG_NOTICE, " 0 - 255: LED Lamp ON duration");
lprintf(LOG_NOTICE,
" <duration> 1 - 127: LED Lamp Test / on duration");
lprintf(LOG_NOTICE, " <color> 0: reserved");
lprintf(LOG_NOTICE, " 1: BLUE");
lprintf(LOG_NOTICE, " 2: RED");
@ -2262,11 +2157,11 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
/* power commands */
else if (!strcmp(argv[0], "power")) {
else if (!strncmp(argv[0], "power", 5)) {
if (argc > 1) {
if (!strcmp(argv[1], "get")) {
if (!strncmp(argv[1], "get", 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 {
lprintf(LOG_NOTICE, "power get <FRU-ID> <type>");
@ -2279,9 +2174,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
return -1;
}
}
else if (!strcmp(argv[1], "set")) {
else if (!strncmp(argv[1], "set", 3)) {
if (argc > 4) {
rc = ipmi_picmg_set_power_level(intf, &(argv[2]));
rc = ipmi_picmg_set_power_level(intf, argc-1, &(argv[2]));
}
else {
lprintf(LOG_NOTICE, "power set <FRU-ID> <level> <present-desired>");
@ -2306,9 +2201,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
return -1;
}
}/* clk commands*/
else if (!strcmp(argv[0], "clk")) {
else if (!strncmp(argv[0], "clk", 3)) {
if (argc > 1) {
if (!strcmp(argv[1], "get")) {
if (!strncmp(argv[1], "get", 3)) {
int8_t clk_res = -1;
uint8_t clk_id;
uint8_t max_res = 15;
@ -2317,7 +2212,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
max_res = 0;
}
if(!strcmp(argv[1], "getall")) {
if(!strncmp(argv[1], "getall", 6)) {
if( verbose ) { printf("Getting all clock state\n") ;}
for(clk_res=0;clk_res<=max_res;clk_res++) {
for(clk_id=0;clk_id<=15;clk_id++) {
@ -2326,7 +2221,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") ;}
for(clk_res=0;clk_res<=max_res;clk_res++) {
for(clk_id=0;clk_id<=15;clk_id++) {
@ -2335,7 +2230,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") ;}
for(clk_res=0;clk_res<=max_res;clk_res++) {
for(clk_id=0;clk_id<=15;clk_id++) {
@ -2364,7 +2259,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
return -1;
}
}
else if (!strcmp(argv[1], "set")) {
else if (!strncmp(argv[1], "set", 3)) {
if (argc > 7) {
rc = ipmi_picmg_clk_set(intf, argc-1, &(argv[2]));
}
@ -2399,7 +2294,7 @@ uint8_t
ipmi_picmg_ipmb_address(struct ipmi_intf *intf) {
struct ipmi_rq req;
struct ipmi_rs *rsp;
uint8_t msg_data;
char msg_data;
if (!intf->picmg_avail) {
return 0;
@ -2428,53 +2323,49 @@ ipmi_picmg_ipmb_address(struct ipmi_intf *intf) {
uint8_t
picmg_discover(struct ipmi_intf *intf) {
/* 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
* not give any problems
* PICMG Extension Version 2.0 (PICMG 3.0 Revision 1.0 ATCA) to
* PICMG Extension Version 2.3 (PICMG 3.0 Revision 3.0 ATCA)
* PICMG Extension Version 4.1 (PICMG 3.0 Revision 3.0 AMC)
* PICMG Extension Version 5.0 (MTCA.0 R1.0)
*/
/* First, check if PICMG extension is available and supported */
struct ipmi_rq req;
struct ipmi_rs *rsp;
uint8_t msg_data;
uint8_t picmg_avail = 0;
char msg_data;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_PICMG;
req.msg.cmd = PICMG_GET_PICMG_PROPERTIES_CMD;
msg_data = 0x00;
req.msg.data = &msg_data;
req.msg.data_len = 1;
msg_data = 0;
if (intf->picmg_avail == 0) {
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_PICMG;
req.msg.cmd = PICMG_GET_PICMG_PROPERTIES_CMD;
msg_data = 0x00;
req.msg.data = &msg_data;
req.msg.data_len = 1;
msg_data = 0;
lprintf(LOG_DEBUG, "Running Get PICMG Properties my_addr %#x, transit %#x, target %#x",
intf->my_addr, intf->transit_addr, intf->target_addr);
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
lprintf(LOG_DEBUG,"No response from Get PICMG Properties");
} else if (rsp->ccode) {
lprintf(LOG_DEBUG,"Error response %#x from Get PICMG Properties",
rsp->ccode);
} else if (rsp->data_len < 4) {
lprintf(LOG_INFO,"Invalid Get PICMG Properties response length %d",
rsp->data_len);
} else if (rsp->data[0] != 0) {
lprintf(LOG_INFO,"Invalid Get PICMG Properties group extension %#x",
rsp->data[0]);
} else if ((rsp->data[1] & 0x0F) != PICMG_ATCA_MAJOR_VERSION
&& (rsp->data[1] & 0x0F) != PICMG_AMC_MAJOR_VERSION
&& (rsp->data[1] & 0x0F) != PICMG_UTCA_MAJOR_VERSION) {
lprintf(LOG_INFO,"Unknown PICMG Extension Version %d.%d",
(rsp->data[1] & 0x0F), (rsp->data[1] >> 4));
} else {
picmg_avail = 1;
lprintf(LOG_DEBUG, "Discovered PICMG Extension Version %d.%d",
(rsp->data[1] & 0x0f), (rsp->data[1] >> 4));
lprintf(LOG_DEBUG, "Running Get PICMG Properties my_addr %#x, transit %#x, target %#x",
intf->my_addr, intf->transit_addr, intf->target_addr);
rsp = intf->sendrecv(intf, &req);
if (rsp && !rsp->ccode) {
if ( (rsp->data[0] == 0) &&
((rsp->data[1] & 0x0F) == PICMG_ATCA_MAJOR_VERSION
|| (rsp->data[1] & 0x0F) == PICMG_AMC_MAJOR_VERSION) ) {
intf->picmg_avail = 1;
lprintf(LOG_DEBUG, "Discovered PICMG Extension %d.%d",
(rsp->data[1] & 0x0f), (rsp->data[1] >> 4));
}
} else {
if (rsp == NULL) {
lprintf(LOG_DEBUG,"No Response from Get PICMG Properties");
} else {
lprintf(LOG_DEBUG,"Error Response %#x from Get PICMG Properities", rsp->ccode);
}
}
}
return picmg_avail;
if (intf->picmg_avail == 0) {
lprintf(LOG_DEBUG, "No PICMG Extenstion discovered");
}
return intf->picmg_avail;
}

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

@ -39,13 +39,13 @@
#include <ipmitool/helper.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_raw.h>
#include <ipmitool/ipmi_fru.h>
#include <ipmitool/ipmi_strings.h>
#define IPMI_I2C_MASTER_MAX_SIZE 0x40 /* 64 bytes */
static int is_valid_param(const char *input_param, uint8_t *uchr_ptr,
const char *label);
int ipmi_spd_print(uint8_t *, int);
/* ipmi_master_write_read - Perform I2C write/read transactions
*
@ -101,11 +101,11 @@ ipmi_master_write_read(struct ipmi_intf * intf, uint8_t bus, uint8_t addr,
}
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "I2C Master Write-Read command failed");
return NULL;
}
else if (rsp->ccode) {
else if (rsp->ccode > 0) {
switch (rsp->ccode) {
case 0x81:
lprintf(LOG_ERR, "I2C Master Write-Read command failed: Lost Arbitration");
@ -130,7 +130,7 @@ ipmi_master_write_read(struct ipmi_intf * intf, uint8_t bus, uint8_t addr,
return rsp;
}
#define RAW_SPD_SIZE 512
#define RAW_SPD_SIZE 256
int
ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv)
@ -145,7 +145,7 @@ ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv)
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]");
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) {
rsp = ipmi_master_write_read(intf, i2cbus, i2caddr,
(uint8_t *)&i, 1, msize );
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read");
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=");
}
#define BUS_KW "bus="
#define CHAN_KW "chan="
int
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;
/* 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;
if (!strcmp(argv[0], BUS_KW "public"))
if (strncmp(argv[0], "bus=public", 10) == 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;
else
bus = 0;
/* handle channel= argument
* 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;
if (sscanf(argv[1], CHAN_KW "%u", &rbus) == 1)
if (sscanf(argv[1], "chan=%u", &rbus) == 1)
bus |= rbus << 4;
}
}
if ((argc - i) < 2 || !strcmp(argv[0], "help")) {
if ((argc-i) < 2 || strncmp(argv[0], "help", 4) == 0) {
rawi2c_usage();
return 0;
}
@ -262,7 +259,7 @@ ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
printbuf(wdata, wsize, "WRITE DATA");
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");
return -1;
}
@ -325,7 +322,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
int i;
uint8_t data[256];
if (argc == 1 && !strcmp(argv[0], "help")) {
if (argc == 1 && strncmp(argv[0], "help", 4) == 0) {
ipmi_raw_help();
return 0;
}
@ -340,6 +337,9 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
return -1;
}
ipmi_intf_session_set_timeout(intf, 15);
ipmi_intf_session_set_retry(intf, 1);
lun = intf->target_lun;
netfn_tmp = str2val(argv[0], ipmi_netfn_vals);
if (netfn_tmp == 0xff) {
@ -382,13 +382,13 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
rsp = intf->sendrecv(intf, &req);
if (!rsp) {
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to send RAW command "
"(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);
return -1;
}
if (rsp->ccode) {
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Unable to send RAW command "
"(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,
@ -420,7 +420,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
*/
int
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.");
return (-1);
}

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