Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1 | /* OpenBSC interface to quagga VTY */ |
| 2 | /* (C) 2009 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 0e7d071 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 3 | * (C) 2009-2011 by Holger Hans Peter Freyther |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 14 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 15 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <stdlib.h> |
Holger Hans Peter Freyther | 73b878a | 2010-12-25 00:33:40 +0100 | [diff] [blame] | 22 | #include <limits.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 23 | #include <unistd.h> |
Holger Hans Peter Freyther | b970894 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 24 | #include <time.h> |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 25 | #include <inttypes.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 26 | |
Harald Welte | 4b037e4 | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 27 | #include <osmocom/vty/command.h> |
| 28 | #include <osmocom/vty/buffer.h> |
| 29 | #include <osmocom/vty/vty.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 30 | |
| 31 | #include <arpa/inet.h> |
| 32 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 33 | #include <osmocom/core/linuxlist.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 34 | #include <openbsc/gsm_data.h> |
| 35 | #include <openbsc/gsm_subscriber.h> |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 36 | #include <openbsc/bsc_subscriber.h> |
Harald Welte | b54d950 | 2009-11-17 06:00:23 +0100 | [diff] [blame] | 37 | #include <openbsc/silent_call.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 38 | #include <openbsc/gsm_04_11.h> |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 39 | #include <osmocom/abis/e1_input.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 40 | #include <openbsc/abis_nm.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 41 | #include <osmocom/gsm/gsm_utils.h> |
| 42 | #include <osmocom/core/utils.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 43 | #include <openbsc/db.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 44 | #include <osmocom/core/talloc.h> |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 45 | #include <openbsc/signal.h> |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 46 | #include <openbsc/debug.h> |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 47 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 48 | #include <openbsc/gsm_04_80.h> |
Harald Welte | ba2ad43 | 2017-06-12 01:52:27 +0200 | [diff] [blame] | 49 | #include <openbsc/gsm_04_14.h> |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 50 | #include <openbsc/chan_alloc.h> |
Holger Hans Peter Freyther | 81c0e25 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 51 | #include <openbsc/sms_queue.h> |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 52 | #include <openbsc/mncc_int.h> |
Holger Hans Peter Freyther | 4485321 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 53 | #include <openbsc/handover.h> |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 54 | #include <openbsc/vlr.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 55 | |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 56 | #include <osmocom/vty/logging.h> |
| 57 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 58 | #include <openbsc/osmo_msc.h> |
| 59 | |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 60 | #include "meas_feed.h" |
| 61 | |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 62 | extern struct gsm_network *gsmnet_from_vty(struct vty *v); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 63 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 64 | static void subscr_dump_full_vty(struct vty *vty, struct vlr_subscr *vsub) |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 65 | { |
Holger Hans Peter Freyther | c9dbe3c | 2015-08-04 13:18:47 +0200 | [diff] [blame] | 66 | int reqs; |
Holger Hans Peter Freyther | c9dbe3c | 2015-08-04 13:18:47 +0200 | [diff] [blame] | 67 | struct llist_head *entry; |
Holger Hans Peter Freyther | b970894 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 68 | char expire_time[200]; |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 69 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 70 | if (strlen(vsub->name)) |
| 71 | vty_out(vty, " Name: '%s'%s", vsub->name, VTY_NEWLINE); |
| 72 | if (strlen(vsub->msisdn)) |
| 73 | vty_out(vty, " Extension: %s%s", vsub->msisdn, |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 74 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 3d76e44 | 2010-12-25 16:40:54 +0100 | [diff] [blame] | 75 | vty_out(vty, " LAC: %d/0x%x%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 76 | vsub->lac, vsub->lac, VTY_NEWLINE); |
| 77 | vty_out(vty, " IMSI: %s%s", vsub->imsi, VTY_NEWLINE); |
| 78 | if (vsub->tmsi != GSM_RESERVED_TMSI) |
| 79 | vty_out(vty, " TMSI: %08X%s", vsub->tmsi, |
| 80 | VTY_NEWLINE); |
| 81 | if (vsub->tmsi_new != GSM_RESERVED_TMSI) |
| 82 | vty_out(vty, " new TMSI: %08X%s", vsub->tmsi_new, |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 83 | VTY_NEWLINE); |
| 84 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 85 | #if 0 |
| 86 | /* TODO: add this to vlr_subscr? */ |
| 87 | if (vsub->auth_info.auth_algo != AUTH_ALGO_NONE) { |
| 88 | struct gsm_auth_info *i = &vsub->auth_info; |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 89 | vty_out(vty, " A3A8 algorithm id: %d%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 90 | i->auth_algo, VTY_NEWLINE); |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 91 | vty_out(vty, " A3A8 Ki: %s%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 92 | osmo_hexdump(i->a3a8_ki, i->a3a8_ki_len), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 93 | VTY_NEWLINE); |
| 94 | } |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 95 | #endif |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 96 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 97 | if (vsub->last_tuple) { |
| 98 | struct gsm_auth_tuple *t = vsub->last_tuple; |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 99 | vty_out(vty, " A3A8 last tuple (used %d times):%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 100 | t->use_count, VTY_NEWLINE); |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 101 | vty_out(vty, " seq # : %d%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 102 | t->key_seq, VTY_NEWLINE); |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 103 | vty_out(vty, " RAND : %s%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 104 | osmo_hexdump(t->vec.rand, sizeof(t->vec.rand)), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 105 | VTY_NEWLINE); |
| 106 | vty_out(vty, " SRES : %s%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 107 | osmo_hexdump(t->vec.sres, sizeof(t->vec.sres)), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 108 | VTY_NEWLINE); |
| 109 | vty_out(vty, " Kc : %s%s", |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 110 | osmo_hexdump(t->vec.kc, sizeof(t->vec.kc)), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 111 | VTY_NEWLINE); |
| 112 | } |
Holger Hans Peter Freyther | b970894 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 113 | |
| 114 | /* print the expiration time of a subscriber */ |
| 115 | strftime(expire_time, sizeof(expire_time), |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 116 | "%a, %d %b %Y %T %z", localtime(&vsub->expire_lu)); |
Holger Hans Peter Freyther | b970894 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 117 | expire_time[sizeof(expire_time) - 1] = '\0'; |
| 118 | vty_out(vty, " Expiration Time: %s%s", expire_time, VTY_NEWLINE); |
Holger Hans Peter Freyther | c9dbe3c | 2015-08-04 13:18:47 +0200 | [diff] [blame] | 119 | |
| 120 | reqs = 0; |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 121 | llist_for_each(entry, &vsub->cs.requests) |
Holger Hans Peter Freyther | c9dbe3c | 2015-08-04 13:18:47 +0200 | [diff] [blame] | 122 | reqs += 1; |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 123 | vty_out(vty, " Paging: %s paging for %d requests%s", |
| 124 | vsub->cs.is_paging ? "is" : "not", reqs, VTY_NEWLINE); |
| 125 | vty_out(vty, " Use count: %u%s", vsub->use_count, VTY_NEWLINE); |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 129 | /* Subscriber */ |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 130 | DEFUN(show_subscr_cache, |
| 131 | show_subscr_cache_cmd, |
| 132 | "show subscriber cache", |
Harald Welte | cfaabbb | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 133 | SHOW_STR "Show information about subscribers\n" |
| 134 | "Display contents of subscriber cache\n") |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 135 | { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 136 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 137 | struct vlr_subscr *vsub; |
| 138 | int count = 0; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 139 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 140 | llist_for_each_entry(vsub, &gsmnet->vlr->subscribers, list) { |
| 141 | if (++count > 100) { |
| 142 | vty_out(vty, "%% More than %d subscribers in cache," |
| 143 | " stopping here.%s", count-1, VTY_NEWLINE); |
| 144 | break; |
| 145 | } |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 146 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 147 | subscr_dump_full_vty(vty, vsub); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | return CMD_SUCCESS; |
| 151 | } |
| 152 | |
| 153 | DEFUN(sms_send_pend, |
| 154 | sms_send_pend_cmd, |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 155 | "sms send pending", |
Neels Hofmeyr | d1fdefe | 2016-04-01 02:17:24 +0200 | [diff] [blame] | 156 | "SMS related commands\n" "SMS Sending related commands\n" |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 157 | "Send all pending SMS") |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 158 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 159 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 160 | struct gsm_sms *sms; |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 161 | unsigned long long sms_id = 0; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 162 | |
| 163 | while (1) { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 164 | sms = db_sms_get_next_unsent(gsmnet, sms_id, UINT_MAX); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 165 | if (!sms) |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 166 | break; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 167 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 168 | if (sms->receiver) |
| 169 | gsm411_send_sms_subscr(sms->receiver, sms); |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 170 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 171 | sms_id = sms->id + 1; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | return CMD_SUCCESS; |
| 175 | } |
| 176 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 177 | static int _send_sms_str(struct vlr_subscr *receiver, |
| 178 | struct vlr_subscr *sender, |
| 179 | char *str, uint8_t tp_pid) |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 180 | { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 181 | struct gsm_network *net = receiver->vlr->user_ctx; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 182 | struct gsm_sms *sms; |
| 183 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 184 | sms = sms_from_text(receiver, sender, 0, str); |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 185 | sms->protocol_id = tp_pid; |
Nico Golde | 5950236 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 186 | |
Holger Hans Peter Freyther | 445e615 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 187 | /* store in database for the queue */ |
| 188 | if (db_sms_store(sms) != 0) { |
Holger Hans Peter Freyther | eff4094 | 2012-11-10 19:46:58 +0100 | [diff] [blame] | 189 | LOGP(DLSMS, LOGL_ERROR, "Failed to store SMS in Database\n"); |
Holger Hans Peter Freyther | 445e615 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 190 | sms_free(sms); |
| 191 | return CMD_WARNING; |
Nico Golde | 5950236 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 192 | } |
Neels Hofmeyr | 1e918c3 | 2016-05-09 21:48:53 +0200 | [diff] [blame] | 193 | LOGP(DLSMS, LOGL_DEBUG, "SMS stored in DB\n"); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 194 | |
Holger Hans Peter Freyther | 445e615 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 195 | sms_free(sms); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 196 | sms_queue_trigger(net->sms_queue); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 197 | return CMD_SUCCESS; |
| 198 | } |
| 199 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 200 | static struct vlr_subscr *get_vsub_by_argv(struct gsm_network *gsmnet, |
| 201 | const char *type, |
| 202 | const char *id) |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 203 | { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 204 | if (!strcmp(type, "extension") || !strcmp(type, "msisdn")) |
| 205 | return vlr_subscr_find_by_msisdn(gsmnet->vlr, id); |
| 206 | else if (!strcmp(type, "imsi") || !strcmp(type, "id")) |
| 207 | return vlr_subscr_find_by_imsi(gsmnet->vlr, id); |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 208 | else if (!strcmp(type, "tmsi")) |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 209 | return vlr_subscr_find_by_tmsi(gsmnet->vlr, atoi(id)); |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 210 | |
| 211 | return NULL; |
| 212 | } |
| 213 | #define SUBSCR_TYPES "(extension|imsi|tmsi|id)" |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 214 | #define SUBSCR_HELP "Operations on a Subscriber\n" \ |
Neels Hofmeyr | d1fdefe | 2016-04-01 02:17:24 +0200 | [diff] [blame] | 215 | "Identify subscriber by extension (phone number)\n" \ |
| 216 | "Identify subscriber by IMSI\n" \ |
| 217 | "Identify subscriber by TMSI\n" \ |
| 218 | "Identify subscriber by database ID\n" \ |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 219 | "Identifier for the subscriber\n" |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 220 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 221 | DEFUN(show_subscr, |
| 222 | show_subscr_cmd, |
| 223 | "show subscriber " SUBSCR_TYPES " ID", |
| 224 | SHOW_STR SUBSCR_HELP) |
| 225 | { |
| 226 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 227 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], |
| 228 | argv[1]); |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 229 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 230 | if (!vsub) { |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 231 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 232 | argv[0], argv[1], VTY_NEWLINE); |
| 233 | return CMD_WARNING; |
| 234 | } |
| 235 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 236 | subscr_dump_full_vty(vty, vsub); |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 237 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 238 | vlr_subscr_put(vsub); |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 239 | |
| 240 | return CMD_SUCCESS; |
| 241 | } |
| 242 | |
Alexander Chemeris | bd6d40f | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 243 | DEFUN(subscriber_create, |
| 244 | subscriber_create_cmd, |
| 245 | "subscriber create imsi ID", |
| 246 | "Operations on a Subscriber\n" \ |
| 247 | "Create new subscriber\n" \ |
| 248 | "Identify the subscriber by his IMSI\n" \ |
| 249 | "Identifier for the subscriber\n") |
| 250 | { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 251 | vty_out(vty, "%% 'subscriber create' now needs to be done at osmo-hlr%s", |
| 252 | VTY_NEWLINE); |
| 253 | return CMD_WARNING; |
Alexander Chemeris | bd6d40f | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 254 | } |
| 255 | |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 256 | DEFUN(subscriber_send_pending_sms, |
| 257 | subscriber_send_pending_sms_cmd, |
Holger Hans Peter Freyther | 3217fa2 | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 258 | "subscriber " SUBSCR_TYPES " ID sms pending-send", |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 259 | SUBSCR_HELP "SMS Operations\n" "Send pending SMS\n") |
| 260 | { |
| 261 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 262 | struct vlr_subscr *vsub; |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 263 | struct gsm_sms *sms; |
| 264 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 265 | vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 266 | if (!vsub) { |
Holger Hans Peter Freyther | 9feef48 | 2013-07-04 20:34:46 +0200 | [diff] [blame] | 267 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 268 | argv[0], argv[1], VTY_NEWLINE); |
| 269 | return CMD_WARNING; |
| 270 | } |
| 271 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 272 | sms = db_sms_get_unsent_for_subscr(vsub, UINT_MAX); |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 273 | if (sms) |
| 274 | gsm411_send_sms_subscr(sms->receiver, sms); |
| 275 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 276 | vlr_subscr_put(vsub); |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 277 | |
| 278 | return CMD_SUCCESS; |
| 279 | } |
| 280 | |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 281 | DEFUN(subscriber_send_sms, |
| 282 | subscriber_send_sms_cmd, |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 283 | "subscriber " SUBSCR_TYPES " ID sms sender " SUBSCR_TYPES " SENDER_ID send .LINE", |
Holger Hans Peter Freyther | 63b0e44 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 284 | SUBSCR_HELP "SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS Text\n") |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 285 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 286 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 287 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 288 | struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 289 | char *str; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 290 | int rc; |
| 291 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 292 | if (!vsub) { |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 293 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 294 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 295 | rc = CMD_WARNING; |
| 296 | goto err; |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 297 | } |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 298 | |
| 299 | if (!sender) { |
| 300 | vty_out(vty, "%% No sender found for %s %s%s", |
| 301 | argv[2], argv[3], VTY_NEWLINE); |
| 302 | rc = CMD_WARNING; |
| 303 | goto err; |
| 304 | } |
| 305 | |
| 306 | str = argv_concat(argv, argc, 4); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 307 | rc = _send_sms_str(vsub, sender, str, 0); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 308 | talloc_free(str); |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 309 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 310 | err: |
| 311 | if (sender) |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 312 | vlr_subscr_put(sender); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 313 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 314 | if (vsub) |
| 315 | vlr_subscr_put(vsub); |
Harald Welte | af8c7b4 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 316 | |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 317 | return rc; |
| 318 | } |
| 319 | |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 320 | DEFUN(subscriber_silent_sms, |
| 321 | subscriber_silent_sms_cmd, |
Harald Welte | 1011d5b | 2014-07-10 20:19:00 +0200 | [diff] [blame] | 322 | |
| 323 | "subscriber " SUBSCR_TYPES " ID silent-sms sender " SUBSCR_TYPES " SENDER_ID send .LINE", |
| 324 | SUBSCR_HELP "Silent SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS Text\n") |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 325 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 326 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 327 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 328 | struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 329 | char *str; |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 330 | int rc; |
| 331 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 332 | if (!vsub) { |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 333 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 334 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 335 | rc = CMD_WARNING; |
| 336 | goto err; |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 337 | } |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 338 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 339 | if (!sender) { |
| 340 | vty_out(vty, "%% No sender found for %s %s%s", |
| 341 | argv[2], argv[3], VTY_NEWLINE); |
| 342 | rc = CMD_WARNING; |
| 343 | goto err; |
| 344 | } |
| 345 | |
| 346 | str = argv_concat(argv, argc, 4); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 347 | rc = _send_sms_str(vsub, sender, str, 64); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 348 | talloc_free(str); |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 349 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 350 | err: |
| 351 | if (sender) |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 352 | vlr_subscr_put(sender); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 353 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 354 | if (vsub) |
| 355 | vlr_subscr_put(vsub); |
Harald Welte | af8c7b4 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 356 | |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 357 | return rc; |
| 358 | } |
| 359 | |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 360 | #define CHAN_TYPES "(any|tch/f|tch/any|sdcch)" |
| 361 | #define CHAN_TYPE_HELP \ |
| 362 | "Any channel\n" \ |
| 363 | "TCH/F channel\n" \ |
| 364 | "Any TCH channel\n" \ |
| 365 | "SDCCH channel\n" |
| 366 | |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 367 | DEFUN(subscriber_silent_call_start, |
| 368 | subscriber_silent_call_start_cmd, |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 369 | "subscriber " SUBSCR_TYPES " ID silent-call start (any|tch/f|tch/any|sdcch)", |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 370 | SUBSCR_HELP "Silent call operation\n" "Start silent call\n" |
| 371 | CHAN_TYPE_HELP) |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 372 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 373 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 374 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 375 | int rc, type; |
| 376 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 377 | if (!vsub) { |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 378 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 379 | argv[0], argv[1], VTY_NEWLINE); |
| 380 | return CMD_WARNING; |
| 381 | } |
| 382 | |
| 383 | if (!strcmp(argv[2], "tch/f")) |
| 384 | type = RSL_CHANNEED_TCH_F; |
| 385 | else if (!strcmp(argv[2], "tch/any")) |
| 386 | type = RSL_CHANNEED_TCH_ForH; |
| 387 | else if (!strcmp(argv[2], "sdcch")) |
| 388 | type = RSL_CHANNEED_SDCCH; |
| 389 | else |
| 390 | type = RSL_CHANNEED_ANY; /* Defaults to ANY */ |
| 391 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 392 | rc = gsm_silent_call_start(vsub, vty, type); |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 393 | if (rc <= 0) { |
| 394 | vty_out(vty, "%% Subscriber not attached%s", |
| 395 | VTY_NEWLINE); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 396 | vlr_subscr_put(vsub); |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 397 | return CMD_WARNING; |
| 398 | } |
| 399 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 400 | vlr_subscr_put(vsub); |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 401 | |
| 402 | return CMD_SUCCESS; |
| 403 | } |
| 404 | |
| 405 | DEFUN(subscriber_silent_call_stop, |
| 406 | subscriber_silent_call_stop_cmd, |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 407 | "subscriber " SUBSCR_TYPES " ID silent-call stop", |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 408 | SUBSCR_HELP "Silent call operation\n" "Stop silent call\n" |
| 409 | CHAN_TYPE_HELP) |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 410 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 411 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 412 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 413 | int rc; |
| 414 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 415 | if (!vsub) { |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 416 | vty_out(vty, "%% No subscriber found for %s %s%s", |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 417 | argv[0], argv[1], VTY_NEWLINE); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 418 | return CMD_WARNING; |
| 419 | } |
| 420 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 421 | rc = gsm_silent_call_stop(vsub); |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 422 | if (rc < 0) { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 423 | vlr_subscr_put(vsub); |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 424 | return CMD_WARNING; |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 425 | } |
| 426 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 427 | vlr_subscr_put(vsub); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 428 | |
| 429 | return CMD_SUCCESS; |
| 430 | } |
| 431 | |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 432 | DEFUN(subscriber_ussd_notify, |
| 433 | subscriber_ussd_notify_cmd, |
Holger Hans Peter Freyther | e731e1d | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 434 | "subscriber " SUBSCR_TYPES " ID ussd-notify (0|1|2) .TEXT", |
Harald Welte | cfaabbb | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 435 | SUBSCR_HELP "Send a USSD notify to the subscriber\n" |
Harald Welte | cfaabbb | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 436 | "Alerting Level 0\n" |
| 437 | "Alerting Level 1\n" |
| 438 | "Alerting Level 2\n" |
| 439 | "Text of USSD message to send\n") |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 440 | { |
| 441 | char *text; |
| 442 | struct gsm_subscriber_connection *conn; |
| 443 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 444 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Holger Hans Peter Freyther | e731e1d | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 445 | int level; |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 446 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 447 | if (!vsub) { |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 448 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 449 | argv[0], argv[1], VTY_NEWLINE); |
| 450 | return CMD_WARNING; |
| 451 | } |
| 452 | |
Holger Hans Peter Freyther | e731e1d | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 453 | level = atoi(argv[2]); |
| 454 | text = argv_concat(argv, argc, 3); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 455 | if (!text) { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 456 | vlr_subscr_put(vsub); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 457 | return CMD_WARNING; |
| 458 | } |
| 459 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 460 | conn = connection_for_subscr(vsub); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 461 | if (!conn) { |
| 462 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 463 | argv[0], argv[1], VTY_NEWLINE); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 464 | vlr_subscr_put(vsub); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 465 | talloc_free(text); |
| 466 | return CMD_WARNING; |
| 467 | } |
| 468 | |
Neels Hofmeyr | 43273c6 | 2016-05-10 12:50:31 +0200 | [diff] [blame] | 469 | msc_send_ussd_notify(conn, level, text); |
| 470 | msc_send_ussd_release_complete(conn); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 471 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 472 | vlr_subscr_put(vsub); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 473 | talloc_free(text); |
| 474 | return CMD_SUCCESS; |
| 475 | } |
| 476 | |
Harald Welte | ba2ad43 | 2017-06-12 01:52:27 +0200 | [diff] [blame] | 477 | static int loop_by_char(uint8_t ch) |
| 478 | { |
| 479 | switch (ch) { |
| 480 | case 'a': |
| 481 | return GSM414_LOOP_A; |
| 482 | case 'b': |
| 483 | return GSM414_LOOP_B; |
| 484 | case 'c': |
| 485 | return GSM414_LOOP_C; |
| 486 | case 'd': |
| 487 | return GSM414_LOOP_D; |
| 488 | case 'e': |
| 489 | return GSM414_LOOP_E; |
| 490 | case 'f': |
| 491 | return GSM414_LOOP_F; |
| 492 | case 'i': |
| 493 | return GSM414_LOOP_I; |
| 494 | } |
| 495 | return -1; |
| 496 | } |
| 497 | |
| 498 | DEFUN(subscriber_mstest_close, |
| 499 | subscriber_mstest_close_cmd, |
| 500 | "subscriber " SUBSCR_TYPES " ID ms-test close-loop (a|b|c|d|e|f|i)", |
| 501 | SUBSCR_HELP "Send a TS 04.14 MS Test Command to subscriber\n" |
| 502 | "Close a TCH Loop inside the MS\n" |
| 503 | "Loop Type A\n" |
| 504 | "Loop Type B\n" |
| 505 | "Loop Type C\n" |
| 506 | "Loop Type D\n" |
| 507 | "Loop Type E\n" |
| 508 | "Loop Type F\n" |
| 509 | "Loop Type I\n") |
| 510 | { |
| 511 | struct gsm_subscriber_connection *conn; |
| 512 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 513 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 514 | const char *loop_str; |
| 515 | int loop_mode; |
| 516 | |
| 517 | if (!vsub) { |
| 518 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 519 | argv[0], argv[1], VTY_NEWLINE); |
| 520 | return CMD_WARNING; |
| 521 | } |
| 522 | |
| 523 | loop_str = argv[2]; |
| 524 | loop_mode = loop_by_char(loop_str[0]); |
| 525 | |
| 526 | conn = connection_for_subscr(vsub); |
| 527 | if (!conn) { |
| 528 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 529 | argv[0], argv[1], VTY_NEWLINE); |
| 530 | vlr_subscr_put(vsub); |
| 531 | return CMD_WARNING; |
| 532 | } |
| 533 | |
| 534 | gsm0414_tx_close_tch_loop_cmd(conn, loop_mode); |
| 535 | |
| 536 | return CMD_SUCCESS; |
| 537 | } |
| 538 | |
| 539 | DEFUN(subscriber_mstest_open, |
| 540 | subscriber_mstest_open_cmd, |
| 541 | "subscriber " SUBSCR_TYPES " ID ms-test open-loop", |
| 542 | SUBSCR_HELP "Send a TS 04.14 MS Test Command to subscriber\n" |
| 543 | "Open a TCH Loop inside the MS\n") |
| 544 | { |
| 545 | struct gsm_subscriber_connection *conn; |
| 546 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 547 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 548 | |
| 549 | if (!vsub) { |
| 550 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 551 | argv[0], argv[1], VTY_NEWLINE); |
| 552 | return CMD_WARNING; |
| 553 | } |
| 554 | |
| 555 | conn = connection_for_subscr(vsub); |
| 556 | if (!conn) { |
| 557 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 558 | argv[0], argv[1], VTY_NEWLINE); |
| 559 | vlr_subscr_put(vsub); |
| 560 | return CMD_WARNING; |
| 561 | } |
| 562 | |
| 563 | gsm0414_tx_open_loop_cmd(conn); |
| 564 | |
| 565 | return CMD_SUCCESS; |
| 566 | } |
| 567 | |
Keith | d32b6d1 | 2017-01-18 17:09:33 +0100 | [diff] [blame] | 568 | DEFUN(ena_subscr_expire, |
| 569 | ena_subscr_expire_cmd, |
| 570 | "subscriber " SUBSCR_TYPES " ID expire", |
| 571 | SUBSCR_HELP "Expire the subscriber Now\n") |
| 572 | { |
Keith | d32b6d1 | 2017-01-18 17:09:33 +0100 | [diff] [blame] | 573 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 574 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], |
| 575 | argv[1]); |
Keith | d32b6d1 | 2017-01-18 17:09:33 +0100 | [diff] [blame] | 576 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 577 | if (!vsub) { |
Keith | d32b6d1 | 2017-01-18 17:09:33 +0100 | [diff] [blame] | 578 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 579 | argv[0], argv[1], VTY_NEWLINE); |
| 580 | return CMD_WARNING; |
| 581 | } |
| 582 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 583 | if (vsub->lu_complete) { |
| 584 | vsub->lu_complete = false; |
| 585 | vlr_subscr_put(vsub); |
| 586 | vty_out(vty, "%% VLR released subscriber %s%s", |
| 587 | vlr_subscr_name(vsub), VTY_NEWLINE); |
| 588 | } |
Keith | d32b6d1 | 2017-01-18 17:09:33 +0100 | [diff] [blame] | 589 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 590 | if (vsub->use_count > 1) |
| 591 | vty_out(vty, "%% Subscriber %s is still in use," |
| 592 | " should be released soon%s", |
| 593 | vlr_subscr_name(vsub), VTY_NEWLINE); |
| 594 | |
| 595 | vlr_subscr_put(vsub); |
Keith | d32b6d1 | 2017-01-18 17:09:33 +0100 | [diff] [blame] | 596 | return CMD_SUCCESS; |
| 597 | } |
| 598 | |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 599 | #define A3A8_ALG_TYPES "(none|xor|comp128v1)" |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 600 | #define A3A8_ALG_HELP \ |
| 601 | "Use No A3A8 algorithm\n" \ |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 602 | "Use XOR algorithm\n" \ |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 603 | "Use COMP128v1 algorithm\n" |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 604 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 605 | DEFUN(ena_subscr_a3a8, |
| 606 | ena_subscr_a3a8_cmd, |
| 607 | "subscriber " SUBSCR_TYPES " ID a3a8 " A3A8_ALG_TYPES " [KI]", |
Harald Welte | d3cf85d | 2010-05-27 10:48:11 +0200 | [diff] [blame] | 608 | SUBSCR_HELP "Set a3a8 parameters for the subscriber\n" |
| 609 | A3A8_ALG_HELP "Encryption Key Ki\n") |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 610 | { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 611 | vty_out(vty, "%% 'subscriber a3a8' is no longer supported.%s" |
| 612 | "%% This is now up to osmo-hlr.%s", |
| 613 | VTY_NEWLINE, VTY_NEWLINE); |
| 614 | return CMD_WARNING; |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 615 | } |
| 616 | |
Holger Hans Peter Freyther | abd0cac | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 617 | DEFUN(subscriber_update, |
| 618 | subscriber_update_cmd, |
| 619 | "subscriber " SUBSCR_TYPES " ID update", |
| 620 | SUBSCR_HELP "Update the subscriber data from the dabase.\n") |
| 621 | { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 622 | vty_out(vty, "%% 'subscriber update' is no longer supported.%s", |
| 623 | VTY_NEWLINE); |
| 624 | return CMD_WARNING; |
Holger Hans Peter Freyther | abd0cac | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 625 | } |
| 626 | |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 627 | static int scall_cbfn(unsigned int subsys, unsigned int signal, |
| 628 | void *handler_data, void *signal_data) |
| 629 | { |
| 630 | struct scall_signal_data *sigdata = signal_data; |
| 631 | struct vty *vty = sigdata->data; |
| 632 | |
| 633 | switch (signal) { |
| 634 | case S_SCALL_SUCCESS: |
Neels Hofmeyr | ce67be1 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 635 | vty_out(vty, "%% silent call success%s", VTY_NEWLINE); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 636 | break; |
| 637 | case S_SCALL_EXPIRED: |
| 638 | vty_out(vty, "%% silent call expired paging%s", VTY_NEWLINE); |
| 639 | break; |
| 640 | } |
| 641 | return 0; |
| 642 | } |
| 643 | |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 644 | DEFUN(show_stats, |
| 645 | show_stats_cmd, |
| 646 | "show statistics", |
| 647 | SHOW_STR "Display network statistics\n") |
| 648 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 649 | struct gsm_network *net = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 650 | |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 651 | vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s", |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 652 | net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_ATTACH].current, |
| 653 | net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_NORMAL].current, |
| 654 | net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_PERIODIC].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 655 | VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 656 | vty_out(vty, "IMSI Detach Indications : %lu%s", |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 657 | net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_DETACH].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 658 | VTY_NEWLINE); |
Neels Hofmeyr | 36891a7 | 2016-05-09 13:18:03 +0200 | [diff] [blame] | 659 | vty_out(vty, "Location Updating Results: %lu completed, %lu failed%s", |
| 660 | net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_COMPLETED].current, |
| 661 | net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_FAILED].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 662 | VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 663 | vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, " |
| 664 | "%lu completed, %lu failed%s", |
Alexander Chemeris | 8508ee5 | 2017-07-08 18:00:36 +0900 | [diff] [blame] | 665 | net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_ATTEMPTED].current, |
| 666 | net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_NO_CHANNEL].current, |
| 667 | net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_TIMEOUT].current, |
| 668 | net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_COMPLETED].current, |
| 669 | net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_FAILED].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 670 | VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 671 | vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s", |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 672 | net->msc_ctrs->ctr[MSC_CTR_SMS_SUBMITTED].current, |
| 673 | net->msc_ctrs->ctr[MSC_CTR_SMS_NO_RECEIVER].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 674 | VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 675 | vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s", |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 676 | net->msc_ctrs->ctr[MSC_CTR_SMS_DELIVERED].current, |
| 677 | net->msc_ctrs->ctr[MSC_CTR_SMS_RP_ERR_MEM].current, |
| 678 | net->msc_ctrs->ctr[MSC_CTR_SMS_RP_ERR_OTHER].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 679 | VTY_NEWLINE); |
Harald Welte | a29e43a | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 680 | vty_out(vty, "MO Calls : %lu setup, %lu connect ack%s", |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 681 | net->msc_ctrs->ctr[MSC_CTR_CALL_MO_SETUP].current, |
| 682 | net->msc_ctrs->ctr[MSC_CTR_CALL_MO_CONNECT_ACK].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 683 | VTY_NEWLINE); |
Harald Welte | a29e43a | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 684 | vty_out(vty, "MT Calls : %lu setup, %lu connect%s", |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 685 | net->msc_ctrs->ctr[MSC_CTR_CALL_MT_SETUP].current, |
| 686 | net->msc_ctrs->ctr[MSC_CTR_CALL_MT_CONNECT].current, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 687 | VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 688 | return CMD_SUCCESS; |
| 689 | } |
| 690 | |
Holger Hans Peter Freyther | 81c0e25 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 691 | DEFUN(show_smsqueue, |
| 692 | show_smsqueue_cmd, |
| 693 | "show sms-queue", |
| 694 | SHOW_STR "Display SMSqueue statistics\n") |
| 695 | { |
| 696 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 697 | |
| 698 | sms_queue_stats(net->sms_queue, vty); |
| 699 | return CMD_SUCCESS; |
| 700 | } |
| 701 | |
Holger Hans Peter Freyther | 7a0e166 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 702 | DEFUN(smsqueue_trigger, |
| 703 | smsqueue_trigger_cmd, |
| 704 | "sms-queue trigger", |
| 705 | "SMS Queue\n" "Trigger sending messages\n") |
| 706 | { |
| 707 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 708 | |
| 709 | sms_queue_trigger(net->sms_queue); |
| 710 | return CMD_SUCCESS; |
| 711 | } |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 712 | |
Holger Hans Peter Freyther | 3c6f6c2 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 713 | DEFUN(smsqueue_max, |
| 714 | smsqueue_max_cmd, |
| 715 | "sms-queue max-pending <1-500>", |
Holger Hans Peter Freyther | 3217fa2 | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 716 | "SMS Queue\n" "SMS to deliver in parallel\n" "Amount\n") |
Holger Hans Peter Freyther | 3c6f6c2 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 717 | { |
| 718 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 719 | |
| 720 | sms_queue_set_max_pending(net->sms_queue, atoi(argv[0])); |
| 721 | return CMD_SUCCESS; |
| 722 | } |
| 723 | |
Holger Hans Peter Freyther | 4dcc5e5 | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 724 | DEFUN(smsqueue_clear, |
| 725 | smsqueue_clear_cmd, |
| 726 | "sms-queue clear", |
| 727 | "SMS Queue\n" "Clear the queue of pending SMS\n") |
| 728 | { |
| 729 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 730 | |
| 731 | sms_queue_clear(net->sms_queue); |
| 732 | return CMD_SUCCESS; |
| 733 | } |
| 734 | |
Holger Hans Peter Freyther | 994dcbb | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 735 | DEFUN(smsqueue_fail, |
| 736 | smsqueue_fail_cmd, |
| 737 | "sms-queue max-failure <1-500>", |
Holger Hans Peter Freyther | 3217fa2 | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 738 | "SMS Queue\n" "Maximum amount of delivery failures\n" "Amount\n") |
Holger Hans Peter Freyther | 994dcbb | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 739 | { |
| 740 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 741 | |
| 742 | sms_queue_set_max_failure(net->sms_queue, atoi(argv[0])); |
| 743 | return CMD_SUCCESS; |
| 744 | } |
| 745 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 746 | |
| 747 | DEFUN(cfg_mncc_int, cfg_mncc_int_cmd, |
| 748 | "mncc-int", "Configure internal MNCC handler") |
| 749 | { |
| 750 | vty->node = MNCC_INT_NODE; |
| 751 | |
| 752 | return CMD_SUCCESS; |
| 753 | } |
| 754 | |
| 755 | static struct cmd_node mncc_int_node = { |
| 756 | MNCC_INT_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 757 | "%s(config-mncc-int)# ", |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 758 | 1, |
| 759 | }; |
| 760 | |
| 761 | static const struct value_string tchf_codec_names[] = { |
| 762 | { GSM48_CMODE_SPEECH_V1, "fr" }, |
| 763 | { GSM48_CMODE_SPEECH_EFR, "efr" }, |
| 764 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 765 | { 0, NULL } |
| 766 | }; |
| 767 | |
| 768 | static const struct value_string tchh_codec_names[] = { |
| 769 | { GSM48_CMODE_SPEECH_V1, "hr" }, |
| 770 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 771 | { 0, NULL } |
| 772 | }; |
| 773 | |
| 774 | static int config_write_mncc_int(struct vty *vty) |
| 775 | { |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 776 | uint16_t meas_port; |
| 777 | char *meas_host; |
Holger Hans Peter Freyther | 8657326 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 778 | const char *meas_scenario; |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 779 | |
| 780 | meas_feed_cfg_get(&meas_host, &meas_port); |
Holger Hans Peter Freyther | 8657326 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 781 | meas_scenario = meas_feed_scenario_get(); |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 782 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 783 | vty_out(vty, "mncc-int%s", VTY_NEWLINE); |
| 784 | vty_out(vty, " default-codec tch-f %s%s", |
| 785 | get_value_string(tchf_codec_names, mncc_int.def_codec[0]), |
| 786 | VTY_NEWLINE); |
| 787 | vty_out(vty, " default-codec tch-h %s%s", |
| 788 | get_value_string(tchh_codec_names, mncc_int.def_codec[1]), |
| 789 | VTY_NEWLINE); |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 790 | if (meas_port) |
| 791 | vty_out(vty, " meas-feed destination %s %u%s", |
| 792 | meas_host, meas_port, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8657326 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 793 | if (strlen(meas_scenario) > 0) |
| 794 | vty_out(vty, " meas-feed scenario %s%s", |
| 795 | meas_scenario, VTY_NEWLINE); |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 796 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 797 | |
| 798 | return CMD_SUCCESS; |
| 799 | } |
| 800 | |
| 801 | DEFUN(mnccint_def_codec_f, |
| 802 | mnccint_def_codec_f_cmd, |
| 803 | "default-codec tch-f (fr|efr|amr)", |
| 804 | "Set default codec\n" "Codec for TCH/F\n" |
| 805 | "Full-Rate\n" "Enhanced Full-Rate\n" "Adaptive Multi-Rate\n") |
| 806 | { |
| 807 | mncc_int.def_codec[0] = get_string_value(tchf_codec_names, argv[0]); |
| 808 | |
| 809 | return CMD_SUCCESS; |
| 810 | } |
| 811 | |
| 812 | DEFUN(mnccint_def_codec_h, |
| 813 | mnccint_def_codec_h_cmd, |
| 814 | "default-codec tch-h (hr|amr)", |
| 815 | "Set default codec\n" "Codec for TCH/H\n" |
| 816 | "Half-Rate\n" "Adaptive Multi-Rate\n") |
| 817 | { |
| 818 | mncc_int.def_codec[1] = get_string_value(tchh_codec_names, argv[0]); |
| 819 | |
| 820 | return CMD_SUCCESS; |
| 821 | } |
| 822 | |
Holger Hans Peter Freyther | 63b0e44 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 823 | #define OBSOLETE_MSG "Obsolete\n" |
Harald Welte | b02fc1e | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 824 | /* this is just for backwards compatibility as the sms code moved into |
| 825 | * libosmocore and old config files no longer parse... */ |
| 826 | DEFUN_DEPRECATED(log_level_sms, log_level_sms_cmd, |
| 827 | "logging level sms (everything|debug|info|notice|error|fatal)", |
Holger Hans Peter Freyther | 63b0e44 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 828 | ".HIDDEN\n" OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG |
| 829 | OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG) |
Harald Welte | b02fc1e | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 830 | { |
| 831 | vty_out(vty, "%% 'logging level sms' is now called 'logging level " |
| 832 | "lsms', please update your config %s", VTY_NEWLINE); |
| 833 | |
| 834 | return CMD_SUCCESS; |
| 835 | } |
| 836 | |
Holger Hans Peter Freyther | a07e38d | 2015-01-31 09:26:20 +0100 | [diff] [blame] | 837 | #define MEAS_STR "Measurement export related\n" |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 838 | DEFUN(mnccint_meas_feed, mnccint_meas_feed_cmd, |
| 839 | "meas-feed destination ADDR <0-65535>", |
Holger Hans Peter Freyther | a07e38d | 2015-01-31 09:26:20 +0100 | [diff] [blame] | 840 | MEAS_STR "destination\n" "address or hostname\n" "port number\n") |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 841 | { |
| 842 | int rc; |
| 843 | |
| 844 | rc = meas_feed_cfg_set(argv[0], atoi(argv[1])); |
| 845 | if (rc < 0) |
| 846 | return CMD_WARNING; |
| 847 | |
| 848 | return CMD_SUCCESS; |
| 849 | } |
| 850 | |
| 851 | DEFUN(meas_feed_scenario, meas_feed_scenario_cmd, |
| 852 | "meas-feed scenario NAME", |
Holger Hans Peter Freyther | a07e38d | 2015-01-31 09:26:20 +0100 | [diff] [blame] | 853 | MEAS_STR "scenario\n" "Name up to 31 characters included in report\n") |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 854 | { |
| 855 | meas_feed_scenario_set(argv[0]); |
| 856 | |
| 857 | return CMD_SUCCESS; |
| 858 | } |
| 859 | |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 860 | |
| 861 | DEFUN(logging_fltr_imsi, |
| 862 | logging_fltr_imsi_cmd, |
| 863 | "logging filter imsi IMSI", |
| 864 | LOGGING_STR FILTER_STR |
| 865 | "Filter log messages by IMSI\n" "IMSI to be used as filter\n") |
| 866 | { |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 867 | struct vlr_subscr *vlr_subscr; |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 868 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 869 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 870 | const char *imsi = argv[0]; |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 871 | |
| 872 | if (!tgt) |
| 873 | return CMD_WARNING; |
| 874 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 875 | vlr_subscr = vlr_subscr_find_by_imsi(gsmnet->vlr, imsi); |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 876 | |
Neels Hofmeyr | 2188a77 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 877 | if (!vlr_subscr) { |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 878 | vty_out(vty, "%%no subscriber with IMSI(%s)%s", |
| 879 | argv[0], VTY_NEWLINE); |
| 880 | return CMD_WARNING; |
| 881 | } |
| 882 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 883 | log_set_filter_vlr_subscr(tgt, vlr_subscr); |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 884 | return CMD_SUCCESS; |
| 885 | } |
Holger Hans Peter Freyther | 925c57f | 2015-01-27 10:58:29 +0100 | [diff] [blame] | 886 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 887 | static struct cmd_node hlr_node = { |
| 888 | HLR_NODE, |
| 889 | "%s(config-hlr)# ", |
| 890 | 1, |
| 891 | }; |
| 892 | |
| 893 | DEFUN(cfg_hlr, cfg_hlr_cmd, |
| 894 | "hlr", "Configure connection to the HLR") |
| 895 | { |
| 896 | vty->node = HLR_NODE; |
| 897 | return CMD_SUCCESS; |
| 898 | } |
| 899 | |
| 900 | DEFUN(cfg_hlr_remote_ip, cfg_hlr_remote_ip_cmd, "remote-ip A.B.C.D", |
| 901 | "Remote GSUP address of the HLR\n" |
| 902 | "Remote GSUP address (default: " MSC_HLR_REMOTE_IP_DEFAULT ")") |
| 903 | { |
| 904 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 905 | talloc_free((void*)gsmnet->gsup_server_addr_str); |
| 906 | gsmnet->gsup_server_addr_str = talloc_strdup(gsmnet, argv[0]); |
| 907 | return CMD_SUCCESS; |
| 908 | } |
| 909 | |
| 910 | DEFUN(cfg_hlr_remote_port, cfg_hlr_remote_port_cmd, "remote-port <1-65535>", |
| 911 | "Remote GSUP port of the HLR\n" |
| 912 | "Remote GSUP port (default: " OSMO_STRINGIFY(MSC_HLR_REMOTE_PORT_DEFAULT) ")") |
| 913 | { |
| 914 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 915 | gsmnet->gsup_server_port = atoi(argv[0]); |
| 916 | return CMD_SUCCESS; |
| 917 | } |
| 918 | |
| 919 | static int config_write_hlr(struct vty *vty) |
| 920 | { |
| 921 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 922 | |
| 923 | vty_out(vty, "hlr%s", VTY_NEWLINE); |
| 924 | vty_out(vty, " remote-ip %s%s", |
| 925 | gsmnet->gsup_server_addr_str, VTY_NEWLINE); |
| 926 | vty_out(vty, " remote-port %u%s", |
| 927 | gsmnet->gsup_server_port, VTY_NEWLINE); |
| 928 | return CMD_SUCCESS; |
| 929 | } |
| 930 | |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 931 | int bsc_vty_init_extra(void) |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 932 | { |
Pablo Neira Ayuso | bbc5b99 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 933 | osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 934 | |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 935 | install_element_ve(&show_subscr_cmd); |
| 936 | install_element_ve(&show_subscr_cache_cmd); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 937 | |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 938 | install_element_ve(&sms_send_pend_cmd); |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 939 | |
Alexander Chemeris | bd6d40f | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 940 | install_element_ve(&subscriber_create_cmd); |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 941 | install_element_ve(&subscriber_send_sms_cmd); |
| 942 | install_element_ve(&subscriber_silent_sms_cmd); |
| 943 | install_element_ve(&subscriber_silent_call_start_cmd); |
| 944 | install_element_ve(&subscriber_silent_call_stop_cmd); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 945 | install_element_ve(&subscriber_ussd_notify_cmd); |
Harald Welte | ba2ad43 | 2017-06-12 01:52:27 +0200 | [diff] [blame] | 946 | install_element_ve(&subscriber_mstest_close_cmd); |
| 947 | install_element_ve(&subscriber_mstest_open_cmd); |
Holger Hans Peter Freyther | abd0cac | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 948 | install_element_ve(&subscriber_update_cmd); |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 949 | install_element_ve(&show_stats_cmd); |
Holger Hans Peter Freyther | 81c0e25 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 950 | install_element_ve(&show_smsqueue_cmd); |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 951 | install_element_ve(&logging_fltr_imsi_cmd); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 952 | |
Keith | d32b6d1 | 2017-01-18 17:09:33 +0100 | [diff] [blame] | 953 | install_element(ENABLE_NODE, &ena_subscr_expire_cmd); |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 954 | install_element(ENABLE_NODE, &ena_subscr_a3a8_cmd); |
Holger Hans Peter Freyther | 7a0e166 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 955 | install_element(ENABLE_NODE, &smsqueue_trigger_cmd); |
Holger Hans Peter Freyther | 3c6f6c2 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 956 | install_element(ENABLE_NODE, &smsqueue_max_cmd); |
Holger Hans Peter Freyther | 4dcc5e5 | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 957 | install_element(ENABLE_NODE, &smsqueue_clear_cmd); |
Holger Hans Peter Freyther | 994dcbb | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 958 | install_element(ENABLE_NODE, &smsqueue_fail_cmd); |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 959 | install_element(ENABLE_NODE, &subscriber_send_pending_sms_cmd); |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 960 | install_element(ENABLE_NODE, &meas_feed_scenario_cmd); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 961 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 962 | install_element(CONFIG_NODE, &cfg_mncc_int_cmd); |
| 963 | install_node(&mncc_int_node, config_write_mncc_int); |
Jacob Erlbeck | 36722e1 | 2013-10-29 09:30:30 +0100 | [diff] [blame] | 964 | vty_install_default(MNCC_INT_NODE); |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 965 | install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd); |
| 966 | install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd); |
Harald Welte | b4771a6 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 967 | install_element(MNCC_INT_NODE, &mnccint_meas_feed_cmd); |
Holger Hans Peter Freyther | 8657326 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 968 | install_element(MNCC_INT_NODE, &meas_feed_scenario_cmd); |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 969 | |
Harald Welte | b02fc1e | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 970 | install_element(CFG_LOG_NODE, &log_level_sms_cmd); |
Holger Hans Peter Freyther | 6995f24 | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 971 | install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd); |
Harald Welte | b02fc1e | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 972 | |
Harald Welte | 9066b74 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 973 | install_element(CONFIG_NODE, &cfg_hlr_cmd); |
| 974 | install_node(&hlr_node, config_write_hlr); |
| 975 | install_element(HLR_NODE, &cfg_hlr_remote_ip_cmd); |
| 976 | install_element(HLR_NODE, &cfg_hlr_remote_port_cmd); |
Holger Hans Peter Freyther | 925c57f | 2015-01-27 10:58:29 +0100 | [diff] [blame] | 977 | |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 978 | return 0; |
| 979 | } |