Compare commits

..

13 Commits

Author SHA1 Message Date
Vincent Fazio
be11d948f8 configure.ac: allow disabling registry downloads
Some environments require reproducible builds. Since the IANA PEN
registry is constantly updating and there is no snapshot available,
installing ipmitool via `make install` is not reproducible.

Provide a configure mechanism to disable the registry download/install..
2023-01-12 13:51:20 +03:00
Alexander Amelkin
4b791f8bf6 lan: channel: Fix set alert on/off
From IPMI Spec, Chapter 22.22 Set Channel Access Command
Table 22, Set Channel Access Command

Byte#2, Bit#5 is "PEF Alerting Enable/Disable"
And the bit value:
    0b = enable PEF Alerting
    1b = disable PEF Alerting on this channel

In current code, alert "on" set Bit#5 to 1 and alert "off" set Bit#5 to
0, it's straightforward but just opposite of IPMI spec bit definition.

Resolves ipmitool/ipmitool#247

Reported-by: Ryan Fang <Ryan.Fang@quantatw.com>
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2023-01-12 13:47:25 +03:00
Alexander Kapshuna
9328748672 make: use correct docdir variable provided by autotools 2023-01-11 19:27:54 +03:00
Vincent Fazio
26b088193a Do not require the IANA PEN registry file
Previously, ipmitool would fail to run if the local copy of the IANA PEN
registry could not be parsed.

When the registry is not available the manufacturer will be "Unknown" but
ipmitool will otherwise function so should not be considered fatal.

Also, fix an issue with improperly handling the `oem_info_list_load`
return value. Previously, in `ipmi_oem_info_init`, if `oem_info_list_load`
returned a negative value due to the registry file not existing, an
improper count would cause `oem_info_init_from_list` to aallocate a list
that didn't encompass the full header/tail list.

  IANA PEN registry open failed: No such file or directory
    Allocating      3 entries
    [     1] 16777214 | A Debug Assisting Company, Ltd.
    [     0]  1048575 | Unspecified

Now, use a signed int and ensure a valid count of loaded OEMs is used.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
2023-01-11 19:17:49 +03:00
Fabrice Fontaine
9dfdf14270 configure.ac: fix readline static build
Use pkg-config to retrieve readline dependencies such as ncurses to
avoid the following static build when readline is built with ncurses
support (which is raised since version 1.8.19 and
63dd71c39c):

** Unable to build Solaris 9 x86 IPMI interface support!
checking for library containing readline... no
configure: error: ** Unable to find readline required by ipmishell.

[...]

configure:15125: /tmp/instance-0/output-1/host/bin/armeb-buildroot-linux-musleabi-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O0 -g0  -static -Wall -Wextra -std=gnu11 -pedantic -Wformat -Wformat-nonliteral -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -static conftest.c -lreadline   -lcrypto >&5
/tmp/instance-0/output-1/host/lib/gcc/armeb-buildroot-linux-musleabi/11.3.0/../../../../armeb-buildroot-linux-musleabi/bin/ld: /tmp/instance-0/output-1/host/armeb-buildroot-linux-musleabi/sysroot/usr/lib/libreadline.a(display.o): in function `_rl_move_cursor_relative':
display.c:(.text+0x80fc): undefined reference to `tputs'

Fixes:
 - http://autobuild.buildroot.org/results/dabc6a4f49d464c129ac6bc3710011678142fcbe

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2023-01-11 18:48:55 +03:00
Alexander Amelkin
707a2980f6 Update github actions for modern OSes
Add Ubuntu 22.04, MacOS 12, Windows Server 2022

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2023-01-11 17:26:01 +03:00
Alexander Amelkin
966d6e80b0
Update macos target name in github actions
The name `macos-catalina` was not correct as the script was actually
executed bothe for catalina (macos-10.15) and big sur (macos-11).
Renamed it to just `macos`.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2023-01-11 16:52:27 +03:00
SliderLu
206dba615d delloem: Fix the unalign bug in arm64
For computers using the arm64 of the Apple chip, the link requires strict
alignment of pointers in 32-bit form. Replace the struct vFlashstr to valstr.
Replace the Function get_vFlash_compcode_str to val2str.

Resolves ipmitool/ipmitool#332
Signed-off-by: SliderLu <314238828@qq.com>
2023-01-09 12:01:28 +03:00
Tom Tung
8f0946a81e lanplus: Realloc the msg if the payload_length gets updated
It's possible the payload_length gets updated in
lanplus_encrypt_payload. If it's updated, the memory of msg should be
updated.

Tested: use ipmitool with lanplus with similar STR  and there is no
memory stomping issue.

Resolved: ipmitool/ipmitool#351
Signed-off-by: Tom Tung <shes050117@gmail.com>
2023-01-05 17:51:26 +03:00
Alexander Amelkin
63d59a50a6 fru print: Add area checksum verification
Before this change, `ipmitool` would not detect any checksum errors
in FRU areas when using 'fru print'. Now it will print whether the
area checksum is OK or INVALID for Chassis, Board, and Product areas.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2022-12-21 15:15:55 +03:00
Alexander Amelkin
f033b5549e fru: Add decoder for multirec system mgmt records
* Add a decoder for System Management records in
  the Multirecord area
