Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/14142


Change subject: bsc-nat: Introduce Osmux test
......................................................................

bsc-nat: Introduce Osmux test

Depends: openbsc.git Iadc004064a5a237c93009f242cb943ebc4d2d7e6
Change-Id: I35f206aab713ccf0a4e074872e291c349c903b9d
---
M bsc-nat/BSCNAT_Tests.default
M bsc-nat/BSCNAT_Tests.ttcn
M bsc-nat/BSC_MS_ConnectionHandler.ttcn
M bsc-nat/BSC_MS_Simulation.ttcn
M bsc-nat/gen_links.sh
M bsc-nat/regen_makefile.sh
6 files changed, 80 insertions(+), 12 deletions(-)



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

diff --git a/bsc-nat/BSCNAT_Tests.default b/bsc-nat/BSCNAT_Tests.default
index 37c1048..3374bcf 100644
--- a/bsc-nat/BSCNAT_Tests.default
+++ b/bsc-nat/BSCNAT_Tests.default
@@ -4,8 +4,19 @@

 [TESTPORT_PARAMETERS]
 #*.*.udpReuseAddress := "yes";
+*.BSCNATVTY.CTRL_MODE := "client"
+*.BSCNATVTY.CTRL_HOSTNAME := "127.0.0.1"
+*.BSCNATVTY.CTRL_PORTNUM := "4244"
+*.BSCNATVTY.CTRL_LOGIN_SKIPPED := "yes"
+*.BSCNATVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"
+*.BSCNATVTY.CTRL_READMODE := "buffered"
+*.BSCNATVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
+*.BSCNATVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
+*.BSCNATVTY.PROMPT1 := "OsmoBSCNAT> "
+

 [MODULE_PARAMETERS]
+Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoBSCNAT";
 mp_bsc_port := 49999;
 mp_bsc_ip   := "127.0.0.1";
 mp_msc_port := 5100;
@@ -22,4 +33,3 @@
 mp_mgw_udp_port := 2427;

 [EXECUTE]
-
diff --git a/bsc-nat/BSCNAT_Tests.ttcn b/bsc-nat/BSCNAT_Tests.ttcn
index 993d668..104e89f 100644
--- a/bsc-nat/BSCNAT_Tests.ttcn
+++ b/bsc-nat/BSCNAT_Tests.ttcn
@@ -15,6 +15,9 @@
 import from MSC_Simulation all;
 import from BSC_MS_Simulation all;

+import from Osmocom_VTY_Functions all;
+import from TELNETasp_PortType all;
+
 const integer NUM_MSC := 1;
 const integer NUM_BSC := 1;

@@ -35,6 +38,8 @@
        var MscState msc[NUM_MSC];
        var BscState bsc[NUM_BSC];

+       port TELNETasp_PT BSCNATVTY;
+
        var boolean g_initialized := false;
        var octetstring g_sio := '83'O;
 }
@@ -101,10 +106,31 @@
        msc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn));
 }

-function f_init() runs on test_CT {
+function f_vty_allow_osmux(boolean allow) runs on test_CT {
+       if (allow) {
+               f_vty_config(BSCNATVTY, "mgcp", "osmux on");
+       } else {
+               f_vty_config(BSCNATVTY, "mgcp", "osmux off");
+       }
+}
+
+function f_init_vty(charstring id := "foo") runs on test_CT {
+       if (BSCNATVTY.checkstate("Mapped")) {
+               /* skip initialization if already executed once */
+               return;
+       }
+       map(self:BSCNATVTY, system:BSCNATVTY);
+       f_vty_set_prompts(BSCNATVTY);
+       f_vty_transceive(BSCNATVTY, "enable");
+}
+
+function f_init(boolean use_osmux) runs on test_CT {
        var integer i;
        var charstring id;

+       f_init_vty("VirtBSCNAT");
+       f_vty_allow_osmux(use_osmux);
+
        for (i := 0; i < NUM_MSC; i := i+1) {
                f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, 
mp_bsc_ssn);
                id := "MSC" & int2str(i);
@@ -114,22 +140,23 @@

        /* Wait for bsc_nat to attach to MSC. Before that all BSC connections 
will be dropped */
        f_sleep(5.0);
+
        for (i := 0; i < NUM_BSC; i := i+1) {
                f_init_BscState(bsc[i], mp_bsc_pc +i, mp_msc_pc, mp_bsc_ssn, 
mp_msc_ssn);
                id := "BSC" & int2str(i);
                bsc[i].BSC := BSC_CT.create(id);
                bsc[i].BSC.start(BSC_MS_Simulation.main(mp_nat_ip, mp_nat_port, 
mp_bsc_ip, mp_bsc_port+i,
                                                        bsc[i].sccp_pars, 
bsc[i].sccp_addr_own,
-                                                       bsc[i].sccp_addr_peer, 
id));
+                                                       bsc[i].sccp_addr_peer, 
use_osmux, id));
        }

 }

