2014-03-23 11:06:36 +00:00
|
|
|
/*
|
|
|
|
* (C) 2014 by Holger Hans Peter Freyther
|
|
|
|
* (C) 2014 by sysmocom s.f.m.c. GmbH
|
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2016-06-07 13:32:16 +00:00
|
|
|
|
2014-08-20 21:47:15 +00:00
|
|
|
#include <osmocom/ctrl/control_cmd.h>
|
2017-01-13 02:12:08 +00:00
|
|
|
#include <osmocom/core/utils.h>
|
2017-09-04 13:04:35 +00:00
|
|
|
#include <osmocom/msc/gsm_data.h>
|
|
|
|
#include <osmocom/msc/gsm_subscriber.h>
|
|
|
|
#include <osmocom/msc/db.h>
|
|
|
|
#include <osmocom/msc/debug.h>
|
|
|
|
#include <osmocom/msc/vlr.h>
|
2014-03-23 11:06:36 +00:00
|
|
|
|
2016-06-30 08:25:49 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2016-06-19 16:06:02 +00:00
|
|
|
static struct gsm_network *msc_ctrl_net = NULL;
|
2016-04-06 20:41:12 +00:00
|
|
|
|
2016-06-19 16:06:02 +00:00
|
|
|
static int get_subscriber_list(struct ctrl_cmd *cmd, void *d)
|
|
|
|
{
|
|
|
|
struct vlr_subscr *vsub;
|
2014-03-23 13:01:08 +00:00
|
|
|
|
2016-06-19 16:06:02 +00:00
|
|
|
if (!msc_ctrl_net) {
|
|
|
|
cmd->reply = "MSC CTRL commands not initialized";
|
|
|
|
return CTRL_CMD_ERROR;
|
2014-03-23 13:01:08 +00:00
|
|
|
}
|
|
|
|
|
2016-06-19 16:06:02 +00:00
|
|
|
if (!msc_ctrl_net->vlr) {
|
|
|
|
cmd->reply = "VLR not initialized";
|
2014-03-23 13:01:08 +00:00
|
|
|
return CTRL_CMD_ERROR;
|
|
|
|
}
|
|
|
|
|
2014-03-23 15:22:55 +00:00
|
|
|
cmd->reply = talloc_strdup(cmd, "");
|
|
|
|
|
2016-06-19 16:06:02 +00:00
|
|
|
llist_for_each_entry(vsub, &msc_ctrl_net->vlr->subscribers, list) {
|
2017-09-09 15:00:21 +00:00
|
|
|
/* Do not list subscribers that aren't successfully attached. */
|
|
|
|
if (!vsub->lu_complete)
|
|
|
|
continue;
|
2016-06-19 16:06:02 +00:00
|
|
|
cmd->reply = talloc_asprintf_append(cmd->reply, "%s,%s\n",
|
|
|
|
vsub->imsi, vsub->msisdn);
|
|
|
|
}
|
|
|
|
printf("%s\n", cmd->reply); /* <-- what? */
|
2014-03-23 15:22:55 +00:00
|
|
|
return CTRL_CMD_REPLY;
|
|
|
|
}
|
2017-05-02 14:44:43 +00:00
|
|
|
CTRL_CMD_DEFINE_RO(subscriber_list, "subscriber-list-active-v1");
|
2014-03-23 15:22:55 +00:00
|
|
|
|
2016-06-19 16:06:02 +00:00
|
|
|
int msc_ctrl_cmds_install(struct gsm_network *net)
|
2014-03-23 11:06:36 +00:00
|
|
|
{
|
|
|
|
int rc = 0;
|
2016-06-19 16:06:02 +00:00
|
|
|
msc_ctrl_net = net;
|
2014-03-23 11:06:36 +00:00
|
|
|
|
2014-03-23 15:22:55 +00:00
|
|
|
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list);
|
2014-03-23 11:06:36 +00:00
|
|
|
return rc;
|
|
|
|
}
|