summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-01-09 17:25:11 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-03-06 22:59:28 +0100
commit448117963d0794013a24dc6d051aacd6088c9826 (patch)
tree537b94ebbd408aedfa998f64b4007761feafd365
parent97af89c01a6e67988fb15d24e9e862610444c464 (diff)
nitb: Add ctrl command for saving the configuration
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_commands.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index a137efac6..63212542a 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -23,6 +23,8 @@
#include <openbsc/ipaccess.h>
#include <openbsc/gsm_data.h>
+#include <osmocom/vty/misc.h>
+
#define CTRL_CMD_VTY_STRING(cmdname, cmdstr, dtype, element) \
CTRL_HELPER_GET_STRING(cmdname, dtype, element) \
CTRL_HELPER_SET_STRING(cmdname, dtype, element) \
@@ -64,6 +66,31 @@ CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999);
CTRL_CMD_VTY_STRING(net_short_name, "short-name", struct gsm_network, name_short);
CTRL_CMD_VTY_STRING(net_long_name, "long-name", struct gsm_network, name_long);
+static int verify_net_save_config(struct ctrl_cmd *cmd, const char *v, void *d)
+{
+ return 0;
+}
+
+static int set_net_save_config(struct ctrl_cmd *cmd, void *data)
+{
+ int rc = osmo_vty_save_config_file();
+ cmd->reply = talloc_asprintf(cmd, "%d", rc);
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+
+ return CTRL_CMD_REPLY;
+}
+
+static int get_net_save_config(struct ctrl_cmd *cmd, void *data)
+{
+ cmd->reply = "Write only attribute";
+ return CTRL_CMD_ERROR;
+}
+
+CTRL_CMD_DEFINE(net_save_config, "save-configuration");
+
static int verify_net_apply_config(struct ctrl_cmd *cmd, const char *v, void *d)
{
return 0;
@@ -158,6 +185,7 @@ int bsc_base_ctrl_cmds_install(void)
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_short_name);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_long_name);
+ rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_save_config);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc_mnc_apply);