1933 Commits

Author SHA1 Message Date
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
Alexander Amelkin
928716244d
sdr: Refactor/optimize code. No functional changes. 2018-07-20 14:23:33 +03:00
Alexander Amelkin
2de8a5e1a9
mc: Refix 861ffb4 2018-07-20 14:23:33 +03:00
Nagaraju Goruganti
861ffb4680 Add an option to display all dates in UTC
Added an option -Z to display all dates in UTC.

Resolves ipmitool/ipmitool#19
Change-Id: Iac3a61190eefde12d95c892af26072ec01f60474
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>

Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
2018-07-19 19:13:42 +03:00
Alexander Amelkin
0310208383
mc: Code refactor to reduce copy-paste ratio
* 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>
2018-06-17 13:38:07 +03:00
Alexander Amelkin
e8e94d8976
mc: watchdog set: Refactor to reduce complexity
Move option parsing for `mc wathdog set` to a separate
function, add a function for host to ipmi integer
conversion (reduce manual byte juggling).
2018-06-17 12:38:05 +03:00
Alexander Amelkin
e49a20eece
mc: watchdog set: Fix intr setting
The previous commit contained a bug due to which
the `intr` option value was never passed to the BMC.
2018-06-17 12:13:35 +03:00
Alexander Amelkin
6c00d448d5
mc: watchdog get: Update to match IPMI 2.0 spec
* 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>
2018-06-17 02:01:19 +03:00
Alexander Amelkin
2a78ff2482
mc: watchdog: Add set command
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>
2018-06-17 01:36:46 +03:00
Alexander Amelkin
27f2f00dc6
framework: Make git ignore cscope.out 2018-06-16 23:22:41 +03:00
William A. Kennington III
f222df3081 plugins/open: Fix for interrupted select
The select syscall can be interrupted for signals like SIGPROF. The IPMI
command sent will still be outstanding but the send_command will return
an error. When the next command is sent it will get the completion for
the previous command and has the tendency to break state of end users.

