[MERGED] libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-03 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: features: move bts feature related functionality to libosmocore
..


features: move bts feature related functionality to libosmocore

osmo-bsc and osmo-bts share enums and value strings to describe
feature data that is exchanged via OML (manufacturer id) on startup.
Also the functions to set and get the respecitive bits in the feature
bitvectors are in osmo-bsc and osmo-bts. This is a code duplication
and should be resolved.

- add enum osmo_bts_features (replaces enum gsm_bts_features)
- add osmo_bts_features_descs (replaces gsm_bts_features_descs)
- add osmo_bts_set_feature (replaces gsm_btsmodel_set_feature)
- add osmo_bts_has_feature (replaces gsm_btsmodel_has_feature)

Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
---
M include/Makefile.am
A include/osmocom/gsm/bts_features.h
M src/gsm/Makefile.am
A src/gsm/bts_features.c
M src/gsm/libosmogsm.map
5 files changed, 95 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/Makefile.am b/include/Makefile.am
index 8b05f80..f82012f 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -67,6 +67,7 @@
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 000..f9b0142
--- /dev/null
+++ b/include/osmocom/gsm/bts_features.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include 
+#include 
+
+#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 b0d6dbd..0439ce6 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -30,7 +30,7 @@
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 000..4ec24fa
--- /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 
+
+const struct value_string osmo_bts_features_descs[] = {
+   { BTS_FEAT_HSCSD,   "HSCSD" },
+   { 

libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-03 Thread Harald Welte

Patch Set 4: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/7034
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-02 Thread dexter
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7034

to look at the new patch set (#4).

features: move bts feature related functionality to libosmocore

osmo-bsc and osmo-bts share enums and value strings to describe
feature data that is exchanged via OML (manufacturer id) on startup.
Also the functions to set and get the respecitive bits in the feature
bitvectors are in osmo-bsc and osmo-bts. This is a code duplication
and should be resolved.

- add enum osmo_bts_features (replaces enum gsm_bts_features)
- add osmo_bts_features_descs (replaces gsm_bts_features_descs)
- add osmo_bts_set_feature (replaces gsm_btsmodel_set_feature)
- add osmo_bts_has_feature (replaces gsm_btsmodel_has_feature)

Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
---
M include/Makefile.am
A include/osmocom/gsm/bts_features.h
M src/gsm/Makefile.am
A src/gsm/bts_features.c
M src/gsm/libosmogsm.map
5 files changed, 95 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/7034/4

diff --git a/include/Makefile.am b/include/Makefile.am
index 8b05f80..f82012f 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -67,6 +67,7 @@
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 000..f9b0142
--- /dev/null
+++ b/include/osmocom/gsm/bts_features.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include 
+#include 
+
+#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 b0d6dbd..0439ce6 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -30,7 +30,7 @@
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 000..4ec24fa
--- /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 
+
+const struct value_string osmo_bts_features_descs[] = {
+   { BTS_FEAT_HSCSD,   "HSCSD" },
+   { BTS_FEAT_GPRS,"GPRS" },
+   { 

libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-02 Thread Harald Welte

Patch Set 3:

(2 comments)

https://gerrit.osmocom.org/#/c/7034/3/include/osmocom/gsm/bts_features.h
File include/osmocom/gsm/bts_features.h:

Line 29: extern const struct value_string osmo_bts_features_descs[];
It is our general policy (mentioned over and over again in patch review) to 
provide an inline function wrapper around every value_string array that is 
exported.  something like "osmo_bts_feature_name(enum osmo_bts_features 
feature)". Please add.


Line 31: static inline int osmo_bts_set_feature(struct bitvec *features, enum 
osmo_bts_features feature)
I don't think those functions are particularly performance critical / called 
frequently (and hence should be inline functions).  What was the rationale?  
I'm not fundamentally opposed, I was just wondering...


-- 
To view, visit https://gerrit.osmocom.org/7034
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-02 Thread dexter

Patch Set 3:

> I cannot See the requested changes, sorry

Sorry, I did not push correctly. Now it should be visible.

-- 
To view, visit https://gerrit.osmocom.org/7034
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-02 Thread dexter
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7034

to look at the new patch set (#3).

features: move bts feature related functionality to libosmocore

osmo-bsc and osmo-bts share enums and value strings to describe
feature data that is exchanged via OML (manufacturer id) on startup.
Also the functions to set and get the respecitive bits in the feature
bitvectors are in osmo-bsc and osmo-bts. This is a code duplication
and should be resolved.

- add enum osmo_bts_features (replaces enum gsm_bts_features)
- add osmo_bts_features_descs (replaces gsm_bts_features_descs)
- add osmo_bts_set_feature (replaces gsm_btsmodel_set_feature)
- add osmo_bts_has_feature (replaces gsm_btsmodel_has_feature)

Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
---
M include/Makefile.am
A include/osmocom/gsm/bts_features.h
M src/gsm/Makefile.am
A src/gsm/bts_features.c
M src/gsm/libosmogsm.map
5 files changed, 86 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/7034/3

diff --git a/include/Makefile.am b/include/Makefile.am
index 8b05f80..f82012f 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -67,6 +67,7 @@
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 000..5e7a87e
--- /dev/null
+++ b/include/osmocom/gsm/bts_features.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include 
+#include 
+
+#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[];
+
+static 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);
+}
+
+static 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 b0d6dbd..0439ce6 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -30,7 +30,7 @@
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 000..4386c60
--- /dev/null
+++ b/src/gsm/bts_features.c
@@ -0,0 +1,42 @@
+/*! \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 
+
+const struct value_string osmo_bts_features_descs[] = {
+   { BTS_FEAT_HSCSD,   "HSCSD" },
+   { BTS_FEAT_GPRS,"GPRS" },
+   { BTS_FEAT_EGPRS,   "EGPRS" },
+   { BTS_FEAT_ECSD, 

libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-02 Thread Harald Welte

Patch Set 2:

I cannot See the requested changes, sorry

-- 
To view, visit https://gerrit.osmocom.org/7034
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-02 Thread dexter

Patch Set 2:

> Please call the files bts_features.[ch] and put them in libosmogsm,
 > as it's BTS/GSM specific.  otherwise I think everything is fine.

I have changed it now.

-- 
To view, visit https://gerrit.osmocom.org/7034
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-01 Thread Harald Welte

Patch Set 1: Code-Review-1

Please call the files bts_features.[ch] and put them in libosmogsm, as it's 
BTS/GSM specific.  otherwise I think everything is fine.

-- 
To view, visit https://gerrit.osmocom.org/7034
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] libosmocore[master]: features: move bts feature related functionality to libosmocore

2018-03-01 Thread dexter

Review at  https://gerrit.osmocom.org/7034

features: move bts feature related functionality to libosmocore

osmo-bsc and osmo-bts share enums and value strings to describe
feature data that is exchanged via OML (manufacturer id) on startup.
Also the functions to set and get the respecitive bits in the feature
bitvectors are in osmo-bsc and osmo-bts. This is a code duplication
and should be resolved.

- add enum osmo_bts_features (replaces enum gsm_bts_features)
- add osmo_bts_features_descs (replaces gsm_bts_features_descs)
- add osmo_bts_set_feature (replaces gsm_btsmodel_set_feature)
- add osmo_bts_has_feature (replaces gsm_btsmodel_has_feature)

Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
---
M include/Makefile.am
A include/osmocom/core/features.h
M src/Makefile.am
A src/features.c
4 files changed, 85 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/7034/1

diff --git a/include/Makefile.am b/include/Makefile.am
index 8b05f80..93b027c 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -23,6 +23,7 @@
osmocom/core/crcgen.h \
osmocom/core/endian.h \
osmocom/core/defs.h \
+   osmocom/core/features.h \
osmocom/core/fsm.h \
osmocom/core/gsmtap.h \
osmocom/core/gsmtap_util.h \
diff --git a/include/osmocom/core/features.h b/include/osmocom/core/features.h
new file mode 100644
index 000..5e7a87e
--- /dev/null
+++ b/include/osmocom/core/features.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include 
+#include 
+
+#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[];
+
+static 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);
+}
+
+static 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/Makefile.am b/src/Makefile.am
index 2641a97..4dc1887 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,7 +22,7 @@
 conv.c application.c rbtree.c strrb.c \
 loggingrb.c crc8gen.c crc16gen.c crc32gen.c crc64gen.c 
\
 macaddr.c stat_item.c stats.c stats_statsd.c prim.c \
-conv_acc.c conv_acc_generic.c sercomm.c prbs.c
+conv_acc.c conv_acc_generic.c sercomm.c prbs.c 
features.c
 
 if HAVE_SSSE3
 libosmocore_la_SOURCES += conv_acc_sse.c
diff --git a/src/features.c b/src/features.c
new file mode 100644
index 000..3d9d3d8
--- /dev/null
+++ b/src/features.c
@@ -0,0 +1,42 @@
+/*! \file features.c
+ * osmo-bts features. */
+/*
+ * (C) 2017 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 
+
+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" },
+