diff options
author | Max <msuraev@sysmocom.de> | 2019-03-06 18:17:32 +0100 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2019-03-27 12:32:04 +0000 |
commit | 6e96dd4665bf5f287283fbf1087f3d218222ea71 (patch) | |
tree | eb2b470b9987597a245a29b0578a89cd5cfff46a /src/encoding.cpp | |
parent | 898dddb1d122068700694b59b9261fe07fa9cdef (diff) |
Fix Channel Coding Command for MCS
Previously result of ".to_num() - 1" was used without any checks which
means that in case of to_num() returning zero we would effectively try
to encode (uint8_t)(-1).
Let's fix this by using proper mcs_chan_code() function which returns
Channel Coding Command for MCS without the need to further correct it
and adjust expected tests output accordingly.
Change-Id: I868062a81fffe6714a811c032215f25a79259905
Diffstat (limited to 'src/encoding.cpp')
-rw-r--r-- | src/encoding.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp index 9920b461..b0d04679 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -268,7 +268,7 @@ static int write_ia_rest_uplink_mba(const gprs_rlcmac_ul_tbf *tbf, bitvec *dest, bitvec_write_field(dest, &wp, usf, 3); // USF bitvec_write_field(dest, &wp, 0, 1); // USF_GRANULARITY bitvec_write_field(dest, &wp, 0, 1); // "0" power control: Not Present - bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 2); // CHANNEL_CODING_COMMAND bitvec_write_field(dest, &wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING if (alpha) { bitvec_write_field(dest, &wp, 0x1, 1); // ALPHA = present @@ -315,7 +315,7 @@ static int write_ia_rest_egprs_uplink_sba(const gprs_rlcmac_ul_tbf *tbf, bitvec CHECK(rc); /* 3GPP TS 44.060 ยง12.10d EGPRS Modulation and coding Scheme description: */ - rc = bitvec_set_u64(dest, tbf->current_cs().to_num() - 1, 4, false); /* EGPRS CHANNEL_CODING_COMMAND */ + rc = bitvec_set_u64(dest, mcs_chan_code(tbf->current_cs()), 4, false); /* EGPRS CHANNEL_CODING_COMMAND */ CHECK(rc); /* TLLI_BLOCK_CHANNEL_CODING */ @@ -571,7 +571,7 @@ void Encoding::write_packet_uplink_assignment( if (!use_egprs) { bitvec_write_field(dest, &wp,0x0,1); // Message escape - bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 2); // CHANNEL_CODING_COMMAND bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts); } else { /* EPGRS */ @@ -579,7 +579,7 @@ void Encoding::write_packet_uplink_assignment( bitvec_write_field(dest, &wp,0x0,2); // EGPRS message contents bitvec_write_field(dest, &wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI bitvec_write_field(dest, &wp,0x0,1); // No COMPACT reduced MA - bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE + bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 4); // EGPRS Modulation and Coding IE /* 0: no RESEGMENT, 1: Segmentation*/ bitvec_write_field(dest, &wp, 0x1, 1); write_ws(dest, &wp, tbf->window_size()); // EGPRS Window Size @@ -809,7 +809,7 @@ static void write_packet_uplink_ack_gprs( struct gprs_rlcmac_ul_tbf *tbf, bool is_final) { - bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 2); // CHANNEL_CODING_COMMAND write_packet_ack_nack_desc_gprs(bts, dest, wp, tbf->window(), is_final); bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI @@ -991,7 +991,7 @@ static void write_packet_uplink_ack_egprs( bitvec_write_field(dest, &wp, 0, 2); // fixed 00 /* CHANNEL_CODING_COMMAND */ bitvec_write_field(dest, &wp, - tbf->current_cs().to_num() - 1, 4); + mcs_chan_code(tbf->current_cs()), 4); /* 0: no RESEGMENT, 1: Segmentation*/ bitvec_write_field(dest, &wp, 1, 1); bitvec_write_field(dest, &wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it? |