blob: 31ac74f1fe20412dd3d9280e7367372a56215d1e [file] [log] [blame]
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +01001/* Control Interface Implementation for the SGSN */
2/*
3 * (C) 2014 by Holger Hans Peter Freyther
4 * (C) 2014 by sysmocom s.f.m.c. GmbH
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
Harald Welteba874b82014-08-20 23:47:15 +020022#include <osmocom/ctrl/control_if.h>
23#include <osmocom/ctrl/control_cmd.h>
24#include <openbsc/gsm_data.h>
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010025#include <openbsc/gprs_sgsn.h>
26#include <openbsc/sgsn.h>
27#include <openbsc/debug.h>
28
29#include <pdp.h>
30
31extern vector ctrl_node_vec;
32
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010033static int get_subscriber_list(struct ctrl_cmd *cmd, void *d)
34{
35 struct sgsn_mm_ctx *mm;
36
37 cmd->reply = talloc_strdup(cmd, "");
38 llist_for_each_entry(mm, &sgsn_mm_ctxts, list) {
39 char *addr = NULL;
40 struct sgsn_pdp_ctx *pdp;
41
42 if (strlen(mm->imsi) == 0)
43 continue;
44
45 llist_for_each_entry(pdp, &mm->pdp_list, list)
46 addr = gprs_pdpaddr2str(pdp->lib->eua.v,
47 pdp->lib->eua.l);
48
49 cmd->reply = talloc_asprintf_append(
50 cmd->reply,
51 "%s,%s\n", mm->imsi, addr ? addr : "");
52 }
53
54 return CTRL_CMD_REPLY;
55}
Max50eb6692017-05-02 16:44:43 +020056CTRL_CMD_DEFINE_RO(subscriber_list, "subscriber-list-active-v1");
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010057
58int sgsn_ctrl_cmds_install(void)
59{
60 int rc = 0;
61 rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list);
62 return rc;
63}
64
Neels Hofmeyr73828152016-02-23 15:10:33 +010065struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *net,
66 const char *bind_addr, uint16_t port)
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010067{
Neels Hofmeyr73828152016-02-23 15:10:33 +010068 return ctrl_interface_setup_dynip(net, bind_addr, port, NULL);
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010069}