Change in osmo-ttcn3-hacks[master]: bsc cbsp: f_page2rsl: fix nr of blocks calculation

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Tue Jul 28 23:49:01 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/19436 )


Change subject: bsc cbsp: f_page2rsl: fix nr of blocks calculation
......................................................................

bsc cbsp: f_page2rsl: fix nr of blocks calculation

Change-Id: I06cc144bd92e94d461dac3f56a738da8e055b73a
---
M bsc/BSC_Tests_CBSP.ttcn
1 file changed, 31 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/36/19436/1

diff --git a/bsc/BSC_Tests_CBSP.ttcn b/bsc/BSC_Tests_CBSP.ttcn
index 781bb8b..fd361bb 100644
--- a/bsc/BSC_Tests_CBSP.ttcn
+++ b/bsc/BSC_Tests_CBSP.ttcn
@@ -289,17 +289,43 @@
 	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)
+private function f_page2rsl(CBSP_IE page, uint16_t msg_id, uint16_t ser_no, boolean ext_cbch := false, integer expect_blocks := -1)
 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;
+	}
+
+	if (expect_blocks > 0 and expect_blocks != num_blocks) {
+		setverdict(fail, "test case claims to model ", expect_blocks, " blocks, but generated ", num_blocks);
+		mtc.stop;
+	}
+
+	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});

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/19436
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I06cc144bd92e94d461dac3f56a738da8e055b73a
Gerrit-Change-Number: 19436
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200728/52f9c9e7/attachment.htm>


More information about the gerrit-log mailing list