Extend EIIOE field handling according to ses4r5 draft.

It should not affect any existing systems.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2020-08-17 15:11:46 +00:00
parent 19642a0cfb
commit c119ccdbfd
2 changed files with 15 additions and 9 deletions

View File

@ -1797,7 +1797,7 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct enc_fsm_state *state,
ses_elem_index_type_t index_type;
eip_hdr = (struct ses_elm_addlstatus_eip_hdr *)elm_hdr;
if (eip_hdr->byte2 & SES_ADDL_EIP_EIIOE) {
if (SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2)) {
index_type = SES_ELEM_INDEX_GLOBAL;
expected_index = iter.global_element_index;
} else {
@ -1807,8 +1807,8 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct enc_fsm_state *state,
if (eip_hdr->element_index < expected_index) {
ENC_VLOG(enc, "%s: provided %selement index "
"%d is lower then expected %d\n",
__func__, (eip_hdr->byte2 &
SES_ADDL_EIP_EIIOE) ? "global " : "",
__func__, SES_ADDL_EIP_EIIOE_EI_GLOB(
eip_hdr->byte2) ? "global " : "",
eip_hdr->element_index, expected_index);
goto badindex;
}
@ -1818,7 +1818,7 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct enc_fsm_state *state,
if (telement == NULL) {
ENC_VLOG(enc, "%s: provided %selement index "
"%d does not exist\n", __func__,
(eip_hdr->byte2 & SES_ADDL_EIP_EIIOE) ?
SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2) ?
"global " : "", eip_hdr->element_index);
goto badindex;
}
@ -1827,7 +1827,7 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct enc_fsm_state *state,
ENC_VLOG(enc, "%s: provided %selement index "
"%d can't have additional status\n",
__func__,
(eip_hdr->byte2 & SES_ADDL_EIP_EIIOE) ?
SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2) ?
"global " : "", eip_hdr->element_index);
badindex:
/*
@ -1843,7 +1843,7 @@ badindex:
element = telement;
}
if (eip_hdr->byte2 & SES_ADDL_EIP_EIIOE)
if (SES_ADDL_EIP_EIIOE_EI_GLOB(eip_hdr->byte2))
index = iter.global_element_index;
else
index = iter.individual_element_index;
@ -1852,8 +1852,8 @@ badindex:
ENC_VLOG(enc, "%s: provided %s element"
"index %d skips mandatory status "
" element at index %d\n",
__func__, (eip_hdr->byte2 &
SES_ADDL_EIP_EIIOE) ? "global " : "",
__func__, SES_ADDL_EIP_EIIOE_EI_GLOB(
eip_hdr->byte2) ? "global " : "",
index, expected_index);
}
}

View File

@ -2439,7 +2439,13 @@ int ses_elm_addlstatus_invalid(struct ses_elm_addlstatus_base_hdr *);
struct ses_elm_addlstatus_eip_hdr {
struct ses_elm_addlstatus_base_hdr base;
uint8_t byte2;
#define SES_ADDL_EIP_EIIOE 1
#define SES_ADDL_EIP_EIIOE_MASK 3
#define SES_ADDL_EIP_EIIOE_SES2 0
#define SES_ADDL_EIP_EIIOE_GLOB 1
#define SES_ADDL_EIP_EIIOE_IND 2
#define SES_ADDL_EIP_EIIOE_MIX 3
#define SES_ADDL_EIP_EIIOE_EI_GLOB(x) \
(((x) & SES_ADDL_EIP_EIIOE_MASK) == SES_ADDL_EIP_EIIOE_GLOB)
uint8_t element_index;
/* NB: This define (currently) applies to all eip=1 headers */
#define SES_EIP_HDR_EXTRA_LEN 2