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 |
| 58 | } |
| 59 | } |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 60 | }; |
| 61 | } |
| 62 | |
| 63 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 64 | type component bssgp_CT extends BSSGP_Client_CT { |
| 65 | var NS_CT ns_component; |
| 66 | var BSSGP_CT bssgp_component; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 67 | port BSSGP_CT_PROC_PT PROC; |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 68 | var boolean g_initialized := false; |
| 69 | } |
| 70 | |
| 71 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 72 | function f_init_bssgp() runs on bssgp_CT { |
| 73 | var MmContext mmctx := { |
| 74 | imsi := '262420000000001'H, |
| 75 | tlli := 'FFFFFFFF'O, |
| 76 | n_u := 0 |
| 77 | }; |
| 78 | |
| 79 | |
| 80 | if (g_initialized == true) { |
| 81 | return; |
| 82 | } |
| 83 | g_initialized := true; |
| 84 | |
| 85 | /* create a new NS component */ |
| 86 | ns_component := NS_CT.create; |
| 87 | bssgp_component := BSSGP_CT.create; |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 88 | /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/ |
| 89 | connect(bssgp_component:BSCP, ns_component:NS_SP); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 90 | connect(self:PROC, bssgp_component:PROC); |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 91 | ns_component.start(NSStart(mp_nsconfig)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 92 | bssgp_component.start(BssgpStart(mp_gb_cfg, testcasename())); |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 93 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 94 | for (var integer i := 0; i < lengthof(mp_gb_cfg.bvc); i := i+1) { |
| 95 | var BSSGP_BVC_CT vc_BVC; |
| 96 | /* obtain reference for BVC component (created by BssgpStart) */ |
| 97 | vc_BVC := f_bssgp_get_bvci_ct(mp_gb_cfg.bvc[i].bvci, PROC); |
| 98 | /* connect our BSSGP port to the BSSGP Emulation */ |
| 99 | connect(self:BSSGP[i], vc_BVC:BSSGP_SP); |
| 100 | connect(self:BSSGP_SIG[i], vc_BVC:BSSGP_SP_SIG); |
| 101 | connect(self:BSSGP_PROC[i], vc_BVC:BSSGP_PROC); |
| 102 | f_bssgp_client_register(mmctx.imsi, mmctx.tlli); |
| 103 | } |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* Establish BSSGP connection to PCU */ |
| 107 | function f_bssgp_establish() runs on BSSGP_Client_CT { |
| 108 | timer T:= 10.0; |
| 109 | |
| 110 | T.start |
| 111 | alt { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 112 | [] BSSGP[0].receive(tr_BssgpStsInd(*, ?, BVC_S_UNBLOCKED)) { } |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 113 | [] BSSGP[0].receive { repeat; } |
| 114 | [] T.timeout { |
| 115 | setverdict(fail, "Timeout establishing BSSGP connection"); |
| 116 | mtc.stop; |
| 117 | } |
| 118 | } |
| 119 | T.stop |
| 120 | log("BSSGP successfully initialized"); |
| 121 | } |
| 122 | |
| 123 | } |