aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2024-03-21 17:21:35 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2024-03-22 11:28:51 +0100
commit1158cc629c0bf6def66ddecd01281da3aa1ba1d7 (patch)
tree3a3ce87c2d3422d350aec22177541269f563f48f /library
parenta16a6b667b3acc25a04990fe9ecc162a0d55a893 (diff)
Move SDP templates to its own SDP_Templates.ttcn file
SDP is used in other protocols than MGCP, eg. SIP. Change-Id: I0610b4cf5533e46a3401c65e60c7cce975c85412
Diffstat (limited to 'library')
-rw-r--r--library/MGCP_Templates.ttcn137
-rw-r--r--library/SDP_Templates.ttcn159
2 files changed, 160 insertions, 136 deletions
diff --git a/library/MGCP_Templates.ttcn b/library/MGCP_Templates.ttcn
index 747700f0..85129e8b 100644
--- a/library/MGCP_Templates.ttcn
+++ b/library/MGCP_Templates.ttcn
@@ -12,6 +12,7 @@ module MGCP_Templates {
import from MGCP_Types all;
import from SDP_Types all;
+import from SDP_Templates all;
function f_mgcp_par_append(inout template MgcpParameterList list, template MgcpParameter par) {
var integer len := lengthof(list);
@@ -288,142 +289,6 @@ template MgcpCommand tr_RSIP := {
sdp := *
}
-/* SDP Templates */
-template SDP_Origin ts_SDP_origin(charstring addr, charstring session_id,
- charstring session_version := "1",
- charstring addr_type := "IP4",
- charstring user_name := "-") := {
- user_name := user_name,
- session_id := session_id,
- session_version := session_version,
- net_type := "IN",
- addr_type := addr_type,
- addr := addr
-}
-
-template SDP_connection ts_SDP_connection_IP(charstring addr, charstring addr_type := "IP4",
- template integer ttl := omit,
- template integer num_of_addr := omit) :={
- net_type := "IN",
- addr_type := addr_type,
- conn_addr := {
- addr := addr,
- ttl := ttl,
- num_of_addr := num_of_addr
- }
-}
-
-template SDP_connection tr_SDP_connection_IP(template charstring addr, template charstring addr_type := ?,
- template integer ttl := *,
- template integer num_of_addr := *) := {
- net_type := "IN",
- addr_type := addr_type,
- conn_addr := {
- addr := addr,
- ttl := ttl,
- num_of_addr := num_of_addr
- }
-}
-
-template SDP_time ts_SDP_time(charstring beg, charstring end) := {
- time_field := {
- start_time := beg,
- stop_time := end
- },
- time_repeat := omit
-}
-
-template SDP_media_desc ts_SDP_media_desc(integer port_number, SDP_fmt_list fmts,
- SDP_attribute_list attributes) := {
- media_field := {
- media := "audio",
- ports := {
- port_number := port_number,
- num_of_ports := omit
- },
- transport := "RTP/AVP",
- fmts := fmts
- },
- information := omit,
- connections := omit,
- bandwidth := omit,
- key := omit,
- attributes := attributes
-}
-
-template SDP_media_desc tr_SDP_media_desc(template integer port_number := ?,
- template SDP_fmt_list fmts := ?,
- template SDP_attribute_list attributes := ?) := {
- media_field := {
- media := "audio",
- ports := {
- port_number := port_number,
- num_of_ports := omit
- },
- transport := "RTP/AVP",
- fmts := fmts
- },
- information := *,
- connections := *,
- bandwidth := *,
- key := *,
- attributes := attributes
-}
-
-/* master template for generating SDP based in template arguments */
-template SDP_Message ts_SDP(charstring local_addr, charstring remote_addr,
- charstring session_id, charstring session_version,
- integer rtp_port, SDP_fmt_list fmts,
- SDP_attribute_list attributes) := {
- protocol_version := 0,
- origin := ts_SDP_origin(local_addr, session_id, session_version, f_mgcp_addr2addrtype(local_addr)),
- session_name := "-",
- information := omit,
- uri := omit,
- emails := omit,
- phone_numbers := omit,
- connection := ts_SDP_connection_IP(remote_addr, f_mgcp_addr2addrtype(remote_addr)),
- bandwidth := omit,
- times := { ts_SDP_time("0","0") },
- timezone_adjustments := omit,
- key := omit,
- attributes := omit,
- media_list := { ts_SDP_media_desc(rtp_port, fmts, attributes) }
-}
-
-template SDP_Message tr_SDP(template charstring remote_addr := ?, template integer rtp_port := ?) := {
- protocol_version := 0,
- origin := ?,
- session_name := ?,
- information := *,
- uri := *,
- emails := *,
- phone_numbers := *,
- connection := tr_SDP_connection_IP(remote_addr, ?),
- bandwidth := *,
- times := ?,
- timezone_adjustments := *,
- key := *,
- attributes := *,
- media_list := { tr_SDP_media_desc(rtp_port) }
-}
-
-template SDP_attribute ts_SDP_rtpmap(integer fmt, charstring val) := {
- rtpmap := {
- attr_value := int2str(fmt) & " " & val
- }
-}
-template SDP_attribute ts_SDP_ptime(integer p) := {
- ptime := {
- attr_value := int2str(p)
- }
-}
-template SDP_attribute ts_SDP_fmtp(integer fmt, charstring val) := {
- fmtp := {
- attr_value := int2str(fmt) & " " & val
- }
-}
-
function f_mgcp_addr2addrtype(charstring addr) return charstring {
for (var integer i := 0; i < lengthof(addr); i := i + 1) {
if (addr[i] == ":") {
diff --git a/library/SDP_Templates.ttcn b/library/SDP_Templates.ttcn
new file mode 100644
index 00000000..525da8e6
--- /dev/null
+++ b/library/SDP_Templates.ttcn
@@ -0,0 +1,159 @@
+module SDP_Templates {
+
+/* SDP Templates, building on top of SDP_Types from Ericsson.
+ *
+ * (C) 2017 by Harald Welte <laforge@gnumonks.org>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ */
+
+import from SDP_Types all;
+
+/* SDP Templates */
+template SDP_Origin ts_SDP_origin(charstring addr, charstring session_id,
+ charstring session_version := "1",
+ charstring addr_type := "IP4",
+ charstring user_name := "-") := {
+ user_name := user_name,
+ session_id := session_id,
+ session_version := session_version,
+ net_type := "IN",
+ addr_type := addr_type,
+ addr := addr
+}
+
+template SDP_connection ts_SDP_connection_IP(charstring addr, charstring addr_type := "IP4",
+ template integer ttl := omit,
+ template integer num_of_addr := omit) :={
+ net_type := "IN",
+ addr_type := addr_type,
+ conn_addr := {
+ addr := addr,
+ ttl := ttl,
+ num_of_addr := num_of_addr
+ }
+}
+
+template SDP_connection tr_SDP_connection_IP(template charstring addr, template charstring addr_type := ?,
+ template integer ttl := *,
+ template integer num_of_addr := *) := {
+ net_type := "IN",
+ addr_type := addr_type,
+ conn_addr := {
+ addr := addr,
+ ttl := ttl,
+ num_of_addr := num_of_addr
+ }
+}
+
+template SDP_time ts_SDP_time(charstring beg, charstring end) := {
+ time_field := {
+ start_time := beg,
+ stop_time := end
+ },
+ time_repeat := omit
+}
+
+template SDP_media_desc ts_SDP_media_desc(integer port_number, SDP_fmt_list fmts,
+ SDP_attribute_list attributes) := {
+ media_field := {
+ media := "audio",
+ ports := {
+ port_number := port_number,
+ num_of_ports := omit
+ },
+ transport := "RTP/AVP",
+ fmts := fmts
+ },
+ information := omit,
+ connections := omit,
+ bandwidth := omit,
+ key := omit,
+ attributes := attributes
+}
+
+template SDP_media_desc tr_SDP_media_desc(template integer port_number := ?,
+ template SDP_fmt_list fmts := ?,
+ template SDP_attribute_list attributes := ?) := {
+ media_field := {
+ media := "audio",
+ ports := {
+ port_number := port_number,
+ num_of_ports := omit
+ },
+ transport := "RTP/AVP",
+ fmts := fmts
+ },
+ information := *,
+ connections := *,
+ bandwidth := *,
+ key := *,
+ attributes := attributes
+}
+
+/* master template for generating SDP based in template arguments */
+template SDP_Message ts_SDP(charstring local_addr, charstring remote_addr,
+ charstring session_id, charstring session_version,
+ integer rtp_port, SDP_fmt_list fmts,
+ SDP_attribute_list attributes) := {
+ protocol_version := 0,
+ origin := ts_SDP_origin(local_addr, session_id, session_version, f_sdp_addr2addrtype(local_addr)),
+ session_name := "-",
+ information := omit,
+ uri := omit,
+ emails := omit,
+ phone_numbers := omit,
+ connection := ts_SDP_connection_IP(remote_addr, f_sdp_addr2addrtype(remote_addr)),
+ bandwidth := omit,
+ times := { ts_SDP_time("0","0") },
+ timezone_adjustments := omit,
+ key := omit,
+ attributes := omit,
+ media_list := { ts_SDP_media_desc(rtp_port, fmts, attributes) }
+}
+
+template SDP_Message tr_SDP(template charstring remote_addr := ?, template integer rtp_port := ?) := {
+ protocol_version := 0,
+ origin := ?,
+ session_name := ?,
+ information := *,
+ uri := *,
+ emails := *,
+ phone_numbers := *,
+ connection := tr_SDP_connection_IP(remote_addr, ?),
+ bandwidth := *,
+ times := ?,
+ timezone_adjustments := *,
+ key := *,
+ attributes := *,
+ media_list := { tr_SDP_media_desc(rtp_port) }
+}
+
+template SDP_attribute ts_SDP_rtpmap(integer fmt, charstring val) := {
+ rtpmap := {
+ attr_value := int2str(fmt) & " " & val
+ }
+}
+template SDP_attribute ts_SDP_ptime(integer p) := {
+ ptime := {
+ attr_value := int2str(p)
+ }
+}
+template SDP_attribute ts_SDP_fmtp(integer fmt, charstring val) := {
+ fmtp := {
+ attr_value := int2str(fmt) & " " & val
+ }
+}
+
+function f_sdp_addr2addrtype(charstring addr) return charstring {
+ for (var integer i := 0; i < lengthof(addr); i := i + 1) {
+ if (addr[i] == ":") {
+ return "IP6";
+ }
+ }
+ return "IP4";
+}
+
+}