diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-01 12:21:52 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-01 12:21:52 +0100 |
commit | 096a497b36f208fb68a12c7ae7576ca0a69f919d (patch) | |
tree | 3845c9631fab6a3a6177813367ddd03f7867700b /lib | |
parent | 7b5768ae6a3fee6cb80300824b9e758021b22f2e (diff) | |
parent | 55031e72e6c02b4ae63e9052bad1a4b40002ac18 (diff) |
Import new upstream release 1.8.15
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.in | 252 | ||||
-rw-r--r-- | lib/dimm_spd.c | 171 | ||||
-rw-r--r-- | lib/helper.c | 1 | ||||
-rw-r--r-- | lib/hpm2.c | 4 | ||||
-rw-r--r-- | lib/ipmi_delloem.c | 99 | ||||
-rw-r--r-- | lib/ipmi_ekanalyzer.c | 2898 | ||||
-rw-r--r-- | lib/ipmi_fru.c | 3 | ||||
-rw-r--r-- | lib/ipmi_fwum.c | 4 | ||||
-rw-r--r-- | lib/ipmi_hpmfwupg.c | 29 | ||||
-rw-r--r-- | lib/ipmi_kontronoem.c | 1257 | ||||
-rw-r--r-- | lib/ipmi_main.c | 4 | ||||
-rw-r--r-- | lib/ipmi_picmg.c | 12 | ||||
-rw-r--r-- | lib/ipmi_sel.c | 4 | ||||
-rw-r--r-- | lib/ipmi_sensor.c | 84 | ||||
-rw-r--r-- | lib/ipmi_sol.c | 44 | ||||
-rw-r--r-- | lib/ipmi_tsol.c | 330 |
16 files changed, 2667 insertions, 2529 deletions
diff --git a/lib/Makefile.in b/lib/Makefile.in index 0925a1f..96e8ae8 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -46,6 +45,51 @@ # EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -66,9 +110,10 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = lib -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -87,29 +132,78 @@ am_libipmitool_la_OBJECTS = helper.lo ipmi_sdr.lo ipmi_sel.lo \ ipmi_gendev.lo ipmi_ime.lo ipmi_delloem.lo ipmi_dcmi.lo \ hpm2.lo md5.lo libipmitool_la_OBJECTS = $(am_libipmitool_la_OBJECTS) -libipmitool_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libipmitool_la_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libipmitool_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(libipmitool_la_LDFLAGS) $(LDFLAGS) -o \ + $@ +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = SOURCES = $(libipmitool_la_SOURCES) DIST_SOURCES = $(libipmitool_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ARCH = @ARCH@ AUTOCONF = @AUTOCONF@ @@ -306,14 +400,17 @@ $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + libipmitool.la: $(libipmitool_la_OBJECTS) $(libipmitool_la_DEPENDENCIES) $(EXTRA_libipmitool_la_DEPENDENCIES) - $(libipmitool_la_LINK) $(libipmitool_la_OBJECTS) $(libipmitool_la_LIBADD) $(LIBS) + $(AM_V_CCLD)$(libipmitool_la_LINK) $(libipmitool_la_OBJECTS) $(libipmitool_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -359,32 +456,32 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< md5.lo: ../src/plugins/lan/md5.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT md5.lo -MD -MP -MF $(DEPDIR)/md5.Tpo -c -o md5.lo `test -f '../src/plugins/lan/md5.c' || echo '$(srcdir)/'`../src/plugins/lan/md5.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/md5.Tpo $(DEPDIR)/md5.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/plugins/lan/md5.c' object='md5.lo' libtool=yes @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT md5.lo -MD -MP -MF $(DEPDIR)/md5.Tpo -c -o md5.lo `test -f '../src/plugins/lan/md5.c' || echo '$(srcdir)/'`../src/plugins/lan/md5.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/md5.Tpo $(DEPDIR)/md5.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../src/plugins/lan/md5.c' object='md5.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o md5.lo `test -f '../src/plugins/lan/md5.c' || echo '$(srcdir)/'`../src/plugins/lan/md5.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o md5.lo `test -f '../src/plugins/lan/md5.c' || echo '$(srcdir)/'`../src/plugins/lan/md5.c mostlyclean-libtool: -rm -f *.lo @@ -392,26 +489,15 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -423,15 +509,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $$unique; \ fi; \ fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -440,6 +522,21 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -582,18 +679,19 @@ uninstall-am: .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLTLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/lib/dimm_spd.c b/lib/dimm_spd.c index 1f27de2..91ae117 100644 --- a/lib/dimm_spd.c +++ b/lib/dimm_spd.c @@ -63,10 +63,11 @@ const struct valstr spd_memtype_vals[] = { { 0x09, "DDR2 SDRAM FB-DIMM" }, { 0x0A, "DDR2 SDRAM FB-DIMM Probe" }, { 0x0B, "DDR3 SDRAM" }, + { 0x0C, "DDR4 SDRAM" }, { 0x00, NULL }, }; -const struct valstr ddr3_density_vals[] = +const struct valstr ddr3_density_vals[] = { { 0, "256 Mb" }, { 1, "512 Mb" }, @@ -87,6 +88,8 @@ const struct valstr ddr3_banks_vals[] = { 0x00, NULL }, }; + +#define ddr4_ecc_vals ddr3_ecc_vals const struct valstr ddr3_ecc_vals[] = { { 0, "0 bits" }, @@ -94,6 +97,62 @@ const struct valstr ddr3_ecc_vals[] = { 0x00, NULL }, }; +const struct valstr ddr4_density_vals[] = +{ + { 0, "256 Mb" }, + { 1, "512 Mb" }, + { 2, "1 Gb" }, + { 3, "2 Gb" }, + { 4, "4 Gb" }, + { 5, "8 Gb" }, + { 6, "16 Gb" }, + { 7, "32 Gb" }, + { 0x00, NULL }, +}; + +const struct valstr ddr4_banks_vals[] = +{ + { 0, "2 (4 Banks)" }, + { 1, "3 (8 Banks)" }, + { 0x00, NULL }, +}; + +const struct valstr ddr4_bank_groups[] = +{ + { 0, "0 (no Bank Groups)" }, + { 1, "1 (2 Bank Groups)" }, + { 2, "2 (4 Bank Groups)" }, + { 0x00, NULL }, +}; + +const struct valstr ddr4_package_type[] = +{ + { 0, "Monolithic DRAM Device" }, + { 1, "Non-Monolithic Device" }, + { 0x00, NULL }, +}; + +const struct valstr ddr4_technology_type[] = +{ + { 0, "Extended module type, see byte 15" }, + { 1, "RDIMM" }, + { 2, "UDIMM" }, + { 3, "SO-DIMM" }, + { 4, "LRDIMM" }, + { 5, "Mini-RDIMM" }, + { 6, "Mini-UDIMM" }, + { 7, "7 - Reserved" }, + { 8, "72b-SO-RDIMM" }, + { 9, "72b-SO-UDIMM" }, + { 10, "10 - Reserved" }, + { 11, "11 - Reserved" }, + { 12, "16b-SO-DIMM" }, + { 13, "32b-SO-DIMM" }, + { 14, "14 - Reserved" }, + { 15, "No base memory present" }, + { 0x00, NULL }, +}; + const struct valstr spd_config_vals[] = { { 0x00, "None" }, { 0x01, "Parity" }, @@ -800,6 +859,92 @@ ipmi_spd_print(uint8_t *spd_data, int len) printf( "%c", *pchPN++ ); } printf("\n"); + } else if (spd_data[2] == 0x0C) /* DDR4 SDRAM */ + { + int i; + int sdram_cap = 0; + int pri_bus_width = 0; + int sdram_width = 0; + int mem_size = 0; + int lrank_dimm; + + if (len < 148) + return -1; /* we need first 91 bytes to do our thing */ + + /* "Logical rank" referes to the individually addressable die + * in a 3DS stack and has no meaning for monolithic or + * multi-load stacked SDRAMs; however, for the purposes of + * calculating the capacity of the module, one should treat + * monolithic and multi-load stack SDRAMs as having one logical + * rank per package rank. + */ + lrank_dimm = (spd_data[12]>>3&0x3) + 1; /* Number of Package Ranks per DIMM */ + if ((spd_data[6] & 0x3) == 0x10) { /* 3DS package Type */ + lrank_dimm *= ((spd_data[6]>>4)&0x3) + 1; /* Die Count */ + } + sdram_cap = ldexp(256,(spd_data[4]&15)); + pri_bus_width = ldexp(8,(spd_data[13]&7)); + sdram_width = ldexp(4,(spd_data[12]&7)); + mem_size = (sdram_cap/8) * (pri_bus_width/sdram_width) * lrank_dimm; + printf(" SDRAM Package Type : %s\n", val2str((spd_data[6]>>7), ddr4_package_type)); + printf(" Technology : %s\n", val2str((spd_data[3]&15), ddr4_technology_type)); + printf(" SDRAM Die Count : %d\n", ((spd_data[6]>>4) & 3)+1); + printf(" SDRAM Capacity : %d Mb\n", sdram_cap ); + printf(" Memory Bank Group : %s\n", val2str((spd_data[4]>>6 & 0x3), ddr4_bank_groups)); + printf(" Memory Banks : %s\n", val2str((spd_data[4]>>4 & 0x3), ddr4_banks_vals)); + printf(" Primary Bus Width : %d bits\n", pri_bus_width ); + printf(" SDRAM Device Width : %d bits\n", sdram_width ); + printf(" Logical Rank per DIMM : %d\n", lrank_dimm ); + printf(" Memory size : %d MB\n", mem_size ); + + printf(" Memory Density : %s\n", val2str(spd_data[4]&15, ddr4_density_vals)); + printf(" 1.2 V Nominal Op : %s\n", (((spd_data[11]&3) != 3) ? "No":"Yes" ) ); + printf(" TBD1 V Nominal Op : %s\n", (((spd_data[11]>>2&3) != 3) ? "No":"Yes" ) ); + printf(" TBD2 V Nominal Op : %s\n", (((spd_data[11]>>4&3) != 3) ? "No":"Yes" ) ); + printf(" Error Detect/Cor : %s\n", val2str(spd_data[13]>>3, ddr4_ecc_vals)); + + printf(" Manufacturer : "); + switch (spd_data[320]&127) + { + case 0: + printf("%s\n", val2str(spd_data[321], jedec_id1_vals)); + break; + + case 1: + printf("%s\n", val2str(spd_data[321], jedec_id2_vals)); + break; + + case 2: + printf("%s\n", val2str(spd_data[321], jedec_id3_vals)); + break; + + case 3: + printf("%s\n", val2str(spd_data[321], jedec_id4_vals)); + break; + + case 4: + printf("%s\n", val2str(spd_data[321], jedec_id5_vals)); + break; + + default: + printf("%s\n", "JEDEC JEP106 update required"); + + } + + u_int year = (spd_data[323]>>4)*10 + spd_data[323]&15; + u_int week = (spd_data[324]>>4)*10 + spd_data[324]&15; + printf(" Manufacture Date : year %4d week %2d\n", + 2000 + year, week); + + printf(" Serial Number : %02x%02x%02x%02x\n", + spd_data[325], spd_data[326], spd_data[327], spd_data[328]); + + printf(" Part Number : "); + for (i=329; i <= 348; i++) + { + printf( "%c", spd_data[i]); + } + printf("\n"); } else { @@ -868,7 +1013,7 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id) struct ipmi_rs * rsp; struct ipmi_rq req; struct fru_info fru; - uint8_t spd_data[256], msg_data[4]; + uint8_t *spd_data, msg_data[4]; int len, offset; msg_data[0] = id; @@ -896,11 +1041,20 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id) 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; } + spd_data = malloc(fru.size); + + if (spd_data == NULL) { + printf(" Unable to malloc memory for spd array of size=%d\n", + fru.size); + return -1; + } + memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_STORAGE; req.msg.cmd = GET_FRU_DATA; @@ -908,22 +1062,27 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id) req.msg.data_len = 4; offset = 0; - memset(spd_data, 0, 256); + memset(spd_data, 0, fru.size); do { + int i; msg_data[0] = id; - msg_data[1] = offset; - msg_data[2] = 0; + msg_data[1] = offset & 0xFF; + msg_data[2] = offset >> 8; msg_data[3] = FRU_DATA_RQST_SIZE; rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { printf(" Device not present (No Response)\n"); + free(spd_data); + spd_data = NULL; return -1; } if (rsp->ccode > 0) { printf(" Device not present (%s)\n", val2str(rsp->ccode, completion_code_vals)); + free(spd_data); + spd_data = NULL; /* Timeouts are acceptable. No DIMM in the socket */ if (rsp->ccode == 0xc3) return 1; @@ -938,6 +1097,8 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id) /* now print spd info */ ipmi_spd_print(spd_data, offset); + free(spd_data); + spd_data = NULL; return 0; } diff --git a/lib/helper.c b/lib/helper.c index 4b903b0..95d641e 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -357,6 +357,7 @@ int str2char(const char *str, int8_t * chr_ptr) if (arg_long < INT8_MIN || arg_long > INT8_MAX) { return (-3); } + *chr_ptr = (uint8_t)arg_long; return 0; } /* str2char(...) */ @@ -30,6 +30,7 @@ * EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ +#include <ipmitool/bswap.h> #include <ipmitool/hpm2.h> #include <ipmitool/ipmi_intf.h> #include <ipmitool/log.h> @@ -233,7 +234,8 @@ int hpm2_get_lan_channel_capabilities(struct ipmi_intf * intf, } /* check parameter revision */ - if (rsp->data[0] != HPM2_LAN_PARAMS_REV) { + if (rsp->data[0] != + LAN_PARAM_REV(HPM2_LAN_PARAMS_REV, HPM2_LAN_PARAMS_REV)) { lprintf(LOG_NOTICE, "Bad HPM.2 LAN parameter revision, rev=%d", rsp->data[0]); return -1; diff --git a/lib/ipmi_delloem.c b/lib/ipmi_delloem.c index e190cd4..308c513 100644 --- a/lib/ipmi_delloem.c +++ b/lib/ipmi_delloem.c @@ -123,6 +123,16 @@ const struct vFlashstr vFlash_completion_code_vals[] = { static int current_arg =0; uint8_t iDRAC_FLAG=0; + +/* + * new flags for + * 11G || 12G || 13G -> _ALL + * 12G || 13G -> _12_13 + * + */ +uint8_t iDRAC_FLAG_ALL=0; +uint8_t iDRAC_FLAG_12_13=0; + LCD_MODE lcd_mode; static uint8_t LcdSupported=0; static uint8_t SetLEDSupported=0; @@ -358,7 +368,7 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) lprintf(LOG_ERR, "lcd is not supported on this system."); return -1; } else if (strncmp(argv[current_arg], "info\0", 5) == 0) { - if ((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G)) { + if (iDRAC_FLAG_ALL) { rc = ipmi_lcd_get_info_wh(intf); } else { rc = ipmi_lcd_get_info(intf); @@ -392,7 +402,7 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) } } if ((strncmp(argv[current_arg], "mode\0", 5) == 0) - && ((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G))) { + && (iDRAC_FLAG_ALL)) { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); @@ -446,7 +456,7 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) ipmi_lcd_usage(); } } else if ((strncmp(argv[current_arg], "lcdqualifier\0", 13) == 0) - && ((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G))) { + && (iDRAC_FLAG_ALL)) { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); @@ -470,7 +480,7 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) ipmi_lcd_usage(); } } else if ((strncmp(argv[current_arg], "errordisplay\0", 13) == 0) - && ((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G))) { + && (iDRAC_FLAG_ALL)) { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); @@ -635,17 +645,33 @@ ipmi_idracvalidator_command(struct ipmi_intf * intf) val2str(rsp->ccode, completion_code_vals)); */ return -1; } + /* + * Set the new flags to 0 + */ + iDRAC_FLAG_ALL = 0; + iDRAC_FLAG_12_13 = 0; /* Support the 11G Monolithic, modular, Maisy and Coaster */ if ((IMC_IDRAC_11G_MONOLITHIC == data[10]) || (IMC_IDRAC_11G_MODULAR == data[10]) || (IMC_MASER_LITE_BMC == data[10]) || (IMC_MASER_LITE_NU == data[10])) { iDRAC_FLAG=IDRAC_11G; + iDRAC_FLAG_ALL = 1; } else if((IMC_IDRAC_12G_MONOLITHIC == data[10]) || (IMC_IDRAC_12G_MODULAR == data[10])) { iDRAC_FLAG = IDRAC_12G; + iDRAC_FLAG_ALL = 1; + iDRAC_FLAG_12_13 = 1; + } else if ((IMC_IDRAC_13G_MONOLITHIC == data[10]) + || (IMC_IDRAC_13G_MODULAR == data[10]) + || (IMC_IDRAC_13G_DCS == data[10])) { + iDRAC_FLAG=IDRAC_13G; + iDRAC_FLAG_ALL = 1; + iDRAC_FLAG_12_13 = 1; } else { iDRAC_FLAG = 0; + iDRAC_FLAG_ALL = 0; + iDRAC_FLAG_12_13 = 0; } IMC_Type = data[10]; return 0; @@ -1394,7 +1420,7 @@ ipmi_lcd_usage(void) lprintf(LOG_NOTICE, ""); lprintf(LOG_NOTICE, -"iDRAC 11g or iDRAC 12g:"); +"iDRAC 11g or iDRAC 12g or iDRAC 13g :"); lprintf(LOG_NOTICE, " lcd set {mode}|{lcdqualifier}|{errordisplay}"); lprintf(LOG_NOTICE, @@ -1561,7 +1587,9 @@ ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum) return -1; } if ((IMC_IDRAC_12G_MODULAR == IMC_Type) - || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type)) { + || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type) + || (IMC_IDRAC_13G_MODULAR == IMC_Type) + || (IMC_IDRAC_13G_MONOLITHIC== IMC_Type)) { /* Get the Chasiss Assigned MAC Addresss for 12g Only */ memcpy(VirtualMacAddress, ((rsp->data) + 1), MACADDRESSLENGH); for (i = 0; i < MACADDRESSLENGH; i++) { @@ -1599,6 +1627,9 @@ ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum) } else if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type)) { printf("\niDRAC7 MAC Address "); + } else if ((IMC_IDRAC_13G_MODULAR == IMC_Type) + || (IMC_IDRAC_13G_MONOLITHIC== IMC_Type)) { + printf ("\niDRAC8 MAC Address "); } else if ((IMC_MASER_LITE_BMC== IMC_Type) || (IMC_MASER_LITE_NU== IMC_Type)) { printf("\nBMC MAC Address "); @@ -1668,6 +1699,9 @@ ipmi_macinfo_drac_idrac_mac(struct ipmi_intf* intf,uint8_t NicNum) } else if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type)) { printf("\niDRAC7 MAC Address "); + } else if ((IMC_IDRAC_13G_MODULAR == IMC_Type) + || (IMC_IDRAC_13G_MONOLITHIC== IMC_Type)) { + printf ("\niDRAC8 MAC Address "); } else if ((IMC_MASER_LITE_BMC== IMC_Type) || (IMC_MASER_LITE_NU== IMC_Type)) { printf("\n\rBMC MAC Address "); @@ -1879,6 +1913,8 @@ ipmi_macinfo(struct ipmi_intf* intf, uint8_t NicNum) || IMC_IDRAC_11G_MONOLITHIC == IMC_Type) || (IMC_IDRAC_12G_MODULAR == IMC_Type || IMC_IDRAC_12G_MONOLITHIC == IMC_Type) + || (IMC_IDRAC_13G_MODULAR == IMC_Type + || IMC_IDRAC_13G_MONOLITHIC == IMC_Type) || (IMC_MASER_LITE_NU == IMC_Type || IMC_MASER_LITE_BMC== IMC_Type)) { return ipmi_macinfo_11g(intf,NicNum); } else { @@ -1946,7 +1982,7 @@ ipmi_delloem_lan_main(struct ipmi_intf * intf, int argc, char ** argv) ipmi_lan_usage(); return -1; } - if (iDRAC_FLAG == IDRAC_12G) { + if (iDRAC_FLAG_12_13) { nic_selection = get_nic_selection_mode_12g(intf, current_arg, argv, nic_set); if (INVALID == nic_selection) { @@ -2063,7 +2099,7 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, } if (argv[current_arg] != NULL && strncmp(argv[current_arg], "lom1\0", 5) == 0) { - if (IMC_IDRAC_12G_MODULAR == IMC_Type) { + if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } if (failover) { @@ -2082,7 +2118,7 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, return 0; } else if (argv[current_arg] != NULL && strncmp(argv[current_arg], "lom2\0", 5) == 0) { - if (IMC_IDRAC_12G_MODULAR == IMC_Type) { + if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } if (failover) { @@ -2101,7 +2137,7 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, return 0; } else if (argv[current_arg] != NULL && strncmp(argv[current_arg], "lom3\0", 5) == 0) { - if (IMC_IDRAC_12G_MODULAR == IMC_Type) { + if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } if (failover) { @@ -2120,7 +2156,7 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, return 0; } else if (argv[current_arg] != NULL && strncmp(argv[current_arg], "lom4\0", 5) == 0) { - if (IMC_IDRAC_12G_MODULAR == IMC_Type) { + if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } if (failover) { @@ -2139,7 +2175,7 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, return 0; } else if (failover && argv[current_arg] != NULL && strncmp(argv[current_arg], "none\0", 5) == 0) { - if (IMC_IDRAC_12G_MODULAR == IMC_Type) { + if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type) ) { return INVAILD_SHARED_MODE; } if (failover) { @@ -2159,7 +2195,7 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, current_arg++; if (failover && argv[current_arg] != NULL && strncmp(argv[current_arg], "loms\0", 5) == 0) { - if (IMC_IDRAC_12G_MODULAR == IMC_Type) { + if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } if (nic_set[0] == 1) { @@ -2242,7 +2278,8 @@ ipmi_lan_set_nic_selection_12g(struct ipmi_intf * intf, uint8_t * nic_selection) lprintf(LOG_ERR, "Error in setting nic selection"); return -1; } else if( (nic_selection[0] == 1) - && ((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED))) { + && (( iDRAC_FLAG_12_13 ) + && (rsp->ccode == LICENSE_NOT_SUPPORTED))) { /* Check license only for setting the dedicated nic. */ lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); @@ -2297,7 +2334,7 @@ ipmi_lan_get_nic_selection(struct ipmi_intf * intf) input_length = 0; req.msg.netfn = DELL_OEM_NETFN; req.msg.lun = 0; - if (iDRAC_FLAG == IDRAC_12G) { + if( iDRAC_FLAG_12_13 ) { req.msg.cmd = GET_NIC_SELECTION_12G_CMD; } else { req.msg.cmd = GET_NIC_SELECTION_CMD; @@ -2314,7 +2351,7 @@ ipmi_lan_get_nic_selection(struct ipmi_intf * intf) return -1; } nic_selection = rsp->data[0]; - if (iDRAC_FLAG == IDRAC_12G) { + if( iDRAC_FLAG_12_13 ) { nic_selection_failover = rsp->data[1]; if ((nic_selection < 6) && (nic_selection > 0) && (nic_selection_failover < 7)) { @@ -2413,7 +2450,7 @@ ipmi_lan_usage(void) lprintf(LOG_NOTICE, " sets the NIC Selection Mode :"); lprintf(LOG_NOTICE, -" on iDRAC12g :"); +" on iDRAC12g OR iDRAC13g :"); lprintf(LOG_NOTICE, " dedicated, shared with lom1, shared with lom2,shared with lom3,shared"); lprintf(LOG_NOTICE, @@ -2433,7 +2470,7 @@ ipmi_lan_usage(void) lprintf(LOG_NOTICE, " lan get "); lprintf(LOG_NOTICE, -" on iDRAC12g :"); +" on iDRAC12g or iDRAC13g :"); lprintf(LOG_NOTICE, " returns the current NIC Selection Mode (dedicated, shared with lom1, shared"); lprintf(LOG_NOTICE, @@ -2662,7 +2699,7 @@ ipmi_get_power_capstatus_command(struct ipmi_intf * intf) if (rsp == NULL) { lprintf(LOG_ERR, "Error getting powercap status"); return -1; - } else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { + } else if (( iDRAC_FLAG_12_13 ) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; /* Return Error as unlicensed */ @@ -2713,7 +2750,7 @@ ipmi_set_power_capstatus_command(struct ipmi_intf * intf, uint8_t val) if (rsp == NULL) { lprintf(LOG_ERR, "Error setting powercap status"); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { + } else if ((iDRAC_FLAG_12_13) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; /* return unlicensed Error code */ @@ -2807,7 +2844,7 @@ ipmi_powermgmt(struct ipmi_intf * intf) return -1; } - if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { + if ((iDRAC_FLAG_12_13) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; @@ -2910,7 +2947,7 @@ ipmi_powermgmt_clear(struct ipmi_intf * intf, uint8_t clearValue) if (rsp == NULL) { lprintf(LOG_ERR, "Error clearing power values."); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) + } else if ((iDRAC_FLAG_12_13) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); @@ -2988,7 +3025,7 @@ ipmi_get_power_headroom_command(struct ipmi_intf * intf,uint8_t unit) if (rsp == NULL) { lprintf(LOG_ERR, "Error getting power headroom status"); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) + } else if ((iDRAC_FLAG_12_13) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); @@ -3122,7 +3159,7 @@ ipmi_get_instan_power_consmpt_data(struct ipmi_intf * intf, if (rsp == NULL) { lprintf(LOG_ERR, "Error getting instantaneous power consumption data ."); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) + } else if ((iDRAC_FLAG_12_13) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); @@ -3215,7 +3252,7 @@ ipmi_get_avgpower_consmpt_history(struct ipmi_intf * intf, lprintf(LOG_ERR, "Error getting average power consumption history data."); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) && (rc == LICENSE_NOT_SUPPORTED)) { + } else if ((iDRAC_FLAG_12_13) && (rc == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; @@ -3264,7 +3301,7 @@ ipmi_get_peakpower_consmpt_history(struct ipmi_intf * intf, if (rc < 0) { lprintf(LOG_ERR, "Error getting peak power consumption history data."); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) && (rc == LICENSE_NOT_SUPPORTED)) { + } else if ((iDRAC_FLAG_12_13) && (rc == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; @@ -3321,7 +3358,7 @@ ipmi_get_minpower_consmpt_history(struct ipmi_intf * intf, if (rc < 0) { lprintf(LOG_ERR, "Error getting peak power consumption history data ."); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) && (rc == LICENSE_NOT_SUPPORTED)) { + } else if ((iDRAC_FLAG_12_13) && (rc == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; @@ -3518,7 +3555,7 @@ ipmi_get_power_cap(struct ipmi_intf * intf, IPMI_POWER_CAP * ipmipowercap) if (rc < 0) { lprintf(LOG_ERR, "Error getting power cap."); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) && (rc == LICENSE_NOT_SUPPORTED)) { + } else if ((iDRAC_FLAG_12_13) && (rc == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; @@ -3618,7 +3655,7 @@ ipmi_set_power_cap(struct ipmi_intf * intf, int unit, int val) if (rc < 0) { lprintf(LOG_ERR, "Error getting power cap."); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) && (rc == LICENSE_NOT_SUPPORTED)) { + } else if ((iDRAC_FLAG_12_13) && (rc == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; @@ -3698,7 +3735,7 @@ ipmi_set_power_cap(struct ipmi_intf * intf, int unit, int val) if (rc < 0) { lprintf(LOG_ERR, "Error setting power cap"); return -1; - } else if ((iDRAC_FLAG == IDRAC_12G) && (rc == LICENSE_NOT_SUPPORTED)) { + } else if ((iDRAC_FLAG_12_13) && (rc == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; @@ -3860,7 +3897,7 @@ ipmi_get_sd_card_info(struct ipmi_intf * intf) { sdcardinfoblock = (IPMI_DELL_SDCARD_INFO *) (void *) rsp->data; - if ((iDRAC_FLAG == IDRAC_12G) + if ((iDRAC_FLAG_12_13) && (sdcardinfoblock->vflashcompcode == VFL_NOT_LICENSED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); diff --git a/lib/ipmi_ekanalyzer.c b/lib/ipmi_ekanalyzer.c index 2ac1012..96d3b44 100644 --- a/lib/ipmi_ekanalyzer.c +++ b/lib/ipmi_ekanalyzer.c @@ -45,9 +45,9 @@ #define NO_MORE_INFO_FIELD 0xc1 #define TYPE_CODE 0xc0 /*Language code*/ -/***************************************************************** -* CONSTANT -*****************************************************************/ +/* + * CONSTANT + */ const int ERROR_STATUS = -1; const int OK_STATUS = 0; @@ -59,10 +59,10 @@ const int SIZE_OF_FILE_TYPE = 3; const unsigned char AMC_MODULE = 0x80; const int PICMG_ID_OFFSET = 3; const unsigned int COMPARE_CANDIDATE = 2; -/*In AMC.0 or PICMG 3.0 specification offset start from 0 with 3 bytes of -* Mfg.ID, 1 byte of Picmg record Id, and -* 1 byte of format version, so the data offset start from 5 -*/ +/* In AMC.0 or PICMG 3.0 specification offset start from 0 with 3 bytes of + * Mfg.ID, 1 byte of Picmg record Id, and + * 1 byte of format version, so the data offset start from 5 + */ const int START_DATA_OFFSET = 5; const int LOWER_OEM_TYPE = 0xf0; const int UPPER_OEM_TYPE = 0xfe; @@ -361,16 +361,18 @@ static void ipmi_ek_display_clock_config_record( * ***************************************************************************/ static void -ipmi_ekanalyzer_usage( void ) +ipmi_ekanalyzer_usage(void) { - lprintf(LOG_NOTICE, "Ekeying analyzer tool version 1.00"); - lprintf(LOG_NOTICE, "ekanalyzer Commands:"); lprintf(LOG_NOTICE, - " print [carrier | power | all] <oc=filename1> <b1=filename2>..."); +"Ekeying analyzer tool version 1.00"); + lprintf(LOG_NOTICE, +"ekanalyzer Commands:"); + lprintf(LOG_NOTICE, +" print [carrier | power | all] <oc=filename1> <b1=filename2>..."); lprintf(LOG_NOTICE, - " frushow <b2=filename>"); +" frushow <b2=filename>"); lprintf(LOG_NOTICE, - " summary [match | unmatch | all] <oc=filename1> <b1=filename2>..."); +" summary [match | unmatch | all] <oc=filename1> <b1=filename2>..."); } /************************************************************************** @@ -395,53 +397,41 @@ ipmi_ekanalyzer_usage( void ) * ipmi_ekanalyzer_module_type for a list of valid type. ***************************************************************************/ static int -ipmi_ek_get_file_type( char * argument ) +ipmi_ek_get_file_type(char *argument) { - int index_name=0; - int filetype = ERROR_STATUS; - - if( strlen (argument) > MIN_ARGUMENT ){ - if( strncmp( argument, "oc=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = ON_CARRIER_FRU_FILE; - } - else if( strncmp( argument, "a1=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = A1_AMC_FRU_FILE; - } - else if( strncmp( argument, "a2=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = A2_AMC_FRU_FILE; - } - else if( strncmp( argument, "a3=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = A3_AMC_FRU_FILE; - } - else if( strncmp( argument, "a4=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = A4_AMC_FRU_FILE; - } - else if( strncmp( argument, "b1=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = B1_AMC_FRU_FILE; - } - else if( strncmp( argument, "b2=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = B2_AMC_FRU_FILE; - } - else if( strncmp( argument, "b3=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = B3_AMC_FRU_FILE; - } - else if( strncmp( argument, "b4=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = B4_AMC_FRU_FILE; - } - else if( strncmp( argument, "rt=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = RTM_FRU_FILE; - } - else if( strncmp( argument, "rc=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = CONFIG_FILE; - } - else if( strncmp( argument, "sm=", SIZE_OF_FILE_TYPE ) == 0 ) { - filetype = SHELF_MANAGER_FRU_FILE; - } - else{ - filetype = ERROR_STATUS; - } - } - return filetype; + int index_name=0; + int filetype = ERROR_STATUS; + if (strlen(argument) <= MIN_ARGUMENT) { + return filetype; + } + if (strncmp(argument, "oc=", SIZE_OF_FILE_TYPE) == 0) { + filetype = ON_CARRIER_FRU_FILE; + } else if (strncmp(argument, "a1=", SIZE_OF_FILE_TYPE) == 0) { + filetype = A1_AMC_FRU_FILE; + } else if (strncmp(argument, "a2=", SIZE_OF_FILE_TYPE) == 0) { + filetype = A2_AMC_FRU_FILE; + } else if (strncmp(argument, "a3=", SIZE_OF_FILE_TYPE) == 0) { + filetype = A3_AMC_FRU_FILE; + } else if (strncmp(argument, "a4=", SIZE_OF_FILE_TYPE) == 0) { + filetype = A4_AMC_FRU_FILE; + } else if (strncmp(argument, "b1=", SIZE_OF_FILE_TYPE) == 0) { + filetype = B1_AMC_FRU_FILE; + } else if (strncmp(argument, "b2=", SIZE_OF_FILE_TYPE) == 0) { + filetype = B2_AMC_FRU_FILE; + } else if (strncmp(argument, "b3=", SIZE_OF_FILE_TYPE) == 0) { + filetype = B3_AMC_FRU_FILE; + } else if (strncmp(argument, "b4=", SIZE_OF_FILE_TYPE) == 0) { + filetype = B4_AMC_FRU_FILE; + } else if (strncmp(argument, "rt=", SIZE_OF_FILE_TYPE) == 0) { + filetype = RTM_FRU_FILE; + } else if (strncmp(argument, "rc=", SIZE_OF_FILE_TYPE) == 0) { + filetype = CONFIG_FILE; + } else if (strncmp(argument, "sm=", SIZE_OF_FILE_TYPE) == 0) { + filetype = SHELF_MANAGER_FRU_FILE; + } else { + filetype = ERROR_STATUS; + } + return filetype; } /************************************************************************** @@ -465,200 +455,194 @@ ipmi_ek_get_file_type( char * argument ) * ***************************************************************************/ int -ipmi_ekanalyzer_main( struct ipmi_intf * intf, int argc, char ** argv ) +ipmi_ekanalyzer_main(struct ipmi_intf *intf, int argc, char **argv) { - int rc = ERROR_STATUS; - int file_type[MAX_FILE_NUMBER]; - int tmp_ret = 0; - char * filename[MAX_FILE_NUMBER]; - unsigned int argument_offset = 0; - unsigned int type_offset = 0; - /*list des multi record*/ - struct ipmi_ek_multi_header * list_head = NULL; - struct ipmi_ek_multi_header * list_record = NULL; - struct ipmi_ek_multi_header * list_last = NULL; - - if ( (argc == 0) || ( (argc - 1) > MAX_FILE_NUMBER ) ){ - lprintf(LOG_ERR, "Too few or too many arguments!"); - ipmi_ekanalyzer_usage(); - rc = ERROR_STATUS; - } - else if ( strcmp(argv[argument_offset], "help") == 0) { - ipmi_ekanalyzer_usage(); - rc = 0; - } - else if ( (strcmp(argv[argument_offset], "frushow") == 0) - && (argc > (MIN_ARGUMENT-1) ) - ){ - for ( type_offset = 0; type_offset < (argc-1); type_offset++ ){ - argument_offset++; - file_type[type_offset] = ipmi_ek_get_file_type (argv[argument_offset]); - if ( file_type[type_offset] != ERROR_STATUS ){ - if ( file_type[type_offset] != CONFIG_FILE ){ - /* because of strlen doesn't count '\0', we need to add 1 byte for - * this character to filename size - */ - filename[type_offset] = malloc( strlen(argv[argument_offset]) + 1 - - SIZE_OF_FILE_TYPE - ); - if( filename[type_offset] != NULL ){ - strcpy(filename[type_offset], - &argv[argument_offset][SIZE_OF_FILE_TYPE]); - printf("Start converting file '%s'...\n", filename[type_offset]); - /* Display FRU header offset */ - rc = ipmi_ek_display_fru_header (filename[type_offset]); - - if ( rc != ERROR_STATUS ){ - /* Display FRU header info in detail record */ - tmp_ret = ipmi_ek_display_fru_header_detail(filename[type_offset]); - /* Convert from binary data into multi record structure */ - rc = ipmi_ekanalyzer_fru_file2structure ( filename[type_offset], - &list_head, &list_record, &list_last ); - - ipmi_ek_display_record ( list_record, list_head, list_last ); - /* Remove record of list */ - while ( list_head != NULL ){ - ipmi_ek_remove_record_from_list( list_head, - &list_head,&list_last ); - if (verbose > 1) - printf("record has been removed!\n"); - } - } - free(filename[type_offset]); - filename[type_offset] = NULL; - } - } - } - else{ - lprintf(LOG_ERR, "Invalid file type!"); - lprintf(LOG_ERR, " ekanalyzer frushow <xx=frufile> ..."); - } - } - } - else if ( (strcmp(argv[argument_offset], "print") == 0) - || (strcmp(argv[argument_offset], "summary") == 0) - ){ - /*Display help of the correspond command if there is not enought argument - * passing in command line - */ - if ( argc < MIN_ARGUMENT ){ - lprintf(LOG_ERR, "Not enough parameters given."); - if ( strcmp(argv[argument_offset], "print") == 0 ){ - lprintf(LOG_ERR, " ekanalyzer print [carrier/power/all]" - " <xx=frufile> <xx=frufile> [xx=frufile]" - ); - } - else{ - lprintf(LOG_ERR, " ekanalyzer summary [match/ unmatch/ all]" - " <xx=frufile> <xx=frufile> [xx=frufile]" - ); - } - } - else{ - char * option; - /*index=1 indicates start position of first file name in command line*/ - int index = 1; - int filename_size=0; - - argument_offset++; - if ( (strcmp(argv[argument_offset], "carrier") == 0) - || (strcmp(argv[argument_offset], "power") == 0) - || (strcmp(argv[argument_offset], "all") == 0) - ){ - option = argv[argument_offset]; - index ++; - argc--; - } - else if ( ( strcmp(argv[argument_offset], "match") == 0 ) - || ( strcmp(argv[argument_offset], "unmatch") == 0 ) - ){ - option = argv[argument_offset]; - index ++; - argc--; - } - /*since the command line must receive xx=filename, so the position of - * "=" sign is 2 - */ - else if ( strncmp(&argv[argument_offset][2], "=", 1) == 0 ){ - option = "default"; - /* Since there is no option from user, the first argument - * becomes first file type */ - index = 1; /* index of argument */ - } - else{ - option = "invalid"; - printf("Invalid option '%s'\n", argv[argument_offset]); - argument_offset--; - if (strcmp(argv[0], "print") == 0){ - lprintf (LOG_ERR, " ekanalyzer print [carrier/power/all]" - " <xx=frufile> <xx=frufile> [xx=frufile]" - ); - } - else{ - lprintf (LOG_ERR, " ekanalyzer summary [match/ unmatch/ all]" - " <xx=frufile> <xx=frufile> [xx=frufile]" - ); - } - rc = ERROR_STATUS; - } - if ( strcmp(option, "invalid") != 0 ){ - int i=0; - - for ( i = 0; i < (argc-1); i++){ - file_type[i] = ipmi_ek_get_file_type (argv[index]); - if ( file_type[i] == ERROR_STATUS ){ - /* display the first 2 charactors (file type) of argument */ - lprintf(LOG_ERR, "Invalid file type: %c%c\n", argv[index][0], - argv[index][1]); - ipmi_ekanalyzer_usage(); - rc = ERROR_STATUS; - break; - } - /*size is equal to string size minus 3 bytes of file type plus - * 1 byte of '\0' since the strlen doesn't count the '\0' - */ - filename_size = strlen( argv[index] ) - SIZE_OF_FILE_TYPE + 1; - if ( filename_size > 0 ){ - filename[i] = malloc( filename_size ); - if (filename[i] != NULL) - strcpy( filename[i], &argv[index][SIZE_OF_FILE_TYPE] ); - } - rc = OK_STATUS; - index++; - } - if ( rc != ERROR_STATUS ){ - if (verbose > 0){ - for (i = 0; i < (argc-1); i++){ - printf ("Type: %s, ", - val2str(file_type[i], ipmi_ekanalyzer_module_type)); - printf("file name: %s\n", filename[i]); - } - } - if (strcmp(argv[0], "print") == 0){ - rc = ipmi_ekanalyzer_print( - (argc-1), option, filename, file_type); - } - else{ - rc = ipmi_ekanalyzer_ekeying_match( - (argc-1), option, filename, file_type); - } - for (i = 0; i < (argc-1); i++){ - if (filename[i] != NULL){ - free(filename[i]); - filename[i] = NULL; - } - } - } /* End of ERROR_STATUS */ - } /* End of comparison of invalid option */ - } /* End of else MIN_ARGUMENT */ - } /* End of print or summary option */ - else{ - lprintf(LOG_ERR, "Invalid ekanalyzer command: %s", argv[0]); - ipmi_ekanalyzer_usage(); - rc = ERROR_STATUS; - } + int rc = ERROR_STATUS; + int file_type[MAX_FILE_NUMBER]; + int tmp_ret = 0; + char *filename[MAX_FILE_NUMBER]; + unsigned int argument_offset = 0; + unsigned int type_offset = 0; + /* list des multi record */ + struct ipmi_ek_multi_header *list_head = NULL; + struct ipmi_ek_multi_header *list_record = NULL; + struct ipmi_ek_multi_header *list_last = NULL; + + if (argc == 0) { + lprintf(LOG_ERR, "Not enough parameters given."); + ipmi_ekanalyzer_usage(); + return (-1); + } else if ((argc - 1) > MAX_FILE_NUMBER) { + lprintf(LOG_ERR, "Too too many parameters given."); + return (-1); + } - return rc; + if (strcmp(argv[argument_offset], "help") == 0) { + ipmi_ekanalyzer_usage(); + return 0; + } else if ((strcmp(argv[argument_offset], "frushow") == 0) + && (argc > (MIN_ARGUMENT-1))) { + for (type_offset = 0; type_offset < (argc-1); type_offset++ ) { + argument_offset++; + file_type[type_offset] = ipmi_ek_get_file_type(argv[argument_offset]); + if (file_type[type_offset] == ERROR_STATUS + || file_type[type_offset] == CONFIG_FILE) { + lprintf(LOG_ERR, "Invalid file type!"); + lprintf(LOG_ERR, " ekanalyzer frushow <xx=frufile> ..."); + return (-1); + } + /* because of strlen doesn't count '\0', + * we need to add 1 byte for this character + * to filename size + */ + filename[type_offset] = malloc(strlen(argv[argument_offset]) + + 1 - SIZE_OF_FILE_TYPE); + if (filename[type_offset] == NULL) { + lprintf(LOG_ERR, "malloc failure"); + return (-1); + } + strcpy(filename[type_offset], + &argv[argument_offset][SIZE_OF_FILE_TYPE]); + printf("Start converting file '%s'...\n", + filename[type_offset]); + /* Display FRU header offset */ + rc = ipmi_ek_display_fru_header (filename[type_offset]); + if (rc != ERROR_STATUS) { + /* Display FRU header info in detail record */ + tmp_ret = ipmi_ek_display_fru_header_detail(filename[type_offset]); + /* Convert from binary data into multi record structure */ + rc = ipmi_ekanalyzer_fru_file2structure (filename[type_offset], + &list_head, &list_record, &list_last ); + ipmi_ek_display_record(list_record, list_head, list_last); + /* Remove record of list */ + while (list_head != NULL) { + ipmi_ek_remove_record_from_list(list_head, + &list_head,&list_last ); + if (verbose > 1) { + printf("record has been removed!\n"); + } + } + } + free(filename[type_offset]); + filename[type_offset] = NULL; + } + } else if ((strcmp(argv[argument_offset], "print") == 0) + || (strcmp(argv[argument_offset], "summary") == 0)) { + /* Display help text for corresponding command + * if not enough parameters were given. + */ + char * option; + /* index=1 indicates start position of first file + * name in command line + */ + int index = 1; + int filename_size=0; + if (argc < MIN_ARGUMENT) { + lprintf(LOG_ERR, "Not enough parameters given."); + if (strcmp(argv[argument_offset], "print") == 0) { + lprintf(LOG_ERR, + " ekanalyzer print [carrier/power/all]" + " <xx=frufile> <xx=frufile> [xx=frufile]"); + } else { + lprintf(LOG_ERR, + " ekanalyzer summary [match/ unmatch/ all]" + " <xx=frufile> <xx=frufile> [xx=frufile]"); + } + return ERROR_STATUS; + } + argument_offset++; + if ((strcmp(argv[argument_offset], "carrier") == 0) + || (strcmp(argv[argument_offset], "power") == 0) + || (strcmp(argv[argument_offset], "all") == 0)) { + option = argv[argument_offset]; + index ++; + argc--; + } else if ((strcmp(argv[argument_offset], "match") == 0) + || ( strcmp(argv[argument_offset], "unmatch") == 0)) { + option = argv[argument_offset]; + index ++; + argc--; + } else if ( strncmp(&argv[argument_offset][2], "=", 1) == 0) { + /* since the command line must receive xx=filename, + * so the position of "=" sign is 2 + */ + option = "default"; + /* Since there is no option from user, the first argument + * becomes first file type + */ + index = 1; /* index of argument */ + } else { + option = "invalid"; + printf("Invalid option '%s'\n", argv[argument_offset]); + argument_offset--; + if (strcmp(argv[0], "print") == 0) { + lprintf (LOG_ERR, + " ekanalyzer print [carrier/power/all]" + " <xx=frufile> <xx=frufile> [xx=frufile]"); + } else { + lprintf (LOG_ERR, + " ekanalyzer summary [match/ unmatch/ all]" + " <xx=frufile> <xx=frufile> [xx=frufile]"); + } + rc = ERROR_STATUS; + } + if (strcmp(option, "invalid") != 0) { + int i=0; + for (i = 0; i < (argc-1); i++) { + file_type[i] = ipmi_ek_get_file_type (argv[index]); + if (file_type[i] == ERROR_STATUS) { + /* display the first 2 charactors (file type) of argument */ + lprintf(LOG_ERR, "Invalid file type: %c%c\n", + argv[index][0], + argv[index][1]); + ipmi_ekanalyzer_usage(); + rc = ERROR_STATUS; + break; + } + /* size is equal to string size minus 3 bytes of file type plus + * 1 byte of '\0' since the strlen doesn't count the '\0' + */ + filename_size = strlen(argv[index]) - SIZE_OF_FILE_TYPE + 1; + if (filename_size > 0) { + /* TODO - check malloc() retval */ + filename[i] = malloc( filename_size ); + if (filename[i] != NULL) { + strcpy(filename[i], &argv[index][SIZE_OF_FILE_TYPE]); + } + } + rc = OK_STATUS; + index++; + } + if (rc != ERROR_STATUS) { + if (verbose > 0) { + for (i = 0; i < (argc-1); i++) { + printf ("Type: %s, ", + val2str(file_type[i], + ipmi_ekanalyzer_module_type)); + printf("file name: %s\n", filename[i]); + } + } + if (strcmp(argv[0], "print") == 0) { + rc = ipmi_ekanalyzer_print((argc-1), + option, filename, file_type); + } else { + rc = ipmi_ekanalyzer_ekeying_match((argc-1), + option, filename, file_type); + } + for (i = 0; i < (argc-1); i++) { + if (filename[i] != NULL) { + free(filename[i]); + filename[i] = NULL; + } + } + } /* End of ERROR_STATUS */ + } /* End of comparison of invalid option */ + } else { + lprintf(LOG_ERR, "Invalid ekanalyzer command: %s", argv[0]); + ipmi_ekanalyzer_usage(); + rc = ERROR_STATUS; + } + return rc; } /************************************************************************** @@ -685,99 +669,96 @@ ipmi_ekanalyzer_main( struct ipmi_intf * intf, int argc, char ** argv ) * ***************************************************************************/ static int -ipmi_ekanalyzer_print( int argc, char * opt, char ** filename, int * file_type ) +ipmi_ekanalyzer_print(int argc, char *opt, char **filename, int *file_type) { - int return_value = OK_STATUS; - - /*Display carrier topology*/ - if ( (strcmp(opt, "carrier") == 0) || (strcmp(opt, "default") == 0) ){ - tboolean found_flag = FALSE; - int index = 0; - int index_name[argc]; - int list = 0; - /*list of multi record*/ - struct ipmi_ek_multi_header * list_head[argc]; - struct ipmi_ek_multi_header * list_record[argc]; - struct ipmi_ek_multi_header * list_last[argc]; - - for ( list=0; list < argc; list++ ){ - list_head[list] = NULL; - list_record[list] = NULL; - list_last[list] = NULL; - } - - list=0; /* reset list count */ - for ( index = 0; index < argc; index++ ){ - if ( file_type[index] == ON_CARRIER_FRU_FILE ){ - index_name[list] = index; - return_value = ipmi_ekanalyzer_fru_file2structure( filename[index], - &list_head[list], &list_record[list], &list_last[list] ); - list++; - found_flag = TRUE; - } - } - if ( !found_flag ){ - printf("No carrier file has been found\n"); - return_value = ERROR_STATUS; - } - else{ - int i = 0; - for ( i = 0; i < argc; i++ ){ - /*this is a flag to advoid displaying the same data multiple time*/ - tboolean first_data = TRUE; - for ( list_record[i] = list_head[i]; - list_record[i] != NULL; - list_record[i] = list_record[i]->next ){ - if ( list_record[i]->data[PICMG_ID_OFFSET] - == - FRU_AMC_CARRIER_P2P ){ - if ( first_data ){ - printf("%s\n", STAR_LINE_LIMITER); - printf("From Carrier file: %s\n", filename[index_name[i]]); - first_data = FALSE; - } - return_value = ipmi_ek_display_carrier_connectivity( - list_record[i] ); - } - else if ( list_record[i]->data[PICMG_ID_OFFSET] - == - FRU_AMC_CARRIER_INFO ){ - /*See AMC.0 specification Table3-3 for mor detail*/ - #define COUNT_OFFSET 6 - if ( first_data ){ - printf("From Carrier file: %s\n", filename[index_name[i]]); - first_data = FALSE; - } - printf(" Number of AMC bays supported by Carrier: %d\n", - list_record[i]->data[COUNT_OFFSET] ); - } - } - } - /*Destroy the list of record*/ - for ( i = 0; i < argc; i++ ){ - while ( list_head[i] != NULL ){ - ipmi_ek_remove_record_from_list( list_head[i], - &list_head[i], &list_last[i] ); - } - /* display deleted result when we reach the last record */ - if ( ( i == (list-1) ) && verbose ) - printf("Record list has been removed successfully\n"); - } - } - } - else if ( (strcmp(opt, "power") == 0) ){ - printf("Print power information\n"); - return_value = ipmi_ek_display_power(argc, opt, filename, file_type); - } - else if ( strcmp(opt, "all") == 0 ){ - printf("Print all information\n"); - return_value = ipmi_ek_display_power(argc, opt, filename, file_type); - } - else{ - lprintf(LOG_ERR, "Invalid option %s", opt); - return_value = ERROR_STATUS; - } - return return_value; + int return_value = OK_STATUS; + /* Display carrier topology */ + if ((strcmp(opt, "carrier") == 0) || (strcmp(opt, "default") == 0)) { + tboolean found_flag = FALSE; + int index = 0; + int index_name[argc]; + int list = 0; + /* list of multi record */ + struct ipmi_ek_multi_header *list_head[argc]; + struct ipmi_ek_multi_header *list_record[argc]; + struct ipmi_ek_multi_header *list_last[argc]; + + for (list=0; list < argc; list++) { + list_head[list] = NULL; + list_record[list] = NULL; + list_last[list] = NULL; + } + /* reset list count */ + list = 0; + for (index = 0; index < argc; index++) { + if (file_type[index] != ON_CARRIER_FRU_FILE) { + continue; + } + index_name[list] = index; + return_value = ipmi_ekanalyzer_fru_file2structure(filename[index], + &list_head[list], + &list_record[list], + &list_last[list]); + list++; + found_flag = TRUE; + } + if (!found_flag) { + printf("No carrier file has been found\n"); + return_value = ERROR_STATUS; + } else { + int i = 0; + for (i = 0; i < argc; i++) { + /* this is a flag to advoid displaying + * the same data multiple time + */ + tboolean first_data = TRUE; + for (list_record[i] = list_head[i]; + list_record[i] != NULL; + list_record[i] = list_record[i]->next) { + if (list_record[i]->data[PICMG_ID_OFFSET] == FRU_AMC_CARRIER_P2P) { + if (first_data) { + printf("%s\n", STAR_LINE_LIMITER); + printf("From Carrier file: %s\n", filename[index_name[i]]); + first_data = FALSE; + } + return_value = ipmi_ek_display_carrier_connectivity(list_record[i]); + } else if (list_record[i]->data[PICMG_ID_OFFSET] == FRU_AMC_CARRIER_INFO) { + /*See AMC.0 specification Table3-3 for mor detail*/ + #define COUNT_OFFSET 6 + if (first_data) { + printf("From Carrier file: %s\n", filename[index_name[i]]); + first_data = FALSE; + } + printf(" Number of AMC bays supported by Carrier: %d\n", + list_record[i]->data[COUNT_OFFSET]); + } + } + } + /*Destroy the list of record*/ + for (i = 0; i < argc; i++) { + while (list_head[i] != NULL) { + ipmi_ek_remove_record_from_list(list_head[i], + &list_head[i], &list_last[i]); + } + /* display deleted result when we + * reach the last record + */ + if ((i == (list-1)) && verbose) { + printf("Record list has been removed successfully\n"); + } + } + } + } else if (strcmp(opt, "power") == 0) { + printf("Print power information\n"); + return_value = ipmi_ek_display_power(argc, opt, filename, file_type); + } else if (strcmp(opt, "all") == 0) { + printf("Print all information\n"); + return_value = ipmi_ek_display_power(argc, opt, filename, file_type); + } else { + lprintf(LOG_ERR, "Invalid option %s", opt); + return_value = ERROR_STATUS; + } + return return_value; } /************************************************************************** @@ -800,86 +781,79 @@ ipmi_ekanalyzer_print( int argc, char * opt, char ** filename, int * file_type ) * ***************************************************************************/ static int -ipmi_ek_display_carrier_connectivity( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_carrier_connectivity(struct ipmi_ek_multi_header *record) { - int return_value = ERROR_STATUS; - struct fru_picmgext_carrier_p2p_record rsc_desc; - struct fru_picmgext_carrier_p2p_descriptor *port_desc; - - if ( record == NULL ){ - lprintf(LOG_ERR, "P2P connectivity record is invalid\n"); - return_value = ERROR_STATUS; - } - else{ - int offset = START_DATA_OFFSET; - if ( verbose > 1 ){ - int k = 0; - printf("Binary data of Carrier p2p connectivity"\ - " record starting from mfg id\n"); - for ( k = 0; k < ( record->header.len ); k++ ){ - printf("%02x ", record->data[k]); - } - printf("\n"); - } - while ( offset <= (record->header.len - START_DATA_OFFSET) ){ - rsc_desc.resource_id = record->data[offset++]; - rsc_desc.p2p_count = record->data[offset++]; - if ( verbose > 0 ){ - printf("resource id= %02x port count= %d\n", - rsc_desc.resource_id,rsc_desc.p2p_count); - } - /*check if it is an AMC Module*/ - if ( ( (rsc_desc.resource_id & AMC_MODULE) ) == AMC_MODULE ) { - /*check if it is an RTM module*/ - if ((rsc_desc.resource_id == AMC_MODULE)){ - printf(" %s topology:\n", val2str( RTM_IPMB_L, - ipmi_ekanalyzer_IPMBL_addr)); - } - else{ - /*The last four bits of resource ID represent site number - * (mask = 0x0f) - */ - printf(" %s topology:\n", - val2str( (rsc_desc.resource_id & 0x0f), - ipmi_ekanalyzer_module_type)); - } - } - else{ - printf(" On Carrier Device ID %d topology: \n", - (rsc_desc.resource_id & 0x0f)); - } - while ( rsc_desc.p2p_count > 0 ){ - unsigned char data[3]; -#ifndef WORDS_BIGENDIAN - data[0] = record->data[offset+0]; - data[1] = record->data[offset+1]; - data[2] = record->data[offset+2]; -#else - data[0] = record->data[offset+2]; - data[1] = record->data[offset+1]; - data[2] = record->data[offset+0]; -#endif - port_desc = (struct fru_picmgext_carrier_p2p_descriptor*)data; - offset += sizeof (struct fru_picmgext_carrier_p2p_descriptor); - if ((port_desc->remote_resource_id & AMC_MODULE) == AMC_MODULE) { - printf("\tPort %d =====> %s, Port %d\n", - port_desc->local_port, - val2str( (port_desc->remote_resource_id & 0x0f), - ipmi_ekanalyzer_module_type), - port_desc->remote_port); + int offset = START_DATA_OFFSET; + struct fru_picmgext_carrier_p2p_record rsc_desc; + struct fru_picmgext_carrier_p2p_descriptor *port_desc; + if (record == NULL) { + lprintf(LOG_ERR, "P2P connectivity record is invalid\n"); + return ERROR_STATUS; + } + if (verbose > 1) { + int k = 0; + printf("Binary data of Carrier p2p connectivity"\ + " record starting from mfg id\n"); + for (k = 0; k < (record->header.len); k++) { + printf("%02x ", record->data[k]); } - else { - printf("\tPort %d =====> On Carrier Device ID %d, Port %d\n", - port_desc->local_port, - (port_desc->remote_resource_id & 0x0f), - port_desc->remote_port); + printf("\n"); + } + while (offset <= (record->header.len - START_DATA_OFFSET)) { + rsc_desc.resource_id = record->data[offset++]; + rsc_desc.p2p_count = record->data[offset++]; + if (verbose > 0) { + printf("resource id= %02x port count= %d\n", + rsc_desc.resource_id, rsc_desc.p2p_count); } - rsc_desc.p2p_count--; - } - } - return_value = OK_STATUS; - } - return return_value; + /* check if it is an AMC Module */ + if ((rsc_desc.resource_id & AMC_MODULE) == AMC_MODULE) { + /* check if it is an RTM module */ + if (rsc_desc.resource_id == AMC_MODULE) { + printf(" %s topology:\n", + val2str(RTM_IPMB_L, + ipmi_ekanalyzer_IPMBL_addr)); + } else { + /* The last four bits of resource ID + * represent site number (mask = 0x0f) + */ + printf(" %s topology:\n", + val2str((rsc_desc.resource_id & 0x0f), + ipmi_ekanalyzer_module_type)); + } + } else { + printf(" On Carrier Device ID %d topology: \n", + (rsc_desc.resource_id & 0x0f)); + } + while (rsc_desc.p2p_count > 0) { + unsigned char data[3]; +# ifndef WORDS_BIGENDIAN + data[0] = record->data[offset + 0]; + data[1] = record->data[offset + 1]; + data[2] = record->data[offset + 2]; +# else + data[0] = record->data[offset + 2]; + data[1] = record->data[offset + 1]; + data[2] = record->data[offset + 0]; +# endif + port_desc = (struct fru_picmgext_carrier_p2p_descriptor*)data; + offset += sizeof(struct fru_picmgext_carrier_p2p_descriptor); + if ((port_desc->remote_resource_id & AMC_MODULE) == AMC_MODULE) { + printf("\tPort %d =====> %s, Port %d\n", + port_desc->local_port, + val2str((port_desc->remote_resource_id & 0x0f), + ipmi_ekanalyzer_module_type), + port_desc->remote_port); + } else { + printf("\tPort %d =====> On Carrier Device ID %d, Port %d\n", + port_desc->local_port, + (port_desc->remote_resource_id & 0x0f), + port_desc->remote_port); + } + rsc_desc.p2p_count--; + } + } + return OK_STATUS; } /************************************************************************** @@ -1050,30 +1024,33 @@ ipmi_ek_display_power( int argc, char * opt, char ** filename, int * file_type ) ***************************************************************************/ static void ipmi_ek_display_current_descriptor( - struct fru_picmgext_carrier_activation_record car, - struct fru_picmgext_activation_record * cur_desc, char * filename ) + struct fru_picmgext_carrier_activation_record car, + struct fru_picmgext_activation_record *cur_desc, + char *filename) { - int index = 0; - float power_in_watt = 0.0; - float current_in_amp = 0.0; - - for ( index = 0; index < car.module_activation_record_count; index++ ){ - /*See AMC.0 specification, Table 3-12 for detail about calculation*/ - current_in_amp = (float) cur_desc[index].max_module_curr * 0.1; - power_in_watt = (float) current_in_amp * AMC_VOLTAGE; - - printf(" Carrier AMC power available on %s:\n", - val2str( cur_desc[index].ibmb_addr, ipmi_ekanalyzer_IPMBL_addr ) ); - printf("\t- Local IPMB Address \t: %02x\n", cur_desc[index].ibmb_addr); - printf("\t- Maximum module Current\t: %.2f Watts (%.2f Amps)\n", - power_in_watt, current_in_amp ); - } - /*Display total power on Carrier*/ - current_in_amp = (float) car.max_internal_curr * 0.1; - power_in_watt = (float) current_in_amp * AMC_VOLTAGE; - printf(" Carrier AMC total power available for all bays from file '%s':", - filename); - printf(" %.2f Watts (%.2f Amps)\n", power_in_watt, current_in_amp ); + int index = 0; + float power_in_watt = 0.0; + float current_in_amp = 0.0; + for (index = 0; index < car.module_activation_record_count; index++) { + /* See AMC.0 specification, Table 3-12 for + * detail about calculation + */ + current_in_amp = (float)cur_desc[index].max_module_curr * 0.1; + power_in_watt = (float)current_in_amp * AMC_VOLTAGE; + printf(" Carrier AMC power available on %s:\n", + val2str( cur_desc[index].ibmb_addr, + ipmi_ekanalyzer_IPMBL_addr)); + printf("\t- Local IPMB Address \t: %02x\n", + cur_desc[index].ibmb_addr); + printf("\t- Maximum module Current\t: %.2f Watts (%.2f Amps)\n", + power_in_watt, current_in_amp); + } + /* Display total power on Carrier */ + current_in_amp = (float)car.max_internal_curr * 0.1; + power_in_watt = (float)current_in_amp * AMC_VOLTAGE; + printf(" Carrier AMC total power available for all bays from file '%s':", + filename); + printf(" %.2f Watts (%.2f Amps)\n", power_in_watt, current_in_amp); } /************************************************************************** @@ -1901,72 +1878,60 @@ ipmi_ek_compare_channel_descriptor( ***************************************************************************/ static int ipmi_ek_compare_link_descriptor( - struct ipmi_ek_amc_p2p_connectivity_record record1, int index1, - struct ipmi_ek_amc_p2p_connectivity_record record2, int index2 ) + struct ipmi_ek_amc_p2p_connectivity_record record1, + int index1, + struct ipmi_ek_amc_p2p_connectivity_record record2, + int index2) { - int result = ERROR_STATUS; - - if (record1.link_desc[index1].type == record2.link_desc[index2].type){ - /*if it is an OEM type, we compare the OEM GUID*/ - if ( (record1.link_desc[index1].type >= LOWER_OEM_TYPE) - && (record1.link_desc[index1].type <= UPPER_OEM_TYPE) - ){ - if ( (record1.guid_count == 0) && (record2.guid_count == 0) ){ - /*there is no GUID for comparison, so the result is always OK*/ - result = OK_STATUS; - } - else{ - int i=0; - int j=0; - - for( i=0; i<record1.guid_count; i++){ - for( j=0; j < record2.guid_count; j++){ - if( memcmp (&record1.oem_guid[i], &record2.oem_guid[j], - SIZE_OF_GUID ) - == 0 - ){ - result = OK_STATUS; - break; - } - } - } - } - } - else{ - result = OK_STATUS; - } - if (result == OK_STATUS){ - if (record1.link_desc[index1].type_ext - == record2.link_desc[index2].type_ext - ){ - unsigned char asym[COMPARE_CANDIDATE]; - int offset = 0; - - asym[offset++] = record1.link_desc[index1].asym_match; - asym[offset] = record2.link_desc[index2].asym_match; - result = ipmi_ek_compare_asym ( asym ); - if (result == OK_STATUS){ - struct fru_picmgext_amc_link_desc_record link[COMPARE_CANDIDATE]; - int index = 0; - - link[index++] = record1.link_desc[index1]; - link[index] = record2.link_desc[index2]; - result = ipmi_ek_compare_number_of_enable_port( link ); - } - else{ - result = ERROR_STATUS; - } - } - else{ - result = ERROR_STATUS; - } - } - } - else{ - result = ERROR_STATUS; - } - - return result; + int result = ERROR_STATUS; + if (record1.link_desc[index1].type != record2.link_desc[index2].type) { + return ERROR_STATUS; + } + /* if it is an OEM type, we compare the OEM GUID */ + if ((record1.link_desc[index1].type >= LOWER_OEM_TYPE) + && (record1.link_desc[index1].type <= UPPER_OEM_TYPE)) { + if ((record1.guid_count == 0) && (record2.guid_count == 0)) { + /*there is no GUID for comparison, so the result is always OK*/ + result = OK_STATUS; + } else { + int i = 0; + int j = 0; + for (i = 0; i < record1.guid_count; i++) { + for (j = 0; j < record2.guid_count; j++) { + if (memcmp(&record1.oem_guid[i], + &record2.oem_guid[j], + SIZE_OF_GUID) == 0) { + result = OK_STATUS; + break; + } + } + } + } + } else { + result = OK_STATUS; + } + if (result != OK_STATUS) { + return result; + } + if (record1.link_desc[index1].type_ext == record2.link_desc[index2].type_ext) { + unsigned char asym[COMPARE_CANDIDATE]; + int offset = 0; + asym[offset++] = record1.link_desc[index1].asym_match; + asym[offset] = record2.link_desc[index2].asym_match; + result = ipmi_ek_compare_asym (asym); + if (result == OK_STATUS){ + struct fru_picmgext_amc_link_desc_record link[COMPARE_CANDIDATE]; + int index = 0; + link[index++] = record1.link_desc[index1]; + link[index] = record2.link_desc[index2]; + result = ipmi_ek_compare_number_of_enable_port(link); + } else { + result = ERROR_STATUS; + } + } else { + result = ERROR_STATUS; + } + return result; } /************************************************************************** @@ -1989,22 +1954,20 @@ ipmi_ek_compare_link_descriptor( ***************************************************************************/ static int -ipmi_ek_compare_asym( unsigned char asym[COMPARE_CANDIDATE] ) +ipmi_ek_compare_asym(unsigned char asym[COMPARE_CANDIDATE]) { - int return_value = ERROR_STATUS; - int first_index = 0; - int second_index = 1; - - if ( (asym[first_index] == 0) && (asym[second_index] == 0) ){ - return_value = OK_STATUS; - } - else if ( (asym[first_index] & asym[second_index]) == 0 ){ - return_value = OK_STATUS; - } - else{ - return_value = ERROR_STATUS; - } - return return_value; + int return_value = ERROR_STATUS; + int first_index = 0; + int second_index = 1; + + if ((asym[first_index] == 0) && (asym[second_index] == 0)) { + return_value = OK_STATUS; + } else if ((asym[first_index] & asym[second_index]) == 0) { + return_value = OK_STATUS; + } else { + return_value = ERROR_STATUS; + } + return return_value; } /************************************************************************** @@ -2027,49 +1990,54 @@ ipmi_ek_compare_asym( unsigned char asym[COMPARE_CANDIDATE] ) ***************************************************************************/ static int ipmi_ek_compare_number_of_enable_port( - struct fru_picmgext_amc_link_desc_record link_desc[COMPARE_CANDIDATE] ) + struct fru_picmgext_amc_link_desc_record link_desc[COMPARE_CANDIDATE]) { - int amc_port_count = 0; - int carrier_port_count = 0; - int return_value = ERROR_STATUS; - int index = 0; - - if (link_desc[index].port_flag_0){ /*bit 0 indicates port 0*/ - amc_port_count++; - } - if (link_desc[index].port_flag_1){ /*bit 1 indicates port 1*/ - amc_port_count++; - } - if (link_desc[index].port_flag_2){ /*bit 2 indicates port 2*/ - amc_port_count++; - } - if (link_desc[index++].port_flag_3){ /*bit 3 indicates port 3*/ - amc_port_count++; - } - - /*2nd link designator*/ - if (link_desc[index].port_flag_0){ /*bit 0 indicates port 0*/ - carrier_port_count++; - } - if (link_desc[index].port_flag_1){ /*bit 1 indicates port 1*/ - carrier_port_count++; - } - if (link_desc[index].port_flag_2){ /*bit 2 indicates port 2*/ - carrier_port_count++; - } - if (link_desc[index].port_flag_3){ /*bit 3 indicates port 3*/ - carrier_port_count++; - } - - if(carrier_port_count == amc_port_count){ + int amc_port_count = 0; + int carrier_port_count = 0; + int return_value = ERROR_STATUS; + int index = 0; + + if (link_desc[index].port_flag_0) { + /*bit 0 indicates port 0*/ + amc_port_count++; + } + if (link_desc[index].port_flag_1) { + /*bit 1 indicates port 1*/ + amc_port_count++; + } + if (link_desc[index].port_flag_2) { + /*bit 2 indicates port 2*/ + amc_port_count++; + } + if (link_desc[index++].port_flag_3) { + /*bit 3 indicates port 3*/ + amc_port_count++; + } - return_value = OK_STATUS; - } - else{ - return_value = ERROR_STATUS; - } + /* 2nd link designator */ + if (link_desc[index].port_flag_0) { + /*bit 0 indicates port 0*/ + carrier_port_count++; + } + if (link_desc[index].port_flag_1) { + /*bit 1 indicates port 1*/ + carrier_port_count++; + } + if (link_desc[index].port_flag_2) { + /*bit 2 indicates port 2*/ + carrier_port_count++; + } + if (link_desc[index].port_flag_3) { + /*bit 3 indicates port 3*/ + carrier_port_count++; + } - return return_value; + if (carrier_port_count == amc_port_count) { + return_value = OK_STATUS; + } else { + return_value = ERROR_STATUS; + } + return return_value; } /************************************************************************** @@ -2096,70 +2064,75 @@ ipmi_ek_compare_number_of_enable_port( * ***************************************************************************/ static tboolean -ipmi_ek_display_link_descriptor( int file_type, unsigned char rsc_id, - char * str, struct fru_picmgext_amc_link_desc_record link_desc ) +ipmi_ek_display_link_descriptor(int file_type, unsigned char rsc_id, + char *str, + struct fru_picmgext_amc_link_desc_record link_desc) { - tboolean isOEMtype = FALSE; - - if (file_type == ON_CARRIER_FRU_FILE){ - printf(" - %s On-Carrier Device ID %d\n", str, (rsc_id & 0x0f) ); - } - else{ - printf(" - %s %s\n", str, - val2str(file_type,ipmi_ekanalyzer_module_type)); - } - - printf(" - Channel ID %d || ", link_desc.channel_id ); - printf("%s", link_desc.port_flag_0 ? "Lane 0: enable" : ""); - printf("%s", link_desc.port_flag_1 ? ", Lane 1: enable" : ""); - printf("%s", link_desc.port_flag_2 ? ", Lane 2: enable" : ""); - printf("%s", link_desc.port_flag_3 ? ", Lane 3: enable" : ""); - - printf("\n"); - printf(" - Link Type: %s \n", - val2str (link_desc.type, ipmi_ekanalyzer_link_type) ); - switch ( link_desc.type ){ - case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE: - case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS1: - case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS2: - printf(" - Link Type extension: %s\n", - val2str (link_desc.type_ext, ipmi_ekanalyzer_extension_PCIE) ); - printf(" - Link Group ID: %d || ", link_desc.group_id ); - printf("Link Asym. Match: %d - %s\n", - link_desc.asym_match, - val2str (link_desc.asym_match, ipmi_ekanalyzer_asym_PCIE) ); - break; - case FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET: - printf(" - Link Type extension: %s\n", - val2str (link_desc.type_ext, ipmi_ekanalyzer_extension_ETHERNET) ); - printf(" - Link Group ID: %d || ", link_desc.group_id ); - printf("Link Asym. Match: %d - %s\n", - link_desc.asym_match, - val2str (link_desc.asym_match, ipmi_ekanalyzer_asym_PCIE) ); - break; - case FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE: - printf(" - Link Type extension: %s\n", - val2str (link_desc.type_ext, ipmi_ekanalyzer_extension_STORAGE) ); - printf(" - Link Group ID: %d || ", link_desc.group_id ); - printf("Link Asym. Match: %d - %s\n", - link_desc.asym_match, - val2str (link_desc.asym_match, ipmi_ekanalyzer_asym_STORAGE) ); - break; - default: - printf(" - Link Type extension: %i\n", link_desc.type_ext ); - printf(" - Link Group ID: %d || ", link_desc.group_id ); - printf("Link Asym. Match: %i\n", link_desc.asym_match); - break; - } - /*return as OEM type if link type indicates OEM*/ - if ( (link_desc.type >= LOWER_OEM_TYPE) - && - (link_desc.type <= UPPER_OEM_TYPE) - ){ - isOEMtype = TRUE; - } - - return isOEMtype; + tboolean isOEMtype = FALSE; + if (file_type == ON_CARRIER_FRU_FILE) { + printf(" - %s On-Carrier Device ID %d\n", str, + (rsc_id & 0x0f)); + } else { + printf(" - %s %s\n", str, val2str(file_type, + ipmi_ekanalyzer_module_type)); + } + printf(" - Channel ID %d || ", link_desc.channel_id); + printf("%s", link_desc.port_flag_0 ? "Lane 0: enable" : ""); + printf("%s", link_desc.port_flag_1 ? ", Lane 1: enable" : ""); + printf("%s", link_desc.port_flag_2 ? ", Lane 2: enable" : ""); + printf("%s", link_desc.port_flag_3 ? ", Lane 3: enable" : ""); + printf("\n"); + printf(" - Link Type: %s \n", val2str(link_desc.type, + ipmi_ekanalyzer_link_type)); + switch (link_desc.type) { + case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE: + case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS1: + case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS2: + printf(" - Link Type extension: %s\n", + val2str(link_desc.type_ext, + ipmi_ekanalyzer_extension_PCIE)); + printf(" - Link Group ID: %d || ", link_desc.group_id); + printf("Link Asym. Match: %d - %s\n", + link_desc.asym_match, + val2str(link_desc.asym_match, + ipmi_ekanalyzer_asym_PCIE)); + break; + case FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET: + printf(" - Link Type extension: %s\n", + val2str(link_desc.type_ext, + ipmi_ekanalyzer_extension_ETHERNET)); + printf(" - Link Group ID: %d || ", link_desc.group_id); + printf("Link Asym. Match: %d - %s\n", + link_desc.asym_match, + val2str(link_desc.asym_match, + ipmi_ekanalyzer_asym_PCIE)); + break; + case FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE: + printf(" - Link Type extension: %s\n", + val2str(link_desc.type_ext, + ipmi_ekanalyzer_extension_STORAGE)); + printf(" - Link Group ID: %d || ", + link_desc.group_id); + printf("Link Asym. Match: %d - %s\n", + link_desc.asym_match, + val2str(link_desc.asym_match, + ipmi_ekanalyzer_asym_STORAGE)); + break; + default: + printf(" - Link Type extension: %i\n", + link_desc.type_ext); + printf(" - Link Group ID: %d || ", + link_desc.group_id); + printf("Link Asym. Match: %i\n", + link_desc.asym_match); + break; + } + /* return as OEM type if link type indicates OEM */ + if ((link_desc.type >= LOWER_OEM_TYPE) + && (link_desc.type <= UPPER_OEM_TYPE)) { + isOEMtype = TRUE; + } + return isOEMtype; } /************************************************************************** @@ -2180,26 +2153,27 @@ ipmi_ek_display_link_descriptor( int file_type, unsigned char rsc_id, * ***************************************************************************/ static void -ipmi_ek_display_oem_guid( - struct ipmi_ek_amc_p2p_connectivity_record amc_record ) +ipmi_ek_display_oem_guid(struct ipmi_ek_amc_p2p_connectivity_record amc_record) { - int index_oem = 0; - int index = 0; - - if ( amc_record.guid_count == 0 ){ - printf("\tThere is no OEM GUID for this module\n"); - } - for (index_oem = 0; index_oem < amc_record.guid_count; index_oem++){ - printf(" - GUID: "); - for(index = 0; index < SIZE_OF_GUID; index++){ - printf("%02x", amc_record.oem_guid[index_oem].guid[index]); - /*For a better look: putting a "-" after displaying four bytes of GUID*/ - if (!(index % 4)){ - printf("-"); - } - } - printf("\n"); - } + int index_oem = 0; + int index = 0; + if (amc_record.guid_count == 0) { + printf("\tThere is no OEM GUID for this module\n"); + } + for (index_oem = 0; index_oem < amc_record.guid_count; index_oem++) { + printf(" - GUID: "); + for (index = 0; index < SIZE_OF_GUID; index++) { + printf("%02x", + amc_record.oem_guid[index_oem].guid[index]); + /* For a better look: putting a "-" after displaying + * four bytes of GUID + */ + if (!(index % 4)){ + printf("-"); + } + } + printf("\n"); + } } /************************************************************************** @@ -2222,8 +2196,8 @@ ipmi_ek_display_oem_guid( * ***************************************************************************/ static int -ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header * record, - struct ipmi_ek_amc_p2p_connectivity_record * amc_record) +ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header *record, + struct ipmi_ek_amc_p2p_connectivity_record *amc_record) { int index_data = START_DATA_OFFSET; int return_status = OK_STATUS; @@ -2334,20 +2308,18 @@ ipmi_ek_create_amc_p2p_record(struct ipmi_ek_multi_header * record, * ***************************************************************************/ static int -ipmi_ek_get_resource_descriptor( int port_count, int index, - struct fru_picmgext_carrier_p2p_descriptor * port_desc, - struct ipmi_ek_multi_header * record ) +ipmi_ek_get_resource_descriptor(int port_count, int index, + struct fru_picmgext_carrier_p2p_descriptor *port_desc, + struct ipmi_ek_multi_header *record) { - int num_port = 0; - - while ( num_port < port_count ){ - memcpy ( &port_desc[num_port], &record->data[index], - sizeof (struct fru_picmgext_carrier_p2p_descriptor) ); - index += sizeof (struct fru_picmgext_carrier_p2p_descriptor); - num_port++; - } - - return index; + int num_port = 0; + while (num_port < port_count) { + memcpy(&port_desc[num_port], &record->data[index], + sizeof (struct fru_picmgext_carrier_p2p_descriptor)); + index += sizeof (struct fru_picmgext_carrier_p2p_descriptor); + num_port++; + } + return index; } /************************************************************************** @@ -2369,9 +2341,9 @@ ipmi_ek_get_resource_descriptor( int port_count, int index, * ***************************************************************************/ static int -ipmi_ek_display_fru_header(char * filename) +ipmi_ek_display_fru_header(char *filename) { - FILE * input_file; + FILE *input_file; struct fru_header header; int ret = 0; @@ -2424,11 +2396,11 @@ ipmi_ek_display_fru_header(char * filename) * ***************************************************************************/ static int -ipmi_ek_display_fru_header_detail(char * filename) +ipmi_ek_display_fru_header_detail(char *filename) { # define FACTOR_OFFSET 8 # define SIZE_MFG_DATE 3 - FILE * input_file; + FILE *input_file; size_t file_offset = 0; struct fru_header header; time_t tval; @@ -2623,7 +2595,7 @@ ipmi_ek_display_fru_header_detail(char * filename) * ***************************************************************************/ static int -ipmi_ek_display_chassis_info_area(FILE * input_file, long offset) +ipmi_ek_display_chassis_info_area(FILE *input_file, long offset) { size_t file_offset; int ret = 0; @@ -2707,8 +2679,8 @@ ipmi_ek_display_chassis_info_area(FILE * input_file, long offset) * ***************************************************************************/ static size_t -ipmi_ek_display_board_info_area(FILE * input_file, char * board_type, - unsigned int * board_length) +ipmi_ek_display_board_info_area(FILE *input_file, char *board_type, + unsigned int *board_length) { size_t file_offset; int ret = 0; @@ -2845,7 +2817,7 @@ out: * ***************************************************************************/ static int -ipmi_ek_display_product_info_area(FILE * input_file, long offset) +ipmi_ek_display_product_info_area(FILE *input_file, long offset) { size_t file_offset; int ret = 0; @@ -2950,102 +2922,105 @@ ipmi_ek_display_product_info_area(FILE * input_file, long offset) * ***************************************************************************/ static void -ipmi_ek_display_record( struct ipmi_ek_multi_header * record, - struct ipmi_ek_multi_header * list_head, - struct ipmi_ek_multi_header * list_last ) +ipmi_ek_display_record(struct ipmi_ek_multi_header *record, + struct ipmi_ek_multi_header *list_head, + struct ipmi_ek_multi_header *list_last) { - if ( list_head == NULL ){ - printf("***empty list***\n"); - } - else{ - printf("%s\n", EQUAL_LINE_LIMITER); - printf("FRU Multi Info area\n"); - printf("%s\n", EQUAL_LINE_LIMITER); - for ( record = list_head; record != NULL; record = record->next ){ - printf("Record Type ID: 0x%02x\n", record->header.type); - printf("Record Format version: 0x%02x\n", record->header.format); - if (record->header.len > PICMG_ID_OFFSET){ - /* In picmg3.0 specification, picmg record id lower than 4 or - * greater than 0x2d is not supported - */ - #define PICMG_ID_LOWER_LIMIT 0x04 - #define PICMG_ID_UPPER_LIMIT 0x2d - unsigned char picmg_id; - - picmg_id = record->data[PICMG_ID_OFFSET]; - printf("Manufacturer ID: %02x%02x%02x h\n", record->data[2], - record->data[1], record->data[0] ); - if( ( picmg_id < PICMG_ID_LOWER_LIMIT ) - || - ( picmg_id > PICMG_ID_UPPER_LIMIT ) ){ - printf("Picmg record ID: Unsupported {0x%02x}\n", picmg_id ); - } - else{ - printf("Picmg record ID: %s {0x%02x}\n", - val2str(picmg_id, ipmi_ekanalyzer_picmg_record_id), - picmg_id ); - } - switch (picmg_id){ - case FRU_PICMG_BACKPLANE_P2P: /*0x04*/ - ipmi_ek_display_backplane_p2p_record (record); - break; - case FRU_PICMG_ADDRESS_TABLE: /*0x10*/ - ipmi_ek_display_address_table_record (record); - break; - case FRU_PICMG_SHELF_POWER_DIST: /*0x11*/ - ipmi_ek_display_shelf_power_distribution_record (record); - break; - case FRU_PICMG_SHELF_ACTIVATION: /*/0x12*/ - ipmi_ek_display_shelf_activation_record (record); - break; - case FRU_PICMG_SHMC_IP_CONN: /*0x13*/ - ipmi_ek_display_shelf_ip_connection_record (record); - break; - case FRU_PICMG_BOARD_P2P: /*0x14*/ - ipmi_ek_display_board_p2p_record (record); - break; - case FRU_RADIAL_IPMB0_LINK_MAPPING: /*0x15*/ - ipmi_ek_display_radial_ipmb0_record (record); - break; - case FRU_AMC_CURRENT: /*0x16*/ - ipmi_ek_display_amc_current_record (record); - break; - case FRU_AMC_ACTIVATION: /*0x17*/ - ipmi_ek_display_amc_activation_record (record); - break; - case FRU_AMC_CARRIER_P2P: /*0x18*/ - ipmi_ek_display_carrier_connectivity (record); - break; - case FRU_AMC_P2P: /*0x19*/ - ipmi_ek_display_amc_p2p_record (record); - break; - case FRU_AMC_CARRIER_INFO: /*0x1a*/ - ipmi_ek_display_amc_carrier_info_record (record); - break; - case FRU_PICMG_CLK_CARRIER_P2P: /*0x2c*/ - ipmi_ek_display_clock_carrier_p2p_record (record); - break; - case FRU_PICMG_CLK_CONFIG: /*0x2d*/ - ipmi_ek_display_clock_config_record (record); - break; - default: - if (verbose > 0){ - int i; - printf("%02x %02x %02x %02x %02x ", record->header.type, - record->header.format, record->header.len, - record->header.record_checksum, - record->header.header_checksum ); - for ( i = 0; i < record->header.len; i++ ){ - printf("%02x ", record->data[i]); - } - printf("\n"); - } - break; - } - printf("%s\n", STAR_LINE_LIMITER); - } - } - } + if (list_head == NULL) { + printf("***empty list***\n"); + return; + } + printf("%s\n", EQUAL_LINE_LIMITER); + printf("FRU Multi Info area\n"); + printf("%s\n", EQUAL_LINE_LIMITER); + for (record = list_head; record != NULL; record = record->next) { + printf("Record Type ID: 0x%02x\n", record->header.type); + printf("Record Format version: 0x%02x\n", + record->header.format); + if (record->header.len <= PICMG_ID_OFFSET) { + continue; + } + /* In picmg3.0 specification, picmg record + * id lower than 4 or greater than 0x2d + * isn't supported + */ + #define PICMG_ID_LOWER_LIMIT 0x04 + #define PICMG_ID_UPPER_LIMIT 0x2d + unsigned char picmg_id; + + picmg_id = record->data[PICMG_ID_OFFSET]; + printf("Manufacturer ID: %02x%02x%02x h\n", + record->data[2], record->data[1], + record->data[0]); + if ((picmg_id < PICMG_ID_LOWER_LIMIT) + || (picmg_id > PICMG_ID_UPPER_LIMIT)) { + printf("Picmg record ID: Unsupported {0x%02x}\n", picmg_id); + } else { + printf("Picmg record ID: %s {0x%02x}\n", + val2str(picmg_id, ipmi_ekanalyzer_picmg_record_id), + picmg_id); + } + switch (picmg_id) { + case FRU_PICMG_BACKPLANE_P2P: /*0x04*/ + ipmi_ek_display_backplane_p2p_record (record); + break; + case FRU_PICMG_ADDRESS_TABLE: /*0x10*/ + ipmi_ek_display_address_table_record (record); + break; + case FRU_PICMG_SHELF_POWER_DIST: /*0x11*/ + ipmi_ek_display_shelf_power_distribution_record (record); + break; + case FRU_PICMG_SHELF_ACTIVATION: /*/0x12*/ + ipmi_ek_display_shelf_activation_record (record); + break; + case FRU_PICMG_SHMC_IP_CONN: /*0x13*/ + ipmi_ek_display_shelf_ip_connection_record (record); + break; + case FRU_PICMG_BOARD_P2P: /*0x14*/ + ipmi_ek_display_board_p2p_record (record); + break; + case FRU_RADIAL_IPMB0_LINK_MAPPING: /*0x15*/ + ipmi_ek_display_radial_ipmb0_record (record); + break; + case FRU_AMC_CURRENT: /*0x16*/ + ipmi_ek_display_amc_current_record (record); + break; + case FRU_AMC_ACTIVATION: /*0x17*/ + ipmi_ek_display_amc_activation_record (record); + break; + case FRU_AMC_CARRIER_P2P: /*0x18*/ + ipmi_ek_display_carrier_connectivity (record); + break; + case FRU_AMC_P2P: /*0x19*/ + ipmi_ek_display_amc_p2p_record (record); + break; + case FRU_AMC_CARRIER_INFO: /*0x1a*/ + ipmi_ek_display_amc_carrier_info_record (record); + break; + case FRU_PICMG_CLK_CARRIER_P2P: /*0x2c*/ + ipmi_ek_display_clock_carrier_p2p_record (record); + break; + case FRU_PICMG_CLK_CONFIG: /*0x2d*/ + ipmi_ek_display_clock_config_record (record); + break; + default: + if (verbose > 0) { + int i; + printf("%02x %02x %02x %02x %02x ", + record->header.type, + record->header.format, + record->header.len, + record->header.record_checksum, + record->header.header_checksum); + for (i = 0; i < record->header.len; i++) { + printf("%02x ", record->data[i]); + } + printf("\n"); + } + break; + } + printf("%s\n", STAR_LINE_LIMITER); + } } /************************************************************************** @@ -3066,62 +3041,59 @@ ipmi_ek_display_record( struct ipmi_ek_multi_header * record, * ***************************************************************************/ static void -ipmi_ek_display_backplane_p2p_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_backplane_p2p_record(struct ipmi_ek_multi_header *record) { - uint8_t index; - int offset = START_DATA_OFFSET; - struct fru_picmgext_slot_desc * slot_d - = (struct fru_picmgext_slot_desc*) &record->data[offset]; - - offset += sizeof(struct fru_picmgext_slot_desc); - - while ( offset <= record->header.len ) { - printf(" Channel Type: "); - switch ( slot_d -> chan_type ) - { - case 0x00: - case 0x07: - printf("PICMG 2.9\n"); - break; - case 0x08: - printf("Single Port Fabric IF\n"); - break; - case 0x09: - printf("Double Port Fabric IF\n"); - break; - case 0x0a: - printf("Full Channel Fabric IF\n"); - break; - case 0x0b: - printf("Base IF\n"); - break; - case 0x0c: - printf("Update Channel IF\n"); - break; - default: - printf("Unknown IF\n"); - break; - } - printf(" Slot Address: %02x\n", slot_d -> slot_addr); - printf(" Channel Count: %i\n", slot_d -> chn_count); - - for ( index = 0; index < (slot_d -> chn_count); index++ ) { - struct fru_picmgext_chn_desc * d - = (struct fru_picmgext_chn_desc *) &record->data[offset]; - - if ( verbose ){ - printf( "\t" - "Chn: %02x --> " - "Chn: %02x in " - "Slot: %02x\n", - d->local_chn, d->remote_chn, d->remote_slot - ); - } - offset += sizeof(struct fru_picmgext_chn_desc); - } - slot_d = (struct fru_picmgext_slot_desc*) &record->data[offset]; - offset += sizeof(struct fru_picmgext_slot_desc); - } + uint8_t index; + int offset = START_DATA_OFFSET; + struct fru_picmgext_slot_desc *slot_d = + (struct fru_picmgext_slot_desc*)&record->data[offset]; + + offset += sizeof(struct fru_picmgext_slot_desc); + while (offset <= record->header.len) { + printf(" Channel Type: "); + switch (slot_d->chan_type) { + case 0x00: + case 0x07: + printf("PICMG 2.9\n"); + break; + case 0x08: + printf("Single Port Fabric IF\n"); + break; + case 0x09: + printf("Double Port Fabric IF\n"); + break; + case 0x0a: + printf("Full Channel Fabric IF\n"); + break; + case 0x0b: + printf("Base IF\n"); + break; + case 0x0c: + printf("Update Channel IF\n"); + break; + default: + printf("Unknown IF\n"); + break; + } + printf(" Slot Address: %02x\n", slot_d->slot_addr); + printf(" Channel Count: %i\n", slot_d->chn_count); + for (index = 0; index < (slot_d->chn_count); index++) { + struct fru_picmgext_chn_desc *d = + (struct fru_picmgext_chn_desc *)&record->data[offset]; + if (verbose) { + printf("\t" + "Chn: %02x --> " + "Chn: %02x in " + "Slot: %02x\n", + d->local_chn, + d->remote_chn, + d->remote_slot); + } + offset += sizeof(struct fru_picmgext_chn_desc); + } + slot_d = (struct fru_picmgext_slot_desc*)&record->data[offset]; + offset += sizeof(struct fru_picmgext_slot_desc); + } } /************************************************************************** @@ -3142,30 +3114,28 @@ ipmi_ek_display_backplane_p2p_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static void -ipmi_ek_display_address_table_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_address_table_record(struct ipmi_ek_multi_header *record) { - unsigned char entries = 0; - unsigned char i; - int offset = START_DATA_OFFSET; - #define SIZE_SHELF_ADDRESS_BYTE 20 - - printf(" Type/Len: 0x%02x\n", record->data[offset++]); - printf(" Shelf Addr: "); - for ( i = 0; i < SIZE_SHELF_ADDRESS_BYTE; i++ ){ - printf("0x%02x ", record->data[offset++]); - } - printf("\n"); - - entries = record->data[offset++]; - printf(" Addr Table Entries count: 0x%02x\n", entries); - - for ( i = 0; i < entries; i++ ){ - printf("\tHWAddr: 0x%02x - SiteNum: 0x%02x - SiteType: 0x%02x \n", - record->data[offset+0], - record->data[offset+1], - record->data[offset+2]); - offset += 3; - } +#define SIZE_SHELF_ADDRESS_BYTE 20 + unsigned char entries = 0; + unsigned char i; + int offset = START_DATA_OFFSET; + + printf(" Type/Len: 0x%02x\n", record->data[offset++]); + printf(" Shelf Addr: "); + for (i = 0; i < SIZE_SHELF_ADDRESS_BYTE; i++) { + printf("0x%02x ", record->data[offset++]); + } + printf("\n"); + entries = record->data[offset++]; + printf(" Addr Table Entries count: 0x%02x\n", entries); + for (i = 0; i < entries; i++) { + printf("\tHWAddr: 0x%02x - SiteNum: 0x%02x - SiteType: 0x%02x \n", + record->data[offset+0], + record->data[offset+1], + record->data[offset+2]); + offset += 3; + } } /************************************************************************** @@ -3187,36 +3157,38 @@ ipmi_ek_display_address_table_record( struct ipmi_ek_multi_header * record ) ***************************************************************************/ static void ipmi_ek_display_shelf_power_distribution_record( - struct ipmi_ek_multi_header * record ) + struct ipmi_ek_multi_header *record) { - int offset = START_DATA_OFFSET; - unsigned char i,j; - unsigned char feeds = 0; - - feeds = record->data[offset++]; - printf(" Number of Power Feeds: 0x%02x\n", feeds); - - for (i=0; i<feeds; i++) { - unsigned char entries; - unsigned long max_ext = 0; - unsigned long max_int = 0; - max_ext = record->data[offset+0] | (record->data[offset+1]<<8); - printf(" Max External Available Current: %ld Amps\n", (max_ext*10) ); - - offset += 2; - - max_int = record->data[offset+0] | (record->data[offset+1]<<8); - printf(" Max Internal Current:\t %ld Amps\n", (max_int*10)); - offset += 2; - printf(" Min Expected Operating Voltage: %d Volts\n", - (record->data[offset++]/2)); - entries = record->data[offset++]; - printf(" Feed to FRU count: 0x%02x\n", entries); - for (j=0; j<entries; j++) { - printf("\tHW: 0x%02x", record->data[offset++]); - printf("\tFRU ID: 0x%02x\n", record->data[offset++]); - } - } + int offset = START_DATA_OFFSET; + unsigned char i; + unsigned char j; + unsigned char feeds = 0; + + feeds = record->data[offset++]; + printf(" Number of Power Feeds: 0x%02x\n", feeds); + for (i = 0; i < feeds; i++) { + unsigned char entries; + unsigned long max_ext = 0; + unsigned long max_int = 0; + max_ext = record->data[offset+0] + | (record->data[offset+1] << 8); + printf(" Max External Available Current: %ld Amps\n", + (max_ext * 10)); + offset += 2; + max_int = record->data[offset+0] + | (record->data[offset+1] << 8); + printf(" Max Internal Current:\t %ld Amps\n", + (max_int * 10)); + offset += 2; + printf(" Min Expected Operating Voltage: %d Volts\n", + (record->data[offset++] / 2)); + entries = record->data[offset++]; + printf(" Feed to FRU count: 0x%02x\n", entries); + for (j = 0; j < entries; j++) { + printf("\tHW: 0x%02x", record->data[offset++]); + printf("\tFRU ID: 0x%02x\n", record->data[offset++]); + } + } } /************************************************************************** @@ -3237,27 +3209,29 @@ ipmi_ek_display_shelf_power_distribution_record( * ***************************************************************************/ static void -ipmi_ek_display_shelf_activation_record( - struct ipmi_ek_multi_header * record ) +ipmi_ek_display_shelf_activation_record(struct ipmi_ek_multi_header *record) { - unsigned char count = 0; - int offset = START_DATA_OFFSET; - - printf(" Allowance for FRU Act Readiness: 0x%02x\n", - record->data[offset++]); - count = record->data[offset++]; - printf(" FRU activation and Power Desc Cnt: 0x%02x\n", count); - - while ( count > 0 ) { - printf(" FRU activation and Power descriptor:\n"); - printf("\tHardware Address:\t\t0x%02x\n", record->data[offset++]); - printf("\tFRU Device ID:\t\t\t0x%02x\n", record->data[offset++]); - printf("\tMax FRU Power Capability:\t0x%04x Watts\n", - ( record->data[offset+0] | (record->data[offset+1]<<8) )); - offset += 2; - printf("\tConfiguration parameter:\t0x%02x\n", record->data[offset++]); - count --; - } + unsigned char count = 0; + int offset = START_DATA_OFFSET; + + printf(" Allowance for FRU Act Readiness: 0x%02x\n", + record->data[offset++]); + count = record->data[offset++]; + printf(" FRU activation and Power Desc Cnt: 0x%02x\n", count); + while (count > 0) { + printf(" FRU activation and Power descriptor:\n"); + printf("\tHardware Address:\t\t0x%02x\n", + record->data[offset++]); + printf("\tFRU Device ID:\t\t\t0x%02x\n", + record->data[offset++]); + printf("\tMax FRU Power Capability:\t0x%04x Watts\n", + (record->data[offset+0] + | (record->data[offset+1]<<8))); + offset += 2; + printf("\tConfiguration parameter:\t0x%02x\n", + record->data[offset++]); + count --; + } } /************************************************************************** @@ -3279,28 +3253,33 @@ ipmi_ek_display_shelf_activation_record( * ***************************************************************************/ static void -ipmi_ek_display_shelf_ip_connection_record( - struct ipmi_ek_multi_header * record ) +ipmi_ek_display_shelf_ip_connection_record(struct ipmi_ek_multi_header *record) { - int ioffset = START_DATA_OFFSET; - if (ioffset > record->header.len) { - printf(" Shelf Manager IP Address: %d.%d.%d.%d\n", - record->data[ioffset+0], record->data[ioffset+1], - record->data[ioffset+2], record->data[ioffset+3]); - ioffset += 4; - } - if (ioffset > record->header.len) { - printf(" Default Gateway Address: %d.%d.%d.%d\n", - record->data[ioffset+0], record->data[ioffset+1], - record->data[ioffset+2], record->data[ioffset+3]); - ioffset += 4; - } - if (ioffset > record->header.len) { - printf(" Subnet Mask: %d.%d.%d.%d\n", - record->data[ioffset+0], record->data[ioffset+1], - record->data[ioffset+2], record->data[ioffset+3]); - ioffset += 4; - } + int ioffset = START_DATA_OFFSET; + if (ioffset > record->header.len) { + printf(" Shelf Manager IP Address: %d.%d.%d.%d\n", + record->data[ioffset+0], + record->data[ioffset+1], + record->data[ioffset+2], + record->data[ioffset+3]); + ioffset += 4; + } + if (ioffset > record->header.len) { + printf(" Default Gateway Address: %d.%d.%d.%d\n", + record->data[ioffset+0], + record->data[ioffset+1], + record->data[ioffset+2], + record->data[ioffset+3]); + ioffset += 4; + } + if (ioffset > record->header.len) { + printf(" Subnet Mask: %d.%d.%d.%d\n", + record->data[ioffset+0], + record->data[ioffset+1], + record->data[ioffset+2], + record->data[ioffset+3]); + ioffset += 4; + } } /************************************************************************** @@ -3322,28 +3301,30 @@ ipmi_ek_display_shelf_ip_connection_record( * ***************************************************************************/ static void -ipmi_ek_display_shelf_fan_geography_record( - struct ipmi_ek_multi_header * record ) +ipmi_ek_display_shelf_fan_geography_record(struct ipmi_ek_multi_header *record) { - int ioffset = START_DATA_OFFSET; - unsigned char fan_count = 0; - - fan_count = record->data[ioffset]; - ioffset++; - printf(" Fan-to-FRU Entry Count: 0x%02x\n", fan_count); - - while ( (fan_count > 0) && (ioffset <= record->header.len) ) { - printf(" Fan-to-FRU Mapping Entry: {%2x%2x%2x%2x}\n", - record->data[ioffset], record->data[ioffset+1], - record->data[ioffset+2], record->data[ioffset+3] - ); - printf(" Hardware Address: 0x%02x\n", record->data[ioffset++]); - printf(" FRU device ID: 0x%02x\n", record->data[ioffset++]); - printf(" Site Number: 0x%02x\n", record->data[ioffset++]); - printf(" Site Type: 0x%02x\n", record->data[ioffset++]); - fan_count --; - } - + int ioffset = START_DATA_OFFSET; + unsigned char fan_count = 0; + + fan_count = record->data[ioffset]; + ioffset++; + printf(" Fan-to-FRU Entry Count: 0x%02x\n", fan_count); + while ((fan_count > 0) && (ioffset <= record->header.len)) { + printf(" Fan-to-FRU Mapping Entry: {%2x%2x%2x%2x}\n", + record->data[ioffset], + record->data[ioffset+1], + record->data[ioffset+2], + record->data[ioffset+3]); + printf(" Hardware Address: 0x%02x\n", + record->data[ioffset++]); + printf(" FRU device ID: 0x%02x\n", + record->data[ioffset++]); + printf(" Site Number: 0x%02x\n", + record->data[ioffset++]); + printf(" Site Type: 0x%02x\n", + record->data[ioffset++]); + fan_count --; + } } /************************************************************************** @@ -3364,147 +3345,133 @@ ipmi_ek_display_shelf_fan_geography_record( * ***************************************************************************/ static void -ipmi_ek_display_board_p2p_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_board_p2p_record(struct ipmi_ek_multi_header *record) { - unsigned char guid_count; - int offset = START_DATA_OFFSET; - int i = 0; - - guid_count = record->data[offset++]; - printf(" GUID count: %2d\n", guid_count); - - for (i = 0 ; i < guid_count; i++ ) { - int j; - printf("\tGUID: "); - for (j=0; j < sizeof(struct fru_picmgext_guid); j++) { - printf("%02x", record->data[offset+j]); - } - printf("\n"); - offset += sizeof(struct fru_picmgext_guid); - } - - for ( offset; - offset < record->header.len; - offset += sizeof(struct fru_picmgext_link_desc) - ) { - /* to solve little endian /big endian problem */ - unsigned long data; - struct fru_picmgext_link_desc * d; - - data = (record->data[offset+0]) | (record->data[offset+1] << 8)\ - | (record->data[offset+2] << 16)\ - | (record->data[offset+3] << 24); - - d = (struct fru_picmgext_link_desc *) &data; - - printf(" Link Descriptor\n"); - printf("\tLink Grouping ID:\t0x%02x\n", d->grouping); - printf("\tLink Type Extension:\t0x%02x - ", d->ext); - - if (d->type == FRU_PICMGEXT_LINK_TYPE_BASE){ - switch (d->ext){ - case 0: - printf("10/100/1000BASE-T Link (four-pair)\n"); - break; - case 1: - printf("ShMC Cross-connect (two-pair)\n"); - break; - default: - printf("Unknwon\n"); - break; - } - } - else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET){ - switch (d->ext){ - case 0: - printf("Fixed 1000Base-BX\n"); - break; - case 1: - printf("Fixed 10GBASE-BX4 [XAUI]\n"); - break; - case 2: - printf("FC-PI\n"); - break; - default: - printf("Unknwon\n"); - break; - } - } - else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND){ - printf("Unknwon\n"); - } - else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR){ - printf("Unknwon\n"); - } - else if (d->type == FRU_PICMGEXT_LINK_TYPE_PCIE){ - printf("Unknwon\n"); - } - else{ - printf("Unknwon\n"); - } - - printf("\tLink Type:\t\t0x%02x - ",d->type); - if (d->type == 0 || d->type == 0xff){ - printf("Reserved\n"); - } - else if (d->type >= 0x06 && d->type <= 0xef) { - printf("Reserved\n"); - } - else if (d->type >= LOWER_OEM_TYPE && d->type <= UPPER_OEM_TYPE) { - printf("OEM GUID Definition\n"); - } - else { - switch (d->type){ - case FRU_PICMGEXT_LINK_TYPE_BASE: - printf("PICMG 3.0 Base Interface 10/100/1000\n"); - break; - case FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET: - printf("PICMG 3.1 Ethernet Fabric Interface\n"); - break; - case FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND: - printf("PICMG 3.2 Infiniband Fabric Interface\n"); - break; - case FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR: - printf("PICMG 3.3 Star Fabric Interface\n"); - break; - case FRU_PICMGEXT_LINK_TYPE_PCIE: - printf("PICMG 3.4 PCI Express Fabric Interface\n"); - break; - default: - printf("Invalid\n"); - break; - } - } - printf("\tLink Designator: \n"); - printf("\t Port 0 Flag: %s\n", - (d->desig_port & 0x01) ? "enable" : "disable"); - printf("\t Port 1 Flag: %s\n", - (d->desig_port & 0x02) ? "enable" : "disable"); - printf("\t Port 2 Flag: %s\n", - (d->desig_port & 0x04) ? "enable" : "disable"); - printf("\t Port 3 Flag: %s\n", - (d->desig_port & 0x08) ? "enable" : "disable"); - - printf("\t Interface: 0x%02x - ", d->desig_if); - switch (d->desig_if){ - case FRU_PICMGEXT_DESIGN_IF_BASE: - printf("Base Interface\n"); - break; - case FRU_PICMGEXT_DESIGN_IF_FABRIC: - printf("Fabric Interface\n"); - break; - case FRU_PICMGEXT_DESIGN_IF_UPDATE_CHANNEL: - printf("Update Channel\n"); - break; - case FRU_PICMGEXT_DESIGN_IF_RESERVED: - printf("Reserved\n"); - break; - default: - printf("Invalid"); - break; - } - printf("\t Channel Number: 0x%02x\n", d->desig_channel); - } + unsigned char guid_count; + int offset = START_DATA_OFFSET; + int i = 0; + + guid_count = record->data[offset++]; + printf(" GUID count: %2d\n", guid_count); + for (i = 0 ; i < guid_count; i++) { + int j; + printf("\tGUID: "); + for (j = 0; j < sizeof(struct fru_picmgext_guid); j++) { + printf("%02x", record->data[offset+j]); + } + printf("\n"); + offset += sizeof(struct fru_picmgext_guid); + } + for (offset; + offset < record->header.len; + offset += sizeof(struct fru_picmgext_link_desc)) { + /* to solve little endian/big endian problem */ + unsigned long data; + struct fru_picmgext_link_desc * d; + data = (record->data[offset+0]) + | (record->data[offset+1] << 8)\ + | (record->data[offset+2] << 16)\ + | (record->data[offset+3] << 24); + d = (struct fru_picmgext_link_desc *)&data; + + printf(" Link Descriptor\n"); + printf("\tLink Grouping ID:\t0x%02x\n", d->grouping); + printf("\tLink Type Extension:\t0x%02x - ", d->ext); + if (d->type == FRU_PICMGEXT_LINK_TYPE_BASE) { + switch (d->ext) { + case 0: + printf("10/100/1000BASE-T Link (four-pair)\n"); + break; + case 1: + printf("ShMC Cross-connect (two-pair)\n"); + break; + default: + printf("Unknwon\n"); + break; + } + } else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET) { + switch (d->ext) { + case 0: + printf("Fixed 1000Base-BX\n"); + break; + case 1: + printf("Fixed 10GBASE-BX4 [XAUI]\n"); + break; + case 2: + printf("FC-PI\n"); + break; + default: + printf("Unknwon\n"); + break; + } + } else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND) { + printf("Unknwon\n"); + } else if (d->type == FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR) { + printf("Unknwon\n"); + } else if (d->type == FRU_PICMGEXT_LINK_TYPE_PCIE) { + printf("Unknwon\n"); + } else { + printf("Unknwon\n"); + } + printf("\tLink Type:\t\t0x%02x - ", d->type); + if (d->type == 0 || d->type == 0xff) { + printf("Reserved\n"); + } else if (d->type >= 0x06 && d->type <= 0xef) { + printf("Reserved\n"); + } else if (d->type >= LOWER_OEM_TYPE && d->type <= UPPER_OEM_TYPE) { + printf("OEM GUID Definition\n"); + } else { + switch (d->type){ + case FRU_PICMGEXT_LINK_TYPE_BASE: + printf("PICMG 3.0 Base Interface 10/100/1000\n"); + break; + case FRU_PICMGEXT_LINK_TYPE_FABRIC_ETHERNET: + printf("PICMG 3.1 Ethernet Fabric Interface\n"); + break; + case FRU_PICMGEXT_LINK_TYPE_FABRIC_INFINIBAND: + printf("PICMG 3.2 Infiniband Fabric Interface\n"); + break; + case FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR: + printf("PICMG 3.3 Star Fabric Interface\n"); + break; + case FRU_PICMGEXT_LINK_TYPE_PCIE: + printf("PICMG 3.4 PCI Express Fabric Interface\n"); + break; + default: + printf("Invalid\n"); + break; + } + } + printf("\tLink Designator: \n"); + printf("\t Port 0 Flag: %s\n", + (d->desig_port & 0x01) ? "enable" : "disable"); + printf("\t Port 1 Flag: %s\n", + (d->desig_port & 0x02) ? "enable" : "disable"); + printf("\t Port 2 Flag: %s\n", + (d->desig_port & 0x04) ? "enable" : "disable"); + printf("\t Port 3 Flag: %s\n", + (d->desig_port & 0x08) ? "enable" : "disable"); + printf("\t Interface: 0x%02x - ", d->desig_if); + switch (d->desig_if) { + case FRU_PICMGEXT_DESIGN_IF_BASE: + printf("Base Interface\n"); + break; + case FRU_PICMGEXT_DESIGN_IF_FABRIC: + printf("Fabric Interface\n"); + break; + case FRU_PICMGEXT_DESIGN_IF_UPDATE_CHANNEL: + printf("Update Channel\n"); + break; + case FRU_PICMGEXT_DESIGN_IF_RESERVED: + printf("Reserved\n"); + break; + default: + printf("Invalid"); + break; + } + printf("\t Channel Number: 0x%02x\n", + d->desig_channel); + } } /************************************************************************** @@ -3525,63 +3492,64 @@ ipmi_ek_display_board_p2p_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static void -ipmi_ek_display_radial_ipmb0_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_radial_ipmb0_record(struct ipmi_ek_multi_header *record) { - int offset = START_DATA_OFFSET; - #define SIZE_OF_CONNECTOR_DEFINER 3; /*bytes*/ - - /*Ref: PICMG 3.0 Specification Revision 2.0, Table 3-59*/ - printf(" IPMB-0 Connector Definer: "); - #ifndef WORDS_BIGENDIAN - printf("%02x %02x %02x h\n", record->data[offset], - record->data[offset+1], record->data[offset+2]); - #else - printf("%02x %02x %02x h\n", record->data[offset+2], - record->data[offset+1], record->data[offset]); - #endif - /*3 bytes of connector definer was used*/ - offset += SIZE_OF_CONNECTOR_DEFINER; - - printf (" IPMB-0 Connector version ID: "); - #ifndef WORDS_BIGENDIAN - printf("%02x %02x h\n", record->data[offset], record->data[offset+1]); - #else - printf("%02x %02x h\n", record->data[offset+1], record->data[offset]); - #endif - offset += 2; - - printf(" IPMB-0 Hub Descriptor Count: 0x%02x", record->data[offset++]); - if (record->data[offset] > 0){ - for (offset; offset < record->header.len;){ - unsigned char entry_count = 0; - printf(" IPMB-0 Hub Descriptor\n"); - printf("\tHardware Address: 0x%02x\n", record->data[offset++]); - printf("\tHub Info {0x%02x}: ", record->data[offset]); - /* Bit mask specified in Table 3-59 of PICMG 3.0 Specification */ - if ( (record->data[offset] & 0x01) == 0x01 ){ - printf("IPMB-A only\n"); - } - else if ( (record->data[offset] & 0x02) == 0x02 ){ - printf("IPMB-B only\n"); - } - else if ( (record->data[offset] & 0x03) == 0x03 ){ - printf("IPMB-A and IPMB-B\n"); - } - else{ - printf("Reserved.\n"); - } - offset ++; - - entry_count = record->data[offset++]; - printf("\tAddress Entry count: 0x%02x", entry_count); - while (entry_count > 0){ - printf("\t Hardware Address: 0x%02x\n", record->data[offset++]); - printf("\t IPMB-0 Link Entry: 0x%02x\n",record->data[offset++]); - entry_count --; - } - } - } - +#define SIZE_OF_CONNECTOR_DEFINER 3; /*bytes*/ + int offset = START_DATA_OFFSET; + /* Ref: PICMG 3.0 Specification Revision 2.0, Table 3-59 */ + printf(" IPMB-0 Connector Definer: "); +#ifndef WORDS_BIGENDIAN + printf("%02x %02x %02x h\n", record->data[offset], + record->data[offset+1], record->data[offset+2]); +#else + printf("%02x %02x %02x h\n", record->data[offset+2], + record->data[offset+1], record->data[offset]); +#endif + /* 3 bytes of connector definer was used */ + offset += SIZE_OF_CONNECTOR_DEFINER; + printf(" IPMB-0 Connector version ID: "); +#ifndef WORDS_BIGENDIAN + printf("%02x %02x h\n", record->data[offset], + record->data[offset+1]); +#else + printf("%02x %02x h\n", record->data[offset+1], + record->data[offset]); +#endif + offset += 2; + printf(" IPMB-0 Hub Descriptor Count: 0x%02x", + record->data[offset++]); + if (record->data[offset] < 1) { + return; + } + for (offset; offset < record->header.len;) { + unsigned char entry_count = 0; + printf(" IPMB-0 Hub Descriptor\n"); + printf("\tHardware Address: 0x%02x\n", + record->data[offset++]); + printf("\tHub Info {0x%02x}: ", record->data[offset]); + /* Bit mask specified in Table 3-59 + * of PICMG 3.0 Specification + */ + if ((record->data[offset] & 0x01) == 0x01) { + printf("IPMB-A only\n"); + } else if ((record->data[offset] & 0x02) == 0x02) { + printf("IPMB-B only\n"); + } else if ((record->data[offset] & 0x03) == 0x03) { + printf("IPMB-A and IPMB-B\n"); + } else { + printf("Reserved.\n"); + } + offset ++; + entry_count = record->data[offset++]; + printf("\tAddress Entry count: 0x%02x", entry_count); + while (entry_count > 0) { + printf("\t Hardware Address: 0x%02x\n", + record->data[offset++]); + printf("\t IPMB-0 Link Entry: 0x%02x\n", + record->data[offset++]); + entry_count --; + } + } } /************************************************************************** @@ -3602,13 +3570,14 @@ ipmi_ek_display_radial_ipmb0_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static void -ipmi_ek_display_amc_current_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_amc_current_record(struct ipmi_ek_multi_header *record) { - unsigned char current; - current = record->data[START_DATA_OFFSET]; - printf(" Current draw: %.1f A @ 12V => %.2f Watt\n", - (float) current/10.0, ((float)current/10.0)*12.0 ); - printf("\n"); + unsigned char current; + current = record->data[START_DATA_OFFSET]; + printf(" Current draw: %.1f A @ 12V => %.2f Watt\n", + (float)current / 10.0, + ((float)current / 10.0) * 12.0); + printf("\n"); } /************************************************************************** @@ -3630,29 +3599,27 @@ ipmi_ek_display_amc_current_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static void -ipmi_ek_display_amc_activation_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_amc_activation_record(struct ipmi_ek_multi_header *record) { - uint16_t max_current; - int offset = START_DATA_OFFSET; - - max_current = record->data[offset]; - max_current |= record->data[++offset] << 8; - printf(" Maximum Internal Current(@12V): %.2f A [ %.2f Watt ]\n", - (float) max_current / 10, - (float) max_current / 10 * 12); - printf(" Module Activation Readiness: %i sec.\n", - record->data[++offset]); - - printf(" Descriptor Count: %i\n", record->data[++offset]); - for(++offset; (offset < record->header.len); offset += 3 ) - { - struct fru_picmgext_activation_record * a = - (struct fru_picmgext_activation_record *) &record->data[offset]; - - printf("\tIPMB-Address:\t\t0x%x\n", a->ibmb_addr); - printf("\tMax. Module Current:\t%.2f A\n", (float)a->max_module_curr/10); - printf("\n"); - } + uint16_t max_current; + int offset = START_DATA_OFFSET; + + max_current = record->data[offset]; + max_current |= record->data[++offset] << 8; + printf(" Maximum Internal Current(@12V): %.2f A [ %.2f Watt ]\n", + (float) max_current / 10, + (float) max_current / 10 * 12); + printf(" Module Activation Readiness: %i sec.\n", + record->data[++offset]); + printf(" Descriptor Count: %i\n", record->data[++offset]); + for (++offset; (offset < record->header.len); offset += 3) { + struct fru_picmgext_activation_record *a = + (struct fru_picmgext_activation_record *)&record->data[offset]; + printf("\tIPMB-Address:\t\t0x%x\n", a->ibmb_addr); + printf("\tMax. Module Current:\t%.2f A\n", + (float)a->max_module_curr / 10); + printf("\n"); + } } /************************************************************************** @@ -3674,119 +3641,133 @@ ipmi_ek_display_amc_activation_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static void -ipmi_ek_display_amc_p2p_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_amc_p2p_record(struct ipmi_ek_multi_header *record) { - int index_data = START_DATA_OFFSET; - int oem_count = 0; - int ch_count = 0; - int index=0; - - oem_count = record->data[index_data++]; - printf("OEM GUID count: %02x\n", oem_count); - - if ( oem_count > 0 ){ - while ( oem_count > 0 ){ - printf("OEM GUID: "); - for ( index = 1; index <= SIZE_OF_GUID; index++ ){ - printf("%02x", record->data[index_data++]); - /* For a better look, display a "-" character after each 5 bytes - * of OEM GUID */ - if ( !(index % 5) ){ - printf("-"); - } - } - printf("\n"); - oem_count--; - } - } - if ( ( record->data[index_data] & AMC_MODULE ) == AMC_MODULE ){ - printf("AMC module connection\n"); - } - else{ - printf("On-Carrier Device %02x h\n", ( record->data[index_data] & 0x0f )); - } - index_data ++; - ch_count = record->data[index_data++]; - printf("AMC Channel Descriptor count: %02x h\n", ch_count); - - if ( ch_count > 0 ){ - for ( index = 0; index < ch_count; index++ ){ - unsigned int data; - struct fru_picmgext_amc_channel_desc_record * ch_desc; - printf(" AMC Channel Descriptor {%02x%02x%02x}\n", - record->data[index_data+2], record->data[index_data+1], - record->data[index_data] - ); - data = record->data[index_data] | - (record->data[index_data + 1] << 8) | - (record->data[index_data + 2] << 16); - ch_desc = ( struct fru_picmgext_amc_channel_desc_record * ) &data; - printf(" Lane 0 Port: %d\n", ch_desc->lane0port); - printf(" Lane 1 Port: %d\n", ch_desc->lane1port); - printf(" Lane 2 Port: %d\n", ch_desc->lane2port); - printf(" Lane 3 Port: %d\n\n", ch_desc->lane3port); - index_data += FRU_PICMGEXT_AMC_CHANNEL_DESC_RECORD_SIZE; - } - } - while ( index_data < record->header.len ){ - /*Warning: For gcc version between 4.0 and 4.3 this code doesnt work*/ - unsigned int data[2]; - struct fru_picmgext_amc_link_desc_record *link_desc; - data[0] = record->data[index_data] | - (record->data[index_data + 1] << 8) | - (record->data[index_data + 2] << 16) | - (record->data[index_data + 3] << 24); - data[1] = record->data[index_data + 4]; - - link_desc = (struct fru_picmgext_amc_link_desc_record *) &data[0]; - - printf(" AMC Link Descriptor:\n" ); - - printf("\t- Link Type: %s \n", - val2str (link_desc->type, ipmi_ekanalyzer_link_type)); - switch ( link_desc->type ) { - case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE: - case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS1: - case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS2: - printf("\t- Link Type extension: %s\n", - val2str (link_desc->type_ext, ipmi_ekanalyzer_extension_PCIE)); - printf("\t- Link Group ID: %d\n ", link_desc->group_id ); - printf("\t- Link Asym. Match: %d - %s\n", - link_desc->asym_match, - val2str (link_desc->asym_match, ipmi_ekanalyzer_asym_PCIE)); - break; - case FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET: - printf("\t- Link Type extension: %s\n", - val2str (link_desc->type_ext, - ipmi_ekanalyzer_extension_ETHERNET)); - printf("\t- Link Group ID: %d \n", link_desc->group_id ); - printf("\t- Link Asym. Match: %d - %s\n", - link_desc->asym_match, - val2str (link_desc->asym_match, ipmi_ekanalyzer_asym_PCIE)); - break; - case FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE: - printf("\t- Link Type extension: %s\n", - val2str (link_desc->type_ext, - ipmi_ekanalyzer_extension_STORAGE)); - printf("\t- Link Group ID: %d \n", link_desc->group_id ); - printf("\t- Link Asym. Match: %d - %s\n", - link_desc->asym_match, - val2str (link_desc->asym_match, ipmi_ekanalyzer_asym_STORAGE)); - break; - default: - printf("\t- Link Type extension: %i (Unknown)\n", link_desc->type_ext ); - printf("\t- Link Group ID: %d \n", link_desc->group_id ); - printf("\t- Link Asym. Match: %i\n", link_desc->asym_match); - break; - } - printf("\t- AMC Link Designator:\n"); - printf("\t Channel ID: %i\n", link_desc->channel_id); - printf("\t\t Lane 0: %s\n", (link_desc->port_flag_0)?"enable":"disable"); - printf("\t\t Lane 1: %s\n", (link_desc->port_flag_1)?"enable":"disable"); - printf("\t\t Lane 2: %s\n", (link_desc->port_flag_2)?"enable":"disable"); - printf("\t\t Lane 3: %s\n", (link_desc->port_flag_3)?"enable":"disable"); - index_data += FRU_PICMGEXT_AMC_LINK_DESC_RECORD_SIZE; - } + int index_data = START_DATA_OFFSET; + int oem_count = 0; + int ch_count = 0; + int index=0; + + oem_count = record->data[index_data++]; + printf("OEM GUID count: %02x\n", oem_count); + if (oem_count > 0) { + while (oem_count > 0) { + printf("OEM GUID: "); + for (index = 1; index <= SIZE_OF_GUID; index++) { + printf("%02x", record->data[index_data++]); + /* For a better look, display a "-" character + * after each 5 bytes of OEM GUID + */ + if (!(index % 5)) { + printf("-"); + } + } + printf("\n"); + oem_count--; + } + } + if ((record->data[index_data] & AMC_MODULE) == AMC_MODULE) { + printf("AMC module connection\n"); + } else { + printf("On-Carrier Device %02x h\n", + (record->data[index_data] & 0x0f)); + } + index_data ++; + ch_count = record->data[index_data++]; + printf("AMC Channel Descriptor count: %02x h\n", ch_count); + + if (ch_count > 0) { + for (index = 0; index < ch_count; index++) { + unsigned int data; + struct fru_picmgext_amc_channel_desc_record *ch_desc; + printf(" AMC Channel Descriptor {%02x%02x%02x}\n", + record->data[index_data+2], + record->data[index_data+1], + record->data[index_data]); + data = record->data[index_data] + | (record->data[index_data + 1] << 8) + | (record->data[index_data + 2] << 16); + ch_desc = (struct fru_picmgext_amc_channel_desc_record *)&data; + printf(" Lane 0 Port: %d\n", ch_desc->lane0port); + printf(" Lane 1 Port: %d\n", ch_desc->lane1port); + printf(" Lane 2 Port: %d\n", ch_desc->lane2port); + printf(" Lane 3 Port: %d\n\n", ch_desc->lane3port); + index_data += FRU_PICMGEXT_AMC_CHANNEL_DESC_RECORD_SIZE; + } + } + while (index_data < record->header.len) { + /* Warning: This code doesn't work with gcc version + * between 4.0 and 4.3 + */ + unsigned int data[2]; + struct fru_picmgext_amc_link_desc_record *link_desc; + data[0] = record->data[index_data] + | (record->data[index_data + 1] << 8) + | (record->data[index_data + 2] << 16) + | (record->data[index_data + 3] << 24); + data[1] = record->data[index_data + 4]; + + link_desc = (struct fru_picmgext_amc_link_desc_record *)&data[0]; + printf(" AMC Link Descriptor:\n"); + printf("\t- Link Type: %s \n", + val2str(link_desc->type, ipmi_ekanalyzer_link_type)); + switch (link_desc->type) { + case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE: + case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS1: + case FRU_PICMGEXT_AMC_LINK_TYPE_PCIE_AS2: + printf("\t- Link Type extension: %s\n", + val2str(link_desc->type_ext, + ipmi_ekanalyzer_extension_PCIE)); + printf("\t- Link Group ID: %d\n ", + link_desc->group_id); + printf("\t- Link Asym. Match: %d - %s\n", + link_desc->asym_match, + val2str(link_desc->asym_match, + ipmi_ekanalyzer_asym_PCIE)); + break; + case FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET: + printf("\t- Link Type extension: %s\n", + val2str (link_desc->type_ext, + ipmi_ekanalyzer_extension_ETHERNET)); + printf("\t- Link Group ID: %d \n", + link_desc->group_id); + printf("\t- Link Asym. Match: %d - %s\n", + link_desc->asym_match, + val2str(link_desc->asym_match, + ipmi_ekanalyzer_asym_PCIE)); + break; + case FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE: + printf("\t- Link Type extension: %s\n", + val2str (link_desc->type_ext, + ipmi_ekanalyzer_extension_STORAGE)); + printf("\t- Link Group ID: %d \n", + link_desc->group_id); + printf("\t- Link Asym. Match: %d - %s\n", + link_desc->asym_match, + val2str(link_desc->asym_match, + ipmi_ekanalyzer_asym_STORAGE)); + break; + default: + printf("\t- Link Type extension: %i (Unknown)\n", + link_desc->type_ext); + printf("\t- Link Group ID: %d \n", + link_desc->group_id); + printf("\t- Link Asym. Match: %i\n", + link_desc->asym_match); + break; + } + printf("\t- AMC Link Designator:\n"); + printf("\t Channel ID: %i\n", link_desc->channel_id); + printf("\t\t Lane 0: %s\n", + (link_desc->port_flag_0) ? "enable" : "disable"); + printf("\t\t Lane 1: %s\n", + (link_desc->port_flag_1) ? "enable" : "disable"); + printf("\t\t Lane 2: %s\n", + (link_desc->port_flag_2) ? "enable" : "disable"); + printf("\t\t Lane 3: %s\n", + (link_desc->port_flag_3) ? "enable" : "disable"); + index_data += FRU_PICMGEXT_AMC_LINK_DESC_RECORD_SIZE; + } } /************************************************************************** @@ -3807,26 +3788,25 @@ ipmi_ek_display_amc_p2p_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static void -ipmi_ek_display_amc_carrier_info_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_amc_carrier_info_record(struct ipmi_ek_multi_header *record) { - unsigned char extVersion; - unsigned char siteCount; - int offset = START_DATA_OFFSET; - - extVersion = record->data[offset++]; - siteCount = record->data[offset++]; - - printf(" AMC.0 extension version: R%d.%d\n", (extVersion >> 0)& 0x0F, - (extVersion >> 4)& 0x0F ); - printf(" Carrier Sie Number Count: %d\n", siteCount); - - while (siteCount > 0){ - printf("\tSite ID (%d): %s \n", record->data[offset], - val2str(record->data[offset], ipmi_ekanalyzer_module_type) ); - offset++; - siteCount--; - } - printf("\n"); + unsigned char extVersion; + unsigned char siteCount; + int offset = START_DATA_OFFSET; + + extVersion = record->data[offset++]; + siteCount = record->data[offset++]; + printf(" AMC.0 extension version: R%d.%d\n", + (extVersion >> 0) & 0x0F, + (extVersion >> 4) & 0x0F); + printf(" Carrier Sie Number Count: %d\n", siteCount); + while (siteCount > 0) { + printf("\tSite ID (%d): %s \n", record->data[offset], + val2str(record->data[offset], ipmi_ekanalyzer_module_type)); + offset++; + siteCount--; + } + printf("\n"); } /************************************************************************** @@ -3849,63 +3829,58 @@ ipmi_ek_display_amc_carrier_info_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static void -ipmi_ek_display_clock_carrier_p2p_record( - struct ipmi_ek_multi_header * record ) +ipmi_ek_display_clock_carrier_p2p_record(struct ipmi_ek_multi_header *record) { - unsigned char desc_count; - int i,j; - int offset = START_DATA_OFFSET; - - desc_count = record->data[offset++]; - - for(i=0; i<desc_count; i++){ - unsigned char resource_id; - unsigned char channel_count; - - resource_id = record->data[offset++]; - channel_count = record->data[offset++]; - - printf(" Clock Resource ID: 0x%02x\n", resource_id); - printf(" Type: "); - if((resource_id & 0xC0)>>6 == 0) { - printf("On-Carrier-Device\n"); - } - else if((resource_id & 0xC0)>>6 == 1) { - printf("AMC slot\n"); - } - else if((resource_id & 0xC0)>>6 == 2) { - printf("Backplane\n"); - } - else{ - printf("reserved\n"); - } - printf(" Channel Count: 0x%02x\n", channel_count); - - for(j=0; j<channel_count; j++){ - unsigned char loc_channel, rem_channel, rem_resource; - - loc_channel = record->data[offset++]; - rem_channel = record->data[offset++]; - rem_resource = record->data[offset++]; - - printf("\tCLK-ID: 0x%02x ---> ", loc_channel); - printf(" remote CLKID: 0x%02x ", rem_channel); - if((rem_resource & 0xC0)>>6 == 0) { - printf("[ Carrier-Dev"); - } - else if((rem_resource & 0xC0)>>6 == 1) { - printf("[ AMC slot "); - } - else if((rem_resource & 0xC0)>>6 == 2) { - printf("[ Backplane "); - } - else{ - printf("reserved "); - } - printf(" 0x%02x ]\n", rem_resource&0xF); - } - } - printf("\n"); + unsigned char desc_count; + int i; + int j; + int offset = START_DATA_OFFSET; + + desc_count = record->data[offset++]; + for(i = 0; i < desc_count; i++) { + unsigned char resource_id; + unsigned char channel_count; + + resource_id = record->data[offset++]; + channel_count = record->data[offset++]; + + printf(" Clock Resource ID: 0x%02x\n", resource_id); + printf(" Type: "); + if ((resource_id & 0xC0) >> 6 == 0) { + printf("On-Carrier-Device\n"); + } else if ((resource_id & 0xC0) >> 6 == 1) { + printf("AMC slot\n"); + } else if ((resource_id & 0xC0) >> 6 == 2) { + printf("Backplane\n"); + } else{ + printf("reserved\n"); + } + printf(" Channel Count: 0x%02x\n", channel_count); + + for (j = 0; j < channel_count; j++) { + unsigned char loc_channel; + unsigned char rem_channel; + unsigned char rem_resource; + + loc_channel = record->data[offset++]; + rem_channel = record->data[offset++]; + rem_resource = record->data[offset++]; + + printf("\tCLK-ID: 0x%02x ---> ", loc_channel); + printf(" remote CLKID: 0x%02x ", rem_channel); + if ((rem_resource & 0xC0) >> 6 == 0) { + printf("[ Carrier-Dev"); + } else if ((rem_resource & 0xC0) >> 6 == 1) { + printf("[ AMC slot "); + } else if ((rem_resource & 0xC0) >> 6 == 2) { + printf("[ Backplane "); + } else { + printf("reserved "); + } + printf(" 0x%02x ]\n", rem_resource & 0xF); + } + } + printf("\n"); } /************************************************************************** @@ -3927,79 +3902,88 @@ ipmi_ek_display_clock_carrier_p2p_record( * ***************************************************************************/ void -ipmi_ek_display_clock_config_record( struct ipmi_ek_multi_header * record ) +ipmi_ek_display_clock_config_record(struct ipmi_ek_multi_header *record) { - unsigned char resource_id, descr_count; - int i; - int offset = START_DATA_OFFSET; - - resource_id = record->data[offset++]; - descr_count = record->data[offset++]; - printf(" Clock Resource ID: 0x%02x\n", resource_id); - printf(" Clock Configuration Descriptor Count: 0x%02x\n", descr_count); - - for(i=0; i<descr_count; i++){ - unsigned char channel_id, control; - unsigned char indirect_cnt, direct_cnt; - int j=0; - - channel_id = record->data[offset++]; - control = record->data[offset++]; - printf("\tCLK-ID: 0x%02x - ", channel_id); - printf("CTRL 0x%02x [ %12s ]\n", control, - ((control&0x1)==0)?"Carrier IPMC":"Application"); - - indirect_cnt = record->data[offset++]; - direct_cnt = record->data[offset++]; - printf("\t Count: Indirect 0x%02x / Direct 0x%02x\n", indirect_cnt, - direct_cnt ); - - /* indirect desc */ - for(j=0; j<indirect_cnt; j++){ - unsigned char feature; - unsigned char dep_chn_id; - - feature = record->data[offset++]; - dep_chn_id = record->data[offset++]; - printf("\t\tFeature: 0x%02x [%8s] - ", feature, - (feature&0x1)==1?"Source":"Receiver"); - printf(" Dep. CLK-ID: 0x%02x\n", dep_chn_id); - } - - /* direct desc */ - for(j=0; j<direct_cnt; j++){ - unsigned char feature, family, accuracy; - unsigned long freq, min_freq, max_freq; - - feature = record->data[offset++]; - family = record->data[offset++]; - accuracy = record->data[offset++]; - freq = (record->data[offset+0] << 0 ) - | (record->data[offset+1] << 8 ) - | (record->data[offset+2] << 16) - | (record->data[offset+3] << 24); - offset += 4; - min_freq = (record->data[offset+0] << 0 ) - | (record->data[offset+1] << 8 ) - | (record->data[offset+2] << 16) - | (record->data[offset+3] << 24); - offset += 4; - max_freq = (record->data[offset+0] << 0 ) - | (record->data[offset+1] << 8 ) - | (record->data[offset+2] << 16) - | (record->data[offset+3] << 24); - offset += 4; - - printf("\t- Feature: 0x%02x - PLL: %x / Asym: %s\n", - feature, - (feature > 1) & 1, - (feature&1)?"Source":"Receiver"); - printf("\tFamily: 0x%02x - AccLVL: 0x%02x\n", family, accuracy); - printf("\tFRQ: %-9ld - min: %-9ld - max: %-9ld\n", - freq, min_freq, max_freq); - } - printf("\n"); - } + unsigned char resource_id; + unsigned char descr_count; + int i; + int offset = START_DATA_OFFSET; + + resource_id = record->data[offset++]; + descr_count = record->data[offset++]; + printf(" Clock Resource ID: 0x%02x\n", resource_id); + printf(" Clock Configuration Descriptor Count: 0x%02x\n", descr_count); + + for (i = 0; i < descr_count; i++) { + int j = 0; + unsigned char channel_id; + unsigned char control; + unsigned char indirect_cnt; + unsigned char direct_cnt; + + channel_id = record->data[offset++]; + control = record->data[offset++]; + printf("\tCLK-ID: 0x%02x - ", channel_id); + printf("CTRL 0x%02x [ %12s ]\n", control, + ((control & 0x1) == 0) ? "Carrier IPMC" : "Application"); + + indirect_cnt = record->data[offset++]; + direct_cnt = record->data[offset++]; + printf("\t Count: Indirect 0x%02x / Direct 0x%02x\n", + indirect_cnt, + direct_cnt); + + /* indirect desc */ + for (j = 0; j < indirect_cnt; j++) { + unsigned char feature; + unsigned char dep_chn_id; + + feature = record->data[offset++]; + dep_chn_id = record->data[offset++]; + printf("\t\tFeature: 0x%02x [%8s] - ", + feature, + (feature & 0x1) == 1 ? "Source" : "Receiver"); + printf(" Dep. CLK-ID: 0x%02x\n", dep_chn_id); + } + /* direct desc */ + for (j = 0; j < direct_cnt; j++) { + unsigned char feature; + unsigned char family; + unsigned char accuracy; + unsigned long freq; + unsigned long min_freq; + unsigned long max_freq; + + feature = record->data[offset++]; + family = record->data[offset++]; + accuracy = record->data[offset++]; + freq = (record->data[offset+0] << 0) + | (record->data[offset+1] << 8) + | (record->data[offset+2] << 16) + | (record->data[offset+3] << 24); + offset += 4; + min_freq = (record->data[offset+0] << 0) + | (record->data[offset+1] << 8) + | (record->data[offset+2] << 16) + | (record->data[offset+3] << 24); + offset += 4; + max_freq = (record->data[offset+0] << 0) + | (record->data[offset+1] << 8) + | (record->data[offset+2] << 16) + | (record->data[offset+3] << 24); + offset += 4; + + printf("\t- Feature: 0x%02x - PLL: %x / Asym: %s\n", + feature, + (feature > 1) & 1, + (feature & 1) ? "Source" : "Receiver"); + printf("\tFamily: 0x%02x - AccLVL: 0x%02x\n", + family, accuracy); + printf("\tFRQ: %-9ld - min: %-9ld - max: %-9ld\n", + freq, min_freq, max_freq); + } + printf("\n"); + } } /************************************************************************** @@ -4022,12 +4006,12 @@ ipmi_ek_display_clock_config_record( struct ipmi_ek_multi_header * record ) * ***************************************************************************/ static int -ipmi_ekanalyzer_fru_file2structure(char * filename, - struct ipmi_ek_multi_header ** list_head, - struct ipmi_ek_multi_header ** list_record, - struct ipmi_ek_multi_header ** list_last) +ipmi_ekanalyzer_fru_file2structure(char *filename, + struct ipmi_ek_multi_header **list_head, + struct ipmi_ek_multi_header **list_record, + struct ipmi_ek_multi_header **list_last) { - FILE * input_file; + FILE *input_file; unsigned char data; unsigned char last_record = 0; unsigned int multi_offset = 0; @@ -4050,21 +4034,23 @@ ipmi_ekanalyzer_fru_file2structure(char * filename, } if (data == 0) { lprintf(LOG_ERR, "There is no multi record in the file '%s'", - filename); + filename); fclose(input_file); return ERROR_STATUS; } /* the offset value is in multiple of 8 bytes. */ multi_offset = data * 8; lprintf(LOG_DEBUG, "start multi offset = 0x%02x", - multi_offset ); + multi_offset); fseek(input_file, multi_offset, SEEK_SET); while (!feof(input_file)) { + /* TODO - check malloc() */ *list_record = malloc(sizeof(struct ipmi_ek_multi_header)); ret = fread(&(*list_record)->header, START_DATA_OFFSET, 1, input_file); if ((ret != 1) || ferror(input_file)) { + /* TODO - no free?! */ lprintf(LOG_ERR, "Invalid Header!"); fclose(input_file); return ERROR_STATUS; @@ -4115,7 +4101,6 @@ ipmi_ekanalyzer_fru_file2structure(char * filename, return OK_STATUS; } - /************************************************************************** * * Function name: ipmi_ek_add_record2list @@ -4135,24 +4120,25 @@ ipmi_ekanalyzer_fru_file2structure(char * filename, * ***************************************************************************/ static void -ipmi_ek_add_record2list( struct ipmi_ek_multi_header ** record, - struct ipmi_ek_multi_header ** list_head, - struct ipmi_ek_multi_header ** list_last ) +ipmi_ek_add_record2list(struct ipmi_ek_multi_header **record, + struct ipmi_ek_multi_header **list_head, + struct ipmi_ek_multi_header **list_last) { - if (*list_head == NULL) { - *list_head = *record; - (*record)->prev = NULL; - if (verbose > 2) - printf("Adding first record to list\n"); - } - else { - (*list_last)->next = *record; - (*record)->prev = *list_last; - if (verbose > 2) - printf("Add 1 record to list\n"); - } - *list_last = *record; - (*record)->next = NULL; + if (*list_head == NULL) { + *list_head = *record; + (*record)->prev = NULL; + if (verbose > 2) { + printf("Adding first record to list\n"); + } + } else { + (*list_last)->next = *record; + (*record)->prev = *list_last; + if (verbose > 2) { + printf("Add 1 record to list\n"); + } + } + *list_last = *record; + (*record)->next = NULL; } /************************************************************************** @@ -4174,22 +4160,20 @@ ipmi_ek_add_record2list( struct ipmi_ek_multi_header ** record, * ***************************************************************************/ static void -ipmi_ek_remove_record_from_list( struct ipmi_ek_multi_header * record, - struct ipmi_ek_multi_header ** list_head, - struct ipmi_ek_multi_header ** list_last ) +ipmi_ek_remove_record_from_list(struct ipmi_ek_multi_header *record, + struct ipmi_ek_multi_header **list_head, + struct ipmi_ek_multi_header **list_last) { - if (record->prev == NULL) - *list_head = record->next; - else - record->prev->next = record->next; - if ( record->next == NULL ) - (*list_last) = record->prev; - else - record->next->prev = record->prev; - free(record); - record = NULL; + if (record->prev == NULL) { + *list_head = record->next; + } else { + record->prev->next = record->next; + } + if (record->next == NULL) { + (*list_last) = record->prev; + } else { + record->next->prev = record->prev; + } + free(record); + record = NULL; } - - - - diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c index 1b2e0cd..17afe5f 100644 --- a/lib/ipmi_fru.c +++ b/lib/ipmi_fru.c @@ -3111,7 +3111,8 @@ ipmi_fru_print_all(struct ipmi_intf * intf) mc = (struct sdr_record_mc_locator *) ipmi_sdr_get_record(intf, header, itr); /* Does this MC device support FRU inventory device? */ - if (mc && (mc->dev_support & 0x08)) { /* FRU inventory device? */ + if (mc && (mc->dev_support & 0x08) && /* FRU inventory device? */ + intf->target_addr != mc->dev_slave_addr) { /* Yes. Prepare to issue FRU commands to FRU device #0 LUN 0 */ /* using the slave address specified in the MC record. */ diff --git a/lib/ipmi_fwum.c b/lib/ipmi_fwum.c index b666a2b..68f40d4 100644 --- a/lib/ipmi_fwum.c +++ b/lib/ipmi_fwum.c @@ -892,14 +892,14 @@ KfwumUploadFirmware(struct ipmi_intf *intf, unsigned char *pBuffer, } if (rc == 0) { if ((address % 1024) == 0) { - KfwumShowProgress("Writting Firmware in Flash", + KfwumShowProgress("Writing Firmware in Flash", address, totalSize); } sequenceNumber++; } } while ((rc == 0) && (address < totalSize)); if (rc == 0) { - KfwumShowProgress("Writting Firmware in Flash", + KfwumShowProgress("Writing Firmware in Flash", 100, 100); } return rc; diff --git a/lib/ipmi_hpmfwupg.c b/lib/ipmi_hpmfwupg.c index 69950b7..fbb5a62 100644 --- a/lib/ipmi_hpmfwupg.c +++ b/lib/ipmi_hpmfwupg.c @@ -344,6 +344,8 @@ HpmfwupgTargetCheck(struct ipmi_intf *intf, int option) generalPropResp.GeneralCompProperties.bitfield.rollbackBackup; gVersionInfo[componentId].coldResetRequired = getCompProp.resp.Response. generalPropResp.GeneralCompProperties.bitfield.payloadColdReset; + gVersionInfo[componentId].deferredActivationSupported = getCompProp.resp.Response. + generalPropResp.GeneralCompProperties.bitfield.deferredActivation; getCompProp.req.selector = HPMFWUPG_COMP_DESCRIPTION_STRING; rc = HpmfwupgGetComponentProperties(intf, &getCompProp); if (rc != HPMFWUPG_SUCCESS) { @@ -395,6 +397,16 @@ HpmfwupgTargetCheck(struct ipmi_intf *intf, int option) gVersionInfo[componentId].rollbackAux[2] = getCompProp.resp.Response.rollbackFwVersionResp.rollbackFwVersion[4]; gVersionInfo[componentId].rollbackAux[3] = getCompProp.resp.Response.rollbackFwVersionResp.rollbackFwVersion[5]; } + mode |= ROLLBACK_VER; + } else { + gVersionInfo[componentId].rollbackMajor = 0xff; + gVersionInfo[componentId].rollbackMinor = 0xff; + gVersionInfo[componentId].rollbackAux[0] = 0xff; + gVersionInfo[componentId].rollbackAux[1] = 0xff; + gVersionInfo[componentId].rollbackAux[2] = 0xff; + gVersionInfo[componentId].rollbackAux[3] = 0xff; + } + if (gVersionInfo[componentId].deferredActivationSupported) { getCompProp.req.selector = HPMFWUPG_COMP_DEFERRED_FIRMWARE_VERSION; rc = HpmfwupgGetComponentProperties(intf, &getCompProp); if (rc != HPMFWUPG_SUCCESS) { @@ -411,14 +423,7 @@ HpmfwupgTargetCheck(struct ipmi_intf *intf, int option) gVersionInfo[componentId].deferredAux[2] = getCompProp.resp.Response.deferredFwVersionResp.deferredFwVersion[4]; gVersionInfo[componentId].deferredAux[3] = getCompProp.resp.Response.deferredFwVersionResp.deferredFwVersion[5]; } - mode |= ROLLBACK_VER; } else { - gVersionInfo[componentId].rollbackMajor = 0xff; - gVersionInfo[componentId].rollbackMinor = 0xff; - gVersionInfo[componentId].rollbackAux[0] = 0xff; - gVersionInfo[componentId].rollbackAux[1] = 0xff; - gVersionInfo[componentId].rollbackAux[2] = 0xff; - gVersionInfo[componentId].rollbackAux[3] = 0xff; gVersionInfo[componentId].deferredMajor = 0xff; gVersionInfo[componentId].deferredMinor = 0xff; gVersionInfo[componentId].deferredAux[0] = 0xff; @@ -1235,10 +1240,12 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components, } else { /* success, buf length is valid */ bufLengthIsSet = 1; - if (blockLength > firmwareLength) { + if (imageOffset + blockLength > firmwareLength || + imageOffset + blockLength < blockLength) { /* * blockLength is the remaining length of the firmware to upload so - * if its greater than the firmware length then its kind of error + * if imageOffset and blockLength sum is greater than the firmware + * length then its kind of error */ lprintf(LOG_NOTICE, "\n Error in Upload FIRMWARE command [rc=%d]\n", @@ -1247,6 +1254,7 @@ HpmFwupgActionUploadFirmware(struct HpmfwupgComponentBitMask components, "\n TotalSent:0x%x Img offset:0x%x Blk length:0x%x Fwlen:0x%x\n", totalSent,imageOffset,blockLength,firmwareLength); rc = HPMFWUPG_ERROR; + continue; } totalSent += count; if (imageOffset != 0x00) { @@ -2296,7 +2304,8 @@ HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf, * receive d5 (on the first get status) from * the ipmi driver. */ - (upgStatusCmd.resp.lastCmdCompCode != 0x00 ) + (upgStatusCmd.resp.lastCmdCompCode == 0x80 || + upgStatusCmd.resp.lastCmdCompCode == 0xD5) && ((timeoutSec2 - timeoutSec1) < upgradeTimeout ) && (rc == HPMFWUPG_SUCCESS)) { /* Must wait at least 1000 ms between status requests */ diff --git a/lib/ipmi_kontronoem.c b/lib/ipmi_kontronoem.c index c154eda..48dc684 100644 --- a/lib/ipmi_kontronoem.c +++ b/lib/ipmi_kontronoem.c @@ -39,770 +39,609 @@ * * This code implements an Kontron OEM proprietary commands. */ - - #include <string.h> #include <ipmitool/helper.h> +#include <ipmitool/log.h> #include <ipmitool/ipmi.h> #include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_fru.h> - extern int verbose; -extern int read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, - uint8_t id, uint32_t offset, uint32_t length, - uint8_t *frubuf); -extern int write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, - unsigned char id, unsigned int soffset, - unsigned int doffset, unsigned int length, - unsigned char *pFrubuf); - -extern char * get_fru_area_str(uint8_t * data, uint32_t * offset); - - +extern int read_fru_area(struct ipmi_intf *intf, struct fru_info *fru, + uint8_t id, uint32_t offset, uint32_t length, + uint8_t *frubuf); +extern int write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, + uint8_t id, uint16_t soffset, + uint16_t doffset, uint16_t length, + uint8_t *pFrubuf); +extern char *get_fru_area_str(uint8_t *data, uint32_t *offset); static void ipmi_kontron_help(void); -static int ipmi_kontron_set_serial_number(struct ipmi_intf * intf); -static int ipmi_kontron_set_mfg_date (struct ipmi_intf * intf); - +static int ipmi_kontron_set_serial_number(struct ipmi_intf *intf); +static int ipmi_kontron_set_mfg_date (struct ipmi_intf *intf); static void ipmi_kontron_nextboot_help(void); -static int ipmi_kontron_nextboot_set(struct ipmi_intf * intf, - int argc, char **argv); +static int ipmi_kontron_nextboot_set(struct ipmi_intf *intf, int argc, + char **argv); +static int ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf, + unsigned char channel, unsigned char size); -static int ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf * intf, - unsigned char channel, - unsigned char size); +static char *bootdev[] = {"BIOS", "FDD", "HDD", "CDROM", "network", 0}; int -ipmi_kontronoem_main(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_kontronoem_main(struct ipmi_intf *intf, int argc, char **argv) { - int rc = 0; - - if (argc == 0) - ipmi_kontron_help(); - else if (strncmp(argv[0], "help", 4) == 0) - ipmi_kontron_help(); - - else if (!strncmp(argv[0], "setsn", 5)) - { - if(argc >= 1) - { - if(ipmi_kontron_set_serial_number(intf) > 0) - { - printf("FRU serial number setted successfully\n"); - } - else - { - printf("FRU serial number set failed\n"); - } - } - else - { - printf("fru setsn\n"); - } - } - else if (!strncmp(argv[0], "setmfgdate", 5)) - { - if(argc >= 1) - { - if(ipmi_kontron_set_mfg_date(intf) > 0) - { - printf("FRU manufacturing date setted successfully\n"); - } - else - { - printf("FRU manufacturing date set failed\n"); - } - } - else - { - printf("fru setmfgdate\n"); - } - } - else if (!strncmp(argv[0], "nextboot", sizeof("nextboot")-1)) - { - if (argc > 1) - { - if ((rc = ipmi_kontron_nextboot_set(intf, argc-1, argv+1)) == 0) - { - printf("Nextboot set successfully\n"); - } - else - { - printf("Nextboot set failed\n"); - } - } - else - { - ipmi_kontron_nextboot_help(); - } - } - - else - { - printf("Invalid Kontron command: %s", argv[0]); - ipmi_kontron_help(); - rc = -1; - } - - return rc; + int rc = 0; + if (argc == 0) { + lprintf(LOG_ERR, "Not enough parameters given."); + ipmi_kontron_help(); + return (-1); + } + if (strncmp(argv[0], "help", 4) == 0) { + ipmi_kontron_help(); + rc = 0; + } else if (!strncmp(argv[0], "setsn", 5)) { + if (argc < 1) { + printf("fru setsn\n"); + return (-1); + } + if (ipmi_kontron_set_serial_number(intf) > 0) { + printf("FRU serial number setted successfully\n"); + } else { + printf("FRU serial number set failed\n"); + rc = (-1); + } + } else if (!strncmp(argv[0], "setmfgdate", 10)) { + if (argc < 1) { + printf("fru setmfgdate\n"); + return (-1); + } + if (ipmi_kontron_set_mfg_date(intf) > 0) { + printf("FRU manufacturing date setted successfully\n"); + } else { + printf("FRU manufacturing date set failed\n"); + rc = (-1); + } + } else if (!strncmp(argv[0], "nextboot", 8)) { + if (argc < 2) { + lprintf(LOG_ERR, "Not enough parameters given."); + ipmi_kontron_nextboot_help(); + rc = (-1); + } + rc = ipmi_kontron_nextboot_set(intf, (argc - 1), (argv + 1)); + if (rc == 0) { + printf("Nextboot set successfully\n"); + } else { + printf("Nextboot set failed\n"); + rc = (-1); + } + } else { + lprintf(LOG_ERR, "Invalid Kontron command: %s", argv[0]); + ipmi_kontron_help(); + rc = (-1); + } + return rc; } - -static void ipmi_kontron_help(void) +static void +ipmi_kontron_help(void) { - printf("Kontron Commands: setsn setmfgdate nextboot\n"); -} - + printf("Kontron Commands: setsn setmfgdate nextboot\n"); +} -int ipmi_kontronoem_set_large_buffer(struct ipmi_intf * intf, unsigned char size) +int +ipmi_kontronoem_set_large_buffer(struct ipmi_intf *intf, unsigned char size) { - uint8_t error_occurs = 0; - uint32_t prev_target_addr = intf->target_addr ; - - if ( intf->target_addr > 0 && (intf->target_addr != intf->my_addr) ) - { - intf->target_addr = intf->my_addr; - - printf("Set local big buffer\n"); - if(ipmi_kontronoem_send_set_large_buffer( intf, 0x0e, size ) == 0) - { - printf("Set local big buffer:success\n"); - } - else - { - error_occurs = 1; - } - - if (error_occurs == 0) - { - if(ipmi_kontronoem_send_set_large_buffer( intf, 0x00, size ) == 0) - { - printf("IPMB was set\n"); - } - else - { - /* Revert back the previous set large buffer */ - error_occurs = 1; - ipmi_kontronoem_send_set_large_buffer( intf, 0x0e, 0 ); - } - } - - /* Restore target address */ - intf->target_addr = prev_target_addr; - } - - if (error_occurs == 0) - { - if(ipmi_kontronoem_send_set_large_buffer( intf, 0x0e, size ) == 0) - { - //printf("Set remote big buffer\n"); - } - else - { - if ( intf->target_addr > 0 && (intf->target_addr != intf->my_addr) ) - { - /* Error occurs revert back the previous set large buffer*/ - intf->target_addr = intf->my_addr; - - //ipmi_kontronoem_send_set_large_buffer( intf, 0x00, 0 ); - ipmi_kontronoem_send_set_large_buffer( intf, 0x0e, 0 ); - - intf->target_addr = prev_target_addr; - } - } - } - return error_occurs; + uint8_t error_occurs = 0; + uint32_t prev_target_addr = intf->target_addr ; + if (intf->target_addr > 0 && (intf->target_addr != intf->my_addr)) { + intf->target_addr = intf->my_addr; + printf("Set local big buffer\n"); + if (ipmi_kontronoem_send_set_large_buffer(intf, 0x0e, size) == 0) { + printf("Set local big buffer:success\n"); + } else { + error_occurs = 1; + } + if (error_occurs == 0) { + if (ipmi_kontronoem_send_set_large_buffer(intf, 0x00, size) == 0) { + printf("IPMB was set\n"); + } else { + /* Revert back the previous set large buffer */ + error_occurs = 1; + ipmi_kontronoem_send_set_large_buffer( intf, 0x0e, 0 ); + } + } + /* Restore target address */ + intf->target_addr = prev_target_addr; + } + if (error_occurs == 0) { + if(ipmi_kontronoem_send_set_large_buffer(intf, 0x0e, size) == 0) { + /* printf("Set remote big buffer\n"); */ + } else { + if (intf->target_addr > 0 && (intf->target_addr != intf->my_addr)) { + /* Error occurs revert back the previous set large buffer */ + intf->target_addr = intf->my_addr; + /* ipmi_kontronoem_send_set_large_buffer(intf, 0x00, 0); */ + ipmi_kontronoem_send_set_large_buffer(intf, 0x0e, 0); + intf->target_addr = prev_target_addr; + } + } + } + return error_occurs; } - -int ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf * intf, unsigned char channel,unsigned char size) +int +ipmi_kontronoem_send_set_large_buffer(struct ipmi_intf *intf, + unsigned char channel, unsigned char size) { - struct ipmi_rs *rsp; - struct ipmi_rq req; - uint8_t msg_data[2]; - int i; - - memset(msg_data, 0, sizeof(msg_data)); - msg_data[0] = channel/*0x0e*/; // Currently running interface - msg_data[1] = size; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = 0x3E; /* OEM NetFn */ - req.msg.cmd = 0x82; /* Set Channel Buffer Length - OEM */ - req.msg.data = msg_data; - req.msg.data_len = 2; - - req.msg.lun = 0x00; - - rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) - { - printf("Cannot send large buffer command\n"); - return(-1); - } - if (rsp->ccode > 0) - { - printf("Invalid length for the selected interface (%s) %d\n", - val2str(rsp->ccode, completion_code_vals), rsp->ccode); - return(-1); - } - return 0; + struct ipmi_rs *rsp; + struct ipmi_rq req; + uint8_t msg_data[2]; + int i; + memset(msg_data, 0, sizeof(msg_data)); + /* channel =~ 0x0e => Currently running interface */ + msg_data[0] = channel; + msg_data[1] = size; + memset(&req, 0, sizeof(req)); + req.msg.netfn = 0x3E; + /* Set Channel Buffer Length - OEM */ + req.msg.cmd = 0x82; + req.msg.data = msg_data; + req.msg.data_len = 2; + req.msg.lun = 0x00; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf("Cannot send large buffer command\n"); + return(-1); + } else if (rsp->ccode > 0) { + printf("Invalid length for the selected interface (%s) %d\n", + val2str(rsp->ccode, completion_code_vals), rsp->ccode); + return(-1); + } + return 0; } - /* ipmi_fru_set_serial_number - Set the Serial Number in FRU * - * @intf: ipmi interface - * @id: fru id + * @intf: ipmi interface + * @id: fru id * * returns -1 on error * returns 1 if successful */ static int -ipmi_kontron_set_serial_number(struct ipmi_intf * intf) +ipmi_kontron_set_serial_number(struct ipmi_intf *intf) { - struct ipmi_rs *rsp; - struct ipmi_rq req; - struct fru_info fru; - struct fru_header header; - uint8_t msg_data[4]; - char *sn; - uint8_t sn_size, checksum; - uint8_t *fru_data; - char *fru_area; - uint32_t fru_data_offset, fru_data_offset_tmp, board_sec_len, prod_sec_len, i; - - sn = NULL; - fru_data = NULL; - - memset(msg_data, 0, 4); - msg_data[0] = 0xb4; - msg_data[1] = 0x90; - msg_data[2] = 0x91; - msg_data[3] = 0x8b; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = 0x3E; - req.msg.cmd = 0x0C; - req.msg.data = msg_data; - req.msg.data_len = 4; - - - /* Set Lun, necessary for this oem command */ - req.msg.lun = 0x03; - - - rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) - { - printf(" Device not present (No Response)\n"); - return -11; - } - - if (rsp->ccode > 0) - { - printf(" This option is not implemented for this board\n"); - return -1; - } - - sn_size = rsp->data_len; - - sn = malloc(sn_size + 1); - - if(sn == NULL) - { - printf("Out of memory!"); - return -1; - } - - memset(sn, 0, sn_size + 1); - memcpy(sn, rsp->data, sn_size); - - if(verbose >= 1) - { - printf("Original serial number is : [%s]\n", sn); - } - - - - memset(msg_data, 0, 4); - msg_data[0] = 0; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_STORAGE; - req.msg.cmd = GET_FRU_INFO; - req.msg.data = msg_data; - req.msg.data_len = 1; - - rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { - printf(" Device not present (No Response)\n"); - free(sn); - sn = NULL; - return -1; - } - if (rsp->ccode > 0) { - printf(" Device not present (%s)\n", - val2str(rsp->ccode, completion_code_vals)); - free(sn); - sn = NULL; - return(-1); - } - - memset(&fru, 0, sizeof(fru)); - fru.size = (rsp->data[1] << 8) | rsp->data[0]; - fru.access = rsp->data[2] & 0x1; - - if (fru.size < 1) { - printf(" Invalid FRU size %d", fru.size); - free(sn); - sn = NULL; - return -1; - } - - /* - * retrieve the FRU header - */ - msg_data[0] = 0; - msg_data[1] = 0; - msg_data[2] = 0; - msg_data[3] = 8; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_STORAGE; - req.msg.cmd = GET_FRU_DATA; - req.msg.data = msg_data; - req.msg.data_len = 4; - - rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) - { - printf(" Device not present (No Response)\n"); - free(sn); - sn = NULL; - return(-1); - } - if (rsp->ccode > 0) - { - printf(" Device not present (%s)\n", - val2str(rsp->ccode, completion_code_vals)); - free(sn); - sn = NULL; - return(-1); - } - - if (verbose > 1) - printbuf(rsp->data, rsp->data_len, "FRU DATA"); - - memcpy(&header, rsp->data + 1, 8); - - if (header.version != 1) - { - printf(" Unknown FRU header version 0x%02x", - header.version); - free(sn); - sn = NULL; - return(-1); - } - - /* Set the Board Section */ - board_sec_len = (header.offset.product * 8) - (header.offset.board * 8); - - - fru_data = malloc( fru.size); - - if(fru_data == NULL) - { - printf("Out of memory!"); - free(sn); - sn = NULL; - return(-1); - } - - memset(fru_data, 0, fru.size); - if(read_fru_area(intf ,&fru ,0 ,(header.offset.board * 8) ,board_sec_len , fru_data) < 0) - { - free(sn); - sn = NULL; - free(fru_data); - fru_data = NULL; - return(-1); - } - - /*Position at Board Manufacturer*/ - fru_data_offset = (header.offset.board * 8) + 6; - fru_area = get_fru_area_str(fru_data, &fru_data_offset); - - /*Position at Board Product Name*/ - fru_area = get_fru_area_str(fru_data, &fru_data_offset); - - fru_data_offset_tmp = fru_data_offset; - - /*Position at Serial Number*/ - fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp); - - fru_data_offset ++; - - if(strlen(fru_area) != sn_size) - { - printf("The length of the serial number in the FRU Board Area is wrong.\n"); - free(sn); - sn = NULL; - free(fru_data); - fru_data = NULL; - return(-1); - } - - /* Copy the new serial number in the board section saved in memory*/ - memcpy(fru_data + fru_data_offset, sn, sn_size); - - checksum = 0; - /* Calculate Header Checksum */ - for( i = (header.offset.board * 8); i < (((header.offset.board * 8)+board_sec_len) - 2) ; i ++ ) - { - checksum += fru_data[i]; - } - checksum = (~checksum) + 1; - - - fru_data[(header.offset.board * 8)+board_sec_len - 1] = checksum; - - /* Write the new FRU Board section */ - if(write_fru_area(intf, &fru, 0, (header.offset.board * 8), (header.offset.board * 8), board_sec_len, fru_data) < 0) - { - free(sn); - sn = NULL; - free(fru_data); - fru_data = NULL; - return(-1); - } - - /* Set the Product Section */ - prod_sec_len = (header.offset.multi * 8) - (header.offset.product * 8); - - if(read_fru_area(intf ,&fru ,0 ,(header.offset.product * 8) ,prod_sec_len , fru_data) < 0) - { - free(sn); - sn = NULL; - free(fru_data); - fru_data = NULL; - return(-1); - } - - /*Position at Product Manufacturer*/ - fru_data_offset = (header.offset.product * 8) + 3; - fru_area = get_fru_area_str(fru_data, &fru_data_offset); - - /*Position at Product Name*/ - fru_area = get_fru_area_str(fru_data, &fru_data_offset); - - /*Position at Product Part*/ - fru_area = get_fru_area_str(fru_data, &fru_data_offset); - - /*Position at Product Version*/ - fru_area = get_fru_area_str(fru_data, &fru_data_offset); - - - - fru_data_offset_tmp = fru_data_offset; - - /*Position at Serial Number*/ - fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp); - - fru_data_offset ++; - - if(strlen(fru_area) != sn_size) - { - free(sn); - sn = NULL; - free(fru_data); - fru_data = NULL; - printf("The length of the serial number in the FRU Product Area is wrong.\n"); - return(-1); - - } - - /* Copy the new serial number in the product section saved in memory*/ - memcpy(fru_data + fru_data_offset, sn, sn_size); - - checksum = 0; - /* Calculate Header Checksum */ - for( i = (header.offset.product * 8); i < (((header.offset.product * 8)+prod_sec_len) - 2) ; i ++ ) - { - checksum += fru_data[i]; - } - checksum = (~checksum) + 1; - - - fru_data[(header.offset.product * 8)+prod_sec_len - 1] = checksum; - - /* Write the new FRU Board section */ - if(write_fru_area(intf, &fru, 0, (header.offset.product * 8), (header.offset.product * 8), prod_sec_len, fru_data) < 0) - { - free(sn); - sn = NULL; - free(fru_data); - fru_data = NULL; - return -1; - } - - free(sn); - sn = NULL; - free(fru_data); - fru_data = NULL; - - return(1); - + struct fru_header header; + struct fru_info fru; + struct ipmi_rs *rsp; + struct ipmi_rq req; + char *sn; + char *fru_area; + uint8_t checksum; + uint8_t *fru_data; + uint8_t msg_data[4]; + uint8_t sn_size; + uint32_t board_sec_len; + uint32_t fru_data_offset; + uint32_t fru_data_offset_tmp; + uint32_t i; + uint32_t prod_sec_len; + + sn = NULL; + fru_data = NULL; + + memset(msg_data, 0, 4); + msg_data[0] = 0xb4; + msg_data[1] = 0x90; + msg_data[2] = 0x91; + msg_data[3] = 0x8b; + + memset(&req, 0, sizeof(req)); + req.msg.netfn = 0x3E; + req.msg.cmd = 0x0C; + req.msg.data = msg_data; + req.msg.data_len = 4; + /* Set Lun, necessary for this oem command */ + req.msg.lun = 0x03; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf(" Device not present (No Response)\n"); + return (-1); + } else if (rsp->ccode > 0) { + printf(" This option is not implemented for this board\n"); + return (-1); + } + sn_size = rsp->data_len; + sn = malloc(sn_size + 1); + if (sn == NULL) { + lprintf(LOG_ERR, "ipmitool: malloc failure"); + return (-1); + } + memset(sn, 0, sn_size + 1); + memcpy(sn, rsp->data, sn_size); + if (verbose >= 1) { + printf("Original serial number is : [%s]\n", sn); + } + memset(msg_data, 0, 4); + msg_data[0] = 0; + memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_STORAGE; + req.msg.cmd = GET_FRU_INFO; + req.msg.data = msg_data; + req.msg.data_len = 1; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf(" Device not present (No Response)\n"); + free(sn); + sn = NULL; + return (-1); + } else if (rsp->ccode > 0) { + printf(" Device not present (%s)\n", + val2str(rsp->ccode, completion_code_vals)); + free(sn); + sn = NULL; + return (-1); + } + memset(&fru, 0, sizeof(fru)); + fru.size = (rsp->data[1] << 8) | rsp->data[0]; + fru.access = rsp->data[2] & 0x1; + if (fru.size < 1) { + printf(" Invalid FRU size %d", fru.size); + free(sn); + sn = NULL; + return (-1); + } + /* retrieve the FRU header */ + msg_data[0] = 0; + msg_data[1] = 0; + msg_data[2] = 0; + msg_data[3] = 8; + + memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_STORAGE; + req.msg.cmd = GET_FRU_DATA; + req.msg.data = msg_data; + req.msg.data_len = 4; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf(" Device not present (No Response)\n"); + free(sn); + sn = NULL; + return (-1); + } else if (rsp->ccode > 0) { + printf(" Device not present (%s)\n", + val2str(rsp->ccode, completion_code_vals)); + free(sn); + sn = NULL; + return (-1); + } + if (verbose > 1) { + printbuf(rsp->data, rsp->data_len, "FRU DATA"); + } + memcpy(&header, rsp->data + 1, 8); + if (header.version != 1) { + printf(" Unknown FRU header version 0x%02x", + header.version); + free(sn); + sn = NULL; + return(-1); + } + /* Set the Board Section */ + board_sec_len = (header.offset.product * 8) - (header.offset.board * 8); + fru_data = malloc(fru.size); + if (fru_data == NULL) { + lprintf(LOG_ERR, "ipmitool: malloc failure"); + free(sn); + sn = NULL; + return (-1); + } + memset(fru_data, 0, fru.size); + if (read_fru_area(intf, &fru, 0, (header.offset.board * 8), + board_sec_len, fru_data) < 0) { + free(sn); + sn = NULL; + free(fru_data); + fru_data = NULL; + return (-1); + } + /* Position at Board Manufacturer */ + fru_data_offset = (header.offset.board * 8) + 6; + fru_area = get_fru_area_str(fru_data, &fru_data_offset); + /* Position at Board Product Name */ + fru_area = get_fru_area_str(fru_data, &fru_data_offset); + fru_data_offset_tmp = fru_data_offset; + /* Position at Serial Number */ + fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp); + fru_data_offset++; + if (strlen(fru_area) != sn_size) { + printf("The length of the serial number in the FRU Board Area is wrong.\n"); + free(sn); + sn = NULL; + free(fru_data); + fru_data = NULL; + return(-1); + } + /* Copy the new serial number in the board section saved in memory*/ + memcpy(fru_data + fru_data_offset, sn, sn_size); + checksum = 0; + /* Calculate Header Checksum */ + for(i = (header.offset.board * 8); + i < (((header.offset.board * 8) + board_sec_len) - 2); + i++) { + checksum += fru_data[i]; + } + checksum = (~checksum) + 1; + fru_data[(header.offset.board * 8) + board_sec_len - 1] = checksum; + /* Write the new FRU Board section */ + if (write_fru_area(intf, &fru, 0, (header.offset.board * 8), + (header.offset.board * 8), + board_sec_len, fru_data) < 0) { + free(sn); + sn = NULL; + free(fru_data); + fru_data = NULL; + return(-1); + } + /* Set the Product Section */ + prod_sec_len = (header.offset.multi * 8) - (header.offset.product * 8); + if (read_fru_area(intf, &fru, 0, (header.offset.product * 8), + prod_sec_len, fru_data) < 0) { + free(sn); + sn = NULL; + free(fru_data); + fru_data = NULL; + return(-1); + } + /* Position at Product Manufacturer */ + fru_data_offset = (header.offset.product * 8) + 3; + fru_area = get_fru_area_str(fru_data, &fru_data_offset); + /* Position at Product Name */ + fru_area = get_fru_area_str(fru_data, &fru_data_offset); + /* Position at Product Part */ + fru_area = get_fru_area_str(fru_data, &fru_data_offset); + /* Position at Product Version */ + fru_area = get_fru_area_str(fru_data, &fru_data_offset); + fru_data_offset_tmp = fru_data_offset; + /* Position at Serial Number */ + fru_area = get_fru_area_str(fru_data, &fru_data_offset_tmp); + fru_data_offset ++; + if (strlen(fru_area) != sn_size) { + free(sn); + sn = NULL; + free(fru_data); + fru_data = NULL; + printf("The length of the serial number in the FRU Product Area is wrong.\n"); + return(-1); + } + /* Copy the new serial number in the product section saved in memory*/ + memcpy(fru_data + fru_data_offset, sn, sn_size); + checksum = 0; + /* Calculate Header Checksum */ + for (i = (header.offset.product * 8); + i < (((header.offset.product * 8) + prod_sec_len) - 2); + i ++) { + checksum += fru_data[i]; + } + checksum = (~checksum) + 1; + fru_data[(header.offset.product * 8)+prod_sec_len - 1] = checksum; + /* Write the new FRU Board section */ + if (write_fru_area(intf, &fru, 0, (header.offset.product * 8), + (header.offset.product * 8), + prod_sec_len, fru_data) < 0) { + free(sn); + sn = NULL; + free(fru_data); + fru_data = NULL; + return -1; + } + free(sn); + sn = NULL; + free(fru_data); + fru_data = NULL; + return(1); } - /* ipmi_fru_set_mfg_date - Set the Manufacturing Date in FRU * - * @intf: ipmi interface - * @id: fru id + * @intf: ipmi interface + * @id: fru id * * returns -1 on error * returns 1 if successful */ static int -ipmi_kontron_set_mfg_date (struct ipmi_intf * intf) +ipmi_kontron_set_mfg_date (struct ipmi_intf *intf) { - struct ipmi_rs *rsp; - struct ipmi_rq req; - struct fru_info fru; - struct fru_header header; - uint8_t msg_data[4]; - uint8_t mfg_date[3]; - - uint32_t board_sec_len, i; - uint8_t *fru_data, checksum; - - - - - memset(msg_data, 0, 4); - msg_data[0] = 0xb4; - msg_data[1] = 0x90; - msg_data[2] = 0x91; - msg_data[3] = 0x8b; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = 0x3E; - req.msg.cmd = 0x0E; - req.msg.data = msg_data; - req.msg.data_len = 4; - - /* Set Lun temporary, necessary for this oem command */ - req.msg.lun = 0x03; - - rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) - { - printf("Device not present (No Response)\n"); - return(-1); - } - - if (rsp->ccode > 0) - { - printf("This option is not implemented for this board\n"); - return(-1); - } - - if(rsp->data_len != 3) - { - printf("Invalid response for the Manufacturing date\n"); - return(-1); - } - - memset(mfg_date, 0, 3); - memcpy(mfg_date, rsp->data, 3); - - memset(msg_data, 0, 4); - msg_data[0] = 0; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_STORAGE; - req.msg.cmd = GET_FRU_INFO; - req.msg.data = msg_data; - 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); - } - - memset(&fru, 0, sizeof(fru)); - fru.size = (rsp->data[1] << 8) | rsp->data[0]; - fru.access = rsp->data[2] & 0x1; - - if (fru.size < 1) { - printf(" Invalid FRU size %d", fru.size); - return(-1); - } - - /* - * retrieve the FRU header - */ - msg_data[0] = 0; - msg_data[1] = 0; - msg_data[2] = 0; - msg_data[3] = 8; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_STORAGE; - req.msg.cmd = GET_FRU_DATA; - req.msg.data = msg_data; - req.msg.data_len = 4; - - 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 (verbose > 1) - printbuf(rsp->data, rsp->data_len, "FRU DATA"); - - memcpy(&header, rsp->data + 1, 8); - - if (header.version != 1) - { - printf(" Unknown FRU header version 0x%02x", - header.version); - return(-1); - } - - - board_sec_len = (header.offset.product * 8) - (header.offset.board * 8); - - fru_data = malloc( fru.size); - - if(fru_data == NULL) - { - printf("Out of memory!"); - return(-1); - } - - memset(fru_data, 0, fru.size); - if(read_fru_area(intf ,&fru ,0 ,(header.offset.board * 8) ,board_sec_len , fru_data) < 0) - { - free(fru_data); - fru_data = NULL; - return(-1); - } - - /* Copy the new manufacturing date in the board section saved in memory*/ - memcpy(fru_data + (header.offset.board * 8) + 3, mfg_date, 3); - - checksum = 0; - /* Calculate Header Checksum */ - for( i = (header.offset.board * 8); i < (((header.offset.board * 8)+board_sec_len) - 2) ; i ++ ) - { - checksum += fru_data[i]; - } - checksum = (~checksum) + 1; - - fru_data[(header.offset.board * 8)+board_sec_len - 1] = checksum; - - /* Write the new FRU Board section */ - if(write_fru_area(intf, &fru, 0, (header.offset.board * 8), (header.offset.board * 8), board_sec_len, fru_data) < 0) - { - free(fru_data); - fru_data = NULL; - return(-1); - } - - free(fru_data); - fru_data = NULL; - return(1); + struct fru_header header; + struct fru_info fru; + struct ipmi_rs *rsp; + struct ipmi_rq req; + uint8_t *fru_data; + uint8_t checksum; + uint8_t msg_data[4]; + uint8_t mfg_date[3]; + uint32_t board_sec_len; + uint32_t i; + + memset(msg_data, 0, 4); + msg_data[0] = 0xb4; + msg_data[1] = 0x90; + msg_data[2] = 0x91; + msg_data[3] = 0x8b; + + memset(&req, 0, sizeof(req)); + req.msg.netfn = 0x3E; + req.msg.cmd = 0x0E; + req.msg.data = msg_data; + req.msg.data_len = 4; + /* Set Lun temporary, necessary for this oem command */ + req.msg.lun = 0x03; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf("Device not present (No Response)\n"); + return(-1); + } else if (rsp->ccode > 0) { + printf("This option is not implemented for this board\n"); + return(-1); + } + if (rsp->data_len != 3) { + printf("Invalid response for the Manufacturing date\n"); + return(-1); + } + memset(mfg_date, 0, 3); + memcpy(mfg_date, rsp->data, 3); + memset(msg_data, 0, 4); + msg_data[0] = 0; + + memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_STORAGE; + req.msg.cmd = GET_FRU_INFO; + req.msg.data = msg_data; + req.msg.data_len = 1; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf(" Device not present (No Response)\n"); + return(-1); + } else if (rsp->ccode > 0) { + printf(" Device not present (%s)\n", + val2str(rsp->ccode, completion_code_vals)); + return(-1); + } + + memset(&fru, 0, sizeof(fru)); + fru.size = (rsp->data[1] << 8) | rsp->data[0]; + fru.access = rsp->data[2] & 0x1; + if (fru.size < 1) { + printf(" Invalid FRU size %d", fru.size); + return(-1); + } + /* retrieve the FRU header */ + msg_data[0] = 0; + msg_data[1] = 0; + msg_data[2] = 0; + msg_data[3] = 8; + + memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_STORAGE; + req.msg.cmd = GET_FRU_DATA; + req.msg.data = msg_data; + req.msg.data_len = 4; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf(" Device not present (No Response)\n"); + return (-1); + } else if (rsp->ccode > 0) { + printf(" Device not present (%s)\n", + val2str(rsp->ccode, completion_code_vals)); + return (-1); + } + if (verbose > 1) { + printbuf(rsp->data, rsp->data_len, "FRU DATA"); + } + memcpy(&header, rsp->data + 1, 8); + if (header.version != 1) { + printf(" Unknown FRU header version 0x%02x", + header.version); + return(-1); + } + board_sec_len = (header.offset.product * 8) - (header.offset.board * 8); + fru_data = malloc(fru.size); + if(fru_data == NULL) { + lprintf(LOG_ERR, "ipmitool: malloc failure"); + return(-1); + } + memset(fru_data, 0, fru.size); + if (read_fru_area(intf ,&fru ,0 ,(header.offset.board * 8), + board_sec_len ,fru_data) < 0) { + free(fru_data); + fru_data = NULL; + return(-1); + } + /* Copy the new manufacturing date in the board section saved in memory*/ + memcpy(fru_data + (header.offset.board * 8) + 3, mfg_date, 3); + checksum = 0; + /* Calculate Header Checksum */ + for (i = (header.offset.board * 8); + i < (((header.offset.board * 8) + board_sec_len) - 2); + i ++ ) { + checksum += fru_data[i]; + } + checksum = (~checksum) + 1; + fru_data[(header.offset.board * 8)+board_sec_len - 1] = checksum; + /* Write the new FRU Board section */ + if (write_fru_area(intf, &fru, 0, (header.offset.board * 8), + (header.offset.board * 8), + board_sec_len, fru_data) < 0) { + free(fru_data); + fru_data = NULL; + return (-1); + } + free(fru_data); + fru_data = NULL; + return (1); } - -static char *bootdev[] = {"BIOS", "FDD", "HDD", "CDROM", "network", 0}; - static void ipmi_kontron_nextboot_help(void) { - int i; - printf("nextboot <device>\n" - "Supported devices:\n"); - for (i = 0; bootdev[i] != 0; i++) { - printf("- %s\n", bootdev[i]); - } + int i; + printf("nextboot <device>\n" + "Supported devices:\n"); + for (i = 0; bootdev[i] != 0; i++) { + printf("- %s\n", bootdev[i]); + } } /* ipmi_kontron_next_boot_set - Select the next boot order on CP6012 * - * @intf: ipmi interface - * @id: fru id + * @intf: ipmi interface + * @id: fru id * * returns -1 on error * returns 1 if successful */ static int -ipmi_kontron_nextboot_set(struct ipmi_intf * intf, int argc, char **argv) +ipmi_kontron_nextboot_set(struct ipmi_intf *intf, int argc, char **argv) { - struct ipmi_rs *rsp; - struct ipmi_rq req; - uint8_t msg_data[8]; - int i; - - memset(msg_data, 0, sizeof(msg_data)); - msg_data[0] = 0xb4; - msg_data[1] = 0x90; - msg_data[2] = 0x91; - msg_data[3] = 0x8b; - msg_data[4] = 0x9d; - msg_data[5] = 0xFF; - msg_data[6] = 0xFF; /* any */ - - for (i = 0; bootdev[i] != 0; i++) { - if (strcmp(argv[0], bootdev[i]) == 0) { - msg_data[5] = i; - break; - } - } - - /* Invalid device selected? */ - if (msg_data[5] == 0xFF) { - printf("Unknown boot device: %s\n", argv[0]); - return -1; - } - - memset(&req, 0, sizeof(req)); - req.msg.netfn = 0x3E; - req.msg.cmd = 0x02; - req.msg.data = msg_data; - req.msg.data_len = 7; - - /* Set Lun temporary, necessary for this oem command */ - req.msg.lun = 0x03; - - 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); - } - return 0; + struct ipmi_rs *rsp; + struct ipmi_rq req; + uint8_t msg_data[8]; + int i; + + memset(msg_data, 0, sizeof(msg_data)); + msg_data[0] = 0xb4; + msg_data[1] = 0x90; + msg_data[2] = 0x91; + msg_data[3] = 0x8b; + msg_data[4] = 0x9d; + msg_data[5] = 0xFF; + msg_data[6] = 0xFF; /* any */ + for (i = 0; bootdev[i] != 0; i++) { + if (strcmp(argv[0], bootdev[i]) == 0) { + msg_data[5] = i; + break; + } + } + /* Invalid device selected? */ + if (msg_data[5] == 0xFF) { + printf("Unknown boot device: %s\n", argv[0]); + return (-1); + } + memset(&req, 0, sizeof(req)); + req.msg.netfn = 0x3E; + req.msg.cmd = 0x02; + req.msg.data = msg_data; + req.msg.data_len = 7; + /* Set Lun temporary, necessary for this oem command */ + req.msg.lun = 0x03; + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + printf("Device not present (No Response)\n"); + return(-1); + } else if (rsp->ccode > 0) { + printf("Device not present (%s)\n", + val2str(rsp->ccode, completion_code_vals)); + return (-1); + } + return 0; } - diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c index 14ca183..2bbbe4b 100644 --- a/lib/ipmi_main.c +++ b/lib/ipmi_main.c @@ -125,8 +125,8 @@ ipmi_password_file_read(char * filename) return NULL; } - /* remove trailing whitespace */ - l = strcspn(pass, " \r\n\t"); + /* remove traling <cr><nl><tab> */ + l = strcspn(pass, "\r\n\t"); if (l > 0) { pass[l] = '\0'; } diff --git a/lib/ipmi_picmg.c b/lib/ipmi_picmg.c index d1c82b2..7a66aa5 100644 --- a/lib/ipmi_picmg.c +++ b/lib/ipmi_picmg.c @@ -2345,7 +2345,7 @@ picmg_discover(struct ipmi_intf *intf) { req.msg.data_len = 1; msg_data = 0; - lprintf(LOG_INFO, "Running Get PICMG Properties my_addr %#x, transit %#x, target %#x", + lprintf(LOG_DEBUG, "Running Get PICMG Properties my_addr %#x, transit %#x, target %#x", intf->my_addr, intf->transit_addr, intf->target_addr); rsp = intf->sendrecv(intf, &req); if (rsp && !rsp->ccode) { @@ -2353,19 +2353,19 @@ picmg_discover(struct ipmi_intf *intf) { ((rsp->data[1] & 0x0F) == PICMG_ATCA_MAJOR_VERSION || (rsp->data[1] & 0x0F) == PICMG_AMC_MAJOR_VERSION) ) { intf->picmg_avail = 1; - lprintf(LOG_INFO, "Discovered PICMG Extension %d.%d", + lprintf(LOG_DEBUG, "Discovered PICMG Extension %d.%d", (rsp->data[1] & 0x0f), (rsp->data[1] >> 4)); - } + } } else { if (rsp == NULL) { - lprintf(LOG_INFO,"No Response from Get PICMG Properties"); + lprintf(LOG_DEBUG,"No Response from Get PICMG Properties"); } else { - lprintf(LOG_INFO,"Error Response %#x from Get PICMG Properities", rsp->ccode); + lprintf(LOG_DEBUG,"Error Response %#x from Get PICMG Properities", rsp->ccode); } } } if (intf->picmg_avail == 0) { - lprintf(LOG_INFO, "No PICMG Extenstion discovered"); + lprintf(LOG_DEBUG, "No PICMG Extenstion discovered"); } return intf->picmg_avail; } diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c index 21ce0c4..67e12e3 100644 --- a/lib/ipmi_sel.c +++ b/lib/ipmi_sel.c @@ -1778,7 +1778,7 @@ ipmi_sel_print_std_entry(struct ipmi_intf * intf, struct sel_event_record * evt) else printf(" | "); - if(evt->record_type < 0xdf) + if(evt->record_type <= 0xdf) { printf ("%02x%02x%02x", evt->sel_type.oem_ts_type.manf_id[0], evt->sel_type.oem_ts_type.manf_id[1], evt->sel_type.oem_ts_type.manf_id[2]); if (csv_output) @@ -1979,7 +1979,7 @@ ipmi_sel_print_std_entry_verbose(struct ipmi_intf * intf, struct sel_event_recor if (evt->record_type >= 0xc0) { - if(evt->record_type < 0xdf) + if(evt->record_type <= 0xdf) { printf (" Manufactacturer ID : %02x%02x%02x\n", evt->sel_type.oem_ts_type.manf_id[0], evt->sel_type.oem_ts_type.manf_id[1], evt->sel_type.oem_ts_type.manf_id[2]); diff --git a/lib/ipmi_sensor.c b/lib/ipmi_sensor.c index 4ef5138..c138c67 100644 --- a/lib/ipmi_sensor.c +++ b/lib/ipmi_sensor.c @@ -42,7 +42,8 @@ #include <ipmitool/ipmi_sensor.h> extern int verbose; -void printf_sensor_get_usage(); +void print_sensor_get_usage(); +void print_sensor_thresh_usage(); // Macro's for Reading the current sensor Data. #define SCANNING_DISABLED 0x40 @@ -515,7 +516,6 @@ __ipmi_sensor_threshold_value_to_raw(struct sdr_record_full_sensor *full, double } } - static int ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv) { @@ -531,33 +531,7 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv) struct sdr_record_list *sdr; 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"); - lprintf(LOG_NOTICE, ""); - lprintf(LOG_NOTICE, - "sensor thresh <id> lower <lnr> <lcr> <lnc>"); - lprintf(LOG_NOTICE, - " Set all lower thresholds at the same time"); - lprintf(LOG_NOTICE, ""); - lprintf(LOG_NOTICE, - "sensor thresh <id> upper <unc> <ucr> <unr>"); - lprintf(LOG_NOTICE, - " Set all upper thresholds at the same time"); - lprintf(LOG_NOTICE, ""); + print_sensor_thresh_usage(); return 0; } @@ -589,7 +563,7 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv) } else if (strncmp(thresh, "lower", 5) == 0) { if (argc < 5) { lprintf(LOG_ERR, - "usage: sensor thresh <id> lower <unc> <ucr> <unr>"); + "usage: sensor thresh <id> lower <lnr> <lcr> <lnc>"); return -1; } allLower = 1; @@ -899,10 +873,10 @@ ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv) if (argc < 1) { lprintf(LOG_ERR, "Not enough parameters given."); - printf_sensor_get_usage(); + print_sensor_get_usage(); return (-1); } else if (strcmp(argv[0], "help") == 0) { - printf_sensor_get_usage(); + print_sensor_get_usage(); return 0; } printf("Locating sensor record...\n"); @@ -952,13 +926,55 @@ ipmi_sensor_main(struct ipmi_intf *intf, int argc, char **argv) return rc; } -/* printf_sensor_get_usage - print usage for # ipmitool sensor get NAC; +/* print_sensor_get_usage - print usage for # ipmitool sensor get NAC; * * @returns: void */ void -printf_sensor_get_usage() +print_sensor_get_usage() { lprintf(LOG_NOTICE, "sensor get <id> ... [id]"); lprintf(LOG_NOTICE, " id : name of desired sensor"); } + +/* print_sensor_thresh_set_usage - print usage for # ipmitool sensor thresh; + * + * @returns: void + */ +void +print_sensor_thresh_usage() +{ + 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"); + lprintf(LOG_NOTICE, +""); + lprintf(LOG_NOTICE, +"sensor thresh <id> lower <lnr> <lcr> <lnc>"); + lprintf(LOG_NOTICE, +" Set all lower thresholds at the same time"); + lprintf(LOG_NOTICE, +""); + lprintf(LOG_NOTICE, +"sensor thresh <id> upper <unc> <ucr> <unr>"); + lprintf(LOG_NOTICE, +" Set all upper thresholds at the same time"); + lprintf(LOG_NOTICE, ""); +} diff --git a/lib/ipmi_sol.c b/lib/ipmi_sol.c index a5b962f..cf58b44 100644 --- a/lib/ipmi_sol.c +++ b/lib/ipmi_sol.c @@ -1477,33 +1477,28 @@ static int ipmi_sol_keepalive_using_sol(struct ipmi_intf * intf) { struct ipmi_v2_payload v2_payload; - struct ipmi_rs * rsp = NULL; struct timeval end; - int ret = 0; - if (_disable_keepalive) return 0; gettimeofday(&end, 0); if (end.tv_sec - _start_keepalive.tv_sec > SOL_KEEPALIVE_TIMEOUT) { - memset(&v2_payload, 0, sizeof(v2_payload)); - - v2_payload.payload.sol_packet.character_count = 0; - - rsp = intf->send_sol(intf, &v2_payload); - + memset(&v2_payload, 0, sizeof(v2_payload)); + v2_payload.payload.sol_packet.character_count = 0; + if (intf->send_sol(intf, &v2_payload) == NULL) + return -1; + /* good return, reset start time */ gettimeofday(&_start_keepalive, 0); - } - return ret; + } + return 0; } static int ipmi_sol_keepalive_using_getdeviceid(struct ipmi_intf * intf) { struct timeval end; - static int ret = 0; if (_disable_keepalive) return 0; @@ -1511,16 +1506,12 @@ ipmi_sol_keepalive_using_getdeviceid(struct ipmi_intf * intf) gettimeofday(&end, 0); if (end.tv_sec - _start_keepalive.tv_sec > SOL_KEEPALIVE_TIMEOUT) { - ret = intf->keepalive(intf); - if ( (ret!=0) && (_keepalive_retries < SOL_KEEPALIVE_RETRIES) ) { - ret = 0; - _keepalive_retries++; - } - else if ((ret==0) && (_keepalive_retries > 0)) - _keepalive_retries = 0; + if (intf->keepalive(intf) != 0) + return -1; + /* good return, reset start time */ gettimeofday(&_start_keepalive, 0); - } - return ret; + } + return 0; } @@ -1653,14 +1644,15 @@ ipmi_sol_red_pill(struct ipmi_intf * intf, int instance) else if (FD_ISSET(intf->fd, &read_fds)) { struct ipmi_rs * rs =intf->recv_sol(intf); - if (! rs) - { - bShouldExit = bBmcClosedSession = 1; - } - else + if ( rs) { output(rs); } + /* + * Should recv_sol come back null, the incoming packet was not ours. + * Just fall through, the keepalive logic will determine if + * the BMC has dropped the session. + */ } diff --git a/lib/ipmi_tsol.c b/lib/ipmi_tsol.c index 94ea284..b4e3cc1 100644 --- a/lib/ipmi_tsol.c +++ b/lib/ipmi_tsol.c @@ -76,78 +76,77 @@ static int _altterm = 0; extern int verbose; static int -ipmi_tsol_command(struct ipmi_intf * intf, char *recvip, int port, unsigned char cmd) +ipmi_tsol_command(struct ipmi_intf *intf, char *recvip, int port, + unsigned char cmd) { - struct ipmi_rs *rsp; - struct ipmi_rq req; - unsigned char data[6]; - unsigned ip1, ip2, ip3, ip4; - - if (sscanf(recvip, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) != 4) { - lprintf(LOG_ERR, "Invalid IP address: %s", recvip); - return -1; - } - + struct ipmi_rs *rsp; + struct ipmi_rq req; + unsigned char data[6]; + unsigned ip1, ip2, ip3, ip4; + + if (sscanf(recvip, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) != 4) { + lprintf(LOG_ERR, "Invalid IP address: %s", recvip); + return (-1); + } memset(&req, 0, sizeof(struct ipmi_rq)); - req.msg.netfn = IPMI_NETFN_TSOL; - req.msg.cmd = cmd; - req.msg.data_len = 6; - req.msg.data = data; + req.msg.netfn = IPMI_NETFN_TSOL; + req.msg.cmd = cmd; + req.msg.data_len = 6; + req.msg.data = data; memset(data, 0, sizeof(data)); - data[0] = ip1; - data[1] = ip2; - data[2] = ip3; - data[3] = ip4; - data[4] = (port & 0xff00) >> 8; - data[5] = (port & 0xff); - - rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + data[0] = ip1; + data[1] = ip2; + data[2] = ip3; + data[3] = ip4; + data[4] = (port & 0xff00) >> 8; + data[5] = (port & 0xff); + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { lprintf(LOG_ERR, "Unable to perform TSOL command"); - return -1; + return (-1); } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Unable to perform TSOL command: %s", - val2str(rsp->ccode, completion_code_vals)); - return -1; - } - - return 0; + val2str(rsp->ccode, completion_code_vals)); + return (-1); + } + return 0; } static int -ipmi_tsol_start(struct ipmi_intf * intf, char *recvip, int port) +ipmi_tsol_start(struct ipmi_intf *intf, char *recvip, int port) { return ipmi_tsol_command(intf, recvip, port, IPMI_TSOL_CMD_START); } static int -ipmi_tsol_stop(struct ipmi_intf * intf, char *recvip, int port) +ipmi_tsol_stop(struct ipmi_intf *intf, char *recvip, int port) { - return ipmi_tsol_command(intf, recvip, port, IPMI_TSOL_CMD_STOP); + return ipmi_tsol_command(intf, recvip, port, IPMI_TSOL_CMD_STOP); } static int -ipmi_tsol_send_keystroke(struct ipmi_intf * intf, char *buff, int length) +ipmi_tsol_send_keystroke(struct ipmi_intf *intf, char *buff, int length) { - struct ipmi_rs * rsp; - struct ipmi_rq req; - unsigned char data[16]; + struct ipmi_rs *rsp; + struct ipmi_rq req; + unsigned char data[16]; static unsigned char keyseq = 0; memset(&req, 0, sizeof(struct ipmi_rq)); - req.msg.netfn = IPMI_NETFN_TSOL; - req.msg.cmd = IPMI_TSOL_CMD_SENDKEY; - req.msg.data_len = length + 2; - req.msg.data = data; + req.msg.netfn = IPMI_NETFN_TSOL; + req.msg.cmd = IPMI_TSOL_CMD_SENDKEY; + req.msg.data_len = length + 2; + req.msg.data = data; memset(data, 0, sizeof(data)); - data[0] = length + 1; + data[0] = length + 1; memcpy(data + 1, buff, length); data[length + 1] = keyseq++; - rsp = intf->sendrecv(intf, &req); + rsp = intf->sendrecv(intf, &req); if (verbose) { if (rsp == NULL) { lprintf(LOG_ERR, "Unable to send keystroke"); @@ -155,61 +154,56 @@ ipmi_tsol_send_keystroke(struct ipmi_intf * intf, char *buff, int length) } if (rsp->ccode > 0) { lprintf(LOG_ERR, "Unable to send keystroke: %s", - val2str(rsp->ccode, completion_code_vals)); + val2str(rsp->ccode, completion_code_vals)); return -1; } } - - return length; + return length; } static int -tsol_keepalive(struct ipmi_intf * intf) +tsol_keepalive(struct ipmi_intf *intf) { - struct timeval end; - - gettimeofday(&end, 0); - - if (end.tv_sec - _start_keepalive.tv_sec <= 30) - return 0; - - intf->keepalive(intf); - + struct timeval end; + gettimeofday(&end, 0); + if (end.tv_sec - _start_keepalive.tv_sec <= 30) { + return 0; + } + intf->keepalive(intf); gettimeofday(&_start_keepalive, 0); - - return 0; + return 0; } static void print_escape_seq(struct ipmi_intf *intf) { lprintf(LOG_NOTICE, - " %c. - terminate connection\n" - " %c^Z - suspend ipmitool\n" - " %c^X - suspend ipmitool, but don't restore tty on restart\n" - " %c? - this message\n" - " %c%c - send the escape character by typing it twice\n" - " (Note that escapes are only recognized immediately after newline.)", - intf->session->sol_escape_char, - intf->session->sol_escape_char, - intf->session->sol_escape_char, - intf->session->sol_escape_char, - intf->session->sol_escape_char, - intf->session->sol_escape_char); +" %c. - terminate connection\n" +" %c^Z - suspend ipmitool\n" +" %c^X - suspend ipmitool, but don't restore tty on restart\n" +" %c? - this message\n" +" %c%c - send the escape character by typing it twice\n" +" (Note that escapes are only recognized immediately after newline.)", + intf->session->sol_escape_char, + intf->session->sol_escape_char, + intf->session->sol_escape_char, + intf->session->sol_escape_char, + intf->session->sol_escape_char, + intf->session->sol_escape_char); } static int leave_raw_mode(void) { - if (!_in_raw_mode) + if (!_in_raw_mode) { return -1; - else if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) + } else if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) { lperror(LOG_ERR, "tcsetattr(stdin)"); - else if (tcsetattr(fileno(stdout), TCSADRAIN, &_saved_tio) == -1) + } else if (tcsetattr(fileno(stdout), TCSADRAIN, &_saved_tio) == -1) { lperror(LOG_ERR, "tcsetattr(stdout)"); - else + } else { _in_raw_mode = 0; - + } return 0; } @@ -217,16 +211,14 @@ static int enter_raw_mode(void) { struct termios tio; - if (tcgetattr(fileno(stdout), &_saved_tio) < 0) { lperror(LOG_ERR, "tcgetattr failed"); return -1; } tio = _saved_tio; - if (_altterm) { - tio.c_iflag &= (ISTRIP | IGNBRK ); + tio.c_iflag &= (ISTRIP | IGNBRK); tio.c_cflag &= ~(CSIZE | PARENB | IXON | IXOFF | IXANY); tio.c_cflag |= (CS8 |CREAD) | (IXON|IXOFF|IXANY); tio.c_lflag &= 0; @@ -241,13 +233,13 @@ enter_raw_mode(void) tio.c_cc[VTIME] = 0; } - if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) < 0) + if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) < 0) { lperror(LOG_ERR, "tcsetattr(stdin)"); - else if (tcsetattr(fileno(stdout), TCSADRAIN, &tio) < 0) + } else if (tcsetattr(fileno(stdout), TCSADRAIN, &tio) < 0) { lperror(LOG_ERR, "tcsetattr(stdout)"); - else + } else { _in_raw_mode = 1; - + } return 0; } @@ -255,11 +247,10 @@ static void suspend_self(int restore_tty) { leave_raw_mode(); - kill(getpid(), SIGTSTP); - - if (restore_tty) + if (restore_tty) { enter_raw_mode(); + } } static int @@ -272,7 +263,7 @@ do_inbuf_actions(struct ipmi_intf *intf, char *in_buff, int len) for(i = 0; i < len ;) { if (!in_esc) { if (last_was_cr && - (in_buff[i] == intf->session->sol_escape_char)) { + (in_buff[i] == intf->session->sol_escape_char)) { in_esc = 1; memmove(in_buff, in_buff + 1, len - i - 1); len--; @@ -289,40 +280,35 @@ do_inbuf_actions(struct ipmi_intf *intf, char *in_buff, int len) switch (in_buff[i]) { case '.': printf("%c. [terminated ipmitool]\n", - intf->session->sol_escape_char); + intf->session->sol_escape_char); return -1; - case 'Z' - 64: printf("%c^Z [suspend ipmitool]\n", - intf->session->sol_escape_char); - suspend_self(1); /* Restore tty back to raw */ + intf->session->sol_escape_char); + /* Restore tty back to raw */ + suspend_self(1); break; - case 'X' - 64: printf("%c^X [suspend ipmitool]\n", - intf->session->sol_escape_char); - suspend_self(0); /* Don't restore to raw mode */ + intf->session->sol_escape_char); + /* Don't restore to raw mode */ + suspend_self(0); break; - case '?': printf("%c? [ipmitool help]\n", - intf->session->sol_escape_char); + intf->session->sol_escape_char); print_escape_seq(intf); break; } - memmove(in_buff, in_buff + 1, len - i - 1); + memmove(in_buff, (in_buff + 1), (len - i - 1)); len--; in_esc = 0; - continue; } - last_was_cr = (in_buff[i] == '\r' || in_buff[i] == '\n'); - i++; } - return len; } @@ -330,27 +316,25 @@ do_inbuf_actions(struct ipmi_intf *intf, char *in_buff, int len) static void do_terminal_cleanup(void) { - if (_saved_winsize.ws_row > 0 && _saved_winsize.ws_col > 0) + if (_saved_winsize.ws_row > 0 && _saved_winsize.ws_col > 0) { ioctl(fileno(stdout), TIOCSWINSZ, &_saved_winsize); - + } leave_raw_mode(); - - if (errno) + if (errno) { lprintf(LOG_ERR, "Exiting due to error %d -> %s", errno, strerror(errno)); + } } static void set_terminal_size(int rows, int cols) { struct winsize winsize; - - if (rows <= 0 || cols <= 0) + if (rows <= 0 || cols <= 0) { return; - + } /* save initial winsize */ ioctl(fileno(stdout), TIOCGWINSZ, &_saved_winsize); - /* set new winsize */ winsize.ws_row = rows; winsize.ws_col = cols; @@ -361,30 +345,35 @@ static void print_tsol_usage(void) { struct winsize winsize; - - lprintf(LOG_NOTICE, "Usage: tsol [recvip] [port=NUM] [ro|rw] [rows=NUM] [cols=NUM] [altterm]"); - lprintf(LOG_NOTICE, " recvip Receiver IP Address [default=local]"); - lprintf(LOG_NOTICE, " port=NUM Receiver UDP Port [default=%d]", - IPMI_TSOL_DEF_PORT); - lprintf(LOG_NOTICE, " ro|rw Set Read-Only or Read-Write [default=rw]"); - - ioctl(fileno(stdout), TIOCGWINSZ, &winsize); - lprintf(LOG_NOTICE, " rows=NUM Set terminal rows [default=%d]", - winsize.ws_row); - lprintf(LOG_NOTICE, " cols=NUM Set terminal columns [default=%d]", - winsize.ws_col); - - lprintf(LOG_NOTICE, " altterm Alternate terminal setup [default=off]"); + lprintf(LOG_NOTICE, +"Usage: tsol [recvip] [port=NUM] [ro|rw] [rows=NUM] [cols=NUM] [altterm]"); + lprintf(LOG_NOTICE, +" recvip Receiver IP Address [default=local]"); + lprintf(LOG_NOTICE, +" port=NUM Receiver UDP Port [default=%d]", + IPMI_TSOL_DEF_PORT); + lprintf(LOG_NOTICE, +" ro|rw Set Read-Only or Read-Write [default=rw]"); + ioctl(fileno(stdout), TIOCGWINSZ, &winsize); + lprintf(LOG_NOTICE, +" rows=NUM Set terminal rows [default=%d]", + winsize.ws_row); + lprintf(LOG_NOTICE, +" cols=NUM Set terminal columns [default=%d]", + winsize.ws_col); + lprintf(LOG_NOTICE, +" altterm Alternate terminal setup [default=off]"); } int -ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv) { struct pollfd fds_wait[3], fds_data_wait[3], *fds; struct sockaddr_in sin, myaddr, *sa_in; socklen_t mylen; char *recvip = NULL; - char out_buff[IPMI_BUF_SIZE * 8], in_buff[IPMI_BUF_SIZE]; + char in_buff[IPMI_BUF_SIZE]; + char out_buff[IPMI_BUF_SIZE * 8]; char buff[IPMI_BUF_SIZE + 4]; int fd_socket, result, i; int out_buff_fill, in_buff_fill; @@ -394,7 +383,7 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) if (strlen(intf->name) < 3 || strncmp(intf->name, "lan", 3) != 0) { lprintf(LOG_ERR, "Error: Tyan SOL is only available over lan interface"); - return -1; + return (-1); } for (i = 0; i<argc; i++) { @@ -402,24 +391,26 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) /* not free'd ...*/ /* recvip = strdup(argv[i]); */ recvip = argv[i]; - } - else if (sscanf(argv[i], "port=%d", &ip1) == 1) + } else if (sscanf(argv[i], "port=%d", &ip1) == 1) { port = ip1; - else if (sscanf(argv[i], "rows=%d", &ip1) == 1) + } else if (sscanf(argv[i], "rows=%d", &ip1) == 1) { rows = ip1; - else if (sscanf(argv[i], "cols=%d", &ip1) == 1) + } else if (sscanf(argv[i], "cols=%d", &ip1) == 1) { cols = ip1; - else if (strlen(argv[i]) == 2 && strncmp(argv[i], "ro", 2) == 0) + } else if (strlen(argv[i]) == 2 + && strncmp(argv[i], "ro", 2) == 0) { read_only = 1; - else if (strlen(argv[i]) == 2 && strncmp(argv[i], "rw", 2) == 0) + } else if (strlen(argv[i]) == 2 + && strncmp(argv[i], "rw", 2) == 0) { read_only = 0; - else if (strlen(argv[i]) == 7 && strncmp(argv[i], "altterm", 7) == 0) + } else if (strlen(argv[i]) == 7 + && strncmp(argv[i], "altterm", 7) == 0) { _altterm = 1; - else if (strlen(argv[i]) == 4 && strncmp(argv[i], "help", 4) == 0) { + } else if (strlen(argv[i]) == 4 + && strncmp(argv[i], "help", 4) == 0) { print_tsol_usage(); return 0; - } - else { + } else { print_tsol_usage(); return 0; } @@ -432,7 +423,7 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) sa_in = (struct sockaddr_in *)&intf->session->addr; result = inet_pton(AF_INET, (const char *)intf->session->hostname, - &sa_in->sin_addr); + &sa_in->sin_addr); if (result <= 0) { struct hostent *host = gethostbyname((const char *)intf->session->hostname); @@ -457,7 +448,7 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) lprintf(LOG_ERR, "Can't open port %d", port); return -1; } - if (-1 == bind(fd_socket, (struct sockaddr *)&sin, sizeof(sin))) { + if (bind(fd_socket, (struct sockaddr *)&sin, sizeof(sin)) == (-1)) { lprintf(LOG_ERR, "Failed to bind socket."); close(fd_socket); return -1; @@ -467,7 +458,8 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) * retrieve local IP address if not supplied on command line */ if (recvip == NULL) { - result = intf->open(intf); /* must connect first */ + /* must connect first */ + result = intf->open(intf); if (result < 0) { close(fd_socket); return -1; @@ -489,7 +481,7 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) } printf("[Starting %sSOL with receiving address %s:%d]\n", - read_only ? "Read-only " : "", recvip, port); + read_only ? "Read-only " : "", recvip, port); set_terminal_size(rows, cols); enter_raw_mode(); @@ -499,14 +491,14 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) * ipmitool -I lan -H 192.168.168.227 -U Administrator raw 0x30 0x06 0xC0 0xA8 0xA8 0x78 0x1A 0x0A */ result = ipmi_tsol_start(intf, recvip, port); - if (result < 0) { + if (result < 0) { lprintf(LOG_ERR, "Error starting SOL"); close(fd_socket); - return -1; - } + return (-1); + } printf("[SOL Session operational. Use %c? for help]\n", - intf->session->sol_escape_char); + intf->session->sol_escape_char); gettimeofday(&_start_keepalive, 0); @@ -533,52 +525,58 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) out_buff_fill = 0; in_buff_fill = 0; fds = fds_wait; - for (;;) { - result = poll(fds, 3, 15*1000); - if (result < 0) + result = poll(fds, 3, 15 * 1000); + if (result < 0) { break; + } /* send keepalive packet */ tsol_keepalive(intf); - if ((fds[0].revents & POLLIN) && (sizeof(out_buff) > out_buff_fill)){ + if ((fds[0].revents & POLLIN) && (sizeof(out_buff) > out_buff_fill)) { socklen_t sin_len = sizeof(sin); - result = recvfrom(fd_socket, buff, sizeof(out_buff) - out_buff_fill + 4, 0, - (struct sockaddr *)&sin, &sin_len); - - /* read the data from udp socket, skip some bytes in the head */ - if((result - 4) > 0 ){ + int buff_size = sizeof(buff); + if ((sizeof(out_buff) - out_buff_fill + 4) < buff_size) { + buff_size = (sizeof(out_buff) - out_buff_fill) + 4; + if ((buff_size - 4) <= 0) { + buff_size = 0; + } + } + result = recvfrom(fd_socket, buff, + buff_size, 0, + (struct sockaddr *)&sin, &sin_len); + /* read the data from udp socket, + * skip some bytes in the head + */ + if ((result - 4) > 0) { int length = result - 4; -#if 1 - length = (unsigned char)buff[2] & 0xff; - length *= 256; - length += ((unsigned char)buff[3] & 0xff); - if ((length <= 0) || (length > (result - 4))) - length = result - 4; -#endif memcpy(out_buff + out_buff_fill, buff + 4, length); out_buff_fill += length; } } if ((fds[1].revents & POLLIN) && (sizeof(in_buff) > in_buff_fill)) { + /* Read from keyboard */ result = read(fileno(stdin), in_buff + in_buff_fill, - sizeof(in_buff) - in_buff_fill); // read from keyboard + sizeof(in_buff) - in_buff_fill); if (result > 0) { int bytes; - bytes = do_inbuf_actions(intf, in_buff + in_buff_fill, result); - if(bytes < 0) { + bytes = do_inbuf_actions(intf, + in_buff + in_buff_fill, result); + if (bytes < 0) { result = ipmi_tsol_stop(intf, recvip, port); do_terminal_cleanup(); return result; } - if (read_only) + if (read_only) { bytes = 0; + } in_buff_fill += bytes; } } if ((fds[2].revents & POLLOUT) && out_buff_fill) { - result = write(fileno(stdout), out_buff, out_buff_fill); // to screen + /* To screen */ + result = write(fileno(stdout), out_buff, out_buff_fill); if (result > 0) { out_buff_fill -= result; if (out_buff_fill) { @@ -591,7 +589,8 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) * translate key and send that to SMDC using IPMI * ipmitool -I lan -H 192.168.168.227 -U Administrator raw 0x30 0x03 0x04 0x1B 0x5B 0x43 */ - result = ipmi_tsol_send_keystroke(intf, in_buff, __min(in_buff_fill,14)); + result = ipmi_tsol_send_keystroke(intf, + in_buff, __min(in_buff_fill, 14)); if (result > 0) { gettimeofday(&_start_keepalive, 0); in_buff_fill -= result; @@ -603,6 +602,5 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) fds = (in_buff_fill || out_buff_fill )? fds_data_wait : fds_wait; } - return 0; } |