bsc: Add a VTY command to show the paging group for a BSC/IMSI

This commit is contained in:
Holger Hans Peter Freyther 2013-02-05 09:39:09 +01:00 committed by Holger Hans Peter Freyther
parent d9e4039516
commit ec37bb2956
2 changed files with 41 additions and 0 deletions

View File

@ -27,6 +27,8 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
#include <osmocom/gsm/gsm0502.h>
#include <arpa/inet.h>
#include <osmocom/core/linuxlist.h>
@ -51,6 +53,8 @@
#include <openbsc/osmo_msc_data.h>
#include <openbsc/osmo_bsc_rf.h>
#include <inttypes.h>
#include "../../bscconfig.h"
@ -1150,6 +1154,36 @@ DEFUN(show_paging,
return CMD_SUCCESS;
}
DEFUN(show_paging_group,
show_paging_group_cmd,
"show paging-group <0-255> IMSI",
SHOW_STR "Display the paging group\n"
"BTS Number\n" "IMSI\n")
{
struct gsm_network *net = gsmnet_from_vty(vty);
struct gsm_bts *bts;
unsigned int page_group;
int bts_nr = atoi(argv[0]);
if (bts_nr >= net->num_bts) {
vty_out(vty, "%% can't find BTS %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
bts = gsm_bts_num(net, bts_nr);
if (!bts) {
vty_out(vty, "%% can't find BTS %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
str_to_imsi(argv[1]));
vty_out(vty, "%%Paging group for IMSI %" PRIu64 " on BTS #%d is %u%s",
str_to_imsi(argv[1]), bts->nr,
page_group, VTY_NEWLINE);
return CMD_SUCCESS;
}
DEFUN(cfg_net,
cfg_net_cmd,
"network", NETWORK_STR)
@ -3095,6 +3129,7 @@ int bsc_vty_init(const struct log_info *cat)
install_element_ve(&logging_fltr_imsi_cmd);
install_element_ve(&show_paging_cmd);
install_element_ve(&show_paging_group_cmd);
logging_vty_add_cmds(cat);
install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);

View File

@ -224,6 +224,12 @@ class TestVTYNITB(TestVTYGenericBSC):
res = self.vty.command('show subscriber imsi '+imsi)
self.assert_(res.find(" IMSI: "+imsi) > 0)
def testShowPagingGroup(self):
res = self.vty.command("show paging-group 255 1234567")
self.assertEqual(res, "% can't find BTS 255")
res = self.vty.command("show paging-group 0 1234567")
self.assertEquals(res, "%Paging group for IMSI 1234567 on BTS #0 is 7")
class TestVTYBSC(TestVTYGenericBSC):
def vty_command(self):