summaryrefslogtreecommitdiffstats
path: root/library/Osmocom_Types.ttcn
diff options
context:
space:
mode:
Diffstat (limited to 'library/Osmocom_Types.ttcn')
-rw-r--r--library/Osmocom_Types.ttcn33
1 files changed, 33 insertions, 0 deletions
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index 484f6d1..495b684 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -27,4 +27,37 @@ module Osmocom_Types {
uint15_t arfcn
} with { variant "" };
+ /* return random integer between 0 and max */
+ function f_rnd_int(integer max) return integer {
+ return float2int(rnd()*int2float(max));
+ }
+
+ /* return hexstring composed of random digits */
+ function f_rnd_hexstring(in integer len, in integer max := 15) return hexstring {
+ var integer i;
+ var hexstring ret := ''H;
+ for (i := 0; i < len; i := i + 1) {
+ ret := ret & int2hex(f_rnd_int(max), 1);
+ }
+ return ret;
+ }
+
+ /* return octetstring composed of random bytes */
+ function f_rnd_octstring(in integer len) return octetstring {
+ var integer i;
+ var octetstring ret := ''O;
+ for (i := 0; i < len; i := i + 1) {
+ ret := ret & int2oct(f_rnd_int(255), 1);
+ }
+ return ret;
+ }
+
+ function f_rnd_imsi(in hexstring prefix) return hexstring {
+ return prefix & f_rnd_hexstring(15 - lengthof(prefix), 9);
+ }
+
+ function f_rnd_msisdn(in octetstring prefix, integer len := 6) return octetstring {
+ return prefix & f_rnd_octstring(len - lengthof(prefix));
+ }
+
} with { encode "RAW"; variant "FIELDORDER(msb)" }