Change in osmo-ttcn3-hacks[master]: library/Osmocom_Types: add f_rnd_bitstring() and f_pad_bit()

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/.

fixeria gerrit-no-reply at lists.osmocom.org
Mon Jul 20 13:26:45 UTC 2020


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


Change subject: library/Osmocom_Types: add f_rnd_bitstring() and f_pad_bit()
......................................................................

library/Osmocom_Types: add f_rnd_bitstring() and f_pad_bit()

Change-Id: I9be55f6979c8ce1cbf5b2ef317c998ae30488e0e
---
M library/Osmocom_Types.ttcn
1 file changed, 14 insertions(+), 0 deletions(-)



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

diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index 16395df..e55f1d6 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -74,6 +74,12 @@
 		return ret;
 	}
 
+	/* return bitstring composed of random bits */
+	function f_rnd_bitstring(in integer len) return bitstring {
+		var octetstring oct := f_rnd_octstring(len / 8 + 1);
+		return substr(oct2bit(oct), 0, len);
+	}
+
 	function f_rnd_imsi(in hexstring prefix) return hexstring {
 		return prefix & f_rnd_hexstring(15 - lengthof(prefix), 9);
 	}
@@ -175,6 +181,14 @@
 	return str;
 }
 
+function f_pad_bit(bitstring str, integer len, BIT1 pad) return bitstring {
+	var integer strlen := lengthof(str);
+	for (var integer i := 0; i < len-strlen; i := i+1) {
+		str := str & pad;
+	}
+	return str;
+}
+
 function f_pad_bcd_number(hexstring number) return hexstring {
 	if (lengthof(number) mod 2 != 0) {
 		return number & 'F'H;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/19333
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: I9be55f6979c8ce1cbf5b2ef317c998ae30488e0e
Gerrit-Change-Number: 19333
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200720/b2499b9d/attachment.htm>


More information about the gerrit-log mailing list