summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/src/gprs/sgsn_vty.c36
-rw-r--r--openbsc/tests/vty_test_runner.py28
2 files changed, 64 insertions, 0 deletions
diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index be575d3..8b6e3ec 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -1,6 +1,7 @@
/*
* (C) 2010-2013 by Harald Welte <laforge@gnumonks.org>
* (C) 2010 by On-Waves
+ * (C) 2015 by Holger Hans Peter Freyther
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -164,6 +165,12 @@ static int config_write_sgsn(struct vty *vty)
actx->ggsn->id, VTY_NEWLINE);
}
+ if (g_cfg->cdr.filename)
+ vty_out(vty, " cdr filename %s%s", g_cfg->cdr.filename, VTY_NEWLINE);
+ else
+ vty_out(vty, " no cdr filename%s", VTY_NEWLINE);
+ vty_out(vty, " cdr interval %d%s", g_cfg->cdr.interval, VTY_NEWLINE);
+
return CMD_SUCCESS;
}
@@ -811,6 +818,32 @@ DEFUN(cfg_no_apn_name, cfg_no_apn_name_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_cdr_filename, cfg_cdr_filename_cmd,
+ "cdr filename NAME",
+ "CDR\nSet filename\nname\n")
+{
+ talloc_free(g_cfg->cdr.filename);
+ g_cfg->cdr.filename = talloc_strdup(tall_vty_ctx, argv[0]);
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_no_cdr_filename, cfg_no_cdr_filename_cmd,
+ "no cdr filename",
+ NO_STR "CDR\nDisable CDR generation\n")
+{
+ talloc_free(g_cfg->cdr.filename);
+ g_cfg->cdr.filename = NULL;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_cdr_interval, cfg_cdr_interval_cmd,
+ "cdr interval <1-2147483647>",
+ "CDR\nPDP periodic log interval\nSeconds\n")
+{
+ g_cfg->cdr.interval = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
int sgsn_vty_init(void)
{
install_element_ve(&show_sgsn_cmd);
@@ -842,6 +875,9 @@ int sgsn_vty_init(void)
install_element(SGSN_NODE, &cfg_apn_imsi_ggsn_cmd);
install_element(SGSN_NODE, &cfg_apn_name_cmd);
install_element(SGSN_NODE, &cfg_no_apn_name_cmd);
+ install_element(SGSN_NODE, &cfg_cdr_filename_cmd);
+ install_element(SGSN_NODE, &cfg_no_cdr_filename_cmd);
+ install_element(SGSN_NODE, &cfg_cdr_interval_cmd);
return 0;
}
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 3581b67..4cd4665 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -891,6 +891,34 @@ class TestVTYSGSN(TestVTYGenericBSC):
res = self.vty.command("show running-config")
self.assertEquals(res.find("apn internet"), -1)
+ def testVtyCDR(self):
+ self.vty.enable()
+ self.assertTrue(self.vty.verify('configure terminal', ['']))
+ self.assertEquals(self.vty.node(), 'config')
+ self.assertTrue(self.vty.verify('sgsn', ['']))
+ self.assertEquals(self.vty.node(), 'config-sgsn')
+
+ res = self.vty.command("show running-config")
+ self.assert_(res.find("no cdr filename") > 0)
+
+ self.vty.command("cdr filename bla.cdr")
+ res = self.vty.command("show running-config")
+ self.assertEquals(res.find("no cdr filename"), -1)
+ self.assert_(res.find(" cdr filename bla.cdr") > 0)
+
+ self.vty.command("no cdr filename")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find("no cdr filename") > 0)
+ self.assertEquals(res.find(" cdr filename bla.cdr"), -1)
+
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" cdr interval 600") > 0)
+
+ self.vty.command("cdr interval 900")
+ res = self.vty.command("show running-config")
+ self.assert_(res.find(" cdr interval 900") > 0)
+ self.assertEquals(res.find(" cdr interval 600"), -1)
+
def add_nat_test(suite, workdir):
if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):
print("Skipping the NAT test")