From df65951d5cd4363aa18cfd8395bf259961b64de1 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 29 Jul 2020 00:41:42 +0200 Subject: 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 --- bsc/BSC_Tests_CBSP.ttcn | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'bsc') diff --git a/bsc/BSC_Tests_CBSP.ttcn b/bsc/BSC_Tests_CBSP.ttcn index 207f3400..2399c3ab 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}); -- cgit v1.2.3