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