diff --git a/lib/Makefile.am b/lib/Makefile.am index cc69a8f..50310ee 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -31,6 +31,7 @@ AUTOMAKE_OPTIONS = subdir-objects AM_CPPFLAGS = -I$(top_srcdir)/include MAINTAINERCLEANFILES = Makefile.in +PEN_LIST = $(srcdir)/ipmi_pen_list.inc.c noinst_LTLIBRARIES = libipmitool.la libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_pef.c \ @@ -48,3 +49,8 @@ libipmitool_la_LDFLAGS = -export-dynamic libipmitool_la_LIBADD = -lm libipmitool_la_DEPENDENCIES = +$(PEN_LIST): + $(srcdir)/create_pen_list $(PEN_LIST) + +ipmi_strings.lo: $(PEN_LIST) + diff --git a/lib/create_pen_list b/lib/create_pen_list new file mode 100755 index 0000000..e2b44d2 --- /dev/null +++ b/lib/create_pen_list @@ -0,0 +1,75 @@ +#!/bin/bash +# vi: set ts=2 sw=2 et : +# +# IANA PEN List generator +# +# This script takes the official IANA PEN registry and generates +# a C language output for inclusion into ipmi_strings.c +# +# Copyright (c) 2018 Alexander Amelkin +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. Neither the name of the copyright holder 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 HOLDER 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. +# + +OUTFILE=$1 +PENLIST_URL=https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers + +if [ -z "$OUTFILE" ]; then + echo $0: Must specify output file + exit +fi + +parse_pen_list() { + iconv -f utf8 -t ascii//TRANSLIT//IGNORE \ + | awk ' + /^[0-9]+/ { + if(PEN) { + print "{ " PEN ", \"" ENTERPRISE "\" }," + } + PEN=$1 + } + + /^ [[:alnum:]]/ { + # Remove leading spaces + sub(/^[[:space:]]+/,"") + # Remove question marks (Chinese characters after iconv) + gsub(/\?/,""); + # Remove non-printable characters + gsub(/[^[:print:]]/,""); + # Escape slashes and double quotes + gsub(/["\\]/,"\\\\&") + ENTERPRISE=$0; + } + + END { + print "{ " PEN ", \"" ENTERPRISE "\" }," + }' +} + +echo "Generating IANA PEN list..." +curl -# "$PENLIST_URL" | parse_pen_list > "$OUTFILE" diff --git a/lib/ipmi_strings.c b/lib/ipmi_strings.c index 94b2abd..90188d3 100644 --- a/lib/ipmi_strings.c +++ b/lib/ipmi_strings.c @@ -39,63 +39,10 @@ const struct valstr ipmi_oem_info[] = { { IPMI_OEM_UNKNOWN, "Unknown" }, - { IPMI_OEM_HP, "Hewlett-Packard" }, - { IPMI_OEM_SUN, "Sun Microsystems" }, - { IPMI_OEM_INTEL, "Intel Corporation" }, - { IPMI_OEM_LMC, "LMC" }, - { IPMI_OEM_RADISYS, "RadiSys Corporation" }, - { IPMI_OEM_TYAN, "Tyan Computer Corporation" }, - { IPMI_OEM_NEWISYS, "Newisys" }, - { IPMI_OEM_SUPERMICRO, "Supermicro" }, - { IPMI_OEM_GOOGLE, "Google" }, - { IPMI_OEM_KONTRON, "Kontron" }, - { IPMI_OEM_NOKIA, "Nokia" }, - { IPMI_OEM_PICMG, "PICMG" }, - { IPMI_OEM_PEPPERCON, "Peppercon AG" }, - { IPMI_OEM_DELL, "DELL Inc" }, - { IPMI_OEM_NEC, "NEC" }, - { IPMI_OEM_MAGNUM, "Magnum Technologies" }, - { IPMI_OEM_FUJITSU_SIEMENS, "Fujitsu Siemens" }, - { IPMI_OEM_TATUNG, "Tatung" }, - { IPMI_OEM_AMI, "AMI" }, - { IPMI_OEM_RARITAN, "Raritan" }, - { IPMI_OEM_AVOCENT, "Avocent" }, - { IPMI_OEM_OSA, "OSA" }, - { IPMI_OEM_TOSHIBA, "Toshiba" }, - { IPMI_OEM_HITACHI_116, "Hitachi" }, - { IPMI_OEM_HITACHI_399, "Hitachi" }, - { IPMI_OEM_NOKIA_SOLUTIONS_AND_NETWORKS, "Nokia Solutions and Networks" }, - { IPMI_OEM_BULL, "Bull Company" }, - { IPMI_OEM_PPS, "Pigeon Point Systems" }, - { IPMI_OEM_BROADCOM, "Broadcom Corporation" }, - { IPMI_OEM_ERICSSON, "Ericsson AB"}, - { IPMI_OEM_QUANTA, "Quanta" }, - { IPMI_OEM_VITA, "VITA" }, - { IPMI_OEM_ADVANTECH, "Advantech" }, - /************************************************************************ - * Add ID String for IANA Enterprise Number of IBM & ADLINK - * https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers - * 2 - * IBM - * Kristine Adamson - * adamson&us.ibm.com - * 4769 - * IBM Corporation - * Victor Sample - * vsample&us.ibm.com - * 20301 - * IBM eServer X - * Lynn Fore - * sls&us.ibm.com - * 24339 - * ADLINK TECHNOLOGY INC. - * Ryan Hsu - * ryan.hsu&adlinktech.com - ************************************************************************/ - { IPMI_OEM_IBM_2, "IBM" }, - { IPMI_OEM_IBM_4769, "IBM Corporation" }, - { IPMI_OEM_IBM_20301, "IBM eServer X" }, - { IPMI_OEM_ADLINK_24339, "ADLINK Technology Inc." }, + +/* The included file is auto-generated from offical IANA PEN list */ +#include "ipmi_pen_list.inc.c" + { 0xffff , NULL }, };