Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2012 by Holger Hans Peter Freyther |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (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 along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <osmocom/gsm/gsm0808.h> |
Philipp Maier | 2240143 | 2017-03-24 17:59:26 +0100 | [diff] [blame] | 22 | #include <osmocom/gsm/gsm0808_utils.h> |
| 23 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 24 | #include <osmocom/gsm/protocol/gsm_08_58.h> |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 25 | |
| 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
Philipp Maier | 2240143 | 2017-03-24 17:59:26 +0100 | [diff] [blame] | 28 | #include <sys/socket.h> |
| 29 | #include <netinet/in.h> |
| 30 | #include <arpa/inet.h> |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 31 | #include <errno.h> |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 32 | |
| 33 | #define VERIFY(msg, data, len) \ |
| 34 | if (msgb_l3len(msg) != len) { \ |
| 35 | printf("%s:%d Length don't match: %d vs. %d. %s\n", \ |
Holger Hans Peter Freyther | fdb4667 | 2015-11-09 16:32:43 +0000 | [diff] [blame] | 36 | __func__, __LINE__, msgb_l3len(msg), (int) len, \ |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 37 | osmo_hexdump(msg->l3h, msgb_l3len(msg))); \ |
| 38 | abort(); \ |
| 39 | } else if (memcmp(msg->l3h, data, len) != 0) { \ |
| 40 | printf("%s:%d didn't match: got: %s\n", \ |
| 41 | __func__, __LINE__, \ |
| 42 | osmo_hexdump(msg->l3h, msgb_l3len(msg))); \ |
| 43 | abort(); \ |
| 44 | } |
| 45 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 46 | /* Setup a fake codec list for testing */ |
| 47 | static void setup_codec_list(struct gsm0808_speech_codec_list *scl) |
| 48 | { |
| 49 | memset(scl, 0, sizeof(*scl)); |
| 50 | |
| 51 | scl->codec[0].pi = true; |
| 52 | scl->codec[0].tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 53 | scl->codec[0].type = GSM0808_SCT_FR3; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 54 | scl->codec[0].cfg = 0xcdef; |
| 55 | |
| 56 | scl->codec[1].fi = true; |
| 57 | scl->codec[1].pt = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 58 | scl->codec[1].type = GSM0808_SCT_FR2; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 59 | |
| 60 | scl->codec[2].fi = true; |
| 61 | scl->codec[2].tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 62 | scl->codec[2].type = GSM0808_SCT_CSD; |
| 63 | scl->codec[2].cfg = 0xc0; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 64 | |
| 65 | scl->len = 3; |
| 66 | } |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 67 | |
| 68 | static void test_create_layer3(void) |
| 69 | { |
| 70 | static const uint8_t res[] = { |
| 71 | 0x00, 0x0e, 0x57, 0x05, 0x08, 0x00, 0x77, 0x62, |
| 72 | 0x83, 0x33, 0x66, 0x44, 0x88, 0x17, 0x01, 0x23 }; |
| 73 | struct msgb *msg, *in_msg; |
Neels Hofmeyr | 178bf7a | 2018-04-20 12:23:45 +0200 | [diff] [blame] | 74 | struct osmo_cell_global_id cgi = { |
| 75 | .lai = { |
| 76 | .plmn = { |
| 77 | .mcc = 0x2244, |
| 78 | .mnc = 0x1122, |
| 79 | }, |
| 80 | .lac = 0x3366, |
| 81 | }, |
| 82 | .cell_identity = 0x4488, |
| 83 | }; |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 84 | printf("Testing creating Layer3\n"); |
| 85 | |
| 86 | in_msg = msgb_alloc_headroom(512, 128, "foo"); |
| 87 | in_msg->l3h = in_msg->data; |
| 88 | msgb_v_put(in_msg, 0x23); |
| 89 | |
Neels Hofmeyr | 178bf7a | 2018-04-20 12:23:45 +0200 | [diff] [blame] | 90 | msg = gsm0808_create_layer3_2(in_msg, &cgi, NULL); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 91 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 92 | msgb_free(msg); |
| 93 | msgb_free(in_msg); |
| 94 | } |
| 95 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 96 | static void test_create_layer3_aoip() |
| 97 | { |
| 98 | static const uint8_t res[] = { |
| 99 | 0x00, 0x17, 0x57, 0x05, 0x08, 0x00, 0x77, 0x62, |
| 100 | 0x83, 0x33, 0x66, 0x44, 0x88, 0x17, 0x01, 0x23, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 101 | GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 102 | 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 103 | GSM0808_SCT_CSD | 0x90, 0xc0 |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 104 | }; |
Max | fa3b482 | 2018-11-05 14:59:54 +0100 | [diff] [blame] | 105 | struct osmo_cell_global_id cgi = { |
| 106 | .lai = { |
| 107 | .plmn = { |
| 108 | .mcc = 0x2244, |
| 109 | .mnc = 0x1122, |
| 110 | }, |
| 111 | .lac = 0x3366, |
| 112 | }, |
| 113 | .cell_identity = 0x4488, |
| 114 | }; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 115 | struct msgb *msg, *in_msg; |
| 116 | struct gsm0808_speech_codec_list sc_list; |
| 117 | printf("Testing creating Layer3 (AoIP)\n"); |
| 118 | |
| 119 | setup_codec_list(&sc_list); |
| 120 | |
| 121 | in_msg = msgb_alloc_headroom(512, 128, "foo"); |
| 122 | in_msg->l3h = in_msg->data; |
| 123 | msgb_v_put(in_msg, 0x23); |
| 124 | |
Max | fa3b482 | 2018-11-05 14:59:54 +0100 | [diff] [blame] | 125 | msg = gsm0808_create_layer3_2(in_msg, &cgi, &sc_list); |
| 126 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 127 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 128 | |
| 129 | msgb_free(msg); |
| 130 | msgb_free(in_msg); |
| 131 | } |
| 132 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 133 | static void test_create_reset() |
| 134 | { |
| 135 | static const uint8_t res[] = { 0x00, 0x04, 0x30, 0x04, 0x01, 0x20 }; |
| 136 | struct msgb *msg; |
| 137 | |
| 138 | printf("Testing creating Reset\n"); |
| 139 | msg = gsm0808_create_reset(); |
| 140 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 141 | msgb_free(msg); |
| 142 | } |
| 143 | |
Philipp Maier | 15596e2 | 2017-04-05 17:55:27 +0200 | [diff] [blame] | 144 | static void test_create_reset_ack() |
| 145 | { |
| 146 | static const uint8_t res[] = { 0x00, 0x01, 0x31 }; |
| 147 | struct msgb *msg; |
| 148 | |
| 149 | printf("Testing creating Reset Ack\n"); |
| 150 | msg = gsm0808_create_reset_ack(); |
| 151 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 152 | msgb_free(msg); |
| 153 | } |
| 154 | |
| 155 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 156 | static void test_create_clear_command() |
| 157 | { |
| 158 | static const uint8_t res[] = { 0x20, 0x04, 0x01, 0x23 }; |
| 159 | struct msgb *msg; |
| 160 | |
| 161 | printf("Testing creating Clear Command\n"); |
| 162 | msg = gsm0808_create_clear_command(0x23); |
| 163 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 164 | msgb_free(msg); |
| 165 | } |
| 166 | |
| 167 | static void test_create_clear_complete() |
| 168 | { |
| 169 | static const uint8_t res[] = { 0x00, 0x01, 0x21 }; |
| 170 | struct msgb *msg; |
| 171 | |
| 172 | printf("Testing creating Clear Complete\n"); |
| 173 | msg = gsm0808_create_clear_complete(); |
| 174 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 175 | msgb_free(msg); |
| 176 | } |
| 177 | |
Philipp Maier | b478dd3 | 2017-03-29 15:50:05 +0200 | [diff] [blame] | 178 | static void test_create_cipher() |
| 179 | { |
| 180 | static const uint8_t res[] = |
| 181 | { 0x00, 0x0c, 0x53, 0x0a, 0x09, 0x03, 0xaa, |
| 182 | 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42 }; |
| 183 | static const uint8_t res2[] = |
| 184 | { 0x00, 0x0e, 0x53, 0x0a, 0x09, 0x03, 0xaa, |
| 185 | 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42, |
| 186 | GSM0808_IE_CIPHER_RESPONSE_MODE, 0x01 }; |
| 187 | struct msgb *msg; |
| 188 | struct gsm0808_encrypt_info ei; |
| 189 | uint8_t include_imeisv; |
| 190 | |
| 191 | memset(&ei, 0, sizeof(ei)); |
| 192 | ei.perm_algo[0] = GSM0808_ALG_ID_A5_0; |
| 193 | ei.perm_algo[1] = GSM0808_ALG_ID_A5_1; |
| 194 | ei.perm_algo_len = 2; |
| 195 | ei.key[0] = 0xaa; |
| 196 | ei.key[1] = 0xbb; |
| 197 | ei.key[2] = 0xcc; |
| 198 | ei.key[3] = 0xdd; |
| 199 | ei.key[4] = 0xee; |
| 200 | ei.key[5] = 0xff; |
| 201 | ei.key[6] = 0x23; |
| 202 | ei.key[7] = 0x42; |
| 203 | ei.key_len = 8; |
| 204 | include_imeisv = 1; |
| 205 | |
| 206 | printf("Testing creating Chipher Mode Command\n"); |
| 207 | msg = gsm0808_create_cipher(&ei, NULL); |
| 208 | OSMO_ASSERT(msg); |
| 209 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 210 | msgb_free(msg); |
| 211 | |
| 212 | msg = gsm0808_create_cipher(&ei, &include_imeisv); |
| 213 | OSMO_ASSERT(msg); |
| 214 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 215 | msgb_free(msg); |
| 216 | } |
| 217 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 218 | static void test_create_cipher_complete() |
| 219 | { |
| 220 | static const uint8_t res1[] = { |
| 221 | 0x00, 0x08, 0x55, 0x20, 0x03, 0x23, 0x42, 0x21, 0x2c, 0x04 }; |
| 222 | static const uint8_t res2[] = { 0x00, 0x03, 0x55, 0x2c, 0x04}; |
| 223 | struct msgb *l3, *msg; |
| 224 | |
| 225 | printf("Testing creating Cipher Complete\n"); |
| 226 | l3 = msgb_alloc_headroom(512, 128, "l3h"); |
| 227 | l3->l3h = l3->data; |
| 228 | msgb_v_put(l3, 0x23); |
| 229 | msgb_v_put(l3, 0x42); |
| 230 | msgb_v_put(l3, 0x21); |
| 231 | |
| 232 | /* with l3 data */ |
| 233 | msg = gsm0808_create_cipher_complete(l3, 4); |
| 234 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 235 | msgb_free(msg); |
| 236 | |
| 237 | /* with l3 data but short */ |
| 238 | l3->len -= 1; |
| 239 | l3->tail -= 1; |
| 240 | msg = gsm0808_create_cipher_complete(l3, 4); |
| 241 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 242 | msgb_free(msg); |
| 243 | |
| 244 | /* without l3 data */ |
| 245 | msg = gsm0808_create_cipher_complete(NULL, 4); |
| 246 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 247 | msgb_free(msg); |
| 248 | |
| 249 | |
| 250 | msgb_free(l3); |
| 251 | } |
| 252 | |
Max | ed651d2 | 2018-11-07 15:25:05 +0100 | [diff] [blame^] | 253 | static inline void parse_cipher_reject(struct msgb *msg, uint8_t exp) |
| 254 | { |
| 255 | struct tlv_parsed tp; |
| 256 | int rc; |
| 257 | |
| 258 | /* skip header and message type so we can parse Cause IE directly */ |
| 259 | msg->l2h = msgb_data(msg) + sizeof(struct bssmap_header) + 1; |
| 260 | |
| 261 | rc = osmo_bssap_tlv_parse(&tp, msg->l2h, msgb_l2len(msg)); |
| 262 | if (rc < 0) |
| 263 | printf("FIXME: failed (%d) to parse created message %s\n", rc, msgb_hexdump(msg)); |
| 264 | |
| 265 | rc = gsm0808_get_cipher_reject_cause(&tp); |
| 266 | if (rc < 0) |
| 267 | printf("FIXME: failed (%s) to extract Cause from created message %s\n", |
| 268 | strerror(-rc), msgb_hexdump(msg)); |
| 269 | |
| 270 | if (exp != (enum gsm0808_cause)rc) |
| 271 | printf("FIXME: wrong Cause %d != %u (" OSMO_BIN_SPEC ") extracted from created message %s\n", |
| 272 | rc, exp, OSMO_BIT_PRINT(exp), msgb_hexdump(msg)); |
| 273 | } |
| 274 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 275 | static void test_create_cipher_reject() |
| 276 | { |
Harald Welte | 62e4085 | 2017-12-17 20:50:34 +0100 | [diff] [blame] | 277 | static const uint8_t res[] = { 0x00, 0x04, 0x59, 0x04, 0x01, 0x23 }; |
Max | ed651d2 | 2018-11-07 15:25:05 +0100 | [diff] [blame^] | 278 | enum gsm0808_cause cause = GSM0808_CAUSE_CCCH_OVERLOAD; |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 279 | struct msgb *msg; |
| 280 | |
| 281 | printf("Testing creating Cipher Reject\n"); |
Max | ed651d2 | 2018-11-07 15:25:05 +0100 | [diff] [blame^] | 282 | msg = gsm0808_create_cipher_reject(cause); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 283 | VERIFY(msg, res, ARRAY_SIZE(res)); |
Max | ed651d2 | 2018-11-07 15:25:05 +0100 | [diff] [blame^] | 284 | |
| 285 | parse_cipher_reject(msg, cause); |
| 286 | |
| 287 | msgb_free(msg); |
| 288 | } |
| 289 | |
| 290 | static void test_create_cipher_reject_ext() |
| 291 | { |
| 292 | static const uint8_t res[] = { 0x00, 0x05, 0x59, 0x04, 0x02, 0xd0, 0xFA }; |
| 293 | uint8_t cause = 0xFA; |
| 294 | struct msgb *msg; |
| 295 | |
| 296 | printf("Testing creating Cipher Reject (extended)\n"); |
| 297 | msg = gsm0808_create_cipher_reject_ext(GSM0808_CAUSE_CLASS_INVAL, cause); |
| 298 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 299 | |
| 300 | parse_cipher_reject(msg, cause); |
| 301 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 302 | msgb_free(msg); |
| 303 | } |
| 304 | |
| 305 | static void test_create_cm_u() |
| 306 | { |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 307 | static const uint8_t res[] = { |
| 308 | 0x00, 0x07, 0x54, 0x12, 0x01, 0x23, 0x13, 0x01, 0x42 }; |
| 309 | static const uint8_t res2o[] = { |
| 310 | 0x00, 0x04, 0x54, 0x12, 0x01, 0x23 }; |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 311 | struct msgb *msg; |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 312 | const uint8_t cm2 = 0x23; |
| 313 | const uint8_t cm3 = 0x42; |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 314 | |
| 315 | printf("Testing creating CM U\n"); |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 316 | msg = gsm0808_create_classmark_update(&cm2, 1, &cm3, 1); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 317 | VERIFY(msg, res, ARRAY_SIZE(res)); |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 318 | |
Neels Hofmeyr | 9a938ae | 2017-11-16 17:34:07 +0100 | [diff] [blame] | 319 | msgb_free(msg); |
| 320 | |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 321 | msg = gsm0808_create_classmark_update(&cm2, 1, NULL, 0); |
| 322 | VERIFY(msg, res2o, ARRAY_SIZE(res2o)); |
| 323 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 324 | msgb_free(msg); |
| 325 | } |
| 326 | |
| 327 | static void test_create_sapi_reject() |
| 328 | { |
| 329 | static const uint8_t res[] = { 0x00, 0x03, 0x25, 0x03, 0x25 }; |
| 330 | struct msgb *msg; |
| 331 | |
| 332 | printf("Testing creating SAPI Reject\n"); |
| 333 | msg = gsm0808_create_sapi_reject(3); |
| 334 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 335 | msgb_free(msg); |
| 336 | } |
| 337 | |
Philipp Maier | c6144a2 | 2017-03-29 17:53:43 +0200 | [diff] [blame] | 338 | static void test_create_ass() |
| 339 | { |
| 340 | static const uint8_t res1[] = |
| 341 | { 0x00, 0x0a, 0x01, 0x0b, 0x04, 0x01, 0x0b, 0xa1, 0x25, 0x01, 0x00, |
| 342 | 0x04 }; |
| 343 | static const uint8_t res2[] = |
| 344 | { 0x00, 0x20, 0x01, 0x0b, 0x04, 0x01, 0x0b, 0xa1, 0x25, 0x01, 0x00, |
| 345 | 0x04, GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 346 | 0x04, 0xd2, GSM0808_IE_SPEECH_CODEC_LIST, 0x07, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 347 | GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 348 | GSM0808_SCT_CSD | 0x90, 0xc0, GSM0808_IE_CALL_ID, 0xaa, 0xbb, |
| 349 | 0xcc, 0xdd }; |
Philipp Maier | c6144a2 | 2017-03-29 17:53:43 +0200 | [diff] [blame] | 350 | |
| 351 | struct msgb *msg; |
| 352 | struct gsm0808_channel_type ct; |
| 353 | uint16_t cic = 0004; |
| 354 | struct sockaddr_storage ss; |
| 355 | struct sockaddr_in sin; |
| 356 | struct gsm0808_speech_codec_list sc_list; |
| 357 | uint32_t call_id = 0xAABBCCDD; |
| 358 | |
| 359 | memset(&ct, 0, sizeof(ct)); |
| 360 | ct.ch_indctr = GSM0808_CHAN_SPEECH; |
| 361 | ct.ch_rate_type = GSM0808_SPEECH_HALF_PREF; |
| 362 | ct.perm_spch[0] = GSM0808_PERM_FR3; |
| 363 | ct.perm_spch[1] = GSM0808_PERM_HR3; |
| 364 | ct.perm_spch_len = 2; |
| 365 | |
| 366 | memset(&sin, 0, sizeof(sin)); |
| 367 | sin.sin_family = AF_INET; |
| 368 | sin.sin_port = htons(1234); |
| 369 | inet_aton("192.168.100.23", &sin.sin_addr); |
| 370 | |
| 371 | memset(&ss, 0, sizeof(ss)); |
| 372 | memcpy(&ss, &sin, sizeof(sin)); |
| 373 | |
| 374 | setup_codec_list(&sc_list); |
| 375 | |
| 376 | printf("Testing creating Assignment Request\n"); |
| 377 | msg = gsm0808_create_ass(&ct, &cic, NULL, NULL, NULL); |
| 378 | OSMO_ASSERT(msg); |
| 379 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 380 | msgb_free(msg); |
| 381 | |
| 382 | msg = gsm0808_create_ass(&ct, &cic, &ss, &sc_list, &call_id); |
| 383 | OSMO_ASSERT(msg); |
| 384 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 385 | msgb_free(msg); |
| 386 | } |
| 387 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 388 | static void test_create_ass_compl() |
| 389 | { |
| 390 | static const uint8_t res1[] = { |
| 391 | 0x00, 0x09, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, |
| 392 | 0x11, 0x40, 0x22 }; |
| 393 | static const uint8_t res2[] = { |
| 394 | 0x00, 0x07, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, 0x11}; |
| 395 | struct msgb *msg; |
| 396 | |
| 397 | printf("Testing creating Assignment Complete\n"); |
| 398 | msg = gsm0808_create_assignment_completed(0x23, 0x42, 0x11, 0x22); |
| 399 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 400 | msgb_free(msg); |
| 401 | |
| 402 | msg = gsm0808_create_assignment_completed(0x23, 0x42, 0x11, 0); |
| 403 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 404 | msgb_free(msg); |
| 405 | } |
| 406 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 407 | static void test_create_ass_compl_aoip() |
| 408 | { |
| 409 | struct sockaddr_storage ss; |
| 410 | struct sockaddr_in sin; |
| 411 | struct gsm0808_speech_codec sc; |
| 412 | struct gsm0808_speech_codec_list sc_list; |
| 413 | static const uint8_t res[] = |
| 414 | { 0x00, 0x1d, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, 0x11, 0x40, 0x22, |
| 415 | GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17, 0x04, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 416 | 0xd2, GSM0808_IE_SPEECH_CODEC, 0x01, GSM0808_SCT_HR1 | 0x90, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 417 | GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef, |
| 418 | 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 }; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 419 | struct msgb *msg; |
| 420 | |
| 421 | memset(&sin, 0, sizeof(sin)); |
| 422 | sin.sin_family = AF_INET; |
| 423 | sin.sin_port = htons(1234); |
| 424 | inet_aton("192.168.100.23", &sin.sin_addr); |
| 425 | |
| 426 | memset(&ss, 0, sizeof(ss)); |
| 427 | memcpy(&ss, &sin, sizeof(sin)); |
| 428 | |
| 429 | memset(&sc, 0, sizeof(sc)); |
| 430 | sc.fi = true; |
| 431 | sc.tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 432 | sc.type = GSM0808_SCT_HR1; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 433 | |
| 434 | setup_codec_list(&sc_list); |
| 435 | |
| 436 | printf("Testing creating Assignment Complete (AoIP)\n"); |
| 437 | msg = gsm0808_create_ass_compl(0x23, 0x42, 0x11, 0x22, |
| 438 | &ss, &sc, &sc_list); |
| 439 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 440 | msgb_free(msg); |
| 441 | } |
| 442 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 443 | static void test_create_ass_fail() |
| 444 | { |
| 445 | static const uint8_t res1[] = { 0x00, 0x04, 0x03, 0x04, 0x01, 0x23 }; |
| 446 | static const uint8_t res2[] = { |
| 447 | 0x00, 0x06, 0x03, 0x04, 0x01, 0x23, 0x15, 0x02}; |
| 448 | uint8_t rr_res = 2; |
| 449 | struct msgb *msg; |
| 450 | |
| 451 | printf("Testing creating Assignment Failure\n"); |
| 452 | msg = gsm0808_create_assignment_failure(0x23, NULL); |
| 453 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 454 | msgb_free(msg); |
| 455 | |
| 456 | msg = gsm0808_create_assignment_failure(0x23, &rr_res); |
| 457 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 458 | msgb_free(msg); |
| 459 | } |
| 460 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 461 | static void test_create_ass_fail_aoip() |
| 462 | { |
| 463 | static const uint8_t res1[] = |
| 464 | { 0x00, 0x0d, 0x03, 0x04, 0x01, 0x23, GSM0808_IE_SPEECH_CODEC_LIST, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 465 | 0x07, GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 466 | 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 }; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 467 | static const uint8_t res2[] = |
| 468 | { 0x00, 0x0f, 0x03, 0x04, 0x01, 0x23, 0x15, 0x02, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 469 | GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef, |
| 470 | 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 }; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 471 | uint8_t rr_res = 2; |
| 472 | struct msgb *msg; |
| 473 | struct gsm0808_speech_codec_list sc_list; |
| 474 | |
| 475 | setup_codec_list(&sc_list); |
| 476 | |
| 477 | printf("Testing creating Assignment Failure (AoIP)\n"); |
| 478 | msg = gsm0808_create_ass_fail(0x23, NULL, &sc_list); |
| 479 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 480 | msgb_free(msg); |
| 481 | |
| 482 | msg = gsm0808_create_ass_fail(0x23, &rr_res, &sc_list); |
| 483 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 484 | msgb_free(msg); |
| 485 | } |
| 486 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 487 | static void test_create_clear_rqst() |
| 488 | { |
| 489 | static const uint8_t res[] = { 0x00, 0x04, 0x22, 0x04, 0x01, 0x23 }; |
| 490 | struct msgb *msg; |
| 491 | |
| 492 | printf("Testing creating Clear Request\n"); |
| 493 | msg = gsm0808_create_clear_rqst(0x23); |
| 494 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 495 | msgb_free(msg); |
| 496 | } |
| 497 | |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 498 | static void test_create_paging() |
| 499 | { |
| 500 | static const uint8_t res[] = |
| 501 | { 0x00, 0x10, 0x52, 0x08, 0x08, 0x09, 0x10, 0x10, 0x00, 0x00, 0x00, |
| 502 | 0x21, 0x43, 0x1a, 0x03, 0x05, 0x23, 0x42 }; |
| 503 | static const uint8_t res2[] = |
| 504 | { 0x00, 0x16, 0x52, 0x08, 0x08, 0x09, 0x10, 0x10, 0x00, 0x00, 0x00, |
| 505 | 0x21, 0x43, GSM0808_IE_TMSI, 0x04, 0x12, 0x34, 0x56, 0x78, 0x1a, |
| 506 | 0x03, 0x05, 0x23, 0x42 }; |
| 507 | static const uint8_t res3[] = |
| 508 | { 0x00, 0x18, 0x52, 0x08, 0x08, 0x09, 0x10, 0x10, 0x00, 0x00, 0x00, |
| 509 | 0x21, 0x43, GSM0808_IE_TMSI, 0x04, 0x12, 0x34, 0x56, 0x78, 0x1a, |
| 510 | 0x03, 0x05, 0x23, 0x42, GSM0808_IE_CHANNEL_NEEDED, |
| 511 | RSL_CHANNEED_TCH_ForH }; |
| 512 | |
| 513 | struct msgb *msg; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 514 | struct gsm0808_cell_id_list2 cil; |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 515 | uint32_t tmsi = 0x12345678; |
| 516 | uint8_t chan_needed = RSL_CHANNEED_TCH_ForH; |
| 517 | |
| 518 | char imsi[] = "001010000001234"; |
| 519 | |
| 520 | cil.id_discr = CELL_IDENT_LAC; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 521 | cil.id_list[0].lac = 0x2342; |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 522 | cil.id_list_len = 1; |
| 523 | |
| 524 | printf("Testing creating Paging Request\n"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 525 | msg = gsm0808_create_paging2(imsi, NULL, &cil, NULL); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 526 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 527 | msgb_free(msg); |
| 528 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 529 | msg = gsm0808_create_paging2(imsi, &tmsi, &cil, NULL); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 530 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 531 | msgb_free(msg); |
| 532 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 533 | msg = gsm0808_create_paging2(imsi, &tmsi, &cil, &chan_needed); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 534 | VERIFY(msg, res3, ARRAY_SIZE(res3)); |
| 535 | msgb_free(msg); |
| 536 | } |
| 537 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 538 | static void test_create_dtap() |
| 539 | { |
| 540 | static const uint8_t res[] = { 0x01, 0x03, 0x02, 0x23, 0x42 }; |
| 541 | struct msgb *msg, *l3; |
| 542 | |
| 543 | printf("Testing creating DTAP\n"); |
| 544 | l3 = msgb_alloc_headroom(512, 128, "test"); |
| 545 | l3->l3h = l3->data; |
| 546 | msgb_v_put(l3, 0x23); |
| 547 | msgb_v_put(l3, 0x42); |
| 548 | |
| 549 | msg = gsm0808_create_dtap(l3, 0x3); |
| 550 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 551 | msgb_free(msg); |
| 552 | msgb_free(l3); |
| 553 | } |
| 554 | |
| 555 | static void test_prepend_dtap() |
| 556 | { |
| 557 | static const uint8_t res[] = { 0x01, 0x03, 0x02, 0x23, 0x42 }; |
| 558 | struct msgb *in_msg; |
| 559 | |
| 560 | printf("Testing prepend DTAP\n"); |
| 561 | |
| 562 | in_msg = msgb_alloc_headroom(512, 128, "test"); |
| 563 | msgb_v_put(in_msg, 0x23); |
| 564 | msgb_v_put(in_msg, 0x42); |
| 565 | |
| 566 | gsm0808_prepend_dtap_header(in_msg, 0x3); |
| 567 | in_msg->l3h = in_msg->data; |
| 568 | VERIFY(in_msg, res, ARRAY_SIZE(res)); |
| 569 | msgb_free(in_msg); |
| 570 | } |
| 571 | |
Philipp Maier | 2240143 | 2017-03-24 17:59:26 +0100 | [diff] [blame] | 572 | static void test_enc_dec_aoip_trasp_addr_v4() |
| 573 | { |
| 574 | struct sockaddr_storage enc_addr; |
| 575 | struct sockaddr_storage dec_addr; |
| 576 | struct sockaddr_in enc_addr_in; |
| 577 | struct msgb *msg; |
| 578 | uint8_t rc_enc; |
| 579 | int rc_dec; |
| 580 | |
| 581 | memset(&enc_addr_in, 0, sizeof(enc_addr_in)); |
| 582 | enc_addr_in.sin_family = AF_INET; |
| 583 | enc_addr_in.sin_port = htons(1234); |
| 584 | inet_aton("255.0.255.255", &enc_addr_in.sin_addr); |
| 585 | |
| 586 | memset(&enc_addr, 0, sizeof(enc_addr)); |
| 587 | memcpy(&enc_addr, &enc_addr_in, sizeof(enc_addr_in)); |
| 588 | |
| 589 | msg = msgb_alloc(1024, "output buffer"); |
| 590 | rc_enc = gsm0808_enc_aoip_trasp_addr(msg, &enc_addr); |
| 591 | OSMO_ASSERT(rc_enc == 8); |
| 592 | rc_dec = |
| 593 | gsm0808_dec_aoip_trasp_addr(&dec_addr, msg->data + 2, msg->len - 2); |
| 594 | OSMO_ASSERT(rc_dec == 6); |
| 595 | OSMO_ASSERT(memcmp(&enc_addr, &dec_addr, sizeof(enc_addr)) == 0); |
| 596 | |
| 597 | msgb_free(msg); |
| 598 | } |
| 599 | |
| 600 | static void test_enc_dec_aoip_trasp_addr_v6() |
| 601 | { |
| 602 | struct sockaddr_storage enc_addr; |
| 603 | struct sockaddr_storage dec_addr; |
| 604 | struct sockaddr_in6 enc_addr_in; |
| 605 | struct msgb *msg; |
| 606 | uint8_t rc_enc; |
| 607 | int rc_dec; |
| 608 | |
| 609 | memset(&enc_addr_in, 0, sizeof(enc_addr_in)); |
| 610 | enc_addr_in.sin6_family = AF_INET6; |
| 611 | enc_addr_in.sin6_port = htons(4567); |
| 612 | inet_pton(AF_INET6, "2001:0db8:85a3:08d3:1319:8a2e:0370:7344", |
| 613 | &enc_addr_in.sin6_addr); |
| 614 | |
| 615 | memset(&enc_addr, 0, sizeof(enc_addr)); |
| 616 | memcpy(&enc_addr, &enc_addr_in, sizeof(enc_addr_in)); |
| 617 | |
| 618 | msg = msgb_alloc(1024, "output buffer"); |
| 619 | rc_enc = gsm0808_enc_aoip_trasp_addr(msg, &enc_addr); |
| 620 | OSMO_ASSERT(rc_enc == 20); |
| 621 | rc_dec = |
| 622 | gsm0808_dec_aoip_trasp_addr(&dec_addr, msg->data + 2, msg->len - 2); |
| 623 | OSMO_ASSERT(rc_dec == 18); |
| 624 | OSMO_ASSERT(memcmp(&enc_addr, &dec_addr, sizeof(enc_addr)) == 0); |
| 625 | |
| 626 | msgb_free(msg); |
| 627 | } |
| 628 | |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 629 | static void test_gsm0808_enc_dec_speech_codec() |
| 630 | { |
Neels Hofmeyr | 9a4286b | 2018-04-20 12:27:52 +0200 | [diff] [blame] | 631 | struct gsm0808_speech_codec enc_sc = { |
| 632 | .pi = true, |
| 633 | .tf = true, |
| 634 | .type = GSM0808_SCT_FR2, |
| 635 | }; |
| 636 | struct gsm0808_speech_codec dec_sc = {}; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 637 | struct msgb *msg; |
| 638 | uint8_t rc_enc; |
| 639 | int rc_dec; |
| 640 | |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 641 | msg = msgb_alloc(1024, "output buffer"); |
| 642 | rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc); |
| 643 | OSMO_ASSERT(rc_enc == 3); |
| 644 | |
| 645 | rc_dec = gsm0808_dec_speech_codec(&dec_sc, msg->data + 2, msg->len - 2); |
| 646 | OSMO_ASSERT(rc_dec == 1); |
| 647 | |
| 648 | OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0); |
| 649 | |
| 650 | msgb_free(msg); |
| 651 | } |
| 652 | |
| 653 | |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 654 | static void test_gsm0808_enc_dec_speech_codec_with_cfg() |
| 655 | { |
Neels Hofmeyr | c62c934 | 2018-04-15 23:31:47 +0200 | [diff] [blame] | 656 | struct gsm0808_speech_codec enc_sc = { |
| 657 | .pi = true, |
| 658 | .tf = true, |
| 659 | .type = GSM0808_SCT_FR3, |
| 660 | .cfg = 0xabcd, |
| 661 | }; |
| 662 | struct gsm0808_speech_codec dec_sc = {}; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 663 | struct msgb *msg; |
| 664 | uint8_t rc_enc; |
| 665 | int rc_dec; |
| 666 | |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 667 | msg = msgb_alloc(1024, "output buffer"); |
| 668 | rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc); |
| 669 | OSMO_ASSERT(rc_enc == 5); |
| 670 | |
| 671 | rc_dec = gsm0808_dec_speech_codec(&dec_sc, msg->data + 2, msg->len - 2); |
| 672 | OSMO_ASSERT(rc_dec == 3); |
| 673 | |
| 674 | OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0); |
| 675 | |
| 676 | msgb_free(msg); |
| 677 | } |
| 678 | |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 679 | static void test_gsm0808_enc_dec_speech_codec_ext_with_cfg() |
| 680 | { |
Neels Hofmeyr | 9a4286b | 2018-04-20 12:27:52 +0200 | [diff] [blame] | 681 | struct gsm0808_speech_codec enc_sc = { |
| 682 | .pi = true, |
| 683 | .tf = true, |
| 684 | .type = GSM0808_SCT_CSD, |
| 685 | .cfg = 0xc0, |
| 686 | }; |
| 687 | struct gsm0808_speech_codec dec_sc = {}; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 688 | struct msgb *msg; |
| 689 | uint8_t rc_enc; |
| 690 | int rc_dec; |
| 691 | |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 692 | msg = msgb_alloc(1024, "output buffer"); |
| 693 | rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc); |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 694 | OSMO_ASSERT(rc_enc == 5); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 695 | |
| 696 | rc_dec = gsm0808_dec_speech_codec(&dec_sc, msg->data + 2, msg->len - 2); |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 697 | OSMO_ASSERT(rc_dec == 3); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 698 | |
| 699 | OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0); |
| 700 | |
| 701 | msgb_free(msg); |
| 702 | } |
| 703 | |
| 704 | static void test_gsm0808_enc_dec_speech_codec_list() |
| 705 | { |
Neels Hofmeyr | 9a4286b | 2018-04-20 12:27:52 +0200 | [diff] [blame] | 706 | struct gsm0808_speech_codec_list enc_scl = { |
| 707 | .codec = { |
| 708 | { |
| 709 | .pi = true, |
| 710 | .tf = true, |
| 711 | .type = GSM0808_SCT_FR3, |
| 712 | .cfg = 0xcdef, |
| 713 | }, |
| 714 | |
| 715 | { |
| 716 | .fi = true, |
| 717 | .pt = true, |
| 718 | .type = GSM0808_SCT_FR2, |
| 719 | }, |
| 720 | |
| 721 | { |
| 722 | .fi = true, |
| 723 | .tf = true, |
| 724 | .type = GSM0808_SCT_CSD, |
| 725 | .cfg = 0xc0, |
| 726 | }, |
| 727 | }, |
| 728 | .len = 3, |
| 729 | }; |
| 730 | struct gsm0808_speech_codec_list dec_scl = {}; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 731 | struct msgb *msg; |
| 732 | uint8_t rc_enc; |
| 733 | int rc_dec; |
| 734 | |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 735 | msg = msgb_alloc(1024, "output buffer"); |
| 736 | rc_enc = gsm0808_enc_speech_codec_list(msg, &enc_scl); |
| 737 | OSMO_ASSERT(rc_enc == 9); |
| 738 | |
| 739 | rc_dec = gsm0808_dec_speech_codec_list(&dec_scl, msg->data + 2, msg->len - 2); |
| 740 | OSMO_ASSERT(rc_dec == 7); |
| 741 | |
| 742 | OSMO_ASSERT(memcmp(&enc_scl, &dec_scl, sizeof(enc_scl)) == 0); |
| 743 | |
| 744 | msgb_free(msg); |
| 745 | } |
| 746 | |
Philipp Maier | f6c369f | 2018-10-16 15:24:47 +0200 | [diff] [blame] | 747 | static void test_gsm0808_enc_dec_empty_speech_codec_list() |
| 748 | { |
| 749 | struct gsm0808_speech_codec_list enc_scl = { |
| 750 | .len = 0, |
| 751 | }; |
| 752 | struct gsm0808_speech_codec_list dec_scl = {}; |
| 753 | struct msgb *msg; |
| 754 | uint8_t rc_enc; |
| 755 | int rc_dec; |
| 756 | |
| 757 | msg = msgb_alloc(1024, "output buffer"); |
| 758 | rc_enc = gsm0808_enc_speech_codec_list(msg, &enc_scl); |
| 759 | OSMO_ASSERT(rc_enc == 2); |
| 760 | |
| 761 | rc_dec = gsm0808_dec_speech_codec_list(&dec_scl, msg->data + 2, msg->len - 2); |
| 762 | OSMO_ASSERT(rc_dec == 0); |
| 763 | |
| 764 | OSMO_ASSERT(memcmp(&enc_scl, &dec_scl, sizeof(enc_scl)) == 0); |
| 765 | |
| 766 | msgb_free(msg); |
| 767 | } |
| 768 | |
Philipp Maier | e0c6530 | 2017-03-28 17:05:40 +0200 | [diff] [blame] | 769 | static void test_gsm0808_enc_dec_channel_type() |
| 770 | { |
Neels Hofmeyr | 9a4286b | 2018-04-20 12:27:52 +0200 | [diff] [blame] | 771 | struct gsm0808_channel_type enc_ct = { |
| 772 | .ch_indctr = GSM0808_CHAN_SPEECH, |
| 773 | .ch_rate_type = GSM0808_SPEECH_HALF_PREF, |
| 774 | .perm_spch = { GSM0808_PERM_FR3, GSM0808_PERM_HR3 }, |
| 775 | .perm_spch_len = 2, |
| 776 | }; |
| 777 | struct gsm0808_channel_type dec_ct = {}; |
Philipp Maier | e0c6530 | 2017-03-28 17:05:40 +0200 | [diff] [blame] | 778 | struct msgb *msg; |
| 779 | uint8_t ct_enc_expected[] = { GSM0808_IE_CHANNEL_TYPE, |
| 780 | 0x04, 0x01, 0x0b, 0xa1, 0x25 |
| 781 | }; |
| 782 | uint8_t rc_enc; |
| 783 | int rc_dec; |
| 784 | |
Philipp Maier | e0c6530 | 2017-03-28 17:05:40 +0200 | [diff] [blame] | 785 | msg = msgb_alloc(1024, "output buffer"); |
| 786 | rc_enc = gsm0808_enc_channel_type(msg, &enc_ct); |
| 787 | OSMO_ASSERT(rc_enc == 6); |
| 788 | OSMO_ASSERT(memcmp(ct_enc_expected, msg->data, msg->len) == 0); |
| 789 | |
| 790 | rc_dec = gsm0808_dec_channel_type(&dec_ct, msg->data + 2, msg->len - 2); |
| 791 | OSMO_ASSERT(rc_dec == 4); |
| 792 | OSMO_ASSERT(memcmp(&enc_ct, &dec_ct, sizeof(enc_ct)) == 0); |
| 793 | |
| 794 | msgb_free(msg); |
| 795 | } |
| 796 | |
Philipp Maier | 14e76b9 | 2017-03-28 18:36:52 +0200 | [diff] [blame] | 797 | static void test_gsm0808_enc_dec_encrypt_info() |
| 798 | { |
Neels Hofmeyr | 9a4286b | 2018-04-20 12:27:52 +0200 | [diff] [blame] | 799 | struct gsm0808_encrypt_info enc_ei = { |
| 800 | .perm_algo = { GSM0808_ALG_ID_A5_0, GSM0808_ALG_ID_A5_1 }, |
| 801 | .perm_algo_len = 2, |
| 802 | .key = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42, }, |
| 803 | .key_len = 8, |
| 804 | }; |
| 805 | struct gsm0808_encrypt_info dec_ei = {}; |
Philipp Maier | 14e76b9 | 2017-03-28 18:36:52 +0200 | [diff] [blame] | 806 | struct msgb *msg; |
| 807 | uint8_t ei_enc_expected[] = |
| 808 | { GSM0808_IE_ENCRYPTION_INFORMATION, 0x09, 0x03, 0xaa, 0xbb, |
| 809 | 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42 |
| 810 | }; |
| 811 | uint8_t rc_enc; |
| 812 | int rc_dec; |
| 813 | |
Philipp Maier | 14e76b9 | 2017-03-28 18:36:52 +0200 | [diff] [blame] | 814 | msg = msgb_alloc(1024, "output buffer"); |
| 815 | rc_enc = gsm0808_enc_encrypt_info(msg, &enc_ei); |
| 816 | OSMO_ASSERT(rc_enc == 11); |
| 817 | OSMO_ASSERT(memcmp(ei_enc_expected, msg->data, msg->len) == 0); |
| 818 | |
| 819 | rc_dec = gsm0808_dec_encrypt_info(&dec_ei, msg->data + 2, msg->len - 2); |
| 820 | OSMO_ASSERT(rc_dec == 9); |
| 821 | |
| 822 | OSMO_ASSERT(memcmp(&enc_ei, &dec_ei, sizeof(enc_ei)) == 0); |
| 823 | |
| 824 | msgb_free(msg); |
| 825 | } |
| 826 | |
Neels Hofmeyr | 066473f | 2018-04-13 04:10:58 +0200 | [diff] [blame] | 827 | #define EXPECT_ENCODED(hexstr) do { \ |
| 828 | const char *enc_str = msgb_hexdump(msg); \ |
| 829 | printf("%s: encoded: %s(rc = %u)\n", __func__, enc_str, rc_enc); \ |
| 830 | OSMO_ASSERT(strcmp(enc_str, hexstr " ") == 0); \ |
| 831 | OSMO_ASSERT(rc_enc == msg->len); \ |
| 832 | } while(0) |
| 833 | |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 834 | static void test_gsm0808_enc_dec_cell_id_list_lac() |
| 835 | { |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 836 | struct gsm0808_cell_id_list2 enc_cil; |
| 837 | struct gsm0808_cell_id_list2 dec_cil; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 838 | struct msgb *msg; |
| 839 | uint8_t rc_enc; |
| 840 | int rc_dec; |
| 841 | |
| 842 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 843 | enc_cil.id_discr = CELL_IDENT_LAC; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 844 | enc_cil.id_list[0].lac = 0x0124; |
Neels Hofmeyr | db2fa4e | 2018-04-13 04:11:20 +0200 | [diff] [blame] | 845 | enc_cil.id_list[1].lac = 0xABCD; |
| 846 | enc_cil.id_list[2].lac = 0x5678; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 847 | enc_cil.id_list_len = 3; |
| 848 | |
| 849 | msg = msgb_alloc(1024, "output buffer"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 850 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
Neels Hofmeyr | db2fa4e | 2018-04-13 04:11:20 +0200 | [diff] [blame] | 851 | EXPECT_ENCODED("1a 07 05 01 24 ab cd 56 78"); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 852 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 853 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 854 | OSMO_ASSERT(rc_dec == 7); |
| 855 | |
| 856 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 857 | |
| 858 | msgb_free(msg); |
| 859 | } |
| 860 | |
| 861 | static void test_gsm0808_enc_dec_cell_id_list_single_lac() |
| 862 | { |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 863 | struct gsm0808_cell_id_list2 enc_cil; |
| 864 | struct gsm0808_cell_id_list2 dec_cil; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 865 | struct msgb *msg; |
| 866 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x03, |
| 867 | 0x05, 0x23, 0x42 |
| 868 | }; |
| 869 | uint8_t rc_enc; |
| 870 | int rc_dec; |
| 871 | |
| 872 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 873 | enc_cil.id_discr = CELL_IDENT_LAC; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 874 | enc_cil.id_list[0].lac = 0x2342; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 875 | enc_cil.id_list_len = 1; |
| 876 | |
| 877 | msg = msgb_alloc(1024, "output buffer"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 878 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 879 | OSMO_ASSERT(rc_enc == 5); |
| 880 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 881 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 882 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 883 | OSMO_ASSERT(rc_dec == 3); |
| 884 | |
| 885 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 886 | |
| 887 | msgb_free(msg); |
| 888 | } |
| 889 | |
Stefan Sperling | e1a8674 | 2018-03-15 18:05:02 +0100 | [diff] [blame] | 890 | static void test_gsm0808_enc_dec_cell_id_list_multi_lac() |
| 891 | { |
| 892 | struct gsm0808_cell_id_list2 enc_cil; |
| 893 | struct gsm0808_cell_id_list2 dec_cil; |
| 894 | struct msgb *msg; |
| 895 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x0b, 0x05, |
| 896 | 0x23, 0x42, |
| 897 | 0x24, 0x43, |
| 898 | 0x25, 0x44, |
| 899 | 0x26, 0x45, |
| 900 | 0x27, 0x46 |
| 901 | }; |
| 902 | uint8_t rc_enc; |
| 903 | int rc_dec; |
| 904 | |
| 905 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 906 | enc_cil.id_discr = CELL_IDENT_LAC; |
| 907 | enc_cil.id_list[0].lac = 0x2342; |
| 908 | enc_cil.id_list[1].lac = 0x2443; |
| 909 | enc_cil.id_list[2].lac = 0x2544; |
| 910 | enc_cil.id_list[3].lac = 0x2645; |
| 911 | enc_cil.id_list[4].lac = 0x2746; |
| 912 | enc_cil.id_list_len = 5; |
| 913 | |
| 914 | msg = msgb_alloc(1024, "output buffer"); |
| 915 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 916 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 917 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 918 | |
| 919 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 920 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 921 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 922 | |
| 923 | msgb_free(msg); |
| 924 | } |
| 925 | |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 926 | static void test_gsm0808_enc_dec_cell_id_list_bss() |
| 927 | { |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 928 | struct gsm0808_cell_id_list2 enc_cil; |
| 929 | struct gsm0808_cell_id_list2 dec_cil; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 930 | struct msgb *msg; |
| 931 | uint8_t rc_enc; |
| 932 | int rc_dec; |
| 933 | |
| 934 | memset(&enc_cil, 0, sizeof(enc_cil)); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 935 | enc_cil.id_discr = CELL_IDENT_BSS; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 936 | |
| 937 | msg = msgb_alloc(1024, "output buffer"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 938 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 939 | OSMO_ASSERT(rc_enc == 3); |
| 940 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 941 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 942 | OSMO_ASSERT(rc_dec == 1); |
| 943 | |
| 944 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 945 | |
| 946 | msgb_free(msg); |
| 947 | } |
| 948 | |
Stefan Sperling | 2338145 | 2018-03-15 19:38:15 +0100 | [diff] [blame] | 949 | static void test_gsm0808_enc_dec_cell_id_list_multi_lai_and_lac() |
| 950 | { |
| 951 | struct gsm0808_cell_id_list2 enc_cil; |
| 952 | struct gsm0808_cell_id_list2 dec_cil; |
| 953 | struct osmo_location_area_id id; |
| 954 | struct msgb *msg; |
| 955 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x10, 0x04, |
| 956 | 0x92, 0x61, 0x54, 0x23, 0x42, |
| 957 | 0x92, 0x72, 0x54, 0x24, 0x43, |
| 958 | 0x92, 0x83, 0x54, 0x25, 0x44 |
| 959 | }; |
| 960 | uint8_t rc_enc; |
| 961 | int rc_dec, i; |
| 962 | |
| 963 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 964 | enc_cil.id_discr = CELL_IDENT_LAI_AND_LAC; |
| 965 | |
| 966 | id.plmn.mcc = 0x123; |
| 967 | osmo_mnc_from_str("456", &id.plmn.mnc, &id.plmn.mnc_3_digits); |
| 968 | id.lac = 0x2342; |
| 969 | memcpy(&enc_cil.id_list[0].lai_and_lac, &id, sizeof(id)); |
| 970 | |
| 971 | id.plmn.mcc = 0x124; |
| 972 | osmo_mnc_from_str("457", &id.plmn.mnc, &id.plmn.mnc_3_digits); |
| 973 | id.lac = 0x2443; |
| 974 | memcpy(&enc_cil.id_list[1].lai_and_lac, &id, sizeof(id)); |
| 975 | |
| 976 | id.plmn.mcc = 0x125; |
| 977 | osmo_mnc_from_str("458", &id.plmn.mnc, &id.plmn.mnc_3_digits); |
| 978 | id.lac = 0x2544; |
| 979 | memcpy(&enc_cil.id_list[2].lai_and_lac, &id, sizeof(id)); |
| 980 | |
| 981 | enc_cil.id_list_len = 3; |
| 982 | |
| 983 | msg = msgb_alloc(1024, "output buffer"); |
| 984 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 985 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 986 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 987 | |
| 988 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 989 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 990 | |
| 991 | OSMO_ASSERT(dec_cil.id_list_len == 3); |
| 992 | /* Check MAXLEN elements to ensure everything has been initialized. */ |
| 993 | for (i = 0; i < GSM0808_CELL_ID_LIST2_MAXLEN; i++) { |
| 994 | struct osmo_location_area_id *enc_id; |
| 995 | struct osmo_location_area_id *dec_id; |
| 996 | enc_id = &enc_cil.id_list[i].lai_and_lac; |
| 997 | dec_id = &dec_cil.id_list[i].lai_and_lac; |
| 998 | OSMO_ASSERT(osmo_plmn_cmp(&enc_id->plmn, &dec_id->plmn) == 0); |
| 999 | OSMO_ASSERT(enc_id->lac == dec_id->lac); |
| 1000 | } |
| 1001 | |
| 1002 | msgb_free(msg); |
| 1003 | } |
| 1004 | |
Stefan Sperling | 9c62fc6 | 2018-03-16 10:23:34 +0100 | [diff] [blame] | 1005 | static void test_gsm0808_enc_dec_cell_id_list_multi_ci() |
| 1006 | { |
| 1007 | struct gsm0808_cell_id_list2 enc_cil; |
| 1008 | struct gsm0808_cell_id_list2 dec_cil; |
| 1009 | struct msgb *msg; |
| 1010 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x09, 0x02, |
| 1011 | 0x00, 0x01, |
| 1012 | 0x00, 0x02, |
| 1013 | 0x00, 0x77, |
| 1014 | 0x01, 0xff, |
| 1015 | }; |
| 1016 | uint8_t rc_enc; |
| 1017 | int rc_dec; |
| 1018 | |
| 1019 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 1020 | enc_cil.id_discr = CELL_IDENT_CI; |
| 1021 | enc_cil.id_list[0].ci = 1; |
| 1022 | enc_cil.id_list[1].ci = 2; |
| 1023 | enc_cil.id_list[2].ci = 119; |
| 1024 | enc_cil.id_list[3].ci = 511; |
| 1025 | enc_cil.id_list_len = 4; |
| 1026 | |
| 1027 | msg = msgb_alloc(1024, "output buffer"); |
| 1028 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 1029 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 1030 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 1031 | |
| 1032 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 1033 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1034 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 1035 | |
| 1036 | msgb_free(msg); |
| 1037 | } |
| 1038 | |
Stefan Sperling | ed4327c | 2018-03-16 11:02:59 +0100 | [diff] [blame] | 1039 | static void test_gsm0808_enc_dec_cell_id_list_multi_lac_and_ci() |
| 1040 | { |
| 1041 | struct gsm0808_cell_id_list2 enc_cil; |
| 1042 | struct gsm0808_cell_id_list2 dec_cil; |
| 1043 | struct msgb *msg; |
| 1044 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x15, 0x01, |
| 1045 | 0x23, 0x42, 0x00, 0x01, |
| 1046 | 0x24, 0x43, 0x00, 0x02, |
| 1047 | 0x25, 0x44, 0x00, 0x77, |
| 1048 | 0x26, 0x45, 0x01, 0xff, |
| 1049 | 0x27, 0x46, 0x02, 0xfe, |
| 1050 | }; |
| 1051 | uint8_t rc_enc; |
| 1052 | int rc_dec; |
| 1053 | |
| 1054 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 1055 | enc_cil.id_discr = CELL_IDENT_LAC_AND_CI; |
| 1056 | enc_cil.id_list[0].lac_and_ci.lac = 0x2342; |
| 1057 | enc_cil.id_list[0].lac_and_ci.ci = 1; |
| 1058 | enc_cil.id_list[1].lac_and_ci.lac = 0x2443; |
| 1059 | enc_cil.id_list[1].lac_and_ci.ci = 2; |
| 1060 | enc_cil.id_list[2].lac_and_ci.lac = 0x2544; |
| 1061 | enc_cil.id_list[2].lac_and_ci.ci = 119; |
| 1062 | enc_cil.id_list[3].lac_and_ci.lac = 0x2645; |
| 1063 | enc_cil.id_list[3].lac_and_ci.ci = 511; |
| 1064 | enc_cil.id_list[4].lac_and_ci.lac = 0x2746; |
| 1065 | enc_cil.id_list[4].lac_and_ci.ci = 766; |
| 1066 | enc_cil.id_list_len = 5; |
| 1067 | |
| 1068 | msg = msgb_alloc(1024, "output buffer"); |
| 1069 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 1070 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 1071 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 1072 | |
| 1073 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 1074 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1075 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 1076 | |
| 1077 | msgb_free(msg); |
| 1078 | } |
| 1079 | |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1080 | static void test_gsm0808_enc_dec_cell_id_list_multi_global() |
| 1081 | { |
| 1082 | struct gsm0808_cell_id_list2 enc_cil; |
| 1083 | struct gsm0808_cell_id_list2 dec_cil; |
| 1084 | struct msgb *msg; |
| 1085 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x16, 0x00, |
Neels Hofmeyr | 473485c | 2018-03-23 02:04:18 +0100 | [diff] [blame] | 1086 | 0x21, 0x63, 0x54, 0x23, 0x42, 0x00, 0x1, |
Neels Hofmeyr | c44fc23 | 2018-03-23 02:15:12 +0100 | [diff] [blame] | 1087 | 0x21, 0xf4, 0x75, 0x24, 0x43, 0x00, 0x2, |
Neels Hofmeyr | 8b8cd93 | 2018-03-23 01:47:37 +0100 | [diff] [blame] | 1088 | 0x21, 0x75, 0x00, 0x25, 0x44, 0x00, 0x77 |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1089 | }; |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1090 | uint8_t rc_enc; |
| 1091 | int rc_dec, i; |
| 1092 | |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1093 | enc_cil = (struct gsm0808_cell_id_list2){ |
| 1094 | .id_discr = CELL_IDENT_WHOLE_GLOBAL, |
| 1095 | .id_list_len = 3, |
| 1096 | .id_list = { |
| 1097 | { |
| 1098 | .global = { |
Neels Hofmeyr | 473485c | 2018-03-23 02:04:18 +0100 | [diff] [blame] | 1099 | .lai = { .plmn = { .mcc = 123, .mnc = 456 }, |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1100 | .lac = 0x2342 }, |
| 1101 | .cell_identity = 1, |
| 1102 | } |
| 1103 | }, |
| 1104 | { |
| 1105 | .global = { |
Neels Hofmeyr | c44fc23 | 2018-03-23 02:15:12 +0100 | [diff] [blame] | 1106 | .lai = { .plmn = { .mcc = 124, .mnc = 57 }, |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1107 | .lac = 0x2443 }, |
| 1108 | .cell_identity = 2, |
| 1109 | } |
| 1110 | }, |
| 1111 | { |
| 1112 | .global = { |
Neels Hofmeyr | c44fc23 | 2018-03-23 02:15:12 +0100 | [diff] [blame] | 1113 | .lai = { .plmn = { .mcc = 125, .mnc = 7, |
| 1114 | .mnc_3_digits = true }, |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1115 | .lac = 0x2544 }, |
| 1116 | .cell_identity = 119, |
| 1117 | } |
| 1118 | }, |
| 1119 | } |
| 1120 | }; |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1121 | |
| 1122 | msg = msgb_alloc(1024, "output buffer"); |
| 1123 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 1124 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1125 | if (memcmp(cil_enc_expected, msg->data, msg->len)) { |
| 1126 | printf(" got: %s\n", osmo_hexdump(msg->data, msg->len)); |
| 1127 | printf("expect: %s\n", osmo_hexdump(cil_enc_expected, sizeof(cil_enc_expected))); |
| 1128 | OSMO_ASSERT(false); |
| 1129 | } |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1130 | |
| 1131 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 1132 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1133 | |
| 1134 | /* Check MAXLEN elements to ensure everything has been initialized. */ |
| 1135 | for (i = 0; i < GSM0808_CELL_ID_LIST2_MAXLEN; i++) { |
| 1136 | struct osmo_cell_global_id *enc_id; |
| 1137 | struct osmo_cell_global_id *dec_id; |
| 1138 | enc_id = &enc_cil.id_list[i].global; |
| 1139 | dec_id = &dec_cil.id_list[i].global; |
| 1140 | OSMO_ASSERT(osmo_plmn_cmp(&enc_id->lai.plmn, &dec_id->lai.plmn) == 0); |
| 1141 | OSMO_ASSERT(enc_id->lai.lac == dec_id->lai.lac); |
| 1142 | OSMO_ASSERT(enc_id->cell_identity == dec_id->cell_identity); |
| 1143 | } |
| 1144 | |
| 1145 | msgb_free(msg); |
| 1146 | } |
| 1147 | |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1148 | static void print_cil(const struct gsm0808_cell_id_list2 *cil) |
| 1149 | { |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1150 | printf(" cell_id_list == %s\n", gsm0808_cell_id_list_name(cil)); |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1151 | } |
| 1152 | |
| 1153 | void test_cell_id_list_add() { |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1154 | size_t zu; |
| 1155 | |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1156 | const struct gsm0808_cell_id_list2 cgi1 = { |
| 1157 | .id_discr = CELL_IDENT_WHOLE_GLOBAL, |
| 1158 | .id_list_len = 1, |
| 1159 | .id_list = { |
| 1160 | { |
| 1161 | .global = { |
| 1162 | .lai = { |
| 1163 | .plmn = { .mcc = 1, .mnc = 2, .mnc_3_digits = false }, |
| 1164 | .lac = 3, |
| 1165 | }, |
| 1166 | .cell_identity = 4, |
| 1167 | } |
| 1168 | }, |
| 1169 | }, |
| 1170 | }; |
| 1171 | |
| 1172 | const struct gsm0808_cell_id_list2 cgi2 = { |
| 1173 | .id_discr = CELL_IDENT_WHOLE_GLOBAL, |
| 1174 | .id_list_len = 2, |
| 1175 | .id_list = { |
| 1176 | { |
| 1177 | .global = { |
| 1178 | .lai = { |
| 1179 | .plmn = { .mcc = 1, .mnc = 2, .mnc_3_digits = true }, |
| 1180 | .lac = 3, |
| 1181 | }, |
| 1182 | .cell_identity = 4, |
| 1183 | } |
| 1184 | }, |
| 1185 | { |
| 1186 | .global = { |
| 1187 | .lai = { |
| 1188 | .plmn = { .mcc = 5, .mnc = 6, .mnc_3_digits = true }, |
| 1189 | .lac = 7, |
| 1190 | }, |
| 1191 | .cell_identity = 8, |
| 1192 | } |
| 1193 | }, |
| 1194 | }, |
| 1195 | }; |
| 1196 | |
| 1197 | const struct gsm0808_cell_id_list2 cgi2a = { |
| 1198 | .id_discr = CELL_IDENT_WHOLE_GLOBAL, |
| 1199 | .id_list_len = 2, |
| 1200 | .id_list = { |
| 1201 | { |
| 1202 | .global = cgi2.id_list[0].global |
| 1203 | }, |
| 1204 | { |
| 1205 | .global = { |
| 1206 | .lai = { |
| 1207 | .plmn = { .mcc = 9, .mnc = 10, .mnc_3_digits = true }, |
| 1208 | .lac = 11, |
| 1209 | }, |
| 1210 | .cell_identity = 12, |
| 1211 | } |
| 1212 | }, |
| 1213 | }, |
| 1214 | }; |
| 1215 | |
| 1216 | const struct gsm0808_cell_id_list2 cgi3 = { |
| 1217 | .id_discr = CELL_IDENT_WHOLE_GLOBAL, |
| 1218 | .id_list_len = 2, |
| 1219 | .id_list = { |
| 1220 | { |
| 1221 | .global = { |
| 1222 | .lai = { |
| 1223 | .plmn = { .mcc = 13, .mnc = 14, .mnc_3_digits = true }, |
| 1224 | .lac = 15, |
| 1225 | }, |
| 1226 | .cell_identity = 16, |
| 1227 | } |
| 1228 | }, |
| 1229 | { |
| 1230 | .global = { |
| 1231 | .lai = { |
| 1232 | .plmn = { .mcc = 16, .mnc = 17, .mnc_3_digits = true }, |
| 1233 | .lac = 18, |
| 1234 | }, |
| 1235 | .cell_identity = 19, |
| 1236 | } |
| 1237 | }, |
| 1238 | }, |
| 1239 | }; |
| 1240 | |
| 1241 | |
| 1242 | const struct gsm0808_cell_id_list2 lac1 = { |
| 1243 | .id_discr = CELL_IDENT_LAC, |
| 1244 | .id_list_len = 1, |
| 1245 | .id_list = { |
| 1246 | { |
| 1247 | .lac = 123 |
| 1248 | }, |
| 1249 | }, |
| 1250 | }; |
| 1251 | |
| 1252 | const struct gsm0808_cell_id_list2 lac2 = { |
| 1253 | .id_discr = CELL_IDENT_LAC, |
| 1254 | .id_list_len = 2, |
| 1255 | .id_list = { |
| 1256 | { |
| 1257 | .lac = 456 |
| 1258 | }, |
| 1259 | { |
| 1260 | .lac = 789 |
| 1261 | }, |
| 1262 | }, |
| 1263 | }; |
| 1264 | |
| 1265 | struct gsm0808_cell_id_list2 cil = {}; |
| 1266 | |
| 1267 | printf("------- %s\n", __func__); |
| 1268 | |
| 1269 | print_cil(&cil); |
| 1270 | |
| 1271 | #define ADD_QUIET(other_cil, expect_rc) do { \ |
| 1272 | int rc = gsm0808_cell_id_list_add(&cil, &other_cil); \ |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1273 | printf("gsm0808_cell_id_list_add(&cil, &" #other_cil ") --> rc = %d\n", rc); \ |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1274 | OSMO_ASSERT(rc == expect_rc); \ |
| 1275 | } while(0) |
| 1276 | |
| 1277 | #define ADD(other_cil, expect_rc) ADD_QUIET(other_cil, expect_rc); print_cil(&cil) |
| 1278 | |
| 1279 | ADD(lac1, 1); |
| 1280 | ADD(lac1, 0); |
| 1281 | ADD(lac2, 2); |
| 1282 | ADD(lac2, 0); |
| 1283 | ADD(cil, 0); |
| 1284 | ADD(cgi1, -EINVAL); |
| 1285 | |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1286 | printf("* can't add to BSS list\n"); |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1287 | cil.id_list_len = 0; |
| 1288 | cil.id_discr = CELL_IDENT_BSS; |
| 1289 | print_cil(&cil); |
| 1290 | ADD(lac1, -EINVAL); |
| 1291 | |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1292 | printf("* other types (including NO_CELL) take on new type iff empty\n"); |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1293 | cil.id_list_len = 0; |
| 1294 | cil.id_discr = CELL_IDENT_NO_CELL; |
| 1295 | print_cil(&cil); |
| 1296 | ADD(cgi1, 1); |
| 1297 | ADD(cgi1, 0); |
| 1298 | ADD(cgi2, 2); |
| 1299 | ADD(cgi2, 0); |
| 1300 | |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1301 | printf("* test gsm0808_cell_id_list_name_buf()'s return val\n"); |
| 1302 | zu = strlen(gsm0808_cell_id_list_name(&cil)); |
| 1303 | printf(" strlen(gsm0808_cell_id_list_name(cil)) == %zu\n", zu); |
| 1304 | zu ++; |
| 1305 | while (1) { |
| 1306 | char buf[128] = "?"; |
| 1307 | int rc; |
| 1308 | OSMO_ASSERT(zu < sizeof(buf)); |
| 1309 | buf[zu] = '#'; |
| 1310 | rc = gsm0808_cell_id_list_name_buf(buf, zu, &cil); |
| 1311 | printf(" gsm0808_cell_id_list_name_buf(buf, %zu, cil)) == %d \"%s\"\n", |
| 1312 | zu, rc, buf); |
| 1313 | OSMO_ASSERT(buf[zu] == '#'); |
| 1314 | if (!zu) |
| 1315 | break; |
| 1316 | zu /= 2; |
| 1317 | } |
| 1318 | |
| 1319 | printf("* list-full behavior\n"); |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1320 | cil.id_list_len = GSM0808_CELL_ID_LIST2_MAXLEN - 1; |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1321 | printf("cil.id_list_len = %u\n", cil.id_list_len); |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1322 | ADD_QUIET(cgi2a, 1); |
| 1323 | printf("cil.id_list_len = %u\n", cil.id_list_len); |
| 1324 | |
| 1325 | cil.id_list_len = GSM0808_CELL_ID_LIST2_MAXLEN - 1; |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1326 | printf("cil.id_list_len = %u\n", cil.id_list_len); |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1327 | ADD_QUIET(cgi3, -ENOSPC); |
Neels Hofmeyr | a4399c8 | 2018-04-17 02:26:10 +0200 | [diff] [blame] | 1328 | printf("cil.id_list_len = %u\n", cil.id_list_len); |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1329 | ADD_QUIET(cgi2a, -ENOSPC); |
| 1330 | printf("cil.id_list_len = %u\n", cil.id_list_len); |
| 1331 | |
| 1332 | printf("------- %s done\n", __func__); |
| 1333 | } |
| 1334 | |
Neels Hofmeyr | 250e7f7 | 2018-04-13 03:30:14 +0200 | [diff] [blame] | 1335 | static void test_gsm0808_enc_dec_cell_id_lac() |
| 1336 | { |
| 1337 | struct gsm0808_cell_id enc_ci = { |
| 1338 | .id_discr = CELL_IDENT_LAC, |
| 1339 | .id.lac = 0x0124, |
| 1340 | }; |
| 1341 | struct gsm0808_cell_id dec_ci; |
| 1342 | struct msgb *msg; |
| 1343 | uint8_t rc_enc; |
| 1344 | int rc_dec; |
| 1345 | |
| 1346 | memset(&dec_ci, 0xa5, sizeof(dec_ci)); |
| 1347 | |
| 1348 | msg = msgb_alloc(1024, "output buffer"); |
| 1349 | rc_enc = gsm0808_enc_cell_id(msg, &enc_ci); |
| 1350 | EXPECT_ENCODED("05 03 05 01 24"); |
| 1351 | |
| 1352 | rc_dec = gsm0808_dec_cell_id(&dec_ci, msg->data + 2, msg->len - 2); |
| 1353 | OSMO_ASSERT(rc_dec == 3); |
| 1354 | |
| 1355 | OSMO_ASSERT(enc_ci.id_discr == dec_ci.id_discr |
| 1356 | && enc_ci.id.lac == dec_ci.id.lac); |
| 1357 | |
| 1358 | msgb_free(msg); |
| 1359 | } |
| 1360 | |
| 1361 | static void test_gsm0808_enc_dec_cell_id_bss() |
| 1362 | { |
| 1363 | struct gsm0808_cell_id enc_ci = { |
| 1364 | .id_discr = CELL_IDENT_BSS, |
| 1365 | }; |
| 1366 | struct gsm0808_cell_id dec_ci; |
| 1367 | struct msgb *msg; |
| 1368 | uint8_t rc_enc; |
| 1369 | int rc_dec; |
| 1370 | |
| 1371 | msg = msgb_alloc(1024, "output buffer"); |
| 1372 | rc_enc = gsm0808_enc_cell_id(msg, &enc_ci); |
| 1373 | EXPECT_ENCODED("05 01 06"); |
| 1374 | |
| 1375 | rc_dec = gsm0808_dec_cell_id(&dec_ci, msg->data + 2, msg->len - 2); |
| 1376 | OSMO_ASSERT(rc_dec == 1); |
| 1377 | |
| 1378 | OSMO_ASSERT(enc_ci.id_discr == dec_ci.id_discr); |
| 1379 | |
| 1380 | msgb_free(msg); |
| 1381 | } |
| 1382 | |
| 1383 | static void test_gsm0808_enc_dec_cell_id_no_cell() |
| 1384 | { |
| 1385 | struct gsm0808_cell_id enc_ci = { |
| 1386 | .id_discr = CELL_IDENT_NO_CELL, |
| 1387 | }; |
| 1388 | struct gsm0808_cell_id dec_ci; |
| 1389 | struct msgb *msg; |
| 1390 | uint8_t rc_enc; |
| 1391 | int rc_dec; |
| 1392 | |
| 1393 | msg = msgb_alloc(1024, "output buffer"); |
| 1394 | rc_enc = gsm0808_enc_cell_id(msg, &enc_ci); |
| 1395 | EXPECT_ENCODED("05 01 03"); |
| 1396 | |
| 1397 | rc_dec = gsm0808_dec_cell_id(&dec_ci, msg->data + 2, msg->len - 2); |
| 1398 | OSMO_ASSERT(rc_dec == 1); |
| 1399 | |
| 1400 | OSMO_ASSERT(enc_ci.id_discr == dec_ci.id_discr); |
| 1401 | |
| 1402 | msgb_free(msg); |
| 1403 | } |
| 1404 | |
| 1405 | static void test_gsm0808_enc_dec_cell_id_lai_and_lac() |
| 1406 | { |
| 1407 | struct gsm0808_cell_id enc_ci = { |
| 1408 | .id_discr = CELL_IDENT_LAI_AND_LAC, |
| 1409 | .id.lai_and_lac = { |
| 1410 | .plmn = { |
| 1411 | .mcc = 123, |
| 1412 | .mnc = 456, |
| 1413 | }, |
| 1414 | .lac = 0x2342, |
| 1415 | }, |
| 1416 | }; |
| 1417 | struct gsm0808_cell_id dec_ci; |
| 1418 | struct msgb *msg; |
| 1419 | uint8_t rc_enc; |
| 1420 | int rc_dec; |
| 1421 | |
| 1422 | msg = msgb_alloc(1024, "output buffer"); |
| 1423 | rc_enc = gsm0808_enc_cell_id(msg, &enc_ci); |
| 1424 | EXPECT_ENCODED("05 06 04 21 63 54 23 42"); |
| 1425 | |
| 1426 | memset(&dec_ci, 0xa5, sizeof(dec_ci)); |
| 1427 | rc_dec = gsm0808_dec_cell_id(&dec_ci, msg->data + 2, msg->len - 2); |
| 1428 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1429 | |
| 1430 | OSMO_ASSERT(enc_ci.id_discr == dec_ci.id_discr |
| 1431 | && osmo_plmn_cmp(&enc_ci.id.lai_and_lac.plmn, &dec_ci.id.lai_and_lac.plmn) == 0 |
| 1432 | && enc_ci.id.lai_and_lac.lac == dec_ci.id.lai_and_lac.lac); |
| 1433 | msgb_free(msg); |
| 1434 | } |
| 1435 | |
| 1436 | static void test_gsm0808_enc_dec_cell_id_ci() |
| 1437 | { |
| 1438 | struct gsm0808_cell_id enc_ci = { |
| 1439 | .id_discr = CELL_IDENT_CI, |
| 1440 | .id.ci = 0x423, |
| 1441 | }; |
| 1442 | struct gsm0808_cell_id dec_ci; |
| 1443 | struct msgb *msg; |
| 1444 | uint8_t rc_enc; |
| 1445 | int rc_dec; |
| 1446 | |
| 1447 | msg = msgb_alloc(1024, "output buffer"); |
| 1448 | rc_enc = gsm0808_enc_cell_id(msg, &enc_ci); |
| 1449 | EXPECT_ENCODED("05 03 02 04 23"); |
| 1450 | |
| 1451 | rc_dec = gsm0808_dec_cell_id(&dec_ci, msg->data + 2, msg->len - 2); |
| 1452 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1453 | OSMO_ASSERT(enc_ci.id_discr == dec_ci.id_discr |
| 1454 | && enc_ci.id.ci == dec_ci.id.ci); |
| 1455 | |
| 1456 | msgb_free(msg); |
| 1457 | } |
| 1458 | |
| 1459 | static void test_gsm0808_enc_dec_cell_id_lac_and_ci() |
| 1460 | { |
| 1461 | struct gsm0808_cell_id enc_ci = { |
| 1462 | .id_discr = CELL_IDENT_LAC_AND_CI, |
| 1463 | .id.lac_and_ci = { |
| 1464 | .lac = 0x423, |
| 1465 | .ci = 0x235, |
| 1466 | }, |
| 1467 | }; |
| 1468 | struct gsm0808_cell_id dec_ci; |
| 1469 | struct msgb *msg; |
| 1470 | uint8_t rc_enc; |
| 1471 | int rc_dec; |
| 1472 | |
| 1473 | msg = msgb_alloc(1024, "output buffer"); |
| 1474 | rc_enc = gsm0808_enc_cell_id(msg, &enc_ci); |
| 1475 | EXPECT_ENCODED("05 05 01 04 23 02 35"); |
| 1476 | |
| 1477 | rc_dec = gsm0808_dec_cell_id(&dec_ci, msg->data + 2, msg->len - 2); |
| 1478 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1479 | OSMO_ASSERT(enc_ci.id_discr == dec_ci.id_discr |
| 1480 | && enc_ci.id.lac_and_ci.lac == dec_ci.id.lac_and_ci.lac |
| 1481 | && enc_ci.id.lac_and_ci.ci == dec_ci.id.lac_and_ci.ci); |
| 1482 | |
| 1483 | msgb_free(msg); |
| 1484 | } |
| 1485 | |
| 1486 | static void test_gsm0808_enc_dec_cell_id_global() |
| 1487 | { |
| 1488 | struct gsm0808_cell_id enc_ci = { |
| 1489 | .id_discr = CELL_IDENT_WHOLE_GLOBAL, |
| 1490 | .id.global = { |
| 1491 | .lai = { |
| 1492 | .plmn = { .mcc = 123, .mnc = 456 }, |
| 1493 | .lac = 0x2342 |
| 1494 | }, |
| 1495 | .cell_identity = 0x423, |
| 1496 | } |
| 1497 | }; |
| 1498 | struct gsm0808_cell_id dec_ci; |
| 1499 | struct msgb *msg; |
| 1500 | uint8_t rc_enc; |
| 1501 | int rc_dec; |
| 1502 | |
| 1503 | msg = msgb_alloc(1024, "output buffer"); |
| 1504 | rc_enc = gsm0808_enc_cell_id(msg, &enc_ci); |
| 1505 | EXPECT_ENCODED("05 08 00 21 63 54 23 42 04 23"); |
| 1506 | |
| 1507 | rc_dec = gsm0808_dec_cell_id(&dec_ci, msg->data + 2, msg->len - 2); |
| 1508 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1509 | |
| 1510 | OSMO_ASSERT(enc_ci.id_discr == dec_ci.id_discr |
| 1511 | && osmo_plmn_cmp(&enc_ci.id.global.lai.plmn, |
| 1512 | &dec_ci.id.global.lai.plmn) == 0 |
| 1513 | && enc_ci.id.global.lai.lac == dec_ci.id.global.lai.lac |
| 1514 | && enc_ci.id.global.cell_identity == dec_ci.id.global.cell_identity); |
| 1515 | msgb_free(msg); |
| 1516 | } |
| 1517 | |
Philipp Maier | 5f2eb15 | 2018-09-19 13:40:21 +0200 | [diff] [blame] | 1518 | static void test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(struct gsm48_multi_rate_conf *cfg) |
| 1519 | { |
| 1520 | uint16_t s15_s0; |
| 1521 | |
| 1522 | printf("Input:\n"); |
| 1523 | printf(" m4_75= %u smod= %u\n", cfg->m4_75, cfg->smod); |
| 1524 | printf(" m5_15= %u spare= %u\n", cfg->m5_15, cfg->spare); |
| 1525 | printf(" m5_90= %u icmi= %u\n", cfg->m5_90, cfg->icmi); |
| 1526 | printf(" m6_70= %u nscb= %u\n", cfg->m6_70, cfg->nscb); |
| 1527 | printf(" m7_40= %u ver= %u\n", cfg->m7_40, cfg->ver); |
| 1528 | printf(" m7_95= %u\n", cfg->m7_95); |
| 1529 | printf(" m10_2= %u\n", cfg->m10_2); |
| 1530 | printf(" m12_2= %u\n", cfg->m12_2); |
| 1531 | |
| 1532 | s15_s0 = gsm0808_sc_cfg_from_gsm48_mr_cfg(cfg, true); |
| 1533 | printf("Result (fr):\n"); |
| 1534 | printf(" S15-S0 = %04x = 0b" OSMO_BIN_SPEC OSMO_BIN_SPEC "\n", s15_s0, |
| 1535 | OSMO_BIN_PRINT(s15_s0 >> 8), OSMO_BIN_PRINT(s15_s0)); |
| 1536 | |
| 1537 | s15_s0 = gsm0808_sc_cfg_from_gsm48_mr_cfg(cfg, false); |
| 1538 | printf("Result (hr):\n"); |
| 1539 | printf(" S15-S0 = %04x = 0b" OSMO_BIN_SPEC OSMO_BIN_SPEC "\n", s15_s0, |
| 1540 | OSMO_BIN_PRINT(s15_s0 >> 8), OSMO_BIN_PRINT(s15_s0)); |
| 1541 | |
| 1542 | printf("\n"); |
| 1543 | } |
| 1544 | |
| 1545 | static void test_gsm0808_sc_cfg_from_gsm48_mr_cfg(void) |
| 1546 | { |
| 1547 | struct gsm48_multi_rate_conf cfg; |
| 1548 | |
| 1549 | printf("Testing gsm0808_sc_cfg_from_gsm48_mr_cfg():\n"); |
| 1550 | |
| 1551 | memset(&cfg, 0, sizeof(cfg)); |
| 1552 | |
| 1553 | cfg.m4_75 = 0; |
| 1554 | cfg.m5_15 = 0; |
| 1555 | cfg.m5_90 = 0; |
| 1556 | cfg.m6_70 = 0; |
| 1557 | cfg.m7_40 = 0; |
| 1558 | cfg.m7_95 = 0; |
| 1559 | cfg.m10_2 = 0; |
| 1560 | cfg.m12_2 = 0; |
| 1561 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1562 | |
| 1563 | cfg.m4_75 = 1; |
| 1564 | cfg.m5_15 = 0; |
| 1565 | cfg.m5_90 = 0; |
| 1566 | cfg.m6_70 = 0; |
| 1567 | cfg.m7_40 = 0; |
| 1568 | cfg.m7_95 = 0; |
| 1569 | cfg.m10_2 = 0; |
| 1570 | cfg.m12_2 = 0; |
| 1571 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1572 | |
| 1573 | cfg.m4_75 = 0; |
| 1574 | cfg.m5_15 = 1; |
| 1575 | cfg.m5_90 = 0; |
| 1576 | cfg.m6_70 = 0; |
| 1577 | cfg.m7_40 = 0; |
| 1578 | cfg.m7_95 = 0; |
| 1579 | cfg.m10_2 = 0; |
| 1580 | cfg.m12_2 = 0; |
| 1581 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1582 | |
| 1583 | cfg.m4_75 = 0; |
| 1584 | cfg.m5_15 = 0; |
| 1585 | cfg.m5_90 = 1; |
| 1586 | cfg.m6_70 = 0; |
| 1587 | cfg.m7_40 = 0; |
| 1588 | cfg.m7_95 = 0; |
| 1589 | cfg.m10_2 = 0; |
| 1590 | cfg.m12_2 = 0; |
| 1591 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1592 | |
| 1593 | cfg.m4_75 = 0; |
| 1594 | cfg.m5_15 = 0; |
| 1595 | cfg.m5_90 = 0; |
| 1596 | cfg.m6_70 = 1; |
| 1597 | cfg.m7_40 = 0; |
| 1598 | cfg.m7_95 = 0; |
| 1599 | cfg.m10_2 = 0; |
| 1600 | cfg.m12_2 = 0; |
| 1601 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1602 | |
| 1603 | cfg.m4_75 = 0; |
| 1604 | cfg.m5_15 = 0; |
| 1605 | cfg.m5_90 = 0; |
| 1606 | cfg.m6_70 = 0; |
| 1607 | cfg.m7_40 = 1; |
| 1608 | cfg.m7_95 = 0; |
| 1609 | cfg.m10_2 = 0; |
| 1610 | cfg.m12_2 = 0; |
| 1611 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1612 | |
| 1613 | cfg.m4_75 = 0; |
| 1614 | cfg.m5_15 = 0; |
| 1615 | cfg.m5_90 = 0; |
| 1616 | cfg.m6_70 = 0; |
| 1617 | cfg.m7_40 = 0; |
| 1618 | cfg.m7_95 = 1; |
| 1619 | cfg.m10_2 = 0; |
| 1620 | cfg.m12_2 = 0; |
| 1621 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1622 | |
| 1623 | cfg.m4_75 = 0; |
| 1624 | cfg.m5_15 = 0; |
| 1625 | cfg.m5_90 = 0; |
| 1626 | cfg.m6_70 = 0; |
| 1627 | cfg.m7_40 = 0; |
| 1628 | cfg.m7_95 = 0; |
| 1629 | cfg.m10_2 = 1; |
| 1630 | cfg.m12_2 = 0; |
| 1631 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1632 | |
| 1633 | cfg.m4_75 = 0; |
| 1634 | cfg.m5_15 = 0; |
| 1635 | cfg.m5_90 = 0; |
| 1636 | cfg.m6_70 = 0; |
| 1637 | cfg.m7_40 = 0; |
| 1638 | cfg.m7_95 = 0; |
| 1639 | cfg.m10_2 = 0; |
| 1640 | cfg.m12_2 = 1; |
| 1641 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1642 | |
| 1643 | cfg.m4_75 = 1; |
| 1644 | cfg.m5_15 = 1; |
| 1645 | cfg.m5_90 = 1; |
| 1646 | cfg.m6_70 = 1; |
| 1647 | cfg.m7_40 = 0; |
| 1648 | cfg.m7_95 = 0; |
| 1649 | cfg.m10_2 = 0; |
| 1650 | cfg.m12_2 = 0; |
| 1651 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1652 | |
| 1653 | cfg.m4_75 = 0; |
| 1654 | cfg.m5_15 = 0; |
| 1655 | cfg.m5_90 = 0; |
| 1656 | cfg.m6_70 = 0; |
| 1657 | cfg.m7_40 = 1; |
| 1658 | cfg.m7_95 = 1; |
| 1659 | cfg.m10_2 = 1; |
| 1660 | cfg.m12_2 = 1; |
| 1661 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1662 | |
| 1663 | cfg.m4_75 = 0; |
| 1664 | cfg.m5_15 = 0; |
| 1665 | cfg.m5_90 = 1; |
| 1666 | cfg.m6_70 = 1; |
| 1667 | cfg.m7_40 = 0; |
| 1668 | cfg.m7_95 = 0; |
| 1669 | cfg.m10_2 = 1; |
| 1670 | cfg.m12_2 = 1; |
| 1671 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1672 | |
| 1673 | cfg.m4_75 = 1; |
| 1674 | cfg.m5_15 = 1; |
| 1675 | cfg.m5_90 = 0; |
| 1676 | cfg.m6_70 = 0; |
| 1677 | cfg.m7_40 = 1; |
| 1678 | cfg.m7_95 = 1; |
| 1679 | cfg.m10_2 = 0; |
| 1680 | cfg.m12_2 = 0; |
| 1681 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1682 | |
| 1683 | cfg.m4_75 = 0; |
| 1684 | cfg.m5_15 = 1; |
| 1685 | cfg.m5_90 = 0; |
| 1686 | cfg.m6_70 = 1; |
| 1687 | cfg.m7_40 = 0; |
| 1688 | cfg.m7_95 = 1; |
| 1689 | cfg.m10_2 = 0; |
| 1690 | cfg.m12_2 = 1; |
| 1691 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1692 | |
| 1693 | cfg.m4_75 = 1; |
| 1694 | cfg.m5_15 = 0; |
| 1695 | cfg.m5_90 = 1; |
| 1696 | cfg.m6_70 = 0; |
| 1697 | cfg.m7_40 = 1; |
| 1698 | cfg.m7_95 = 0; |
| 1699 | cfg.m10_2 = 1; |
| 1700 | cfg.m12_2 = 0; |
| 1701 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1702 | |
| 1703 | cfg.m4_75 = 1; |
| 1704 | cfg.m5_15 = 1; |
| 1705 | cfg.m5_90 = 1; |
| 1706 | cfg.m6_70 = 1; |
| 1707 | cfg.m7_40 = 1; |
| 1708 | cfg.m7_95 = 1; |
| 1709 | cfg.m10_2 = 1; |
| 1710 | cfg.m12_2 = 1; |
| 1711 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg); |
| 1712 | } |
| 1713 | |
Philipp Maier | 8515d03 | 2018-09-25 15:57:49 +0200 | [diff] [blame] | 1714 | static void test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single(uint16_t s15_s0) |
| 1715 | { |
| 1716 | struct gsm48_multi_rate_conf cfg; |
| 1717 | |
| 1718 | printf("Input:\n"); |
| 1719 | printf(" S15-S0 = %04x = 0b" OSMO_BIN_SPEC OSMO_BIN_SPEC "\n", s15_s0, |
| 1720 | OSMO_BIN_PRINT(s15_s0 >> 8), OSMO_BIN_PRINT(s15_s0)); |
| 1721 | |
| 1722 | gsm48_mr_cfg_from_gsm0808_sc_cfg(&cfg, s15_s0); |
| 1723 | |
| 1724 | printf("Output:\n"); |
| 1725 | printf(" m4_75= %u smod= %u\n", cfg.m4_75, cfg.smod); |
| 1726 | printf(" m5_15= %u spare= %u\n", cfg.m5_15, cfg.spare); |
| 1727 | printf(" m5_90= %u icmi= %u\n", cfg.m5_90, cfg.icmi); |
| 1728 | printf(" m6_70= %u nscb= %u\n", cfg.m6_70, cfg.nscb); |
| 1729 | printf(" m7_40= %u ver= %u\n", cfg.m7_40, cfg.ver); |
| 1730 | printf(" m7_95= %u\n", cfg.m7_95); |
| 1731 | printf(" m10_2= %u\n", cfg.m10_2); |
| 1732 | printf(" m12_2= %u\n", cfg.m12_2); |
| 1733 | |
| 1734 | printf("\n"); |
| 1735 | } |
| 1736 | |
| 1737 | void test_gsm48_mr_cfg_from_gsm0808_sc_cfg() |
| 1738 | { |
| 1739 | printf("Testing gsm48_mr_cfg_from_gsm0808_sc_cfg():\n"); |
| 1740 | |
| 1741 | /* Only one codec per setting */ |
| 1742 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1743 | (GSM0808_SC_CFG_DEFAULT_AMR_4_75); |
| 1744 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1745 | (GSM0808_SC_CFG_DEFAULT_AMR_5_15); |
| 1746 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1747 | (GSM0808_SC_CFG_DEFAULT_AMR_5_90); |
| 1748 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1749 | (GSM0808_SC_CFG_DEFAULT_AMR_6_70); |
| 1750 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1751 | (GSM0808_SC_CFG_DEFAULT_AMR_7_40); |
| 1752 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1753 | (GSM0808_SC_CFG_DEFAULT_AMR_7_95); |
| 1754 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1755 | (GSM0808_SC_CFG_DEFAULT_AMR_10_2); |
| 1756 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1757 | (GSM0808_SC_CFG_DEFAULT_AMR_12_2); |
| 1758 | |
| 1759 | /* Combinations */ |
| 1760 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1761 | (GSM0808_SC_CFG_DEFAULT_AMR_4_75 | GSM0808_SC_CFG_DEFAULT_AMR_6_70 | |
| 1762 | GSM0808_SC_CFG_DEFAULT_AMR_10_2); |
| 1763 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1764 | (GSM0808_SC_CFG_DEFAULT_AMR_10_2 | GSM0808_SC_CFG_DEFAULT_AMR_12_2 | |
| 1765 | GSM0808_SC_CFG_DEFAULT_AMR_7_40); |
| 1766 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single |
| 1767 | (GSM0808_SC_CFG_DEFAULT_AMR_7_95 | GSM0808_SC_CFG_DEFAULT_AMR_12_2); |
| 1768 | } |
| 1769 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1770 | int main(int argc, char **argv) |
| 1771 | { |
| 1772 | printf("Testing generation of GSM0808 messages\n"); |
| 1773 | test_create_layer3(); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 1774 | test_create_layer3_aoip(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1775 | test_create_reset(); |
Philipp Maier | 15596e2 | 2017-04-05 17:55:27 +0200 | [diff] [blame] | 1776 | test_create_reset_ack(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1777 | test_create_clear_command(); |
| 1778 | test_create_clear_complete(); |
Philipp Maier | b478dd3 | 2017-03-29 15:50:05 +0200 | [diff] [blame] | 1779 | test_create_cipher(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1780 | test_create_cipher_complete(); |
| 1781 | test_create_cipher_reject(); |
Max | ed651d2 | 2018-11-07 15:25:05 +0100 | [diff] [blame^] | 1782 | test_create_cipher_reject_ext(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1783 | test_create_cm_u(); |
| 1784 | test_create_sapi_reject(); |
Philipp Maier | c6144a2 | 2017-03-29 17:53:43 +0200 | [diff] [blame] | 1785 | test_create_ass(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1786 | test_create_ass_compl(); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 1787 | test_create_ass_compl_aoip(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1788 | test_create_ass_fail(); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 1789 | test_create_ass_fail_aoip(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1790 | test_create_clear_rqst(); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 1791 | test_create_paging(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1792 | test_create_dtap(); |
| 1793 | test_prepend_dtap(); |
Philipp Maier | 2240143 | 2017-03-24 17:59:26 +0100 | [diff] [blame] | 1794 | test_enc_dec_aoip_trasp_addr_v4(); |
| 1795 | test_enc_dec_aoip_trasp_addr_v6(); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 1796 | test_gsm0808_enc_dec_speech_codec(); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 1797 | test_gsm0808_enc_dec_speech_codec_ext_with_cfg(); |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 1798 | test_gsm0808_enc_dec_speech_codec_with_cfg(); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 1799 | test_gsm0808_enc_dec_speech_codec_list(); |
Philipp Maier | f6c369f | 2018-10-16 15:24:47 +0200 | [diff] [blame] | 1800 | test_gsm0808_enc_dec_empty_speech_codec_list(); |
Philipp Maier | e0c6530 | 2017-03-28 17:05:40 +0200 | [diff] [blame] | 1801 | test_gsm0808_enc_dec_channel_type(); |
Philipp Maier | 14e76b9 | 2017-03-28 18:36:52 +0200 | [diff] [blame] | 1802 | test_gsm0808_enc_dec_encrypt_info(); |
Neels Hofmeyr | 250e7f7 | 2018-04-13 03:30:14 +0200 | [diff] [blame] | 1803 | |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 1804 | test_gsm0808_enc_dec_cell_id_list_lac(); |
| 1805 | test_gsm0808_enc_dec_cell_id_list_single_lac(); |
Stefan Sperling | e1a8674 | 2018-03-15 18:05:02 +0100 | [diff] [blame] | 1806 | test_gsm0808_enc_dec_cell_id_list_multi_lac(); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 1807 | test_gsm0808_enc_dec_cell_id_list_bss(); |
Stefan Sperling | 2338145 | 2018-03-15 19:38:15 +0100 | [diff] [blame] | 1808 | test_gsm0808_enc_dec_cell_id_list_multi_lai_and_lac(); |
Stefan Sperling | 9c62fc6 | 2018-03-16 10:23:34 +0100 | [diff] [blame] | 1809 | test_gsm0808_enc_dec_cell_id_list_multi_ci(); |
Stefan Sperling | ed4327c | 2018-03-16 11:02:59 +0100 | [diff] [blame] | 1810 | test_gsm0808_enc_dec_cell_id_list_multi_lac_and_ci(); |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1811 | test_gsm0808_enc_dec_cell_id_list_multi_global(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1812 | |
Neels Hofmeyr | 74663d9 | 2018-03-23 01:46:42 +0100 | [diff] [blame] | 1813 | test_cell_id_list_add(); |
| 1814 | |
Neels Hofmeyr | 250e7f7 | 2018-04-13 03:30:14 +0200 | [diff] [blame] | 1815 | test_gsm0808_enc_dec_cell_id_lac(); |
| 1816 | test_gsm0808_enc_dec_cell_id_bss(); |
| 1817 | test_gsm0808_enc_dec_cell_id_no_cell(); |
| 1818 | test_gsm0808_enc_dec_cell_id_lai_and_lac(); |
| 1819 | test_gsm0808_enc_dec_cell_id_ci(); |
| 1820 | test_gsm0808_enc_dec_cell_id_lac_and_ci(); |
| 1821 | test_gsm0808_enc_dec_cell_id_global(); |
| 1822 | |
Philipp Maier | 5f2eb15 | 2018-09-19 13:40:21 +0200 | [diff] [blame] | 1823 | test_gsm0808_sc_cfg_from_gsm48_mr_cfg(); |
Philipp Maier | 8515d03 | 2018-09-25 15:57:49 +0200 | [diff] [blame] | 1824 | test_gsm48_mr_cfg_from_gsm0808_sc_cfg(); |
Philipp Maier | 5f2eb15 | 2018-09-19 13:40:21 +0200 | [diff] [blame] | 1825 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1826 | printf("Done\n"); |
| 1827 | return EXIT_SUCCESS; |
| 1828 | } |