-testcase TC_recv_dump() runs on test_CT {
+function f_TC_recv_dump(boolean use_osmux := false) runs on test_CT {
        var integer i;
        timer T := 30.0;

-       f_init();
+       f_init(use_osmux);

        alt {
                /* wait for BSC to stop. The idea is that the BSC components 
terminate first */
@@ -144,8 +171,17 @@
        }
 }

+testcase TC_recv_dump() runs on test_CT {
+       f_TC_recv_dump();
+}
+
+testcase TC_recv_dump_osmux() runs on test_CT {
+       f_TC_recv_dump(true);
+}
+
 control {
        execute( TC_recv_dump() );
+       execute( TC_recv_dump_osmux() );
 }

 }
diff --git a/bsc-nat/BSC_MS_ConnectionHandler.ttcn 
b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
index 28ff349..eb376db 100644
--- a/bsc-nat/BSC_MS_ConnectionHandler.ttcn
+++ b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
@@ -54,6 +54,7 @@
        decode_dtap := false,
        role_ms := true,
        protocol := RAN_PROTOCOL_BSSAP,
+       /* Always false. We don't want to enable Osmux signalling in SCCPLite 
messages: */
        use_osmux := false,
        sccp_addr_local := omit,
        sccp_addr_peer := omit
@@ -80,11 +81,12 @@
 }

 /* main function processing various incoming events */
-function main(SCCP_PAR_Address sccp_addr_own, SCCP_PAR_Address 
sccp_addr_remote)
+function main(SCCP_PAR_Address sccp_addr_own, SCCP_PAR_Address 
sccp_addr_remote, boolean use_osmux)
 runs on BSC_MS_ConnHdlr {
        var PDU_BSSAP bssap;
        var MgcpCommand mgcp_cmd;
-       var MgcpResponse mgcp_resp;
+       var template MgcpResponse mgcp_resp;
+       var MgcpOsmuxCID osmux_cid;

        log("Starting main of BSC_MS_ConnHdlr");

@@ -118,7 +120,19 @@
                                                  valueof(ts_SDP_ptime(20)) }));
                        /* respond with CRCX_ACK */
                        g_state := BSC_STATE_WAIT_MDCX;
-                       BSSAP.send(ts_CRCX_ACK(mgcp_cmd.line.trans_id, 
g_mgcp_conn_id, g_sdp));
+
+                       if (use_osmux != f_MgcpCmd_contains_par(mgcp_cmd, 
"X-OSMUX")) {
+                               setverdict(fail, log2str("Received Osmux CID 
presence doesn't match presence expectancy (", use_osmux, ")"));
+                               self.stop;
+                       }
+
+                       if (use_osmux) {
+                               osmux_cid := 
f_MgcpCmd_extract_osmux_cid(mgcp_cmd);
+                               mgcp_resp := 
ts_CRCX_ACK_osmux(mgcp_cmd.line.trans_id, g_mgcp_conn_id, osmux_cid, g_sdp);
+                       } else {
+                               mgcp_resp := 
ts_CRCX_ACK(mgcp_cmd.line.trans_id, g_mgcp_conn_id, g_sdp);
+                       }
+                       BSSAP.send(valueof(mgcp_resp));
                        }

                /* MDCX -> OK */
diff --git a/bsc-nat/BSC_MS_Simulation.ttcn b/bsc-nat/BSC_MS_Simulation.ttcn
index c45b5ac..bab1fab 100644
--- a/bsc-nat/BSC_MS_Simulation.ttcn
+++ b/bsc-nat/BSC_MS_Simulation.ttcn
@@ -23,6 +23,7 @@

        var SCCP_PAR_Address g_sccp_addr_own;
        var SCCP_PAR_Address g_sccp_addr_remote;
+       var boolean g_use_osmux;

        var charstring g_bsc_num_str;
 }
