Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 1 | module Osmocom_CTRL_Adapter { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* Module that test suites can 'inherit' in order to have a CTRL connection to the IUT which they're testing |
| 4 | * (C) 2018 Harald Welte <laforge@gnumonks.org> |
| 5 | * contributions by sysmocom - s.f.m.c. GmbH |
| 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 | */ |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 13 | |
| 14 | import from IPL4asp_Types all; |
| 15 | |
| 16 | import from IPA_Emulation all; |
| 17 | import from IPA_Types all; |
| 18 | |
| 19 | import from Osmocom_CTRL_Functions all; |
| 20 | import from Osmocom_CTRL_Types all; |
| 21 | |
| 22 | |
| 23 | type component CTRL_Adapter_CT { |
| 24 | var IPA_Emulation_CT vc_CTRL_IPA; |
| 25 | /* test port for the CTRL interface of the BSC */ |
| 26 | port IPA_CTRL_PT IPA_CTRL; |
| 27 | } |
| 28 | |
| 29 | |
| 30 | /*! Start the CTRL connection to the specified BSC IP+Port */ |
| 31 | function f_ipa_ctrl_start(charstring bsc_host, PortNumber bsc_port) |
| 32 | runs on CTRL_Adapter_CT { |
| 33 | var charstring id := "IPA-CTRL" |
| 34 | timer T := 10.0; |
| 35 | |
| 36 | vc_CTRL_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 37 | |
| 38 | map(vc_CTRL_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 39 | connect(vc_CTRL_IPA:IPA_CTRL_PORT, self:IPA_CTRL); |
| 40 | |
Philipp Maier | 1f581b4 | 2018-12-18 17:04:25 +0100 | [diff] [blame] | 41 | vc_CTRL_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 0, |
Harald Welte | 2d86aff | 2018-04-17 11:23:04 +0200 | [diff] [blame] | 42 | c_IPA_default_ccm_pars, false)); |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 43 | |
| 44 | /* wait for IPA CTRL link to connect and send UP */ |
| 45 | T.start; |
| 46 | alt { |
Vadim Yanitskiy | a2afacc | 2020-05-18 21:16:19 +0700 | [diff] [blame^] | 47 | [] IPA_CTRL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) { } |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 48 | [] T.timeout { |
| 49 | setverdict(fail, "Timeout CTRL waiting for ASP_IPA_EVENT_UP"); |
Daniel Willmann | e4ff537 | 2018-07-05 17:35:03 +0200 | [diff] [blame] | 50 | mtc.stop; |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
Harald Welte | 1205547 | 2018-03-17 20:10:08 +0100 | [diff] [blame] | 55 | function f_ipa_ctrl_stop() runs on CTRL_Adapter_CT { |
| 56 | vc_CTRL_IPA.stop; |
| 57 | } |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 58 | |
| 59 | |
| 60 | /* BSC specific CTRL helper functions */ |
| 61 | function f_ctrl_get_bts(IPA_CTRL_PT pt, integer bts_nr, charstring suffix) return CtrlValue { |
| 62 | return f_ctrl_get(pt, "bts." & int2str(bts_nr) & "." & suffix); |
| 63 | } |
Pau Espin Pedrol | 5a2d743 | 2019-06-07 19:43:45 +0200 | [diff] [blame] | 64 | function f_ctrl_set_bts(IPA_CTRL_PT pt, integer bts_nr, charstring suffix, CtrlValue val) { |
| 65 | f_ctrl_set(pt, "bts." & int2str(bts_nr) & "." & suffix, val); |
| 66 | } |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 67 | |
| 68 | template charstring ts_bts(integer bts_nr) := "bts." & int2str(bts_nr) & "."; |
| 69 | template charstring ts_bts_trx(integer bts_nr, integer trx_nr ) := |
| 70 | valueof(ts_bts(bts_nr)) & "trx." & int2str(trx_nr) & "."; |
| 71 | |
| 72 | function f_ctrl_get_exp_bts(IPA_CTRL_PT pt, integer bts_nr, CtrlVariable suffix, template CtrlValue exp) { |
| 73 | f_ctrl_get_exp(pt, valueof(ts_bts(bts_nr)) & suffix, exp); |
| 74 | } |
| 75 | |
| 76 | function f_ctrl_get_exp_trx(IPA_CTRL_PT pt, integer bts_nr, integer trx_nr, CtrlVariable suffix, |
| 77 | template CtrlValue exp) |
| 78 | { |
| 79 | f_ctrl_get_exp(pt, valueof(ts_bts_trx(bts_nr, trx_nr)) & suffix, exp); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | } |