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> |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 27 | #include "csn1.h" |
| 28 | #include "gsm_rlcmac.h" |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 29 | #include "gprs_rlcmac.h" |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 30 | #include "decoding.h" |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 31 | |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 32 | extern "C" { |
| 33 | extern const struct log_info gprs_log_info; |
| 34 | #include "pcu_vty.h" |
| 35 | #include <osmocom/vty/telnet_interface.h> |
| 36 | #include <osmocom/vty/logging.h> |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 37 | #include <osmocom/core/utils.h> |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 38 | #include <osmocom/core/msgb.h> |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 39 | #include <osmocom/core/application.h> |
| 40 | } |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 41 | using namespace std; |
| 42 | |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 43 | void *tall_pcu_ctx; |
| 44 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 45 | void printSizeofRLCMAC() |
| 46 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 47 | printf("*** %s ***\n", __func__); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 48 | cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl; |
| 49 | cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl; |
| 50 | cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl; |
| 51 | cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl; |
| 52 | cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl; |
| 53 | cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl; |
| 54 | cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl; |
| 55 | cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl; |
| 56 | cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl; |
| 57 | cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl; |
| 58 | cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl; |
| 59 | cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl; |
| 60 | cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl; |
| 61 | cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl; |
| 62 | cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl; |
| 63 | |
| 64 | cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl; |
| 65 | 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] | 66 | cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl; |
| 67 | cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 68 | cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl; |
| 69 | cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl; |
| 70 | cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl; |
| 71 | cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl; |
| 72 | cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl; |
| 73 | cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl; |
| 74 | cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl; |
| 75 | cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl; |
| 76 | cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl; |
| 77 | cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl; |
| 78 | cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl; |
| 79 | cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl; |
| 80 | cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl; |
| 81 | cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl; |
| 82 | cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl; |
| 83 | cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl; |
| 84 | cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl; |
| 85 | cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl; |
| 86 | cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl; |
| 87 | cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl; |
| 88 | cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl; |
| 89 | cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl; |
| 90 | cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; |
| 91 | } |
| 92 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 93 | void testRlcMacDownlink(void *test_ctx) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 94 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 95 | printf("*** %s ***\n", __func__); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 96 | |
| 97 | int rc; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 98 | struct bitvec *resultVector = bitvec_alloc(23, test_ctx); |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 99 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 100 | |
| 101 | std::string testData[] = { |
| 102 | "4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment |
Saurabh Sharan | 656eed5 | 2016-03-10 14:15:29 +0530 | [diff] [blame] | 103 | "48282407a6a07422720100032b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 104 | "47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack |
Saurabh Sharan | bacb65b | 2016-03-10 17:24:49 +0530 | [diff] [blame] | 105 | "47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment |
| 106 | "400820001a3904df0680efb3300b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment (EGPRS) |
Saurabh Sharan | 2b09c39 | 2016-03-16 19:17:32 +0530 | [diff] [blame] | 107 | "40284f0000001009810c826f4406809dcecb2b2b2b2b2b", // Packet Uplink Assignment (EGPRS) |
Pau Espin Pedrol | 5cb002f | 2020-01-23 23:45:17 +0100 | [diff] [blame] | 108 | "4024030f2f0000000087b0042b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Ack Nack (EGPRS) |
Vadim Yanitskiy | 9b2f7c4 | 2020-02-11 21:45:19 +0700 | [diff] [blame] | 109 | "4913e00850884013a8048b2b2b2b2b2b2b2b2b2b2b2b2b", // Polling Request (malformed) |
Pau Espin Pedrol | 5cb002f | 2020-01-23 23:45:17 +0100 | [diff] [blame] | 110 | "412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b", // Packet Uplink Ack Nack? |
| 111 | "41942b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // System Info 13? |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | int testDataSize = sizeof(testData)/sizeof(testData[0]); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 115 | |
| 116 | cout << " DOWNLINK " << endl; |
| 117 | for (int i = 0; i < testDataSize; i++) |
| 118 | { |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 119 | cout << "vector1 = " << testData[i] << endl; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 120 | bitvec *vector = bitvec_alloc(23, test_ctx); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 121 | bitvec_unhex(vector, testData[i].c_str()); |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 122 | |
Pau Espin Pedrol | 99c437b | 2020-01-24 12:34:50 +0100 | [diff] [blame] | 123 | RlcMacDownlink_t data; |
| 124 | memset(&data, 0, sizeof(data)); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 125 | cout << "=========Start DECODE===========" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 126 | rc = decode_gsm_rlcmac_downlink(vector, &data); |
| 127 | cout << "+++++++++Finish DECODE ("<< rc <<")++++++++++" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 128 | cout << "=========Start ENCODE=============" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 129 | rc = encode_gsm_rlcmac_downlink(resultVector, &data); |
| 130 | cout << "+++++++++Finish ENCODE ("<< rc <<")+++++++++++" << endl; |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 131 | cout << "vector1 = " << osmo_hexdump(vector->data, 23) << endl; |
| 132 | cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl; |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 133 | if (memcmp(vector->data, resultVector->data, 23) == 0) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 134 | cout << "vector1 == vector2 : TRUE" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 135 | else |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 136 | cout << "vector1 == vector2 : FALSE" << endl; |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 137 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 138 | bitvec_free(vector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 139 | } |
Andreas Eversberg | 273a222 | 2013-01-16 08:56:33 +0100 | [diff] [blame] | 140 | |
| 141 | bitvec_free(resultVector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 145 | void testRlcMacUplink(void *test_ctx) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 146 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 147 | printf("*** %s ***\n", __func__); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 148 | |
| 149 | int rc; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 150 | struct bitvec *resultVector = bitvec_alloc(23, test_ctx); |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 151 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 152 | |
| 153 | std::string testData[] = { |
Saurabh Sharan | 656eed5 | 2016-03-10 14:15:29 +0530 | [diff] [blame] | 154 | "400e1e61d11d2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block |
| 155 | "400b8020000000000000002480e0032b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack |
Saurabh Sharan | bacb65b | 2016-03-10 17:24:49 +0530 | [diff] [blame] | 156 | "4016713dc094270ca2ae57ef909006aa0fc0001f80222b", // Packet Resource Request |
| 157 | "40200ffc0021ec010b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // EPDAN |
Pau Espin Pedrol | 5cb002f | 2020-01-23 23:45:17 +0100 | [diff] [blame] | 158 | "400a9020000000000000003010012a0800132b2b2b2b2b", // Packet Downlink Ack/Nack ? |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | int testDataSize = sizeof(testData)/sizeof(testData[0]); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 162 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 163 | |
| 164 | cout << " UPLINK " << endl; |
| 165 | for (int i = 0; i < testDataSize; i++) |
| 166 | { |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 167 | cout << "vector1 = " << testData[i] << endl; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 168 | bitvec *vector = bitvec_alloc(23, test_ctx); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 169 | bitvec_unhex(vector, testData[i].c_str()); |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 170 | |
Pau Espin Pedrol | 99c437b | 2020-01-24 12:34:50 +0100 | [diff] [blame] | 171 | RlcMacUplink_t data; |
| 172 | memset(&data, 0, sizeof(data)); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 173 | cout << "=========Start DECODE===========" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 174 | rc = decode_gsm_rlcmac_uplink(vector, &data); |
| 175 | cout << "+++++++++Finish DECODE ("<< rc << ")++++++++++" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 176 | cout << "=========Start ENCODE=============" << endl; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 177 | rc = encode_gsm_rlcmac_uplink(resultVector, &data); |
| 178 | cout << "+++++++++Finish ENCODE ("<< rc <<")+++++++++++" << endl; |
Pau Espin Pedrol | 87bfbe4 | 2020-01-23 23:51:34 +0100 | [diff] [blame] | 179 | cout << "vector1 = " << osmo_hexdump(vector->data, 23) << endl; |
| 180 | cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl; |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 181 | if (memcmp(vector->data, resultVector->data, 23) == 0) |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 182 | cout << "vector1 == vector2 : TRUE" << endl; |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 183 | else |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 184 | cout << "vector1 == vector2 : FALSE" << endl; |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 185 | bitvec_unhex(resultVector, DUMMY_VEC); |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 186 | bitvec_free(vector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 187 | } |
Andreas Eversberg | 273a222 | 2013-01-16 08:56:33 +0100 | [diff] [blame] | 188 | |
| 189 | bitvec_free(resultVector); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 190 | } |
| 191 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 192 | void testCsnLeftAlignedVarBmpBounds(void *test_ctx) |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 193 | { |
Pau Espin Pedrol | 54681c3 | 2020-01-23 21:59:23 +0100 | [diff] [blame] | 194 | printf("*** %s ***\n", __func__); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 195 | |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 196 | struct msgb *m = msgb_alloc(80, "test"); |
| 197 | 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] | 198 | bitvec *vector = bitvec_alloc(23, test_ctx); |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 199 | int rc; |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 200 | |
| 201 | bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000"); |
| 202 | RlcMacUplink_t data; |
Pau Espin Pedrol | 99c437b | 2020-01-24 12:34:50 +0100 | [diff] [blame] | 203 | memset(&data, 0, sizeof(data)); |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 204 | |
| 205 | EGPRS_AckNack_Desc_t *urbb = |
| 206 | &data.u.Egprs_Packet_Downlink_Ack_Nack.EGPRS_AckNack.Desc; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 207 | rc = decode_gsm_rlcmac_uplink(vector, &data); |
| 208 | OSMO_ASSERT(rc == 0); |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 209 | |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 210 | memcpy(msgb_put(m, 13), urbb->URBB, 13); |
| 211 | if (!msgb_eq_data_print(m, exp, 13)) |
| 212 | printf("%s failed!\n", __func__); |
| 213 | msgb_free(m); |
Aravind Sirsikar | 9f5f008 | 2016-08-30 13:20:23 +0530 | [diff] [blame] | 214 | } |
| 215 | |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 216 | void testRAcap(void *test_ctx) |
| 217 | { |
| 218 | printf("*** %s ***\n", __func__); |
| 219 | MS_Radio_Access_capability_t data; |
| 220 | memset(&data, 0, sizeof(data)); |
| 221 | bitvec *vector = bitvec_alloc(23, test_ctx); |
| 222 | int rc; |
| 223 | /* |
| 224 | MS RA capability 1 |
| 225 | 0001 .... = Access Technology Type: GSM E --note that GSM E covers GSM P (1) |
| 226 | .... 0010 101. .... = Length in bits: 0x15 (21) |
| 227 | ...0 01.. RF Power Capability, GMSK Power Class: Not specified (1) |
| 228 | A5 Bits: Same values apply for parameters as in the immediately preceding Access capabilities field within this IE (0) |
| 229 | .... ...1 = Controlled early Classmark Sending: Implemented |
| 230 | 0... .... = Pseudo Synchronisation: Not Present |
| 231 | .0.. .... = Voice Group Call Service: no VGCS capability or no notifications wanted |
| 232 | ..0. .... = Voice Broadcast Service: no VBS capability or no notifications wanted |
| 233 | ...1 .... = Multislot capability struct: Present |
| 234 | .... ..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) |
| 235 | ...0 .... = GPRS Extended Dynamic Allocation Capability: Not Implemented |
| 236 | */ |
| 237 | bitvec_unhex(vector, "12a5146200"); |
| 238 | |
| 239 | rc = decode_gsm_ra_cap(vector, &data); |
| 240 | printf("decode_gsm_ra_cap fails? %s\n", rc !=0 ? "yes" : "no"); |
| 241 | #if 0 |
| 242 | /* FIXME: OS#1525, OS#3499: csn1 fails to parse this MS RA Cap IE value */ |
| 243 | assert (rc == 0); |
| 244 | |
| 245 | /* Make sure there's 1 value (currently fails due to failed decoding) */ |
| 246 | osmo_assert(cap->Count_MS_RA_capability_value == 1); |
| 247 | |
| 248 | /* Make sure MS multislot class is parsed correctly (currently fails due |
| 249 | to failed decoding and count being 0) */ |
| 250 | uint8_t ms_class = Decoding::get_ms_class_by_capability(&data); |
| 251 | assert(ms_class == 3); |
| 252 | #endif |
| 253 | } |
| 254 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 255 | int main(int argc, char *argv[]) |
| 256 | { |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 257 | void *ctx = talloc_named_const(NULL, 1, "RLCMACTest"); |
Neels Hofmeyr | 42f2d61 | 2018-04-01 16:54:40 +0200 | [diff] [blame] | 258 | osmo_init_logging2(ctx, &gprs_log_info); |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 259 | log_parse_category_mask(osmo_stderr_target, "DPCU,3:DLGLOBAL,1:"); |
Andreas Eversberg | 138f4e6 | 2013-01-14 12:31:11 +0100 | [diff] [blame] | 260 | |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 261 | //printSizeofRLCMAC(); |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 262 | testRlcMacDownlink(ctx); |
| 263 | testRlcMacUplink(ctx); |
| 264 | testCsnLeftAlignedVarBmpBounds(ctx); |
Pau Espin Pedrol | cdbc5db | 2020-01-23 21:00:19 +0100 | [diff] [blame] | 265 | testRAcap(ctx); |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 266 | talloc_free(ctx); |
Ivan Kluchnikov | 487a141 | 2011-12-21 13:17:53 +0300 | [diff] [blame] | 267 | } |