2066 Commits

Author SHA1 Message Date
Patrick Venture
83fee27624 drop unused static arrays
Originally marked unused, now dropped.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
3e0ecc5edc move static objects to source file
Move static objects declared in headers to the source files where
they're used.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
8ea6094118 cleanup all unused-parameter warnings
Cleanup all unused-parameter warnings.  Each warning was examined to
verify it wasn't simply a case of a build macro difference.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
d6d9c85139 use __UNUSED__ macro instead of gcc specific attribute
Use __UNUSED__ macro defined in helper.h instead of the gcc-specific
attribute unused macro.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
9a55136bfb implement __UNUSED__ macro for marking unused
Implement __UNUSED__ macro for marking symbols unused safely.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Patrick Venture
4ac93853a6 Add .dirstamp to .gitignore
Add the .dirstamp path to .gitignore.  .dirstamp is automatically
generated by some build systems.

Signed-off-by: Patrick Venture <venture@google.com>
2018-11-23 16:41:06 +03:00
Alexander Amelkin
a4c1040420
fru: Fix processing of unspecified board mfg. date
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'.

Resolves ipmitool/ipmitool#57

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-16 22:25:27 +03:00
Vernon Mauery
576d4855d9 [compiler-warnings-fixes] use correct fall through comment
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 resolves ipmitool/ipmitool#13

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-11 14:55:43 +03:00
Vernon Mauery
f2780c5d86 [compiler-warnings-fixes] ipmi_start_daemon: check return values
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 resolves ipmitool/ipmitool#13

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-11 14:55:43 +03:00
Vernon Mauery
dc9b4ebfc9 [compiler-warnings-fixes] ipmi_sdr.c: remove unused function parameters
Several functions were passed a struct ipmi_intf* even though it was
unused. This removes the unused parameters and changes calls and
signatures.

Partially resolves ipmitool/ipmitool#13

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-11 14:55:43 +03:00
Alexander Amelkin
6e2b688e24
lan: Fix processing disabled VLAN
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.

Resolves ipmitool/ipmitool#55

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-11 11:57:12 +03:00
Alexander Amelkin
6c3d4b56c9
Make ipmitool respect system locale settings
Dates, times and floating point numbers from now on
will be displayed using system locale settings.

Resolves ipmitoo/ipmitool#23

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-08 21:26:32 +03:00
Alexander Amelkin
4f05b95f6c
Fix strftime() non-literal argument warning
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 resolves ipmitool/ipmitool#23

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-07 18:50:10 +03:00
Alexander Amelkin
f0d5c17ea7
Refactor timestamp handling
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 resolves ipmitool/ipmitool#23

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-07 18:11:58 +03:00
Alexander Amelkin
a4ac8ce4ab
doc: Update manpage with new contact info 2018-11-01 19:32:11 +03:00
Alexander Amelkin
65a2c548d8 lanplus: Refactoring
Some minor formatting corrections.
Also introduced a new helper function to reduce nesting level.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-11-01 19:29:45 +03:00
Alexander Amelkin
1283382e82 lanplus: Fix -C option processing
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>
2018-11-01 19:29:45 +03:00
Vernon Mauery
7772254b62 lanplus: Auto-select 'best' cipher suite available
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.

Resolves ipmitool/ipmitool#29

Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2018-11-01 19:29:45 +03:00
Rosen Penev
a8862d7508 lanplus: Fix compile with deprecated APIs disabled.
From the man page:

EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. As a result,
EVP_CIPHER_CTX_reset() appeared and EVP_CIPHER_CTX_cleanup() disappeared.
EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset().

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2018-10-31 16:29:19 +03:00
Alexander Amelkin
081bde8e1b
doc: Update home page links 2018-10-01 18:55:00 +03:00
Alexander Amelkin
9e05c0b120
doc: Update formatting of ipmitool man page 2018-10-01 18:54:43 +03:00
eyjhbb@gmail.com
6f336d04f1 sensor: Refactor ipmi_sensor_print_fc_threshold()
Break the function into smaller pieces to reduce
complexity.
2018-09-25 14:32:46 +03:00
eyjhbb@gmail.com
9d49a6edfe sensor: Add support for csv output 2018-09-25 14:32:46 +03:00
BenjaminFair
c70665c3d1 plugins: open: Properly enable event receiver (#35)
The ioctl to enable the event receiver in the OpenIPMI interface is
called with an argument of 0, which tells OpenIPMI to disable it. Set
the argument to 1 instead so that it will be enabled.

Signed-off-by: Benjamin Fair <benjaminfair@google.com>
2018-09-09 14:48:58 +03:00
Alexander Amelkin
2ed677c388
lan: Refactoring: Remove unused function
Function ipmi_lan_build_rsp() is never used anywhere.
Remove it.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:32:35 +03:00
Alexander Amelkin
03d2b53c97
strings: Refix 329ebdff: Enlarge data type
Make val in valstr 32-bit to accomodate the values added
by commit 329ebdff.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:18:07 +03:00
Alexander Amelkin
4c155320be
general: Get rid of some unused parameter warnings
Silence the unused parameter warnings in helper.c
introduced earlier.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:10:28 +03:00
Alexander Amelkin
40d52b5fa1
mc: guid: Implement encoding autodetection
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.

Resolves ipmitool/ipmitool#25

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 18:10:28 +03:00
Alexander Amelkin
0b6abe8cd9
mc: guid: Fix timestamp decoding
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 resolves ipmitool/ipmitool#25

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 17:30:26 +03:00
Alexander Amelkin
f43a78bfc3
mc: guid: Add support for non-standard encodings
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 resolves ipmitool/ipmitool#25

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 17:30:25 +03:00
Alexander Amelkin
b44ec2fb65
mc: guid: Fix byte ordering to follow IPMI spec
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 resolves ipmitool/ipmitool#25

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 17:30:25 +03:00
Alexander Amelkin
e9716e216d
Refactoring: optimize pointer checks
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>
2018-08-21 17:30:25 +03:00
Alexander Amelkin
f3ef88724f
imb: Refactoring: remove duplicate code
Merge GetAsyncImbpMessage() and GetAsyncImbpMessage_Ex() functions
as they share 95% of the code. Make the former call the latter().

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-21 11:55:03 +03:00
Alexander Amelkin
9ecfb762bd
Refactoring: get rid of superfluous comparisons
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>
2018-08-21 11:55:03 +03:00
Alexander Amelkin
bb1a4cc805
Refactoring. Improve code reuse ratio.
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>
2018-08-14 16:44:52 +03:00
Thorsten Horstmann
232773d171 general: Fix several misspellings
Fix misspellings found by codespell in code comments,
console output and documentation.

Resolves ipmitool/ipmitool#28
2018-08-06 15:59:06 +03:00
Alexander Amelkin
a8f3413dc2
mc: Fix compiler warnings
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>
2018-08-02 00:48:32 +03:00
Alexander Amelkin
29e7d26edb
general: Add array_byteswap() to helper
Make unconditional array byte swapping publicly available

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-01 15:57:37 +03:00
Alexander Amelkin
7747d86cc4
lanplus: Make byteswapping generic
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 resolves ipmitool/ipmitool#26

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-01 11:33:44 +03:00
Alexander Amelkin
5491b12596
refix 249e0929: Fix byteswapping helpers
Commit 249e0929 added extra conditionals in byteswapping functions.
They are not needed and didn't work properly.
Now those functions must finally be ok.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-08-01 10:45:22 +03:00
Alexander Amelkin
3db2bf6c4b
framework: Update .gitignore 2018-07-31 12:12:41 +03:00
Alexander Amelkin
5a684b54ed
framework: Switch to C11 standard with GNU extensions
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-07-31 12:12:41 +03:00
Alexander Amelkin
6d6411d2fc framework: ci: Add support for Travis CI
Future commits to ipmitool will be verified by Travis CI.
This commit adds a basic configuration for that purpose.
2018-07-29 01:16:56 +03:00
qctbmc
5c033c06ab oem: Add basic support for Quanta 2018-07-28 19:15:10 +03:00
Alexander Amelkin
72b4b25b05
intf: Refactoring. Remove unused sendrsp()
The sendrsp() callback is never ever called from anywhere.
Remove it from interface structure.
2018-07-27 17:22:31 +03:00
Alexander Amelkin
3aade24297
dummy: Add default dummy socket
fake-ipmistack uses a default socket at /tmp/.ipmi_dummy.
Use it when IPMI_DUMMY_SOCK environment variable is not set.
2018-07-27 17:13:18 +03:00
Alexander Amelkin
329ebdff84
mc: Fix manufacturer ID masking
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>
2018-07-26 19:54:57 +03:00
Alexander Amelkin
6ee52071dd
Refactoring. Remove useless feature test macros.
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.
2018-07-25 15:58:00 +03:00
Alexander Amelkin
249e092967
general: Make byteswapping arch-independent
ipmiXXtoh() and htoipmiXX() functions were broken
and only worked properly for big-endian hosts.

This commit makes them endianness-independent.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-07-20 19:43:56 +03:00
Alexander Amelkin
b3d258b234
sel: Minor refactoring
Minor code duplication reduction

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-07-20 19:12:33 +03:00