static void set_watchdog_timer(IPMIBmcSim *ibs,

                               uint8_t *cmd, unsigned int cmd_len,

                               uint8_t *rsp, unsigned int *rsp_len,

                               unsigned int max_rsp_len)

{

    IPMIInterface *s = ibs->parent.intf;

    IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);

    unsigned int val;



    IPMI_CHECK_CMD_LEN(8);

    val = cmd[2] & 0x7; /* Validate use */

    if (val == 0 || val > 5) {

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }

    val = cmd[3] & 0x7; /* Validate action */

    switch (val) {

    case IPMI_BMC_WATCHDOG_ACTION_NONE:

        break;



    case IPMI_BMC_WATCHDOG_ACTION_RESET:

        rsp[2] = k->do_hw_op(s, IPMI_RESET_CHASSIS, 1);

        break;



    case IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN:

        rsp[2] = k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 1);

        break;



    case IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE:

        rsp[2] = k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 1);

        break;



    default:

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

    }

    if (rsp[2]) {

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }



    val = (cmd[3] >> 4) & 0x7; /* Validate preaction */

    switch (val) {

    case IPMI_BMC_WATCHDOG_PRE_MSG_INT:

    case IPMI_BMC_WATCHDOG_PRE_NONE:

        break;



    case IPMI_BMC_WATCHDOG_PRE_NMI:

        if (!k->do_hw_op(s, IPMI_SEND_NMI, 1)) {

            /* NMI not supported. */

            rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

            return;

        }

        break;



    default:

        /* We don't support PRE_SMI */

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }



    ibs->watchdog_initialized = 1;

    ibs->watchdog_use = cmd[2] & IPMI_BMC_WATCHDOG_USE_MASK;

    ibs->watchdog_action = cmd[3] & IPMI_BMC_WATCHDOG_ACTION_MASK;

    ibs->watchdog_pretimeout = cmd[4];

    ibs->watchdog_expired &= ~cmd[5];

    ibs->watchdog_timeout = cmd[6] | (((uint16_t) cmd[7]) << 8);

    if (ibs->watchdog_running & IPMI_BMC_WATCHDOG_GET_DONT_STOP(ibs)) {

        do_watchdog_reset(ibs);

    } else {

        ibs->watchdog_running = 0;

    }

}

static void set_watchdog_timer(IPMIBmcSim *ibs,

                               uint8_t *cmd, unsigned int cmd_len,

                               uint8_t *rsp, unsigned int *rsp_len,

                               unsigned int max_rsp_len)

{

    IPMIInterface *s = ibs->parent.intf;

    IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);

    unsigned int val;



    IPMI_CHECK_CMD_LEN(8);

    val = cmd[2] & 0x7; 

    if (val == 0 || val > 5) {

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }

    val = cmd[3] & 0x7; 

    switch (val) {

    case IPMI_BMC_WATCHDOG_ACTION_NONE:

        break;



    case IPMI_BMC_WATCHDOG_ACTION_RESET:

        rsp[2] = k->do_hw_op(s, IPMI_RESET_CHASSIS, 1);

        break;



    case IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN:

        rsp[2] = k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 1);

        break;



    case IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE:

        rsp[2] = k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 1);

        break;



    default:

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

    }

    if (rsp[2]) {

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }



    val = (cmd[3] >> 4) & 0x7; 

    switch (val) {

    case IPMI_BMC_WATCHDOG_PRE_MSG_INT:

    case IPMI_BMC_WATCHDOG_PRE_NONE:

        break;



    case IPMI_BMC_WATCHDOG_PRE_NMI:

        if (!k->do_hw_op(s, IPMI_SEND_NMI, 1)) {

            

            rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

            return;

        }

        break;



    default:

        

        rsp[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }



    ibs->watchdog_initialized = 1;

    ibs->watchdog_use = cmd[2] & IPMI_BMC_WATCHDOG_USE_MASK;

    ibs->watchdog_action = cmd[3] & IPMI_BMC_WATCHDOG_ACTION_MASK;

    ibs->watchdog_pretimeout = cmd[4];

    ibs->watchdog_expired &= ~cmd[5];

    ibs->watchdog_timeout = cmd[6] | (((uint16_t) cmd[7]) << 8);

    if (ibs->watchdog_running & IPMI_BMC_WATCHDOG_GET_DONT_STOP(ibs)) {

        do_watchdog_reset(ibs);

    } else {

        ibs->watchdog_running = 0;

    }

}

                               uint8_t *cmd, unsigned int cmd_len,                                uint8_t *rsp, unsigned int *rsp_len,     IPMI_CHECK_CMD_LEN(8);     IPMI_CHECK_CMD_LEN(8);     IPMI_CHECK_CMD_LEN(8);     IPMI_CHECK_CMD_LEN(8);     IPMI_CHECK_CMD_LEN(8);
