Holger Hans Peter Freyther | a273030 | 2014-03-23 18:08:26 +0100 | [diff] [blame] | 1 | /* 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 Welte | ba874b8 | 2014-08-20 23:47:15 +0200 | [diff] [blame] | 22 | #include <osmocom/ctrl/control_if.h> |
| 23 | #include <osmocom/ctrl/control_cmd.h> |
Neels Hofmeyr | 396f2e6 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 24 | #include <osmocom/sgsn/gprs_sgsn.h> |
| 25 | #include <osmocom/sgsn/sgsn.h> |
| 26 | #include <osmocom/sgsn/debug.h> |
Holger Hans Peter Freyther | a273030 | 2014-03-23 18:08:26 +0100 | [diff] [blame] | 27 | |
| 28 | #include <pdp.h> |
| 29 | |
| 30 | extern vector ctrl_node_vec; |
| 31 | |
Holger Hans Peter Freyther | a273030 | 2014-03-23 18:08:26 +0100 | [diff] [blame] | 32 | static 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 | } |
Max | 50eb669 | 2017-05-02 16:44:43 +0200 | [diff] [blame] | 55 | CTRL_CMD_DEFINE_RO(subscriber_list, "subscriber-list-active-v1"); |
Holger Hans Peter Freyther | a273030 | 2014-03-23 18:08:26 +0100 | [diff] [blame] | 56 | |
| 57 | int 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 Hofmeyr | 7382815 | 2016-02-23 15:10:33 +0100 | [diff] [blame] | 64 | struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *net, |
| 65 | const char *bind_addr, uint16_t port) |
Holger Hans Peter Freyther | a273030 | 2014-03-23 18:08:26 +0100 | [diff] [blame] | 66 | { |
Neels Hofmeyr | 7382815 | 2016-02-23 15:10:33 +0100 | [diff] [blame] | 67 | return ctrl_interface_setup_dynip(net, bind_addr, port, NULL); |
Holger Hans Peter Freyther | a273030 | 2014-03-23 18:08:26 +0100 | [diff] [blame] | 68 | } |