ipa: First version that emulates both MSC and BSC up to ASSIGNMENT REQ
diff --git a/library/IPA_Emulation.ttcn b/library/IPA_Emulation.ttcn
index 4d21bb4..ed51110 100644
--- a/library/IPA_Emulation.ttcn
+++ b/library/IPA_Emulation.ttcn
@@ -12,6 +12,11 @@
}
*/
+type enumerated IpaMode {
+ IPA_MODE_CLIENT,
+ IPA_MODE_SERVER
+}
+
type record ASP_IPA_Unitdata {
IpaStreamId streamId,
octetstring payload
@@ -31,6 +36,8 @@
var boolean g_initialized := false;
var ConnectionId g_ipa_conn_id := -1;
+
+ var IpaMode g_mode;
}
function f_connect(charstring remote_host, PortNumber remote_port,
@@ -41,6 +48,13 @@
g_ipa_conn_id := res.connId;
}
+function f_bind(charstring local_host, PortNumber local_port) runs on IPA_Emulation_CT {
+ var Result res;
+ res := IPA_CodecPort_CtrlFunct.f_IPL4_listen(IPA_PORT,
+ local_host, local_port, { tcp:={} });
+ g_ipa_conn_id := res.connId;
+}
+
template ASP_MTP3_TRANSFERind ts_MTP3_XFER_ind(integer opc, octetstring data) := {
sio := { '10'B, '00'B, '0011'B },
opc := opc,
@@ -107,6 +121,15 @@
u := omit
}
+template PDU_IPA_CCM ts_IPA_ID_GET := {
+ msg_type := IPAC_MSGT_ID_GET,
+ u := {
+ get := {
+ { 1, IPAC_IDTAG_UNITNAME }
+ }
+ }
+}
+
/* receive IPA CCM message */
private function f_ccm_rx(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT {
select (ccm.msg_type) {
@@ -142,12 +165,24 @@
return ret;
}
-function ScanEvents() runs on IPA_Emulation_CT {
+function main_client(charstring remote_host, PortNumber remote_port,
+ charstring local_host, PortNumber local_port) runs on IPA_Emulation_CT {
+ g_mode := IPA_MODE_CLIENT;
+ f_connect(remote_host, remote_port, local_host, local_port);
+ ScanEvents();
+}
+
+function main_server(charstring local_host, PortNumber local_port) runs on IPA_Emulation_CT {
+ g_mode := IPA_MODE_SERVER;
+ f_bind(local_host, local_port);
+ ScanEvents();
+}
+
+private function ScanEvents() runs on IPA_Emulation_CT {
var IPA_RecvFrom ipa_rx;
var ASP_IPA_Unitdata ipa_ud;
var ASP_MTP3_TRANSFERreq mtp_req;
-
- f_connect("127.0.0.1", 5000, "127.0.0.1", 49999);
+ var ASP_Event asp_evt;
while (true) {
alt {
@@ -170,6 +205,21 @@
}
}
+ /* server only */
+ [] IPA_PORT.receive(ASP_Event:{connOpened:=?}) -> value asp_evt {
+ log("IPA: Connected");
+ g_ipa_conn_id := asp_evt.connOpened.connId;
+ if (g_mode == IPA_MODE_SERVER) {
+ f_ccm_tx(valueof(ts_IPA_ID_GET));
+ }
+ }
+
+ [] IPA_PORT.receive(ASP_Event:{connClosed:=?}) -> value asp_evt {
+ log("IPA: Closed");
+ g_ipa_conn_id := -1;
+ self.stop;
+ }
+
/* Received SCCP -> down into IPA */
[] MTP3_SP_PORT.receive(ASP_MTP3_TRANSFERreq: ?) -> value mtp_req {
var IPA_Send ipa_tx := {