attempt to fix bridged commands over lan interfaces

This commit is contained in:
Duncan Laurie 2006-01-26 21:38:11 +00:00
parent 6f3e247274
commit e21475c78d
2 changed files with 79 additions and 119 deletions

View File

@ -403,11 +403,7 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
uint8_t ourAddress = intf->my_addr; uint8_t ourAddress = intf->my_addr;
if (ourAddress == 0) if (ourAddress == 0)
{
ourAddress = IPMI_BMC_SLAVE_ADDR; ourAddress = IPMI_BMC_SLAVE_ADDR;
}
rsp = ipmi_lan_recv_packet(intf); rsp = ipmi_lan_recv_packet(intf);
@ -486,25 +482,15 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
rsp->payload.ipmi_response.cmd); rsp->payload.ipmi_response.cmd);
if (entry) { if (entry) {
lprintf(LOG_DEBUG+2, "IPMI Request Match found"); lprintf(LOG_DEBUG+2, "IPMI Request Match found");
if ( if ((intf->target_addr != ourAddress) && bridgePossible) {
(intf->target_addr != ourAddress) && if ((rsp->data_len) &&
(bridgePossible) (rsp->payload.ipmi_response.cmd != 0x34)) {
) printbuf(&rsp->data[x], rsp->data_len-x,
{
if(
(rsp->data_len) &&
(rsp->payload.ipmi_response.cmd != 0x34)
)
{
printbuf(
&rsp->data[x],
(rsp->data_len-x),
"bridge command response"); "bridge command response");
} }
/* bridged command: lose extra header */ /* bridged command: lose extra header */
if (rsp->payload.ipmi_response.cmd == 0x34) { if (rsp->payload.ipmi_response.cmd == 0x34) {
if( rsp->data_len == 38 ) if (rsp->data_len == 38) {
{
entry->req.msg.cmd = entry->req.msg.target_cmd; entry->req.msg.cmd = entry->req.msg.target_cmd;
rsp = ipmi_lan_recv_packet(intf); rsp = ipmi_lan_recv_packet(intf);
continue; continue;
@ -586,9 +572,7 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
uint8_t bridgedRequest = 0; uint8_t bridgedRequest = 0;
if (ourAddress == 0) if (ourAddress == 0)
{
ourAddress = IPMI_BMC_SLAVE_ADDR; ourAddress = IPMI_BMC_SLAVE_ADDR;
}
if (curr_seq >= 64) if (curr_seq >= 64)
curr_seq = 0; curr_seq = 0;
@ -629,22 +613,15 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
} }
/* message length */ /* message length */
if ( if ((intf->target_addr == ourAddress) || !bridgePossible) {
(intf->target_addr == ourAddress) ||
(!bridgePossible)
)
{
msg[len++] = req->msg.data_len + 7; msg[len++] = req->msg.data_len + 7;
cs = mp = len; cs = mp = len;
} } else {
else
{
/* bridged request: encapsulate w/in Send Message */ /* bridged request: encapsulate w/in Send Message */
bridgedRequest = 1; bridgedRequest = 1;
msg[len++] = req->msg.data_len + 15; msg[len++] = req->msg.data_len + 15;
cs = mp = len; cs = mp = 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);
@ -660,15 +637,16 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
/* ipmi message header */ /* ipmi message header */
msg[len++] = intf->target_addr; msg[len++] = intf->target_addr;
msg[len++] = req->msg.netfn << 2; msg[len++] = req->msg.netfn << 2 | (req->msg.lun & 3);
tmp = len - cs; tmp = len - cs;
msg[len++] = ipmi_csum(msg+cs, tmp); msg[len++] = ipmi_csum(msg+cs, tmp);
cs = len; cs = len;
if (!bridgedRequest) if (!bridgedRequest)
msg[len++] = IPMI_REMOTE_SWID; msg[len++] = IPMI_REMOTE_SWID;
else /* Bridged message */ else /* Bridged message */
msg[len++] = intf->my_addr; msg[len++] = intf->my_addr;
entry->rq_seq = curr_seq++; entry->rq_seq = curr_seq++;
msg[len++] = entry->rq_seq << 2; msg[len++] = entry->rq_seq << 2;
msg[len++] = req->msg.cmd; msg[len++] = req->msg.cmd;
@ -698,13 +676,11 @@ ipmi_lan_build_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
msg[len++] = ipmi_csum(msg+cs, tmp); msg[len++] = ipmi_csum(msg+cs, tmp);
/* bridged request: 2nd checksum */ /* 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);
} }
if (s->active) { if (s->active) {
/* /*
* s->authcode is already copied to msg+ap but some * s->authcode is already copied to msg+ap but some

View File

@ -1334,37 +1334,24 @@ void getIpmiPayloadWireRep(
uint8_t rq_seq, uint8_t rq_seq,
uint8_t curr_seq) uint8_t curr_seq)
{ {
int cs, /*mp,*/ tmp, len; int cs, tmp, len;
int cs2 = 0; int cs2 = 0;
uint8_t ourAddress = intf->my_addr; uint8_t ourAddress = intf->my_addr;
uint8_t bridgedRequest = 0; uint8_t bridgedRequest = 0;
if (ourAddress == 0) if (ourAddress == 0)
{
ourAddress = IPMI_BMC_SLAVE_ADDR; ourAddress = IPMI_BMC_SLAVE_ADDR;
}
len = 0; len = 0;
/* IPMI Message Header -- Figure 13-4 of the IPMI v2.0 spec */ /* IPMI Message Header -- Figure 13-4 of the IPMI v2.0 spec */
if ( if ((intf->target_addr == ourAddress) || (!bridgePossible))
(intf->target_addr == ourAddress) ||
(!bridgePossible)
)
{
cs = len; cs = len;
} else {
else
{
/* bridged request: encapsulate w/in Send Message */ /* bridged request: encapsulate w/in Send Message */
bridgedRequest = 1; bridgedRequest = 1;
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);
@ -1387,7 +1374,7 @@ void getIpmiPayloadWireRep(
msg[len++] = intf->target_addr; /* IPMI_BMC_SLAVE_ADDR; */ msg[len++] = intf->target_addr; /* IPMI_BMC_SLAVE_ADDR; */
/* net Fn */ /* net Fn */
msg[len++] = req->msg.netfn << 2; msg[len++] = req->msg.netfn << 2 | (req->msg.lun & 3);
tmp = len - cs; tmp = len - cs;
/* checkSum */ /* checkSum */
@ -1408,9 +1395,7 @@ void getIpmiPayloadWireRep(
/* message data */ /* message data */
if (req->msg.data_len) { if (req->msg.data_len) {
memcpy(msg + len, memcpy(msg + len, req->msg.data, req->msg.data_len);
req->msg.data,
req->msg.data_len);
len += req->msg.data_len; len += req->msg.data_len;
} }
@ -1419,8 +1404,7 @@ void getIpmiPayloadWireRep(
msg[len++] = ipmi_csum(msg+cs, tmp); msg[len++] = ipmi_csum(msg+cs, tmp);
/* bridged request: 2nd checksum */ /* 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);
payload->payload_length += 1; payload->payload_length += 1;