diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2018-06-26 00:22:36 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2018-06-26 00:22:36 +0200 |
commit | 8c9d76589b8a385edf03627f917cff7b753c88b7 (patch) | |
tree | 104da20235169314ae4d3c2d0f4bb1d14bcb798b /util | |
parent | afca8e5a682f3b087d9e63cf88a1ab0bdcba523c (diff) | |
parent | 40234879fb4fc1337ed040573ad9a03fb6580109 (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'util')
-rw-r--r-- | util/ievents.c | 2 | ||||
-rw-r--r-- | util/ifru.c | 76 | ||||
-rw-r--r-- | util/ifruset.c | 5 | ||||
-rw-r--r-- | util/ilan.c | 232 | ||||
-rw-r--r-- | util/ipmiutil.c | 2 |
5 files changed, 146 insertions, 171 deletions
diff --git a/util/ievents.c b/util/ievents.c index d37d5fd..bb3a81f 100644 --- a/util/ievents.c +++ b/util/ievents.c @@ -80,7 +80,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern char *progver; /*from ipmiutil.c*/ static char * progname = "ipmiutil events"; #else -static char *progver = "3.08"; +static char *progver = "3.11"; static char *progname = "ievents"; #endif static char fsensdesc = 0; /* 1= get extended sensor descriptions*/ diff --git a/util/ifru.c b/util/ifru.c index effa9b7..86e47bf 100644 --- a/util/ifru.c +++ b/util/ifru.c @@ -116,7 +116,7 @@ extern int ipmi_kontronoem_main(void * intf, int argc, char ** argv); extern char *progver; /*from ipmiutil.c*/ static char *progname = "ipmiutil fru"; #else -static char *progver = "3.08"; +static char *progver = "3.11"; static char *progname = "ifru"; #endif @@ -200,7 +200,7 @@ static int sdr_get_reservation(uchar *res_id, int fdev) { return(-1); } #define STRING_DATA_TYPE_SIX_BIT_ASCII 0x02 #define STRING_DATA_TYPE_LANG_DEPENDENT 0x03 -#define FRUCHUNK_SZ 16 +#define FRUCHUNK_SZ 16 /* optimal chunk = 16 bytes */ #define FRU_END 0xC1 #define FRU_EMPTY_FIELD 0xC0 #define FRU_TYPE_MASK 0xC0 @@ -270,7 +270,7 @@ int load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) { int ret = 0; - uchar indata[16]; + uchar indata[FRUCHUNK_SZ+9]; uchar resp[18]; int sresp; uchar cc; @@ -282,6 +282,7 @@ load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) if (pfrubuf == NULL) return(ERR_BAD_PARAM); *pfrubuf = NULL; + memset(indata, 0, sizeof(indata)); indata[0] = frudev; sresp = sizeof(resp); if (fdebug) printf("load_fru: sa=%02x, frudev=%02x, addrtype=%d\n", @@ -315,14 +316,14 @@ load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) } indata[1] = fruoff & 0x00FF; indata[2] = (fruoff & 0xFF00) >> 8; - sresp = sizeof(resp); + sresp = sizeof(resp); ret = ipmi_cmd_mc(READ_FRU_DATA,indata,4,resp,&sresp,&cc,fdebug); - if (ret != 0) break; - else if (cc != 0) { - if (i == 0) ret = cc & 0x00ff; - if (fdebug) printf("read_fru[%d]: ret = %d cc = %x\n",i,ret,cc); - break; - } + if (ret != 0) break; + else if (cc != 0) { + if (i == 0) ret = cc & 0x00ff; + if (fdebug) printf("read_fru[%d]: ret = %d cc = %x\n",i,ret,cc); + break; + } memcpy(&frubuf[i],&resp[1],chunk); } @@ -338,16 +339,16 @@ load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) if (fdebug) printf("get_SystemGuid: ret = %d\n",rv); } if (rv == 0 && cc == 0) { - if (fdebug) { - printf("system guid (%d): ",sresp); - for (i=0; i<16; i++) printf("%02x ",resp[i]); - printf("\n"); - } - memcpy(&guid,&resp,16); - guid[16] = 0; + if (fdebug) { + printf("system guid (%d): ",sresp); + for (i=0; i<16; i++) printf("%02x ",resp[i]); + printf("\n"); + } + memcpy(&guid,&resp,16); + guid[16] = 0; } else { - printf("WARNING: GetSystemGuid error %d, %s\n",rv,decode_rv(rv)); - /*do not pass this error upstream*/ + printf("WARNING: GetSystemGuid error %d, %s\n",rv,decode_rv(rv)); + /*do not pass this error upstream*/ } } /*endif*/ return(ret); @@ -1077,8 +1078,8 @@ int write_fru_data(uchar id, ushort offset, uchar *data, int dlen, char fdebug) int ret = -1; int chunk; ushort fruoff; - uchar req[25]; - uchar resp[16]; + uchar req[FRUCHUNK_SZ+9]; + uchar resp[FRUCHUNK_SZ]; int sresp; uchar cc; int i, j; @@ -1880,25 +1881,26 @@ int i_fru(int argc, char **argv) recid = 0; while (recid != LAST_REC) { - if (do_reserve) { + if (do_reserve) { /* reserve the SDR repository */ ret = sdr_get_reservation((uchar *)&rsvid,fdevsdrs); if (fdebug) printf("sdr_get_reservation ret=%d\n",ret); - if (ret == 0) do_reserve = 0; - } - - len = sizeof(sdr); /*sizeof(sdr); get 32 sdr bytes*/ - ret = get_sdr(recid,rsvid,&nextid,sdr,&len,&cc); - if ((ret != 0) || (cc != 0)) { - printf("SDR[%04x] error %d ccode = %x\n",recid,ret,cc); - if ((cc == 0xC5) || (cc == 0x83)) ; /*do not stop (ARC)*/ - else break; /*stop if errors*/ - } - if (len >= MIN_SDR_SZ) { - if ((sdr[3] == 0x11) || (sdr[3] == 0x12)) /*SDR FRU or IPMB type*/ - ret = get_show_fru(recid, sdr,len); - do_reserve = 1; - } /*endif get_show_fru */ + if (ret == 0) do_reserve = 0; + } + + len = sizeof(sdr); /*sizeof(sdr); get 32 sdr bytes*/ + ret = get_sdr(recid,rsvid,&nextid,sdr,&len,&cc); + if ((ret != 0) || (cc != 0)) { + printf("SDR[%04x] error %d ccode = %x\n",recid,ret,cc); + if (cc == 0xC5) do_reserve = 1; /*retry w reserve*/ + if (cc == 0x83) os_usleep(0,100); /*busy, retry*/ + else break; /*stop if errors*/ + } + if (len >= MIN_SDR_SZ) { + if ((sdr[3] == 0x11) || (sdr[3] == 0x12)) /*SDR FRU or IPMB type*/ + ret = get_show_fru(recid, sdr,len); + do_reserve = 1; + } /*endif get_show_fru */ #ifdef PICMG_CHILD /* * Special logic for blade child MCs in PICMG ATCA systems diff --git a/util/ifruset.c b/util/ifruset.c index fbde21e..b2f8b66 100644 --- a/util/ifruset.c +++ b/util/ifruset.c @@ -245,7 +245,7 @@ int load_fru(uchar sa, uchar frudev, uchar frutype) { int ret = 0; - uchar indata[16]; + uchar indata[FRUCHUNK_SZ]; uchar resp[18]; int sresp; uchar cc; @@ -255,6 +255,7 @@ load_fru(uchar sa, uchar frudev, uchar frutype) int i; int chunk; + memset(indata, 0, sizeof(indata)); indata[0] = frudev; sresp = sizeof(resp); if (fdebug) printf("load_fru: sa = %02x, frudev = %02x\n",sa,frudev); @@ -923,7 +924,7 @@ write_fru_data(uchar id, ushort offset, uchar *data, int dlen, char fdebug) int ret = -1; int chunk; ushort fruoff; - uchar req[25]; + uchar req[FRUCHUNK_SZ+9]; uchar resp[16]; int sresp; uchar cc; diff --git a/util/ilan.c b/util/ilan.c index 8364c88..635a22a 100644 --- a/util/ilan.c +++ b/util/ilan.c @@ -4098,7 +4098,8 @@ main(int argc, char **argv) while ((c = getopt (argc, argv, "a:b:cdef:gh:i:j:klm:n:op:q:rstu:v:w:xy:z#::A:B:C:DEF:G:H:I:J:K:L:M:N:OP:Q:R:S:T:U:V:X:YZ:?")) - != EOF) { + != EOF) + { switch (c) { case 'a': /* alert dest number (usu 1 thru 4) */ alertnum = atob (optarg); @@ -4126,12 +4127,11 @@ main(int argc, char **argv) break; case 'f': i = atoi (optarg); /*set arp_ctl */ - if (i < 0 || i > 3) - printf ("Invalid ARP control %d\n", i); + if (i < 0 || i > 3) printf ("Invalid ARP control %d\n", i); else { - arp_ctl = i; - fsetarp = 1; - j++; + arp_ctl = i; + fsetarp = 1; + j++; } break; case 'l': @@ -4143,39 +4143,34 @@ main(int argc, char **argv) case 'h': /* VLAN ID */ i = atoi (optarg); if (i > 4095) - vlan_enable = 0; + vlan_enable = 0; else { - vlan_enable = 1; - vlan_id = (ushort) i; + vlan_enable = 1; + vlan_id = (ushort) i; } j++; break; case 'y': /* OEM LAN Failover enable/disable */ i = atoi (optarg); - if (i < 0) - printf ("Failover(-y) parameter is negative\n"); - else - failover_enable = i; + if (i < 0) printf ("Failover(-y) parameter is negative\n"); + else failover_enable = i; j++; break; case 'Q': /* VLAN Priority */ i = atoi (optarg); - if (i > 7 || i < 0) - vlan_enable = 0; + if (i > 7 || i < 0) vlan_enable = 0; else { - vlan_enable = 1; - vlan_prio = (uchar) i; + vlan_enable = 1; + vlan_prio = (uchar) i; } j++; break; case 'i': /* eth interface (ifname) */ fsetifn = 1; i = sizeof (ifname); - if (strlen (optarg) > (uint) i) - optarg[i] = 0; + if (strlen (optarg) > (uint) i) optarg[i] = 0; strcpy (ifname, optarg); - if (fdebug) - printf ("ifname = %s\n", ifname); + if (fdebug) printf ("ifname = %s\n", ifname); j++; break; case 'j': @@ -4194,15 +4189,15 @@ main(int argc, char **argv) custPEF[8] = htoi (&optarg[16]); /*data1offset */ custPEF[9] = htoi (&optarg[18]); /*data1mask */ if (optarg[20] != 0) { - /* optionally get 8 extra PEF entry bytes */ - custPEF[10] = htoi (&optarg[20]); /*data1cmp1 */ - custPEF[11] = htoi (&optarg[22]); /*data1cmp2 */ - custPEF[12] = htoi (&optarg[24]); /*data2mask */ - custPEF[13] = htoi (&optarg[26]); /*data2cmp1 */ - custPEF[14] = htoi (&optarg[28]); /*data2cmp2 */ - custPEF[15] = htoi (&optarg[30]); /*data3mask */ - custPEF[16] = htoi (&optarg[32]); /*data3cmp1 */ - custPEF[17] = htoi (&optarg[34]); /*data3cmp2 */ + /* optionally get 8 extra PEF entry bytes */ + custPEF[10] = htoi (&optarg[20]); /*data1cmp1 */ + custPEF[11] = htoi (&optarg[22]); /*data1cmp2 */ + custPEF[12] = htoi (&optarg[24]); /*data2mask */ + custPEF[13] = htoi (&optarg[26]); /*data2cmp1 */ + custPEF[14] = htoi (&optarg[28]); /*data2cmp2 */ + custPEF[15] = htoi (&optarg[30]); /*data3mask */ + custPEF[16] = htoi (&optarg[32]); /*data3cmp1 */ + custPEF[17] = htoi (&optarg[34]); /*data3cmp2 */ } j++; break; @@ -4217,11 +4212,11 @@ main(int argc, char **argv) fpefenable = 1; pefnum = atob (optarg); if (pefnum >= MAXPEF) { - pefnum = MAXPEF - 1; - fAdjustPefNum = 1; + pefnum = MAXPEF - 1; + fAdjustPefNum = 1; } else - fUserPefNum = 1; + fUserPefNum = 1; j++; break; case 'o': @@ -4242,18 +4237,14 @@ main(int argc, char **argv) break; case 'v': /* user access privilege level */ i = atoi (optarg); - if (valid_priv (i)) - lan_access = i & 0x0f; - else - printf ("Invalid privilege -v %d, using Admin\n", i); + if (valid_priv (i)) lan_access = i & 0x0f; + else printf ("Invalid privilege -v %d, using Admin\n", i); j++; break; case 'w': i = atoi (optarg); /*set grat arp interval, in #sec */ - if (i >= 0 && i < 256) - arp_interval = i * 2; - else - printf ("Invalid arp interval -w %d, skipping\n", i); + if (i >= 0 && i < 256) arp_interval = i * 2; + else printf ("Invalid arp interval -w %d, skipping\n", i); break; case 'x': fdebug = 1; @@ -4276,8 +4267,7 @@ main(int argc, char **argv) break; case 'M': /* My BMC MAC Address */ atomac (rgmymac, optarg); - if (!MacIsValid (rgmymac)) - printf ("Invalid MAC for -M\n"); + if (!MacIsValid (rgmymac)) printf ("Invalid MAC for -M\n"); j++; break; case 'S': /* Subnet IP Address */ @@ -4296,8 +4286,7 @@ main(int argc, char **argv) break; case 'H': /* Gateway MAC Address */ atomac (rggwymac, optarg); - if (!MacIsValid (rggwymac)) - printf ("Invalid MAC for -H\n"); + if (!MacIsValid (rggwymac)) printf ("Invalid MAC for -H\n"); j++; break; case 'B': /* SOL Baud rate */ @@ -4314,8 +4303,7 @@ main(int argc, char **argv) break; case 'X': /* Alert Dest MAC Address */ atomac (rgdestmac, optarg); - if (!MacIsValid (rgdestmac)) - printf ("Invalid MAC for -X\n"); + if (!MacIsValid (rgdestmac)) printf ("Invalid MAC for -X\n"); fpefenable = 1; /* PEF is implied here */ j++; break; @@ -4329,8 +4317,7 @@ main(int argc, char **argv) case 'C': /* Community String */ fsetcommunity = 1; i = sizeof (rgcommunity); /*usu 18 */ - if (strlen (optarg) > (uint) i) - optarg[i] = 0; + if (strlen (optarg) > (uint) i) optarg[i] = 0; strcpy (rgcommunity, optarg); fpefenable = 1; /* PEF is implied here */ j++; @@ -4344,8 +4331,7 @@ main(int argc, char **argv) if (strlen (optarg) > PSW_MAX) optarg[PSW_MAX] = 0; strcpy (passwordData, optarg); - if (fdebug) - printf ("Password = %s\n", passwordData); + if (fdebug) printf ("Password = %s\n", passwordData); /* Hide password from 'ps' */ memset (optarg, ' ', strlen (optarg)); j++; @@ -4353,16 +4339,15 @@ main(int argc, char **argv) case 'q': case '#': usernum = atob (optarg); - if (usernum > 15) - usernum = 0; /*MAX_IPMI_USERS = 15 */ + if (usernum > 15) usernum = 0; /*MAX_IPMI_USERS = 15 */ j++; break; case 'L': if (strcmp (optarg, "list") == 0) - fshowchan = 1; + fshowchan = 1; lan_ch_parm = atob (optarg); if (lan_ch_parm > MAXCHAN) - lan_ch_parm = PARM_INIT; /*invalid */ + lan_ch_parm = PARM_INIT; /*invalid */ break; case 'V': /* priv level */ fprivset = 1; @@ -4474,90 +4459,78 @@ main(int argc, char **argv) pefmax = 20; /*default Intel PEF */ switch (prod_id) { case 0x4311: /* Intel NSI2U w SE7520JR23 */ - fmBMC = 1; /* Intel miniBMC */ - if (pefnum == 12) - pefnum = 14; /* change CritStop pefnum */ - pefdesc = &pefdesc2[0]; /*mini-BMC PEF */ - pefmax = 30; - fsharedMAC = 1; /* shared-MAC BMC LAN port, same MAC */ - break; + fmBMC = 1; /* Intel miniBMC */ + if (pefnum == 12) pefnum = 14; /* change CritStop pefnum */ + pefdesc = &pefdesc2[0]; /*mini-BMC PEF */ + pefmax = 30; + fsharedMAC = 1; /* shared-MAC BMC LAN port, same MAC */ + break; case 0x0022: /* Intel TIGI2U w SE7520JR23 +IMM */ - fsharedMAC = 1; /* shared-MAC BMC LAN port, same MAC */ - gcm_ch = 3; /* IMM GCM port, dedicated MAC */ - show_users = 4; - break; + fsharedMAC = 1; /* shared-MAC BMC LAN port, same MAC */ + gcm_ch = 3; /* IMM GCM port, dedicated MAC */ + show_users = 4; + break; case 0x000C: /*TSRLT2 */ case 0x001B: /*TIGPR2U */ - /* fmBMC=0; Intel Sahalee BMC */ - fsharedMAC = 1; /* shared-MAC BMC LAN port, same MAC */ - break; + /* fmBMC=0; Intel Sahalee BMC */ + fsharedMAC = 1; /* shared-MAC BMC LAN port, same MAC */ + break; case 0x0026: /*S5000 Bridgeport */ case 0x0028: /*S5000PAL Alcolu */ case 0x0029: /*S5000PSL StarLake */ case 0x0811: /*S5000PHB TIGW1U */ - /* fmBMC=0; Intel Sahalee ESB2 BMC */ - fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ - gcm_ch = 3; - parm7 = &iparm7[0]; /*TTL=30 */ - break; + /* fmBMC=0; Intel Sahalee ESB2 BMC */ + fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ + gcm_ch = 3; + parm7 = &iparm7[0]; /*TTL=30 */ + break; case 0x003E: /*NSN2U or CG2100 Urbanna */ - fiBMC = 1; /* Intel iBMC */ - fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ - // gcm_ch = 3; - parm7 = &iparm7[0]; /*TTL=30 */ - if (fsetarp == 0) - arp_ctl = 0x02; /*grat arp disabled, arp resp enabled */ - arp_interval = 0x00; /*0 sec, since grat arp disabled */ - sol_accum[0] = 0x0c; /*Intel defaults */ - sol_accum[1] = 0x60; /*Intel defaults */ - sol_retry[0] = 0x07; /*Intel defaults */ - sol_retry[1] = 0x32; /*Intel defaults */ - set_max_kcs_loops (URNLOOPS); /*longer for SetLan cmds (default 300) */ - break; + fiBMC = 1; /* Intel iBMC */ + fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ + // gcm_ch = 3; + parm7 = &iparm7[0]; /*TTL=30 */ + if (fsetarp == 0) arp_ctl = 0x02; /*grat arp disabled,arp resp enabled*/ + arp_interval = 0x00; /*0 sec, since grat arp disabled */ + sol_accum[0] = 0x0c; /*Intel defaults */ + sol_accum[1] = 0x60; /*Intel defaults */ + sol_retry[0] = 0x07; /*Intel defaults */ + sol_retry[1] = 0x32; /*Intel defaults */ + set_max_kcs_loops (URNLOOPS); /*longer for SetLan cmds (default 300)*/ + break; case 0x0107: /* Intel Caneland */ - fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ - gcm_ch = 3; - break; + fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ + gcm_ch = 3; + break; case 0x0100: /*Tiger2 ia64 */ - /* for ia64 set chan_pefon, chan_pefoff accordingly */ - chan_pefon = CHAN_ACC_PEFON64; - chan_pefoff = CHAN_ACC_PEFOFF64; - /* fall through */ + /* for ia64 set chan_pefon, chan_pefoff accordingly */ + chan_pefon = CHAN_ACC_PEFON64; + chan_pefoff = CHAN_ACC_PEFOFF64; + /* fall through */ default: /* else other Intel */ - /* fmBMC = 0; * Intel Sahalee BMC */ - if (fIPMI20) - fsharedMAC = 0; /* recent, not-shared BMC MAC */ - else - fsharedMAC = 1; /* usu IPMI 1.x has shared BMC MAC */ - break; + /* fmBMC = 0; * Intel Sahalee BMC */ + if (fIPMI20) fsharedMAC = 0; /* recent, not-shared BMC MAC */ + else fsharedMAC = 1; /* usu IPMI 1.x has shared BMC MAC */ + break; } /*end switch */ - if (is_romley (vend_id, prod_id)) - fRomley = 1; - if (is_grantley (vend_id, prod_id)) - fGrantley = 1; + if (is_romley(vend_id, prod_id)) fRomley = 1; + if (is_grantley(vend_id, prod_id)) fGrantley = 1; if (fRomley) { - fiBMC = 1; /* Intel iBMC */ - fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ - set_max_kcs_loops (URNLOOPS); /*longer for SetLan (default 300) */ - fipv6 = 1; - if (fsetarp == 0) - arp_ctl = 0x03; /*default to both for Romley */ + fiBMC = 1; /* Intel iBMC */ + fsharedMAC = 0; /* not-shared BMC LAN port, separate MAC */ + set_max_kcs_loops (URNLOOPS); /*longer for SetLan (default 300) */ + fipv6 = 1; + if (fsetarp == 0) arp_ctl = 0x03; /*default to both for Romley */ } } else { /* else other vendors */ - if (fIPMI20) - fsharedMAC = 0; /* recent, not-shared BMC MAC */ - else - fsharedMAC = 1; /* usu IPMI 1.x has shared BMC MAC */ + if (fIPMI20) fsharedMAC = 0; /* recent, not-shared BMC MAC */ + else fsharedMAC = 1; /* usu IPMI 1.x has shared BMC MAC */ pefdesc = NULL; /* unknown, see PefDesc() */ - if (pefnum == 12) - pefnum = 15; /* change CritStop pefnum to 15? */ + if (pefnum == 12) pefnum = 15; /* change CritStop pefnum to 15? */ pefmax = 20; - if (!fUserPefNum) - fAdjustPefNum = 1; + if (!fUserPefNum) fAdjustPefNum = 1; } - if (fmBMC) - show_users = 1; /* mBMC doesn't support more than 1 user */ + if (fmBMC) show_users = 1; /* mBMC doesn't support more than 1 user */ } if (fshowchan) { @@ -4583,16 +4556,15 @@ main(int argc, char **argv) i = 0; /* default to eth0, lan_ch set already. */ if (vend_id == VENDOR_INTEL) { if ((prod_id == 0x001B) || (prod_id == 0x000c)) { - /* Intel TIGPR2U or TSRLT2 defaults are special */ - if (lan_ch_parm == 6) { - i = 0; - lan_ch = 6; - } - else { - i = 1; - lan_ch = 7; - } - ser_ch = 1; + /* Intel TIGPR2U or TSRLT2 defaults are special */ + if (lan_ch_parm == 6) { + i = 0; + lan_ch = 6; + } else { + i = 1; + lan_ch = 7; + } + ser_ch = 1; } } } diff --git a/util/ipmiutil.c b/util/ipmiutil.c index e2a23d4..eea67d0 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"; -char *progver = "3.10"; +char *progver = "3.11"; // static char fdebug = 0; /*int ipmiutil(int argc, char **argv); */ |