Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 1 | module SGSN_Components { |
| 2 | /* |
| 3 | * Osmocom PCU test suite in TTCN-3, components for BSSGP handlng |
| 4 | * (C) 2018-2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2020 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | */ |
| 13 | |
| 14 | import from BSSGP_Types all; |
| 15 | import from BSSGP_Emulation all; |
| 16 | import from NS_Types all; |
| 17 | import from NS_Emulation all; |
| 18 | import from GPRS_Context all; |
| 19 | |
| 20 | modulepar { |
| 21 | BssgpConfig mp_gb_cfg := { |
| 22 | nsei := 1234, |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 23 | sgsn_role := true, |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 24 | bvc := { |
| 25 | { |
| 26 | bvci := 1234, |
| 27 | cell_id := { |
| 28 | ra_id := { |
| 29 | lai := { |
| 30 | mcc_mnc := '262F42'H, lac := 13135 |
| 31 | }, |
| 32 | rac := 0 |
| 33 | }, |
| 34 | cell_id := 20960 |
| 35 | }, |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 36 | depth := BSSGP_DECODE_DEPTH_BSSGP, |
| 37 | create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 38 | } |
| 39 | } |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | NSConfiguration mp_nsconfig := { |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 43 | nsei := 2342, |
| 44 | role_sgsn := true, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 45 | handle_sns := true, |
| 46 | nsvc := { |
| 47 | { |
| 48 | provider := { |
| 49 | ip := { |
| 50 | address_family := AF_INET, |
| 51 | local_udp_port := 23000, |
| 52 | local_ip := "127.0.0.1", |
| 53 | remote_udp_port := 21000, |
| 54 | remote_ip := "127.0.0.1" |
| 55 | } |
| 56 | }, |
| 57 | nsvci := 0 |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 58 | }, |
| 59 | { |
| 60 | provider := { |
| 61 | ip := { |
| 62 | address_family := AF_INET, |
| 63 | local_udp_port := 23001, |
| 64 | local_ip := "127.0.0.1", |
| 65 | remote_udp_port := 21000, |
| 66 | remote_ip := "127.0.0.1" |
| 67 | } |
| 68 | }, |
| 69 | nsvci := 0 |
| 70 | }, |
| 71 | { |
| 72 | provider := { |
| 73 | ip := { |
| 74 | address_family := AF_INET, |
| 75 | local_udp_port := 23002, |
| 76 | local_ip := "127.0.0.1", |
| 77 | remote_udp_port := 21000, |
| 78 | remote_ip := "127.0.0.1" |
| 79 | } |
| 80 | }, |
| 81 | nsvci := 0 |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 82 | } |
| 83 | } |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 84 | }; |
| 85 | } |
| 86 | |
| 87 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 88 | type component bssgp_CT extends BSSGP_Client_CT { |
| 89 | var NS_CT ns_component; |
| 90 | var BSSGP_CT bssgp_component; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 91 | port BSSGP_CT_PROC_PT PROC; |
Pau Espin Pedrol | efe6664 | 2021-01-20 14:41:59 +0100 | [diff] [blame^] | 92 | port BSSGP_PT RIM; |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 93 | var boolean g_initialized := false; |
| 94 | } |
| 95 | |
| 96 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 97 | function f_init_bssgp() runs on bssgp_CT { |
| 98 | var MmContext mmctx := { |
| 99 | imsi := '262420000000001'H, |
| 100 | tlli := 'FFFFFFFF'O, |
| 101 | n_u := 0 |
| 102 | }; |
| 103 | |
| 104 | |
| 105 | if (g_initialized == true) { |
| 106 | return; |
| 107 | } |
| 108 | g_initialized := true; |
| 109 | |
| 110 | /* create a new NS component */ |
| 111 | ns_component := NS_CT.create; |
| 112 | bssgp_component := BSSGP_CT.create; |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 113 | /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/ |
| 114 | connect(bssgp_component:BSCP, ns_component:NS_SP); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 115 | connect(self:PROC, bssgp_component:PROC); |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 116 | ns_component.start(NSStart(mp_nsconfig)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 117 | bssgp_component.start(BssgpStart(mp_gb_cfg, testcasename())); |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 118 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 119 | for (var integer i := 0; i < lengthof(mp_gb_cfg.bvc); i := i+1) { |
| 120 | var BSSGP_BVC_CT vc_BVC; |
| 121 | /* obtain reference for BVC component (created by BssgpStart) */ |
| 122 | vc_BVC := f_bssgp_get_bvci_ct(mp_gb_cfg.bvc[i].bvci, PROC); |
| 123 | /* connect our BSSGP port to the BSSGP Emulation */ |
| 124 | connect(self:BSSGP[i], vc_BVC:BSSGP_SP); |
| 125 | connect(self:BSSGP_SIG[i], vc_BVC:BSSGP_SP_SIG); |
| 126 | connect(self:BSSGP_PROC[i], vc_BVC:BSSGP_PROC); |
| 127 | f_bssgp_client_register(mmctx.imsi, mmctx.tlli); |
| 128 | } |
Pau Espin Pedrol | efe6664 | 2021-01-20 14:41:59 +0100 | [diff] [blame^] | 129 | /* connect RIM related port */ |
| 130 | connect(self:RIM, bssgp_component:RIM); |
Harald Welte | 9b461a9 | 2020-12-10 23:41:14 +0100 | [diff] [blame] | 131 | connect(self:BSSGP_GLOBAL[0], bssgp_component:GLOBAL); |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | /* Establish BSSGP connection to PCU */ |
| 135 | function f_bssgp_establish() runs on BSSGP_Client_CT { |
| 136 | timer T:= 10.0; |
| 137 | |
| 138 | T.start |
| 139 | alt { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 140 | [] BSSGP[0].receive(tr_BssgpStsInd(*, ?, BVC_S_UNBLOCKED)) { } |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 141 | [] BSSGP[0].receive { repeat; } |
| 142 | [] T.timeout { |
| 143 | setverdict(fail, "Timeout establishing BSSGP connection"); |
| 144 | mtc.stop; |
| 145 | } |
| 146 | } |
| 147 | T.stop |
| 148 | log("BSSGP successfully initialized"); |
| 149 | } |
| 150 | |
| 151 | } |