Compare commits

..

1 Commits

113 changed files with 3997 additions and 27563 deletions

View File

@ -1,4 +1,3 @@
Duncan Laurie <duncan@iceblink.org>
Duncan Laurie <duncan@sun.com>
Fredrik <20>hrn <ohrn@chl.chalmers.se>
Jon Cassorla <jon.cassorla@newisys.com>
Jeremy Ellington <jeremy@jeremye.net>

View File

@ -1,56 +1,3 @@
version 1.8.0
* Fix IPMIv2.0 issues
* Fix chassis boot parameter support
* Add support for linear sensors
version 1.7.1
* Update bmc plugin to work with new Solaris bmc driver (new ioctl
for interface detection and new STREAMS message-based interface)
version 1.7.0
* Propogate errors correctly so exit status will be useful
* More consistent display of errors including completion code text
* Errors and debug is send to stderr now
* New "sel get" command that will print details about SEL entry
and corresponding SDR records as well as FRUs via entity association
* Improved event generator, now supports reading events from text file
* New "-o oemtype" option for specifying OEM boards
exsting types are "supermicro" and "intelwv2"
* New PEF subsystem from Tim Murphy at Dell
* New "bmc" plugin for Solaris 10 x86
* Many bugfixes and contributed patches
version 1.6.2
* Support for Supermicro BMC OEM authentication method
version 1.6.1
* Fix minor problem with LAN parameter setting
version 1.6.0
* Add a README file
* Add Solaris x86 interface plugin
* Add support for building Solaris packages
* Fix segfault when doing "sel list" (from Matthew Braithwaite)
* Fix "chassis identify" on some BMCs (from ebrower@sourceforge)
* Add command "bmc info" and related output (from ebrower@sourceforge)
* Add support for IPMIv2 and Serial-over-LAN from Jeremy at Newisys
* Add support for building RPMs as non-root user
* Add new "shell" and "exec" commands
* Lots of other contributed patches
version 1.5.9
* 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
* Add README for rrdtool scripts in contrib directory
* Improve lan interface retry handling
* Support prompting for password or reading from environment
* Move chaninfo command into channel subcommand
* Fix reservation ID handling when two sessions open to BMC
* Fix reading of large FRU data
* Add configure option for changing binary to ipmiadm for Solaris
* Fix compile problem on Solaris 8
version 1.5.8
* Enable static compilation of interfaces
* Fix types to be 64-bit safe

View File

@ -32,52 +32,14 @@
# in the design, construction, operation or maintenance of any nuclear
# facility.
DOCDIR = $(DESTDIR)/$(datadir)/doc/$(PACKAGE)
DOCLIST = README COPYING AUTHORS ChangeLog
EXTRA_DIST = $(DOCLIST) \
debian/changelog debian/control debian/copyright \
debian/dirs debian/docs debian/rules
AUTOMAKE_OPTIONS = dist-bzip2
EXTRA_DIST = ipmitool.spec.in AUTHORS COPYING ChangeLog debian/*
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure configure-stamp \
config.guess config.sub depcomp install-sh ltmain.sh missing \
mkinstalldirs config.h.in stamp-h.in \
$(distdir).tar.gz $(distdir).tar.bz2
mkinstalldirs config.h.in stamp-h.in $(distdir).tar.gz
SUBDIRS = lib src include doc contrib control
SUBDIRS = libltdl lib src include doc contrib
dist-hook:
cp control/ipmitool.spec $(distdir)
install-data-local:
mkdir -p $(DOCDIR)
install -m 644 $(DOCLIST) $(DOCDIR)
.PHONY: pkg
pkg: PKG := ipmitool-@VERSION@-@OS@-@ARCH@
pkg: control/pkginfo
$(STRIP) src/ipmitool
$(STRIP) src/ipmitool
(cd control ; pkgmk -o -d /tmp)
pkgtrans -s /tmp $(PKG) ipmitool
gzip -c /tmp/$(PKG) > $(PKG).gz
-rm -rf /tmp/ipmitool /tmp/$(PKG)
BUILDDIR = ${shell cd $(top_builddir) ; pwd | sed -e 's,^[^:\\/]:[\\/],/,'}
SRCDIR = ${shell cd $(top_srcdir) ; pwd | sed -e 's,^[^:\\/]:[\\/],/,'}
RPMDIR = $(BUILDDIR)/rpmbuild
.PHONY: rpm
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:
-rm -rf $(RPMDIR)
dist-hook: ipmitool.spec
cp ipmitool.spec $(distdir)

View File

@ -1,309 +0,0 @@
ipmitool
Duncan Laurie
duncan@iceblink.org
Overview
========
ipmitool is a utility for managing and configuring devices that support
the Intelligent Platform Management Interface. IPMI is an open standard
for monitoring, logging, recovery, inventory, and control of hardware
that is implemented independent of the main CPU, BIOS, and OS. The
service processor (or Baseboard Management Controller, BMC) is the brain
behind platform management and its primary purpose is to handle the
autonomous sensor monitoring and event logging features.
The ipmitool program provides a simple command-line interface to this BMC.
It features the ability to read the sensor data repository (SDR) and print
sensor values, display the contents of the System Event Log (SEL), print
Field Replaceable Unit (FRU) inventory information, read and set LAN
configuration parameters, and perform remote chassis power control.
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 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
under a BSD license and give others the chance to make use of it.
ipmitool was not written to provide large-scale (aka Enterprise) management
application functionality. The functionality that ipmitool proivides is
easily accomplished by sending simple IPMI request messages and parsing
the returned response. It is intended to be used by system administrators
who like the simplicity and scriptability of command-line utilities, as
well as those debugging or developing their own BMC implementations.
Requirements
============
Obviously the largest requirement is hardware with a service processor
that supports the IPMI specification. Many x86-based servers are now
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
access through the System Interface or over the LAN. (or serial, but
currently ipmitool does not support the serial interface)
System Interface
----------------
There are multiple types of system interfaces, but they are all similar
enough to allow a single well-designed driver to support them all.
Different types of system interfaces include Keyboard Controller Style
(KCS), Block Transfer (BT), System Management Interface Chip (SMIC) and
SMBus. Different hardware vendors will have different preference and
implementations.
On Linux the OpenIPMI kernel driver should support all of these system
interfaces and it should be a simple matter of loading the right
kernel modules and setting up the device node to use it. The driver
module names vary slightly in different kernel versions, but for all
releases you need these two modules:
ipmi_msghandler: incoming and outgoing message handler
ipmi_devintf: character device interface to IPMI driver
For 2.4.x and early 2.6.x kernels you need to choose a module based on
the type of system interface your hardware supports. For example:
ipmi_kcs_drv: Keyboard Controller Style driver
More recent 2.6.x kernels have combined these into a single module:
ipmi_si: a universal IPMI system interface driver
See the documentation that comes with your distribution and/or kernel
for more information on what kernel modules are required. Once the
required modules are loaded and the driver has found a suitable system
interface to the BMC then you need to ensure the device node at
/dev/ipmi0 is pointing at the correct major number.
This is because OpenIPMI is given a dynamically assigned major number
when it is loaded, but depending on what other modules are present
this number may be anywhere from 254 on down. The easiest way to tell
is to check the output of /proc/devices and see what major number the
"ipmidev" device is assigned to.
There is a sample script included with ipmitool called ipmi.init that
can be used to automate this process at bootup.
LAN Interface
-------------
This is often referred to as "IPMI-over-LAN" and defines how IPMI messages
can be sent to and from the BMC encapsulated in Remote Management Control
Protocol (RMCP) packets which are then transferred as UDP datagrams.
IPMI-over-LAN is only supported with version 1.5 and higher of the IPMI
specification. The RMCP packet format is defined by the Alert Standard
Forum, and it has been followed up with the RMCP+ protocol that adds
encryption and payload support. The IPMIv2 specification was updated
accordingly to to support the RMCP+ protocol and brings with it enhanced
security with encryption as well as support for Serial over LAN.
There are different types of LAN interfaces as well. Some systems have
shared management networks where the NIC will intercept UDP packets to
port 623 and redirect them to the BMC over SMBUS. This type of LAN
interface requires that the BMC be configured with the same settings that
the system uses. It also suffers from an increased security risk just by
the nature of sharing that interface with normal traffic.
I have also seen bugs in some implementations that have rendered the
IPMI-over-LAN feature "dangerous" to enable in some situations. (in
particular there can be an issue with RPC because it will sometimes choose
to use port 623 and you will lose response packets...)
There is a sample shell script included with ipmitool called bmclanconf
that can be used to simplify the LAN settings configuration process using
the System Interface to configure the settings. In some cases the
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 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.
Usage
=====
All invocations of ipmitool require specifying an interface to use, unless
you want to use the default interface as set at compile time. Each call
must also specify a command to run. You can see the list of supported
interfaces and which is default as well as a list of top level commands in
the usage output available with the -h option:
usage: ipmitool [options...] <command>
-h This help
-V Show version information
-v Verbose (can use multiple times)
-c Display output in comma separated format
-I intf Interface to use
-H hostname Remote host name for LAN interface
-p port Remote RMCP port [default=623]
-L level Remote session privilege level [default=USER]
-A authtype Force use of authtype NONE, PASSWORD, MD2 or MD5
-U username Remote session username
-P password Remote session password
-f file Read remote session password from file
-a Prompt for remote password
-E Read password from IPMI_PASSWORD environment variable
-m address Set local IPMB address
-t address Bridge request to remote target address
Interfaces:
open Linux OpenIPMI Interface [default]
imb Intel IMB Interface
lan IPMI v1.5 LAN Interface
lanplus IPMI v2.0 RMCP+ LAN Interface
Commands:
raw Send a RAW IPMI request and print response
lan Configure LAN Channels
chassis Get chassis status and set power state
event Send pre-defined events to BMC
bmc Print BMC status and configure global enables
sdr Print Sensor Data Repository entries and readings
sensor Print detailed sensor information
fru Print built-in FRU and scan SDR for FRU locators
sel Print System Evelnt Log
sol Configure IPMIv2.0 Serial-over-LAN
user Configure BMC users
channel Configure BMC channels
session Print session information
shell Launch interactive IPMI shell
exec Run list of commands from file
set Set runtime variable for shell and exec
Commands
========
More help on the supported commands can be found by running them with the
help argument, for example "chassis help". There are a few commands with
special meaning:
> shell: This command will launch an shell interface to the ipmitool
command set. You can use this for interactively entering commands to
monitor system status. An example session:
# ipmitool -I open shell
ipmitool> chassis status
System Power : off
Power Overload : false
Power Interlock : inactive
Main Power Fault : false
Power Control Fault : false
Power Restore Policy : always-off
Last Power Event : command
Chassis Intrusion : active
Front-Panel Lockout : inactive
Drive Fault : false
Cooling/Fan Fault : false
ipmitool> user list 7
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
1 true false true ADMINISTRATOR
ipmitool> exit
> exec: This command will read a text file and execute ipmitool commands
in sequence. It can be used for scriptable commands:
# cat lansetup.scr
lan set 7 ipsrc static
lan set 7 ipaddr 10.1.1.10
lan set 7 netmask 255.255.255.0
lan set 7 defgw ipaddr 10.1.1.254
# ipmitool -I open exec lansetup.scr
Setting LAN IP Address to 10.1.1.10
Setting Lan Subnet Mask to 255.255.255.0
Setting Lan Default Gateway IP to 10.1.1.254
> set: This command can be used by the shell and exec modes to configure
various session parameters:
hostname <host> Session hostname
username <user> Session username
password <pass> Session password
privlvl <level> Session privilege level force
authtype <type> Authentication type force
localaddr <addr> Local IPMB address
targetaddr <addr> Remote target IPMB address
port <port> Remote RMCP port
csv [level] enable output in comma separated format
verbose [level] Verbose level
# cat getstatus.scr
set hostname sf-v20z-1
set password admin
chassis status
# ipmitool -I lan exec getstatus.scr
Set session hostname to lx50
Set session password
System Power : off
Power Overload : false
Power Interlock : inactive
Main Power Fault : false
Power Control Fault : false
Power Restore Policy : always-off
Last Power Event : command
Chassis Intrusion : active
Front-Panel Lockout : inactive
Drive Fault : false
Cooling/Fan Fault : false
ipmievd
=======
Included with ipmitool is another utility called ipmievd that is a daemon
which will listen for events from the BMC that are being sent to the SEL
and also log those messages to syslog. By default when run (as root) with
no arguments it will daemonize and poll on the OpenIPMI device waiting for
an event notification. Upon receipt of an event it will log it to syslog
with the LOG_LOCAL4 facility. You can test ipmievd by sending test events
over the LAN interface with ipmitool:
remote# ipmievd
local$ ipmitool -I lan -H lx50 -P admin event help
usage: event <num>
1 : Temperature - Upper Critical - Going High
2 : Voltage Threshold - Lower Critical - Going Low
3 : Memory - Correctable ECC
local$ ipmitool -I lan -H lx50 -P admin event 1
Sending Temperature - Upper Critical - Going High event to BMC
local$ ipmitool -I lan -H lx50 -P admin event 2
Sending Voltage Threshold - Lower Critical - Going Low event to BMC
local$ ipmitool -I lan -H lx50 -P admin event 3
Sending Memory - Correctable ECC event to BMC
remote# tail /var/log/messages (timestamps removed)
ipmievd: Waiting for events...
ipmievd: Temperature Sensor 30 - Upper Critical - going high
ipmievd: Voltage Sensor 60 - Lower Critical - going low
ipmievd: Memory Sensor 01 - Correctable ECC
Resources
=========
IPMItool homepage
http://ipmitool.sourceforge.net
IPMItool manpage
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
http://www.intel.com/design/servers/ipmi/spec.htm
OpenIPMI project: Linux IPMI kernel driver and userland library
http://openipmi.sourceforge.net

View File

@ -35,7 +35,7 @@
# facility.
aclocal
libtoolize --automake --copy
libtoolize --automake --copy --ltdl
autoheader
automake --foreign --add-missing --copy

View File

@ -2,46 +2,70 @@ dnl
dnl autoconf for ipmitool
dnl
AC_INIT([src/ipmitool.c])
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([ipmitool], [1.8.0])
AM_INIT_AUTOMAKE([ipmitool], [1.5.8])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_SRCDIR([src/ipmitool.c])
AC_PREREQ(2.50)
IPMITOOL_PKG=ipmitool
AC_SUBST(IPMITOOL_PKG)
AC_SUBST(ac_configure_args)
dnl check for requirements
dnl check for programs
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_CHECK_PROG([RPMBUILD], [rpmbuild], [rpmbuild], [rpm])
AC_CHECK_PROG([SED], [sed], [sed])
AC_CHECK_PROG(SED, sed, sed)
dnl setup libtool
AC_LIB_LTDL
AC_LIBTOOL_DLOPEN
AC_LIBLTDL_CONVENIENCE
AM_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --silent"
AC_SUBST(INCLTDL)
AC_SUBST(LIBLTDL)
AC_CONFIG_SUBDIRS(libltdl)
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(socket, socket, ,
[AC_CHECK_LIB(nsl, socket, LIBS="$LIBS -lsocket -lnsl", , -lsocket)])
dnl check for headers
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h sys/ioctl.h sys/stat.h unistd.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/socket.h])
AC_CHECK_HEADERS([sys/byteorder.h byteswap.h])
dnl check for typedefs, structs, and compiler options
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
dnl check for lib functions
AC_FUNC_MALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STAT
AC_FUNC_STRTOD
AC_CHECK_FUNCS([alarm gethostbyname socket select])
AC_CHECK_FUNCS([memmove memset strchr strdup strerror])
AC_CHECK_FUNCS([getpassphrase])
CFLAGS="$CFLAGS -fno-strict-aliasing"
dnl check for byteswap functionality
AC_CHECK_HEADERS([sys/byteorder.h byteswap.h])
AM_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --silent"
dnl set kernel directory for openipmi header files
AC_ARG_WITH([kerneldir],
[[ --with-kerneldir=DIR Set kernel path to DIR]],
[kerneldir="$withval"],
[kerneldir="/usr/src/linux-2.4"])
CFLAGS="$CFLAGS -I${kerneldir}/include"
AC_SUBST(CFLAGS)
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket], [],
[AC_CHECK_LIB([nsl], [socket],
[LIBS="$LIBS -lsocket -lnsl"], [], [-lsocket])])
have_openipmi=no
AC_CHECK_HEADER([linux/ipmi.h],
[have_openipmi=yes],
[AC_MSG_WARN([Unable to find OpenIPMI header files])])
if test "x$prefix" = "xNONE"; then
prefix="$ac_default_prefix"
@ -51,273 +75,103 @@ if test "x$exec_prefix" = "xNONE"; then
exec_prefix="$prefix"
fi
dnl set some things so we build with GNU tools on Solaris
case "$host_os" in
solaris*)
MAKE=gmake
STRIP=gstrip
LD=gld
AR=gar
# openssl libs are in /usr/sfw/lib on solaris 10
LIBS="$LIBS -R/usr/sfw/lib"
# disable the linux-specific interfaces
# and bmc on SPARC (there is no bmc driver for SPARC)
if [[ `mach -p` = sparc ]]; then
enable_intf_bmc=no
else
enable_intf_bmc=yes
fi
enable_intf_imb=no
enable_intf_open=no
enable_ipmievd=no
enable_ipmishell=no
;;
*cygwin*)
# disable the linux and solaris-specific interfaces
enable_intf_imb=no
enable_intf_open=no
enable_intf_lipmi=no
enable_intf_bmc=no
enable_ipmievd=no
enable_ipmishell=no
;;
*darwin*)
# disable the linux and solaris-specific interfaces
enable_intf_imb=no
enable_intf_open=no
enable_intf_lipmi=no
enable_intf_bmc=no
enable_ipmived=no
enable_ipmishell=no
;;
esac
dnl enable plugins for interfaces
AC_ARG_WITH([plugin-path],
[[ --with-plugin-path=DIR Set plugin path to DIR]],
[pluginpath="$withval"],
[pluginpath="${exec_prefix}/lib/ipmitool"])
AC_SUBST(ARCH, $host_cpu)
AC_SUBST(OS, $host_os)
AC_SUBST(PSTAMP, $host)
AC_SUBST(BASEDIR, $prefix)
AC_DEFINE_UNQUOTED(PLUGIN_PATH, "$pluginpath", "IPMI interface plugin path")
AC_SUBST(pluginpath)
dnl check for OpenSSL functionality
AC_ARG_ENABLE([internal-md5],
[AC_HELP_STRING([--enable-internal-md5],
[enable internal MD5 library [default=no]])],
[], [enable_internal_md5=no])
STATIC_INTF_LIST=
STATIC_INTF=
STATIC_INTF_EXT=
STATIC_INTF_LIB=
AC_CHECK_LIB([crypto], [EVP_aes_128_cbc],
[if test "x$enable_internal_md5" != "xyes"; then
have_crypto=yes; LIBS="$LIBS -lcrypto"
fi], [have_crypto=no], [-lcrypto])
AC_CHECK_LIB([crypto], [MD5_Init],
[if test "x$enable_internal_md5" != "xyes"; then
if test "x$have_crypto" != "xyes"; then
LIBS="$LIBS -lcrypto"
have_md5=yes
fi
AC_DEFINE(HAVE_CRYPTO_MD5, [1], [Define to 1 if libcrypto supports MD5.])
fi], [], [-lcrypto])
AC_CHECK_LIB([crypto], [MD2_Init],
[if test "x$enable_internal_md5" != "xyes"; then
if test "x$have_crypto" != "xyes" && test "x$have_md5" != "xyes"; then
LIBS="$LIBS -lcrypto"
have_md2=yes
fi
AC_DEFINE(HAVE_CRYPTO_MD2, [1], [Define to 1 if libcrypto supports MD2.])
fi], [], [-lcrypto])
dnl enable IPMIv1.5 LAN interface
PLUGIN_INTF_LAN=
STATIC_INTF_LAN=
LDFLAGS_INTF_LAN=
AC_ARG_ENABLE([intf-lan],
[AC_HELP_STRING([--enable-intf-lan],
[enable IPMIv1.5 LAN interface [default=yes]])],
[], [enable_intf_lan=yes])
if test "x$enable_intf_lan" = "xstatic" || test "x$enable_intf_lan" = "xplugin"; then
enable_intf_lan=yes
fi
if test "x$enable_intf_lan" = "xyes"; then
AC_DEFINE(IPMI_INTF_LAN, [1], [Define to 1 to enable LAN IPMIv1.5 interface.])
AC_SUBST(INTF_LAN, [lan])
AC_SUBST(INTF_LAN_LIB, [libintf_lan.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lan/libintf_lan.la"
fi
dnl enable IPMIv2.0 RMCP+ LAN interface
AC_ARG_ENABLE([intf-lanplus],
[AC_HELP_STRING([--enable-intf-lanplus],
[enable IPMIv2.0 RMCP+ LAN interface [default=auto]])],
[if test "x$enable_intf_lanplus" != "xno" && test "x$have_crypto" != "xyes"; then
echo "** The lanplus interface requires an SSL library with EVP_aes_128_cbc defined."
enable_intf_lanplus=no
[[ --enable-intf-lan enable IPMI-over-LAN interface [default=yes]]],
[if test "x$enableval" = "xyes"; then
AC_SUBST(INTF_LAN,lan)
PLUGIN_INTF_LAN="libintf_lan.la"
LDFLAGS_INTF_LAN="-rpath $pluginpath -avoid-version"
DYNAMIC_INTF_LIST="lan $DYNAMIC_INTF_LIST"
elif test "x$enableval" = "xstatic"; then
AC_SUBST(INTF_LAN,lan)
STATIC_INTF_LAN="libintf_lan.la"
STATIC_INTF_LIST="lan $STATIC_INTF_LIST"
fi],
[enable_intf_lanplus=$have_crypto])
if test "x$enable_intf_lanplus" = "xstatic" || test "x$enable_intf_lanplus" = "xplugin"; then
enable_intf_lanplus=yes
fi
if test "x$enable_intf_lanplus" = "xyes"; then
AC_DEFINE(IPMI_INTF_LANPLUS, [1], [Define to 1 to enable LAN+ IPMIv2 interface.])
AC_SUBST(INTF_LANPLUS, [lanplus])
AC_SUBST(INTF_LANPLUS_LIB, [libintf_lanplus.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lanplus/libintf_lanplus.la"
else
enable_intf_lanplus=no
fi
[AC_SUBST(INTF_LAN,lan)
PLUGIN_INTF_LAN="libintf_lan.la"
LDFLAGS_INTF_LAN="-rpath $pluginpath -avoid-version"
DYNAMIC_INTF_LIST="lan $DYNAMIC_INTF_LIST"
])
AC_SUBST(PLUGIN_INTF_LAN)
AC_SUBST(STATIC_INTF_LAN)
AC_SUBST(LDFLAGS_INTF_LAN)
dnl look for OpenIPMI header files
AC_ARG_WITH([kerneldir],
[AC_HELP_STRING([--with-kerneldir=DIR],
[set kernel include path to DIR])],
[if test "x$with_kerneldir" = "xyes"; then
with_kerneldir="/lib/modules/`uname -r`/build"
fi
CFLAGS="$CFLAGS -I ${with_kerneldir}/include"
AC_SUBST(CFLAGS)
if test -s ${with_kerneldir}/include/linux/version.h ; then
kernelver=`grep UTS_RELEASE ${with_kerneldir}/include/linux/version.h | \
sed 's/^\#define UTS_RELEASE \"\(2\.[0-9]\)\..*/\1/'`
if test "x$kernelver" = "x2.6"; then
CPPFLAGS="$CPPFLAGS -D__user="
AC_SUBST(CPPFLAGS)
fi
fi])
AC_CHECK_HEADER([linux/ipmi.h],
[AC_DEFINE(HAVE_OPENIPMI_H, [1],
[Define to 1 if you have the <linux/ipmi.h> header file.])],
[echo "** Unable to find OpenIPMI header files. Using internal version."])
dnl enable Linux OpenIPMI interface
PLUGIN_INTF_OPEN=
STATIC_INTF_OPEN=
LDFLAGS_INTF_OPEN=
AC_ARG_ENABLE([intf-open],
[AC_HELP_STRING([--enable-intf-open],
[enable Linux OpenIPMI interface [default=auto]])],
[], [enable_intf_open=yes])
if test "x$enable_intf_open" = "xstatic" || test "x$enable_intf_open" = "xplugin"; then
enable_intf_open=yes
fi
if test "x$enable_intf_open" = "xyes"; then
AC_DEFINE(IPMI_INTF_OPEN, [1], [Define to 1 to enable Linux OpenIPMI interface.])
AC_SUBST(INTF_OPEN, [open])
AC_SUBST(INTF_OPEN_LIB, [libintf_open.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB open/libintf_open.la"
fi
[[ --enable-intf-open enable OpenIPMI device interface [default=no]]],
[if test "x$enableval" = "xyes"; then
if test "x$have_openipmi" = "xyes"; then
AC_SUBST(INTF_OPEN,open)
PLUGIN_INTF_OPEN="libintf_open.la"
LDFLAGS_INTF_OPEN="-rpath $pluginpath -avoid-version"
DYNAMIC_INTF_LIST="open $DYNAMIC_INTF_LIST"
else
echo "** Unable to build OpenIPMI interface support!"
exit 1
fi
elif test "x$enableval" = "xstatic"; then
AC_SUBST(INTF_OPEN,open)
STATIC_INTF_OPEN="libintf_open.la"
STATIC_INTF_LIST="open $STATIC_INTF_LIST"
fi])
AC_SUBST(PLUGIN_INTF_OPEN)
AC_SUBST(STATIC_INTF_OPEN)
AC_SUBST(LDFLAGS_INTF_OPEN)
dnl enable Intel IMB interface
AC_ARG_ENABLE([intf-imb],
[AC_HELP_STRING([--enable-intf-imb],
[enable Intel IMB driver interface [default=auto]])],
[], [enable_intf_imb=yes])
if test "x$enable_intf_imb" = "xstatic" || test "x$enable_intf_imb" = "xplugin"; then
enable_intf_imb=yes
fi
if test "x$enable_intf_imb" = "xyes"; then
AC_DEFINE(IPMI_INTF_IMB, [1], [Define to 1 to enable Intel IMB interface.])
AC_SUBST(INTF_IMB, [imb])
AC_SUBST(INTF_IMB_LIB, [libintf_imb.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB imb/libintf_imb.la"
fi
for name in $STATIC_INTF_LIST; do
STATIC_INTF="$STATIC_INTF { \"intf_${name}\", ${name}_intf_setup },";
STATIC_INTF_EXT="$STATIC_INTF_EXT extern int ${name}_intf_setup(struct ipmi_intf ** intf);";
STATIC_INTF_LIB="$STATIC_INTF_LIB \$(top_builddir)/src/plugins/${name}/libintf_${name}.la";
done
dnl enable Solaris LIPMI interface
AC_CHECK_HEADER([sys/lipmi/lipmi_intf.h], [have_lipmi=yes], [have_lipmi=no])
AC_ARG_ENABLE([intf-lipmi],
[AC_HELP_STRING([--enable-intf-lipmi],
[enable Solaris 9 x86 IPMI interface [default=no]])],
[if test "x$enable_intf_lipmi" != "xno" && test "x$have_lipmi" != "xyes"; then
echo "** Unable to build Solaris 9 x86 IPMI interface support!"
enable_intf_lipmi=no
fi],
[enable_intf_lipmi=no])
if test "x$enable_intf_lipmi" = "xstatic" || test "x$enable_intf_lipmi" = "xplugin"; then
enable_intf_lipmi=yes
fi
if test "x$enable_intf_lipmi" = "xyes"; then
AC_DEFINE(IPMI_INTF_LIPMI, [1], [Define to 1 to enable Solaris 9 LIPMI interface.])
AC_SUBST(INTF_LIPMI, [lipmi])
AC_SUBST(INTF_LIPMI_LIB, [libintf_lipmi.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lipmi/libintf_lipmi.la"
fi
AC_SUBST(STATIC_INTF)
AC_SUBST(STATIC_INTF_EXT)
AC_SUBST(STATIC_INTF_LIB)
dnl enable Solaris BMC interface
AC_ARG_ENABLE([intf-bmc],
[AC_HELP_STRING([--enable-intf-bmc],
[enable Solaris 10 x86 IPMI interface [default=auto]])],,
[enable_intf_bmc=no])
if test "x$enable_intf_bmc" = "xstatic" || test "x$enable_intf_bmc" = "xplugin"; then
enable_intf_bmc=yes
fi
if test "x$enable_intf_bmc" = "xyes"; then
AC_DEFINE(IPMI_INTF_BMC, [1], [Define to 1 to enable Solaris 10 BMC interface.])
AC_SUBST(INTF_BMC, [bmc])
AC_SUBST(INTF_BMC_LIB, [libintf_bmc.la])
IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB bmc/libintf_bmc.la"
fi
AC_SUBST(IPMITOOL_INTF_LIB)
dnl check for readline library to enable ipmi shell
AC_ARG_ENABLE([ipmishell],
[AC_HELP_STRING([--enable-ipmishell],
[enable IPMI shell interface [default=yes]])],
[], [enable_ipmishell=yes])
if test "x$enable_ipmishell" = "xyes"; then
AC_SEARCH_LIBS([readline], [readline], [have_readline=yes])
AC_SEARCH_LIBS([initscr], [curses ncurses], [have_curses=yes])
if test "x$have_curses" = "xyes" && test "x$have_readline" = "xyes"; then
AC_DEFINE(HAVE_READLINE, [1], [Define to 1 if readline present.])
fi
fi
dnl enable IPMI Event Daemon
AC_ARG_ENABLE([ipmievd],
[AC_HELP_STRING([--enable-ipmievd],
[enable IPMI Event daemon [default=auto]])],
[], [enable_ipmievd=yes])
AM_CONDITIONAL(IPMIEVD, [test "x$enable_ipmievd" = "xyes"])
if test "x$enable_ipmievd" = "xyes"; then
AC_SUBST(IPMIEVD_BIN, [ipmievd])
fi
[[ --enable-ipmievd enable IPMI event daemon [default=no]]],,enable_ipmievd=no)
AM_CONDITIONAL(IPMIEVD, test "x$enable_ipmievd" = "xyes")
dnl Enable -Wall -Werror
AC_ARG_ENABLE([buildcheck],
[AC_HELP_STRING([--enable-buildcheck],
[enable -Wall -Werror for build testing [default=no]])],
[if test "x$enable_buildcheck" != "xno"; then
CFLAGS="$CFLAGS -Wall -Werror"
fi], [])
AC_SUBST(CFLAGS)
dnl Generate files for build
AC_CONFIG_FILES([Makefile
AC_CONFIG_FILES([ipmitool.spec
Makefile
doc/Makefile
contrib/Makefile
control/Makefile
control/pkginfo
control/prototype
control/ipmitool.spec
lib/Makefile
include/Makefile
include/ipmitool/Makefile
src/Makefile
src/plugins/ipmi_intf_static.c
src/plugins/Makefile
src/plugins/lan/Makefile
src/plugins/lanplus/Makefile
src/plugins/open/Makefile
src/plugins/imb/Makefile
src/plugins/bmc/Makefile
src/plugins/lipmi/Makefile])
src/plugins/open/Makefile])
AC_OUTPUT
AC_MSG_RESULT([])
AC_MSG_RESULT([ipmitool $VERSION])
AC_MSG_RESULT([$PACKAGE $VERSION])
AC_MSG_RESULT([])
AC_MSG_RESULT([Interfaces])
AC_MSG_RESULT([ lan : $enable_intf_lan])
AC_MSG_RESULT([ lanplus : $enable_intf_lanplus])
AC_MSG_RESULT([ open : $enable_intf_open])
AC_MSG_RESULT([ imb : $enable_intf_imb])
AC_MSG_RESULT([ bmc : $enable_intf_bmc])
AC_MSG_RESULT([ lipmi : $enable_intf_lipmi])
AC_MSG_RESULT([])
AC_MSG_RESULT([Extra tools])
AC_MSG_RESULT([ ipmievd : $enable_ipmievd])
AC_MSG_RESULT([ Interface Path........ : $pluginpath])
AC_MSG_RESULT([ Static Interfaces..... : $STATIC_INTF_LIST])
AC_MSG_RESULT([ Dynamic Interfaces.... : $DYNAMIC_INTF_LIST])
AC_MSG_RESULT([ Build ipmievd......... : $enable_ipmievd])
AC_MSG_RESULT([])

View File

@ -34,7 +34,5 @@
MAINTAINERCLEANFILES = Makefile.in
dist_pkgdata_DATA = bmclanconf README \
ipmi.init.basic ipmi.init.redhat \
collect_data.sh create_rrds.sh create_webpage_compact.sh create_webpage.sh
EXTRA_DIST = collect_data.sh create_rrds.sh create_webpage.sh

View File

@ -1,95 +0,0 @@
Graphs for ipmitool
-------------------
This is a set of shell-scripts to quickly create a webpage with pretty graphs!
Prerequisites are a webserver with cgi-bin support and RRDtool, a data
collection and graphing utility you can get here:
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/
First, decide on a directory where to store the RRDtool database files and make
sure it exists. The user that will run the cronjob to collect updates must have
write permissions in this dir.
Next, you'll need to edit some variables at the top of each script.
Common to all scripts:
hostname Override this if you are collecting data from a remote host,
or if the $HOSTNAME variable is incorrect.
ipmi_cmd Command line used to call ipmitool. Default is to collect
data from the local server using OpenIPMI.
If you want to collect data from a remote host, add the
-I lan, -H, -U and -P options as necessary.
BIG NOTE! I do not recommend using remote data collection since
you'll have to store the password in the script. If you do,
make sure unauthorized people can't read or execute the scripts
or they'll be able to wreak havoc on your server.
rrd_dir Enter the dir where to store the RRDtool database here.
Now you can get the data collection going. Run create_rrds.sh to create the
RDDtool database, you'll find one .rrd file per sensor in the designated dir.
Add a line to your crontab that executes collect_data.sh every 5 minutes.
Something like this:
*/5 * * * * /usr/local/bin/collect_data.sh
If you are a Solaris user you'll have to write the more verbose:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/collect_data.sh
Finally it's time to create the webpage, begin with editing some more variables
in the create_webpage.sh and/or create_webpage_compact.sh scripts:
rrdcgi Full path to the rrdcgi executable.
img_dir Directory to store the graph images. This path must be within
the document root and writable by the web server user.
Example: /usr/local/apache2/htdocs/images/graphs
web_dir Relative path of the URL where the images will show up
on the web server.
Example: With the img_dir path above the corresponding web_dir
would be /images/graphs
graph_width Size of the graph area in pixels (excluding title, legends etc.)
graph_height
graph_daily Decide which of daily, weekly and monthly graphs you want
graph_weekly included on the page.
graph_monthly
Finally run the create webpage script and store the output as a cgi-script and
don't forget to make it executable.
Example:
create_webpage.sh > /usr/local/apache2/cgi-bin/my_ipmi_graphs.cgi
chmod 755 /usr/local/apache2/cgi-bin/my_ipmi_graphs.cgi
Now you can surf to http://my.server.com/cgi-bin/my_ipmi_graphs.cgi and enjoy!
The difference between create_webpage.sh and create_webpage_compact.sh is that
the first script displays sensor thresholds in the graphs. The second script
collects all sensors that measure the same unit into the same graph thus
producing a lot fewer graphs.
Note, RRDtool sometimes scales the graphs such that the sensor thresholds
fall outside the visible area.
Happy graphing!

View File

@ -1,313 +0,0 @@
#!/bin/bash
#
# 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.
#
# You acknowledge that this software is not designed or intended for use
# in the design, construction, operation or maintenance of any nuclear
# facility.
#
# This script is designed for Sun Fire LX50, V60x and V65x systems.
# It may work with other setups as long as you use the correct channel
# and interface settings. It can be used on the V20z as long as you
# specify network settings on the command line.
#
# If the wrong channel is used you could lose network access to the
# box because your BMC will be sending out bad Gratuitous ARP packets
# with the wrong MAC address. You will need to use a console or
# override your local ARP cache with the correct addr.
usage ()
{
echo "
usage: $0 -c <chan> -i <interface> [options]
$0 -c <chan> [-v|w|x|y|z address] [options]
-c channel Which BMC channel to configure [-c help for more info]
-i interface Auto-configure BMC based on interface network settings
-v address Use specified IP address
-w address Use specified Netmask address
-x address Use specified MAC address
-y address Use specified Gateway IP address
-z address Use specified Gateway MAC address
-m interface Which IPMI interface to use [default linux=open solaris=lipmi]
-p password Set BMC channel password
-s string Set SNMP community string
-a interval Set Gratuitous ARP interval, off=0, default=4
-r Reset BMC channel, zero all network settings, disable
-d Debug mode, does not make any changes
"
exit 0;
}
channel_usage ()
{
echo "
Sun Fire V60x and V65x - Linux 2.4
eth0 = channel 6, top
eth1 = channel 7, bottom
Sun Fire V60x and V65x - Linux 2.6
eth0 = channel 7, bottom
eth1 = channel 6, top
Sun Fire V60x and V65x - Solaris x86
e1000g0 = channel 7, bottom
e1000g1 = channel 6, top
Sun LX50 - Linux
eth0 = channel 7, bottom
eth1 = channel 6, top
Sun LX50 - Solaris x86
le0 = channel 7, bottom
le1 = channel 6, top
Sun Fire V20z (-i option does not apply)
channel 1
"
exit 0
}
hex_to_ip ()
{
test $# -ge 1 || return;
local HEX B1 B2 B3 B4;
HEX=`echo $1 | tr '[:lower:]' '[:upper:]'`;
H1=`echo $HEX | cut -c1-2`
H2=`echo $HEX | cut -c3-4`
H3=`echo $HEX | cut -c5-6`
H4=`echo $HEX | cut -c7-8`
B1=`echo 10 o 16 i $H1 p | dc`
B2=`echo 10 o 16 i $H2 p | dc`
B3=`echo 10 o 16 i $H3 p | dc`
B4=`echo 10 o 16 i $H4 p | dc`
echo "$B1.$B2.$B3.$B4"
}
ipmitool_lan_set ()
{
[ $# -lt 1 ] && return
local PARAM=$1
local VALUE=
[ $# -ge 2 ] && VALUE=$2
if [ $DEBUG -gt 0 ]; then
echo "Setting LAN parameter $PARAM $VALUE"
echo "$IPMITOOL -I $IPMIINTF lan set $CHANNEL $PARAM $VALUE"
return
fi
$IPMITOOL -I $IPMIINTF lan set $CHANNEL $PARAM $VALUE
}
ipmitool_lan_reset ()
{
ipmitool_lan_set "ipsrc" "static"
ipmitool_lan_set "ipaddr" "0.0.0.0"
ipmitool_lan_set "netmask" "0.0.0.0"
ipmitool_lan_set "macaddr" "00:00:00:00:00:00"
ipmitool_lan_set "defgw ipaddr" "0.0.0.0"
ipmitool_lan_set "defgw macaddr" "00:00:00:00:00:00"
ipmitool_lan_set "password"
ipmitool_lan_set "snmp" "public"
ipmitool_lan_set "arp generate" "off"
ipmitool_lan_set "access" "off"
exit 0
}
DEBUG=0
LINUX=0
SOLARIS=0
CHANNEL=0
IFACE=
PASSWORD=
SNMP=
GRATARP=8
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin
case `uname -s` in
Linux)
IPMIINTF=open
IPMITOOL=ipmitool
PING=ping
IFCONFIG=ifconfig
ARP=arp
ROUTE=route
;;
SunOS)
IPMIINTF=lipmi
IPMITOOL=ipmiadm
PING=ping
IFCONFIG=ifconfig
ARP=arp
ROUTE=route
;;
*)
echo "Invalid OS!"
exit 1
esac
while getopts "dhri:c:m:p:s:a:v:w:x:y:z:" OPTION ; do
case "$OPTION" in
i) IFACE=$OPTARG ;;
c) CHANNEL=$OPTARG ; test X$CHANNEL = Xhelp && channel_usage ;;
m) IPMIINTF=$OPTARG ;;
p) PASSWORD=$OPTARG ;;
s) SNMP=$OPTARG ;;
a) GRATARP=$OPTARG ;;
d) DEBUG=1 ;;
v) IP_ADDRESS=$OPTARG ;;
w) IP_NETMASK=$OPTARG ;;
x) MAC_ADDRESS=$OPTARG ;;
y) GATEWAY_IP=$OPTARG ;;
z) GATEWAY_MAC=$OPTARG ;;
r) ipmitool_lan_reset ;;
h) usage ;;
*) echo "Ignoring invalid option : -$OPTARG" ;;
esac
done
if [ ! -x `which $IPMITOOL` ]; then
echo "Error: unable to find $IPMITOOL"
exit 1
fi
if [ $CHANNEL -eq 0 ]; then
echo
echo "Error: you must specify a channel with -c"
echo
exit 1
fi
if [ "$IFACE" ]; then
if ! $IFCONFIG $IFACE 2>/dev/null | grep "inet " >/dev/null 2>&1 ; then
echo
echo "Error: unable to find interface $IFACE"
echo
exit 1
fi
echo "Auto-configuring $IFACE (channel $CHANNEL)"
fi
case `uname -s` in
SunOS)
if [ X$IFACE != X ]; then
if [ X$IP_ADDRESS = X ]; then
IP_ADDRESS=`$IFCONFIG $IFACE | grep inet | awk '{print $2}'`
fi
if [ X$IP_NETMASK = X ]; then
HEX_NETMASK=`$IFCONFIG $IFACE | grep netmask | awk '{print $4}'`
IP_NETMASK=`hex_to_ip $HEX_NETMASK`
fi
if [ X$MAC_ADDRESS = X ]; then
MAC_ADDRESS=`$IFCONFIG $IFACE | grep ether | awk '{print $2}'`
fi
if [ X$GATEWAY_IP = X ]; then
GATEWAY_IP=`$ROUTE -n get default | grep gateway: | awk '{print $2}'`
fi
if [ X$GATEWAY_MAC = X ]; then
$PING -i $IFACE $GATEWAY_IP 1 >/dev/null 2>&1
GATEWAY_MAC=`$ARP $GATEWAY_IP | awk '{print $4}'`
if [ X$GATEWAY_MAC = Xno ]; then
GATEWAY_MAC=
fi
fi
fi
;;
Linux)
if [ X$IFACE != X ]; then
if [ X$IP_ADDRESS = X ]; then
IP_ADDRESS=`$IFCONFIG $IFACE | grep "inet addr" | awk -F"[:[:space:]]+" '{print $4}'`
fi
if [ X$IP_NETMASK = X ]; then
IP_NETMASK=`$IFCONFIG $IFACE | grep Bcast | awk -F"[:[:space:]]+" '{print $8}'`
fi
if [ X$MAC_ADDRESS = X ]; then
MAC_ADDRESS=`$IFCONFIG $IFACE | grep HWaddr | awk '{print $5}'`
fi
if [ X$GATEWAY_IP = X ]; then
GATEWAY_IP=`$ROUTE -n | awk '/^0.0.0.0/ {print $2}'`
fi
if [ X$GATEWAY_MAC = X ]; then
$PING -q -c1 $GATEWAY_IP >/dev/null 2>&1
GATEWAY_MAC=`$ARP -an | grep "$GATEWAY_IP[^0-9]" | awk '{print $4}'`
fi
fi
;;
esac
if [ X$IP_ADDRESS != X ]; then
ipmitool_lan_set "ipsrc" "static"
ipmitool_lan_set "ipaddr" "$IP_ADDRESS"
fi
if [ X$IP_NETMASK != X ]; then
ipmitool_lan_set "netmask" "$IP_NETMASK"
fi
if [ X$MAC_ADDRESS != X ]; then
ipmitool_lan_set "macaddr" "$MAC_ADDRESS"
fi
if [ X$GATEWAY_IP != X ]; then
ipmitool_lan_set "defgw ipaddr" "$GATEWAY_IP"
fi
if [ X$GATEWAY_MAC != X ]; then
ipmitool_lan_set "defgw macaddr" "$GATEWAY_MAC"
fi
if [ X$PASSWORD != X ]; then
ipmitool_lan_set "password" "$PASSWORD"
fi
if [ X$SNMP != X ]; then
ipmitool_lan_set "snmp" "$SNMP"
fi
if [ "$GRATARP" -ne 0 ]; then
ipmitool_lan_set "arp generate" "on"
ipmitool_lan_set "arp interval" "$GRATARP"
else
ipmitool_lan_set "arp generate" "off"
fi
echo "Setting channel authentication capabilities"
ipmitool_lan_set "auth callback,user,operator,admin" "md2,md5"
echo "Enabling channel $CHANNEL"
ipmitool_lan_set "access" "on"
ipmitool_lan_set "user"
exit 0

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2003-2004 Fredrik Ohrn. All Rights Reserved.
# Copyright (c) 2003 Fredrik Ohrn. All Rights Reserved.
#
# See the included COPYING file for license details.
#
@ -22,30 +22,20 @@ img_dir=/usr/local/apache2/htdocs/images/graphs
# Where will the graphs show up on the webserver?
web_dir=/images/graphs
# Size of graph area (excluding title, legends etc.)
graph_width=500
graph_height=150
# Graphs to include on page
graph_daily=1
graph_weekly=1
graph_monthly=0
# No need to edit below this point.
color[0]="2020FF"
color[1]="20FF20"
color[2]="FF2020"
color[3]="FF21FF"
color[4]="21FFFF"
color[5]="FFFF21"
color[6]="8F21FF"
color[7]="21FF8F"
color[8]="FF8F21"
color[9]="FF2190"
color[10]="2190FF"
color[11]="90FF21"
color[0]="0000FF"
color[1]="00FF00"
color[2]="FF0000"
color[3]="FFFF00"
color[4]="FF00FF"
color[5]="00FFFF"
color[6]="4444AA"
color[7]="44AA44"
color[8]="AA4444"
color[9]="AAAA44"
color[10]="AA44AA"
color[11]="44AAAA"
cat << EOF
#!$rrdcgi
@ -161,48 +151,38 @@ for group in $groups ; do
fi
fi
echo "<h3>${!group_title}</h3>"
if [ "$graph_daily" -ne 0 ] ; then
cat << EOF
cat << EOF
<h3>${!group_title}</h3>
<RRD::GRAPH "$img_dir/$hostname-$group-daily.gif"
--imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">"
--lazy
--height 200
--vertical-label "${!group_unit}"
--title "Daily graph"
--height $graph_height
--width $graph_width ${!group} $thres
--width 576 ${!group} $thres
>
EOF
fi
if [ "$graph_weekly" -ne 0 ] ; then
cat << EOF
<RRD::GRAPH "$img_dir/$hostname-$group-weekly.gif"
--imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">"
--lazy
--start -7d
--height 200
--vertical-label "${!group_unit}"
--title "Weelky graph"
--height $graph_height
--width $graph_width ${!group} $thres
--width 672 ${!group} $thres
>
EOF
fi
#<RRD::GRAPH "$img_dir/$hostname-$group-monthly.gif"
# --imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">"
# --lazy
# --start -30d
# --height 200
# --vertical-label "${!group_unit}"
# --title "Monthly graph"
# --width 720 ${!group} $thres
#>
#EOF
if [ "$graph_monthly" -ne 0 ] ; then
cat << EOF
<RRD::GRAPH "$img_dir/$hostname-$group-monthly.gif"
--imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">"
--lazy
--start -30d
--vertical-label "${!group_unit}"
--title "Monthly graph"
--height $graph_height
--width $graph_width ${!group} $thres
>
EOF
fi
done
cat << EOF

View File

@ -1,151 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2003-2004 Fredrik Ohrn. All Rights Reserved.
#
# See the included COPYING file for license details.
#
# Edit the variables
hostname=$HOSTNAME
ipmi_cmd="/usr/local/bin/ipmitool -I open"
rrd_dir="/some/dir/rrd"
# Full path to the rrdcgi executable.
rrdcgi=/usr/local/bin/rrdcgi
# Where should rrdcgi store the graphs? This path must be within the
# document root and writable by the webserver user.
img_dir=/usr/local/apache2/htdocs/images/graphs
# Where will the graphs show up on the webserver?
web_dir=/images/graphs
# Size of graph area (excluding title, legends etc.)
graph_width=500
graph_height=150
# Graphs to include on page
graph_daily=1
graph_weekly=1
graph_monthly=0
# No need to edit below this point.
color[0]="2020FF"
color[1]="20FF20"
color[2]="FF2020"
color[3]="FF21FF"
color[4]="21FFFF"
color[5]="FFFF21"
color[6]="8F21FF"
color[7]="21FF8F"
color[8]="FF8F21"
color[9]="FF2190"
color[10]="2190FF"
color[11]="90FF21"
cat << EOF
#!$rrdcgi
<html>
<head>
<title>$hostname</title>
<RRD::GOODFOR 300>
<body>
<h2>$hostname</h2>
EOF
IFS="
"
i=0
groups=
for line in `eval $ipmi_cmd -c -v sdr list full` ; do
IFS=,
split=($line)
file="$rrd_dir/$hostname-${split[0]}.rrd"
group=`echo "${split[2]}" | tr ' .-' ___`
group_color=${group}_color
if [ -z "${!group}" ] ; then
groups="$groups $group"
declare $group_color=0
group_unit=${group}_unit
declare $group_unit="${split[2]}"
fi
declare $group="${!group}
DEF:var$i=\"$file\":var:AVERAGE LINE1:var$i#${color[${!group_color}]}:\"${split[0]}\""
declare $group_color=$[ ${!group_color} + 1 ]
c=$[ c + 1 ]
i=$[ i + 1 ]
done
IFS=" "
for group in $groups ; do
group_unit=${group}_unit
IFS=,
echo "<h3>${!group_unit}</h3>"
if [ "$graph_daily" -ne 0 ] ; then
cat << EOF
<RRD::GRAPH "$img_dir/$hostname-$group-daily.gif"
--imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">"
--lazy
--vertical-label "${!group_unit}"
--title "Daily graph"
--height $graph_height
--width $graph_width ${!group}
>
EOF
fi
if [ "$graph_weekly" -ne 0 ] ; then
cat << EOF
<RRD::GRAPH "$img_dir/$hostname-$group-weekly.gif"
--imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">"
--lazy
--start -7d
--vertical-label "${!group_unit}"
--title "Weelky graph"
--height $graph_height
--width $graph_width ${!group}
>
EOF
fi
if [ "$graph_monthly" -ne 0 ] ; then
cat << EOF
<RRD::GRAPH "$img_dir/$hostname-$group-monthly.gif"
--imginfo "<img src="$web_dir/%s" width="%lu" height="%lu">"
--lazy
--start -30d
--vertical-label "${!group_unit}"
--title "Monthly graph"
--height $graph_height
--width $graph_width ${!group}
>
EOF
fi
done
cat << EOF
</body>
</html>
EOF

View File

@ -1,17 +0,0 @@
#!/bin/sh
echo "Setting up OpenIPMI driver..."
# load the ipmi modules
modprobe ipmi_msghandler
modprobe ipmi_devintf
if ! modprobe ipmi_kcs_drv ; then
modprobe ipmi_si # try new module name
fi
maj=$(cat /proc/devices | awk '/ipmidev/{print $1}')
if [ "$maj" ]; then
test -e /dev/ipmi0 && rm -f /dev/ipmi0
/bin/mknod /dev/ipmi0 c $maj 0
fi

View File

@ -1,216 +0,0 @@
#!/bin/sh
#
# chkconfig: 2345 11 60
# description: start, stop, or query ipmi system monitoring tools
# config: /etc/sysconfig/ipmi
#
# For Redhat, Fedora, or similar systems. Handles both 2.4 and 2.6
# configurations. Requires an /etc/sysconfig/ipmi file to function,
# see below.
#
# Phil Hollenback
# philiph@pobox.com
# Source function library.
. /etc/init.d/functions
# Exit silently if we don't have a sysconfig file,
# and read IPMI setting from it to determine whether or
# not to continue.
# The only current setting is ipmi={YES|NO}, whether or not
# to enable IPMI.
[ -f /etc/sysconfig/ipmi ] || exit 0
. /etc/sysconfig/ipmi
[ "${IPMI}" = "yes" ] || exit 0
RETVAL=0
start() {
echo -n $"Starting ipmi: "
# If ipmidev isn't listed in /proc/devices, try
# loading the modules.
if ! grep -q ipmidev /proc/devices
then
/sbin/modprobe ipmi_msghandler || RETVAL=1
/sbin/modprobe ipmi_devintf || RETVAL=1
# Try loading new driver module, fall back to old
# module if that fails.
if ! /sbin/modprobe ipmi_si >/dev/null 2>&1
then
/sbin/modprobe ipmi_kcs_drv || RETVAL=1
fi
fi
# If ipmidev still isn't listed in /proc/devices after we load
# modules, this just isn't going to work. Set RETVAL to mark
# this failure.
grep -q ipmidev /proc/devices || RETVAL=1
# Check if the device file exists and create if not.
if [ ! -c /dev/ipmi0 ] && [ $RETVAL -eq 0 ]
then
major=$(awk '/ ipmidev$/{print $1}' /proc/devices)
/bin/mknod -m 0600 /dev/ipmi0 c $major 0 || RETVAL=1
fi
if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ipmi ; then
echo_success
echo
else
echo_failure
echo
fi
}
stop() {
echo -n $"Shutting down ipmi: "
# Stop doesn't actually do anything because we currently don't
# unload ipmi modules on stop. That might change in the future
# if we decide unloading the ipmi modules is safe.
RETVAL=0
if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ipmi ; then
echo_success
echo
else
echo_failure
echo
fi
}
dostatus() {
# Extract cpu temperatures from ipmitool output.
# Abort if we don't have the ipmitool program.
if ! /usr/bin/ipmitool -V >/dev/null
then
echo "/usr/bin/ipmitool not found!" >&2
exit 1
fi
# Abort if ipmi isn't loaded.
if ! grep -q ipmidev /proc/devices
then
echo "ipmi not listed in /proc/devices!" >&2
exit 1
fi
# Check if we are running on a v1.0 IPMI system, and
# change our processor search string appropriately.
if /usr/bin/ipmitool -I open bmc info | \
grep -q "IPMI Version.*1.0"
then
IpmiVersion="1.0"
fi
# Determine # of running processors
NumProcs=$(grep -c processor /proc/cpuinfo)
if [ $NumProcs -eq 0 ]
then
echo "Can't determine number of processors!" >&2
exit 1
fi
# Now build the query string. Concatenate it into
# one string because that's more efficient on 2.4 systems.
Count=1
TempString=""
while [ $Count -le $NumProcs ]
do
if [ x$IpmiVersion = x"1.0" ]
then
TempString="$TempString CPU\ $Count"
else
TempString="$TempString Processor$Count\ Temp"
fi
Count=$((Count + 1))
done
# building TempString like this and eval'ing it is ugly, but
# it's the only way I could make the quoting work. Sorry.
TempString="/usr/bin/ipmitool -I open sensor get $TempString"
eval $TempString | awk -v "c=$Count" '
BEGIN {
n = 1
}
/Sensor Reading/ {
printf "CPU%s Temp: %s\n",n,$4
n++
}
END {
if ( n != c) {
printf "Error: found %s CPUs, but got temps for %s\n",--c,--n >"/dev/stderr"
exit 1
}
exit 0
}'
RETVAL=$((RETVAL + $?))
return $RETVAL
}
restart() {
stop
start
RETVAL=$?
}
condrestart() {
[ -e /var/lock/subsys/ipmi ] && restart || :
}
remove () {
# Actually remove the drivers. Don't do during stop in case
# this causes system to become unstable (a la lm_sensors)
if /sbin/lsmod | awk '{print $1}' | grep -q ipmi_
then
# Try removing both 2.4 and 2.6 modules.
/sbin/rmmod ipmi_si 2>/dev/null
/sbin/rmmod ipmi_kcs_drv 2>/dev/null
/sbin/rmmod ipmi_devintf
/sbin/rmmod ipmi_msghandler
else
echo "No ipmi modules loaded!" >&2
RETVAL=1
return $RETVAL
fi
# Wait a sec to give modules time to unload.
sleep 1
# Check if we failed to remove any modules, and complain if so.
if /sbin/lsmod | awk '{print $1}' | grep -q ipmi_
then
echo "ipmi modules still loaded!" >&2
RETVAL=1
return $RETVAL
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
dostatus
;;
restart|reload)
restart
;;
condrestart)
condrestart
;;
remove)
remove
;;
*)
echo "Usage: ipmi {start|stop|status|restart|condrestart|remove}"
exit 1
esac
exit $RETVAL

View File

@ -1,41 +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.
#
# You acknowledge that this software is not designed or intended for use
# in the design, construction, operation or maintenance of any nuclear
# facility.
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = pkginfo.in prototype.in ipmitool.spec.in \
rpmrc rpmmacros
dist-hook: pkginfo prototype

View File

@ -1,171 +0,0 @@
Name: ipmitool
Summary: ipmitool - Utility for IPMI control
Version: @VERSION@
Release: 1%{?_distro:.%{_distro}}
Copyright: BSD
Group: Utilities
Packager: Duncan Laurie <duncan@iceblink.org>
Source: ipmitool-@VERSION@.tar.gz
Buildroot: /var/tmp/ipmitool-root
%description
This package contains a utility for interfacing with devices that support
the Intelligent Platform Management Interface specification. IPMI is
an open standard for machine health, inventory, and remote power control.
This utility can communicate with IPMI-enabled devices through either a
kernel driver such as OpenIPMI or over the RMCP LAN protocol defined in
the IPMI specification. IPMIv2 adds support for encrypted LAN
communications and remote Serial-over-LAN functionality.
It provides commands for reading the Sensor Data Repository (SDR) and
displaying sensor values, displaying the contents of the System Event
Log (SEL), printing Field Replaceable Unit (FRU) information, reading and
setting LAN configuration, and chassis power control.
%prep
if [ "$RPM_BUILD_ROOT" ] && [ "$RPM_BUILD_ROOT" != "/" ]; then
rm -rf $RPM_BUILD_ROOT
fi
%setup
%build
./configure --with-kerneldir \
--prefix=%{_prefix} \
--bindir=%{_bindir} \
--datadir=%{_datadir} \
--includedir=%{_includedir} \
--libdir=%{_libdir} \
--mandir=%{_mandir} \
--sysconfdir=%{_sysconfdir}
make
%install
make DESTDIR=$RPM_BUILD_ROOT install-strip
%clean
if [ "$RPM_BUILD_ROOT" ] && [ "$RPM_BUILD_ROOT" != "/" ]; then
rm -rf $RPM_BUILD_ROOT
fi
rm -rf $RPM_BUILD_DIR/ipmitool-@VERSION@
%files
%defattr(-,root,root)
%{_bindir}/*
%{_datadir}/ipmitool/*
%doc %{_mandir}/man1/*
%doc %{_datadir}/doc/ipmitool/*
%changelog
* Wed Mar 16 2005 <duncan@iceblink.org> 1.8.0-1
- Fix IPMIv2.0 issues
- Fix chassis boot parameter support
- Add support for linear sensors
- Update bmc plugin to work with new Solaris bmc driver (new ioctl
for interface detection and new STREAMS message-based interface)
* Tue Jan 18 2005 <duncan@iceblink.org> 1.7.0-1
- Propogate errors correctly so exit status will be useful
- More consistent display of errors including completion code text
- Errors and debug is send to stderr now
- New "sel get" command that will print details about SEL entry
and corresponding SDR records as well as FRUs via entity association
- Improved event generator, now supports reading events from text file
- New "-o oemtype" option for specifying OEM boards
exsting types are "supermicro" and "intelwv2"
- New PEF subsystem from Tim Murphy at Dell
- New "bmc" plugin for Solaris 10 x86
- Many bugfixes and contributed patches
- Support for Supermicro BMC OEM authentication method
- Fix minor problem with LAN parameter setting
* Wed Aug 18 2004 <duncan@iceblink.org> 1.6.0-1
- Add a README
- Add support for IPMIv2 and Serial-over-LAN from Newisys
- Add Solaris x86 lipmi interface
- Add support for building Solaris packages
- Add support for building RPMs as non-root user
- Fix segfault when doing "sel list" (from Matthew Braithwaite)
- Fix "chassis identify" on some BMCs (from ebrower@sourceforge)
- Add "bmc info" and related output (from ebrower@sourceforge)
- new "shell" and "exec" commands
- lots of other contributed patches
* 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
- Add README for rrdtool scripts in contrib directory
- Improve lan interface retry handling
- Support prompting for password or reading from environment
- Move chaninfo command into channel subcommand
- Fix reservation ID handling when two sessions open to BMC
- Fix reading of large FRU data
- Add configure option for changing binary to ipmiadm for Solaris
- Fix compile problem on Solaris 8
* Tue Jan 27 2004 <duncan@iceblink.org> 1.5.8-1
- Enable static compilation of interfaces
- Fix types to be 64-bit safe
- Fix compilation problems on Solaris
- Fix multiple big-endian problems for Solaris/SPARC
- Fix channel access to save settings to NVRAM
- Set channel privilege limit to ADMIN during "access on"
- Enable gratuitous ARP in bmcautoconf.sh
- Add support for Linux kernel panic messages in SEL output
- Add support for type 3 SDR records
* Mon Jan 5 2004 <duncan@iceblink.org> 1.5.7-1
- add IPMIv1.5 eratta fixes
- additions to FRU printing and FRU multirecords
- better handling of SDR printing
- contrib scripts for creating rrdtool graphs
* Thu Dec 4 2003 <duncan@iceblink.org> 1.5.6-1
- 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 <EFBFBD>hrn
* Tue Nov 25 2003 <duncan@iceblink.org> 1.5.5-1
- Add -U option for setting LAN username
- Fix -v usage for plugin interfaces
* Fri Nov 14 2003 <duncan@iceblink.org> 1.5.4-1
- pull interface plugin api into library
- fix ipmievd
* Fri Oct 31 2003 <duncan@iceblink.org> 1.5.3-1
- add -g optin for pedantic ipmi-over-lan communication
* Fri Oct 24 2003 <duncan@iceblink.org> 1.5.2-1
- add gratuitous arp interval setting
* Wed Oct 8 2003 <duncan@iceblink.org> 1.5.1-1
- better SEL support
- fix display bug in SDR list
* Fri Sep 5 2003 <duncan@iceblink.org> 1.5.0-1
- use automake/autoconf/libtool
- dynamic loading interface plugins
* Wed May 28 2003 <duncan@iceblink.org> 1.4.0-1
- make UDP packet handling more robust
- fix imb driver support
* Thu May 22 2003 <duncan@iceblink.org> 1.3-1
- update manpage
- rework of low-level network handling
- add basic imb driver support
* Wed Apr 2 2003 <duncan@iceblink.org> 1.2-1
- change command line option parsing
- support for more chassis commands
* Tue Apr 1 2003 <duncan@iceblink.org> 1.1-1
- minor fixes.
* Sun Mar 30 2003 <duncan@iceblink.org> 1.0-1
- Initial release.

View File

@ -1,10 +0,0 @@
PKG="@PACKAGE@"
NAME="@PACKAGE@ - Utility for Intelligent Platform Management Interface (IPMI) control"
ARCH="@ARCH@"
VERSION="@VERSION@"
CATEGORY="system"
VENDOR="Duncan Laurie"
EMAIL="duncan@sun.com"
PSTAMP="@PSTAMP@"
BASEDIR="@BASEDIR@"
CLASSES="none"

View File

@ -1,7 +0,0 @@
i pkginfo
d none bin ? ? ?
f none bin/@PACKAGE@=../src/@PACKAGE@ 0755 root bin
d none share ? ? ?
d none share/man ? ? ?
d none share/man/man1 ? ? ?
f none share/man/man1/@PACKAGE@.1=../doc/@PACKAGE@.1 0644 root bin

View File

@ -1,11 +0,0 @@
%_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
%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%packager duncan@iceblink.org
%distribution Sourceforge Build

View File

@ -1 +0,0 @@
macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/etc/rpm/macros.specspo:/etc/rpm/macros:/etc/rpm/%{_target}/macros:%(echo $CONFIGDIR)/rpmmacros

View File

@ -1,77 +1,3 @@
ipmitool (1.8.0) unstable; urgency=low
* Fix IPMIv2.0 issues
* Fix chassis boot parameter support
* Add support for linear sensors
-- Duncan Laurie <duncan@iceblink.org> Wed, Mar 16 2005 17:08:12 -0700
ipmitool (1.7.1) unstable; urgency=low
* Update bmc plugin to work with new Solaris bmc driver (new ioctl
for interface detection and new STREAMS message-based interface).
-- Seth Goldberg <sethmeisterg@hotmail.com> Mon, Mar 7 2005 18:03:00 -0800
ipmitool (1.7.0) unstable; urgency=low
* Propogate errors correctly so exit status will be useful
* More consistent display of errors including completion code text
* Errors and debug is send to stderr now
* New "sel get" command that will print details about SEL entry
and corresponding SDR records as well as FRUs via entity association
* Improved event generator, now supports reading events from text file
* New "-o oemtype" option for specifying OEM boards
exsting types are "supermicro" and "intelwv2"
* New PEF subsystem
* New "bmc" plugin for Solaris 10 x86
* Many bugfixes and contributed patches
-- Duncan Laurie <duncan@iceblink.org> Fri, Jan 7 2005 19:58:22 -0700
ipmitool (1.6.2) unstable; urgency=low
* Support for Supermicro BMC OEM authentication method
-- Duncan Laurie <duncan@iceblink.org> Mon, 16 Nov 2004 08:20:01 -0700
ipmitool (1.6.1) unstable; urgency=low
* Fix minor problem with LAN parameter setting
-- Duncan Laurie <duncan@iceblink.org> Wed, 29 Sep 2004 11:19:17 -0700
ipmitool (1.6.0) unstable; urgency=low
* Add a README
* Add support for IPMIv2 and Serial-over-LAN from Newisys
* Add Solaris x86 lipmi interface
* Add support for building Solaris packages
* Add support for building RPMs as non-root user
* Fix segfault when doing "sel list" (from Matthew Braithwaite)
* Fix "chassis identify" on some BMCs (from ebrower@sourceforge)
* Add "bmc info" and related output (from ebrower@sourceforge)
* new "shell" and "exec" commands
* lots of other contributed patches
-- Duncan Laurie <duncan@iceblink.org> Thu, 9 Sep 2004 21:39:37 -0700
ipmitool (1.5.9) unstable; urgency=low
* 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
* Add README for rrdtool scripts in contrib directory
* Improve lan interface retry handling
* Support prompting for password or reading from environment
* Move chaninfo command into channel subcommand
* Fix reservation ID handling when two sessions open to BMC
* Fix reading of large FRU data
* Add configure option for changing binary to ipmiadm for Solaris
* Fix compile problem on Solaris 8
-- Duncan Laurie <duncan@sun.com> Sat, 27 Mar 2004 00:11:37 -0700
ipmitool (1.5.8) unstable; urgency=low
* Enable static compilation of interfaces

View File

@ -1,12 +1,12 @@
Source: ipmitool
Section: contrib
Priority: optional
Maintainer: Duncan Laurie <duncan@iceblink.org>
Maintainer: Duncan Laurie <duncan@sun.com>
Build-Depends: debhelper (>> 3.0.0)
Standards-Version: 3.5.8
Package: ipmitool
Architecture: i386 amd64
Architecture: i386
Provides: ipmitool
Description: Utility for IPMI control with kernel driver or LAN interface

View File

@ -1,3 +1,2 @@
usr/bin
usr/share/ipmitool
usr/share/doc/ipmitool
usr/include/ipmitool

View File

@ -1,4 +0,0 @@
README
COPYING
AUTHORS
ChangeLog

View File

@ -19,7 +19,10 @@ configure: configure-stamp
configure-stamp:
dh_testdir
./configure --prefix=/usr \
--with-kerneldir \
--with-pluginpath=/usr/lib/ipmitool \
--enable-intf-lan=static \
--enable-intf-open=static \
--enable-ipmievd \
--mandir=/usr/share/man
touch configure-stamp
@ -79,7 +82,7 @@ binary-common:
dh_testdir
dh_testroot
# dh_installdebconf
dh_installdocs
# dh_installdocs
# dh_installexamples
# dh_installmenu
# dh_installemacsen

View File

@ -37,4 +37,3 @@ MAINTAINERCLEANFILES = Makefile.in
man_MANS = ipmitool.1
EXTRA_DIST = $(man_MANS)

View File

@ -2,20 +2,14 @@
.SH "NAME"
.LP
ipmitool \- utility for controlling IPMI-enabled devices
.SH "SYNOPSIS"
.SH "SYNTAX"
.LP
ipmitool [\fB\-ghcvV\fR] \fB\-I\fR \fIlan\fP \fB\-H\fR \fIhostname\fP [\fB\-L\fR \fIprivlvl\fP] [\fB\-a\fR|\fB\-E\fR|\fB\-P\fR \fIpassword\fP] <\fIexpression\fP>
.LP
ipmitool [\fB\-ghcvV\fR] \fB\-I\fR \fIlanplus\fP \fB\-H\fR \fIhostname\fP [\fB\-L\fR \fIprivlvl\fP] [\fB\-a\fR|\fB\-E\fR|\fB\-P\fR \fIpassword\fP] <\fIexpression\fP>
.LP
ipmitool [\fB\-ghcvV\fR] \fB\-I\fR \fIlan\fP \fB\-H\fR \fIhostname\fP [\fB\-P\fR \fIpassword\fP] <\fIexpression\fP>
.br
ipmitool [\fB\-ghcvV\fR] \fB\-I\fR \fIopen\fP <\fIexpression\fP>
.SH "DESCRIPTION"
.LP
This program lets you manage Intelligent Platform Management Interface
(IPMI) functions of either the local system, via a kernel device driver,
or a remote system, using IPMI V1.5 . These functions include printing
FRU information, LAN configuration, sensor readings, and remote chassis
power control.
This program lets you perform various IPMI functions with either a kernel device driver or over a LAN interface. These functions include printing FRU information, LAN configuration, sensor readings, and remote chassis power control.
.SH "OPTIONS"
.LP
.TP
@ -23,37 +17,28 @@ power control.
Get basic usage help from the command line.
.TP
\fB\-c\fR
Display output with comma field separator instead of spaces. Not available with all commands.
Make output suitable for parsing where possible by separating fields with commas instead of spaces.
.TP
\fB\-g\fR
Attempt to be extra robust in IPMI-over-LAN communications.
.TP
\fB\-V\fR
Display version information.
.TP
\fB\-v\fR
Increase verbose output level. This option may be specified multiple times to increase the level of debug output.
Increase verbose output level. This option may be specified multiple times to increase the level of debug output. If given three times you will get hexdumps of all incoming and outgoing packets.
.TP
\fB\-I\fR <\fIinterface\fP>
Selects IPMI interface to use. Possible interfaces are \fIlan\fP, \fIlanplus\fP or \fIopen\fP.
Selects IPMI interface to use. Possible interfaces are \fIlan\fP or \fIopen\fP.
.TP
\fB\-H\fR <\fIaddress\fP>
Remote server address, can be IP address or hostname. This option is required for the LAN interface connection.
.TP
\fB\-P\fR <\fIpassword\fP>
Remote server password, 16 character maximum. This is optional for the LAN interface, if it is not provided the session will not be authenticated.
.TP
\fB\-U\fR <\fIusername\fP>
Remote username, default is NULL user.
.TP
\fB\-L\fR <\fIprivlvl\fP>
Force session privilege level. Can be CALLBACK, USER, OPERATOR, ADMIN. Default is ADMIN.
.TP
\fB\-a\fR
Prompt for the remote server password, 16 character maximum. This is optional for the LAN interface, if a password is not provided the session will not be authenticated.
.TP
\fB\-E\fR
The remote server password is specified by the environment variable \fBIPMI_PASSWORD\fR. This option is intended for shell scripts.
.TP
\fB\-f\fR <\fIfile\fP>
Read remote server password from file.
.TP
\fB\-P\fR <\fIpassword\fP>
Remote server password. \fBNote!\fR Specifying the password as a commandline option is not recommended since it will be visible in the process list.
.SH "EXPRESSIONS"
.LP
.TP
@ -63,12 +48,12 @@ This can be used to get command-line help on ipmitool commands. It may also be
.PP
ipmitool -I open help
.br
Commands: bmc, chassis, event, fru, lan, raw, sdr, sel, sensor, sol, userinfo, channel
Commands: chassis, fru, lan, sdr, sel
.LP
.PP
ipmitool -I open chassis help
.br
Chassis Commands: status, power, identify, policy, restart_cause, poh
Chassis Commands: status, power, identify, policy, restart_cause
.LP
.PP
ipmitool -I open chassis power help
@ -81,7 +66,7 @@ Chassis Power Commands: status, on, off, cycle, reset, diag, soft
This will allow you to execute raw IPMI commands. For example to query the POH counter with a raw command:
.RS
.PP
ipmitool -v -I open raw 0x0 0xf
ipmitool -I open raw 0x0 0xf
.br
RAW REQ (netfn=0x0 cmd=0xf data_len=0)
.br
@ -91,28 +76,7 @@ RAW RSP (5 bytes)
.LP
.RE
.TP
.I channel
.RS
.TP
\fIauthcap\fP <\fBchannel number\fR> <\fBmax priv\fR>
This command will display information about the authentication capabilities of the selected channel at the specified privelige level.
.RS
.TP
Possible privilege levels are:
.br
1 Callback level
.br
2 User level
.br
3 Operator level
.br
4 Administrator level
.br
5 OEM Proprietary level
.LP
.RE
.TP
\fIinfo\fP [\fBchannel number\fR]
\fIchaninfo\fP [\fBchannel\fR]
This command will display information about the selected channel. If no channel is given it will display information about the currently used channel:
.RS
.PP
@ -132,11 +96,11 @@ Channel 0xf info:
.LP
.RE
.TP
\fIuser\fP <\fBchannel number\fR> [\fBuser number\fR]
This command will display information about configured user information on a specific LAN channel. This command will fail on system interfaces.
\fIuserinfo\fP <\fBchannel\fR>
This command will display information about configured user information on a specific LAN channel. This command will fail on system interfaces. Try channel 6 or 7.
.RS
.PP
ipmitool -I open channel user 6
ipmitool -I open userinfo 6
.br
Maximum User IDs : 4
.br
@ -151,7 +115,6 @@ Link Authentication : disabled
IPMI Messaging : enabled
.LP
.RE
.RE
.TP
.I chassis
.RS
@ -246,9 +209,6 @@ Set the backup gateway MAC address.
\fIpassword\fP <\fBpass\fR>
Set the null user password.
.TP
\fIsnmp\fP <\fBcommunity string\fR>
Set the SNMP community string.
.TP
\fIuser\fP
Enable user access mode.
.TP
@ -303,59 +263,10 @@ This command will read all Field Replacable Unit inventory data and extract such
.I sdr
.RS
.TP
.I info
This command will query the BMC for information about the SDR.
.TP
.I list
This command will read the SDR and extract sensor information, then query each sensor and print its name, reading, and status.
.RE
.TP
.I pef
.RS
.TP
.I info
This command will query the BMC and print information about the PEF supported features.
.TP
.I status
This command prints the current PEF status (the last SEL entry processed by the BMC, etc).
.TP
.I policy
This command lists the PEF policy table entries. Each policy entry describes an alert destination. A policy set is a collection of table entries. PEF alert actions reference policy sets.
.TP
.I list
This command lists the PEF table entries. Each PEF entry relates a sensor event to an action. When PEF is active, each platform event causes the BMC to scan this table for entries matching the event, and possible actions to be taken. Actions are performed in priority order (higher criticality first).
.RE
.TP
.I sensor
.RS
.TP
.I list
This command will list sensors and thresholds in a wide table format.
.TP
\fIget\fP <\fBid\fR> ... [\fBid\fR]
This command will print info for sensors specified by name.
.TP
\fIthresh\fP <\fBid\fR> <\fBthreshold\fR> <\fBsetting\fR>
This allows you to set a particular sensor threshold value. The sensor is specified by name.
.RS
.TP
Valid thresholds are:
.br
unr Upper Non-Recoverable
.br
ucr Upper Critical
.br
unc Uperr Non-Critical
.br
lnc Lower Non-Critical
.br
lcr Lower Critical
.br
lnr Lower Non-Recoverable
.LP
.RE
.RE
.TP
.I sel
.RS
.TP
@ -369,101 +280,11 @@ This command will clear the contents of the SEL. It cannot be undone so be care
This command will list the contents of the SEL.
.RE
.TP
.I session
.RS
.TP
\fIinfo\fP <\fBparameter\fR> [\fBargument\fR]
This command will query the BMC for information about its session capabilities and current sessions. Valid parameters are:
.RS
.TP
\fIactive\fP
Queries the BMC for information about the current session. That is, the session used to execute this command.
.TP
\fIall\fP
Queries the BMC for information about all active sessions
.TP
\fIid\fP <\fBid\fR>
Queries the BMC for information about the session with the specified ID. The ID should be specified in hex.
.TP
\fIhandle\fP <\fBhandle\fR>
Queries the BMC for information about the session with the specified handle. The handle should be specified in hex.
.RE
.RE
.TP
.I sol
.RS
.TP
\fIinfo\fP [\fBchannel\fR]
Retrieve information about the Serial-Over-LAN configuration on the specified channel. If no channel is given, it will display SOL configuration data for the currently used channel.
.RE
.RS
.TP
\fIset\fP <\fBparameter\fR> <\fBvalue\fR> [\fBchannel\fR]
Configure parameters for Serial Over Lan. If no channel is given, it will display SOL configuration data for the currently used channel. Configuration parameter updates are automatically guarded with the updates to the set-in-progress parameter.
.RS
.TP
Valid parameters and values are:
.br
.TP
set-in-progress
set-complete set-in-progress commit-write
.TP
enabled
true false
.TP
force-encryption
true false
.TP
force-authentication
true false
.TP
privilege-level
user operator admin oem
.TP
character-accumulate-level
Decimal number given in 5 milliseconds increments
.TP
character-send-threshold
Decimal number
.TP
retry-count
Decimal number. 0 indicates no retries after packet is transmitted.
.TP
retry-interval
Decimal number in 10 millisend increments. 0 indicates that retries should be sent back to back.
.TP
non-volatile-bit-rate
serial, 19.2, 38.4, 57.6, 115.2. Setting this value to serial indiates that the BMC should use the setting used by the IPMI over serial channel.
.TP
volatile-bit-rate
serial, 19.2, 38.4, 57.6, 115.2. Setting this value to serial indiates that the BMC should use the setting used by the IPMI over serial channel.
.LP
.RE
.RE
.RS
.TP
.I activate
This command causes ipmitool to enter Serial Over LAN mode, and is only available when using the lanplus interface. An RMCP+ connection is made to the BMC, the terminal is set to raw mode, and user input is sent to the serial console on the remote server. On exit, the the SOL payload mode is deactivated and the terminal is reset to its original settings.
.RS
.TP
Special escape sequences are provided to control the SOL session:
~. Terminate connection
.br
~^Z Suspend ipmitool
.br
~B Send break
.br
~~ Send the escape character by typing it twice
.br
~? Print the supported escape sequences
.LP
.RE
.RE
.RS
.TP
.I deactivate
This command deactivates Serial Over LAN mode on the BMC. Exiting Serial Over LAN mode should automatically cause this command to be sent to the BMC, but in the case of an unintentional exit from SOL mode, this command may be necessary to reset the state of the BMC.
.RE
.I setup
Setup Serial-over-LAN: enable, set authentication and baud rate.
.RE
.SH "OPEN INTERFACE"
.LP
@ -484,16 +305,9 @@ Once they are loaded there will be a dynamic char device entry that must exist a
.LP
.I mknod /dev/ipmi0 c 254 0
.LP
In order to force ipmitool to make use of the OpenIPMI device interface you can specifiy it on the command line:
In order to force ipmitool to make use of the device interface you can specifiy it on the command line:
.PP
ipmitool \-I open <expression>
.SH "LIPMI INTERFACE"
.LP
The ipmitool \fIlipmi\fP interface uses the Solaris x86 IPMI kernel device driver.
.LP
You can tell ipmitool to use the Solaris IPMI driver with the \fB-I\fR option:
.PP
ipmitool \-I lipmi <expression>
.SH "LAN INTERFACE"
.LP
The ipmitool \fIlan\fP interface communicates with the BMC over an Ethernet LAN connection using UDP under IPv4. UDP datagrams are formatted to contain IPMI request/response messages with a IPMI session headers and RMCP headers.
@ -504,20 +318,9 @@ The LAN interface is an authenticatiod multi\-session connection; messages deliv
.LP
You can tell ipmitool to use the lan interface with the \fB\-I\fR option:
.PP
ipmitool \-I lan \-H <hostname> [\-U username] [\-P password] <expression>
ipmitool \-I lan \-H <hostname> \-P [password] <expression>
.LP
A hostname \fBmust\fR be given on the command line in order to use the lan interface with ipmitool. The password field is optional; if you do not provide a password on the command line, ipmitool will attempt to connect without authentication. If you specify a password it will use MD5 authentication if supported by the BMC and straight password/key otherwise.
.SH "LANPLUS INTERFACE"
.LP
Like the \fIlan\fP interface, the \fIlanplus\fP interface communicates with the BMC over an Ethernet LAN connection using UDP under IPv4. The difference is that the \fIlanplus\fP interface uses the RMCP+ protocol as described in the IMPI v2.0 specification. RMCP+ allows for improved authentication and data integrity checks, as well as encryption and the ability to carry multiple types of payloads. Generic Serial Over LAN support requires RMCP+, so the ipmitool \fIsol activate\fP command requires the use of the \fIlanplus\fP interface.
.LP
RMCP+ session establishment uses a protocol call RAKP (Remote Authenticated Key-Exchange Protocol) which allows the negotiation of many options. ipmitool does not yet allow the user to specify the value of every option, defaulting to the most obvious settings, marked as required in the v2.0 specification. Authentication and integrity HMACS are produced with SHA1, and encryption is performed with AES-CBC-128. Role-level logins are not supported. ipmitool must be configured with the appropriate option for the \fIlanplus\fP interface to be available, as it is not enabled by default. This interface currently requires the OpenSSL library.
.LP
You can tell ipmitool to use the lanplus interface with the \fB\-I\fR option:
.PP
ipmitool \-I lanplus \-H <hostname> [\-U username] [\-P password] <expression>
.LP
The options available for the \fIlanplus\fP inteface are identical to those available for the \fIlan\fP inteface.
A hostname \fBmust\fR be given on the command line in order to use the lan interface with ipmitool. The password field is optional; if you do not provide a password on the command line ipmitool will attempt to connect without authentication. If you specify a password it will use MD5 authentication if supported by the BMC and straight password/key otherwise.
.SH "FILES"
.TP
.I /dev/ipmi0
@ -535,7 +338,7 @@ ipmitool \-I lan \-H 192.168.1.1 \-P password chassis power status
Chassis Power is on
.SH "AUTHOR"
.LP
Duncan Laurie <duncan@iceblink.org>
Duncan Laurie <duncan@sun.com>
.SH "SEE ALSO"
.LP
.TP
@ -547,4 +350,3 @@ http://www.intel.com/design/servers/ipmi/spec.htm
.TP
OpenIPMI project (MontaVista IPMI kernel driver)
http://openipmi.sourceforge.net

View File

@ -34,10 +34,9 @@
MAINTAINERCLEANFILES = Makefile.in
noinst_HEADERS = log.h bswap.h helper.h ipmi.h ipmi_intf.h \
ipmi_chassis.h ipmi_entity.h ipmi_fru.h ipmi_lanp.h \
ipmi_sdr.h ipmi_sel.h ipmi_sol.h ipmi_mc.h ipmi_raw.h \
ipmi_channel.h ipmi_sensor.h ipmi_event.h ipmi_session.h \
ipmi_strings.h ipmi_constants.h ipmi_user.h ipmi_pef.h \
ipmi_oem.h ipmi_isol.h
ipmitooldir = $(includedir)/ipmitool
ipmitool_HEADERS = bswap.h helper.h ipmi.h ipmi_intf.h \
ipmi_chassis.h ipmi_entity.h ipmi_fru.h ipmi_lanp.h \
ipmi_sdr.h ipmi_sel.h ipmi_sol.h ipmi_bmc.h ipmi_sensor.h

View File

@ -41,13 +41,12 @@
# include <config.h>
#endif
#undef BSWAP_16
#undef BSWAP_32
#if HAVE_BYTESWAP_H
# include <byteswap.h>
# define BSWAP_16(x) bswap_16(x)
# define BSWAP_32(x) bswap_32(x)
#elif HAVE_SYS_BYTEORDER_H
# include <sys/byteorder.h>
#else
# define BSWAP_16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
# define BSWAP_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) |\

View File

@ -37,29 +37,24 @@
#ifndef IPMI_HELPER_H
#define IPMI_HELPER_H
#include <sys/types.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdint.h>
struct valstr {
uint16_t val;
unsigned short val;
const char * str;
};
const char * val2str(uint16_t val, const struct valstr * vs);
uint16_t str2val(const char * str, const struct valstr * vs);
const char * val2str(unsigned short val, const struct valstr * vs);
uint16_t buf2short(uint8_t * buf);
uint32_t buf2long(uint8_t * buf);
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);
unsigned short buf2short(unsigned char * buf);
uint32_t buf2long(unsigned char * buf);
const char * buf2str(unsigned char * buf, int len);
void printbuf(unsigned char * buf, int len, char * desc);
#define ipmi_open_file_read(file) ipmi_open_file(file, 0)
#define ipmi_open_file_write(file) ipmi_open_file(file, 1)
void signal_handler(int sig, void * handler);
#ifndef __min
# define __min(a, b) ((a) < (b) ? (a) : (b))
#endif
#define SIG_IGNORE(s) ((void)signal((s), SIG_IGN))
#define SIG_DEFAULT(s) ((void)signal((s), SIG_DFL))
#define SIG_HANDLE(s,h) ((void)signal_handler((s), (h)))
#endif /* IPMI_HELPER_H */

View File

@ -39,199 +39,77 @@
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <sys/types.h>
#include <stdint.h>
#include <netinet/in.h>
#include <ipmitool/helper.h>
#define IPMI_BUF_SIZE 1024
/* From table 13.16 of the IPMI v2 specification */
#define IPMI_PAYLOAD_TYPE_IPMI 0x00
#define IPMI_PAYLOAD_TYPE_SOL 0x01
#define IPMI_PAYLOAD_TYPE_OEM 0x02
#define IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST 0x10
#define IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE 0x11
#define IPMI_PAYLOAD_TYPE_RAKP_1 0x12
#define IPMI_PAYLOAD_TYPE_RAKP_2 0x13
#define IPMI_PAYLOAD_TYPE_RAKP_3 0x14
#define IPMI_PAYLOAD_TYPE_RAKP_4 0x15
#define BUF_SIZE 256
extern int verbose;
extern int csv_output;
struct ipmi_session {
unsigned char username[16];
unsigned char challenge[16];
unsigned char password;
unsigned char authtype;
unsigned char authcode[16];
unsigned char privlvl;
uint32_t in_seq;
uint32_t out_seq;
uint32_t id;
int active;
};
struct ipmi_rq {
struct {
uint8_t netfn;
uint8_t cmd;
uint8_t target_cmd;
uint16_t data_len;
uint8_t *data;
unsigned char netfn;
unsigned char cmd;
unsigned short data_len;
unsigned char *data;
} msg;
};
/*
* This is what the sendrcv_v2() function would take as an argument. The common case
* is for payload_type to be IPMI_PAYLOAD_TYPE_IPMI.
*/
struct ipmi_v2_payload {
uint16_t payload_length;
uint8_t payload_type;
union {
struct {
uint8_t rq_seq;
struct ipmi_rq * request;
} ipmi_request;
struct {
uint8_t rs_seq;
struct ipmi_rs * response;
} ipmi_response;
/* Only used internally by the lanplus interface */
struct {
uint8_t * request;
} open_session_request;
/* Only used internally by the lanplus interface */
struct {
uint8_t * message;
} rakp_1_message;
/* Only used internally by the lanplus interface */
struct {
uint8_t * message;
} rakp_2_message;
/* Only used internally by the lanplus interface */
struct {
uint8_t * message;
} rakp_3_message;
/* Only used internally by the lanplus interface */
struct {
uint8_t * message;
} rakp_4_message;
struct {
uint8_t data[IPMI_BUF_SIZE];
uint16_t character_count;
uint8_t packet_sequence_number;
uint8_t acked_packet_number;
uint8_t accepted_character_count;
uint8_t is_nack; /* bool */
uint8_t assert_ring_wor; /* bool */
uint8_t generate_break; /* bool */
uint8_t deassert_cts; /* bool */
uint8_t deassert_dcd_dsr; /* bool */
uint8_t flush_inbound; /* bool */
uint8_t flush_outbound; /* bool */
} sol_packet;
} payload;
};
struct ipmi_rq_entry {
struct ipmi_rq req;
struct ipmi_intf * intf;
uint8_t rq_seq;
uint8_t * msg_data;
struct ipmi_session * session;
unsigned char rq_seq;
unsigned char * msg_data;
int msg_len;
struct ipmi_rq_entry * next;
};
struct ipmi_rs {
uint8_t ccode;
uint8_t data[IPMI_BUF_SIZE];
/*
* Looks like this is the length of the entire packet, including the RMCP
* stuff, then modified to be the length of the extra IPMI message data
*/
unsigned char ccode;
unsigned char data[BUF_SIZE];
int data_len;
struct {
uint8_t netfn;
uint8_t cmd;
uint8_t seq;
uint8_t lun;
} msg;
struct {
uint8_t authtype;
uint32_t seq;
uint32_t id;
uint8_t bEncrypted; /* IPMI v2 only */
uint8_t bAuthenticated; /* IPMI v2 only */
uint8_t payloadtype; /* IPMI v2 only */
/* This is the total length of the payload or
IPMI message. IPMI v2.0 requires this to
be 2 bytes. Not really used for much. */
uint16_t msglen;
unsigned char authtype;
uint32_t seq;
uint32_t id;
} session;
/*
* A union of the different possible payload meta-data
*/
union {
struct {
uint8_t rq_addr;
uint8_t netfn;
uint8_t rq_lun;
uint8_t rs_addr;
uint8_t rq_seq;
uint8_t rs_lun;
uint8_t cmd;
} ipmi_response;
struct {
uint8_t message_tag;
uint8_t rakp_return_code;
uint8_t max_priv_level;
uint32_t console_id;
uint32_t bmc_id;
uint8_t auth_alg;
uint8_t integrity_alg;
uint8_t crypt_alg;
} open_session_response;
struct {
uint8_t message_tag;
uint8_t rakp_return_code;
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[20];
} rakp2_message;
struct {
uint8_t message_tag;
uint8_t rakp_return_code;
uint32_t console_id;
uint8_t integrity_check_value[20];
} rakp4_message;
struct {
uint8_t packet_sequence_number;
uint8_t acked_packet_number;
uint8_t accepted_character_count;
uint8_t is_nack; /* bool */
uint8_t transfer_unavailable; /* bool */
uint8_t sol_inactive; /* bool */
uint8_t transmit_overrun; /* bool */
uint8_t break_detected; /* bool */
} sol_packet;
} payload;
unsigned char msglen;
struct {
unsigned char rq_addr;
unsigned char netfn;
unsigned char rq_lun;
unsigned char rs_addr;
unsigned char rq_seq;
unsigned char rs_lun;
unsigned char cmd;
} header;
};
struct ipmi_intf {
int fd;
struct sockaddr_in addr;
int abort;
int pedantic;
int (*open)(struct ipmi_intf *, char *, int, char *, char *);
void (*close)(struct ipmi_intf *);
struct ipmi_rs *(*sendrecv)(struct ipmi_intf *, struct ipmi_rq *);
};
#define IPMI_NETFN_CHASSIS 0x0
#define IPMI_NETFN_BRIDGE 0x2
@ -240,11 +118,11 @@ struct ipmi_rs {
#define IPMI_NETFN_FIRMWARE 0x8
#define IPMI_NETFN_STORAGE 0xa
#define IPMI_NETFN_TRANSPORT 0xc
#define IPMI_NETFN_ISOL 0x34
#define IPMI_NETFN_SOL 0x34
#define IPMI_BMC_SLAVE_ADDR 0x20
#define IPMI_REMOTE_SWID 0x81
extern const struct valstr completion_code_vals[];
const struct valstr completion_code_vals[25];
#endif /* IPMI_H */

View File

@ -34,14 +34,16 @@
* facility.
*/
#ifndef IPMI_EVENT_H
#define IPMI_EVENT_H
#ifndef IPMI_BMC_H
#define IPMI_BMC_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
int ipmi_event_main(struct ipmi_intf *, int, char **);
#define BMC_GET_DEVICE_ID 0x01
#define BMC_COLD_RESET 0x02
#define BMC_WARM_RESET 0x03
#define BMC_GET_SELF_TEST 0x04
#endif /*IPMI_EVENT_H*/
int ipmi_bmc_main(struct ipmi_intf *, int, char **);
#endif /*IPMI_BMC_H*/

View File

@ -1,233 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_CHANNEL_H
#define IPMI_CHANNEL_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
#define IPMI_GET_CHANNEL_AUTH_CAP 0x38
#define IPMI_GET_CHANNEL_ACCESS 0x41
#define IPMI_GET_CHANNEL_INFO 0x42
#define IPMI_SET_USER_ACCESS 0x43
#define IPMI_GET_USER_ACCESS 0x44
#define IPMI_SET_USER_NAME 0x45
#define IPMI_GET_USER_NAME 0x46
#define IPMI_SET_USER_PASSWORD 0x47
#define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54
/*
* The Get Authentication Capabilities response structure
* From table 22-15 of the IPMI v2.0 spec
*/
struct get_channel_auth_cap_rsp {
uint8_t channel_number;
#if WORDS_BIGENDIAN
uint8_t v20_data_available : 1; /* IPMI v2.0 data is available */
uint8_t __reserved1 : 1;
uint8_t enabled_auth_types : 6; /* IPMI v1.5 enabled auth types */
#else
uint8_t enabled_auth_types : 6; /* IPMI v1.5 enabled auth types */
uint8_t __reserved1 : 1;
uint8_t v20_data_available : 1; /* IPMI v2.0 data is available */
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved2 : 2;
uint8_t kg_status : 1; /* two-key login status */
uint8_t per_message_auth : 1; /* per-message authentication status */
uint8_t user_level_auth : 1; /* user-level authentication status */
uint8_t non_null_usernames : 1; /* one or more non-null users exist */
uint8_t null_usernames : 1; /* one or more null usernames non-null pwds */
uint8_t anon_login_enabled : 1; /* a null-named, null-pwd user exists */
#else
uint8_t anon_login_enabled : 1; /* a null-named, null-pwd user exists */
uint8_t null_usernames : 1; /* one or more null usernames non-null pwds */
uint8_t non_null_usernames : 1; /* one or more non-null users exist */
uint8_t user_level_auth : 1; /* user-level authentication status */
uint8_t per_message_auth : 1; /* per-message authentication status */
uint8_t kg_status : 1; /* two-key login status */
uint8_t __reserved2 : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved3 : 6;
uint8_t ipmiv15_support : 1; /* channel supports IPMI v1.5 connections */
uint8_t ipmiv20_support : 1; /* channel supports IPMI v2.0 connections */
#else
uint8_t ipmiv20_support : 1; /* channel supports IPMI v2.0 connections */
uint8_t ipmiv15_support : 1; /* channel supports IPMI v1.5 connections */
uint8_t __reserved3 : 6;
#endif
uint8_t oem_id[3]; /* IANA enterprise number for auth type */
uint8_t oem_aux_data; /* Additional OEM specific data for oem auths */
} __attribute__ ((packed));
/*
* The Get Channel Info response structure
* From table 22-29 of the IPMI v2.0 spec
*/
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__ ((packed));
/*
* The Get Channel Access response structure
* From table 22-28 of the IPMI v2.0 spec
*/
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__ ((packed));
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__ ((packed));
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__ ((packed));
uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel);
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_info(struct ipmi_intf * intf, uint8_t channel);
#endif /*IPMI_CHANNEL_H*/

View File

@ -1,115 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_CONSTANTS_H
#define IPMI_CONSTANTS_H
/*
* COMMANDS
*/
#define IPMI_GET_SDR_REPOSITORY_INFO 0x20
#define IMPI_SOL_ACTIVATING 0x20
#define IMPI_SET_SOL_CONFIG_PARAMETERS 0x21
#define IMPI_GET_SOL_CONFIG_PARAMETERS 0x22
#define IPMI_SET_USER_ACCESS 0x43
#define IPMI_GET_USER_ACCESS 0x44
#define IPMI_SET_USER_NAME 0x45
#define IPMI_GET_USER_NAME 0x46
#define IPMI_SET_USER_PASSWORD 0x47
#define IPMI_ACTIVATE_PAYLOAD 0x48
#define IPMI_DEACTIVATE_PAYLOAD 0x49
#define IPMI_SUSPEND_RESUME_PAYLOAD_ENCRYPTYION 0x55
#define IPMI_GET_SEL_TIME 0x48
#define IPMI_SET_SEL_TIME 0x49
#define IPMI_1_5_AUTH_TYPE_BIT_NONE 0x01
#define IPMI_1_5_AUTH_TYPE_BIT_MD2 0x02
#define IPMI_1_5_AUTH_TYPE_BIT_MD5 0x04
#define IPMI_1_5_AUTH_TYPE_BIT_PASSWORD 0x10
#define IPMI_1_5_AUTH_TYPE_BIT_OEM 0x20
#define IPMI_SESSION_AUTHTYPE_NONE 0x0
#define IPMI_SESSION_AUTHTYPE_MD2 0x1
#define IPMI_SESSION_AUTHTYPE_MD5 0x2
#define IPMI_SESSION_AUTHTYPE_KEY 0x4
#define IPMI_SESSION_AUTHTYPE_PASSWORD IPMI_SESSION_AUTHTYPE_KEY
#define IPMI_SESSION_AUTHTYPE_OEM 0x5
#define IPMI_SESSION_AUTHTYPE_RMCP_PLUS 0x6
#define IPMI_SESSION_PRIV_UNSPECIFIED 0x0
#define IPMI_SESSION_PRIV_CALLBACK 0x1
#define IPMI_SESSION_PRIV_USER 0x2
#define IPMI_SESSION_PRIV_OPERATOR 0x3
#define IPMI_SESSION_PRIV_ADMIN 0x4
#define IPMI_SESSION_PRIV_OEM 0x5
#define IPMI_SET_IN_PROGRESS_SET_COMPLETE 0x00
#define IPMI_SET_IN_PROGRESS_IN_PROGRESS 0x01
#define IPMI_SET_IN_PROGRESS_COMMIT_WRITE 0x02
#define IPMI_CHANNEL_MEDIUM_RESERVED 0x0
#define IPMI_CHANNEL_MEDIUM_IPMB 0x1
#define IPMI_CHANNEL_MEDIUM_ICMB_1 0x2
#define IPMI_CHANNEL_MEDIUM_ICMB_09 0x3
#define IPMI_CHANNEL_MEDIUM_LAN 0x4
#define IPMI_CHANNEL_MEDIUM_SERIAL 0x5
#define IPMI_CHANNEL_MEDIUM_LAN_OTHER 0x6
#define IPMI_CHANNEL_MEDIUM_SMBUS_PCI 0x7
#define IPMI_CHANNEL_MEDIUM_SMBUS_1 0x8
#define IPMI_CHANNEL_MEDIUM_SMBUS_2 0x9
#define IPMI_CHANNEL_MEDIUM_USB_1 0xa
#define IPMI_CHANNEL_MEDIUM_USB_2 0xb
#define IPMI_CHANNEL_MEDIUM_SYSTEM 0xc
/* From table 13-17 of the IPMI v2 specification */
#define IPMI_AUTH_RAKP_NONE 0x00
#define IPMI_AUTH_RAKP_HMAC_SHA1 0x01
#define IPMI_AUTH_RAKP_HMAC_MD5 0x02
/* 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
/* 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

@ -37,15 +37,97 @@
#ifndef IPMI_ENTITY_H
#define IPMI_ENTITY_H
struct entity_id {
uint8_t id; /* physical entity id */
#if WORDS_BIGENDIAN
uint8_t logical : 1; /* physical/logical */
uint8_t instance : 7; /* instance number */
#else
uint8_t instance : 7; /* instance number */
uint8_t logical : 1; /* physical/logical */
#endif
} __attribute__ ((packed));
#include <ipmitool/helper.h>
const struct valstr entity_id_vals[] __attribute__((unused)) = {
{ 0x00, "Unspecified" },
{ 0x01, "Other" },
{ 0x02, "Unknown" },
{ 0x03, "Processor" },
{ 0x04, "Disk or Disk Bay" },
{ 0x05, "Peripheral Bay" },
{ 0x06, "System Management Module" },
{ 0x07, "System Board" },
{ 0x08, "Memory Module" },
{ 0x09, "Processor Module" },
{ 0x0a, "Power Supply" },
{ 0x0b, "Add-in Card" },
{ 0x0c, "Front Panel Board" },
{ 0x0d, "Back Panel Board" },
{ 0x0e, "Power System Board" },
{ 0x0f, "Drive Backplane" },
{ 0x10, "System Internal Expansion Board" },
{ 0x11, "Other System Board" },
{ 0x12, "Processor Board" },
{ 0x13, "Power Unit" },
{ 0x14, "Power Module" },
{ 0x15, "Power Management" },
{ 0x16, "Chassis Back Panel Board" },
{ 0x17, "System Chassis" },
{ 0x18, "Sub-Chassis" },
{ 0x19, "Other Chassis Board" },
{ 0x1a, "Disk Drive Bay" },
{ 0x1b, "Peripheral Bay" },
{ 0x1c, "Device Bay" },
{ 0x1d, "Fan Device" },
{ 0x1e, "Cooling Unit" },
{ 0x1f, "Cable/Interconnect" },
{ 0x20, "Memory Device" },
{ 0x21, "System Management Software" },
{ 0x22, "BIOS" },
{ 0x23, "Operating System" },
{ 0x24, "System Bus" },
{ 0x25, "Group" },
{ 0x26, "Remote Management Device" },
{ 0x27, "External Environment" },
{ 0x28, "Battery" },
{ 0x00, NULL },
};
const struct valstr device_type_vals[] __attribute__((unused)) = {
{ 0x00, "Reserved" },
{ 0x01, "Reserved" },
{ 0x02, "DS1624 temperature sensor" },
{ 0x03, "DS1621 temperature sensor" },
{ 0x04, "LM75 Temperature Sensor" },
{ 0x05, "Heceta ASIC" },
{ 0x06, "Reserved" },
{ 0x07, "Reserved" },
{ 0x08, "EEPROM, 24C01" },
{ 0x09, "EEPROM, 24C02" },
{ 0x0a, "EEPROM, 24C04" },
{ 0x0b, "EEPROM, 24C08" },
{ 0x0c, "EEPROM, 24C16" },
{ 0x0d, "EEPROM, 24C17" },
{ 0x0e, "EEPROM, 24C32" },
{ 0x0f, "EEPROM, 24C64" },
{ 0x1000, "IPMI FRU Inventory" },
{ 0x1001, "DIMM Memory ID" },
{ 0x1002, "IPMI FRU Inventory" },
{ 0x1003, "System Processor Cartridge FRU" },
{ 0x11, "Reserved" },
{ 0x12, "Reserved" },
{ 0x13, "Reserved" },
{ 0x14, "PCF 8570 256 byte RAM" },
{ 0x15, "PCF 8573 clock/calendar" },
{ 0x16, "PCF 8574A I/O Port" },
{ 0x17, "PCF 8583 clock/calendar" },
{ 0x18, "PCF 8593 clock/calendar" },
{ 0x19, "Clock calendar" },
{ 0x1a, "PCF 8591 A/D, D/A Converter" },
{ 0x1b, "I/O Port" },
{ 0x1c, "A/D Converter" },
{ 0x1d, "D/A Converter" },
{ 0x1e, "A/D, D/A Converter" },
{ 0x1f, "LCD Controler/Driver" },
{ 0x20, "Core Logic (Chip set) Device" },
{ 0x21, "LMC6874 Intelligent Battery controller" },
{ 0x22, "Intelligent Batter controller" },
{ 0x23, "Combo Management ASIC" },
{ 0x24, "Maxim 1617 Temperature Sensor" },
{ 0xbf, "Other/Unspecified" },
{ 0x00, NULL },
};
#endif /* IPMI_ENTITY_H */

View File

@ -37,9 +37,8 @@
#ifndef IPMI_FRU_H
#define IPMI_FRU_H
#include <inttypes.h>
#include <stdint.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
#if HAVE_CONFIG_H
# include <config.h>
@ -65,35 +64,35 @@ enum {
};
struct fru_info {
uint16_t size;
uint8_t access : 1;
unsigned short size;
unsigned char access : 1;
} __attribute__ ((packed));
struct fru_header {
uint8_t version;
unsigned char version;
struct {
uint8_t internal;
uint8_t chassis;
uint8_t board;
uint8_t product;
uint8_t multi;
unsigned char internal;
unsigned char chassis;
unsigned char board;
unsigned char product;
unsigned char multi;
} offset;
uint8_t pad;
uint8_t checksum;
unsigned char pad;
unsigned char checksum;
} __attribute__ ((packed));
struct fru_area_chassis {
uint8_t area_ver;
uint8_t type;
uint16_t area_len;
unsigned char area_ver;
unsigned char area_len;
unsigned char type;
char * part;
char * serial;
};
struct fru_area_board {
uint8_t area_ver;
uint8_t lang;
uint16_t area_len;
unsigned char area_ver;
unsigned char area_len;
unsigned char lang;
uint32_t mfg_date_time;
char * mfg;
char * prod;
@ -103,9 +102,9 @@ struct fru_area_board {
};
struct fru_area_product {
uint8_t area_ver;
uint8_t lang;
uint16_t area_len;
unsigned char area_ver;
unsigned char area_len;
unsigned char lang;
char * mfg;
char * name;
char * part;
@ -122,55 +121,55 @@ struct fru_multirec_header {
#define FRU_RECORD_TYPE_MANAGEMENT_ACCESS 0x03
#define FRU_RECORD_TYPE_BASE_COMPATIBILITY 0x04
#define FRU_RECORD_TYPE_EXTENDED_COMPATIBILITY 0x05
uint8_t type;
uint8_t format;
uint8_t len;
uint8_t record_checksum;
uint8_t header_checksum;
unsigned char type;
unsigned char format;
unsigned char len;
unsigned char record_checksum;
unsigned char header_checksum;
} __attribute__ ((packed));
struct fru_multirec_powersupply {
#if WORDS_BIGENDIAN
uint16_t capacity;
unsigned short capacity;
#else
uint16_t capacity : 12;
uint16_t __reserved1 : 4;
unsigned short capacity : 12;
unsigned short __reserved1 : 4;
#endif
uint16_t peak_va;
uint8_t inrush_current;
uint8_t inrush_interval;
uint16_t lowend_input1;
uint16_t highend_input1;
uint16_t lowend_input2;
uint16_t highend_input2;
uint8_t lowend_freq;
uint8_t highend_freq;
uint8_t dropout_tolerance;
unsigned short peak_va;
unsigned char inrush_current;
unsigned char inrush_interval;
unsigned short lowend_input1;
unsigned short highend_input1;
unsigned short lowend_input2;
unsigned short highend_input2;
unsigned char lowend_freq;
unsigned char highend_freq;
unsigned char dropout_tolerance;
#if WORDS_BIGENDIAN
uint8_t __reserved2 : 3;
uint8_t tach : 1;
uint8_t hotswap : 1;
uint8_t autoswitch : 1;
uint8_t pfc : 1;
uint8_t predictive_fail : 1;
unsigned char __reserved2 : 3;
unsigned char tach : 1;
unsigned char hotswap : 1;
unsigned char autoswitch : 1;
unsigned char pfc : 1;
unsigned char predictive_fail : 1;
#else
uint8_t predictive_fail : 1;
uint8_t pfc : 1;
uint8_t autoswitch : 1;
uint8_t hotswap : 1;
uint8_t tach : 1;
uint8_t __reserved2 : 3;
unsigned char predictive_fail : 1;
unsigned char pfc : 1;
unsigned char autoswitch : 1;
unsigned char hotswap : 1;
unsigned char tach : 1;
unsigned char __reserved2 : 3;
#endif
uint16_t peak_cap_ht;
unsigned short peak_cap_ht;
#if WORDS_BIGENDIAN
uint8_t combined_voltage1 : 4;
uint8_t combined_voltage2 : 4;
unsigned char combined_voltage1 : 4;
unsigned char combined_voltage2 : 4;
#else
uint8_t combined_voltage2 : 4;
uint8_t combined_voltage1 : 4;
unsigned char combined_voltage2 : 4;
unsigned char combined_voltage1 : 4;
#endif
uint16_t combined_capacity;
uint8_t rps_threshold;
unsigned short combined_capacity;
unsigned char rps_threshold;
} __attribute__ ((packed));
static const char * combined_voltage_desc[] __attribute__((unused)) = {
@ -179,36 +178,36 @@ static const char * combined_voltage_desc[] __attribute__((unused)) = {
struct fru_multirec_dcoutput {
#if WORDS_BIGENDIAN
uint8_t standby : 1;
uint8_t __reserved : 3;
uint8_t output_number : 4;
unsigned char standby : 1;
unsigned char __reserved : 3;
unsigned char output_number : 4;
#else
uint8_t output_number : 4;
uint8_t __reserved : 3;
uint8_t standby : 1;
unsigned char output_number : 4;
unsigned char __reserved : 3;
unsigned char standby : 1;
#endif
short nominal_voltage;
short max_neg_dev;
short max_pos_dev;
uint16_t ripple_and_noise;
uint16_t min_current;
uint16_t max_current;
unsigned short ripple_and_noise;
unsigned short min_current;
unsigned short max_current;
} __attribute__ ((packed));
struct fru_multirec_dcload {
#if WORDS_BIGENDIAN
uint8_t __reserved : 4;
uint8_t output_number : 4;
unsigned char __reserved : 4;
unsigned char output_number : 4;
#else
uint8_t output_number : 4;
uint8_t __reserved : 4;
unsigned char output_number : 4;
unsigned char __reserved : 4;
#endif
short nominal_voltage;
short min_voltage;
short max_voltage;
uint16_t ripple_and_noise;
uint16_t min_current;
uint16_t max_current;
unsigned short ripple_and_noise;
unsigned short min_current;
unsigned short max_current;
} __attribute__ ((packed));
static const char * chassis_type_desc[] __attribute__((unused)) = {
@ -222,7 +221,7 @@ static const char * chassis_type_desc[] __attribute__((unused)) = {
"Rack Mount Chassis"
};
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);
void ipmi_print_fru(struct ipmi_intf *, unsigned char);
int ipmi_fru_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_FRU_H */

View File

@ -38,148 +38,14 @@
#define IPMI_INTF_H
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_oem.h>
#include <ipmitool/ipmi_constants.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
/*
* An enumeration that describes every possible session state for
* an IPMIv2 / RMCP+ session.
*/
enum LANPLUS_SESSION_STATE {
LANPLUS_STATE_PRESESSION = 0,
LANPLUS_STATE_OPEN_SESSION_SENT,
LANPLUS_STATE_OPEN_SESSION_RECEIEVED,
LANPLUS_STATE_RAKP_1_SENT,
LANPLUS_STATE_RAKP_2_RECEIVED,
LANPLUS_STATE_RAKP_3_SENT,
LANPLUS_STATE_ACTIVE,
LANPLUS_STATE_CLOSE_SENT,
};
#define IPMI_AUTHCODE_BUFFER_SIZE 20
#define IPMI_SIK_BUFFER_SIZE 20
#define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */
struct ipmi_session {
uint8_t hostname[64];
uint8_t username[16];
uint8_t authcode[IPMI_AUTHCODE_BUFFER_SIZE + 1];
uint8_t challenge[16];
uint8_t authtype;
uint8_t authtype_set;
#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
uint8_t authstatus;
uint8_t authextra;
uint8_t privlvl;
uint8_t cipher_suite_id;
int password;
int port;
int active;
uint32_t session_id;
uint32_t in_seq;
uint32_t out_seq;
uint32_t timeout;
struct sockaddr_in addr;
socklen_t addrlen;
/*
* This struct holds state data specific to IMPI v2 / RMCP+ sessions
*/
struct {
enum LANPLUS_SESSION_STATE session_state;
/* These are the algorithms agreed upon for the session */
uint8_t requested_auth_alg;
uint8_t requested_integrity_alg;
uint8_t requested_crypt_alg;
uint8_t auth_alg;
uint8_t integrity_alg;
uint8_t crypt_alg;
uint8_t max_priv_level;
uint32_t console_id;
uint32_t bmc_id;
/*
* Values required for RAKP mesages
*/
/* Random number generated byt the console */
uint8_t console_rand[16];
/* Random number generated by the BMC */
uint8_t bmc_rand[16];
uint8_t bmc_guid[16];
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 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;
/*
* This data is specific to the Serial Over Lan session
*/
struct {
uint16_t max_inbound_payload_size;
uint16_t max_outbound_payload_size;
uint16_t port;
uint8_t sequence_number;
/* This data describes the last SOL packet */
uint8_t last_received_sequence_number;
uint8_t last_received_byte_count;
void (*sol_input_handler)(struct ipmi_rs * rsp);
} sol_data;
};
struct ipmi_intf {
char name[16];
char desc[128];
int fd;
int opened;
int abort;
struct ipmi_session * session;
struct ipmi_oem_handle * oem;
uint32_t my_addr;
uint32_t target_addr;
int (*setup)(struct ipmi_intf * 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);
struct static_intf {
char * name;
int (*setup)(struct ipmi_intf ** intf);
};
int ipmi_intf_init(void);
void ipmi_intf_exit(void);
struct ipmi_intf * ipmi_intf_load(char * name);
void ipmi_intf_print(void);
void ipmi_intf_session_set_hostname(struct ipmi_intf * intf, char * hostname);
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_cipher_suite_id(struct ipmi_intf * intf, uint8_t cipher_suite_id);
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_cleanup(struct ipmi_intf * intf);
#endif /* IPMI_INTF_H */

View File

@ -1,60 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_ISOL_H
#define IPMI_ISOL_H
#include <ipmitool/ipmi.h>
#define ACTIVATE_ISOL 0x01
#define SET_ISOL_CONFIG 0x03
#define GET_ISOL_CONFIG 0x04
#define ISOL_ENABLE_PARAM 0x01
#define ISOL_AUTHENTICATION_PARAM 0x02
#define ISOL_ENABLE_FLAG 0x01
#define ISOL_PRIVILEGE_LEVEL_USER 0x02
#define ISOL_BAUD_RATE_PARAM 0x05
#define ISOL_BAUD_RATE_9600 0x06
#define ISOL_BAUD_RATE_19200 0x07
#define ISOL_BAUD_RATE_38400 0x08
#define ISOL_BAUD_RATE_57600 0x09
#define ISOL_BAUD_RATE_115200 0x0A
#define ISOL_PREFERRED_BAUD_RATE 0x07
int ipmi_isol_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_SOL_H */

View File

@ -46,13 +46,21 @@
# define IPMI_LAN_SUSPEND_ARP_GRAT (1)
#define IPMI_LAN_GET_STAT 0x04
#define IPMI_CHANNEL_NUMBER_MAX 0xd
#define IPMI_SESSION_AUTHTYPE_NONE 0x0
#define IPMI_SESSION_AUTHTYPE_MD2 0x1
#define IPMI_SESSION_AUTHTYPE_MD5 0x2
#define IPMI_SESSION_AUTHTYPE_KEY 0x4
#define IPMI_SESSION_AUTHTYPE_OEM 0x5
#define IPMI_LANP_TIMEOUT 3
#define IPMI_LANP_RETRIES 10
#define IPMI_LANP_WRITE_UNLOCK 0
#define IPMI_LANP_WRITE_LOCK 1
#define IPMI_LANP_WRITE_COMMIT 2
#define IPMI_SESSION_PRIV_CALLBACK 0x1
#define IPMI_SESSION_PRIV_USER 0x2
#define IPMI_SESSION_PRIV_OPERATOR 0x3
#define IPMI_SESSION_PRIV_ADMIN 0x4
#define IPMI_SESSION_PRIV_OEM 0x5
extern const struct valstr ipmi_privlvl_vals[];
extern const struct valstr ipmi_authtype_vals[];
extern struct ipmi_session lan_session;
enum {
IPMI_LANP_SET_IN_PROGRESS,
@ -60,26 +68,21 @@ enum {
IPMI_LANP_AUTH_TYPE_ENABLE,
IPMI_LANP_IP_ADDR,
IPMI_LANP_IP_ADDR_SRC,
IPMI_LANP_MAC_ADDR, /* 5 */
IPMI_LANP_MAC_ADDR,
IPMI_LANP_SUBNET_MASK,
IPMI_LANP_IP_HEADER,
IPMI_LANP_PRI_RMCP_PORT,
IPMI_LANP_SEC_RMCP_PORT,
IPMI_LANP_BMC_ARP, /* 10 */
IPMI_LANP_BMC_ARP,
IPMI_LANP_GRAT_ARP,
IPMI_LANP_DEF_GATEWAY_IP,
IPMI_LANP_DEF_GATEWAY_MAC,
IPMI_LANP_BAK_GATEWAY_IP,
IPMI_LANP_BAK_GATEWAY_MAC, /* 15 */
IPMI_LANP_BAK_GATEWAY_MAC,
IPMI_LANP_SNMP_STRING,
IPMI_LANP_NUM_DEST,
IPMI_LANP_DEST_TYPE,
IPMI_LANP_DEST_ADDR,
IPMI_LANP_VLAN_ID, /* 20 */
IPMI_LANP_VLAN_PRIORITY,
IPMI_LANP_RMCP_CIPHER_SUPPORT,
IPMI_LANP_RMCP_CIPHERS,
IPMI_LANP_RMCP_PRIV_LEVELS,
IPMI_LANP_OEM_ALERT_STRING=96,
IPMI_LANP_ALERT_RETRY=97,
IPMI_LANP_UTC_OFFSET=98,
@ -93,44 +96,39 @@ static struct lan_param {
int cmd;
int size;
char desc[24];
uint8_t * data;
int data_len;
unsigned char * data;
} 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, 1, "Auth Type" },
{ 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_MAC_ADDR, 6, "MAC Address" },
{ 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_BMC_ARP, 1, "BMC ARP Control" },
{ 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_BAK_GATEWAY_MAC, 6, "Backup Gateway MAC" },
{ IPMI_LANP_SNMP_STRING, 18, "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_OEM_ALERT_STRING, 28, "OEM Alert String" },
{ 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_DHCP_SERVER_MAC, 6, "DHDP Server MAC" },
{ IPMI_LANP_DHCP_ENABLE, 1, "DHCP Enable" },
{ IPMI_LANP_CHAN_ACCESS_MODE, 2, "Channel Access Mode" },
{ -1 }
};
void ipmi_get_channel_info(struct ipmi_intf * intf, unsigned char channel);
int ipmi_lanp_main(struct ipmi_intf *, int, char **);
#endif /*IPMI_LANP_H*/

View File

@ -1,87 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_MC_H
#define IPMI_MC_H
#include <ipmitool/ipmi.h>
#define BMC_GET_DEVICE_ID 0x01
#define BMC_COLD_RESET 0x02
#define BMC_WARM_RESET 0x03
#define BMC_GET_SELF_TEST 0x04
#define BMC_SET_GLOBAL_ENABLES 0x2e
#define BMC_GET_GLOBAL_ENABLES 0x2f
#define BMC_GET_GUID 0x37
int ipmi_mc_main(struct ipmi_intf *, int, char **);
/*
* Response data from IPM Get Device ID Command (IPMI rev 1.5, section 17.1)
* The following really apply to any IPM device, not just BMCs...
*/
struct ipm_devid_rsp {
uint8_t device_id;
uint8_t device_revision;
uint8_t fw_rev1;
uint8_t fw_rev2;
uint8_t ipmi_version;
uint8_t adtl_device_support;
uint8_t manufacturer_id[3];
uint8_t product_id[2];
uint8_t aux_fw_rev[4];
} __attribute__ ((packed));
#define IPM_DEV_DEVICE_ID_SDR_MASK (0x80) /* 1 = provides SDRs */
#define IPM_DEV_DEVICE_ID_REV_MASK (0x07) /* BCD-enoded */
#define IPM_DEV_FWREV1_AVAIL_MASK (0x80) /* 0 = normal operation */
#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 */
#define IPM_DEV_IPMI_VER_MINOR_SHIFT (4) /* Minor rev shift */
#define IPM_DEV_IPMI_VERSION_MAJOR(x) \
(x & IPM_DEV_IPMI_VER_MAJOR_MASK)
#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(x) \
((uint32_t) ((x[2] & 0x0F) << 16 | x[1] << 8 | x[0]))
#define IPM_DEV_ADTL_SUPPORT_BITS (8)
#endif /*IPMI_MC_H*/

View File

@ -1,51 +0,0 @@
/*
* 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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_OEM_H
#define IPMI_OEM_H
#include <ipmitool/ipmi.h>
/* oem handler, see lib/ipmi_oem.c */
struct ipmi_oem_handle {
const char * name;
const char * desc;
int (*setup)(struct ipmi_intf * intf);
};
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

@ -1,788 +0,0 @@
/*
* Copyright (c) 2004 Dell Computers. 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 Dell Computers, 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.
* DELL COMPUTERS ("DELL") 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
* DELL 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 DELL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_PEF_H
#define IPMI_PEF_H
#include <ipmitool/ipmi.h>
/* PEF */
struct pef_capabilities { /* "get pef capabilities" response */
uint8_t version;
uint8_t actions; /* mapped by PEF_ACTION_xxx */
uint8_t tblsize;
};
typedef enum {
P_TRUE,
P_SUPP,
P_ACTV,
P_ABLE,
} flg_e;
struct pef_table_entry {
#define PEF_CONFIG_ENABLED 0x80
#define PEF_CONFIG_PRECONFIGURED 0x40
uint8_t config;
#define PEF_ACTION_DIAGNOSTIC_INTERRUPT 0x20
#define PEF_ACTION_OEM 0x10
#define PEF_ACTION_POWER_CYCLE 0x08
#define PEF_ACTION_RESET 0x04
#define PEF_ACTION_POWER_DOWN 0x02
#define PEF_ACTION_ALERT 0x01
uint8_t action;
#define PEF_POLICY_NUMBER_MASK 0x0f
uint8_t policy_number;
#define PEF_SEVERITY_NON_RECOVERABLE 0x20
#define PEF_SEVERITY_CRITICAL 0x10
#define PEF_SEVERITY_WARNING 0x08
#define PEF_SEVERITY_OK 0x04
#define PEF_SEVERITY_INFORMATION 0x02
#define PEF_SEVERITY_MONITOR 0x01
uint8_t severity;
uint8_t generator_ID_addr;
uint8_t generator_ID_lun;
uint8_t sensor_type;
#define PEF_SENSOR_NUMBER_MATCH_ANY 0xff
uint8_t sensor_number;
#define PEF_EVENT_TRIGGER_UNSPECIFIED 0x0
#define PEF_EVENT_TRIGGER_THRESHOLD 0x1
#define PEF_EVENT_TRIGGER_SENSOR_SPECIFIC 0x6f
#define PEF_EVENT_TRIGGER_MATCH_ANY 0xff
uint8_t event_trigger;
uint8_t event_data_1_offset_mask[2];
uint8_t event_data_1_AND_mask;
uint8_t event_data_1_compare_1;
uint8_t event_data_1_compare_2;
uint8_t event_data_2_AND_mask;
uint8_t event_data_2_compare_1;
uint8_t event_data_2_compare_2;
uint8_t event_data_3_AND_mask;
uint8_t event_data_3_compare_1;
uint8_t event_data_3_compare_2;
} __attribute__ ((packed));
struct desc_map { /* maps a description to a value/mask */
const char *desc;
uint32_t mask;
};
struct bit_desc_map { /* description text container */
#define BIT_DESC_MAP_LIST 0x1 /* index-based text array */
#define BIT_DESC_MAP_ANY 0x2 /* bitwise, but only print 1st one */
#define BIT_DESC_MAP_ALL 0x3 /* bitwise, print them all */
uint32_t desc_map_type;
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]))
struct pef_policy_entry {
#define PEF_POLICY_ID_MASK 0xf0
#define PEF_POLICY_ID_SHIFT 4
#define PEF_POLICY_ENABLED 0x08
#define PEF_POLICY_FLAGS_MASK 0x07
#define PEF_POLICY_FLAGS_MATCH_ALWAYS 0
#define PEF_POLICY_FLAGS_PREV_OK_SKIP 1
#define PEF_POLICY_FLAGS_PREV_OK_NEXT_POLICY_SET 2
#define PEF_POLICY_FLAGS_PREV_OK_NEXT_CHANNEL_IN_SET 3
#define PEF_POLICY_FLAGS_PREV_OK_NEXT_DESTINATION_IN_SET 4
uint8_t policy;
#define PEF_POLICY_CHANNEL_MASK 0xf0
#define PEF_POLICY_CHANNEL_SHIFT 4
#define PEF_POLICY_DESTINATION_MASK 0x0f
uint8_t chan_dest;
#define PEF_POLICY_EVENT_SPECIFIC 0x80
uint8_t alert_string_key;
} __attribute__ ((packed));
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}
} };
struct pef_cfgparm_selector {
#define PEF_CFGPARM_ID_REVISION_ONLY_MASK 0x80
#define PEF_CFGPARM_ID_SET_IN_PROGRESS 0
#define PEF_CFGPARM_ID_PEF_CONTROL 1
#define PEF_CFGPARM_ID_PEF_ACTION 2
#define PEF_CFGPARM_ID_PEF_STARTUP_DELAY 3
#define PEF_CFGPARM_ID_PEF_ALERT_STARTUP_DELAY 4
#define PEF_CFGPARM_ID_PEF_FILTER_TABLE_SIZE 5
#define PEF_CFGPARM_ID_PEF_FILTER_TABLE_ENTRY 6
#define PEF_CFGPARM_ID_PEF_FILTER_TABLE_DATA_1 7
#define PEF_CFGPARM_ID_PEF_ALERT_POLICY_TABLE_SIZE 8
#define PEF_CFGPARM_ID_PEF_ALERT_POLICY_TABLE_ENTRY 9
#define PEF_CFGPARM_ID_SYSTEM_GUID 10
#define PEF_CFGPARM_ID_PEF_ALERT_STRING_TABLE_SIZE 11
#define PEF_CFGPARM_ID_PEF_ALERT_STRING_KEY 12
#define PEF_CFGPARM_ID_PEF_ALERT_STRING_TABLE_ENTRY 13
uint8_t id;
uint8_t set;
uint8_t block;
} __attribute__ ((packed));
struct pef_cfgparm_set_in_progress {
#define PEF_SET_IN_PROGRESS_COMMIT_WRITE 0x02
#define PEF_SET_IN_PROGRESS 0x01
uint8_t data1;
} __attribute__ ((packed));
struct pef_cfgparm_control {
#define PEF_CONTROL_ENABLE_ALERT_STARTUP_DELAY 0x08
#define PEF_CONTROL_ENABLE_STARTUP_DELAY 0x04
#define PEF_CONTROL_ENABLE_EVENT_MESSAGES 0x02
#define PEF_CONTROL_ENABLE 0x01
uint8_t data1;
} __attribute__ ((packed));
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}
} };
struct pef_cfgparm_action {
#define PEF_ACTION_ENABLE_DIAGNOSTIC_INTERRUPT 0x20
#define PEF_ACTION_ENABLE_OEM 0x10
#define PEF_ACTION_ENABLE_POWER_CYCLE 0x08
#define PEF_ACTION_ENABLE_RESET 0x04
#define PEF_ACTION_ENABLE_POWER_DOWN 0x02
#define PEF_ACTION_ENABLE_ALERT 0x01
uint8_t data1;
} __attribute__ ((packed));
struct pef_cfgparm_startup_delay {
uint8_t data1;
} __attribute__ ((packed));
struct pef_cfgparm_alert_startup_delay {
uint8_t data1;
} __attribute__ ((packed));
struct pef_cfgparm_filter_table_size {
#define PEF_FILTER_TABLE_SIZE_MASK 0x7f
uint8_t data1;
} __attribute__ ((packed));
struct pef_cfgparm_filter_table_entry {
#define PEF_FILTER_TABLE_ID_MASK 0x7f
uint8_t data1;
struct pef_table_entry entry;
} __attribute__ ((packed));
struct pef_cfgparm_filter_table_data_1 {
uint8_t data1;
uint8_t data2;
} __attribute__ ((packed));
struct pef_cfgparm_policy_table_size {
#define PEF_POLICY_TABLE_SIZE_MASK 0x7f
uint8_t data1;
} __attribute__ ((packed));
struct pef_cfgparm_policy_table_entry {
#define PEF_POLICY_TABLE_ID_MASK 0x7f
uint8_t data1;
struct pef_policy_entry entry;
} __attribute__ ((packed));
struct pef_cfgparm_system_guid {
#define PEF_SYSTEM_GUID_USED_IN_PET 0x01
uint8_t data1;
uint8_t guid[16];
} __attribute__ ((packed));
struct pef_cfgparm_alert_string_table_size {
#define PEF_ALERT_STRING_TABLE_SIZE_MASK 0x7f
uint8_t data1;
} __attribute__ ((packed));
struct pef_cfgparm_alert_string_keys {
#define PEF_ALERT_STRING_ID_MASK 0x7f
uint8_t data1;
#define PEF_EVENT_FILTER_ID_MASK 0x7f
uint8_t data2;
#define PEF_ALERT_STRING_SET_ID_MASK 0x7f
uint8_t data3;
} __attribute__ ((packed));
struct pef_cfgparm_alert_string_table_entry {
uint8_t id;
uint8_t blockno;
uint8_t block[16];
} __attribute__ ((packed));
/* PEF - LAN */
struct pef_lan_cfgparm_selector {
#define PEF_LAN_CFGPARM_CH_REVISION_ONLY_MASK 0x80
#define PEF_LAN_CFGPARM_CH_MASK 0x0f
#define PEF_LAN_CFGPARM_ID_PET_COMMUNITY 16
#define PEF_LAN_CFGPARM_ID_DEST_COUNT 17
#define PEF_LAN_CFGPARM_ID_DESTTYPE 18
#define PEF_LAN_CFGPARM_ID_DESTADDR 19
uint8_t ch;
uint8_t id;
uint8_t set;
uint8_t block;
} __attribute__ ((packed));
struct pef_lan_cfgparm_dest_size {
#define PEF_LAN_DEST_TABLE_SIZE_MASK 0x0f
uint8_t data1;
} __attribute__ ((packed));
struct pef_lan_cfgparm_dest_type {
#define PEF_LAN_DEST_TYPE_ID_MASK 0x0f
uint8_t dest;
#define PEF_LAN_DEST_TYPE_ACK 0x80
#define PEF_LAN_DEST_TYPE_MASK 0x07
#define PEF_LAN_DEST_TYPE_PET 0
#define PEF_LAN_DEST_TYPE_OEM_1 6
#define PEF_LAN_DEST_TYPE_OEM_2 7
uint8_t dest_type;
uint8_t alert_timeout;
#define PEF_LAN_RETRIES_MASK 0x07
uint8_t retries;
} __attribute__ ((packed));
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}
} };
struct pef_lan_cfgparm_dest_info {
#define PEF_LAN_DEST_MASK 0x0f
uint8_t dest;
#define PEF_LAN_DEST_ADDRTYPE_MASK 0xf0
#define PEF_LAN_DEST_ADDRTYPE_SHIFT 4
#define PEF_LAN_DEST_ADDRTYPE_IPV4_MAC 0x00
uint8_t addr_type;
#define PEF_LAN_DEST_GATEWAY_USE_BACKUP 0x01
uint8_t gateway;
uint8_t ip[4];
uint8_t mac[6];
} __attribute__ ((packed));
/* PEF - Serial/PPP */
struct pef_serial_cfgparm_selector {
#define PEF_SERIAL_CFGPARM_CH_REVISION_ONLY_MASK 0x80
#define PEF_SERIAL_CFGPARM_CH_MASK 0x0f
#define PEF_SERIAL_CFGPARM_ID_DEST_COUNT 16
#define PEF_SERIAL_CFGPARM_ID_DESTINFO 17
#define PEF_SERIAL_CFGPARM_ID_DEST_DIAL_STRING_COUNT 20
#define PEF_SERIAL_CFGPARM_ID_DEST_DIAL_STRING 21
#define PEF_SERIAL_CFGPARM_ID_TAP_ACCT_COUNT 24
#define PEF_SERIAL_CFGPARM_ID_TAP_ACCT_INFO 25
#define PEF_SERIAL_CFGPARM_ID_TAP_ACCT_PAGER_STRING 27
uint8_t ch;
uint8_t id;
uint8_t set;
uint8_t block;
} __attribute__ ((packed));
struct pef_serial_cfgparm_dest_size {
#define PEF_SERIAL_DEST_TABLE_SIZE_MASK 0x0f
uint8_t data1;
} __attribute__ ((packed));
struct pef_serial_cfgparm_dest_info {
#define PEF_SERIAL_DEST_MASK 0x0f
uint8_t dest;
#define PEF_SERIAL_DEST_TYPE_ACK 0x80
#define PEF_SERIAL_DEST_TYPE_MASK 0x0f
#define PEF_SERIAL_DEST_TYPE_DIAL 0
#define PEF_SERIAL_DEST_TYPE_TAP 1
#define PEF_SERIAL_DEST_TYPE_PPP 2
#define PEF_SERIAL_DEST_TYPE_BASIC_CALLBACK 3
#define PEF_SERIAL_DEST_TYPE_PPP_CALLBACK 4
#define PEF_SERIAL_DEST_TYPE_OEM_1 14
#define PEF_SERIAL_DEST_TYPE_OEM_2 15
uint8_t dest_type;
uint8_t alert_timeout;
#define PEF_SERIAL_RETRIES_MASK 0x77
#define PEF_SERIAL_RETRIES_POST_CONNECT_MASK 0x70
#define PEF_SERIAL_RETRIES_PRE_CONNECT_MASK 0x07
uint8_t retries;
#define PEF_SERIAL_DIALPAGE_STRING_ID_MASK 0xf0
#define PEF_SERIAL_DIALPAGE_STRING_ID_SHIFT 4
#define PEF_SERIAL_TAP_PAGE_SERVICE_ID_MASK 0x0f
#define PEF_SERIAL_PPP_ACCT_IPADDR_ID_MASK 0xf0
#define PEF_SERIAL_PPP_ACCT_IPADDR_ID_SHIFT 4
#define PEF_SERIAL_PPP_ACCT_ID_MASK 0x0f
#define PEF_SERIAL_CALLBACK_IPADDR_ID_MASK 0x0f
#define PEF_SERIAL_CALLBACK_IPADDR_ID_SHIFT 4
#define PEF_SERIAL_CALLBACK_ACCT_ID_MASK 0xf0
uint8_t data5;
} __attribute__ ((packed));
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}
} };
struct pef_serial_cfgparm_dial_string_count {
#define PEF_SERIAL_DIAL_STRING_COUNT_MASK 0x0f
uint8_t data1;
} __attribute__ ((packed));
struct pef_serial_cfgparm_dial_string {
#define PEF_SERIAL_DIAL_STRING_MASK 0x0f
uint8_t data1;
uint8_t data2;
uint8_t data3;
} __attribute__ ((packed));
struct pef_serial_cfgparm_tap_acct_count {
#define PEF_SERIAL_TAP_ACCT_COUNT_MASK 0x0f
uint8_t data1;
} __attribute__ ((packed));
struct pef_serial_cfgparm_tap_acct_info {
uint8_t data1;
#define PEF_SERIAL_TAP_ACCT_INFO_DIAL_STRING_ID_MASK 0xf0
#define PEF_SERIAL_TAP_ACCT_INFO_DIAL_STRING_ID_SHIFT 4
#define PEF_SERIAL_TAP_ACCT_INFO_SVC_SETTINGS_ID_MASK 0x0f
uint8_t data2;
} __attribute__ ((packed));
struct pef_serial_cfgparm_tap_svc_settings {
uint8_t data1;
#define PEF_SERIAL_TAP_CONFIRMATION_ACK_AFTER_ETX 0x0
#define PEF_SERIAL_TAP_CONFIRMATION_211_ACK_AFTER_ETX 0x01
#define PEF_SERIAL_TAP_CONFIRMATION_21X_ACK_AFTER_ETX 0x02
uint8_t confirmation_flags;
uint8_t service_type[3];
uint8_t escape_mask[4];
uint8_t timeout_parms[3];
uint8_t retry_parms[2];
} __attribute__ ((packed));
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 */
struct pef_cfgparm_set_in_progress;
struct pef_cfgparm_control;
struct pef_cfgparm_action;
struct pef_cfgparm_startup_delay; /* in seconds, 1-based */
struct pef_cfgparm_alert_startup_delay; /* in seconds, 1-based */
struct pef_cfgparm_filter_table_size; /* 1-based, READ-ONLY */
struct pef_cfgparm_filter_table_entry;
struct pef_cfgparm_filter_table_data_1;
struct pef_cfgparm_policy_table_size;
struct pef_cfgparm_policy_table_entry;
struct pef_cfgparm_system_guid;
struct pef_cfgparm_alert_string_table_size;
struct pef_cfgparm_alert_string_keys;
struct pef_cfgparm_alert_string_table_entry;
} __attribute__ ((packed));
struct pef_lan_config_parms { /* LAN */
struct pef_lan_cfgparm_set_in_progress;
struct pef_lan_cfgparm_auth_capabilities;
struct pef_lan_cfgparm_auth_type;
struct pef_lan_cfgparm_ip_address;
struct pef_lan_cfgparm_ip_address_source;
struct pef_lan_cfgparm_mac_address;
struct pef_lan_cfgparm_subnet_mask;
struct pef_lan_cfgparm_ipv4_header_parms;
struct pef_lan_cfgparm_primary_rmcp_port;
struct pef_lan_cfgparm_secondary_rmcp_port;
struct pef_lan_cfgparm_bmc_generated_arp_control;
struct pef_lan_cfgparm_gratuitous_arp;
struct pef_lan_cfgparm_default_gateway_ipaddr;
struct pef_lan_cfgparm_default_gateway_macaddr;
struct pef_lan_cfgparm_backup_gateway_ipaddr;
struct pef_lan_cfgparm_backup_gateway_macaddr;
struct pef_lan_cfgparm_pet_community;
struct pef_lan_cfgparm_destination_count;
struct pef_lan_cfgparm_destination_type;
struct pef_lan_cfgparm_destination_ipaddr;
} __attribute__ ((packed));
struct pef_serial_config_parms { /* Serial/PPP */
struct pef_serial_cfgparm_set_in_progress;
struct pef_serial_cfgparm_auth_capabilities;
struct pef_serial_cfgparm_auth_type;
struct pef_serial_cfgparm_connection_mode;
struct pef_serial_cfgparm_idle_timeout;
struct pef_serial_cfgparm_callback_control;
struct pef_serial_cfgparm_session_termination;
struct pef_serial_cfgparm_ipmi_settings;
struct pef_serial_cfgparm_mux_control;
struct pef_serial_cfgparm_modem_ring_time;
struct pef_serial_cfgparm_modem_init_string;
struct pef_serial_cfgparm_modem_escape_sequence;
struct pef_serial_cfgparm_modem_hangup_sequence;
struct pef_serial_cfgparm_modem_dial_command;
struct pef_serial_cfgparm_page_blackout_interval;
struct pef_serial_cfgparm_pet_community;
struct pef_serial_cfgparm_destination_count;
struct pef_serial_cfgparm_destination_info;
struct pef_serial_cfgparm_call_retry_interval;
struct pef_serial_cfgparm_destination_settings;
struct pef_serial_cfgparm_dialstring_count;
struct pef_serial_cfgparm_dialstring_info;
struct pef_serial_cfgparm_ipaddr_count;
struct pef_serial_cfgparm_ipaddr_info;
struct pef_serial_cfgparm_tap_acct_count;
struct pef_serial_cfgparm_tap_acct_info;
struct pef_serial_cfgparm_tap_acct_passwords; /* WRITE only */
struct pef_serial_cfgparm_tap_pager_id_strings;
struct pef_serial_cfgparm_tap_service_settings;
struct pef_serial_cfgparm_terminal_mode_config;
struct pef_serial_cfgparm_ppp_otions;
struct pef_serial_cfgparm_ppp_primary_rmcp_port;
struct pef_serial_cfgparm_ppp_secondary_rmcp_port;
struct pef_serial_cfgparm_ppp_link_auth;
struct pef_serial_cfgparm_ppp_chap_name;
struct pef_serial_cfgparm_ppp_accm;
struct pef_serial_cfgparm_ppp_snoop_accm;
struct pef_serial_cfgparm_ppp_acct_count;
struct pef_serial_cfgparm_ppp_acct_dialstring_selector;
struct pef_serial_cfgparm_ppp_acct_ipaddrs;
struct pef_serial_cfgparm_ppp_acct_user_names;
struct pef_serial_cfgparm_ppp_acct_user_domains;
struct pef_serial_cfgparm_ppp_acct_user_passwords; /* WRITE only */
struct pef_serial_cfgparm_ppp_acct_auth_settings;
struct pef_serial_cfgparm_ppp_acct_connect_hold_times;
struct pef_serial_cfgparm_ppp_udp_proxy_ipheader;
struct pef_serial_cfgparm_ppp_udp_proxy_xmit_bufsize;
struct pef_serial_cfgparm_ppp_udp_proxy_recv_bufsize;
struct pef_serial_cfgparm_ppp_remote_console_ipaddr;
} __attribute__ ((packed));
#endif
#define IPMI_CMD_GET_PEF_CAPABILITIES 0x10
#define IPMI_CMD_GET_PEF_CONFIG_PARMS 0x13
#define IPMI_CMD_GET_LAST_PROCESSED_EVT_ID 0x15
#define IPMI_CMD_GET_SYSTEM_GUID 0x37
#define IPMI_CMD_GET_CHANNEL_INFO 0x42
#define IPMI_CMD_LAN_GET_CONFIG 0x02
#define IPMI_CMD_SERIAL_GET_CONFIG 0x11
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);
void ipmi_pef_print_hex(const char * text, uint32_t val);
void ipmi_pef_print_1xd(const char * text, uint32_t val);
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

@ -41,32 +41,31 @@
# include <config.h>
#endif
#include <inttypes.h>
#include <stdint.h>
#include <math.h>
#include <ipmitool/bswap.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_entity.h>
int ipmi_sdr_main(struct ipmi_intf *, int, char **);
int32_t utos(uint32_t val, int bits);
int utos(unsigned val, unsigned bits);
#if WORDS_BIGENDIAN
# define __TO_TOL(mtol) (uint16_t)(mtol & 0x3f)
# define __TO_M(mtol) (int16_t)(utos((((mtol & 0xff00) >> 8) | ((mtol & 0xc0) << 2)), 10))
# define __TO_B(bacc) (int32_t)(utos((((bacc & 0xff000000) >> 24) | ((bacc & 0xc00000) >> 14)), 10))
# define __TO_ACC(bacc) (uint32_t)(((bacc & 0x3f0000) >> 16) | ((bacc & 0xf000) >> 6))
# define __TO_ACC_EXP(bacc) (uint32_t)((bacc & 0xc00) >> 10)
# define __TO_R_EXP(bacc) (int32_t)(utos(((bacc & 0xf0) >> 4), 4))
# define __TO_B_EXP(bacc) (int32_t)(utos((bacc & 0xf), 4))
# define __TO_TOL(mtol) (unsigned short)(mtol & 0x3f)
# define __TO_M(mtol) (unsigned short)(utos((((mtol & 0xff00) >> 8) | ((mtol & 0xc0) << 2)), 10))
# define __TO_B(bacc) (unsigned int)(utos((((bacc & 0xff000000) >> 24) | ((bacc & 0xc00000) >> 14)), 10))
# define __TO_ACC(bacc) (unsigned int)(((bacc & 0x3f0000) >> 16) | ((bacc & 0xf000) >> 6))
# define __TO_ACC_EXP(bacc) (unsigned int)((bacc & 0xc00) >> 10)
# define __TO_R_EXP(bacc) (unsigned int)(utos(((bacc & 0xf0) >> 4), 4))
# define __TO_B_EXP(bacc) (unsigned int)(utos((bacc & 0xf), 4))
#else
# define __TO_TOL(mtol) (uint16_t)(BSWAP_16(mtol) & 0x3f)
# define __TO_M(mtol) (int16_t)(utos((((BSWAP_16(mtol) & 0xff00) >> 8) | ((BSWAP_16(mtol) & 0xc0) << 2)), 10))
# define __TO_B(bacc) (int32_t)(utos((((BSWAP_32(bacc) & 0xff000000) >> 24) | \
# define __TO_TOL(mtol) (unsigned short)(BSWAP_16(mtol) & 0x3f)
# define __TO_M(mtol) (unsigned short)(utos((((BSWAP_16(mtol) & 0xff00) >> 8) | ((BSWAP_16(mtol) & 0xc0) << 2)), 10))
# define __TO_B(bacc) (unsigned int)(utos((((BSWAP_32(bacc) & 0xff000000) >> 24) | \
((BSWAP_32(bacc) & 0xc00000) >> 14)), 10))
# define __TO_ACC(bacc) (uint32_t)(((BSWAP_32(bacc) & 0x3f0000) >> 16) | ((BSWAP_32(bacc) & 0xf000) >> 6))
# define __TO_ACC_EXP(bacc) (uint32_t)((BSWAP_32(bacc) & 0xc00) >> 10)
# define __TO_R_EXP(bacc) (int32_t)(utos(((BSWAP_32(bacc) & 0xf0) >> 4), 4))
# define __TO_B_EXP(bacc) (int32_t)(utos((BSWAP_32(bacc) & 0xf), 4))
# define __TO_ACC(bacc) (unsigned int)(((BSWAP_32(bacc) & 0x3f0000) >> 16) | ((BSWAP_32(bacc) & 0xf000) >> 6))
# define __TO_ACC_EXP(bacc) (unsigned int)((BSWAP_32(bacc) & 0xc00) >> 10)
# define __TO_R_EXP(bacc) (unsigned int)(utos(((BSWAP_32(bacc) & 0xf0) >> 4), 4))
# define __TO_B_EXP(bacc) (unsigned int)(utos((BSWAP_32(bacc) & 0xf), 4))
#endif
#define GET_SDR_REPO_INFO 0x20
@ -80,32 +79,33 @@ int32_t utos(uint32_t val, int bits);
#define SDR_SENSOR_STAT_HI_NR (1<<5)
struct sdr_repo_info_rs {
uint8_t version; /* SDR version (51h) */
uint16_t count; /* number of records */
uint16_t free; /* free space in SDR */
unsigned char version; /* SDR version (51h) */
unsigned short count; /* number of records */
unsigned short free; /* free space in SDR */
uint32_t add_stamp; /* last add timestamp */
uint32_t erase_stamp; /* last del timestamp */
uint8_t op_support; /* supported operations */
unsigned char op_support; /* supported operations */
} __attribute__ ((packed));
#define GET_SDR_RESERVE_REPO 0x22
struct sdr_reserve_repo_rs {
uint16_t reserve_id; /* reservation ID */
unsigned short reserve_id; /* reservation ID */
} __attribute__ ((packed));
#define GET_SDR 0x23
struct sdr_get_rq {
uint16_t reserve_id; /* reservation ID */
uint16_t id; /* record ID */
uint8_t offset; /* offset into SDR */
unsigned short reserve_id; /* reservation ID */
unsigned short id; /* record ID */
unsigned char offset; /* offset into SDR */
#define GET_SDR_ENTIRE_RECORD 0xff
uint8_t length; /* length to read */
#define GET_SDR_MAX_LEN 30
unsigned char length; /* length to read */
} __attribute__ ((packed));
struct sdr_get_rs {
uint16_t next; /* next record id */
uint16_t id; /* record ID */
uint8_t version; /* SDR version (51h) */
unsigned short next; /* next record id */
unsigned short id; /* record ID */
unsigned char version; /* SDR version (51h) */
#define SDR_RECORD_TYPE_FULL_SENSOR 0x01
#define SDR_RECORD_TYPE_COMPACT_SENSOR 0x02
#define SDR_RECORD_TYPE_EVENTONLY_SENSOR 0x03
@ -117,445 +117,466 @@ struct sdr_get_rs {
#define SDR_RECORD_TYPE_MC_CONFIRMATION 0x13
#define SDR_RECORD_TYPE_BMC_MSG_CHANNEL_INFO 0x14
#define SDR_RECORD_TYPE_OEM 0xc0
uint8_t type; /* record type */
uint8_t length; /* remaining record bytes */
unsigned char type; /* record type */
unsigned char length; /* remaining record bytes */
} __attribute__ ((packed));
struct sdr_record_compact_sensor {
struct {
uint8_t owner_id;
unsigned char owner_id;
#if WORDS_BIGENDIAN
uint8_t channel : 4; /* channel number */
uint8_t __reserved : 2;
uint8_t lun : 2; /* sensor owner lun */
unsigned char channel : 4; /* channel number */
unsigned char __reserved : 2;
unsigned char lun : 2; /* sensor owner lun */
#else
uint8_t lun : 2; /* sensor owner lun */
uint8_t __reserved : 2;
uint8_t channel : 4; /* channel number */
unsigned char lun : 2; /* sensor owner lun */
unsigned char __reserved : 2;
unsigned char channel : 4; /* channel number */
#endif
uint8_t sensor_num; /* unique sensor number */
unsigned char sensor_num; /* unique sensor number */
} keys;
struct entity_id entity;
struct {
unsigned char id; /* physical entity id */
#if WORDS_BIGENDIAN
unsigned char logical : 1; /* physical/logical */
unsigned char instance : 7; /* instance number */
#else
unsigned char instance : 7; /* instance number */
unsigned char logical : 1; /* physical/logical */
#endif
} entity;
struct {
struct {
#if WORDS_BIGENDIAN
uint8_t __reserved : 1;
uint8_t scanning : 1;
uint8_t events : 1;
uint8_t thresholds : 1;
uint8_t hysteresis : 1;
uint8_t type : 1;
uint8_t event_gen : 1;
uint8_t sensor_scan : 1;
unsigned char __reserved : 1;
unsigned char scanning : 1;
unsigned char events : 1;
unsigned char thresholds : 1;
unsigned char hysteresis : 1;
unsigned char type : 1;
unsigned char event_gen : 1;
unsigned char sensor_scan : 1;
#else
uint8_t sensor_scan : 1;
uint8_t event_gen : 1;
uint8_t type : 1;
uint8_t hysteresis : 1;
uint8_t thresholds : 1;
uint8_t events : 1;
uint8_t scanning : 1;
uint8_t __reserved : 1;
unsigned char sensor_scan : 1;
unsigned char event_gen : 1;
unsigned char type : 1;
unsigned char hysteresis : 1;
unsigned char thresholds : 1;
unsigned char events : 1;
unsigned char scanning : 1;
unsigned char __reserved : 1;
#endif
} init;
struct {
#if WORDS_BIGENDIAN
uint8_t ignore : 1;
uint8_t rearm : 1;
uint8_t hysteresis : 2;
uint8_t threshold : 2;
uint8_t event_msg : 2;
unsigned char ignore : 1;
unsigned char rearm : 1;
unsigned char hysteresis : 2;
unsigned char threshold : 2;
unsigned char event_msg : 2;
#else
uint8_t event_msg : 2;
uint8_t threshold : 2;
uint8_t hysteresis : 2;
uint8_t rearm : 1;
uint8_t ignore : 1;
unsigned char event_msg : 2;
unsigned char threshold : 2;
unsigned char hysteresis : 2;
unsigned char rearm : 1;
unsigned char ignore : 1;
#endif
} capabilities;
uint8_t type; /* sensor type */
unsigned char type; /* sensor type */
} sensor;
uint8_t event_type; /* event/reading type code */
unsigned char event_type; /* event/reading type code */
union {
struct {
uint16_t assert_event; /* assertion event mask */
uint16_t deassert_event; /* de-assertion event mask */
uint16_t read; /* discrete reaading mask */
unsigned short assert_event; /* assertion event mask */
unsigned short deassert_event; /* de-assertion event mask */
unsigned short read; /* discrete reaading mask */
} discrete;
struct {
uint16_t lower; /* lower threshold reading mask */
uint16_t upper; /* upper threshold reading mask */
uint8_t set; /* settable threshold mask */
uint8_t read; /* readable threshold mask */
unsigned short lower; /* lower threshold reading mask */
unsigned short upper; /* upper threshold reading mask */
unsigned char set; /* settable threshold mask */
unsigned char read; /* readable threshold mask */
} threshold;
} mask;
struct {
#if WORDS_BIGENDIAN
uint8_t analog : 2;
uint8_t rate : 3;
uint8_t modifier : 2;
uint8_t pct : 1;
unsigned char analog : 2;
unsigned char rate : 3;
unsigned char modifier : 2;
unsigned char pct : 1;
#else
uint8_t pct : 1;
uint8_t modifier : 2;
uint8_t rate : 3;
uint8_t analog : 2;
unsigned char pct : 1;
unsigned char modifier : 2;
unsigned char rate : 3;
unsigned char analog : 2;
#endif
struct {
uint8_t base;
uint8_t modifier;
unsigned char base;
unsigned char modifier;
} type;
} unit;
struct {
#if WORDS_BIGENDIAN
uint8_t __reserved : 2;
uint8_t mod_type : 2;
uint8_t count : 4;
unsigned char __reserved : 2;
unsigned char mod_type : 2;
unsigned char count : 4;
#else
uint8_t count : 4;
uint8_t mod_type : 2;
uint8_t __reserved : 2;
unsigned char count : 4;
unsigned char mod_type : 2;
unsigned char __reserved : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t entity_inst : 1;
uint8_t mod_offset : 7;
unsigned char entity_inst : 1;
unsigned char mod_offset : 7;
#else
uint8_t mod_offset : 7;
uint8_t entity_inst : 1;
unsigned char mod_offset : 7;
unsigned char entity_inst : 1;
#endif
} share;
struct {
struct {
uint8_t positive;
uint8_t negative;
unsigned char positive;
unsigned char negative;
} hysteresis;
} threshold;
uint8_t __reserved[3];
uint8_t oem; /* reserved for OEM use */
uint8_t id_code; /* sensor ID string type/length code */
uint8_t id_string[16]; /* sensor ID string bytes, only if id_code != 0 */
unsigned char __reserved[3];
unsigned char oem; /* reserved for OEM use */
unsigned char id_code; /* sensor ID string type/length code */
unsigned char id_string[16]; /* sensor ID string bytes, only if id_code != 0 */
} __attribute__ ((packed));
struct sdr_record_eventonly_sensor {
struct {
uint8_t owner_id;
unsigned char owner_id;
#if WORDS_BIGENDIAN
uint8_t channel : 4; /* channel number */
uint8_t fru_owner : 2; /* fru device owner lun */
uint8_t lun : 2; /* sensor owner lun */
unsigned char channel : 4; /* channel number */
unsigned char fru_owner : 2; /* fru device owner lun */
unsigned char lun : 2; /* sensor owner lun */
#else
uint8_t lun : 2; /* sensor owner lun */
uint8_t fru_owner : 2; /* fru device owner lun */
uint8_t channel : 4; /* channel number */
unsigned char lun : 2; /* sensor owner lun */
unsigned char fru_owner : 2; /* fru device owner lun */
unsigned char channel : 4; /* channel number */
#endif
uint8_t sensor_num; /* unique sensor number */
unsigned char sensor_num; /* unique sensor number */
} keys;
struct entity_id entity;
uint8_t sensor_type; /* sensor type */
uint8_t event_type; /* event/reading type code */
struct {
unsigned char id; /* physical entity id */
#if WORDS_BIGENDIAN
unsigned char logical : 1; /* physical/logical */
unsigned char instance : 7; /* instance number */
#else
unsigned char instance : 7; /* instance number */
unsigned char logical : 1; /* physical/logical */
#endif
} entity;
unsigned char sensor_type; /* sensor type */
unsigned char event_type; /* event/reading type code */
struct {
#if WORDS_BIGENDIAN
uint8_t __reserved : 2;
uint8_t mod_type : 2;
uint8_t count : 4;
unsigned char __reserved : 2;
unsigned char mod_type : 2;
unsigned char count : 4;
#else
uint8_t count : 4;
uint8_t mod_type : 2;
uint8_t __reserved : 2;
unsigned char count : 4;
unsigned char mod_type : 2;
unsigned char __reserved : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t entity_inst : 1;
uint8_t mod_offset : 7;
unsigned char entity_inst : 1;
unsigned char mod_offset : 7;
#else
uint8_t mod_offset : 7;
uint8_t entity_inst : 1;
unsigned char mod_offset : 7;
unsigned char entity_inst : 1;
#endif
} share;
uint8_t __reserved;
uint8_t oem; /* reserved for OEM use */
uint8_t id_code; /* sensor ID string type/length code */
uint8_t id_string[16]; /* sensor ID string bytes, only if id_code != 0 */
unsigned char __reserved;
unsigned char oem; /* reserved for OEM use */
unsigned char id_code; /* sensor ID string type/length code */
unsigned char id_string[16]; /* sensor ID string bytes, only if id_code != 0 */
} __attribute__ ((packed));
struct sdr_record_full_sensor {
struct {
uint8_t owner_id;
unsigned char owner_id;
#if WORDS_BIGENDIAN
uint8_t channel : 4; /* channel number */
uint8_t __reserved : 2;
uint8_t lun : 2; /* sensor owner lun */
unsigned char channel : 4; /* channel number */
unsigned char __reserved : 2;
unsigned char lun : 2; /* sensor owner lun */
#else
uint8_t lun : 2; /* sensor owner lun */
uint8_t __reserved : 2;
uint8_t channel : 4; /* channel number */
unsigned char lun : 2; /* sensor owner lun */
unsigned char __reserved : 2;
unsigned char channel : 4; /* channel number */
#endif
uint8_t sensor_num; /* unique sensor number */
unsigned char sensor_num; /* unique sensor number */
} keys;
struct entity_id entity;
struct {
unsigned char id; /* physical entity id */
#if WORDS_BIGENDIAN
unsigned char logical : 1; /* physical/logical */
unsigned char instance : 7; /* instance number */
#else
unsigned char instance : 7; /* instance number */
unsigned char logical : 1; /* physical/logical */
#endif
} entity;
struct {
struct {
#if WORDS_BIGENDIAN
uint8_t __reserved : 1;
uint8_t scanning : 1;
uint8_t events : 1;
uint8_t thresholds : 1;
uint8_t hysteresis : 1;
uint8_t type : 1;
uint8_t event_gen : 1;
uint8_t sensor_scan : 1;
unsigned char __reserved : 1;
unsigned char scanning : 1;
unsigned char events : 1;
unsigned char thresholds : 1;
unsigned char hysteresis : 1;
unsigned char type : 1;
unsigned char event_gen : 1;
unsigned char sensor_scan : 1;
#else
uint8_t sensor_scan : 1;
uint8_t event_gen : 1;
uint8_t type : 1;
uint8_t hysteresis : 1;
uint8_t thresholds : 1;
uint8_t events : 1;
uint8_t scanning : 1;
uint8_t __reserved : 1;
unsigned char sensor_scan : 1;
unsigned char event_gen : 1;
unsigned char type : 1;
unsigned char hysteresis : 1;
unsigned char thresholds : 1;
unsigned char events : 1;
unsigned char scanning : 1;
unsigned char __reserved : 1;
#endif
} init;
struct {
#if WORDS_BIGENDIAN
uint8_t ignore : 1;
uint8_t rearm : 1;
uint8_t hysteresis : 2;
uint8_t threshold : 2;
uint8_t event_msg : 2;
unsigned char ignore : 1;
unsigned char rearm : 1;
unsigned char hysteresis : 2;
unsigned char threshold : 2;
unsigned char event_msg : 2;
#else
uint8_t event_msg : 2;
uint8_t threshold : 2;
uint8_t hysteresis : 2;
uint8_t rearm : 1;
uint8_t ignore : 1;
unsigned char event_msg : 2;
unsigned char threshold : 2;
unsigned char hysteresis : 2;
unsigned char rearm : 1;
unsigned char ignore : 1;
#endif
} capabilities;
uint8_t type;
unsigned char type;
} sensor;
uint8_t event_type; /* event/reading type code */
unsigned char event_type; /* event/reading type code */
union {
struct {
uint16_t assert_event; /* assertion event mask */
uint16_t deassert_event; /* de-assertion event mask */
uint16_t read; /* discrete reaading mask */
unsigned short assert_event; /* assertion event mask */
unsigned short deassert_event; /* de-assertion event mask */
unsigned short read; /* discrete reaading mask */
} discrete;
struct {
uint16_t lower; /* lower threshold reading mask */
uint16_t upper; /* upper threshold reading mask */
uint8_t set; /* settable threshold mask */
uint8_t read; /* readable threshold mask */
unsigned short lower; /* lower threshold reading mask */
unsigned short upper; /* upper threshold reading mask */
unsigned char set; /* settable threshold mask */
unsigned char read; /* readable threshold mask */
} threshold;
} mask;
struct {
#if WORDS_BIGENDIAN
uint8_t analog : 2;
uint8_t rate : 3;
uint8_t modifier : 2;
uint8_t pct : 1;
unsigned char analog : 2;
unsigned char rate : 3;
unsigned char modifier : 2;
unsigned char pct : 1;
#else
uint8_t pct : 1;
uint8_t modifier : 2;
uint8_t rate : 3;
uint8_t analog : 2;
unsigned char pct : 1;
unsigned char modifier : 2;
unsigned char rate : 3;
unsigned char analog : 2;
#endif
struct {
uint8_t base;
uint8_t modifier;
unsigned char base;
unsigned char modifier;
} type;
} unit;
#define SDR_SENSOR_L_LINEAR 0x00
#define SDR_SENSOR_L_LN 0x01
#define SDR_SENSOR_L_LOG10 0x02
#define SDR_SENSOR_L_LOG2 0x03
#define SDR_SENSOR_L_E 0x04
#define SDR_SENSOR_L_EXP10 0x05
#define SDR_SENSOR_L_EXP2 0x06
#define SDR_SENSOR_L_1_X 0x07
#define SDR_SENSOR_L_SQR 0x08
#define SDR_SENSOR_L_CUBE 0x09
#define SDR_SENSOR_L_SQRT 0x0a
#define SDR_SENSOR_L_CUBERT 0x0b
#define SDR_SENSOR_L_NONLINEAR 0x70
uint8_t linearization; /* 70h=non linear, 71h-7Fh=non linear, OEM */
uint16_t mtol; /* M, tolerance */
unsigned char linearization; /* 70h=non linear, 71h-7Fh=non linear, OEM */
unsigned short mtol; /* M, tolerance */
uint32_t bacc; /* accuracy, B, Bexp, Rexp */
struct {
#if WORDS_BIGENDIAN
uint8_t __reserved : 5;
uint8_t normal_min : 1; /* normal min field specified */
uint8_t normal_max : 1; /* normal max field specified */
uint8_t nominal_read : 1; /* nominal reading field specified */
unsigned char __reserved : 5;
unsigned char normal_min : 1; /* normal min field specified */
unsigned char normal_max : 1; /* normal max field specified */
unsigned char nominal_read : 1; /* nominal reading field specified */
#else
uint8_t nominal_read : 1; /* nominal reading field specified */
uint8_t normal_max : 1; /* normal max field specified */
uint8_t normal_min : 1; /* normal min field specified */
uint8_t __reserved : 5;
unsigned char nominal_read : 1; /* nominal reading field specified */
unsigned char normal_max : 1; /* normal max field specified */
unsigned char normal_min : 1; /* normal min field specified */
unsigned char __reserved : 5;
#endif
} analog_flag;
uint8_t nominal_read; /* nominal reading, raw value */
uint8_t normal_max; /* normal maximum, raw value */
uint8_t normal_min; /* normal minimum, raw value */
uint8_t sensor_max; /* sensor maximum, raw value */
uint8_t sensor_min; /* sensor minimum, raw value */
unsigned char nominal_read; /* nominal reading, raw value */
unsigned char normal_max; /* normal maximum, raw value */
unsigned char normal_min; /* normal minimum, raw value */
unsigned char sensor_max; /* sensor maximum, raw value */
unsigned char sensor_min; /* sensor minimum, raw value */
struct {
struct {
uint8_t non_recover;
uint8_t critical;
uint8_t non_critical;
unsigned char non_recover;
unsigned char critical;
unsigned char non_critical;
} upper;
struct {
uint8_t non_recover;
uint8_t critical;
uint8_t non_critical;
unsigned char non_recover;
unsigned char critical;
unsigned char non_critical;
} lower;
struct {
uint8_t positive;
uint8_t negative;
unsigned char positive;
unsigned char negative;
} hysteresis;
} threshold;
uint8_t __reserved[2];
uint8_t oem; /* reserved for OEM use */
uint8_t id_code; /* sensor ID string type/length code */
uint8_t id_string[16]; /* sensor ID string bytes, only if id_code != 0 */
unsigned char __reserved[2];
unsigned char oem; /* reserved for OEM use */
unsigned char id_code; /* sensor ID string type/length code */
unsigned char id_string[16]; /* sensor ID string bytes, only if id_code != 0 */
} __attribute__ ((packed));
struct sdr_record_fru_device_locator {
struct {
#if WORDS_BIGENDIAN
unsigned char __reserved2 : 1;
unsigned char dev_access_addr : 6;
unsigned char __reserved1 : 1;
#else
unsigned char __reserved1 : 1;
unsigned char dev_access_addr : 6;
unsigned char __reserved2 : 1;
#endif
unsigned char fru_device_id;
#if WORDS_BIGENDIAN
unsigned char logical_dev : 1;
unsigned char __reserved3 : 2;
unsigned char access_lun : 2;
unsigned char private_bus : 3;
#else
unsigned char private_bus : 3;
unsigned char access_lun : 2;
unsigned char __reserved3 : 2;
unsigned char logical_dev : 1;
#endif
#if WORDS_BIGENDIAN
unsigned char channel_num : 4;
unsigned char __reserved4 : 4;
#else
unsigned char __reserved4 : 4;
unsigned char channel_num : 4;
#endif
} keys;
unsigned char __reserved;
unsigned char device_type;
unsigned char device_type_modifier;
unsigned char fru_entity_id;
unsigned char fru_entity_instance;
unsigned char oem;
unsigned char id_code;
unsigned char id_string[16];
} __attribute__ ((packed));
struct sdr_record_mc_locator {
uint8_t dev_slave_addr;
#if WORDS_BIGENDIAN
uint8_t __reserved2 : 4;
uint8_t channel_num : 4;
unsigned char dev_slave_addr : 7;
unsigned char __reserved1 : 1;
#else
uint8_t channel_num : 4;
uint8_t __reserved2 : 4;
unsigned char __reserved1 : 1;
unsigned char dev_slave_addr : 7;
#endif
#if WORDS_BIGENDIAN
uint8_t pwr_state_notif : 3;
uint8_t __reserved3 : 1;
uint8_t global_init : 4;
unsigned char __reserved2 : 4;
unsigned char channel_num : 4;
#else
uint8_t global_init : 4;
uint8_t __reserved3 : 1;
uint8_t pwr_state_notif : 3;
unsigned char channel_num : 4;
unsigned char __reserved2 : 4;
#endif
uint8_t dev_support;
uint8_t __reserved4[3];
struct entity_id entity;
uint8_t oem;
uint8_t id_code;
uint8_t id_string[16];
#if WORDS_BIGENDIAN
unsigned char pwr_state_notif : 3;
unsigned char __reserved3 : 1;
unsigned char global_init : 4;
#else
unsigned char global_init : 4;
unsigned char __reserved3 : 1;
unsigned char pwr_state_notif : 3;
#endif
unsigned char dev_support;
unsigned char __reserved4[3];
struct {
unsigned char id;
unsigned char instance;
} entity;
unsigned char oem;
unsigned char id_code;
unsigned char id_string[16];
} __attribute__ ((packed));
struct sdr_record_fru_locator {
uint8_t dev_slave_addr;
uint8_t device_id;
#if WORDS_BIGENDIAN
uint8_t logical : 1;
uint8_t __reserved2 : 2;
uint8_t lun : 2;
uint8_t bus : 3;
unsigned char dev_slave_addr : 7;
unsigned char __reserved1 : 1;
#else
uint8_t bus : 3;
uint8_t lun : 2;
uint8_t __reserved2 : 2;
uint8_t logical : 1;
unsigned char __reserved1 : 1;
unsigned char dev_slave_addr : 7;
#endif
unsigned char device_id;
#if WORDS_BIGENDIAN
unsigned char bus : 3;
unsigned char lun : 2;
unsigned char __reserved2 : 2;
unsigned char logical : 1;
#else
unsigned char logical : 1;
unsigned char __reserved2 : 2;
unsigned char lun : 2;
unsigned char bus : 3;
#endif
#if WORDS_BIGENDIAN
uint8_t channel_num : 4;
uint8_t __reserved3 : 4;
unsigned char __reserved3 : 4;
unsigned char channel_num : 4;
#else
uint8_t __reserved3 : 4;
uint8_t channel_num : 4;
unsigned char channel_num : 4;
unsigned char __reserved3 : 4;
#endif
uint8_t __reserved4;
uint8_t dev_type;
uint8_t dev_type_modifier;
struct entity_id entity;
uint8_t oem;
uint8_t id_code;
uint8_t id_string[16];
unsigned char __reserved4;
unsigned char dev_type;
unsigned char dev_type_modifier;
struct {
unsigned char id;
unsigned char instance;
} entity;
unsigned char oem;
unsigned char id_code;
unsigned char id_string[16];
} __attribute__ ((packed));
struct sdr_record_oem {
uint8_t * data;
int data_len;
};
/*
* The Get SDR Repository Info response structure
* From table 33-3 of the IPMI v2.0 spec
*/
struct get_sdr_repository_info_rsp {
uint8_t sdr_version;
uint8_t record_count_lsb;
uint8_t record_count_msb;
uint8_t free_space[2];
uint8_t most_recent_addition_timestamp[4];
uint8_t most_recent_erase_timestamp[4];
#if WORDS_BIGENDIAN
uint8_t overflow_flag : 1;
uint8_t modal_update_support : 2;
uint8_t __reserved1 : 1;
uint8_t delete_sdr_supported : 1;
uint8_t partial_add_sdr_supported : 1;
uint8_t reserve_sdr_repository_supported : 1;
uint8_t get_sdr_repository_allo_info_supported : 1;
#else
uint8_t get_sdr_repository_allo_info_supported : 1;
uint8_t reserve_sdr_repository_supported : 1;
uint8_t partial_add_sdr_supported : 1;
uint8_t delete_sdr_supported : 1;
uint8_t __reserved1 : 1;
uint8_t modal_update_support : 2;
uint8_t overflow_flag : 1;
#endif
} __attribute__ ((packed));
struct ipmi_sdr_iterator
{
uint16_t reservation;
unsigned short reservation;
int total;
int next;
};
struct sdr_record_list {
uint16_t id;
uint8_t type;
struct sdr_record_list * next;
union {
struct sdr_record_full_sensor * full;
struct sdr_record_compact_sensor * compact;
struct sdr_record_eventonly_sensor * eventonly;
struct sdr_record_fru_locator * fruloc;
struct sdr_record_mc_locator * mcloc;
struct sdr_record_oem * oem;
} record;
};
/* unit description codes (IPMI v1.5 section 37.16) */
#define UNIT_MAX 0x90
static const char * unit_desc[] __attribute__((unused)) = {
@ -601,28 +622,12 @@ static const char * sensor_type_desc[] __attribute__((unused)) = {
struct ipmi_sdr_iterator * ipmi_sdr_start(struct ipmi_intf * intf);
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);
unsigned char * ipmi_sdr_get_record(struct ipmi_intf * intf, struct sdr_get_rs * header, 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_rawentry(struct ipmi_intf * intf, uint8_t type, uint8_t * raw, int len);
int ipmi_sdr_print_listentry(struct ipmi_intf * intf, struct sdr_record_list * entry);
const char * ipmi_sdr_get_status(uint8_t stat);
double sdr_convert_sensor_reading(struct sdr_record_full_sensor * sensor, uint8_t val);
uint8_t sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor * sensor, double val);
struct ipmi_rs * ipmi_sdr_get_sensor_reading(struct ipmi_intf * intf, uint8_t sensor);
const char * ipmi_sdr_get_sensor_type_desc(const uint8_t type);
void ipmi_sdr_print_sdr(struct ipmi_intf * intf, unsigned char type);
const char * ipmi_sdr_get_status(unsigned char stat);
float sdr_convert_sensor_reading(struct sdr_record_full_sensor * sensor, unsigned char val);
struct ipmi_rs * ipmi_sdr_get_sensor_reading(struct ipmi_intf * intf, unsigned char sensor);
int ipmi_sdr_print_sensor_full(struct ipmi_intf * intf, struct sdr_record_full_sensor * sensor);
int ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf, struct sdr_record_compact_sensor * sensor);
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf * intf, struct sdr_record_eventonly_sensor * sensor);
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);
struct sdr_record_list * ipmi_sdr_find_sdr_byentity(struct ipmi_intf * intf, struct entity_id * entity);
struct sdr_record_list * ipmi_sdr_find_sdr_bynumtype(struct ipmi_intf * intf, uint8_t num, uint8_t type);
struct sdr_record_list * ipmi_sdr_find_sdr_byid(struct ipmi_intf * intf, char * id);
void ipmi_sdr_list_empty(struct ipmi_intf * intf);
int ipmi_sdr_print_info(struct ipmi_intf * intf);
void ipmi_sdr_print_discrete_state(uint8_t sensor_type, uint8_t event_type, uint8_t state);
#endif /* IPMI_SDR_H */

View File

@ -37,7 +37,7 @@
#ifndef IPMI_SEL_H
#define IPMI_SEL_H
#include <inttypes.h>
#include <stdint.h>
#include <ipmitool/ipmi.h>
#define IPMI_CMD_GET_SEL_INFO 0x40
@ -61,50 +61,50 @@ enum {
};
struct sel_get_rq {
uint16_t reserve_id;
uint16_t record_id;
uint8_t offset;
uint8_t length;
unsigned short reserve_id;
unsigned short record_id;
unsigned char offset;
unsigned char length;
} __attribute__ ((packed));
struct sel_event_record {
uint16_t record_id;
uint8_t record_type;
unsigned short record_id;
unsigned char record_type;
uint32_t timestamp;
uint16_t gen_id;
uint8_t evm_rev;
uint8_t sensor_type;
uint8_t sensor_num;
uint8_t event_type : 7;
uint8_t event_dir : 1;
unsigned short gen_id;
unsigned char evm_rev;
unsigned char sensor_type;
unsigned char sensor_num;
unsigned char event_type : 7;
unsigned char event_dir : 1;
#define DATA_BYTE2_SPECIFIED_MASK 0xc0 /* event_data[0] bit mask */
#define DATA_BYTE3_SPECIFIED_MASK 0x30 /* event_data[0] bit mask */
#define EVENT_OFFSET_MASK 0x0f /* event_data[0] bit mask */
uint8_t event_data[3];
unsigned char event_data[3];
} __attribute__ ((packed));
struct sel_oem_record_ts {
uint16_t next_id;
uint16_t record_id;
uint8_t record_type;
unsigned short next_id;
unsigned short record_id;
unsigned char record_type;
uint32_t timestamp;
uint8_t mfg_id[3];
uint8_t oem_defined[6];
unsigned char mfg_id[3];
unsigned char oem_defined[6];
} __attribute__ ((packed));
struct sel_oem_record_nots {
uint16_t next_id;
uint16_t record_id;
uint8_t record_type;
uint8_t oem_defined[13];
unsigned short next_id;
unsigned short record_id;
unsigned char record_type;
unsigned char oem_defined[13];
} __attribute__ ((packed));
struct ipmi_event_sensor_types {
uint8_t code;
uint8_t offset;
unsigned char code;
unsigned char offset;
#define ALL_OFFSETS_SPECIFIED 0xff
uint8_t data;
uint8_t class;
unsigned char data;
unsigned char class;
const char * type;
const char * desc;
};
@ -138,7 +138,7 @@ static struct ipmi_event_sensor_types generic_event_types[] __attribute__((unuse
{ 0x06, 0x01, 0xff, IPMI_EVENT_CLASS_DIGITAL, "Digital State", "Performance Lags" },
/* Severity Event States */
{ 0x07, 0x00, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Severity State", "Transition to OK" },
{ 0x07, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Severity State", "Transition to Non-critical from OK" },
{ 0x07, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Severity State", "Transition to Non-critial from OK" },
{ 0x07, 0x02, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Severity State", "Transition to Critical from less severe" },
{ 0x07, 0x03, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Severity State", "Transition to Non-recoverable from less severe" },
{ 0x07, 0x04, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Severity State", "Transition to Non-critical from more severe" },
@ -194,7 +194,7 @@ static struct ipmi_event_sensor_types sensor_specific_types[] __attribute__((unu
{ 0x05, 0x06, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Physical Security", "FAN area intrusion" },
{ 0x06, 0x00, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Platform Security", "Front Panel Lockout violation attempted" },
{ 0x06, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Platform Security", "Pre-boot password violation - user password" },
{ 0x06, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Platform Security", "Pre-boot password viiolation - user password" },
{ 0x06, 0x02, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Platform Security", "Pre-boot password violation - setup password" },
{ 0x06, 0x03, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Platform Security", "Pre-boot password violation - network boot password" },
{ 0x06, 0x04, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Platform Security", "Other pre-boot password violation" },
@ -267,7 +267,7 @@ static struct ipmi_event_sensor_types sensor_specific_types[] __attribute__((unu
{ 0x12, 0x00, 0xff, IPMI_EVENT_CLASS_DISCRETE, "System Event", "System Reconfigured" },
{ 0x12, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "System Event", "OEM System boot event" },
{ 0x12, 0x02, 0xff, IPMI_EVENT_CLASS_DISCRETE, "System Event", "Undetermined system hardware failure" },
{ 0x12, 0x03, 0xff, IPMI_EVENT_CLASS_DISCRETE, "System Event", "Entry added to auxiliary log" },
{ 0x12, 0x03, 0xff, IPMI_EVENT_CLASS_DISCRETE, "System Event", "Entry added to auxillary log" },
{ 0x12, 0x04, 0xff, IPMI_EVENT_CLASS_DISCRETE, "System Event", "PEF Action" },
{ 0x12, 0x05, 0xff, IPMI_EVENT_CLASS_DISCRETE, "System Event", "Timestamp Clock Sync." },
@ -320,11 +320,11 @@ static struct ipmi_event_sensor_types sensor_specific_types[] __attribute__((unu
{ 0x21, 0x00, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Fault Status asserted" },
{ 0x21, 0x01, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Identify Status asserted" },
{ 0x21, 0x02, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Device installed/attached" },
{ 0x21, 0x03, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Ready for device installation" },
{ 0x21, 0x04, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Ready for device removal" },
{ 0x21, 0x02, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Slot/Connector Device installed/attached" },
{ 0x21, 0x03, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Slot/Connector ready for device installation" },
{ 0x21, 0x04, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Slot/Connector ready for device removal" },
{ 0x21, 0x05, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Slot Power is off" },
{ 0x21, 0x06, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Device removal request" },
{ 0x21, 0x06, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Slot/Connector device removal request" },
{ 0x21, 0x07, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Interlock asserted" },
{ 0x21, 0x08, 0xff, IPMI_EVENT_CLASS_DISCRETE, "Slot/Connector", "Slot is disabled" },
@ -381,8 +381,5 @@ static struct ipmi_event_sensor_types sensor_specific_types[] __attribute__((unu
int ipmi_sel_main(struct ipmi_intf *, int, char **);
void ipmi_sel_print_std_entry(struct sel_event_record * evt);
void ipmi_sel_print_std_entry_verbose(struct sel_event_record * evt);
void ipmi_get_event_desc(struct sel_event_record * rec, char ** desc);
const char * ipmi_sel_get_sensor_type(uint8_t code);
#endif /* IPMI_SEL_H */

View File

@ -40,56 +40,12 @@
#include <math.h>
#include <ipmitool/bswap.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
/* ipmi sensor commands */
#define GET_SENSOR_READING 0x2d
#define GET_SENSOR_FACTORS 0x23
#define SET_SENSOR_THRESHOLDS 0x26
#define GET_SENSOR_THRESHOLDS 0x27
#define GET_SENSOR_THRES 0x27
#define GET_SENSOR_TYPE 0x2f
/* threshold specification bits for analog sensors for get sensor threshold command
* and set sensor threshold command
*/
#define UPPER_NON_RECOV_SPECIFIED 0x20
#define UPPER_CRIT_SPECIFIED 0x10
#define UPPER_NON_CRIT_SPECIFIED 0x08
#define LOWER_NON_RECOV_SPECIFIED 0x04
#define LOWER_CRIT_SPECIFIED 0x02
#define LOWER_NON_CRIT_SPECIFIED 0x01
/* state assertion bits for discrete sensors for get sensor reading command */
#define STATE_0_ASSERTED 0x01
#define STATE_1_ASSERTED 0x02
#define STATE_2_ASSERTED 0x04
#define STATE_3_ASSERTED 0x08
#define STATE_4_ASSERTED 0x10
#define STATE_5_ASSERTED 0x20
#define STATE_6_ASSERTED 0x40
#define STATE_7_ASSERTED 0x80
#define STATE_8_ASSERTED 0x01
#define STATE_9_ASSERTED 0x02
#define STATE_10_ASSERTED 0x04
#define STATE_11_ASSERTED 0x08
#define STATE_12_ASSERTED 0x10
#define STATE_13_ASSERTED 0x20
#define STATE_14_ASSERTED 0x40
struct sensor_set_thresh_rq {
uint8_t sensor_num; /* sensor # */
uint8_t set_mask; /* threshold setting mask */
uint8_t lower_non_crit; /* new lower non critical threshold*/
uint8_t lower_crit; /* new lower critical threshold*/
uint8_t lower_non_recov; /* new lower non recoverable threshold*/
uint8_t upper_non_crit; /* new upper non critical threshold*/
uint8_t upper_crit; /* new upper critical threshold*/
uint8_t upper_non_recov; /* new upper non recoverable threshold*/
} __attribute__ ((packed));
int ipmi_sensor_main(struct ipmi_intf *, int, char **);
int ipmi_sensor_print_full(struct ipmi_intf *, struct sdr_record_full_sensor *);
int ipmi_sensor_print_compact(struct ipmi_intf *, struct sdr_record_compact_sensor *);
#endif /* IPMI_SENSOR_H */

View File

@ -1,129 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_SESSION_H
#define IPMI_SESSION_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
#define IPMI_GET_SESSION_INFO 0x3D
/*
* From table 22.25 of the IPMIv2 specification
*/
struct get_session_info_rsp
{
uint8_t session_handle;
#if WORDS_BIGENDIAN
uint8_t __reserved1 : 2;
uint8_t session_slot_count : 6; /* 1-based */
#else
uint8_t session_slot_count : 6; /* 1-based */
uint8_t __reserved1 : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved2 : 2;
uint8_t active_session_count : 6; /* 1-based */
#else
uint8_t active_session_count : 6; /* 1-based */
uint8_t __reserved2 : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved3 : 2;
uint8_t user_id : 6;
#else
uint8_t user_id : 6;
uint8_t __reserved3 : 2;
#endif
#if WORDS_BIGENDIAN
uint8_t __reserved4 : 4;
uint8_t privilege_level : 4;
#else
uint8_t privilege_level : 4;
uint8_t __reserved4 : 4;
#endif
#if WORDS_BIGENDIAN
uint8_t auxiliary_data : 4;
uint8_t channel_number : 4;
#else
uint8_t channel_number : 4;
uint8_t auxiliary_data : 4;
#endif
union
{
/* Only exists if channel type is 802.3 LAN */
struct
{
uint8_t console_ip[4]; /* MSBF */
uint8_t console_mac[6]; /* MSBF */
uint16_t console_port; /* LSBF */
} lan_data;
/* Only exists if channel type is async. serial modem */
struct
{
uint8_t session_channel_activity_type;
#if WORDS_BIGENDIAN
uint8_t __reserved5 : 4;
uint8_t destination_selector : 4;
#else
uint8_t destination_selector : 4;
uint8_t __reserved5 : 4;
#endif
uint8_t console_ip[4]; /* MSBF */
/* Only exists if session is PPP */
uint16_t console_port; /* LSBF */
} modem_data;
} channel_data;
} __attribute__ ((packed));
int ipmi_session_main(struct ipmi_intf *, int, char **);
#endif /*IPMI_CHANNEL_H*/

View File

@ -39,48 +39,17 @@
#include <ipmitool/ipmi.h>
#define ACTIVATE_SOL 0x01
#define SET_SOL_CONFIG 0x03
#define GET_SOL_CONFIG 0x04
#define IPMI_SOL_SERIAL_ALERT_MASK_SUCCEED 0x08
#define IPMI_SOL_SERIAL_ALERT_MASK_DEFERRED 0x04
#define IPMI_SOL_SERIAL_ALERT_MASK_FAIL 0x00
#define IPMI_SOL_BMC_ASSERTS_CTS_MASK_TRUE 0x00
#define IPMI_SOL_BMC_ASSERTS_CTS_MASK_FALSE 0x02
struct sol_config_parameters {
uint8_t set_in_progress;
uint8_t enabled;
uint8_t force_encryption;
uint8_t force_authentication;
uint8_t privilege_level;
uint8_t character_accumulate_level;
uint8_t character_send_threshold;
uint8_t retry_count;
uint8_t retry_interval;
uint8_t non_volatile_bit_rate;
uint8_t volatile_bit_rate;
uint8_t payload_channel;
uint16_t payload_port;
};
/*
* The ACTIVATE PAYLOAD command reponse structure
* From table 24-2 of the IPMI v2.0 spec
*/
struct activate_payload_rsp {
uint8_t auxiliary_data[4];
uint8_t inbound_payload_size[2]; /* LS byte first */
uint8_t outbound_payload_size[2]; /* LS byte first */
uint8_t payload_udp_port[2]; /* LS byte first */
uint8_t payload_vlan_number[2]; /* LS byte first */
} __attribute__ ((packed));
#define SOL_ENABLE_PARAM 0x01
#define SOL_AUTHENTICATION_PARAM 0x02
#define SOL_ENABLE_FLAG 0x01
#define SOL_PRIVILEGE_LEVEL_USER 0x02
#define SOL_BAUD_RATE_PARAM 0x05
#define SOL_PREFERRED_BAUD_RATE 0x07
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);
#endif /* IPMI_SOL_H */

View File

@ -1,59 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_STRINGS_H
#define IPMI_STRINGS_H
#include <ipmitool/helper.h>
extern const struct valstr completion_code_vals[];
extern const struct valstr entity_id_vals[];
extern const struct valstr entity_device_type_vals[];
extern const struct valstr ipmi_channel_activity_type_vals[];
extern const struct valstr ipmi_privlvl_vals[];
extern const struct valstr impi_bit_rate_vals[];
extern const struct valstr ipmi_set_in_progress_vals[];
extern const struct valstr ipmi_authtype_session_vals[];
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_auth_algorithms[];
extern const struct valstr ipmi_integrity_algorithms[];
extern const struct valstr ipmi_encryption_algorithms[];
#endif /*IPMI_STRINGS_H*/

View File

@ -1,93 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_USER_H
#define IPMI_USER_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
/*
* The GET USER ACCESS response from table 22-32 of the IMPI 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
#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
#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__ ((packed));
int ipmi_user_main(struct ipmi_intf *, int, char **);
#endif /* IPMI_USER_H */

View File

@ -1,67 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMITOOL_LOG_H
#define IPMITOOL_LOG_H
#include <syslog.h>
/* sys/syslog.h:
* LOG_EMERG 0 system is unusable
* LOG_ALERT 1 action must be taken immediately
* LOG_CRIT 2 critical conditions
* LOG_ERR 3 error conditions
* LOG_WARNING 4 warning conditions
* LOG_NOTICE 5 normal but significant condition
* LOG_INFO 6 informational
* LOG_DEBUG 7 debug-level messages
*/
#define LOG_ERROR LOG_ERR
#define LOG_WARN LOG_WARNING
#define LOG_NAME_DEFAULT "ipmitool"
#define LOG_MSG_LENGTH 1024
void log_init(const char * name, int isdaemon, int verbose);
void log_halt(void);
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*/

132
ipmitool/ipmitool.spec.in Normal file
View File

@ -0,0 +1,132 @@
Name: @IPMITOOL_PKG@
Summary: @IPMITOOL_PKG@ - Utility for interfacing with IPMI devices
Version: @VERSION@
Release: 1
Copyright: BSD
Group: Utilities
Vendor: Sun Microsystems
Packager: Duncan Laurie <duncan@sun.com>
Source: @IPMITOOL_PKG@-@VERSION@.tar.gz
Buildroot: /var/tmp/@IPMITOOL_PKG@-root
%package dev
Summary: Development files for ipmitool
Group: Utilities
%description
This package contains a utility for interfacing with IPMI-enabled devices
through either the OpenIPMI kernel driver or with IPMI-over-LAN protocol.
It provides some basic functions for reading the SDR and displaying sensor
values, displaying the contents of the SEL, printing FRU information,
reading and setting LAN configuration, and chassis power control.
%description dev
Additional development files for creating applications or interface plugins
for ipmitool.
%prep
if [ "$RPM_BUILD_ROOT" ] && [ "$RPM_BUILD_ROOT" != "/" ]; then
rm -rf $RPM_BUILD_ROOT
fi
%setup
%build
./configure \
--enable-ipmievd \
--enable-intf-lan=static \
--enable-intf-open=static \
--with-kerneldir=/usr/src/linux-2.4 \
--prefix=%{_prefix} \
--bindir=%{_bindir} \
--datadir=%{_datadir} \
--includedir=%{_includedir} \
--libdir=%{_libdir} \
--mandir=%{_mandir} \
--sysconfdir=%{_sysconfdir}
make
%install
make DESTDIR=$RPM_BUILD_ROOT install-strip
%clean
if [ "$RPM_BUILD_ROOT" ] && [ "$RPM_BUILD_ROOT" != "/" ]; then
rm -rf $RPM_BUILD_ROOT
fi
rm -rf $RPM_BUILD_DIR/@IPMITOOL_PKG@-@VERSION@
%files
%defattr(-,root,root)
%doc %{_mandir}/man1/*
%{_bindir}/*
%files dev
%defattr(-,root,root)
%dir %{_includedir}/ipmitool
%{_includedir}/ipmitool/*.h
%changelog
* Tue Jan 27 2004 <duncan@sun.com> 1.5.8-1
- Enable static compilation of interfaces
- Fix types to be 64-bit safe
- Fix compilation problems on Solaris
- Fix multiple big-endian problems for Solaris/SPARC
- Fix channel access to save settings to NVRAM
- Set channel privilege limit to ADMIN during "access on"
- Enable gratuitous ARP in bmcautoconf.sh
- Add support for Linux kernel panic messages in SEL output
- Add support for type 3 SDR records
* Mon Jan 5 2004 <duncan@sun.com> 1.5.7-1
- add IPMIv1.5 eratta fixes
- additions to FRU printing and FRU multirecords
- better handling of SDR printing
- contrib scripts for creating rrdtool graphs
* Thu Dec 4 2003 <duncan@sun.com> 1.5.6-1
- 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 <EFBFBD>hrn
* Tue Nov 25 2003 <duncan@sun.com> 1.5.5-1
- Add -U option for setting LAN username
- Fix -v usage for plugin interfaces
* Fri Nov 14 2003 <duncan@sun.com> 1.5.4-1
- pull interface plugin api into library
- fix ipmievd
* Fri Oct 31 2003 <duncan@sun.com> 1.5.3-1
- add -g optin for pedantic ipmi-over-lan communication
* Fri Oct 24 2003 <duncan@sun.com> 1.5.2-1
- add gratuitous arp interval setting
* Wed Oct 8 2003 <duncan@sun.com> 1.5.1-1
- better SEL support
- fix display bug in SDR list
* Fri Sep 5 2003 <duncan@sun.com> 1.5.0-1
- use automake/autoconf/libtool
- dynamic loading interface plugins
* Wed May 28 2003 <duncan@sun.com> 1.4.0-1
- make UDP packet handling more robust
- fix imb driver support
* Thu May 22 2003 <duncan@sun.com> 1.3-1
- update manpage
- rework of low-level network handling
- add basic imb driver support
* Wed Apr 2 2003 <duncan@sun.com> 1.2-1
- change command line option parsing
- support for more chassis commands
* Tue Apr 1 2003 <duncan@sun.com> 1.1-1
- minor fixes.
* Sun Mar 30 2003 <duncan@sun.com> 1.0-1
- Initial release.

View File

@ -36,11 +36,8 @@ INCLUDES = -I$(top_srcdir)/include
MAINTAINERCLEANFILES = Makefile.in
noinst_LTLIBRARIES = libipmitool.la
libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_pef.c \
ipmi_lanp.c ipmi_fru.c ipmi_chassis.c ipmi_mc.c log.c \
dimm_spd.c ipmi_sensor.c ipmi_channel.c ipmi_event.c \
ipmi_session.c ipmi_strings.c ipmi_user.c ipmi_raw.c \
ipmi_oem.c ipmi_isol.c
libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_lanp.c \
ipmi_fru.c ipmi_chassis.c ipmi_bmc.c dimm_spd.c ipmi_sensor.c
libipmitool_la_LDFLAGS = -export-dynamic
libipmitool_la_LIBADD = -lm
libipmitool_la_DEPENDENCIES =

View File

@ -35,9 +35,6 @@
*/
#include <ipmitool/ipmi.h>
#include <ipmitool/log.h>
#include <ipmitool/helper.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_fru.h>
#include <stdlib.h>
@ -672,14 +669,14 @@ const struct valstr jedec_id5_vals[] = {
{ 0x00, NULL },
};
int
ipmi_spd_print(struct ipmi_intf * intf, uint8_t id)
void ipmi_spd_print(struct ipmi_intf * intf, unsigned char id)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct fru_info fru;
uint8_t spd_data[256], msg_data[4];
int len, offset, size;
unsigned char spd_data[256], msg_data[4];
int i, len, offset;
int size, conf;
msg_data[0] = id;
@ -690,26 +687,14 @@ ipmi_spd_print(struct ipmi_intf * intf, uint8_t id)
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
printf(" Device not present (No Response)\n");
return -1;
}
if (rsp->ccode > 0) {
printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (!rsp || rsp->ccode)
return;
fru.size = (rsp->data[1] << 8) | rsp->data[0];
fru.access = rsp->data[2] & 0x1;
lprintf(LOG_DEBUG, "fru.size = %d bytes (accessed by %s)",
fru.size, fru.access ? "words" : "bytes");
if (fru.size < 1) {
lprintf(LOG_ERR, " Invalid FRU size %d", fru.size);
return -1;
}
if (verbose > 1)
printf("fru.size = %d bytes (accessed by %s)\n",
fru.size, fru.access ? "words" : "bytes");
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_STORAGE;
@ -726,63 +711,49 @@ ipmi_spd_print(struct ipmi_intf * intf, uint8_t id)
msg_data[3] = 32;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
printf(" Device not present (No Response)\n");
return -1;
if (!rsp) {
printf(" Error while reading FRU data.\n");
return;
}
if (rsp->ccode > 0) {
printf(" Device not present (%s)\n",
val2str(rsp->ccode, completion_code_vals));
/* Timeouts are acceptable. No DIMM in the socket */
if (rsp->ccode == 0xc3)
return 1;
return -1;
if (rsp->ccode == 0xc3) {
printf(" Timeout while reading FRU data. (Device not present?)\n");
return;
}
if (rsp->ccode)
break;
len = rsp->data[0];
memcpy(&spd_data[offset], rsp->data + 1, len);
offset += len;
} while (offset < fru.size);
if (verbose > 1)
if (verbose)
printbuf(spd_data, offset, "SPD DATA");
if (offset < 92)
return -1; /* we need first 91 bytes to do our thing */
return; /* we need first 91 bytes to do our thing */
size = spd_data[5] * (spd_data[31] << 2);
printf(" Memory Size : %d MB\n", size);
printf(" Memory Type : %s\n",
val2str(spd_data[2], spd_memtype_vals));
printf(" Voltage Intf : %s\n",
val2str(spd_data[8], spd_voltage_vals));
printf(" Error Detect/Cor : %s\n",
val2str(spd_data[11], spd_config_vals));
printf(" Memory Size : %d MB\n", size);
printf(" Memory Type : %s\n", val2str(spd_data[2], spd_memtype_vals));
printf(" Voltage Intf : %s\n", val2str(spd_data[8], spd_voltage_vals));
printf(" Error Detect/Cor : %s\n", val2str(spd_data[11], spd_config_vals));
/* handle jedec table bank continuation values */
printf(" Manufacturer : ");
printf(" Manufacturer : ");
if (spd_data[64] != 0x7f)
printf("%s\n",
val2str(spd_data[64], jedec_id1_vals));
printf("%s\n", val2str(spd_data[64], jedec_id1_vals));
else {
if (spd_data[65] != 0x7f)
printf("%s\n",
val2str(spd_data[65], jedec_id2_vals));
printf("%s\n", val2str(spd_data[65], jedec_id2_vals));
else {
if (spd_data[66] != 0x7f)
printf("%s\n",
val2str(spd_data[66], jedec_id3_vals));
printf("%s\n", val2str(spd_data[66], jedec_id3_vals));
else {
if (spd_data[67] != 0x7f)
printf("%s\n",
val2str(spd_data[67],
jedec_id4_vals));
printf("%s\n", val2str(spd_data[67], jedec_id4_vals));
else
printf("%s\n",
val2str(spd_data[68],
jedec_id5_vals));
printf("%s\n", val2str(spd_data[68], jedec_id5_vals));
}
}
}
@ -791,8 +762,6 @@ ipmi_spd_print(struct ipmi_intf * intf, uint8_t id)
char part[19];
memcpy(part, spd_data+73, 18);
part[18] = 0;
printf(" Part Number : %s\n", part);
printf(" Part Number : %s\n", part);
}
return 0;
}

View File

@ -36,37 +36,29 @@
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>
#include <signal.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
extern int verbose;
#include <string.h>
uint32_t buf2long(uint8_t * buf)
uint32_t buf2long(unsigned char * buf)
{
return (uint32_t)(buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]);
}
uint16_t buf2short(uint8_t * buf)
unsigned short buf2short(unsigned char * buf)
{
return (uint16_t)(buf[1] << 8 | buf[0]);
return (unsigned short)(buf[1] << 8 | buf[0]);
}
const char * buf2str(uint8_t * buf, int len)
const char * buf2str(unsigned char * buf, int len)
{
static char str[1024];
int i;
if (len <= 0 || len > 1024)
if (!len || len > 1024)
return NULL;
memset(str, 0, 1024);
@ -79,31 +71,28 @@ const char * buf2str(uint8_t * buf, int len)
return (const char *)str;
}
void printbuf(const uint8_t * buf, int len, const char * desc)
void printbuf(unsigned char * buf, int len, char * desc)
{
int i;
if (len <= 0)
if (!len)
return;
if (verbose < 1)
return;
fprintf(stderr, "%s (%d bytes)\n", desc, len);
printf("%s (%d bytes)\n", desc, len);
for (i=0; i<len; i++) {
if (((i%16) == 0) && (i != 0))
fprintf(stderr, "\n");
fprintf(stderr, " %2.2x", buf[i]);
printf("\n");
printf(" %2.2x", buf[i]);
}
fprintf(stderr, "\n");
printf("\n");
}
const char * val2str(uint16_t val, const struct valstr *vs)
const char * val2str(unsigned short val, const struct valstr *vs)
{
static char un_str[16];
int i = 0;
while (vs[i].str != NULL) {
while (vs[i].str) {
if (vs[i].val == val)
return vs[i].str;
i++;
@ -115,116 +104,25 @@ const char * val2str(uint16_t val, const struct valstr *vs)
return un_str;
}
uint16_t str2val(const char *str, const struct valstr *vs)
void signal_handler(int sig, void * handler)
{
int i = 0;
struct sigaction act;
while (vs[i].str != NULL) {
if (!strncasecmp(vs[i].str, str, strlen(str)))
return vs[i].val;
i++;
if (!sig || !handler)
return;
memset(&act, 0, sizeof(act));
act.sa_handler = handler;
act.sa_flags = 0;
if (sigemptyset(&act.sa_mask) < 0) {
psignal(sig, "unable to empty signal set");
return;
}
return 0;
}
/* ipmi_csum - calculate an ipmi checksum
*
* @d: buffer to check
* @s: position in buffer to start checksum from
*/
uint8_t
ipmi_csum(uint8_t * d, int s)
{
uint8_t c = 0;
for (; s > 0; s--, d++)
c += *d;
return -c;
}
/* ipmi_open_file - safely open a file for reading or writing
*
* @file: filename
* @rw: read-write flag, 1=write
*
* returns pointer to file handler on success
* returns NULL on error
*/
FILE *
ipmi_open_file(const char * file, int rw)
{
struct stat st1, st2;
FILE * fp;
/* verify existance */
if (lstat(file, &st1) < 0) {
if (rw) {
/* does not exist, ok to create */
fp = fopen(file, "w");
if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s "
"for write", file);
return NULL;
}
/* created ok, now return the descriptor */
return fp;
} else {
lprintf(LOG_ERR, "File %s does not exist", file);
return NULL;
}
}
/* it exists - only regular files, not links */
if (S_ISREG(st1.st_mode) == 0) {
lprintf(LOG_ERR, "File %s has invalid mode: %d",
file, st1.st_mode);
return NULL;
}
/* allow only files with 1 link (itself) */
if (st1.st_nlink != 1) {
lprintf(LOG_ERR, "File %s has invalid link count: %d != 1",
file, (int)st1.st_nlink);
return NULL;
}
fp = fopen(file, rw ? "w+" : "r");
if (fp == NULL) {
lperror(LOG_ERR, "Unable to open file %s", file);
return NULL;
}
/* stat again */
if (fstat(fileno(fp), &st2) < 0) {
lperror(LOG_ERR, "Unable to stat file %s", file);
fclose(fp);
return NULL;
}
/* verify inode */
if (st1.st_ino != st2.st_ino) {
lprintf(LOG_ERR, "File %s has invalid inode: %d != %d",
file, st1.st_ino, st2.st_ino);
fclose(fp);
return NULL;
}
/* verify owner */
if (st1.st_uid != st2.st_uid) {
lprintf(LOG_ERR, "File %s has invalid user id: %d != %d",
file, st1.st_uid, st2.st_uid);
fclose(fp);
return NULL;
}
/* verify inode */
if (st2.st_nlink != 1) {
lprintf(LOG_ERR, "File %s has invalid link count: %d != 1",
file, st2.st_nlink);
fclose(fp);
return NULL;
}
return fp;
if (sigaction(sig, &act, NULL) < 0) {
psignal(sig, "unable to register handler");
return;
}
}

View File

@ -34,82 +34,86 @@
* facility.
*/
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/log.h>
#include <ipmitool/helper.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_raw.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_bmc.h>
int
ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
extern int verbose;
const struct valstr completion_code_vals[] = {
{ 0x00, "Command completed normally" },
{ 0xc0, "Node busy" },
{ 0xc1, "Invalid command" },
{ 0xc2, "Invalid command on LUN" },
{ 0xc3, "Timeout" },
{ 0xc4, "Out of space" },
{ 0xc5, "Reservation cancelled or invalid" },
{ 0xc6, "Request data truncated" },
{ 0xc7, "Request data length invalid" },
{ 0xc8, "Request data field length limit exceeded" },
{ 0xc9, "Parameter out of range" },
{ 0xca, "Cannot return number of requested data bytes" },
{ 0xcb, "Requested sensor, data, or record not found" },
{ 0xcc, "Invalid data field in request" },
{ 0xcd, "Command illegal for specified sensor or record type" },
{ 0xce, "Command response could not be provided" },
{ 0xcf, "Cannot execute duplicated request" },
{ 0xd0, "SDR Repository in update mode" },
{ 0xd1, "Device firmeware in update mode" },
{ 0xd2, "BMC initialization in progress" },
{ 0xd3, "Destination unavailable" },
{ 0xd4, "Insufficient priviledge level" },
{ 0xd5, "Command not supported in present state" },
{ 0xff, "Unspecified error" },
{ 0x00, NULL }
};
static int ipmi_bmc_reset(struct ipmi_intf * intf, int cmd)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t netfn, cmd;
int i;
uint8_t data[256];
if (argc < 2 || strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "RAW Commands: raw <netfn> <cmd> [data]");
return -1;
}
else if (argc > sizeof(data))
{
lprintf(LOG_NOTICE, "Raw command input limit (256 bytes) exceeded");
return -1;
}
netfn = (uint8_t)strtol(argv[0], NULL, 0);
cmd = (uint8_t)strtol(argv[1], NULL, 0);
memset(data, 0, sizeof(data));
memset(&req, 0, sizeof(req));
req.msg.netfn = netfn;
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = cmd;
req.msg.data = data;
for (i=2; i<argc; i++) {
uint8_t val = (uint8_t)strtol(argv[i], NULL, 0);
req.msg.data[i-2] = val;
req.msg.data_len++;
}
lprintf(LOG_INFO, "RAW REQ (netfn=0x%x cmd=0x%x data_len=%d)",
req.msg.netfn, req.msg.cmd, req.msg.data_len);
printbuf(req.msg.data, req.msg.data_len, "RAW REQUEST");
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to send RAW command "
"(netfn=0x%x cmd=0x%x)",
req.msg.netfn, req.msg.cmd);
if (!rsp) {
printf("Error in BMC Reset Command\n");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Unable to send RAW command "
"(netfn=0x%x cmd=0x%x rsp=0x%x): %s",
req.msg.netfn, req.msg.cmd, rsp->ccode,
val2str(rsp->ccode, completion_code_vals));
if (rsp->ccode) {
printf("BMC Reset Command returned %x\n", rsp->ccode);
return -1;
}
lprintf(LOG_INFO, "RAW RSP (%d bytes)", rsp->data_len);
/* print the raw response buffer */
for (i=0; i<rsp->data_len; i++) {
if (((i%16) == 0) && (i != 0))
printf("\n");
printf(" %2.2x", rsp->data[i]);
}
printf("\n");
return 0;
}
int ipmi_bmc_main(struct ipmi_intf * intf, int argc, char ** argv)
{
if (!argc || !strncmp(argv[0], "help", 4)) {
printf("BMC Commands: reset\n");
return 0;
}
else if (!strncmp(argv[0], "reset", 5)) {
if (argc < 2 || !strncmp(argv[1], "help", 4)) {
printf("reset commands: warm, cold\n");
}
else if (!strncmp(argv[1], "cold", 4)) {
ipmi_bmc_reset(intf, BMC_COLD_RESET);
}
else if (!strncmp(argv[1], "warm", 4)) {
ipmi_bmc_reset(intf, BMC_WARM_RESET);
}
else {
printf("reset commands: warm, cold\n");
}
}
return 0;
}

View File

@ -1,858 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi_lanp.h>
#include <ipmitool/ipmi_channel.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/ipmi_constants.h>
extern int csv_output;
extern int verbose;
void printf_channel_usage (void);
/**
* ipmi_1_5_authtypes
*
* Create a string describing the supported authentication types as
* specificed by the parameter n
*/
static const char *
ipmi_1_5_authtypes(uint8_t n)
{
uint32_t i;
static char supportedTypes[128];
bzero(supportedTypes, 128);
for (i = 0; ipmi_authtype_vals[i].val != 0; i++) {
if (n & ipmi_authtype_vals[i].val) {
strcat(supportedTypes, ipmi_authtype_vals[i].str);
strcat(supportedTypes, " ");
}
}
return supportedTypes;
}
/**
* ipmi_get_channel_auth_cap
*
* return 0 on success
* -1 on failure
*/
int
ipmi_get_channel_auth_cap(struct ipmi_intf * intf,
uint8_t channel,
uint8_t priv)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct get_channel_auth_cap_rsp auth_cap;
uint8_t msg_data[2];
msg_data[0] = channel | 0x80; // Ask for IPMI v2 data as well
msg_data[1] = priv;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; // 0x06
req.msg.cmd = IPMI_GET_CHANNEL_AUTH_CAP; // 0x38
req.msg.data = msg_data;
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
if ((rsp == NULL) || (rsp->ccode > 0)) {
/*
* It's very possible that this failed because we asked for IPMI v2 data
* Ask again, without requesting IPMI v2 data
*/
msg_data[0] &= 0x7F;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Authentication Capabilities");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Authentication Capabilities failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
}
memcpy(&auth_cap, rsp->data, sizeof(struct get_channel_auth_cap_rsp));
printf("Channel number : %d\n",
auth_cap.channel_number);
printf("IPMI v1.5 auth types : %s\n",
ipmi_1_5_authtypes(auth_cap.enabled_auth_types));
if (auth_cap.v20_data_available)
printf("KG status : %s\n",
(auth_cap.kg_status) ? "non-zero" : "default (all zeroes)");
printf("Per message authentication : %sabled\n",
(auth_cap.per_message_auth) ? "en" : "dis");
printf("User level authentication : %sabled\n",
(auth_cap.user_level_auth) ? "en" : "dis");
printf("Non-null user names exist : %s\n",
(auth_cap.non_null_usernames) ? "yes" : "no");
printf("Null user names exist : %s\n",
(auth_cap.null_usernames) ? "yes" : "no");
printf("Anonymous login enabled : %s\n",
(auth_cap.anon_login_enabled) ? "yes" : "no");
if (auth_cap.v20_data_available) {
printf("Channel supports IPMI v1.5 : %s\n",
(auth_cap.ipmiv15_support) ? "yes" : "no");
printf("Channel supports IPMI v2.0 : %s\n",
(auth_cap.ipmiv20_support) ? "yes" : "no");
}
/*
* If there is support for an OEM authentication type, there is some
* information.
*/
if (auth_cap.enabled_auth_types & IPMI_1_5_AUTH_TYPE_BIT_OEM) {
printf("IANA Number for OEM : %d\n",
auth_cap.oem_id[0] |
auth_cap.oem_id[1] << 8 |
auth_cap.oem_id[2] << 16);
printf("OEM Auxiliary Data : 0x%x\n",
auth_cap.oem_aux_data);
}
return 0;
}
/**
* ipmi_get_channel_info
*
* returns 0 on success
* -1 on failure
*
*/
int
ipmi_get_channel_info(struct ipmi_intf * intf, uint8_t channel)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t rqdata[2];
struct get_channel_info_rsp channel_info;
struct get_channel_access_rsp channel_access;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; // 0x06
req.msg.cmd = IPMI_GET_CHANNEL_INFO; // 0x42
req.msg.data = &channel;
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Info");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Info failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(&channel_info, rsp->data, sizeof(struct get_channel_info_rsp));
printf("Channel 0x%x info:\n", channel_info.channel_number);
printf(" Channel Medium Type : %s\n",
val2str(channel_info.channel_medium, ipmi_channel_medium_vals));
printf(" Channel Protocol Type : %s\n",
val2str(channel_info.channel_protocol, ipmi_channel_protocol_vals));
printf(" Session Support : ");
switch (channel_info.session_support) {
case 0x00:
printf("session-less\n");
break;
case 0x40:
printf("single-session\n");
break;
case 0x80:
printf("multi-session\n");
break;
case 0xc0:
default:
printf("session-based\n");
break;
}
printf(" Active Session Count : %d\n",
channel_info.active_sessions);
printf(" Protocol Vendor ID : %d\n",
channel_info.vendor_id[0] |
channel_info.vendor_id[1] << 8 |
channel_info.vendor_id[2] << 16);
memset(&req, 0, sizeof(req));
rqdata[0] = channel & 0xf;
/* get volatile settings */
rqdata[1] = 0x80; /* 0x80=active */
req.msg.netfn = IPMI_NETFN_APP; // 0x06
req.msg.cmd = IPMI_GET_CHANNEL_ACCESS; // 0x41
req.msg.data = rqdata;
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Access (volatile)");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Access (volatile) failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(&channel_access, rsp->data, sizeof(struct get_channel_access_rsp));
printf(" Volatile(active) Settings\n");
printf(" Alerting : %sabled\n",
(channel_access.alerting) ? "dis" : "en");
printf(" Per-message Auth : %sabled\n",
(channel_access.per_message_auth) ? "dis" : "en");
printf(" User Level Auth : %sabled\n",
(channel_access.user_level_auth) ? "dis" : "en");
printf(" Access Mode : ");
switch (channel_access.access_mode) {
case 0:
printf("disabled\n");
break;
case 1:
printf("pre-boot only\n");
break;
case 2:
printf("always available\n");
break;
case 3:
printf("shared\n");
break;
default:
printf("unknown\n");
break;
}
/* get non-volatile settings */
rqdata[1] = 0x40; /* 0x40=non-volatile */
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Access (non-volatile)");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Access (non-volatile) failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(&channel_access, rsp->data, sizeof(struct get_channel_access_rsp));
printf(" Non-Volatile Settings\n");
printf(" Alerting : %sabled\n",
(channel_access.alerting) ? "dis" : "en");
printf(" Per-message Auth : %sabled\n",
(channel_access.per_message_auth) ? "dis" : "en");
printf(" User Level Auth : %sabled\n",
(channel_access.user_level_auth) ? "dis" : "en");
printf(" Access Mode : ");
switch (channel_access.access_mode) {
case 0:
printf("disabled\n");
break;
case 1:
printf("pre-boot only\n");
break;
case 2:
printf("always available\n");
break;
case 3:
printf("shared\n");
break;
default:
printf("unknown\n");
break;
}
return 0;
}
static int
ipmi_get_user_access(struct ipmi_intf * intf, uint8_t channel, uint8_t userid)
{
struct ipmi_rs * rsp;
struct ipmi_rq req1, req2;
uint8_t rqdata[2];
struct get_user_access_rsp user_access;
int curr_uid, max_uid = 0, init = 1;
curr_uid = userid ? : 1;
memset(&req1, 0, sizeof(req1));
req1.msg.netfn = IPMI_NETFN_APP;
req1.msg.cmd = IPMI_GET_USER_ACCESS;
req1.msg.data = rqdata;
req1.msg.data_len = 2;
memset(&req2, 0, sizeof(req2));
req2.msg.netfn = IPMI_NETFN_APP;
req2.msg.cmd = IPMI_GET_USER_NAME;
req2.msg.data = rqdata;
req2.msg.data_len = 1;
do
{
rqdata[0] = channel & 0xf;
rqdata[1] = curr_uid & 0x3f;
rsp = intf->sendrecv(intf, &req1);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get User Access (channel %d id %d)",
rqdata[0], rqdata[1]);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get User Access (channel %d id %d) failed: %s",
rqdata[0], rqdata[1],
val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(&user_access, rsp->data, sizeof(struct get_user_access_rsp));
rqdata[0] = curr_uid & 0x3f;
rsp = intf->sendrecv(intf, &req2);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get User Name (id %d)", rqdata[0]);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get User Name (id %d) failed: %s",
rqdata[0], val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (init) {
printf("Maximum User IDs : %d\n", user_access.max_user_ids);
printf("Enabled User IDs : %d\n", user_access.enabled_user_ids);
max_uid = user_access.max_user_ids;
init = 0;
}
printf("\n");
printf("User ID : %d\n", curr_uid);
printf("User Name : %s\n", rsp->data);
printf("Fixed Name : %s\n",
(curr_uid <= user_access.fixed_user_ids) ? "Yes" : "No");
printf("Access Available : %s\n",
(user_access.callin_callback) ? "callback" : "call-in / callback");
printf("Link Authentication : %sabled\n",
(user_access.link_auth) ? "en" : "dis");
printf("IPMI Messaging : %sabled\n",
(user_access.ipmi_messaging) ? "en" : "dis");
printf("Privilege Level : %s\n",
val2str(user_access.privilege_limit, ipmi_privlvl_vals));
curr_uid ++;
} while (!userid && curr_uid <= max_uid);
return 0;
}
static int
ipmi_set_user_access(struct ipmi_intf * intf, int argc, char ** argv)
{
uint8_t channel, userid;
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t rqdata[2];
struct get_user_access_rsp user_access;
struct set_user_access_data set_access;
int i;
if ((argc < 3) || (strncmp(argv[0], "help", 4) == 0)) {
printf_channel_usage();
return 0;
}
channel = (uint8_t)strtol(argv[0], NULL, 0);
userid = (uint8_t)strtol(argv[1], NULL, 0);
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = IPMI_GET_USER_ACCESS;
req.msg.data = rqdata;
req.msg.data_len = 2;
rqdata[0] = channel & 0xf;
rqdata[1] = userid & 0x3f;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get User Access (channel %d id %d)",
rqdata[0], rqdata[1]);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get User Access (channel %d id %d) failed: %s",
rqdata[0], rqdata[1],
val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(&user_access, rsp->data, sizeof(struct get_user_access_rsp));
set_access.change_bits = 1;
set_access.callin_callback = user_access.callin_callback;
set_access.link_auth = user_access.link_auth;
set_access.ipmi_messaging = user_access.ipmi_messaging;
set_access.channel = channel;
set_access.user_id = userid;
set_access.privilege_limit = user_access.privilege_limit;
set_access.session_limit = 0;
for (i = 2; i < argc; i ++)
{
if (strncmp(argv[i], "callin=", 7) == 0) {
set_access.callin_callback = !(strncmp (argv[i]+7, "off", 3));
}
else if (strncmp(argv[i], "link=", 5) == 0) {
set_access.link_auth = strncmp (argv[i]+5, "off", 3);
}
else if (strncmp(argv[i], "ipmi=", 5) == 0) {
set_access.ipmi_messaging = strncmp (argv[i]+5, "off", 3);
}
else if (strncmp(argv[i], "privilege=", 10) == 0) {
set_access.privilege_limit = strtol (argv[i]+10, NULL, 0);
}
else {
printf ("Invalid option: %s\n", argv [i]);
return -1;
}
}
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = IPMI_SET_USER_ACCESS;
req.msg.data = (uint8_t *) &set_access;
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Set User Access (channel %d id %d)",
set_access.channel, set_access.user_id);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set User Access (channel %d id %d) failed: %s",
set_access.channel, set_access.user_id,
val2str(rsp->ccode, completion_code_vals));
return -1;
}
return 0;
}
static const char *
iana_string(uint32_t iana)
{
static char s[10];
if (iana)
{
sprintf(s, "%06x", iana);
return s;
}
else
return "N/A";
}
static int
ipmi_get_channel_cipher_suites(struct ipmi_intf * intf,
const char * which,
const char * payload_type,
uint8_t channel)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t oem_record;
uint8_t rqdata[3];
uint32_t iana;
uint8_t auth_alg, integrity_alg, crypt_alg;
uint8_t cipher_suite_id;
uint8_t list_index = 0;
uint8_t cipher_suite_data[1024]; // 0x40 sets * 16 bytes per set
uint16_t offset = 0;
uint16_t cipher_suite_data_length = 0; // how much was returned, total
memset(cipher_suite_data, 0, sizeof(cipher_suite_data));
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; // 0x06
req.msg.cmd = IPMI_GET_CHANNEL_CIPHER_SUITES; // 0x54
req.msg.data = rqdata;
req.msg.data_len = 3;
rqdata[0] = channel;
rqdata[1] = ((strncmp(payload_type, "ipmi", 4) == 0)? 0: 1);
rqdata[2] = ((strncmp(which, "all", 3) == 0)? 0x80: 0);
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
// Grab the returned channel number once. We assume it's the same
// in future calls.
if (rsp->data_len >= 1)
channel = rsp->data[0];
while ((rsp->data_len > 1) && (list_index < 0x3F))
{
//
// We got back cipher suite data -- store it.
//
//printf("copying data to offset %d\n", offset);
//printbuf(rsp->data + 1, rsp->data_len - 1, "this is the data");
memcpy(cipher_suite_data + offset, rsp->data + 1, rsp->data_len - 1);
offset += rsp->data_len - 1;
//
// Increment our list for the next call
//
++list_index;
rqdata[2] = (rqdata[2] & 0x80) + list_index;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Cipher Suites");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Cipher Suites failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
}
//
// We can chomp on all our data now.
//
cipher_suite_data_length = offset;
offset = 0;
if (! csv_output)
printf("ID IANA Auth Alg Integrity Alg Confidentiality Alg\n");
while (offset < cipher_suite_data_length)
{
if (cipher_suite_data[offset++] == 0xC0)
{
oem_record = 0; // standard type
iana = 0;
// Verify that we have at least a full record left
if ((cipher_suite_data_length - offset) < 4) // id + 3 algs
{
lprintf(LOG_ERR, "Incomplete data record in cipher suite data");
return -1;
}
cipher_suite_id = cipher_suite_data[offset++];
}
else if (cipher_suite_data[offset++] == 0xC1)
{
oem_record = 1; // OEM record type
// Verify that we have at least a full record left
if ((cipher_suite_data_length - offset) < 4) // id + iana + 3 algs
{
lprintf(LOG_ERR, "Incomplete data record in cipher suite data");
return -1;
}
cipher_suite_id = cipher_suite_data[offset++];
//
// Grab the IANA
//
iana =
cipher_suite_data[offset] |
(cipher_suite_data[offset + 1] << 8) |
(cipher_suite_data[offset + 2] << 16);
offset += 3;
}
else
{
lprintf(LOG_ERR, "Bad start of record byte in cipher suite data");
return -1;
}
//
// Grab the algorithms for this cipher suite. I guess we can't be
// sure of what order they'll come in. Also, I suppose we default
// to the NONE algorithm if one were absent. This part of the spec is
// poorly written -- I have read the errata document. For now, I'm only
// allowing one algorithm per type (auth, integrity, crypt) because I
// don't I understand how it could be otherwise.
//
auth_alg = IPMI_AUTH_RAKP_NONE;
integrity_alg = IPMI_INTEGRITY_NONE;
crypt_alg = IPMI_CRYPT_NONE;
while (((cipher_suite_data[offset] & 0xC0) != 0xC0) &&
((cipher_suite_data_length - offset) > 0))
{
switch (cipher_suite_data[offset] & 0xC0)
{
case 0x00:
// Authentication algorithm specifier
auth_alg = cipher_suite_data[offset++] & 0x3F;
break;
case 0x40:
// Interity algorithm specifier
integrity_alg = cipher_suite_data[offset++] & 0x3F;
break;
case 0x80:
// Confidentiality algorithm specifier
crypt_alg = cipher_suite_data[offset++] & 0x3F;
break;
}
}
//
// We have everything we need to spit out a cipher suite record
//
printf((csv_output? "%d,%s,%s,%s,%s\n" :
"%-4d %-7s %-15s %-15s %-15s\n"),
cipher_suite_id,
iana_string(iana),
val2str(auth_alg, ipmi_auth_algorithms),
val2str(integrity_alg, ipmi_integrity_algorithms),
val2str(crypt_alg, ipmi_encryption_algorithms));
}
return 0;
}
uint8_t
ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct get_channel_info_rsp info;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = IPMI_GET_CHANNEL_INFO;
req.msg.data = &channel;
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Get Channel Info command failed");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Channel Info command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(&info, rsp->data, sizeof(struct get_channel_info_rsp));
lprintf(LOG_DEBUG, "Channel type: %s",
val2str(info.channel_medium, ipmi_channel_medium_vals));
return info.channel_medium;
}
uint8_t
ipmi_current_channel_medium(struct ipmi_intf * intf)
{
return ipmi_get_channel_medium(intf, 0xE);
}
void
printf_channel_usage()
{
lprintf(LOG_NOTICE, "Channel Commands: authcap <channel number> <max privilege>");
lprintf(LOG_NOTICE, " getaccess <channel number> [user id]");
lprintf(LOG_NOTICE, " setaccess <channel number> "
"<user id> [callin=on|off] [ipmi=on|off] [link=on|off] [privilege=level]");
lprintf(LOG_NOTICE, " info [channel number]");
lprintf(LOG_NOTICE, " getciphers <all | supported> <ipmi | sol> [channel]\n");
lprintf(LOG_NOTICE, "Possible privilege levels are:");
lprintf(LOG_NOTICE, " 1 Callback level");
lprintf(LOG_NOTICE, " 2 User level");
lprintf(LOG_NOTICE, " 3 Operator level");
lprintf(LOG_NOTICE, " 4 Administrator level");
lprintf(LOG_NOTICE, " 5 OEM Proprietary level");
lprintf(LOG_NOTICE, " 15 No access");
}
int
ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int retval = 0;
if ((argc == 0) || (strncmp(argv[0], "help", 4) == 0))
{
printf_channel_usage();
}
else if (strncmp(argv[0], "authcap", 7) == 0)
{
if (argc != 3)
printf_channel_usage();
else
retval = ipmi_get_channel_auth_cap(intf,
(uint8_t)strtol(argv[1], NULL, 0),
(uint8_t)strtol(argv[2], NULL, 0));
}
else if (strncmp(argv[0], "getaccess", 10) == 0)
{
if ((argc < 2) || (argc > 3))
printf_channel_usage();
else {
uint8_t ch = (uint8_t)strtol(argv[1], NULL, 0);
uint8_t id = 0;
if (argc == 3)
id = (uint8_t)strtol(argv[2], NULL, 0);
retval = ipmi_get_user_access(intf, ch, id);
}
}
else if (strncmp(argv[0], "setaccess", 9) == 0)
{
retval = ipmi_set_user_access(intf, argc-1, &(argv[1]));
}
else if (strncmp(argv[0], "info", 4) == 0)
{
if (argc > 2)
printf_channel_usage();
else {
uint8_t ch = 0xe;
if (argc == 2)
ch = (uint8_t)strtol(argv[1], NULL, 0);
retval = ipmi_get_channel_info(intf, ch);
}
}
// it channel getciphers <all | supported> <ipmi | sol> [channel]
else if (strncmp(argv[0], "getciphers", 10) == 0)
{
if ((argc < 3) || (argc > 4) ||
(strncmp(argv[1], "all", 3) && strncmp(argv[1], "supported", 9)) ||
(strncmp(argv[2], "ipmi", 4) && strncmp(argv[2], "sol", 3)))
printf_channel_usage();
else
{
uint8_t ch = 0xe;
if (argc == 4)
ch = (uint8_t)strtol(argv[3], NULL, 0);
retval = ipmi_get_channel_cipher_suites(intf,
argv[1], // all | supported
argv[2], // ipmi | sol
ch);
}
}
else
{
printf("Invalid CHANNEL command: %s\n", argv[0]);
printf_channel_usage();
retval = -1;
}
return retval;
}

View File

@ -40,14 +40,11 @@
#include <ipmitool/helper.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_chassis.h>
extern int verbose;
static int
ipmi_chassis_power_status(struct ipmi_intf * intf)
static int ipmi_chassis_power_status(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
@ -58,19 +55,14 @@ ipmi_chassis_power_status(struct ipmi_intf * intf)
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to get Chassis Power Status");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Chassis Power Status failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
if (!rsp || rsp->ccode) {
printf("error in Chassis Status Command\n");
return 0;
}
printf("Chassis Power is %s\n", (rsp->data[0] & 0x1) ? "on" : "off");
return 0;
return rsp->data[0] & 0x1;
}
static const struct valstr ipmi_chassis_power_control_vals[] = {
@ -83,10 +75,8 @@ static const struct valstr ipmi_chassis_power_control_vals[] = {
{ 0x00, NULL },
};
static int
ipmi_chassis_power_control(struct ipmi_intf * intf, uint8_t ctl)
static void ipmi_chassis_power_control(struct ipmi_intf * intf, unsigned char ctl)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
memset(&req, 0, sizeof(req));
@ -95,96 +85,52 @@ ipmi_chassis_power_control(struct ipmi_intf * intf, uint8_t ctl)
req.msg.data = &ctl;
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to set Chassis Power Control to %s",
val2str(ctl, ipmi_chassis_power_control_vals));
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Chassis Power Control to %s failed: %s",
val2str(ctl, ipmi_chassis_power_control_vals),
val2str(rsp->ccode, completion_code_vals));
return -1;
}
printf("Chassis Power Control: %s\n",
val2str(ctl, ipmi_chassis_power_control_vals));
/* sessions often get lost when changing chassis power */
intf->sendrecv(intf, &req);
intf->abort = 1;
return 0;
}
static int
ipmi_chassis_identify(struct ipmi_intf * intf, char * arg)
static void ipmi_chassis_identify(struct ipmi_intf * intf, char * arg)
{
struct ipmi_rq req;
struct ipmi_rs * rsp;
struct {
uint8_t interval;
uint8_t force_on;
} identify_data;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_CHASSIS;
req.msg.cmd = 0x4;
if (arg != NULL) {
if (strncmp(arg, "force", 5) == 0) {
identify_data.interval = 0;
identify_data.force_on = 1;
} else {
identify_data.interval = (uint8_t)atoi(arg);
identify_data.force_on = 0;
}
req.msg.data = (uint8_t *)&identify_data;
/* The Force Identify On byte is optional and not
* supported by all devices-- if force is not specified,
* we pass only one data byte; if specified, we pass two
* data bytes and check for an error completion code
*/
req.msg.data_len = (identify_data.force_on) ? 2 : 1;
}
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to set Chassis Identify");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Chassis Identify failed: %s",
val2str(rsp->ccode, completion_code_vals));
if (identify_data.force_on != 0) {
/* Intel SE7501WV2 F/W 1.2 returns CC 0xC7, but
* the IPMI v1.5 spec does not standardize a CC
* if unsupported, so we warn
*/
lprintf(LOG_WARNING, "Chassis may not support Force Identify On\n");
}
return -1;
}
printf("Chassis identify interval: ");
if (arg == NULL) {
printf("default (15 seconds)\n");
if (arg) {
struct {
unsigned char interval;
unsigned char force_on;
} identify_data;
if (!strcmp(arg, "force")){
identify_data.interval = 0;
identify_data.force_on = 1;
printf("indefinite\n");
} else {
identify_data.interval = (unsigned char)atoi(arg);
identify_data.force_on = 0;
if (identify_data.interval)
printf("%d seconds\n", identify_data.interval);
else
printf("off\n");
}
req.msg.data = (unsigned char *)&identify_data;
req.msg.data_len = 2;
} else {
if (identify_data.force_on != 0) {
printf("indefinate\n");
} else {
if (identify_data.interval == 0)
printf("off\n");
else
printf("%i seconds\n", identify_data.interval);
}
printf("default (15 seconds)\n");
}
return 0;
intf->sendrecv(intf, &req);
}
static int
ipmi_chassis_poh(struct ipmi_intf * intf)
static void ipmi_chassis_poh(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
@ -195,26 +141,17 @@ ipmi_chassis_poh(struct ipmi_intf * intf)
req.msg.cmd = 0xf;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to get Chassis Power-On-Hours");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Chassis Power-On-Hours failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (!rsp || rsp->ccode)
return;
memcpy(&count, rsp->data+1, 4);
printf("POH Counter : %li hours total (%li days, %li hours)\n",
(long)count, (long)(count / 24), (long)(count % 24));
return 0;
count, (uint32_t)(count / 24), (uint32_t)(count % 24));
}
static int
ipmi_chassis_restart_cause(struct ipmi_intf * intf)
static void ipmi_chassis_restart_cause(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
@ -224,15 +161,9 @@ ipmi_chassis_restart_cause(struct ipmi_intf * intf)
req.msg.cmd = 0x7;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to get Chassis Restart Cause");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Chassis Restart Cause failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (!rsp || rsp->ccode)
return;
printf("System restart cause: ");
@ -268,14 +199,11 @@ ipmi_chassis_restart_cause(struct ipmi_intf * intf)
printf("power-cycle via PEF\n");
break;
default:
printf("invalid\n");
printf("error!\n");
}
return 0;
}
static int
ipmi_chassis_status(struct ipmi_intf * intf)
static void ipmi_chassis_status(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
@ -285,15 +213,8 @@ ipmi_chassis_status(struct ipmi_intf * intf)
req.msg.cmd = 0x1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error sending Chassis Status command");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error sending Chassis Status command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (!rsp || rsp->ccode)
return;
/* byte 1 */
printf("System Power : %s\n", (rsp->data[0] & 0x1) ? "on" : "off");
@ -337,31 +258,29 @@ ipmi_chassis_status(struct ipmi_intf * intf)
printf("Drive Fault : %s\n", (rsp->data[2] & 0x4) ? "true" : "false");
printf("Cooling/Fan Fault : %s\n", (rsp->data[2] & 0x8) ? "true" : "false");
if (rsp->data_len > 3) {
/* optional byte 4 */
if (rsp->data[3] == 0) {
printf("Front Panel Control : none\n");
} else {
printf("Sleep Button Disable : %s\n", (rsp->data[3] & 0x80) ? "allowed" : "not allowed");
printf("Diag Button Disable : %s\n", (rsp->data[3] & 0x40) ? "allowed" : "not allowed");
printf("Reset Button Disable : %s\n", (rsp->data[3] & 0x20) ? "allowed" : "not allowed");
printf("Power Button Disable : %s\n", (rsp->data[3] & 0x10) ? "allowed" : "not allowed");
printf("Sleep Button Disabled: %s\n", (rsp->data[3] & 0x80) ? "true" : "false");
printf("Diag Button Disabled : %s\n", (rsp->data[3] & 0x40) ? "true" : "false");
printf("Reset Button Disabled: %s\n", (rsp->data[3] & 0x20) ? "true" : "false");
printf("Power Button Disabled: %s\n", (rsp->data[3] & 0x10) ? "true" : "false");
}
if (rsp->data_len > 3)
{
/* optional byte 4 */
if (rsp->data[3] == 0) {
printf("Front Panel Control : none\n");
} else {
printf("Sleep Button Disable : %s\n", (rsp->data[3] & 0x80) ? "allowed" : "not allowed");
printf("Diag Button Disable : %s\n", (rsp->data[3] & 0x40) ? "allowed" : "not allowed");
printf("Reset Button Disable : %s\n", (rsp->data[3] & 0x20) ? "allowed" : "not allowed");
printf("Power Button Disable : %s\n", (rsp->data[3] & 0x10) ? "allowed" : "not allowed");
printf("Sleep Button Disabled: %s\n", (rsp->data[3] & 0x80) ? "true" : "false");
printf("Diag Button Disabled : %s\n", (rsp->data[3] & 0x40) ? "true" : "false");
printf("Reset Button Disabled: %s\n", (rsp->data[3] & 0x20) ? "true" : "false");
printf("Power Button Disabled: %s\n", (rsp->data[3] & 0x10) ? "true" : "false");
}
}
return 0;
}
static int
ipmi_chassis_set_bootparam(struct ipmi_intf * intf, uint8_t param, uint8_t * data, int len)
static void ipmi_chassis_set_bootparam(struct ipmi_intf * intf, unsigned char param, unsigned char * data, int len)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t msg_data[16];
unsigned char msg_data[16];
memset(msg_data, 0, 16);
msg_data[0] = param & 0x7f;
@ -374,33 +293,26 @@ ipmi_chassis_set_bootparam(struct ipmi_intf * intf, uint8_t param, uint8_t * dat
req.msg.data_len = len + 1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error setting Chassis Boot Parameter %d", param);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Chassis Boot Parameter %d failed: %s",
param, val2str(rsp->ccode, completion_code_vals));
return -1;
if (!rsp || rsp->ccode) {
printf("Error setting Chassis Boot Parameter %d\n", param);
return;
}
lprintf(LOG_DEBUG, "Chassis Set Boot Parameter %d to %s", param, buf2str(data, len));
return 0;
printf("Chassis Set Boot Param %d to %s\n", param, data);
}
static int
ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg)
static void ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t msg_data[3];
unsigned char msg_data[3];
if (arg == NULL)
return -1;
if (!arg)
return;
memset(msg_data, 0, 3);
msg_data[0] = (uint8_t)atoi(arg) & 0x7f;
msg_data[0] = (unsigned char)atoi(arg) & 0x7f;
msg_data[1] = 0;
msg_data[2] = 0;
@ -411,15 +323,8 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg)
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error Getting Chassis Boot Parameter %s", arg);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Chassis Boot Parameter %s failed: %s",
arg, val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (!rsp || rsp->ccode)
return;
if (verbose > 2)
printbuf(rsp->data, rsp->data_len, "Boot Option");
@ -430,65 +335,50 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg)
printf("Boot parameter data: %s\n", buf2str(rsp->data+2, rsp->data_len - 2));
}
static int
ipmi_chassis_set_bootdev(struct ipmi_intf * intf, char * arg)
static void ipmi_chassis_set_bootflag(struct ipmi_intf * intf, char * arg)
{
uint8_t flags[5];
int rc = 0;
unsigned char flags[5];
if (arg == NULL) {
lprintf(LOG_ERR, "No argument supplied");
return -1;
if (!arg) {
printf("Error: no bootflag argument supplied\n");
return;
}
memset(flags, 0, 5);
flags[0] = 0x01;
flags[1] = 0x01;
rc = ipmi_chassis_set_bootparam(intf, 4, flags, 2);
if (rc < 0)
return -1;
memset(flags, 0, 5);
if (strncmp(arg, "pxe", 3) == 0 ||
strncmp(arg, "force_pxe", 9) == 0)
flags[1] = 0x04;
else if (strncmp(arg, "disk", 4) == 0 ||
strncmp(arg, "force_disk", 10) == 0)
flags[1] = 0x08;
else if (strncmp(arg, "safe", 4) == 0 ||
strncmp(arg, "force_safe", 10) == 0)
flags[1] = 0x0c;
else if (strncmp(arg, "diag", 4) == 0 ||
strncmp(arg, "force_diag", 10) == 0)
flags[1] = 0x10;
else if (strncmp(arg, "cdrom", 5) == 0 ||
strncmp(arg, "force_cdrom", 11) == 0)
flags[1] = 0x14;
else if (strncmp(arg, "floppy", 6) == 0 ||
strncmp(arg, "force_floppy", 12) == 0)
flags[1] = 0x3c;
else if (strncmp(arg, "bios", 4) == 0 ||
strncmp(arg, "force_bios", 10) == 0)
flags[1] = 0x18;
if (!strncmp(arg, "force_pxe", 9)) {
flags[1] = 0x04; // 00000100
}
else if (!strncmp(arg, "force_disk", 10)) {
flags[1] = 0x08; // 00001000
}
else if (!strncmp(arg, "force_diag", 10)) {
flags[1] = 0x10; // 00010000
}
else if (!strncmp(arg, "force_cdrom", 11)) {
flags[1] = 0x14; // 00010100
}
else if (!strncmp(arg, "force_floppy", 12)) {
flags[1] = 0x3c; // 00111100
}
else {
lprintf(LOG_ERR, "Invalid argument: %s", arg);
return -1;
printf("Invalid bootflag: %s\n", arg);
return;
}
/* set flag valid bit */
flags[0] = 0x80;
rc = ipmi_chassis_set_bootparam(intf, 5, flags, 5);
if (rc == 0)
printf("Set Boot Device to %s\n", arg);
return rc;
flags[0] = 0x80; /* set flag valid bit */
ipmi_chassis_set_bootparam(intf, 5, flags, 5);
flags[0] = 0x08; /* don't automatically clear boot flag valid bit in 60 seconds */
ipmi_chassis_set_bootparam(intf, 3, flags, 1);
}
static int
ipmi_chassis_power_policy(struct ipmi_intf * intf, uint8_t policy)
static void ipmi_chassis_power_policy(struct ipmi_intf * intf, unsigned char policy)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
if (!policy)
return;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_CHASSIS;
req.msg.cmd = 0x6;
@ -496,15 +386,8 @@ ipmi_chassis_power_policy(struct ipmi_intf * intf, uint8_t policy)
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Power Restore Policy command");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Power Restore Policy command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (!rsp || rsp->ccode)
return;
if (policy == IPMI_CHASSIS_POLICY_NO_CHANGE) {
printf("Supported chassis power policy: ");
@ -532,139 +415,121 @@ ipmi_chassis_power_policy(struct ipmi_intf * intf, uint8_t policy)
printf("unknown\n");
}
}
return 0;
}
int
ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv)
int ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int rc = 0;
if ((argc == 0) || (strncmp(argv[0], "help", 4) == 0)) {
lprintf(LOG_NOTICE, "Chassis Commands: status, power, identify, policy, restart_cause, poh, bootdev");
if (!argc || !strncmp(argv[0], "help", 4)) {
printf("Chassis Commands: status, power, identify, policy, restart_cause, poh\n");
return 0;
}
else if (strncmp(argv[0], "status", 6) == 0) {
rc = ipmi_chassis_status(intf);
else if (!strncmp(argv[0], "status", 6)) {
ipmi_chassis_status(intf);
}
else if (strncmp(argv[0], "power", 5) == 0) {
uint8_t ctl = 0;
else if (!strncmp(argv[0], "power", 5)) {
unsigned char ctl = 0;
if ((argc < 2) || (strncmp(argv[1], "help", 4) == 0)) {
lprintf(LOG_NOTICE, "chassis power Commands: status, on, off, cycle, reset, diag, soft");
if (argc < 2 || !strncmp(argv[1], "help", 4)) {
printf("chassis power Commands: status, on, off, cycle, reset, diag, soft\n");
return 0;
}
if (strncmp(argv[1], "status", 6) == 0) {
rc = ipmi_chassis_power_status(intf);
return rc;
if (!strncmp(argv[1], "status", 6)) {
ipmi_chassis_power_status(intf);
return 0;
}
if ((strncmp(argv[1], "up", 2) == 0) || (strncmp(argv[1], "on", 2) == 0))
if (!strncmp(argv[1], "up", 2) || !strncmp(argv[1], "on", 2))
ctl = IPMI_CHASSIS_CTL_POWER_UP;
else if ((strncmp(argv[1], "down", 4) == 0) || (strncmp(argv[1], "off", 3) == 0))
else if (!strncmp(argv[1], "down", 4) || !strncmp(argv[1], "off", 3))
ctl = IPMI_CHASSIS_CTL_POWER_DOWN;
else if (strncmp(argv[1], "cycle", 5) == 0)
else if (!strncmp(argv[1], "cycle", 5))
ctl = IPMI_CHASSIS_CTL_POWER_CYCLE;
else if (strncmp(argv[1], "reset", 5) == 0)
else if (!strncmp(argv[1], "reset", 5))
ctl = IPMI_CHASSIS_CTL_HARD_RESET;
else if (strncmp(argv[1], "diag", 4) == 0)
else if (!strncmp(argv[1], "diag", 5))
ctl = IPMI_CHASSIS_CTL_PULSE_DIAG;
else if ((strncmp(argv[1], "acpi", 4) == 0) || (strncmp(argv[1], "soft", 4) == 0))
else if (!strncmp (argv[1], "acpi", 4) || !strncmp(argv[1], "soft", 4))
ctl = IPMI_CHASSIS_CTL_ACPI_SOFT;
else {
lprintf(LOG_ERR, "Invalid chassis power command: %s", argv[1]);
printf("Invalid chassis power command: %s\n", argv[1]);
return -1;
}
rc = ipmi_chassis_power_control(intf, ctl);
ipmi_chassis_power_control(intf, ctl);
}
else if (strncmp(argv[0], "identify", 8) == 0) {
else if (!strncmp(argv[0], "identify", 8)) {
if (argc < 2) {
rc = ipmi_chassis_identify(intf, NULL);
ipmi_chassis_identify(intf, NULL);
}
else if (strncmp(argv[1], "help", 4) == 0) {
lprintf(LOG_NOTICE, "chassis identify <interval>");
lprintf(LOG_NOTICE, " default is 15 seconds");
lprintf(LOG_NOTICE, " 0 to turn off");
lprintf(LOG_NOTICE, " force to turn on indefinitely");
else if (!strncmp(argv[1], "help", 4)) {
printf("chassis identify <interval>\n");
printf(" default is 15 seconds\n");
printf(" 0 to turn off\n");
printf(" force to turn on indefinitely\n");
} else {
rc = ipmi_chassis_identify(intf, argv[1]);
ipmi_chassis_identify(intf, argv[1]);
}
}
else if (strncmp(argv[0], "poh", 3) == 0) {
rc = ipmi_chassis_poh(intf);
else if (!strncmp(argv[0], "poh", 3)) {
ipmi_chassis_poh(intf);
}
else if (strncmp(argv[0], "restart_cause", 13) == 0) {
rc = ipmi_chassis_restart_cause(intf);
else if (!strncmp(argv[0], "restart_cause", 13)) {
ipmi_chassis_restart_cause(intf);
}
else if (strncmp(argv[0], "policy", 4) == 0) {
if ((argc < 2) || (strncmp(argv[1], "help", 4) == 0)) {
lprintf(LOG_NOTICE, "chassis policy <state>");
lprintf(LOG_NOTICE, " list : return supported policies");
lprintf(LOG_NOTICE, " always-on : turn on when power is restored");
lprintf(LOG_NOTICE, " previous : return to previous state when power is restored");
lprintf(LOG_NOTICE, " always-off : stay off after power is restored");
else if (!strncmp(argv[0], "policy", 4)) {
if (argc < 2 || !strncmp(argv[1], "help", 4)) {
printf("chassis policy <state>\n");
printf(" list : return supported policies\n");
printf(" always-on : turn on when power is restored\n");
printf(" previous : return to previous state when power is restored\n");
printf(" always-off : stay off after power is restored\n");
} else {
uint8_t ctl;
if (strncmp(argv[1], "list", 4) == 0)
unsigned char ctl;
if (!strncmp(argv[1], "list", 4))
ctl = IPMI_CHASSIS_POLICY_NO_CHANGE;
else if (strncmp(argv[1], "always-on", 9) == 0)
else if (!strncmp(argv[1], "always-on", 9))
ctl = IPMI_CHASSIS_POLICY_ALWAYS_ON;
else if (strncmp(argv[1], "previous", 8) == 0)
else if (!strncmp(argv[1], "previous", 8))
ctl = IPMI_CHASSIS_POLICY_PREVIOUS;
else if (strncmp(argv[1], "always-off", 10) == 0)
else if (!strncmp(argv[1], "always-off", 10))
ctl = IPMI_CHASSIS_POLICY_ALWAYS_OFF;
else {
lprintf(LOG_ERR, "Invalid chassis policy: %s", argv[1]);
printf("invalid chassis policy: %s\n", argv[1]);
return -1;
}
rc = ipmi_chassis_power_policy(intf, ctl);
ipmi_chassis_power_policy(intf, ctl);
}
}
else if (strncmp(argv[0], "bootparam", 9) == 0) {
if ((argc < 3) || (strncmp(argv[1], "help", 4) == 0)) {
lprintf(LOG_NOTICE, "bootparam get <param #>");
lprintf(LOG_NOTICE, "bootparam set bootflag <flag>");
lprintf(LOG_NOTICE, " force_pxe : Force PXE boot");
lprintf(LOG_NOTICE, " force_disk : Force boot from default Hard-drive");
lprintf(LOG_NOTICE, " force_safe : Force boot from default Hard-drive, request Safe Mode");
lprintf(LOG_NOTICE, " force_diag : Force boot from Diagnostic Partition");
lprintf(LOG_NOTICE, " force_cdrom : Force boot from CD/DVD");
lprintf(LOG_NOTICE, " force_bios : Force boot into BIOS Setup");
else if (!strncmp(argv[0], "bootparam", 7)) {
if (argc < 3 || !strncmp(argv[1], "help", 4)) {
printf("bootparam get|set <option> [value ...]\n");
}
else {
if (strncmp(argv[1], "get", 3) == 0) {
rc = ipmi_chassis_get_bootparam(intf, argv[2]);
if (!strncmp(argv[1], "get", 3)) {
ipmi_chassis_get_bootparam(intf, argv[2]);
}
else if (strncmp(argv[1], "set", 3) == 0) {
else if (!strncmp(argv[1], "set", 3)) {
if (argc < 4) {
lprintf(LOG_NOTICE, "bootparam set <option> [value ...]");
printf("bootparam set <option> [value ...]\n");
} else {
if (strncmp(argv[2], "bootflag", 8) == 0)
rc = ipmi_chassis_set_bootdev(intf, argv[3]);
else
lprintf(LOG_NOTICE, "bootparam set <option> [value ...]");
if (!strncmp(argv[2], "bootflag", 8)) {
ipmi_chassis_set_bootflag(intf, argv[3]);
}
else {
printf("bootparam set <option> [value ...]\n");
}
}
}
else
lprintf(LOG_NOTICE, "bootparam get|set <option> [value ...]");
}
}
else if (strncmp(argv[0], "bootdev", 7) == 0) {
if ((argc < 2) || (strncmp(argv[1], "help", 4) == 0)) {
lprintf(LOG_NOTICE, "bootdev <device>");
lprintf(LOG_NOTICE, " pxe : Force PXE boot");
lprintf(LOG_NOTICE, " disk : Force boot from default Hard-drive");
lprintf(LOG_NOTICE, " safe : Force boot from default Hard-drive, request Safe Mode");
lprintf(LOG_NOTICE, " diag : Force boot from Diagnostic Partition");
lprintf(LOG_NOTICE, " cdrom : Force boot from CD/DVD");
lprintf(LOG_NOTICE, " bios : Force boot into BIOS Setup");
} else {
rc = ipmi_chassis_set_bootdev(intf, argv[1]);
else {
printf("bootparam get|set <option> [value]\n");
}
}
}
else {
lprintf(LOG_ERR, "Invalid Chassis command: %s", argv[0]);
printf("Invalid Chassis command: %s\n", argv[0]);
return -1;
}
return rc;
return 0;
}

View File

@ -1,272 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <ctype.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi_sel.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/ipmi_channel.h>
static int
ipmi_send_platform_event(struct ipmi_intf * intf, int num)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t rqdata[8];
uint8_t chmed;
int p = 0;
memset(&req, 0, sizeof(req));
memset(rqdata, 0, 8);
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 */
req.msg.data_len = 8;
rqdata[p++] = 0x20;
}
/* IPMB/LAN/etc */
switch (num) {
case 1: /* temperature */
printf("Sending SAMPLE event: Temperature - "
"Upper Critical - Going High\n");
rqdata[p++] = 0x04; /* EvMRev */
rqdata[p++] = 0x01; /* Sensor Type */
rqdata[p++] = 0x30; /* Sensor # */
rqdata[p++] = 0x01; /* Event Dir / Event Type */
rqdata[p++] = 0x59; /* Event Data 1 */
rqdata[p++] = 0x00; /* Event Data 2 */
rqdata[p++] = 0x00; /* Event Data 3 */
break;
case 2: /* voltage error */
printf("Sending SAMPLE event: Voltage Threshold - "
"Lower Critical - Going Low\n");
rqdata[p++] = 0x04; /* EvMRev */
rqdata[p++] = 0x02; /* Sensor Type */
rqdata[p++] = 0x60; /* Sensor # */
rqdata[p++] = 0x01; /* Event Dir / Event Type */
rqdata[p++] = 0x52; /* Event Data 1 */
rqdata[p++] = 0x00; /* Event Data 2 */
rqdata[p++] = 0x00; /* Event Data 3 */
break;
case 3: /* correctable ECC */
printf("Sending SAMPLE event: Memory - Correctable ECC\n");
rqdata[p++] = 0x04; /* EvMRev */
rqdata[p++] = 0x0c; /* Sensor Type */
rqdata[p++] = 0x53; /* Sensor # */
rqdata[p++] = 0x6f; /* Event Dir / Event Type */
rqdata[p++] = 0x00; /* Event Data 1 */
rqdata[p++] = 0x00; /* Event Data 2 */
rqdata[p++] = 0x00; /* Event Data 3 */
break;
default:
lprintf(LOG_ERR, "Invalid event number: %d", num);
return -1;
}
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Platform Event Message command failed");
return -1;
}
else if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Platform Event Message command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
return 0;
}
static int
ipmi_event_fromfile(struct ipmi_intf * intf, char * file)
{
FILE * fp;
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 == 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] = 0x20;
req.msg.data_len = 8;
}
fp = ipmi_open_file_read(file);
if (fp == NULL)
return -1;
while (feof(fp) == 0) {
if (fgets(buf, 1024, fp) == NULL)
continue;
/* clip off optional comment tail indicated by # */
ptr = strchr(buf, '#');
if (ptr)
*ptr = '\0';
else
ptr = buf + strlen(buf);
/* clip off trailing and leading whitespace */
ptr--;
while (isspace(*ptr) && ptr >= buf)
*ptr-- = '\0';
ptr = buf;
while (isspace(*ptr))
ptr++;
if (strlen(ptr) == 0)
continue;
/* parse the event, 7 bytes with optional comment */
/* 0x00 0x00 0x00 0x00 0x00 0x00 0x00 # event */
i = 0;
tok = strtok(ptr, " ");
while (tok) {
if (i == 7)
break;
j = i++;
if (chmed == IPMI_CHANNEL_MEDIUM_SYSTEM)
j++;
rqdata[j] = (uint8_t)strtol(tok, NULL, 0);
tok = strtok(NULL, " ");
}
if (i < 7) {
lprintf(LOG_ERR, "Invalid Event: %s",
buf2str(rqdata, sizeof(rqdata)));
continue;
}
memset(&sel_event, 0, sizeof(struct sel_event_record));
sel_event.record_id = 0;
sel_event.gen_id = 2;
j = (chmed == IPMI_CHANNEL_MEDIUM_SYSTEM) ? 1 : 0;
sel_event.evm_rev = rqdata[j++];
sel_event.sensor_type = rqdata[j++];
sel_event.sensor_num = rqdata[j++];
sel_event.event_type = rqdata[j] & 0x7f;
sel_event.event_dir = (rqdata[j++] & 0x80) >> 7;
sel_event.event_data[0] = rqdata[j++];
sel_event.event_data[1] = rqdata[j++];
sel_event.event_data[2] = rqdata[j++];
ipmi_sel_print_std_entry(&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);
return rc;
}
int
ipmi_event_main(struct ipmi_intf * intf, int argc, char ** argv)
{
uint8_t c;
int rc = 0;
if (argc == 0 || strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "usage: event <num>");
lprintf(LOG_NOTICE, " 1 : Temperature - Upper Critical - Going High");
lprintf(LOG_NOTICE, " 2 : Voltage Threshold - Lower Critical - Going Low");
lprintf(LOG_NOTICE, " 3 : Memory - Correctable ECC");
lprintf(LOG_NOTICE, "usage: event file <filename>");
lprintf(LOG_NOTICE, " Will read list of events from file");
return 0;
}
if (strncmp(argv[0], "file", 4) == 0) {
if (argc < 2) {
lprintf(LOG_NOTICE, "usage: event file <filename>\n");
rc = -1;
} else {
rc = ipmi_event_fromfile(intf, argv[1]);
}
} else {
c = (uint8_t)strtol(argv[0], NULL, 0);
rc = ipmi_send_platform_event(intf, c);
}
return rc;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,195 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_isol.h>
const struct valstr ipmi_isol_baud_vals[] = {
{ ISOL_BAUD_RATE_9600, "9600" },
{ ISOL_BAUD_RATE_19200, "19200" },
{ ISOL_BAUD_RATE_38400, "38400" },
{ ISOL_BAUD_RATE_57600, "57600" },
{ ISOL_BAUD_RATE_115200, "115200" },
{ 0x00, NULL }
};
extern int verbose;
static int ipmi_isol_setup(struct ipmi_intf * intf, char baudsetting)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
unsigned char data[6];
/* TEST FOR AVAILABILITY */
memset(data, 0, 6);
data[0] = 0x00;
data[1] = ISOL_ENABLE_PARAM;
data[2] = ISOL_ENABLE_FLAG;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_ISOL;
req.msg.cmd = SET_ISOL_CONFIG;
req.msg.data = data;
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Set ISOL Config Command");
return -1;
}
if (rsp->ccode == 0xc1) {
lprintf(LOG_ERR, "IPMI v1.5 Serial Over Lan (ISOL) not supported!");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Set ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
/* GET ISOL CONFIG */
memset(data, 0, 6);
data[0] = 0x00;
data[1] = ISOL_AUTHENTICATION_PARAM;
data[2] = 0x00; /* block */
data[3] = 0x00; /* selector */
req.msg.cmd = GET_ISOL_CONFIG;
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
if (verbose > 1)
printbuf(rsp->data, rsp->data_len, "ISOL Config");
/* SET ISOL CONFIG - AUTHENTICATION */
memset(data, 0, 6);
data[0] = 0x00;
data[1] = ISOL_AUTHENTICATION_PARAM;
data[2] = ISOL_PRIVILEGE_LEVEL_USER | (rsp->data[1] & 0x80);
req.msg.cmd = SET_ISOL_CONFIG;
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Set ISOL Config (Authentication) Command");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Set ISOL Config (Authentication) Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
/* SET ISOL CONFIG - BAUD RATE */
memset(data, 0, 6);
data[0] = 0x00;
data[1] = ISOL_BAUD_RATE_PARAM;
data[2] = baudsetting;
req.msg.cmd = SET_ISOL_CONFIG;
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error in Set ISOL Config (Baud Rate) Command");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error in Set ISOL Config (Baud Rate) Command: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
printf("Set ISOL Baud Rate to %s\n",
val2str(baudsetting, ipmi_isol_baud_vals));
return 0;
}
int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int ret = 0;
if (argc < 2 || strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "ISOL Commands: setup <baud>");
lprintf(LOG_NOTICE, "ISOL Baud Rates: 9600, 19200, 38400, 57600, 115200");
return 0;
}
if (strncmp(argv[0], "setup", 5) == 0) {
if (strncmp(argv[1], "9600", 4) == 0) {
ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_9600);
}
else if (strncmp(argv[1], "19200", 5) == 0) {
ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_19200);
}
else if (strncmp(argv[1], "38400", 5) == 0) {
ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_38400);
}
else if (strncmp(argv[1], "57600", 5) == 0) {
ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_57600);
}
else if (strncmp(argv[1], "115200", 6) == 0) {
ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_115200);
}
else {
lprintf(LOG_ERR, "ISOL - Unsupported baud rate: %s", argv[1]);
ret = -1;
}
}
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,449 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_mc.h>
#include <ipmitool/ipmi_strings.h>
extern int verbose;
/* ipmi_mc_reset - attempt to reset an MC
*
* @intf: ipmi interface
* @cmd: reset command to send
* BMC_WARM_RESET or
* BMC_COLD_RESET
*
* returns 0 on success
* returns -1 on error
*/
static int
ipmi_mc_reset(struct ipmi_intf * intf, int cmd)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = cmd;
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Reset command failed");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Reset command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
return 0;
}
struct bmc_enables_data {
#if WORDS_BIGENDIAN
uint8_t oem2 : 1;
uint8_t oem1 : 1;
uint8_t oem0 : 1;
uint8_t __reserved : 1;
uint8_t system_event_log : 1;
uint8_t event_msgbuf : 1;
uint8_t event_msgbuf_intr : 1;
uint8_t receive_msg_intr : 1;
#else
uint8_t receive_msg_intr : 1;
uint8_t event_msgbuf_intr : 1;
uint8_t event_msgbuf : 1;
uint8_t system_event_log : 1;
uint8_t __reserved : 1;
uint8_t oem0 : 1;
uint8_t oem1 : 1;
uint8_t oem2 : 1;
#endif
} __attribute__ ((packed));
struct bitfield_data {
const char * name;
const char * desc;
uint32_t mask;
};
struct bitfield_data mc_enables_bf[] = {
{
name: "recv_msg_intr",
desc: "Receive Message Queue Interrupt",
mask: 1<<0,
},
{
name: "event_msg_intr",
desc: "Event Message Buffer Full Interrupt",
mask: 1<<1,
},
{
name: "event_msg",
desc: "Event Message Buffer",
mask: 1<<2,
},
{
name: "system_event_log",
desc: "System Event Logging",
mask: 1<<3,
},
{
name: "oem0",
desc: "OEM 0",
mask: 1<<5,
},
{
name: "oem1",
desc: "OEM 1",
mask: 1<<6,
},
{
name: "oem2",
desc: "OEM 2",
mask: 1<<7,
},
{ NULL },
};
static void
printf_mc_usage()
{
struct bitfield_data * bf;
printf("MC Commands:\n");
printf(" reset <warm|cold>\n");
printf(" info\n");
printf(" getenables\n");
printf(" setenables <option=on|off> ...\n");
for (bf = mc_enables_bf; bf->name != NULL; bf++) {
printf(" %-20s %s\n", bf->name, bf->desc);
}
}
/* ipmi_mc_get_enables - print out MC enables
*
* @intf: ipmi inteface
*
* returns 0 on success
* returns -1 on error
*/
static int
ipmi_mc_get_enables(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct bitfield_data * bf;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_GET_GLOBAL_ENABLES;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Get Global Enables command failed");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Global Enables command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
for (bf = mc_enables_bf; bf->name != NULL; bf++) {
printf("%-40s : %sabled\n", bf->desc,
rsp->data[0] & bf->mask ? "en" : "dis");
}
return 0;
}
/* ipmi_mc_set_enables - set MC enable flags
*
* @intf: ipmi inteface
* @argc: argument count
* @argv: argument list
*
* returns 0 on success
* returns -1 on error
*/
static int
ipmi_mc_set_enables(struct ipmi_intf * intf, int argc, char ** argv)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct bitfield_data * bf;
uint8_t en;
int i;
if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
printf_mc_usage();
return 0;
}
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_GET_GLOBAL_ENABLES;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Get Global Enables command failed");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Global Enables command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
en = rsp->data[0];
for (i = 0; i < argc; i++) {
for (bf = mc_enables_bf; bf->name != NULL; bf++) {
int nl = strlen(bf->name);
if (strncmp(argv[i], bf->name, nl) != 0)
continue;
if (strncmp(argv[i]+nl+1, "off", 3) == 0) {
printf("Disabling %s\n", bf->desc);
en &= ~bf->mask;
}
else if (strncmp(argv[i]+nl+1, "on", 2) == 0) {
printf("Enabling %s\n", bf->desc);
en |= bf->mask;
}
else {
lprintf(LOG_ERR, "Unrecognized option: %s", argv[i]);
}
}
}
if (en == rsp->data[0]) {
printf("\nNothing to change...\n");
ipmi_mc_get_enables(intf);
return 0;
}
req.msg.cmd = BMC_SET_GLOBAL_ENABLES;
req.msg.data = &en;
req.msg.data_len = 1;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Set Global Enables command failed");
return -1;
}
else if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Global Enables command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
printf("\nVerifying...\n");
ipmi_mc_get_enables(intf);
return 0;
}
/* IPM Device, Get Device ID Command - Additional Device Support */
const char *ipm_dev_adtl_dev_support[8] = {
"Sensor Device", /* bit 0 */
"SDR Repository Device", /* bit 1 */
"SEL Device", /* bit 2 */
"FRU Inventory Device", /* ... */
"IPMB Event Receiver",
"IPMB Event Generator",
"Bridge",
"Chassis Device" /* bit 7 */
};
/* ipmi_mc_get_deviceid - print information about this MC
*
* @intf: ipmi interface
*
* returns 0 on success
* returns -1 on error
*/
static int
ipmi_mc_get_deviceid(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct ipm_devid_rsp *devid;
int i;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_GET_DEVICE_ID;
req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Get Device ID command failed");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get Device ID command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
devid = (struct ipm_devid_rsp *) rsp->data;
printf("Device ID : %i\n",
devid->device_id);
printf("Device Revision : %i\n",
devid->device_revision & IPM_DEV_DEVICE_ID_REV_MASK);
printf("Firmware Revision : %u.%x\n",
devid->fw_rev1 & IPM_DEV_FWREV1_MAJOR_MASK,
devid->fw_rev2);
printf("IPMI Version : %x.%x\n",
IPM_DEV_IPMI_VERSION_MAJOR(devid->ipmi_version),
IPM_DEV_IPMI_VERSION_MINOR(devid->ipmi_version));
printf("Manufacturer ID : %lu\n",
(long)IPM_DEV_MANUFACTURER_ID(devid->manufacturer_id));
printf("Product ID : %u (0x%02x%02x)\n",
buf2short((uint8_t *)(devid->product_id)),
devid->product_id[1], devid->product_id[0]);
printf("Device Available : %s\n",
(devid->fw_rev1 & IPM_DEV_FWREV1_AVAIL_MASK) ?
"no" : "yes");
printf("Provides Device SDRs : %s\n",
(devid->device_revision & IPM_DEV_DEVICE_ID_SDR_MASK) ?
"yes" : "no");
printf("Additional Device Support :\n");
for (i = 0; i < IPM_DEV_ADTL_SUPPORT_BITS; i++) {
if (devid->adtl_device_support & (1 << i)) {
printf(" %s\n", ipm_dev_adtl_dev_support[i]);
}
}
printf("Aux Firmware Rev Info : \n");
/* These values could be looked-up by vendor if documented,
* so we put them on individual lines for better treatment later
*/
printf(" 0x%02x\n 0x%02x\n 0x%02x\n 0x%02x\n",
devid->aux_fw_rev[0], devid->aux_fw_rev[1],
devid->aux_fw_rev[2], devid->aux_fw_rev[3]);
return 0;
}
/* ipmi_mc_get_guid - print this MC GUID
*
* @intf: ipmi interface
*
* returns 0 on success
* returns -1 on error
*/
static int
ipmi_mc_get_guid(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = BMC_GET_GUID;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Get GUID command failed");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get GUID command failed: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
printf("System GUID: %s\n", buf2str(rsp->data, rsp->data_len));
return 0;
}
/* ipmi_mc_main - top-level handler for MC functions
*
* @intf: ipmi interface
* @argc: number of arguments
* @argv: argument list
*
* returns 0 on success
* returns -1 on error
*/
int
ipmi_mc_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int rc = 0;
if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
printf_mc_usage();
}
else if (strncmp(argv[0], "reset", 5) == 0) {
if (argc < 2 || strncmp(argv[1], "help", 4) == 0) {
lprintf(LOG_ERR, "reset commands: warm, cold");
}
else if (strncmp(argv[1], "cold", 4) == 0) {
rc = ipmi_mc_reset(intf, BMC_COLD_RESET);
}
else if (strncmp(argv[1], "warm", 4) == 0) {
rc = ipmi_mc_reset(intf, BMC_WARM_RESET);
}
else {
lprintf(LOG_ERR, "reset commands: warm, cold");
}
}
else if (strncmp(argv[0], "info", 4) == 0) {
rc = ipmi_mc_get_deviceid(intf);
}
else if (strncmp(argv[0], "guid", 4) == 0) {
rc = ipmi_mc_get_guid(intf);
}
else if (strncmp(argv[0], "getenables", 10) == 0) {
rc = ipmi_mc_get_enables(intf);
}
else if (strncmp(argv[0], "setenables", 10) == 0) {
rc = ipmi_mc_set_enables(intf, argc-1, &(argv[1]));
}
return rc;
}

View File

@ -1,150 +0,0 @@
/*
* 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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <string.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_constants.h>
#include <ipmitool/log.h>
#include <ipmitool/helper.h>
static int ipmi_oem_supermicro(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: "intelwv2",
desc: "Intel SE7501WV2 IPMIv1.5 BMC with extra LAN communication support",
},
{
name: "intelplus",
desc: "Intel IPMI 2.0 BMC with RMCP+ communication support",
},
{ 0 },
};
/* Supermicro IPMIv2 BMCs use OEM authtype */
static int
ipmi_oem_supermicro(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;
lprintf(LOG_NOTICE, "\nOEM Support:");
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, "");
}
/* ipmi_oem_setup - do initial setup of OEM handle
*
* @intf: ipmi interface
* @oemtype: OEM handle name
*
* returns 0 on success
* returns -1 on error
*/
int
ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype)
{
struct ipmi_oem_handle * oem;
int i;
int rc = 0;
if (strncmp(oemtype, "help", 4) == 0 ||
strncmp(oemtype, "list", 4) == 0 ||
oemtype == NULL) {
ipmi_oem_print();
return -1;
}
for (oem=ipmi_oem_list, i=0; i < sizeof(ipmi_oem_list)/sizeof(struct ipmi_oem_handle); oem++, i++) {
if (oem->name == NULL)
continue;
if (strncmp(oemtype, oem->name, strlen(oem->name)) == 0)
break;
}
if (oem->name == NULL) {
/* nothing was found */
lprintf(LOG_ERR, "OEM support not found for \"%s\"", oemtype);
return -1;
}
/* save pointer for later use */
intf->oem = oem;
/* run optional setup function if it is defined */
if (oem->setup != NULL) {
lprintf(LOG_DEBUG, "Running OEM setup for \"%s\"", oem->desc);
rc = oem->setup(intf);
}
return rc;
}
/* ipmi_oem_active - used to determine if a particular OEM type is set
*
* @intf: ipmi interface
* @oemtype: string containing name of ipmi handle to check
*
* returns 1 if requested ipmi handle is active
* returns 0 otherwise
*/
int
ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype)
{
if (intf->oem == NULL)
return 0;
if (strncmp(intf->oem->name, oemtype, strlen(oemtype)) == 0)
return 1;
return 0;
}

View File

@ -1,861 +0,0 @@
/*
* Copyright (c) 2004 Dell Computers. 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 Dell Computers, 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.
* DELL COMPUTERS ("DELL") 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
* DELL 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 DELL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <string.h>
#include <math.h>
#include <time.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_pef.h>
extern int verbose;
/*
// common kywd/value printf() templates
*/
static const char * pef_fld_fmts[][2] = {
{"%-*s : %u\n", " | %u"}, /* F_DEC: unsigned value */
{"%-*s : %d\n", " | %d"}, /* F_INT: signed value */
{"%-*s : %s\n", " | %s"}, /* F_STR: string value */
{"%-*s : 0x%x\n", " | 0x%x"}, /* F_HEX: "N hex digits" */
{"%-*s : 0x%04x\n", " | 0x%04x"}, /* F_2XD: "2 hex digits" */
{"%-*s : 0x%02x\n", " | 0x%02x"}, /* F_1XD: "1 hex digit" */
{"%-*s : %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
" | %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"},
};
typedef enum {
F_DEC,
F_INT,
F_STR,
F_HEX,
F_2XD,
F_1XD,
F_UID,
} fmt_e;
#define KYWD_LENGTH 24
static int first_field = 1;
static const char * pef_flag_fmts[][3] = {
{"", "false", "true"},
{"supported", "un", ""},
{"active", "in", ""},
{"abled", "dis", "en"},
};
static const char * listitem[] = {" | %s", ",%s", "%s"};
const char *
ipmi_pef_bit_desc(struct bit_desc_map * map, uint32_t value)
{ /*
// return description/text label(s) for the given value.
// NB: uses a static buffer
*/
static char buf[128];
char * p;
struct desc_map * pmap;
uint32_t match, index;
*(p = buf) = '\0';
index = 2;
for (pmap=map->desc_maps; pmap && pmap->desc; pmap++) {
if (map->desc_map_type == BIT_DESC_MAP_LIST)
match = (value == pmap->mask);
else
match = ((value & pmap->mask) == pmap->mask);
if (match) {
sprintf(p, listitem[index], pmap->desc);
p = strchr(p, '\0');
if (map->desc_map_type != BIT_DESC_MAP_ALL)
break;
index = 1;
}
}
if (p == buf)
return("None");
return((const char *)buf);
}
void
ipmi_pef_print_flags(struct bit_desc_map * map, flg_e type, uint32_t val)
{ /*
// print features/flags, using val (a bitmask), according to map.
// observe the verbose flag, and print any labels, etc. based on type
*/
struct desc_map * pmap;
uint32_t maskval, index;
index = 0;
for (pmap=map->desc_maps; pmap && pmap->desc; pmap++) {
maskval = (val & pmap->mask);
if (verbose)
printf("%-*s : %s%s\n", KYWD_LENGTH,
ipmi_pef_bit_desc(map, pmap->mask),
pef_flag_fmts[type][1 + (maskval != 0)],
pef_flag_fmts[type][0]);
else if (maskval != 0) {
printf(listitem[index], ipmi_pef_bit_desc(map, maskval));
index = 1;
}
}
}
static void
ipmi_pef_print_field(const char * fmt[2], const char * label, unsigned long val)
{ /*
// print a 'field' (observes 'verbose' flag)
*/
if (verbose)
printf(fmt[0], KYWD_LENGTH, label, val);
else if (first_field)
printf(&fmt[1][2], val); /* skip field separator */
else
printf(fmt[1], val);
first_field = 0;
}
void
ipmi_pef_print_dec(const char * text, uint32_t val)
{ /* unsigned */
ipmi_pef_print_field(pef_fld_fmts[F_DEC], text, val);
}
void
ipmi_pef_print_int(const char * text, uint32_t val)
{ /* signed */
ipmi_pef_print_field(pef_fld_fmts[F_INT], text, val);
}
void
ipmi_pef_print_hex(const char * text, uint32_t val)
{ /* hex */
ipmi_pef_print_field(pef_fld_fmts[F_HEX], text, val);
}
void
ipmi_pef_print_str(const char * text, const char * val)
{ /* string */
ipmi_pef_print_field(pef_fld_fmts[F_STR], text, (unsigned long)val);
}
void
ipmi_pef_print_2xd(const char * text, uint8_t u1, uint8_t u2)
{ /* 2 hex digits */
uint32_t val = ((u1 << 8) + u2) & 0xffff;
ipmi_pef_print_field(pef_fld_fmts[F_2XD], text, val);
}
void
ipmi_pef_print_1xd(const char * text, uint32_t val)
{ /* 1 hex digit */
ipmi_pef_print_field(pef_fld_fmts[F_1XD], text, val);
}
static struct ipmi_rs *
ipmi_pef_msg_exchange(struct ipmi_intf * intf, struct ipmi_rq * req, char * txt)
{ /*
// common IPMItool rqst/resp handling
*/
struct ipmi_rs * rsp = intf->sendrecv(intf, req);
if (!rsp)
return(NULL);
if (rsp->ccode) {
lprintf(LOG_ERR, " **Error %x in '%s' command",
rsp ? rsp->ccode : 0, txt);
return(NULL);
}
if (verbose > 2)
printbuf(rsp->data, rsp->data_len, txt);
return(rsp);
}
static uint8_t
ipmi_pef_get_policy_table(struct ipmi_intf * intf,
struct pef_cfgparm_policy_table_entry ** table)
{ /*
// get the PEF policy table: allocate space, fillin, and return its size
// NB: the caller must free the returned area (when returned size > 0)
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_cfgparm_selector psel;
struct pef_cfgparm_policy_table_entry * ptbl, * ptmp;
uint32_t i;
uint8_t tbl_size;
memset(&psel, 0, sizeof(psel));
psel.id = PEF_CFGPARM_ID_PEF_ALERT_POLICY_TABLE_SIZE;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_GET_PEF_CONFIG_PARMS;
req.msg.data = (uint8_t *)&psel;
req.msg.data_len = sizeof(psel);
rsp = ipmi_pef_msg_exchange(intf, &req, "Alert policy table size");
if (!rsp)
return(0);
tbl_size = (rsp->data[1] & PEF_POLICY_TABLE_SIZE_MASK);
i = (tbl_size * sizeof(struct pef_cfgparm_policy_table_entry));
if (!i
|| (ptbl = (struct pef_cfgparm_policy_table_entry *)malloc(i)) == NULL)
return(0);
memset(&psel, 0, sizeof(psel));
psel.id = PEF_CFGPARM_ID_PEF_ALERT_POLICY_TABLE_ENTRY;
for (ptmp=ptbl, i=1; i<=tbl_size; i++) {
psel.set = (i & PEF_POLICY_TABLE_ID_MASK);
rsp = ipmi_pef_msg_exchange(intf, &req, "Alert policy table entry");
if (!rsp
|| i != (rsp->data[1] & PEF_POLICY_TABLE_ID_MASK)) {
lprintf(LOG_ERR, " **Error retrieving %s",
"Alert policy table entry");
free(ptbl);
ptbl = NULL;
tbl_size = 0;
break;
}
memcpy(ptmp, &rsp->data[1], sizeof(*ptmp));
ptmp++;
}
*table = ptbl;
return(tbl_size);
}
static void
ipmi_pef_print_lan_dest(struct ipmi_intf * intf, uint8_t ch, uint8_t dest)
{ /*
// print LAN alert destination info
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_lan_cfgparm_selector lsel;
struct pef_lan_cfgparm_dest_type * ptype;
struct pef_lan_cfgparm_dest_info * pinfo;
char buf[32];
uint8_t tbl_size, dsttype, timeout, retries;
memset(&lsel, 0, sizeof(lsel));
lsel.id = PEF_LAN_CFGPARM_ID_DEST_COUNT;
lsel.ch = ch;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_TRANSPORT;
req.msg.cmd = IPMI_CMD_LAN_GET_CONFIG;
req.msg.data = (uint8_t *)&lsel;
req.msg.data_len = sizeof(lsel);
rsp = ipmi_pef_msg_exchange(intf, &req, "Alert destination count");
if (!rsp) {
lprintf(LOG_ERR, " **Error retrieving %s",
"Alert destination count");
return;
}
tbl_size = (rsp->data[1] & PEF_LAN_DEST_TABLE_SIZE_MASK);
if (!dest || tbl_size == 0) /* LAN alerting not supported */
return;
lsel.id = PEF_LAN_CFGPARM_ID_DESTTYPE;
lsel.set = dest;
rsp = ipmi_pef_msg_exchange(intf, &req, "Alert destination type");
if (!rsp || rsp->data[1] != lsel.set) {
lprintf(LOG_ERR, " **Error retrieving %s",
"Alert destination type");
return;
}
ptype = (struct pef_lan_cfgparm_dest_type *)&rsp->data[1];
dsttype = (ptype->dest_type & PEF_LAN_DEST_TYPE_MASK);
timeout = ptype->alert_timeout;
retries = (ptype->retries & PEF_LAN_RETRIES_MASK);
ipmi_pef_print_str("Alert destination type",
ipmi_pef_bit_desc(&pef_b2s_lan_desttype, dsttype));
if (dsttype == PEF_LAN_DEST_TYPE_PET) {
lsel.id = PEF_LAN_CFGPARM_ID_PET_COMMUNITY;
lsel.set = 0;
rsp = ipmi_pef_msg_exchange(intf, &req, "PET community");
if (!rsp)
lprintf(LOG_ERR, " **Error retrieving %s",
"PET community");
else {
rsp->data[19] = '\0';
ipmi_pef_print_str("PET Community", &rsp->data[1]);
}
}
ipmi_pef_print_dec("ACK timeout/retry (secs)", timeout);
ipmi_pef_print_dec("Retries", retries);
lsel.id = PEF_LAN_CFGPARM_ID_DESTADDR;
lsel.set = dest;
rsp = ipmi_pef_msg_exchange(intf, &req, "Alert destination info");
if (!rsp || rsp->data[1] != lsel.set)
lprintf(LOG_ERR, " **Error retrieving %s",
"Alert destination info");
else {
pinfo = (struct pef_lan_cfgparm_dest_info *)&rsp->data[1];
sprintf(buf, "%u.%u.%u.%u",
pinfo->ip[0], pinfo->ip[1], pinfo->ip[2], pinfo->ip[3]);
ipmi_pef_print_str("IP address", buf);
sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
pinfo->mac[0], pinfo->mac[1], pinfo->mac[2],
pinfo->mac[3], pinfo->mac[4], pinfo->mac[5]);
ipmi_pef_print_str("MAC address", buf);
}
}
static void
ipmi_pef_print_serial_dest_dial(struct ipmi_intf * intf, char * label,
struct pef_serial_cfgparm_selector * ssel)
{ /*
// print a dial string
*/
#define BLOCK_SIZE 16
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_serial_cfgparm_selector tmp;
char * p, strval[(6 * BLOCK_SIZE) + 1];
memset(&tmp, 0, sizeof(tmp));
tmp.id = PEF_SERIAL_CFGPARM_ID_DEST_DIAL_STRING_COUNT;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_TRANSPORT;
req.msg.cmd = IPMI_CMD_SERIAL_GET_CONFIG;
req.msg.data = (uint8_t *)&tmp;
req.msg.data_len = sizeof(tmp);
rsp = ipmi_pef_msg_exchange(intf, &req, "Dial string count");
if (!rsp || (rsp->data[1] & PEF_SERIAL_DIAL_STRING_COUNT_MASK) == 0)
return; /* sssh, not supported */
memcpy(&tmp, ssel, sizeof(tmp));
tmp.id = PEF_SERIAL_CFGPARM_ID_DEST_DIAL_STRING;
tmp.block = 1;
memset(strval, 0, sizeof(strval));
p = strval;
for (;;) {
rsp = ipmi_pef_msg_exchange(intf, &req, label);
if (!rsp
|| (rsp->data[1] != ssel->id)
|| (rsp->data[2] != tmp.block)) {
lprintf(LOG_ERR, " **Error retrieving %s", label);
return;
}
memcpy(p, &rsp->data[3], BLOCK_SIZE);
if (strchr(p, '\0') <= (p + BLOCK_SIZE))
break;
if ((p += BLOCK_SIZE) >= &strval[sizeof(strval)-1])
break;
tmp.block++;
}
ipmi_pef_print_str(label, strval);
#undef BLOCK_SIZE
}
static void
ipmi_pef_print_serial_dest_tap(struct ipmi_intf * intf,
struct pef_serial_cfgparm_selector * ssel)
{ /*
// print TAP destination info
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_serial_cfgparm_selector tmp;
struct pef_serial_cfgparm_tap_svc_settings * pset;
uint8_t dialstr_id, setting_id;
memset(&tmp, 0, sizeof(tmp));
tmp.id = PEF_SERIAL_CFGPARM_ID_TAP_ACCT_COUNT;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_TRANSPORT;
req.msg.cmd = IPMI_CMD_SERIAL_GET_CONFIG;
req.msg.data = (uint8_t *)&tmp;
req.msg.data_len = sizeof(tmp);
rsp = ipmi_pef_msg_exchange(intf, &req, "Number of TAP accounts");
if (!rsp || (rsp->data[1] & PEF_SERIAL_TAP_ACCT_COUNT_MASK) == 0)
return; /* sssh, not supported */
memcpy(&tmp, ssel, sizeof(tmp));
tmp.id = PEF_SERIAL_CFGPARM_ID_TAP_ACCT_INFO;
rsp = ipmi_pef_msg_exchange(intf, &req, "TAP account info");
if (!rsp || (rsp->data[1] != tmp.set)) {
lprintf(LOG_ERR, " **Error retrieving %s",
"TAP account info");
return;
}
dialstr_id = (rsp->data[2] & PEF_SERIAL_TAP_ACCT_INFO_DIAL_STRING_ID_MASK);
dialstr_id >>= PEF_SERIAL_TAP_ACCT_INFO_DIAL_STRING_ID_SHIFT;
setting_id = (rsp->data[2] & PEF_SERIAL_TAP_ACCT_INFO_SVC_SETTINGS_ID_MASK);
tmp.set = dialstr_id;
ipmi_pef_print_serial_dest_dial(intf, "TAP Dial string", &tmp);
tmp.set = setting_id;
rsp = ipmi_pef_msg_exchange(intf, &req, "TAP service settings");
if (!rsp || (rsp->data[1] != tmp.set)) {
lprintf(LOG_ERR, " **Error retrieving %s",
"TAP service settings");
return;
}
pset = (struct pef_serial_cfgparm_tap_svc_settings *)&rsp->data[1];
ipmi_pef_print_str("TAP confirmation",
ipmi_pef_bit_desc(&pef_b2s_tap_svc_confirm, pset->confirmation_flags));
/* TODO : additional TAP settings? */
}
static void
ipmi_pef_print_serial_dest_ppp(struct ipmi_intf * intf,
struct pef_serial_cfgparm_selector * ssel)
{ /*
// print PPP destination info
*/
/* TODO */
}
static void
ipmi_pef_print_serial_dest_callback(struct ipmi_intf * intf,
struct pef_serial_cfgparm_selector * ssel)
{ /*
// print callback destination info
*/
/* TODO */
}
static void
ipmi_pef_print_serial_dest(struct ipmi_intf * intf, uint8_t ch, uint8_t dest)
{ /*
// print Serial/PPP alert destination info
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_serial_cfgparm_selector ssel;
uint8_t tbl_size, wrk;
struct pef_serial_cfgparm_dest_info * pinfo;
memset(&ssel, 0, sizeof(ssel));
ssel.id = PEF_SERIAL_CFGPARM_ID_DEST_COUNT;
ssel.ch = ch;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_TRANSPORT;
req.msg.cmd = IPMI_CMD_SERIAL_GET_CONFIG;
req.msg.data = (uint8_t *)&ssel;
req.msg.data_len = sizeof(ssel);
rsp = ipmi_pef_msg_exchange(intf, &req, "Alert destination count");
if (!rsp) {
lprintf(LOG_ERR, " **Error retrieving %s",
"Alert destination count");
return;
}
tbl_size = (rsp->data[1] & PEF_SERIAL_DEST_TABLE_SIZE_MASK);
if (!dest || tbl_size == 0) /* Page alerting not supported */
return;
ssel.id = PEF_SERIAL_CFGPARM_ID_DESTINFO;
ssel.set = dest;
rsp = ipmi_pef_msg_exchange(intf, &req, "Alert destination info");
if (!rsp || rsp->data[1] != ssel.set)
lprintf(LOG_ERR, " **Error retrieving %s",
"Alert destination info");
else {
pinfo = (struct pef_serial_cfgparm_dest_info *)rsp->data;
wrk = (pinfo->dest_type & PEF_SERIAL_DEST_TYPE_MASK);
ipmi_pef_print_str("Alert destination type",
ipmi_pef_bit_desc(&pef_b2s_serial_desttype, wrk));
ipmi_pef_print_dec("ACK timeout (secs)",
pinfo->alert_timeout);
ipmi_pef_print_dec("Retries",
(pinfo->retries & PEF_SERIAL_RETRIES_MASK));
switch (wrk) {
case PEF_SERIAL_DEST_TYPE_DIAL:
ipmi_pef_print_serial_dest_dial(intf, "Serial dial string", &ssel);
break;
case PEF_SERIAL_DEST_TYPE_TAP:
ipmi_pef_print_serial_dest_tap(intf, &ssel);
break;
case PEF_SERIAL_DEST_TYPE_PPP:
ipmi_pef_print_serial_dest_ppp(intf, &ssel);
break;
case PEF_SERIAL_DEST_TYPE_BASIC_CALLBACK:
case PEF_SERIAL_DEST_TYPE_PPP_CALLBACK:
ipmi_pef_print_serial_dest_callback(intf, &ssel);
break;
}
}
}
static void
ipmi_pef_print_dest(struct ipmi_intf * intf, uint8_t ch, uint8_t dest)
{ /*
// print generic alert destination info
*/
ipmi_pef_print_dec("Destination ID", dest);
}
void
ipmi_pef_print_event_info(struct pef_cfgparm_filter_table_entry * pef, char * buf)
{ /*
// print PEF entry Event info: class, severity, trigger, etc.
*/
static char * classes[] = {"Discrete", "Threshold", "OEM"};
uint16_t offmask;
char * p;
int i;
uint8_t t;
ipmi_pef_print_str("Event severity",
ipmi_pef_bit_desc(&pef_b2s_severities, pef->entry.severity));
t = pef->entry.event_trigger;
if (t == PEF_EVENT_TRIGGER_THRESHOLD)
i = 1;
else if (t > PEF_EVENT_TRIGGER_SENSOR_SPECIFIC)
i = 2;
else
i = 0;
ipmi_pef_print_str("Event class", classes[i]);
offmask = ((pef->entry.event_data_1_offset_mask[1] << 8)
+ pef->entry.event_data_1_offset_mask[0]);
if (offmask == 0xffff || t == PEF_EVENT_TRIGGER_MATCH_ANY)
strcpy(buf, "Any");
else if (t == PEF_EVENT_TRIGGER_UNSPECIFIED)
strcpy(buf, "Unspecified");
else if (t == PEF_EVENT_TRIGGER_SENSOR_SPECIFIC)
strcpy(buf, "Sensor-specific");
else if (t > PEF_EVENT_TRIGGER_SENSOR_SPECIFIC)
strcpy(buf, "OEM");
else {
sprintf(buf, "(0x%02x/0x%04x)", t, offmask);
p = strchr(buf, '\0');
for (i=0; i<PEF_B2S_GENERIC_ER_ENTRIES; i++) {
if (offmask & 1) {
sprintf(p, ",%s", ipmi_pef_bit_desc(pef_b2s_generic_ER[t-1], i));
p = strchr(p, '\0');
}
offmask >>= 1;
}
}
ipmi_pef_print_str("Event trigger(s)", buf);
}
static void
ipmi_pef_print_entry(struct ipmi_rs * rsp, uint8_t id,
struct pef_cfgparm_filter_table_entry * pef)
{ /*
// print a PEF table entry
*/
uint8_t wrk, set;
char buf[128];
ipmi_pef_print_dec("PEF table entry", id);
wrk = !!(pef->entry.config & PEF_CONFIG_ENABLED);
sprintf(buf, "%sactive", (wrk ? "" : "in"));
if (pef->entry.config & PEF_CONFIG_PRECONFIGURED)
strcat(buf, ", pre-configured");
ipmi_pef_print_str("Status", buf);
if (wrk != 0) {
ipmi_pef_print_1xd("Version", rsp->data[0]);
ipmi_pef_print_str("Sensor type",
ipmi_pef_bit_desc(&pef_b2s_sensortypes, pef->entry.sensor_type));
if (pef->entry.sensor_number == PEF_SENSOR_NUMBER_MATCH_ANY)
ipmi_pef_print_str("Sensor number", "Any");
else
ipmi_pef_print_dec("Sensor number", pef->entry.sensor_number);
ipmi_pef_print_event_info(pef, buf);
ipmi_pef_print_str("Action",
ipmi_pef_bit_desc(&pef_b2s_actions, pef->entry.action));
if (pef->entry.action & PEF_ACTION_ALERT) {
set = (pef->entry.policy_number & PEF_POLICY_NUMBER_MASK);
ipmi_pef_print_int("Policy set", set);
}
}
}
static void
ipmi_pef_list_entries(struct ipmi_intf * intf)
{ /*
// list all PEF table entries
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_cfgparm_selector psel;
struct pef_cfgparm_filter_table_entry * pcfg;
uint32_t i;
uint8_t max_filters;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_GET_PEF_CAPABILITIES;
rsp = ipmi_pef_msg_exchange(intf, &req, "PEF capabilities");
if (!rsp
|| (max_filters = ((struct pef_capabilities *)rsp->data)->tblsize) == 0)
return; /* sssh, not supported */
memset(&psel, 0, sizeof(psel));
psel.id = PEF_CFGPARM_ID_PEF_FILTER_TABLE_ENTRY;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_GET_PEF_CONFIG_PARMS;
req.msg.data = (uint8_t *)&psel;
req.msg.data_len = sizeof(psel);
for (i=1; i<=max_filters; i++) {
if (i > 1)
printf("\n");
psel.set = (i & PEF_FILTER_TABLE_ID_MASK);
rsp = ipmi_pef_msg_exchange(intf, &req, "PEF table entry");
if (!rsp
|| (psel.set != (rsp->data[1] & PEF_FILTER_TABLE_ID_MASK))) {
lprintf(LOG_ERR, " **Error retrieving %s",
"PEF table entry");
continue;
}
pcfg = (struct pef_cfgparm_filter_table_entry *)&rsp->data[1];
first_field = 1;
ipmi_pef_print_entry(rsp, psel.set, pcfg);
}
}
static void
ipmi_pef_list_policies(struct ipmi_intf * intf)
{ /*
// list PEF alert policies
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_cfgparm_policy_table_entry * ptbl, * ptmp;
uint32_t i;
uint8_t wrk, ch, medium, tbl_size;
tbl_size = ipmi_pef_get_policy_table(intf, &ptbl);
if (!tbl_size)
return;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = IPMI_CMD_GET_CHANNEL_INFO;
req.msg.data = &ch;
req.msg.data_len = sizeof(ch);
for (ptmp=ptbl, i=1; i<=tbl_size; i++, ptmp++) {
if ((ptmp->entry.policy & PEF_POLICY_ENABLED) == PEF_POLICY_ENABLED) {
if (i > 1)
printf("\n");
first_field = 1;
ipmi_pef_print_dec("Alert policy table entry",
(ptmp->data1 & PEF_POLICY_TABLE_ID_MASK));
ipmi_pef_print_dec("Policy set",
(ptmp->entry.policy & PEF_POLICY_ID_MASK) >> PEF_POLICY_ID_SHIFT);
ipmi_pef_print_str("Policy entry rule",
ipmi_pef_bit_desc(&pef_b2s_policies, (ptmp->entry.policy & PEF_POLICY_FLAGS_MASK)));
if (ptmp->entry.alert_string_key & PEF_POLICY_EVENT_SPECIFIC) {
ipmi_pef_print_str("Event-specific", "true");
continue;
}
wrk = ptmp->entry.chan_dest;
/* channel/description */
ch = (wrk & PEF_POLICY_CHANNEL_MASK) >> PEF_POLICY_CHANNEL_SHIFT;
rsp = ipmi_pef_msg_exchange(intf, &req, "Channel info");
if (!rsp || rsp->data[0] != ch) {
lprintf(LOG_ERR, " **Error retrieving %s",
"Channel info");
continue;
}
medium = rsp->data[1];
ipmi_pef_print_dec("Channel number", ch);
ipmi_pef_print_str("Channel medium",
ipmi_pef_bit_desc(&pef_b2s_ch_medium, medium));
/* destination/description */
wrk &= PEF_POLICY_DESTINATION_MASK;
switch (medium) {
case PEF_CH_MEDIUM_TYPE_LAN:
ipmi_pef_print_lan_dest(intf, ch, wrk);
break;
case PEF_CH_MEDIUM_TYPE_SERIAL:
ipmi_pef_print_serial_dest(intf, ch, wrk);
break;
default:
ipmi_pef_print_dest(intf, ch, wrk);
break;
}
}
}
free(ptbl);
}
static void
ipmi_pef_get_status(struct ipmi_intf * intf)
{ /*
// report the PEF status
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_cfgparm_selector psel;
char tbuf[40];
time_t ts;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_GET_LAST_PROCESSED_EVT_ID;
rsp = ipmi_pef_msg_exchange(intf, &req, "Last S/W processed ID");
if (!rsp) {
lprintf(LOG_ERR, " **Error retrieving %s",
"Last S/W processed ID");
return;
}
#if WORDS_BIGENDIAN
ts = (time_t)(rsp->data[0]<<24 + rsp->data[1]<<16 + rsp->data[2]<<8 + rsp->data[3]);
#else
ts = (time_t)(*(long *)rsp->data);
#endif
strftime(tbuf, sizeof(tbuf), "%m/%d/%Y %H:%M:%S", localtime(&ts));
ipmi_pef_print_str("Last SEL addition", tbuf);
ipmi_pef_print_2xd("Last SEL record ID", rsp->data[5], rsp->data[4]);
ipmi_pef_print_2xd("Last S/W processed ID", rsp->data[7], rsp->data[6]);
ipmi_pef_print_2xd("Last BMC processed ID", rsp->data[9], rsp->data[8]);
memset(&psel, 0, sizeof(psel));
psel.id = PEF_CFGPARM_ID_PEF_CONTROL;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_GET_PEF_CONFIG_PARMS;
req.msg.data = (uint8_t *)&psel;
req.msg.data_len = sizeof(psel);
rsp = ipmi_pef_msg_exchange(intf, &req, "PEF control");
if (!rsp) {
lprintf(LOG_ERR, " **Error retrieving %s",
"PEF control");
return;
}
ipmi_pef_print_flags(&pef_b2s_control, P_ABLE, rsp->data[1]);
}
static void
ipmi_pef_get_info(struct ipmi_intf * intf)
{ /*
// report PEF capabilities + System GUID
*/
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct pef_capabilities * pcap;
struct pef_cfgparm_selector psel;
struct pef_cfgparm_policy_table_entry * ptbl;
uint8_t * uid;
uint8_t actions, tbl_size;
if ((tbl_size = ipmi_pef_get_policy_table(intf, &ptbl)) > 0)
free(ptbl);
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_GET_PEF_CAPABILITIES;
rsp = ipmi_pef_msg_exchange(intf, &req, "PEF capabilities");
if (!rsp)
return;
pcap = (struct pef_capabilities *)rsp->data;
ipmi_pef_print_1xd("Version", pcap->version);
ipmi_pef_print_dec("PEF table size", pcap->tblsize);
ipmi_pef_print_dec("Alert policy table size", tbl_size);
actions = pcap->actions;
memset(&psel, 0, sizeof(psel));
psel.id = PEF_CFGPARM_ID_SYSTEM_GUID;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = IPMI_CMD_GET_PEF_CONFIG_PARMS;
req.msg.data = (uint8_t *)&psel;
req.msg.data_len = sizeof(psel);
rsp = ipmi_pef_msg_exchange(intf, &req, "System GUID");
uid = NULL;
if (rsp && (rsp->data[1] & PEF_SYSTEM_GUID_USED_IN_PET))
uid = &rsp->data[2];
else {
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = IPMI_CMD_GET_SYSTEM_GUID;
rsp = ipmi_pef_msg_exchange(intf, &req, "System GUID");
if (rsp)
uid = &rsp->data[0];
}
if (uid) { /* got GUID? */
if (verbose)
printf(pef_fld_fmts[F_UID][0], KYWD_LENGTH, "System GUID",
uid[0], uid[1], uid[2], uid[3], uid[4], uid[5], uid[6], uid[7],
uid[8], uid[9], uid[10],uid[11],uid[12],uid[13],uid[14],uid[15]);
else
printf(pef_fld_fmts[F_UID][1],
uid[0], uid[1], uid[2], uid[3], uid[4], uid[5], uid[6], uid[7],
uid[8], uid[9], uid[10],uid[11],uid[12],uid[13],uid[14],uid[15]);
}
ipmi_pef_print_flags(&pef_b2s_actions, P_SUPP, actions);
}
int ipmi_pef_main(struct ipmi_intf * intf, int argc, char ** argv)
{ /*
// PEF subcommand handling
*/
int help = 0;
if (!argc || !strncmp(argv[0], "info", 4))
ipmi_pef_get_info(intf);
else if (!strncmp(argv[0], "help", 4))
help = 1;
else if (!strncmp(argv[0], "status", 6))
ipmi_pef_get_status(intf);
else if (!strncmp(argv[0], "policy", 6))
ipmi_pef_list_policies(intf);
else if (!strncmp(argv[0], "list", 4))
ipmi_pef_list_entries(intf);
else {
help = 1;
lprintf(LOG_ERR, "Invalid PEF command: '%s'\n", argv[0]);
}
if (help)
lprintf(LOG_NOTICE, "PEF commands: info status policy list");
else if (!verbose)
printf("\n");
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -38,634 +38,118 @@
#include <math.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_sdr.h>
#include <ipmitool/ipmi_sel.h>
#include <ipmitool/ipmi_sensor.h>
extern int verbose;
#define READING_UNAVAILABLE 0x20
#define SCANNING_DISABLED 0x80
static
struct ipmi_rs *
ipmi_sensor_get_sensor_thresholds(struct ipmi_intf * intf, uint8_t sensor)
static void
ipmi_get_sensor_info_compact(struct ipmi_intf * intf,
struct sdr_record_compact_sensor * sensor)
{
struct ipmi_rq req;
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = GET_SENSOR_THRESHOLDS;
req.msg.data = &sensor;
req.msg.data_len = sizeof(sensor);
return intf->sendrecv(intf, &req);
}
static
struct ipmi_rs *
ipmi_sensor_set_sensor_thresholds(struct ipmi_intf * intf,
uint8_t sensor,
uint8_t threshold,
uint8_t setting)
static void
ipmi_get_sensor_info_full(struct ipmi_intf * intf,
struct sdr_record_full_sensor * sensor)
{
struct ipmi_rq req;
static struct sensor_set_thresh_rq set_thresh_rq;
struct ipmi_rs * rsp;
char sval[16], unitstr[16], desc[17];
float val, tol;
unsigned raw_tol;
int i=0, not_available=0;
memset(&set_thresh_rq, 0, sizeof(set_thresh_rq));
set_thresh_rq.sensor_num = sensor;
set_thresh_rq.set_mask = threshold;
if (threshold == UPPER_NON_RECOV_SPECIFIED)
set_thresh_rq.upper_non_recov = setting;
else if (threshold == UPPER_CRIT_SPECIFIED)
set_thresh_rq.upper_crit = setting;
else if (threshold == UPPER_NON_CRIT_SPECIFIED)
set_thresh_rq.upper_non_crit = setting;
else if (threshold == LOWER_NON_CRIT_SPECIFIED)
set_thresh_rq.lower_non_crit = setting;
else if (threshold == LOWER_CRIT_SPECIFIED)
set_thresh_rq.lower_crit = setting;
else if (threshold == LOWER_NON_RECOV_SPECIFIED)
set_thresh_rq.lower_non_recov = setting;
else
return NULL;
memset(desc, 0, sizeof(desc));
memcpy(desc, sensor->id_string, 16);
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = SET_SENSOR_THRESHOLDS;
req.msg.data = (uint8_t *)&set_thresh_rq;
req.msg.data_len = sizeof(set_thresh_rq);
return intf->sendrecv(intf, &req);
}
static int
ipmi_sensor_print_full_discrete(struct ipmi_intf * intf,
struct sdr_record_full_sensor * sensor)
{
char id[17];
char * unitstr = "discrete";
int validread=1;
uint8_t val = 0;
struct ipmi_rs * rsp;
if (sensor == NULL)
return -1;
memset(id, 0, sizeof(id));
memcpy(id, sensor->id_string, 16);
/*
* Get current reading
*/
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
id, sensor->keys.sensor_num);
return -1;
} else if (rsp->ccode > 0 || (rsp->data[1] & READING_UNAVAILABLE)) {
validread = 0;
} else {
/* convert RAW reading into units */
val = rsp->data[0];
}
if (csv_output)
{
/* NOT IMPLEMENTED */
}
else
{
if (verbose == 0) {
/* output format
* id value units status thresholds....
*/
printf("%-16s ", id);
if (validread) {
printf("| 0x%-8x | %-10s | 0x%02x%02x",
val,
unitstr,
rsp->data[2],
rsp->data[3]);
} else {
printf("| %-10s | %-10s | %-6s",
"na",
unitstr,
"na");
}
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
"na", "na", "na", "na", "na", "na");
printf("\n");
} else {
printf("Sensor ID : %s (0x%x)\n",
id, sensor->keys.sensor_num);
printf(" Entity ID : %d.%d\n",
sensor->entity.id, sensor->entity.instance);
printf(" Sensor Type (Discrete): %s\n",
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
ipmi_sdr_print_discrete_state(sensor->sensor.type,
sensor->event_type,
rsp->data[2]);
printf("\n");
}
}
return 0;
}
static int
ipmi_sensor_print_full_analog(struct ipmi_intf * intf,
struct sdr_record_full_sensor * sensor)
{
char unitstr[16], id[17];
int i=0, validread=1, thresh_available = 1;
double val = 0.0;
struct ipmi_rs * rsp;
char * status = NULL;
if (sensor == NULL)
return -1;
memset(id, 0, sizeof(id));
memcpy(id, sensor->id_string, 16);
/* only handle linear and linearized sensors (for now) */
if (sensor->linearization>=SDR_SENSOR_L_NONLINEAR) {
printf("sensor %s non-linear!\n", id);
return -1;
}
/*
* Get current reading
*/
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
id, sensor->keys.sensor_num);
return -1;
} else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
validread = 0;
} else {
/* convert RAW reading into units */
val = (rsp->data[0] > 0)
? sdr_convert_sensor_reading(sensor, rsp->data[0])
: 0;
status = (char*)ipmi_sdr_get_status(rsp->data[2]);
}
/*
* Figure out units
*/
memset(unitstr, 0, sizeof(unitstr));
switch (sensor->unit.modifier)
{
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if ((rsp && (rsp->data[1] & READING_UNAVAILABLE)) ||
(rsp && !(rsp->data[1] & SCANNING_DISABLED)))
not_available = 1;
else {
memset(unitstr, 0, sizeof(unitstr));
/* determine units with possible modifiers */
switch (sensor->unit.modifier) {
case 2:
i += snprintf(unitstr, sizeof(unitstr), "%s * %s",
unit_desc[sensor->unit.type.base],
unit_desc[sensor->unit.type.modifier]);
break;
i += snprintf(unitstr, sizeof(unitstr), "%s * %s",
unit_desc[sensor->unit.type.base],
unit_desc[sensor->unit.type.modifier]);
break;
case 1:
i += snprintf(unitstr, sizeof(unitstr), "%s/%s",
unit_desc[sensor->unit.type.base],
unit_desc[sensor->unit.type.modifier]);
break;
i += snprintf(unitstr, sizeof(unitstr), "%s/%s",
unit_desc[sensor->unit.type.base],
unit_desc[sensor->unit.type.modifier]);
break;
case 0:
default:
i += snprintf(unitstr, sizeof(unitstr), "%s",
unit_desc[sensor->unit.type.base]);
break;
}
i += snprintf(unitstr, sizeof(unitstr), "%s",
unit_desc[sensor->unit.type.base]);
break;
}
/*
* Get sensor thresholds
*/
rsp = ipmi_sensor_get_sensor_thresholds(intf, sensor->keys.sensor_num);
if (rsp == NULL)
thresh_available = 0;
val = sdr_convert_sensor_reading(sensor, rsp->data[0]);
raw_tol = (sensor->mtol & 0x3f00) >> 8;
tol = sdr_convert_sensor_reading(sensor, raw_tol * 2);
}
if (csv_output)
{
/* NOT IPMLEMENTED */
}
else
{
if (verbose == 0)
{
/* output format
* id value units status thresholds....
*/
printf("%-16s ", id);
if (validread) {
printf("| %-10.3f | %-10s | %-6s",
val, unitstr, status ? : "");
} else {
printf("| %-10s | %-10s | %-6s",
"na", unitstr, "na");
}
if (thresh_available)
{
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[3]));
else
printf("| %-10s", "na");
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[2]));
else
printf("| %-10s", "na");
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[1]));
else
printf("| %-10s", "na");
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[4]));
else
printf("| %-10s", "na");
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[5]));
else
printf("| %-10s", "na");
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
printf("| %-10.3f", sdr_convert_sensor_reading(sensor, rsp->data[6]));
else
printf("| %-10s", "na");
}
else
{
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
"na", "na", "na", "na", "na", "na");
}
if (!verbose) {
/*
* print sensor name, reading, state
*/
printf("%-16s | ", sensor->id_code ? desc : NULL);
printf("\n");
}
else
{
printf("Sensor ID : %s (0x%x)\n",
id, sensor->keys.sensor_num);
i = 0;
memset(sval, 0, sizeof(sval));
if (not_available) {
i += snprintf(sval, sizeof(sval), "no reading ");
} else {
i += snprintf(sval, sizeof(sval), "%.*f %s", (val==(int)val) ? 0 : 3, val, unitstr);
}
printf("%s", sval);
printf(" Entity ID : %d.%d\n",
sensor->entity.id, sensor->entity.instance);
i--;
for (; i<sizeof(sval); i++)
printf(" ");
printf(" | ");
printf(" Sensor Type (Analog) : %s\n",
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
printf(" Sensor Reading : ");
if (validread) {
uint16_t raw_tol = __TO_TOL(sensor->mtol);
double tol = sdr_convert_sensor_reading(sensor, raw_tol * 2);
printf("%.*f (+/- %.*f) %s\n",
(val==(int)val) ? 0 : 3,
val,
(tol==(int)tol) ? 0 : 3,
tol,
unitstr);
printf(" Status : %s\n", status ? : "");
if (thresh_available)
{
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
printf(" Lower Non-Recoverable : %.3f\n",
sdr_convert_sensor_reading(sensor, rsp->data[3]));
else
printf(" Lower Non-Recoverable : na\n");
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
printf(" Lower Critical : %.3f\n",
sdr_convert_sensor_reading(sensor, rsp->data[2]));
else
printf(" Lower Critical : na\n");
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
printf(" Lower Non-Critical : %.3f\n",
sdr_convert_sensor_reading(sensor, rsp->data[1]));
else
printf(" Lower Non-Critical : na\n");
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
printf(" Upper Non-Critical : %.3f\n",
sdr_convert_sensor_reading(sensor, rsp->data[4]));
else
printf(" Upper Non-Critical : na\n");
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
printf(" Upper Critical : %.3f\n",
sdr_convert_sensor_reading(sensor, rsp->data[5]));
else
printf(" Upper Critical : na\n");
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
printf(" Upper Non-Recoverable : %.3f\n",
sdr_convert_sensor_reading(sensor, rsp->data[6]));
else
printf(" Upper Non-Recoverable : na\n");
}
}
else
{
printf("Not Present\n");
}
printf("\n");
}
}
return 0;
printf("%s", ipmi_sdr_get_status(rsp->data[2]));
printf("\n");
} else {
printf("Sensor ID : %s (0x%x)\n", desc, sensor->keys.sensor_num);
if (not_available)
printf("Sensor Reading : Unavailable");
else
printf("Sensor Reading : %.*f (+/- %.*f) %s\n",
(val==(int)val) ? 0 : 3,
val,
(tol==(int)tol) ? 0 : 3,
tol,
unitstr);
printf("\n");
}
}
int
ipmi_sensor_print_full(struct ipmi_intf * intf,
struct sdr_record_full_sensor * sensor)
{
if (sensor->unit.analog != 3)
return ipmi_sensor_print_full_analog(intf, sensor);
else
return ipmi_sensor_print_full_discrete(intf, sensor);
}
int
ipmi_sensor_print_compact(struct ipmi_intf * intf,
struct sdr_record_compact_sensor * sensor)
{
char id[17];
char * unitstr = "discrete";
int validread = 1;
uint8_t val = 0;
struct ipmi_rs * rsp;
if (sensor == NULL)
return -1;
memset(id, 0, sizeof(id));
memcpy(id, sensor->id_string, 16);
/*
* Get current reading
*/
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if (rsp == NULL) {
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
id, sensor->keys.sensor_num);
return -1;
} else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
validread = 0;
} else {
/* convert RAW reading into units */
val = rsp->data[0];
}
if (csv_output)
{
/* NOT IMPLEMENTED */
}
else
{
if (!verbose)
{
/* output format
* id value units status thresholds....
*/
printf("%-16s ", id);
if (validread) {
printf("| 0x%-8x | %-10s | 0x%02x%02x",
val, unitstr,
rsp->data[2], rsp->data[3]);
} else {
printf("| %-10s | %-10s | %-6s",
"na", unitstr, "na");
}
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
"na", "na", "na", "na", "na", "na");
printf("\n");
}
else
{
printf("Sensor ID : %s (0x%x)\n",
id, sensor->keys.sensor_num);
printf(" Entity ID : %d.%d\n",
sensor->entity.id, sensor->entity.instance);
printf(" Sensor Type (Discrete): %s\n",
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
ipmi_sdr_print_discrete_state(sensor->sensor.type, sensor->event_type, rsp->data[2]);
printf("\n");
}
}
return 0;
}
static int
static void
ipmi_sensor_list(struct ipmi_intf * intf)
{
struct sdr_get_rs * header;
struct ipmi_sdr_iterator * itr;
int rc = 0;
lprintf(LOG_DEBUG, "Querying SDR for sensor list");
itr = ipmi_sdr_start(intf);
if (itr == NULL) {
lprintf(LOG_ERR, "Unable to open SDR for reading");
return -1;
}
while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL)
{
int r = 0;
uint8_t * rec;
rec = ipmi_sdr_get_record(intf, header, itr);
if (rec == NULL)
continue;
switch(header->type)
{
case SDR_RECORD_TYPE_FULL_SENSOR:
r = ipmi_sensor_print_full(intf,
(struct sdr_record_full_sensor *)rec);
break;
case SDR_RECORD_TYPE_COMPACT_SENSOR:
r = ipmi_sensor_print_compact(intf,
(struct sdr_record_compact_sensor *)rec);
break;
}
free(rec);
/* save any errors */
rc = (r == 0) ? rc : r;
}
ipmi_sdr_end(intf, itr);
return rc;
}
static const struct valstr threshold_vals[] = {
{ UPPER_NON_RECOV_SPECIFIED, "Upper Non-Recoverable" },
{ UPPER_CRIT_SPECIFIED, "Upper Critical" },
{ UPPER_NON_CRIT_SPECIFIED, "Upper Non-Critical" },
{ LOWER_NON_RECOV_SPECIFIED, "Lower Non-Recoverable" },
{ LOWER_CRIT_SPECIFIED, "Lower Critical" },
{ LOWER_NON_CRIT_SPECIFIED, "Lower Non-Critical" },
{ 0x00, NULL },
};
static int
ipmi_sensor_set_threshold(struct ipmi_intf * intf, int argc, char ** argv)
{
char * id, * thresh;
uint8_t settingMask;
double setting;
struct sdr_record_list * sdr;
struct ipmi_rs * rsp;
if (argc < 3 || strncmp(argv[0], "help", 4) == 0)
{
lprintf(LOG_NOTICE, "sensor thresh <id> <threshold> <setting>");
lprintf(LOG_NOTICE, " id : name of the sensor for which threshold is to be set");
lprintf(LOG_NOTICE, " threshold : which threshold to set");
lprintf(LOG_NOTICE, " unr = upper non-recoverable");
lprintf(LOG_NOTICE, " ucr = upper critical");
lprintf(LOG_NOTICE, " unc = upper non-critical");
lprintf(LOG_NOTICE, " lnc = lower non-critical");
lprintf(LOG_NOTICE, " lcr = lower critical");
lprintf(LOG_NOTICE, " lnr = lower non-recoverable");
lprintf(LOG_NOTICE, " setting : the value to set the threshold to");
return 0;
}
id = argv[0];
thresh = argv[1];
setting = (double)atof(argv[2]);
if (strncmp(thresh, "unr", 3) == 0)
settingMask = UPPER_NON_RECOV_SPECIFIED;
else if (strncmp(thresh, "ucr", 3) == 0)
settingMask = UPPER_CRIT_SPECIFIED;
else if (strncmp(thresh, "unc", 3) == 0)
settingMask = UPPER_NON_CRIT_SPECIFIED;
else if (strncmp(thresh, "lnc", 3) == 0)
settingMask = LOWER_NON_CRIT_SPECIFIED;
else if (strncmp(thresh, "lcr", 3) == 0)
settingMask = LOWER_CRIT_SPECIFIED;
else if (strncmp(thresh, "lnr", 3) == 0)
settingMask = LOWER_NON_RECOV_SPECIFIED;
else {
lprintf(LOG_ERR, "Valid threshold not specified!");
return -1;
}
printf("Locating sensor record...\n");
/* lookup by sensor name */
sdr = ipmi_sdr_find_sdr_byid(intf, id);
if (sdr == NULL) {
lprintf(LOG_ERR, "Sensor data record not found!");
return -1;
}
if (sdr->type != SDR_RECORD_TYPE_FULL_SENSOR) {
lprintf(LOG_ERR, "Invalid sensor type %02x", sdr->type);
return -1;
}
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
sdr->record.full->id_string,
val2str(settingMask, threshold_vals), setting);
rsp = ipmi_sensor_set_sensor_thresholds(intf,
sdr->record.full->keys.sensor_num, settingMask,
sdr_convert_sensor_value_to_raw(sdr->record.full, setting));
if (rsp == NULL) {
lprintf(LOG_ERR, "Error setting threshold");
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Error setting threshold: %s",
val2str(rsp->ccode, completion_code_vals));
return -1;
}
return 0;
}
static int
ipmi_sensor_get(struct ipmi_intf * intf, int argc, char ** argv)
{
struct sdr_record_list * sdr;
int i, v;
int rc = 0;
if (argc < 1 || strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "sensor get <id> ... [id]");
lprintf(LOG_NOTICE, " id : name of desired sensor");
return -1;
}
printf("Locating sensor record...\n");
/* lookup by sensor name */
for (i=0; i<argc; i++) {
int r = 0;
sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]);
if (sdr == NULL) {
lprintf(LOG_ERR, "Sensor data record \"%s\" not found!",
argv[i]);
rc = -1;
continue;
}
/* need to set verbose level to 1 */
v = verbose;
verbose = 1;
switch (sdr->type) {
case SDR_RECORD_TYPE_FULL_SENSOR:
r = ipmi_sensor_print_full(intf, sdr->record.full);
break;
case SDR_RECORD_TYPE_COMPACT_SENSOR:
r = ipmi_sensor_print_compact(intf, sdr->record.compact);
break;
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
r = ipmi_sdr_print_sensor_eventonly(intf, sdr->record.eventonly);
break;
case SDR_RECORD_TYPE_FRU_DEVICE_LOCATOR:
r = ipmi_sdr_print_sensor_fru_locator(intf, sdr->record.fruloc);
break;
case SDR_RECORD_TYPE_MC_DEVICE_LOCATOR:
r = ipmi_sdr_print_sensor_mc_locator(intf, sdr->record.mcloc);
break;
}
verbose = v;
/* save errors */
rc = (r == 0) ? rc : r;
}
return rc;
ipmi_sdr_print_sdr(intf, 0xff);
}
int
ipmi_sensor_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int rc = 0;
if (argc == 0) {
rc = ipmi_sensor_list(intf);
if (!argc)
ipmi_sensor_list(intf);
else if (!strncmp(argv[0], "help", 4)) {
printf("Sensor Commands: list\n");
}
else if (strncmp(argv[0], "help", 4) == 0) {
lprintf(LOG_NOTICE, "Sensor Commands: list thresh get");
else if (!strncmp(argv[0], "list", 4)) {
ipmi_sensor_list(intf);
}
else if (strncmp(argv[0], "list", 4) == 0) {
rc = ipmi_sensor_list(intf);
}
else if (strncmp(argv[0], "thresh", 5) == 0) {
rc = ipmi_sensor_set_threshold(intf, argc-1, &argv[1]);
}
else if (strncmp(argv[0], "get", 3) == 0) {
rc = ipmi_sensor_get(intf, argc-1, &argv[1]);
}
else {
lprintf(LOG_ERR, "Invalid sensor command: %s",
argv[0]);
rc = -1;
}
return rc;
else
printf("Invalid sensor command: %s\n", argv[0]);
return 0;
}

View File

@ -1,485 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi_lanp.h>
#include <ipmitool/ipmi_session.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/bswap.h>
typedef enum {
IPMI_SESSION_REQUEST_CURRENT = 0,
IPMI_SESSION_REQUEST_ALL,
IPMI_SESSION_REQUEST_BY_ID,
IPMI_SESSION_REQUEST_BY_HANDLE
} Ipmi_Session_Request_Type;
/*
* print_session_info_csv
*/
static void
print_session_info_csv(const struct get_session_info_rsp * session_info,
int data_len)
{
char buffer[18];
uint16_t console_port_tmp;
printf("%d", session_info->session_handle);
printf(",%d", session_info->session_slot_count);
printf(",%d", session_info->active_session_count);
if (data_len == 3)
{
/* There is no session data here*/
printf("\n");
return;
}
printf(",%d", session_info->user_id);
printf(",%s", val2str(session_info->privilege_level, ipmi_privlvl_vals));
printf(",%s", session_info->auxiliary_data?
"IPMIv2/RMCP+" : "IPMIv1.5");
printf(",0x%02x", session_info->channel_number);
if (data_len == 18)
{
/* We have 802.3 LAN data */
#ifdef __CYGWIN__
printf(",%d.%d.%d.%d",
session_info->channel_data.lan_data.console_ip[0],
session_info->channel_data.lan_data.console_ip[1],
session_info->channel_data.lan_data.console_ip[2],
session_info->channel_data.lan_data.console_ip[3]);
#else
printf(",%s",
inet_ntop(AF_INET,
&(session_info->channel_data.lan_data.console_ip),
buffer,
16));
#endif
printf(",%02x:%02x:%02x:%02x:%02x:%02x",
session_info->channel_data.lan_data.console_mac[0],
session_info->channel_data.lan_data.console_mac[1],
session_info->channel_data.lan_data.console_mac[2],
session_info->channel_data.lan_data.console_mac[3],
session_info->channel_data.lan_data.console_mac[4],
session_info->channel_data.lan_data.console_mac[5]);
console_port_tmp = session_info->channel_data.lan_data.console_port;
#if WORDS_BIGENDIAN
console_port_tmp = BSWAP_16(console_port_tmp);
#endif
printf(",%d", console_port_tmp);
}
else if ((data_len == 12) || (data_len == 14))
{
/* Channel async serial/modem */
printf(",%s",
val2str(session_info->channel_data.modem_data.session_channel_activity_type,
ipmi_channel_activity_type_vals));
printf(",%d",
session_info->channel_data.modem_data.destination_selector);
#ifdef __CYGWIN__
printf(",%d.%d.%d.%d",
session_info->channel_data.modem_data.console_ip[0],
session_info->channel_data.modem_data.console_ip[1],
session_info->channel_data.modem_data.console_ip[2],
session_info->channel_data.modem_data.console_ip[3]);
#else
printf(",%s",
inet_ntop(AF_INET,
&(session_info->channel_data.modem_data.console_ip),
buffer,
16));
#endif
if (data_len == 14)
{
/* Connection is PPP */
console_port_tmp = session_info->channel_data.lan_data.console_port;
#if WORDS_BIGENDIAN
console_port_tmp = BSWAP_16(console_port_tmp);
#endif
printf(",%d", console_port_tmp);
}
}
printf("\n");
}
/*
* print_session_info_verbose
*/
static void
print_session_info_verbose(const struct get_session_info_rsp * session_info,
int data_len)
{
char buffer[18];
uint16_t console_port_tmp;
printf("session handle : %d\n", session_info->session_handle);
printf("slot count : %d\n", session_info->session_slot_count);
printf("active sessions : %d\n", session_info->active_session_count);
if (data_len == 3)
{
/* There is no session data here */
printf("\n");
return;
}
printf("user id : %d\n", session_info->user_id);
printf("privilege level : %s\n",
val2str(session_info->privilege_level, ipmi_privlvl_vals));
printf("session type : %s\n", session_info->auxiliary_data?
"IPMIv2/RMCP+" : "IPMIv1.5");
printf("channel number : 0x%02x\n", session_info->channel_number);
if (data_len == 18)
{
/* We have 802.3 LAN data */
#ifdef __CYGWIN__
printf("console ip : %d.%d.%d.%d\n",
session_info->channel_data.lan_data.console_ip[0],
session_info->channel_data.lan_data.console_ip[1],
session_info->channel_data.lan_data.console_ip[2],
session_info->channel_data.lan_data.console_ip[3]);
#else
printf("console ip : %s\n",
inet_ntop(AF_INET,
&(session_info->channel_data.lan_data.console_ip),
buffer,
16));
#endif
printf("console mac : %02x:%02x:%02x:%02x:%02x:%02x\n",
session_info->channel_data.lan_data.console_mac[0],
session_info->channel_data.lan_data.console_mac[1],
session_info->channel_data.lan_data.console_mac[2],
session_info->channel_data.lan_data.console_mac[3],
session_info->channel_data.lan_data.console_mac[4],
session_info->channel_data.lan_data.console_mac[5]);
console_port_tmp = session_info->channel_data.lan_data.console_port;
#if WORDS_BIGENDIAN
console_port_tmp = BSWAP_16(console_port_tmp);
#endif
printf("console port : %d\n", console_port_tmp);
}
else if ((data_len == 12) || (data_len == 14))
{
/* Channel async serial/modem */
printf("Session/Channel Activity Type : %s\n",
val2str(session_info->channel_data.modem_data.session_channel_activity_type,
ipmi_channel_activity_type_vals));
printf("Destination selector : %d\n",
session_info->channel_data.modem_data.destination_selector);
#ifdef __CYGWIN__
printf("console ip : %d.%d.%d.%d\n",
session_info->channel_data.modem_data.console_ip[0],
session_info->channel_data.modem_data.console_ip[1],
session_info->channel_data.modem_data.console_ip[2],
session_info->channel_data.modem_data.console_ip[3]);
#else
printf("console ip : %s\n",
inet_ntop(AF_INET,
&(session_info->channel_data.modem_data.console_ip),
buffer,
16));
#endif
if (data_len == 14)
{
/* Connection is PPP */
console_port_tmp = session_info->channel_data.lan_data.console_port;
#if WORDS_BIGENDIAN
console_port_tmp = BSWAP_16(console_port_tmp);
#endif
printf("console port : %d\n", console_port_tmp);
}
}
printf("\n");
}
static void print_session_info(const struct get_session_info_rsp * session_info,
int data_len)
{
if (csv_output)
print_session_info_csv(session_info, data_len);
else
print_session_info_verbose(session_info, data_len);
}
/*
* ipmi_get_session_info
*
* returns 0 on success
* -1 on error
*/
int
ipmi_get_session_info(struct ipmi_intf * intf,
Ipmi_Session_Request_Type session_request_type,
uint32_t id_or_handle)
{
int i, retval = 0;
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t rqdata[5]; // max length of the variable length request
struct get_session_info_rsp session_info;
memset(&req, 0, sizeof(req));
memset(&session_info, 0, sizeof(session_info));
req.msg.netfn = IPMI_NETFN_APP; // 0x06
req.msg.cmd = IPMI_GET_SESSION_INFO; // 0x3D
req.msg.data = rqdata;
switch (session_request_type)
{
case IPMI_SESSION_REQUEST_CURRENT:
case IPMI_SESSION_REQUEST_BY_ID:
case IPMI_SESSION_REQUEST_BY_HANDLE:
switch (session_request_type)
{
case IPMI_SESSION_REQUEST_CURRENT:
rqdata[0] = 0x00;
req.msg.data_len = 1;
break;
case IPMI_SESSION_REQUEST_BY_ID:
rqdata[0] = 0xFF;
rqdata[1] = id_or_handle & 0x000000FF;
rqdata[2] = (id_or_handle >> 8) & 0x000000FF;
rqdata[3] = (id_or_handle >> 16) & 0x000000FF;
rqdata[4] = (id_or_handle >> 24) & 0x000000FF;
req.msg.data_len = 5;
break;
case IPMI_SESSION_REQUEST_BY_HANDLE:
rqdata[0] = 0xFE;
rqdata[1] = (uint8_t)id_or_handle;
req.msg.data_len = 2;
break;
case IPMI_SESSION_REQUEST_ALL:
break;
}
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL)
{
lprintf(LOG_ERR, "Get Session Info command failed");
retval = -1;
}
else if (rsp->ccode > 0)
{
lprintf(LOG_ERR, "Get Session Info command failed: %s",
val2str(rsp->ccode, completion_code_vals));
retval = -1;
}
if (retval < 0)
{
if ((session_request_type == IPMI_SESSION_REQUEST_CURRENT) &&
(strncmp(intf->name, "lan", 3) != 0))
lprintf(LOG_ERR, "It is likely that the channel in use "
"does not support sessions");
}
else
{
memcpy(&session_info, rsp->data, rsp->data_len);
print_session_info(&session_info, rsp->data_len);
}
break;
case IPMI_SESSION_REQUEST_ALL:
req.msg.data_len = 1;
i = 1;
do
{
rqdata[0] = i++;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL)
{
lprintf(LOG_ERR, "Get Session Info command failed");
retval = -1;
break;
}
else if (rsp->ccode > 0 && rsp->ccode != 0xCC && rsp->ccode != 0xCB)
{
lprintf(LOG_ERR, "Get Session Info command failed: %s",
val2str(rsp->ccode, completion_code_vals));
retval = -1;
break;
}
else if (rsp->data_len < 3)
{
retval = -1;
break;
}
memcpy(&session_info, rsp->data, rsp->data_len);
print_session_info(&session_info, rsp->data_len);
} while (i <= session_info.session_slot_count);
break;
}
return retval;
}
void
printf_session_usage()
{
lprintf(LOG_NOTICE, "Session Commands: info <active | all | id 0xnnnnnnnn | handle 0xnn>");
}
int
ipmi_session_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int retval = 0;
if (argc == 0 || strncmp(argv[0], "help", 4) == 0)
{
printf_session_usage();
}
else if (strncmp(argv[0], "info", 4) == 0)
{
if ((argc < 2) || strncmp(argv[1], "help", 4) == 0)
{
printf_session_usage();
}
else
{
Ipmi_Session_Request_Type session_request_type = 0;
uint32_t id_or_handle = 0;
if (strncmp(argv[1], "active", 6) == 0)
session_request_type = IPMI_SESSION_REQUEST_CURRENT;
else if (strncmp(argv[1], "all", 3) == 0)
session_request_type = IPMI_SESSION_REQUEST_ALL;
else if (strncmp(argv[1], "id", 2) == 0)
{
if (argc >= 3)
{
session_request_type = IPMI_SESSION_REQUEST_BY_ID;
id_or_handle = strtol(argv[2], NULL, 16);
}
else
{
lprintf(LOG_ERR, "Missing id argument");
printf_session_usage();
retval = -1;
}
}
else if (strncmp(argv[1], "handle", 6) == 0)
{
if (argc >= 3)
{
session_request_type = IPMI_SESSION_REQUEST_BY_HANDLE;
id_or_handle = strtol(argv[2], NULL, 16);
}
else
{
lprintf(LOG_ERR, "Missing handle argument");
printf_session_usage();
retval = -1;
}
}
else
{
lprintf(LOG_ERR, "Invalid SESSION info parameter: %s", argv[1]);
printf_session_usage();
retval = -1;
}
if (retval == 0)
retval = ipmi_get_session_info(intf,
session_request_type,
id_or_handle);
}
}
else
{
lprintf(LOG_ERR, "Invalid SESSION command: %s", argv[0]);
printf_session_usage();
retval = -1;
}
return retval;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,278 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stddef.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/ipmi_constants.h>
#include <ipmitool/ipmi_sensor.h>
/*
* From table 26-4 of the IPMI v2 specification
*/
const struct valstr impi_bit_rate_vals[] = {
{ 0x00, "IPMI-Over-Serial-Setting"}, /* Using the value in the IPMI Over Serial Config */
{ 0x06, "9.6" },
{ 0x07, "19.2" },
{ 0x08, "38.4" },
{ 0x09, "57.6" },
{ 0x0A, "115.2" },
{ 0x00, NULL },
};
const struct valstr ipmi_channel_activity_type_vals[] = {
{ 0, "IPMI Messaging session active" },
{ 1, "Callback Messaging session active" },
{ 2, "Dial-out Alert active" },
{ 3, "TAP Page Active" },
{ 0x00, NULL },
};
const struct valstr ipmi_privlvl_vals[] = {
{ IPMI_SESSION_PRIV_CALLBACK, "CALLBACK" },
{ IPMI_SESSION_PRIV_USER, "USER" },
{ IPMI_SESSION_PRIV_OPERATOR, "OPERATOR" },
{ IPMI_SESSION_PRIV_ADMIN, "ADMINISTRATOR" },
{ IPMI_SESSION_PRIV_OEM, "OEM" },
{ 0xF, "NO ACCESS" },
{ 0, NULL },
};
const struct valstr ipmi_set_in_progress_vals[] = {
{ IPMI_SET_IN_PROGRESS_SET_COMPLETE, "set-complete" },
{ IPMI_SET_IN_PROGRESS_IN_PROGRESS, "set-in-progress" },
{ IPMI_SET_IN_PROGRESS_COMMIT_WRITE, "commit-write" },
{ 0, NULL },
};
const struct valstr ipmi_authtype_session_vals[] = {
{ IPMI_SESSION_AUTHTYPE_NONE, "NONE" },
{ IPMI_SESSION_AUTHTYPE_MD2, "MD2" },
{ IPMI_SESSION_AUTHTYPE_MD5, "MD5" },
{ IPMI_SESSION_AUTHTYPE_PASSWORD, "PASSWORD" },
{ IPMI_SESSION_AUTHTYPE_OEM, "OEM" },
{ 0, NULL },
};
const struct valstr ipmi_authtype_vals[] = {
{ IPMI_1_5_AUTH_TYPE_BIT_NONE, "NONE" },
{ IPMI_1_5_AUTH_TYPE_BIT_MD2, "MD2" },
{ IPMI_1_5_AUTH_TYPE_BIT_MD5, "MD5" },
{ IPMI_1_5_AUTH_TYPE_BIT_PASSWORD, "PASSWORD" },
{ IPMI_1_5_AUTH_TYPE_BIT_OEM, "OEM" },
{ 0, NULL },
};
const struct valstr entity_id_vals[] = {
{ 0x00, "Unspecified" },
{ 0x01, "Other" },
{ 0x02, "Unknown" },
{ 0x03, "Processor" },
{ 0x04, "Disk or Disk Bay" },
{ 0x05, "Peripheral Bay" },
{ 0x06, "System Management Module" },
{ 0x07, "System Board" },
{ 0x08, "Memory Module" },
{ 0x09, "Processor Module" },
{ 0x0a, "Power Supply" },
{ 0x0b, "Add-in Card" },
{ 0x0c, "Front Panel Board" },
{ 0x0d, "Back Panel Board" },
{ 0x0e, "Power System Board" },
{ 0x0f, "Drive Backplane" },
{ 0x10, "System Internal Expansion Board" },
{ 0x11, "Other System Board" },
{ 0x12, "Processor Board" },
{ 0x13, "Power Unit" },
{ 0x14, "Power Module" },
{ 0x15, "Power Management" },
{ 0x16, "Chassis Back Panel Board" },
{ 0x17, "System Chassis" },
{ 0x18, "Sub-Chassis" },
{ 0x19, "Other Chassis Board" },
{ 0x1a, "Disk Drive Bay" },
{ 0x1b, "Peripheral Bay" },
{ 0x1c, "Device Bay" },
{ 0x1d, "Fan Device" },
{ 0x1e, "Cooling Unit" },
{ 0x1f, "Cable/Interconnect" },
{ 0x20, "Memory Device" },
{ 0x21, "System Management Software" },
{ 0x22, "BIOS" },
{ 0x23, "Operating System" },
{ 0x24, "System Bus" },
{ 0x25, "Group" },
{ 0x26, "Remote Management Device" },
{ 0x27, "External Environment" },
{ 0x28, "Battery" },
{ 0x00, NULL },
};
const struct valstr entity_device_type_vals[] = {
{ 0x00, "Reserved" },
{ 0x01, "Reserved" },
{ 0x02, "DS1624 temperature sensor" },
{ 0x03, "DS1621 temperature sensor" },
{ 0x04, "LM75 Temperature Sensor" },
{ 0x05, "Heceta ASIC" },
{ 0x06, "Reserved" },
{ 0x07, "Reserved" },
{ 0x08, "EEPROM, 24C01" },
{ 0x09, "EEPROM, 24C02" },
{ 0x0a, "EEPROM, 24C04" },
{ 0x0b, "EEPROM, 24C08" },
{ 0x0c, "EEPROM, 24C16" },
{ 0x0d, "EEPROM, 24C17" },
{ 0x0e, "EEPROM, 24C32" },
{ 0x0f, "EEPROM, 24C64" },
{ 0x1000, "IPMI FRU Inventory" },
{ 0x1001, "DIMM Memory ID" },
{ 0x1002, "IPMI FRU Inventory" },
{ 0x1003, "System Processor Cartridge FRU" },
{ 0x11, "Reserved" },
{ 0x12, "Reserved" },
{ 0x13, "Reserved" },
{ 0x14, "PCF 8570 256 byte RAM" },
{ 0x15, "PCF 8573 clock/calendar" },
{ 0x16, "PCF 8574A I/O Port" },
{ 0x17, "PCF 8583 clock/calendar" },
{ 0x18, "PCF 8593 clock/calendar" },
{ 0x19, "Clock calendar" },
{ 0x1a, "PCF 8591 A/D, D/A Converter" },
{ 0x1b, "I/O Port" },
{ 0x1c, "A/D Converter" },
{ 0x1d, "D/A Converter" },
{ 0x1e, "A/D, D/A Converter" },
{ 0x1f, "LCD Controller/Driver" },
{ 0x20, "Core Logic (Chip set) Device" },
{ 0x21, "LMC6874 Intelligent Battery controller" },
{ 0x22, "Intelligent Batter controller" },
{ 0x23, "Combo Management ASIC" },
{ 0x24, "Maxim 1617 Temperature Sensor" },
{ 0xbf, "Other/Unspecified" },
{ 0x00, NULL },
};
const struct valstr ipmi_channel_protocol_vals[] = {
{ 0x00, "reserved" },
{ 0x01, "IPMB-1.0" },
{ 0x02, "ICMB-1.0" },
{ 0x03, "reserved" },
{ 0x04, "IPMI-SMBus" },
{ 0x05, "KCS" },
{ 0x06, "SMIC" },
{ 0x07, "BT-10" },
{ 0x08, "BT-15" },
{ 0x09, "TMode" },
{ 0x1c, "OEM 1" },
{ 0x1d, "OEM 2" },
{ 0x1e, "OEM 3" },
{ 0x1f, "OEM 4" },
{ 0x00, NULL },
};
const struct valstr ipmi_channel_medium_vals[] = {
{ IPMI_CHANNEL_MEDIUM_RESERVED, "reserved" },
{ IPMI_CHANNEL_MEDIUM_IPMB, "IPMB (I2C)" },
{ IPMI_CHANNEL_MEDIUM_ICMB_1, "ICMB v1.0" },
{ IPMI_CHANNEL_MEDIUM_ICMB_09, "ICMB v0.9" },
{ IPMI_CHANNEL_MEDIUM_LAN, "802.3 LAN" },
{ IPMI_CHANNEL_MEDIUM_SERIAL, "Serial/Modem" },
{ IPMI_CHANNEL_MEDIUM_LAN_OTHER,"Other LAN" },
{ IPMI_CHANNEL_MEDIUM_SMBUS_PCI,"PCI SMBus" },
{ IPMI_CHANNEL_MEDIUM_SMBUS_1, "SMBus v1.0/v1.1" },
{ IPMI_CHANNEL_MEDIUM_SMBUS_2, "SMBus v2.0" },
{ IPMI_CHANNEL_MEDIUM_USB_1, "USB 1.x" },
{ IPMI_CHANNEL_MEDIUM_USB_2, "USB 2.x" },
{ IPMI_CHANNEL_MEDIUM_SYSTEM, "System Interface" },
{ 0x00, NULL },
};
const struct valstr completion_code_vals[] = {
{ 0x00, "Command completed normally" },
{ 0xc0, "Node busy" },
{ 0xc1, "Invalid command" },
{ 0xc2, "Invalid command on LUN" },
{ 0xc3, "Timeout" },
{ 0xc4, "Out of space" },
{ 0xc5, "Reservation cancelled or invalid" },
{ 0xc6, "Request data truncated" },
{ 0xc7, "Request data length invalid" },
{ 0xc8, "Request data field length limit exceeded" },
{ 0xc9, "Parameter out of range" },
{ 0xca, "Cannot return number of requested data bytes" },
{ 0xcb, "Requested sensor, data, or record not found" },
{ 0xcc, "Invalid data field in request" },
{ 0xcd, "Command illegal for specified sensor or record type" },
{ 0xce, "Command response could not be provided" },
{ 0xcf, "Cannot execute duplicated request" },
{ 0xd0, "SDR Repository in update mode" },
{ 0xd1, "Device firmeware in update mode" },
{ 0xd2, "BMC initialization in progress" },
{ 0xd3, "Destination unavailable" },
{ 0xd4, "Insufficient privilege level" },
{ 0xd5, "Command not supported in present state" },
{ 0xff, "Unspecified error" },
{ 0x00, NULL }
};
const struct valstr ipmi_auth_algorithms[] = {
{ IPMI_AUTH_RAKP_NONE, "none" },
{ IPMI_AUTH_RAKP_HMAC_SHA1, "hmac_sha1" },
{ IPMI_AUTH_RAKP_HMAC_MD5, "hmac_md5" },
{ 0x00, NULL }
};
const struct valstr ipmi_integrity_algorithms[] = {
{ IPMI_INTEGRITY_NONE, "none" },
{ IPMI_INTEGRITY_HMAC_SHA1_96, "hmac_sha1_96" },
{ IPMI_INTEGRITY_HMAC_MD5_128, "hmac_md5_128" },
{ IPMI_INTEGRITY_MD5_128 , "md5_128" },
{ 0x00, NULL }
};
const struct valstr ipmi_encryption_algorithms[] = {
{ IPMI_CRYPT_NONE, "none" },
{ IPMI_CRYPT_AES_CBC_128, "aes_cbc_128" },
{ IPMI_CRYPT_XRC4_128, "xrc4_128" },
{ IPMI_CRYPT_XRC4_40, "xrc4_40" },
{ 0x00, NULL }
};

View File

@ -1,752 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/time.h>
#include <signal.h>
#include <unistd.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_user.h>
#include <ipmitool/ipmi_constants.h>
#include <ipmitool/ipmi_strings.h>
#include <ipmitool/bswap.h>
extern int verbose;
extern int csv_output;
#define IPMI_PASSWORD_DISABLE_USER 0x00
#define IPMI_PASSWORD_ENABLE_USER 0x01
#define IPMI_PASSWORD_SET_PASSWORD 0x02
#define IPMI_PASSWORD_TEST_PASSWORD 0x03
/*
* ipmi_get_user_access
*
* param intf [in]
* param channel_number [in]
* param user_id [in]
* param user_access [out]
*
* return 0 on succes
* 1 on failure
*/
static int
ipmi_get_user_access(
struct ipmi_intf * intf,
uint8_t channel_number,
uint8_t user_id,
struct user_access_rsp * user_access)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t msg_data[2];
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; /* 0x06 */
req.msg.cmd = IPMI_GET_USER_ACCESS; /* 0x44 */
req.msg.data = msg_data;
req.msg.data_len = 2;
/* The channel number will remain constant throughout this function */
msg_data[0] = channel_number;
msg_data[1] = user_id;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Get User Access command failed "
"(channel %d, user %d)", channel_number, user_id);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get User Access command failed "
"(channel %d, user %d): %s", channel_number, user_id,
val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(user_access,
rsp->data,
sizeof(struct user_access_rsp));
return 0;
}
/*
* ipmi_get_user_name
*
* param intf [in]
* param channel_number [in]
* param user_id [in]
* param user_name [out]
*
* return 0 on succes
* 1 on failure
*/
static int
ipmi_get_user_name(
struct ipmi_intf * intf,
uint8_t user_id,
char * user_name)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t msg_data[1];
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; /* 0x06 */
req.msg.cmd = IPMI_GET_USER_NAME; /* 0x45 */
req.msg.data = msg_data;
req.msg.data_len = 1;
msg_data[0] = user_id;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Get User Name command failed (user %d)",
user_id);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Get User Name command failed (user %d): %s",
user_id, val2str(rsp->ccode, completion_code_vals));
return -1;
}
memcpy(user_name, rsp->data, 16);
return 0;
}
static void
dump_user_access(
uint8_t user_id,
const char * user_name,
struct user_access_rsp * user_access)
{
static int printed_header = 0;
if (! printed_header)
{
printf("ID Name Callin Link Auth IPMI Msg "
"Channel Priv Limit\n");
printed_header = 1;
}
printf("%-4d%-17s%-8s%-11s%-11s%-s\n",
user_id,
user_name,
user_access->no_callin_access? "false": "true ",
user_access->link_auth_access? "true ": "false",
user_access->ipmi_messaging_access? "true ": "false",
val2str(user_access->channel_privilege_limit,
ipmi_privlvl_vals));
}
static void
dump_user_access_csv(
uint8_t user_id,
const char * user_name,
struct user_access_rsp * user_access)
{
printf("%d,%s,%s,%s,%s,%s\n",
user_id,
user_name,
user_access->no_callin_access? "false": "true",
user_access->link_auth_access? "true": "false",
user_access->ipmi_messaging_access? "true": "false",
val2str(user_access->channel_privilege_limit,
ipmi_privlvl_vals));
}
static int
ipmi_print_user_list(
struct ipmi_intf * intf,
uint8_t channel_number)
{
/* This is where you were! */
char user_name[17];
struct user_access_rsp user_access;
uint8_t current_user_id = 1;
do
{
if (ipmi_get_user_access(intf,
channel_number,
current_user_id,
&user_access))
return -1;
if (ipmi_get_user_name(intf,
current_user_id,
user_name))
return -1;
if ((current_user_id == 0) ||
user_access.link_auth_access ||
user_access.ipmi_messaging_access ||
strcmp("", user_name))
{
if (csv_output)
dump_user_access_csv(current_user_id,
user_name, &user_access);
else
dump_user_access(current_user_id,
user_name,
&user_access);
}
++current_user_id;
} while((current_user_id <= user_access.maximum_ids) &&
(current_user_id <= 63)); /* Absolute maximum allowed by spec */
return 0;
}
static int
ipmi_print_user_summary(
struct ipmi_intf * intf,
uint8_t channel_number)
{
struct user_access_rsp user_access;
if (ipmi_get_user_access(intf,
channel_number,
1,
&user_access))
return -1;
if (csv_output)
{
printf("%d,%d,%d\n",
user_access.maximum_ids,
user_access.enabled_user_count,
user_access.fixed_name_count);
}
else
{
printf("Maximum IDs : %d\n",
user_access.maximum_ids);
printf("Enabled User Count : %d\n",
user_access.enabled_user_count);
printf("Fixed Name Count : %d\n",
user_access.fixed_name_count);
}
return 0;
}
/*
* ipmi_user_set_username
*/
static int
ipmi_user_set_username(
struct ipmi_intf * intf,
uint8_t user_id,
const char * name)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t msg_data[17];
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; /* 0x06 */
req.msg.cmd = IPMI_SET_USER_NAME; /* 0x45 */
req.msg.data = msg_data;
req.msg.data_len = 17;
/* The channel number will remain constant throughout this function */
msg_data[0] = user_id;
memset(msg_data + 1, 0, 16);
strcpy(msg_data + 1, name);
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Set User Name command failed (user %d, name %s)",
user_id, name);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set User Name command failed (user %d, name %s): %s",
user_id, name, val2str(rsp->ccode, completion_code_vals));
return -1;
}
return 0;
}
/*
* ipmi_user_set_password
*
* This function is responsible for 4 things
* Enabling/Disabling users
* Setting/Testing passwords
*/
static int
ipmi_user_set_password(
struct ipmi_intf * intf,
uint8_t user_id,
uint8_t operation,
const char * password,
int is_twenty_byte_password)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
char * msg_data;
int password_length = (is_twenty_byte_password? 20 : 16);
msg_data = (char*)malloc(password_length + 2);
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_APP; /* 0x06 */
req.msg.cmd = IPMI_SET_USER_PASSWORD; /* 0x47 */
req.msg.data = msg_data;
req.msg.data_len = password_length + 2;
/* The channel number will remain constant throughout this function */
msg_data[0] = user_id;
if (is_twenty_byte_password)
msg_data[0] |= 0x80;
msg_data[1] = operation;
memset(msg_data + 2, 0, password_length);
if (password != NULL)
strncpy(msg_data + 2, password, password_length);
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Set User Password command failed (user %d)",
user_id);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set User Password command failed (user %d): %s",
user_id, val2str(rsp->ccode, completion_code_vals));
return rsp->ccode;
}
return 0;
}
/*
* ipmi_user_test_password
*
* Call ipmi_user_set_password, and interpret the result
*/
static int
ipmi_user_test_password(
struct ipmi_intf * intf,
uint8_t user_id,
const char * password,
int is_twenty_byte_password)
{
int ret;
ret = ipmi_user_set_password(intf,
user_id,
IPMI_PASSWORD_TEST_PASSWORD,
password,
is_twenty_byte_password);
switch (ret) {
case 0:
printf("Success\n");
break;
case 0x80:
printf("Failure: password incorrect\n");
break;
case 0x81:
printf("Failure: wrong password size\n");
break;
default:
printf("Unknown error\n");
}
return ((ret == 0) ? 0 : -1);
}
/*
* print_user_usage
*/
void
print_user_usage()
{
lprintf(LOG_NOTICE, "User Commands: summary [<channel number>]");
lprintf(LOG_NOTICE, " list [<channel number>]");
lprintf(LOG_NOTICE, " set name <user id> <username>");
lprintf(LOG_NOTICE, " set password <user id> [<password>]");
lprintf(LOG_NOTICE, " disable <user id>");
lprintf(LOG_NOTICE, " enable <user id>");
lprintf(LOG_NOTICE, " test <user id> <16|20> [<password]>\n");
}
const char *
ipmi_user_build_password_prompt(uint8_t user_id)
{
static char prompt[128];
memset(prompt, 0, 128);
snprintf(prompt, 128, "Password for user %d: ", user_id);
return prompt;
}
/*
* ipmi_user_main
*
* Upon entry to this function argv should contain our arguments
* specific to this subcommand
*/
int
ipmi_user_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int retval = 0;
/*
* Help
*/
if (argc == 0 || strncmp(argv[0], "help", 4) == 0)
{
print_user_usage();
}
/*
* Summary
*/
else if (strncmp(argv[0], "summary", 7) == 0)
{
uint8_t channel;
if (argc == 1)
channel = 0x0E; /* Ask about the current channel */
else if (argc == 2)
channel = (uint8_t)strtol(argv[1], NULL, 0);
else
{
print_user_usage();
return -1;
}
retval = ipmi_print_user_summary(intf, channel);
}
/*
* List
*/
else if (strncmp(argv[0], "list", 4) == 0)
{
uint8_t channel;
if (argc == 1)
channel = 0x0E; /* Ask about the current channel */
else if (argc == 2)
channel = (uint8_t)strtol(argv[1], NULL, 0);
else
{
print_user_usage();
return -1;
}
retval = ipmi_print_user_list(intf, channel);
}
/*
* Test
*/
else if (strncmp(argv[0], "test", 4) == 0)
{
// a little fucking irritating, isn't it
if ((argc == 3 || argc == 4) &&
((strncmp(argv[2], "16", 2) == 0) ||
(strncmp(argv[2], "20", 2) == 0)))
{
char * password = NULL;
int password_length = atoi(argv[2]);
uint8_t user_id = (uint8_t)strtol(argv[1],
NULL,
0);
if (user_id == 0)
{
lprintf(LOG_ERR, "Invalid user ID: %d", user_id);
return -1;
}
if (argc == 3)
{
/* We need to prompt for a password */
char * tmp;
const char * password_prompt =
ipmi_user_build_password_prompt(user_id);
#ifdef HAVE_GETPASSPHRASE
tmp = getpassphrase (password_prompt);
#else
tmp = (char*)getpass (password_prompt);
#endif
if (tmp != NULL)
password = strdup(tmp);
if (password == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1;
}
}
else
password = argv[3];
retval = ipmi_user_test_password(intf,
user_id,
password,
password_length == 20);
}
else
{
print_user_usage();
return -1;
}
}
/*
* Set
*/
else if (strncmp(argv[0], "set", 3) == 0)
{
/*
* Set Password
*/
if ((argc >= 3) &&
(strncmp("password", argv[1], 8) == 0))
{
char * password = NULL;
uint8_t user_id = (uint8_t)strtol(argv[2],
NULL,
0);
if (user_id == 0)
{
lprintf(LOG_ERR, "Invalid user ID: %d", user_id);
return -1;
}
if (argc == 3)
{
/* We need to prompt for a password */
char * tmp;
const char * password_prompt =
ipmi_user_build_password_prompt(user_id);
#ifdef HAVE_GETPASSPHRASE
tmp = getpassphrase (password_prompt);
#else
tmp = (char*)getpass (password_prompt);
#endif
if (tmp != NULL)
{
password = strdup(tmp);
if (password == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1;
}
#ifdef HAVE_GETPASSPHRASE
tmp = getpassphrase (password_prompt);
#else
tmp = (char*)getpass (password_prompt);
#endif
if (tmp != NULL)
{
if (strlen(password) != strlen(tmp))
{
lprintf(LOG_ERR, "Passwords do not match");
return -1;
}
if (strncmp(password, tmp, strlen(tmp)))
{
lprintf(LOG_ERR, "Passwords to not match");
return -1;
}
}
}
}
else
password = argv[3];
if (strlen(password) > 20)
{
lprintf(LOG_ERR, "Password is too long (> 20 bytes)");
return -1;
}
retval = ipmi_user_set_password(intf,
user_id,
IPMI_PASSWORD_SET_PASSWORD,
password,
strlen(password) > 16);
}
/*
* Set Name
*/
else if ((argc >= 2) &&
(strncmp("name", argv[1], 4) == 0))
{
if (argc != 4)
{
print_user_usage();
return -1;
}
retval = ipmi_user_set_username(intf,
(uint8_t)strtol(argv[2],
NULL,
0),
argv[3]);
}
else
{
print_user_usage();
return -1;
}
}
/*
* Disable / Enable
*/
else if ((strncmp(argv[0], "disable", 7) == 0) ||
(strncmp(argv[0], "enable", 6) == 0))
{
uint8_t user_id;
uint8_t operation;
char null_password[16]; /* Not used, but required */
memset(null_password, 0, sizeof(null_password));
if (argc != 2)
{
print_user_usage();
return -1;
}
user_id = (uint8_t)strtol(argv[1],
NULL,
0);
if (user_id == 0)
{
lprintf(LOG_ERR, "Invalid user ID: %d", user_id);
return -1;
}
operation = (strncmp(argv[0], "disable", 7) == 0) ?
IPMI_PASSWORD_DISABLE_USER : IPMI_PASSWORD_ENABLE_USER;
retval = ipmi_user_set_password(intf,
user_id,
operation,
null_password,
0); /* This field is ignored */
}
else
{
print_user_usage();
}
return retval;
}

View File

@ -1,158 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <errno.h>
#include <stdarg.h>
#include <string.h>
#include <ipmitool/log.h>
struct logpriv_s {
char * name;
int daemon;
int level;
};
struct logpriv_s *logpriv;
static void log_reinit(void)
{
log_init(NULL, 0, 0);
}
void lprintf(int level, const char * format, ...)
{
static char logmsg[LOG_MSG_LENGTH];
va_list vptr;
if (!logpriv)
log_reinit();
if (logpriv->level < level)
return;
va_start(vptr, format);
vsnprintf(logmsg, LOG_MSG_LENGTH, format, vptr);
va_end(vptr);
if (logpriv->daemon)
syslog(level, "%s", logmsg);
else
fprintf(stderr, "%s\n", logmsg);
return;
}
void lperror(int level, const char * format, ...)
{
static char logmsg[LOG_MSG_LENGTH];
va_list vptr;
if (!logpriv)
log_reinit();
if (logpriv->level < level)
return;
va_start(vptr, format);
vsnprintf(logmsg, LOG_MSG_LENGTH, format, vptr);
va_end(vptr);
if (logpriv->daemon)
syslog(level, "%s: %s", logmsg, strerror(errno));
else
fprintf(stderr, "%s: %s\n", logmsg, strerror(errno));
return;
}
/*
* open connection to syslog if daemon
*/
void log_init(const char * name, int isdaemon, int verbose)
{
if (logpriv)
return;
logpriv = malloc(sizeof(*logpriv));
if (!logpriv)
return;
if (name != NULL)
logpriv->name = strdup(name);
else
logpriv->name = strdup(LOG_NAME_DEFAULT);
if (logpriv->name == NULL)
fprintf(stderr, "ipmitool: malloc failure\n");
logpriv->daemon = isdaemon;
logpriv->level = verbose + LOG_NOTICE;
if (logpriv->daemon)
openlog(logpriv->name, LOG_CONS, LOG_LOCAL4);
}
/*
* stop syslog logging if daemon mode,
* free used memory that stored log service
*/
void log_halt(void)
{
if (!logpriv)
return;
if (logpriv->name)
free(logpriv->name);
if (logpriv->daemon)
closelog();
free(logpriv);
logpriv = NULL;
}
int log_level_get(void)
{
return logpriv->level;
}
void log_level_set(int level)
{
logpriv->level = level;
}

View File

@ -37,15 +37,18 @@ SUBDIRS = plugins
MAINTAINERCLEANFILES = Makefile.in
ipmitool_SOURCES = ipmitool.c ipmishell.c
ipmitool_LDADD = $(top_builddir)/lib/libipmitool.la plugins/libintf.la
if IPMIEVD
EXTRA_DIST = bmcautoconf.sh
bin_PROGRAMS = ipmievd ipmitool
ipmievd_SOURCES = ipmievd.c
ipmievd_LDADD = $(top_builddir)/lib/libipmitool.la plugins/libintf.la
ipmievd_LDADD = $(top_srcdir)/lib/libipmitool.la $(top_srcdir)/src/plugins/libintf.la
else
EXTRA_DIST = bmcautoconf.sh ipmievd.c
bin_PROGRAMS = ipmitool
endif
EXTRA_DIST = ipmievd.c
ipmitool_SOURCES = ipmitool.c
ipmitool_LDADD = $(top_srcdir)/lib/libipmitool.la $(top_srcdir)/src/plugins/libintf.la
bin_SCRIPTS = bmcautoconf.sh
bin_PROGRAMS = ipmitool @IPMIEVD_BIN@
EXTRA_PROGRAMS = ipmitool ipmievd

152
ipmitool/src/bmcautoconf.sh Executable file
View File

@ -0,0 +1,152 @@
#!/bin/bash
#
# bmcautoconf [interface] [channel]
#
#
# 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.
#
# You acknowledge that this software is not designed or intended for use
# in the design, construction, operation or maintenance of any nuclear
# facility.
DEBUG=0
# if the wrong channel is used serious problems could occur
# Channel 6 == eth0, top interface on v60x and v65x
# Channel 6 == eth1, top interface on LX50
# Channel 7 == eth1, bottom interface on v60x and v65x
# Channel 7 == eth0, bottom interface on LX50
CHANNEL=6
IFACE=eth0
# ipmitool interface
# open = OpenIPMI kernel driver
# [ipmi_msghandler, ipmi_kcs_drv, ipmi_devintf]
# imb = Intel IMB
IPMIINTF=open
# util locations
IPMITOOL=/usr/bin/ipmitool
PING=/bin/ping
ARP=/sbin/arp
IFCONFIG=/sbin/ifconfig
ROUTE=/sbin/route
ipmitool_lan_set ()
{
[ $# -lt 1 ] && return
PARAM=$1
VALUE=
[ $# -ge 2 ] && VALUE=$2
if [ $DEBUG -gt 0 ]; then
echo "Setting LAN parameter ${PARAM} to ${VALUE}"
echo "$IPMITOOL -I $IPMIINTF lan set $CHANNEL $PARAM $VALUE"
fi
$IPMITOOL -I $IPMIINTF lan set $CHANNEL $PARAM $VALUE
}
if [ ! -x $IPMITOOL ]; then
echo "Error: unable to find $IPMITOOL"
exit 1
fi
if [ $# -ge 1 ]; then
IFACE=$1
if ! $IFCONFIG $IFACE | grep -q "inet addr:" >/dev/null 2>&1 ; then
echo "Error: unable to find interface $IFACE"
exit 1
fi
fi
if [ $# -ge 2 ]; then
CHANNEL=$2
if [ $CHANNEL -ne 6 ] && [ $CHANNEL -ne 7 ]; then
echo "Invalid channel: $CHANNEL"
exit 1
fi
fi
[ $DEBUG -gt 0 ] && echo "Auto-configuring $IFACE (channel $CHANNEL)"
# IP Address
IP_ADDRESS=$( $IFCONFIG $IFACE | grep "inet addr:" | awk -F"[:[:space:]]+" '{ print $4 }' )
if [ X$IP_ADDRESS = X ]; then
echo "Unable to determine IP address for interface $IFACE"
exit 2
fi
# Netmask
IP_NETMASK=$( $IFCONFIG $IFACE | grep "inet addr:" | awk -F"[:[:space:]]+" '{ print $8 }' )
if [ X$IP_NETMASK = X ]; then
echo "Unable to determine IP netmask for interface $IFACE"
exit 3
fi
# MAC Address
MAC_ADDRESS=$( $IFCONFIG $IFACE | grep "HWaddr" | awk '{ print $5 }' )
if [ X$MAC_ADDRESS = X ]; then
echo "Unable to determine MAC address for interface $IFACE"
exit 4
fi
# default route IP Address
DEF_ROUTE_IP=$( $ROUTE -n | awk '/^0.0.0.0/ { print $2 }' )
if [ X$DEF_ROUTE_IP = X ]; then
echo "Unable to determine default route IP address"
exit 5
fi
# Default Route MAC Address
# (ping it first to populate arp table)
$PING -q -c1 $DEF_ROUTE_IP >/dev/null 2>&1
DEF_ROUTE_MAC=$( $ARP -an -i $IFACE | grep "$DEF_ROUTE_IP[^0-9]" | awk '{ print $4 }' )
if [ X$DEF_ROUTE_MAC = X ]; then
echo "Unable to determine default route MAC address"
exit 6
fi
ipmitool_lan_set "ipsrc" "static"
ipmitool_lan_set "ipaddr" $IP_ADDRESS
ipmitool_lan_set "netmask" $IP_NETMASK
ipmitool_lan_set "macaddr" $MAC_ADDRESS
ipmitool_lan_set "defgw ipaddr" $DEF_ROUTE_IP
ipmitool_lan_set "defgw macaddr" $DEF_ROUTE_MAC
ipmitool_lan_set "auth callback,user,operator,admin" "md2,md5"
ipmitool_lan_set "access" "on"
ipmitool_lan_set "user"
ipmitool_lan_set "arp generate" "on"
ipmitool_lan_set "arp interval" "8"
exit 0

View File

@ -40,27 +40,15 @@
#include <sys/ioctl.h>
#include <errno.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>
#ifdef __FreeBSD__
#include <signal.h>
#include <paths.h>
#endif
#include <linux/ipmi.h>
#include <config.h>
#ifdef HAVE_OPENIPMI_H
# include <linux/ipmi.h>
#else
# include "plugins/open/open.h"
#endif
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_sel.h>
@ -69,73 +57,12 @@ extern int errno;
int verbose = 0;
int csv_output = 0;
static void daemonize(void)
{
pid_t pid;
int fd;
#ifdef SIGHUP
sigset_t sighup;
#endif
/* if we are started from init no need to become daemon */
if (getppid() == 1)
return;
#ifdef SIGHUP
sigemptyset(&sighup);
sigaddset(&sighup, SIGHUP);
if (sigprocmask(SIG_UNBLOCK, &sighup, NULL) < 0)
fprintf(stderr, "ERROR: could not unblock SIGHUP signal\n");
signal(SIGHUP, SIG_IGN);
#endif
#ifdef SIGTTOU
signal(SIGTTOU, SIG_IGN);
#endif
#ifdef SIGTTIN
signal(SIGTTIN, SIG_IGN);
#endif
#ifdef SIGQUIT
signal(SIGQUIT, SIG_IGN);
#endif
#ifdef SIGTSTP
signal(SIGTSTP, SIG_IGN);
#endif
pid = (pid_t) fork();
if (pid < 0 || pid > 0)
exit(0);
#if defined(SIGTSTP) && defined(TIOCNOTTY)
if (setpgid(0, getpid()) == -1)
exit(1);
if ((fd = open(_PATH_TTY, O_RDWR)) >= 0) {
ioctl(fd, TIOCNOTTY, NULL);
close(fd);
}
#else
if (setpgrp() == -1)
exit(1);
pid = (pid_t) fork();
if (pid < 0 || pid > 0)
exit(0);
#endif
chdir("/");
umask(0);
for (fd=0; fd<64; fd++)
close(fd);
open("/dev/null", O_RDWR);
dup(0);
dup(0);
}
static int enable_event_msg_buffer(struct ipmi_intf * intf)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
uint8_t bmc_global_enables;
unsigned char bmc_global_enables;
int r;
/* we must read/modify/write bmc global enables */
memset(&req, 0, sizeof(req));
@ -144,7 +71,7 @@ static int enable_event_msg_buffer(struct ipmi_intf * intf)
rsp = intf->sendrecv(intf, &req);
if (!rsp || rsp->ccode) {
lprintf(LOG_WARNING, "Get BMC Global Enables command filed [ccode %02x]",
printf("ERROR:%x Get BMC Global Enables command\n",
rsp ? rsp->ccode : 0);
return -1;
}
@ -156,43 +83,22 @@ static int enable_event_msg_buffer(struct ipmi_intf * intf)
rsp = intf->sendrecv(intf, &req);
if (!rsp || rsp->ccode) {
lprintf(LOG_WARNING, "Set BMC Global Enables command failed [ccode %02x]",
printf("ERROR:%x Set BMC Global Enables command\n",
rsp ? rsp->ccode : 0);
return -1;
}
lprintf(LOG_DEBUG, "BMC Event Message Buffer enabled");
if (verbose)
printf("BMC Event Message Buffer enabled.\n");
return 0;
}
static void log_event(struct sel_event_record * evt)
{
char *desc;
if (!evt)
return;
if (evt->record_type == 0xf0)
lprintf(LOG_ALERT, "Linux kernel panic: %.11s", (char *) evt + 5);
else if (evt->record_type >= 0xc0)
lprintf(LOG_NOTICE, "IPMI Event OEM Record %02x", evt->record_type);
else {
ipmi_get_event_desc(evt, &desc);
if (desc) {
lprintf(LOG_NOTICE, "%s Sensor %02x - %s",
ipmi_sel_get_sensor_type(evt->sensor_type),
evt->sensor_num, desc);
free(desc);
}
}
}
static void read_event(struct ipmi_intf * intf)
{
struct ipmi_addr addr;
struct ipmi_recv recv;
uint8_t data[80];
unsigned char data[80];
int rv;
recv.addr = (char *) &addr;
@ -202,121 +108,125 @@ static void read_event(struct ipmi_intf * intf)
rv = ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv);
if (rv < 0) {
switch (errno) {
case EINTR:
return; /* abort */
case EMSGSIZE:
recv.msg.data_len = sizeof(data); /* truncated */
break;
default:
lperror(LOG_ERR, "Unable to receive IPMI message");
if (errno == EINTR)
/* abort */
return;
if (errno == EMSGSIZE) {
/* message truncated */
recv.msg.data_len = sizeof(data);
} else {
printf("ERROR: receiving IPMI message: %s\n",
strerror(errno));
return;
}
}
if (!recv.msg.data || recv.msg.data_len == 0) {
lprintf(LOG_ERR, "No data in event");
printf("ERROR: No data in event!\n");
return;
}
if (verbose > 1) {
printf(" type = %d\n", recv.recv_type);
printf(" channel = 0x%x\n", addr.channel);
printf(" msgid = %ld\n", recv.msgid);
printf(" netfn = 0x%x\n", recv.msg.netfn);
printf(" cmd = 0x%x\n", recv.msg.cmd);
printf(" data_len = %d\n", recv.msg.data_len);
printbuf(recv.msg.data, recv.msg.data_len, "data");
}
if (recv.recv_type != IPMI_ASYNC_EVENT_RECV_TYPE) {
lprintf(LOG_ERR, "Type %x is not an event", recv.recv_type);
printf("ERROR: Not an event!\n");
return;
}
lprintf(LOG_DEBUG, "netfn:%x cmd:%x ccode:%d",
recv.msg.netfn, recv.msg.cmd, recv.msg.data[0]);
log_event((struct sel_event_record *)recv.msg.data);
if (verbose)
ipmi_sel_print_std_entry_verbose((struct sel_event_record *)recv.msg.data);
else
ipmi_sel_print_std_entry((struct sel_event_record *)recv.msg.data);
}
static int do_exit(struct ipmi_intf * intf, int rv)
{
if (intf)
intf->close(intf);
log_halt();
ipmi_intf_exit();
exit(rv);
}
static void usage(void)
{
fprintf(stderr, "usage: ipmievd [-hvd]\n");
fprintf(stderr, "\n");
fprintf(stderr, " -h This help\n");
fprintf(stderr, " -v Verbose (can use multiple times)\n");
fprintf(stderr, " -s Do NOT daemonize\n");
fprintf(stderr, "\n");
printf("usage: ipmievd [-hv]\n");
printf("\n");
printf(" -h This help\n");
printf(" -v Verbose (can use multiple times)\n");
printf("\n");
}
int main(int argc, char ** argv)
{
struct ipmi_intf * intf;
int r, a;
int i = 1;
int daemon = 1;
int r, i=1, a;
struct pollfd pfd;
/* make sure we have UID 0 */
if (geteuid() || getuid()) {
fprintf(stderr, "Inadequate privledges\n");
do_exit(NULL, EXIT_FAILURE);
}
while ((a = getopt(argc, (char **)argv, "hvs")) != -1) {
while ((a = getopt(argc, (char **)argv, "hv")) != -1) {
switch (a) {
case 'h':
usage();
do_exit(NULL, EXIT_SUCCESS);
break;
case 'v':
verbose++;
break;
case 's':
daemon = 0;
break;
default:
usage();
do_exit(NULL, EXIT_FAILURE);
}
}
if (daemon)
daemonize();
if (verbose)
printf("Loading OpenIPMI interface plugin.\n");
log_init("ipmievd", daemon, verbose);
/* load interface */
lprintf(LOG_DEBUG, "Loading OpenIPMI interface");
intf = ipmi_intf_load("open");
if (!intf) {
lprintf(LOG_ERR, "Unable to load OpenIPMI interface");
do_exit(NULL, EXIT_FAILURE);
/* init interface plugin support */
r = ipmi_intf_init();
if (r < 0) {
printf("ERROR: Unable to initialize plugin interface\n");
exit(EXIT_FAILURE);
}
/* load interface plugin */
intf = ipmi_intf_load("intf_open");
if (!intf) {
printf("ERROR: unable to load OpenIPMI interface plugin\n");
exit(EXIT_FAILURE);
}
if (verbose)
printf("Connecting to OpenIPMI device.\n");
/* open connection to openipmi device */
lprintf(LOG_DEBUG, "Connecting to OpenIPMI device");
r = intf->open(intf);
r = intf->open(intf, NULL, 0, NULL, NULL);
if (r < 0) {
lprintf(LOG_ERR, "Unable to open OpenIPMI device");
do_exit(NULL, EXIT_FAILURE);
printf("ERROR: Unable to open OpenIPMI device\n");
exit(EXIT_FAILURE);
}
/* enable event message buffer */
lprintf(LOG_DEBUG, "Enabling event message buffer");
r = enable_event_msg_buffer(intf);
if (r < 0) {
lprintf(LOG_ERR, "Could not enable event message buffer");
printf("ERROR: Unable to enable event message buffer.\n");
do_exit(intf, EXIT_FAILURE);
}
if (verbose)
printf("Enabling event receiver.\n");
/* enable OpenIPMI event receiver */
lprintf(LOG_DEBUG, "Enabling event receiver");
r = ioctl(intf->fd, IPMICTL_SET_GETS_EVENTS_CMD, &i);
if (r != 0) {
lperror(LOG_ERR, "Could not enable event receiver");
if (ioctl(intf->fd, IPMICTL_SET_GETS_EVENTS_CMD, &i)) {
perror("ERROR: Could not enable event receiver");
do_exit(intf, EXIT_FAILURE);
}
lprintf(LOG_NOTICE, "Waiting for events...");
printf("ipmievd loaded, waiting for events...\n");
for (;;) {
pfd.fd = intf->fd; /* wait on openipmi device */
@ -328,7 +238,7 @@ int main(int argc, char ** argv)
/* timeout is disabled */
break;
case -1:
lperror(LOG_CRIT, "Unable to read from IPMI device");
perror("ERROR: poll operation failed");
do_exit(intf, EXIT_FAILURE);
break;
default:
@ -337,6 +247,8 @@ int main(int argc, char ** argv)
}
}
lprintf(LOG_DEBUG, "Shutting down...");
if (verbose)
printf("Exiting.\n");
do_exit(intf, EXIT_SUCCESS);
}

View File

@ -1,385 +0,0 @@
/*
* Copyright (c) 2003, 2004 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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_session.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#define EXEC_BUF_SIZE 1024
#define EXEC_ARG_SIZE 32
extern void ipmi_cmd_print(void);
extern int ipmi_cmd_run(struct ipmi_intf * intf, char * name, int argc, char ** argv);
extern const struct valstr ipmi_privlvl_vals[];
extern const struct valstr ipmi_authtype_session_vals[];
#ifdef HAVE_READLINE
#include <readline/readline.h>
#include <readline/history.h>
#define RL_PROMPT "ipmitool> "
#define RL_TIMEOUT 30
static struct ipmi_intf * shell_intf;
/* This function attempts to keep lan sessions active
* so they do not time out waiting for user input. The
* readline timeout is set to 1 second but lan session
* timeout is ~60 seconds.
*/
static int rl_event_keepalive(void)
{
static int internal_timer = 0;
if (shell_intf == NULL)
return -1;
if (shell_intf->keepalive == NULL)
return 0;
#if defined (RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0402
if (internal_timer++ < RL_TIMEOUT)
#else
/* In readline < 4.2 keyboard timeout hardcoded to 0.1 second */
if (internal_timer++ < RL_TIMEOUT * 10)
#endif
return 0;
internal_timer = 0;
shell_intf->keepalive(shell_intf);
return 0;
}
int ipmi_shell_main(struct ipmi_intf * intf, int argc, char ** argv)
{
char *pbuf, **ap, *__argv[20];
int __argc, rc=0;
rl_readline_name = "ipmitool";
/* this essentially disables command completion
* until its implemented right, otherwise we get
* the current directory contents... */
rl_bind_key('\t', rl_insert);
if (intf->keepalive) {
/* hook to keep lan sessions active */
shell_intf = intf;
rl_event_hook = rl_event_keepalive;
#if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0402
/* set to 1 second */
rl_set_keyboard_input_timeout(1000*1000);
#endif
}
while ((pbuf = (char *)readline(RL_PROMPT)) != NULL) {
if (strlen(pbuf) == 0) {
free(pbuf);
continue;
}
if (strncmp(pbuf, "quit", 4) == 0 ||
strncmp(pbuf, "exit", 4) == 0) {
free(pbuf);
return 0;
}
if (strncmp(pbuf, "help", 4) == 0 ||
strncmp(pbuf, "?", 1) == 0) {
ipmi_cmd_print();
free(pbuf);
continue;
}
/* for the all-important up arrow :) */
add_history(pbuf);
__argc = 0;
ap = __argv;
for (*ap = strtok(pbuf, " \t");
*ap != NULL;
*ap = strtok(NULL, " \t")) {
__argc++;
if (**ap != '\0') {
if (++ap >= &__argv[20])
break;
}
}
if (__argc && __argv[0])
rc = ipmi_cmd_run(intf,
__argv[0],
__argc-1,
&(__argv[1]));
free(pbuf);
}
return rc;
}
#else /* HAVE_READLINE */
int
ipmi_shell_main(struct ipmi_intf * intf, int argc, char ** argv)
{
lprintf(LOG_ERR, "Compiled without readline, shell is disabled");
return -1;
}
#endif /* HAVE_READLINE */
static void
ipmi_set_usage(void)
{
lprintf(LOG_NOTICE, "Usage: set <option> <value>\n");
lprintf(LOG_NOTICE, "Options are:");
lprintf(LOG_NOTICE, " hostname <host> Session hostname");
lprintf(LOG_NOTICE, " username <user> Session username");
lprintf(LOG_NOTICE, " password <pass> Session password");
lprintf(LOG_NOTICE, " privlvl <level> Session privilege level force");
lprintf(LOG_NOTICE, " authtype <type> Authentication type force");
lprintf(LOG_NOTICE, " localaddr <addr> Local IPMB address");
lprintf(LOG_NOTICE, " targetaddr <addr> Remote target IPMB address");
lprintf(LOG_NOTICE, " port <port> Remote RMCP port");
lprintf(LOG_NOTICE, " csv [level] enable output in comma separated format");
lprintf(LOG_NOTICE, " verbose [level] Verbose level");
lprintf(LOG_NOTICE, "");
}
int ipmi_set_main(struct ipmi_intf * intf, int argc, char ** argv)
{
if (argc == 0 || strncmp(argv[0], "help", 4) == 0) {
ipmi_set_usage();
return -1;
}
/* these options can have no arguments */
if (strncmp(argv[0], "verbose", 7) == 0) {
verbose = (argc > 1) ? atoi(argv[1]) : verbose+1;
return 0;
}
if (strncmp(argv[0], "csv", 3) == 0) {
csv_output = (argc > 1) ? atoi(argv[1]) : 1;
return 0;
}
/* the rest need an argument */
if (argc == 1) {
ipmi_set_usage();
return -1;
}
if (strncmp(argv[0], "host", 4) == 0 ||
strncmp(argv[0], "hostname", 8) == 0) {
ipmi_intf_session_set_hostname(intf, argv[1]);
printf("Set session hostname to %s\n", intf->session->hostname);
}
else if (strncmp(argv[0], "user", 4) == 0 ||
strncmp(argv[0], "username", 8) == 0) {
ipmi_intf_session_set_username(intf, argv[1]);
printf("Set session username to %s\n", intf->session->username);
}
else if (strncmp(argv[0], "pass", 4) == 0 ||
strncmp(argv[0], "password", 8) == 0) {
ipmi_intf_session_set_password(intf, argv[1]);
printf("Set session password\n");
}
else if (strncmp(argv[0], "authtype", 8) == 0) {
int authtype;
authtype = str2val(argv[1], ipmi_authtype_session_vals);
if (authtype < 0) {
lprintf(LOG_ERR, "Invalid authtype: %s", argv[1]);
} else {
ipmi_intf_session_set_authtype(intf, authtype);
printf("Set session authtype to %s\n",
val2str(intf->session->authtype_set, ipmi_authtype_session_vals));
}
}
else if (strncmp(argv[0], "privlvl", 7) == 0) {
int privlvl;
privlvl = str2val(argv[1], ipmi_privlvl_vals);
if (privlvl < 0) {
lprintf(LOG_ERR, "Invalid privilege level: %s", argv[1]);
} else {
ipmi_intf_session_set_privlvl(intf, privlvl);
printf("Set session privilege level to %s\n",
val2str(intf->session->privlvl, ipmi_privlvl_vals));
}
}
else if (strncmp(argv[0], "port", 4) == 0) {
int port = atoi(argv[1]);
ipmi_intf_session_set_port(intf, port);
printf("Set session port to %d\n", intf->session->port);
}
else if (strncmp(argv[0], "localaddr", 9) == 0) {
intf->my_addr = (uint8_t)strtol(argv[1], NULL, 0);
printf("Set local IPMB address to 0x%02x\n", intf->my_addr);
}
else if (strncmp(argv[0], "targetaddr", 10) == 0) {
intf->target_addr = (uint8_t)strtol(argv[1], NULL, 0);
printf("Set remote IPMB address to 0x%02x\n", intf->target_addr);
}
else {
ipmi_set_usage();
return -1;
}
return 0;
}
int ipmi_exec_main(struct ipmi_intf * intf, int argc, char ** argv)
{
FILE * fp;
char buf[EXEC_BUF_SIZE];
char * ptr, * tok, * ret, * tmp;
int __argc, i, r;
char * __argv[EXEC_ARG_SIZE];
int rc=0;
if (argc < 1) {
lprintf(LOG_ERR, "Usage: exec <filename>");
return -1;
}
fp = ipmi_open_file_read(argv[0]);
if (fp == NULL)
return -1;
while (feof(fp) == 0) {
ret = fgets(buf, EXEC_BUF_SIZE, fp);
if (ret == NULL)
continue;
/* clip off optional comment tail indicated by # */
ptr = strchr(buf, '#');
if (ptr)
*ptr = '\0';
else
ptr = buf + strlen(buf);
/* change "" and '' with spaces in the middle to ~
* this is really ugly but I'm in a hurry */
ptr = buf;
while (*ptr != '\0') {
if (*ptr == '"') {
ptr++;
while (*ptr != '"') {
if (isspace(*ptr))
*ptr = '~';
ptr++;
}
}
if (*ptr == '\'') {
ptr++;
while (*ptr != '\'') {
if (isspace(*ptr))
*ptr = '~';
ptr++;
}
}
ptr++;
}
/* clip off trailing and leading whitespace */
ptr--;
while (isspace(*ptr) && ptr >= buf)
*ptr-- = '\0';
ptr = buf;
while (isspace(*ptr))
ptr++;
if (strlen(ptr) == 0)
continue;
/* parse it and make argument list */
__argc = 0;
for (tok = strtok(ptr, " "); tok != NULL; tok = strtok(NULL, " ")) {
if (__argc < EXEC_ARG_SIZE) {
__argv[__argc++] = strdup(tok);
if (__argv[__argc-1] == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return -1;
}
tmp = __argv[__argc-1];
if (*tmp == '\'') {
memmove(tmp, tmp+1, strlen(tmp));
while (*tmp != '\'') {
if (*tmp == '~')
*tmp = ' ';
tmp++;
}
*tmp = '\0';
}
if (*tmp == '"') {
memmove(tmp, tmp+1, strlen(tmp));
while (*tmp != '"') {
if (*tmp == '~')
*tmp = ' ';
tmp++;
}
*tmp = '\0';
}
}
}
/* now run the command, save the result if not successful */
r = ipmi_cmd_run(intf, __argv[0], __argc-1, &(__argv[1]));
if (r != 0)
rc = r;
/* free argument list */
for (i=0; i<__argc; i++) {
if (__argv[i] != NULL) {
free(__argv[i]);
__argv[i] = NULL;
}
}
}
fclose(fp);
return rc;
}

View File

@ -1,9 +1,6 @@
/*
* Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
* Use is subject to license terms.
*/
/*
* 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:
@ -38,261 +35,243 @@
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <config.h>
#include <ipmitool/helper.h>
#include <ipmitool/log.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_session.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
#include <ipmitool/ipmi_sel.h>
#include <ipmitool/ipmi_fru.h>
#include <ipmitool/ipmi_sol.h>
#include <ipmitool/ipmi_isol.h>
#include <ipmitool/ipmi_lanp.h>
#include <ipmitool/ipmi_chassis.h>
#include <ipmitool/ipmi_mc.h>
#include <ipmitool/ipmi_bmc.h>
#include <ipmitool/ipmi_sensor.h>
#include <ipmitool/ipmi_channel.h>
#include <ipmitool/ipmi_session.h>
#include <ipmitool/ipmi_event.h>
#include <ipmitool/ipmi_user.h>
#include <ipmitool/ipmi_raw.h>
#include <ipmitool/ipmi_pef.h>
#include <ipmitool/ipmi_oem.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef __sun
# define OPTION_STRING "I:hVvcH:f:U:p:"
#else
# define OPTION_STRING "I:hVvcgsEao:H:P:f:U:p:C:L:A:t:m:"
#endif
struct ipmi_session lan_session;
int csv_output = 0;
int verbose = 0;
extern const struct valstr ipmi_privlvl_vals[];
extern const struct valstr ipmi_authtype_session_vals[];
/* defined in ipmishell.c */
#ifdef HAVE_READLINE
extern int ipmi_shell_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif
extern int ipmi_set_main(struct ipmi_intf * intf, int argc, char ** argv);
extern int ipmi_exec_main(struct ipmi_intf * intf, int argc, char ** argv);
struct ipmi_cmd {
int (*func)(struct ipmi_intf * intf, int argc, char ** argv);
const char * name;
const char * desc;
} ipmi_cmd_list[] = {
{ ipmi_raw_main, "raw", "Send a RAW IPMI request and print response" },
{ ipmi_lanp_main, "lan", "Configure LAN Channels" },
{ ipmi_chassis_main, "chassis", "Get chassis status and set power state" },
{ ipmi_event_main, "event", "Send pre-defined events to MC" },
{ ipmi_mc_main, "mc", "Management Controller status and global enables" },
{ ipmi_mc_main, "bmc", NULL }, /* for backwards compatibility */
{ ipmi_sdr_main, "sdr", "Print Sensor Data Repository entries and readings" },
{ ipmi_sensor_main, "sensor", "Print detailed sensor information" },
{ ipmi_fru_main, "fru", "Print built-in FRU and scan SDR for FRU locators" },
{ ipmi_sel_main, "sel", "Print System Event Log (SEL)" },
{ ipmi_pef_main, "pef", "Configure Platform Event Filtering (PEF)" },
{ ipmi_sol_main, "sol", "Configure IPMIv2.0 Serial-over-LAN" },
{ ipmi_isol_main, "isol", "Configure IPMIv1.5 Serial-over-LAN" },
{ ipmi_user_main, "user", "Configure Management Controller users" },
{ ipmi_channel_main, "channel", "Configure Management Controller channels" },
{ ipmi_session_main, "session", "Print session information" },
#ifdef HAVE_READLINE
{ ipmi_shell_main, "shell", "Launch interactive IPMI shell" },
#endif
{ ipmi_exec_main, "exec", "Run list of commands from file" },
{ ipmi_set_main, "set", "Set runtime variable for shell and exec" },
{ NULL },
};
/*
* Print all the commands in the above table to stderr
* used for help text on command line and shell
*/
void
ipmi_cmd_print(void)
void usage(void)
{
struct ipmi_cmd * cmd;
lprintf(LOG_NOTICE, "Commands:");
for (cmd=ipmi_cmd_list; cmd->func != NULL; cmd++) {
if (cmd->desc == NULL)
continue;
lprintf(LOG_NOTICE, "\t%-12s %s", cmd->name, cmd->desc);
}
lprintf(LOG_NOTICE, "");
printf("ipmitool version %s\n", VERSION);
printf("\n");
printf("usage: ipmitool [options...] <command>\n");
printf("\n");
printf(" -h This help\n");
printf(" -V Show version information\n");
printf(" -v Verbose (can use multiple times)\n");
printf(" -c CSV output suitable for parsing\n");
printf(" -g Attempt to be extra robust in LAN communications\n");
printf(" -H hostname Remote host name for LAN interface\n");
printf(" -p port Remote RMCP port (default is 623)\n");
printf(" -P password Remote administrator password\n");
printf(" -I intf Inteface to use\n");
printf("\n\n");
exit(EXIT_SUCCESS);
}
/* ipmi_cmd_run - run a command from list based on parameters
* called from main()
*
* 1. iterate through ipmi_cmd_list matching on name
* 2. call func() for that command
*
* @intf: ipmi interface
* @name: command name
* @argc: command argument count
* @argv: command argument list
*
* returns value from func() of that commnad if found
* returns -1 if command is not found
*/
int
ipmi_cmd_run(struct ipmi_intf * intf, char * name, int argc, char ** argv)
int ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
{
struct ipmi_cmd * cmd;
struct ipmi_rs * rsp;
struct ipmi_rq req;
unsigned char netfn, cmd;
int i;
unsigned char data[32];
for (cmd=ipmi_cmd_list; cmd->func != NULL; cmd++) {
if (strncmp(name, cmd->name, strlen(cmd->name)) == 0)
break;
}
if (cmd->func == NULL) {
lprintf(LOG_ERR, "Invalid command: %s", name);
if (argc < 2 || !strncmp(argv[0], "help", 4)) {
printf("RAW Commands: raw <netfn> <cmd> [data]\n");
return -1;
}
return cmd->func(intf, argc, argv);
netfn = (unsigned char)strtol(argv[0], NULL, 0);
cmd = (unsigned char)strtol(argv[1], NULL, 0);
memset(data, 0, sizeof(data));
memset(&req, 0, sizeof(req));
req.msg.netfn = netfn;
req.msg.cmd = cmd;
req.msg.data = data;
for (i=2; i<argc; i++) {
unsigned char val = (unsigned char)strtol(argv[i], NULL, 0);
req.msg.data[i-2] = val;
req.msg.data_len++;
}
if (req.msg.data_len) {
for (i=0; i<req.msg.data_len; i++) {
if (((i%16) == 0) && (i != 0))
printf("\n");
printf(" %2.2x", req.msg.data[i]);
}
printf("\n");
}
printf("RAW REQ (netfn=0x%x cmd=0x%x data_len=%d)\n",
req.msg.netfn, req.msg.cmd, req.msg.data_len);
rsp = intf->sendrecv(intf, &req);
if (!rsp || rsp->ccode) {
printf("Error:%x sending RAW command\n",
rsp ? rsp->ccode : 0);
return -1;
}
printf("RAW RSP (%d bytes)\n", rsp->data_len);
for (i=0; i<rsp->data_len; i++) {
if (((i%16) == 0) && (i != 0))
printf("\n");
printf(" %2.2x", rsp->data[i]);
}
printf("\n");
return 0;
}
/* ipmitool_usage - print usage help
*/
static void
ipmitool_usage(void)
static int
ipmi_get_user_access(struct ipmi_intf * intf, unsigned char channel, unsigned char userid)
{
lprintf(LOG_NOTICE, "ipmitool version %s\n", VERSION);
lprintf(LOG_NOTICE, "usage: ipmitool [options...] <command>\n");
lprintf(LOG_NOTICE, " -h This help");
lprintf(LOG_NOTICE, " -V Show version information");
lprintf(LOG_NOTICE, " -v Verbose (can use multiple times)");
lprintf(LOG_NOTICE, " -c Display output in comma separated format");
lprintf(LOG_NOTICE, " -I intf Interface to use");
lprintf(LOG_NOTICE, " -H hostname Remote host name for LAN interface");
lprintf(LOG_NOTICE, " -p port Remote RMCP port [default=623]");
lprintf(LOG_NOTICE, " -U username Remote session username");
lprintf(LOG_NOTICE, " -f file Read remote session password from file");
lprintf(LOG_NOTICE, " -C ciphersuite Cipher suite to be used by lanplus interface");
#ifndef __sun
lprintf(LOG_NOTICE, " -L level Remote session privilege level [default=USER]");
lprintf(LOG_NOTICE, " -A authtype Force use of auth type NONE, PASSWORD, MD2, MD5 or OEM");
lprintf(LOG_NOTICE, " -P password Remote session password");
lprintf(LOG_NOTICE, " -a Prompt for remote password");
lprintf(LOG_NOTICE, " -E Read password from IPMI_PASSWORD environment variable");
lprintf(LOG_NOTICE, " -m address Set local IPMB address");
lprintf(LOG_NOTICE, " -t address Bridge request to remote target address");
lprintf(LOG_NOTICE, " -o oemtype Setup for OEM (use 'list' to see available OEM types)");
#endif
lprintf(LOG_NOTICE, "");
ipmi_intf_print();
ipmi_cmd_print();
struct ipmi_rs * rsp;
struct ipmi_rq req;
unsigned char rqdata[2];
memset(&req, 0, sizeof(req));
rqdata[0] = channel & 0xf;
rqdata[1] = userid & 0x3f;
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = 0x44;
req.msg.data = rqdata;
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
if (!rsp || rsp->ccode) {
printf("Error:%x Get User Access Command (0x%x)\n",
rsp ? rsp->ccode : 0, channel);
return -1;
}
printf("Maximum User IDs : %d\n", rsp->data[0] & 0x3f);
printf("Enabled User IDs : %d\n", rsp->data[1] & 0x3f);
printf("Fixed Name User IDs : %d\n", rsp->data[2] & 0x3f);
printf("Access Available : %s\n", (rsp->data[3] & 0x40) ? "callback" : "call-in / callback");
printf("Link Authentication : %sabled\n", (rsp->data[3] & 0x20) ? "en" : "dis");
printf("IPMI Messaging : %sabled\n", (rsp->data[3] & 0x10) ? "en" : "dis");
// printf("Privilege Level : %s\n", val2str(rsp->data[3] & 0x0f, ipmi_privlvl_vals));
return 0;
}
/* ipmi_password_file_read - Open file and read password from it
*
* @filename: file name to read from
*
* returns pointer to allocated buffer containing password
* (caller is expected to free when finished)
* returns NULL on error
*/
static char *
ipmi_password_file_read(char * filename)
static int
ipmi_send_platform_event(struct ipmi_intf * intf, int num)
{
FILE * fp;
char * pass = NULL;
int l;
struct ipmi_rs * rsp;
struct ipmi_rq req;
unsigned char rqdata[8];
pass = malloc(16);
if (pass == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return NULL;
memset(&req, 0, sizeof(req));
memset(rqdata, 0, 8);
printf("Sending ");
/* IPMB/LAN/etc */
switch (num) {
case 0: /* temperature */
printf("Temperature");
rqdata[0] = 0x04; /* EvMRev */
rqdata[1] = 0x01; /* Sensor Type */
rqdata[2] = 0x30; /* Sensor # */
rqdata[3] = 0x04; /* Event Dir / Event Type */
rqdata[4] = 0x00; /* Event Data 1 */
rqdata[5] = 0x00; /* Event Data 2 */
rqdata[6] = 0x00; /* Event Data 3 */
break;
case 1: /* correctable ECC */
printf("Memory Correctable ECC");
rqdata[0] = 0x04; /* EvMRev */
rqdata[1] = 0x0c; /* Sensor Type */
rqdata[2] = 0x01; /* Sensor # */
rqdata[3] = 0x6f; /* Event Dir / Event Type */
rqdata[4] = 0x00; /* Event Data 1 */
rqdata[5] = 0x00; /* Event Data 2 */
rqdata[6] = 0x00; /* Event Data 3 */
break;
case 2: /* uncorrectable ECC */
printf("Memory Uncorrectable ECC");
rqdata[0] = 0x04; /* EvMRev */
rqdata[1] = 0x0c; /* Sensor Type */
rqdata[2] = 0x01; /* Sensor # */
rqdata[3] = 0x6f; /* Event Dir / Event Type */
rqdata[4] = 0x01; /* Event Data 1 */
rqdata[5] = 0x00; /* Event Data 2 */
rqdata[6] = 0x00; /* Event Data 3 */
break;
case 3: /* parity error */
printf("Memory Parity Error");
rqdata[0] = 0x04; /* EvMRev */
rqdata[1] = 0x0c; /* Sensor Type */
rqdata[2] = 0x01; /* Sensor # */
rqdata[3] = 0x6f; /* Event Dir / Event Type */
rqdata[4] = 0x02; /* Event Data 1 */
rqdata[5] = 0x00; /* Event Data 2 */
rqdata[6] = 0x00; /* Event Data 3 */
break;
default:
printf("Invalid event number: %d\n", num);
return -1;
}
fp = ipmi_open_file_read((const char *)filename);
if (fp == NULL) {
lprintf(LOG_ERR, "Unable to open password file %s",
filename);
return NULL;
printf(" event to BMC\n");
req.msg.netfn = IPMI_NETFN_SE;
req.msg.cmd = 0x02;
req.msg.data = rqdata;
req.msg.data_len = 7;
rsp = intf->sendrecv(intf, &req);
if (!rsp || rsp->ccode) {
printf("Error:%x Platform Event Message Command\n", rsp?rsp->ccode:0);
return -1;
}
/* read in id */
if (fgets(pass, 16, fp) == NULL) {
lprintf(LOG_ERR, "Unable to read password from file %s",
filename);
fclose(fp);
return NULL;
}
/* remove trailing whitespace */
l = strcspn(pass, " \r\n\t");
if (l > 0) {
pass[l] = '\0';
}
fclose(fp);
return pass;
return 0;
}
int
main(int argc, char ** argv)
int main(int argc, char ** argv)
{
int (*submain)(struct ipmi_intf *, int, char **);
struct ipmi_intf * intf = NULL;
uint8_t privlvl = 0;
uint8_t target_addr = 0;
uint8_t my_addr = 0;
int authtype = -1;
char * tmp = NULL;
char * hostname = NULL;
char * username = NULL;
char * password = NULL;
char * intfname = NULL;
char * progname = NULL;
char * oemtype = NULL;
int port = 0;
int cipher_suite_id = 3; /* See table 22-19 of the IPMIv2 spec */
int argflag, i;
int rc = -1;
char * hostname = NULL, * password = NULL, * username = NULL;
int argflag, i, rc=0, port = 623, pedantic = 0;
char intfname[32];
/* save program name */
progname = strrchr(argv[0], '/');
progname = ((progname == NULL) ? argv[0] : progname);
if (ipmi_intf_init() < 0)
exit(EXIT_FAILURE);
while ((argflag = getopt(argc, (char **)argv, OPTION_STRING)) != -1)
while ((argflag = getopt(argc, (char **)argv, "hVvcgI:H:P:U:p:")) != -1)
{
switch (argflag) {
case 'I':
intfname = strdup(optarg);
if (intfname == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
break;
case 'h':
ipmitool_usage();
rc = 0;
goto out_free;
usage();
break;
case 'V':
printf("%s version %s\n", progname, VERSION);
rc = 0;
goto out_free;
printf("ipmitool version %s\n", VERSION);
exit(EXIT_SUCCESS);
break;
case 'p':
port = atoi(optarg);
break;
case 'C':
cipher_suite_id = atoi(optarg);
case 'g':
pedantic = 1;
break;
case 'v':
verbose++;
@ -300,247 +279,147 @@ main(int argc, char ** argv)
case 'c':
csv_output = 1;
break;
case 'I':
memset(intfname, 0, sizeof(intfname));
i = snprintf(intfname, sizeof(intfname), "intf_%s", optarg);
intf = ipmi_intf_load(intfname);
if (!intf) {
printf("Error loading interface %s\n", optarg);
exit(EXIT_FAILURE);
}
break;
case 'H':
hostname = strdup(optarg);
if (hostname == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
break;
case 'f':
if (password)
free(password);
password = ipmi_password_file_read(optarg);
if (password == NULL)
lprintf(LOG_ERR, "Unable to read password "
"from file %s", optarg);
break;
case 'a':
#ifdef HAVE_GETPASSPHRASE
tmp = getpassphrase("Password: ");
#else
tmp = getpass("Password: ");
#endif
if (tmp != NULL) {
if (password)
free(password);
password = strdup(tmp);
if (password == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
}
case 'P':
password = strdup(optarg);
break;
case 'U':
username = strdup(optarg);
if (username == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
break;
#ifndef __sun /* some options not enabled on solaris yet */
case 'o':
oemtype = strdup(optarg);
if (oemtype == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
if (strncmp(oemtype, "list", 4) == 0) {
ipmi_oem_print();
goto out_free;
}
case 'p':
port = atoi(optarg);
break;
case 'g':
/* backwards compatible oem hack */
oemtype = strdup("intelwv2");
break;
case 's':
/* backwards compatible oem hack */
oemtype = strdup("supermicro");
break;
case 'P':
if (password)
free(password);
password = strdup(optarg);
if (password == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
/* Prevent password snooping with ps */
i = strlen(optarg);
memset(optarg, 'X', i);
break;
case 'E':
if ((tmp = getenv("IPMITOOL_PASSWORD")))
{
if (password)
free(password);
password = strdup(tmp);
if (password == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
}
else if ((tmp = getenv("IPMI_PASSWORD")))
{
if (password)
free(password);
password = strdup(tmp);
if (password == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
goto out_free;
}
}
else {
lprintf(LOG_WARN, "Unable to read password from environment");
}
break;
case 'L':
privlvl = (uint8_t)str2val(optarg, ipmi_privlvl_vals);
if (!privlvl)
lprintf(LOG_WARN, "Invalid privilege level %s", optarg);
break;
case 'A':
authtype = (int)str2val(optarg, ipmi_authtype_session_vals);
break;
case 't':
target_addr = (uint8_t)strtol(optarg, NULL, 0);
break;
case 'm':
my_addr = (uint8_t)strtol(optarg, NULL, 0);
break;
#endif
default:
ipmitool_usage();
goto out_free;
usage();
}
}
/* check for command before doing anything */
if (argc-optind <= 0) {
lprintf(LOG_ERR, "No command provided!");
ipmitool_usage();
goto out_free;
}
if (strncmp(argv[optind], "help", 4) == 0) {
ipmi_cmd_print();
rc = 0;
goto out_free;
printf("No command provided!\n");
usage();
}
if (!intf) {
printf("No interface specified!\n");
usage();
}
intf->pedantic = pedantic;
/*
* If the user has specified a hostname (-H option)
* then this is a remote access session.
*
* If no password was specified by any other method
* and the authtype was not explicitly set to NONE
* then prompt the user.
*/
if (hostname != NULL && password == NULL &&
(authtype != IPMI_SESSION_AUTHTYPE_NONE || authtype < 0)) {
#ifdef HAVE_GETPASSPHRASE
tmp = getpassphrase("Password: ");
#else
tmp = getpass("Password: ");
#endif
if (tmp != NULL) {
password = strdup(tmp);
if (password == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
if (!strncmp(argv[optind], "help", 4)) {
printf("Commands: bmc, chaninfo, chassis, event, fru, lan, raw, sdr, sel, sensor, sol, userinfo\n");
goto out_free;
}
else if (!strncmp(argv[optind], "event", 5)) {
if (argc-optind-1 > 0) {
unsigned char c = (unsigned char)strtol(argv[optind+1], NULL, 0);
if (intf->open(intf, hostname, port, username, password) < 0)
goto out_free;
}
}
}
/* if no interface was specified but a
* hostname was then use LAN by default
* otherwise the default is hardcoded
* to use the first entry in the list
*/
if (intfname == NULL && hostname != NULL) {
intfname = strdup("lan");
if (intfname == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
ipmi_send_platform_event(intf, c);
goto out_close;
} else {
printf("event <num>\n");
goto out_free;
}
}
/* load interface */
intf = ipmi_intf_load(intfname);
if (intf == NULL) {
lprintf(LOG_ERR, "Error loading interface %s", intfname);
else if (!strncmp(argv[optind], "bmc", 3)) {
submain = ipmi_bmc_main;
}
else if (!strncmp(argv[optind], "chassis", 7)) {
submain = ipmi_chassis_main;
}
else if (!strncmp(argv[optind], "fru", 3)) {
submain = ipmi_fru_main;
}
else if (!strncmp(argv[optind], "lan", 3)) {
submain = ipmi_lanp_main;
}
else if (!strncmp(argv[optind], "sdr", 3)) {
submain = ipmi_sdr_main;
}
else if (!strncmp(argv[optind], "sel", 3)) {
submain = ipmi_sel_main;
}
else if (!strncmp(argv[optind], "sensor", 6)) {
submain = ipmi_sensor_main;
}
else if (!strncmp(argv[optind], "sol", 3)) {
submain = ipmi_sol_main;
}
else if (!strncmp(argv[optind], "raw", 3)) {
submain = ipmi_raw_main;
}
else if (!strncmp(argv[optind], "userinfo", 8)) {
if (argc-optind-1 > 0) {
unsigned char c = (unsigned char)strtol(argv[optind+1], NULL, 0);
rc = intf->open(intf, hostname, port, username, password);
if (rc < 0)
goto out_free;
ipmi_get_user_access(intf, c, 1);
goto out_close;
}
else {
printf("userinfo <channel>\n");
goto out_free;
}
}
else if (!strncmp(argv[optind], "chaninfo", 8)) {
if (argc-optind-1 > 0) {
unsigned char c = (unsigned char)strtol(argv[optind+1], NULL, 0);
rc = intf->open(intf, hostname, port, username, password);
if (rc < 0)
goto out_free;
verbose++;
ipmi_get_channel_info(intf, c);
verbose--;
goto out_close;
}
else {
printf("chaninfo <channel>\n");
goto out_free;
}
}
else {
printf("Invalid comand: %s\n", argv[optind]);
rc = -1;
goto out_free;
}
/* setup log */
log_init(progname, 0, verbose);
/* run OEM setup if found */
if (oemtype != NULL &&
ipmi_oem_setup(intf, oemtype) < 0) {
lprintf(LOG_ERR, "OEM setup for \"%s\" failed", oemtype);
if (!submain)
goto out_free;
if (intf->open) {
rc = intf->open(intf, hostname, port, username, password);
if (rc < 0)
goto out_free;
}
/* set session variables */
if (hostname != NULL)
ipmi_intf_session_set_hostname(intf, hostname);
if (username != NULL)
ipmi_intf_session_set_username(intf, username);
if (password != NULL)
ipmi_intf_session_set_password(intf, password);
if (port > 0)
ipmi_intf_session_set_port(intf, port);
if (authtype >= 0)
ipmi_intf_session_set_authtype(intf, (uint8_t)authtype);
if (privlvl > 0)
ipmi_intf_session_set_privlvl(intf, privlvl);
else
ipmi_intf_session_set_privlvl(intf,
IPMI_SESSION_PRIV_ADMIN); /* default */
rc = submain(intf, argc-optind-1, &(argv[optind+1]));
ipmi_intf_session_set_cipher_suite_id(intf, cipher_suite_id);
/* setup IPMB local and target address if given */
intf->my_addr = my_addr ? : IPMI_BMC_SLAVE_ADDR;
if (target_addr > 0) {
/* need to open the interface first */
if (intf->open != NULL)
intf->open(intf);
intf->target_addr = target_addr;
/* must be admin level to do this over lan */
ipmi_intf_session_set_privlvl(intf, IPMI_SESSION_PRIV_ADMIN);
}
/* now we finally run the command */
rc = ipmi_cmd_run(intf,
argv[optind],
argc-optind-1,
&(argv[optind+1]));
/* clean repository caches */
ipmi_cleanup(intf);
/* call interface close function if available */
if (intf->opened > 0 && intf->close != NULL)
out_close:
if (intf->close)
intf->close(intf);
out_free:
log_halt();
ipmi_intf_exit();
if (intfname != NULL)
free(intfname);
if (hostname != NULL)
out_free:
if (hostname)
free(hostname);
if (username != NULL)
if (username)
free(username);
if (password != NULL)
if (password)
free(password);
if (oemtype != NULL)
free(oemtype);
if (rc >= 0)
exit(EXIT_SUCCESS);

View File

@ -32,16 +32,18 @@
# in the design, construction, operation or maintenance of any nuclear
# facility.
MAINTAINERCLEANFILES = Makefile.in
plugindir = $(pluginpath)
INCLUDES = -I$(top_srcdir)/include
INCLUDES = -I$(top_srcdir)/include $(INCLTDL)
MAINTAINERCLEANFILES = Makefile.in ipmi_intf_static.c
EXTRA_DIST = ipmi_intf_static.c.in
SUBDIRS = @INTF_LAN@ @INTF_LANPLUS@ @INTF_OPEN@ @INTF_LIPMI@ @INTF_IMB@ @INTF_BMC@
DIST_SUBDIRS = lan lanplus open lipmi imb bmc
SUBDIRS = @INTF_LAN@ @INTF_OPEN@
DIST_SUBDIRS = lan open
noinst_LTLIBRARIES = libintf.la
libintf_la_SOURCES = ipmi_intf.c
libintf_la_SOURCES = ipmi_intf.c ipmi_intf_static.c
libintf_la_LDFLAGS = -export-dynamic
libintf_la_LIBADD = @IPMITOOL_INTF_LIB@
libintf_la_DEPENDENCIES = @IPMITOOL_INTF_LIB@
libintf_la_LIBADD = $(LIBLTDL) @STATIC_INTF_LIB@
libintf_la_DEPENDENCIES = $(LIBLTDL) @STATIC_INTF_LIB@

View File

@ -1,45 +0,0 @@
# Copyright (c) 2004 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.
#
# You acknowledge that this software is not designed or intended for use
# in the design, construction, operation or maintenance of any nuclear
# facility.
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_srcdir)/include
EXTRA_LTLIBRARIES = libintf_bmc.la
noinst_LTLIBRARIES = @INTF_BMC_LIB@
libintf_bmc_la_LIBADD = $(top_builddir)/lib/libipmitool.la
libintf_bmc_la_SOURCES = \
bmc.c bmc.h \
bmc_intf.h

View File

@ -1,349 +0,0 @@
/*
* Copyright (c) 2004 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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
/*
* interface routines between ipmitool and the bmc kernel driver
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stropts.h>
#include <stddef.h>
#include <stropts.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include "bmc_intf.h"
#include "bmc.h"
static int curr_seq;
static int bmc_method(int fd, int *if_type);
struct ipmi_rs *(*sendrecv_fn)(struct ipmi_intf *, struct ipmi_rq *) = NULL;
extern int verbose;
static void dump_request(bmc_req_t *request);
static void dump_response(bmc_rsp_t *response);
static struct ipmi_rs *ipmi_bmc_send_cmd_ioctl(struct ipmi_intf *intf,
struct ipmi_rq *req);
static struct ipmi_rs *ipmi_bmc_send_cmd_putmsg(struct ipmi_intf *intf,
struct ipmi_rq *req);
#define MESSAGE_BUFSIZE 1024
struct ipmi_intf ipmi_bmc_intf = {
name: "bmc",
desc: "IPMI v2.0 BMC interface",
open: ipmi_bmc_open,
close: ipmi_bmc_close,
sendrecv: ipmi_bmc_send_cmd};
void
ipmi_bmc_close(struct ipmi_intf *intf)
{
if (intf && intf->fd >= 0)
close(intf->fd);
intf->opened = 0;
intf->fd = -1;
}
int
ipmi_bmc_open(struct ipmi_intf *intf)
{
int method;
if (!intf)
return -1;
/* Open local device */
intf->fd = open(BMC_DEV, O_RDWR);
if (intf->fd <= 0) {
perror("Could not open bmc device");
return (-1);
}
curr_seq = 0;
intf->opened = 1;
if (bmc_method(intf->fd, &method) < 0) {
perror("Could not determine bmc messaging interface");
return (-1);
}
sendrecv_fn = (method == BMC_PUTMSG_METHOD) ?
ipmi_bmc_send_cmd_putmsg : ipmi_bmc_send_cmd_ioctl;
return (intf->fd);
}
struct ipmi_rs *
ipmi_bmc_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
{
/* If not already opened open the device or network connection */
if (!intf->opened && intf->open && intf->open(intf) < 0)
return NULL;
/* sendrecv_fn cannot be NULL at this point */
return ((*sendrecv_fn)(intf, req));
}
static struct ipmi_rs *
ipmi_bmc_send_cmd_ioctl(struct ipmi_intf *intf, struct ipmi_rq *req)
{
struct strioctl istr;
static struct bmc_reqrsp reqrsp;
static struct ipmi_rs rsp;
memset(&reqrsp, 0, sizeof (reqrsp));
reqrsp.req.fn = req->msg.netfn;
reqrsp.req.lun = 0;
reqrsp.req.cmd = req->msg.cmd;
reqrsp.req.datalength = req->msg.data_len;
memcpy(reqrsp.req.data, req->msg.data, req->msg.data_len);
reqrsp.rsp.datalength = RECV_MAX_PAYLOAD_SIZE;
istr.ic_cmd = IOCTL_IPMI_KCS_ACTION;
istr.ic_timout = 0;
istr.ic_dp = (char *)&reqrsp;
istr.ic_len = sizeof (struct bmc_reqrsp);
if (verbose) {
printf("--\n");
dump_request(&reqrsp.req);
printf("--\n");
}
if (ioctl(intf->fd, I_STR, &istr) < 0) {
perror("BMC IOCTL: I_STR");
return (NULL);
}
if (verbose > 2) {
dump_response(&reqrsp.rsp);
printf("--\n");
}
memset(&rsp, 0, sizeof (struct ipmi_rs));
rsp.ccode = reqrsp.rsp.ccode;
rsp.data_len = reqrsp.rsp.datalength;
/* Decrement for sizeof lun, cmd and ccode */
rsp.data_len -= 3;
if (!rsp.ccode && (rsp.data_len > 0))
memcpy(rsp.data, reqrsp.rsp.data, rsp.data_len);
return (&rsp);
}
static struct ipmi_rs *
ipmi_bmc_send_cmd_putmsg(struct ipmi_intf *intf, struct ipmi_rq *req)
{
struct strbuf sb;
int flags = 0;
static uint32_t msg_seq = 0;
/*
* The length of the message structure is equal to the size of the
* bmc_req_t structure, PLUS any additional data space in excess of
* the data space already reserved in the data member + <n> for
* the rest of the members in the bmc_msg_t structure.
*/
int msgsz = offsetof(bmc_msg_t, msg) + sizeof(bmc_req_t) +
((req->msg.data_len > SEND_MAX_PAYLOAD_SIZE) ?
(req->msg.data_len - SEND_MAX_PAYLOAD_SIZE) : 0);
bmc_msg_t *msg = malloc(msgsz);
bmc_req_t *request = (bmc_req_t *)&msg->msg[0];
bmc_rsp_t *response;
static struct ipmi_rs rsp;
struct ipmi_rs *ret = NULL;
msg->m_type = BMC_MSG_REQUEST;
msg->m_id = msg_seq++;
request->fn = req->msg.netfn;
request->lun = 0;
request->cmd = req->msg.cmd;
request->datalength = req->msg.data_len;
memcpy(request->data, req->msg.data, req->msg.data_len);
sb.len = msgsz;
sb.buf = (unsigned char *)msg;
if (verbose) {
printf("--\n");
dump_request(request);
printf("--\n");
}
if (putmsg(intf->fd, NULL, &sb, 0) < 0) {
perror("BMC putmsg: ");
free(msg);
return (NULL);
}
free(msg);
sb.buf = malloc(MESSAGE_BUFSIZE);
sb.maxlen = MESSAGE_BUFSIZE;
if (getmsg(intf->fd, NULL, &sb, &flags) < 0) {
perror("BMC getmsg: ");
free(sb.buf);
return (NULL);
}
msg = (bmc_msg_t *)sb.buf;
if (verbose > 3) {
printf("Got msg (id 0x%x) type 0x%x\n", msg->m_id, msg->m_type);
}
/* Did we get an error back from the stream? */
switch (msg->m_type) {
case BMC_MSG_RESPONSE:
response = (bmc_rsp_t *)&msg->msg[0];
if (verbose > 2) {
dump_response(response);
printf("--\n");
}
memset(&rsp, 0, sizeof (struct ipmi_rs));
rsp.ccode = response->ccode;
rsp.data_len = response->datalength;
if (!rsp.ccode && (rsp.data_len > 0))
memcpy(rsp.data, response->data, rsp.data_len);
ret = &rsp;
break;
case BMC_MSG_ERROR:
/* In case of an error, msg->msg[0] has the error code */
printf("bmc_send_cmd: %s\n", strerror(msg->msg[0]));
break;
}
free(sb.buf);
return (ret);
}
/*
* Determine which interface to use. Returns the interface method
* to use.
*/
static int
bmc_method(int fd, int *if_type)
{
struct strioctl istr;
int retval = 0;
uint8_t method = BMC_PUTMSG_METHOD;
istr.ic_cmd = IOCTL_IPMI_INTERFACE_METHOD;
istr.ic_timout = 0;
istr.ic_dp = (uint8_t *)&method;
istr.ic_len = 1;
/*
* If the ioctl doesn't exist, we should get an EINVAL back.
* Bail out on any other error.
*/
if (ioctl(fd, I_STR, &istr) < 0) {
if (errno != EINVAL)
retval = -1;
else
method = BMC_IOCTL_METHOD;
}
if (retval == 0)
*if_type = method;
return (retval);
}
static void
dump_request(bmc_req_t *request)
{
int i;
printf("BMC req.fn : 0x%x\n", request->fn);
printf("BMC req.lun : 0x%x\n", request->lun);
printf("BMC req.cmd : 0x%x\n", request->cmd);
printf("BMC req.datalength : 0x%x\n", request->datalength);
printf("BMC req.data : ");
if (request->datalength > 0) {
for (i = 0; i < request->datalength; i++)
printf("0x%x ", request->data[i]);
} else {
printf("<NONE>");
}
printf("\n");
}
static void
dump_response(bmc_rsp_t *response)
{
int i;
printf("BMC rsp.fn : 0x%x\n", response->fn);
printf("BMC rsp.lun : 0x%x\n", response->lun);
printf("BMC rsp.cmd : 0x%x\n", response->cmd);
printf("BMC rsp.ccode : 0x%x\n", response->ccode);
printf("BMC rsp.datalength : 0x%x\n", response->datalength);
printf("BMC rsp.data : ");
if (response->datalength > 0) {
for (i = 0; i < response->datalength; i++)
printf("0x%x ", response->data[i]);
} else {
printf("<NONE>");
}
printf("\n");
}

View File

@ -1,56 +0,0 @@
/*
* Copyright (c) 2004 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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef _IPMI_BMC_H_
#define _IPMI_BMC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <ipmitool/ipmi.h>
#define BMC_DEV "/dev/bmc"
struct ipmi_rs *ipmi_bmc_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req);
int ipmi_bmc_open(struct ipmi_intf *intf);
void ipmi_bmc_close(struct ipmi_intf *intf);
#ifdef __cplusplus
}
#endif
#endif /* _IPMI_BMC_H_ */

View File

@ -1,211 +0,0 @@
/*
* Copyright (c) 2004 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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef _BMC_INTF_H
#define _BMC_INTF_H
#pragma ident "@(#)bmc_intf.h 1.2 05/03/07 SMI"
#ifdef __cplusplus
extern "C" {
#endif
#define BMC_SUCCESS 0x0
#define BMC_FAILURE 0x1
#define BMC_NETFN_CHASSIS 0x0
#define BMC_NETFN_BRIDGE 0x2
#define BMC_NETFN_SE 0x4
#define BMC_NETFN_APP 0x6
#define BMC_NETFN_FIRMWARE 0x8
#define BMC_NETFN_STORAGE 0xa
#define BMC_NETFN_TRANSPORT 0xc
#define SEND_MAX_PAYLOAD_SIZE 34 /* MAX payload */
#define RECV_MAX_PAYLOAD_SIZE 33 /* MAX payload */
#define BMC_MIN_RESPONSE_SIZE 3
#define BMC_MIN_REQUEST_SIZE 2
#define BMC_MAX_RESPONSE_SIZE (BMC_MIN_RESPONSE_SIZE + RECV_MAX_PAYLOAD_SIZE)
#define BMC_MAX_REQUEST_SIZE (BMC_MIN_REQUEST_SIZE + BMC_MAX_RESPONSE_SIZE)
#define BUF_SIZE 256
#define MAX_BUF_SIZE 256
/*
* Useful macros
*/
#define FORM_NETFNLUN(net, lun) ((((net) << 2) | ((lun) & 0x3)))
#define GET_NETFN(netfn) (((netfn) >> 2) & 0x3f)
#define GET_LUN(netfn) (netfn & 0x3)
#define RESP_NETFN(nflun) ((nflun) | 1)
#define ISREQUEST(nl) (((nl) & 1) == 0) /* test for request */
#define ISRESPONSE(nl) (((nl) & 1) == 1) /* test for response */
/* for checking BMC specific stuff */
#define BMC_GET_DEVICE_ID 0x1 /* GET DEVICE ID COMMAND */
#define BMC_IPMI_15_VER 0x51 /* IPMI 1.5 definion */
/* BMC Completion Code and OEM Completion Code */
#define BMC_IPMI_UNSPECIFIC_ERROR 0xFF /* Unspecific Error */
#define BMC_IPMI_INVALID_COMMAND 0xC1 /* Invalid Command */
#define BMC_IPMI_COMMAND_TIMEOUT 0xC3 /* Command Timeout */
#define BMC_IPMI_DATA_LENGTH_EXCEED 0xC8 /* DataLength exceeded limit */
#define BMC_IPMI_OEM_FAILURE_SENDBMC 0x7E /* Cannot send BMC req */
#define IOCTL_IPMI_KCS_ACTION 0x01
#define IOCTL_IPMI_INTERFACE_METHOD 0x02
/* Interface methods returned from IOCTL_IPMI_INTERFACE_METHOD ioctl: */
#define BMC_IOCTL_METHOD 0 /* Not returned from ioctl, */
/* but can be used by */
/* applications that want to */
/* compare against an */
/* alternative method. */
#define BMC_PUTMSG_METHOD 1
/*
* bmc_req_t is the data structure to send
* request packet from applications to the driver
* module.
*
* the request pkt is mainly for KCS-interface-BMC
* messages. Since the system interface is session-less
* connections, the packet won't have any session
* information.
*
* the data payload will be 2 bytes less than max
* BMC supported packet size.
* the address of the responder is always BMC and so
* rsSa field is not required.
*/
typedef struct bmc_req {
uint8_t fn; /* netFn for command */
uint8_t lun; /* logical unit on responder */
uint8_t cmd; /* command */
uint8_t datalength; /* length of following data */
uint8_t data[SEND_MAX_PAYLOAD_SIZE]; /* request data */
} bmc_req_t;
/*
* bmc_rsp_t is the data structure to send
* respond packet from applications to the driver
* module.
*
* the respond pkt is mainly for KCS-interface-BMC
* messages. Since the system interface is session-less
* connections, the packet won't have any session
* information.
*
* the data payload will be 2 bytes less than max
* BMC supported packet size.
*/
typedef struct bmc_rsp {
uint8_t fn; /* netFn for command */
uint8_t lun; /* logical unit on responder */
uint8_t cmd; /* command */
uint8_t ccode; /* completion code */
uint8_t datalength; /* Length */
uint8_t data[RECV_MAX_PAYLOAD_SIZE]; /* response */
} bmc_rsp_t;
/*
* the data structure for synchronous operation via ioctl (DEPRECATED)
*/
typedef struct bmc_reqrsp {
bmc_req_t req; /* request half */
bmc_rsp_t rsp; /* response half */
} bmc_reqrsp_t;
/*
* The new way of communicating with the bmc driver is to use putmsg() to
* send a message of a particular type. Replies from the driver also have this
* form, and will require the user to process the type field before examining
* the rest of the reply.
*
* The only change that must be observed when using the request and response
* structures defined above is as follows:
* when sending messages to the bmc driver, the data portion is now variable
* (the caller must allocate enough space to store the all structure members,
* plus enough space to cover the amount of data in the request), e.g.:
*
* bmc_msg_t *msg = malloc(offsetof(bmc_msg_t, msg) + sizeof(bmc_req_t) + 10);
*
* The amount allocated for the message is (# of bytes before the msg field) +
* the size of a bmc_req_t (which includes SEND_MAX_PAYLOAD_SIZE
* bytes in the data field), plus an additional 10 bytes for the data
* field (so the data field would occupy (SEND_MAX_PAYLOAD_SIZE + 10)
* bytes). The datalength member must reflect the amount of data in the
* request's data field (as was required when using the ioctl interface).
*/
typedef struct bmc_msg {
uint8_t m_type; /* Message type (see below) */
uint32_t m_id; /* Message ID */
uint8_t reserved[32];
uint8_t msg[1]; /* Variable length message data */
} bmc_msg_t;
/*
* An error response passed back from the bmc driver will have its m_id
* field set to BMC_UNKNOWN_MSG_ID if a message is sent to it that is not
* at least as large as a bmc_msg_t.
*/
#define BMC_UNKNOWN_MSG_ID ~((uint32_t)0)
/*
* Possible values for the m_type field in bmc_msg_t:
*/
#define BMC_MSG_REQUEST 1 /* BMC request (as above, sent to the */
/* driver by the user), bmc_msg.msg */
/* begins with the bmc_req_t */
/* structure. */
#define BMC_MSG_RESPONSE 2 /* BMC response (sent by the driver) */
/* bmc_msg.msg begins with the */
/* bmc_rsp_t structure. */
#define BMC_MSG_ERROR 3 /* Error while processing a user msg */
/* msg[0] is the error code */
/* (interpret as an errno value) */
#ifdef __cplusplus
}
#endif
#endif /* _BMC_INTF_H */

View File

@ -1,43 +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.
#
# You acknowledge that this software is not designed or intended for use
# in the design, construction, operation or maintenance of any nuclear
# facility.
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_srcdir)/include
EXTRA_LTLIBRARIES = libintf_imb.la
noinst_LTLIBRARIES = @INTF_IMB_LIB@
libintf_imb_la_LIBADD = $(top_builddir)/lib/libipmitool.la
libintf_imb_la_SOURCES = imbapi.c imbapi.h imb.c

View File

@ -1,133 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/helper.h>
#include "imbapi.h"
#define IPMI_IMB_TIMEOUT (1000 * 1000)
#define IPMI_IMB_MAX_RETRY 3
#define IPMI_IMB_DEV "/dev/imb"
#define IPMI_IMB_BUF_SIZE 64
extern int verbose;
static int ipmi_imb_open(struct ipmi_intf * intf)
{
struct stat stbuf;
if (stat(IPMI_IMB_DEV, &stbuf) < 0) {
printf("Error: no IMB driver found at %s!\n", IPMI_IMB_DEV);
return -1;
}
intf->opened = 1;
return 0;
}
static void ipmi_imb_close(struct ipmi_intf * intf)
{
intf->opened = 0;
}
static struct ipmi_rs * ipmi_imb_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
{
IMBPREQUESTDATA imbreq;
static struct ipmi_rs rsp;
int status, i;
unsigned char ccode;
imbreq.rsSa = IPMI_BMC_SLAVE_ADDR;
imbreq.rsLun = 0;
imbreq.busType = 0;
imbreq.netFn = req->msg.netfn;
imbreq.cmdType = req->msg.cmd;
imbreq.data = req->msg.data;
imbreq.dataLength = req->msg.data_len;
if (verbose > 1) {
printf("IMB rsSa : %x\n", imbreq.rsSa);
printf("IMB netFn : %x\n", imbreq.netFn);
printf("IMB cmdType : %x\n", imbreq.cmdType);
printf("IMB dataLength : %d\n", imbreq.dataLength);
}
rsp.data_len = IPMI_IMB_BUF_SIZE;
memset(rsp.data, 0, rsp.data_len);
for (i=0; i<IPMI_IMB_MAX_RETRY; i++) {
if (verbose > 2)
printbuf(imbreq.data, imbreq.dataLength, "ipmi_imb request");
status = SendTimedImbpRequest(&imbreq, IPMI_IMB_TIMEOUT,
rsp.data, &rsp.data_len, &ccode);
if (status == 0) {
if (verbose > 2)
printbuf(rsp.data, rsp.data_len, "ipmi_imb response");
break;
}
/* error */
printf("Error sending IMB request, status=%x ccode=%x\n",
status, ccode);
}
rsp.ccode = ccode;
return &rsp;
}
struct ipmi_intf ipmi_imb_intf = {
name: "imb",
desc: "Intel IMB Interface",
open: ipmi_imb_open,
close: ipmi_imb_close,
sendrecv: ipmi_imb_send_cmd,
target_addr: IPMI_BMC_SLAVE_ADDR,
};

File diff suppressed because it is too large Load Diff

View File

@ -1,652 +0,0 @@
/*M*
// PVCS:
// $Workfile: imb_api.h $
// $Revision: 1.2 $
// $Modtime: Jul 22 2002 16:40:32 $
// $Author: iceblink $
//
// Combined include files needed for imbapi.c
//
*M*/
/*----------------------------------------------------------------------*
The BSD License
Copyright (c) 2002, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
a.. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
b.. Redistributions 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.
c.. Neither the name of Intel Corporation nor the names of its 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
*----------------------------------------------------------------------*/
#ifndef _WINDEFS_H
#define _WINDEFS_H
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef WIN32
/* WIN32 defines this in stdio.h */
#ifndef _WCHAR_T
#define _WCHAR_T
typedef long wchar_t;
#endif
#endif
#define far
#define near
#define FAR far
#define NEAR near
#ifndef CONST
#define CONST const
#endif
typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef float FLOAT;
typedef FLOAT *PFLOAT;
typedef BOOL near *PBOOL;
typedef BOOL far *LPBOOL;
typedef BYTE near *PBYTE;
typedef BYTE far *LPBYTE;
typedef int near *PINT;
typedef int far *LPINT;
typedef WORD near *PWORD;
typedef WORD far *LPWORD;
typedef long far *LPLONG;
typedef DWORD near *PDWORD;
typedef DWORD far *LPDWORD;
typedef void far *LPVOID;
typedef CONST void far *LPCVOID;
typedef int INT;
typedef unsigned int UINT;
typedef unsigned int *PUINT;
typedef DWORD NTSTATUS;
/*
File structures
*/
#ifndef WIN32
typedef struct _OVERLAPPED {
DWORD Internal;
DWORD InternalHigh;
DWORD Offset;
DWORD OffsetHigh;
/* HANDLE hEvent; */
} OVERLAPPED, *LPOVERLAPPED;
#endif
/*
* Data structure redefines
*/
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
typedef char * PCHAR;
typedef short * PSHORT;
typedef long * PLONG;
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
typedef unsigned char * PUCHAR;
typedef unsigned short * PUSHORT;
typedef unsigned long * PULONG;
typedef char CCHAR;
typedef short CSHORT;
typedef ULONG CLONG;
typedef CCHAR * PCCHAR;
typedef CSHORT * PCSHORT;
typedef CLONG * PCLONG;
typedef void * PVOID;
#ifndef WIN32
typedef void VOID;
typedef struct _LARGE_INTEGER {
ULONG LowPart;
LONG HighPart;
} LARGE_INTEGER;
typedef struct _ULARGE_INTEGER {
ULONG LowPart;
ULONG HighPart;
} ULARGE_INTEGER;
#endif
typedef LARGE_INTEGER * PLARGE_INTEGER;
typedef LARGE_INTEGER PHYSICAL_ADDRESS;
typedef LARGE_INTEGER * PPHYSICAL_ADDRESS;
typedef ULARGE_INTEGER * PULARGE_INTEGER;
typedef UCHAR BOOLEAN;
typedef BOOLEAN *PBOOLEAN;
typedef wchar_t WCHAR;
typedef WCHAR *PWCHAR, *PWSTR;
typedef CONST WCHAR *LPCWSTR, *PCWSTR;
#ifndef _SYS_TYPES_H
#ifndef _CADDR_T
#define _CADDR_T
typedef char * caddr_t;
#endif
#endif
/*
Unicode strings are counted 16-bit character strings. If they are
NULL terminated, Length does not include trailing NULL.
*/
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING;
typedef UNICODE_STRING *PUNICODE_STRING;
#define UNICODE_NULL ((WCHAR)0) /* winnt*/
#define IN /* */
#define OUT /* */
#define OPTIONAL /* */
#ifndef WIN32
#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
#define UNREFERENCED_PARAMETER(x)
typedef int HANDLE;
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
#endif
typedef HANDLE *PHANDLE;
/*
Define the method codes for how buffers are passed for I/O and FS controls
*/
#define METHOD_BUFFERED 0
/*
Define the access check value for any access
The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
constants *MUST* always be in sync.
*/
#define FILE_ANY_ACCESS 0
/*
These are the generic rights.
*/
#define MAX_PATH 260
#define GetLastError() (NTstatus.Status)
/*
Macro definition for defining IOCTL and FSCTL function control codes. Note
that function codes 0-2047 are reserved for Microsoft Corporation, and
2048-4095 are reserved for customers.
*/
/*
* Linux drivers expect ioctls defined using macros defined in ioctl.h.
* So, instead of using the CTL_CODE defined for NT and UW, I define CTL_CODE
* using these macros. That way imb_if.h, where the ioctls are defined get
* to use the correct ioctl command we expect.
* Notes: I am using the generic _IO macro instead of the more specific
* ones. The macros expect 8bit entities, so I am cleaning what is sent to
* us from imb_if.h - Mahendra
*/
#ifndef WIN32
#define CTL_CODE(DeviceType, Function, Method, Access)\
_IO(DeviceType & 0x00FF, Function & 0x00FF)
#else
#define CTL_CODE( DeviceType, Function, Method, Access ) ((ULONG)( \
((ULONG)(DeviceType) << 16) | ((ULONG)(Access) << 14) | ((ULONG)(Function) << 2) | ((ULONG)Method) \
))
#endif
#endif /*_WINDEFS_H */
/*----------------------------------------------------------------------*/
#ifndef _SMI_H
#define _SMI_H
#define SMI_Version1_00 0x00001000
struct smi {
DWORD smi_VersionNo;
DWORD smi_Reserved1;
DWORD smi_Reserved2;
LPVOID ntstatus; /* address of NT status block*/
LPVOID lpvInBuffer; /* address of buffer for input data*/
DWORD cbInBuffer; /* size of input buffer*/
LPVOID lpvOutBuffer; /* address of output buffer*/
DWORD cbOutBuffer; /* size of output buffer*/
LPDWORD lpcbBytesReturned; /* address of actual bytes of output*/
LPOVERLAPPED lpoOverlapped; /* address of overlapped structure*/
};
#ifndef STATUS_SUCCESS
typedef struct _IO_STATUS_BLOCK {
ULONG Status;
ULONG Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
/*
* I2C ioctl's return NTStatus codes
*/
#define STATUS_SUCCESS (0x00000000U)
#define STATUS_UNSUCCESSFUL (0xC0000001U)
#define STATUS_DEVICE_BUSY (0x80000011U)
#ifndef WIN32
#define STATUS_PENDING (0x00000103U)
// see <win2000ddk>\inc\winnt.h(1171)
#endif
#define STATUS_INVALID_PARAMETER (0xC000000DU)
#define STATUS_INVALID_DEVICE_REQUEST (0xC0000010U)
#define STATUS_BUFFER_TOO_SMALL (0xC0000023U)
#define STATUS_FILE_CLOSED (0xC0000128U)
#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AU)
#define STATUS_NO_DATA_DETECTED (0x80000022U)
#define STATUS_NO_SUCH_DEVICE (0xC000000EU)
#define STATUS_ALLOTTED_EXCEEDED (0xC000000FU)
#define STATUS_IO_DEVICE_ERROR (0xC0000185U)
#define STATUS_TOO_MANY_OPEN_FILES (0xC000011FU)
#define STATUS_ACCESS_DENIED (0xC0000022U)
#define STATUS_BUFFER_OVERFLOW (0x80000005U)
#define STATUS_CANCELLED (0xC0000120U)
#endif /* STATUS_SUCCESS*/
#endif /* _SMI_H*/
/*----------------------------------------------------------------------*/
#ifndef IMB_IF__
#define IMB_IF__
/*
* This is the structure passed in to the IOCTL_IMB_SHUTDOWN_CODE request
*/
typedef struct {
int code;
int delayTime;
} ShutdownCmdBuffer;
#define SD_NO_ACTION 0
#define SD_RESET 1
#define SD_POWER_OFF 2
#pragma pack(1)
/*
* This is the generic IMB packet format, the final checksum cant be
* represented in this structure and will show up as the last data byte
*/
typedef struct {
BYTE rsSa;
BYTE nfLn;
BYTE cSum1;
BYTE rqSa;
BYTE seqLn;
BYTE cmd;
BYTE data[1];
} ImbPacket;
#define MIN_IMB_PACKET_SIZE 7
#define MAX_IMB_PACKET_SIZE 33
/*
* This is the standard IMB response format where the first byte of
* IMB packet data is interpreted as a command completion code.
*/
typedef struct {
BYTE rsSa;
BYTE nfLn;
BYTE cSum1;
BYTE rqSa;
BYTE seqLn;
BYTE cmd;
BYTE cCode;
BYTE data[1];
} ImbRespPacket;
#define MIN_IMB_RESPONSE_SIZE 7 /* min packet + completion code */
#define MAX_IMB_RESPONSE_SIZE MAX_IMB_PACKET_SIZE
/************************
* ImbRequestBuffer
************************/
/*D*
// Name: ImbRequestBuffer
// Purpose: Structure definition for holding IMB message data
// Context: Used by SendTimedImbpMessage and SendTimedI2cMessge
// functions in the library interface. In use, it is overlayed on a
// char buffer of size MIN_IMB_REQ_BUF_SIZE +
// Fields:
// respBufSize size of the response buffer
//
// timeout timeout value in milli seconds
//
// req body of request to send
//
*D*/
typedef struct {
BYTE rsSa;
BYTE cmd;
BYTE netFn;
BYTE rsLun;
BYTE dataLength;
BYTE data[1];
} ImbRequest;
typedef struct {
DWORD flags; /* request flags*/
#define NO_RESPONSE_EXPECTED 0x01 /*dont wait around for an IMB response*/
DWORD timeOut; /* in uSec units*/
ImbRequest req; /* message buffer*/
} ImbRequestBuffer;
#define MIN_IMB_REQ_BUF_SIZE 13 /* a buffer without any request data*/
/************************
* ImbResponseBuffer
************************/
/*D*
// Name: ImbResponseBuffer
// Purpose: Structure definition for response of a previous send
// Context: Used by DeviceIoControl to pass the message to be sent to
// MISSMIC port
// Fields:
// cCode completion code returned by firmware
// data buffer for response data from firmware
*D*/
typedef struct {
BYTE cCode;
BYTE data[1];
} ImbResponseBuffer;
#define MIN_IMB_RESP_BUF_SIZE 1
#define MAX_IMB_RESP_SIZE (MIN_IMB_RESP_BUF_SIZE + MAX_IMB_RESPONSE_SIZE)
#pragma pack()
/*
* Async message access structures and types
*/
typedef DWORD ImbAsyncSeq;
/*
* This is the structure passed in to IOCTL_IMB_GET_ASYNC_MSG
*/
typedef struct {
DWORD timeOut;
ImbAsyncSeq lastSeq;
} ImbAsyncRequest;
#define ASYNC_SEQ_START 0
typedef struct {
ImbAsyncSeq thisSeq;
BYTE data[1];
} ImbAsyncResponse;
#define MIN_ASYNC_RESP_SIZE sizeof( ImbAsyncSeq )
#define MAX_ASYNC_RESP_SIZE (MIN_ASYNC_RESP_SIZE + MAX_IMB_PACKET_SIZE)
/*
** Driver Ioctls
** In Linux, these calculate to:
** IOCTL_IMB_SEND_MESSAGE =1082
** IOCTL_IMB_GET_ASYNC_MSG =1088
** IOCTL_IMB_MAP_MEMORY =108e
** IOCTL_IMB_UNMAP_MEMORY =1090
** IOCTL_IMB_SHUTDOWN_CODE =1092
** IOCTL_IMB_REGISTER_ASYNC_OBJ =1098
** IOCTL_IMB_DEREGISTER_ASYNC_OBJ=109a
** IOCTL_IMB_CHECK_EVENT =109c
** IOCTL_IMB_POLL_ASYNC =1094
*/
#define FILE_DEVICE_IMB 0x00008010
#define IOCTL_IMB_BASE 0x00000880
#define IOCTL_IMB_SEND_MESSAGE CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 2), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_GET_ASYNC_MSG CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 8), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_MAP_MEMORY CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 14), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_UNMAP_MEMORY CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 16), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_SHUTDOWN_CODE CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 18), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_REGISTER_ASYNC_OBJ CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 24), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_DEREGISTER_ASYNC_OBJ CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 26), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_CHECK_EVENT CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 28), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_IMB_POLL_ASYNC CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 20), METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif /* IMB_IF__ */
/*----------------------------------------------------------------------*/
/* No asynchronous messages available */
#define IMB_MSG_NOT_AVAILABLE ((NTSTATUS)0xE0070012L)
#ifdef IMBLOG_H__
/* Define the facility codes */
#define FACILITY_RPC_STUBS 0x3
#define FACILITY_RPC_RUNTIME 0x2
#define FACILITY_IO_ERROR_CODE 0x4
#define IMB_IO_ERROR_CODE 0x7
#define STATUS_SEVERITY_WARNING 0x2
#define STATUS_SEVERITY_SUCCESS 0x0
#define STATUS_SEVERITY_INFORMATIONAL 0x1
#define STATUS_SEVERITY_ERROR 0x3
/* Not enough memory for internal storage of device %1. */
#define INSUFFICIENT_RESOURCES ((NTSTATUS)0xE0070001L)
#define INVALID_INPUT_BUFFER ((NTSTATUS)0xE0070002L)
#define INVALID_OUTPUT_BUFFER ((NTSTATUS)0xE0070003L)
#define IMB_SEND_TIMEOUT ((NTSTATUS)0xE0070004L)
#define IMB_RECEIVE_TIMEOUT ((NTSTATUS)0xE0070005L)
#define IMB_IF_SEND_TIMEOUT ((NTSTATUS)0xE0070006L)
#define IMB_IF_RECEIVE_TIMEOUT ((NTSTATUS)0xE0040007L)
#define HARDWARE_FAILURE ((NTSTATUS)0xE0040008L)
#define DRIVER_FAILURE ((NTSTATUS)0xE0040009L)
#define IMB_INVALID_IF_RESPONSE ((NTSTATUS)0xE004000AL)
#define IMB_INVALID_PACKET ((NTSTATUS)0xE004000BL)
#define IMB_RESPONSE_DATA_OVERFLOW ((NTSTATUS)0xE004000CL)
#define IMB_INVALID_REQUEST ((NTSTATUS)0xE007000DL)
#define INVALID_DRIVER_IOCTL ((NTSTATUS)0xE007000EL)
#define INVALID_DRIVER_REQUEST ((NTSTATUS)0xE007000FL)
#define IMB_CANT_GET_SMS_BUFFER ((NTSTATUS)0xE0070010L)
#define INPUT_BUFFER_TOO_SMALL ((NTSTATUS)0xE0070011L)
#define IMB_SEND_ERROR ((NTSTATUS)0xE0070013L)
#endif /* IMBLOG_H__ */
/*----------------------------------------------------------------------*/
#ifndef IMBAPI_H__
#define IMBAPI_H__
#include <sys/types.h>
#define WRITE_READ_I2C 0x52
#define WRITE_EMP_BUFFER 0x7a
#define GET_DEVICE_ID 0x1
#define SEND_MESSAGE 0x34
#define BMC_SA 0x20
#define BMC_LUN 0
#define APP_NETFN 0x06
#define IPMI_09_VERSION 0x90
#define IPMI_10_VERSION 0x01
#define IPMI_15_VERSION 0x51
#ifndef IPMI10_GET_DEVICE_ID_RESP_LENGTH
#define IPMI10_GET_DEVICE_ID_RESP_LENGTH 12
#endif
#define IPMB_CHANNEL 0x0
#define EMP_CHANNEL 0x1
#define LAN_CHANNEL 0x2
#define RESERVED_LUN 0x3
#define IPMB_LUN 0x2
#define EMP_LUN 0x0
#define PUBLIC_BUS 0
#define BMC_CONTROLLER 0x20
#define FPC_CONTROLLER 0x22
typedef enum {
ACCESN_OK,
ACCESN_ERROR,
ACCESN_OUT_OF_RANGE,
ACCESN_END_OF_DATA,
ACCESN_UNSUPPORTED,
ACCESN_INVALID_TRANSACTION,
ACCESN_TIMED_OUT
} ACCESN_STATUS;
#pragma pack(1)
/*
* Request structure provided to SendTimedImbpRequest()
*/
typedef struct {
unsigned char cmdType;
unsigned char rsSa;
unsigned char busType;
unsigned char netFn;
unsigned char rsLun;
unsigned char * data;
int dataLength;
} IMBPREQUESTDATA;
/*
* Request structure provided to SendTimedI2cRequest()
*/
typedef struct {
unsigned char rsSa;
unsigned char busType;
unsigned char numberOfBytesToRead;
unsigned char * data;
int dataLength;
} I2CREQUESTDATA;
#pragma pack()
/*#ifdef IMB_API
*
* This section is provided to be able to compile using imb_if.h
*
*
* function return type. This is also defined in the local instrumentation
* so we ifdef here to avoid conflict.
*/
#define METHOD_BUFFERED 0
#define FILE_ANY_ACCESS 0
/*
* This is necessary to compile using memIf.h
*/
typedef enum _INTERFACE_TYPE
{
Internal,
Isa,
Eisa,
MicroChannel,
TurboChannel,
MaximumInterfaceType
} INTERFACE_TYPE, * PINTERFACE_TYPE;
#ifdef WIN32
/* From memIf.h */
#pragma pack(1)
typedef struct
{
INTERFACE_TYPE InterfaceType; // Isa, Eisa, etc....
ULONG BusNumber; // Bus number
PHYSICAL_ADDRESS BusAddress; // Bus-relative address
ULONG AddressSpace; // 0 is memory, 1 is I/O
ULONG Length; // Length of section to map
} PHYSICAL_MEMORY_INFO, * PPHYSICAL_MEMORY_INFO;
#pragma pack()
#endif
/*#else // not IMB_API */
/*
* These are defined in imb_if.h but are needed by users of the imbapi library
*/
#define ASYNC_SEQ_START 0
/*
* This is the generic IMB packet format, the final checksum cant be
* represented in this structure and will show up as the last data byte
*/
/*
#define MIN_IMB_PACKET_SIZE 7
#define MAX_IMB_PACKET_SIZE 33
*/
#define MAX_BUFFER_SIZE 64
/*#endif // IMB_API */
/******************************
* FUNCTION PROTOTYPES
******************************/
ACCESN_STATUS
SendTimedImbpRequest (
IMBPREQUESTDATA *reqPtr,
int timeOut,
BYTE * respDataPtr,
int * respDataLen,
BYTE * completionCode
);
ACCESN_STATUS
SendTimedI2cRequest (
I2CREQUESTDATA *reqPtr,
int timeOut,
BYTE * respDataPtr,
int * respDataLen,
BYTE * completionCode
);
ACCESN_STATUS
SendAsyncImbpRequest (
IMBPREQUESTDATA *reqPtr,
BYTE * seqNo
);
ACCESN_STATUS
GetAsyncImbpMessage (
ImbPacket * msgPtr,
DWORD * msgLen,
DWORD timeOut,
ImbAsyncSeq * seqNo,
DWORD channelNumber
);
ACCESN_STATUS
GetAsyncImbpMessage_Ex (
ImbPacket * msgPtr,
DWORD * msgLen,
DWORD timeOut,
ImbAsyncSeq * seqNo,
DWORD channelNumber,
BYTE * sessionHandle,
BYTE * privilege
);
ACCESN_STATUS
UnmapPhysicalMemory( int virtualAddress, int Length );
ACCESN_STATUS
StartAsyncMesgPoll(void);
ACCESN_STATUS
MapPhysicalMemory (
int startAddress,
int addressLength,
int *virtualAddress
);
ACCESN_STATUS
SetShutDownCode (
int delayTime,
int code
);
ACCESN_STATUS
SendTimedEmpMessageResponse (
ImbPacket * ptr,
char *responseDataBuf,
int responseDataLen,
int timeOut
);
ACCESN_STATUS
SendTimedEmpMessageResponse_Ex (
ImbPacket * ptr,
char *responseDataBuf,
int responseDataLen,
int timeOut,
BYTE sessionHandle,
BYTE channelNumber
);
ACCESN_STATUS
SendTimedLanMessageResponse (
ImbPacket * ptr,
char *responseDataBuf,
int responseDataLen,
int timeOut
);
ACCESN_STATUS
SendTimedLanMessageResponse_Ex (
ImbPacket * ptr,
char *responseDataBuf,
int responseDataLen,
int timeOut ,
BYTE sessionHandle,
BYTE channelNumber
);
ACCESN_STATUS
IsAsyncMessageAvailable (unsigned int eventId );
ACCESN_STATUS
RegisterForImbAsyncMessageNotification (unsigned int *handleId);
ACCESN_STATUS
UnRegisterForImbAsyncMessageNotification (unsigned int handleId,int iFlag);
BYTE GetIpmiVersion(void);
#endif /* IMBAPI_H__ */

View File

@ -36,199 +36,92 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ltdl.h>
#include <config.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
#include <ipmitool/log.h>
#ifdef IPMI_INTF_OPEN
extern struct ipmi_intf ipmi_open_intf;
#endif
#ifdef IPMI_INTF_IMB
extern struct ipmi_intf ipmi_imb_intf;
#endif
#ifdef IPMI_INTF_LIPMI
extern struct ipmi_intf ipmi_lipmi_intf;
#endif
#ifdef IPMI_INTF_BMC
extern struct ipmi_intf ipmi_bmc_intf;
#endif
#ifdef IPMI_INTF_LAN
extern struct ipmi_intf ipmi_lan_intf;
#endif
#ifdef IPMI_INTF_LANPLUS
extern struct ipmi_intf ipmi_lanplus_intf;
#endif
extern struct static_intf static_intf_list[];
struct ipmi_intf * ipmi_intf_table[] = {
#ifdef IPMI_INTF_OPEN
&ipmi_open_intf,
#endif
#ifdef IPMI_INTF_IMB
&ipmi_imb_intf,
#endif
#ifdef IPMI_INTF_LIPMI
&ipmi_lipmi_intf,
#endif
#ifdef IPMI_INTF_BMC
&ipmi_bmc_intf,
#endif
#ifdef IPMI_INTF_LAN
&ipmi_lan_intf,
#endif
#ifdef IPMI_INTF_LANPLUS
&ipmi_lanplus_intf,
#endif
NULL
};
/* ipmi_intf_print - Print list of interfaces
*
* no meaningful return code
/* ipmi_intf_init
* initialize dynamic plugin interface
*/
void ipmi_intf_print(void)
int ipmi_intf_init(void)
{
struct ipmi_intf ** intf;
int def = 1;
lprintf(LOG_NOTICE, "Interfaces:");
for (intf = ipmi_intf_table; intf && *intf; intf++) {
lprintf(LOG_NOTICE, "\t%-12s %s %s",
(*intf)->name, (*intf)->desc,
def ? "[default]" : "");
def = 0;
if (lt_dlinit() < 0) {
printf("ERROR: Unable to initialize ltdl\n");
return -1;
}
lprintf(LOG_NOTICE, "");
if (lt_dlsetsearchpath(PLUGIN_PATH) < 0) {
printf("ERROR: Unable to set ltdl plugin path to %s\n",
PLUGIN_PATH);
lt_dlexit();
return -1;
}
return 0;
}
/* ipmi_intf_load - Load an interface from the interface table above
* If no interface name is given return first entry
*
* @name: interface name to try and load
*
* returns pointer to inteface structure if found
* returns NULL on error
/* ipmi_intf_exit
* close dynamic plugin interface
*/
void ipmi_intf_exit(void)
{
if (lt_dlexit() < 0)
printf("ERROR: Unable to cleanly exit ltdl\n");
}
/* ipmi_intf_load
* name: interface plugin name to load
*/
struct ipmi_intf * ipmi_intf_load(char * name)
{
struct ipmi_intf ** intf;
struct ipmi_intf * i;
lt_dlhandle handle;
struct ipmi_intf * intf;
int (*setup)(struct ipmi_intf ** intf);
struct static_intf *i = static_intf_list;
char libname[16];
if (name == NULL) {
i = ipmi_intf_table[0];
if (i->setup != NULL && (i->setup(i) < 0)) {
lprintf(LOG_ERR, "Unable to setup "
"interface %s", name);
return NULL;
}
return i;
}
for (intf = ipmi_intf_table;
((intf != NULL) && (*intf != NULL));
intf++) {
i = *intf;
if (strncmp(name, i->name, strlen(name)) == 0) {
if (i->setup != NULL && (i->setup(i) < 0)) {
lprintf(LOG_ERR, "Unable to setup "
"interface %s", name);
while (i->name) {
if (!strcmp(name, i->name)) {
if (i->setup(&intf) < 0) {
printf("ERROR: Unable to setup static interface %s\n", name);
return NULL;
}
return i;
return intf;
}
i++;
}
return NULL;
}
void
ipmi_intf_session_set_hostname(struct ipmi_intf * intf, char * hostname)
{
if (intf->session == NULL)
return;
memset(intf->session->hostname, 0, 16);
if (hostname != NULL) {
memcpy(intf->session->hostname, hostname,
__min(strlen(hostname), 64));
}
}
void
ipmi_intf_session_set_username(struct ipmi_intf * intf, char * username)
{
if (intf->session == NULL)
return;
memset(intf->session->username, 0, 16);
if (username == NULL)
return;
memcpy(intf->session->username, username, __min(strlen(username), 16));
}
void
ipmi_intf_session_set_password(struct ipmi_intf * intf, char * password)
{
if (intf->session == NULL)
return;
memset(intf->session->authcode, 0, IPMI_AUTHCODE_BUFFER_SIZE);
if (password == NULL) {
intf->session->password = 0;
return;
memset(libname, 0, 16);
if (snprintf(libname, sizeof(libname), "lib%s", name) <= 0) {
printf("ERROR: Unable to find plugin '%s' in '%s'\n",
name, PLUGIN_PATH);
return NULL;
}
intf->session->password = 1;
memcpy(intf->session->authcode, password,
__min(strlen(password), IPMI_AUTHCODE_BUFFER_SIZE));
handle = lt_dlopenext(libname);
if (handle == NULL) {
printf("ERROR: Unable to find plugin '%s' in '%s'\n",
libname, PLUGIN_PATH);
return NULL;
}
setup = lt_dlsym(handle, "intf_setup");
if (!setup) {
printf("ERROR: Unable to find interface setup symbol in plugin %s\n", name);
lt_dlclose(handle);
return NULL;
}
if (setup(&intf) < 0) {
printf("ERROR: Unable to run interface setup for plugin %s\n", name);
lt_dlclose(handle);
return NULL;
}
return intf;
}
void
ipmi_intf_session_set_privlvl(struct ipmi_intf * intf, uint8_t level)
{
if (intf->session == NULL)
return;
intf->session->privlvl = level;
}
void
ipmi_intf_session_set_cipher_suite_id(struct ipmi_intf * intf, uint8_t cipher_suite_id)
{
if (intf->session == NULL)
return;
intf->session->cipher_suite_id = cipher_suite_id;
}
void
ipmi_intf_session_set_port(struct ipmi_intf * intf, int port)
{
if (intf->session == NULL)
return;
intf->session->port = port;
}
void
ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype)
{
if (intf->session == NULL)
return;
intf->session->authtype_set = authtype;
}
void
ipmi_cleanup(struct ipmi_intf * intf)
{
ipmi_sdr_list_empty(intf);
}

View File

@ -34,11 +34,16 @@
* facility.
*/
#ifndef IPMI_RAW_H
#define IPMI_RAW_H
#include <stdio.h>
#include <stdlib.h>
#include <config.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi.h>
int ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv);
@STATIC_INTF_EXT@
#endif /* IPMI_RAW_H */
struct static_intf static_intf_list[] = {
@STATIC_INTF@
{ 0, 0 }
};

View File

@ -32,12 +32,16 @@
# in the design, construction, operation or maintenance of any nuclear
# facility.
MAINTAINERCLEANFILES = Makefile.in
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_srcdir)/include
plugindir = $(pluginpath)
INCLUDES = -I$(top_srcdir)/include
EXTRA_LTLIBRARIES = libintf_lan.la
noinst_LTLIBRARIES = @INTF_LAN_LIB@
libintf_lan_la_LIBADD = $(top_builddir)/lib/libipmitool.la
libintf_lan_la_SOURCES = lan.c lan.h asf.h rmcp.h auth.c auth.h md5.c md5.h
plugin_LTLIBRARIES = @PLUGIN_INTF_LAN@
noinst_LTLIBRARIES = @STATIC_INTF_LAN@
libintf_lan_la_LDFLAGS = @LDFLAGS_INTF_LAN@
libintf_lan_la_LIBADD = $(top_srcdir)/lib/libipmitool.la
libintf_lan_la_SOURCES = lan.c lan.h asf.h rmcp.h md5.c md5.h

View File

@ -61,13 +61,13 @@ static const struct valstr asf_type_vals[] __attribute__((unused)) = {
/* ASF message header */
struct asf_hdr {
uint32_t iana;
uint8_t type;
uint8_t tag;
uint8_t __reserved;
uint8_t len;
unsigned long iana;
unsigned char type;
unsigned char tag;
unsigned char __reserved;
unsigned char len;
} __attribute__((packed));
int handle_asf(struct ipmi_intf * intf, uint8_t * data, int data_len);
int handle_asf(struct ipmi_intf * intf, unsigned char * data, int data_len);
#endif /* IPMI_ASF_H */

View File

@ -1,224 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <ipmitool/helper.h>
#include <ipmitool/bswap.h>
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_CRYPTO_MD2
# include <openssl/md2.h>
#endif
#ifdef HAVE_CRYPTO_MD5
# include <openssl/md5.h>
#else
# include "md5.h"
#endif
/*
* multi-session authcode generation for MD5
* H(password + session_id + msg + session_seq + password)
*
* Use OpenSSL implementation of MD5 algorithm if found
*/
uint8_t * ipmi_auth_md5(struct ipmi_session * s, uint8_t * data, int data_len)
{
#ifdef HAVE_CRYPTO_MD5
MD5_CTX ctx;
static uint8_t md[16];
uint32_t temp;
#if WORDS_BIGENDIAN
temp = BSWAP_32(s->in_seq);
#else
temp = s->in_seq;
#endif
memset(md, 0, 16);
memset(&ctx, 0, sizeof(MD5_CTX));
MD5_Init(&ctx);
MD5_Update(&ctx, (const uint8_t *)s->authcode, 16);
MD5_Update(&ctx, (const uint8_t *)&s->session_id, 4);
MD5_Update(&ctx, (const uint8_t *)data, data_len);
MD5_Update(&ctx, (const uint8_t *)&temp, sizeof(uint32_t));
MD5_Update(&ctx, (const uint8_t *)s->authcode, 16);
MD5_Final(md, &ctx);
if (verbose > 3)
printf(" MD5 AuthCode : %s\n", buf2str(md, 16));
return md;
#else /*HAVE_CRYPTO_MD5*/
md5_state_t state;
static md5_byte_t digest[16];
uint32_t temp;
memset(digest, 0, 16);
memset(&state, 0, sizeof(md5_state_t));
md5_init(&state);
md5_append(&state, (const md5_byte_t *)s->authcode, 16);
md5_append(&state, (const md5_byte_t *)&s->session_id, 4);
md5_append(&state, (const md5_byte_t *)data, data_len);
#if WORDS_BIGENDIAN
temp = BSWAP_32(s->in_seq);
#else
temp = s->in_seq;
#endif
md5_append(&state, (const md5_byte_t *)&temp, 4);
md5_append(&state, (const md5_byte_t *)s->authcode, 16);
md5_finish(&state, digest);
if (verbose > 3)
printf(" MD5 AuthCode : %s\n", buf2str(digest, 16));
return digest;
#endif /*HAVE_CRYPTO_MD5*/
}
/*
* multi-session authcode generation for MD2
* H(password + session_id + msg + session_seq + password)
*
* Use OpenSSL implementation of MD2 algorithm if found.
* This function is analogous to ipmi_auth_md5
*/
uint8_t * ipmi_auth_md2(struct ipmi_session * s, uint8_t * data, int data_len)
{
#ifdef HAVE_CRYPTO_MD2
MD2_CTX ctx;
static uint8_t md[16];
uint32_t temp;
#if WORDS_BIGENDIAN
temp = BSWAP_32(s->in_seq);
#else
temp = s->in_seq;
#endif
memset(md, 0, 16);
memset(&ctx, 0, sizeof(MD2_CTX));
MD2_Init(&ctx);
MD2_Update(&ctx, (const uint8_t *)s->authcode, 16);
MD2_Update(&ctx, (const uint8_t *)&s->session_id, 4);
MD2_Update(&ctx, (const uint8_t *)data, data_len);
MD2_Update(&ctx, (const uint8_t *)&temp, sizeof(uint32_t));
MD2_Update(&ctx, (const uint8_t *)s->authcode, 16);
MD2_Final(md, &ctx);
if (verbose > 3)
printf(" MD2 AuthCode : %s\n", buf2str(md, 16));
return md;
#else /*HAVE_CRYPTO_MD2*/
static uint8_t md[16];
memset(md, 0, 16);
printf("WARNING: No internal support for MD2! "
"Please re-compile with OpenSSL.\n");
return md;
#endif /*HAVE_CRYPTO_MD2*/
}
/* special authentication method */
uint8_t * ipmi_auth_special(struct ipmi_session * s)
{
#ifdef HAVE_CRYPTO_MD5
MD5_CTX ctx;
static uint8_t md[16];
uint8_t challenge[16];
int i;
memset(challenge, 0, 16);
memset(md, 0, 16);
memset(&ctx, 0, sizeof(MD5_CTX));
MD5_Init(&ctx);
MD5_Update(&ctx, (const uint8_t *)s->authcode, strlen(s->authcode));
MD5_Final(md, &ctx);
for (i=0; i<16; i++)
challenge[i] = s->challenge[i] ^ md[i];
memset(md, 0, 16);
memset(&ctx, 0, sizeof(MD5_CTX));
MD5_Init(&ctx);
MD5_Update(&ctx, (const uint8_t *)challenge, 16);
MD5_Final(md, &ctx);
return md;
#else /*HAVE_CRYPTO_MD5*/
int i;
md5_state_t state;
static md5_byte_t digest[16];
uint8_t challenge[16];
memset(challenge, 0, 16);
memset(digest, 0, 16);
memset(&state, 0, sizeof(md5_state_t));
md5_init(&state);
md5_append(&state, (const md5_byte_t *)s->authcode, strlen(s->authcode));
md5_finish(&state, digest);
for (i=0; i<16; i++)
challenge[i] = s->challenge[i] ^ digest[i];
memset(digest, 0, 16);
memset(&state, 0, sizeof(md5_state_t));
md5_init(&state);
md5_append(&state, (const md5_byte_t *)challenge, 16);
md5_finish(&state, digest);
return digest;
#endif /*HAVE_CRYPTO_MD5*/
}

View File

@ -1,44 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_AUTH_H
#define IPMI_AUTH_H
uint8_t * ipmi_auth_md2(struct ipmi_session * s, uint8_t * data, int data_len);
uint8_t * ipmi_auth_md5(struct ipmi_session * s, uint8_t * data, int data_len);
uint8_t * ipmi_auth_special(struct ipmi_session * s);
#endif /*IPMI_AUTH_H*/

File diff suppressed because it is too large Load Diff

View File

@ -38,24 +38,37 @@
#define IPMI_LAN_H
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_intf.h>
#define IPMI_LAN_CHANNEL_1 0x07
#define IPMI_LAN_CHANNEL_2 0x06
#define IPMI_LAN_CHANNEL_E 0x0e
#define IPMI_LAN_PORT 0x26f
#define IPMI_LAN_TIMEOUT 2
#define IPMI_LAN_RETRY 4
#define IPMI_SESSION_AUTHTYPE_NONE 0x0
#define IPMI_SESSION_AUTHTYPE_MD2 0x1
#define IPMI_SESSION_AUTHTYPE_MD5 0x2
#define IPMI_SESSION_AUTHTYPE_KEY 0x4
#define IPMI_SESSION_AUTHTYPE_OEM 0x5
#define IPMI_SESSION_PRIV_CALLBACK 0x1
#define IPMI_SESSION_PRIV_USER 0x2
#define IPMI_SESSION_PRIV_OPERATOR 0x3
#define IPMI_SESSION_PRIV_ADMIN 0x4
#define IPMI_SESSION_PRIV_OEM 0x5
extern const struct valstr ipmi_privlvl_vals[];
extern const struct valstr ipmi_authtype_vals[];
extern struct ipmi_session lan_session;
unsigned char * ipmi_auth_md5(unsigned char * data, int data_len);
unsigned char ipmi_csum(unsigned char * d, int s);
struct ipmi_rs * ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
int ipmi_lan_send_rsp(struct ipmi_intf * intf, struct ipmi_rs * rsp);
int ipmi_lan_open(struct ipmi_intf * intf);
int ipmi_lan_open(struct ipmi_intf * intf, char * hostname, int port, char * username, char * password);
void ipmi_lan_close(struct ipmi_intf * intf);
void ipmi_get_channel_info(struct ipmi_intf * intf, uint8_t channel);
void ipmi_get_channel_info(struct ipmi_intf * intf, unsigned char channel);
int ipmi_lan_ping(struct ipmi_intf * intf);
extern struct ipmi_intf ipmi_lan_intf;
int lan_intf_setup(struct ipmi_intf ** intf);
struct ipmi_intf ipmi_lan_intf;
#endif /*IPMI_LAN_H*/

View File

@ -39,7 +39,6 @@
#include <ipmitool/helper.h>
#include "lan.h"
#include "asf.h"
#define RMCP_VERSION_1 0x06
@ -70,22 +69,12 @@ static const struct valstr rmcp_class_vals[] __attribute__((unused)) = {
/* RMCP message header */
struct rmcp_hdr {
uint8_t ver;
uint8_t __reserved;
uint8_t seq;
uint8_t class;
unsigned char ver;
unsigned char __reserved;
unsigned char seq;
unsigned char class;
} __attribute__((packed));
struct rmcp_pong {
struct rmcp_hdr rmcp;
struct asf_hdr asf;
uint32_t iana;
uint32_t oem;
uint8_t sup_entities;
uint8_t sup_interact;
uint8_t reserved[6];
} __attribute__((packed));
int handle_rmcp(struct ipmi_intf * intf, uint8_t * data, int data_len);
int handle_rmcp(struct ipmi_intf * intf, unsigned char * data, int data_len);
#endif /* IPMI_RMCP_H */

View File

@ -1,49 +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.
#
# You acknowledge that this software is not designed or intended for use
# in the design, construction, operation or maintenance of any nuclear
# facility.
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_srcdir)/include
EXTRA_LTLIBRARIES = libintf_lanplus.la
noinst_LTLIBRARIES = @INTF_LANPLUS_LIB@
libintf_lanplus_la_LIBADD = $(top_builddir)/lib/libipmitool.la
libintf_lanplus_la_SOURCES = \
rmcp.h asf.h \
lanplus.c lanplus.h \
lanplus_strings.c \
lanplus_crypt.c lanplus_crypt.h \
lanplus_dump.h lanplus_dump.c \
lanplus_crypt_impl.h lanplus_crypt_impl.c

View File

@ -1,74 +0,0 @@
This interface exists to provide a means of connecting to an IPMIv2 enabled
BMC. In some places, the IPMIv2 specification is either unclear or
inconsistent, and interpretations of the intent of the specification had to
be made at the discretion of the implementor. The purpose of this
document is to make those decisions clear so that 1) they can be reviewed
by others and 2) so that the rationale for those decisions can be made
clear.
* Though it's not stated explicitly with which algorithm the K1 and K2 keys
should be generated, we chose to use the authentication algorithm. The
specification states that K1 and K2 are generated with an HMAC algorithm,
and all of the authentication algorithms (except for "none") are HMAC
algorithms, whereas the integrity algorithms are not all HMAC. See section
13.32 for details about K1 and K2, and section
* The IPMIv2 specification describes a key, Kg, that is the "BMC key".
This key functions as a global key that is required to be known in addition
to the user's key, by authenticating users. If the BMC has a null Kg, the
users key, Kuid, is used in its place in algorithms where Kg is required,
per the specification section 13.33. A user can obtain the status of Kg by
querying the BMC with the Get Channel Authentication Capabilities command.
Currently, this implementation does not provide a way for a user to specify
Kg for BMCs that require it.
* The specification is unclear as to which key is used for HMAC based
integrity checking. One the one hand, section 13.28.4 states explicitly
that HMAC integrity algorithms use the session integrity key as the HMAC
key. Confusing that matter is a statement in section 13.32 regarding the
creation of additional keying material. In this section it is stated that
"all keying material for the RSP integrity and confidentiality algorithms
will be generated by processing a pre-defined set of constants using HMAC
per [RFC2104], keyed by sik". And "For the mandatory-to-implement
integrity and confidentiality algorithms defined in this specification,
processing the first two (2) constants will generate the require amount of
keying material." We decided to use K1 as our HMAC key for the generation
of authentication codes (integrity checking). Furthermore, we are using
all 20 bytes of K1.
* IPMIv2 compliant BMCs are supposed to support 20 byte passwords, as well
store metadata describing whether the password was stored as a 16 byte or
20 byte class password. We do not currently support 20 byte passwords. It
should be noted that there are obvious mistakes in the SET USER PASSWORD
command specification, as it mentions the ability to query for 16/20 byte
password status, but the packet format does not support this.
* The IPMIv2 specification describes a type of login called a "role only
login." This feature allows a user to login providing only a requested
privilege level and a password. We do not currently support this feature.
Supporting this feature would only require the ability to specify
username/privilege lookups in the RAKP 1 message sent from ipmitool. We
currently specify the use of username only lookups for authentication.
* In the IPMIv2 packet description in table 13-8 of the IPMv2
specification, there are two fields that are rather ambiguous in meaning.
The fields are "Pad Length" and "Next Header". Although neither field is
listed as belonging to the IPMIv2 packet format, we include/expect them
both in our IPMIv2 packets. Are rationale is 1) the Next Headers field's
comment states what the value of that field should be for IPMIv2, and 2)
for the most part the ASF and IPMIv2 fields seem to parallel each other,
and we feel that the Pad Length and Next Header fields were left out of the
IPMIv2 column by mistake.
* The GET CHANNEL CIPHER SUITES command documentation seems to have
mistakes. The "start of record" byte is stated to be either 0x30 or 0x31,
whereas the detailed description in table 22-18 leads us to believe that
this byte should really be 0xC0 or 0xC1. Also the description of bits 5:0
in the start of record byte should probably be 00_0000 rather than 00_000.

View File

@ -1,73 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_ASF_H
#define IPMI_ASF_H
#include <ipmitool/helper.h>
#include "lanplus.h"
#define ASF_RMCP_IANA 0x000011be
#define ASF_TYPE_PING 0x80
#define ASF_TYPE_PONG 0x40
static const struct valstr asf_type_vals[] __attribute__((unused)) = {
{ 0x10, "Reset" },
{ 0x11, "Power-up" },
{ 0x12, "Unconditional Power-down" },
{ 0x13, "Power Cycle" },
{ 0x40, "Presence Pong" },
{ 0x41, "Capabilities Response" },
{ 0x42, "System State Response" },
{ 0x80, "Presence Ping" },
{ 0x81, "Capabilities Request" },
{ 0x82, "System State Request" },
{ 0x00, NULL }
};
/* ASF message header */
struct asf_hdr {
uint32_t iana;
uint8_t type;
uint8_t tag;
uint8_t __reserved;
uint8_t len;
} __attribute__((packed));
int handle_asf(struct ipmi_intf * intf, uint8_t * data, int data_len);
#endif /* IPMI_ASF_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,130 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#ifndef IPMI_LANPLUS_H
#define IPMI_LANPLUS_H
#include <ipmitool/ipmi.h>
#define IPMI_LANPLUS_PORT 0x26f
/*
* RAKP return codes. These values come from table 13-15 of the IPMI v2
* specification.
*/
#define IPMI_RAKP_STATUS_NO_ERRORS 0x00
#define IPMI_RAKP_STATUS_INSUFFICIENT_RESOURCES_FOR_SESSION 0x01
#define IPMI_RAKP_STATUS_INVALID_SESSION_ID 0x02
#define IPMI_RAKP_STATUS_INVALID_PAYLOAD_TYPE 0x03
#define IPMI_RAKP_STATUS_INVALID_AUTHENTICATION_ALGORITHM 0x04
#define IPMI_RAKP_STATUS_INVALID_INTEGRITTY_ALGORITHM 0x05
#define IPMI_RAKP_STATUS_NO_MATCHING_AUTHENTICATION_PAYLOAD 0x06
#define IPMI_RAKP_STATUS_NO_MATCHING_INTEGRITY_PAYLOAD 0x07
#define IPMI_RAKP_STATUS_INACTIVE_SESSION_ID 0x08
#define IPMI_RAKP_STATUS_INVALID_ROLE 0x09
#define IPMI_RAKP_STATUS_UNAUTHORIZED_ROLE_REQUESTED 0x0A
#define IPMI_RAKP_STATUS_INSUFFICIENT_RESOURCES_FOR_ROLE 0x0B
#define IPMI_RAKP_STATUS_INVALID_NAME_LENGTH 0x0C
#define IPMI_RAKP_STATUS_UNAUTHORIZED_NAME 0x0D
#define IPMI_RAKP_STATUS_UNAUTHORIZED_GUID 0x0E
#define IPMI_RAKP_STATUS_INVALID_INTEGRITY_CHECK_VALUE 0x0F
#define IPMI_RAKP_STATUS_INVALID_CONFIDENTIALITY_ALGORITHM 0x10
#define IPMI_RAKP_STATUS_NO_CIPHER_SUITE_MATCH 0x11
#define IPMI_RAKP_STATUS_ILLEGAL_PARAMTER 0x12
#define IPMI_LAN_CHANNEL_1 0x07
#define IPMI_LAN_CHANNEL_2 0x06
#define IPMI_LAN_CHANNEL_E 0x0e
#define IPMI_LAN_TIMEOUT 2
#define IPMI_LAN_RETRY 4
#define IPMI_PRIV_CALLBACK 1
#define IPMI_PRIV_USER 2
#define IPMI_PRIV_OPERATOR 3
#define IPMI_PRIV_ADMIN 4
#define IPMI_PRIV_OEM 5
#define IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE 0x10
/* Session message offsets, from table 13-8 of the v2 specification */
#define IMPI_LANPLUS_OFFSET_AUTHTYPE 0x04
#define IMPI_LANPLUS_OFFSET_PAYLOAD_TYPE 0x05
#define IMPI_LANPLUS_OFFSET_SESSION_ID 0x06
#define IMPI_LANPLUS_OFFSET_SEQUENCE_NUM 0x0A
#define IMPI_LANPLUS_OFFSET_PAYLOAD_SIZE 0x0E
#define IPMI_LANPLUS_OFFSET_PAYLOAD 0x10
#define IPMI_GET_CHANNEL_AUTH_CAP 0x38
/*
* TODO: these are wild guesses and should be checked
*/
#define IPMI_MAX_CONF_HEADER_SIZE 0x20
#define IPMI_MAX_PAYLOAD_SIZE 0xFFFF /* Includes confidentiality header/trailer */
#define IPMI_MAX_CONF_TRAILER_SIZE 0x20
#define IPMI_MAX_INTEGRITY_PAD_SIZE 0x20
#define IPMI_MAX_AUTH_CODE_SIZE 0x20
#define IPMI_REQUEST_MESSAGE_SIZE 0x07
#define IPMI_MAX_MAC_SIZE 0x14 /* The largest mac we ever expect to generate */
#define IPMI_SHA1_AUTHCODE_SIZE 0x0C
/*
*This is accurate, as long as we're only passing 1 auth algorithm,
* one integrity algorithm, and 1 encyrption alogrithm
*/
#define IPMI_OPEN_SESSION_REQUEST_SIZE 32
#define IPMI_RAKP1_MESSAGE_SIZE 44
#define IPMI_RAKP3_MESSAGE_MAX_SIZE 28
#define IPMI_MAX_USER_NAME_LENGTH 16
extern const struct valstr ipmi_privlvl_vals[];
extern const struct valstr ipmi_authtype_vals[];
extern struct ipmi_intf ipmi_lanplus_intf;
struct ipmi_rs * ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req);
int ipmi_lanplus_open(struct ipmi_intf * intf);
void ipmi_lanplus_close(struct ipmi_intf * intf);
int ipmiv2_lan_ping(struct ipmi_intf * intf);
#endif /*IPMI_LAN_H*/

View File

@ -1,914 +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.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/
#include <assert.h>
#include <string.h>
#include <config.h>
#include <ipmitool/bswap.h>
#include <ipmitool/log.h>
#include "lanplus.h"
#include "lanplus_crypt.h"
#include "lanplus_crypt_impl.h"
/*
* lanplus_rakp2_hmac_matches
*
* param session holds all the state data that we need to generate the hmac
* param hmac is the HMAC sent by the BMC in the RAKP 2 message
*
* The HMAC was generated [per RFC2404] from :
*
* SIDm - Remote console session ID
* SIDc - BMC session ID
* Rm - Remote console random number
* Rc - BMC random number
* GUIDc - BMC guid
* ROLEm - Requested privilege level (entire byte)
* ULENGTHm - Username length
* <UNAMEm> - Username (absent for null user names)
*
* generated by using Kuid. I am aware that the subscripts on the values
* look backwards, but that's the way they are written in the specification.
*
* If the authentication algorithm is IPMI_AUTH_RAKP_NONE, we return success.
*
* return 0 on success (the authcode matches)
* 1 on failure (the authcode does not match)
*/
int lanplus_rakp2_hmac_matches(const struct ipmi_session * session,
const uint8_t * bmc_mac,
struct ipmi_intf * intf)
{
char * buffer;
int bufferLength, i;
uint8_t mac[20];
uint32_t macLength;
uint32_t SIDm_lsbf, SIDc_lsbf;
if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE)
return 1;
/* We don't yet support other algorithms */
assert(session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1);
bufferLength =
4 + /* SIDm */
4 + /* SIDc */
16 + /* Rm */
16 + /* Rc */
16 + /* GUIDc */
1 + /* ROLEm */
1 + /* ULENGTHm */
strlen(session->username); /* optional */
buffer = malloc(bufferLength);
if (buffer == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return 1;
}
/*
* Fill the buffer. I'm assuming that we're using the LSBF representation of the
* multibyte numbers in use.
*/
/* SIDm */
SIDm_lsbf = session->v2_data.console_id;
#if WORDS_BIGENDIAN
SIDm_lsbf = BSWAP_32(SIDm_lsbf);
#endif
memcpy(buffer, &SIDm_lsbf, 4);
/* SIDc */
SIDc_lsbf = session->v2_data.bmc_id;
#if WORDS_BIGENDIAN
SIDc_lsbf = BSWAP_32(SIDc_lsbf);
#endif
memcpy(buffer + 4, &SIDc_lsbf, 4);
/* Rm */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
buffer[8 + i] = session->v2_data.console_rand[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
buffer[8 + i] = session->v2_data.console_rand[i];
#endif
/* Rc */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
buffer[24 + i] = session->v2_data.bmc_rand[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
buffer[24 + i] = session->v2_data.bmc_rand[i];
#endif
/* GUIDc */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
buffer[40 + i] = session->v2_data.bmc_guid[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
buffer[40 + i] = session->v2_data.bmc_guid[i];
#endif
/* ROLEm */
buffer[56] = session->v2_data.requested_role;
/* ULENGTHm */
buffer[57] = strlen(session->username);
/* UserName [optional] */
for (i = 0; i < buffer[57]; ++i)
buffer[58 + i] = session->username[i];
if (verbose > 2)
{
printbuf(buffer, bufferLength, ">> rakp2 mac input buffer");
printbuf((char*)(session->authcode), IPMI_AUTHCODE_BUFFER_SIZE, ">> rakp2 mac key");
}
/*
* The buffer is complete. Let's hash.
*/
lanplus_HMAC(session->v2_data.auth_alg,
session->authcode,
IPMI_AUTHCODE_BUFFER_SIZE,
buffer,
bufferLength,
mac,
&macLength);
free(buffer);
if (verbose > 2)
{
printbuf(mac, macLength, ">> rakp2 mac as computed by the remote console");
}
return (memcmp(bmc_mac, mac, macLength) == 0);
}
/*
* lanplus_rakp4_hmac_matches
*
* param session holds all the state data that we need to generate the hmac
* param hmac is the HMAC sent by the BMC in the RAKP 4 message
*
* The HMAC was generated [per RFC2404] from :
*
* Rm - Remote console random number
* SIDc - BMC session ID
* GUIDc - BMC guid
*
* generated by using SIK (the session integrity key). I am aware that the
* subscripts on the values look backwards, but that's the way they are
* written in the specification.
*
* If the authentication algorithm is IPMI_AUTH_RAKP_NONE, we return success.
*
* return 1 on success (the authcode matches)
* 0 on failure (the authcode does not match)
*
*/
int lanplus_rakp4_hmac_matches(const struct ipmi_session * session,
const uint8_t * bmc_mac,
struct ipmi_intf * intf)
{
char * buffer;
int bufferLength, i;
uint8_t mac[20];
uint32_t macLength;
uint32_t SIDc_lsbf;
if (ipmi_oem_active(intf, "intelplus")){
/* Intel BMC responds with the integrity Algorithm in RAKP4 */
if (session->v2_data.integrity_alg == IPMI_INTEGRITY_NONE)
return 1;
/* We don't yet support other algorithms */
assert(session->v2_data.integrity_alg == IPMI_INTEGRITY_HMAC_SHA1_96);
} else {
if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE)
return 1;
/* We don't yet support other algorithms */
assert(session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1);
}
bufferLength =
16 + /* Rm */
4 + /* SIDc */
16; /* GUIDc */
buffer = (char*)malloc(bufferLength);
if (buffer == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return 1;
}
/*
* Fill the buffer. I'm assuming that we're using the LSBF representation of the
* multibyte numbers in use.
*/
/* Rm */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
buffer[i] = session->v2_data.console_rand[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
buffer[i] = session->v2_data.console_rand[i];
#endif
/* SIDc */
SIDc_lsbf = session->v2_data.bmc_id;
#if WORDS_BIGENDIAN
SIDc_lsbf = BSWAP_32(SIDc_lsbf);
#endif
memcpy(buffer + 16, &SIDc_lsbf, 4);
/* GUIDc */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
buffer[i + 20] = session->v2_data.bmc_guid[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
buffer[i + 20] = session->v2_data.bmc_guid[i];
#endif
if (verbose > 2)
{
printbuf(buffer, bufferLength, ">> rakp4 mac input buffer");
printbuf(session->v2_data.sik, 20l, ">> rakp4 mac key (sik)");
}
/*
* The buffer is complete. Let's hash.
*/
lanplus_HMAC((ipmi_oem_active(intf, "intelplus"))
? session->v2_data.integrity_alg
: session->v2_data.auth_alg ,
session->v2_data.sik,
IPMI_SIK_BUFFER_SIZE,
buffer,
bufferLength,
mac,
&macLength);
if (verbose > 2)
{
printbuf(bmc_mac, macLength, ">> rakp4 mac as computed by the BMC");
printbuf(mac, macLength, ">> rakp4 mac as computed by the remote console");
}
free(buffer);
assert(macLength == 20);
return (memcmp(bmc_mac, mac, 12) == 0);
}
/*
* lanplus_generate_rakp3_auth_code
*
* This auth code is an HMAC generated with :
*
* Rc - BMC random number
* SIDm - Console session ID
* ROLEm - Requested privilege level (entire byte)
* ULENGTHm - Username length
* <USERNAME> - Usename (absent for null usernames)
*
* The key used to generated the MAC is Kuid
*
* I am aware that the subscripts look backwards, but that is the way they are
* written in the spec.
*
* param output_buffer [out] will hold the generated MAC
* param session [in] holds all the state data we need to generate the auth code
* param mac_length [out] will be set to the length of the auth code
*
* returns 0 on success
* 1 on failure
*/
int lanplus_generate_rakp3_authcode(char * output_buffer,
const struct ipmi_session * session,
uint32_t * mac_length,
struct ipmi_intf * intf)
{
int ret = 0;
int input_buffer_length, i;
char * input_buffer;
uint32_t SIDm_lsbf;
if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE)
{
*mac_length = 0;
return 0;
}
/* We don't yet support other algorithms */
assert(session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1);
input_buffer_length =
16 + /* Rc */
4 + /* SIDm */
1 + /* ROLEm */
1 + /* ULENGTHm */
strlen(session->username);
input_buffer = malloc(input_buffer_length);
if (input_buffer == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return 1;
}
/*
* Fill the buffer. I'm assuming that we're using the LSBF representation of the
* multibyte numbers in use.
*/
/* Rc */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
input_buffer[i] = session->v2_data.bmc_rand[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
input_buffer[i] = session->v2_data.bmc_rand[i];
#endif
/* SIDm */
SIDm_lsbf = session->v2_data.console_id;
#if WORDS_BIGENDIAN
SIDm_lsbf = BSWAP_32(SIDm_lsbf);
#endif
memcpy(input_buffer + 16, &SIDm_lsbf, 4);
/* ROLEm */
if (ipmi_oem_active(intf, "intelplus"))
input_buffer[20] = session->privlvl;
else
input_buffer[20] = session->v2_data.requested_role;
/* ULENGTHm */
input_buffer[21] = strlen(session->username);
/* USERNAME */
for (i = 0; i < input_buffer[21]; ++i)
input_buffer[22 + i] = session->username[i];
if (verbose > 2)
{
printbuf(input_buffer, input_buffer_length, ">> rakp3 mac input buffer");
printbuf((char*)(session->authcode), IPMI_AUTHCODE_BUFFER_SIZE, ">> rakp3 mac key");
}
lanplus_HMAC(session->v2_data.auth_alg,
session->authcode,
IPMI_AUTHCODE_BUFFER_SIZE,
input_buffer,
input_buffer_length,
output_buffer,
mac_length);
if (verbose > 2)
printbuf(output_buffer, *mac_length, "generated rakp3 mac");
free(input_buffer);
return ret;
}
/*
* lanplus_generate_sik
*
* Generate the session integrity key (SIK) used for integrity checking
* during the IPMI v2 / RMCP+ session
*
* This session integrity key is a HMAC generated with :
*
* Rm - Console generated random number
* Rc - BMC generated random number
* ROLEm - Requested privilege level (entire byte)
* ULENGTHm - Username length
* <USERNAME> - Usename (absent for null usernames)
*
* The key used to generated the SIK is Kg if Kg is not null (two-key logins are
* enabled). Otherwise Kuid (the user authcode) is used as the key to genereate
* the SIK.
*
* I am aware that the subscripts look backwards, but that is the way they are
* written in the spec.
*
* param session [in/out] contains our input and output fields.
*
* returns 0 on success
* 1 on failure
*/
int lanplus_generate_sik(struct ipmi_session * session)
{
char * input_buffer;
int input_buffer_length, i;
char * input_key;
uint32_t mac_length;
memset(session->v2_data.sik, 0, IPMI_SIK_BUFFER_SIZE);
if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE)
return 0;
/* We don't yet support other algorithms */
assert(session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1);
input_buffer_length =
16 + /* Rm */
16 + /* Rc */
1 + /* ROLEm */
1 + /* ULENGTHm */
strlen(session->username);
input_buffer = malloc(input_buffer_length);
if (input_buffer == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return 1;
}
/*
* Fill the buffer. I'm assuming that we're using the LSBF representation of the
* multibyte numbers in use.
*/
/* Rm */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
input_buffer[i] = session->v2_data.console_rand[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
input_buffer[i] = session->v2_data.console_rand[i];
#endif
/* Rc */
#if WORDS_BIGENDIAN
for (i = 0; i < 16; ++i)
input_buffer[16 + i] = session->v2_data.bmc_rand[16 - 1 - i];
#else
for (i = 0; i < 16; ++i)
input_buffer[16 + i] = session->v2_data.bmc_rand[i];
#endif
/* ROLEm */
input_buffer[32] = session->v2_data.requested_role;
/* ULENGTHm */
input_buffer[33] = strlen(session->username);
/* USERNAME */
for (i = 0; i < input_buffer[33]; ++i)
input_buffer[34 + i] = session->username[i];
if (session->v2_data.kg[0])
{
/* We will be hashing with Kg */
/*
* TODO: Section 13.31 of the IPMI v2 spec describes the SIK creation
* using Kg. It specifies that Kg should not be truncated, but I
* do not know what is meant by that.
*/
lprintf(LOG_ERR, "lanplus_generate_sik: We dont yet support hashing with Kg");
assert(0);
input_key = session->v2_data.kg;
}
else
{
/* We will be hashing with Kuid */
input_key = session->authcode;
}
if (verbose >= 2)
printbuf(input_buffer, input_buffer_length, "session integrity key input");
lanplus_HMAC(session->v2_data.auth_alg,
input_key,
IPMI_AUTHCODE_BUFFER_SIZE,
input_buffer,
input_buffer_length,
session->v2_data.sik,
&mac_length);
free(input_buffer);
assert(mac_length == 20);
/*
* The key MAC generated is 20 bytes, but we will only be using the first
* 12 for SHA1 96
*/
if (verbose >= 2)
printbuf(session->v2_data.sik, 20, "Generated session integrity key");
return 0;
}
/*
* lanplus_generate_k1
*
* Generate K1, the key presumably used to generate integrity authcodes
*
* We use the authentication algorithm to generated the HMAC, using
* the session integrity key (SIK) as our key.
*
* param session [in/out].
*
* returns 0 on success
* 1 on failure
*/
int lanplus_generate_k1(struct ipmi_session * session)
{
uint32_t mac_length;
uint8_t CONST_1[] =
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE)
memcpy(session->v2_data.k1, CONST_1, 20);
else
{
lanplus_HMAC(session->v2_data.auth_alg,
session->v2_data.sik,
IPMI_SIK_BUFFER_SIZE, /* SIK length */
CONST_1,
20,
session->v2_data.k1,
&mac_length);
assert(mac_length == 20);
}
if (verbose >= 2)
printbuf(session->v2_data.k1, 20, "Generated K1");
return 0;
}
/*
* lanplus_generate_k2
*
* Generate K2, the key used for RMCP+ AES encryption.
*
* We use the authentication algorithm to generated the HMAC, using
* the session integrity key (SIK) as our key.
*
* param session [in/out].
*
* returns 0 on success
* 1 on failure
*/
int lanplus_generate_k2(struct ipmi_session * session)
{
uint32_t mac_length;
uint8_t CONST_2[] =
{0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02};
if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE)
memcpy(session->v2_data.k2, CONST_2, 20);
else
{
lanplus_HMAC(session->v2_data.auth_alg,
session->v2_data.sik,
IPMI_SIK_BUFFER_SIZE, /* SIK length */
CONST_2,
20,
session->v2_data.k2,
&mac_length);
assert(mac_length == 20);
}
if (verbose >= 2)
printbuf(session->v2_data.k2, 20, "Generated K2");
return 0;
}
/*
* lanplus_encrypt_payload
*
* Perform the appropriate encryption on the input data. Output the encrypted
* data to output, including the required confidentiality header and trailer.
* If the crypt_alg is IPMI_CRYPT_NONE, simply copy the input to the output and
* set bytes_written to input_length.
*
* param crypt_alg specifies the encryption algorithm (from table 13-19 of the
* IPMI v2 spec)
* param key is the used as input to the encryption algorithmf
* param input is the input data to be encrypted
* param input_length is the length of the input data to be encrypted
* param output is the cipher text generated by the encryption process
* param bytes_written is the number of bytes written during the encryption
* process
*
* returns 0 on success
* 1 on failure
*/
int lanplus_encrypt_payload(uint8_t crypt_alg,
const uint8_t * key,
const uint8_t * input,
uint32_t input_length,
uint8_t * output,
uint16_t * bytes_written)
{
uint8_t * padded_input;
uint32_t mod, i, bytes_encrypted;
uint8_t pad_length = 0;
if (crypt_alg == IPMI_CRYPT_NONE)
{
/* Just copy the input to the output */
*bytes_written = input_length;
return 0;
}
/* Currently, we only support AES */
assert(crypt_alg == IPMI_CRYPT_AES_CBC_128);
assert(input_length <= IPMI_MAX_PAYLOAD_SIZE);
/*
* The input to the AES encryption algorithm has to be a multiple of the
* block size (16 bytes). The extra byte we are adding is the pad length
* byte.
*/
mod = (input_length + 1) % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE;
if (mod)
pad_length = IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE - mod;
padded_input = (uint8_t*)malloc(input_length + pad_length + 1);
if (padded_input == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return 1;
}
memcpy(padded_input, input, input_length);
/* add the pad */
for (i = 0; i < pad_length; ++i)
padded_input[input_length + i] = i + 1;
/* add the pad length */
padded_input[input_length + pad_length] = pad_length;
/* Generate an initialization vector, IV, for the encryption process */
if (lanplus_rand(output, IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE))
{
lprintf(LOG_ERR, "lanplus_encrypt_payload: Error generating IV");
return 1;
}
if (verbose > 2)
printbuf(output, IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, ">> Initialization vector");
lanplus_encrypt_aes_cbc_128(output, /* IV */
key, /* K2 */
padded_input, /* Data to encrypt */
input_length + pad_length + 1, /* Input length */
output + IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, /* output */
&bytes_encrypted); /* bytes written */
*bytes_written =
IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE + /* IV */
bytes_encrypted;
free(padded_input);
return 0;
}
/*
* lanplus_has_valid_auth_code
*
* Determine whether the packets authcode field is valid for packet.
*
* We always return success if any of the following are true.
* - this is not an IPMIv2 packet
* - the session is not yet active
* - the packet specifies that it is not authenticated
* - the integrity algorithm agreed upon during session creation is "none"
*
* The authcode is computed using the specified integrity algorithm starting
* with the AuthType / Format field, and ending with the field immediately
* preceeding the authcode itself.
*
* The key key used to generate the authcode MAC is K1.
*
* param rs holds the response structure.
* param session holds our session state, including our chosen algorithm, key, etc.
*
* returns 1 on success (authcode is valid)
* 0 on failure (autchode integrity check failed)
*/
int lanplus_has_valid_auth_code(struct ipmi_rs * rs,
struct ipmi_session * session)
{
uint8_t * bmc_authcode;
uint8_t generated_authcode[IPMI_MAX_MAC_SIZE];
uint32_t generated_authcode_length;
if ((rs->session.authtype != IPMI_SESSION_AUTHTYPE_RMCP_PLUS) ||
(session->v2_data.session_state != LANPLUS_STATE_ACTIVE) ||
(! rs->session.bAuthenticated) ||
(session->v2_data.integrity_alg == IPMI_INTEGRITY_NONE))
return 1;
/* We only support SHA1-96 now */
assert(session->v2_data.integrity_alg == IPMI_INTEGRITY_HMAC_SHA1_96);
/*
* For SHA1-96, the authcode will be the last 12 bytes in the packet
*/
bmc_authcode = rs->data + (rs->data_len - IPMI_SHA1_AUTHCODE_SIZE);
lanplus_HMAC(session->v2_data.integrity_alg,
session->v2_data.k1,
IPMI_AUTHCODE_BUFFER_SIZE,
rs->data + IMPI_LANPLUS_OFFSET_AUTHTYPE,
rs->data_len - IMPI_LANPLUS_OFFSET_AUTHTYPE - IPMI_SHA1_AUTHCODE_SIZE,
generated_authcode,
&generated_authcode_length);
if (verbose > 3)
{
lprintf(LOG_DEBUG+2, "Validating authcode");
printbuf(session->v2_data.k1, 20, "K1");
printbuf(rs->data + IMPI_LANPLUS_OFFSET_AUTHTYPE,
rs->data_len - IMPI_LANPLUS_OFFSET_AUTHTYPE - IPMI_SHA1_AUTHCODE_SIZE,
"Authcode Input Data");
printbuf(generated_authcode, 12, "Generated authcode");
printbuf(bmc_authcode, 12, "Expected authcode");
}
assert(generated_authcode_length == 20);
return (memcmp(bmc_authcode, generated_authcode, 12) == 0);
}
/*
* lanplus_decrypt_payload
*
*
* param input points to the beginning of the payload (which will be the IV if
* we are using AES)
* param payload_size [out] will be set to the size of the payload EXCLUDING
* padding
*
* returns 0 on success (we were able to successfully decrypt the packet)
* 1 on failure (we were unable to successfully decrypt the packet)
*/
int lanplus_decrypt_payload(uint8_t crypt_alg,
const uint8_t * key,
const uint8_t * input,
uint32_t input_length,
uint8_t * output,
uint16_t * payload_size)
{
uint8_t * decrypted_payload;
uint32_t bytes_decrypted;
if (crypt_alg == IPMI_CRYPT_NONE)
{
/* We are not encrypted. The paylaod size is is everything. */
*payload_size = input_length;
memmove(output, input, input_length);
return 0;
}
/* We only support AES */
assert(crypt_alg == IPMI_CRYPT_AES_CBC_128);
decrypted_payload = (uint8_t*)malloc(input_length);
if (decrypted_payload == NULL) {
lprintf(LOG_ERR, "ipmitool: malloc failure");
return 1;
}
lanplus_decrypt_aes_cbc_128(input, /* IV */
key, /* Key */
input +
IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, /* Data to decrypt */
input_length -
IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, /* Input length */
decrypted_payload, /* output */
&bytes_decrypted); /* bytes written */
if (bytes_decrypted != 0)
{
/* Success */
uint8_t conf_pad_length;
int i;
memmove(output,
decrypted_payload,
bytes_decrypted);
/*
* We have to determine the payload size, by substracting the padding, etc.
* The last byte of the decrypted payload is the confidentiality pad length.
*/
conf_pad_length = decrypted_payload[bytes_decrypted - 1];
*payload_size = bytes_decrypted - conf_pad_length - 1;
/*
* Extra test to make sure that the padding looks like it should (should start
* with 0x01, 0x02, 0x03, etc...
*/
for (i = 0; i < conf_pad_length; ++i)
{
if (decrypted_payload[*payload_size + i] == i)
{
lprintf(LOG_ERR, "Malformed payload padding");
assert(0);
}
}
}
else
{
lprintf(LOG_ERR, "ERROR: lanplus_decrypt_aes_cbc_128 decryptd 0 bytes");
assert(0);
}
free(decrypted_payload);
return (bytes_decrypted == 0);
}

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