MGCP_Templates: Some more convenience extraction functions

Change-Id: I2fc121b1d90327c879a096773ecc5c04faad07d7
This commit is contained in:
Harald Welte 2018-01-29 21:57:26 +01:00
parent 5cfa867ba1
commit 1fe7481174
1 changed files with 17 additions and 4 deletions

View File

@ -273,20 +273,33 @@ module MGCP_Templates {
return ""; return "";
} }
function f_MgcpResp_extract_conn_id(MgcpResponse resp) return MgcpConnectionId { function f_MgcpResp_extract_par(MgcpResponse resp, MgcpInfoCode code) return charstring {
var MgcpMessage msg := { var MgcpMessage msg := {
response := resp response := resp
} }
return str2hex(f_mgcp_extract_par(msg, "I")); return f_mgcp_extract_par(msg, code);
} }
function f_MgcpCmd_extract_call_id(MgcpCommand cmd) return MgcpCallId { function f_MgcpCmd_extract_par(MgcpCommand cmd, MgcpInfoCode code) return charstring {
var MgcpMessage msg := { var MgcpMessage msg := {
command := cmd command := cmd
} }
return str2hex(f_mgcp_extract_par(msg, "C")); return f_mgcp_extract_par(msg, code);
} }
function f_MgcpResp_extract_conn_id(MgcpResponse resp) return MgcpConnectionId {
return str2hex(f_MgcpResp_extract_par(resp, "I"));
}
function f_MgcpCmd_extract_call_id(MgcpCommand cmd) return MgcpCallId {
return str2hex(f_MgcpCmd_extract_par(cmd, "C"));
}
function f_MgcpCmd_extract_conn_id(MgcpCommand cmd) return MgcpConnectionId {
return str2hex(f_MgcpCmd_extract_par(cmd, "I"));
}
function f_mgcp_alloc_tid() return MgcpTransId { function f_mgcp_alloc_tid() return MgcpTransId {
return int2str(float2int(rnd()*2147483647.0)); return int2str(float2int(rnd()*2147483647.0));
} }