library/DIAMETER_Emulation: implement 'raw' mode of operation

This patch implements a new mode of operation, which allows to
have direct communication between the emulation component and
the other component connected via the 'DIAMETER_UNIT' port.
This eliminates the need to have dedicated components for each
IMSI, what is not necessarily needed in some specific cases.

Change-Id: I52e22ac70cc85be5b0436b68c77356aabc4f05e1
Related: SYS#5602
This commit is contained in:
Vadim Yanitskiy 2021-12-06 03:23:13 +03:00 committed by fixeria
parent c3c6ee6c63
commit b46f01e130
3 changed files with 22 additions and 5 deletions

View File

@ -18,6 +18,10 @@ module DIAMETER_Emulation {
* the DiameterOps.unitdata_cb() callback, which is registered with an argument to the
* main() function below.
*
* Alternatively, all inbound DIAMETER PDUs can be routed to a single component
* regardless of the IMSI. This is called 'raw' mode and can be achieved by
* setting the 'raw' field in DIAMETEROps to true.
*
* (C) 2019 by Harald Welte <laforge@gnumonks.org>
* All rights reserved.
*
@ -94,7 +98,10 @@ runs on DIAMETER_Emulation_CT return template PDU_DIAMETER;
type record DIAMETEROps {
DIAMETERCreateCallback create_cb,
DIAMETERUnitdataCallback unitdata_cb
DIAMETERUnitdataCallback unitdata_cb,
/* If true, this parameter disables IMSI based routing, so that all incoming
* PDUs get routed to a single component connected via the DIAMETER_UNIT port. */
boolean raw
}
type record DIAMETER_conn_parameters {
@ -337,8 +344,16 @@ function main(DIAMETEROps ops, DIAMETER_conn_parameters p, charstring id) runs o
DIAMETER.send(t_DIAMETER_Send(g_diameter_conn_id, valueof(resp)));
}
/* DIAMETER from remote peer */
[] DIAMETER.receive(tr_DIAMETER_RecvFrom_R(?)) -> value mrf {
/* DIAMETER from the test suite */
[ops.raw] DIAMETER_UNIT.receive(PDU_DIAMETER:?) -> value msg {
DIAMETER.send(t_DIAMETER_Send(g_diameter_conn_id, msg));
}
/* DIAMETER from remote peer (raw mode) */
[ops.raw] DIAMETER.receive(tr_DIAMETER_RecvFrom_R(?)) -> value mrf {
DIAMETER_UNIT.send(mrf.msg);
}
/* DIAMETER from remote peer (IMSI based routing) */
[not ops.raw] DIAMETER.receive(tr_DIAMETER_RecvFrom_R(?)) -> value mrf {
imsi_t := f_DIAMETER_get_imsi(mrf.msg);
if (isvalue(imsi_t)) {
imsi := valueof(imsi_t);

View File

@ -213,7 +213,8 @@ runs on DIAMETER_Emulation_CT return template PDU_DIAMETER {
friend function f_init_diameter(charstring id) runs on MTC_CT {
var DIAMETEROps ops := {
create_cb := refers(DIAMETER_Emulation.ExpectedCreateCallback),
unitdata_cb := refers(DiameterForwardUnitdataCallback)
unitdata_cb := refers(DiameterForwardUnitdataCallback),
raw := false /* handler mode (IMSI based routing) */
};
var DIAMETER_conn_parameters pars := {
remote_ip := mp_mme_ip,

View File

@ -115,7 +115,8 @@ runs on DIAMETER_Emulation_CT return template PDU_DIAMETER {
friend function f_init_diameter(charstring id) runs on PGW_Test_CT {
var DIAMETEROps ops := {
create_cb := refers(DIAMETER_Emulation.ExpectedCreateCallback),
unitdata_cb := refers(DiameterForwardUnitdataCallback)
unitdata_cb := refers(DiameterForwardUnitdataCallback),
raw := false /* handler mode (IMSI based routing) */
};
var DIAMETER_conn_parameters pars := {
remote_ip := mp_pgw_hostname,