| module Osmocom_CTRL_Adapter { |
| |
| /* Module that test suites can 'inherit' in order to have a CTRL connection to the IUT which they're testing |
| * (C) 2018 Harald Welte <laforge@gnumonks.org> |
| * contributions by sysmocom - s.f.m.c. GmbH |
| * All rights reserved. |
| * |
| * Released under the terms of GNU General Public License, Version 2 or |
| * (at your option) any later version. |
| * |
| * SPDX-License-Identifier: GPL-2.0-or-later |
| */ |
| |
| import from IPL4asp_Types all; |
| |
| import from IPA_Emulation all; |
| import from IPA_Types all; |
| |
| import from Osmocom_CTRL_Functions all; |
| import from Osmocom_CTRL_Types all; |
| |
| |
| type component CTRL_Adapter_CT { |
| var IPA_Emulation_CT vc_CTRL_IPA; |
| /* test port for the CTRL interface of the BSC */ |
| port IPA_CTRL_PT IPA_CTRL; |
| } |
| |
| /* wait for IPA CTRL link to connect and send UP */ |
| function f_ipa_ctrl_wait_link_up() |
| runs on CTRL_Adapter_CT { |
| timer T := 10.0; |
| T.start; |
| alt { |
| [] IPA_CTRL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) { } |
| [] T.timeout { |
| setverdict(fail, "Timeout CTRL waiting for ASP_IPA_EVENT_UP"); |
| mtc.stop; |
| } |
| } |
| } |
| |
| /* wait for IPA CTRL link to connect and send UP */ |
| function f_ipa_ctrl_wait_link_down() |
| runs on CTRL_Adapter_CT { |
| timer T := 10.0; |
| T.start; |
| alt { |
| [] IPA_CTRL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) { } |
| [] T.timeout { |
| setverdict(fail, "Timeout CTRL waiting for ASP_IPA_EVENT_DOWN"); |
| mtc.stop; |
| } |
| } |
| } |
| |
| /*! Start the CTRL client connection to the specified CTRL IP+Port server*/ |
| function f_ipa_ctrl_start_client(charstring bsc_host, PortNumber bsc_port) |
| runs on CTRL_Adapter_CT { |
| var charstring id := "IPA-CTRL-CLI" |
| |
| vc_CTRL_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| |
| map(vc_CTRL_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| connect(vc_CTRL_IPA:IPA_CTRL_PORT, self:IPA_CTRL); |
| |
| vc_CTRL_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 0, |
| c_IPA_default_ccm_pars, false)); |
| |
| f_ipa_ctrl_wait_link_up(); |
| } |
| |
| /*! Start the CTRL server on the specified CTRL IP+Port */ |
| function f_ipa_ctrl_start_server(charstring listen_host, PortNumber listen_port) |
| runs on CTRL_Adapter_CT { |
| var charstring id := "IPA-CTRL-SRV" |
| timer T := 10.0; |
| |
| vc_CTRL_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| |
| map(vc_CTRL_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| connect(vc_CTRL_IPA:IPA_CTRL_PORT, self:IPA_CTRL); |
| |
| vc_CTRL_IPA.start(IPA_Emulation.main_server(listen_host, listen_port, false)); |
| } |
| |
| function f_ipa_ctrl_stop() runs on CTRL_Adapter_CT { |
| vc_CTRL_IPA.stop; |
| } |
| |
| |
| /* BSC specific CTRL helper functions */ |
| function f_ctrl_get_bts(IPA_CTRL_PT pt, integer bts_nr, charstring suffix) return CtrlValue { |
| return f_ctrl_get(pt, "bts." & int2str(bts_nr) & "." & suffix); |
| } |
| function f_ctrl_set_bts(IPA_CTRL_PT pt, integer bts_nr, charstring suffix, CtrlValue val) { |
| f_ctrl_set(pt, "bts." & int2str(bts_nr) & "." & suffix, val); |
| } |
| |
| template charstring ts_bts(integer bts_nr) := "bts." & int2str(bts_nr) & "."; |
| template charstring ts_bts_trx(integer bts_nr, integer trx_nr ) := |
| valueof(ts_bts(bts_nr)) & "trx." & int2str(trx_nr) & "."; |
| |
| function f_ctrl_get_exp_bts(IPA_CTRL_PT pt, integer bts_nr, CtrlVariable suffix, template CtrlValue exp) { |
| f_ctrl_get_exp(pt, valueof(ts_bts(bts_nr)) & suffix, exp); |
| } |
| |
| function f_ctrl_get_exp_trx(IPA_CTRL_PT pt, integer bts_nr, integer trx_nr, CtrlVariable suffix, |
| template CtrlValue exp) |
| { |
| f_ctrl_get_exp(pt, valueof(ts_bts_trx(bts_nr, trx_nr)) & suffix, exp); |
| } |
| |
| |
| } |