summaryrefslogtreecommitdiffstats
path: root/bsc
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-07-29 00:41:42 +0200
committerlaforge <laforge@osmocom.org>2020-08-13 05:36:26 +0000
commitdf65951d5cd4363aa18cfd8395bf259961b64de1 (patch)
tree7e89fc302b3ccfa5bd4c23c45fa5e46f478a8b78 /bsc
parent289c36a6e39c4ec04cc5811625b05352c24454b3 (diff)
bsc CBSP: f_page2rsl: fix nr of blocks calculation
When dividing the payload by 22, the initial 6 header octets must also be taken into account. And, the last_block value indicates 4 as 0, which is not encoded correctly before this patch. Add a separate f_cbsp_block_count_enc() to fix the calculation. Change-Id: I06cc144bd92e94d461dac3f56a738da8e055b73a
Diffstat (limited to 'bsc')
-rw-r--r--bsc/BSC_Tests_CBSP.ttcn28
1 files changed, 24 insertions, 4 deletions
diff --git a/bsc/BSC_Tests_CBSP.ttcn b/bsc/BSC_Tests_CBSP.ttcn
index 207f340..2399c3a 100644
--- a/bsc/BSC_Tests_CBSP.ttcn
+++ b/bsc/BSC_Tests_CBSP.ttcn
@@ -289,17 +289,37 @@ tr_RslCbCmdType(template (present) uint2_t lblock := ?, template (present) RSL_C
last_block := lblock
}
+/* translate blocks count to RSL_CB_CMD_LASTBLOCK_1..4 values */
+private function f_cbsp_block_count_enc(integer num_blocks) return integer
+{
+ if (num_blocks < 1 or num_blocks > 4) {
+ setverdict(fail, "Invalid num_blocks: ", num_blocks);
+ mtc.stop;
+ }
+ if (num_blocks == 4) {
+ return 0;
+ }
+ return num_blocks;
+}
+
/* build a RSL_Message receive template from a CBSP page */
private function f_page2rsl(CBSP_IE page, uint16_t msg_id, uint16_t ser_no, boolean ext_cbch := false)
return template (present) RSL_Message
{
var template RSL_Message tr;
- var integer lblock := page.body.msg_content.user_len / 22;
+ var integer len;
+ var integer num_blocks;
var octetstring payload;
- if (page.body.msg_content.user_len mod 22 > 0) {
- lblock := lblock + 1;
- }
+
payload := int2oct(ser_no, 2) & int2oct(msg_id, 2) & '0011'O & page.body.msg_content.val;
+ len := lengthof(payload);
+ num_blocks := len / 22;
+ if (len mod 22 > 0) {
+ num_blocks := num_blocks + 1;
+ }
+
+ var integer lblock := f_cbsp_block_count_enc(num_blocks);
+
tr := tr_RSL_SMSCB_CMD(tr_RslCbCmdType(lblock), f_pad_oct(payload, 88, '00'O));
if (ext_cbch) {
tr.ies[3] := tr_RSL_IE(RSL_IE_Body:{smscb_chan_ind := 1});