diff options
Diffstat (limited to 'util/ilan.c')
-rw-r--r-- | util/ilan.c | 239 |
1 files changed, 108 insertions, 131 deletions
diff --git a/util/ilan.c b/util/ilan.c index a6e91a3..635a22a 100644 --- a/util/ilan.c +++ b/util/ilan.c @@ -305,8 +305,13 @@ extern char *get_sensor_type_desc (uchar stype); /*from ievents.c */ /* * Global variables */ -static char * progname = "ilan"; +#ifdef METACOMMAND +extern char * progver; /*from ipmiutil.c*/ +static char * progname = "ipmiutil lan"; +#else static char * progver = "3.08"; +static char * progname = "ilan"; +#endif static char fdebug = 0; static char fipmilan = 0; static char fIPMI10 = 0; /* =1 if IPMI v1.0 or less */ @@ -4093,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); @@ -4121,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': @@ -4138,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': @@ -4189,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; @@ -4212,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': @@ -4237,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; @@ -4271,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 */ @@ -4291,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 */ @@ -4309,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; @@ -4324,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++; @@ -4339,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++; @@ -4348,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; @@ -4469,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) { @@ -4578,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; } } } |