A few places where we print out the response buffer from an IPMI command
weren't updated when log timestamps were added, resulting in very hard
to read output. Add a little helper to format buffers and use it to
print these with only one timestamp.
Example:
[04:59:01] ipmi_get_bmc_versions: BMC version resp [0][16]:
0x00 0x20 0x01 0x02 0x13 0x02 0xbf 0x00
0x00 0x00 0xbb 0xaa 0x58 0x98 0x01 0x00
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
uint16_t resp_len = 8;
uint8_t resp[8];
uint8_t req[] = { 0x1, 0x5, 0x0, 0x0 };
uint16_t resp_len = 8;
uint8_t resp[8];
uint8_t req[] = { 0x1, 0x5, 0x0, 0x0 };
int i, rc;
rc = ipmi_transaction(ipmi, IPMI_NETFN_TRANSPORT,
int i, rc;
rc = ipmi_transaction(ipmi, IPMI_NETFN_TRANSPORT,
resp, &resp_len,
ipmi_timeout);
resp, &resp_len,
ipmi_timeout);
- pb_debug_fn("BMC MAC resp [%d][%d]:\n", rc, resp_len);
+ debug_buf = format_buffer(ipmi, resp, resp_len);
+ pb_debug_fn("BMC MAC resp [%d][%d]:\n%s\n",
+ rc, resp_len, debug_buf);
+ talloc_free(debug_buf);
if (rc == 0 && resp_len > 0) {
for (i = 2; i < resp_len; i++) {
if (rc == 0 && resp_len > 0) {
for (i = 2; i < resp_len; i++) {
- pb_debug(" %x", resp[i]);
{
uint16_t resp_len = 16;
uint8_t resp[16], bcd;
{
uint16_t resp_len = 16;
uint8_t resp[16], bcd;
+ char *debug_buf;
+ int rc;
/* Retrieve info from current side */
rc = ipmi_transaction(ipmi, IPMI_NETFN_APP,
/* Retrieve info from current side */
rc = ipmi_transaction(ipmi, IPMI_NETFN_APP,
resp, &resp_len,
ipmi_timeout);
resp, &resp_len,
ipmi_timeout);
- pb_debug_fn("BMC version resp [%d][%d]:\n", rc, resp_len);
- if (resp_len > 0) {
- for (i = 0; i < resp_len; i++) {
- pb_debug(" %x", resp[i]);
- }
- pb_debug("\n");
- }
+ debug_buf = format_buffer(ipmi, resp, resp_len);
+ pb_debug_fn("BMC version resp [%d][%d]:\n%s\n",
+ rc, resp_len, debug_buf);
+ talloc_free(debug_buf);
if (rc == 0 && (resp_len == 12 || resp_len == 16)) {
info->bmc_current = talloc_array(info, char *, 4);
if (rc == 0 && (resp_len == 12 || resp_len == 16)) {
info->bmc_current = talloc_array(info, char *, 4);
resp, &resp_len,
ipmi_timeout);
resp, &resp_len,
ipmi_timeout);
- pb_debug_fn("BMC golden resp [%d][%d]:\n", rc, resp_len);
- if (resp_len > 0) {
- for (i = 0; i < resp_len; i++) {
- pb_debug(" %x", resp[i]);
- }
- pb_debug("\n");
- }
+ debug_buf = format_buffer(ipmi, resp, resp_len);
+ pb_debug_fn("BMC golden resp [%d][%d]:\n%s\n",
+ rc, resp_len, debug_buf);
+ talloc_free(debug_buf);
if (rc == 0 && (resp_len == 12 || resp_len == 16)) {
info->bmc_golden = talloc_array(info, char *, 4);
if (rc == 0 && (resp_len == 12 || resp_len == 16)) {
info->bmc_golden = talloc_array(info, char *, 4);
{
uint16_t resp_len;
uint8_t resp[8];
{
uint16_t resp_len;
uint8_t resp[8];
int rc;
uint8_t req[] = {
0x05, /* parameter selector: boot flags */
int rc;
uint8_t req[] = {
0x05, /* parameter selector: boot flags */
- pb_debug("IPMI get_bootdev response:\n");
- for (int i = 0; i < resp_len; i++)
- pb_debug("%x ", resp[i]);
- pb_debug("\n");
+ debug_buf = format_buffer(platform, resp, resp_len);
+ pb_debug_fn("IPMI get_bootdev response:\n%s\n", debug_buf);
+ talloc_free(debug_buf);
if (resp[0] != 0) {
pb_log("platform: non-zero completion code %d from IPMI req\n",
if (resp[0] != 0) {
pb_log("platform: non-zero completion code %d from IPMI req\n",
uint16_t min_len = 12, resp_len = 53, version;
const uint32_t magic_value = 0x21706221;
uint8_t resp[resp_len];
uint16_t min_len = 12, resp_len = 53, version;
const uint32_t magic_value = 0x21706221;
uint8_t resp[resp_len];
uint32_t cookie;
bool persistent;
int i, rc;
uint32_t cookie;
bool persistent;
int i, rc;
resp, &resp_len,
ipmi_timeout);
resp, &resp_len,
ipmi_timeout);
- pb_debug("IPMI net override resp [%d][%d]:\n", rc, resp_len);
- if (resp_len > 0) {
- for (i = 0; i < resp_len; i++) {
- pb_debug(" %02x", resp[i]);
- if (i && (i + 1) % 16 == 0 && i != resp_len - 1)
- pb_debug("\n");
- else if (i && (i + 1) % 8 == 0)
- pb_debug(" ");
- }
- pb_debug("\n");
- }
+ debug_buf = format_buffer(platform, resp, resp_len);
+ pb_debug_fn("IPMI net override response:\n%s\n", debug_buf);
+ talloc_free(debug_buf);
if (rc) {
pb_debug("IPMI network config option unavailable\n");
if (rc) {
pb_debug("IPMI network config option unavailable\n");
#include <assert.h>
#include <util/util.h>
#include <assert.h>
#include <util/util.h>
+#include <talloc/talloc.h>
static const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f', };
static const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f', };
+
+char *format_buffer(void *ctx, const uint8_t *buf, unsigned int len)
+{
+ char *str;
+ unsigned int i;
+
+ if (len == 0)
+ return "";
+
+ str = talloc_asprintf(ctx, "0x%02x%s", buf[0], len > 1 ? " " : "");
+ for (i = 1; i < len; i++)
+ str = talloc_asprintf_append(str, "0x%02x%s", buf[i],
+ ((i + 1) % 8 == 0 && i != len - 1) ? "\n" : " ");
+
+ return str;
+}
do { (void)sizeof(char[(x)?1:-1]); } while (0)
void mac_str(uint8_t *mac, unsigned int maclen, char *buf, unsigned int buflen);
do { (void)sizeof(char[(x)?1:-1]); } while (0)
void mac_str(uint8_t *mac, unsigned int maclen, char *buf, unsigned int buflen);
+char *format_buffer(void *ctx, const uint8_t *buf, unsigned int len);