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