Cleanup style in method ipmi_fru_oemkontron_get as well as add inverted
logic checks to reduce indentation.
Signed-off-by: Patrick Venture <venture@google.com>
Fixup the following array bounds checking bugs:
[lib/ipmi_fru.c:1003]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1127]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1262]: (style) Array index 'i' is
used before limits check.
Signed-off-by: Patrick Venture <venture@google.com>
For `sol activate` the timeout on lanplus interface was hard-coded
to 1 second, overriding the value set with the `-N` option.
Resolvesipmitool/ipmitool#87
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Move led color static array from header to ipmi_picmg module
and introduce `picmg_led_color_str()` function for use in
ipmi_vita module.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Move static objects declared in headers to the source files where
they're used.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Patrick Venture <venture@google.com>
Cleanup all unused-parameter warnings. Each warning was examined to
verify it wasn't simply a case of a build macro difference.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Patrick Venture <venture@google.com>
Use __UNUSED__ macro defined in helper.h instead of the gcc-specific
attribute unused macro.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Patrick Venture <venture@google.com>
FRU board mfg. date uses a different value for 'unspecified'
timestamp than the general IPMI specification.
This commit makes ekanalyzer and fru commands process unspecified
FRU dates properly, displaying 'Unspecified' instead of
'Mon Jan 1 03:00:00 1996'.
Resolvesipmitool/ipmitool#57
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
In some of the SDR calculating code, there were switch statements that
had cases that would fall through deliberately into the next case. But
the compiler didn't like the comment and would complain about the fall
through anyway. This changes to a comment that the compiler recognizes.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
Some return values were being ignored in ipmi_start_daemon. This adds
checks to the values and changes some hard-coded numbers into named
values.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
Several functions were passed a struct ipmi_intf* even though it was
unused. This removes the unused parameters and changes calls and
signatures.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
Before this fix `ipmitool` would complain that VLAN ID
is out of range when trying to disable an already disabled VLAN
on a lan channel. With this fix it will properly report that
VLAN is already disabled.
Resolvesipmitool/ipmitool#55
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Dates, times and floating point numbers from now on
will be displayed using system locale settings.
Resolvesipmitoo/ipmitool#23
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
There is a bug in gcc since 4.3.2 and still not fixed in 8.1.0.
Even if __attribute__((format(strftime... is specified for a
wrapper function around strftime, gcc still complains about strftime
being called from the wrapper with a "non-literal" format argument.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438
This commit adds 'ugly hacks' from that discussion to call strftime()
from strftime-formatted wrappers and silence the warnings.
Partially resolvesipmitool/ipmitool#23
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Handle all date/time stamps uniformly, taking in account the host
endianness. Respect the local time zone and the '-Z' option for
all ipmitool commands. Unify the date and time formatting.
Add correct handling of IPMI timestamps 'since system startup'
and for 'unspecified' timestamps.
Partially resolvesipmitool/ipmitool#23
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Some minor formatting corrections.
Also introduced a new helper function to reduce nesting level.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Cipher suite ID is a byte as per IPMI spec.
Use the appropriate function and consider target endianness
(so write to a temporary variable).
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Based on current crypto alogrithms, one could rank cipher suites along
these lines:
17 > 3 >> all the rest
17 and 3 are the only cipher suites that implement any sort of
confidentiality alogorithm that is secure. In addition, any hmac-md5 or
md5 integrity algorithm used in integrity is weak at best and dangerous
for authentication.
This could possibly be enabled in a simpler mechanism by simply checking
for 17 and then choosing it before falling back to 3, but the way this
is implemented, it makes it easy to change the list of acceptable
algorithms from two to three or more items.
Resolvesipmitool/ipmitool#29
Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
With this commit the GUID encoding is now by default detected
automatically based on the validity of the version field,
and the timestamp (for time-based version 1 GUIDs).
The version is considered valid if it is 1 through 5.
The timestamp is considered valid if the year is past UNIX Epoch
and before the current year.
Resolvesipmitool/ipmitool#25
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Before this commit the 'Timestamp' line was always printed
for all versions of GUID, even for non-time-based ones.
Plus, only the time_low field was used, and it was used as if
it contained seconds since UNIX Epoch, which it didn't. In fact
this field along with other time_* fields constitute a single
60-bit value representing the count of 100ns intervals since
adoption of Gregorial calendar (00:00:00.00 15 Oct 1582).
For non-time-based versions of GUID, the time_* fields do
not represent any time at all.
So, after this commit, the timestamp will be properly decoded
for time-based GUID version 1 only. For other versions the
'Timestamp' line will not be displayed. A line showing the
GUID version will be added to the output.
Partially resolvesipmitool/ipmitool#25
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
There are lots of BMC implementations that violate the IPMI
specification in regard to GUID encoding and instead encode
GUIDs according to either RFC4122 or SMBIOS specifications.
This commit restores the default behavior of `mc guid` to
SMBIOS-based decoding and adds options to allow for decoding
according to IPMI or RFC4122 specifications.
It also allows to simply dump the received GUID as is
without any parsing.
It is possible that in future versions `ipmitool` will
change default behavior to 'ipmi' instead of 'smbios'.
Partially resolvesipmitool/ipmitool#25
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Before this commit the bytes for the GUID 'node' part were displayed in
reverse order as if they were reported by BMC according to SMBIOS
specification, not accordint to IPMI.
The field order in guid_t was also specified according to RFC4122/SMBIOS,
which is the reverse of IPMI specification. It has now been fixed.
The time_low field of GUID was taken directly, without taking in
account the ipmitool host endianness. It is now properly converted
from IPMI little-endian to host byte order. Other GUID fields are
also properly converted now. As of now, ipmitool does not generally work
properly when built for a big-endian target, but that's out of scope
of this commit.
Please note that this commit most probably breaks the output of
`ipmitool mc guid` with most existing BMC implementations, but that's
just an indication of them being broken. A follow-up commit will
re-add support for the broken behavior.
Partially resolvesipmitool/ipmitool#25
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Remove all direct comparisons to 'NULL' for pointers.
Replace them with boolean-like 'if (ptr)' and 'if (!ptr)'.
This makes conditions shorter and easier to read.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Make code better readable by replacing `if (rsp->ccode > 0)`
and 'if (rsp->ccode != 0)' with just `if (rsp->ccode)` as
rsp->ccode is anyway an unsigned byte and can't be negative.
Also replace 'if (rsp->ccode == 0)' with 'if (!rsp->ccode)'.
All these changes make lines shorter and easier to read as
a non-zero ccode is an indication of some failure, and so !ccode
naturally reads as 'no error'.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Add ARRAY_SIZE() macro.
Use the new macro in all places where array size is calculated by
means of sizeof(array)/sizeof(array[0]).
Fix minor bugs and warnings in the affected code.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Fix a number of warnings in ipmi_mc.c, including a potentially
uninitialized variable for `mc watchdog set` command.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Get rid of lanplus-specific yet very generic in nature
lanplus_swap() function that unconditionally swaps bytes
in an arbitrary byte array. Move it to helper module and
add two conditionally working interfaces to it:
- array_ntoh() for network (BE) to host conversion, and
- array_letoh() for ipmi (LE) to host conversion.
The added functions will only perform byte swapping if
the target architecture differs in endianness from the
data source. array_ntoh() will only do swap on LE machines,
while array_letoh() will only do it on BE ones.
These functions are introduced for future use in other
places of ipmitool.
Partially resolvesipmitool/ipmitool#26
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
A potential future problem has been identified in the manufacturer
ID processing code for `mc info` command. Only 16 of 24 bits were
used. This is fixed now.
Also added support for ID 0x0FFFFF, the 'reserved' value as per
IPMI specification. It is now reported as 'Unspecified' unlike other
non-listed IDs that are still reported as 'Unknown'.
ID 0xFFFFFE is used for debugging purposes in hope that IANA won't
reach that number of entities any soon. If it will though, then
IANA's assignment will take precedence.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
There are lots of feature test macros like _POSIX_SOURCE,
_BSD_SOURCE, etc. chaotically placed at the beginning of
multiple files without apparent reason, sometime purely
erroneously.
This commit removes them all for the sake of cleaner code.
No new warnings are added due to that at least for gcc 5.4
on Linux with glibc 2.23.
Added an option -Z to display all dates in UTC.
Resolvesipmitool/ipmitool#19
Change-Id: Iac3a61190eefde12d95c892af26072ec01f60474
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
* Replace with a macro all calls to val2str() for completion codes
* Replace with a macro all calls to val2str() for manufacturer name
* Replace with a macro all calls to val2str() for product name
* Add ipmi24toh() and ipmi32toh() helpers, unify ipmi*toh() interface
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
* Add output of "don't log" and "pre-timeout interrupt" fields
* Display timers with 100ms precision
* List timer use expiration flags as text, not just numerically
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Add `ipmitool mc watchdog set` command in full compliance
with IPMI spec 2.0 section 27.6. Setting of all fields
is fully supported.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>