fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/31455 )
Change subject: library/DIAMETER_Emulation: add API for generating Session-Id AVP
......................................................................
library/DIAMETER_Emulation: add API for generating Session-Id AVP
Change-Id: I0fbd271ad123e9663aab5163915e1edbf5915bb6
Related: SYS#6343, SYS#5602
---
M library/DIAMETER_Emulation.ttcn
1 file changed, 37 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/55/31455/1
diff --git a/library/DIAMETER_Emulation.ttcn b/library/DIAMETER_Emulation.ttcn
index 6eb72ad..2a7bbd0 100644
--- a/library/DIAMETER_Emulation.ttcn
+++ b/library/DIAMETER_Emulation.ttcn
@@ -86,6 +86,10 @@
/* test port for unit data messages */
port DIAMETER_PT DIAMETER_UNIT;
+ /* monotonically increasing 64-bit value for Session-Id AVP */
+ var uint32_t g_sess_id_seed_h32;
+ var uint32_t g_sess_id_seed_l32;
+
var charstring g_diameter_id;
var integer g_diameter_conn_id := -1;
}
@@ -307,6 +311,10 @@
DIAMETER_UNIT.send(DiameterCapabilityExchgInd:{rx := rsp, tx := valueof(req)});
}
+ /* Init seed for Session-Id AVP: randomize the high 32 bits */
+ g_sess_id_seed_h32 := f_rnd_int(c_UINT32_MAX);
+ g_sess_id_seed_l32 := 0;
+
while (true) {
var DIAMETER_ConnHdlr vc_conn;
var template IMSI imsi_t;
@@ -314,6 +322,7 @@
var DIAMETER_RecvFrom mrf;
var PDU_DIAMETER msg;
var charstring vlr_name, mme_name;
+ var charstring identity;
var PortEvent port_evt;
alt {
@@ -381,6 +390,14 @@
f_create_expect(imsi, vc_conn);
DIAMETER_PROC.reply(DIAMETEREM_register:{imsi, vc_conn}) to vc_conn;
}
+ [] DIAMETER_PROC.getcall(DIAMETEREM_gen_sess_id:{?,?}) -> param(identity) {
+ var charstring sess_id := identity & ";" &
int2str(g_sess_id_seed_h32)
+ & ";" & int2str(g_sess_id_seed_l32);
+ if (g_sess_id_seed_l32 == c_UINT32_MAX)
+ { g_sess_id_seed_h32 := g_sess_id_seed_h32 + 1; }
+ g_sess_id_seed_l32 := g_sess_id_seed_l32 + 1;
+ DIAMETER_PROC.reply(DIAMETEREM_gen_sess_id:{identity, sess_id});
+ }
}
@@ -395,9 +412,11 @@
}
signature DIAMETEREM_register(in hexstring imsi, in DIAMETER_ConnHdlr hdlr);
+signature DIAMETEREM_gen_sess_id(in charstring identity, out charstring sess_id);
type port DIAMETEREM_PROC_PT procedure {
inout DIAMETEREM_register;
+ inout DIAMETEREM_gen_sess_id;
} with { extension "internal" };
/* Function that can be used as create_cb and will use the expect table */
@@ -452,6 +471,14 @@
}
}
+function f_diameter_gen_sess_id(DIAMETEREM_PROC_PT pt, charstring identity) return
charstring {
+ var charstring sess_id;
+ pt.call(DIAMETEREM_gen_sess_id:{identity,-}) {
+ [] pt.getreply(DIAMETEREM_gen_sess_id:{?,?}) -> param (sess_id) {};
+ }
+ return sess_id;
+}
+
private function f_expect_table_init()
runs on DIAMETER_Emulation_CT {
var integer i;
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/31455
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: I0fbd271ad123e9663aab5163915e1edbf5915bb6
Gerrit-Change-Number: 31455
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange