Harald Welte | fbc5ca0 | 2010-03-04 10:39:50 +0100 | [diff] [blame] | 1 | /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 2 | * |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 6 | * 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 Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 13 | * GNU Affero General Public License for more details. |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 14 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * 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 Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 17 | * |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #include <stdlib.h> |
Harald Welte | 51f3845 | 2009-02-24 22:36:40 +0000 | [diff] [blame] | 22 | #include <stdio.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 23 | #include <string.h> |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 24 | #include <errno.h> |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 25 | #include <ctype.h> |
Max | c08ee71 | 2016-05-11 12:45:13 +0200 | [diff] [blame] | 26 | #include <stdbool.h> |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 27 | #include <netinet/in.h> |
| 28 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 29 | #include <osmocom/core/linuxlist.h> |
| 30 | #include <osmocom/core/talloc.h> |
| 31 | #include <osmocom/gsm/gsm_utils.h> |
| 32 | #include <osmocom/core/statistics.h> |
Max | c08ee71 | 2016-05-11 12:45:13 +0200 | [diff] [blame] | 33 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 34 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 35 | #include <osmocom/msc/gsm_data.h> |
Holger Hans Peter Freyther | ed83286 | 2010-06-28 18:20:22 +0800 | [diff] [blame] | 36 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 37 | void *tall_bsc_ctx; |
| 38 | |
Harald Welte | 92b1fe4 | 2010-03-25 11:45:30 +0800 | [diff] [blame] | 39 | static 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 Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | enum rrlp_mode rrlp_mode_parse(const char *arg) |
| 48 | { |
Harald Welte | 92b1fe4 | 2010-03-25 11:45:30 +0800 | [diff] [blame] | 49 | return get_string_value(rrlp_mode_names, arg); |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | const char *rrlp_mode_name(enum rrlp_mode mode) |
| 53 | { |
Harald Welte | 92b1fe4 | 2010-03-25 11:45:30 +0800 | [diff] [blame] | 54 | return get_value_string(rrlp_mode_names, mode); |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 55 | } |
Harald Welte | d12b0fd | 2009-12-15 21:36:05 +0100 | [diff] [blame] | 56 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 57 | bool 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 Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 66 | |
| 67 | const 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 | }; |