Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 1 | /* 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. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | |
| 22 | //#include <BitVector.h> |
| 23 | #include <iostream> |
| 24 | #include <cstdlib> |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 25 | #include <cstring> |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 26 | #include <assert.h> |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 27 | #include "gprs_rlcmac.h" |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 28 | #include "decoding.h" |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 29 | |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 30 | extern "C" { |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 31 | #include "pcu_vty.h" |
| 32 | #include <osmocom/vty/telnet_interface.h> |
| 33 | #include <osmocom/vty/logging.h> |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 34 | #include <osmocom/core/utils.h> |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 35 | #include <osmocom/core/msgb.h> |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 36 | #include <osmocom/core/application.h> |
Vadim Yanitskiy | 39a6505 | 2020-01-25 01:24:59 +0700 | [diff] [blame] | 37 | |
| 38 | #include "csn1.h" |
Pau Espin Pedrol | b2653fe | 2020-03-26 15:14:01 +0100 | [diff] [blame] | 39 | #include "gsm_rlcmac.h" |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 40 | } |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 41 | using namespace std; |
| 42 | |
Pau Espin Pedrol | 1e97951 | 2021-03-09 15:46:35 +0100 | [diff] [blame] | 43 | #include "gprs_debug.h" |
| 44 | |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 45 | void *tall_pcu_ctx; |
| 46 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 47 | void printSizeofRLCMAC() |
| 48 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 49 | printf("*** %s ***\n", __func__); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 50 | cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl; |
| 51 | cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl; |
| 52 | cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl; |
| 53 | cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl; |
| 54 | cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl; |
| 55 | cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl; |
| 56 | cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl; |
| 57 | cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl; |
| 58 | cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl; |
| 59 | cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl; |
| 60 | cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl; |
| 61 | cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl; |
| 62 | cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl; |
| 63 | cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl; |
| 64 | cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl; |
| 65 | |
| 66 | cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl; |
| 67 | cout << "sizeof Packet_Access_Reject_t " << sizeof(Packet_Access_Reject_t) << endl; |
Holger Hans Peter Freyther | e13298d | 2013-07-28 16:45:54 +0200 | [diff] [blame] | 68 | cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl; |
| 69 | cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 70 | cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl; |
| 71 | cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl; |
| 72 | cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl; |
| 73 | cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl; |
| 74 | cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl; |
| 75 | cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl; |
| 76 | cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl; |
| 77 | cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl; |
| 78 | cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl; |
| 79 | cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl; |
| 80 | cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl; |
| 81 | cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl; |
| 82 | cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl; |
| 83 | cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl; |
| 84 | cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl; |
| 85 | cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl; |
| 86 | cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl; |
| 87 | cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl; |
| 88 | cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl; |
| 89 | cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl; |
| 90 | cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl; |
| 91 | cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl; |
| 92 | cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; |
| 93 | } |
| 94 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 95 | void testRlcMacDownlink(void *test_ctx) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 96 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 97 | printf("*** %s ***\n", __func__); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 98 | |
| 99 | int rc; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 100 | struct bitvec *resultVector = bitvec_alloc(23, test_ctx); |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 101 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 102 | |
| 103 | std::string testData[] = { |
| 104 | "4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment |
Saurabh Sharan | 656eed5 | 2016-03-10 14:15:29 +0530 | [diff] [blame] | 105 | "48282407a6a07422720100032b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 106 | "47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack |
Saurabh Sharan | bacb65b | 2016-03-10 17:24:49 +0530 | [diff] [blame] | 107 | "47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment |
| 108 | "400820001a3904df0680efb3300b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment (EGPRS) |
Saurabh Sharan | 2b09c39 | 2016-03-16 19:17:32 +0530 | [diff] [blame] | 109 | "40284f0000001009810c826f4406809dcecb2b2b2b2b2b", // Packet Uplink Assignment (EGPRS) |
Pau Espin Pedrol | 5cb002f | 2020-01-23 23:45:17 +0100 | [diff] [blame] | 110 | "4024030f2f0000000087b0042b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Ack Nack (EGPRS) |
Vadim Yanitskiy | 9b2f7c4 | 2020-02-11 21:45:19 +0700 | [diff] [blame] | 111 | "4913e00850884013a8048b2b2b2b2b2b2b2b2b2b2b2b2b", // Polling Request (malformed) |
Pau Espin Pedrol | 5cb002f | 2020-01-23 23:45:17 +0100 | [diff] [blame] | 112 | "412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b", // Packet Uplink Ack Nack? |
| 113 | "41942b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // System Info 13? |
Pau Espin Pedrol | 259a694 | 2020-11-23 17:57:35 +0100 | [diff] [blame] | 114 | "40883c1493120000000012002b2b2b2b2b2b2b2b2b2b2b", // Pkt Paging Request (OS#4838) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | int testDataSize = sizeof(testData)/sizeof(testData[0]); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 118 | |
| 119 | cout << " DOWNLINK " << endl; |
| 120 | for (int i = 0; i < testDataSize; i++) |
| 121 | { |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 122 | cout << "vector1 = " << testData[i] << endl; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 123 | bitvec *vector = bitvec_alloc(23, test_ctx); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 124 | bitvec_unhex(vector, testData[i].c_str()); |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 125 | |
Pau Espin Pedrol | 99c437b | 2020-01-24 12:34:50 +0100 | [diff] [blame] | 126 | RlcMacDownlink_t data; |
| 127 | memset(&data, 0, sizeof(data)); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 128 | cout << "=========Start DECODE===========" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 129 | rc = decode_gsm_rlcmac_downlink(vector, &data); |
| 130 | cout << "+++++++++Finish DECODE ("<< rc <<")++++++++++" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 131 | cout << "=========Start ENCODE=============" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 132 | rc = encode_gsm_rlcmac_downlink(resultVector, &data); |
| 133 | cout << "+++++++++Finish ENCODE ("<< rc <<")+++++++++++" << endl; |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 134 | cout << "vector1 = " << osmo_hexdump(vector->data, 23) << endl; |
| 135 | cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl; |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 136 | if (memcmp(vector->data, resultVector->data, 23) == 0) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 137 | cout << "vector1 == vector2 : TRUE" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 138 | else |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 139 | cout << "vector1 == vector2 : FALSE" << endl; |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 140 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 141 | bitvec_free(vector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 142 | } |
Andreas Eversberg | 273a222 | 2013-01-16 08:56:33 +0100 | [diff] [blame] | 143 | |
| 144 | bitvec_free(resultVector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 148 | void testRlcMacUplink(void *test_ctx) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 149 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 150 | printf("*** %s ***\n", __func__); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 151 | |
| 152 | int rc; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 153 | struct bitvec *resultVector = bitvec_alloc(23, test_ctx); |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 154 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 155 | |
| 156 | std::string testData[] = { |
Saurabh Sharan | 656eed5 | 2016-03-10 14:15:29 +0530 | [diff] [blame] | 157 | "400e1e61d11d2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block |
| 158 | "400b8020000000000000002480e0032b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack |
Saurabh Sharan | bacb65b | 2016-03-10 17:24:49 +0530 | [diff] [blame] | 159 | "4016713dc094270ca2ae57ef909006aa0fc0001f80222b", // Packet Resource Request |
Vadim Yanitskiy | f22163b | 2020-03-06 06:51:48 +0700 | [diff] [blame] | 160 | "401673c87f24af2632b25964200600000091000b780080", // Packet Resource Request (from keith) |
Saurabh Sharan | bacb65b | 2016-03-10 17:24:49 +0530 | [diff] [blame] | 161 | "40200ffc0021ec010b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // EPDAN |
Pau Espin Pedrol | 5cb002f | 2020-01-23 23:45:17 +0100 | [diff] [blame] | 162 | "400a9020000000000000003010012a0800132b2b2b2b2b", // Packet Downlink Ack/Nack ? |
Vadim Yanitskiy | 809dc8b | 2021-01-28 20:31:42 +0100 | [diff] [blame] | 163 | |
| 164 | /* Packet Resource Request (see OS#4955, mistakes in 3GPP TS 44.060) */ |
| 165 | "4117ea1b903eaeb2686564b2330820078000102b2b2b2b", |
| 166 | "40167e49f7f8ef2632b2596620060000806d00541c0080", |
| 167 | "4017787174d92eba686564b2ccc30800a000040b2b2b2b", |
| 168 | "4017e5b2cd5a2eca68655e44aec84880139300412b2b2b", |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | int testDataSize = sizeof(testData)/sizeof(testData[0]); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 172 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 173 | |
| 174 | cout << " UPLINK " << endl; |
| 175 | for (int i = 0; i < testDataSize; i++) |
| 176 | { |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 177 | cout << "vector1 = " << testData[i] << endl; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 178 | bitvec *vector = bitvec_alloc(23, test_ctx); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 179 | bitvec_unhex(vector, testData[i].c_str()); |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 180 | |
Pau Espin Pedrol | 99c437b | 2020-01-24 12:34:50 +0100 | [diff] [blame] | 181 | RlcMacUplink_t data; |
| 182 | memset(&data, 0, sizeof(data)); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 183 | cout << "=========Start DECODE===========" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 184 | rc = decode_gsm_rlcmac_uplink(vector, &data); |
| 185 | cout << "+++++++++Finish DECODE ("<< rc << ")++++++++++" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 186 | cout << "=========Start ENCODE=============" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 187 | rc = encode_gsm_rlcmac_uplink(resultVector, &data); |
| 188 | cout << "+++++++++Finish ENCODE ("<< rc <<")+++++++++++" << endl; |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 189 | cout << "vector1 = " << osmo_hexdump(vector->data, 23) << endl; |
| 190 | cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl; |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 191 | if (memcmp(vector->data, resultVector->data, 23) == 0) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 192 | cout << "vector1 == vector2 : TRUE" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 193 | else |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 194 | cout << "vector1 == vector2 : FALSE" << endl; |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 195 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 196 | bitvec_free(vector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 197 | } |
Andreas Eversberg | 273a222 | 2013-01-16 08:56:33 +0100 | [diff] [blame] | 198 | |
| 199 | bitvec_free(resultVector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 200 | } |
| 201 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 202 | void testCsnLeftAlignedVarBmpBounds(void *test_ctx) |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 203 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 204 | printf("*** %s ***\n", __func__); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 205 | |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 206 | struct msgb *m = msgb_alloc(80, "test"); |
| 207 | static uint8_t exp[] = { 0x7f, 0xff, 0xff, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 208 | bitvec *vector = bitvec_alloc(23, test_ctx); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 209 | int rc; |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 210 | |
| 211 | bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000"); |
| 212 | RlcMacUplink_t data; |
Pau Espin Pedrol | 99c437b | 2020-01-24 12:34:50 +0100 | [diff] [blame] | 213 | memset(&data, 0, sizeof(data)); |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 214 | |
| 215 | EGPRS_AckNack_Desc_t *urbb = |
| 216 | &data.u.Egprs_Packet_Downlink_Ack_Nack.EGPRS_AckNack.Desc; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 217 | rc = decode_gsm_rlcmac_uplink(vector, &data); |
| 218 | OSMO_ASSERT(rc == 0); |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 219 | |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 220 | memcpy(msgb_put(m, 13), urbb->URBB, 13); |
| 221 | if (!msgb_eq_data_print(m, exp, 13)) |
| 222 | printf("%s failed!\n", __func__); |
| 223 | msgb_free(m); |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 224 | } |
| 225 | |
Pau Espin Pedrol | b2653fe | 2020-03-26 15:14:01 +0100 | [diff] [blame] | 226 | extern "C" { |
Pau Espin Pedrol | 007056e | 2020-03-26 15:03:33 +0100 | [diff] [blame] | 227 | int encode_gsm_ra_cap(struct bitvec *vector, MS_Radio_Access_capability_t * data); |
Pau Espin Pedrol | b2653fe | 2020-03-26 15:14:01 +0100 | [diff] [blame] | 228 | } |
Vadim Yanitskiy | b47e53b | 2020-02-20 04:33:50 +0700 | [diff] [blame] | 229 | |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 230 | void testRAcap(void *test_ctx) |
| 231 | { |
Pau Espin Pedrol | 866bece | 2020-03-21 01:20:52 +0100 | [diff] [blame] | 232 | printf("*** %s ***\n", __func__); |
| 233 | MS_Radio_Access_capability_t data; |
| 234 | memset(&data, 0, sizeof(data)); |
| 235 | bitvec *bv_dec = bitvec_alloc(23, test_ctx); |
| 236 | bitvec *bv_enc = bitvec_alloc(23, test_ctx); |
| 237 | unsigned int len_dec, len_enc; |
| 238 | int rc; |
| 239 | /* |
| 240 | MS RA capability 1 |
| 241 | 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1) |
| 242 | .... 0011 011. .... = Length in bits: 0x1b (27) |
| 243 | ...0 01.. RF Power Capability, GMSK Power Class: Not specified (1) |
| 244 | A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0) |
| 245 | .... ...1 = Controlled early Classmark Sending: Implemented |
| 246 | 0... .... = Pseudo Synchronisation: Not Present |
| 247 | .0.. .... = Voice Group Call Service: no VGCS capability or no notifications wanted |
| 248 | ..0. .... = Voice Broadcast Service: no VBS capability or no notifications wanted |
| 249 | ...1 .... = Multislot capability struct: Present |
| 250 | HSCSD multislot class: Bits are not available (0) |
| 251 | SMS_VALUE (Switch-Measure-Switch): Bits are not available (0) |
| 252 | ECSD multislot class: Bits are not available (0) |
| 253 | DTM GPRS Multi Slot Class: Bits are not available (0) |
| 254 | .... ..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) |
| 255 | ...0 .... = GPRS Extended Dynamic Allocation Capability: Not Implemented |
| 256 | .... ...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) |
| 257 | .... 0... = EGPRS Extended Dynamic Allocation Capability: Not Implemented |
| 258 | */ |
| 259 | bitvec_unhex(bv_dec, "1365146230"); |
| 260 | |
| 261 | printf("=== Test decoding of MS RA Capability ===\n"); |
| 262 | rc = decode_gsm_ra_cap(bv_dec, &data); |
| 263 | OSMO_ASSERT(rc == 0); |
| 264 | |
| 265 | /* Make sure there's 1 value (currently fails due to failed decoding) */ |
| 266 | OSMO_ASSERT(data.Count_MS_RA_capability_value == 1); |
| 267 | |
| 268 | /* Make sure GPRS / EGPRS multislot class is parsed correctly */ |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 269 | printf("GPRS multislot class = %u\n", get_ms_class_by_capability(&data)); |
| 270 | printf("EGPRS multislot class = %u\n", get_egprs_ms_class_by_capability(&data)); |
Pau Espin Pedrol | 866bece | 2020-03-21 01:20:52 +0100 | [diff] [blame] | 271 | |
| 272 | /* Test encoding of decoded MS RA Capability */ |
| 273 | printf("=== Test encoding of MS RA Capability ===\n"); |
| 274 | rc = encode_gsm_ra_cap(bv_enc, &data); |
| 275 | printf("encode_gsm_ra_cap() returns %d\n", rc); |
| 276 | |
| 277 | bv_dec->cur_bit = 4; |
| 278 | len_dec = bitvec_get_uint(bv_dec, 7); |
| 279 | bv_enc->cur_bit = 4; |
| 280 | len_enc = bitvec_get_uint(bv_enc, 7); |
| 281 | |
| 282 | /* NOTE: vector2 is expected to be different because there is actually no |
| 283 | * way to distinguish between NULL and 0 in MS_Radio_Access_capability_t. |
| 284 | * The difference is in length indicator: 27 bits vs 65 bits. */ |
| 285 | printf("vector1 (len_ind=%u) = %s\n", len_dec, osmo_hexdump(bv_dec->data, bv_dec->data_len)); |
| 286 | printf("vector2 (len_ind=%u) = %s\n", len_enc, osmo_hexdump(bv_enc->data, bv_enc->data_len)); |
| 287 | |
| 288 | /* Mangle the length indicator (set it to 21) */ |
| 289 | unsigned int writeIndex = 4; |
| 290 | rc = bitvec_write_field(bv_dec, &writeIndex, 21, 7); |
| 291 | OSMO_ASSERT(rc == 0); |
| 292 | |
| 293 | /* Make sure decoding attempt fails */ |
| 294 | printf("=== Test decoding of a malformed vector (short length indicator) ===\n"); |
| 295 | rc = decode_gsm_ra_cap(bv_dec, &data); |
| 296 | printf("decode_gsm_ra_cap() returns %d\n", rc); |
| 297 | } |
| 298 | |
| 299 | void testMalformedRAcap(void *test_ctx) |
| 300 | { |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 301 | printf("*** %s ***\n", __func__); |
| 302 | MS_Radio_Access_capability_t data; |
| 303 | memset(&data, 0, sizeof(data)); |
Vadim Yanitskiy | b47e53b | 2020-02-20 04:33:50 +0700 | [diff] [blame] | 304 | bitvec *bv_dec = bitvec_alloc(23, test_ctx); |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 305 | int rc; |
| 306 | /* |
| 307 | MS RA capability 1 |
| 308 | 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1) |
Vadim Yanitskiy | 55f06c3 | 2020-02-18 05:45:15 +0700 | [diff] [blame] | 309 | .... 0011 101. .... = Length in bits: 0x1d (29) |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 310 | ...0 01.. RF Power Capability, GMSK Power Class: Not specified (1) |
| 311 | A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0) |
| 312 | .... ...1 = Controlled early Classmark Sending: Implemented |
| 313 | 0... .... = Pseudo Synchronisation: Not Present |
| 314 | .0.. .... = Voice Group Call Service: no VGCS capability or no notifications wanted |
| 315 | ..0. .... = Voice Broadcast Service: no VBS capability or no notifications wanted |
| 316 | ...1 .... = Multislot capability struct: Present |
| 317 | .... ..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) |
| 318 | ...0 .... = GPRS Extended Dynamic Allocation Capability: Not Implemented |
Pau Espin Pedrol | 866bece | 2020-03-21 01:20:52 +0100 | [diff] [blame] | 319 | |
| 320 | It doesn't show up in wireshark's tree above because specific parser is |
| 321 | used, but this RA Cap bitstream has Exist_EGPRS_multislot_class = 1 but |
| 322 | it provides no struct with the expected data (malformed, generated |
| 323 | erroneusly through TTCN3). The CSN.1 dceoder should ideally return an |
| 324 | error here, but it doesn't (it returns a >0 value which we convert to 0 |
| 325 | in decode_gsm_ra_cap()). |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 326 | */ |
Vadim Yanitskiy | b47e53b | 2020-02-20 04:33:50 +0700 | [diff] [blame] | 327 | bitvec_unhex(bv_dec, "13a5146200"); |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 328 | |
Vadim Yanitskiy | b47e53b | 2020-02-20 04:33:50 +0700 | [diff] [blame] | 329 | printf("=== Test decoding of MS RA Capability ===\n"); |
| 330 | rc = decode_gsm_ra_cap(bv_dec, &data); |
Pau Espin Pedrol | 866bece | 2020-03-21 01:20:52 +0100 | [diff] [blame] | 331 | printf("decode_gsm_ra_cap() returns %d\n", rc); |
Vadim Yanitskiy | 55f06c3 | 2020-02-18 05:45:15 +0700 | [diff] [blame] | 332 | OSMO_ASSERT(rc == 0); |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 333 | |
Pau Espin Pedrol | 866bece | 2020-03-21 01:20:52 +0100 | [diff] [blame] | 334 | /* For sake of completeness, check if the decoder could find 1 value |
| 335 | before failing to decode it */ |
Vadim Yanitskiy | 55f06c3 | 2020-02-18 05:45:15 +0700 | [diff] [blame] | 336 | OSMO_ASSERT(data.Count_MS_RA_capability_value == 1); |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 337 | |
Pau Espin Pedrol | 2f16924 | 2020-03-20 23:59:44 +0100 | [diff] [blame] | 338 | bitvec_free(bv_dec); |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 339 | } |
| 340 | |
Pau Espin Pedrol | efad80b | 2020-03-23 14:35:26 +0100 | [diff] [blame] | 341 | /* Reproduce crash from ticket OS#4463 */ |
| 342 | void testRAcap2(void *test_ctx) |
| 343 | { |
| 344 | printf("*** %s ***\n", __func__); |
| 345 | MS_Radio_Access_capability_t data; |
| 346 | memset(&data, 0, sizeof(data)); |
| 347 | bitvec *bv_dec = bitvec_alloc(23, test_ctx); |
| 348 | int rc; |
| 349 | /* |
| 350 | MS Radio Access Capability |
| 351 | Element ID: 0x13 |
| 352 | 1... .... = ext: 1 |
| 353 | Length: 23 |
| 354 | ------------------------------------------- Hex bitstream starts here: |
| 355 | MS RA capability 1 |
| 356 | 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1) |
| 357 | .... 1001 001. .... = Length in bits: 0x49 (73) |
| 358 | ...1 00.. RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4) |
| 359 | A5 Bits: A5 bits follow (1) |
| 360 | A5/1: encryption algorithm available (1) |
| 361 | A5/2: encryption algorithm not available (0) |
| 362 | A5/3: encryption algorithm available (1) |
| 363 | A5/4: encryption algorithm not available (0) |
| 364 | A5/5: encryption algorithm not available (0) |
| 365 | A5/6: encryption algorithm not available (0) |
| 366 | A5/7: encryption algorithm not available (0) |
| 367 | .... ..1. = Controlled early Classmark Sending: Implemented |
| 368 | .... ...1 = Pseudo Synchronisation: Present |
| 369 | 0... .... = Voice Group Call Service: no VGCS capability or no notifications wanted |
| 370 | .0.. .... = Voice Broadcast Service: no VBS capability or no notifications wanted |
| 371 | ..1. .... = Multislot capability struct: Present |
| 372 | HSCSD multislot class: Bits are not available (0) |
| 373 | .... 0111 = SMS_VALUE (Switch-Measure-Switch): 8/4 timeslot (~1154 microseconds) (7) |
| 374 | 0001 .... = (SM_VALUE) Switch-Measure: 2/4 timeslot (~288 microseconds) (1) |
| 375 | ECSD multislot class: Bits are not available (0) |
| 376 | .... ...0 = Single Slot DTM: Not supported |
| 377 | 1... .... = DTM EGPRS Multi Slot Class: Present |
| 378 | .... .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) |
| 379 | ..1. .... = GPRS Extended Dynamic Allocation Capability: Implemented |
| 380 | .... ..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) |
| 381 | ...1 .... = EGPRS Extended Dynamic Allocation Capability: Implemented |
| 382 | .... .11. = DTM GPRS Multi Slot Class: Multislot class 11 supported (3) |
| 383 | .11. .... = DTM EGPRS Multi Slot Class: Multislot class 11 supported (3) |
| 384 | ...1 .... = 8PSK Power Capability Bits: Present |
| 385 | 8PSK Power Capability: Power class E2 (2) |
| 386 | .... ..0. = COMPACT Interference Measurement Capability: Not Implemented |
| 387 | .... ...1 = Revision Level Indicator: The ME is Release '99 onwards |
| 388 | 0... .... = UMTS FDD Radio Access Technology Capability: Not supported |
| 389 | .0.. .... = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported |
| 390 | ..0. .... = CDMA 2000 Radio Access Technology Capability: Not supported |
| 391 | ...0 .... = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported |
| 392 | .... 1... = GERAN Feature Package 1: Supported |
| 393 | Extended DTM EGPRS Multi Slot Class: Bits are not available (0) |
| 394 | .... ..0. = Modulation based multislot class support: Not supported |
| 395 | High Multislot Capability: Bits are not available (0) |
| 396 | 0... .... = GERAN Iu mode: Not supported |
| 397 | GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 3 (3) |
| 398 | 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 3 (3) |
| 399 | .... .0.. = Multiple TBF Capability: Not supported |
| 400 | .... ..01 = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1) |
| 401 | 1... .... = Extended RLC/MAC Control Message Segmentation Capability: Supported |
| 402 | .1.. .... = DTM Enhancements Capability: The mobile station supports enhanced DTM CS establishment and enhanced DTM CS release procedures |
| 403 | ...0 .... = PS Handover Capability: Not supported |
| 404 | MS RA capability 2 |
| 405 | .... .011 1... .... = Access Technology Type: GSM 850 (7) |
| 406 | .010 0010 = Length in bits: 0x22 (34) |
| 407 | 100. .... RF Power Capability, GMSK Power Class: 2 W (33 dBm) (4) |
| 408 | A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0) |
| 409 | .... 1... = Controlled early Classmark Sending: Implemented |
| 410 | .... .1.. = Pseudo Synchronisation: Present |
| 411 | .... ..0. = Voice Group Call Service: no VGCS capability or no notifications wanted |
| 412 | .... ...0 = Voice Broadcast Service: no VBS capability or no notifications wanted |
| 413 | 0... .... = Multislot capability struct: Not Present |
| 414 | .1.. .... = 8PSK Power Capability Bits: Present |
| 415 | 8PSK Power Capability: Power class E2 (2) |
| 416 | .... 0... = COMPACT Interference Measurement Capability: Not Implemented |
| 417 | .... .1.. = Revision Level Indicator: The ME is Release '99 onwards |
| 418 | .... ..0. = UMTS FDD Radio Access Technology Capability: Not supported |
| 419 | .... ...0 = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported |
| 420 | 0... .... = CDMA 2000 Radio Access Technology Capability: Not supported |
| 421 | .0.. .... = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported |
| 422 | ..1. .... = GERAN Feature Package 1: Supported |
| 423 | Extended DTM EGPRS Multi Slot Class: Bits are not available (0) |
| 424 | .... 0... = Modulation based multislot class support: Not supported |
| 425 | High Multislot Capability: Bits are not available (0) |
| 426 | .... ..0. = GERAN Iu mode: Not supported |
| 427 | GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 3 (3) |
| 428 | 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 3 (3) |
| 429 | ...0 .... = Multiple TBF Capability: Not supported |
| 430 | .... 01.. = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1) |
| 431 | .... ..1. = Extended RLC/MAC Control Message Segmentation Capability: Supported |
| 432 | .... ...1 = DTM Enhancements Capability: The mobile station supports enhanced DTM CS establishment and enhanced DTM CS release procedures |
| 433 | .0.. .... = PS Handover Capability: Not supported |
| 434 | MS RA capability 3 |
| 435 | ...0 011. = Access Technology Type: GSM 1800 (3) |
| 436 | .... ...0 1000 10.. = Length in bits: 0x22 (34) |
| 437 | .... ..00 1... .... RF Power Capability, GMSK Power Class: 1 W (30 dBm) (1) |
| 438 | A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0) |
| 439 | ..1. .... = Controlled early Classmark Sending: Implemented |
| 440 | ...1 .... = Pseudo Synchronisation: Present |
| 441 | .... 0... = Voice Group Call Service: no VGCS capability or no notifications wanted |
| 442 | .... .0.. = Voice Broadcast Service: no VBS capability or no notifications wanted |
| 443 | .... ..0. = Multislot capability struct: Not Present |
| 444 | .... ...1 = 8PSK Power Capability Bits: Present |
| 445 | 8PSK Power Capability: Power class E2 (2) |
| 446 | ..0. .... = COMPACT Interference Measurement Capability: Not Implemented |
| 447 | ...1 .... = Revision Level Indicator: The ME is Release '99 onwards |
| 448 | .... 0... = UMTS FDD Radio Access Technology Capability: Not supported |
| 449 | .... .0.. = UMTS 3.84 Mcps TDD Radio Access Technology Capability: Not supported |
| 450 | .... ..0. = CDMA 2000 Radio Access Technology Capability: Not supported |
| 451 | .... ...0 = UMTS 1.28 Mcps TDD Radio Access Technology Capability: Not supported |
| 452 | 1... .... = GERAN Feature Package 1: Supported |
| 453 | Extended DTM EGPRS Multi Slot Class: Bits are not available (0) |
| 454 | ..0. .... = Modulation based multislot class support: Not supported |
| 455 | High Multislot Capability: Bits are not available (0) |
| 456 | .... 0... = GERAN Iu mode: Not supported |
| 457 | GMSK Multislot Power Profile: GMSK_MULTISLOT_POWER_PROFILE 3 (3) |
| 458 | 8-PSK Multislot Power Profile: 8-PSK_MULTISLOT_POWER_PROFILE 3 (3) |
| 459 | .0.. .... = Multiple TBF Capability: Not supported |
| 460 | ..01 .... = Downlink Advanced Receiver Performance: Downlink Advanced Receiver Performance - phase I supported (1) |
| 461 | .... 1... = Extended RLC/MAC Control Message Segmentation Capability: Supported |
| 462 | .... .1.. = DTM Enhancements Capability: The mobile station supports enhanced DTM CS establishment and enhanced DTM CS release procedures |
| 463 | .... ...0 = PS Handover Capability: Not supported |
| 464 | */ |
| 465 | bitvec_unhex(bv_dec, "1933432b37159ef90879cba28c6421e72688b190879c00"); |
| 466 | |
| 467 | printf("=== Test decoding of multi-band MS RA Capability ===\n"); |
| 468 | rc = decode_gsm_ra_cap(bv_dec, &data); |
Pau Espin Pedrol | 7faa5da | 2020-03-21 00:13:33 +0100 | [diff] [blame] | 469 | printf("decode_gsm_ra_cap() returns %d\n", rc); |
| 470 | OSMO_ASSERT(rc == 0); |
| 471 | |
| 472 | /* Make sure there's 3 values */ |
Pau Espin Pedrol | efad80b | 2020-03-23 14:35:26 +0100 | [diff] [blame] | 473 | OSMO_ASSERT(data.Count_MS_RA_capability_value == 3); |
| 474 | |
| 475 | /* Make sure GPRS / EGPRS multislot class is parsed correctly */ |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 476 | printf("GPRS multislot class = %u\n", get_ms_class_by_capability(&data)); |
| 477 | printf("EGPRS multislot class = %u\n", get_egprs_ms_class_by_capability(&data)); |
Pau Espin Pedrol | 7faa5da | 2020-03-21 00:13:33 +0100 | [diff] [blame] | 478 | |
Pau Espin Pedrol | efad80b | 2020-03-23 14:35:26 +0100 | [diff] [blame] | 479 | bitvec_free(bv_dec); |
| 480 | } |
| 481 | |
Vadim Yanitskiy | a2d972a | 2020-04-04 03:44:35 +0700 | [diff] [blame] | 482 | void testEGPRSPktChReq(void *test_ctx) |
| 483 | { |
| 484 | EGPRS_PacketChannelRequest_t req; |
| 485 | int rc; |
| 486 | |
| 487 | printf("*** %s ***\n", __func__); |
| 488 | |
| 489 | static const uint16_t EGPRSPktChReqs[] = { |
| 490 | /* < One Phase Access Request : '0'B |
| 491 | < MultislotClass : '10101'B > |
| 492 | < Priority : '10'B > |
| 493 | < RandomBits : '101'B > > */ |
| 494 | 0x2b5, |
| 495 | /* < One Phase Access Request : '0'B |
| 496 | < MultislotClass : '01010'B > |
| 497 | < Priority : '01'B > |
| 498 | < RandomBits : '010'B > > */ |
| 499 | 0x14a, |
| 500 | /* < Short Access Request : '100'B |
| 501 | < NumberOfBlocks : '001'B > |
| 502 | < Priority : '01'B > |
| 503 | < RandomBits : '000'B > > */ |
| 504 | 0x428, |
| 505 | /* < Two Phase Access Request : '110000'B |
| 506 | < Priority : '00'B > |
| 507 | < RandomBits : '000'B > > */ |
| 508 | 0x600, |
| 509 | /* < Two Phase Access Request : '110000'B |
| 510 | < Priority : '11'B > |
| 511 | < RandomBits : '111'B > > */ |
| 512 | 0x61f, |
| 513 | /* < Signalling : '110011'B |
| 514 | < RandomBits : '10101'B > > */ |
| 515 | 0x675, |
| 516 | /* < Signalling : '110011'B |
| 517 | < RandomBits : '10001'B > > */ |
| 518 | 0x671, |
| 519 | /* < Emergency call : '110111'B |
| 520 | < RandomBits : '11001'B > > */ |
| 521 | 0x6f9, |
| 522 | /* < Unknown (test) : '111111'B |
| 523 | < RandomBits : '01010'B > > */ |
| 524 | 0x7ea, |
| 525 | }; |
| 526 | |
| 527 | for (size_t i = 0; i < ARRAY_SIZE(EGPRSPktChReqs); i++) { |
| 528 | rc = decode_egprs_pkt_ch_req(EGPRSPktChReqs[i], &req); |
| 529 | printf("decode_egprs_pkt_ch_req(0x%03x) returns %d\n", EGPRSPktChReqs[i], rc); |
| 530 | if (rc == 0) |
| 531 | printf(" ==> %s\n", get_value_string(egprs_pkt_ch_req_type_names, req.Type)); |
| 532 | } |
| 533 | } |
| 534 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 535 | int main(int argc, char *argv[]) |
| 536 | { |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 537 | void *ctx = talloc_named_const(NULL, 1, "RLCMACTest"); |
Neels Hofmeyr | 42f2d61 | 2018-04-01 16:54:40 +0200 | [diff] [blame] | 538 | osmo_init_logging2(ctx, &gprs_log_info); |
Harald Welte | 570f913 | 2020-03-19 15:03:01 +0100 | [diff] [blame] | 539 | log_parse_category_mask(osmo_stderr_target, "DPCU,3:DLGLOBAL,1:DRLCMACDATA,2:DCSN1,1:"); |
Vadim Yanitskiy | 8a87f91 | 2020-02-17 01:19:10 +0700 | [diff] [blame] | 540 | |
| 541 | log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); |
| 542 | log_set_print_category_hex(osmo_stderr_target, 0); |
| 543 | log_set_print_category(osmo_stderr_target, 1); |
| 544 | log_set_print_level(osmo_stderr_target, 1); |
| 545 | log_set_use_color(osmo_stderr_target, 0); |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 546 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 547 | //printSizeofRLCMAC(); |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 548 | testRlcMacDownlink(ctx); |
| 549 | testRlcMacUplink(ctx); |
| 550 | testCsnLeftAlignedVarBmpBounds(ctx); |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 551 | testRAcap(ctx); |
Pau Espin Pedrol | 866bece | 2020-03-21 01:20:52 +0100 | [diff] [blame] | 552 | testMalformedRAcap(ctx); |
Pau Espin Pedrol | efad80b | 2020-03-23 14:35:26 +0100 | [diff] [blame] | 553 | testRAcap2(ctx); |
Vadim Yanitskiy | a2d972a | 2020-04-04 03:44:35 +0700 | [diff] [blame] | 554 | |
| 555 | testEGPRSPktChReq(ctx); |
| 556 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 557 | talloc_free(ctx); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 558 | } |