mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-12 03:27:24 +00:00
Unfinished: Attempt to fix endianness for interfaces
This is a work in progress. This branch will be force-pushed a lot. Don't use it. This is just for saving the work as I move between workstations. Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
parent
a4c1040420
commit
6bed638c24
@ -241,6 +241,15 @@ struct ipmi_intf {
|
||||
void (*set_max_response_data_size)(struct ipmi_intf * intf, uint16_t size);
|
||||
};
|
||||
|
||||
/* Interface method wrappers to perform any host-specific actions */
|
||||
struct ipmi_rs *ipmi_sendrecv(struct ipmi_intf * intf, struct ipmi_rq * req);
|
||||
struct ipmi_rs *ipmi_recv_sol(struct ipmi_intf * intf);
|
||||
struct ipmi_rs *ipmi_send_sol(struct ipmi_intf * intf, struct ipmi_v2_payload * payload);
|
||||
int ipmi_keepalive(struct ipmi_intf * intf);
|
||||
int ipmi_set_my_addr(struct ipmi_intf * intf, uint8_t addr);
|
||||
void ipmi_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size);
|
||||
void ipmi_set_max_response_data_size(struct ipmi_intf * intf, uint16_t size);
|
||||
|
||||
struct ipmi_intf * ipmi_intf_load(char * name);
|
||||
void ipmi_intf_print(struct ipmi_intf_support * intflist);
|
||||
|
||||
|
@ -132,6 +132,12 @@ main(int argc, char ** argv)
|
||||
{
|
||||
int rc;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
printf("BIG ENDIAN\n");
|
||||
#else
|
||||
printf("LITTLE ENDIAN\n");
|
||||
#endif
|
||||
|
||||
rc = ipmi_main(argc, argv, ipmitool_cmd_list, NULL);
|
||||
|
||||
if (rc < 0)
|
||||
|
@ -623,3 +623,53 @@ ipmi_intf_set_max_response_data_size(struct ipmi_intf * intf, uint16_t size)
|
||||
intf->max_response_data_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Interface method wrappers.
|
||||
* Do any host-specific things like byteswapping here.
|
||||
* Command-specific data manipulation is not done here,
|
||||
* only the common headers are mangled.
|
||||
*/
|
||||
struct ipmi_rs *ipmi_sendrecv(struct ipmi_intf * intf, struct ipmi_rq * req)
|
||||
{
|
||||
struct ipmi_rs *rsp;
|
||||
|
||||
/* Data length must be in IPMI order (LE) */
|
||||
htoipmi16(req->msg.data_len, &req->msg.data_len);
|
||||
rsp = intf->sendrecv(intf, req);
|
||||
if (rsp) {
|
||||
rsp->data_len = ipmi16toh(&rsp->data_len);
|
||||
}
|
||||
|
||||
return rsp;
|
||||
}
|
||||
|
||||
struct ipmi_rs *ipmi_recv_sol(struct ipmi_intf * intf)
|
||||
{
|
||||
return intf->recv_sol(intf);
|
||||
}
|
||||
|
||||
struct ipmi_rs *ipmi_send_sol(struct ipmi_intf * intf, struct ipmi_v2_payload * payload)
|
||||
{
|
||||
return intf->send_sol(intf, payload);
|
||||
}
|
||||
|
||||
int ipmi_keepalive(struct ipmi_intf * intf)
|
||||
{
|
||||
return intf->keepalive(intf);
|
||||
}
|
||||
|
||||
int ipmi_set_my_addr(struct ipmi_intf * intf, uint8_t addr)
|
||||
{
|
||||
return intf->set_my_addr(intf, addr);
|
||||
}
|
||||
|
||||
void ipmi_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size)
|
||||
{
|
||||
intf->set_max_request_data_size(intf, size);
|
||||
}
|
||||
|
||||
void ipmi_set_max_response_data_size(struct ipmi_intf * intf, uint16_t size)
|
||||
{
|
||||
intf->set_max_response_data_size(intf, size);
|
||||
}
|
||||
|
@ -923,27 +923,19 @@ read_open_session_response(struct ipmi_rs * rsp, int offset)
|
||||
/*** offset + 3 is reserved ***/
|
||||
|
||||
/* Remote console session ID */
|
||||
memcpy(&(rsp->payload.open_session_response.console_id),
|
||||
rsp->data + offset + 4,
|
||||
4);
|
||||
#if WORDS_BIGENDIAN
|
||||
rsp->payload.open_session_response.console_id =
|
||||
BSWAP_32(rsp->payload.open_session_response.console_id);
|
||||
#endif
|
||||
rsp->payload.open_session_response.console_id
|
||||
= ipmi32toh(&rsp->data[offset + 4]);
|
||||
|
||||
/* only tag, status, privlvl, and console id are returned if error */
|
||||
if (rsp->payload.open_session_response.rakp_return_code !=
|
||||
IPMI_RAKP_STATUS_NO_ERRORS)
|
||||
if (rsp->payload.open_session_response.rakp_return_code
|
||||
!= IPMI_RAKP_STATUS_NO_ERRORS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* BMC session ID */
|
||||
memcpy(&(rsp->payload.open_session_response.bmc_id),
|
||||
rsp->data + offset + 8,
|
||||
4);
|
||||
#if WORDS_BIGENDIAN
|
||||
rsp->payload.open_session_response.bmc_id =
|
||||
BSWAP_32(rsp->payload.open_session_response.bmc_id);
|
||||
#endif
|
||||
rsp->payload.open_session_response.bmc_id
|
||||
= ipmi32toh(&rsp->data[offset + 8]);
|
||||
|
||||
/* And of course, our negotiated algorithms */
|
||||
rsp->payload.open_session_response.auth_alg = rsp->data[offset + 16];
|
||||
@ -1007,16 +999,16 @@ read_rakp2_message(
|
||||
case IPMI_AUTH_RAKP_HMAC_SHA1:
|
||||
/* We need to copy 20 bytes */
|
||||
for (i = 0; i < IPMI_SHA_DIGEST_LENGTH; ++i) {
|
||||
rsp->payload.rakp2_message.key_exchange_auth_code[i] =
|
||||
rsp->data[offset + 40 + i];
|
||||
rsp->payload.rakp2_message.key_exchange_auth_code[i]
|
||||
= rsp->data[offset + 40 + i];
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMI_AUTH_RAKP_HMAC_MD5:
|
||||
/* We need to copy 16 bytes */
|
||||
for (i = 0; i < IPMI_MD5_DIGEST_LENGTH; ++i) {
|
||||
rsp->payload.rakp2_message.key_exchange_auth_code[i] =
|
||||
rsp->data[offset + 40 + i];
|
||||
rsp->payload.rakp2_message.key_exchange_auth_code[i]
|
||||
= rsp->data[offset + 40 + i];
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1024,14 +1016,15 @@ read_rakp2_message(
|
||||
case IPMI_AUTH_RAKP_HMAC_SHA256:
|
||||
/* We need to copy 32 bytes */
|
||||
for (i = 0; i < IPMI_SHA256_DIGEST_LENGTH; ++i) {
|
||||
rsp->payload.rakp2_message.key_exchange_auth_code[i] =
|
||||
rsp->data[offset + 40 + i];
|
||||
rsp->payload.rakp2_message.key_exchange_auth_code[i]
|
||||
= rsp->data[offset + 40 + i];
|
||||
}
|
||||
break;
|
||||
#endif /* HAVE_CRYPTO_SHA256 */
|
||||
|
||||
default:
|
||||
lprintf(LOG_ERR, "read_rakp2_message: no support "
|
||||
lprintf(LOG_ERR,
|
||||
"read_rakp2_message: no support "
|
||||
"for authentication algorithm 0x%x", auth_alg);
|
||||
assert(0);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user