static void FUNC_0(IPMIBmcSim *VAR_0,

                               uint8_t *VAR_1, unsigned int VAR_2,

                               uint8_t *VAR_3, unsigned int *VAR_4,

                               unsigned int VAR_5)

{

    IPMIInterface *s = VAR_0->parent.intf;

    IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);

    unsigned int VAR_6;



    IPMI_CHECK_CMD_LEN(8);

    VAR_6 = VAR_1[2] & 0x7; 

    if (VAR_6 == 0 || VAR_6 > 5) {

        VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }

    VAR_6 = VAR_1[3] & 0x7; 

    switch (VAR_6) {

    case IPMI_BMC_WATCHDOG_ACTION_NONE:

        break;



    case IPMI_BMC_WATCHDOG_ACTION_RESET:

        VAR_3[2] = k->do_hw_op(s, IPMI_RESET_CHASSIS, 1);

        break;



    case IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN:

        VAR_3[2] = k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 1);

        break;



    case IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE:

        VAR_3[2] = k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 1);

        break;



    default:

        VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;

    }

    if (VAR_3[2]) {

        VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }



    VAR_6 = (VAR_1[3] >> 4) & 0x7; 

    switch (VAR_6) {

    case IPMI_BMC_WATCHDOG_PRE_MSG_INT:

    case IPMI_BMC_WATCHDOG_PRE_NONE:

        break;



    case IPMI_BMC_WATCHDOG_PRE_NMI:

        if (!k->do_hw_op(s, IPMI_SEND_NMI, 1)) {

            

            VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;

            return;

        }

        break;



    default:

        

        VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD;

        return;

    }



    VAR_0->watchdog_initialized = 1;

    VAR_0->watchdog_use = VAR_1[2] & IPMI_BMC_WATCHDOG_USE_MASK;

    VAR_0->watchdog_action = VAR_1[3] & IPMI_BMC_WATCHDOG_ACTION_MASK;

    VAR_0->watchdog_pretimeout = VAR_1[4];

    VAR_0->watchdog_expired &= ~VAR_1[5];

    VAR_0->watchdog_timeout = VAR_1[6] | (((uint16_t) VAR_1[7]) << 8);

    if (VAR_0->watchdog_running & IPMI_BMC_WATCHDOG_GET_DONT_STOP(VAR_0)) {

        do_watchdog_reset(VAR_0);

    } else {

        VAR_0->watchdog_running = 0;

    }

}

static void FUNC_0(IPMIBmcSim *VAR_0,
uint8_t *VAR_1, unsigned int VAR_2,
uint8_t *VAR_3, unsigned int *VAR_4,
unsigned int VAR_5)
{ IPMIInterface *s = VAR_0->parent.intf; IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s); unsigned int VAR_6; IPMI_CHECK_CMD_LEN(8); VAR_6 = VAR_1[2] & 0x7; if (VAR_6 == 0 || VAR_6 > 5) { VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD; return; } VAR_6 = VAR_1[3] & 0x7; switch (VAR_6) { case IPMI_BMC_WATCHDOG_ACTION_NONE:
break; case IPMI_BMC_WATCHDOG_ACTION_RESET:
VAR_3[2] = k->do_hw_op(s, IPMI_RESET_CHASSIS, 1); break; case IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN:
VAR_3[2] = k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 1); break; case IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE:
VAR_3[2] = k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 1); break; default:
VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD; } if (VAR_3[2]) { VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD; return; } VAR_6 = (VAR_1[3] >> 4) & 0x7; switch (VAR_6) { case IPMI_BMC_WATCHDOG_PRE_MSG_INT:
case IPMI_BMC_WATCHDOG_PRE_NONE:
break; case IPMI_BMC_WATCHDOG_PRE_NMI:
if (!k->do_hw_op(s, IPMI_SEND_NMI, 1)) { VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD; return; } break; default:
VAR_3[2] = IPMI_CC_INVALID_DATA_FIELD; return; } VAR_0->watchdog_initialized = 1; VAR_0->watchdog_use = VAR_1[2] & IPMI_BMC_WATCHDOG_USE_MASK; VAR_0->watchdog_action = VAR_1[3] & IPMI_BMC_WATCHDOG_ACTION_MASK; VAR_0->watchdog_pretimeout = VAR_1[4]; VAR_0->watchdog_expired &= ~VAR_1[5]; VAR_0->watchdog_timeout = VAR_1[6] | (((uint16_t) VAR_1[7]) << 8); if (VAR_0->watchdog_running & IPMI_BMC_WATCHDOG_GET_DONT_STOP(VAR_0)) { do_watchdog_reset(VAR_0); } else { VAR_0->watchdog_running = 0; } }