blob: f7795b201d376139dbd6d6147457253a67f0892e [file] [log] [blame]
Harald Weltefbc5ca02010-03-04 10:39:50 +01001/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welte8470bf22008-12-25 23:28:35 +00002 *
Harald Welte52b1f982008-12-23 20:25:15 +00003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Harald Welte52b1f982008-12-23 20:25:15 +00008 * (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
Harald Welte9af6ddf2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Harald Welte52b1f982008-12-23 20:25:15 +000014 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte52b1f982008-12-23 20:25:15 +000017 *
18 */
19
20
21#include <stdlib.h>
Harald Welte51f38452009-02-24 22:36:40 +000022#include <stdio.h>
Harald Welte52b1f982008-12-23 20:25:15 +000023#include <string.h>
Harald Weltefcd24452009-06-20 18:15:19 +020024#include <errno.h>
Harald Welte42581822009-08-08 16:12:58 +020025#include <ctype.h>
Maxc08ee712016-05-11 12:45:13 +020026#include <stdbool.h>
Harald Welte97a282b2010-03-14 15:37:43 +080027#include <netinet/in.h>
28
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010029#include <osmocom/core/linuxlist.h>
30#include <osmocom/core/talloc.h>
31#include <osmocom/gsm/gsm_utils.h>
32#include <osmocom/core/statistics.h>
Maxc08ee712016-05-11 12:45:13 +020033#include <osmocom/gsm/protocol/gsm_04_08.h>
Harald Welte52b1f982008-12-23 20:25:15 +000034
Neels Hofmeyr90843962017-09-04 15:04:35 +020035#include <osmocom/msc/gsm_data.h>
Holger Hans Peter Freythered832862010-06-28 18:20:22 +080036
Andreas Eversberg8226fa72009-06-29 15:19:38 +020037void *tall_bsc_ctx;
38
Harald Welte92b1fe42010-03-25 11:45:30 +080039static const struct value_string rrlp_mode_names[] = {
40 { RRLP_MODE_NONE, "none" },
41 { RRLP_MODE_MS_BASED, "ms-based" },
42 { RRLP_MODE_MS_PREF, "ms-preferred" },
43 { RRLP_MODE_ASS_PREF, "ass-preferred" },
44 { 0, NULL }
Harald Welteeab84a12009-12-13 10:53:12 +010045};
46
47enum rrlp_mode rrlp_mode_parse(const char *arg)
48{
Harald Welte92b1fe42010-03-25 11:45:30 +080049 return get_string_value(rrlp_mode_names, arg);
Harald Welteeab84a12009-12-13 10:53:12 +010050}
51
52const char *rrlp_mode_name(enum rrlp_mode mode)
53{
Harald Welte92b1fe42010-03-25 11:45:30 +080054 return get_value_string(rrlp_mode_names, mode);
Harald Welteeab84a12009-12-13 10:53:12 +010055}
Harald Welted12b0fd2009-12-15 21:36:05 +010056
Harald Welte2483f1b2016-06-19 18:06:02 +020057bool classmark_is_r99(struct gsm_classmark *cm)
58{
59 int rev_lev = 0;
60 if (cm->classmark1_set)
61 rev_lev = cm->classmark1.rev_lev;
62 else if (cm->classmark2_len > 0)
63 rev_lev = (cm->classmark2[0] >> 5) & 0x3;
64 return rev_lev >= 2;
65}
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020066
67const struct value_string ran_type_names[] = {
68 OSMO_VALUE_STRING(RAN_UNKNOWN),
69 OSMO_VALUE_STRING(RAN_GERAN_A),
70 OSMO_VALUE_STRING(RAN_UTRAN_IU),
71 { 0, NULL }
72};