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> |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 31 | |
| 32 | #define VERIFY(msg, data, len) \ |
| 33 | if (msgb_l3len(msg) != len) { \ |
| 34 | 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] | 35 | __func__, __LINE__, msgb_l3len(msg), (int) len, \ |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 36 | osmo_hexdump(msg->l3h, msgb_l3len(msg))); \ |
| 37 | abort(); \ |
| 38 | } else if (memcmp(msg->l3h, data, len) != 0) { \ |
| 39 | printf("%s:%d didn't match: got: %s\n", \ |
| 40 | __func__, __LINE__, \ |
| 41 | osmo_hexdump(msg->l3h, msgb_l3len(msg))); \ |
| 42 | abort(); \ |
| 43 | } |
| 44 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 45 | /* Setup a fake codec list for testing */ |
| 46 | static void setup_codec_list(struct gsm0808_speech_codec_list *scl) |
| 47 | { |
| 48 | memset(scl, 0, sizeof(*scl)); |
| 49 | |
| 50 | scl->codec[0].pi = true; |
| 51 | scl->codec[0].tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 52 | scl->codec[0].type = GSM0808_SCT_FR3; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 53 | scl->codec[0].cfg = 0xcdef; |
| 54 | |
| 55 | scl->codec[1].fi = true; |
| 56 | scl->codec[1].pt = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 57 | scl->codec[1].type = GSM0808_SCT_FR2; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 58 | |
| 59 | scl->codec[2].fi = true; |
| 60 | scl->codec[2].tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 61 | scl->codec[2].type = GSM0808_SCT_CSD; |
| 62 | scl->codec[2].cfg = 0xc0; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 63 | |
| 64 | scl->len = 3; |
| 65 | } |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 66 | |
| 67 | static void test_create_layer3(void) |
| 68 | { |
| 69 | static const uint8_t res[] = { |
| 70 | 0x00, 0x0e, 0x57, 0x05, 0x08, 0x00, 0x77, 0x62, |
| 71 | 0x83, 0x33, 0x66, 0x44, 0x88, 0x17, 0x01, 0x23 }; |
| 72 | struct msgb *msg, *in_msg; |
| 73 | printf("Testing creating Layer3\n"); |
| 74 | |
| 75 | in_msg = msgb_alloc_headroom(512, 128, "foo"); |
| 76 | in_msg->l3h = in_msg->data; |
| 77 | msgb_v_put(in_msg, 0x23); |
| 78 | |
| 79 | msg = gsm0808_create_layer3(in_msg, 0x1122, 0x2244, 0x3366, 0x4488); |
| 80 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 81 | msgb_free(msg); |
| 82 | msgb_free(in_msg); |
| 83 | } |
| 84 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 85 | static void test_create_layer3_aoip() |
| 86 | { |
| 87 | static const uint8_t res[] = { |
| 88 | 0x00, 0x17, 0x57, 0x05, 0x08, 0x00, 0x77, 0x62, |
| 89 | 0x83, 0x33, 0x66, 0x44, 0x88, 0x17, 0x01, 0x23, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 90 | GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 91 | 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 92 | GSM0808_SCT_CSD | 0x90, 0xc0 |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | struct msgb *msg, *in_msg; |
| 96 | struct gsm0808_speech_codec_list sc_list; |
| 97 | printf("Testing creating Layer3 (AoIP)\n"); |
| 98 | |
| 99 | setup_codec_list(&sc_list); |
| 100 | |
| 101 | in_msg = msgb_alloc_headroom(512, 128, "foo"); |
| 102 | in_msg->l3h = in_msg->data; |
| 103 | msgb_v_put(in_msg, 0x23); |
| 104 | |
| 105 | msg = |
| 106 | gsm0808_create_layer3_aoip(in_msg, 0x1122, 0x2244, 0x3366, 0x4488, |
| 107 | &sc_list); |
| 108 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 109 | |
| 110 | msgb_free(msg); |
| 111 | msgb_free(in_msg); |
| 112 | } |
| 113 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 114 | static void test_create_reset() |
| 115 | { |
| 116 | static const uint8_t res[] = { 0x00, 0x04, 0x30, 0x04, 0x01, 0x20 }; |
| 117 | struct msgb *msg; |
| 118 | |
| 119 | printf("Testing creating Reset\n"); |
| 120 | msg = gsm0808_create_reset(); |
| 121 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 122 | msgb_free(msg); |
| 123 | } |
| 124 | |
Philipp Maier | 15596e2 | 2017-04-05 17:55:27 +0200 | [diff] [blame] | 125 | static void test_create_reset_ack() |
| 126 | { |
| 127 | static const uint8_t res[] = { 0x00, 0x01, 0x31 }; |
| 128 | struct msgb *msg; |
| 129 | |
| 130 | printf("Testing creating Reset Ack\n"); |
| 131 | msg = gsm0808_create_reset_ack(); |
| 132 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 133 | msgb_free(msg); |
| 134 | } |
| 135 | |
| 136 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 137 | static void test_create_clear_command() |
| 138 | { |
| 139 | static const uint8_t res[] = { 0x20, 0x04, 0x01, 0x23 }; |
| 140 | struct msgb *msg; |
| 141 | |
| 142 | printf("Testing creating Clear Command\n"); |
| 143 | msg = gsm0808_create_clear_command(0x23); |
| 144 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 145 | msgb_free(msg); |
| 146 | } |
| 147 | |
| 148 | static void test_create_clear_complete() |
| 149 | { |
| 150 | static const uint8_t res[] = { 0x00, 0x01, 0x21 }; |
| 151 | struct msgb *msg; |
| 152 | |
| 153 | printf("Testing creating Clear Complete\n"); |
| 154 | msg = gsm0808_create_clear_complete(); |
| 155 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 156 | msgb_free(msg); |
| 157 | } |
| 158 | |
Philipp Maier | b478dd3 | 2017-03-29 15:50:05 +0200 | [diff] [blame] | 159 | static void test_create_cipher() |
| 160 | { |
| 161 | static const uint8_t res[] = |
| 162 | { 0x00, 0x0c, 0x53, 0x0a, 0x09, 0x03, 0xaa, |
| 163 | 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42 }; |
| 164 | static const uint8_t res2[] = |
| 165 | { 0x00, 0x0e, 0x53, 0x0a, 0x09, 0x03, 0xaa, |
| 166 | 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42, |
| 167 | GSM0808_IE_CIPHER_RESPONSE_MODE, 0x01 }; |
| 168 | struct msgb *msg; |
| 169 | struct gsm0808_encrypt_info ei; |
| 170 | uint8_t include_imeisv; |
| 171 | |
| 172 | memset(&ei, 0, sizeof(ei)); |
| 173 | ei.perm_algo[0] = GSM0808_ALG_ID_A5_0; |
| 174 | ei.perm_algo[1] = GSM0808_ALG_ID_A5_1; |
| 175 | ei.perm_algo_len = 2; |
| 176 | ei.key[0] = 0xaa; |
| 177 | ei.key[1] = 0xbb; |
| 178 | ei.key[2] = 0xcc; |
| 179 | ei.key[3] = 0xdd; |
| 180 | ei.key[4] = 0xee; |
| 181 | ei.key[5] = 0xff; |
| 182 | ei.key[6] = 0x23; |
| 183 | ei.key[7] = 0x42; |
| 184 | ei.key_len = 8; |
| 185 | include_imeisv = 1; |
| 186 | |
| 187 | printf("Testing creating Chipher Mode Command\n"); |
| 188 | msg = gsm0808_create_cipher(&ei, NULL); |
| 189 | OSMO_ASSERT(msg); |
| 190 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 191 | msgb_free(msg); |
| 192 | |
| 193 | msg = gsm0808_create_cipher(&ei, &include_imeisv); |
| 194 | OSMO_ASSERT(msg); |
| 195 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 196 | msgb_free(msg); |
| 197 | } |
| 198 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 199 | static void test_create_cipher_complete() |
| 200 | { |
| 201 | static const uint8_t res1[] = { |
| 202 | 0x00, 0x08, 0x55, 0x20, 0x03, 0x23, 0x42, 0x21, 0x2c, 0x04 }; |
| 203 | static const uint8_t res2[] = { 0x00, 0x03, 0x55, 0x2c, 0x04}; |
| 204 | struct msgb *l3, *msg; |
| 205 | |
| 206 | printf("Testing creating Cipher Complete\n"); |
| 207 | l3 = msgb_alloc_headroom(512, 128, "l3h"); |
| 208 | l3->l3h = l3->data; |
| 209 | msgb_v_put(l3, 0x23); |
| 210 | msgb_v_put(l3, 0x42); |
| 211 | msgb_v_put(l3, 0x21); |
| 212 | |
| 213 | /* with l3 data */ |
| 214 | msg = gsm0808_create_cipher_complete(l3, 4); |
| 215 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 216 | msgb_free(msg); |
| 217 | |
| 218 | /* with l3 data but short */ |
| 219 | l3->len -= 1; |
| 220 | l3->tail -= 1; |
| 221 | msg = gsm0808_create_cipher_complete(l3, 4); |
| 222 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 223 | msgb_free(msg); |
| 224 | |
| 225 | /* without l3 data */ |
| 226 | msg = gsm0808_create_cipher_complete(NULL, 4); |
| 227 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 228 | msgb_free(msg); |
| 229 | |
| 230 | |
| 231 | msgb_free(l3); |
| 232 | } |
| 233 | |
| 234 | static void test_create_cipher_reject() |
| 235 | { |
Harald Welte | 62e4085 | 2017-12-17 20:50:34 +0100 | [diff] [blame] | 236 | static const uint8_t res[] = { 0x00, 0x04, 0x59, 0x04, 0x01, 0x23 }; |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 237 | struct msgb *msg; |
| 238 | |
| 239 | printf("Testing creating Cipher Reject\n"); |
| 240 | msg = gsm0808_create_cipher_reject(0x23); |
| 241 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 242 | msgb_free(msg); |
| 243 | } |
| 244 | |
| 245 | static void test_create_cm_u() |
| 246 | { |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 247 | static const uint8_t res[] = { |
| 248 | 0x00, 0x07, 0x54, 0x12, 0x01, 0x23, 0x13, 0x01, 0x42 }; |
| 249 | static const uint8_t res2o[] = { |
| 250 | 0x00, 0x04, 0x54, 0x12, 0x01, 0x23 }; |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 251 | struct msgb *msg; |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 252 | const uint8_t cm2 = 0x23; |
| 253 | const uint8_t cm3 = 0x42; |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 254 | |
| 255 | printf("Testing creating CM U\n"); |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 256 | msg = gsm0808_create_classmark_update(&cm2, 1, &cm3, 1); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 257 | VERIFY(msg, res, ARRAY_SIZE(res)); |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 258 | |
Neels Hofmeyr | 9a938ae | 2017-11-16 17:34:07 +0100 | [diff] [blame] | 259 | msgb_free(msg); |
| 260 | |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 261 | msg = gsm0808_create_classmark_update(&cm2, 1, NULL, 0); |
| 262 | VERIFY(msg, res2o, ARRAY_SIZE(res2o)); |
| 263 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 264 | msgb_free(msg); |
| 265 | } |
| 266 | |
| 267 | static void test_create_sapi_reject() |
| 268 | { |
| 269 | static const uint8_t res[] = { 0x00, 0x03, 0x25, 0x03, 0x25 }; |
| 270 | struct msgb *msg; |
| 271 | |
| 272 | printf("Testing creating SAPI Reject\n"); |
| 273 | msg = gsm0808_create_sapi_reject(3); |
| 274 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 275 | msgb_free(msg); |
| 276 | } |
| 277 | |
Philipp Maier | c6144a2 | 2017-03-29 17:53:43 +0200 | [diff] [blame] | 278 | static void test_create_ass() |
| 279 | { |
| 280 | static const uint8_t res1[] = |
| 281 | { 0x00, 0x0a, 0x01, 0x0b, 0x04, 0x01, 0x0b, 0xa1, 0x25, 0x01, 0x00, |
| 282 | 0x04 }; |
| 283 | static const uint8_t res2[] = |
| 284 | { 0x00, 0x20, 0x01, 0x0b, 0x04, 0x01, 0x0b, 0xa1, 0x25, 0x01, 0x00, |
| 285 | 0x04, GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 286 | 0x04, 0xd2, GSM0808_IE_SPEECH_CODEC_LIST, 0x07, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 287 | GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 288 | GSM0808_SCT_CSD | 0x90, 0xc0, GSM0808_IE_CALL_ID, 0xaa, 0xbb, |
| 289 | 0xcc, 0xdd }; |
Philipp Maier | c6144a2 | 2017-03-29 17:53:43 +0200 | [diff] [blame] | 290 | |
| 291 | struct msgb *msg; |
| 292 | struct gsm0808_channel_type ct; |
| 293 | uint16_t cic = 0004; |
| 294 | struct sockaddr_storage ss; |
| 295 | struct sockaddr_in sin; |
| 296 | struct gsm0808_speech_codec_list sc_list; |
| 297 | uint32_t call_id = 0xAABBCCDD; |
| 298 | |
| 299 | memset(&ct, 0, sizeof(ct)); |
| 300 | ct.ch_indctr = GSM0808_CHAN_SPEECH; |
| 301 | ct.ch_rate_type = GSM0808_SPEECH_HALF_PREF; |
| 302 | ct.perm_spch[0] = GSM0808_PERM_FR3; |
| 303 | ct.perm_spch[1] = GSM0808_PERM_HR3; |
| 304 | ct.perm_spch_len = 2; |
| 305 | |
| 306 | memset(&sin, 0, sizeof(sin)); |
| 307 | sin.sin_family = AF_INET; |
| 308 | sin.sin_port = htons(1234); |
| 309 | inet_aton("192.168.100.23", &sin.sin_addr); |
| 310 | |
| 311 | memset(&ss, 0, sizeof(ss)); |
| 312 | memcpy(&ss, &sin, sizeof(sin)); |
| 313 | |
| 314 | setup_codec_list(&sc_list); |
| 315 | |
| 316 | printf("Testing creating Assignment Request\n"); |
| 317 | msg = gsm0808_create_ass(&ct, &cic, NULL, NULL, NULL); |
| 318 | OSMO_ASSERT(msg); |
| 319 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 320 | msgb_free(msg); |
| 321 | |
| 322 | msg = gsm0808_create_ass(&ct, &cic, &ss, &sc_list, &call_id); |
| 323 | OSMO_ASSERT(msg); |
| 324 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 325 | msgb_free(msg); |
| 326 | } |
| 327 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 328 | static void test_create_ass_compl() |
| 329 | { |
| 330 | static const uint8_t res1[] = { |
| 331 | 0x00, 0x09, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, |
| 332 | 0x11, 0x40, 0x22 }; |
| 333 | static const uint8_t res2[] = { |
| 334 | 0x00, 0x07, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, 0x11}; |
| 335 | struct msgb *msg; |
| 336 | |
| 337 | printf("Testing creating Assignment Complete\n"); |
| 338 | msg = gsm0808_create_assignment_completed(0x23, 0x42, 0x11, 0x22); |
| 339 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 340 | msgb_free(msg); |
| 341 | |
| 342 | msg = gsm0808_create_assignment_completed(0x23, 0x42, 0x11, 0); |
| 343 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 344 | msgb_free(msg); |
| 345 | } |
| 346 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 347 | static void test_create_ass_compl_aoip() |
| 348 | { |
| 349 | struct sockaddr_storage ss; |
| 350 | struct sockaddr_in sin; |
| 351 | struct gsm0808_speech_codec sc; |
| 352 | struct gsm0808_speech_codec_list sc_list; |
| 353 | static const uint8_t res[] = |
| 354 | { 0x00, 0x1d, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, 0x11, 0x40, 0x22, |
| 355 | GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17, 0x04, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 356 | 0xd2, GSM0808_IE_SPEECH_CODEC, 0x01, GSM0808_SCT_HR1 | 0x90, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 357 | GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef, |
| 358 | 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 }; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 359 | struct msgb *msg; |
| 360 | |
| 361 | memset(&sin, 0, sizeof(sin)); |
| 362 | sin.sin_family = AF_INET; |
| 363 | sin.sin_port = htons(1234); |
| 364 | inet_aton("192.168.100.23", &sin.sin_addr); |
| 365 | |
| 366 | memset(&ss, 0, sizeof(ss)); |
| 367 | memcpy(&ss, &sin, sizeof(sin)); |
| 368 | |
| 369 | memset(&sc, 0, sizeof(sc)); |
| 370 | sc.fi = true; |
| 371 | sc.tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 372 | sc.type = GSM0808_SCT_HR1; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 373 | |
| 374 | setup_codec_list(&sc_list); |
| 375 | |
| 376 | printf("Testing creating Assignment Complete (AoIP)\n"); |
| 377 | msg = gsm0808_create_ass_compl(0x23, 0x42, 0x11, 0x22, |
| 378 | &ss, &sc, &sc_list); |
| 379 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 380 | msgb_free(msg); |
| 381 | } |
| 382 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 383 | static void test_create_ass_fail() |
| 384 | { |
| 385 | static const uint8_t res1[] = { 0x00, 0x04, 0x03, 0x04, 0x01, 0x23 }; |
| 386 | static const uint8_t res2[] = { |
| 387 | 0x00, 0x06, 0x03, 0x04, 0x01, 0x23, 0x15, 0x02}; |
| 388 | uint8_t rr_res = 2; |
| 389 | struct msgb *msg; |
| 390 | |
| 391 | printf("Testing creating Assignment Failure\n"); |
| 392 | msg = gsm0808_create_assignment_failure(0x23, NULL); |
| 393 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 394 | msgb_free(msg); |
| 395 | |
| 396 | msg = gsm0808_create_assignment_failure(0x23, &rr_res); |
| 397 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 398 | msgb_free(msg); |
| 399 | } |
| 400 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 401 | static void test_create_ass_fail_aoip() |
| 402 | { |
| 403 | static const uint8_t res1[] = |
| 404 | { 0x00, 0x0d, 0x03, 0x04, 0x01, 0x23, GSM0808_IE_SPEECH_CODEC_LIST, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 405 | 0x07, GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 406 | 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 }; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 407 | static const uint8_t res2[] = |
| 408 | { 0x00, 0x0f, 0x03, 0x04, 0x01, 0x23, 0x15, 0x02, |
Philipp Maier | 7e27b14 | 2018-03-22 17:26:46 +0100 | [diff] [blame] | 409 | GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef, |
| 410 | 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 }; |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 411 | uint8_t rr_res = 2; |
| 412 | struct msgb *msg; |
| 413 | struct gsm0808_speech_codec_list sc_list; |
| 414 | |
| 415 | setup_codec_list(&sc_list); |
| 416 | |
| 417 | printf("Testing creating Assignment Failure (AoIP)\n"); |
| 418 | msg = gsm0808_create_ass_fail(0x23, NULL, &sc_list); |
| 419 | VERIFY(msg, res1, ARRAY_SIZE(res1)); |
| 420 | msgb_free(msg); |
| 421 | |
| 422 | msg = gsm0808_create_ass_fail(0x23, &rr_res, &sc_list); |
| 423 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 424 | msgb_free(msg); |
| 425 | } |
| 426 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 427 | static void test_create_clear_rqst() |
| 428 | { |
| 429 | static const uint8_t res[] = { 0x00, 0x04, 0x22, 0x04, 0x01, 0x23 }; |
| 430 | struct msgb *msg; |
| 431 | |
| 432 | printf("Testing creating Clear Request\n"); |
| 433 | msg = gsm0808_create_clear_rqst(0x23); |
| 434 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 435 | msgb_free(msg); |
| 436 | } |
| 437 | |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 438 | static void test_create_paging() |
| 439 | { |
| 440 | static const uint8_t res[] = |
| 441 | { 0x00, 0x10, 0x52, 0x08, 0x08, 0x09, 0x10, 0x10, 0x00, 0x00, 0x00, |
| 442 | 0x21, 0x43, 0x1a, 0x03, 0x05, 0x23, 0x42 }; |
| 443 | static const uint8_t res2[] = |
| 444 | { 0x00, 0x16, 0x52, 0x08, 0x08, 0x09, 0x10, 0x10, 0x00, 0x00, 0x00, |
| 445 | 0x21, 0x43, GSM0808_IE_TMSI, 0x04, 0x12, 0x34, 0x56, 0x78, 0x1a, |
| 446 | 0x03, 0x05, 0x23, 0x42 }; |
| 447 | static const uint8_t res3[] = |
| 448 | { 0x00, 0x18, 0x52, 0x08, 0x08, 0x09, 0x10, 0x10, 0x00, 0x00, 0x00, |
| 449 | 0x21, 0x43, GSM0808_IE_TMSI, 0x04, 0x12, 0x34, 0x56, 0x78, 0x1a, |
| 450 | 0x03, 0x05, 0x23, 0x42, GSM0808_IE_CHANNEL_NEEDED, |
| 451 | RSL_CHANNEED_TCH_ForH }; |
| 452 | |
| 453 | struct msgb *msg; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 454 | struct gsm0808_cell_id_list2 cil; |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 455 | uint32_t tmsi = 0x12345678; |
| 456 | uint8_t chan_needed = RSL_CHANNEED_TCH_ForH; |
| 457 | |
| 458 | char imsi[] = "001010000001234"; |
| 459 | |
| 460 | cil.id_discr = CELL_IDENT_LAC; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 461 | cil.id_list[0].lac = 0x2342; |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 462 | cil.id_list_len = 1; |
| 463 | |
| 464 | printf("Testing creating Paging Request\n"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 465 | msg = gsm0808_create_paging2(imsi, NULL, &cil, NULL); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 466 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 467 | msgb_free(msg); |
| 468 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 469 | msg = gsm0808_create_paging2(imsi, &tmsi, &cil, NULL); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 470 | VERIFY(msg, res2, ARRAY_SIZE(res2)); |
| 471 | msgb_free(msg); |
| 472 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 473 | msg = gsm0808_create_paging2(imsi, &tmsi, &cil, &chan_needed); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 474 | VERIFY(msg, res3, ARRAY_SIZE(res3)); |
| 475 | msgb_free(msg); |
| 476 | } |
| 477 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 478 | static void test_create_dtap() |
| 479 | { |
| 480 | static const uint8_t res[] = { 0x01, 0x03, 0x02, 0x23, 0x42 }; |
| 481 | struct msgb *msg, *l3; |
| 482 | |
| 483 | printf("Testing creating DTAP\n"); |
| 484 | l3 = msgb_alloc_headroom(512, 128, "test"); |
| 485 | l3->l3h = l3->data; |
| 486 | msgb_v_put(l3, 0x23); |
| 487 | msgb_v_put(l3, 0x42); |
| 488 | |
| 489 | msg = gsm0808_create_dtap(l3, 0x3); |
| 490 | VERIFY(msg, res, ARRAY_SIZE(res)); |
| 491 | msgb_free(msg); |
| 492 | msgb_free(l3); |
| 493 | } |
| 494 | |
| 495 | static void test_prepend_dtap() |
| 496 | { |
| 497 | static const uint8_t res[] = { 0x01, 0x03, 0x02, 0x23, 0x42 }; |
| 498 | struct msgb *in_msg; |
| 499 | |
| 500 | printf("Testing prepend DTAP\n"); |
| 501 | |
| 502 | in_msg = msgb_alloc_headroom(512, 128, "test"); |
| 503 | msgb_v_put(in_msg, 0x23); |
| 504 | msgb_v_put(in_msg, 0x42); |
| 505 | |
| 506 | gsm0808_prepend_dtap_header(in_msg, 0x3); |
| 507 | in_msg->l3h = in_msg->data; |
| 508 | VERIFY(in_msg, res, ARRAY_SIZE(res)); |
| 509 | msgb_free(in_msg); |
| 510 | } |
| 511 | |
Philipp Maier | 2240143 | 2017-03-24 17:59:26 +0100 | [diff] [blame] | 512 | static void test_enc_dec_aoip_trasp_addr_v4() |
| 513 | { |
| 514 | struct sockaddr_storage enc_addr; |
| 515 | struct sockaddr_storage dec_addr; |
| 516 | struct sockaddr_in enc_addr_in; |
| 517 | struct msgb *msg; |
| 518 | uint8_t rc_enc; |
| 519 | int rc_dec; |
| 520 | |
| 521 | memset(&enc_addr_in, 0, sizeof(enc_addr_in)); |
| 522 | enc_addr_in.sin_family = AF_INET; |
| 523 | enc_addr_in.sin_port = htons(1234); |
| 524 | inet_aton("255.0.255.255", &enc_addr_in.sin_addr); |
| 525 | |
| 526 | memset(&enc_addr, 0, sizeof(enc_addr)); |
| 527 | memcpy(&enc_addr, &enc_addr_in, sizeof(enc_addr_in)); |
| 528 | |
| 529 | msg = msgb_alloc(1024, "output buffer"); |
| 530 | rc_enc = gsm0808_enc_aoip_trasp_addr(msg, &enc_addr); |
| 531 | OSMO_ASSERT(rc_enc == 8); |
| 532 | rc_dec = |
| 533 | gsm0808_dec_aoip_trasp_addr(&dec_addr, msg->data + 2, msg->len - 2); |
| 534 | OSMO_ASSERT(rc_dec == 6); |
| 535 | OSMO_ASSERT(memcmp(&enc_addr, &dec_addr, sizeof(enc_addr)) == 0); |
| 536 | |
| 537 | msgb_free(msg); |
| 538 | } |
| 539 | |
| 540 | static void test_enc_dec_aoip_trasp_addr_v6() |
| 541 | { |
| 542 | struct sockaddr_storage enc_addr; |
| 543 | struct sockaddr_storage dec_addr; |
| 544 | struct sockaddr_in6 enc_addr_in; |
| 545 | struct msgb *msg; |
| 546 | uint8_t rc_enc; |
| 547 | int rc_dec; |
| 548 | |
| 549 | memset(&enc_addr_in, 0, sizeof(enc_addr_in)); |
| 550 | enc_addr_in.sin6_family = AF_INET6; |
| 551 | enc_addr_in.sin6_port = htons(4567); |
| 552 | inet_pton(AF_INET6, "2001:0db8:85a3:08d3:1319:8a2e:0370:7344", |
| 553 | &enc_addr_in.sin6_addr); |
| 554 | |
| 555 | memset(&enc_addr, 0, sizeof(enc_addr)); |
| 556 | memcpy(&enc_addr, &enc_addr_in, sizeof(enc_addr_in)); |
| 557 | |
| 558 | msg = msgb_alloc(1024, "output buffer"); |
| 559 | rc_enc = gsm0808_enc_aoip_trasp_addr(msg, &enc_addr); |
| 560 | OSMO_ASSERT(rc_enc == 20); |
| 561 | rc_dec = |
| 562 | gsm0808_dec_aoip_trasp_addr(&dec_addr, msg->data + 2, msg->len - 2); |
| 563 | OSMO_ASSERT(rc_dec == 18); |
| 564 | OSMO_ASSERT(memcmp(&enc_addr, &dec_addr, sizeof(enc_addr)) == 0); |
| 565 | |
| 566 | msgb_free(msg); |
| 567 | } |
| 568 | |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 569 | static void test_gsm0808_enc_dec_speech_codec() |
| 570 | { |
| 571 | struct gsm0808_speech_codec enc_sc; |
| 572 | struct gsm0808_speech_codec dec_sc; |
| 573 | struct msgb *msg; |
| 574 | uint8_t rc_enc; |
| 575 | int rc_dec; |
| 576 | |
| 577 | memset(&enc_sc, 0, sizeof(enc_sc)); |
| 578 | enc_sc.fi = true; |
| 579 | enc_sc.pt = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 580 | enc_sc.type = GSM0808_SCT_FR2; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 581 | |
| 582 | msg = msgb_alloc(1024, "output buffer"); |
| 583 | rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc); |
| 584 | OSMO_ASSERT(rc_enc == 3); |
| 585 | |
| 586 | rc_dec = gsm0808_dec_speech_codec(&dec_sc, msg->data + 2, msg->len - 2); |
| 587 | OSMO_ASSERT(rc_dec == 1); |
| 588 | |
| 589 | OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0); |
| 590 | |
| 591 | msgb_free(msg); |
| 592 | } |
| 593 | |
| 594 | |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 595 | static void test_gsm0808_enc_dec_speech_codec_with_cfg() |
| 596 | { |
| 597 | struct gsm0808_speech_codec enc_sc; |
| 598 | struct gsm0808_speech_codec dec_sc; |
| 599 | struct msgb *msg; |
| 600 | uint8_t rc_enc; |
| 601 | int rc_dec; |
| 602 | |
| 603 | enc_sc.pi = true; |
| 604 | enc_sc.tf = true; |
| 605 | enc_sc.type = GSM0808_SCT_FR3; |
| 606 | enc_sc.cfg = 0xabcd; |
| 607 | |
| 608 | msg = msgb_alloc(1024, "output buffer"); |
| 609 | rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc); |
| 610 | OSMO_ASSERT(rc_enc == 5); |
| 611 | |
| 612 | rc_dec = gsm0808_dec_speech_codec(&dec_sc, msg->data + 2, msg->len - 2); |
| 613 | OSMO_ASSERT(rc_dec == 3); |
| 614 | |
| 615 | OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0); |
| 616 | |
| 617 | msgb_free(msg); |
| 618 | } |
| 619 | |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 620 | static void test_gsm0808_enc_dec_speech_codec_ext_with_cfg() |
| 621 | { |
| 622 | struct gsm0808_speech_codec enc_sc; |
| 623 | struct gsm0808_speech_codec dec_sc; |
| 624 | struct msgb *msg; |
| 625 | uint8_t rc_enc; |
| 626 | int rc_dec; |
| 627 | |
| 628 | enc_sc.pi = true; |
| 629 | enc_sc.tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 630 | enc_sc.type = GSM0808_SCT_CSD; |
| 631 | enc_sc.cfg = 0xc0; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 632 | |
| 633 | msg = msgb_alloc(1024, "output buffer"); |
| 634 | rc_enc = gsm0808_enc_speech_codec(msg, &enc_sc); |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 635 | OSMO_ASSERT(rc_enc == 5); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 636 | |
| 637 | 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] | 638 | OSMO_ASSERT(rc_dec == 3); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 639 | |
| 640 | OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0); |
| 641 | |
| 642 | msgb_free(msg); |
| 643 | } |
| 644 | |
| 645 | static void test_gsm0808_enc_dec_speech_codec_list() |
| 646 | { |
| 647 | struct gsm0808_speech_codec_list enc_scl; |
| 648 | struct gsm0808_speech_codec_list dec_scl; |
| 649 | struct msgb *msg; |
| 650 | uint8_t rc_enc; |
| 651 | int rc_dec; |
| 652 | |
| 653 | memset(&enc_scl, 0, sizeof(enc_scl)); |
| 654 | |
| 655 | enc_scl.codec[0].pi = true; |
| 656 | enc_scl.codec[0].tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 657 | enc_scl.codec[0].type = GSM0808_SCT_FR3; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 658 | enc_scl.codec[0].cfg = 0xcdef; |
| 659 | |
| 660 | enc_scl.codec[1].fi = true; |
| 661 | enc_scl.codec[1].pt = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 662 | enc_scl.codec[1].type = GSM0808_SCT_FR2; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 663 | |
| 664 | enc_scl.codec[2].fi = true; |
| 665 | enc_scl.codec[2].tf = true; |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 666 | enc_scl.codec[2].type = GSM0808_SCT_CSD; |
| 667 | enc_scl.codec[2].cfg = 0xc0; |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 668 | |
| 669 | enc_scl.len = 3; |
| 670 | |
| 671 | msg = msgb_alloc(1024, "output buffer"); |
| 672 | rc_enc = gsm0808_enc_speech_codec_list(msg, &enc_scl); |
| 673 | OSMO_ASSERT(rc_enc == 9); |
| 674 | |
| 675 | rc_dec = gsm0808_dec_speech_codec_list(&dec_scl, msg->data + 2, msg->len - 2); |
| 676 | OSMO_ASSERT(rc_dec == 7); |
| 677 | |
| 678 | OSMO_ASSERT(memcmp(&enc_scl, &dec_scl, sizeof(enc_scl)) == 0); |
| 679 | |
| 680 | msgb_free(msg); |
| 681 | } |
| 682 | |
Philipp Maier | e0c6530 | 2017-03-28 17:05:40 +0200 | [diff] [blame] | 683 | static void test_gsm0808_enc_dec_channel_type() |
| 684 | { |
| 685 | struct gsm0808_channel_type enc_ct; |
| 686 | struct gsm0808_channel_type dec_ct; |
| 687 | struct msgb *msg; |
| 688 | uint8_t ct_enc_expected[] = { GSM0808_IE_CHANNEL_TYPE, |
| 689 | 0x04, 0x01, 0x0b, 0xa1, 0x25 |
| 690 | }; |
| 691 | uint8_t rc_enc; |
| 692 | int rc_dec; |
| 693 | |
| 694 | memset(&enc_ct, 0, sizeof(enc_ct)); |
| 695 | enc_ct.ch_indctr = GSM0808_CHAN_SPEECH; |
| 696 | enc_ct.ch_rate_type = GSM0808_SPEECH_HALF_PREF; |
| 697 | enc_ct.perm_spch[0] = GSM0808_PERM_FR3; |
| 698 | enc_ct.perm_spch[1] = GSM0808_PERM_HR3; |
| 699 | enc_ct.perm_spch_len = 2; |
| 700 | |
| 701 | msg = msgb_alloc(1024, "output buffer"); |
| 702 | rc_enc = gsm0808_enc_channel_type(msg, &enc_ct); |
| 703 | OSMO_ASSERT(rc_enc == 6); |
| 704 | OSMO_ASSERT(memcmp(ct_enc_expected, msg->data, msg->len) == 0); |
| 705 | |
| 706 | rc_dec = gsm0808_dec_channel_type(&dec_ct, msg->data + 2, msg->len - 2); |
| 707 | OSMO_ASSERT(rc_dec == 4); |
| 708 | OSMO_ASSERT(memcmp(&enc_ct, &dec_ct, sizeof(enc_ct)) == 0); |
| 709 | |
| 710 | msgb_free(msg); |
| 711 | } |
| 712 | |
Philipp Maier | 14e76b9 | 2017-03-28 18:36:52 +0200 | [diff] [blame] | 713 | static void test_gsm0808_enc_dec_encrypt_info() |
| 714 | { |
| 715 | struct gsm0808_encrypt_info enc_ei; |
| 716 | struct gsm0808_encrypt_info dec_ei; |
| 717 | struct msgb *msg; |
| 718 | uint8_t ei_enc_expected[] = |
| 719 | { GSM0808_IE_ENCRYPTION_INFORMATION, 0x09, 0x03, 0xaa, 0xbb, |
| 720 | 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42 |
| 721 | }; |
| 722 | uint8_t rc_enc; |
| 723 | int rc_dec; |
| 724 | |
| 725 | memset(&enc_ei, 0, sizeof(enc_ei)); |
| 726 | enc_ei.perm_algo[0] = GSM0808_ALG_ID_A5_0; |
| 727 | enc_ei.perm_algo[1] = GSM0808_ALG_ID_A5_1; |
| 728 | enc_ei.perm_algo_len = 2; |
| 729 | enc_ei.key[0] = 0xaa; |
| 730 | enc_ei.key[1] = 0xbb; |
| 731 | enc_ei.key[2] = 0xcc; |
| 732 | enc_ei.key[3] = 0xdd; |
| 733 | enc_ei.key[4] = 0xee; |
| 734 | enc_ei.key[5] = 0xff; |
| 735 | enc_ei.key[6] = 0x23; |
| 736 | enc_ei.key[7] = 0x42; |
| 737 | enc_ei.key_len = 8; |
| 738 | |
| 739 | msg = msgb_alloc(1024, "output buffer"); |
| 740 | rc_enc = gsm0808_enc_encrypt_info(msg, &enc_ei); |
| 741 | OSMO_ASSERT(rc_enc == 11); |
| 742 | OSMO_ASSERT(memcmp(ei_enc_expected, msg->data, msg->len) == 0); |
| 743 | |
| 744 | rc_dec = gsm0808_dec_encrypt_info(&dec_ei, msg->data + 2, msg->len - 2); |
| 745 | OSMO_ASSERT(rc_dec == 9); |
| 746 | |
| 747 | OSMO_ASSERT(memcmp(&enc_ei, &dec_ei, sizeof(enc_ei)) == 0); |
| 748 | |
| 749 | msgb_free(msg); |
| 750 | } |
| 751 | |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 752 | static void test_gsm0808_enc_dec_cell_id_list_lac() |
| 753 | { |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 754 | struct gsm0808_cell_id_list2 enc_cil; |
| 755 | struct gsm0808_cell_id_list2 dec_cil; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 756 | struct msgb *msg; |
| 757 | uint8_t rc_enc; |
| 758 | int rc_dec; |
| 759 | |
| 760 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 761 | enc_cil.id_discr = CELL_IDENT_LAC; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 762 | enc_cil.id_list[0].lac = 0x0124; |
| 763 | enc_cil.id_list[0].lac = 0xABCD; |
| 764 | enc_cil.id_list[0].lac = 0x5678; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 765 | enc_cil.id_list_len = 3; |
| 766 | |
| 767 | msg = msgb_alloc(1024, "output buffer"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 768 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 769 | OSMO_ASSERT(rc_enc == 9); |
| 770 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 771 | 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] | 772 | OSMO_ASSERT(rc_dec == 7); |
| 773 | |
| 774 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 775 | |
| 776 | msgb_free(msg); |
| 777 | } |
| 778 | |
| 779 | static void test_gsm0808_enc_dec_cell_id_list_single_lac() |
| 780 | { |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 781 | struct gsm0808_cell_id_list2 enc_cil; |
| 782 | struct gsm0808_cell_id_list2 dec_cil; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 783 | struct msgb *msg; |
| 784 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x03, |
| 785 | 0x05, 0x23, 0x42 |
| 786 | }; |
| 787 | uint8_t rc_enc; |
| 788 | int rc_dec; |
| 789 | |
| 790 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 791 | enc_cil.id_discr = CELL_IDENT_LAC; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 792 | enc_cil.id_list[0].lac = 0x2342; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 793 | enc_cil.id_list_len = 1; |
| 794 | |
| 795 | msg = msgb_alloc(1024, "output buffer"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 796 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 797 | OSMO_ASSERT(rc_enc == 5); |
| 798 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 799 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 800 | 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] | 801 | OSMO_ASSERT(rc_dec == 3); |
| 802 | |
| 803 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 804 | |
| 805 | msgb_free(msg); |
| 806 | } |
| 807 | |
Stefan Sperling | e1a8674 | 2018-03-15 18:05:02 +0100 | [diff] [blame] | 808 | static void test_gsm0808_enc_dec_cell_id_list_multi_lac() |
| 809 | { |
| 810 | struct gsm0808_cell_id_list2 enc_cil; |
| 811 | struct gsm0808_cell_id_list2 dec_cil; |
| 812 | struct msgb *msg; |
| 813 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x0b, 0x05, |
| 814 | 0x23, 0x42, |
| 815 | 0x24, 0x43, |
| 816 | 0x25, 0x44, |
| 817 | 0x26, 0x45, |
| 818 | 0x27, 0x46 |
| 819 | }; |
| 820 | uint8_t rc_enc; |
| 821 | int rc_dec; |
| 822 | |
| 823 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 824 | enc_cil.id_discr = CELL_IDENT_LAC; |
| 825 | enc_cil.id_list[0].lac = 0x2342; |
| 826 | enc_cil.id_list[1].lac = 0x2443; |
| 827 | enc_cil.id_list[2].lac = 0x2544; |
| 828 | enc_cil.id_list[3].lac = 0x2645; |
| 829 | enc_cil.id_list[4].lac = 0x2746; |
| 830 | enc_cil.id_list_len = 5; |
| 831 | |
| 832 | msg = msgb_alloc(1024, "output buffer"); |
| 833 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 834 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 835 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 836 | |
| 837 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 838 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 839 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 840 | |
| 841 | msgb_free(msg); |
| 842 | } |
| 843 | |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 844 | static void test_gsm0808_enc_dec_cell_id_list_bss() |
| 845 | { |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 846 | struct gsm0808_cell_id_list2 enc_cil; |
| 847 | struct gsm0808_cell_id_list2 dec_cil; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 848 | struct msgb *msg; |
| 849 | uint8_t rc_enc; |
| 850 | int rc_dec; |
| 851 | |
| 852 | memset(&enc_cil, 0, sizeof(enc_cil)); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 853 | enc_cil.id_discr = CELL_IDENT_BSS; |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 854 | |
| 855 | msg = msgb_alloc(1024, "output buffer"); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 856 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 857 | OSMO_ASSERT(rc_enc == 3); |
| 858 | |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 859 | 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] | 860 | OSMO_ASSERT(rc_dec == 1); |
| 861 | |
| 862 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 863 | |
| 864 | msgb_free(msg); |
| 865 | } |
| 866 | |
Stefan Sperling | 2338145 | 2018-03-15 19:38:15 +0100 | [diff] [blame] | 867 | static void test_gsm0808_enc_dec_cell_id_list_multi_lai_and_lac() |
| 868 | { |
| 869 | struct gsm0808_cell_id_list2 enc_cil; |
| 870 | struct gsm0808_cell_id_list2 dec_cil; |
| 871 | struct osmo_location_area_id id; |
| 872 | struct msgb *msg; |
| 873 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x10, 0x04, |
| 874 | 0x92, 0x61, 0x54, 0x23, 0x42, |
| 875 | 0x92, 0x72, 0x54, 0x24, 0x43, |
| 876 | 0x92, 0x83, 0x54, 0x25, 0x44 |
| 877 | }; |
| 878 | uint8_t rc_enc; |
| 879 | int rc_dec, i; |
| 880 | |
| 881 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 882 | enc_cil.id_discr = CELL_IDENT_LAI_AND_LAC; |
| 883 | |
| 884 | id.plmn.mcc = 0x123; |
| 885 | osmo_mnc_from_str("456", &id.plmn.mnc, &id.plmn.mnc_3_digits); |
| 886 | id.lac = 0x2342; |
| 887 | memcpy(&enc_cil.id_list[0].lai_and_lac, &id, sizeof(id)); |
| 888 | |
| 889 | id.plmn.mcc = 0x124; |
| 890 | osmo_mnc_from_str("457", &id.plmn.mnc, &id.plmn.mnc_3_digits); |
| 891 | id.lac = 0x2443; |
| 892 | memcpy(&enc_cil.id_list[1].lai_and_lac, &id, sizeof(id)); |
| 893 | |
| 894 | id.plmn.mcc = 0x125; |
| 895 | osmo_mnc_from_str("458", &id.plmn.mnc, &id.plmn.mnc_3_digits); |
| 896 | id.lac = 0x2544; |
| 897 | memcpy(&enc_cil.id_list[2].lai_and_lac, &id, sizeof(id)); |
| 898 | |
| 899 | enc_cil.id_list_len = 3; |
| 900 | |
| 901 | msg = msgb_alloc(1024, "output buffer"); |
| 902 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 903 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 904 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 905 | |
| 906 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 907 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 908 | |
| 909 | OSMO_ASSERT(dec_cil.id_list_len == 3); |
| 910 | /* Check MAXLEN elements to ensure everything has been initialized. */ |
| 911 | for (i = 0; i < GSM0808_CELL_ID_LIST2_MAXLEN; i++) { |
| 912 | struct osmo_location_area_id *enc_id; |
| 913 | struct osmo_location_area_id *dec_id; |
| 914 | enc_id = &enc_cil.id_list[i].lai_and_lac; |
| 915 | dec_id = &dec_cil.id_list[i].lai_and_lac; |
| 916 | OSMO_ASSERT(osmo_plmn_cmp(&enc_id->plmn, &dec_id->plmn) == 0); |
| 917 | OSMO_ASSERT(enc_id->lac == dec_id->lac); |
| 918 | } |
| 919 | |
| 920 | msgb_free(msg); |
| 921 | } |
| 922 | |
Stefan Sperling | 9c62fc6 | 2018-03-16 10:23:34 +0100 | [diff] [blame] | 923 | static void test_gsm0808_enc_dec_cell_id_list_multi_ci() |
| 924 | { |
| 925 | struct gsm0808_cell_id_list2 enc_cil; |
| 926 | struct gsm0808_cell_id_list2 dec_cil; |
| 927 | struct msgb *msg; |
| 928 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x09, 0x02, |
| 929 | 0x00, 0x01, |
| 930 | 0x00, 0x02, |
| 931 | 0x00, 0x77, |
| 932 | 0x01, 0xff, |
| 933 | }; |
| 934 | uint8_t rc_enc; |
| 935 | int rc_dec; |
| 936 | |
| 937 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 938 | enc_cil.id_discr = CELL_IDENT_CI; |
| 939 | enc_cil.id_list[0].ci = 1; |
| 940 | enc_cil.id_list[1].ci = 2; |
| 941 | enc_cil.id_list[2].ci = 119; |
| 942 | enc_cil.id_list[3].ci = 511; |
| 943 | enc_cil.id_list_len = 4; |
| 944 | |
| 945 | msg = msgb_alloc(1024, "output buffer"); |
| 946 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 947 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 948 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 949 | |
| 950 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 951 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 952 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 953 | |
| 954 | msgb_free(msg); |
| 955 | } |
| 956 | |
Stefan Sperling | ed4327c | 2018-03-16 11:02:59 +0100 | [diff] [blame] | 957 | static void test_gsm0808_enc_dec_cell_id_list_multi_lac_and_ci() |
| 958 | { |
| 959 | struct gsm0808_cell_id_list2 enc_cil; |
| 960 | struct gsm0808_cell_id_list2 dec_cil; |
| 961 | struct msgb *msg; |
| 962 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x15, 0x01, |
| 963 | 0x23, 0x42, 0x00, 0x01, |
| 964 | 0x24, 0x43, 0x00, 0x02, |
| 965 | 0x25, 0x44, 0x00, 0x77, |
| 966 | 0x26, 0x45, 0x01, 0xff, |
| 967 | 0x27, 0x46, 0x02, 0xfe, |
| 968 | }; |
| 969 | uint8_t rc_enc; |
| 970 | int rc_dec; |
| 971 | |
| 972 | memset(&enc_cil, 0, sizeof(enc_cil)); |
| 973 | enc_cil.id_discr = CELL_IDENT_LAC_AND_CI; |
| 974 | enc_cil.id_list[0].lac_and_ci.lac = 0x2342; |
| 975 | enc_cil.id_list[0].lac_and_ci.ci = 1; |
| 976 | enc_cil.id_list[1].lac_and_ci.lac = 0x2443; |
| 977 | enc_cil.id_list[1].lac_and_ci.ci = 2; |
| 978 | enc_cil.id_list[2].lac_and_ci.lac = 0x2544; |
| 979 | enc_cil.id_list[2].lac_and_ci.ci = 119; |
| 980 | enc_cil.id_list[3].lac_and_ci.lac = 0x2645; |
| 981 | enc_cil.id_list[3].lac_and_ci.ci = 511; |
| 982 | enc_cil.id_list[4].lac_and_ci.lac = 0x2746; |
| 983 | enc_cil.id_list[4].lac_and_ci.ci = 766; |
| 984 | enc_cil.id_list_len = 5; |
| 985 | |
| 986 | msg = msgb_alloc(1024, "output buffer"); |
| 987 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 988 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
| 989 | OSMO_ASSERT(memcmp(cil_enc_expected, msg->data, msg->len) == 0); |
| 990 | |
| 991 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 992 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 993 | OSMO_ASSERT(memcmp(&enc_cil, &dec_cil, sizeof(enc_cil)) == 0); |
| 994 | |
| 995 | msgb_free(msg); |
| 996 | } |
| 997 | |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 998 | static void test_gsm0808_enc_dec_cell_id_list_multi_global() |
| 999 | { |
| 1000 | struct gsm0808_cell_id_list2 enc_cil; |
| 1001 | struct gsm0808_cell_id_list2 dec_cil; |
| 1002 | struct msgb *msg; |
| 1003 | uint8_t cil_enc_expected[] = { GSM0808_IE_CELL_IDENTIFIER_LIST, 0x16, 0x00, |
Neels Hofmeyr | 473485c | 2018-03-23 02:04:18 +0100 | [diff] [blame] | 1004 | 0x21, 0x63, 0x54, 0x23, 0x42, 0x00, 0x1, |
Neels Hofmeyr | c44fc23 | 2018-03-23 02:15:12 +0100 | [diff] [blame] | 1005 | 0x21, 0xf4, 0x75, 0x24, 0x43, 0x00, 0x2, |
Neels Hofmeyr | 8b8cd93 | 2018-03-23 01:47:37 +0100 | [diff] [blame] | 1006 | 0x21, 0x75, 0x00, 0x25, 0x44, 0x00, 0x77 |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1007 | }; |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1008 | uint8_t rc_enc; |
| 1009 | int rc_dec, i; |
| 1010 | |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1011 | enc_cil = (struct gsm0808_cell_id_list2){ |
| 1012 | .id_discr = CELL_IDENT_WHOLE_GLOBAL, |
| 1013 | .id_list_len = 3, |
| 1014 | .id_list = { |
| 1015 | { |
| 1016 | .global = { |
Neels Hofmeyr | 473485c | 2018-03-23 02:04:18 +0100 | [diff] [blame] | 1017 | .lai = { .plmn = { .mcc = 123, .mnc = 456 }, |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1018 | .lac = 0x2342 }, |
| 1019 | .cell_identity = 1, |
| 1020 | } |
| 1021 | }, |
| 1022 | { |
| 1023 | .global = { |
Neels Hofmeyr | c44fc23 | 2018-03-23 02:15:12 +0100 | [diff] [blame] | 1024 | .lai = { .plmn = { .mcc = 124, .mnc = 57 }, |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1025 | .lac = 0x2443 }, |
| 1026 | .cell_identity = 2, |
| 1027 | } |
| 1028 | }, |
| 1029 | { |
| 1030 | .global = { |
Neels Hofmeyr | c44fc23 | 2018-03-23 02:15:12 +0100 | [diff] [blame] | 1031 | .lai = { .plmn = { .mcc = 125, .mnc = 7, |
| 1032 | .mnc_3_digits = true }, |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1033 | .lac = 0x2544 }, |
| 1034 | .cell_identity = 119, |
| 1035 | } |
| 1036 | }, |
| 1037 | } |
| 1038 | }; |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1039 | |
| 1040 | msg = msgb_alloc(1024, "output buffer"); |
| 1041 | rc_enc = gsm0808_enc_cell_id_list2(msg, &enc_cil); |
| 1042 | OSMO_ASSERT(rc_enc == sizeof(cil_enc_expected)); |
Neels Hofmeyr | c1991df | 2018-03-23 02:00:00 +0100 | [diff] [blame] | 1043 | if (memcmp(cil_enc_expected, msg->data, msg->len)) { |
| 1044 | printf(" got: %s\n", osmo_hexdump(msg->data, msg->len)); |
| 1045 | printf("expect: %s\n", osmo_hexdump(cil_enc_expected, sizeof(cil_enc_expected))); |
| 1046 | OSMO_ASSERT(false); |
| 1047 | } |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1048 | |
| 1049 | rc_dec = gsm0808_dec_cell_id_list2(&dec_cil, msg->data + 2, msg->len - 2); |
| 1050 | OSMO_ASSERT(rc_dec == msg->len - 2); |
| 1051 | |
| 1052 | /* Check MAXLEN elements to ensure everything has been initialized. */ |
| 1053 | for (i = 0; i < GSM0808_CELL_ID_LIST2_MAXLEN; i++) { |
| 1054 | struct osmo_cell_global_id *enc_id; |
| 1055 | struct osmo_cell_global_id *dec_id; |
| 1056 | enc_id = &enc_cil.id_list[i].global; |
| 1057 | dec_id = &dec_cil.id_list[i].global; |
| 1058 | OSMO_ASSERT(osmo_plmn_cmp(&enc_id->lai.plmn, &dec_id->lai.plmn) == 0); |
| 1059 | OSMO_ASSERT(enc_id->lai.lac == dec_id->lai.lac); |
| 1060 | OSMO_ASSERT(enc_id->cell_identity == dec_id->cell_identity); |
| 1061 | } |
| 1062 | |
| 1063 | msgb_free(msg); |
| 1064 | } |
| 1065 | |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1066 | int main(int argc, char **argv) |
| 1067 | { |
| 1068 | printf("Testing generation of GSM0808 messages\n"); |
| 1069 | test_create_layer3(); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 1070 | test_create_layer3_aoip(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1071 | test_create_reset(); |
Philipp Maier | 15596e2 | 2017-04-05 17:55:27 +0200 | [diff] [blame] | 1072 | test_create_reset_ack(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1073 | test_create_clear_command(); |
| 1074 | test_create_clear_complete(); |
Philipp Maier | b478dd3 | 2017-03-29 15:50:05 +0200 | [diff] [blame] | 1075 | test_create_cipher(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1076 | test_create_cipher_complete(); |
| 1077 | test_create_cipher_reject(); |
| 1078 | test_create_cm_u(); |
| 1079 | test_create_sapi_reject(); |
Philipp Maier | c6144a2 | 2017-03-29 17:53:43 +0200 | [diff] [blame] | 1080 | test_create_ass(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1081 | test_create_ass_compl(); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 1082 | test_create_ass_compl_aoip(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1083 | test_create_ass_fail(); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 1084 | test_create_ass_fail_aoip(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1085 | test_create_clear_rqst(); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 1086 | test_create_paging(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1087 | test_create_dtap(); |
| 1088 | test_prepend_dtap(); |
Philipp Maier | 2240143 | 2017-03-24 17:59:26 +0100 | [diff] [blame] | 1089 | test_enc_dec_aoip_trasp_addr_v4(); |
| 1090 | test_enc_dec_aoip_trasp_addr_v6(); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 1091 | test_gsm0808_enc_dec_speech_codec(); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 1092 | test_gsm0808_enc_dec_speech_codec_ext_with_cfg(); |
Philipp Maier | bb83966 | 2017-06-01 17:11:19 +0200 | [diff] [blame] | 1093 | test_gsm0808_enc_dec_speech_codec_with_cfg(); |
Philipp Maier | 6f725d6 | 2017-03-24 18:03:17 +0100 | [diff] [blame] | 1094 | test_gsm0808_enc_dec_speech_codec_list(); |
Philipp Maier | e0c6530 | 2017-03-28 17:05:40 +0200 | [diff] [blame] | 1095 | test_gsm0808_enc_dec_channel_type(); |
Philipp Maier | 14e76b9 | 2017-03-28 18:36:52 +0200 | [diff] [blame] | 1096 | test_gsm0808_enc_dec_encrypt_info(); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 1097 | test_gsm0808_enc_dec_cell_id_list_lac(); |
| 1098 | test_gsm0808_enc_dec_cell_id_list_single_lac(); |
Stefan Sperling | e1a8674 | 2018-03-15 18:05:02 +0100 | [diff] [blame] | 1099 | test_gsm0808_enc_dec_cell_id_list_multi_lac(); |
Philipp Maier | 783047e | 2017-03-29 11:35:50 +0200 | [diff] [blame] | 1100 | test_gsm0808_enc_dec_cell_id_list_bss(); |
Stefan Sperling | 2338145 | 2018-03-15 19:38:15 +0100 | [diff] [blame] | 1101 | test_gsm0808_enc_dec_cell_id_list_multi_lai_and_lac(); |
Stefan Sperling | 9c62fc6 | 2018-03-16 10:23:34 +0100 | [diff] [blame] | 1102 | test_gsm0808_enc_dec_cell_id_list_multi_ci(); |
Stefan Sperling | ed4327c | 2018-03-16 11:02:59 +0100 | [diff] [blame] | 1103 | test_gsm0808_enc_dec_cell_id_list_multi_lac_and_ci(); |
Stefan Sperling | 483f386 | 2018-03-16 12:21:26 +0100 | [diff] [blame] | 1104 | test_gsm0808_enc_dec_cell_id_list_multi_global(); |
Holger Hans Peter Freyther | 9751081 | 2012-01-22 13:36:52 +0100 | [diff] [blame] | 1105 | |
| 1106 | printf("Done\n"); |
| 1107 | return EXIT_SUCCESS; |
| 1108 | } |