aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-31 22:16:00 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-31 22:38:48 +0100
commit4e13a8f9f9d40e5d62c9cee7d76348ef8b558981 (patch)
tree71a31d8620d449137fda631a4dc6719eea6d82ec /openbsc/src/libbsc
parentb8c204cb929a8455bfa6006a95a958d57274ab08 (diff)
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
Diffstat (limited to 'openbsc/src/libbsc')
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_commands.c44
-rw-r--r--openbsc/src/libbsc/bsc_vty.c11
2 files changed, 44 insertions, 11 deletions
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index aea4a9bc8..368d0e7c6 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -1,6 +1,6 @@
/*
- * (C) 2013-2014 by Holger Hans Peter Freyther
- * (C) 2013-2014 by sysmocom s.f.m.c. GmbH
+ * (C) 2013-2015 by Holger Hans Peter Freyther
+ * (C) 2013-2015 by sysmocom s.f.m.c. GmbH
*
* All Rights Reserved
*
@@ -299,6 +299,45 @@ static int set_bts_oml_conn(struct ctrl_cmd *cmd, void *data)
}
CTRL_CMD_DEFINE(bts_oml_conn, "oml-connection-state");
+static int verify_bts_gprs_mode(struct ctrl_cmd *cmd, const char *value, void *_data)
+{
+ int valid;
+ enum bts_gprs_mode mode;
+ struct gsm_bts *bts = cmd->node;
+
+ mode = bts_gprs_mode_parse(value, &valid);
+ if (!valid) {
+ cmd->reply = "Mode is not known";
+ return 1;
+ }
+
+ if (!bts_gprs_mode_is_compat(bts, mode)) {
+ cmd->reply = "bts does not support this mode";
+ return 1;
+ }
+
+ return 0;
+}
+
+static int get_bts_gprs_mode(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_bts *bts = cmd->node;
+
+ cmd->reply = talloc_strdup(cmd, bts_gprs_mode_name(bts->gprs.mode));
+ return CTRL_CMD_REPLY;
+}
+
+static int set_bts_gprs_mode(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_bts *bts = cmd->node;
+
+ bts->gprs.mode = bts_gprs_mode_parse(cmd->value, NULL);
+ return get_bts_gprs_mode(cmd, data);
+}
+
+CTRL_CMD_DEFINE(bts_gprs_mode, "gprs-mode");
+
+
/* TRX related commands below here */
CTRL_HELPER_GET_INT(trx_max_power, struct gsm_bts_trx, max_power_red);
static int verify_trx_max_power(struct ctrl_cmd *cmd, const char *value, void *_data)
@@ -356,6 +395,7 @@ int bsc_base_ctrl_cmds_install(void)
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_si);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_chan_load);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_oml_conn);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_gprs_mode);
rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_max_power);
rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_arfcn);
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 2857494eb..588be267f 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -2500,16 +2500,9 @@ DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
"EGPRS (EDGE) Enabled on this BTS\n")
{
struct gsm_bts *bts = vty->index;
- enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
+ enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0], NULL);
- if (mode != BTS_GPRS_NONE &&
- !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
- vty_out(vty, "This BTS type does not support %s%s", argv[0],
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (mode == BTS_GPRS_EGPRS &&
- !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
+ if (!bts_gprs_mode_is_compat(bts, mode)) {
vty_out(vty, "This BTS type does not support %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;