blob: 30476c551680514615028de05438e2c3f21653f2 [file] [log] [blame]
Ivan Kluchnikov487a1412011-12-21 13:17:53 +03001/* RLCMACTest.cpp
2 *
3 * Copyright (C) 2011 Ivan Klyuchnikov
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Ivan Kluchnikov487a1412011-12-21 13:17:53 +030014 */
15
16
17
18//#include <BitVector.h>
19#include <iostream>
20#include <cstdlib>
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +040021#include <cstring>
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +010022#include <assert.h>
Max7426c5f2019-02-18 20:42:42 +010023#include "gprs_rlcmac.h"
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +010024#include "decoding.h"
Max7426c5f2019-02-18 20:42:42 +010025
Andreas Eversberg138f4e62013-01-14 12:31:11 +010026extern "C" {
Andreas Eversberg138f4e62013-01-14 12:31:11 +010027#include "pcu_vty.h"
28#include <osmocom/vty/telnet_interface.h>
29#include <osmocom/vty/logging.h>
Aravind Sirsikar9f5f0082016-08-30 13:20:23 +053030#include <osmocom/core/utils.h>
Maxd3a0d912019-03-05 16:15:01 +010031#include <osmocom/core/msgb.h>
Andreas Eversberg138f4e62013-01-14 12:31:11 +010032#include <osmocom/core/application.h>
Vadim Yanitskiy39a65052020-01-25 01:24:59 +070033
34#include "csn1.h"
Pau Espin Pedrolb2653fe2020-03-26 15:14:01 +010035#include "gsm_rlcmac.h"
Andreas Eversberg138f4e62013-01-14 12:31:11 +010036}
Ivan Kluchnikov487a1412011-12-21 13:17:53 +030037using namespace std;
38
Pau Espin Pedrol1e979512021-03-09 15:46:35 +010039#include "gprs_debug.h"
40
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +010041void *tall_pcu_ctx;
42
Ivan Kluchnikov487a1412011-12-21 13:17:53 +030043void printSizeofRLCMAC()
44{
Pau Espin Pedrol54681c32020-01-23 21:59:23 +010045 printf("*** %s ***\n", __func__);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +030046 cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl;
47 cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl;
48 cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl;
49 cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl;
50 cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl;
51 cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl;
52 cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl;
53 cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl;
54 cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl;
55 cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl;
56 cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl;
57 cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl;
58 cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl;
59 cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl;
60 cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl;
61
62 cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl;
63 cout << "sizeof Packet_Access_Reject_t " << sizeof(Packet_Access_Reject_t) << endl;
Holger Hans Peter Freythere13298d2013-07-28 16:45:54 +020064 cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl;
65 cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl;
Ivan Kluchnikov487a1412011-12-21 13:17:53 +030066 cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl;
67 cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl;
68 cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl;
69 cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl;
70 cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl;
71 cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl;
72 cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl;
73 cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl;
74 cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl;
75 cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl;
76 cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl;
77 cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl;
78 cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl;
79 cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl;
80 cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl;
81 cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl;
82 cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl;
83 cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl;
84 cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl;
85 cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl;
86 cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl;
87 cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl;
88 cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl;
89}
90
Alexander Couzensccde5c92017-02-04 03:10:08 +010091void testRlcMacDownlink(void *test_ctx)
Ivan Kluchnikov487a1412011-12-21 13:17:53 +030092{
Pau Espin Pedrol54681c32020-01-23 21:59:23 +010093 printf("*** %s ***\n", __func__);
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +010094
95 int rc;
Alexander Couzensccde5c92017-02-04 03:10:08 +010096 struct bitvec *resultVector = bitvec_alloc(23, test_ctx);
Max7426c5f2019-02-18 20:42:42 +010097 bitvec_unhex(resultVector, DUMMY_VEC);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +030098
99 std::string testData[] = {
100 "4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment
Saurabh Sharan656eed52016-03-10 14:15:29 +0530101 "48282407a6a07422720100032b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300102 "47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack
Saurabh Sharanbacb65b2016-03-10 17:24:49 +0530103 "47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment
104 "400820001a3904df0680efb3300b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment (EGPRS)
Saurabh Sharan2b09c392016-03-16 19:17:32 +0530105 "40284f0000001009810c826f4406809dcecb2b2b2b2b2b", // Packet Uplink Assignment (EGPRS)
Pau Espin Pedrol5cb002f2020-01-23 23:45:17 +0100106 "4024030f2f0000000087b0042b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Ack Nack (EGPRS)
Vadim Yanitskiy9b2f7c42020-02-11 21:45:19 +0700107 "4913e00850884013a8048b2b2b2b2b2b2b2b2b2b2b2b2b", // Polling Request (malformed)
Pau Espin Pedrol5cb002f2020-01-23 23:45:17 +0100108 "412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b", // Packet Uplink Ack Nack?
109 "41942b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // System Info 13?
Pau Espin Pedrol259a6942020-11-23 17:57:35 +0100110 "40883c1493120000000012002b2b2b2b2b2b2b2b2b2b2b", // Pkt Paging Request (OS#4838)
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300111 };
112
113 int testDataSize = sizeof(testData)/sizeof(testData[0]);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300114
115 cout << " DOWNLINK " << endl;
116 for (int i = 0; i < testDataSize; i++)
117 {
Pau Espin Pedrol87bfbe42020-01-23 23:51:34 +0100118 cout << "vector1 = " << testData[i] << endl;
Alexander Couzensccde5c92017-02-04 03:10:08 +0100119 bitvec *vector = bitvec_alloc(23, test_ctx);
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +0400120 bitvec_unhex(vector, testData[i].c_str());
Pau Espin Pedrol87bfbe42020-01-23 23:51:34 +0100121
Pau Espin Pedrol99c437b2020-01-24 12:34:50 +0100122 RlcMacDownlink_t data;
123 memset(&data, 0, sizeof(data));
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300124 cout << "=========Start DECODE===========" << endl;
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100125 rc = decode_gsm_rlcmac_downlink(vector, &data);
126 cout << "+++++++++Finish DECODE ("<< rc <<")++++++++++" << endl;
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300127 cout << "=========Start ENCODE=============" << endl;
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100128 rc = encode_gsm_rlcmac_downlink(resultVector, &data);
129 cout << "+++++++++Finish ENCODE ("<< rc <<")+++++++++++" << endl;
Pau Espin Pedrol87bfbe42020-01-23 23:51:34 +0100130 cout << "vector1 = " << osmo_hexdump(vector->data, 23) << endl;
131 cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl;
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +0400132 if (memcmp(vector->data, resultVector->data, 23) == 0)
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300133 cout << "vector1 == vector2 : TRUE" << endl;
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300134 else
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300135 cout << "vector1 == vector2 : FALSE" << endl;
Max7426c5f2019-02-18 20:42:42 +0100136 bitvec_unhex(resultVector, DUMMY_VEC);
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +0400137 bitvec_free(vector);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300138 }
Andreas Eversberg273a2222013-01-16 08:56:33 +0100139
140 bitvec_free(resultVector);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300141}
142
143
Alexander Couzensccde5c92017-02-04 03:10:08 +0100144void testRlcMacUplink(void *test_ctx)
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300145{
Pau Espin Pedrol54681c32020-01-23 21:59:23 +0100146 printf("*** %s ***\n", __func__);
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100147
148 int rc;
Alexander Couzensccde5c92017-02-04 03:10:08 +0100149 struct bitvec *resultVector = bitvec_alloc(23, test_ctx);
Max7426c5f2019-02-18 20:42:42 +0100150 bitvec_unhex(resultVector, DUMMY_VEC);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300151
152 std::string testData[] = {
Saurabh Sharan656eed52016-03-10 14:15:29 +0530153 "400e1e61d11d2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block
154 "400b8020000000000000002480e0032b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack
Saurabh Sharanbacb65b2016-03-10 17:24:49 +0530155 "4016713dc094270ca2ae57ef909006aa0fc0001f80222b", // Packet Resource Request
Vadim Yanitskiyf22163b2020-03-06 06:51:48 +0700156 "401673c87f24af2632b25964200600000091000b780080", // Packet Resource Request (from keith)
Saurabh Sharanbacb65b2016-03-10 17:24:49 +0530157 "40200ffc0021ec010b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // EPDAN
Pau Espin Pedrol5cb002f2020-01-23 23:45:17 +0100158 "400a9020000000000000003010012a0800132b2b2b2b2b", // Packet Downlink Ack/Nack ?
Vadim Yanitskiy809dc8b2021-01-28 20:31:42 +0100159
160 /* Packet Resource Request (see OS#4955, mistakes in 3GPP TS 44.060) */
161 "4117ea1b903eaeb2686564b2330820078000102b2b2b2b",
162 "40167e49f7f8ef2632b2596620060000806d00541c0080",
163 "4017787174d92eba686564b2ccc30800a000040b2b2b2b",
164 "4017e5b2cd5a2eca68655e44aec84880139300412b2b2b",
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300165 };
166
167 int testDataSize = sizeof(testData)/sizeof(testData[0]);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300168
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300169
170 cout << " UPLINK " << endl;
171 for (int i = 0; i < testDataSize; i++)
172 {
Pau Espin Pedrol87bfbe42020-01-23 23:51:34 +0100173 cout << "vector1 = " << testData[i] << endl;
Alexander Couzensccde5c92017-02-04 03:10:08 +0100174 bitvec *vector = bitvec_alloc(23, test_ctx);
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +0400175 bitvec_unhex(vector, testData[i].c_str());
Pau Espin Pedrol87bfbe42020-01-23 23:51:34 +0100176
Pau Espin Pedrol99c437b2020-01-24 12:34:50 +0100177 RlcMacUplink_t data;
178 memset(&data, 0, sizeof(data));
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300179 cout << "=========Start DECODE===========" << endl;
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100180 rc = decode_gsm_rlcmac_uplink(vector, &data);
181 cout << "+++++++++Finish DECODE ("<< rc << ")++++++++++" << endl;
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300182 cout << "=========Start ENCODE=============" << endl;
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100183 rc = encode_gsm_rlcmac_uplink(resultVector, &data);
184 cout << "+++++++++Finish ENCODE ("<< rc <<")+++++++++++" << endl;
Pau Espin Pedrol87bfbe42020-01-23 23:51:34 +0100185 cout << "vector1 = " << osmo_hexdump(vector->data, 23) << endl;
186 cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl;
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +0400187 if (memcmp(vector->data, resultVector->data, 23) == 0)
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300188 cout << "vector1 == vector2 : TRUE" << endl;
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300189 else
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300190 cout << "vector1 == vector2 : FALSE" << endl;
Max7426c5f2019-02-18 20:42:42 +0100191 bitvec_unhex(resultVector, DUMMY_VEC);
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +0400192 bitvec_free(vector);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300193 }
Andreas Eversberg273a2222013-01-16 08:56:33 +0100194
195 bitvec_free(resultVector);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300196}
197
Alexander Couzensccde5c92017-02-04 03:10:08 +0100198void testCsnLeftAlignedVarBmpBounds(void *test_ctx)
Aravind Sirsikar9f5f0082016-08-30 13:20:23 +0530199{
Pau Espin Pedrol54681c32020-01-23 21:59:23 +0100200 printf("*** %s ***\n", __func__);
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100201
Maxd3a0d912019-03-05 16:15:01 +0100202 struct msgb *m = msgb_alloc(80, "test");
203 static uint8_t exp[] = { 0x7f, 0xff, 0xff, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Alexander Couzensccde5c92017-02-04 03:10:08 +0100204 bitvec *vector = bitvec_alloc(23, test_ctx);
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100205 int rc;
Aravind Sirsikar9f5f0082016-08-30 13:20:23 +0530206
207 bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000");
208 RlcMacUplink_t data;
Pau Espin Pedrol99c437b2020-01-24 12:34:50 +0100209 memset(&data, 0, sizeof(data));
Aravind Sirsikar9f5f0082016-08-30 13:20:23 +0530210
211 EGPRS_AckNack_Desc_t *urbb =
212 &data.u.Egprs_Packet_Downlink_Ack_Nack.EGPRS_AckNack.Desc;
Pau Espin Pedrol5e300ce2020-02-03 17:18:03 +0100213 rc = decode_gsm_rlcmac_uplink(vector, &data);
214 OSMO_ASSERT(rc == 0);
Aravind Sirsikar9f5f0082016-08-30 13:20:23 +0530215
Maxd3a0d912019-03-05 16:15:01 +0100216 memcpy(msgb_put(m, 13), urbb->URBB, 13);
217 if (!msgb_eq_data_print(m, exp, 13))
218 printf("%s failed!\n", __func__);
219 msgb_free(m);
Aravind Sirsikar9f5f0082016-08-30 13:20:23 +0530220}
221
Pau Espin Pedrolb2653fe2020-03-26 15:14:01 +0100222extern "C" {
Pau Espin Pedrol007056e2020-03-26 15:03:33 +0100223int encode_gsm_ra_cap(struct bitvec *vector, MS_Radio_Access_capability_t * data);
Pau Espin Pedrolb2653fe2020-03-26 15:14:01 +0100224}
Vadim Yanitskiyb47e53b2020-02-20 04:33:50 +0700225
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100226void testRAcap(void *test_ctx)
227{
Pau Espin Pedrol866bece2020-03-21 01:20:52 +0100228 printf("*** %s ***\n", __func__);
229 MS_Radio_Access_capability_t data;
230 memset(&data, 0, sizeof(data));
231 bitvec *bv_dec = bitvec_alloc(23, test_ctx);
232 bitvec *bv_enc = bitvec_alloc(23, test_ctx);
233 unsigned int len_dec, len_enc;
234 int rc;
235/*
236MS RA capability 1
237 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1)
238 .... 0011 011. .... = Length in bits: 0x1b (27)
239 ...0 01.. RF Power Capability, GMSK Power Class: Not specified (1)
240 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
241 .... ...1 = Controlled early Classmark Sending: Implemented
242 0... .... = Pseudo Synchronisation: Not Present
243 .0.. .... = Voice Group Call Service: no VGCS capability or no notifications wanted
244 ..0. .... = Voice Broadcast Service: no VBS capability or no notifications wanted
245 ...1 .... = Multislot capability struct: Present
246 HSCSD multislot class: Bits are not available (0)
247 SMS_VALUE (Switch-Measure-Switch): Bits are not available (0)
248 ECSD multislot class: Bits are not available (0)
249 DTM GPRS Multi Slot Class: Bits are not available (0)
250 .... ..00 011. .... = GPRS multislot class: Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:3 Tta:3 Ttb:2 Tra:3 Trb:1 Type:1 (3)
251 ...0 .... = GPRS Extended Dynamic Allocation Capability: Not Implemented
252 .... ...0 0011 .... = EGPRS multislot class: Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:3 Tta:3 Ttb:2 Tra:3 Trb:1 Type:1 (3)
253 .... 0... = EGPRS Extended Dynamic Allocation Capability: Not Implemented
254*/
255 bitvec_unhex(bv_dec, "1365146230");
256
257 printf("=== Test decoding of MS RA Capability ===\n");
258 rc = decode_gsm_ra_cap(bv_dec, &data);
259 OSMO_ASSERT(rc == 0);
260
261 /* Make sure there's 1 value (currently fails due to failed decoding) */
262 OSMO_ASSERT(data.Count_MS_RA_capability_value == 1);
263
264 /* Make sure GPRS / EGPRS multislot class is parsed correctly */
Pau Espin Pedrol8a35e642021-01-18 17:14:14 +0100265 printf("GPRS multislot class = %u\n", get_ms_class_by_capability(&data));
266 printf("EGPRS multislot class = %u\n", get_egprs_ms_class_by_capability(&data));
Pau Espin Pedrol866bece2020-03-21 01:20:52 +0100267
268 /* Test encoding of decoded MS RA Capability */
269 printf("=== Test encoding of MS RA Capability ===\n");
270 rc = encode_gsm_ra_cap(bv_enc, &data);
271 printf("encode_gsm_ra_cap() returns %d\n", rc);
272
273 bv_dec->cur_bit = 4;
274 len_dec = bitvec_get_uint(bv_dec, 7);
275 bv_enc->cur_bit = 4;
276 len_enc = bitvec_get_uint(bv_enc, 7);
277
278 /* NOTE: vector2 is expected to be different because there is actually no
279 * way to distinguish between NULL and 0 in MS_Radio_Access_capability_t.
280 * The difference is in length indicator: 27 bits vs 65 bits. */
281 printf("vector1 (len_ind=%u) = %s\n", len_dec, osmo_hexdump(bv_dec->data, bv_dec->data_len));
282 printf("vector2 (len_ind=%u) = %s\n", len_enc, osmo_hexdump(bv_enc->data, bv_enc->data_len));
283
284 /* Mangle the length indicator (set it to 21) */
285 unsigned int writeIndex = 4;
286 rc = bitvec_write_field(bv_dec, &writeIndex, 21, 7);
287 OSMO_ASSERT(rc == 0);
288
289 /* Make sure decoding attempt fails */
290 printf("=== Test decoding of a malformed vector (short length indicator) ===\n");
291 rc = decode_gsm_ra_cap(bv_dec, &data);
292 printf("decode_gsm_ra_cap() returns %d\n", rc);
293}
294
295void testMalformedRAcap(void *test_ctx)
296{
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100297 printf("*** %s ***\n", __func__);
298 MS_Radio_Access_capability_t data;
299 memset(&data, 0, sizeof(data));
Vadim Yanitskiyb47e53b2020-02-20 04:33:50 +0700300 bitvec *bv_dec = bitvec_alloc(23, test_ctx);
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100301 int rc;
302/*
303 MS RA capability 1
304 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1)
Vadim Yanitskiy55f06c32020-02-18 05:45:15 +0700305 .... 0011 101. .... = Length in bits: 0x1d (29)
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100306 ...0 01.. RF Power Capability, GMSK Power Class: Not specified (1)
307 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
308 .... ...1 = Controlled early Classmark Sending: Implemented
309 0... .... = Pseudo Synchronisation: Not Present
310 .0.. .... = Voice Group Call Service: no VGCS capability or no notifications wanted
311 ..0. .... = Voice Broadcast Service: no VBS capability or no notifications wanted
312 ...1 .... = Multislot capability struct: Present
313 .... ..00 011. .... = GPRS multislot class: Max Rx-Slot/TDMA:2 Max Tx-Slot/TDMA:2 Max-Sum-Slot/TDMA:3 Tta:3 Ttb:2 Tra:3 Trb:1 Type:1 (3)
314 ...0 .... = GPRS Extended Dynamic Allocation Capability: Not Implemented
Pau Espin Pedrol866bece2020-03-21 01:20:52 +0100315
316 It doesn't show up in wireshark's tree above because specific parser is
317 used, but this RA Cap bitstream has Exist_EGPRS_multislot_class = 1 but
318 it provides no struct with the expected data (malformed, generated
319 erroneusly through TTCN3). The CSN.1 dceoder should ideally return an
320 error here, but it doesn't (it returns a >0 value which we convert to 0
321 in decode_gsm_ra_cap()).
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100322*/
Vadim Yanitskiyb47e53b2020-02-20 04:33:50 +0700323 bitvec_unhex(bv_dec, "13a5146200");
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100324
Vadim Yanitskiyb47e53b2020-02-20 04:33:50 +0700325 printf("=== Test decoding of MS RA Capability ===\n");
326 rc = decode_gsm_ra_cap(bv_dec, &data);
Pau Espin Pedrol866bece2020-03-21 01:20:52 +0100327 printf("decode_gsm_ra_cap() returns %d\n", rc);
Vadim Yanitskiy55f06c32020-02-18 05:45:15 +0700328 OSMO_ASSERT(rc == 0);
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100329
Pau Espin Pedrol866bece2020-03-21 01:20:52 +0100330 /* For sake of completeness, check if the decoder could find 1 value
331 before failing to decode it */
Vadim Yanitskiy55f06c32020-02-18 05:45:15 +0700332 OSMO_ASSERT(data.Count_MS_RA_capability_value == 1);
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100333
Pau Espin Pedrol2f169242020-03-20 23:59:44 +0100334 bitvec_free(bv_dec);
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100335}
336
Pau Espin Pedrolefad80b2020-03-23 14:35:26 +0100337/* Reproduce crash from ticket OS#4463 */
338void testRAcap2(void *test_ctx)
339{
340 printf("*** %s ***\n", __func__);
341 MS_Radio_Access_capability_t data;
342 memset(&data, 0, sizeof(data));
343 bitvec *bv_dec = bitvec_alloc(23, test_ctx);
344 int rc;
345/*
346MS Radio Access Capability
347 Element ID: 0x13
348 1... .... = ext: 1
349 Length: 23
350 ------------------------------------------- Hex bitstream starts here:
351 MS RA capability 1
352 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1)
353 .... 1001 001. .... = Length in bits: 0x49 (73)
354 ...1 00.. RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4)
355 A5 Bits: A5 bits follow (1)
356 A5/1: encryption algorithm available (1)
357 A5/2: encryption algorithm not available (0)
358 A5/3: encryption algorithm available (1)
359 A5/4: encryption algorithm not available (0)
360 A5/5: encryption algorithm not available (0)
361 A5/6: encryption algorithm not available (0)
362 A5/7: encryption algorithm not available (0)
363 .... ..1. = Controlled early Classmark Sending: Implemented
364 .... ...1 = Pseudo Synchronisation: Present
365 0... .... = Voice Group Call Service: no VGCS capability or no notifications wanted
366 .0.. .... = Voice Broadcast Service: no VBS capability or no notifications wanted
367 ..1. .... = Multislot capability struct: Present
368 HSCSD multislot class: Bits are not available (0)
369 .... 0111 = SMS_VALUE (Switch-Measure-Switch): 8/4 timeslot (~1154 microseconds) (7)
370 0001 .... = (SM_VALUE) Switch-Measure: 2/4 timeslot (~288 microseconds) (1)
371 ECSD multislot class: Bits are not available (0)
372 .... ...0 = Single Slot DTM: Not supported
373 1... .... = DTM EGPRS Multi Slot Class: Present
374 .... .011 00.. .... = GPRS multislot class: Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1 (12)
375 ..1. .... = GPRS Extended Dynamic Allocation Capability: Implemented
376 .... ..01 100. .... = EGPRS multislot class: Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1 (12)
377 ...1 .... = EGPRS Extended Dynamic Allocation Capability: Implemented
378 .... .11. = DTM GPRS Multi Slot Class: Multislot class 11 supported (3)
379 .11. .... = DTM EGPRS Multi Slot Class: Multislot class 11 supported (3)
380 ...1 .... = 8PSK Power Capability Bits: Present
381 8PSK Power Capability: Power class E2 (2)
382 .... ..0. = COMPACT Interference Measurement Capability: Not Implemented
383 .... ...1 = Revision Level Indicator: The ME is Release '99 onwards
384 0... .... = UMTS FDD Radio Access Technology Capability: Not supported
385 .0.. .... = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
386 ..0. .... = CDMA 2000 Radio Access Technology Capability: Not supported
387 ...0 .... = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
388 .... 1... = GERAN Feature Package 1: Supported
389 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
390 .... ..0. = Modulation based multislot class support: Not supported
391 High Multislot Capability: Bits are not available (0)
392 0... .... = GERAN Iu mode: Not supported
393 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 3 (3)
394 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 3 (3)
395 .... .0.. = Multiple TBF Capability: Not supported
396 .... ..01 = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1)
397 1... .... = Extended RLC/MAC Control Message Segmentation Capability: Supported
398 .1.. .... = DTM Enhancements Capability: The mobile station supports enhanced DTM CS establishment and enhanced DTM CS release procedures
399 ...0 .... = PS Handover Capability: Not supported
400 MS RA capability 2
401 .... .011 1... .... = Access Technology Type: GSM 850 (7)
402 .010 0010 = Length in bits: 0x22 (34)
403 100. .... RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4)
404 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
405 .... 1... = Controlled early Classmark Sending: Implemented
406 .... .1.. = Pseudo Synchronisation: Present
407 .... ..0. = Voice Group Call Service: no VGCS capability or no notifications wanted
408 .... ...0 = Voice Broadcast Service: no VBS capability or no notifications wanted
409 0... .... = Multislot capability struct: Not Present
410 .1.. .... = 8PSK Power Capability Bits: Present
411 8PSK Power Capability: Power class E2 (2)
412 .... 0... = COMPACT Interference Measurement Capability: Not Implemented
413 .... .1.. = Revision Level Indicator: The ME is Release '99 onwards
414 .... ..0. = UMTS FDD Radio Access Technology Capability: Not supported
415 .... ...0 = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
416 0... .... = CDMA 2000 Radio Access Technology Capability: Not supported
417 .0.. .... = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
418 ..1. .... = GERAN Feature Package 1: Supported
419 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
420 .... 0... = Modulation based multislot class support: Not supported
421 High Multislot Capability: Bits are not available (0)
422 .... ..0. = GERAN Iu mode: Not supported
423 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 3 (3)
424 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 3 (3)
425 ...0 .... = Multiple TBF Capability: Not supported
426 .... 01.. = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1)
427 .... ..1. = Extended RLC/MAC Control Message Segmentation Capability: Supported
428 .... ...1 = DTM Enhancements Capability: The mobile station supports enhanced DTM CS establishment and enhanced DTM CS release procedures
429 .0.. .... = PS Handover Capability: Not supported
430 MS RA capability 3
431 ...0 011. = Access Technology Type: GSM 1800 (3)
432 .... ...0 1000 10.. = Length in bits: 0x22 (34)
433 .... ..00 1... .... RF Power Capability, GMSK Power Class: 1 W (30 dBm) (1)
434 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
435 ..1. .... = Controlled early Classmark Sending: Implemented
436 ...1 .... = Pseudo Synchronisation: Present
437 .... 0... = Voice Group Call Service: no VGCS capability or no notifications wanted
438 .... .0.. = Voice Broadcast Service: no VBS capability or no notifications wanted
439 .... ..0. = Multislot capability struct: Not Present
440 .... ...1 = 8PSK Power Capability Bits: Present
441 8PSK Power Capability: Power class E2 (2)
442 ..0. .... = COMPACT Interference Measurement Capability: Not Implemented
443 ...1 .... = Revision Level Indicator: The ME is Release '99 onwards
444 .... 0... = UMTS FDD Radio Access Technology Capability: Not supported
445 .... .0.. = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
446 .... ..0. = CDMA 2000 Radio Access Technology Capability: Not supported
447 .... ...0 = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
448 1... .... = GERAN Feature Package 1: Supported
449 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
450 ..0. .... = Modulation based multislot class support: Not supported
451 High Multislot Capability: Bits are not available (0)
452 .... 0... = GERAN Iu mode: Not supported
453 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 3 (3)
454 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 3 (3)
455 .0.. .... = Multiple TBF Capability: Not supported
456 ..01 .... = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1)
457 .... 1... = Extended RLC/MAC Control Message Segmentation Capability: Supported
458 .... .1.. = DTM Enhancements Capability: The mobile station supports enhanced DTM CS establishment and enhanced DTM CS release procedures
459 .... ...0 = PS Handover Capability: Not supported
460*/
461 bitvec_unhex(bv_dec, "1933432b37159ef90879cba28c6421e72688b190879c00");
462
463 printf("=== Test decoding of multi-band MS RA Capability ===\n");
464 rc = decode_gsm_ra_cap(bv_dec, &data);
Pau Espin Pedrol7faa5da2020-03-21 00:13:33 +0100465 printf("decode_gsm_ra_cap() returns %d\n", rc);
466 OSMO_ASSERT(rc == 0);
467
468 /* Make sure there's 3 values */
Pau Espin Pedrolefad80b2020-03-23 14:35:26 +0100469 OSMO_ASSERT(data.Count_MS_RA_capability_value == 3);
470
471 /* Make sure GPRS / EGPRS multislot class is parsed correctly */
Pau Espin Pedrol8a35e642021-01-18 17:14:14 +0100472 printf("GPRS multislot class = %u\n", get_ms_class_by_capability(&data));
473 printf("EGPRS multislot class = %u\n", get_egprs_ms_class_by_capability(&data));
Pau Espin Pedrol7faa5da2020-03-21 00:13:33 +0100474
Pau Espin Pedrolefad80b2020-03-23 14:35:26 +0100475 bitvec_free(bv_dec);
476}
477
Pau Espin Pedrol2282b502021-10-07 12:19:01 +0200478/* RAcap larger than 23 bytes */
479void testRAcap3(void *test_ctx)
480{
481 printf("*** %s ***\n", __func__);
482 MS_Radio_Access_capability_t data;
483 memset(&data, 0, sizeof(data));
484 bitvec *bv_dec = bitvec_alloc(31, test_ctx);
485 int rc;
486/*
487MS Radio Access Capability
488 Element ID: 0x13
489 1... .... = ext: 1
490 Length: 31
491 ------------------------------------------- Hex bitstream starts here:
492 MS RA capability 1
493 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1)
494 .... 1010 111. .... = Length in bits: 0x57 (87)
495 ...1 00.. RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4)
496 A5 Bits: A5 bits follow (1)
497 A5/1: encryption algorithm available (1)
498 A5/2: encryption algorithm not available (0)
499 A5/3: encryption algorithm available (1)
500 A5/4: encryption algorithm not available (0)
501 A5/5: encryption algorithm not available (0)
502 A5/6: encryption algorithm not available (0)
503 A5/7: encryption algorithm not available (0)
504 .... ..1. = Controlled early Classmark Sending: Implemented
505 .... ...1 = Pseudo Synchronisation: Present
506 0... .... = Voice Group Call Service: no VGCS capability or no notifications wanted
507 .0.. .... = Voice Broadcast Service: no VBS capability or no notifications wanted
508 ..1. .... = Multislot capability struct: Present
509 HSCSD multislot class: Bits are not available (0)
510 SMS_VALUE (Switch-Measure-Switch): Bits are not available (0)
511 ECSD multislot class: Bits are not available (0)
512 DTM GPRS Multi Slot Class: Bits are not available (0)
513 .... .011 00.. .... = GPRS multislot class: Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1 (12)
514 ..1. .... = GPRS Extended Dynamic Allocation Capability: Implemented
515 .... ..01 100. .... = EGPRS multislot class: Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1 (12)
516 ...1 .... = EGPRS Extended Dynamic Allocation Capability: Implemented
517 .... .1.. = 8PSK Power Capability Bits: Present
518 8PSK Power Capability: Power class E2 (2)
519 0... .... = COMPACT Interference Measurement Capability: Not Implemented
520 .1.. .... = Revision Level Indicator: The ME is Release '99 onwards
521 ..0. .... = UMTS FDD Radio Access Technology Capability: Not supported
522 ...0 .... = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
523 .... 0... = CDMA 2000 Radio Access Technology Capability: Not supported
524 .... .0.. = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
525 .... ..1. = GERAN Feature Package 1: Supported
526 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
527 0... .... = Modulation based multislot class support: Not supported
528 High Multislot Capability: 0x00 (0) - This field effect all other multislot fields. To understand the value please read TS 24.008 5.6.0 Release 5 Chap 10.5.5.12 Page 406
529 .... 0... = GERAN Iu mode: Not supported
530 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 0 (0)
531 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 0 (0)
532 .0.. .... = Multiple TBF Capability: Not supported
533 ..01 .... = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1)
534 .... 0... = Extended RLC/MAC Control Message Segmentation Capability: Not supported
535 .... .0.. = DTM Enhancements Capability: The mobile station does not support enhanced DTM CS establishment and enhanced DTM CS release procedures
536 .... ...0 = PS Handover Capability: Not supported
537 0... .... = DTM Handover Capability: Not supported
538 ..0. .... = Flexible Timeslot Assignment: Not supported
539 ...0 .... = GAN PS Handover Capability: Not supported
540 .... 0... = RLC Non-persistent Mode: Not supported
541 .... .0.. = Reduced Latency Capability: Not supported
542 .... ..00 = Uplink EGPRS2: The mobile station does not support either EGPRS2-A or EGPRS2-B in the uplink (0)
543 00.. .... = Downlink EGPRS2: The mobile station does not support either EGPRS2-A or EGPRS2-B in the downlink (0)
544 ..0. .... = E-UTRA FDD support: Not supported
545 ...0 .... = E-UTRA TDD support: Not supported
546 .... 00.. = GERAN to E-UTRA support in GERAN packet transfer mode: None (0)
547 .... ..0. = Priority-based reselection support: Not supported
548 0... .... = Indication of Upper Layer PDU Start Capability for RLC UM: Not supported
549 .0.. .... = Enhanced Multiplexing for Single TBF Capability: Not supported
550 ..0. .... = Multiple TTI Capability: Not supported
551 ...0 .... = Reporting of UTRAN CSG cells in packet transfer mode: Not supported
552 .... 0... = Reporting of E-UTRAN CSG cells in packet transfer mode: Not supported
553 .... .0.. = Dynamic Timeslot Reduction Capability: Not supported
554 .... ..0. = Enhanced Multiplexing for Single RLC Entity Capability: Not supported
555 .... ...0 = Fast Downlink Frequency Switching Capability: Not supported
556 01.. .... = TIGHTER Capability: TIGHTER supported for speech and signalling channels only (1)
557 MS RA capability 2
558 ...0 111. = Access Technology Type: GSM 850 (7)
559 .... ...0 1111 10.. = Length in bits: 0x3e (62)
560 .... ..10 0... .... RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4)
561 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
562 ..1. .... = Controlled early Classmark Sending: Implemented
563 ...1 .... = Pseudo Synchronisation: Present
564 .... 0... = Voice Group Call Service: no VGCS capability or no notifications wanted
565 .... .0.. = Voice Broadcast Service: no VBS capability or no notifications wanted
566 .... ..0. = Multislot capability struct: Not Present
567 .... ...1 = 8PSK Power Capability Bits: Present
568 8PSK Power Capability: Power class E2 (2)
569 ..0. .... = COMPACT Interference Measurement Capability: Not Implemented
570 ...1 .... = Revision Level Indicator: The ME is Release '99 onwards
571 .... 0... = UMTS FDD Radio Access Technology Capability: Not supported
572 .... .0.. = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
573 .... ..0. = CDMA 2000 Radio Access Technology Capability: Not supported
574 .... ...0 = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
575 1... .... = GERAN Feature Package 1: Supported
576 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
577 ..0. .... = Modulation based multislot class support: Not supported
578 High Multislot Capability: 0x00 (0) - This field effect all other multislot fields. To understand the value please read TS 24.008 5.6.0 Release 5 Chap 10.5.5.12 Page 406
579 .... ..0. = GERAN Iu mode: Not supported
580 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 0 (0)
581 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 0 (0)
582 ...0 .... = Multiple TBF Capability: Not supported
583 .... 01.. = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1)
584 .... ..0. = Extended RLC/MAC Control Message Segmentation Capability: Not supported
585 .... ...0 = DTM Enhancements Capability: The mobile station does not support enhanced DTM CS establishment and enhanced DTM CS release procedures
586 .0.. .... = PS Handover Capability: Not supported
587 ..0. .... = DTM Handover Capability: Not supported
588 .... 0... = Flexible Timeslot Assignment: Not supported
589 .... .0.. = GAN PS Handover Capability: Not supported
590 .... ..0. = RLC Non-persistent Mode: Not supported
591 .... ...0 = Reduced Latency Capability: Not supported
592 00.. .... = Uplink EGPRS2: The mobile station does not support either EGPRS2-A or EGPRS2-B in the uplink (0)
593 ..00 .... = Downlink EGPRS2: The mobile station does not support either EGPRS2-A or EGPRS2-B in the downlink (0)
594 .... 0... = E-UTRA FDD support: Not supported
595 .... .0.. = E-UTRA TDD support: Not supported
596 .... ..00 = GERAN to E-UTRA support in GERAN packet transfer mode: None (0)
597 0... .... = Priority-based reselection support: Not supported
598 ..0. .... = Indication of Upper Layer PDU Start Capability for RLC UM: Not supported
599 ...0 .... = Enhanced Multiplexing for Single TBF Capability: Not supported
600 .... 0... = Multiple TTI Capability: Not supported
601 .... .0.. = Reporting of UTRAN CSG cells in packet transfer mode: Not supported
602 .... ..0. = Reporting of E-UTRAN CSG cells in packet transfer mode: Not supported
603 .... ...0 = Dynamic Timeslot Reduction Capability: Not supported
604 0... .... = Enhanced Multiplexing for Single RLC Entity Capability: Not supported
605 .0.. .... = Fast Downlink Frequency Switching Capability: Not supported
606 ..01 .... = TIGHTER Capability: TIGHTER supported for speech and signalling channels only (1)
607 MS RA capability 3
608 .... .010 0... .... = Access Technology Type: GSM 1900 (4)
609 .011 1110 = Length in bits: 0x3e (62)
610 001. .... RF Power Capability, GMSK Power Class: 1 W (30 dBm) (1)
611 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
612 .... 1... = Controlled early Classmark Sending: Implemented
613 .... .1.. = Pseudo Synchronisation: Present
614 .... ..0. = Voice Group Call Service: no VGCS capability or no notifications wanted
615 .... ...0 = Voice Broadcast Service: no VBS capability or no notifications wanted
616 0... .... = Multislot capability struct: Not Present
617 .1.. .... = 8PSK Power Capability Bits: Present
618 8PSK Power Capability: Power class E2 (2)
619 .... 0... = COMPACT Interference Measurement Capability: Not Implemented
620 .... .1.. = Revision Level Indicator: The ME is Release '99 onwards
621 .... ..0. = UMTS FDD Radio Access Technology Capability: Not supported
622 .... ...0 = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
623 0... .... = CDMA 2000 Radio Access Technology Capability: Not supported
624 .0.. .... = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
625 ..1. .... = GERAN Feature Package 1: Supported
626 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
627 .... 0... = Modulation based multislot class support: Not supported
628 High Multislot Capability: 0x00 (0) - This field effect all other multislot fields. To understand the value please read TS 24.008 5.6.0 Release 5 Chap 10.5.5.12 Page 406
629 0... .... = GERAN Iu mode: Not supported
630 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 0 (0)
631 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 0 (0)
632 .... .0.. = Multiple TBF Capability: Not supported
633 .... ..01 = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1)
634 0... .... = Extended RLC/MAC Control Message Segmentation Capability: Not supported
635 .0.. .... = DTM Enhancements Capability: The mobile station does not support enhanced DTM CS establishment and enhanced DTM CS release procedures
636 ...0 .... = PS Handover Capability: Not supported
637 .... 0... = DTM Handover Capability: Not supported
638 .... ..0. = Flexible Timeslot Assignment: Not supported
639 .... ...0 = GAN PS Handover Capability: Not supported
640 0... .... = RLC Non-persistent Mode: Not supported
641 .0.. .... = Reduced Latency Capability: Not supported
642 ..00 .... = Uplink EGPRS2: The mobile station does not support either EGPRS2-A or EGPRS2-B in the uplink (0)
643 .... 00.. = Downlink EGPRS2: The mobile station does not support either EGPRS2-A or EGPRS2-B in the downlink (0)
644 .... ..0. = E-UTRA FDD support: Not supported
645 .... ...0 = E-UTRA TDD support: Not supported
646 00.. .... = GERAN to E-UTRA support in GERAN packet transfer mode: None (0)
647 ..0. .... = Priority-based reselection support: Not supported
648 .... 0... = Indication of Upper Layer PDU Start Capability for RLC UM: Not supported
649 .... .0.. = Enhanced Multiplexing for Single TBF Capability: Not supported
650 .... ..0. = Multiple TTI Capability: Not supported
651 .... ...0 = Reporting of UTRAN CSG cells in packet transfer mode: Not supported
652 0... .... = Reporting of E-UTRAN CSG cells in packet transfer mode: Not supported
653 .0.. .... = Dynamic Timeslot Reduction Capability: Not supported
654 ..0. .... = Enhanced Multiplexing for Single RLC Entity Capability: Not supported
655 ...0 .... = Fast Downlink Frequency Switching Capability: Not supported
656 .... 01.. = TIGHTER Capability: TIGHTER supported for speech and signalling channels only (1)
657*/
658 bitvec_unhex(bv_dec, "1af3432b25964240100000006efa319090040000001a3e2c64240100000004");
659
660 printf("=== Test decoding of MS RA Capability 3===\n");
661 rc = decode_gsm_ra_cap(bv_dec, &data);
662 printf("decode_gsm_ra_cap() returns %d\n", rc);
663 OSMO_ASSERT(rc == 0);
664
665 /* Make sure there's 3 values */
666 OSMO_ASSERT(data.Count_MS_RA_capability_value == 3);
667
668 /* Make sure GPRS / EGPRS multislot class is parsed correctly */
669 printf("GPRS multislot class = %u\n", get_ms_class_by_capability(&data));
670 printf("EGPRS multislot class = %u\n", get_egprs_ms_class_by_capability(&data));
671
672 bitvec_free(bv_dec);
673}
674
Pau Espin Pedrol089d7342021-10-07 18:30:30 +0200675/* RAcap larger than 23 bytes */
676void testRAcap4(void *test_ctx)
677{
678 printf("*** %s ***\n", __func__);
679 MS_Radio_Access_capability_t data;
680 memset(&data, 0, sizeof(data));
681 bitvec *bv_dec = bitvec_alloc(22, test_ctx);
682 int rc;
683
684/*
685MS Radio Access Capability
686 Element ID: 0x13
687 1... .... = ext: 1
688 Length: 22
689 ------------------------------------------- Hex bitstream starts here:
690 MS RA capability 1
691 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1)
692 .... 0111 101. .... = Length in bits: 0x3d (61)
693 ...1 00.. RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4)
694 A5 Bits: A5 bits follow (1)
695 A5/1: encryption algorithm available (1)
696 A5/2: encryption algorithm not available (0)
697 A5/3: encryption algorithm available (1)
698 A5/4: encryption algorithm not available (0)
699 A5/5: encryption algorithm not available (0)
700 A5/6: encryption algorithm not available (0)
701 A5/7: encryption algorithm not available (0)
702 .... ..1. = Controlled early Classmark Sending: Implemented
703 .... ...1 = Pseudo Synchronisation: Present
704 0... .... = Voice Group Call Service: no VGCS capability or no notifications wanted
705 .0.. .... = Voice Broadcast Service: no VBS capability or no notifications wanted
706 ..1. .... = Multislot capability struct: Present
707 HSCSD multislot class: Bits are not available (0)
708 SMS_VALUE (Switch-Measure-Switch): Bits are not available (0)
709 ECSD multislot class: Bits are not available (0)
710 DTM GPRS Multi Slot Class: Bits are not available (0)
711 .... .011 00.. .... = GPRS multislot class: Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1 (12)
712 ..1. .... = GPRS Extended Dynamic Allocation Capability: Implemented
713 .... ..01 100. .... = EGPRS multislot class: Max Rx-Slot/TDMA:4 Max Tx-Slot/TDMA:4 Max-Sum-Slot/TDMA:5 Tta:2 Ttb:1 Tra:2 Trb:1 Type:1 (12)
714 ...1 .... = EGPRS Extended Dynamic Allocation Capability: Implemented
715 .... .1.. = 8PSK Power Capability Bits: Present
716 8PSK Power Capability: Power class E2 (2)
717 0... .... = COMPACT Interference Measurement Capability: Not Implemented
718 .1.. .... = Revision Level Indicator: The ME is Release '99 onwards
719 ..1. .... = UMTS FDD Radio Access Technology Capability: Supported
720 ...0 .... = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
721 .... 0... = CDMA 2000 Radio Access Technology Capability: Not supported
722 .... .0.. = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
723 .... ..1. = GERAN Feature Package 1: Supported
724 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
725 0... .... = Modulation based multislot class support: Not supported
726 High Multislot Capability: Bits are not available (0)
727 ..0. .... = GERAN Iu mode: Not supported
728 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 0 (0)
729 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 0 (0)
730 .... ...0 = Multiple TBF Capability: Not supported
731 00.. .... = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance not supported (0)
732 ..0. .... = Extended RLC/MAC Control Message Segmentation Capability: Not supported
733 ...0 .... = DTM Enhancements Capability: The mobile station does not support enhanced DTM CS establishment and enhanced DTM CS release procedures
734 .... .0.. = PS Handover Capability: Not supported
735 .... ..0. = DTM Handover Capability: Not supported
736 MS RA capability 2
737 .001 1... = Access Technology Type: GSM 1800 (3)
738 .... .010 0100 .... = Length in bits: 0x24 (36)
739 .... 001. RF Power Capability, GMSK Power Class: 1 W (30 dBm) (1)
740 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
741 1... .... = Controlled early Classmark Sending: Implemented
742 .1.. .... = Pseudo Synchronisation: Present
743 ..0. .... = Voice Group Call Service: no VGCS capability or no notifications wanted
744 ...0 .... = Voice Broadcast Service: no VBS capability or no notifications wanted
745 .... 0... = Multislot capability struct: Not Present
746 .... .1.. = 8PSK Power Capability Bits: Present
747 8PSK Power Capability: Power class E2 (2)
748 0... .... = COMPACT Interference Measurement Capability: Not Implemented
749 .1.. .... = Revision Level Indicator: The ME is Release '99 onwards
750 ..1. .... = UMTS FDD Radio Access Technology Capability: Supported
751 ...0 .... = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
752 .... 0... = CDMA 2000 Radio Access Technology Capability: Not supported
753 .... .0.. = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
754 .... ..1. = GERAN Feature Package 1: Supported
755 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
756 0... .... = Modulation based multislot class support: Not supported
757 High Multislot Capability: Bits are not available (0)
758 ..0. .... = GERAN Iu mode: Not supported
759 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 0 (0)
760 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 0 (0)
761 .... ...0 = Multiple TBF Capability: Not supported
762 00.. .... = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance not supported (0)
763 ..0. .... = Extended RLC/MAC Control Message Segmentation Capability: Not supported
764 ...0 .... = DTM Enhancements Capability: The mobile station does not support enhanced DTM CS establishment and enhanced DTM CS release procedures
765 .... .0.. = PS Handover Capability: Not supported
766 .... ..0. = DTM Handover Capability: Not supported
767 MS RA capability 3
768 .011 1... = Access Technology Type: GSM 850 (7)
769 .... .010 0100 .... = Length in bits: 0x24 (36)
770 .... 100. RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4)
771 A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0)
772 1... .... = Controlled early Classmark Sending: Implemented
773 .1.. .... = Pseudo Synchronisation: Present
774 ..0. .... = Voice Group Call Service: no VGCS capability or no notifications wanted
775 ...0 .... = Voice Broadcast Service: no VBS capability or no notifications wanted
776 .... 0... = Multislot capability struct: Not Present
777 .... .1.. = 8PSK Power Capability Bits: Present
778 8PSK Power Capability: Power class E2 (2)
779 0... .... = COMPACT Interference Measurement Capability: Not Implemented
780 .1.. .... = Revision Level Indicator: The ME is Release '99 onwards
781 ..1. .... = UMTS FDD Radio Access Technology Capability: Supported
782 ...0 .... = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported
783 .... 0... = CDMA 2000 Radio Access Technology Capability: Not supported
784 .... .0.. = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported
785 .... ..1. = GERAN Feature Package 1: Supported
786 Extended DTM EGPRS Multi Slot Class: Bits are not available (0)
787 0... .... = Modulation based multislot class support: Not supported
788 High Multislot Capability: Bits are not available (0)
789 ..0. .... = GERAN Iu mode: Not supported
790 GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 0 (0)
791 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 0 (0)
792 .... ...0 = Multiple TBF Capability: Not supported
793 00.. .... = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance not supported (0)
794 ..0. .... = Extended RLC/MAC Control Message Segmentation Capability: Not supported
795 ...0 .... = DTM Enhancements Capability: The mobile station does not support enhanced DTM CS establishment and enhanced DTM CS release procedures
796 .... .0.. = PS Handover Capability: Not supported
797 .... ..0. = DTM Handover Capability: Not supported
798*/
799
800 bitvec_unhex(bv_dec, "17b3432b25966200019a42c6620001ba48c662000100");
801
802 printf("=== Test decoding of MS RA Capability 4===\n");
803 rc = decode_gsm_ra_cap(bv_dec, &data);
804 printf("decode_gsm_ra_cap() returns %d\n", rc);
Pau Espin Pedrolebdc0d82021-10-19 16:48:16 +0200805 OSMO_ASSERT(rc == 0);
Pau Espin Pedrol089d7342021-10-07 18:30:30 +0200806
807 /* Make sure there's 3 values */
Pau Espin Pedrolebdc0d82021-10-19 16:48:16 +0200808 OSMO_ASSERT(data.Count_MS_RA_capability_value == 3);
Pau Espin Pedrol089d7342021-10-07 18:30:30 +0200809
810 /* Make sure GPRS / EGPRS multislot class is parsed correctly */
Pau Espin Pedrolebdc0d82021-10-19 16:48:16 +0200811 printf("GPRS multislot class = %u\n", get_ms_class_by_capability(&data));
812 printf("EGPRS multislot class = %u\n", get_egprs_ms_class_by_capability(&data));
Pau Espin Pedrol089d7342021-10-07 18:30:30 +0200813
814 bitvec_free(bv_dec);
815}
816
Vadim Yanitskiya2d972a2020-04-04 03:44:35 +0700817void testEGPRSPktChReq(void *test_ctx)
818{
819 EGPRS_PacketChannelRequest_t req;
820 int rc;
821
822 printf("*** %s ***\n", __func__);
823
824 static const uint16_t EGPRSPktChReqs[] = {
825 /* < One Phase Access Request : '0'B
826 < MultislotClass : '10101'B >
827 < Priority : '10'B >
828 < RandomBits : '101'B > > */
829 0x2b5,
830 /* < One Phase Access Request : '0'B
831 < MultislotClass : '01010'B >
832 < Priority : '01'B >
833 < RandomBits : '010'B > > */
834 0x14a,
835 /* < Short Access Request : '100'B
836 < NumberOfBlocks : '001'B >
837 < Priority : '01'B >
838 < RandomBits : '000'B > > */
839 0x428,
840 /* < Two Phase Access Request : '110000'B
841 < Priority : '00'B >
842 < RandomBits : '000'B > > */
843 0x600,
844 /* < Two Phase Access Request : '110000'B
845 < Priority : '11'B >
846 < RandomBits : '111'B > > */
847 0x61f,
848 /* < Signalling : '110011'B
849 < RandomBits : '10101'B > > */
850 0x675,
851 /* < Signalling : '110011'B
852 < RandomBits : '10001'B > > */
853 0x671,
854 /* < Emergency call : '110111'B
855 < RandomBits : '11001'B > > */
856 0x6f9,
857 /* < Unknown (test) : '111111'B
858 < RandomBits : '01010'B > > */
859 0x7ea,
860 };
861
862 for (size_t i = 0; i < ARRAY_SIZE(EGPRSPktChReqs); i++) {
863 rc = decode_egprs_pkt_ch_req(EGPRSPktChReqs[i], &req);
864 printf("decode_egprs_pkt_ch_req(0x%03x) returns %d\n", EGPRSPktChReqs[i], rc);
865 if (rc == 0)
866 printf(" ==> %s\n", get_value_string(egprs_pkt_ch_req_type_names, req.Type));
867 }
868}
869
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300870int main(int argc, char *argv[])
871{
Alexander Couzensccde5c92017-02-04 03:10:08 +0100872 void *ctx = talloc_named_const(NULL, 1, "RLCMACTest");
Neels Hofmeyr42f2d612018-04-01 16:54:40 +0200873 osmo_init_logging2(ctx, &gprs_log_info);
Harald Welte570f9132020-03-19 15:03:01 +0100874 log_parse_category_mask(osmo_stderr_target, "DPCU,3:DLGLOBAL,1:DRLCMACDATA,2:DCSN1,1:");
Vadim Yanitskiy8a87f912020-02-17 01:19:10 +0700875
876 log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);
877 log_set_print_category_hex(osmo_stderr_target, 0);
878 log_set_print_category(osmo_stderr_target, 1);
879 log_set_print_level(osmo_stderr_target, 1);
880 log_set_use_color(osmo_stderr_target, 0);
Andreas Eversberg138f4e62013-01-14 12:31:11 +0100881
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300882 //printSizeofRLCMAC();
Alexander Couzensccde5c92017-02-04 03:10:08 +0100883 testRlcMacDownlink(ctx);
884 testRlcMacUplink(ctx);
885 testCsnLeftAlignedVarBmpBounds(ctx);
Pau Espin Pedrolcdbc5db2020-01-23 21:00:19 +0100886 testRAcap(ctx);
Pau Espin Pedrol866bece2020-03-21 01:20:52 +0100887 testMalformedRAcap(ctx);
Pau Espin Pedrolefad80b2020-03-23 14:35:26 +0100888 testRAcap2(ctx);
Pau Espin Pedrol2282b502021-10-07 12:19:01 +0200889 testRAcap3(ctx);
Vadim Yanitskiya2d972a2020-04-04 03:44:35 +0700890
891 testEGPRSPktChReq(ctx);
892
Pau Espin Pedrol089d7342021-10-07 18:30:30 +0200893 testRAcap4(ctx);
894
Alexander Couzensccde5c92017-02-04 03:10:08 +0100895 talloc_free(ctx);
Ivan Kluchnikov487a1412011-12-21 13:17:53 +0300896}