+}
+#endif
+
+void ipmb_invalid(struct ipmb_resp *resp)
+{
+#if 0
+ static unsigned char cmd_invalid[] = {0xc2};
+
+ resp->data = cmd_invalid;
+ resp->datalen = sizeof(cmd_invalid);
+ ipmb_send(resp);
+#endif
+}
+
+void ipmb_cmd(struct ipmb_req *req)
+{
+ struct ipmb_resp resp;
+ static unsigned char get_devid[] =
+ {IPMB_CC_NORMALLY, 0x42, 0x42, 0x01, 0x01, 0x51, 0xff /* Add. Dev. Supp */, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ static unsigned char get_wd_timer[] =
+ {IPMB_CC_NORMALLY, 0x42, 0x00, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xfe};
+ static unsigned char cc_normal[] =
+ {IPMB_CC_NORMALLY};
+
+ resp.rqSA = req->rqSA;
+ resp.netFn = req->netFn+1;
+ resp.rqLUN = req->rqLUN;
+ resp.rsSA = req->rsSA;
+ resp.rqSEQ = req->rqSEQ;
+ resp.rsLUN = req->rsLUN;
+ resp.cmd = req->cmd;
+
+ switch (req->netFn) {
+ case IPMB_NETFN_CHASSIS:
+ switch (req->cmd) {
+ case IPMB_CHASSIS_CONTROL:
+ chassis_control(*(req->data));
+ resp.data = cc_normal;
+ resp.datalen = sizeof(cc_normal);
+ ipmb_send(&resp);
+ break;
+ default:
+#ifdef DEBUG
+ printf("Unknown chassis cmd 0x%02x\n", req->cmd);
+ ipmb_dump_req(req);
+#endif
+ ipmb_invalid(&resp);
+ break;
+ }
+ break;
+
+ case IPMB_NETFN_SENSOR_EVENT:
+ switch (req->cmd) {
+ default:
+#ifdef DEBUG
+ printf("Unknown sensor cmd 0x%02x\n", req->cmd);
+ ipmb_dump_req(req);
+#endif
+ ipmb_invalid(&resp);
+ break;
+ }
+ break;
+
+ case IPMB_NETFN_APP:
+ switch (req->cmd) {
+ case IPMB_APP_GET_DEVICE_ID:
+ resp.data = get_devid;
+ resp.datalen = sizeof(get_devid);
+ ipmb_send(&resp);
+ break;
+
+ case IPMB_APP_GET_WATCHDOG_TIMER:
+ resp.data = get_wd_timer;
+ resp.datalen = sizeof(get_wd_timer);
+ ipmb_send(&resp);
+ break;
+
+ default:
+#ifdef DEBUG
+ printf("Unknown app cmd 0x%02x\n", req->cmd);
+ ipmb_dump_req(req);
+#endif
+ ipmb_invalid(&resp);
+ break;
+ }
+ break;
+
+ case IPMB_NETFN_STORAGE:
+ switch (req->cmd) {
+ default:
+#ifdef DEBUG
+ printf("Unknown storage cmd 0x%02x\n", req->cmd);
+ ipmb_dump_req(req);
+#endif
+ ipmb_invalid(&resp);
+ break;
+ }
+ break;
+
+ default:
+#ifdef DEBUG
+ printf("Unknown netFn 0x%02x\n", req->netFn);
+ ipmb_dump_req(req);
+#endif
+ ipmb_invalid(&resp);
+ break;
+ }
+}
+
+void decode_ipmb_pkt(unsigned char *buf, int len)
+{
+ struct ipmb_req req;