From 4e13a8f9f9d40e5d62c9cee7d76348ef8b558981 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 31 Jan 2015 22:16:00 +0100 Subject: bsc/nitb: Allow to set the GPRS mode through the ctrl command Create a control command to read and modify the gprs mode. Use the get_string_value to indicate if the value was found or not. This is useful for the ctrl interface where I didn't want to replicate "none", "gprs" and "egprs". Share code to verify that a BTS supports the mode. Related: SYS#591 --- openbsc/src/libcommon/gsm_data.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'openbsc/src/libcommon/gsm_data.c') diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 7cb1d3814..ef98f7d0b 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -199,9 +199,14 @@ static const struct value_string bts_gprs_mode_names[] = { { 0, NULL } }; -enum bts_gprs_mode bts_gprs_mode_parse(const char *arg) +enum bts_gprs_mode bts_gprs_mode_parse(const char *arg, int *valid) { - return get_string_value(bts_gprs_mode_names, arg); + int rc; + + rc = get_string_value(bts_gprs_mode_names, arg); + if (valid) + *valid = rc != -EINVAL; + return rc; } const char *bts_gprs_mode_name(enum bts_gprs_mode mode) @@ -209,6 +214,20 @@ const char *bts_gprs_mode_name(enum bts_gprs_mode mode) return get_value_string(bts_gprs_mode_names, mode); } +int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode) +{ + if (mode != BTS_GPRS_NONE && + !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) { + return 0; + } + if (mode == BTS_GPRS_EGPRS && + !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) { + return 0; + } + + return 1; +} + struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan) { struct gsm_meas_rep *meas_rep; -- cgit v1.2.3