library/DIAMETER_Emulation: initiate CER/CEA exchange in client mode
Change-Id: I7537b306c2a569e2232597f21e15d3cf4ec9a12c
Related: SYS#5602, SYS#6333
diff --git a/library/DIAMETER_Emulation.ttcn b/library/DIAMETER_Emulation.ttcn
index f16acae..6eb72ad 100644
--- a/library/DIAMETER_Emulation.ttcn
+++ b/library/DIAMETER_Emulation.ttcn
@@ -276,13 +276,14 @@
}
function main(DIAMETEROps ops, DIAMETER_conn_parameters p, charstring id) runs on DIAMETER_Emulation_CT {
+ var boolean server_mode := p.remote_sctp_port == -1;
var Result res;
g_diameter_id := id;
f_imsi_table_init();
f_expect_table_init();
map(self:DIAMETER, system:DIAMETER_CODEC_PT);
- if (p.remote_sctp_port == -1) {
+ if (server_mode) {
res := DIAMETER_CodecPort_CtrlFunct.f_IPL4_listen(DIAMETER, p.local_ip, p.local_sctp_port, { sctp := valueof(ts_SCTP) });
} else {
res := DIAMETER_CodecPort_CtrlFunct.f_IPL4_connect(DIAMETER, p.remote_ip, p.remote_sctp_port,
@@ -294,6 +295,18 @@
}
g_diameter_conn_id := res.connId;
+ /* If in client mode, send CER immediately */
+ if (not server_mode) {
+ var template (value) PDU_DIAMETER req;
+ var PDU_DIAMETER rsp;
+
+ req := ts_DIA_CER(f_inet_addr(p.local_ip), p.vendor_app_id,
+ orig_host := p.origin_host, orig_realm := p.origin_realm);
+ rsp := f_diameter_xceive(req, tr_DIAMETER_A(Capabilities_Exchange, req.application_id));
+ /* notify our user that the CER->CEA exchange has happened */
+ DIAMETER_UNIT.send(DiameterCapabilityExchgInd:{rx := rsp, tx := valueof(req)});
+ }
+
while (true) {
var DIAMETER_ConnHdlr vc_conn;
var template IMSI imsi_t;