* Refactor GUID/UUID decoding: Use the same code for `mc guid`
  and for `fru print` to decode the GUID and System Unique ID
  in System Management records in the Multirecord Area.
* Fix some type errors in calls to printf/sprintf in GUID decoder

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2022-12-06 02:48:52 +03:00
Alexander Amelkin
1edb0e27e4
Fix enterprise-numbers URL
IANA has changed their URL scheme, and the content at the old URL for
enterprise-numbers switched from text/plain to text/html.

Fix Makefile.am to use the new URL

Resolves ipmitool/ipmitool#377

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2022-11-22 13:55:33 +03:00
Alexander Amelkin
4519b4baac
Update issue templates 2022-09-14 16:35:00 +03:00
18 changed files with 362 additions and 95 deletions

37
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

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

View File

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

11
INSTALL
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -211,6 +211,21 @@ typedef struct {
parsed_guid_t ipmi_parse_guid(void *guid, ipmi_guid_mode_t guid_mode); parsed_guid_t ipmi_parse_guid(void *guid, ipmi_guid_mode_t guid_mode);
/**
* Convert a binary GUID/UUID to a canonical hex string form.
* If the version/encoding of the source data is unknown,
* dump the source data as a simple hex string.
*
* @param[out] str The string representation of GUID
* @param[in] data The source binary GUID data
* @param[in] mode The conversion mode, use GUID_AUTO for automatic detection
*
* @returns The parsed GUID structure
*/
parsed_guid_t
ipmi_guid2str(char *str, const void *data, ipmi_guid_mode_t mode);
#define GUID_STR_MAXLEN 36 /* 8+4+4+4+12 bytes plus the dashes */
int _ipmi_mc_get_guid(struct ipmi_intf *intf, ipmi_guid_t *guid); int _ipmi_mc_get_guid(struct ipmi_intf *intf, ipmi_guid_t *guid);
#ifdef HAVE_PRAGMA_PACK #ifdef HAVE_PRAGMA_PACK

View File

@ -55,7 +55,7 @@ extern const struct valstr ipmi_integrity_algorithms[];
extern const struct valstr ipmi_encryption_algorithms[]; extern const struct valstr ipmi_encryption_algorithms[];
extern const struct valstr ipmi_user_enable_status_vals[]; extern const struct valstr ipmi_user_enable_status_vals[];
extern const struct valstr *ipmi_oem_info; extern const struct valstr *ipmi_oem_info;
int ipmi_oem_info_init(); void ipmi_oem_info_init();
void ipmi_oem_info_free(); void ipmi_oem_info_free();
extern const struct valstr picmg_frucontrol_vals[]; extern const struct valstr picmg_frucontrol_vals[];

View File

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

View File

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

View File

@ -1026,10 +1026,10 @@ ipmi_set_alert_enable(struct ipmi_intf *intf, uint8_t channel, uint8_t enable)
channel); channel);
return (-1); return (-1);
} }
if (enable != 0) { if (enable) {
channel_access.alerting = 1; channel_access.alerting = ALERTING_ENABLED;
} else { } else {
channel_access.alerting = 0; channel_access.alerting = ALERTING_DISABLED;
} }
/* non-volatile */ /* non-volatile */
ccode = _ipmi_set_channel_access(intf, channel_access, 1, 0); ccode = _ipmi_set_channel_access(intf, channel_access, 1, 0);

View File

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

View File

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

View File

@ -1719,39 +1719,30 @@ out:
return rc; return rc;
} }
int ipmi_oem_info_init() void ipmi_oem_info_init()
{ {
oem_valstr_list_t terminator = { { -1, NULL}, NULL }; /* Terminator */ oem_valstr_list_t terminator = { { -1, NULL}, NULL }; /* Terminator */
oem_valstr_list_t *oemlist = &terminator; oem_valstr_list_t *oemlist = &terminator;
bool free_strings = true; bool free_strings = true;
size_t count; int count;
int rc = -4;
lprintf(LOG_INFO, "Loading IANA PEN Registry..."); lprintf(LOG_INFO, "Loading IANA PEN Registry...");
if (ipmi_oem_info) { if (ipmi_oem_info) {
lprintf(LOG_INFO, "IANA PEN Registry is already loaded"); lprintf(LOG_INFO, "IANA PEN Registry is already loaded");
rc = 0;
goto out; goto out;
} }
if (!(count = oem_info_list_load(&oemlist))) { if ((count = oem_info_list_load(&oemlist)) < 1) {
/* lprintf(LOG_WARN, "Failed to load entries from IANA PEN Registry");
* We can't identify OEMs without a loaded registry. count = 0;
* Set the pointer to dummy and return.
*/
ipmi_oem_info = ipmi_oem_info_dummy;
goto out;
} }
/* In the array was allocated, don't free the strings at cleanup */ /* In the array was allocated, don't free the strings at cleanup */
free_strings = !oem_info_init_from_list(oemlist, count); free_strings = !oem_info_init_from_list(oemlist, count);
rc = IPMI_CC_OK;
out: out:
oem_info_list_free(&oemlist, free_strings); oem_info_list_free(&oemlist, free_strings);
return rc;
} }
void ipmi_oem_info_free() void ipmi_oem_info_free()

View File

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

View File

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