blob: eff94e0741b84d41bfef1c49b7c2806b80b95434 [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
33static int verify_subscriber_list(struct ctrl_cmd *cmd, const char *v, void *d)
34{
35 return 1;
36}
37
38static int set_subscriber_list(struct ctrl_cmd *cmd, void *d)
39{
40 cmd->reply = "Get only attribute";
41 return CTRL_CMD_ERROR;
42}
43
44static int get_subscriber_list(struct ctrl_cmd *cmd, void *d)
45{
46 struct sgsn_mm_ctx *mm;
47
48 cmd->reply = talloc_strdup(cmd, "");
49 llist_for_each_entry(mm, &sgsn_mm_ctxts, list) {
50 char *addr = NULL;
51 struct sgsn_pdp_ctx *pdp;
52
53 if (strlen(mm->imsi) == 0)
54 continue;
55
56 llist_for_each_entry(pdp, &mm->pdp_list, list)
57 addr = gprs_pdpaddr2str(pdp->lib->eua.v,
58 pdp->lib->eua.l);
59
60 cmd->reply = talloc_asprintf_append(
61 cmd->reply,
62 "%s,%s\n", mm->imsi, addr ? addr : "");
63 }
64
65 return CTRL_CMD_REPLY;
66}
67CTRL_CMD_DEFINE(subscriber_list, "subscriber-list-active-v1");
68
69int sgsn_ctrl_cmds_install(void)
70{
71 int rc = 0;
72 rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list);
73 return rc;
74}
75
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010076struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *net, uint16_t port)
77{
Harald Welte74d4adc2014-08-21 15:25:25 +020078 return ctrl_interface_setup(net, port, NULL);
Holger Hans Peter Freythera2730302014-03-23 18:08:26 +010079}