blob: 071e3e8a1ea9fc3a33e41eda3d03b240ef70e0a2 [file] [log] [blame]
Pau Espin Pedrolb54acca2021-11-22 20:35:44 +01001module HNBGW_ConnectionHandler {
2
3/* HNBGW Connection Handler of HNB_Tests in TTCN-3
4 * (C) 2021 by sysmocom - s.m.f.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
13import from Misc_Helpers all;
14import from General_Types all;
15import from Osmocom_Types all;
16import from IPL4asp_Types all;
17import from Native_Functions all;
18
19import from SDP_Types all;
20
21import from StatsD_Checker all;
22
23import from TELNETasp_PortType all;
24import from Osmocom_VTY_Functions all;
25
26import from HNBAP_Templates all;
27
28import from Iuh_Emulation all;
29
30/* this component represents a single Iuh connection at the HNBGW. */
31type component HNBGW_ConnHdlr extends StatsD_ConnHdlr {
32 port TELNETasp_PT HNBVTY;
33 port HNBAP_PT HNBAP;
34 port RUA_PT RUA;
35 var TestHdlrParams g_pars;
36
37 var boolean g_vty_initialized := false;
38}
39
40function f_HNBGW_ConnHdlr_init_vty() runs on HNBGW_ConnHdlr {
41 if (not g_vty_initialized) {
42 map(self:HNBVTY, system:HNBVTY);
43 f_vty_set_prompts(HNBVTY);
44 f_vty_transceive(HNBVTY, "enable");
45 g_vty_initialized := true;
46 }
47}
48
49/* initialize all parameters */
50function f_HNBGW_ConnHdlr_init(TestHdlrParams pars) runs on HNBGW_ConnHdlr {
51 var integer i := 0;
52 var Iuh_Emulation_CT vc_Iuh;
53
54 g_pars := valueof(pars);
55 vc_Iuh := Iuh_Emulation_CT.create("HNBGW" & int2str(i));
56 connect(self:HNBAP, vc_Iuh:HNBAP);
57 connect(self:RUA, vc_Iuh:RUA);
58
59 var Iuh_conn_parameters iuh_pars;
60 iuh_pars.remote_ip := g_pars.hnodeb_addr;
61 iuh_pars.remote_sctp_port := -1;
62 iuh_pars.local_ip := g_pars.hnbgw_addr;
63 iuh_pars.local_sctp_port := g_pars.hnbgw_port;
64 vc_Iuh.start(Iuh_Emulation.main(iuh_pars, "Iuh" & int2str(i)));
65
66 f_HNBGW_ConnHdlr_init_vty();
67}
68
69type record TestHdlrParams {
70 charstring hnbgw_addr,
71 charstring hnodeb_addr,
72 integer hnbgw_port,
73 uint16_t rnc_id,
74 charstring hNB_Identity_Info,
75 OCT3 plmnid,
76 uint32_t cell_identity,
77 uint16_t lac,
78 uint8_t rac,
79 uint8_t sac
80};
81
82/* Note: Do not use valueof() to get a value of this template, use
83 * f_gen_test_hdlr_pars() instead in order to get a configuration. */
84template (value) TestHdlrParams t_def_TestHdlrPars := {
85 hnbgw_addr := "127.0.0.1",
86 hnodeb_addr := "127.0.0.1",
87 hnbgw_port := 29169,
88 rnc_id := 23,
89 hNB_Identity_Info := "OsmoHNodeB",
90 plmnid := '00F110'O,
91 cell_identity := 1,
92 lac := 2,
93 rac := 3,
94 sac := 4
95}
96
97
98function f_handle_hnbap_hnb_register_req()
99runs on HNBGW_ConnHdlr {
100 HNBAP.receive(tr_HNBAP_HNBRegisterRequest(char2oct(g_pars.hNB_Identity_Info),
101 g_pars.plmnid,
102 int2bit(g_pars.cell_identity, 28),
103 int2oct(g_pars.lac, 2),
104 int2oct(g_pars.rac, 1),
105 int2oct(g_pars.sac, 2)
106 ));
107 HNBAP.send(ts_HNBAP_HNBRegisterAccept(g_pars.rnc_id));
108}
109
110
111
112}