[PATCH] osmo-ttcn3-hacks[master]: BSSMAP_Emulation: use BSSAP_CodecPort

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Dec 16 22:04:17 UTC 2017


Review at  https://gerrit.osmocom.org/5444

BSSMAP_Emulation: use BSSAP_CodecPort

So far, BSSMAP_Emulation used the SCCPasp_SP_PORT directly, explicitly
calling BSSAP encode/decode functions while processing the primitives.

Let's clean this up and use the BSSAP_CodecPort which has meanwhile
been developed as a dual-faced port that can be stacked between SCCPasp
and the user to avoid any manual encode/decode function calls.

Change-Id: Icded789d18f3469f74e16f552df2c7ac44ac4294
---
M bsc-nat/BSC_MS_ConnectionHandler.ttcn
M bsc-nat/BSC_MS_Simulation.ttcn
M bsc-nat/MSC_ConnectionHandler.ttcn
M bsc-nat/MSC_Simulation.ttcn
M bsc-nat/gen_links.sh
M library/BSSMAP_Emulation.ttcn
6 files changed, 33 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/44/5444/1

diff --git a/bsc-nat/BSC_MS_ConnectionHandler.ttcn b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
index a385525..876d2ec 100644
--- a/bsc-nat/BSC_MS_ConnectionHandler.ttcn
+++ b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
@@ -4,6 +4,7 @@
 import from Osmocom_Types all;
 import from SCCPasp_Types all;
 import from BSSAP_Types all;
+import from BSSAP_CodecPort all;
 import from BSSMAP_Emulation all;
 import from BSSMAP_Templates all;
 
@@ -28,7 +29,7 @@
 
 /* Callback function from general BSSMAP_Emulation whenever a new incoming
  * SCCP connection arrivces. Must create + start a new component */
-private function CreateCallback(ASP_SCCP_N_CONNECT_ind conn_ind, charstring id)
+private function CreateCallback(BSSAP_N_CONNECT_ind conn_ind, charstring id)
 runs on BSSMAP_Emulation_CT return BSSAP_ConnHdlr {
 	log("Incoming SCCP Connection on BSC ?!?");
 	self.stop;
diff --git a/bsc-nat/BSC_MS_Simulation.ttcn b/bsc-nat/BSC_MS_Simulation.ttcn
index eab7fe9..b9414a3 100644
--- a/bsc-nat/BSC_MS_Simulation.ttcn
+++ b/bsc-nat/BSC_MS_Simulation.ttcn
@@ -8,6 +8,7 @@
 import from SCCPasp_Types all;
 import from SCCP_Emulation all;
 
+import from BSSAP_CodecPort all;
 import from BSSMAP_Emulation all;
 
 import from BSC_MS_ConnectionHandler all;
@@ -53,7 +54,7 @@
 	connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
 
 	/* connect BSSMAP dispatcher to upper side of SCCP */
-	connect(vc_BSSMAP:SCCP, vc_SCCP:SCCP_SP_PORT);
+	connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);
 
 	/* connect BSSMAP dispatcher to IPA_Emulation MGCP */
 	connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
diff --git a/bsc-nat/MSC_ConnectionHandler.ttcn b/bsc-nat/MSC_ConnectionHandler.ttcn
index 3fc11e9..b038ce5 100644
--- a/bsc-nat/MSC_ConnectionHandler.ttcn
+++ b/bsc-nat/MSC_ConnectionHandler.ttcn
@@ -4,6 +4,7 @@
 import from Osmocom_Types all;
 import from SCCPasp_Types all;
 import from BSSAP_Types all;
+import from BSSAP_CodecPort all;
 import from BSSMAP_Emulation all;
 import from BSSMAP_Templates all;
 
@@ -26,7 +27,7 @@
 
 /* Callback function from general BSSMAP_Emulation whenever a new incoming
  * SCCP connection arrivces. Must create + start a new component */
