2017-12-09 00:03:01 +00:00
|
|
|
module BSSAP_Adapter {
|
2017-11-25 14:00:50 +00:00
|
|
|
|
2017-12-09 00:03:01 +00:00
|
|
|
/* This module implements a 'dumb' BSSAP adapter. It creates the M3UA and SCCP components and stacks a BSSAP
|
|
|
|
* codec port on top. As a result, it provides the ability to transceive SCCP-User-SAP primitives with
|
|
|
|
* deoded BSSAP payload. Use this if you want to have full control about what you transmit or receive,
|
|
|
|
* without any automatisms in place. Allows you to refuse connections or other abnormal behavior. */
|
2017-11-25 14:00:50 +00:00
|
|
|
|
2017-12-09 00:03:01 +00:00
|
|
|
import from General_Types all;
|
|
|
|
import from Osmocom_Types all;
|
|
|
|
|
|
|
|
import from M3UA_Types all;
|
|
|
|
import from M3UA_Emulation all;
|
|
|
|
import from MTP3asp_Types all;
|
|
|
|
import from MTP3asp_PortType all;
|
2017-11-25 14:00:50 +00:00
|
|
|
|
2018-04-16 17:16:01 +00:00
|
|
|
import from IPA_Emulation all;
|
|
|
|
|
2017-11-25 14:00:50 +00:00
|
|
|
import from SCCP_Types all;
|
|
|
|
import from SCCPasp_Types all;
|
|
|
|
import from SCCP_Emulation all;
|
|
|
|
|
2017-12-09 00:03:01 +00:00
|
|
|
import from SCTPasp_Types all;
|
|
|
|
import from SCTPasp_PortType all;
|
2017-11-25 14:00:50 +00:00
|
|
|
|
2017-12-09 00:03:01 +00:00
|
|
|
import from BSSAP_CodecPort all;
|
2017-11-25 14:00:50 +00:00
|
|
|
import from BSSMAP_Templates all;
|
2017-12-16 18:26:04 +00:00
|
|
|
import from BSSMAP_Emulation all;
|
|
|
|
|
2018-02-08 23:17:14 +00:00
|
|
|
type record BSSAP_Adapter {
|
2017-11-25 14:00:50 +00:00
|
|
|
/* component references */
|
2018-05-24 18:00:00 +00:00
|
|
|
M3UA_CT vc_M3UA, /* only in 3GPP AoIP */
|
|
|
|
IPA_Emulation_CT vc_IPA, /* only in SCCPlite */
|
|
|
|
IPA_EventWaiter_CT vc_WAIT, /* only in SCCPlite */
|
2018-02-08 23:17:14 +00:00
|
|
|
SCCP_CT vc_SCCP,
|
2017-12-09 00:03:01 +00:00
|
|
|
|
2018-02-08 23:17:14 +00:00
|
|
|
MSC_SCCP_MTP3_parameters sccp_pars,
|
|
|
|
SCCP_PAR_Address sccp_addr_own,
|
|
|
|
SCCP_PAR_Address sccp_addr_peer,
|
2017-12-16 18:26:04 +00:00
|
|
|
|
|
|
|
/* handler mode */
|
2018-02-08 23:17:14 +00:00
|
|
|
BSSMAP_Emulation_CT vc_BSSMAP
|
2017-11-25 14:00:50 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 17:16:01 +00:00
|
|
|
type enumerated BSSAP_Transport {
|
|
|
|
BSSAP_TRANSPORT_AoIP, /* 3GPP AoIP: SCCP over M3UA over SCTP */
|
|
|
|
BSSAP_TRANSPORT_SCCPlite_SERVER, /* SCCPlite: SCCP over IPA over TCP */
|
|
|
|
BSSAP_TRANSPORT_SCCPlite_CLIENT /* SCCPlite: SCCP over IPA over TCP */
|
|
|
|
};
|
|
|
|
|
2018-02-08 23:17:14 +00:00
|
|
|
type record BSSAP_Configuration {
|
2018-04-16 17:16:01 +00:00
|
|
|
BSSAP_Transport transport,
|
2018-02-08 23:17:14 +00:00
|
|
|
charstring sccp_service_type,
|
|
|
|
SCTP_Association_Address sctp_addr,
|
|
|
|
integer own_pc,
|
|
|
|
integer own_ssn,
|
|
|
|
integer peer_pc,
|
|
|
|
integer peer_ssn,
|
2018-03-27 12:52:35 +00:00
|
|
|
octetstring sio,
|
|
|
|
integer rctx
|
2018-02-08 23:17:14 +00:00
|
|
|
};
|
2017-12-09 00:03:01 +00:00
|
|
|
|
|
|
|
/* construct a SCCP_PAR_Address with just PC + SSN and no GT */
|
2018-02-08 23:17:14 +00:00
|
|
|
template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn, octetstring sio,
|
|
|
|
charstring sccp_srv_type) := {
|
2017-12-09 00:03:01 +00:00
|
|
|
addressIndicator := {
|
|
|
|
pointCodeIndic := '1'B,
|
|
|
|
ssnIndicator := '1'B,
|
|
|
|
globalTitleIndic := '0000'B,
|
|
|
|
routingIndicator := '1'B
|
|
|
|
},
|
2018-02-08 23:17:14 +00:00
|
|
|
signPointCode := SCCP_SPC_int2bit(pc, sccp_srv_type, sio),
|
2017-12-09 00:03:01 +00:00
|
|
|
subsystemNumber := ssn,
|
|
|
|
globalTitle := omit
|
|
|
|
}
|
|
|
|
|
2018-02-08 23:17:14 +00:00
|
|
|
private function init_pars(inout BSSAP_Adapter ba, in BSSAP_Configuration cfg) {
|
|
|
|
ba.sccp_pars := {
|
2017-12-09 00:03:01 +00:00
|
|
|
sio := {
|
2018-02-08 23:17:14 +00:00
|
|
|
ni := substr(oct2bit(cfg.sio),0,2),
|
|
|
|
prio := substr(oct2bit(cfg.sio),2,2),
|
|
|
|
si := substr(oct2bit(cfg.sio),4,4)
|
2017-12-09 00:03:01 +00:00
|
|
|
},
|
2018-02-08 23:17:14 +00:00
|
|
|
opc := cfg.own_pc,
|
|
|
|
dpc := cfg.peer_pc,
|
2017-12-09 00:03:01 +00:00
|
|
|
sls := 0,
|
2018-02-08 23:17:14 +00:00
|
|
|
sccp_serviceType := cfg.sccp_service_type,
|
|
|
|
ssn := cfg.own_ssn
|
2017-12-09 00:03:01 +00:00
|
|
|
};
|
2018-02-08 23:17:14 +00:00
|
|
|
ba.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(cfg.own_pc, cfg.own_ssn, cfg.sio, cfg.sccp_service_type));
|
|
|
|
ba.sccp_addr_peer := valueof(ts_SccpAddr_PC_SSN(cfg.peer_pc, cfg.peer_ssn, cfg.sio, cfg.sccp_service_type));
|
2017-11-25 14:00:50 +00:00
|
|
|
}
|
|
|
|
|
2017-12-09 00:03:01 +00:00
|
|
|
|
2018-02-08 23:17:14 +00:00
|
|
|
function f_bssap_init(inout BSSAP_Adapter ba, in BSSAP_Configuration cfg, charstring id,
|
|
|
|
template BssmapOps ops) {
|
|
|
|
init_pars(ba, cfg);
|
|
|
|
ops.sccp_addr_local := ba.sccp_addr_own;
|
|
|
|
ops.sccp_addr_peer := ba.sccp_addr_peer;
|
2017-12-09 00:03:01 +00:00
|
|
|
|
2017-11-25 14:00:50 +00:00
|
|
|
/* create components */
|
2018-02-08 23:17:14 +00:00
|
|
|
ba.vc_SCCP := SCCP_CT.create(id & "-SCCP");
|
2018-01-17 21:19:03 +00:00
|
|
|
if (isvalue(ops)) {
|
2018-02-08 23:17:14 +00:00
|
|
|
ba.vc_BSSMAP := BSSMAP_Emulation_CT.create(id & "-BSSMAP");
|
2017-12-16 18:26:04 +00:00
|
|
|
}
|
2018-04-16 17:16:01 +00:00
|
|
|
select (cfg.transport) {
|
|
|
|
case (BSSAP_TRANSPORT_AoIP) {
|
|
|
|
ba.vc_M3UA := M3UA_CT.create(id & "-M3UA");
|
|
|
|
map(ba.vc_M3UA:SCTP_PORT, system:sctp);
|
|
|
|
/* connect MTP3 service provider (M3UA) to lower side of SCCP */
|
|
|
|
connect(ba.vc_M3UA:MTP3_SP_PORT, ba.vc_SCCP:MTP3_SCCP_PORT);
|
|
|
|
ba.vc_M3UA.start(f_M3UA_Emulation(cfg.sctp_addr, cfg.rctx));
|
|
|
|
}
|
|
|
|
case (BSSAP_TRANSPORT_SCCPlite_SERVER) {
|
|
|
|
ba.vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
|
|
|
|
map(ba.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
|
|
|
|
/* connect MTP3 service provider (IPA) to lower side of SCCP */
|
|
|
|
connect(ba.vc_IPA:MTP3_SP_PORT, ba.vc_SCCP:MTP3_SCCP_PORT);
|
2018-05-24 18:00:00 +00:00
|
|
|
/* connect waiter to general IPA port (for ASP_IPA_Event) */
|
|
|
|
ba.vc_WAIT := IPA_EventWaiter_CT.create(id & "-IPA-WAIT");
|
|
|
|
connect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT);
|
|
|
|
ba.vc_WAIT.start(IPA_Emulation.waiter_main());
|
2018-04-16 17:16:01 +00:00
|
|
|
ba.vc_IPA.start(IPA_Emulation.main_server(cfg.sctp_addr.local_ip_addr,
|
|
|
|
cfg.sctp_addr.local_sctp_port));
|
2018-05-24 18:00:00 +00:00
|
|
|
/* wait until we received an IPA CCM ID_ACK */
|
|
|
|
ba.vc_WAIT.done;
|
|
|
|
disconnect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT);
|
2018-04-16 17:16:01 +00:00
|
|
|
}
|
|
|
|
case (BSSAP_TRANSPORT_SCCPlite_CLIENT) {
|
|
|
|
ba.vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
|
|
|
|
map(ba.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
|
|
|
|
/* connect MTP3 service provider (IPA) to lower side of SCCP */
|
|
|
|
connect(ba.vc_IPA:MTP3_SP_PORT, ba.vc_SCCP:MTP3_SCCP_PORT);
|
2018-05-24 18:00:00 +00:00
|
|
|
/* connect waiter to general IPA port (for ASP_IPA_Event) */
|
|
|
|
ba.vc_WAIT := IPA_EventWaiter_CT.create(id & "-IPA-WAIT");
|
|
|
|
connect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT);
|
|
|
|
ba.vc_WAIT.start(IPA_Emulation.waiter_main());
|
2018-04-16 17:16:01 +00:00
|
|
|
ba.vc_IPA.start(IPA_Emulation.main_client(cfg.sctp_addr.remote_ip_addr,
|
|
|
|
cfg.sctp_addr.remote_sctp_port,
|
|
|
|
cfg.sctp_addr.local_ip_addr,
|
|
|
|
cfg.sctp_addr.local_sctp_port));
|
2018-05-24 18:00:00 +00:00
|
|
|
/* wait until we received an IPA CCM ID_ACK */
|
|
|
|
ba.vc_WAIT.done;
|
|
|
|
disconnect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT);
|
2018-04-16 17:16:01 +00:00
|
|
|
}
|
|
|
|
case else {
|
|
|
|
setverdict(fail, "Unsuppored BSSAP_Transport");
|
|
|
|
self.stop;
|
|
|
|
}
|
|
|
|
}
|
2017-11-25 14:00:50 +00:00
|
|
|
|
2018-01-17 21:19:03 +00:00
|
|
|
if (isvalue(ops)) {
|
2018-01-21 12:53:17 +00:00
|
|
|
timer T := 5.0;
|
|
|
|
T.start;
|
2018-02-08 23:17:14 +00:00
|
|
|
//T.timeout;
|
|
|
|
log("Connecting BSSMAP Emulation to SCCP_SP_PORT and starting emulation");
|
2018-01-21 12:53:17 +00:00
|
|
|
/* connect BSSNAP component to upposer side of SCCP */
|
2018-02-08 23:17:14 +00:00
|
|
|
connect(ba.vc_BSSMAP:BSSAP, ba.vc_SCCP:SCCP_SP_PORT);
|
2018-01-21 12:53:17 +00:00
|
|
|
/* start the BSSMAP emulation */
|
2018-02-08 23:17:14 +00:00
|
|
|
ba.vc_BSSMAP.start(BSSMAP_Emulation.main(valueof(ops), ""));
|
2017-12-09 00:03:01 +00:00
|
|
|
}
|
2018-05-24 18:00:00 +00:00
|
|
|
|
|
|
|
ba.vc_SCCP.start(SCCPStart(ba.sccp_pars));
|
|
|
|
|
2017-12-09 00:03:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-25 14:00:50 +00:00
|
|
|
}
|