Neels Hofmeyr | 5c5b276 | 2020-10-01 06:35:56 +0200 | [diff] [blame] | 1 | module BSC_ConnectionHandler { |
| 2 | |
| 3 | /* BSC Connection Handler of SMLC Tests in TTCN-3 |
| 4 | * (C) 2020 sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | */ |
| 12 | |
| 13 | import from Misc_Helpers all; |
| 14 | import from General_Types all; |
| 15 | import from Osmocom_Types all; |
| 16 | import from SCCPasp_Types all; |
| 17 | import from BSSAP_Types all; |
| 18 | import from BSSAP_CodecPort all; |
| 19 | import from RAN_Emulation all; |
| 20 | import from BSSMAP_Templates all; |
| 21 | import from BSSAP_LE_Emulation all; |
| 22 | import from BSSAP_LE_Types all; |
| 23 | import from BSSMAP_LE_Templates all; |
| 24 | |
| 25 | import from TELNETasp_PortType all; |
| 26 | import from Osmocom_VTY_Functions all; |
| 27 | |
| 28 | /* this component represents a single subscriber connection at the SMLC. */ |
| 29 | type component BSC_ConnHdlr extends BSSAP_LE_ConnHdlr { |
| 30 | /* SCCP Connecction Identifier for the underlying SCCP connection */ |
| 31 | var integer g_sccp_conn_id; |
| 32 | |
| 33 | port TELNETasp_PT SMLCVTY; |
| 34 | |
| 35 | var TestHdlrParams g_pars; |
| 36 | |
| 37 | var charstring host_bsc := "127.0.0.4"; |
| 38 | |
| 39 | var boolean g_vty_initialized := false; |
| 40 | } |
| 41 | |
| 42 | function f_BscConnHdlr_init_vty() runs on BSC_ConnHdlr { |
| 43 | if (not g_vty_initialized) { |
| 44 | map(self:SMLCVTY, system:SMLCVTY); |
| 45 | f_vty_set_prompts(SMLCVTY); |
| 46 | f_vty_transceive(SMLCVTY, "enable"); |
| 47 | g_vty_initialized := true; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /* initialize all parameters */ |
| 52 | function f_BscConnHdlr_init() runs on BSC_ConnHdlr { |
| 53 | f_BscConnHdlr_init_vty(); |
| 54 | } |
| 55 | |
| 56 | /* Callback function from general BSSAP_LE_Emulation whenever a connectionless |
| 57 | * BSSAP_LE message arrives. Can return a PDU_BSSAP_LE that should be sent in return */ |
| 58 | private function BSSAP_LE_UnitdataCallback(PDU_BSSAP_LE bssap) |
| 59 | runs on BSSAP_LE_Emulation_CT return template PDU_BSSAP_LE { |
| 60 | var template PDU_BSSAP_LE resp := omit; |
| 61 | |
| 62 | /* answer all RESET with a RESET ACK */ |
| 63 | if (match(bssap, tr_BSSMAP_LE_Reset)) { |
| 64 | resp := ts_BSSMAP_LE_ResetAck; |
| 65 | } |
| 66 | |
| 67 | return resp; |
| 68 | } |
| 69 | |
| 70 | const BssapLeOps BSC_BssapLeOps := { |
| 71 | create_cb := refers(BSSAP_LE_Emulation.ExpectedCreateCallback), |
| 72 | unitdata_cb := refers(BSSAP_LE_UnitdataCallback), |
| 73 | decode_dtap := false, |
| 74 | role_ms := false, |
| 75 | sccp_addr_local := omit, |
| 76 | sccp_addr_peer := omit |
| 77 | } |
| 78 | type record TestHdlrParams { |
| 79 | hexstring imsi, |
| 80 | integer bssap_le_idx, |
| 81 | SCCP_PAR_Address sccp_addr_bsc optional, |
| 82 | SCCP_PAR_Address sccp_addr_smlc optional |
| 83 | }; |
| 84 | |
| 85 | /* Note: Do not use valueof() to get a value of this template, use |
| 86 | * f_gen_test_hdlr_pars() instead in order to get a configuration that is |
| 87 | * matched to the current test situation (aoip vs. sccplite) */ |
| 88 | template (value) TestHdlrParams t_def_TestHdlrPars := { |
| 89 | imsi := '001019876543210'H, |
| 90 | bssap_le_idx := 0, |
| 91 | sccp_addr_bsc := omit, |
| 92 | sccp_addr_smlc := omit |
| 93 | } |
| 94 | |
| 95 | } |