Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 1 | module RAW_NS { |
| 2 | |
| 3 | /* Osmocom NS test suite for NS in TTCN-3 |
| 4 | * (C) 2018-2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | */ |
| 12 | |
| 13 | import from Misc_Helpers all; |
| 14 | import from General_Types all; |
| 15 | import from Osmocom_Types all; |
| 16 | import from Osmocom_Gb_Types all; |
| 17 | import from NS_Emulation all; |
| 18 | import from NS_Types all; |
| 19 | import from BSSGP_Types all; |
| 20 | import from NS_Emulation all; |
| 21 | import from Native_Functions all; |
| 22 | import from IPL4asp_Types all; |
| 23 | import from NS_Provider_IPL4 all; |
| 24 | #ifdef NS_EMULATION_FR |
| 25 | import from NS_Provider_FR all; |
| 26 | #endif |
| 27 | |
| 28 | public type component RAW_NS_CT { |
| 29 | /* UDP port towards the bottom (IUT) */ |
| 30 | port NS_PROVIDER_PT NSCP[4]; |
| 31 | var NS_Provider_IPL4_CT vc_NSP_IP[4]; |
| 32 | #ifdef NS_EMULATION_FR |
| 33 | var NS_Provider_FR_CT vc_NSP_FR[4]; |
| 34 | #endif |
| 35 | var NSConfiguration g_nsconfig; |
| 36 | timer g_T_guard; |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 37 | var boolean g_handle_rx_alive := false; |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | public altstep as_Tguard() runs on RAW_NS_CT { |
| 41 | [] g_T_guard.timeout { |
| 42 | setverdict(fail, "Timeout of T_guard"); |
| 43 | mtc.stop; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | function f_init_ns_codec(NSConfiguration ns_config, integer idx := 0, float guard_secs := 60.0, charstring id := testcasename()) runs on RAW_NS_CT { |
| 48 | var Result res; |
| 49 | |
| 50 | if (not g_T_guard.running) { |
| 51 | g_T_guard.start(guard_secs); |
| 52 | activate(as_Tguard()); |
| 53 | } |
| 54 | |
| 55 | if (not isbound(g_nsconfig)) { |
| 56 | g_nsconfig := ns_config; |
| 57 | } |
| 58 | |
| 59 | if (ischosen(ns_config.nsvc[idx].provider.ip)) { |
| 60 | /* Connect the UDP socket */ |
| 61 | vc_NSP_IP[idx] := NS_Provider_IPL4_CT.create(id & "-provIP"); |
| 62 | connect(self:NSCP[idx], vc_NSP_IP[idx]:NSE); |
| 63 | vc_NSP_IP[idx].start(NS_Provider_IPL4.main(ns_config.nsvc[idx], ns_config, id)); |
| 64 | #ifdef NS_EMULATION_FR |
| 65 | } else if (ischosen(ns_config.nsvc[idx].provider.fr)) { |
| 66 | vc_NSP_FR[idx] := NS_Provider_FR_CT.create(id & "-provFR"); |
| 67 | connect(self:NSCP[idx], vc_NSP_FR[idx]:NSE); |
| 68 | vc_NSP_FR[idx].start(NS_Provider_FR.main(ns_config.nsvc[idx], ns_config, id)); |
| 69 | #endif |
| 70 | } else { |
| 71 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported NS provider"); |
| 72 | } |
| 73 | |
| 74 | NSCP[idx].receive(NS_Provider_Evt:{link_status:=NS_PROV_LINK_STATUS_UP}); |
| 75 | } |
| 76 | |
| 77 | function f_clean_ns_codec() runs on RAW_NS_CT { |
| 78 | for (var integer i := 0; i < lengthof(vc_NSP_IP); i := i + 1) { |
| 79 | vc_NSP_IP[i].stop; |
| 80 | } |
| 81 | #ifdef NS_EMULATION_FR |
| 82 | for (var integer i := 0; i < lengthof(vc_NSP_FR); i := i + 1) { |
| 83 | vc_NSP_FR[i].stop; |
| 84 | } |
| 85 | #endif NS_EMULATION_FR |
| 86 | } |
| 87 | |
| 88 | public altstep ax_rx_fail_on_any_ns(integer idx := 0) runs on RAW_NS_CT { |
| 89 | var PDU_NS nrf; |
| 90 | [] NSCP[idx].receive(PDU_NS: ?) -> value nrf { |
| 91 | setverdict(fail, "Received unexpected NS: ", nrf); |
| 92 | mtc.stop; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS { |
| 97 | var PDU_NS nrf; |
| 98 | log("f_ns_exp() expecting ", exp_rx); |
| 99 | /* last activated altstep has the lowest priority */ |
| 100 | var default d := activate(ax_rx_fail_on_any_ns()); |
| 101 | alt { |
| 102 | [] NSCP[idx].receive(PDU_NS: exp_rx) -> value nrf { } |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 103 | [g_handle_rx_alive] as_rx_alive_tx_ack(); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 104 | } |
| 105 | deactivate(d); |
| 106 | return nrf; |
| 107 | } |
| 108 | |
| 109 | /* perform outbound NS-ALIVE procedure */ |
| 110 | function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT { |
| 111 | NSCP[idx].send(t_NS_ALIVE); |
| 112 | alt { |
| 113 | [] NSCP[idx].receive(t_NS_ALIVE_ACK); |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 114 | [g_handle_rx_alive] as_rx_alive_tx_ack(); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 115 | [] NSCP[idx].receive { repeat; } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /* perform outbound NS-ALIVE procedure */ |
| 120 | function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT { |
| 121 | timer T := tout; |
| 122 | NSCP[idx].send(t_NS_ALIVE); |
| 123 | T.start; |
| 124 | alt { |
| 125 | [] NSCP[idx].receive(t_NS_ALIVE_ACK) { |
| 126 | setverdict(fail, "Received unexpected NS-ALIVE ACK"); |
| 127 | } |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 128 | [g_handle_rx_alive] as_rx_alive_tx_ack(); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 129 | [] NSCP[idx].receive { repeat; } |
| 130 | [] T.timeout { |
| 131 | setverdict(pass); |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | function f_outgoing_ns_reset(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT { |
| 137 | timer T := tout; |
| 138 | var template PDU_NS reset := ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[idx].nsvci, g_nsconfig.nsei) |
| 139 | NSCP[idx].send(reset); |
| 140 | T.start; |
| 141 | alt { |
| 142 | [] NSCP[idx].receive(ts_NS_RESET_ACK(g_nsconfig.nsvc[idx].nsvci, g_nsconfig.nsei)) { |
| 143 | setverdict(pass); |
| 144 | } |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 145 | [g_handle_rx_alive] as_rx_alive_tx_ack(); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 146 | [] NSCP[idx].receive { repeat; } |
| 147 | [] T.timeout { |
| 148 | setverdict(fail, "Failed to receive a RESET ACK"); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /* perform outbound NS-BLOCK procedure */ |
| 154 | function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT { |
| 155 | NSCP[idx].send(ts_NS_BLOCK(cause, g_nsconfig.nsvc[idx].nsvci)); |
| 156 | alt { |
| 157 | [] NSCP[idx].receive(tr_NS_BLOCK_ACK(g_nsconfig.nsvc[idx].nsvci)); |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 158 | [g_handle_rx_alive] as_rx_alive_tx_ack(); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 159 | [] NSCP[idx].receive { repeat; } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /* perform outbound NS-UNBLOCK procedure */ |
| 164 | function f_outgoing_ns_unblock(integer idx := 0) runs on RAW_NS_CT { |
| 165 | NSCP[idx].send(t_NS_UNBLOCK); |
| 166 | alt { |
| 167 | [] NSCP[idx].receive(t_NS_UNBLOCK_ACK); |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 168 | [g_handle_rx_alive] as_rx_alive_tx_ack(); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 169 | [] NSCP[idx].receive { repeat; } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /* receive NS-ALIVE and ACK it */ |
| 174 | altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 175 | [] NSCP[idx].receive(t_NS_ALIVE) { |
| 176 | NSCP[idx].send(t_NS_ALIVE_ACK); |
| 177 | if (not oneshot) { repeat; } |
| 178 | } |
Harald Welte | 6a414c8 | 2021-03-24 00:56:44 +0100 | [diff] [blame] | 179 | /* in oneshot mode, ignore any NS-UNITDATA we receive meanwhile. This is |
| 180 | * particularly useful when waiting for the first NS-ALIVE after SNS-CONFIG, |
| 181 | * where there is a high chance of UNITDATA during the first Tns-test cycle |
| 182 | * before the peer sends its first NS-ALIVE after Tns-test expiration */ |
| 183 | [oneshot] NSCP[idx].receive(tr_NS_UNITDATA(?,?,?)) { |
| 184 | repeat; |
| 185 | } |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /* Transmit BSSGP RESET for given BVCI and expect ACK */ |
| 189 | function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, template (omit) BssgpCellId tx_cell_id, template BssgpCellId rx_cell_id, |
| 190 | integer idx := 0, boolean exp_ack := true) |
| 191 | runs on RAW_NS_CT { |
| 192 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci, |
| 193 | tx_cell_id)); |
| 194 | timer T := 5.0; |
| 195 | NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))); |
| 196 | T.start; |
| 197 | alt { |
| 198 | [exp_ack] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, 0, |
| 199 | decmatch tr_BVC_RESET_ACK(bvci, rx_cell_id))) { |
| 200 | setverdict(pass); |
| 201 | } |
| 202 | [exp_ack] T.timeout { |
| 203 | setverdict(fail, "No response to BVC-RESET"); |
| 204 | } |
| 205 | [not exp_ack] T.timeout { |
| 206 | setverdict(pass); |
| 207 | } |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 208 | [g_handle_rx_alive] as_rx_alive_tx_ack(); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 209 | [] NSCP[idx].receive { repeat; } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | /* Receive a BSSGP RESET for given BVCI and ACK it */ |
| 214 | altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, template BssgpCellId rx_cell_id, template (omit) BssgpCellId tx_cell_id, |
| 215 | boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 216 | var PDU_NS ns_rf; |
| 217 | [] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, 0, |
| 218 | decmatch tr_BVC_RESET(?, bvci, rx_cell_id))) |
| 219 | -> value ns_rf { |
| 220 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.pDU_NS_Unitdata.nS_SDU); |
| 221 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, tx_cell_id)); |
| 222 | NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))); |
| 223 | if (not oneshot) { repeat; } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | |
| 228 | /* Receive a BSSGP UNBLOCK for given BVCI and ACK it */ |
| 229 | altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 230 | var PDU_NS ns_rf; |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 231 | [] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_UNBLOCK(bvci))) -> value ns_rf { |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 232 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.pDU_NS_Unitdata.nS_SDU); |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 233 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_UNBLOCK_ACK(bvci)); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 234 | NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))); |
| 235 | if (not oneshot) { repeat; } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | /* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */ |
| 240 | altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 241 | var PDU_NS ns_rf; |
| 242 | [] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, bvci, |
| 243 | decmatch tr_BVC_FC_BVC)) |
| 244 | -> value ns_rf { |
| 245 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.pDU_NS_Unitdata.nS_SDU); |
| 246 | var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value; |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 247 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_FC_BVC_ACK(tag)); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 248 | NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx))); |
| 249 | if (not oneshot) { repeat; } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | /********************************************************************************** |
| 254 | * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS * |
| 255 | **********************************************************************************/ |
| 256 | |
| 257 | /* Receive a NS-RESET and ACK it */ |
| 258 | public altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 259 | var PDU_NS ns_rf; |
| 260 | [] NSCP[idx].receive(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig.nsvc[idx].nsvci, |
| 261 | g_nsconfig.nsei)) -> value ns_rf { |
| 262 | NSCP[idx].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[idx].nsvci, g_nsconfig.nsei)); |
| 263 | if (not oneshot) { repeat; } |
| 264 | } |
| 265 | } |
| 266 | /* Receive a NS-UNBLOCK and ACK it */ |
| 267 | public altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 268 | var PDU_NS ns_rf; |
| 269 | [] NSCP[idx].receive(t_NS_UNBLOCK) -> value ns_rf { |
| 270 | NSCP[idx].send(t_NS_UNBLOCK_ACK); |
| 271 | if (not oneshot) { repeat; } |
| 272 | } |
| 273 | } |
| 274 | |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 275 | /* Receive a NS-BLOCK and ACK it */ |
| 276 | public altstep as_rx_ns_block_ack(boolean oneshot := false, integer idx := 0, template NsCause cause := *, template Nsvci nsvci := *) runs on RAW_NS_CT { |
| 277 | var PDU_NS ns_rf; |
| 278 | [] NSCP[idx].receive(tr_NS_BLOCK(cause, nsvci)) -> value ns_rf { |
| 279 | NSCP[idx].send(ts_NS_BLOCK_ACK(oct2int(ns_rf.pDU_NS_Block.nS_VCI.nS_VCI))); |
| 280 | if (not oneshot) { repeat; } |
| 281 | } |
| 282 | } |
| 283 | |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 284 | /********************************************************************************** |
| 285 | * IP Sub-Network Service (SNS) |
| 286 | **********************************************************************************/ |
| 287 | |
| 288 | /* perform inbound SNS-SIZE procedure */ |
Harald Welte | 22deecc | 2021-03-23 13:13:52 +0100 | [diff] [blame] | 289 | function f_incoming_sns_size(template (omit) NsCause cause := omit, integer idx := 0, |
| 290 | template integer num_max_nsvcs := ?, template integer num_ep := ?) |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 291 | runs on RAW_NS_CT { |
| 292 | log("f_incoming_sns_size(idx=", idx, ")"); |
| 293 | var PDU_NS rx; |
| 294 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx]; |
| 295 | |
| 296 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 297 | /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */ |
Harald Welte | 22deecc | 2021-03-23 13:13:52 +0100 | [diff] [blame] | 298 | rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := num_max_nsvcs, |
| 299 | num_v4 := num_ep, num_v6 := omit), idx); |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 300 | } else { |
| 301 | /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */ |
Harald Welte | 22deecc | 2021-03-23 13:13:52 +0100 | [diff] [blame] | 302 | rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := num_max_nsvcs, |
| 303 | num_v4 := omit, num_v6 := num_ep), idx); |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 304 | } |
| 305 | NSCP[idx].send(ts_SNS_SIZE_ACK(g_nsconfig.nsei, cause)); |
| 306 | } |
| 307 | |
| 308 | /* perform outbound SNS-SIZE procedure */ |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 309 | function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer max_nsvcs := 1, |
| 310 | integer num_ip := 1, integer idx:= 0) |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 311 | runs on RAW_NS_CT { |
| 312 | log("f_outgoing_sns_size(idx=", idx, ")"); |
| 313 | var PDU_NS rx; |
| 314 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx]; |
| 315 | |
| 316 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 317 | NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := max_nsvcs, |
| 318 | num_v4 := num_ip, num_v6 := omit) |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 319 | ); |
| 320 | } else { |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 321 | NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := max_nsvcs, |
| 322 | num_v4 := omit, num_v6 := num_ip) |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 323 | ); |
| 324 | } |
Harald Welte | 424ec52 | 2021-03-23 18:20:12 +0100 | [diff] [blame^] | 325 | /* expect one single SNS-SIZE */ |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 326 | rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig.nsei, cause), idx); |
| 327 | } |
| 328 | |
| 329 | /* perform inbound SNS-CONFIG procedure */ |
| 330 | function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0) |
| 331 | runs on RAW_NS_CT { |
| 332 | log("f_incoming_sns_config(idx=", idx, ")"); |
| 333 | var PDU_NS rx; |
| 334 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx]; |
| 335 | |
| 336 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 337 | var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip, |
| 338 | nsvc_cfg.provider.ip.remote_udp_port) }; |
| 339 | rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig.nsei, end_flag := true, v4 := v4_elem), idx); |
| 340 | } else { |
| 341 | var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip, |
| 342 | nsvc_cfg.provider.ip.remote_udp_port) }; |
| 343 | rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig.nsei, end_flag := true, v6 := v6_elem), idx); |
| 344 | } |
| 345 | NSCP[idx].send(ts_SNS_CONFIG_ACK(g_nsconfig.nsei, cause)); |
| 346 | } |
| 347 | |
| 348 | /* perform outbound SNS-CONFIG procedure */ |
| 349 | function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0) |
| 350 | runs on RAW_NS_CT { |
| 351 | log("f_outgoing_sns_config(idx=", idx, ")"); |
| 352 | var PDU_NS rx; |
| 353 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx]; |
| 354 | |
| 355 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 356 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip, |
| 357 | nsvc_cfg.provider.ip.local_udp_port) } |
| 358 | NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, v4)); |
| 359 | } else { |
| 360 | var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip, |
| 361 | nsvc_cfg.provider.ip.local_udp_port) } |
| 362 | NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, omit, v6)); |
| 363 | } |
| 364 | rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig.nsei, cause), idx); |
| 365 | } |
| 366 | |
| 367 | /* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */ |
| 368 | function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0) |
| 369 | runs on RAW_NS_CT { |
| 370 | log("f_outgoing_sns_config_1c1u(idx=", idx, ")"); |
| 371 | var PDU_NS rx; |
| 372 | |
| 373 | if (g_nsconfig.nsvc[0].provider.ip.address_family == AF_INET) { |
| 374 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig.nsvc[0].provider.ip.local_ip, |
| 375 | g_nsconfig.nsvc[0].provider.ip.local_udp_port, 1, 0), |
| 376 | ts_SNS_IPv4(g_nsconfig.nsvc[1].provider.ip.local_ip, |
| 377 | g_nsconfig.nsvc[1].provider.ip.local_udp_port, 0, 1) }; |
| 378 | NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, v4)); |
| 379 | } else { |
| 380 | var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig.nsvc[0].provider.ip.local_ip, |
| 381 | g_nsconfig.nsvc[0].provider.ip.local_udp_port, 1, 0), |
| 382 | ts_SNS_IPv6(g_nsconfig.nsvc[1].provider.ip.local_ip, |
| 383 | g_nsconfig.nsvc[1].provider.ip.local_udp_port, 0, 1) }; |
| 384 | NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, omit, v6)); |
| 385 | } |
| 386 | rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig.nsei, cause), idx); |
| 387 | } |
| 388 | |
| 389 | /* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */ |
| 390 | function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := omit, integer idx := 0) |
| 391 | runs on RAW_NS_CT { |
| 392 | log("f_outgoing_sns_config_1c1u_separate(idx=", idx, ")"); |
| 393 | var PDU_NS rx; |
| 394 | if (g_nsconfig.nsvc[0].provider.ip.address_family == AF_INET) { |
| 395 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig.nsvc[1].provider.ip.local_ip, |
| 396 | g_nsconfig.nsvc[1].provider.ip.local_udp_port, 1, 0), |
| 397 | ts_SNS_IPv4(g_nsconfig.nsvc[2].provider.ip.local_ip, |
| 398 | g_nsconfig.nsvc[2].provider.ip.local_udp_port, 0, 1) }; |
| 399 | NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, v4)); |
| 400 | } else { |
| 401 | var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig.nsvc[1].provider.ip.local_ip, |
| 402 | g_nsconfig.nsvc[1].provider.ip.local_udp_port, 1, 0), |
| 403 | ts_SNS_IPv6(g_nsconfig.nsvc[2].provider.ip.local_ip, |
| 404 | g_nsconfig.nsvc[2].provider.ip.local_udp_port, 0, 1) }; |
| 405 | NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, omit, v6)); |
| 406 | } |
| 407 | rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig.nsei, cause), idx); |
| 408 | } |
| 409 | |
Alexander Couzens | d5ac510 | 2021-02-27 20:53:37 +0100 | [diff] [blame] | 410 | /* perform inbound SNS-CHANGE-WEIGHT procedure */ |
| 411 | function f_incoming_sns_chg_weight(template (omit) NsCause cause := omit, integer idx := 0) |
| 412 | runs on RAW_NS_CT { |
| 413 | log("f_incoming_sns_chg_weight(idx=", idx, ")"); |
| 414 | var PDU_NS rx; |
| 415 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx]; |
| 416 | |
| 417 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 418 | var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip, |
| 419 | nsvc_cfg.provider.ip.remote_udp_port) }; |
| 420 | rx := f_ns_exp(tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := v4_elem), idx); |
| 421 | } else { |
| 422 | var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip, |
| 423 | nsvc_cfg.provider.ip.remote_udp_port) }; |
| 424 | rx := f_ns_exp(tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := omit, v6 := v6_elem), idx); |
| 425 | } |
| 426 | NSCP[idx].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_ChangeWeight.transactionID)); |
| 427 | } |
| 428 | |
| 429 | |
Alexander Couzens | 98ee6f6 | 2021-02-03 16:17:08 +0100 | [diff] [blame] | 430 | function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0, template (omit) NsCause cause := omit) |
| 431 | runs on RAW_NS_CT { |
| 432 | log("f_outgoing_sns_add(idx_add=", idx_add, ")"); |
| 433 | var PDU_NS rx; |
| 434 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_add]; |
| 435 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 436 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip, |
| 437 | nsvc_cfg.provider.ip.local_udp_port, |
| 438 | w_sig, w_user) }; |
| 439 | NSCP[idx].send(ts_SNS_ADD(g_nsconfig.nsei, 23, v4)); |
| 440 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 23, cause, v4)); |
| 441 | } else { |
| 442 | var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip, |
| 443 | nsvc_cfg.provider.ip.local_udp_port, |
| 444 | w_sig, w_user) }; |
| 445 | NSCP[idx].send(ts_SNS_ADD(g_nsconfig.nsei, 23, omit, v6)); |
| 446 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 23, cause, omit, v6)); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0) |
| 451 | runs on RAW_NS_CT { |
| 452 | log("f_outgoing_sns_del(idx_del=", idx_del, ")"); |
| 453 | var PDU_NS rx; |
| 454 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_del]; |
| 455 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 456 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip, |
| 457 | nsvc_cfg.provider.ip.local_udp_port, |
| 458 | w_sig, w_user) }; |
| 459 | NSCP[idx].send(ts_SNS_DEL(g_nsconfig.nsei, 24, omit, v4)); |
| 460 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 24, omit, v4)); |
| 461 | } else { |
| 462 | var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip, |
| 463 | nsvc_cfg.provider.ip.local_udp_port, |
| 464 | w_sig, w_user) }; |
| 465 | NSCP[idx].send(ts_SNS_DEL(g_nsconfig.nsei, 24, omit, omit, v6)); |
| 466 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 24, omit, omit, v6)); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0) |
| 471 | runs on RAW_NS_CT { |
| 472 | log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")"); |
| 473 | var PDU_NS rx; |
| 474 | var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_chg]; |
| 475 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 476 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip, |
| 477 | nsvc_cfg.provider.ip.local_udp_port, |
| 478 | w_sig, w_user) }; |
| 479 | NSCP[idx].send(ts_SNS_CHG_WEIGHT(g_nsconfig.nsei, 25, v4)); |
| 480 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 25, omit, v4)); |
| 481 | } else { |
| 482 | var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip, |
| 483 | nsvc_cfg.provider.ip.local_udp_port, |
| 484 | w_sig, w_user) }; |
| 485 | NSCP[idx].send(ts_SNS_CHG_WEIGHT(g_nsconfig.nsei, 25, omit, v6)); |
| 486 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 25, omit, omit, v6)); |
| 487 | } |
| 488 | } |
| 489 | |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 490 | } |