]>
git.zerfleddert.de Git - rsbs2/blob - bmc/ipmb.c
7d272fbc994bb29f89d0196f8d2701e6c3154ae5
5 uint8_t ipmb_csum(unsigned char *buf
, int len
)
10 for(i
= 0; i
< len
; i
++) {
17 void decode_ipmb_pkt(unsigned char *buf
, int len
)
23 req
.netFn
= (buf
[1]>>2)&0x3f;
24 req
.rsLUN
= (buf
[1] & 0x03);
26 req
.rqSEQ
= (buf
[4]>>2)&0x3f;
27 req
.rqLUN
= (buf
[4] & 0x03);
30 req
.datalen
= len
- 6 - 1;
32 printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
33 printf("Connection Header:\n");
34 printf("\trs Slave Addr.: 0x%02x\n", req
.rsSA
);
35 printf("\tnetFn: 0x%02x, LUN: 0x%02x\n", req
.netFn
, req
.rsLUN
);
36 printf("\tChecksum: 0x%02x (%s)\n", buf
[2],
37 (buf
[2] == ipmb_csum(buf
, 2)) ? "OK" : "Wrong");
39 printf("\trq Slave Addr.: 0x%02x\n", req
.rqSA
);
40 printf("\trqSeq: 0x%02x, rqLUN: 0x%02x\n", req
.rqSEQ
, req
.rqLUN
);
41 printf("\tcmd: 0x%02x\n", req
.cmd
);
43 for(i
= 0; i
< req
.datalen
; i
++) {
44 printf("0x%02x ", req
.data
[i
]);
47 printf("\tChecksum: 0x%02x (%s)\n", buf
[len
-1],
48 (buf
[len
-1] == ipmb_csum(buf
+3, len
-4)) ? "OK" : "Wrong");
49 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
51 if ((buf
[2] != ipmb_csum(buf
, 2)) ||
52 (buf
[len
-1] == ipmb_csum(buf
+3, len
-4)))
53 return; /* Checksum wrong */
55 //i2c_send((unsigned char*)"\x28\x00",1);