[PATCH] openbsc[master]: Move string - BTS type conversion to shared header

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Mon Apr 10 12:06:06 UTC 2017


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

Move string - BTS type conversion to shared header

Move value_string definition and corresponding functions to shared
header to make it re-usable by OsmoBTS. While at it - rename for
consistency and make functions inline.

Change-Id: Ida94725a6fce968443541e3526f48f13758031fd
Related: OS#1614
---
M openbsc/include/openbsc/gsm_data_shared.h
M openbsc/src/libbsc/bsc_vty.c
M openbsc/src/libcommon/gsm_data.c
3 files changed, 21 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/86/2286/1

diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 242889a..ad5d05a 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -504,6 +504,26 @@
 	_NUM_BTS_VARIANT
 };
 
+static const struct value_string bts_type_names[_NUM_GSM_BTS_TYPE + 1] = {
+	{ GSM_BTS_TYPE_UNKNOWN,		"unknown" },
+	{ GSM_BTS_TYPE_BS11,		"bs11" },
+	{ GSM_BTS_TYPE_NANOBTS,		"nanobts" },
+	{ GSM_BTS_TYPE_RBS2000,		"rbs2000" },
+	{ GSM_BTS_TYPE_NOKIA_SITE,	"nokia_site" },
+	{ GSM_BTS_TYPE_OSMOBTS,		"sysmobts" },
+	{ 0, NULL }
+};
+
+static inline enum gsm_bts_type str2btstype(const char *arg)
+{
+	return get_string_value(bts_type_names, arg);
+}
+
+static inline const char *btstype2str(enum gsm_bts_type type)
+{
+	return get_value_string(bts_type_names, type);
+}
+
 struct vty;
 
 struct gsm_bts_model {
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index c1882fc..702af4a 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -1615,7 +1615,7 @@
 	struct gsm_bts *bts = vty->index;
 	int rc;
 
-	rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
+	rc = gsm_set_bts_type(bts, str2btstype(argv[0]));
 	if (rc < 0)
 		return CMD_WARNING;
 
diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index fd34793..8ec0be5 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -90,16 +90,6 @@
 	return NULL;
 }
 
-const struct value_string bts_type_names[_NUM_GSM_BTS_TYPE+1] = {
-	{ GSM_BTS_TYPE_UNKNOWN,	"unknown" },
-	{ GSM_BTS_TYPE_BS11,	"bs11" },
-	{ GSM_BTS_TYPE_NANOBTS,	"nanobts" },
-	{ GSM_BTS_TYPE_RBS2000,	"rbs2000" },
-	{ GSM_BTS_TYPE_NOKIA_SITE, "nokia_site" },
-	{ GSM_BTS_TYPE_OSMOBTS,	"sysmobts" },
-	{ 0,			NULL }
-};
-
 const struct value_string bts_type_descs[_NUM_GSM_BTS_TYPE+1] = {
 	{ GSM_BTS_TYPE_UNKNOWN,		"Unknown BTS Type" },
 	{ GSM_BTS_TYPE_BS11,		"Siemens BTS (BS-11 or compatible)" },
@@ -109,16 +99,6 @@
 	{ GSM_BTS_TYPE_OSMOBTS,		"sysmocom sysmoBTS" },
 	{ 0,				NULL }
 };
-
-enum gsm_bts_type parse_btstype(const char *arg)
-{
-	return get_string_value(bts_type_names, arg);
-}
-
-const char *btstype2str(enum gsm_bts_type type)
-{
-	return get_value_string(bts_type_names, type);
-}
 
 struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr)
 {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida94725a6fce968443541e3526f48f13758031fd
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list