dl tbf: initialize punct values and verify
Solves a sanitizer issue where punct2 is unset when passed to gprs_rlc_mcs_cps() and thus takes a value not defined in the enum. Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693
This commit is contained in:
parent
49b83ec3a3
commit
b609190369
30
src/rlc.cpp
30
src/rlc.cpp
|
@ -378,6 +378,36 @@ unsigned int gprs_rlc_mcs_cps(GprsCodingScheme cs,
|
||||||
enum egprs_puncturing_values punct,
|
enum egprs_puncturing_values punct,
|
||||||
enum egprs_puncturing_values punct2, int with_padding)
|
enum egprs_puncturing_values punct2, int with_padding)
|
||||||
{
|
{
|
||||||
|
/* validate that punct and punct2 are as expected */
|
||||||
|
switch (GprsCodingScheme::Scheme(cs)) {
|
||||||
|
case GprsCodingScheme::MCS9:
|
||||||
|
case GprsCodingScheme::MCS8:
|
||||||
|
case GprsCodingScheme::MCS7:
|
||||||
|
if (punct2 == EGPRS_PS_INVALID) {
|
||||||
|
LOGP(DRLCMACDL, LOGL_ERROR,
|
||||||
|
"Invalid punct2 value for coding scheme %d: %d\n",
|
||||||
|
GprsCodingScheme::Scheme(cs), punct2);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* fall through */
|
||||||
|
case GprsCodingScheme::MCS6:
|
||||||
|
case GprsCodingScheme::MCS5:
|
||||||
|
case GprsCodingScheme::MCS4:
|
||||||
|
case GprsCodingScheme::MCS3:
|
||||||
|
case GprsCodingScheme::MCS2:
|
||||||
|
case GprsCodingScheme::MCS1:
|
||||||
|
if (punct == EGPRS_PS_INVALID) {
|
||||||
|
LOGP(DRLCMACDL, LOGL_ERROR,
|
||||||
|
"Invalid punct value for coding scheme %d: %d\n",
|
||||||
|
GprsCodingScheme::Scheme(cs), punct);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See 3GPP TS 44.060 10.4.8a.3.1, 10.4.8a.2.1, 10.4.8a.1.1 */
|
||||||
switch (GprsCodingScheme::Scheme(cs)) {
|
switch (GprsCodingScheme::Scheme(cs)) {
|
||||||
case GprsCodingScheme::MCS1: return 0b1011 +
|
case GprsCodingScheme::MCS1: return 0b1011 +
|
||||||
punct % EGPRS_MAX_PS_NUM_2;
|
punct % EGPRS_MAX_PS_NUM_2;
|
||||||
|
|
|
@ -627,10 +627,16 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
|
||||||
GprsCodingScheme cs;
|
GprsCodingScheme cs;
|
||||||
int bsns[ARRAY_SIZE(rlc.block_info)];
|
int bsns[ARRAY_SIZE(rlc.block_info)];
|
||||||
unsigned num_bsns;
|
unsigned num_bsns;
|
||||||
enum egprs_puncturing_values punct[ARRAY_SIZE(rlc.block_info)];
|
|
||||||
bool need_padding = false;
|
bool need_padding = false;
|
||||||
enum egprs_rlcmac_dl_spb spb = EGPRS_RLCMAC_DL_NO_RETX;
|
enum egprs_rlcmac_dl_spb spb = EGPRS_RLCMAC_DL_NO_RETX;
|
||||||
unsigned int spb_status = get_egprs_dl_spb_status(index);
|
unsigned int spb_status = get_egprs_dl_spb_status(index);
|
||||||
|
|
||||||
|
enum egprs_puncturing_values punct[2] = {
|
||||||
|
EGPRS_PS_INVALID, EGPRS_PS_INVALID
|
||||||
|
};
|
||||||
|
osmo_static_assert(ARRAY_SIZE(rlc.block_info) == 2,
|
||||||
|
rlc_block_info_size_is_two);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: This is an experimental work-around to put 2 BSN into
|
* TODO: This is an experimental work-around to put 2 BSN into
|
||||||
* MSC-7 to MCS-9 encoded messages. It just sends the same BSN
|
* MSC-7 to MCS-9 encoded messages. It just sends the same BSN
|
||||||
|
@ -763,10 +769,8 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate CPS only for EGPRS case */
|
/* Calculate CPS only for EGPRS case */
|
||||||
if (cs.isEgprs()) {
|
if (cs.isEgprs())
|
||||||
OSMO_ASSERT(ARRAY_SIZE(punct) >= 2);
|
|
||||||
rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding);
|
rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding);
|
||||||
}
|
|
||||||
|
|
||||||
/* If the TBF has just started, relate frames_since_last_poll to the
|
/* If the TBF has just started, relate frames_since_last_poll to the
|
||||||
* current fn */
|
* current fn */
|
||||||
|
|
Loading…
Reference in New Issue