diff options
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/osmocom/gsm/bts_features.h | 43 | ||||
-rw-r--r-- | src/gsm/Makefile.am | 2 | ||||
-rw-r--r-- | src/gsm/bts_features.c | 48 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 2 |
5 files changed, 95 insertions, 1 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 8b05f80b..f82012f3 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -67,6 +67,7 @@ nobase_include_HEADERS = \ osmocom/gsm/a5.h \ osmocom/gsm/abis_nm.h \ osmocom/gsm/apn.h \ + osmocom/gsm/bts_features.h \ osmocom/gsm/comp128.h \ osmocom/gsm/comp128v23.h \ osmocom/gsm/bitvec_gsm.h \ diff --git a/include/osmocom/gsm/bts_features.h b/include/osmocom/gsm/bts_features.h new file mode 100644 index 00000000..f9b0142f --- /dev/null +++ b/include/osmocom/gsm/bts_features.h @@ -0,0 +1,43 @@ +#pragma once + +#include <osmocom/core/utils.h> +#include <osmocom/core/bitvec.h> + +#define MAX_BTS_FEATURES 128 + +/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility + with BTS compiled against earlier version of this header. Also make sure that the description strings + gsm_bts_features_descs[] in gsm_data.c are also updated accordingly! */ +enum osmo_bts_features { + BTS_FEAT_HSCSD, + BTS_FEAT_GPRS, + BTS_FEAT_EGPRS, + BTS_FEAT_ECSD, + BTS_FEAT_HOPPING, + BTS_FEAT_MULTI_TSC, + BTS_FEAT_OML_ALERTS, + BTS_FEAT_AGCH_PCH_PROP, + BTS_FEAT_CBCH, + BTS_FEAT_SPEECH_F_V1, + BTS_FEAT_SPEECH_H_V1, + BTS_FEAT_SPEECH_F_EFR, + BTS_FEAT_SPEECH_F_AMR, + BTS_FEAT_SPEECH_H_AMR, + _NUM_BTS_FEAT +}; + +extern const struct value_string osmo_bts_features_descs[]; + +const char *osmo_bts_feature_name(enum osmo_bts_features feature); + +inline int osmo_bts_set_feature(struct bitvec *features, enum osmo_bts_features feature) +{ + OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); + return bitvec_set_bit_pos(features, feature, 1); +} + +inline bool osmo_bts_has_feature(const struct bitvec *features, enum osmo_bts_features feature) +{ + OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); + return bitvec_get_bit_pos(features, feature); +} diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index b0d6dbd2..0439ce62 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -30,7 +30,7 @@ libgsmint_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ milenage/aes-internal.c milenage/aes-internal-enc.c \ milenage/milenage.c gan.c ipa.c gsm0341.c apn.c \ gsup.c gprs_gea.c gsm0503_conv.c oap.c gsm0808_utils.c \ - gsm23003.c mncc.c + gsm23003.c mncc.c bts_features.c libgsmint_la_LDFLAGS = -no-undefined libgsmint_la_LIBADD = $(top_builddir)/src/libosmocore.la diff --git a/src/gsm/bts_features.c b/src/gsm/bts_features.c new file mode 100644 index 00000000..4ec24fa2 --- /dev/null +++ b/src/gsm/bts_features.c @@ -0,0 +1,48 @@ +/*! \file bts_features.c + * osmo-bts features. */ +/* + * (C) 2018 by sysmocom s.f.m.c. GmbH + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include <osmocom/gsm/bts_features.h> + +const struct value_string osmo_bts_features_descs[] = { + { BTS_FEAT_HSCSD, "HSCSD" }, + { BTS_FEAT_GPRS, "GPRS" }, + { BTS_FEAT_EGPRS, "EGPRS" }, + { BTS_FEAT_ECSD, "ECSD" }, + { BTS_FEAT_HOPPING, "Frequency Hopping" }, + { BTS_FEAT_MULTI_TSC, "Multi-TSC" }, + { BTS_FEAT_OML_ALERTS, "OML Alerts" }, + { BTS_FEAT_AGCH_PCH_PROP, "AGCH/PCH proportional allocation" }, + { BTS_FEAT_CBCH, "CBCH" }, + { BTS_FEAT_SPEECH_F_V1, "Fullrate speech V1" }, + { BTS_FEAT_SPEECH_H_V1, "Halfrate speech V1" }, + { BTS_FEAT_SPEECH_F_EFR, "Fullrate speech EFR" }, + { BTS_FEAT_SPEECH_F_AMR, "Fullrate speech AMR" }, + { BTS_FEAT_SPEECH_H_AMR, "Halfrate speech AMR" }, + { 0, NULL } +}; + +/*! return string representation of a BTS feature */ +const char *osmo_bts_feature_name(enum osmo_bts_features feature) +{ + return get_value_string(osmo_bts_features_descs, feature); +} diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 0a1c0c6f..b9035041 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -262,6 +262,8 @@ gsm48_mcc_mnc_to_bcd; gsm48_mcc_mnc_from_bcd; gsm48_generate_lai2; gsm48_decode_lai2; +osmo_bts_features_descs; +osmo_bts_feature_name; osmo_plmn_to_bcd; osmo_plmn_from_bcd; osmo_mcc_name; |