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