Signed-off-by: William A. Kennington III <wak@google.com>
2018-06-16 22:53:46 +03:00
Alexander Amelkin
8c0e76c21a
nm: Fix policy range (#12)
From Node Manager spec 4.0, policy ID is one Byte data and the range is 0-255.
2018-05-30 19:08:26 +03:00
Alexander Amelkin
432f06db3f
Replace user_id masks with a macro (#8)
In multiple places throughout ipmi_user.c a user id mask
was used as a magic number, in some places the mask was wrong.
This commit replaces all those magic numbers with a single
IPMI_UID() macro.

Resolves ipmitool/ipmitool#6
2018-05-30 18:57:20 +03:00
Hnan-Ting Lo
564aef2aff fru: internaluse: Fix segmentation fault (#9)
A segmentation fault was trigged by executing 'ipmitool fru internaluse 1 info'.
A memset() was attempted on the address of a pointer, not on the pointer itself.
The erroneous memset() is removed with this commit because it duplicates
the memset() in line 4072.

Resolves ipmitool/ipmitool#9
Signed-off-by: Kylix Lo <kylix0713@gmail.com>
2018-05-30 18:31:24 +03:00
Thomas Abraham
ef7564a7ac
Re-apply commit 58d510f90feb
Commit 58d510f90feb ("ID : 103 picmg discover messages should
be DEBUG, not INFO") changed picmg discover messages from DEBUG
to INFO. However, commit f1c6118c722b ("ID:320 - Add VITA 46.11
support") reverted this without explanation.

This patch reverts the picmg discover messages back to DEBUG.
2018-05-11 14:24:17 +03:00
Alexander Amelkin
724f7329a3
dcmi: Refactor
- Refactor the ipmi_dcmi code for better readability;
- Get rid of space indents;
- Use tabs for indent, spaces for alignment;
- Wrap too long lines;
2018-04-05 21:08:22 +03:00
Alexander Amelkin
f498e3e296
ID:508 - Refix 6d9c540: Forgotten changes
Some array terminators were left unmodifed.
This commit removes the diversity to make all terminators unified.
2018-04-05 20:11:30 +03:00
Alexander Amelkin
6d9c540f6b
ID:508 - Fix segfaults in dcmi command handlers
Some command lists were not terminated properly.
This commit fixes that.
2018-04-03 19:46:35 +03:00
Alexander Amelkin
60723084e6
vendor: Add YADRO VESNIN identification
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-03-30 12:45:03 +03:00
Alexander Amelkin
9d41136c9b
ID:491 - Fetch vendor IDs from IANA
Prior to this commit, ipmitool had hard-coded list
of OEM Vendor IDs that it recognized.

With this commit, the list is fetched directly from
IANA PEN registry at build time, so that each release
will now contain an up-to-date list of vendors.

Only basic ASCII characters are supported now. Any
Unicode or extended ASCII will be either transliterated
(cyrillic and diacritic) or simply removed (chinese).

Closes:
ID:491 https://sourceforge.net/p/ipmitool/bugs/491/
ID:505 https://sourceforge.net/p/ipmitool/bugs/505/

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2018-03-30 02:33:35 +03:00
srinivasa_mareedu
ecb4cfbff8 ID:472 - Fix The Most recent Addition/Erase date
Fix the Most recent Addition/Erase date are not matched between in-band and
out-band.

ipmitool SDR code doesn't have to check for valid date to print
based on 'Delete SDR command supported' and 'Partial Add SDR command
supported', if 0xffffffff is taken. Also 'Timestamp' data type needs to change
to time_t(long) because same data type is using for gmtime(time_t) API, it has
different behaviour for Linux and Windows C.
2017-04-06 21:51:45 +02:00
Holger Liebig
1664902525 ID:480 - Call EVP_CIPHER_CTX_free() instead of EVP_CIPHER_CTX_cleanup()
Call EVP_CIPHER_CTX_free() instead of EVP_CIPHER_CTX_cleanup() to fix memory
leak.
2017-04-04 20:54:22 +02:00
Zdenek Styblik
f004b4b719 ID:480 - ipmitool coredumps in EVP_CIPHER_CTX_init
IPMI tool coredumps due to changes introduced in ID:461. This shouldn't be
surprise as a NULL pointer is passed to init. Commit addresses this issue by
calling EVP_CIPHER_CTX_new() instead of EVP_CIPHER_CTX_init(), which is
deprecated, and by checking return value of call to former function.
2017-03-26 15:15:30 +02:00
Alexander Amelkin
ba01dc84b4 Make git revision more descriptive
The previously introduced mechanism of generating
a git revision was only using the abbreviated hash.
That approach doesn't give a clue whether version
1.8.18.2c99bf6 is newer or older than 1.8.18.7f8d374.

The project uses tags, so `git describe` can be
employed to produce an incremental revision number
since the last tag. Version 1.8.18.13 is much more
understandable and comparable. Howerver that doesn't
answer the question "what codebase was used". To
address that, the abbreviated hash should also be
preserved. Hence, this commit introduces a new
versioning scheme like `1.8.18.13.gee01aa5`.

For git snapshots when git program is absent the
version will be like `1.8.18.0.gsnapshot`.

For cases when .git directory is missing (Release
compilation?) the suffix part will be omitted
completely yielding a version like `1.8.18`.

The suffix generation has been moved to the added
csv-revision script. The script is absolutely
POSIX-ly correct and doesn't require XSI or any
other POSIX extensions.
2017-03-19 18:55:11 +01:00
Alexander Amelkin
497f7767cd ID:477 - fru: Fix decoding of non-text data in get_fru_area_str()
The get_fru_area_str() function is used to decode FRU area
fields into text. Areas may be encoded as text, binary,
BCDplus or 6-bit ASCII. Decoding of 6-bit ASCII and BCDplus
was broken. There was an error in the formulas used to
calculate the resulting string length, plus the decoding
formulas for BCDplus was wrong.

For BCDplus the resulting length was considered equal
the encoded data length, while in fact it's twice as big.
Only one character instead of two was being extracted from
a single input byte while two nibbles must have been taken
into account.

For 6-bit ASCII rounding of 3 to 4 bytes conversion was done
improperly adding 2 to the original length instead of the
result of multiplication.
2017-02-08 11:46:04 +03:00
Alexander Amelkin
7b0302cef5 ID:479 - ekanalyzer: fix processing of custom mfg. fields
Ekanalyzer was not reading the type/length byte for the 2nd and
subsequent custom fields. Also the message it displayed when
lacked data for custom fields was very relaxing and incorrect.
2017-02-08 11:45:59 +03:00
Alexander Amelkin
840f573083 ID:478 - ekanalyzer: Fixed decoding of FRU fields
Got rid of the field decoding code that was only capable of
processing ASCII and binary fields, and switched to using
get_fru_area_str() that can also decode BCDplus and 6-bit ASCII
and maybe will eventually be enabled to decode Unicode text
as well.

This is the first step to completely get rid of the completely
awfully written FRU data decoding functionality of ekanalyzer
that essentially duplicates that of ipmi_fru.c module.
2017-02-02 16:02:57 +03:00
Alexander Amelkin
41fa699ae9 Add some more configure/build/editor byproducts to .gitignore 2017-02-02 15:43:12 +03:00
Alexander Amelkin
b35a634908 Add git hash and dirty mark to ipmitool version
Replace the static 'csv' suffix with a short hash
and a 'dirty' mark (when the tree is modified).

When git is not available, '.git_snapshot' suffix
will be used.
2017-02-02 15:42:36 +03:00
Alexander Amelkin
bc7d23761d Prevent autoreconf from complaining about missing NEWS 2017-01-31 00:22:40 +03:00
Sergey Kleymenov
e45dc6234b Add bootstrap support for Mac 2017-01-31 00:22:40 +03:00
Leonid Nevecherya
5db314f694 ID:474 - Compile fix on nonlinux systems
This patch fixes compilation on systems without a separate <malloc.h>.
2017-01-21 16:50:52 +01:00
Zdenek Styblik
77fe563503 ID:461 - Make compiler happier about changes related to OpenSSL 1.1
Complaint was that ctx isn't initialized.
2017-01-15 15:11:25 +01:00
Zdenek Styblik
7b102293e8 Merge commit 'b57487e360916ab3eaa50aa6d021c73b6337a4a0' 2017-01-15 15:01:38 +01:00