move MGCP utility functions from MSC_ConnectionHandler to MGCP_Templates
diff --git a/ipa/MSC_ConnectionHandler.ttcn b/ipa/MSC_ConnectionHandler.ttcn
index 53123fe..e97c6a1 100644
--- a/ipa/MSC_ConnectionHandler.ttcn
+++ b/ipa/MSC_ConnectionHandler.ttcn
@@ -67,26 +67,6 @@
MSC_STATE_WAIT_DLCX_ACK
}
-private function f_mgcp_alloc_tid() return MgcpTransId {
- return int2str(float2int(rnd()*2147483647.0));
-}
-
-private function f_mgcp_alloc_call_id() return MgcpCallId {
- return int2hex(float2int(rnd()*2147483647.0), 8);
-}
-
-function extract_conn_id(MgcpResponse resp) return MgcpConnectionId {
- var integer i;
- for (i := 0; i < lengthof(resp.params); i := i + 1) {
- var MgcpParameter par := resp.params[i];
- if (par.code == "I") {
- return str2hex(par.val);
- }
- }
- setverdict(fail);
- return '00000000'H;
-}
-
/* main function processing various incoming events */
function main(integer connection_id, integer timeslot) runs on MSC_ConnHdlr {
var MgcpResponse mgcp_rsp;
@@ -121,7 +101,7 @@
/* receive CRCX ACK: transmit MDCX */
[g_state == MSC_STATE_WAIT_CRCX_ACK] BSSAP.receive(tr_CRCX_ACK) -> value mgcp_rsp {
/* extract connection ID */
- g_mgcp_conn_id := extract_conn_id(mgcp_rsp);
+ g_mgcp_conn_id := f_MgcpResp_extract_conn_id(mgcp_rsp);
g_state := MSC_STATE_WAIT_MDCX_ACK;
var MgcpTransId trans_id := f_mgcp_alloc_tid();
BSSAP.send(ts_MDCX(trans_id, g_ep_name, "sendrecv", g_call_id, g_mgcp_conn_id));
diff --git a/library/MGCP_Templates.ttcn b/library/MGCP_Templates.ttcn
index 7a67c41..8b9aae9 100644
--- a/library/MGCP_Templates.ttcn
+++ b/library/MGCP_Templates.ttcn
@@ -196,4 +196,28 @@
}
}
+ function f_MgcpResp_extract_conn_id(MgcpResponse resp) return MgcpConnectionId {
+ var integer i;
+ for (i := 0; i < lengthof(resp.params); i := i + 1) {
+ var MgcpParameter par := resp.params[i];
+ if (par.code == "I") {
+ return str2hex(par.val);
+ }
+ }
+ setverdict(fail);
+ return '00000000'H;
+ }
+
+ function f_mgcp_alloc_tid() return MgcpTransId {
+ return int2str(float2int(rnd()*2147483647.0));
+ }
+
+ function f_mgcp_alloc_call_id() return MgcpCallId {
+ return int2hex(float2int(rnd()*2147483647.0), 8);
+ }
+
+ function f_mgcp_alloc_conn_id() return MgcpConnectionId {
+ return int2hex(float2int(rnd()*2147483647.0), 8);
+ }
+
}