diff --git a/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm b/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm index 138ceb632..6ac214259 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm @@ -944,16 +944,34 @@ sub getnetinfo { \@returnd ); + if($error) { $rc = 1; $text = $error; } else { + # response format: + # 4 bytes (RMCP header) + # 1 byte (auth type) + # 4 bytes (session sequence) + # 4 bytes (session id) + # 16 bytes (message auth code, not present if auth type is 0, $authoffset=16) + # 1 byte (ipmi message length) + # 1 byte (requester's address + # 1 byte (netfun, req lun) + # 1 byte (checksum) + # 1 byte (Responder's slave address) + # 1 byte (Sequence number, generated by the requester) + # 1 byte (command) + # 1 byte (return code) + # 1 byte (param revision) + # N bytes (data) + # 1 byte (checksum) if($subcommand eq "garp") { - $code = $returnd[36]; + $code = $returnd[36-$authoffset]; if($code == 0x00) { - $code = $returnd[38] / 2; + $code = $returnd[38-$authoffset] / 2; $text = sprintf("$format %d","Gratuitous ARP seconds:",$code); } else { @@ -962,7 +980,7 @@ sub getnetinfo { } } elsif($subcommand eq "alert") { - if ($returnd[39] & 0x8) { + if ($returnd[39-$authoffset] & 0x8) { $text = "SP Alerting: enabled"; } else { $text = "SP Alerting: disabled"; @@ -971,50 +989,50 @@ sub getnetinfo { elsif($subcommand =~ m/^snmpdest(\d+)/ ) { $text = sprintf("$format %d.%d.%d.%d", "SP SNMP Destination $1:", - $returnd[41], - $returnd[42], - $returnd[43], - $returnd[44]); + $returnd[41-$authoffset], + $returnd[42-$authoffset], + $returnd[43-$authoffset], + $returnd[44-$authoffset]); } elsif($subcommand eq "ip") { $text = sprintf("$format %d.%d.%d.%d", "BMC IP:", - $returnd[38], - $returnd[39], - $returnd[40], - $returnd[41]); + $returnd[38-$authoffset], + $returnd[39-$authoffset], + $returnd[40-$authoffset], + $returnd[41-$authoffset]); } elsif($subcommand eq "netmask") { $text = sprintf("$format %d.%d.%d.%d", "BMC Netmask:", - $returnd[38], - $returnd[39], - $returnd[40], - $returnd[41]); + $returnd[38-$authoffset], + $returnd[39-$authoffset], + $returnd[40-$authoffset], + $returnd[41-$authoffset]); } elsif($subcommand eq "gateway") { $text = sprintf("$format %d.%d.%d.%d", "BMC Gateway:", - $returnd[38], - $returnd[39], - $returnd[40], - $returnd[41]); + $returnd[38-$authoffset], + $returnd[39-$authoffset], + $returnd[40-$authoffset], + $returnd[41-$authoffset]); } elsif($subcommand eq "backupgateway") { $text = sprintf("$format %d.%d.%d.%d", "BMC Backup Gateway:", - $returnd[38], - $returnd[39], - $returnd[40], - $returnd[41]); + $returnd[38-$authoffset], + $returnd[39-$authoffset], + $returnd[40-$authoffset], + $returnd[41-$authoffset]); } elsif ($subcommand eq "community") { $text = sprintf("$format ","SP SNMP Community:"); - my $l = 38; + my $l = 38-$authoffset; while ($returnd[$l] ne 0) { $l = $l + 1; } - my $i=38; + my $i=38-$authoffset; while ($i<$l) { $text = $text . sprintf("%c",$returnd[$i]); $i = $i + 1;