diff options
Diffstat (limited to 'util')
40 files changed, 394 insertions, 144 deletions
diff --git a/util/Makefile.am b/util/Makefile.am index 16a8665..c3312ac 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -59,8 +59,11 @@ LANPLUS_OBJ = $(shell ar t @LANPLUS_LIB@ 2>/dev/null) bin_PROGRAMS = ipmiutil ievents idiscover sbin_PROGRAMS = ipmi_port iseltime DEV_LIB = libipmiutil.a -SHR_LIB = libipmiutil.so +# SHRLINK is libipmiutil.so.1 if OS supports it SHRLINK = @SHR_LINK@ +SHR_LIB = $(SHRLINK) +SHR_BLIB = libipmiutil.so +LDNAME = -Wl,-soname,$(SHR_LIB) EXTRA_PROGRAMS = ipmi_sample ipmi_sample_evt TESTPROGS = libimbapi.a iconfig ipmimv ifruset ipmi_sample2 ialarms_enc # OLDPROGS are old/previous binaries that may exist and need to be deleted. @@ -98,13 +101,16 @@ $(SHR_LIB): $(CMDMOD:.c=.o) @LANPLUS_LIB@ @LIBSENSORS@ $(CC) $(CFLAGS_SAMX) -o $(tmpobj)/ipmilanplus.o -c ipmilanplus.c; \ $(CC) $(CFLAGS_SAMX) -o $(tmpobj)/ipmilan.o -c ipmilan.c; \ ar x @LANPLUS_LIB@ ; \ - $(CC) $(LDFLAGS) -shared -o $(SHR_LIB) $(LIBOBJ) $(LANPLUS_OBJ); \ + $(CC) $(LDFLAGS) -shared $(LDNAME) -o $(SHR_LIB) $(LIBOBJ) $(LANPLUS_OBJ); \ else \ $(CC) $(CFLAGS_SAM) -o $(tmpobj)/ipmilanplus.o -c ipmilanplus.c; \ $(CC) $(CFLAGS_SAM) -o $(tmpobj)/ipmilan.o -c ipmilan.c; \ - $(CC) $(LDFLAGS) -shared -o $(SHR_LIB) $(LIBOBJ) ; \ + $(CC) $(LDFLAGS) -shared $(LDNAME) -o $(SHR_LIB) $(LIBOBJ) ; \ fi +$(SHR_BLIB): $(SHR_LIB) + ln -s $(SHR_LIB) $(SHR_BLIB) + # To build ipmiutil, need to use METACFLAGS for each .c/.o idiscover$(EXEEXT): idiscover.c @@ -180,7 +186,7 @@ EXTRA_DIST = imb_api.h ipmicmd.h ipmidir.h ipmilan.h ipmilanplus.h AnsiTerm.h i all-am: Makefile $(bin_PROGRAMS) $(sbin_PROGRAMS) $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) -install-data-am: $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) +install-data-am: $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) @INS_LIB@ mkdir -p $(DESTDIR)$(extradir) @INS_LIB@ mkdir -p $(DESTDIR)$(LIBDIR) @INS_LIB@ mkdir -p $(DESTDIR)$(inc_dir) @@ -191,10 +197,10 @@ install-data-am: $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) @INS_LIB@ cp -f isensor.h ievents.h $(DESTDIR)$(extradir) @INS_LIB@ cp -f Makefile.sample $(DESTDIR)$(extradir)/Makefile @INS_LIB@ cp -f $(DEV_LIB) $(DESTDIR)$(LIBDIR) - if [ "x$(SHRLINK)" != "x" ]; then \ - touch $(SHRLINK) ; \ - @INS_LIB@ cp -f $(SHR_LIB) $(DESTDIR)$(LIBDIR) ; \ - fi + @INS_LIB@ if [ "x$(SHRLINK)" != "x" ]; then \ + @INS_LIB@ cp -f $(SHRLINK) $(DESTDIR)$(LIBDIR) ; \ + @INS_LIB@ cd $(DESTDIR); ln -sf $(LIBDIR)/$(SHRLINK) $(DESTDIR)$(LIBDIR)/$(SHR_BLIB); \ + @INS_LIB@ fi clean-generic: rm -f $(DEV_LIB) $(EXTRA_PROGRAMS) $(OLDPROGS) $(TESTPROGS) $(SHRLINK) diff --git a/util/Makefile.in b/util/Makefile.in index 466c530..a745663 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -299,8 +299,11 @@ L2OBJ = @SAM2OBJ@ METASOURCE = ipmiutil.c ialarms.c ihealth.c ievents.c ifru.c ifru_picmg.c igetevent.c ireset.c icmd.c ilan.c isensor.c isel.c iserial.c iwdt.c isol.c idiscover.c iconfig.c ipicmg.c ifirewall.c ifwum.c ihpm.c itsol.c idcmi.c $(OEMMOD) $(CMDMOD) LANPLUS_OBJ = $(shell ar t @LANPLUS_LIB@ 2>/dev/null) DEV_LIB = libipmiutil.a -SHR_LIB = libipmiutil.so +# SHRLINK is libipmiutil.so.1 if OS supports it SHRLINK = @SHR_LINK@ +SHR_LIB = $(SHRLINK) +SHR_BLIB = libipmiutil.so +LDNAME = -Wl,-soname,$(SHR_LIB) TESTPROGS = libimbapi.a iconfig ipmimv ifruset ipmi_sample2 ialarms_enc # OLDPROGS are old/previous binaries that may exist and need to be deleted. OLDPROGS = alarms bmchealth fruconfig getevent hwreset icmd isolconsole pefconfig sensor showsel tmconfig wdt @@ -745,13 +748,16 @@ $(SHR_LIB): $(CMDMOD:.c=.o) @LANPLUS_LIB@ @LIBSENSORS@ $(CC) $(CFLAGS_SAMX) -o $(tmpobj)/ipmilanplus.o -c ipmilanplus.c; \ $(CC) $(CFLAGS_SAMX) -o $(tmpobj)/ipmilan.o -c ipmilan.c; \ ar x @LANPLUS_LIB@ ; \ - $(CC) $(LDFLAGS) -shared -o $(SHR_LIB) $(LIBOBJ) $(LANPLUS_OBJ); \ + $(CC) $(LDFLAGS) -shared $(LDNAME) -o $(SHR_LIB) $(LIBOBJ) $(LANPLUS_OBJ); \ else \ $(CC) $(CFLAGS_SAM) -o $(tmpobj)/ipmilanplus.o -c ipmilanplus.c; \ $(CC) $(CFLAGS_SAM) -o $(tmpobj)/ipmilan.o -c ipmilan.c; \ - $(CC) $(LDFLAGS) -shared -o $(SHR_LIB) $(LIBOBJ) ; \ + $(CC) $(LDFLAGS) -shared $(LDNAME) -o $(SHR_LIB) $(LIBOBJ) ; \ fi +$(SHR_BLIB): $(SHR_LIB) + ln -s $(SHR_LIB) $(SHR_BLIB) + # To build ipmiutil, need to use METACFLAGS for each .c/.o idiscover$(EXEEXT): idiscover.c @@ -816,7 +822,7 @@ ipmiutil$(EXEEXT): $(METASOURCE:.c=.o) @LANPLUS_LIB@ all-am: Makefile $(bin_PROGRAMS) $(sbin_PROGRAMS) $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) -install-data-am: $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) +install-data-am: $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) @INS_LIB@ mkdir -p $(DESTDIR)$(extradir) @INS_LIB@ mkdir -p $(DESTDIR)$(LIBDIR) @INS_LIB@ mkdir -p $(DESTDIR)$(inc_dir) @@ -827,10 +833,10 @@ install-data-am: $(EXTRA_PROGRAMS) $(DEV_LIB) $(SHRLINK) @INS_LIB@ cp -f isensor.h ievents.h $(DESTDIR)$(extradir) @INS_LIB@ cp -f Makefile.sample $(DESTDIR)$(extradir)/Makefile @INS_LIB@ cp -f $(DEV_LIB) $(DESTDIR)$(LIBDIR) - if [ "x$(SHRLINK)" != "x" ]; then \ - touch $(SHRLINK) ; \ - @INS_LIB@ cp -f $(SHR_LIB) $(DESTDIR)$(LIBDIR) ; \ - fi + @INS_LIB@ if [ "x$(SHRLINK)" != "x" ]; then \ + @INS_LIB@ cp -f $(SHRLINK) $(DESTDIR)$(LIBDIR) ; \ + @INS_LIB@ cd $(DESTDIR); ln -sf $(LIBDIR)/$(SHRLINK) $(DESTDIR)$(LIBDIR)/$(SHR_BLIB); \ + @INS_LIB@ fi clean-generic: rm -f $(DEV_LIB) $(EXTRA_PROGRAMS) $(OLDPROGS) $(TESTPROGS) $(SHRLINK) diff --git a/util/getopt.h-win32 b/util/getopt.h-win32 new file mode 100644 index 0000000..62fe3dd --- /dev/null +++ b/util/getopt.h-win32 @@ -0,0 +1,40 @@ +/* + * getopt.h + * + * 07/13/07 ARCress - created. + * + Copyright (c) 2007 Andy Cress <arcress at users.sourceforge.net> + BSD-3-clause + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + a. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + b. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + c. Neither the name of Kontron, nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _GETOPT_H_ +#define _GETOPT_H_ + +extern int getopt(int argc, char **argv, char *opts); + +extern int optind; +extern int optopt; +extern int opterr; +extern char *optarg; + +#endif diff --git a/util/ialarms.c b/util/ialarms.c index 68f69b4..e13960b 100644 --- a/util/ialarms.c +++ b/util/ialarms.c @@ -75,7 +75,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "ialarms"; static char fdebug = 0; static char fbmctam = 0; diff --git a/util/icmd.c b/util/icmd.c index c12de8a..4472879 100644 --- a/util/icmd.c +++ b/util/icmd.c @@ -78,7 +78,7 @@ extern void ipmi_lan_set_timeout(int ipmito, int tries, int pingto); /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "icmd"; static char fdebug = 0; static char fquiet = 0; diff --git a/util/iconfig.c b/util/iconfig.c index 6bdb104..ea2b65d 100644 --- a/util/iconfig.c +++ b/util/iconfig.c @@ -171,7 +171,7 @@ typedef struct /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "iconfig"; static char fdebug = 0; static char fipmilan = 0; @@ -392,7 +392,7 @@ static struct { #define DCMI_CONFIG 0x05 /*DCMI Config params*/ static int GetDeviceID(uchar *pLanRecord) -{ +{ /*See also ipmi_getdeviceid( pLanRecord, sizeof(LAN_RECORD),fdebug); */ uchar responseData[MAX_BUFFER_SIZE]; int responseLength = MAX_BUFFER_SIZE; int status; diff --git a/util/idcmi.c b/util/idcmi.c index 9ab1c82..173e55a 100644 --- a/util/idcmi.c +++ b/util/idcmi.c @@ -62,7 +62,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "idcmi.h" static char * progname = "idcmi"; -static char * progver = "2.96"; +static char * progver = "2.97"; extern char fdebug; /*from ipmicmd.c*/ static uchar g_bus = PUBLIC_BUS; static uchar g_sa = BMC_SA; diff --git a/util/idiscover.c b/util/idiscover.c index 57471e3..6dd0225 100644 --- a/util/idiscover.c +++ b/util/idiscover.c @@ -117,10 +117,14 @@ static char frawok = 0; /*raw not working in Solaris*/ #define RAW_DOMAIN AF_INET #define RAW_PROTO IPPROTO_RAW static char frawok = 0; /*raw not working in FreeBSD*/ +#elif HPUX +#define RAW_DOMAIN AF_INET +#define RAW_PROTO IPPROTO_RAW +static char frawok = 0; /*raw not working in HPUX*/ #elif MACOS #define RAW_DOMAIN AF_INET #define RAW_PROTO IPPROTO_RAW -static char frawok = 0; /*raw not working in FreeBSD*/ +static char frawok = 0; /*raw not working in MacOS*/ #elif WIN32 #define RAW_DOMAIN AF_INET #define RAW_PROTO IPPROTO_ICMP @@ -153,7 +157,7 @@ int GetFirstIP(uchar *ipaddr, uchar *macadr, char *ipname, char fdb); /*ilan.c*/ /* * Global variables */ -static char * progver = "1.9"; +static char * progver = "1.10"; static char * progname = "idiscover"; static char fdebug = 0; static char fping = 1; @@ -387,7 +391,7 @@ int inet_aton(const char *cp, struct in_addr *inp) else rv = 1; /*success*/ return(rv); } -#elif defined(SOLARIS) +#elif defined(SOLARIS) || defined(HPUX) int find_ifname(char *ifname) { return(-1); } #else @@ -398,15 +402,15 @@ int find_ifname(char *ifname) int rv = -1; if (getifaddrs(&ifaddr) == -1) return(rv); for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_addr == NULL) continue; - if ((ifa->ifa_addr->sa_family != AF_INET) && - (ifa->ifa_addr->sa_family != AF_INET6)) continue; - if (strcmp(ifa->ifa_name,"lo") == 0) continue; - /* if here, we have a valid ifname */ - strcpy(ifname,ifa->ifa_name); - if (fdebug) printf("find_ifname: found %s\n",ifname); - rv = 0; - break; + if (ifa->ifa_addr == NULL) continue; + if ((ifa->ifa_addr->sa_family != AF_INET) && + (ifa->ifa_addr->sa_family != AF_INET6)) continue; + if (strcmp(ifa->ifa_name,"lo") == 0) continue; + /* if here, we have a valid ifname */ + strcpy(ifname,ifa->ifa_name); + if (fdebug) printf("find_ifname: found %s\n",ifname); + rv = 0; + break; } freeifaddrs(ifaddr); return(rv); @@ -483,7 +487,7 @@ int sock_init( char *_interface, char *_startIP, char *_endIP) n = find_ifname(devname); if (n >= 0) { _interface = devname; - findif = 0; + findif = 0; /*found, do not find again below */ } } if (findif) @@ -630,10 +634,10 @@ void *receiveThread(void *p) if ((g_sockraw = socket(RAW_DOMAIN, SOCK_RAW,RAW_PROTO)) == SockInvalid) { printerr("raw socket: %s\n", showlasterr()); - fraw = 0; + fraw = 0; } else { - sockrecv = g_sockraw; - if (fdebug) printf("g_sockraw = %d\n",g_sockraw); + sockrecv = g_sockraw; + if (fdebug) printf("g_sockraw = %d\n",g_sockraw); } } @@ -1011,7 +1015,7 @@ main(int argc, char **argv) #endif if (fraw == 1) { if (frawok == 0) { - printf("Warning: SOCK_RAW not yet implemented on this OS\n"); + printf("Warning: SOCK_RAW not yet implemented on this OS\n"); } #ifdef LINUX else { diff --git a/util/ievents.c b/util/ievents.c index f0034b2..dcef599 100644 --- a/util/ievents.c +++ b/util/ievents.c @@ -76,7 +76,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define SELprintf printf #define SMS_SA 0x41 #define SMI_SA 0x21 -static char *progver = "2.96"; +static char *progver = "2.97"; static char *progname = "ievents"; static char fsensdesc = 0; /* 1= get extended sensor descriptions*/ static char fcanonical = 0; /* 1= show canonical, delimited output*/ diff --git a/util/ifirewall.c b/util/ifirewall.c index f9da95d..9a9fa25 100644 --- a/util/ifirewall.c +++ b/util/ifirewall.c @@ -64,7 +64,7 @@ /* global variables */ static char * progname = "ifirewall"; -static char * progver = "2.96"; +static char * progver = "2.97"; static char fdebug = 0; static uchar g_bus = PUBLIC_BUS; static uchar g_sa = BMC_SA; diff --git a/util/ifirewall.h b/util/ifirewall.h index 3953b09..b442745 100644 --- a/util/ifirewall.h +++ b/util/ifirewall.h @@ -96,7 +96,7 @@ struct ipmi_function_params { unsigned char force; }; -#ifdef WIN32 +#if defined(WIN32) || defined(HPUX) #define INLINE /*nop*/ #else #define INLINE inline diff --git a/util/ifru.c b/util/ifru.c index 5b5192f..61a19f3 100644 --- a/util/ifru.c +++ b/util/ifru.c @@ -116,7 +116,7 @@ extern int ipmi_kontronoem_main(void * intf, int argc, char ** argv); #endif static char *progname = "ifru"; -static char *progver = "2.96"; +static char *progver = "2.97"; static int vend_id = 0; static int prod_id = 0; static char fdebug = 0; diff --git a/util/ifruset.c b/util/ifruset.c index 472b71f..f8beada 100644 --- a/util/ifruset.c +++ b/util/ifruset.c @@ -106,7 +106,7 @@ extern void fmt_time(time_t etime, char *buf, int bufsz); /*see ievents.c*/ #define IPROD_OEM 7 static char *progname = "ifruset"; -static char *progver = "2.96"; +static char *progver = "2.97"; static char fdebug = 0; static char fpicmg = 0; static char fonlybase = 0; diff --git a/util/igetevent.c b/util/igetevent.c index 96f5442..25d0d8e 100644 --- a/util/igetevent.c +++ b/util/igetevent.c @@ -113,6 +113,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <fcntl.h> #if defined(HPUX) /* getopt is defined in stdio.h */ +#include <limits.h> /* for _SC_OPEN_MAX, usu 1024. */ #elif defined(MACOS) /* getopt is defined in unistd.h */ #include <unistd.h> @@ -168,7 +169,7 @@ extern void free_sdr_cache(uchar *pret); /*see isensor.c*/ * Global variables */ static char * progname = "igetevent"; -static char * progver = "2.96"; +static char * progver = "2.97"; static char fdebug = 0; static char fipmilan = 0; static char frunonce = 0; diff --git a/util/ihealth.c b/util/ihealth.c index 5167950..fbe5f0d 100644 --- a/util/ihealth.c +++ b/util/ihealth.c @@ -82,7 +82,7 @@ extern int oem_supermicro_get_firmware_str(char *pstr, int sz); /*oem_supermicro * Global variables */ static char * progname = "ihealth"; -static char * progver = "2.96"; +static char * progver = "2.97"; static char fdebug = 0; static char fipmilan = 0; static char fcanonical = 0; @@ -725,8 +725,9 @@ void show_devid_all(int dtype, uchar *devrec, int sdevrec) case 1603: prodstr = "(X9SPU)"; break; /*0x0643*/ case 1636: prodstr = "(X9DRH)"; break; /*0x0664*/ case 1643: prodstr = "(X9SRL)"; break; /*0x066b*/ - case 1797: prodstr = "(X9DR7)"; break; /*0x0705*/ - case 4520: prodstr = "(H8DGU)"; break; + case 1797: prodstr = "(X9DR7)"; break; /*0x0705*/ + case 2137: prodstr = "(X10DRH)"; break; /*0x0859*/ + case 4520: prodstr = "(H8DGU)"; break; case 43025: prodstr = "(H8DGU-F)"; break; case 43707: prodstr = "(X8DTH)"; break; case 48145: prodstr = "(H8DG6)"; break; diff --git a/util/ilan.c b/util/ilan.c index 2458fbb..b314c73 100644 --- a/util/ilan.c +++ b/util/ilan.c @@ -305,7 +305,7 @@ extern char *get_sensor_type_desc(uchar stype); /*from ievents.c*/ /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "ilan"; static char fdebug = 0; static char fipmilan = 0; @@ -624,7 +624,7 @@ static void getauthstr(uchar auth, char *s) } static int GetDeviceID(LAN_RECORD *pLanRecord) -{ +{ /*See also ipmi_getdeviceid( pLanRecord, sizeof(LAN_RECORD),fdebug); */ uchar responseData[MAX_BUFFER_SIZE]; int responseLength = MAX_BUFFER_SIZE; int status; diff --git a/util/imb_api.h b/util/imb_api.h index 56a940c..e6951f8 100644 --- a/util/imb_api.h +++ b/util/imb_api.h @@ -49,7 +49,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* DOS defines wchar_t in stdlib.h */ #else // defined(LINUX) | defined(SOLARIS) -#ifndef _WCHAR_T +#if !defined(_WCHAR_T) && !defined(__WCHAR_TYPE__) #define _WCHAR_T typedef long wchar_t; #endif diff --git a/util/imbapi.c b/util/imbapi.c index cbc8fa1..dd62e8b 100644 --- a/util/imbapi.c +++ b/util/imbapi.c @@ -909,6 +909,8 @@ int ipmi_cmdraw_ia(BYTE cmd, BYTE netfn, BYTE lun, BYTE sa, BYTE bus, #ifdef WIN32 imbDev = "[imbdrv]"; if (1) +#elif HPUX + imbDev = "/dev/ipmi"; #else imbDev = "/dev/imb"; if (stat(imbDev, &stbuf) == -1) { diff --git a/util/ipicmg.c b/util/ipicmg.c index 634fb16..7315270 100644 --- a/util/ipicmg.c +++ b/util/ipicmg.c @@ -81,7 +81,7 @@ /* Global data */ static char * progname = "ipicmg"; -static char * progver = "2.96"; +static char * progver = "2.97"; static char fdebug = 0; static char fset_mc = 0; static uint8_t g_bus = PUBLIC_BUS; diff --git a/util/ipmicmd.c b/util/ipmicmd.c index 858d062..d969173 100644 --- a/util/ipmicmd.c +++ b/util/ipmicmd.c @@ -460,28 +460,6 @@ static struct { // { DRV_VA, "va" }, // { DRV_GNU, "free" }, -char *show_driver_type(int idx) -{ - int i; - char *tag; - for (i = 0; i < ndrivers; i++) - { - if (drv_types[i].idx == idx) { - tag = drv_types[i].tag; - break; - } - } - if (i >= ndrivers) { /*not found*/ - tag = "unknown"; - } - return(tag); -} - -int get_driver_type(void) -{ - return(fDriverTyp); -} - void set_iana(int iana) { my_devid[6] = (iana & 0x0000ff); @@ -504,6 +482,28 @@ void get_mfgid(int *pvend, int *pprod) *pprod = my_devid[9] + (my_devid[10] << 8); } +char *show_driver_type(int idx) +{ + int i; + char *tag; + for (i = 0; i < ndrivers; i++) + { + if (drv_types[i].idx == idx) { + tag = drv_types[i].tag; + break; + } + } + if (i >= ndrivers) { /*not found*/ + tag = "unknown"; + } + return(tag); +} + +int get_driver_type(void) +{ + return(fDriverTyp); +} + int set_driver_type(char *tag) { int rv = 0; @@ -1048,6 +1048,8 @@ int ipmi_getpicmg(uchar *presp, int sresp, char fdebug) int ipmi_getdeviceid(uchar *presp, int sresp, char fdebug) { int rc, i; uchar cc; + char mbstr[80] = "unknown"; + /* check that sresp is big enough (default is 15 bytes for Langley)*/ if (sresp < 15) return(ERR_BAD_LENGTH); rc = ipmi_cmd_mc(GET_DEVICE_ID, NULL, 0, presp,&sresp, &cc, fdebug); @@ -1345,7 +1347,7 @@ void parse_lan_options(int c, char *popt, char fdebugcmd) switch(c) { - case 'p': + case 'p': i = atoi(popt); if (i > 0) lanp.port = i; else printf("-p port %d < 0, defaults to %d\n", diff --git a/util/ipmicmd.h b/util/ipmicmd.h index a4c911b..989cd8d 100644 --- a/util/ipmicmd.h +++ b/util/ipmicmd.h @@ -475,6 +475,7 @@ int ipmi_getdeviceid(uchar *presp, int sresp, char fdebugcmd); int ipmi_getpicmg(uchar *presp, int sresp, char fdebug); char *show_driver_type(int idx); int set_driver_type(char *tag); +int set_driver_options(int fdir); int get_driver_type(void); int nodeislocal(char *nodename); /* These *_mc routines are used to manage changing the mc. diff --git a/util/ipmidir.c b/util/ipmidir.c index 4865bc0..501f47b 100644 --- a/util/ipmidir.c +++ b/util/ipmidir.c @@ -46,6 +46,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *----------------------------------------------------------------------*/ +#if defined(__IA64__) +#define STUB_IO 1 +#endif #if defined(STUB_IO) /* May stub out direct io. For instance, PPC does not support <sys/io.h> */ #define UCHAR unsigned char @@ -64,7 +67,7 @@ int ipmi_cmd_direct(UINT16 icmd, UCHAR *pdata, int sdata, UCHAR *presp, int ipmi_set_max_kcs_loops(int ms) { return(0); } -#elif defined(LINUX) || defined(BSD) || defined(DOS) || defined(MACOS) +#elif defined(LINUX) || defined(BSD) || defined(DOS) || defined(MACOS) || defined(HPUX) #include <stdio.h> #include <stdlib.h> #include <fcntl.h> @@ -85,7 +88,7 @@ int ipmi_set_max_kcs_loops(int ms) #if defined(LINUX) #include <sys/io.h> -#elif defined(BSD) || defined(MACOS) +#elif defined(BSD) || defined(MACOS) || defined(HPUX) // #include <machine/cpufunc.h> int iofd = -1; @@ -201,7 +204,7 @@ extern unsigned outp(unsigned _port, unsigned _value); #define WritePortUchar( addr, val ) outp((addr),(val)) #define WritePortUlong( addr, val ) ( outp((addr),(val)) ) #define ReadPortUlong( addr, valp ) (*(valp) = inp((addr)) ) -#elif defined(BSD) || defined(MACOS) +#elif defined(BSD) || defined(MACOS) || defined(HPUX) #define _INB(addr) inbc((addr)) #define _OUTB(data, addr) outbc((addr),(data)) #define _IOPL(data) 0 @@ -421,6 +424,8 @@ int ipmi_open_direct(int fdebugcmd) BMC_base = mybase; DBGP("smbios: Driver=%d(%s), sa=%02x, Base=0x%04x, Spacing=%d\n", g_DriverType,BmcDesc(g_DriverType),sa,mybase,inc); + } else { + return ERR_NO_DRV; /*no SMBIOS IPMI record*/ } } @@ -467,7 +472,7 @@ int ipmi_open_direct(int fdebugcmd) int ipmi_close_direct(void) { int status = 0; -#if defined(BSD) || defined(MACOS) +#if defined(BSD) || defined(MACOS) || defined(HPUX) close(iofd); iofd = -1; #endif @@ -1227,7 +1232,7 @@ int ImbInit_dir(void) BMC_base = kcsBaseAddress; DBGP("Continuing with KCS on Default Port 0x%04x\n",kcsBaseAddress); } -#if defined(BSD) || defined(MACOS) +#if defined(BSD) || defined(MACOS) || defined(HPUX) iofd = open("/dev/io",O_RDWR); if (iofd < 0) { printf("Cannot open /dev/io...Exiting\n"); diff --git a/util/ipmilan.c b/util/ipmilan.c index 814092e..1f5b949 100644 --- a/util/ipmilan.c +++ b/util/ipmilan.c @@ -85,7 +85,7 @@ typedef unsigned int socklen_t; #include <stdlib.h> #undef HAVE_LANPLUS -#else /* Linux */ +#else /* Linux, BSD, etc. */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> @@ -103,8 +103,12 @@ typedef unsigned int socklen_t; #include <sys/time.h> #include <time.h> #include <signal.h> +#ifdef HPUX +#define RECV_MSG_FLAGS 0x40 /*match MSG_WAITALL for HPUX*/ +#else #define RECV_MSG_FLAGS MSG_WAITALL #endif +#endif #include "ipmicmd.h" #include "ipmilan.h" @@ -638,8 +642,11 @@ int open_sockfd(char *node, int port, SockType *sfd, SOCKADDR_T *daddr, fprintf(fperr,"lan, gethostbyname(%s): errno=%d\n", node,get_errno()); #elif SOLARIS fprintf(fperr,"lan, gethostbyname(%s): errno=%d\n", node,get_errno()); +#elif defined(HPUX) + /*added by ugene */ + fprintf(fperr,"lan, gethostbyname(%s): errno=%d\n", node,errno); #else - fprintf(fperr,"lan, gethostbyname(%s): %s\n", node,hstrerror(errno)); + fprintf(fperr,"lan, gethostbyname(%s): %s\n", node,hstrerror(errno)); #endif } close_sockfd(_sockfd); @@ -1426,7 +1433,14 @@ static int ipmilan_open_session(SockType sfd, struct sockaddr *destaddr, fprintf(fpdbg,"GetChanAuth reports only v2 capability\n"); rv = LAN_ERR_V2; /*try v2 instead*/ goto ERREXIT; - } + } else { + /* Always switch to IPMI LAN 2.0 if detected. */ + /* This avoids errors from Dell & Huawei firmware */ + if (fdebuglan) + fprintf(fpdbg,"GetChanAuth detected v2, so switch to v2\n"); + rv = LAN_ERR_V2; /*use v2 instead*/ + goto ERREXIT; + } } /* Check authentication support */ imsgauth = rbuf[3]; diff --git a/util/ipmimv.c b/util/ipmimv.c index 06b1baf..4404beb 100644 --- a/util/ipmimv.c +++ b/util/ipmimv.c @@ -52,7 +52,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *----------------------------------------------------------------------*/ -#if defined(LINUX) || defined(BSD) || defined(MACOS) +#if defined(LINUX) || defined(BSD) || defined(MACOS) || defined(HPUX) #include <stdio.h> #include <fcntl.h> #include <unistd.h> @@ -62,6 +62,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <time.h> #include <errno.h> #include <sys/ioctl.h> +#include <sys/select.h> #if defined(MACOS) #include <sys/time.h> #else @@ -111,7 +112,7 @@ struct timeval { #endif int ipmi_timeout_mv = 10; /* 10 seconds, was 5 sec */ -#if defined(BSD) || defined(MACOS) +#if defined(BSD) || defined(MACOS) || defined(HPUX) #pragma pack(1) #endif @@ -152,7 +153,7 @@ struct ipmi_cmdspec unsigned char netfn; unsigned char cmd; }; -#if defined(BSD) || defined(MACOS) +#if defined(BSD) || defined(MACOS) || defined(HPUX) #pragma pack() /* FreeBSD 7.x ipmi ioctls, use _IOW */ #define IPMI_IOC_MAGIC 'i' @@ -253,23 +254,23 @@ int ipmi_open_mv(char fdebugcmd) pdev = "/dev/ipmi/0"; ipmi_fd = open("/dev/ipmi/0", O_RDWR); if (ipmi_fd == -1) { - if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); - pdev = "/dev/ipmi0"; - ipmi_fd = open(pdev, O_RDWR); + if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); + pdev = "/dev/ipmi0"; + ipmi_fd = open(pdev, O_RDWR); } if (ipmi_fd == -1) { - if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); - pdev = "/dev/ipmidev0"; - ipmi_fd = open(pdev, O_RDWR); + if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); + pdev = "/dev/ipmidev0"; + ipmi_fd = open(pdev, O_RDWR); } if (ipmi_fd == -1) { - if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); - pdev = "/dev/ipmidev/0"; - ipmi_fd = open(pdev, O_RDWR); + if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); + pdev = "/dev/ipmidev/0"; + ipmi_fd = open(pdev, O_RDWR); } if (ipmi_fd == -1) { - if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); - return(-1); + if (fdebugcmd) dbgmsg("ipmi_open_mv: cannot open %s\n",pdev); + return(-1); } ipmi_get_mymc(&bus,&sa,&lun,NULL); if (sa != BMC_SA) { /* user specified my slave address*/ diff --git a/util/ipmiutil.c b/util/ipmiutil.c index 05c13db..d5ad57d 100644 --- a/util/ipmiutil.c +++ b/util/ipmiutil.c @@ -57,7 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "ipmiutil.h" static char *progname = "ipmiutil"; -static char *progver = "2.96"; +static char *progver = "2.97"; // static char fdebug = 0; /*int ipmiutil(int argc, char **argv); */ diff --git a/util/ipmiutil.mak b/util/ipmiutil.mak index 40daaf8..5ead440 100644 --- a/util/ipmiutil.mak +++ b/util/ipmiutil.mak @@ -58,7 +58,8 @@ MKLIB=lib RM=del
CP=copy
-LIBS_EX = advapi32.lib kernel32.lib wsock32.lib $(LIBS_W) $(LIBC_RT)
+# added ws2_32.lib
+LIBS_EX = advapi32.lib kernel32.lib wsock32.lib ws2_32.lib $(LIBS_W) $(LIBC_RT)
LIBS_PEF = /LIBPATH:$(LIB_D) iphlpapi.lib
# LIBS_EX+=wsock32.lib user32.lib gdi32.lib
@@ -414,6 +415,12 @@ ipmi_sample2.exe: $(SAMP_LIB) ipmi_sample.c isensor.c ievents.c $(LINK) $(LFLAGS) /OUT:ipmi_sample2.exe ipmi_sample.obj isensor.obj ievents.obj $(SAMP_LIB) $(LIBS_PEF) $(LIBS_EX)
del isensor.obj ievents.obj
+ifruset.obj: ifruset.c
+ $(CC) /c $(CFLAGS_SAM) ifruset.c
+
+ifruset.exe: $(SAMP_LIB) ifruset.obj ifru_picmg.obj
+ $(LINK) $(LFLAGS) /OUT:ifruset.exe ifruset.obj ifru_picmg.obj $(SAMP_LIB) $(LIBS_PEF) $(LIBS_EX)
+
ipmi_sample_evt.obj: ipmi_sample_evt.c $(HEADER)
$(CC) /c $(CFLAGS_SAM) ipmi_sample_evt.c
@@ -425,3 +432,4 @@ ievents2.obj: ievents.c ievents.h $(HEADER) ipmi_sample_evt.exe: $(SAMP_LIB) ipmi_sample_evt.obj ievents2.obj isensor2.obj
$(LINK) $(LFLAGS) /OUT:ipmi_sample_evt.exe ipmi_sample_evt.obj ievents2.obj isensor2.obj $(SAMP_LIB) $(LIBS_PEF) $(LIBS_EX)
+
diff --git a/util/ipmiutil64.mak b/util/ipmiutil64.mak index fa6b88e..adb06a2 100644 --- a/util/ipmiutil64.mak +++ b/util/ipmiutil64.mak @@ -411,10 +411,10 @@ ipmi_sample2.exe: $(SAMP_LIB) ipmi_sample.c isensor.c ievents.c del isensor.obj ievents.obj
ifruset.obj: ifruset.c
- $(CC) /c $(CFLAGS_SAM) ifruset.c
+ $(CC) /c $(CFLAGS_SAM) ifruset.c
-ifruset.exe: $(SAMP_LIB) ifruset.obj ifru_picmg.obj
- $(LINK) $(LFLAGS) /OUT:ifruset.exe ifruset.obj ifru_picmg.obj $(SAMP_LIB) $(LIBS_PEF) $(LIBS_EX)
+ifruset.exe: $(SAMP_LIB) ifruset.obj ifru_picmg.obj
+ $(LINK) $(LFLAGS) /OUT:ifruset.exe ifruset.obj ifru_picmg.obj $(SAMP_LIB) $(LIBS_PEF) $(LIBS_EX)
ipmi_sample_evt.obj: ipmi_sample_evt.c $(HEADER)
$(CC) /c $(CFLAGS_SAM) ipmi_sample_evt.c
@@ -427,3 +427,4 @@ ievents2.obj: ievents.c ievents.h $(HEADER) ipmi_sample_evt.exe: $(SAMP_LIB) ipmi_sample_evt.obj ievents2.obj isensor2.obj
$(LINK) $(LFLAGS) /OUT:ipmi_sample_evt.exe ipmi_sample_evt.obj ievents2.obj isensor2.obj $(SAMP_LIB) $(LIBS_PEF) $(LIBS_EX)
+
diff --git a/util/ireset.c b/util/ireset.c index 0bfdeb0..713599d 100644 --- a/util/ireset.c +++ b/util/ireset.c @@ -108,7 +108,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "ireset"; static uchar ipmi_maj; static uchar ipmi_min; @@ -410,7 +410,7 @@ static int IPMI_Reset(uchar bpower, uchar bootopt) responseData[0], responseData[1]); } if (status == ACCESS_OK && completionCode == 0) { - printf("chassis_reset ok\n"); + printf("chassis_reset(%x) ok\n",bpower); //successful, done return(0); } else if (fipmilan && (status < 0)) { diff --git a/util/isel.c b/util/isel.c index 723ae48..3492342 100644 --- a/util/isel.c +++ b/util/isel.c @@ -162,7 +162,7 @@ typedef struct #define RDATA_OFFSET 13 //byte offset to the record event data static char *progname = "isel"; -static char *progver = "2.96"; +static char *progver = "2.97"; #ifdef WIN32 #define IDXFILE "sel.idx" static char idxfile[80] = IDXFILE; @@ -767,8 +767,9 @@ int i_sel(int argc, char **argv) ret = geteuid(); if (ret > 1) { printf("Not superuser (%d)\n", ret); - ret = ERR_NOT_ALLOWED; - goto do_exit; + /* Show warning, but could be ok if /dev/ipmi0 is accessible */ + //ret = ERR_NOT_ALLOWED; + //goto do_exit; } } #endif diff --git a/util/iseltime.c b/util/iseltime.c index 0d82c90..0675cce 100644 --- a/util/iseltime.c +++ b/util/iseltime.c @@ -75,7 +75,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "iseltime"; static char fdebug = 0; static char fset = 0; diff --git a/util/isensor.c b/util/isensor.c index e5a80e0..6be2836 100644 --- a/util/isensor.c +++ b/util/isensor.c @@ -247,7 +247,7 @@ char *decode_entity_id(int id) { * Global Data ************************/ static char *progname = "isensor"; -static char *progver = "2.96"; +static char *progver = "2.97"; #ifdef WIN32 static char savefile[] = "%ipmiutildir%\\thresholds.cmd"; #else @@ -1353,10 +1353,13 @@ int get_sdr_file(char *sdrfile, uchar **sdrlist) /* determine number of SDRs by number of lines in the file */ num = 0; while (fgets(buff, 255, fp)) { num++; } - if (fdebug) printf("Reading %d SDRs from file %s\n",num,sdrfile); - if ((psdrcache != NULL) && (nsdrs > 0)) { /*already have sdrcache*/ - printf("get_sdr_file: Already have cache\n"); /*++++*/ - } + if (fdebug) { + printf("Reading %d SDRs from file %s\n",num,sdrfile); + if ((psdrcache != NULL) && (nsdrs > 0)) { /*already have sdrcache*/ + printf("get_sdr_file: Already have cache\n"); /*fdebug*/ + free_sdr_cache(psdrcache); /*free previous sdrcache*/ + } + } sdrbuf = malloc(num * SDR_SZ); if (sdrbuf == NULL) { fclose(fp); @@ -1405,10 +1408,9 @@ int get_sdr_cache(uchar **pret) if ((psdrcache != NULL) && (nsdrs > 0)) { /*already have sdrcache*/ *pret = psdrcache; if (fdebug) printf("get_sdr_cache: already have cache (%p)\n",*pret); - printf("get_sdr_cache: Already have cache\n"); /*++++*/ return(0); } - else printf("get_sdr_cache: Allocating cache\n"); /*++++*/ + else if (fdebug) printf("get_sdr_cache: Allocating cache\n"); rv = GetSDRRepositoryInfo(&n,&fdevsdrs); if (rv != 0) return(rv); @@ -1612,6 +1614,7 @@ int find_sdr_by_id(uchar *psdr, uchar *pcache, ushort id) recid = sdr[0] + (sdr[1] << 8); asz += len; if (recid == id) { rv = 0; break; } + else if (id == 0) { rv = 0; break; } /* 0000 = first one */ } if (rv == 0) memcpy(psdr,sdr,len); return(rv); @@ -2462,11 +2465,13 @@ ShowSDR(char *tag, uchar *sdr) if (fdebug) printf("ShowSDR: len=%d, type=%x\n",len,sdr[3]); memset(sens,0,4); if (frawsdr || fdebug) { + /* raw is different than dump_buf */ printf("raw SDR: "); for (i = 0; i < len; i++) printf("%02x ",sdr[i]); printf("\n"); } + strcpy(idstr,"INIT"); /*always set idstr to some initial string*/ switch(sdr[3]) { case 0x01: /* Full sensor record */ @@ -2475,12 +2480,19 @@ ShowSDR(char *tag, uchar *sdr) if (ioff > len) { if (fdebug) printf("bad length: type=%x, len=%d, ioff=%d\n", sdr[3],len,ioff); - printf("Bad SDR Length, please apply the correct FRU/SDR diskette\n"); + fprintf(stderr,"Bad SDR Length %d, please apply the correct FRU/SDR diskette\n",len); return; } sens_cap = sdr[11]; /*sdr01->sens_capab*/ + // ilen = (sdr[ioff] & 0x1f); /*sdr01->id_typelen*/ ilen = len - ioff; + if (fdebug) printf("SDR[%x] Full ioff=%d idTypLen=0x%02x ilen=%d\n", + sdr01->recid, ioff,sdr[ioff] ,ilen); if (ilen >= sizeof(idstr)) ilen = sizeof(idstr) - 1; + if (ilen <= 0) { /*bug if true*/ + fprintf(stderr,"Bad SDR Length %d, omits ID string\n",len); + ilen = 16; /*less than sizeof(idstr)*/ + } memcpy(idstr,&sdr[ioff],ilen); for (i=ilen; i<16; i++) { idstr[i] = ' '; ilen++; } idstr[ilen] = 0; /* stringify */ @@ -2580,7 +2592,7 @@ ShowSDR(char *tag, uchar *sdr) if (ioff > len) { if (fdebug) printf("bad length: type=%x, len=%d, ioff=%d\n", sdr[3],len,ioff); - printf("Bad SDR Length, please apply the correct FRU/SDR diskette\n"); + fprintf(stderr,"Bad SDR Length, please apply the correct FRU/SDR diskette\n"); return; } sens_cap = sdr[11]; /*sdr02->sens_capab*/ @@ -2682,7 +2694,7 @@ ShowSDR(char *tag, uchar *sdr) sdr02 = (SDR02REC *)sdr; ioff = 17; if (ioff > len) { - printf("Bad SDR %x Length %d. Please apply the correct FRU/SDR diskette\n", + fprintf(stderr,"Bad SDR %x Length %d. Please apply the correct FRU/SDR diskette\n", sdr02->recid, len); return; } @@ -3065,7 +3077,7 @@ int i_sensor(int argc, char **argv) uchar devrec[16]; int sz, i, j; int fsetfound = 0; - int iloop; + int iloop, irec; int ipass, npass; uchar *pset; char *p; @@ -3264,8 +3276,9 @@ int i_sensor(int argc, char **argv) i = geteuid(); if (i > 1) { printf("Not superuser (%d)\n", i); - ret = ERR_NOT_ALLOWED; - goto do_exit; + /* Show warning, but could be ok if /dev/ipmi0 is accessible */ + //ret = ERR_NOT_ALLOWED; + //goto do_exit; } } #endif @@ -3454,10 +3467,13 @@ int i_sensor(int argc, char **argv) { if (fshowidx) recid = sensor_idx1; else recid = 0; + irec = 0; /*first sdr record*/ while (recid != 0xffff) { if (fjumpstart) { - ret = find_sdr_next(sdrdata,psdrcache,recid); + if (irec == 0) /*need sdr_by_id if fshowid recid>0*/ + ret = find_sdr_by_id(sdrdata,psdrcache,recid); + else ret = find_sdr_next(sdrdata,psdrcache,recid); if (ret != 0) { /*end of sdrs*/ if (fdebug) printf("find_sdr_next(%04x): ret = %d\n", recid,ret); ret = 0; break; @@ -3476,8 +3492,8 @@ int i_sensor(int argc, char **argv) printf("GetSDR[%04x]: ret = %x, next=%x\n",recid,ret,recnext); if (ret != 0) { if (ret > 0) { /* ret is a completion code error */ - printf("%04x GetSDR error 0x%02x %s, rlen=%d\n",recid,ret, - decode_cc((ushort)0,(uchar)ret),sz); + fprintf(stderr,"%04x GetSDR error 0x%02x %s, rlen=%d\n", + recid,ret,decode_cc((ushort)0,(uchar)ret),sz); if (ret == 0xC5) { /* lost Reservation ID, retry */ /* This means that some other IPMI software has * requested a Reservation before we finished, so @@ -3488,7 +3504,8 @@ int i_sensor(int argc, char **argv) printf("GetSDR[%04x]: ret = %x, next=%x\n",recid,ret, recnext); } - } else printf("%04x GetSDR error %d, rlen = %d\n", recid,ret,sz); + } else fprintf(stderr,"%04x GetSDR error %d, rlen = %d\n", + recid,ret,sz); if (sz < MIN_SDR_SZ) { /* don't have recnext, so abort */ break; } /* else fall through & continue */ @@ -3559,7 +3576,7 @@ int i_sensor(int argc, char **argv) { ret = GetSDR(_recid,&_recnext,_sdrdata,sizeof(_sdrdata),&_sz); if (ret != 0) { - printf("%04x GetSDR error %d, rlen = %d\n",_recid,ret,_sz); + fprintf(stderr,"%04x GetSDR error %d, rlen = %d\n",_recid,ret,_sz); break; } else if (_sz >= MIN_SDR_SZ) @@ -3644,15 +3661,16 @@ int i_sensor(int argc, char **argv) } /*endif ok, got full SDR */ NextSdr: - if (fshowidx) { - /* if we have already read the last in the range, done. */ - if (recid >= sensor_idxN) break; // recnext = 0xffff; // break; - } if (fjumpstart) recid = recnext; else { if (recnext == recid) recid = 0xffff; /*break;*/ else recid = recnext; } + if (fshowidx) { + /* if we have already read the last in the range, done. */ + if (recid >= sensor_idxN) break; // recnext = 0xffff; // break; + } + irec++; } /*end while recid*/ if (fdoloop && (nloops > 1)) { printf("\n"); /* output an empty separator line */ diff --git a/util/iserial.c b/util/iserial.c index 07fc3cc..48145ea 100644 --- a/util/iserial.c +++ b/util/iserial.c @@ -155,7 +155,7 @@ typedef struct /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "iserial"; static int vend_id = 0; static int prod_id = 0; diff --git a/util/isol.c b/util/isol.c index 50b0caf..c73099a 100644 --- a/util/isol.c +++ b/util/isol.c @@ -165,7 +165,7 @@ void dbglog( char *pattn, ... ); /*local prototype*/ /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "isol"; static char fdebug = 0; static char fpicmg = 0; diff --git a/util/itsol.c b/util/itsol.c index 21e5f6c..e713982 100644 --- a/util/itsol.c +++ b/util/itsol.c @@ -98,7 +98,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz); extern int verbose; extern char fdebug; /*from ipmicmd.c*/ static char * progname = "itsol"; -static char * progver = "2.96"; +static char * progver = "2.97"; static uchar g_bus = PUBLIC_BUS; static uchar g_sa = BMC_SA; static uchar g_lun = BMC_LUN; @@ -511,6 +511,11 @@ ipmi_tsol_main(void * intf, int argc, char ** argv) if (recvip != NULL) result = ipmi_tsol_stop(intf, recvip, port); return LAN_ERR_NOTSUPPORT; +#elif defined(HPUX) + printf("HPUX TSOL terminal handling not yet implemented\n"); + if (recvip != NULL) + result = ipmi_tsol_stop(intf, recvip, port); + return LAN_ERR_NOTSUPPORT; #else /* * retrieve local IP address if not supplied on command line diff --git a/util/iwdt.c b/util/iwdt.c index 0e6d932..66db234 100644 --- a/util/iwdt.c +++ b/util/iwdt.c @@ -100,7 +100,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* * Global variables */ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "iwdt"; static char fdebug = 0; static char fdontlog = 0; diff --git a/util/mem_if.c b/util/mem_if.c index c445138..9be58a9 100644 --- a/util/mem_if.c +++ b/util/mem_if.c @@ -65,8 +65,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <sys/param.h> #include <sys/mman.h> #include <sys/ioctl.h> +#ifdef __linux__ +#include <linux/param.h> #endif -#if defined(SOLARIS) || defined(BSD) +#endif +#if defined(SOLARIS) || defined(BSD) || defined(HPUX) #define EXEC_PAGESIZE 4096 #endif @@ -274,6 +277,11 @@ static int m_iCount = 0; int OpenIMemoryInterface(void) { int rv = -1; +/* ARM64 does not handle /dev/mem the same. + * It exposes SMBIOS at /sys/firmware/dmi/tables/, but because + * IO memory is memory mapped, cannot use legacy /dev/mem. */ +#ifndef __arm__ +#ifndef __aarch64__ //check to see if driver has been previously defined if (!m_iDriver) { //open the driver m_iDriver = open(MEM_DRIVER, O_RDONLY); @@ -286,6 +294,8 @@ int OpenIMemoryInterface(void) m_iCount++; } if (m_iDriver > 0) rv = 0; +#endif +#endif return(rv); } diff --git a/util/oem_dell.c b/util/oem_dell.c index 0e16d95..530f16a 100644 --- a/util/oem_dell.c +++ b/util/oem_dell.c @@ -132,7 +132,7 @@ char NIC_Selection_Mode_String_12g[] [50] = { "shared with failover all loms" }; -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "idelloem"; static int verbose = 0; static char fdebug = 0; @@ -5694,10 +5694,10 @@ char * get_dell_evt_desc(uchar *sel_rec) } node = (incr + i)/dimmsPerNode; dimmNum = ((incr + i)%dimmsPerNode)+1; - dimmStr[5] = node + 'A'; + dimmStr[6] = node + 'A'; sprintf(tmpdesc,"%d",dimmNum); - dimmStr[6] = tmpdesc[0]; - dimmStr[7] = '\0'; + dimmStr[7] = tmpdesc[0]; + dimmStr[8] = '\0'; strcat(str,dimmStr); count++; } @@ -5719,8 +5719,8 @@ char * get_dell_evt_desc(uchar *sel_rec) count = 0; } sprintf(tmpdesc,"%d",(i + incr + 1)); - dimmStr[4] = tmpdesc[0]; - dimmStr[5] = '\0'; + dimmStr[5] = tmpdesc[0]; + dimmStr[6] = '\0'; strcat(str, dimmStr); count++; } diff --git a/util/oem_sun.c b/util/oem_sun.c index 65a3522..fc899bd 100644 --- a/util/oem_sun.c +++ b/util/oem_sun.c @@ -109,7 +109,7 @@ static const struct valstr sunoem_led_mode_optvals[] = { /* global variables */ static char * progname = "isunoem"; -static char * progver = "2.96"; +static char * progver = "2.97"; static char fdebug = 0; static uchar g_bus = PUBLIC_BUS; static uchar g_sa = BMC_SA; diff --git a/util/oem_supermicro.c b/util/oem_supermicro.c index 5d7dee9..35df1bd 100644 --- a/util/oem_supermicro.c +++ b/util/oem_supermicro.c @@ -66,7 +66,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void set_loglevel(int level); /*prototype */ extern char fsm_debug; /*mem_if.c*/ -static char * progver = "2.96"; +static char * progver = "2.97"; static char * progname = "ismcoem"; static int verbose = 0; static char fdebug = 0; @@ -106,6 +106,18 @@ int oem_supermicro_get_bmc_status(uchar *sts) return(rv); } +/* + * oem_supermicro_get_bmc_services_status + * + * Request + * 0x30 - OEM network function + * 0x70 - OEM cmd + * 0xF0 - subcommand + * 0x?? - action 00=disable, 01=enable, 02=status + * + * Response + * 0x?? - if action=status: 00=disabled, 01=enabled + */ int oem_supermicro_set_bmc_status(uchar sts) { int rv; @@ -132,6 +144,83 @@ int oem_supermicro_set_bmc_status(uchar sts) return(rv); } +/* + oem_supermicro_psstatus1(uchar psnum, uchar *val) +*/ +int oem_supermicro_psstatus1(uchar psnum, uchar *val) +{ + int rv; + int rlen; + uchar idata[16]; + uchar rdata[16]; + uchar cc; + + idata[0] = 0x07; /*busid*/ + if (psnum <= 1) idata[1] = 0x70; /* PS 1 */ + else if (psnum == 2) idata[1] = 0x72; /* PS 2 */ + else /*if (psnum == 3)*/ idata[1] = 0x74; /* PS 3 */ + idata[2] = 0x01; /* return one byte of PS status data */ + idata[3] = 0x0C; + rlen = sizeof(rdata); + rv = ipmi_cmd(MASTER_WRITE_READ, idata, 4, rdata, &rlen, &cc, fdebug); + if ((rv == 0) && (cc != 0)) rv = cc; + if (rv == 0) { *val = rdata[0]; } + return(rv); +} + +/* + oem_supermicro_psstatus2(uchar psnum, uchar *val) + Get PMBus Power Supply Status, for X10 motherboards +*/ +int oem_supermicro_psstatus2(uchar psnum, uchar *val) +{ + int rv; + int rlen; + uchar idata[16]; + uchar rdata[16]; + uchar cc; + + idata[0] = 0x07; /*busid*/ + if (psnum <= 1) idata[1] = 0x78; /* PS 1 */ + else if (psnum == 2) idata[1] = 0x7A; /* PS 2 */ + else /*if (psnum == 3)*/ idata[1] = 0x7C; /* PS 3 */ + idata[2] = 0x01; /* return one byte of PS status data */ + idata[3] = 0x78; + rlen = sizeof(rdata); + rv = ipmi_cmd(MASTER_WRITE_READ, idata, 4, rdata, &rlen, &cc, fdebug); + if ((rv == 0) && (cc != 0)) rv = cc; + if (rv == 0) { *val = rdata[0]; } + return(rv); +} + +/* + oem_supermicro_psstatus3(uchar psnum, uchar *val) + Get PMBus Power Supply Status, for X10 motherboards + + raw 0x06 0x52 0x07 0xb0 0x01 0x0c for power supply 1 + raw 0x06 0x52 0x07 0xb2 0x01 0x0c for power supply 2 +*/ +int oem_supermicro_psstatus3(uchar psnum, uchar *val) +{ + int rv; + int rlen; + uchar idata[16]; + uchar rdata[16]; + uchar cc; + + idata[0] = 0x07; /*busid*/ + if (psnum <= 1) idata[1] = 0xB0; /* PS 1 */ + else if (psnum == 2) idata[1] = 0xB2; /* PS 2 */ + else /*if (psnum == 3)*/ idata[1] = 0xB4; /* PS 3 */ + idata[2] = 0x01; /* return one byte of PS status data */ + idata[3] = 0x0C; + rlen = sizeof(rdata); + rv = ipmi_cmd(MASTER_WRITE_READ, idata, 4, rdata, &rlen, &cc, fdebug); + if ((rv == 0) && (cc != 0)) rv = cc; + if (rv == 0) { *val = rdata[0]; } + return(rv); +} + int oem_supermicro_get_lan_port(uchar *val) { int rv; @@ -448,12 +537,13 @@ static void usage(void) printf(" bmcstatus [enable| disable] = get/set BMC status\n"); printf(" firmware = get extra firmware info\n"); printf(" lanport [dedicated| lan1| failover] = get/set IPMI LAN port\n"); + printf(" powersupply <num> = get PMBus PowerSupply status\n"); printf("These commands may not work on all SuperMicro systems\n"); } static int ipmi_smcoem_main(int argc, char **argv) { - int rv = 0; + int n,rv = 0; char msg[80]; uchar val; @@ -506,6 +596,39 @@ static int ipmi_smcoem_main(int argc, char **argv) if (rv == 0) oem_supermicro_show_lan_port(val); } } + } else if (strncmp(argv[0],"powersupply",11) == 0) { + if (argv[1] == NULL) { + usage(); + rv = ERR_USAGE; + } else { + char DevRec[16]; + int xver = 9; + n = atoi(argv[1]); /* power supply number */ + rv = ipmi_getdeviceid( DevRec, sizeof(DevRec),fdebug); + if (rv == 0) { + int vend_id, prod_id; + /* 1562 (0x061A) = X8SIU */ + /* 1572 (0x0624) = X9SCM */ + /* 1797 (0x0705) = X9DR7 */ + /* 2137 (0x0859) = X10DRH */ + vend_id = DevRec[6] + (DevRec[7] << 8) + (DevRec[8] << 16); + prod_id = DevRec[9] + (DevRec[10] << 8); + if (prod_id > 0x0800) xver = 10; + else if (prod_id > 1570) xver = 9; + else xver = 8; + } + if (xver == 10) rv = oem_supermicro_psstatus3(n, &val); + else if (xver == 9) rv = oem_supermicro_psstatus2(n, &val); + else /*xver==8*/ rv = oem_supermicro_psstatus1(n, &val); + if (rv == 0) { + if (val == 0x00) strcpy(msg,"good"); + else if (val == 0x02) strcpy(msg,"ok"); + else sprintf(msg,"bad 0x%02x",val); + printf("X%d Power Supply %d status = %d (%s)\n",xver,n,val,msg); + } else { + printf("X%d Power Supply %d error = %d\n",xver,n,rv); + } + } } else { usage(); rv = ERR_USAGE; diff --git a/util/subs.c b/util/subs.c index c5f9308..13e1603 100644 --- a/util/subs.c +++ b/util/subs.c @@ -132,6 +132,7 @@ void lprintf(int level, const char * format, ...) static char logtmp[LOG_MSG_LENGTH]; FILE *fp = stderr; if (!verbose && (level > loglevel)) return; + if (level > LOG_WARN) fp = stdout; /*NOTICE,INFO*/ if (fdbglog && (fplog != NULL)) fp = fplog; #ifdef WIN32 va_start(vptr, format); @@ -834,7 +835,7 @@ void WriteSyslog(char *msgbuf) int level; sev = find_msg_sev(msgbuf); switch(sev) { - case SEV_MIN: level = LOG_WARNING; break; + case SEV_MIN: level = LOG_WARN; break; case SEV_MAJ: level = LOG_ERR; break; case SEV_CRIT: level = LOG_CRIT; break; case SEV_INFO: |