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