-private function CreateCallback(ASP_SCCP_N_CONNECT_ind conn_ind, charstring id)
+private function CreateCallback(BSSAP_N_CONNECT_ind conn_ind, charstring id)
 runs on BSSMAP_Emulation_CT return BSSAP_ConnHdlr {
 	var MSC_ConnHdlr vc_conn;
 	/* Create a new BSSAP_ConnHdlr component */
diff --git a/bsc-nat/MSC_Simulation.ttcn b/bsc-nat/MSC_Simulation.ttcn
index f9fb0d4..7e39ca1 100755
--- a/bsc-nat/MSC_Simulation.ttcn
+++ b/bsc-nat/MSC_Simulation.ttcn
@@ -51,7 +51,7 @@
 	connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
 
 	/* connect BSSNAP dispatcher to upper side of SCCP */
-	connect(vc_BSSMAP:SCCP, vc_SCCP:SCCP_SP_PORT);
+	connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);
 
 	if (mp_mgcp_uses_udp == false) {
 		/* connect BSSMAP dispatcher to IPA_Emulation MGCP */
diff --git a/bsc-nat/gen_links.sh b/bsc-nat/gen_links.sh
index 9846d9a..9a45c89 100755
--- a/bsc-nat/gen_links.sh
+++ b/bsc-nat/gen_links.sh
@@ -55,5 +55,5 @@
 gen_links $DIR $FILES
 
 DIR=../library
-FILES="General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcn L3_Templates.ttcn BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc RSL_Types.ttcn Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn"
+FILES="General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcn L3_Templates.ttcn BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc RSL_Types.ttcn Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn BSSAP_CodecPort.ttcn"
 gen_links $DIR $FILES
diff --git a/library/BSSMAP_Emulation.ttcn b/library/BSSMAP_Emulation.ttcn
index 42f7739..14bf238 100644
--- a/library/BSSMAP_Emulation.ttcn
+++ b/library/BSSMAP_Emulation.ttcn
@@ -3,6 +3,7 @@
 import from SCCP_Emulation all;
 import from SCCPasp_Types all;
 import from BSSAP_Types all;
+import from BSSAP_CodecPort all;
 import from BSSMAP_Templates all;
 import from MGCP_Types all;
 import from MGCP_Templates all;
@@ -48,7 +49,7 @@
 
 type component BSSMAP_Emulation_CT {
 	/* SCCP port on the bottom side, using ASP primitives */
-	port SCCPasp_PT SCCP;
+	port BSSAP_CODEC_PT BSSAP;
 	/* BSSAP port to the per-connection clients */
 	port BSSAP_Conn_PT CLIENT;
 	/* MGCP port */
@@ -228,10 +229,9 @@
 }
 
 /* handle (optional) userData portion of various primitives and dispatch it to the client */
-private function f_handle_userData(BSSAP_ConnHdlr client, octetstring userdata)
+private function f_handle_userData(BSSAP_ConnHdlr client, PDU_BSSAP bssap)
 runs on BSSMAP_Emulation_CT {
 	/* decode + send decoded BSSAP to client */
-	var PDU_BSSAP bssap := dec_PDU_BSSAP(valueof(userdata));
 
 	/* BSC Side: If this is an assignment command, store CIC */
 	if (ischosen(bssap.pdu.bssmap.assignmentRequest) and
@@ -247,7 +247,7 @@
 
 /* call-back type, to be provided by specific implementation; called when new SCCP connection
  * arrives */
-type function BssmapCreateCallback(ASP_SCCP_N_CONNECT_ind conn_ind, charstring id)
+type function BssmapCreateCallback(BSSAP_N_CONNECT_ind conn_ind, charstring id)
 runs on BSSMAP_Emulation_CT return BSSAP_ConnHdlr;
 
 type function BssmapUnitdataCallback(PDU_BSSAP bssap)
@@ -264,11 +264,11 @@
 	f_conn_table_init();
 
 	while (true) {
-		var ASP_SCCP_N_UNITDATA_ind ud_ind;
-		var ASP_SCCP_N_CONNECT_ind conn_ind;
-		var ASP_SCCP_N_CONNECT_cfm conn_cfm;
-		var ASP_SCCP_N_DATA_ind data_ind;
-		var ASP_SCCP_N_DISCONNECT_ind disc_ind;
+		var BSSAP_N_UNITDATA_ind ud_ind;
+		var BSSAP_N_CONNECT_ind conn_ind;
+		var BSSAP_N_CONNECT_cfm conn_cfm;
+		var BSSAP_N_DATA_ind data_ind;
+		var BSSAP_N_DISCONNECT_ind disc_ind;
 		var BSSAP_Conn_Req creq;
 		var BSSAP_ConnHdlr vc_conn;
 		var PDU_BSSAP bssap;
@@ -277,32 +277,29 @@
 
 		alt {
 		/* SCCP -> Client: UNIT-DATA (connectionless SCCP) from a BSC */
-		[] SCCP.receive(ASP_SCCP_N_UNITDATA_ind:?) -> value ud_ind {
+		[] BSSAP.receive(BSSAP_N_UNITDATA_ind:?) -> value ud_ind {
 			/* Connectionless Procedures like RESET */
 			var template PDU_BSSAP resp;
-			bssap := dec_PDU_BSSAP(ud_ind.userData);
-			resp := ops.unitdata_cb.apply(bssap);
+			resp := ops.unitdata_cb.apply(ud_ind.userData);
 			if (isvalue(resp)) {
-				var octetstring resp_ud := enc_PDU_BSSAP(valueof(resp));
-				SCCP.send(t_ASP_N_UNITDATA_req(ud_ind.callingAddress,
-								ud_ind.calledAddress, omit,
-								omit, resp_ud, omit));
+				BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress,
+								ud_ind.calledAddress, resp));
 			}
 			}
 
 		/* SCCP -> Client: new connection from BSC */
-		[] SCCP.receive(ASP_SCCP_N_CONNECT_ind:?) -> value conn_ind {
+		[] BSSAP.receive(BSSAP_N_CONNECT_ind:?) -> value conn_ind {
 			vc_conn := ops.create_cb.apply(conn_ind, id);
 			/* store mapping between client components and SCCP connectionId */
 			f_conn_table_add(vc_conn, conn_ind.connectionId);
 			/* handle user payload */
 			f_handle_userData(vc_conn, conn_ind.userData);
 			/* confirm connection establishment */
-			SCCP.send(t_ASP_N_CONNECT_res(omit, omit, omit, omit, conn_ind.connectionId, omit));
+			BSSAP.send(ts_BSSAP_CONNECT_res(conn_ind.connectionId, omit));
 			}
 
 		/* SCCP -> Client: connection-oriented data in existing connection */
-		[] SCCP.receive(ASP_SCCP_N_DATA_ind:?) -> value data_ind {
+		[] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value data_ind {
 			vc_conn := f_comp_by_conn_id(data_ind.connectionId);
 			if (ispresent(data_ind.userData)) {
 				f_handle_userData(vc_conn, data_ind.userData);
@@ -310,7 +307,7 @@
 			}
 
 		/* SCCP -> Client: disconnect of an existing connection */
-		[] SCCP.receive(ASP_SCCP_N_DISCONNECT_ind:?) -> value disc_ind {
+		[] BSSAP.receive(BSSAP_N_DISCONNECT_ind:?) -> value disc_ind {
 			vc_conn := f_comp_by_conn_id(disc_ind.connectionId);
 			if (ispresent(disc_ind.userData)) {
 				f_handle_userData(vc_conn, disc_ind.userData);
@@ -323,7 +320,7 @@
 			}
 
 		/* SCCP -> Client: connection confirm for outbound connection */
-		[] SCCP.receive(ASP_SCCP_N_CONNECT_cfm:?) -> value conn_cfm {
+		[] BSSAP.receive(BSSAP_N_CONNECT_cfm:?) -> value conn_cfm {
 			/* handle user payload */
 			if (ispresent(conn_cfm.userData)) {
 				f_handle_userData(vc_conn, conn_cfm.userData);
@@ -333,15 +330,14 @@
 		/* Disconnect request client -> SCCP */
 		[] CLIENT.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_REQ) -> sender vc_conn {
 			var integer conn_id := f_conn_id_by_comp(vc_conn);
-			SCCP.send(t_ASP_N_DISCONNECT_req(omit, 0, omit, conn_id, omit));
+			BSSAP.send(ts_BSSAP_DISC_req(conn_id, 0));
 			f_conn_table_del(conn_id);
 			}
 
 		/* BSSAP from client -> SCCP */
 		[] CLIENT.receive(BSSAP_Conn_Req:?) -> value creq sender vc_conn {
 			var integer conn_id;
-			/* encode + send to dispatcher */
-			var octetstring userdata := enc_PDU_BSSAP(creq.bssap);
+			/* send to dispatcher */
 
 			if (f_comp_known(vc_conn) == false) {
 				/* unknown client, create new connection */
@@ -350,21 +346,20 @@
 				/* store mapping between client components and SCCP connectionId */
 				f_conn_table_add(vc_conn, conn_id);
 
-				SCCP.send(t_ASP_N_CONNECT_req(creq.addr_peer, creq.addr_own, omit, omit,
-								userdata, conn_id, omit));
+				BSSAP.send(ts_BSSAP_CONNECT_req(creq.addr_peer, creq.addr_own, conn_id,
+								creq.bssap));
 			} else {
 				/* known client, send via existing connection */
 				conn_id := f_conn_id_by_comp(vc_conn);
-				SCCP.send(t_ASP_N_DATA_req(userdata, conn_id, omit));
+				BSSAP.send(ts_BSSAP_DATA_req(conn_id, creq.bssap));
 			}
 
 			}
 
 		[] CLIENT.receive(PDU_BSSAP:?) -> value bssap sender vc_conn {
 			var integer conn_id := f_conn_id_by_comp(vc_conn);
-			/* encode + send it to dispatcher */
-			var octetstring userdata := enc_PDU_BSSAP(bssap);
-			SCCP.send(t_ASP_N_DATA_req(userdata, conn_id, omit));
+			/* send it to dispatcher */
+			BSSAP.send(ts_BSSAP_DATA_req(conn_id, bssap));
 			}
 
 		/* Handling of MGCP in IPA SCCPLite case.  This predates 3GPP AoIP

-- 
To view, visit https://gerrit.osmocom.org/5444
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icded789d18f3469f74e16f552df2c7ac44ac4294
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list