blob: f2e69672218f32727091db75e569d50f567086ca [file] [log] [blame]
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +02001module 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
14import from BSSGP_Types all;
15import from BSSGP_Emulation all;
16import from NS_Types all;
17import from NS_Emulation all;
18import from GPRS_Context all;
19
20modulepar {
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 := {
Alexander Couzens1e5dc482020-07-28 15:38:46 +020038 remote_proto := PCUIF_ADDR_TYPE_IPV4,
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +020039 local_udp_port := 23000,
40 local_ip := "127.0.0.1",
41 remote_udp_port := 21000,
42 remote_ip := "127.0.0.1",
43 nsvci := 0,
44 nsei := 2342,
45 role_sgsn := true,
46 handle_sns := true
47 };
48}
49
50/* FIXME: merge this into BSSGP_Client_CT ? */
51type component bssgp_CT extends BSSGP_Client_CT {
52 var NS_CT ns_component;
53 var BSSGP_CT bssgp_component;
54 var boolean g_initialized := false;
55}
56
57/* FIXME: merge this into BSSGP_Client_CT ? */
58function f_init_bssgp() runs on bssgp_CT {
59 var MmContext mmctx := {
60 imsi := '262420000000001'H,
61 tlli := 'FFFFFFFF'O,
62 n_u := 0
63 };
64
65
66 if (g_initialized == true) {
67 return;
68 }
69 g_initialized := true;
70
71 /* create a new NS component */
72 ns_component := NS_CT.create;
73 bssgp_component := BSSGP_CT.create;
74 /* connect our BSSGP port to the BSSGP Emulation */
75 connect(self:BSSGP[0], bssgp_component:BSSGP_SP);
76 connect(self:BSSGP_SIG[0], bssgp_component:BSSGP_SP_SIG);
77 connect(self:BSSGP_PROC[0], bssgp_component:BSSGP_PROC);
78 /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/
79 connect(bssgp_component:BSCP, ns_component:NS_SP);
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +020080 ns_component.start(NSStart(mp_nsconfig));
81 bssgp_component.start(BssgpStart(mp_gb_cfg));
82
83 f_bssgp_client_register(mmctx.imsi, mmctx.tlli, mp_gb_cfg.cell_id);
84}
85
86/* Establish BSSGP connection to PCU */
87function f_bssgp_establish() runs on BSSGP_Client_CT {
88 timer T:= 10.0;
89
90 T.start
91 alt {
92 [] BSSGP[0].receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { }
93 [] BSSGP[0].receive { repeat; }
94 [] T.timeout {
95 setverdict(fail, "Timeout establishing BSSGP connection");
96 mtc.stop;
97 }
98 }
99 T.stop
100 log("BSSGP successfully initialized");
101}
102
103}