static void get_sdr(IPMIBmcSim *ibs,

                    uint8_t *cmd, unsigned int cmd_len,

                    uint8_t *rsp, unsigned int *rsp_len,

                    unsigned int max_rsp_len)

{

    unsigned int pos;

    uint16_t nextrec;

    struct ipmi_sdr_header *sdrh;



    IPMI_CHECK_CMD_LEN(8);

    if (cmd[6]) {

        IPMI_CHECK_RESERVATION(2, ibs->sdr.reservation);

    }

    pos = 0;

    if (sdr_find_entry(&ibs->sdr, cmd[4] | (cmd[5] << 8),

                       &pos, &nextrec)) {

        rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;

        return;

    }



    sdrh = (struct ipmi_sdr_header *) &ibs->sdr.sdr[pos];



    if (cmd[6] > ipmi_sdr_length(sdrh)) {

        rsp[2] = IPMI_CC_PARM_OUT_OF_RANGE;

        return;

    }



    IPMI_ADD_RSP_DATA(nextrec & 0xff);

    IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff);



    if (cmd[7] == 0xff) {

        cmd[7] = ipmi_sdr_length(sdrh) - cmd[6];

    }



    if ((cmd[7] + *rsp_len) > max_rsp_len) {

        rsp[2] = IPMI_CC_CANNOT_RETURN_REQ_NUM_BYTES;

        return;

    }

    memcpy(rsp + *rsp_len, ibs->sdr.sdr + pos + cmd[6], cmd[7]);

    *rsp_len += cmd[7];

}

static void get_sdr(IPMIBmcSim *ibs,

                    uint8_t *cmd, unsigned int cmd_len,

                    uint8_t *rsp, unsigned int *rsp_len,

                    unsigned int max_rsp_len)

{

    unsigned int pos;

    uint16_t nextrec;

    struct ipmi_sdr_header *sdrh;



    IPMI_CHECK_CMD_LEN(8);

    if (cmd[6]) {

        IPMI_CHECK_RESERVATION(2, ibs->sdr.reservation);

    }

    pos = 0;

    if (sdr_find_entry(&ibs->sdr, cmd[4] | (cmd[5] << 8),

                       &pos, &nextrec)) {

        rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;

        return;

    }



    sdrh = (struct ipmi_sdr_header *) &ibs->sdr.sdr[pos];



    if (cmd[6] > ipmi_sdr_length(sdrh)) {

        rsp[2] = IPMI_CC_PARM_OUT_OF_RANGE;

        return;

    }



    IPMI_ADD_RSP_DATA(nextrec & 0xff);

    IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff);



    if (cmd[7] == 0xff) {

        cmd[7] = ipmi_sdr_length(sdrh) - cmd[6];

    }



    if ((cmd[7] + *rsp_len) > max_rsp_len) {

        rsp[2] = IPMI_CC_CANNOT_RETURN_REQ_NUM_BYTES;

        return;

    }

    memcpy(rsp + *rsp_len, ibs->sdr.sdr + pos + cmd[6], cmd[7]);

    *rsp_len += cmd[7];

}

    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)

{

    unsigned int VAR_6;

    uint16_t nextrec;

    struct ipmi_sdr_header *VAR_7;



    IPMI_CHECK_CMD_LEN(8);

    if (VAR_1[6]) {

        IPMI_CHECK_RESERVATION(2, VAR_0->sdr.reservation);

    }

    VAR_6 = 0;

    if (sdr_find_entry(&VAR_0->sdr, VAR_1[4] | (VAR_1[5] << 8),

                       &VAR_6, &nextrec)) {

        VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;

        return;

    }



    VAR_7 = (struct ipmi_sdr_header *) &VAR_0->sdr.sdr[VAR_6];



    if (VAR_1[6] > ipmi_sdr_length(VAR_7)) {

        VAR_3[2] = IPMI_CC_PARM_OUT_OF_RANGE;

        return;

    }



    IPMI_ADD_RSP_DATA(nextrec & 0xff);

    IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff);



    if (VAR_1[7] == 0xff) {

        VAR_1[7] = ipmi_sdr_length(VAR_7) - VAR_1[6];

    }



    if ((VAR_1[7] + *VAR_4) > VAR_5) {

        VAR_3[2] = IPMI_CC_CANNOT_RETURN_REQ_NUM_BYTES;

        return;

    }

    memcpy(VAR_3 + *VAR_4, VAR_0->sdr.sdr + VAR_6 + VAR_1[6], VAR_1[7]);

    *VAR_4 += VAR_1[7];

}

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)
{ unsigned int VAR_6; uint16_t nextrec; struct ipmi_sdr_header *VAR_7; IPMI_CHECK_CMD_LEN(8); if (VAR_1[6]) { IPMI_CHECK_RESERVATION(2, VAR_0->sdr.reservation); } VAR_6 = 0; if (sdr_find_entry(&VAR_0->sdr, VAR_1[4] | (VAR_1[5] << 8),
&VAR_6, &nextrec)) { VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } VAR_7 = (struct ipmi_sdr_header *) &VAR_0->sdr.sdr[VAR_6]; if (VAR_1[6] > ipmi_sdr_length(VAR_7)) { VAR_3[2] = IPMI_CC_PARM_OUT_OF_RANGE; return; } IPMI_ADD_RSP_DATA(nextrec & 0xff); IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff); if (VAR_1[7] == 0xff) { VAR_1[7] = ipmi_sdr_length(VAR_7) - VAR_1[6]; } if ((VAR_1[7] + *VAR_4) > VAR_5) { VAR_3[2] = IPMI_CC_CANNOT_RETURN_REQ_NUM_BYTES; return; } memcpy(VAR_3 + *VAR_4, VAR_0->sdr.sdr + VAR_6 + VAR_1[6], VAR_1[7]); *VAR_4 += VAR_1[7]; }