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

MNCC_Emulation: Make sure to connect to MNCC sokcket at start of main()

Change-Id: I5f72031693915e4b869f8004404d8d6d276fd66c
---
M library/MNCC_Emulation.ttcn
1 file changed, 39 insertions(+), 2 deletions(-)


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

diff --git a/library/MNCC_Emulation.ttcn b/library/MNCC_Emulation.ttcn
index bcf6c0f..b368816 100644
--- a/library/MNCC_Emulation.ttcn
+++ b/library/MNCC_Emulation.ttcn
@@ -33,6 +33,7 @@
 import from Osmocom_Types all;
 import from MNCC_CodecPort all;
 import from MNCC_Types all;
+import from UD_Types all;
 
 /* General "base class" component definition, of which specific implementations
  * derive themselves by means of the "extends" feature */
@@ -183,12 +184,34 @@
 }
 
 
+function f_connect(charstring sock) runs on MNCC_Emulation_CT {
+       var UD_connect_result res;
+       timer T := 5.0;
+
+       T.start;
+       MNCC.send(UD_connect:{sock, -1});
+       alt {
+       [] MNCC.receive(UD_connect_result:?) -> value res {
+               if (ispresent(res.result) and ispresent(res.result.result_code) 
and res.result.result_code == ERROR) {
+                       setverdict(fail, "Error connecting to MNCC socket", 
res);
+                       self.stop;
+               } else {
+                       g_mncc_ud_id := res.id;
+               }
+               }
+       [] T.timeout {
+               setverdict(fail, "Timeout connecting to MNCC socket");
+               self.stop;
+               }
+       }
+}
+
 /* call-back type, to be provided by specific implementation; called when new 
SCCP connection
  * arrives */
 type function MnccCreateCallback(MNCC_PDU conn_ind, charstring id)
 runs on MNCC_Emulation_CT return MNCC_ConnHdlr;
 
-type function MnccUnitdataCallback(MNCC_PDU mncp)
+type function MnccUnitdataCallback(MNCC_PDU mncc)
 runs on MNCC_Emulation_CT return template MNCC_PDU;
 
 type record MnccOps {
@@ -196,8 +219,9 @@
        MnccUnitdataCallback unitdata_cb
 }
 
-function main(MnccOps ops, charstring id) runs on MNCC_Emulation_CT {
+function main(MnccOps ops, charstring id, charstring sock) runs on 
MNCC_Emulation_CT {
 
+       f_connect(sock);
        f_call_table_init();
 
        while (true) {
@@ -328,6 +352,7 @@
        return ret;
 }
 
+/* server/emulation side function to create expect */
 private function f_create_expect(charstring dest_number, MNCC_ConnHdlr hdlr)
 runs on MNCC_Emulation_CT {
        var integer i;
@@ -342,5 +367,17 @@
        setverdict(fail, "No space left in MnccMnccExpectTable");
 }
 
+/* client/conn_hdlr side function to use procedure port to create expect in 
emulation */
+function f_create_mncc_expect(charstring dest_number) runs on MNCC_ConnHdlr {
+       MNCC_PROC.call(MNCCEM_register:{dest_number, self}) {
+               [] MNCC_PROC.getreply(MNCCEM_register:{?,?}) {};
+       }
+}
+
+function DummyUnitdataCallback(MNCC_PDU mncc)
+runs on MNCC_Emulation_CT return template MNCC_PDU {
+       log("Ignoring MNCC ", mncc);
+       return omit;
+}
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f72031693915e4b869f8004404d8d6d276fd66c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to