aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-05 15:26:33 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-05 15:42:32 +0200
commit8ccf06c58b2f5fc2d95bc199dea5c39f7201a3c4 (patch)
tree2f0a52e0ba5b21886434316a4e92fa8a383613ed /openbsc
parentab94ca18f236013f78bd23e3788f003f738396cb (diff)
nat: Add ctrl command to save the configuration
$ bsc_control.py -d localhost -p 4250 -s net.0.save-configuration 0
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
index bdb1709e5..54e1dc4c2 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -25,6 +25,8 @@
#include <osmocom/ctrl/control_if.h>
#include <osmocom/ctrl/ports.h>
+#include <osmocom/vty/misc.h>
+
#include <openbsc/ctrl.h>
#include <openbsc/bsc_nat.h>
#include <openbsc/vty.h>
@@ -436,6 +438,30 @@ static int verify_net_cfg_acc_cmd(struct ctrl_cmd *cmd, const char *value, void
return 0;
}
+CTRL_CMD_DEFINE(net_save_cmd, "net 0 save-configuration");
+static int verify_net_save_cmd(struct ctrl_cmd *cmd, const char *v, void *d)
+{
+ return 0;
+}
+
+static int set_net_save_cmd(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_cmd(struct ctrl_cmd *cmd, void *data)
+{
+ cmd->reply = "Write only attribute";
+ return CTRL_CMD_ERROR;
+}
+
struct ctrl_handle *bsc_nat_controlif_setup(struct bsc_nat *nat, int port)
{
struct ctrl_handle *ctrl;
@@ -463,6 +489,11 @@ struct ctrl_handle *bsc_nat_controlif_setup(struct bsc_nat *nat, int port)
fprintf(stderr, "Failed to install the net acc command. Exiting.\n");
goto error;
}
+ rc = ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_save_cmd);
+ if (rc) {
+ fprintf(stderr, "Failed to install the net save command. Exiting.\n");
+ goto error;
+ }
g_nat = nat;
return ctrl;