Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 1 | module MGCP_Test { |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 2 | import from Osmocom_Types all; |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 3 | import from MGCP_Types all; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 4 | import from SDP_Types all; |
| 5 | import from MGCP_CodecPort all; |
| 6 | import from MGCP_CodecPort_CtrlFunct all; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 7 | import from RTP_CodecPort all; |
| 8 | import from RTP_CodecPort_CtrlFunct all; |
| 9 | import from RTP_Endpoint all; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 10 | import from IPL4asp_Types all; |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 11 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 12 | /* any variables declared in the component will be available to |
| 13 | * all functions that 'run on' the named component, similar to |
| 14 | * class members in C++ */ |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 15 | type component dummy_CT { |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 16 | port MGCP_CODEC_PT MGCP; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 17 | port RTP_CODEC_PT RTP; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 18 | var boolean initialized := false; |
Harald Welte | 5501536 | 2017-11-18 16:02:42 +0100 | [diff] [blame] | 19 | var ConnectionId g_mgcp_conn_id := -1; |
Harald Welte | e1e18c5 | 2017-09-17 16:23:07 +0800 | [diff] [blame] | 20 | var integer g_trans_id; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 21 | |
| 22 | var RtpEndpoint g_rtp_ep[2]; |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 23 | }; |
| 24 | |
Harald Welte | e1e18c5 | 2017-09-17 16:23:07 +0800 | [diff] [blame] | 25 | function get_next_trans_id() runs on dummy_CT return MgcpTransId { |
| 26 | var MgcpTransId tid := int2str(g_trans_id); |
| 27 | g_trans_id := g_trans_id + 1; |
| 28 | return tid; |
| 29 | } |
| 30 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 31 | /* all parameters declared here can be modified / overridden by |
| 32 | * the config file in the [MODULE_PARAMETERS] section. If no |
| 33 | * config file is used or the file doesn't specify them, the |
| 34 | * default values assigned below are used */ |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 35 | modulepar { |
| 36 | PortNumber mp_local_udp_port := 2727; |
| 37 | charstring mp_local_ip := "127.0.0.1"; |
| 38 | PortNumber mp_remote_udp_port := 2427; |
| 39 | charstring mp_remote_ip := "127.0.0.1"; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 40 | PortNumber mp_local_rtp_port_base := 10000; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 41 | } |
| 42 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 43 | /* initialization function, called by each test case at the |
| 44 | * beginning, but 'initialized' variable ensures its body is |
| 45 | * only executed once */ |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 46 | private function f_init(template MgcpEndpoint ep := omit) runs on dummy_CT { |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 47 | var Result res; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 48 | var uint32_t ssrc; |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 49 | if (initialized == false) { |
| 50 | initialized := true; |
| 51 | |
| 52 | /* some random number for the initial transaction id */ |
| 53 | g_trans_id := float2int(rnd()*65535.0); |
| 54 | map(self:MGCP, system:MGCP_CODEC_PT); |
| 55 | /* connect the MGCP test port using the given |
| 56 | * source/destionation ip/port and store the connection id in g_mgcp_conn_id |
| 57 | * */ |
| 58 | res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP, mp_remote_ip, mp_remote_udp_port, mp_local_ip, mp_local_udp_port, 0, { udp := {} }); |
| 59 | g_mgcp_conn_id := res.connId; |
| 60 | |
| 61 | map(self:RTP, system:RTP_CODEC_PT); |
| 62 | ssrc := float2int(rnd()*4294967296.0); |
| 63 | rtp_endpoint_init(g_rtp_ep[0], mp_local_ip, mp_local_rtp_port_base, ssrc); |
| 64 | rtp_endpoint_bind(RTP, g_rtp_ep[0]); |
| 65 | rtp_endpoint_init(g_rtp_ep[1], mp_local_ip, mp_local_rtp_port_base+2, ssrc); |
| 66 | rtp_endpoint_bind(RTP, g_rtp_ep[1]); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 67 | } |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 68 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 69 | if (isvalue(ep)) { |
| 70 | /* do a DLCX on all connections of the EP */ |
| 71 | f_dlcx_ignore(valueof(ep)); |
| 72 | } |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 73 | } |
| 74 | |
Harald Welte | 8d2fbb4 | 2017-11-18 20:34:21 +0100 | [diff] [blame] | 75 | function f_mgcp_par_append(inout template MgcpParameterList list, template MgcpParameter par) { |
| 76 | var integer len := lengthof(list); |
| 77 | list[len] := par; |
| 78 | } |
| 79 | |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 80 | /* 3.2.2.6 Connection Mode (sendonly, recvonly, sendrecv, confrnce, inactive, loopback, |
| 81 | * conttest, netwloop, netwtest) */ |
| 82 | template MgcpParameter t_MgcpParConnMode(template MgcpConnectionMode mode) := { "M", mode }; |
| 83 | |
| 84 | /* 3.2.2.2 CallId: maximum 32 hex chars */ |
| 85 | template MgcpParameter ts_MgcpParCallId(MgcpCallId cid) := { |
| 86 | code := "C", |
| 87 | val := hex2str(cid) |
| 88 | }; |
| 89 | |
| 90 | /* 3.2.2.18 RequestIdentifier: Maximum 32 hex chars */ |
| 91 | template MgcpParameter ts_MgcpParReqId(MgcpRequestId rid) := { |
| 92 | code := "X", |
| 93 | val := hex2str(rid) |
| 94 | }; |
| 95 | |
| 96 | /* 3.2.2.10: LocalConnectionOptions (codec, packetization, bandwidth, ToS, eco, gain, silence, ...) */ |
| 97 | template MgcpParameter t_MgcpParLocConnOpt(template charstring lco) := { "L", lco }; |
| 98 | |
| 99 | /* 3.2.2.5: ConnectionId: maximum 32 hex chars */ |
| 100 | template MgcpParameter ts_MgcpParConnectionId(MgcpConnectionId cid) := { |
| 101 | code := "I", |
| 102 | val := hex2str(cid) |
| 103 | }; |
| 104 | |
| 105 | /* osmo-bsc_mgcp implements L/C/M/X only, osmo-mgw adds 'I' */ |
| 106 | /* SDP: osmo-bsc_mgcp implements Tx of v,o,s,c,t,m,a */ |
| 107 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 108 | template MgcpResponse tr_MgcpResp_Err(template MgcpResponseCode code) := { |
| 109 | line := { |
| 110 | code := code, |
| 111 | trans_id := ?, |
| 112 | string := ? |
| 113 | }, |
| 114 | params := {}, |
| 115 | sdp := omit |
| 116 | } |
| 117 | |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 118 | template MgcpCommandLine t_MgcpCmdLine(template charstring verb, template MgcpTransId trans_id, template charstring ep) := { |
| 119 | verb := verb, |
| 120 | trans_id := trans_id, |
| 121 | ep := ep, |
| 122 | ver := "1.0" |
| 123 | }; |
| 124 | |
| 125 | template MgcpCommand ts_CRCX(MgcpTransId trans_id, charstring ep, MgcpConnectionMode mode, MgcpCallId call_id, template SDP_Message sdp := omit) := { |
| 126 | line := t_MgcpCmdLine("CRCX", trans_id, ep), |
| 127 | params := { |
| 128 | t_MgcpParConnMode(mode), |
| 129 | ts_MgcpParCallId(call_id), |
| 130 | //t_MgcpParReqId(omit), |
Harald Welte | 5e5cce5 | 2017-11-18 22:13:51 +0100 | [diff] [blame] | 131 | t_MgcpParLocConnOpt("p:20, a:PCMU") |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 132 | }, |
| 133 | sdp := sdp |
| 134 | } |
| 135 | |
Harald Welte | 9988d28 | 2017-11-18 19:22:00 +0100 | [diff] [blame] | 136 | template MgcpResponse tr_CRCX_ACK := { |
| 137 | line := { |
| 138 | code := "200", |
| 139 | string := "OK" |
| 140 | }, |
| 141 | params:= { { "I", ? }, *}, |
| 142 | sdp := ? |
| 143 | } |
| 144 | |
Harald Welte | 2bcfd3a | 2017-11-18 22:14:35 +0100 | [diff] [blame^] | 145 | template MgcpCommand ts_MDCX(MgcpTransId trans_id, charstring ep, MgcpConnectionMode mode, MgcpCallId call_id, MgcpConnectionId conn_id, template SDP_Message sdp := omit) := { |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 146 | line := t_MgcpCmdLine("MDCX", trans_id, ep), |
| 147 | params := { |
| 148 | t_MgcpParConnMode(mode), |
| 149 | ts_MgcpParCallId(call_id), |
Harald Welte | 2bcfd3a | 2017-11-18 22:14:35 +0100 | [diff] [blame^] | 150 | ts_MgcpParConnectionId(conn_id), |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 151 | //t_MgcpParReqId(omit), |
Harald Welte | 5e5cce5 | 2017-11-18 22:13:51 +0100 | [diff] [blame] | 152 | t_MgcpParLocConnOpt("p:20, a:PCMU") |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 153 | }, |
| 154 | sdp := sdp |
| 155 | } |
| 156 | |
Harald Welte | c40e0c3 | 2017-11-18 19:08:22 +0100 | [diff] [blame] | 157 | /* have a function that generates a template, rather than a template in order to handle |
| 158 | * optional parameters */ |
| 159 | function ts_DLCX(MgcpTransId trans_id, charstring ep, template MgcpCallId call_id := omit, |
| 160 | template MgcpConnectionId conn_id := omit) return template MgcpCommand { |
| 161 | var template MgcpCommand cmd; |
| 162 | cmd.line := t_MgcpCmdLine("DLCX", trans_id, ep); |
| 163 | cmd.params := {}; |
| 164 | cmd.sdp := omit; |
| 165 | if (isvalue(call_id)) { |
| 166 | f_mgcp_par_append(cmd.params, ts_MgcpParCallId(valueof(call_id))); |
| 167 | if (isvalue(conn_id)) { |
| 168 | f_mgcp_par_append(cmd.params, ts_MgcpParConnectionId(valueof(conn_id))); |
| 169 | } |
| 170 | } |
| 171 | return cmd; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /* SDP Templates */ |
| 175 | template SDP_Origin ts_SDP_origin(charstring addr, charstring session_id, |
| 176 | charstring session_version := "1", |
| 177 | charstring addr_type := "IP4", |
| 178 | charstring user_name := "-") := { |
| 179 | user_name := user_name, |
| 180 | session_id := session_id, |
| 181 | session_version := session_version, |
| 182 | net_type := "IN", |
| 183 | addr_type := addr_type, |
| 184 | addr := addr |
| 185 | } |
| 186 | |
| 187 | template SDP_connection ts_SDP_connection_IP(charstring addr, charstring addr_type := "IP4", |
| 188 | template integer ttl := omit, |
| 189 | template integer num_of_addr := omit) :={ |
| 190 | net_type := "IN", |
| 191 | addr_type := addr_type, |
| 192 | conn_addr := { |
| 193 | addr := addr, |
| 194 | ttl := ttl, |
| 195 | num_of_addr := num_of_addr |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | template SDP_time ts_SDP_time(charstring beg, charstring end) := { |
| 200 | time_field := { |
| 201 | start_time := beg, |
| 202 | stop_time := end |
| 203 | }, |
| 204 | time_repeat := omit |
| 205 | } |
| 206 | |
| 207 | template SDP_media_desc ts_SDP_media_desc(integer port_number, SDP_fmt_list fmts, |
| 208 | SDP_attribute_list attributes) := { |
| 209 | media_field := { |
| 210 | media := "audio", |
| 211 | ports := { |
| 212 | port_number := port_number, |
| 213 | num_of_ports := omit |
| 214 | }, |
| 215 | transport := "ARTP/AVP", |
| 216 | fmts := fmts |
| 217 | }, |
| 218 | information := omit, |
| 219 | connections := omit, |
| 220 | bandwidth := omit, |
| 221 | key := omit, |
| 222 | attributes := attributes |
| 223 | } |
| 224 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 225 | /* master template for generating SDP based in template arguments */ |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 226 | template SDP_Message ts_SDP(charstring local_addr, charstring remote_addr, |
| 227 | charstring session_id, charstring session_version, |
| 228 | integer rtp_port, SDP_fmt_list fmts, |
| 229 | SDP_attribute_list attributes) := { |
| 230 | protocol_version := 0, |
| 231 | origin := ts_SDP_origin(local_addr, session_id, session_version), |
| 232 | session_name := "-", |
| 233 | information := omit, |
| 234 | uri := omit, |
| 235 | emails := omit, |
| 236 | phone_numbers := omit, |
| 237 | connection := ts_SDP_connection_IP(remote_addr), |
| 238 | bandwidth := omit, |
| 239 | times := { ts_SDP_time("0","0") }, |
| 240 | timezone_adjustments := omit, |
| 241 | key := omit, |
| 242 | attributes := omit, |
| 243 | media_list := { ts_SDP_media_desc(rtp_port, fmts, attributes) } |
| 244 | } |
| 245 | |
| 246 | template SDP_attribute ts_SDP_rtpmap(integer fmt, charstring val) := { |
| 247 | rtpmap := { |
| 248 | attr_value := int2str(fmt) & " " & val |
| 249 | } |
| 250 | } |
| 251 | template SDP_attribute ts_SDP_ptime(integer p) := { |
| 252 | ptime := { |
| 253 | attr_value := int2str(p) |
| 254 | } |
| 255 | } |
| 256 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 257 | testcase TC_selftest() runs on dummy_CT { |
| 258 | const charstring c_auep := "AUEP 158663169 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n"; |
| 259 | const charstring c_mdcx3 := "MDCX 18983215 1@mgw MGCP 1.0\r\n"; |
| 260 | const charstring c_mdcx3_ret := "200 18983215 OK\r\n" & |
| 261 | "I: 1\n" & |
| 262 | "\n" & |
| 263 | "v=0\r\n" & |
| 264 | "o=- 1 23 IN IP4 0.0.0.0\r\n" & |
| 265 | "s=-\r\n" & |
| 266 | "c=IN IP4 0.0.0.0\r\n" & |
| 267 | "t=0 0\r\n" & |
| 268 | "m=audio 0 RTP/AVP 126\r\n" & |
| 269 | "a=rtpmap:126 AMR/8000\r\n" & |
| 270 | "a=ptime:20\r\n"; |
| 271 | const charstring c_mdcx4 := "MDCX 18983216 1@mgw MGCP 1.0\r\n" & |
| 272 | "M: sendrecv\r" & |
| 273 | "C: 2\r\n" & |
| 274 | "I: 1\r\n" & |
| 275 | "L: p:20, a:AMR, nt:IN\r\n" & |
| 276 | "\n" & |
| 277 | "v=0\r\n" & |
| 278 | "o=- 1 23 IN IP4 0.0.0.0\r\n" & |
Harald Welte | 2871d0b | 2017-09-14 22:42:12 +0800 | [diff] [blame] | 279 | "s=-\r\n" & |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 280 | "c=IN IP4 0.0.0.0\r\n" & |
| 281 | "t=0 0\r\n" & |
| 282 | "m=audio 4441 RTP/AVP 99\r\n" & |
| 283 | "a=rtpmap:99 AMR/8000\r\n" & |
| 284 | "a=ptime:40\r\n"; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 285 | const charstring c_crcx510_ret := "510 23 FAIL\r\n" |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 286 | |
| 287 | log(c_auep); |
| 288 | log(dec_MgcpCommand(c_auep)); |
| 289 | |
| 290 | log(c_mdcx3); |
| 291 | log(dec_MgcpCommand(c_mdcx3)); |
| 292 | |
| 293 | log(c_mdcx3_ret); |
| 294 | log(dec_MgcpResponse(c_mdcx3_ret)); |
| 295 | |
| 296 | log(c_mdcx4); |
| 297 | log(dec_MgcpCommand(c_mdcx4)); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 298 | |
| 299 | log(ts_CRCX("23", "42@mgw", "sendrecv", '1234'H)); |
| 300 | log(enc_MgcpCommand(valueof(ts_CRCX("23", "42@mgw", "sendrecv", '1234'H)))); |
| 301 | |
| 302 | log(c_crcx510_ret); |
| 303 | log(dec_MgcpResponse(c_crcx510_ret)); |
| 304 | log(dec_MgcpMessage(c_crcx510_ret)); |
| 305 | } |
| 306 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 307 | /* CRCX test ideas: |
Harald Welte | e0b331f | 2017-11-18 20:34:33 +0100 | [diff] [blame] | 308 | * x without mandatory CallId |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 309 | * - with forbidden parameters (e.g. Capabilities, PackageList, ... |
| 310 | * - CRCX with remote session description and without |
| 311 | * |
| 312 | * general ideas: |
Harald Welte | e0b331f | 2017-11-18 20:34:33 +0100 | [diff] [blame] | 313 | * x packetization != 20ms |
| 314 | * x invalid mode |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 315 | * x unsupported mode (517) |
| 316 | * x bidirectional mode before RemoteConnDesc: 527 |
| 317 | * - invalid codec |
Harald Welte | e0b331f | 2017-11-18 20:34:33 +0100 | [diff] [blame] | 318 | * x retransmission of same transaction |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 319 | * - unsupported LocalConnectionOptions ("b", "a", "e", "gc", "s", "r", "k", ..) |
| 320 | */ |
| 321 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 322 | /* build a receive template for receiving a MGCP message. You |
| 323 | * pass the MGCP response template in, and it will generate an |
| 324 | * MGCP_RecvFrom template that can match the primitives arriving on the |
| 325 | * MGCP_CodecPort */ |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 326 | function tr_MGCP_RecvFrom_R(template MgcpResponse resp) runs on dummy_CT return template MGCP_RecvFrom { |
| 327 | var template MGCP_RecvFrom mrf := { |
Harald Welte | 5501536 | 2017-11-18 16:02:42 +0100 | [diff] [blame] | 328 | connId := g_mgcp_conn_id, |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 329 | remName := mp_remote_ip, |
| 330 | remPort := mp_remote_udp_port, |
| 331 | locName := mp_local_ip, |
| 332 | locPort := mp_local_udp_port, |
| 333 | msg := { response := resp } |
| 334 | } |
| 335 | return mrf; |
| 336 | } |
| 337 | |
| 338 | /* Send a MGCP request + receive a (matching!) response */ |
| 339 | function mgcp_transceive_mgw(template MgcpCommand cmd, template MgcpResponse resp := ?) runs on dummy_CT return MgcpResponse { |
| 340 | var MgcpMessage msg := { command := valueof(cmd) }; |
| 341 | resp.line.trans_id := cmd.line.trans_id; |
| 342 | var template MGCP_RecvFrom mrt := tr_MGCP_RecvFrom_R(resp); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 343 | var MGCP_RecvFrom mrf; |
| 344 | timer T := 5.0; |
| 345 | |
Harald Welte | 5501536 | 2017-11-18 16:02:42 +0100 | [diff] [blame] | 346 | MGCP.send(t_MGCP_Send(g_mgcp_conn_id, msg)); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 347 | T.start; |
| 348 | alt { |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 349 | [] MGCP.receive(mrt) -> value mrf { } |
| 350 | [] MGCP.receive(tr_MGCP_RecvFrom_R(?)) { setverdict(fail); } |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 351 | [] MGCP.receive { repeat; } |
| 352 | [] T.timeout { setverdict(fail); } |
| 353 | } |
| 354 | T.stop; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 355 | |
| 356 | if (isbound(mrf) and isbound(mrf.msg) and ischosen(mrf.msg.response)) { |
| 357 | return mrf.msg.response; |
| 358 | } else { |
| 359 | var MgcpResponse r := { line := { code := "999", trans_id := valueof(cmd.line.trans_id) } }; |
| 360 | return r; |
| 361 | } |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 362 | } |
| 363 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 364 | function extract_conn_id(MgcpResponse resp) return MgcpConnectionId { |
| 365 | var integer i; |
| 366 | for (i := 0; i < lengthof(resp.params); i := i + 1) { |
| 367 | var MgcpParameter par := resp.params[i]; |
| 368 | if (par.code == "I") { |
| 369 | return str2hex(par.val); |
| 370 | } |
| 371 | } |
| 372 | setverdict(fail); |
| 373 | return '00000000'H; |
| 374 | } |
| 375 | |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 376 | function f_dlcx(MgcpEndpoint ep, template MgcpResponseCode ret_code, template charstring ret_val, |
| 377 | template MgcpCallId call_id := omit, |
| 378 | template MgcpConnectionId conn_id := omit) runs on dummy_CT { |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 379 | var template MgcpCommand cmd; |
| 380 | var MgcpResponse resp; |
| 381 | var template MgcpResponse rtmpl := { |
| 382 | line := { |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 383 | code := ret_code, |
| 384 | string := ret_val |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 385 | }, |
| 386 | params := *, |
| 387 | sdp := * |
| 388 | }; |
Harald Welte | c40e0c3 | 2017-11-18 19:08:22 +0100 | [diff] [blame] | 389 | cmd := ts_DLCX(get_next_trans_id(), ep, call_id, conn_id); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 390 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 391 | } |
| 392 | |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 393 | /* Send DLCX and expect OK response */ |
| 394 | function f_dlcx_ok(MgcpEndpoint ep, template MgcpCallId call_id := omit, |
| 395 | template MgcpConnectionId conn_id := omit) runs on dummy_CT { |
| 396 | f_dlcx(ep, "200", "OK", call_id, conn_id); |
| 397 | } |
| 398 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 399 | /* Send DLCX and accept any response */ |
Harald Welte | c40e0c3 | 2017-11-18 19:08:22 +0100 | [diff] [blame] | 400 | function f_dlcx_ignore(MgcpEndpoint ep, template MgcpCallId call_id := omit, |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 401 | template MgcpConnectionId conn_id := omit) runs on dummy_CT { |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 402 | f_dlcx(ep, ?, *, call_id, conn_id); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 403 | } |
| 404 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 405 | /* test valid CRCX without SDP */ |
| 406 | testcase TC_crcx() runs on dummy_CT { |
| 407 | var template MgcpCommand cmd; |
| 408 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 409 | var MgcpEndpoint ep := "2@mgw"; |
| 410 | var MgcpCallId call_id := '1234'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 411 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 412 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 413 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 414 | /* create the connection on the MGW */ |
| 415 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | 9988d28 | 2017-11-18 19:22:00 +0100 | [diff] [blame] | 416 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 417 | extract_conn_id(resp); |
| 418 | |
| 419 | /* clean-up */ |
| 420 | f_dlcx_ok(ep, call_id); |
| 421 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 422 | setverdict(pass); |
| 423 | } |
| 424 | |
| 425 | /* test CRCX with unsupported mode, expect 517 */ |
| 426 | testcase TC_crcx_unsupp_mode() runs on dummy_CT { |
| 427 | var template MgcpCommand cmd; |
| 428 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 429 | var MgcpEndpoint ep := "2@mgw"; |
| 430 | var MgcpCallId call_id := '1233'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 431 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("517"); |
| 432 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 433 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 434 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 435 | cmd := ts_CRCX(get_next_trans_id(), ep, "netwtest", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 436 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 437 | setverdict(pass); |
| 438 | } |
| 439 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 440 | /* test CRCX with early bi-directional mode, expect 527 as |
| 441 | * bi-diretional media can only be established once both local and |
| 442 | * remote side are specified, see MGCP RFC */ |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 443 | testcase TC_crcx_early_bidir_mode() runs on dummy_CT { |
| 444 | var template MgcpCommand cmd; |
| 445 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 446 | var MgcpEndpoint ep := "2@mgw"; |
| 447 | var MgcpCallId call_id := '1232'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 448 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("527"); |
| 449 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 450 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 451 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 452 | cmd := ts_CRCX(get_next_trans_id(), ep, "sendrecv", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 453 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 454 | setverdict(pass); |
| 455 | } |
| 456 | |
| 457 | /* test CRCX with unsupported Parameters */ |
| 458 | testcase TC_crcx_unsupp_param() runs on dummy_CT { |
| 459 | var template MgcpCommand cmd; |
| 460 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 461 | var MgcpEndpoint ep := "2@mgw"; |
| 462 | var MgcpCallId call_id := '1231'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 463 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("539"); |
| 464 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 465 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 466 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 467 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | a01e38d | 2017-11-18 18:40:01 +0100 | [diff] [blame] | 468 | /* osmo-bsc_mgcp/mgw doesn't implement notifications */ |
| 469 | f_mgcp_par_append(cmd.params, MgcpParameter:{ "N", "foobar" }); |
| 470 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 471 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 472 | setverdict(pass); |
| 473 | } |
| 474 | |
| 475 | /* test CRCX with missing CallId */ |
| 476 | testcase TC_crcx_missing_callid() runs on dummy_CT { |
| 477 | var template MgcpCommand cmd; |
| 478 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 479 | var MgcpEndpoint ep := "2@mgw"; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 480 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("400"); |
| 481 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 482 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 483 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 484 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", '1230'H); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 485 | cmd.params := { |
| 486 | t_MgcpParConnMode("recvonly"), |
| 487 | t_MgcpParLocConnOpt("p:20") |
| 488 | } |
| 489 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 490 | setverdict(pass); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 491 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | /* test CRCX with missing Mode */ |
| 495 | testcase TC_crcx_missing_mode() runs on dummy_CT { |
| 496 | var template MgcpCommand cmd; |
| 497 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 498 | var MgcpEndpoint ep := "2@mgw"; |
| 499 | var MgcpCallId call_id := '1229'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 500 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("400"); |
| 501 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 502 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 503 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 504 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 505 | cmd.params := { |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 506 | ts_MgcpParCallId(call_id), |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 507 | t_MgcpParLocConnOpt("p:20") |
| 508 | } |
| 509 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 510 | setverdict(pass); |
| 511 | } |
| 512 | |
| 513 | /* test CRCX with unsupported packetization interval */ |
| 514 | testcase TC_crcx_unsupp_packet_intv() runs on dummy_CT { |
| 515 | var template MgcpCommand cmd; |
| 516 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 517 | var MgcpEndpoint ep := "2@mgw"; |
| 518 | var MgcpCallId call_id := '1228'H; |
Harald Welte | 0d19861 | 2017-11-18 19:58:31 +0100 | [diff] [blame] | 519 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("535"); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 520 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 521 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 522 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 523 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | a01e38d | 2017-11-18 18:40:01 +0100 | [diff] [blame] | 524 | cmd.params[2] := t_MgcpParLocConnOpt("p:111"); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 525 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 526 | setverdict(pass); |
| 527 | } |
| 528 | |
| 529 | /* test CRCX with illegal double presence of local connection option */ |
| 530 | testcase TC_crcx_illegal_double_lco() runs on dummy_CT { |
| 531 | var template MgcpCommand cmd; |
| 532 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 533 | var MgcpEndpoint ep := "2@mgw"; |
| 534 | var MgcpCallId call_id := '1227'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 535 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("524"); |
| 536 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 537 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 538 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 539 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | a01e38d | 2017-11-18 18:40:01 +0100 | [diff] [blame] | 540 | /* p:20 is permitted only once and not twice! */ |
| 541 | cmd.params[2] := t_MgcpParLocConnOpt("p:20, a:AMR, p:20"); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 542 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 543 | setverdict(pass); |
| 544 | } |
| 545 | |
| 546 | /* test valid CRCX with valid SDP */ |
| 547 | testcase TC_crcx_sdp() runs on dummy_CT { |
| 548 | var template MgcpCommand cmd; |
| 549 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 550 | var MgcpEndpoint ep := "2@mgw"; |
| 551 | var MgcpCallId call_id := '1226'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 552 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 553 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 554 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 555 | cmd := ts_CRCX(get_next_trans_id(), ep, "sendrecv", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 556 | cmd.sdp := ts_SDP("127.0.0.1", "127.0.0.2", "23", "42", 2344, { "98" }, |
| 557 | { valueof(ts_SDP_rtpmap(98, "AMR/8000")), |
| 558 | valueof(ts_SDP_ptime(20)) }); |
Harald Welte | 9988d28 | 2017-11-18 19:22:00 +0100 | [diff] [blame] | 559 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 560 | setverdict(pass); |
| 561 | } |
| 562 | |
| 563 | /* TODO: various SDP related bits */ |
| 564 | |
| 565 | |
| 566 | /* TODO: CRCX with X-Osmux */ |
| 567 | /* TODO: double CRCX without force_realloc */ |
| 568 | |
| 569 | /* TODO: MDCX (various) */ |
| 570 | |
| 571 | /* TODO: MDCX without CRCX first */ |
| 572 | testcase TC_mdcx_without_crcx() runs on dummy_CT { |
| 573 | var template MgcpCommand cmd; |
| 574 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 575 | var MgcpEndpoint ep := "3@mgw"; |
| 576 | var MgcpCallId call_id := '1225'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 577 | var template MgcpResponse rtmpl := { |
| 578 | line := { |
| 579 | /* TODO: accept/enforce better error? */ |
| 580 | code := "400", |
| 581 | string := ? |
| 582 | }, |
| 583 | params:= { }, |
| 584 | sdp := omit |
| 585 | }; |
| 586 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 587 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 588 | |
Harald Welte | 2bcfd3a | 2017-11-18 22:14:35 +0100 | [diff] [blame^] | 589 | cmd := ts_MDCX(get_next_trans_id(), ep, "sendrecv", call_id, call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 590 | cmd.sdp := ts_SDP("127.0.0.1", "127.0.0.2", "23", "42", 2344, { "98" }, |
| 591 | { valueof(ts_SDP_rtpmap(98, "AMR/8000")), |
| 592 | valueof(ts_SDP_ptime(20)) }); |
| 593 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 594 | setverdict(pass); |
| 595 | } |
| 596 | |
| 597 | /* DLCX without CRCX first */ |
| 598 | testcase TC_dlcx_without_crcx() runs on dummy_CT { |
| 599 | var template MgcpCommand cmd; |
| 600 | var MgcpResponse resp; |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 601 | var MgcpEndpoint ep := "4@mgw"; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 602 | var template MgcpResponse rtmpl := { |
| 603 | line := { |
| 604 | /* TODO: accept/enforce better error? */ |
| 605 | code := "400", |
| 606 | string := ? |
| 607 | }, |
| 608 | params:= { }, |
| 609 | sdp := omit |
| 610 | }; |
| 611 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 612 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 613 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 614 | cmd := ts_DLCX(get_next_trans_id(), ep, '41234'H); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 615 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 616 | setverdict(pass); |
| 617 | } |
| 618 | |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 619 | /* Test (valid) CRCX followed by (valid) DLCX containig EP+CallId+ConnId */ |
| 620 | testcase TC_crcx_and_dlcx_ep_callid_connid() runs on dummy_CT { |
| 621 | var template MgcpCommand cmd; |
| 622 | var MgcpResponse resp; |
| 623 | var MgcpEndpoint ep := "5@mgw"; |
| 624 | var MgcpCallId call_id := '51234'H; |
| 625 | |
| 626 | f_init(ep); |
| 627 | |
| 628 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 629 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 630 | |
| 631 | f_dlcx_ok(ep, call_id, extract_conn_id(resp)); |
| 632 | |
| 633 | setverdict(pass); |
| 634 | } |
| 635 | |
| 636 | /* Test (valid) CRCX followed by (valid) DLCX containing EP+CallId */ |
| 637 | testcase TC_crcx_and_dlcx_ep_callid() runs on dummy_CT { |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 638 | var template MgcpCommand cmd; |
| 639 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 640 | var MgcpEndpoint ep := "5@mgw"; |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 641 | var MgcpCallId call_id := '51233'H; |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 642 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 643 | f_init(ep); |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 644 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 645 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | 9988d28 | 2017-11-18 19:22:00 +0100 | [diff] [blame] | 646 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 647 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 648 | f_dlcx_ok(ep, call_id); |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 649 | |
| 650 | setverdict(pass); |
| 651 | } |
| 652 | |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 653 | /* Test (valid) CRCX followed by (valid) DLCX containing EP */ |
| 654 | testcase TC_crcx_and_dlcx_ep() runs on dummy_CT { |
| 655 | var template MgcpCommand cmd; |
| 656 | var MgcpResponse resp; |
| 657 | var MgcpEndpoint ep := "5@mgw"; |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 658 | var MgcpCallId call_id := '51232'H; |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 659 | |
| 660 | f_init(ep); |
| 661 | |
| 662 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 663 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 664 | |
| 665 | f_dlcx_ok(ep); |
| 666 | |
| 667 | setverdict(pass); |
| 668 | } |
| 669 | |
| 670 | |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 671 | /* CRCX + DLCX of valid endpoint but invalid call-id */ |
| 672 | testcase TC_crcx_and_dlcx_ep_callid_inval() runs on dummy_CT { |
| 673 | var template MgcpCommand cmd; |
| 674 | var MgcpResponse resp; |
| 675 | var MgcpEndpoint ep := "5@mgw"; |
| 676 | var MgcpCallId call_id := '51231'H; |
| 677 | |
| 678 | f_init(ep); |
| 679 | |
| 680 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 681 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 682 | |
| 683 | f_dlcx(ep, "516", *, 'ffff'H); |
| 684 | |
| 685 | setverdict(pass); |
| 686 | } |
| 687 | |
| 688 | |
| 689 | /* CRCX + DLCX of valid endpoint and call-id but invalid conn-id */ |
| 690 | testcase TC_crcx_and_dlcx_ep_callid_connid_inval() runs on dummy_CT { |
| 691 | var template MgcpCommand cmd; |
| 692 | var MgcpResponse resp; |
| 693 | var MgcpEndpoint ep := "5@mgw"; |
| 694 | var MgcpCallId call_id := '51230'H; |
| 695 | |
| 696 | f_init(ep); |
| 697 | |
| 698 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 699 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 700 | |
| 701 | f_dlcx(ep, "515", *, call_id, 'ffff'H); |
| 702 | |
| 703 | setverdict(pass); |
| 704 | } |
| 705 | |
| 706 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 707 | /* TODO: Double-DLCX (retransmission) */ |
Harald Welte | f53f164 | 2017-11-18 19:57:11 +0100 | [diff] [blame] | 708 | testcase TC_crcx_and_dlcx_retrans() runs on dummy_CT { |
| 709 | var template MgcpCommand cmd; |
| 710 | var MgcpResponse resp; |
| 711 | var MgcpEndpoint ep := "5@mgw"; |
| 712 | var MgcpCallId call_id := '51229'H; |
| 713 | var template MgcpResponse rtmpl := { |
| 714 | line := { |
| 715 | code := "200", |
| 716 | string := "OK" |
| 717 | }, |
| 718 | params:= { }, |
| 719 | sdp := omit |
| 720 | }; |
| 721 | |
| 722 | f_init(ep); |
| 723 | |
| 724 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 725 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 726 | |
| 727 | cmd := ts_DLCX(get_next_trans_id(), ep, call_id); |
| 728 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 729 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 730 | |
| 731 | setverdict(pass); |
| 732 | } |
| 733 | |
| 734 | |
| 735 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 736 | /* TODO: Double-DLCX (no retransmission) */ |
| 737 | |
| 738 | |
| 739 | |
| 740 | /* TODO: AUEP (various) */ |
| 741 | /* TODO: RSIP (various) */ |
| 742 | /* TODO: RQNT (various) */ |
| 743 | /* TODO: EPCF (various) */ |
| 744 | /* TODO: AUCX (various) */ |
| 745 | /* TODO: invalid verb (various) */ |
| 746 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 747 | control { |
| 748 | execute(TC_selftest()); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 749 | execute(TC_crcx()); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 750 | execute(TC_crcx_unsupp_mode()); |
| 751 | execute(TC_crcx_early_bidir_mode()); |
| 752 | execute(TC_crcx_unsupp_param()); |
| 753 | execute(TC_crcx_missing_callid()); |
| 754 | execute(TC_crcx_missing_mode()); |
| 755 | execute(TC_crcx_unsupp_packet_intv()); |
| 756 | execute(TC_crcx_illegal_double_lco()); |
| 757 | execute(TC_crcx_sdp()); |
| 758 | execute(TC_mdcx_without_crcx()); |
| 759 | execute(TC_dlcx_without_crcx()); |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 760 | execute(TC_crcx_and_dlcx_ep_callid_connid()); |
| 761 | execute(TC_crcx_and_dlcx_ep_callid()); |
| 762 | execute(TC_crcx_and_dlcx_ep()); |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 763 | execute(TC_crcx_and_dlcx_ep_callid_inval()); |
| 764 | execute(TC_crcx_and_dlcx_ep_callid_connid_inval()); |
Harald Welte | f53f164 | 2017-11-18 19:57:11 +0100 | [diff] [blame] | 765 | execute(TC_crcx_and_dlcx_retrans()); |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 766 | } |
| 767 | } |