- Added dual bridge support

This commit is contained in:
Jean-Michel Audet 2007-04-26 13:45:00 +00:00
parent ed84ac0a9b
commit 80b8d3b318

View File

@ -84,14 +84,14 @@ static struct ipmi_rs * ipmi_lanplus_send_ipmi_cmd(struct ipmi_intf * intf, stru
static struct ipmi_rs * ipmi_lanplus_send_payload(struct ipmi_intf * intf, static struct ipmi_rs * ipmi_lanplus_send_payload(struct ipmi_intf * intf,
struct ipmi_v2_payload * payload); struct ipmi_v2_payload * payload);
static void getIpmiPayloadWireRep( static void getIpmiPayloadWireRep(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct ipmi_v2_payload * payload, /* in */ struct ipmi_v2_payload * payload, /* in */
uint8_t * out, uint8_t * out,
struct ipmi_rq * req, struct ipmi_rq * req,
uint8_t rq_seq, uint8_t rq_seq,
uint8_t curr_seq); uint8_t curr_seq);
static void getSolPayloadWireRep( static void getSolPayloadWireRep(
struct ipmi_intf * intf, struct ipmi_intf * intf,
uint8_t * msg, uint8_t * msg,
struct ipmi_v2_payload * payload); struct ipmi_v2_payload * payload);
static void read_open_session_response(struct ipmi_rs * rsp, int offset); static void read_open_session_response(struct ipmi_rs * rsp, int offset);
@ -110,8 +110,8 @@ static int check_sol_packet_for_new_data(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct ipmi_rs *rsp); struct ipmi_rs *rsp);
static void ack_sol_packet( static void ack_sol_packet(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct ipmi_rs * rsp); struct ipmi_rs * rsp);
static uint8_t bridgePossible = 0; static uint8_t bridgePossible = 0;
@ -246,7 +246,7 @@ int lanplus_get_requested_ciphers(int cipher_suite_id,
*/ */
void lanplus_swap( void lanplus_swap(
uint8_t * buffer, uint8_t * buffer,
int length) int length)
{ {
int i; int i;
uint8_t temp; uint8_t temp;
@ -262,16 +262,16 @@ void lanplus_swap(
static const struct valstr plus_payload_types_vals[] = { static const struct valstr plus_payload_types_vals[] = {
{ IPMI_PAYLOAD_TYPE_IPMI, "IPMI (0)" }, // IPMI Message { IPMI_PAYLOAD_TYPE_IPMI, "IPMI (0)" }, // IPMI Message
{ IPMI_PAYLOAD_TYPE_SOL, "SOL (1)" }, // SOL (Serial over LAN) { IPMI_PAYLOAD_TYPE_SOL, "SOL (1)" }, // SOL (Serial over LAN)
{ IPMI_PAYLOAD_TYPE_OEM, "OEM (2)" }, // OEM Explicid { IPMI_PAYLOAD_TYPE_OEM, "OEM (2)" }, // OEM Explicid
{ IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST, "OpenSession Req (0x10)" }, { IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST, "OpenSession Req (0x10)" },
{ IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE,"OpenSession Resp (0x11)" }, { IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE,"OpenSession Resp (0x11)" },
{ IPMI_PAYLOAD_TYPE_RAKP_1, "RAKP1 (0x12)" }, { IPMI_PAYLOAD_TYPE_RAKP_1, "RAKP1 (0x12)" },
{ IPMI_PAYLOAD_TYPE_RAKP_2, "RAKP2 (0x13)" }, { IPMI_PAYLOAD_TYPE_RAKP_2, "RAKP2 (0x13)" },
{ IPMI_PAYLOAD_TYPE_RAKP_3, "RAKP3 (0x14)" }, { IPMI_PAYLOAD_TYPE_RAKP_3, "RAKP3 (0x14)" },
{ IPMI_PAYLOAD_TYPE_RAKP_4, "RAKP4 (0x15)" }, { IPMI_PAYLOAD_TYPE_RAKP_4, "RAKP4 (0x15)" },
{ 0x00, NULL }, { 0x00, NULL },
}; };
@ -496,18 +496,18 @@ ipmi_handle_pong(struct ipmi_intf * intf, struct ipmi_rs * rsp)
if (verbose) if (verbose)
printf("Received IPMI/RMCP response packet: " printf("Received IPMI/RMCP response packet: "
"IPMI%s Supported\n", "IPMI%s Supported\n",
(pong->sup_entities & 0x80) ? "" : " NOT"); (pong->sup_entities & 0x80) ? "" : " NOT");
if (verbose > 1) if (verbose > 1)
printf(" ASF Version %s\n" printf(" ASF Version %s\n"
" RMCP Version %s\n" " RMCP Version %s\n"
" RMCP Sequence %d\n" " RMCP Sequence %d\n"
" IANA Enterprise %lu\n\n", " IANA Enterprise %lu\n\n",
(pong->sup_entities & 0x01) ? "1.0" : "unknown", (pong->sup_entities & 0x01) ? "1.0" : "unknown",
(pong->rmcp.ver == 6) ? "1.0" : "unknown", (pong->rmcp.ver == 6) ? "1.0" : "unknown",
pong->rmcp.seq, pong->rmcp.seq,
(unsigned long)ntohl(pong->iana)); (unsigned long)ntohl(pong->iana));
return (pong->sup_entities & 0x80) ? 1 : 0; return (pong->sup_entities & 0x80) ? 1 : 0;
} }
@ -655,8 +655,8 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
} }
if ((session->v2_data.session_state == LANPLUS_STATE_ACTIVE) && if ((session->v2_data.session_state == LANPLUS_STATE_ACTIVE) &&
(rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) &&
(rsp->session.bEncrypted)) (rsp->session.bEncrypted))
{ {
lanplus_decrypt_payload(session->v2_data.crypt_alg, lanplus_decrypt_payload(session->v2_data.crypt_alg,
@ -711,13 +711,13 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
/* Are we expecting this packet? */ /* Are we expecting this packet? */
entry = ipmi_req_lookup_entry(rsp->payload.ipmi_response.rq_seq, entry = ipmi_req_lookup_entry(rsp->payload.ipmi_response.rq_seq,
rsp->payload.ipmi_response.cmd); rsp->payload.ipmi_response.cmd);
if (entry != NULL) { if (entry != NULL) {
lprintf(LOG_DEBUG+2, "IPMI Request Match found"); lprintf(LOG_DEBUG+2, "IPMI Request Match found");
if (intf->target_addr != ourAddress && if (intf->target_addr != ourAddress &&
bridgePossible) { bridgePossible) {
if (rsp->data_len && if (rsp->data_len &&
rsp->payload.ipmi_response.cmd != 0x34) { rsp->payload.ipmi_response.cmd != 0x34) {
printbuf( printbuf(
&rsp->data[offset], &rsp->data[offset],
(rsp->data_len-offset), (rsp->data_len-offset),
@ -739,7 +739,7 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
} }
} }
ipmi_req_remove_entry(rsp->payload.ipmi_response.rq_seq, ipmi_req_remove_entry(rsp->payload.ipmi_response.rq_seq,
rsp->payload.ipmi_response.cmd); rsp->payload.ipmi_response.cmd);
} else { } else {
lprintf(LOG_INFO, "IPMI Request Match NOT FOUND"); lprintf(LOG_INFO, "IPMI Request Match NOT FOUND");
rsp = ipmi_lan_recv_packet(intf); rsp = ipmi_lan_recv_packet(intf);
@ -767,11 +767,11 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
/* /*
* Open Response * Open Response
*/ */
else if (rsp->session.payloadtype == else if (rsp->session.payloadtype ==
IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE) IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE)
{ {
if (session->v2_data.session_state != if (session->v2_data.session_state !=
LANPLUS_STATE_OPEN_SESSION_SENT) LANPLUS_STATE_OPEN_SESSION_SENT)
{ {
lprintf(LOG_ERR, "Error: Received an Unexpected Open Session " lprintf(LOG_ERR, "Error: Received an Unexpected Open Session "
"Response"); "Response");
@ -787,7 +787,7 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
/* /*
* RAKP 2 * RAKP 2
*/ */
else if (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_RAKP_2) else if (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_RAKP_2)
{ {
if (session->v2_data.session_state != LANPLUS_STATE_RAKP_1_SENT) if (session->v2_data.session_state != LANPLUS_STATE_RAKP_1_SENT)
{ {
@ -804,7 +804,7 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
/* /*
* RAKP 4 * RAKP 4
*/ */
else if (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_RAKP_4) else if (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_RAKP_4)
{ {
if (session->v2_data.session_state != LANPLUS_STATE_RAKP_3_SENT) if (session->v2_data.session_state != LANPLUS_STATE_RAKP_3_SENT)
{ {
@ -821,7 +821,7 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
/* /*
* SOL * SOL
*/ */
else if (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) else if (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL)
{ {
int payload_start = offset; int payload_start = offset;
int extra_data_length; int extra_data_length;
@ -877,7 +877,7 @@ void
read_open_session_response(struct ipmi_rs * rsp, int offset) read_open_session_response(struct ipmi_rs * rsp, int offset)
{ {
memset(&rsp->payload.open_session_response, 0, memset(&rsp->payload.open_session_response, 0,
sizeof(rsp->payload.open_session_response)); sizeof(rsp->payload.open_session_response));
/* Message tag */ /* Message tag */
rsp->payload.open_session_response.message_tag = rsp->data[offset]; rsp->payload.open_session_response.message_tag = rsp->data[offset];
@ -901,7 +901,7 @@ read_open_session_response(struct ipmi_rs * rsp, int offset)
/* only tag, status, privlvl, and console id are returned if error */ /* only tag, status, privlvl, and console id are returned if error */
if (rsp->payload.open_session_response.rakp_return_code != if (rsp->payload.open_session_response.rakp_return_code !=
IPMI_RAKP_STATUS_NO_ERRORS) IPMI_RAKP_STATUS_NO_ERRORS)
return; return;
/* BMC session ID */ /* BMC session ID */
@ -940,9 +940,9 @@ read_open_session_response(struct ipmi_rs * rsp, int offset)
*/ */
void void
read_rakp2_message( read_rakp2_message(
struct ipmi_rs * rsp, struct ipmi_rs * rsp,
int offset, int offset,
uint8_t auth_alg) uint8_t auth_alg)
{ {
int i; int i;
@ -1021,9 +1021,9 @@ read_rakp2_message(
*/ */
void void
read_rakp4_message( read_rakp4_message(
struct ipmi_rs * rsp, struct ipmi_rs * rsp,
int offset, int offset,
uint8_t auth_alg) uint8_t auth_alg)
{ {
int i; int i;
@ -1187,9 +1187,9 @@ read_session_data_v2x(
* param s holds our session state * param s holds our session state
*/ */
void read_session_data_v15( void read_session_data_v15(
struct ipmi_rs * rsp, struct ipmi_rs * rsp,
int * offset, int * offset,
struct ipmi_session * s) struct ipmi_session * s)
{ {
/* All v15 messages are IPMI messages */ /* All v15 messages are IPMI messages */
rsp->session.payloadtype = IPMI_PAYLOAD_TYPE_IPMI; rsp->session.payloadtype = IPMI_PAYLOAD_TYPE_IPMI;
@ -1318,15 +1318,16 @@ void read_sol_packet(struct ipmi_rs * rsp, int * offset)
* param rq_seq [in] is the IPMI command sequence number. * param rq_seq [in] is the IPMI command sequence number.
*/ */
void getIpmiPayloadWireRep( void getIpmiPayloadWireRep(
struct ipmi_intf * intf, /* in out */ struct ipmi_intf * intf, /* in out */
struct ipmi_v2_payload * payload, /* in */ struct ipmi_v2_payload * payload, /* in */
uint8_t * msg, uint8_t * msg,
struct ipmi_rq * req, struct ipmi_rq * req,
uint8_t rq_seq, uint8_t rq_seq,
uint8_t curr_seq) uint8_t curr_seq)
{ {
int cs, tmp, len; int cs, tmp, len;
int cs2 = 0; int cs2 = 0;
int cs3 = 0;
uint8_t ourAddress = intf->my_addr; uint8_t ourAddress = intf->my_addr;
uint8_t bridgedRequest = 0; uint8_t bridgedRequest = 0;
@ -1339,26 +1340,54 @@ void getIpmiPayloadWireRep(
if ((intf->target_addr == ourAddress) || (!bridgePossible)) if ((intf->target_addr == ourAddress) || (!bridgePossible))
cs = len; cs = len;
else { else {
/* bridged request: encapsulate w/in Send Message */
bridgedRequest = 1; bridgedRequest = 1;
if(intf->transit_addr != ourAddress)
{
bridgedRequest++;
}
/* bridged request: encapsulate w/in Send Message */
cs = len; cs = len;
msg[len++] = IPMI_BMC_SLAVE_ADDR; msg[len++] = IPMI_BMC_SLAVE_ADDR;
msg[len++] = IPMI_NETFN_APP << 2; msg[len++] = IPMI_NETFN_APP << 2;
tmp = len - cs; tmp = len - cs;
msg[len++] = ipmi_csum(msg+cs, tmp); msg[len++] = ipmi_csum(msg+cs, tmp);
cs2 = len; cs2 = len;
msg[len++] = IPMI_REMOTE_SWID; msg[len++] = IPMI_REMOTE_SWID;
msg[len++] = curr_seq << 2; msg[len++] = curr_seq << 2;
msg[len++] = 0x34; /* Send Message rqst */ msg[len++] = 0x34; /* Send Message rqst */
#if 0 /* From lan.c example */ if(bridgedRequest == 2)
entry->req.msg.target_cmd = entry->req.msg.cmd; /* Save target command */ msg[len++] = (0x40|intf->transit_channel); /* Track request*/
entry->req.msg.cmd = 0x34; /* (fixup request entry) */ else
#endif msg[len++] = (0x40|intf->target_channel); /* Track request*/
msg[len++] = (0x40|intf->target_channel); /* Track request*/
payload->payload_length += 7; payload->payload_length += 7;
cs = len; cs = len;
if(bridgedRequest == 2)
{
/* bridged request: encapsulate w/in Send Message */
cs = len;
msg[len++] = intf->transit_addr;
msg[len++] = IPMI_NETFN_APP << 2;
tmp = len - cs;
msg[len++] = ipmi_csum(msg+cs, tmp);
cs3 = len;
msg[len++] = intf->my_addr;
msg[len++] = curr_seq << 2;
msg[len++] = 0x34; /* Send Message rqst */
#if 0 /* From lan.c example */
entry->req.msg.target_cmd = entry->req.msg.cmd; /* Save target command */
entry->req.msg.cmd = 0x34; /* (fixup request entry) */
#endif
msg[len++] = (0x40|intf->target_channel); /* Track request*/
payload->payload_length += 7;
cs = len;
}
} }
/* rsAddr */ /* rsAddr */
@ -1394,7 +1423,14 @@ void getIpmiPayloadWireRep(
tmp = len - cs; tmp = len - cs;
msg[len++] = ipmi_csum(msg+cs, tmp); msg[len++] = ipmi_csum(msg+cs, tmp);
/* bridged request: 2nd checksum */ /* Dual bridged request: 2nd checksum */
if (bridgedRequest == 2) {
tmp = len - cs3;
msg[len++] = ipmi_csum(msg+cs3, tmp);
payload->payload_length += 1;
}
/* bridged request: 2nd checksum */
if (bridgedRequest) { if (bridgedRequest) {
tmp = len - cs2; tmp = len - cs2;
msg[len++] = ipmi_csum(msg+cs2, tmp); msg[len++] = ipmi_csum(msg+cs2, tmp);
@ -1453,8 +1489,8 @@ void getSolPayloadWireRep(
/* We may have data to add */ /* We may have data to add */
memcpy(msg + i, memcpy(msg + i,
payload->payload.sol_packet.data, payload->payload.sol_packet.data,
payload->payload.sol_packet.character_count); payload->payload.sol_packet.character_count);
lprintf(LOG_DEBUG, "> SOL character count : %d", lprintf(LOG_DEBUG, "> SOL character count : %d",
payload->payload.sol_packet.character_count); payload->payload.sol_packet.character_count);
@ -1510,11 +1546,11 @@ void getSolPayloadWireRep(
*/ */
void void
ipmi_lanplus_build_v2x_msg( ipmi_lanplus_build_v2x_msg(
struct ipmi_intf * intf, /* in */ struct ipmi_intf * intf, /* in */
struct ipmi_v2_payload * payload, /* in */ struct ipmi_v2_payload * payload, /* in */
int * msg_len, /* out */ int * msg_len, /* out */
uint8_t ** msg_data, /* out */ uint8_t ** msg_data, /* out */
uint8_t curr_seq) uint8_t curr_seq)
{ {
uint32_t session_trailer_length = 0; uint32_t session_trailer_length = 0;
struct ipmi_session * session = intf->session; struct ipmi_session * session = intf->session;
@ -1609,11 +1645,11 @@ ipmi_lanplus_build_v2x_msg(
{ {
case IPMI_PAYLOAD_TYPE_IPMI: case IPMI_PAYLOAD_TYPE_IPMI:
getIpmiPayloadWireRep(intf, getIpmiPayloadWireRep(intf,
payload, /* in */ payload, /* in */
msg + IPMI_LANPLUS_OFFSET_PAYLOAD, msg + IPMI_LANPLUS_OFFSET_PAYLOAD,
payload->payload.ipmi_request.request, payload->payload.ipmi_request.request,
payload->payload.ipmi_request.rq_seq, payload->payload.ipmi_request.rq_seq,
curr_seq); curr_seq);
break; break;
case IPMI_PAYLOAD_TYPE_SOL: case IPMI_PAYLOAD_TYPE_SOL:
@ -1631,24 +1667,24 @@ ipmi_lanplus_build_v2x_msg(
case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST: case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST:
/* never encrypted, so our job is easy */ /* never encrypted, so our job is easy */
memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD, memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD,
payload->payload.open_session_request.request, payload->payload.open_session_request.request,
payload->payload_length); payload->payload_length);
len += payload->payload_length; len += payload->payload_length;
break; break;
case IPMI_PAYLOAD_TYPE_RAKP_1: case IPMI_PAYLOAD_TYPE_RAKP_1:
/* never encrypted, so our job is easy */ /* never encrypted, so our job is easy */
memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD, memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD,
payload->payload.rakp_1_message.message, payload->payload.rakp_1_message.message,
payload->payload_length); payload->payload_length);
len += payload->payload_length; len += payload->payload_length;
break; break;
case IPMI_PAYLOAD_TYPE_RAKP_3: case IPMI_PAYLOAD_TYPE_RAKP_3:
/* never encrypted, so our job is easy */ /* never encrypted, so our job is easy */
memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD, memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD,
payload->payload.rakp_3_message.message, payload->payload.rakp_3_message.message,
payload->payload_length); payload->payload_length);
len += payload->payload_length; len += payload->payload_length;
break; break;
@ -1804,7 +1840,7 @@ ipmi_lanplus_build_v2x_ipmi_cmd(
* know the sequence number when we generate our IPMI * know the sequence number when we generate our IPMI
* representation far below. * representation far below.
*/ */
static uint8_t curr_seq = 0; static uint8_t curr_seq = 0;
curr_seq += 1; curr_seq += 1;
@ -1822,10 +1858,10 @@ ipmi_lanplus_build_v2x_ipmi_cmd(
v2_payload.payload.ipmi_request.rq_seq = curr_seq; v2_payload.payload.ipmi_request.rq_seq = curr_seq;
ipmi_lanplus_build_v2x_msg(intf, // in ipmi_lanplus_build_v2x_msg(intf, // in
&v2_payload, // in &v2_payload, // in
&(entry->msg_len), // out &(entry->msg_len), // out
&(entry->msg_data), // out &(entry->msg_data), // out
curr_seq); // in curr_seq); // in
return entry; return entry;
} }
@ -2054,8 +2090,8 @@ ipmi_lanplus_send_payload(
* before we attempt to open a v2.x session. * before we attempt to open a v2.x session.
*/ */
if ((ipmi_request->msg.netfn == IPMI_NETFN_APP) && if ((ipmi_request->msg.netfn == IPMI_NETFN_APP) &&
(ipmi_request->msg.cmd == IPMI_GET_CHANNEL_AUTH_CAP) && (ipmi_request->msg.cmd == IPMI_GET_CHANNEL_AUTH_CAP) &&
(session->v2_data.bmc_id == 0)) // jme - check (session->v2_data.bmc_id == 0)) // jme - check
{ {
lprintf(LOG_DEBUG+1, "BUILDING A v1.5 COMMAND"); lprintf(LOG_DEBUG+1, "BUILDING A v1.5 COMMAND");
entry = ipmi_lanplus_build_v15_ipmi_cmd(intf, ipmi_request); entry = ipmi_lanplus_build_v15_ipmi_cmd(intf, ipmi_request);
@ -2081,10 +2117,10 @@ ipmi_lanplus_send_payload(
assert(session->v2_data.session_state == LANPLUS_STATE_PRESESSION); assert(session->v2_data.session_state == LANPLUS_STATE_PRESESSION);
ipmi_lanplus_build_v2x_msg(intf, /* in */ ipmi_lanplus_build_v2x_msg(intf, /* in */
payload, /* in */ payload, /* in */
&msg_length, /* out */ &msg_length, /* out */
&msg_data, /* out */ &msg_data, /* out */
0); /* irrelevant for this msg*/ 0); /* irrelevant for this msg*/
} }
@ -2092,13 +2128,13 @@ ipmi_lanplus_send_payload(
{ {
lprintf(LOG_DEBUG, ">> SENDING A RAKP 1 MESSAGE\n"); lprintf(LOG_DEBUG, ">> SENDING A RAKP 1 MESSAGE\n");
assert(session->v2_data.session_state == assert(session->v2_data.session_state ==
LANPLUS_STATE_OPEN_SESSION_RECEIEVED); LANPLUS_STATE_OPEN_SESSION_RECEIEVED);
ipmi_lanplus_build_v2x_msg(intf, /* in */ ipmi_lanplus_build_v2x_msg(intf, /* in */
payload, /* in */ payload, /* in */
&msg_length, /* out */ &msg_length, /* out */
&msg_data, /* out */ &msg_data, /* out */
0); /* irrelevant for this msg*/ 0); /* irrelevant for this msg*/
} }
@ -2106,13 +2142,13 @@ ipmi_lanplus_send_payload(
{ {
lprintf(LOG_DEBUG, ">> SENDING A RAKP 3 MESSAGE\n"); lprintf(LOG_DEBUG, ">> SENDING A RAKP 3 MESSAGE\n");
assert(session->v2_data.session_state == assert(session->v2_data.session_state ==
LANPLUS_STATE_RAKP_2_RECEIVED); LANPLUS_STATE_RAKP_2_RECEIVED);
ipmi_lanplus_build_v2x_msg(intf, /* in */ ipmi_lanplus_build_v2x_msg(intf, /* in */
payload, /* in */ payload, /* in */
&msg_length, /* out */ &msg_length, /* out */
&msg_data, /* out */ &msg_data, /* out */
0); /* irrelevant for this msg*/ 0); /* irrelevant for this msg*/
} }
@ -2122,10 +2158,10 @@ ipmi_lanplus_send_payload(
assert(session->v2_data.session_state == LANPLUS_STATE_ACTIVE); assert(session->v2_data.session_state == LANPLUS_STATE_ACTIVE);
ipmi_lanplus_build_v2x_msg(intf, /* in */ ipmi_lanplus_build_v2x_msg(intf, /* in */
payload, /* in */ payload, /* in */
&msg_length, /* out */ &msg_length, /* out */
&msg_data, /* out */ &msg_data, /* out */
0); /* irrelevant for this msg*/ 0); /* irrelevant for this msg*/
} }
else else
@ -2187,8 +2223,8 @@ ipmi_lanplus_send_payload(
* the BMC * the BMC
*/ */
intf->session->sol_data.sol_input_handler(rsp); intf->session->sol_data.sol_input_handler(rsp);
/* In order to avoid duplicate output, just set data_len to 0 */ /* In order to avoid duplicate output, just set data_len to 0 */
rsp->data_len = 0; rsp->data_len = 0;
} }
} }
@ -2240,9 +2276,9 @@ ipmi_lanplus_send_payload(
* 0 if this isn't an ACK or we don't need to resend anything * 0 if this isn't an ACK or we don't need to resend anything
*/ */
int is_sol_partial_ack( int is_sol_partial_ack(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct ipmi_v2_payload * v2_payload, struct ipmi_v2_payload * v2_payload,
struct ipmi_rs * rs) struct ipmi_rs * rs)
{ {
int chars_to_resend = 0; int chars_to_resend = 0;
@ -2254,7 +2290,7 @@ int is_sol_partial_ack(
v2_payload->payload.sol_packet.character_count)) v2_payload->payload.sol_packet.character_count))
{ {
if (ipmi_oem_active(intf, "intelplus") && if (ipmi_oem_active(intf, "intelplus") &&
rs->payload.sol_packet.accepted_character_count == 0) rs->payload.sol_packet.accepted_character_count == 0)
return 0; return 0;
chars_to_resend = chars_to_resend =
@ -2271,8 +2307,8 @@ int is_sol_partial_ack(
* set_sol_packet_sequence_number * set_sol_packet_sequence_number
*/ */
static void set_sol_packet_sequence_number( static void set_sol_packet_sequence_number(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct ipmi_v2_payload * v2_payload) struct ipmi_v2_payload * v2_payload)
{ {
/* Keep our sequence number sane */ /* Keep our sequence number sane */
if (intf->session->sol_data.sequence_number > 0x0F) if (intf->session->sol_data.sequence_number > 0x0F)
@ -2326,8 +2362,8 @@ ipmi_lanplus_send_sol(
chars_to_resend = is_sol_partial_ack(intf, v2_payload, rs); chars_to_resend = is_sol_partial_ack(intf, v2_payload, rs);
while (rs && !rs->payload.sol_packet.transfer_unavailable && while (rs && !rs->payload.sol_packet.transfer_unavailable &&
!rs->payload.sol_packet.is_nack && !rs->payload.sol_packet.is_nack &&
chars_to_resend) chars_to_resend)
{ {
/* /*
* We first need to handle any new data we might have * We first need to handle any new data we might have
@ -2436,8 +2472,8 @@ check_sol_packet_for_new_data(
*/ */
static void static void
ack_sol_packet( ack_sol_packet(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct ipmi_rs * rsp) struct ipmi_rs * rsp)
{ {
if (rsp && if (rsp &&
(rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) &&
@ -2503,8 +2539,8 @@ ipmi_lanplus_recv_sol(struct ipmi_intf * intf)
*/ */
struct ipmi_rs * struct ipmi_rs *
ipmi_lanplus_send_ipmi_cmd( ipmi_lanplus_send_ipmi_cmd(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct ipmi_rq * req) struct ipmi_rq * req)
{ {
struct ipmi_v2_payload v2_payload; struct ipmi_v2_payload v2_payload;
@ -2536,8 +2572,8 @@ ipmi_lanplus_send_ipmi_cmd(
*/ */
static int static int
ipmi_get_auth_capabilities_cmd( ipmi_get_auth_capabilities_cmd(
struct ipmi_intf * intf, struct ipmi_intf * intf,
struct get_channel_auth_cap_rsp * auth_cap) struct get_channel_auth_cap_rsp * auth_cap)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
@ -2581,8 +2617,8 @@ ipmi_get_auth_capabilities_cmd(
memcpy(auth_cap, memcpy(auth_cap,
rsp->data, rsp->data,
sizeof(struct get_channel_auth_cap_rsp)); sizeof(struct get_channel_auth_cap_rsp));
bridgePossible = backupBridgePossible; bridgePossible = backupBridgePossible;
@ -2766,7 +2802,7 @@ ipmi_lanplus_open_session(struct ipmi_intf * intf)
else else
{ {
if (rsp->payload.open_session_response.console_id != if (rsp->payload.open_session_response.console_id !=
session->v2_data.console_id) { session->v2_data.console_id) {
lprintf(LOG_WARNING, "Warning: Console session ID is not " lprintf(LOG_WARNING, "Warning: Console session ID is not "
"what we requested"); "what we requested");
} }
@ -2962,13 +2998,13 @@ ipmi_lanplus_rakp1(struct ipmi_intf * intf)
/* Error */ /* Error */
lprintf(LOG_INFO, "> RAKP 2 HMAC is invalid"); lprintf(LOG_INFO, "> RAKP 2 HMAC is invalid");
session->v2_data.rakp2_return_code = IPMI_RAKP_STATUS_INVALID_INTEGRITY_CHECK_VALUE; session->v2_data.rakp2_return_code = IPMI_RAKP_STATUS_INVALID_INTEGRITY_CHECK_VALUE;
rc = 1; rc = 1;
} }
else else
{ {
/* Success */ /* Success */
session->v2_data.rakp2_return_code = IPMI_RAKP_STATUS_NO_ERRORS; session->v2_data.rakp2_return_code = IPMI_RAKP_STATUS_NO_ERRORS;
} }
} }
return rc; return rc;
@ -3116,8 +3152,8 @@ ipmi_lanplus_rakp3(struct ipmi_intf * intf)
{ {
/* Validate the authcode */ /* Validate the authcode */
if (lanplus_rakp4_hmac_matches(session, if (lanplus_rakp4_hmac_matches(session,
rsp->payload.rakp4_message.integrity_check_value, rsp->payload.rakp4_message.integrity_check_value,
intf)) intf))
{ {
/* Success */ /* Success */
session->v2_data.session_state = LANPLUS_STATE_ACTIVE; session->v2_data.session_state = LANPLUS_STATE_ACTIVE;
@ -3414,8 +3450,8 @@ void test_crypt2(void)
{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14}; 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14};
uint8_t iv[] = uint8_t iv[] =
{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14}; 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14};
uint8_t data[8] = "12345678"; uint8_t data[8] = "12345678";
uint8_t encrypt_buffer[1000]; uint8_t encrypt_buffer[1000];
@ -3463,16 +3499,16 @@ ipmi_lanplus_keepalive(struct ipmi_intf * intf)
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
while (rsp != NULL && is_sol_packet(rsp)) { while (rsp != NULL && is_sol_packet(rsp)) {
/* rsp was SOL data instead of our answer */ /* rsp was SOL data instead of our answer */
/* since it didn't go through the sol recv, do sol recv stuff here */ /* since it didn't go through the sol recv, do sol recv stuff here */
ack_sol_packet(intf, rsp); ack_sol_packet(intf, rsp);
check_sol_packet_for_new_data(intf, rsp); check_sol_packet_for_new_data(intf, rsp);
if (rsp->data_len) if (rsp->data_len)
intf->session->sol_data.sol_input_handler(rsp); intf->session->sol_data.sol_input_handler(rsp);
rsp = ipmi_lan_poll_recv(intf); rsp = ipmi_lan_poll_recv(intf);
if (rsp == NULL) /* the get device id answer never got back, but retry mechanism was bypassed by SOL data */ if (rsp == NULL) /* the get device id answer never got back, but retry mechanism was bypassed by SOL data */
return 0; /* so get device id command never returned, the connection is still alive */ return 0; /* so get device id command never returned, the connection is still alive */
} }
if (rsp == NULL) if (rsp == NULL)
return -1; return -1;