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