blob: 3d749253a0b1790fda3b790f6c399b8141b9789f [file] [log] [blame]
Harald Weltef6bd9802017-12-12 14:56:02 +01001module Selftest {
2
3import from General_Types all;
4import from Osmocom_Types all;
5import from GSM_Types all;
6import from IPL4asp_Types all;
7import from IPL4asp_PortType all;
Harald Weltef6bd9802017-12-12 14:56:02 +01008
9import from BSSAP_Types all;
10//import from BSSAP_Adapter all;
11import from BSSAP_CodecPort all;
12import from BSSMAP_Templates all;
13import from IPA_Emulation all;
14import from IPA_Types all;
15import from RSL_Types all;
16
17import from Osmocom_CTRL_Functions all;
18import from Osmocom_CTRL_Types all;
19
20import from MobileL3_CommonIE_Types all;
21import from L3_Templates all;
22import from GSM_RR_Types all;
23
24
25type component IPA_selftest_CT {
26 /* upper end of IPA_Emulation */
Harald Weltef6bd9802017-12-12 14:56:02 +010027 port IPA_RSL_PT IPA_RSL;
28 port IPA_CTRL_PT IPA_CTRL;
29 port IPA_SP_PT IPA_SP;
30
31 var IPA_Emulation_CT vc_IPA;
32
33 /* raw IP port */
34 port IPL4asp_PT IP;
35 var ConnectionId g_ip_conn_id := -1;
36}
37
38
39function f_ipa_srv_init() runs on IPA_selftest_CT {
40 vc_IPA := IPA_Emulation_CT.create("IPA_Emulation");
41 map(vc_IPA:IPA_PORT, system: IPA_CODEC_PT);
Harald Weltef6bd9802017-12-12 14:56:02 +010042 connect(vc_IPA:IPA_RSL_PORT, self:IPA_RSL);
43 connect(vc_IPA:IPA_CTRL_PORT, self:IPA_CTRL);
Harald Weltef6bd9802017-12-12 14:56:02 +010044 vc_IPA.start(IPA_Emulation.main_server("127.0.0.1", 55555));
45}
46
47function f_ipa_wait_up() runs on IPA_selftest_CT {
48 interleave {
Vadim Yanitskiy61564be2020-05-18 20:44:14 +070049 [] IPA_RSL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP));
50 [] IPA_CTRL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP));
Harald Weltef6bd9802017-12-12 14:56:02 +010051 }
52}
53
54function f_tcp_client_init() runs on IPA_selftest_CT {
55 var Result res;
56 map(self:IP, system:IP);
57 res := IPL4asp_PortType.f_IPL4_connect(IP, "127.0.0.1", 55555, "", -1,-1, {tcp:={}});
Harald Welte9220f632018-05-23 20:27:02 +020058 if (not ispresent(res.connId)) {
59 setverdict(fail, "Could not connect to TCP port, check your configuration");
Daniel Willmannafce8662018-07-06 23:11:32 +020060 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +020061 }
Harald Weltef6bd9802017-12-12 14:56:02 +010062 g_ip_conn_id := res.connId;
63}
64
65
66template ASP_Send ts_ASP_Send(ConnectionId id, template octetstring tx) := {
67 connId := id,
68 proto := omit,
69 msg := tx
70}
71
72testcase TC_ipa_fragment() runs on IPA_selftest_CT {
73 var integer i;
74 var octetstring tx_buf;
75 var RSL_Message rsl;
76
77 f_ipa_srv_init();
78 f_tcp_client_init();
79 f_ipa_wait_up();
80
81 rsl := valueof(ts_RSL_CHAN_RQD('23'O, 2342));
82 tx_buf := enc_PDU_IPA(valueof(ts_PDU_IPA(IPAC_PROTO_RSL_TRX0, enc_RSL_Message(rsl))));
83 /* send in rapid sequence to fill multiple messages in one TCP segment */
84 for (i := 0; i < 10; i := i+1) {
85 IP.send(ts_ASP_Send(g_ip_conn_id, tx_buf));
86 }
87 timer T:= 1.0;
88 T.start;
89 T.timeout;
90
91 for (i := 0; i < 10; i := i+1) {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +070092 IPA_RSL.receive(tr_ASP_RSL_UD(rsl));
Harald Weltef6bd9802017-12-12 14:56:02 +010093 }
94 setverdict(pass);
95}
96
97
98control {
99 execute( TC_ipa_fragment() );
100}
101
102
103}