blob: 42efb7d563060b26052eec8e17e625f85d6ff492 [file] [log] [blame]
Alexander Couzensc3165722021-01-11 02:51:45 +01001module 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
13import from Misc_Helpers all;
14import from General_Types all;
15import from Osmocom_Types all;
16import from Osmocom_Gb_Types all;
17import from NS_Emulation all;
18import from NS_Types all;
19import from BSSGP_Types all;
20import from NS_Emulation all;
21import from Native_Functions all;
22import from IPL4asp_Types all;
23import from NS_Provider_IPL4 all;
24#ifdef NS_EMULATION_FR
25import from NS_Provider_FR all;
26#endif
27
28public 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 Welte424ec522021-03-23 18:20:12 +010037 var boolean g_handle_rx_alive := false;
Alexander Couzensc3165722021-01-11 02:51:45 +010038}
39
40public 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
47function 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
77function 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
88public 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
96function 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 { }
Alexander Couzens3f1d6612021-04-19 02:57:14 +0200103 [g_handle_rx_alive] as_rx_alive_tx_ack(idx := idx);
Alexander Couzensc3165722021-01-11 02:51:45 +0100104 }
105 deactivate(d);
106 return nrf;
107}
108
109/* perform outbound NS-ALIVE procedure */
110function 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);
Alexander Couzens3f1d6612021-04-19 02:57:14 +0200114 [g_handle_rx_alive] as_rx_alive_tx_ack(idx := idx);
Alexander Couzensc3165722021-01-11 02:51:45 +0100115 [] NSCP[idx].receive { repeat; }
116 }
117}
118
119/* perform outbound NS-ALIVE procedure */
120function 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 }
Alexander Couzens3f1d6612021-04-19 02:57:14 +0200128 [g_handle_rx_alive] as_rx_alive_tx_ack(idx := idx);
Alexander Couzensc3165722021-01-11 02:51:45 +0100129 [] NSCP[idx].receive { repeat; }
130 [] T.timeout {
131 setverdict(pass);
132 }
133 }
134}
135
136function 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 }
Alexander Couzens3f1d6612021-04-19 02:57:14 +0200145 [g_handle_rx_alive] as_rx_alive_tx_ack(idx := idx);
Alexander Couzensc3165722021-01-11 02:51:45 +0100146 [] 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 */
154function 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));
Alexander Couzens3f1d6612021-04-19 02:57:14 +0200158 [g_handle_rx_alive] as_rx_alive_tx_ack(idx := idx);
Alexander Couzensc3165722021-01-11 02:51:45 +0100159 [] NSCP[idx].receive { repeat; }
160 }
161}
162
163/* perform outbound NS-UNBLOCK procedure */
164function 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);
Alexander Couzens3f1d6612021-04-19 02:57:14 +0200168 [g_handle_rx_alive] as_rx_alive_tx_ack(idx := idx);
Alexander Couzensc3165722021-01-11 02:51:45 +0100169 [] NSCP[idx].receive { repeat; }
170 }
171}
172
173/* receive NS-ALIVE and ACK it */
174altstep 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 Welte6a414c82021-03-24 00:56:44 +0100179 /* 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 Couzensc3165722021-01-11 02:51:45 +0100186}
187
188/* Transmit BSSGP RESET for given BVCI and expect ACK */
189function 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)
191runs 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 }
Alexander Couzens3f1d6612021-04-19 02:57:14 +0200208 [g_handle_rx_alive] as_rx_alive_tx_ack(idx := idx);
Alexander Couzensc3165722021-01-11 02:51:45 +0100209 [] NSCP[idx].receive { repeat; }
210 }
211}
212
213/* Receive a BSSGP RESET for given BVCI and ACK it */
214altstep 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 */
229altstep 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 Pedrol6ee01262021-02-05 13:05:06 +0100231 [] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_UNBLOCK(bvci))) -> value ns_rf {
Alexander Couzensc3165722021-01-11 02:51:45 +0100232 var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.pDU_NS_Unitdata.nS_SDU);
Pau Espin Pedrol6ee01262021-02-05 13:05:06 +0100233 var PDU_BSSGP bssgp_tx := valueof(ts_BVC_UNBLOCK_ACK(bvci));
Alexander Couzensc3165722021-01-11 02:51:45 +0100234 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 */
240altstep 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 Pedrol6ee01262021-02-05 13:05:06 +0100247 var PDU_BSSGP bssgp_tx := valueof(ts_BVC_FC_BVC_ACK(tag));
Alexander Couzensc3165722021-01-11 02:51:45 +0100248 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 */
258public 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 */
267public 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 Couzens20cd41e2021-01-11 02:56:03 +0100275/* Receive a NS-BLOCK and ACK it */
276public 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 Couzens98ee6f62021-02-03 16:17:08 +0100284/**********************************************************************************
285 * IP Sub-Network Service (SNS)
286 **********************************************************************************/
287
288/* perform inbound SNS-SIZE procedure */
Harald Welte22deecc2021-03-23 13:13:52 +0100289function f_incoming_sns_size(template (omit) NsCause cause := omit, integer idx := 0,
290 template integer num_max_nsvcs := ?, template integer num_ep := ?)
Alexander Couzens98ee6f62021-02-03 16:17:08 +0100291runs 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 Welte22deecc2021-03-23 13:13:52 +0100298 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 Couzens98ee6f62021-02-03 16:17:08 +0100300 } else {
301 /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */
Harald Welte22deecc2021-03-23 13:13:52 +0100302 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 Couzens98ee6f62021-02-03 16:17:08 +0100304 }
305 NSCP[idx].send(ts_SNS_SIZE_ACK(g_nsconfig.nsei, cause));
306}
307
308/* perform outbound SNS-SIZE procedure */
Harald Welte424ec522021-03-23 18:20:12 +0100309function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer max_nsvcs := 1,
310 integer num_ip := 1, integer idx:= 0)
Alexander Couzens98ee6f62021-02-03 16:17:08 +0100311runs 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 Welte424ec522021-03-23 18:20:12 +0100317 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 Couzens98ee6f62021-02-03 16:17:08 +0100319 );
320 } else {
Harald Welte424ec522021-03-23 18:20:12 +0100321 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 Couzens98ee6f62021-02-03 16:17:08 +0100323 );
324 }
Harald Welte424ec522021-03-23 18:20:12 +0100325 /* expect one single SNS-SIZE */
Alexander Couzens98ee6f62021-02-03 16:17:08 +0100326 rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig.nsei, cause), idx);
327}
328
329/* perform inbound SNS-CONFIG procedure */
330function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
331runs 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 */
349function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
350runs 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 */
368function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0)
369runs 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 */
390function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := omit, integer idx := 0)
391runs 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 Couzensd5ac5102021-02-27 20:53:37 +0100410/* perform inbound SNS-CHANGE-WEIGHT procedure */
Alexander Couzens2d10ee62021-06-06 23:14:03 +0200411function f_incoming_sns_chg_weight(integer idx_chg := 0, template (omit) NsCause cause := omit, integer idx := 0)
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100412runs on RAW_NS_CT {
413 log("f_incoming_sns_chg_weight(idx=", idx, ")");
414 var PDU_NS rx;
Alexander Couzens2d10ee62021-06-06 23:14:03 +0200415 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_chg];
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100416
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 Couzensc56a3b22021-04-19 02:57:26 +0200430/* perform inbound SNS-ADD procedure */
431function f_incoming_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0, template (omit) NsCause cause := omit)
432runs on RAW_NS_CT {
433 log("f_incoming_sns_add(idx=", idx, ")");
434 var PDU_NS rx;
435 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_add];
436
437 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
438 var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
439 nsvc_cfg.provider.ip.remote_udp_port,
440 w_sig, w_user) };
441 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, v4 := v4_elem), idx);
442 } else {
443 var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
444 nsvc_cfg.provider.ip.remote_udp_port,
445 w_sig, w_user) };
446 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, omit, v6_elem), idx);
447 }
448 NSCP[idx].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Add.transactionID));
449}
450
Alexander Couzens98ee6f62021-02-03 16:17:08 +0100451function 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)
452runs on RAW_NS_CT {
453 log("f_outgoing_sns_add(idx_add=", idx_add, ")");
454 var PDU_NS rx;
455 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_add];
456 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
457 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
458 nsvc_cfg.provider.ip.local_udp_port,
459 w_sig, w_user) };
460 NSCP[idx].send(ts_SNS_ADD(g_nsconfig.nsei, 23, v4));
461 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 23, cause, v4));
462 } else {
463 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
464 nsvc_cfg.provider.ip.local_udp_port,
465 w_sig, w_user) };
466 NSCP[idx].send(ts_SNS_ADD(g_nsconfig.nsei, 23, omit, v6));
467 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 23, cause, omit, v6));
468 }
469}
470
Alexander Couzens54ebb4a2021-04-19 03:14:44 +0200471/* perform inbound SNS-DELETE procedure */
472function f_incoming_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0, template (omit) NsCause cause := omit)
473runs on RAW_NS_CT {
474 log("f_incoming_sns_del(idx=", idx, ")");
475 var PDU_NS rx;
476 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_del];
477
478 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
479 var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
480 nsvc_cfg.provider.ip.remote_udp_port,
481 w_sig, w_user) };
482 rx := f_ns_exp(tr_SNS_DEL(g_nsconfig.nsei, ?, omit, v4 := v4_elem), idx);
483 } else {
484 var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
485 nsvc_cfg.provider.ip.remote_udp_port,
486 w_sig, w_user) };
487 rx := f_ns_exp(tr_SNS_DEL(g_nsconfig.nsei, ?, omit, omit, v6_elem), idx);
488 }
489 NSCP[idx].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Delete.transactionID));
490}
491
492
Alexander Couzens98ee6f62021-02-03 16:17:08 +0100493function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
494runs on RAW_NS_CT {
495 log("f_outgoing_sns_del(idx_del=", idx_del, ")");
496 var PDU_NS rx;
497 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_del];
498 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
499 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
500 nsvc_cfg.provider.ip.local_udp_port,
501 w_sig, w_user) };
502 NSCP[idx].send(ts_SNS_DEL(g_nsconfig.nsei, 24, omit, v4));
503 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 24, omit, v4));
504 } else {
505 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
506 nsvc_cfg.provider.ip.local_udp_port,
507 w_sig, w_user) };
508 NSCP[idx].send(ts_SNS_DEL(g_nsconfig.nsei, 24, omit, omit, v6));
509 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 24, omit, omit, v6));
510 }
511}
512
513function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0)
514runs on RAW_NS_CT {
515 log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")");
516 var PDU_NS rx;
517 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_chg];
518 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
519 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
520 nsvc_cfg.provider.ip.local_udp_port,
521 w_sig, w_user) };
522 NSCP[idx].send(ts_SNS_CHG_WEIGHT(g_nsconfig.nsei, 25, v4));
523 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 25, omit, v4));
524 } else {
525 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
526 nsvc_cfg.provider.ip.local_udp_port,
527 w_sig, w_user) };
528 NSCP[idx].send(ts_SNS_CHG_WEIGHT(g_nsconfig.nsei, 25, omit, v6));
529 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 25, omit, omit, v6));
530 }
531}
532
Alexander Couzensc3165722021-01-11 02:51:45 +0100533}