blob: dc5ae79ae707ea3b0006bd7c25ac5ace611f8b78 [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>
Neels Hofmeyr396f2e62017-09-04 15:13:25 +020024#include <osmocom/sgsn/gprs_sgsn.h>
25#include <osmocom/sgsn/sgsn.h>
26#include <osmocom/sgsn/debug.h>
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010027
28#include <pdp.h>
29
30extern vector ctrl_node_vec;
31
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010032static int get_subscriber_list(struct ctrl_cmd *cmd, void *d)
33{
34 struct sgsn_mm_ctx *mm;
35
36 cmd->reply = talloc_strdup(cmd, "");
37 llist_for_each_entry(mm, &sgsn_mm_ctxts, list) {
38 char *addr = NULL;
39 struct sgsn_pdp_ctx *pdp;
40
41 if (strlen(mm->imsi) == 0)
42 continue;
43
44 llist_for_each_entry(pdp, &mm->pdp_list, list)
45 addr = gprs_pdpaddr2str(pdp->lib->eua.v,
46 pdp->lib->eua.l);
47
48 cmd->reply = talloc_asprintf_append(
49 cmd->reply,
50 "%s,%s\n", mm->imsi, addr ? addr : "");
51 }
52
53 return CTRL_CMD_REPLY;
54}
Max50eb6692017-05-02 16:44:43 +020055CTRL_CMD_DEFINE_RO(subscriber_list, "subscriber-list-active-v1");
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010056
57int sgsn_ctrl_cmds_install(void)
58{
59 int rc = 0;
60 rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list);
61 return rc;
62}
63
Neels Hofmeyr73828152016-02-23 15:10:33 +010064struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *net,
65 const char *bind_addr, uint16_t port)
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010066{
Neels Hofmeyr73828152016-02-23 15:10:33 +010067 return ctrl_interface_setup_dynip(net, bind_addr, port, NULL);
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010068}