Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 1 | /* GPRS-NS Emulation in TTCN-3 |
| 2 | * (C) 2018 Harald Welte <laforge@gnumonks.org> |
| 3 | * contributions by sysmocom - s.f.m.c. GmbH |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Released under the terms of GNU General Public License, Version 2 or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 10 | */ |
| 11 | |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 12 | module NS_Emulation { |
| 13 | import from NS_Types all; |
| 14 | import from BSSGP_Types all; |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 15 | import from Osmocom_Gb_Types all; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 16 | import from NS_CodecPort all; |
| 17 | import from NS_CodecPort_CtrlFunct all; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 18 | import from IPL4asp_Types all; |
Alexander Couzens | 1e5dc48 | 2020-07-28 15:38:46 +0200 | [diff] [blame] | 19 | import from PCUIF_Types all; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 20 | |
| 21 | type record NsUnitdataRequest { |
| 22 | BssgpBvci bvci, |
| 23 | Nsei nsei, |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 24 | octetstring sdu optional, |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 25 | PDU_BSSGP bssgp optional |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | template NsUnitdataRequest t_NsUdReq(template Nsei nsei, template BssgpBvci bvci, template octetstring sdu, |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 29 | template PDU_BSSGP bssgp) := { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 30 | bvci := bvci, |
| 31 | nsei := nsei, |
| 32 | sdu := sdu, |
| 33 | bssgp := bssgp |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | type record NsUnitdataIndication { |
| 37 | BssgpBvci bvci, |
| 38 | Nsei nsei, |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 39 | octetstring sdu optional, |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 40 | PDU_BSSGP bssgp optional |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | template NsUnitdataIndication t_NsUdInd(Nsei nsei, BssgpBvci bvci, octetstring sdu) := { |
| 44 | bvci := bvci, |
| 45 | nsei := nsei, |
| 46 | sdu := sdu, |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 47 | bssgp := dec_PDU_BSSGP(sdu) |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | type record NsStatusIndication { |
| 51 | Nsei nsei, |
| 52 | Nsvci nsvci, |
| 53 | NseState old_state, |
| 54 | NseState new_state |
| 55 | } |
| 56 | |
| 57 | template NsStatusIndication t_NsStsInd(Nsei nsei, Nsvci nsvci, NseState old_state, NseState state) := { |
| 58 | nsei := nsei, |
| 59 | nsvci := nsvci, |
| 60 | old_state := old_state, |
| 61 | new_state := state |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | type enumerated NseState { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 65 | NSE_S_DEAD_BLOCKED, |
| 66 | NSE_S_WAIT_RESET, |
| 67 | NSE_S_ALIVE_BLOCKED, |
| 68 | NSE_S_ALIVE_UNBLOCKED |
| 69 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 70 | |
| 71 | /* port from our (internal) point of view */ |
| 72 | type port NS_SP_PT message { |
| 73 | in NsUnitdataRequest; |
| 74 | out NsUnitdataIndication, |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 75 | NsStatusIndication, |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 76 | ASP_Event; |
| 77 | } with { extension "internal" }; |
| 78 | |
| 79 | /* port from the user point of view */ |
| 80 | type port NS_PT message { |
| 81 | in ASP_Event, |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 82 | NsStatusIndication, |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 83 | NsUnitdataIndication; |
| 84 | out NsUnitdataRequest; |
| 85 | } with { extension "internal" }; |
| 86 | |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 87 | function NSStart(NSConfiguration init_config) runs on NS_CT { |
| 88 | config := init_config; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 89 | f_init(); |
| 90 | f_ScanEvents(); |
| 91 | } |
| 92 | |
| 93 | private function f_init() runs on NS_CT { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 94 | var Result res; |
| 95 | /* Connect the UDP socket */ |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 96 | res := f_IPL4_connect(NSCP, config.remote_ip, config.remote_udp_port, config.local_ip, config.local_udp_port, 0, { udp := {}}); |
Harald Welte | 9220f63 | 2018-05-23 20:27:02 +0200 | [diff] [blame] | 97 | if (not ispresent(res.connId)) { |
Max | 39e6cae | 2018-11-06 19:00:50 +0100 | [diff] [blame] | 98 | setverdict(fail, "Could not connect NS UDP socket from " & |
| 99 | config.local_ip & ":" & int2str(config.local_udp_port) & |
| 100 | " to " & config.remote_ip & ":" & int2str(config.remote_udp_port)); |
Daniel Willmann | e4ff537 | 2018-07-05 17:35:03 +0200 | [diff] [blame] | 101 | mtc.stop; |
Harald Welte | 9220f63 | 2018-05-23 20:27:02 +0200 | [diff] [blame] | 102 | } |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 103 | g_conn_id := res.connId; |
| 104 | f_change_state(NSE_S_DEAD_BLOCKED); |
| 105 | /* Send the first NS-ALIVE to test the connection */ |
Harald Welte | e81d84e | 2018-07-05 03:17:00 +0200 | [diff] [blame] | 106 | if (not config.role_sgsn) { |
| 107 | f_sendReset(); |
| 108 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | type component NS_CT { |
| 112 | /* UDP port towards the bottom (IUT) */ |
| 113 | port NS_CODEC_PT NSCP; |
| 114 | /* NS-User SAP towards the user */ |
| 115 | port NS_SP_PT NS_SP; |
| 116 | |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 117 | var NSConfiguration config; |
| 118 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 119 | var NseState g_state := NSE_S_DEAD_BLOCKED; |
| 120 | var ConnectionId g_conn_id := -1; |
| 121 | |
| 122 | timer Tns_alive := 3.0; |
| 123 | timer Tns_test := 10.0; |
| 124 | timer Tns_block := 10.0; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 125 | } |
| 126 | |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 127 | type record NSConfiguration { |
Alexander Couzens | 1e5dc48 | 2020-07-28 15:38:46 +0200 | [diff] [blame] | 128 | PCUIF_AddrType remote_proto, |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 129 | PortNumber local_udp_port, |
| 130 | charstring local_ip, |
| 131 | PortNumber remote_udp_port, |
| 132 | charstring remote_ip, |
| 133 | Nsvci nsvci, |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 134 | Nsvci nsei, |
| 135 | boolean role_sgsn, |
| 136 | boolean handle_sns |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 137 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 138 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 139 | private function f_change_state(NseState new_state) runs on NS_CT { |
| 140 | var NseState old_state := g_state; |
| 141 | g_state := new_state; |
| 142 | log("NS State Transition: ", old_state, " -> ", new_state); |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 143 | NS_SP.send(t_NsStsInd(config.nsei, config.nsvci, old_state, new_state)); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 144 | } |
| 145 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 146 | private function f_sendReset() runs on NS_CT { |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 147 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_RESET(NS_CAUSE_OM_INTERVENTION, config.nsvci, config.nsei))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 148 | g_state := NSE_S_WAIT_RESET; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 149 | } |
| 150 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 151 | private function f_sendAlive() runs on NS_CT { |
| 152 | NSCP.send(t_NS_Send(g_conn_id, t_NS_ALIVE)); |
| 153 | Tns_alive.start; |
| 154 | } |
| 155 | |
| 156 | private function f_sendUnblock() runs on NS_CT { |
| 157 | NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK)); |
| 158 | Tns_block.start; |
| 159 | } |
| 160 | |
| 161 | private function f_sendBlock(NsCause cause) runs on NS_CT { |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 162 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_BLOCK(cause, config.nsvci))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 163 | Tns_block.start; |
| 164 | } |
| 165 | |
| 166 | altstep as_allstate() runs on NS_CT { |
| 167 | var NS_RecvFrom rf; |
| 168 | var ASP_Event evt; |
| 169 | |
| 170 | /* transition to DEAD if t_alive times out */ |
Harald Welte | c27f684 | 2018-03-02 21:40:03 +0100 | [diff] [blame] | 171 | [Tns_alive.running] Tns_alive.timeout { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 172 | log("Tns-alive expired: changing to DEAD_BLOCKED + starting Tns-test"); |
| 173 | f_change_state(NSE_S_DEAD_BLOCKED); |
| 174 | Tns_test.start; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 175 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 176 | |
Harald Welte | c27f684 | 2018-03-02 21:40:03 +0100 | [diff] [blame] | 177 | [Tns_test.running] Tns_test.timeout { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 178 | log("Tns-test expired: sending NS-ALIVE"); |
| 179 | f_sendAlive(); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 180 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 181 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 182 | /* Stop t_alive when receiving ALIVE-ACK */ |
| 183 | [] NSCP.receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) { |
| 184 | log("NS-ALIVE-ACK received: stopping Tns-alive; starting Tns-test"); |
| 185 | Tns_alive.stop; |
| 186 | Tns_test.start; |
| 187 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 188 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 189 | /* respond to NS-ALIVE with NS-ALIVE-ACK */ |
| 190 | [] NSCP.receive(t_NS_RecvFrom(t_NS_ALIVE)) { |
| 191 | NSCP.send(t_NS_Send(g_conn_id, t_NS_ALIVE_ACK)); |
| 192 | } |
| 193 | |
| 194 | /* Respond to BLOCK for wrong NSVCI */ |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 195 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK(?, ?))) -> value rf { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 196 | log("Rx NS-BLOCK for unknown NSVCI"); |
| 197 | /* FIXME */ |
| 198 | } |
| 199 | |
| 200 | /* Respond to RESET with correct NSEI/NSVCI */ |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 201 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_RESET(?, config.nsvci, config.nsei))) -> value rf { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 202 | f_change_state(NSE_S_ALIVE_BLOCKED); |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 203 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_RESET_ACK(config.nsvci, config.nsei))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /* Respond to RESET with wrong NSEI/NSVCI */ |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 207 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_RESET(?, ?, ?))) -> value rf { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 208 | log("Rx NS-RESET for unknown NSEI/NSVCI"); |
| 209 | /* FIXME */ |
| 210 | } |
| 211 | |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 212 | [config.role_sgsn and config.handle_sns] as_sns_sgsn(); |
| 213 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 214 | /* default case of handling unknown PDUs */ |
| 215 | [] NSCP.receive(t_NS_RecvFrom(?)) -> value rf { |
| 216 | log("Rx Unexpected NS PDU ", rf.msg," in state ", g_state); |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 217 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_STATUS(NS_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE, rf.msg))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 218 | } |
| 219 | /* Forwarding of ASP_Evet to user */ |
| 220 | [] NSCP.receive(ASP_Event:?) -> value evt { NS_SP.send(evt); } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 221 | } |
| 222 | |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 223 | /* simple IP Sub-Network Service responder for the SGSN side. This is not a full implementation |
| 224 | * of the protocol, merely sufficient to make the PCU/BSS side happy to proceed */ |
| 225 | altstep as_sns_sgsn() runs on NS_CT { |
| 226 | var NS_RecvFrom rf; |
| 227 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_SIZE(config.nsei))) -> value rf { |
| 228 | /* blindly acknowledge whatever the PCU sends */ |
| 229 | NSCP.send(t_NS_Send(g_conn_id, ts_SNS_SIZE_ACK(config.nsei, omit))); |
| 230 | } |
| 231 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_SIZE(?))) { |
| 232 | setverdict(fail, "SNS-SIZE from unexpected NSEI"); |
| 233 | self.stop; |
| 234 | } |
| 235 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, true, |
| 236 | {tr_SNS_IPv4(config.remote_ip, config.remote_udp_port)}))) -> value rf { |
| 237 | /* blindly acknowledge whatever the PCU sends */ |
| 238 | NSCP.send(t_NS_Send(g_conn_id, ts_SNS_CONFIG_ACK(config.nsei, omit))); |
| 239 | /* send a SNS-CONFIG in response and expect a SNS-CONFIG-ACK */ |
| 240 | var IP4_Elements v4 := { valueof(ts_SNS_IPv4(config.local_ip, config.local_udp_port)) }; |
| 241 | NSCP.send(t_NS_Send(g_conn_id, ts_SNS_CONFIG(config.nsei, true, v4))); |
| 242 | alt { |
| 243 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG_ACK(config.nsei, omit))) { |
| 244 | /* success */ |
| 245 | } |
| 246 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG_ACK(config.nsei, ?))) { |
| 247 | setverdict(fail, "Unexpected SNS-CONFIG-NACK"); |
| 248 | self.stop; |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, false, ?))) { /* ignore */} |
| 253 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, true, ?))) { |
| 254 | setverdict(fail, "Unexpected SNS-CONFIG content"); |
| 255 | self.stop; |
| 256 | } |
| 257 | [] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(?, ?, ?))) { |
| 258 | setverdict(fail, "SNS-CONFIG from unexpected NSEI"); |
| 259 | self.stop; |
| 260 | } |
| 261 | } |
| 262 | |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 263 | private function f_ScanEvents() runs on NS_CT { |
| 264 | var NsUnitdataRequest ud_req; |
| 265 | var NS_RecvFrom rf; |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 266 | var default d; |
| 267 | |
| 268 | d := activate(as_allstate()); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 269 | |
| 270 | while (true) { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 271 | if (g_state == NSE_S_DEAD_BLOCKED) { |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 272 | alt { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 273 | [false] any timer.timeout {} |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 274 | } |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 275 | } else if (g_state == NSE_S_WAIT_RESET) { |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 276 | alt { |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 277 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_RESET_ACK(config.nsvci, config.nsei))) -> value rf { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 278 | f_change_state(NSE_S_ALIVE_BLOCKED); |
| 279 | f_sendAlive(); |
| 280 | f_sendUnblock(); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 281 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 282 | } |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 283 | } else if (g_state == NSE_S_ALIVE_BLOCKED) { |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 284 | alt { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 285 | /* bogus block, just respond with ACK */ |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 286 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK(?, config.nsvci))) -> value rf { |
| 287 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_BLOCK_ACK(config.nsvci))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 288 | } |
| 289 | /* Respond to UNBLOCK with UNBLOCK-ACK + change state */ |
| 290 | [] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value rf { |
| 291 | NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK_ACK)); |
| 292 | Tns_block.stop; |
| 293 | f_change_state(NSE_S_ALIVE_UNBLOCKED); |
| 294 | } |
| 295 | [] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK_ACK)) -> value rf { |
| 296 | Tns_block.stop; |
| 297 | f_change_state(NSE_S_ALIVE_UNBLOCKED); |
| 298 | } |
| 299 | [] Tns_block.timeout { |
| 300 | /* repeat unblock transmission */ |
| 301 | f_sendUnblock(); |
| 302 | } |
| 303 | } |
| 304 | } else if (g_state == NSE_S_ALIVE_UNBLOCKED) { |
| 305 | alt { |
| 306 | /* bogus unblock, just respond with ACK */ |
| 307 | [] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value rf { |
| 308 | NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK_ACK)); |
| 309 | } |
| 310 | /* Respond to BLOCK with BLOCK-ACK + change state */ |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 311 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK(?, config.nsvci))) -> value rf { |
| 312 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_BLOCK_ACK(config.nsvci))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 313 | Tns_block.stop; |
| 314 | f_change_state(NSE_S_ALIVE_BLOCKED); |
| 315 | } |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 316 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(config.nsvci))) -> value rf { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 317 | Tns_block.stop; |
| 318 | } |
| 319 | /* NS-UNITDATA PDU from network to NS-UNITDATA.ind to user */ |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 320 | [] NSCP.receive(t_NS_RecvFrom(tr_NS_UNITDATA(?, ?, ?))) -> value rf { |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 321 | NS_SP.send(t_NsUdInd(config.nsei, |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 322 | oct2int(rf.msg.pDU_NS_Unitdata.bVCI), |
| 323 | rf.msg.pDU_NS_Unitdata.nS_SDU)); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 324 | } |
| 325 | /* NS-UNITDATA.req from user to NS-UNITDATA PDU on network */ |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 326 | [] NS_SP.receive(t_NsUdReq(config.nsei, ?, ?, omit)) -> value ud_req { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 327 | /* using raw octetstring PDU */ |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 328 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, ud_req.sdu))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 329 | } |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 330 | [] NS_SP.receive(t_NsUdReq(config.nsei, ?, omit, ?)) -> value ud_req { |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 331 | /* using decoded BSSGP PDU that we need to encode first */ |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 332 | var octetstring enc := enc_PDU_BSSGP(ud_req.bssgp); |
Harald Welte | 387ab37 | 2018-06-30 10:27:06 +0200 | [diff] [blame] | 333 | NSCP.send(t_NS_Send(g_conn_id, ts_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, enc))); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 334 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 338 | } /* while */ |
| 339 | //deactivate(d); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 340 | } |
| 341 | } |