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
diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index 7cb1d38..ef98f7d 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -199,9 +199,14 @@
{ 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 @@
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;