@@ -35,7 +36,8 @@
                charstring local_ip, PortNumber local_port,
                MSC_SCCP_MTP3_parameters sccp_pars,
                SCCP_PAR_Address sccp_addr_own,
-               SCCP_PAR_Address sccp_addr_remote, charstring id) runs on BSC_CT
+               SCCP_PAR_Address sccp_addr_remote,
+               boolean use_osmux, charstring id) runs on BSC_CT
 {
        var integer i := 0;
        timer T := 1.0;
@@ -44,6 +46,7 @@

        g_sccp_addr_own := sccp_addr_own;
        g_sccp_addr_remote := sccp_addr_remote;
+       g_use_osmux := use_osmux;

        /* create components for IPA/SCCP/BSS[M]AP stack */
        vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
@@ -88,7 +91,7 @@
        /* connect client BSSAP port to BSSAP dispatcher */
        connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
        /* start component */
-       vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, 
g_sccp_addr_remote));
+       vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, 
g_sccp_addr_remote, g_use_osmux));
        /* blocking wait until component terminates.  If you want to start MSs 
in parallel,
         * you have to remove this statement here */
        vc_conn.done;
diff --git a/bsc-nat/gen_links.sh b/bsc-nat/gen_links.sh
index 7b7f928..01d4c7b 100755
--- a/bsc-nat/gen_links.sh
+++ b/bsc-nat/gen_links.sh
@@ -20,6 +20,11 @@
 FILES="IPL4asp_Functions.ttcn  IPL4asp_PT.cc  IPL4asp_PT.hh 
IPL4asp_PortType.ttcn  IPL4asp_Types.ttcn  IPL4asp_discovery.cc 
IPL4asp_protocol_L234.hh"
 gen_links $DIR $FILES
 
+# for Osmocom_VTY
+DIR=$BASEDIR/titan.TestPorts.TELNETasp/src
+FILES="TELNETasp_PT.cc  TELNETasp_PT.hh  TELNETasp_PortType.ttcn"
+gen_links $DIR $FILES
+
 # required by SCCP Emulation
 DIR=$BASEDIR/titan.TestPorts.MTP3asp/src
 FILES="MTP3asp_PortType.ttcn  MTP3asp_Types.ttcn"
@@ -47,7 +52,7 @@
 gen_links $DIR $FILES

 DIR=../library
-FILES="Misc_Helpers.ttcn 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.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn RAN_Emulation.ttcnpp MGCP_Types.ttcn MGCP_Templates.ttcn 
MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn 
MGCP_CodecPort_CtrlFunctDef.cc Osmocom_CTRL_Types.ttcn 
Osmocom_CTRL_Functions.ttcn BSSAP_CodecPort.ttcn"
+FILES="Misc_Helpers.ttcn 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.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn RAN_Emulation.ttcnpp MGCP_Types.ttcn MGCP_Templates.ttcn 
MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn 
MGCP_CodecPort_CtrlFunctDef.cc Osmocom_CTRL_Types.ttcn 
Osmocom_VTY_Functions.ttcn Osmocom_CTRL_Functions.ttcn BSSAP_CodecPort.ttcn"
 gen_links $DIR $FILES

 ignore_pp_results
diff --git a/bsc-nat/regen_makefile.sh b/bsc-nat/regen_makefile.sh
index f49df7e..0f3cfab 100755
--- a/bsc-nat/regen_makefile.sh
+++ b/bsc-nat/regen_makefile.sh
@@ -2,7 +2,7 @@

 MAIN=BSCNAT_Tests.ttcn

-FILES="*.ttcn *.ttcnpp SCCP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc 
IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc 
RTP_EncDec.cc SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc"
+FILES="*.ttcn *.ttcnpp SCCP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc 
IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc 
RTP_EncDec.cc SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc TELNETasp_PT.cc"

 export CPPFLAGS_TTCN3="-DIPA_EMULATION_SCCP -DIPA_EMULATION_MGCP 
-DRAN_EMULATION_BSSAP -DRAN_EMULATION_MGCP -DUSE_MTP3_DISTRIBUTOR"


--
To view, visit https://gerrit.osmocom.org/14142
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I35f206aab713ccf0a4e074872e291c349c903b9d
Gerrit-Change-Number: 14142
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <[email protected]>

Reply via email to