DIAMETER_Emulation: Notify user of CapabilityExchange

During start of the test case, we must wait until the IUT has
established a DIAMETER/SCTP connection to the testsuite.  Implement
this by means of a message on the DIAMETER_UNIT port and an associated
helper function.

Change-Id: I95434307efc67025ee6d373561f6d22398f959c5
This commit is contained in:
Harald Welte 2020-04-26 22:05:53 +02:00
parent 61f73d553b
commit d01b5d0af0
2 changed files with 30 additions and 1 deletions

View File

@ -37,6 +37,12 @@ import from Native_Functions all;
type hexstring IMSI;
/* notify the recipient that a Capability Exchange happened */
type record DiameterCapabilityExchgInd {
PDU_DIAMETER rx,
PDU_DIAMETER tx
};
type component DIAMETER_ConnHdlr {
port DIAMETER_Conn_PT DIAMETER;
/* procedure based port to register for incoming connections */
@ -50,7 +56,7 @@ type port DIAMETER_Conn_PT message {
/* global test port e.g. for non-imsi/conn specific messages */
type port DIAMETER_PT message {
inout PDU_DIAMETER;
inout PDU_DIAMETER, DiameterCapabilityExchgInd;
} with { extension "internal" };
@ -319,6 +325,8 @@ function main(DIAMETEROps ops, DIAMETER_conn_parameters p, charstring id) runs o
resp := ts_DIA_CEA(mrf.msg.hop_by_hop_id, mrf.msg.end_to_end_id, p.origin_host,
p.origin_realm, f_inet_addr(p.local_ip), p.vendor_app_id);
DIAMETER.send(t_DIAMETER_Send(g_diameter_conn_id, resp));
/* notify our user that the CER->CEA exchange has happened */
DIAMETER_UNIT.send(DiameterCapabilityExchgInd:{rx:=mrf.msg, tx:=valueof(resp)});
}
/* DIAMETER from remote peer */
@ -434,4 +442,23 @@ runs on DIAMETER_Emulation_CT return template PDU_DIAMETER {
}
function f_diameter_wait_capability(DIAMETER_PT pt)
{
/* Wait for the Capability Exchange with the DUT */
timer T := 10.0;
T.start;
alt {
[] pt.receive(DiameterCapabilityExchgInd:?) {}
[] pt.receive {
setverdict(fail, "Unexpected receive waiting for DiameterCapabilityExchgInd");
mtc.stop;
}
[] T.timeout {
setverdict(fail, "Timeout waiting for DiameterCapabilityExchgInd");
mtc.stop;
}
}
}
}

View File

@ -229,6 +229,8 @@ friend function f_init_diameter(charstring id) runs on MTC_CT {
connect(vc_DIAMETER:DIAMETER_UNIT, self:DIAMETER_UNIT);
connect(vc_DIAMETER:DIAMETER_PROC, self:DIAMETER_PROC);
vc_DIAMETER.start(DIAMETER_Emulation.main(ops, pars, id));
f_diameter_wait_capability(DIAMETER_UNIT);
}
friend template (value) TAI ts_enb_S1AP_TAI(EnbParams enb) := {