diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-03-23 16:22:55 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-03-23 16:22:55 +0100 |
commit | d883db027bb75cb4299a733d005de6ff6a1f426c (patch) | |
tree | 25baa81427fc50e965279f3d38f70f0332b632a9 /openbsc/src/libmsc/ctrl_commands.c | |
parent | 2d99eeb7f2c7978e9d96f5df61e462e6feb05973 (diff) |
nitb/ctrl: Implement a command to list all active subscribers
This is only useful for small networks. List the IMSI and MSISDN
of all active subscribers.
Fixes: SYS#266
Diffstat (limited to 'openbsc/src/libmsc/ctrl_commands.c')
-rw-r--r-- | openbsc/src/libmsc/ctrl_commands.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c index b66cece8e..58558fd9f 100644 --- a/openbsc/src/libmsc/ctrl_commands.c +++ b/openbsc/src/libmsc/ctrl_commands.c @@ -140,11 +140,40 @@ static int set_subscriber_delete(struct ctrl_cmd *cmd, void *data) } CTRL_CMD_DEFINE(subscriber_delete, "subscriber-delete-v1"); +static int verify_subscriber_list(struct ctrl_cmd *cmd, const char *value, void *d) +{ + return 1; +} + +static int set_subscriber_list(struct ctrl_cmd *cmd, void *d) +{ + cmd->reply = "Get only attribute"; + return CTRL_CMD_ERROR; +} + +static void list_cb(struct gsm_subscriber *subscr, void *d) +{ + char **data = (char **) d; + *data = talloc_asprintf_append(*data, "%s,%s\n", + subscr->imsi, subscr->extension); +} + +static int get_subscriber_list(struct ctrl_cmd *cmd, void *d) +{ + cmd->reply = talloc_strdup(cmd, ""); + + db_subscriber_list_active(list_cb, &cmd->reply); + printf("%s\n", cmd->reply); + return CTRL_CMD_REPLY; +} +CTRL_CMD_DEFINE(subscriber_list, "subscriber-list-active-v1"); + int msc_ctrl_cmds_install(void) { int rc = 0; rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_modify); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_delete); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list); return rc; } |