blob: 0f908e5912f53fff3b8d094068aafe542e0c1888 [file] [log] [blame]
Philipp Maier844876f2018-07-13 09:17:07 +02001/*
2 * (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
3 * All Rights Reserved
4 *
5 * Author: Philipp Maier
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include <osmocom/bsc/osmo_bsc.h>
23#include <osmocom/bsc/bsc_msc_data.h>
24#include <osmocom/bsc/gsm_04_80.h>
25#include <osmocom/core/application.h>
26#include <osmocom/bsc/codec_pref.h>
27
28#include <stdio.h>
29
30void *ctx = NULL;
31
32#define MSC_AUDIO_SUPPORT_MAX 5
33#define N_CONFIG_VARIANTS 9
34
35/* Make sure that there is some memory to put our test configuration. */
36static void init_msc_config(struct bsc_msc_data *msc)
37{
38 unsigned int i;
39
40 msc->audio_support = talloc_zero_array(ctx, struct gsm_audio_support *, MSC_AUDIO_SUPPORT_MAX);
41 msc->audio_length = MSC_AUDIO_SUPPORT_MAX;
42 for (i = 0; i < MSC_AUDIO_SUPPORT_MAX; i++) {
43 msc->audio_support[i] = talloc_zero(msc->audio_support, struct gsm_audio_support);
44 }
45}
46
47/* Free memory that we have used for the test configuration. */
48static void free_msc_config(struct bsc_msc_data *msc)
49{
50 talloc_free(msc->audio_support);
51}
52
53/* The speech codec list is sent by the MS and lists the voice codec settings
54 * that the MS is able to support. The BSC must select one of this codecs
55 * depending on what the MSC is able to support. The following function
56 * generates some realistically made up speech codec lists. */
57static void make_scl_config(struct gsm0808_speech_codec_list *scl, uint8_t config_no)
58{
59 OSMO_ASSERT(config_no < N_CONFIG_VARIANTS);
60
61 switch (config_no) {
62 case 0:
63 /* FR1 only */
64 scl->codec[0].type = GSM0808_SCT_FR1;
65 scl->len = 1;
66 break;
67 case 1:
68 /* HR1 only */
69 scl->codec[0].type = GSM0808_SCT_HR1;
70 scl->len = 1;
71 break;
72 case 2:
73 /* FR2 only */
74 scl->codec[0].type = GSM0808_SCT_FR2;
75 scl->len = 1;
76 break;
77 case 3:
78 /* FR3 only */
79 scl->codec[0].type = GSM0808_SCT_FR3;
80 scl->len = 1;
81 break;
82 case 4:
83 /* HR3 only */
84 scl->codec[0].type = GSM0808_SCT_HR3;
85 scl->len = 1;
86 break;
87 case 5:
88 /* FR1 and HR1 */
89 scl->codec[0].type = GSM0808_SCT_FR1;
90 scl->codec[1].type = GSM0808_SCT_HR1;
91 scl->len = 2;
92 break;
93 case 6:
94 /* FR1, FR2 and HR1 */
95 scl->codec[0].type = GSM0808_SCT_FR1;
96 scl->codec[1].type = GSM0808_SCT_FR2;
97 scl->codec[2].type = GSM0808_SCT_HR1;
98 scl->len = 3;
99 break;
100 case 7:
101 /* FR1, FR3 and HR3 */
102 scl->codec[0].type = GSM0808_SCT_FR1;
103 scl->codec[1].type = GSM0808_SCT_FR3;
104 scl->codec[2].type = GSM0808_SCT_HR3;
105 scl->len = 3;
106 break;
107 case 8:
108 /* FR1, FR2, FR3, HR1 and HR3 */
109 scl->codec[0].type = GSM0808_SCT_FR1;
110 scl->codec[1].type = GSM0808_SCT_FR2;
111 scl->codec[2].type = GSM0808_SCT_FR3;
112 scl->codec[3].type = GSM0808_SCT_HR1;
113 scl->codec[4].type = GSM0808_SCT_HR3;
114 scl->len = 5;
115 break;
116 }
117}
118
119/* The channel type element which is sent to the BSC by the MSC lists all the
120 * codecs that the MSC is able to support. The following function generates
121 * a realistic permitted speech settings */
122static void make_ct_config(struct gsm0808_channel_type *ct, uint8_t config_no)
123{
124 OSMO_ASSERT(config_no < N_CONFIG_VARIANTS);
125
126 switch (config_no) {
127 case 0:
128 /* FR1 only */
129 ct->perm_spch[0] = GSM0808_PERM_FR1;
130 ct->perm_spch_len = 1;
131 break;
132 case 1:
133 /* HR1 only */
134 ct->perm_spch[0] = GSM0808_PERM_HR1;
135 ct->perm_spch_len = 1;
136 break;
137 case 2:
138 /* FR2 only */
139 ct->perm_spch[0] = GSM0808_PERM_FR2;
140 ct->perm_spch_len = 1;
141 break;
142 case 3:
143 /* FR3 only */
144 ct->perm_spch[0] = GSM0808_PERM_FR3;
145 ct->perm_spch_len = 1;
146 break;
147 case 4:
148 /* HR3 only */
149 ct->perm_spch[0] = GSM0808_PERM_HR3;
150 ct->perm_spch_len = 1;
151 break;
152 case 5:
153 /* FR1 and HR1 */
154 ct->perm_spch[0] = GSM0808_PERM_FR1;
155 ct->perm_spch[1] = GSM0808_PERM_HR1;
156 ct->perm_spch_len = 2;
157 break;
158 case 6:
159 /* FR1, FR2 and HR1 */
160 ct->perm_spch[0] = GSM0808_PERM_FR1;
161 ct->perm_spch[1] = GSM0808_PERM_FR2;
162 ct->perm_spch[2] = GSM0808_PERM_HR1;
163 ct->perm_spch_len = 3;
164 break;
165 case 7:
166 /* FR1, FR3 and HR3 */
167 ct->perm_spch[0] = GSM0808_PERM_FR1;
168 ct->perm_spch[1] = GSM0808_PERM_FR3;
169 ct->perm_spch[2] = GSM0808_PERM_HR3;
170 ct->perm_spch_len = 3;
171 break;
172 case 8:
173 /* FR1, FR2, FR3, HR1 and HR3 */
174 ct->perm_spch[0] = GSM0808_PERM_FR1;
175 ct->perm_spch[1] = GSM0808_PERM_FR2;
176 ct->perm_spch[2] = GSM0808_PERM_FR3;
177 ct->perm_spch[3] = GSM0808_PERM_HR1;
178 ct->perm_spch[4] = GSM0808_PERM_HR3;
179 ct->perm_spch_len = 5;
180 break;
181 }
182}
183
184/* Generate some realistic MSC configuration which one also could find in the
185 * real world. This configuration acts as a filter. While the MSC could in
186 * theory advertise codecs more codecs as we are able to support we have to
187 * make sure that only the codecs we have support for are considered. */
188static void make_msc_config(struct bsc_msc_data *msc, uint8_t config_no)
189{
190 /* 1 = FR1/HR1
191 * 2 = FR2/HR2
192 * 3 = FR2/HR3
193 * Note: HR2 is deprecated */
194
195 OSMO_ASSERT(config_no < N_CONFIG_VARIANTS);
196
197 switch (config_no) {
198 case 0:
199 /* FR1 only */
200 msc->audio_support[0]->ver = 1;
201 msc->audio_support[0]->hr = 0;
202 msc->audio_length = 1;
203 break;
204 case 1:
205 /* HR1 only */
206 msc->audio_support[0]->ver = 1;
207 msc->audio_support[0]->hr = 1;
208 msc->audio_length = 1;
209 break;
210 case 2:
211 /* FR2 only */
212 msc->audio_support[0]->ver = 2;
213 msc->audio_support[0]->hr = 0;
214 msc->audio_length = 1;
215 break;
216 case 3:
217 /* FR3 only */
218 msc->audio_support[0]->ver = 3;
219 msc->audio_support[0]->hr = 0;
220 msc->audio_length = 1;
221 break;
222 case 4:
223 /* HR3 only */
224 msc->audio_support[0]->ver = 3;
225 msc->audio_support[0]->hr = 1;
226 msc->audio_length = 1;
227 break;
228 case 5:
229 /* FR1 and HR1 */
230 msc->audio_support[0]->ver = 1;
231 msc->audio_support[0]->hr = 0;
232 msc->audio_support[1]->ver = 1;
233 msc->audio_support[1]->hr = 1;
234 msc->audio_length = 2;
235 break;
236 case 6:
237 /* FR1, FR2 and HR1 */
238 msc->audio_support[0]->ver = 1;
239 msc->audio_support[0]->hr = 0;
240 msc->audio_support[1]->ver = 2;
241 msc->audio_support[1]->hr = 0;
242 msc->audio_support[2]->ver = 1;
243 msc->audio_support[2]->hr = 1;
244 msc->audio_length = 3;
245 break;
246 case 7:
247 /* FR1, FR3 and HR3 */
248 msc->audio_support[0]->ver = 1;
249 msc->audio_support[0]->hr = 0;
250 msc->audio_support[1]->ver = 3;
251 msc->audio_support[1]->hr = 0;
252 msc->audio_support[2]->ver = 3;
253 msc->audio_support[2]->hr = 1;
254 msc->audio_length = 3;
255 break;
256 case 8:
257 /* FR1, FR2, FR3, HR1 and HR3 */
258 msc->audio_support[0]->ver = 1;
259 msc->audio_support[0]->hr = 0;
260 msc->audio_support[1]->ver = 2;
261 msc->audio_support[1]->hr = 0;
262 msc->audio_support[2]->ver = 3;
263 msc->audio_support[2]->hr = 0;
264 msc->audio_support[3]->ver = 1;
265 msc->audio_support[3]->hr = 1;
266 msc->audio_support[4]->ver = 3;
267 msc->audio_support[4]->hr = 1;
268 msc->audio_length = 5;
269 break;
270 }
271}
272
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200273/* Generate a realitically looking bts codec configuration */
274static void make_bts_config(struct gsm_bts *bts, uint8_t config_no)
275{
276 /* Note: FR is supported by all BTSs, so there is no flag for it */
277
278 OSMO_ASSERT(config_no < N_CONFIG_VARIANTS);
279
280 bts->codec.hr = 0;
281 bts->codec.efr = 0;
282 bts->codec.amr = 0;
283
284 switch (config_no) {
285 case 0:
286 /* FR1 (implicit) only */
287 break;
288 case 1:
289 /* HR1 only (+FR implicit) */
290 bts->codec.hr = 1;
291 break;
292 case 2:
293 /* FR2 only (+FR implicit) */
294 bts->codec.efr = 1;
295 break;
296 case 3:
297 /* FR3 only (+FR implicit) */
298 bts->codec.amr = 1;
299 break;
300 case 4:
301 /* HR3 only (+FR implicit) */
302 bts->codec.amr = 1;
303 break;
304 case 5:
305 /* FR1 (implicit) and HR1 */
306 bts->codec.hr = 1;
307 break;
308 case 6:
309 /* FR1 (implicit), FR2 and HR1 */
310 bts->codec.efr = 1;
311 bts->codec.hr = 1;
312 break;
313 case 7:
314 /* FR1 (implicit), FR3 and HR3 */
315 bts->codec.amr = 1;
316 break;
317 case 8:
318 /* FR1 (implicit), FR2, FR3, HR1 and HR3 */
319 bts->codec.hr = 1;
320 bts->codec.efr = 1;
321 bts->codec.amr = 1;
322 break;
323 }
324}
325
Philipp Maier844876f2018-07-13 09:17:07 +0200326/* Try execute match_codec_pref(), display input and output parameters */
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200327static int test_match_codec_pref(const struct gsm0808_channel_type *ct, const struct gsm0808_speech_codec_list *scl,
328 const struct bsc_msc_data *msc, struct gsm_bts *bts)
Philipp Maier844876f2018-07-13 09:17:07 +0200329{
330 int rc;
331 unsigned int i;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200332 bool full_rate;
Philipp Maier844876f2018-07-13 09:17:07 +0200333 enum gsm48_chan_mode chan_mode;
334
335 printf("Determining channel mode and rate:\n");
336
337 printf(" * MS: speech codec list (%u items):\n", scl->len);
338 for (i = 0; i < scl->len; i++)
339 printf(" codec[%u]->type=%s\n", i, gsm0808_speech_codec_type_name(scl->codec[i].type));
340
341 printf(" * MSC: channel type permitted speech (%u items):\n", ct->perm_spch_len);
342 for (i = 0; i < ct->perm_spch_len; i++)
343 printf(" perm_spch[%u]=%s\n", i, gsm0808_permitted_speech_name(ct->perm_spch[i]));
344
345 printf(" * BSS: audio support settings (%u items):\n", msc->audio_length);
346 for (i = 0; i < msc->audio_length; i++)
347 if (msc->audio_support[i]->hr)
348 printf(" audio_support[%u]=HR%u\n", i, msc->audio_support[i]->ver);
349 else
350 printf(" audio_support[%u]=FR%u\n", i, msc->audio_support[i]->ver);
351
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200352 printf(" * BTS: audio support settings:\n");
353 printf(" (GSM-FR implicitly supported)\n");
354 printf(" codec->hr=%u\n", bts->codec.hr);
355 printf(" codec->efr=%u\n", bts->codec.efr);
356 printf(" codec->amr=%u\n", bts->codec.amr);
357
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200358 rc = match_codec_pref(&chan_mode, &full_rate, ct, scl, msc->audio_support, msc->audio_length, &bts->codec);
Philipp Maier844876f2018-07-13 09:17:07 +0200359 printf(" * result: rc=%i, full_rate=%i, chan_mode=%s\n", rc, full_rate, gsm48_chan_mode_name(chan_mode));
360
361 printf("\n");
362
363 return rc;
364}
365
366/* MS, MSC and local MSC settings are the same */
367static void test_one_to_one(void)
368{
369 unsigned int i;
370 struct gsm0808_channel_type ct_msc;
371 struct gsm0808_speech_codec_list scl_ms;
372 struct bsc_msc_data msc_local;
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200373 struct gsm_bts bts_local;
Philipp Maier844876f2018-07-13 09:17:07 +0200374 int rc;
375
376 printf("============== test_one_to_one ==============\n\n");
377
378 init_msc_config(&msc_local);
379
380 for (i = 0; i < N_CONFIG_VARIANTS; i++) {
381 make_msc_config(&msc_local, i);
382 make_scl_config(&scl_ms, i);
383 make_ct_config(&ct_msc, i);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200384 make_bts_config(&bts_local, i);
385 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200386 OSMO_ASSERT(rc == 0);
387 }
388
389 free_msc_config(&msc_local);
390}
391
392/* Network supports all combinations, MS varies */
393static void test_ms(void)
394{
395 unsigned int i;
396 struct gsm0808_channel_type ct_msc;
397 struct gsm0808_speech_codec_list scl_ms;
398 struct bsc_msc_data msc_local;
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200399 struct gsm_bts bts_local;
Philipp Maier844876f2018-07-13 09:17:07 +0200400 int rc;
401
402 printf("============== test_ms ==============\n\n");
403
404 init_msc_config(&msc_local);
405
406 make_msc_config(&msc_local, 8);
407 make_ct_config(&ct_msc, 8);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200408 make_bts_config(&bts_local, 8);
Philipp Maier844876f2018-07-13 09:17:07 +0200409 for (i = 0; i < N_CONFIG_VARIANTS; i++) {
410 make_scl_config(&scl_ms, i);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200411 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200412 OSMO_ASSERT(rc == 0);
413 }
414
415 free_msc_config(&msc_local);
416}
417
418/* BSS and MS support all combinations, MSC varies */
419static void test_ct(void)
420{
421 unsigned int i;
422 struct gsm0808_channel_type ct_msc;
423 struct gsm0808_speech_codec_list scl_ms;
424 struct bsc_msc_data msc_local;
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200425 struct gsm_bts bts_local;
Philipp Maier844876f2018-07-13 09:17:07 +0200426 int rc;
427
428 printf("============== test_ct ==============\n\n");
429
430 init_msc_config(&msc_local);
431
432 make_msc_config(&msc_local, 8);
433 make_scl_config(&scl_ms, 8);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200434 make_bts_config(&bts_local, 8);
Philipp Maier844876f2018-07-13 09:17:07 +0200435 for (i = 0; i < N_CONFIG_VARIANTS; i++) {
436 make_ct_config(&ct_msc, i);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200437 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200438 OSMO_ASSERT(rc == 0);
439 }
440
441 free_msc_config(&msc_local);
442}
443
444/* MSC and MS support all combinations, BSS varies */
445static void test_msc(void)
446{
447 unsigned int i;
448 struct gsm0808_channel_type ct_msc;
449 struct gsm0808_speech_codec_list scl_ms;
450 struct bsc_msc_data msc_local;
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200451 struct gsm_bts bts_local;
Philipp Maier844876f2018-07-13 09:17:07 +0200452 int rc;
453
454 printf("============== test_msc ==============\n\n");
455
456 init_msc_config(&msc_local);
457
458 make_ct_config(&ct_msc, 8);
459 make_scl_config(&scl_ms, 8);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200460 make_bts_config(&bts_local, 8);
Philipp Maier844876f2018-07-13 09:17:07 +0200461 for (i = 0; i < N_CONFIG_VARIANTS; i++) {
462 make_msc_config(&msc_local, 8);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200463 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200464 OSMO_ASSERT(rc == 0);
465 }
466
467 free_msc_config(&msc_local);
468}
469
470/* Some mixed configurations that are supposed to work */
471static void test_selected_working(void)
472{
473 struct gsm0808_channel_type ct_msc;
474 struct gsm0808_speech_codec_list scl_ms;
475 struct bsc_msc_data msc_local;
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200476 struct gsm_bts bts_local;
Philipp Maier844876f2018-07-13 09:17:07 +0200477 int rc;
478
479 printf("============== test_selected_working ==============\n\n");
480
481 init_msc_config(&msc_local);
482
483 make_scl_config(&scl_ms, 6);
484 make_ct_config(&ct_msc, 5);
485 make_msc_config(&msc_local, 7);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200486 make_bts_config(&bts_local, 8);
487 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200488 OSMO_ASSERT(rc == 0);
489
490 make_scl_config(&scl_ms, 0);
491 make_ct_config(&ct_msc, 5);
492 make_msc_config(&msc_local, 7);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200493 make_bts_config(&bts_local, 8);
494 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200495 OSMO_ASSERT(rc == 0);
496
497 make_scl_config(&scl_ms, 1);
498 make_ct_config(&ct_msc, 5);
499 make_msc_config(&msc_local, 6);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200500 make_bts_config(&bts_local, 8);
501 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
502 OSMO_ASSERT(rc == 0);
503
504 make_scl_config(&scl_ms, 6);
505 make_ct_config(&ct_msc, 5);
506 make_msc_config(&msc_local, 7);
507 make_bts_config(&bts_local, 4);
508 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
509 OSMO_ASSERT(rc == 0);
510
511 make_scl_config(&scl_ms, 0);
512 make_ct_config(&ct_msc, 5);
513 make_msc_config(&msc_local, 7);
514 make_bts_config(&bts_local, 2);
515 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
516 OSMO_ASSERT(rc == 0);
517
518 make_scl_config(&scl_ms, 1);
519 make_ct_config(&ct_msc, 5);
520 make_msc_config(&msc_local, 6);
521 make_bts_config(&bts_local, 1);
522 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200523 OSMO_ASSERT(rc == 0);
524
525 free_msc_config(&msc_local);
526}
527
528/* Some mixed configurations that can not work */
529static void test_selected_non_working(void)
530{
531 struct gsm0808_channel_type ct_msc;
532 struct gsm0808_speech_codec_list scl_ms;
533 struct bsc_msc_data msc_local;
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200534 struct gsm_bts bts_local;
Philipp Maier844876f2018-07-13 09:17:07 +0200535 int rc;
536
537 printf("============== test_selected_non_working ==============\n\n");
538
539 init_msc_config(&msc_local);
540
541 make_scl_config(&scl_ms, 1);
542 make_ct_config(&ct_msc, 5);
543 make_msc_config(&msc_local, 7);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200544 make_bts_config(&bts_local, 8);
545 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200546 OSMO_ASSERT(rc == -1);
547
548 make_scl_config(&scl_ms, 1);
549 make_ct_config(&ct_msc, 5);
550 make_msc_config(&msc_local, 7);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200551 make_bts_config(&bts_local, 8);
552 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200553 OSMO_ASSERT(rc == -1);
554
555 make_scl_config(&scl_ms, 1);
556 make_ct_config(&ct_msc, 4);
557 make_msc_config(&msc_local, 6);
Philipp Maier5bc43cd2018-07-13 16:14:18 +0200558 make_bts_config(&bts_local, 8);
559 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
560 OSMO_ASSERT(rc == -1);
561
562 make_scl_config(&scl_ms, 1);
563 make_ct_config(&ct_msc, 2);
564 make_msc_config(&msc_local, 7);
565 make_bts_config(&bts_local, 8);
566 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
567 OSMO_ASSERT(rc == -1);
568
569 make_scl_config(&scl_ms, 1);
570 make_ct_config(&ct_msc, 5);
571 make_msc_config(&msc_local, 4);
572 make_bts_config(&bts_local, 8);
573 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
574 OSMO_ASSERT(rc == -1);
575
576 make_scl_config(&scl_ms, 8);
577 make_ct_config(&ct_msc, 4);
578 make_msc_config(&msc_local, 6);
579 make_bts_config(&bts_local, 7);
580 rc = test_match_codec_pref(&ct_msc, &scl_ms, &msc_local, &bts_local);
Philipp Maier844876f2018-07-13 09:17:07 +0200581 OSMO_ASSERT(rc == -1);
582
583 free_msc_config(&msc_local);
584}
585
586static const struct log_info_cat log_categories[] = {
587 [DMSC] = {
588 .name = "DMSC",
589 .description = "Mobile Switching Center",
590 .enabled = 1,.loglevel = LOGL_NOTICE,
591 },
592};
593
594static const struct log_info log_info = {
595 .cat = log_categories,
596 .num_cat = ARRAY_SIZE(log_categories),
597};
598
599int main(int argc, char **argv)
600{
601 ctx = talloc_named_const(NULL, 0, "codec_pref_test");
602 msgb_talloc_ctx_init(ctx, 0);
603 osmo_init_logging2(ctx, &log_info);
604
605 test_one_to_one();
606 test_ms();
607 test_ct();
608 test_msc();
609 test_selected_working();
610 test_selected_non_working();
611
612 printf("Testing execution completed.\n");
613 talloc_free(ctx);
614 return 0;
615}