Harald Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 1 | module Selftest { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | import from GSM_Types all; |
| 6 | import from IPL4asp_Types all; |
| 7 | import from IPL4asp_PortType all; |
Harald Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 8 | |
| 9 | import from BSSAP_Types all; |
| 10 | //import from BSSAP_Adapter all; |
| 11 | import from BSSAP_CodecPort all; |
| 12 | import from BSSMAP_Templates all; |
| 13 | import from IPA_Emulation all; |
| 14 | import from IPA_Types all; |
| 15 | import from RSL_Types all; |
| 16 | |
| 17 | import from Osmocom_CTRL_Functions all; |
| 18 | import from Osmocom_CTRL_Types all; |
| 19 | |
| 20 | import from MobileL3_CommonIE_Types all; |
| 21 | import from L3_Templates all; |
| 22 | import from GSM_RR_Types all; |
| 23 | |
| 24 | |
| 25 | type component IPA_selftest_CT { |
| 26 | /* upper end of IPA_Emulation */ |
Harald Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 27 | 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 | |
| 39 | function 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 Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 42 | connect(vc_IPA:IPA_RSL_PORT, self:IPA_RSL); |
| 43 | connect(vc_IPA:IPA_CTRL_PORT, self:IPA_CTRL); |
Harald Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 44 | vc_IPA.start(IPA_Emulation.main_server("127.0.0.1", 55555)); |
| 45 | } |
| 46 | |
| 47 | function f_ipa_wait_up() runs on IPA_selftest_CT { |
| 48 | interleave { |
Vadim Yanitskiy | 61564be | 2020-05-18 20:44:14 +0700 | [diff] [blame] | 49 | [] IPA_RSL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)); |
| 50 | [] IPA_CTRL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)); |
Harald Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | |
| 54 | function 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 Welte | 9220f63 | 2018-05-23 20:27:02 +0200 | [diff] [blame] | 58 | if (not ispresent(res.connId)) { |
| 59 | setverdict(fail, "Could not connect to TCP port, check your configuration"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 60 | mtc.stop; |
Harald Welte | 9220f63 | 2018-05-23 20:27:02 +0200 | [diff] [blame] | 61 | } |
Harald Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 62 | g_ip_conn_id := res.connId; |
| 63 | } |
| 64 | |
| 65 | |
| 66 | template ASP_Send ts_ASP_Send(ConnectionId id, template octetstring tx) := { |
| 67 | connId := id, |
| 68 | proto := omit, |
| 69 | msg := tx |
| 70 | } |
| 71 | |
| 72 | testcase 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 Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 92 | IPA_RSL.receive(tr_ASP_RSL_UD(rsl)); |
Harald Welte | f6bd980 | 2017-12-12 14:56:02 +0100 | [diff] [blame] | 93 | } |
| 94 | setverdict(pass); |
| 95 | } |
| 96 | |
| 97 | |
| 98 | control { |
| 99 | execute( TC_ipa_fragment() ); |
| 100 | } |
| 101 | |
| 102 | |
| 103 | } |