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, |
| 23 | bvci := 1234, |
| 24 | cell_id := { |
| 25 | ra_id := { |
| 26 | lai := { |
| 27 | mcc_mnc := '262F42'H, lac := 13135 |
| 28 | }, |
| 29 | rac := 0 |
| 30 | }, |
| 31 | cell_id := 20960 |
| 32 | }, |
| 33 | sgsn_role := true, |
| 34 | depth := BSSGP_DECODE_DEPTH_BSSGP |
| 35 | }; |
| 36 | |
| 37 | NSConfiguration mp_nsconfig := { |
| 38 | local_udp_port := 23000, |
| 39 | local_ip := "127.0.0.1", |
| 40 | remote_udp_port := 21000, |
| 41 | remote_ip := "127.0.0.1", |
| 42 | nsvci := 0, |
| 43 | nsei := 2342, |
| 44 | role_sgsn := true, |
| 45 | handle_sns := true |
| 46 | }; |
| 47 | } |
| 48 | |
| 49 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 50 | type component bssgp_CT extends BSSGP_Client_CT { |
| 51 | var NS_CT ns_component; |
| 52 | var BSSGP_CT bssgp_component; |
| 53 | var boolean g_initialized := false; |
| 54 | } |
| 55 | |
| 56 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 57 | function f_init_bssgp() runs on bssgp_CT { |
| 58 | var MmContext mmctx := { |
| 59 | imsi := '262420000000001'H, |
| 60 | tlli := 'FFFFFFFF'O, |
| 61 | n_u := 0 |
| 62 | }; |
| 63 | |
| 64 | |
| 65 | if (g_initialized == true) { |
| 66 | return; |
| 67 | } |
| 68 | g_initialized := true; |
| 69 | |
| 70 | /* create a new NS component */ |
| 71 | ns_component := NS_CT.create; |
| 72 | bssgp_component := BSSGP_CT.create; |
| 73 | /* connect our BSSGP port to the BSSGP Emulation */ |
| 74 | connect(self:BSSGP[0], bssgp_component:BSSGP_SP); |
| 75 | connect(self:BSSGP_SIG[0], bssgp_component:BSSGP_SP_SIG); |
| 76 | connect(self:BSSGP_PROC[0], bssgp_component:BSSGP_PROC); |
| 77 | /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/ |
| 78 | connect(bssgp_component:BSCP, ns_component:NS_SP); |
| 79 | /* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */ |
| 80 | map(ns_component:NSCP, system:NS_CODEC_PORT); |
| 81 | ns_component.start(NSStart(mp_nsconfig)); |
| 82 | bssgp_component.start(BssgpStart(mp_gb_cfg)); |
| 83 | |
| 84 | f_bssgp_client_register(mmctx.imsi, mmctx.tlli, mp_gb_cfg.cell_id); |
| 85 | } |
| 86 | |
| 87 | /* Establish BSSGP connection to PCU */ |
| 88 | function f_bssgp_establish() runs on BSSGP_Client_CT { |
| 89 | timer T:= 10.0; |
| 90 | |
| 91 | T.start |
| 92 | alt { |
| 93 | [] BSSGP[0].receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { } |
| 94 | [] BSSGP[0].receive { repeat; } |
| 95 | [] T.timeout { |
| 96 | setverdict(fail, "Timeout establishing BSSGP connection"); |
| 97 | mtc.stop; |
| 98 | } |
| 99 | } |
| 100 | T.stop |
| 101 | log("BSSGP successfully initialized"); |
| 102 | } |
| 103 | |
| 104 | } |