Holger Hans Peter Freyther | bdae6f9 | 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 | c1cf9d5 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 3 | * (C) 2009-2011 by Holger Hans Peter Freyther |
Holger Hans Peter Freyther | bdae6f9 | 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 | 0e3e88e | 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 | bdae6f9 | 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 | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 14 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 15 | * |
Harald Welte | 0e3e88e | 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 | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <stdlib.h> |
Holger Hans Peter Freyther | ae9c9d9 | 2010-12-25 00:33:40 +0100 | [diff] [blame] | 22 | #include <limits.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 23 | #include <unistd.h> |
Holger Hans Peter Freyther | 2a835d8 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 24 | #include <time.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 25 | |
Harald Welte | bd9591f | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 26 | #include <osmocom/vty/command.h> |
| 27 | #include <osmocom/vty/buffer.h> |
| 28 | #include <osmocom/vty/vty.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 29 | |
| 30 | #include <arpa/inet.h> |
| 31 | |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 32 | #include <osmocom/core/linuxlist.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 33 | #include <openbsc/gsm_data.h> |
| 34 | #include <openbsc/gsm_subscriber.h> |
Harald Welte | 0101b81 | 2009-11-17 06:00:23 +0100 | [diff] [blame] | 35 | #include <openbsc/silent_call.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 36 | #include <openbsc/gsm_04_11.h> |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 37 | #include <osmocom/abis/e1_input.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 38 | #include <openbsc/abis_nm.h> |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 39 | #include <osmocom/gsm/gsm_utils.h> |
| 40 | #include <osmocom/core/utils.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 41 | #include <openbsc/db.h> |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 42 | #include <osmocom/core/talloc.h> |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 43 | #include <openbsc/signal.h> |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 44 | #include <openbsc/debug.h> |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 45 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 46 | #include <openbsc/gsm_04_80.h> |
| 47 | #include <openbsc/chan_alloc.h> |
Holger Hans Peter Freyther | 6ec8098 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 48 | #include <openbsc/sms_queue.h> |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 49 | #include <openbsc/mncc_int.h> |
Holger Hans Peter Freyther | f4dfea1 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 50 | #include <openbsc/handover.h> |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 51 | |
Holger Hans Peter Freyther | 75cf52a | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 52 | #include <osmocom/vty/logging.h> |
| 53 | |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 54 | #include "meas_feed.h" |
| 55 | |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 56 | extern struct gsm_network *gsmnet_from_vty(struct vty *v); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 57 | |
Holger Hans Peter Freyther | dd1f026 | 2015-04-06 09:55:10 +0200 | [diff] [blame] | 58 | static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr) |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 59 | { |
| 60 | int rc; |
| 61 | struct gsm_auth_info ainfo; |
| 62 | struct gsm_auth_tuple atuple; |
Holger Hans Peter Freyther | 2a835d8 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 63 | char expire_time[200]; |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 64 | |
| 65 | vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, |
| 66 | subscr->authorized, VTY_NEWLINE); |
Holger Hans Peter Freyther | 477f928 | 2014-04-04 11:50:41 +0200 | [diff] [blame] | 67 | if (strlen(subscr->name)) |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 68 | vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 4fcba8e | 2014-04-04 11:53:18 +0200 | [diff] [blame] | 69 | if (strlen(subscr->extension)) |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 70 | vty_out(vty, " Extension: %s%s", subscr->extension, |
| 71 | VTY_NEWLINE); |
Holger Hans Peter Freyther | ff8dd57 | 2010-12-25 16:40:54 +0100 | [diff] [blame] | 72 | vty_out(vty, " LAC: %d/0x%x%s", |
| 73 | subscr->lac, subscr->lac, VTY_NEWLINE); |
Holger Hans Peter Freyther | b0be39b | 2013-07-14 08:38:24 +0200 | [diff] [blame] | 74 | vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 75 | if (subscr->tmsi != GSM_RESERVED_TMSI) |
| 76 | vty_out(vty, " TMSI: %08X%s", subscr->tmsi, |
| 77 | VTY_NEWLINE); |
| 78 | |
Sylvain Munaut | 48858d2 | 2010-06-09 11:32:51 +0200 | [diff] [blame] | 79 | rc = db_get_authinfo_for_subscr(&ainfo, subscr); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 80 | if (!rc) { |
| 81 | vty_out(vty, " A3A8 algorithm id: %d%s", |
| 82 | ainfo.auth_algo, VTY_NEWLINE); |
| 83 | vty_out(vty, " A3A8 Ki: %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 84 | osmo_hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 85 | VTY_NEWLINE); |
| 86 | } |
| 87 | |
Sylvain Munaut | 48858d2 | 2010-06-09 11:32:51 +0200 | [diff] [blame] | 88 | rc = db_get_lastauthtuple_for_subscr(&atuple, subscr); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 89 | if (!rc) { |
| 90 | vty_out(vty, " A3A8 last tuple (used %d times):%s", |
| 91 | atuple.use_count, VTY_NEWLINE); |
| 92 | vty_out(vty, " seq # : %d%s", |
| 93 | atuple.key_seq, VTY_NEWLINE); |
| 94 | vty_out(vty, " RAND : %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 95 | osmo_hexdump(atuple.rand, sizeof(atuple.rand)), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 96 | VTY_NEWLINE); |
| 97 | vty_out(vty, " SRES : %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 98 | osmo_hexdump(atuple.sres, sizeof(atuple.sres)), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 99 | VTY_NEWLINE); |
| 100 | vty_out(vty, " Kc : %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 101 | osmo_hexdump(atuple.kc, sizeof(atuple.kc)), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 102 | VTY_NEWLINE); |
| 103 | } |
Holger Hans Peter Freyther | 2a835d8 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 104 | |
| 105 | /* print the expiration time of a subscriber */ |
| 106 | strftime(expire_time, sizeof(expire_time), |
| 107 | "%a, %d %b %Y %T %z", localtime(&subscr->expire_lu)); |
| 108 | expire_time[sizeof(expire_time) - 1] = '\0'; |
| 109 | vty_out(vty, " Expiration Time: %s%s", expire_time, VTY_NEWLINE); |
Holger Hans Peter Freyther | 61623df | 2015-04-06 12:03:45 +0200 | [diff] [blame^] | 110 | vty_out(vty, " Paging: %s paging%s", |
| 111 | subscr->is_paging ? "is" : "not", VTY_NEWLINE); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 112 | vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); |
| 113 | } |
| 114 | |
| 115 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 116 | /* Subscriber */ |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 117 | DEFUN(show_subscr_cache, |
| 118 | show_subscr_cache_cmd, |
| 119 | "show subscriber cache", |
Harald Welte | 557f399 | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 120 | SHOW_STR "Show information about subscribers\n" |
| 121 | "Display contents of subscriber cache\n") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 122 | { |
| 123 | struct gsm_subscriber *subscr; |
| 124 | |
| 125 | llist_for_each_entry(subscr, &active_subscribers, entry) { |
| 126 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | dd1f026 | 2015-04-06 09:55:10 +0200 | [diff] [blame] | 127 | subscr_dump_full_vty(vty, subscr); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | return CMD_SUCCESS; |
| 131 | } |
| 132 | |
| 133 | DEFUN(sms_send_pend, |
| 134 | sms_send_pend_cmd, |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 135 | "sms send pending", |
Harald Welte | 557f399 | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 136 | "SMS related comamnds\n" "SMS Sending related commands\n" |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 137 | "Send all pending SMS") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 138 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 139 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 140 | struct gsm_sms *sms; |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 141 | int id = 0; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 142 | |
| 143 | while (1) { |
Holger Hans Peter Freyther | ae9c9d9 | 2010-12-25 00:33:40 +0100 | [diff] [blame] | 144 | sms = db_sms_get_unsent_by_subscr(gsmnet, id, UINT_MAX); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 145 | if (!sms) |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 146 | break; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 147 | |
| 148 | gsm411_send_sms_subscr(sms->receiver, sms); |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 149 | |
| 150 | id = sms->receiver->id + 1; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | return CMD_SUCCESS; |
| 154 | } |
| 155 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 156 | static int _send_sms_str(struct gsm_subscriber *receiver, |
| 157 | struct gsm_subscriber *sender, |
| 158 | char *str, uint8_t tp_pid) |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 159 | { |
| 160 | struct gsm_sms *sms; |
| 161 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 162 | sms = sms_from_text(receiver, sender, 0, str); |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 163 | sms->protocol_id = tp_pid; |
Nico Golde | 2e6bc80 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 164 | |
Holger Hans Peter Freyther | e78b443 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 165 | /* store in database for the queue */ |
| 166 | if (db_sms_store(sms) != 0) { |
Holger Hans Peter Freyther | d0a34ed | 2012-11-10 19:46:58 +0100 | [diff] [blame] | 167 | LOGP(DLSMS, LOGL_ERROR, "Failed to store SMS in Database\n"); |
Holger Hans Peter Freyther | e78b443 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 168 | sms_free(sms); |
| 169 | return CMD_WARNING; |
Nico Golde | 2e6bc80 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 170 | } |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 171 | |
Holger Hans Peter Freyther | e78b443 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 172 | sms_free(sms); |
Jacob Erlbeck | da8770b | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 173 | sms_queue_trigger(receiver->group->net->sms_queue); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 174 | return CMD_SUCCESS; |
| 175 | } |
| 176 | |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 177 | static struct gsm_subscriber *get_subscr_by_argv(struct gsm_network *gsmnet, |
| 178 | const char *type, |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 179 | const char *id) |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 180 | { |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 181 | if (!strcmp(type, "extension")) |
Jacob Erlbeck | da8770b | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 182 | return subscr_get_by_extension(gsmnet->subscr_group, id); |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 183 | else if (!strcmp(type, "imsi")) |
Jacob Erlbeck | da8770b | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 184 | return subscr_get_by_imsi(gsmnet->subscr_group, id); |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 185 | else if (!strcmp(type, "tmsi")) |
Jacob Erlbeck | da8770b | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 186 | return subscr_get_by_tmsi(gsmnet->subscr_group, atoi(id)); |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 187 | else if (!strcmp(type, "id")) |
Jacob Erlbeck | da8770b | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 188 | return subscr_get_by_id(gsmnet->subscr_group, atoi(id)); |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 189 | |
| 190 | return NULL; |
| 191 | } |
| 192 | #define SUBSCR_TYPES "(extension|imsi|tmsi|id)" |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 193 | #define SUBSCR_HELP "Operations on a Subscriber\n" \ |
| 194 | "Identify subscriber by his extension (phone number)\n" \ |
| 195 | "Identify subscriber by his IMSI\n" \ |
| 196 | "Identify subscriber by his TMSI\n" \ |
| 197 | "Identify subscriber by his database ID\n" \ |
| 198 | "Identifier for the subscriber\n" |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 199 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 200 | DEFUN(show_subscr, |
| 201 | show_subscr_cmd, |
| 202 | "show subscriber " SUBSCR_TYPES " ID", |
| 203 | SHOW_STR SUBSCR_HELP) |
| 204 | { |
| 205 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 206 | struct gsm_subscriber *subscr = |
| 207 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 208 | |
| 209 | if (!subscr) { |
| 210 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 211 | argv[0], argv[1], VTY_NEWLINE); |
| 212 | return CMD_WARNING; |
| 213 | } |
| 214 | |
Holger Hans Peter Freyther | dd1f026 | 2015-04-06 09:55:10 +0200 | [diff] [blame] | 215 | subscr_dump_full_vty(vty, subscr); |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 216 | |
| 217 | subscr_put(subscr); |
| 218 | |
| 219 | return CMD_SUCCESS; |
| 220 | } |
| 221 | |
Alexander Chemeris | e092dec | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 222 | DEFUN(subscriber_create, |
| 223 | subscriber_create_cmd, |
| 224 | "subscriber create imsi ID", |
| 225 | "Operations on a Subscriber\n" \ |
| 226 | "Create new subscriber\n" \ |
| 227 | "Identify the subscriber by his IMSI\n" \ |
| 228 | "Identifier for the subscriber\n") |
| 229 | { |
| 230 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 231 | struct gsm_subscriber *subscr; |
| 232 | |
Jacob Erlbeck | da8770b | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 233 | subscr = subscr_create_subscriber(gsmnet->subscr_group, argv[0]); |
Alexander Chemeris | e092dec | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 234 | if (!subscr) { |
| 235 | vty_out(vty, "%% No subscriber created for IMSI %s%s", |
| 236 | argv[0], VTY_NEWLINE); |
| 237 | return CMD_WARNING; |
| 238 | } |
| 239 | |
| 240 | /* Show info about the created subscriber. */ |
Holger Hans Peter Freyther | dd1f026 | 2015-04-06 09:55:10 +0200 | [diff] [blame] | 241 | subscr_dump_full_vty(vty, subscr); |
Alexander Chemeris | e092dec | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 242 | |
| 243 | subscr_put(subscr); |
| 244 | |
| 245 | return CMD_SUCCESS; |
| 246 | } |
| 247 | |
Nico Golde | 55ab246 | 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 | e6a500e | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 250 | "subscriber " SUBSCR_TYPES " ID sms pending-send", |
Nico Golde | 55ab246 | 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); |
Holger Hans Peter Freyther | e6e99e1 | 2013-07-04 20:34:46 +0200 | [diff] [blame] | 254 | struct gsm_subscriber *subscr; |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 255 | struct gsm_sms *sms; |
| 256 | |
Holger Hans Peter Freyther | e6e99e1 | 2013-07-04 20:34:46 +0200 | [diff] [blame] | 257 | subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 258 | if (!subscr) { |
| 259 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 260 | argv[0], argv[1], VTY_NEWLINE); |
| 261 | return CMD_WARNING; |
| 262 | } |
| 263 | |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 264 | sms = db_sms_get_unsent_by_subscr(gsmnet, subscr->id, UINT_MAX); |
| 265 | if (sms) |
| 266 | gsm411_send_sms_subscr(sms->receiver, sms); |
| 267 | |
| 268 | subscr_put(subscr); |
| 269 | |
| 270 | return CMD_SUCCESS; |
| 271 | } |
| 272 | |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 273 | DEFUN(subscriber_send_sms, |
| 274 | subscriber_send_sms_cmd, |
Sylvain Munaut | 9431faa | 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 | ebe3725 | 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 | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 277 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 278 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 279 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 280 | struct gsm_subscriber *sender = get_subscr_by_argv(gsmnet, argv[2], argv[3]); |
Harald Welte | 3699e20 | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 281 | char *str; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 282 | int rc; |
| 283 | |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 284 | if (!subscr) { |
| 285 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 286 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 287 | rc = CMD_WARNING; |
| 288 | goto err; |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 289 | } |
Sylvain Munaut | 9431faa | 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); |
| 299 | rc = _send_sms_str(subscr, sender, str, 0); |
Harald Welte | 3699e20 | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 300 | talloc_free(str); |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 301 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 302 | err: |
| 303 | if (sender) |
| 304 | subscr_put(sender); |
| 305 | |
| 306 | if (subscr) |
| 307 | subscr_put(subscr); |
Harald Welte | bbe3172 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 308 | |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 309 | return rc; |
| 310 | } |
| 311 | |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 312 | DEFUN(subscriber_silent_sms, |
| 313 | subscriber_silent_sms_cmd, |
Harald Welte | 3ed864f | 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 | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 317 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 318 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 319 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 320 | struct gsm_subscriber *sender = get_subscr_by_argv(gsmnet, argv[2], argv[3]); |
Harald Welte | 3699e20 | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 321 | char *str; |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 322 | int rc; |
| 323 | |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 324 | if (!subscr) { |
| 325 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 326 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 327 | rc = CMD_WARNING; |
| 328 | goto err; |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 329 | } |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 330 | |
Sylvain Munaut | 9431faa | 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); |
| 339 | rc = _send_sms_str(subscr, sender, str, 64); |
Harald Welte | 3699e20 | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 340 | talloc_free(str); |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 341 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 342 | err: |
| 343 | if (sender) |
| 344 | subscr_put(sender); |
| 345 | |
| 346 | if (subscr) |
| 347 | subscr_put(subscr); |
Harald Welte | bbe3172 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 348 | |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 349 | return rc; |
| 350 | } |
| 351 | |
Harald Welte | 18ce31c | 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 | 1c378a7 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 359 | DEFUN(subscriber_silent_call_start, |
| 360 | subscriber_silent_call_start_cmd, |
Harald Welte | a8ca70f | 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 | 18ce31c | 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 | 1c378a7 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 364 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 365 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 366 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 1c378a7 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 367 | int rc, type; |
| 368 | |
| 369 | if (!subscr) { |
| 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 | |
| 384 | rc = gsm_silent_call_start(subscr, vty, type); |
| 385 | if (rc <= 0) { |
| 386 | vty_out(vty, "%% Subscriber not attached%s", |
| 387 | VTY_NEWLINE); |
| 388 | subscr_put(subscr); |
| 389 | return CMD_WARNING; |
| 390 | } |
| 391 | |
| 392 | subscr_put(subscr); |
| 393 | |
| 394 | return CMD_SUCCESS; |
| 395 | } |
| 396 | |
| 397 | DEFUN(subscriber_silent_call_stop, |
| 398 | subscriber_silent_call_stop_cmd, |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 399 | "subscriber " SUBSCR_TYPES " ID silent-call stop", |
Harald Welte | 18ce31c | 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 | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 402 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 403 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 404 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 405 | int rc; |
| 406 | |
| 407 | if (!subscr) { |
| 408 | vty_out(vty, "%% No subscriber found for %s %s%s", |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 409 | argv[0], argv[1], VTY_NEWLINE); |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 410 | return CMD_WARNING; |
| 411 | } |
| 412 | |
Sylvain Munaut | 1c378a7 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 413 | rc = gsm_silent_call_stop(subscr); |
| 414 | if (rc < 0) { |
| 415 | subscr_put(subscr); |
| 416 | return CMD_WARNING; |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | subscr_put(subscr); |
| 420 | |
| 421 | return CMD_SUCCESS; |
| 422 | } |
| 423 | |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 424 | DEFUN(subscriber_ussd_notify, |
| 425 | subscriber_ussd_notify_cmd, |
Holger Hans Peter Freyther | 7429476 | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 426 | "subscriber " SUBSCR_TYPES " ID ussd-notify (0|1|2) .TEXT", |
Harald Welte | 557f399 | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 427 | SUBSCR_HELP "Send a USSD notify to the subscriber\n" |
Harald Welte | 557f399 | 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 | b506d72 | 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); |
| 436 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Holger Hans Peter Freyther | 7429476 | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 437 | int level; |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 438 | |
| 439 | if (!subscr) { |
| 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 | 7429476 | 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 | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 447 | if (!text) { |
| 448 | subscr_put(subscr); |
| 449 | return CMD_WARNING; |
| 450 | } |
| 451 | |
| 452 | conn = connection_for_subscr(subscr); |
| 453 | if (!conn) { |
| 454 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 455 | argv[0], argv[1], VTY_NEWLINE); |
| 456 | subscr_put(subscr); |
| 457 | talloc_free(text); |
| 458 | return CMD_WARNING; |
| 459 | } |
| 460 | |
Holger Hans Peter Freyther | 7429476 | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 461 | gsm0480_send_ussdNotify(conn, level, text); |
Holger Hans Peter Freyther | 9059790 | 2010-07-27 03:31:50 +0800 | [diff] [blame] | 462 | gsm0480_send_releaseComplete(conn); |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 463 | |
| 464 | subscr_put(subscr); |
| 465 | talloc_free(text); |
| 466 | return CMD_SUCCESS; |
| 467 | } |
| 468 | |
Ruben Pollan | 6af2b40 | 2014-09-24 20:50:13 -0500 | [diff] [blame] | 469 | DEFUN(ena_subscr_delete, |
| 470 | ena_subscr_delete_cmd, |
| 471 | "subscriber " SUBSCR_TYPES " ID delete", |
| 472 | SUBSCR_HELP "Delete subscriber in HLR\n") |
| 473 | { |
| 474 | int rc; |
| 475 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 476 | struct gsm_subscriber *subscr = |
| 477 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 478 | |
| 479 | if (!subscr) { |
| 480 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 481 | argv[0], argv[1], VTY_NEWLINE); |
| 482 | return CMD_WARNING; |
| 483 | } |
| 484 | |
| 485 | if (subscr->use_count != 1) { |
| 486 | vty_out(vty, "Removing active subscriber%s", VTY_NEWLINE); |
| 487 | } |
| 488 | |
| 489 | rc = db_subscriber_delete(subscr); |
| 490 | subscr_put(subscr); |
| 491 | |
| 492 | if (rc != 0) { |
| 493 | vty_out(vty, "Failed to remove subscriber%s", VTY_NEWLINE); |
| 494 | return CMD_WARNING; |
| 495 | } |
| 496 | |
| 497 | return CMD_SUCCESS; |
| 498 | } |
| 499 | |
| 500 | DEFUN(ena_subscr_authorized, |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 501 | ena_subscr_authorized_cmd, |
| 502 | "subscriber " SUBSCR_TYPES " ID authorized (0|1)", |
| 503 | SUBSCR_HELP "(De-)Authorize subscriber in HLR\n" |
| 504 | "Subscriber should NOT be authorized\n" |
| 505 | "Subscriber should be authorized\n") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 506 | { |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 507 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 508 | struct gsm_subscriber *subscr = |
| 509 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 510 | |
| 511 | if (!subscr) { |
| 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 | subscr->authorized = atoi(argv[2]); |
| 518 | db_sync_subscriber(subscr); |
| 519 | |
| 520 | subscr_put(subscr); |
| 521 | |
| 522 | return CMD_SUCCESS; |
| 523 | } |
| 524 | |
| 525 | DEFUN(ena_subscr_name, |
| 526 | ena_subscr_name_cmd, |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 527 | "subscriber " SUBSCR_TYPES " ID name .NAME", |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 528 | SUBSCR_HELP "Set the name of the subscriber\n" |
| 529 | "Name of the Subscriber\n") |
| 530 | { |
| 531 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 532 | struct gsm_subscriber *subscr = |
| 533 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 534 | char *name; |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 535 | |
| 536 | if (!subscr) { |
| 537 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 538 | argv[0], argv[1], VTY_NEWLINE); |
| 539 | return CMD_WARNING; |
| 540 | } |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 541 | |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 542 | name = argv_concat(argv, argc, 2); |
Holger Hans Peter Freyther | a36df37 | 2010-07-26 19:43:54 +0800 | [diff] [blame] | 543 | if (!name) { |
| 544 | subscr_put(subscr); |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 545 | return CMD_WARNING; |
Holger Hans Peter Freyther | a36df37 | 2010-07-26 19:43:54 +0800 | [diff] [blame] | 546 | } |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 547 | |
Jacob Erlbeck | 508c310 | 2015-04-07 17:49:49 +0200 | [diff] [blame] | 548 | if (strlen(name) > sizeof(subscr->name)-1) { |
| 549 | vty_out(vty, |
| 550 | "%% NAME is too long, max. %d characters are allowed%s", |
| 551 | sizeof(subscr->name)-1, VTY_NEWLINE); |
| 552 | return CMD_WARNING; |
| 553 | } |
| 554 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 555 | strncpy(subscr->name, name, sizeof(subscr->name)); |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 556 | talloc_free(name); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 557 | db_sync_subscriber(subscr); |
| 558 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 559 | subscr_put(subscr); |
| 560 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 561 | return CMD_SUCCESS; |
| 562 | } |
| 563 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 564 | DEFUN(ena_subscr_extension, |
| 565 | ena_subscr_extension_cmd, |
| 566 | "subscriber " SUBSCR_TYPES " ID extension EXTENSION", |
| 567 | SUBSCR_HELP "Set the extension (phone number) of the subscriber\n" |
| 568 | "Extension (phone number)\n") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 569 | { |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 570 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 571 | struct gsm_subscriber *subscr = |
| 572 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Holger Hans Peter Freyther | c1cf9d5 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 573 | const char *ext = argv[2]; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 574 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 575 | if (!subscr) { |
| 576 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 577 | argv[0], argv[1], VTY_NEWLINE); |
| 578 | return CMD_WARNING; |
| 579 | } |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 580 | |
Jacob Erlbeck | 508c310 | 2015-04-07 17:49:49 +0200 | [diff] [blame] | 581 | if (strlen(ext) > sizeof(subscr->extension)-1) { |
| 582 | vty_out(vty, |
| 583 | "%% EXTENSION is too long, max. %d characters are allowed%s", |
| 584 | sizeof(subscr->extension)-1, VTY_NEWLINE); |
| 585 | return CMD_WARNING; |
| 586 | } |
| 587 | |
Holger Hans Peter Freyther | c1cf9d5 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 588 | strncpy(subscr->extension, ext, sizeof(subscr->extension)); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 589 | db_sync_subscriber(subscr); |
| 590 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 591 | subscr_put(subscr); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 592 | |
| 593 | return CMD_SUCCESS; |
| 594 | } |
| 595 | |
Holger Hans Peter Freyther | f4dfea1 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 596 | DEFUN(ena_subscr_handover, |
| 597 | ena_subscr_handover_cmd, |
| 598 | "subscriber " SUBSCR_TYPES " ID handover BTS_NR", |
| 599 | SUBSCR_HELP "Handover the active connection\n" |
| 600 | "Number of the BTS to handover to\n") |
| 601 | { |
| 602 | int ret; |
| 603 | struct gsm_subscriber_connection *conn; |
| 604 | struct gsm_bts *bts; |
| 605 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 606 | struct gsm_subscriber *subscr = |
| 607 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 608 | |
| 609 | if (!subscr) { |
| 610 | vty_out(vty, "%% No subscriber found for %s %s.%s", |
| 611 | argv[0], argv[1], VTY_NEWLINE); |
| 612 | return CMD_WARNING; |
| 613 | } |
| 614 | |
| 615 | conn = connection_for_subscr(subscr); |
| 616 | if (!conn) { |
| 617 | vty_out(vty, "%% No active connection for subscriber %s %s.%s", |
| 618 | argv[0], argv[1], VTY_NEWLINE); |
| 619 | subscr_put(subscr); |
| 620 | return CMD_WARNING; |
| 621 | } |
| 622 | |
| 623 | bts = gsm_bts_num(gsmnet, atoi(argv[2])); |
| 624 | if (!bts) { |
| 625 | vty_out(vty, "%% BTS with number(%d) could not be found.%s", |
| 626 | atoi(argv[2]), VTY_NEWLINE); |
| 627 | subscr_put(subscr); |
| 628 | return CMD_WARNING; |
| 629 | } |
| 630 | |
| 631 | /* now start the handover */ |
| 632 | ret = bsc_handover_start(conn->lchan, bts); |
| 633 | if (ret != 0) { |
| 634 | vty_out(vty, "%% Handover failed with errno %d.%s", |
| 635 | ret, VTY_NEWLINE); |
| 636 | } else { |
| 637 | vty_out(vty, "%% Handover started from %s", |
| 638 | gsm_lchan_name(conn->lchan)); |
| 639 | vty_out(vty, " to %s.%s", gsm_lchan_name(conn->ho_lchan), |
| 640 | VTY_NEWLINE); |
| 641 | } |
| 642 | |
| 643 | subscr_put(subscr); |
| 644 | return CMD_SUCCESS; |
| 645 | } |
| 646 | |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 647 | #define A3A8_ALG_TYPES "(none|xor|comp128v1)" |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 648 | #define A3A8_ALG_HELP \ |
| 649 | "Use No A3A8 algorithm\n" \ |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 650 | "Use XOR algorithm\n" \ |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 651 | "Use COMP128v1 algorithm\n" |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 652 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 653 | DEFUN(ena_subscr_a3a8, |
| 654 | ena_subscr_a3a8_cmd, |
| 655 | "subscriber " SUBSCR_TYPES " ID a3a8 " A3A8_ALG_TYPES " [KI]", |
Harald Welte | c4bf319 | 2010-05-27 10:48:11 +0200 | [diff] [blame] | 656 | SUBSCR_HELP "Set a3a8 parameters for the subscriber\n" |
| 657 | A3A8_ALG_HELP "Encryption Key Ki\n") |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 658 | { |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 659 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 660 | struct gsm_subscriber *subscr = |
| 661 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 662 | const char *alg_str = argv[2]; |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 663 | const char *ki_str = argc == 4 ? argv[3] : NULL; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 664 | struct gsm_auth_info ainfo; |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 665 | int rc, minlen, maxlen; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 666 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 667 | if (!subscr) { |
| 668 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 669 | argv[0], argv[1], VTY_NEWLINE); |
| 670 | return CMD_WARNING; |
| 671 | } |
| 672 | |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 673 | if (!strcasecmp(alg_str, "none")) { |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 674 | ainfo.auth_algo = AUTH_ALGO_NONE; |
| 675 | minlen = maxlen = 0; |
| 676 | } else if (!strcasecmp(alg_str, "xor")) { |
| 677 | ainfo.auth_algo = AUTH_ALGO_XOR; |
| 678 | minlen = A38_XOR_MIN_KEY_LEN; |
| 679 | maxlen = A38_XOR_MAX_KEY_LEN; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 680 | } else if (!strcasecmp(alg_str, "comp128v1")) { |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 681 | ainfo.auth_algo = AUTH_ALGO_COMP128v1; |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 682 | minlen = maxlen = A38_COMP128_KEY_LEN; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 683 | } else { |
| 684 | /* Unknown method */ |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 685 | subscr_put(subscr); |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 686 | vty_out(vty, "%% Unknown auth method %s%s", |
| 687 | alg_str, VTY_NEWLINE); |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 688 | return CMD_WARNING; |
| 689 | } |
| 690 | |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 691 | if (ki_str) { |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 692 | rc = osmo_hexparse(ki_str, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki)); |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 693 | if ((rc > maxlen) || (rc < minlen)) { |
| 694 | subscr_put(subscr); |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 695 | vty_out(vty, "%% Wrong Ki `%s'%s", |
| 696 | ki_str, VTY_NEWLINE); |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 697 | return CMD_WARNING; |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 698 | } |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 699 | ainfo.a3a8_ki_len = rc; |
| 700 | } else { |
| 701 | ainfo.a3a8_ki_len = 0; |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 702 | if (minlen) { |
| 703 | subscr_put(subscr); |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 704 | vty_out(vty, "%% Missing Ki argument%s", VTY_NEWLINE); |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 705 | return CMD_WARNING; |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 706 | } |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | rc = db_sync_authinfo_for_subscr( |
| 710 | ainfo.auth_algo == AUTH_ALGO_NONE ? NULL : &ainfo, |
| 711 | subscr); |
| 712 | |
Sylvain Munaut | 0d7d991 | 2010-06-10 22:00:48 +0200 | [diff] [blame] | 713 | /* the last tuple probably invalid with the new auth settings */ |
| 714 | db_sync_lastauthtuple_for_subscr(NULL, subscr); |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 715 | subscr_put(subscr); |
Sylvain Munaut | 0d7d991 | 2010-06-10 22:00:48 +0200 | [diff] [blame] | 716 | |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 717 | if (rc) { |
| 718 | vty_out(vty, "%% Operation has failed%s", VTY_NEWLINE); |
| 719 | return CMD_WARNING; |
| 720 | } |
| 721 | return CMD_SUCCESS; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 722 | } |
| 723 | |
Holger Hans Peter Freyther | ed1d030 | 2010-12-22 16:33:23 +0100 | [diff] [blame] | 724 | DEFUN(subscriber_purge, |
| 725 | subscriber_purge_cmd, |
| 726 | "subscriber purge-inactive", |
| 727 | "Operations on a Subscriber\n" "Purge subscribers with a zero use count.\n") |
| 728 | { |
| 729 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 730 | int purged; |
| 731 | |
Jacob Erlbeck | da8770b | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 732 | purged = subscr_purge_inactive(net->subscr_group); |
Holger Hans Peter Freyther | ed1d030 | 2010-12-22 16:33:23 +0100 | [diff] [blame] | 733 | vty_out(vty, "%d subscriber(s) were purged.%s", purged, VTY_NEWLINE); |
| 734 | return CMD_SUCCESS; |
| 735 | } |
| 736 | |
Holger Hans Peter Freyther | 0c29e5f | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 737 | DEFUN(subscriber_update, |
| 738 | subscriber_update_cmd, |
| 739 | "subscriber " SUBSCR_TYPES " ID update", |
| 740 | SUBSCR_HELP "Update the subscriber data from the dabase.\n") |
| 741 | { |
| 742 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 743 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 744 | |
| 745 | if (!subscr) { |
| 746 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 747 | argv[0], argv[1], VTY_NEWLINE); |
| 748 | return CMD_WARNING; |
| 749 | } |
| 750 | |
| 751 | subscr_update_from_db(subscr); |
| 752 | subscr_put(subscr); |
| 753 | return CMD_SUCCESS; |
| 754 | } |
| 755 | |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 756 | static int scall_cbfn(unsigned int subsys, unsigned int signal, |
| 757 | void *handler_data, void *signal_data) |
| 758 | { |
| 759 | struct scall_signal_data *sigdata = signal_data; |
| 760 | struct vty *vty = sigdata->data; |
| 761 | |
| 762 | switch (signal) { |
| 763 | case S_SCALL_SUCCESS: |
| 764 | vty_out(vty, "%% silent call on ARFCN %u timeslot %u%s", |
Holger Hans Peter Freyther | d3aaf66 | 2010-06-17 15:05:57 +0800 | [diff] [blame] | 765 | sigdata->conn->lchan->ts->trx->arfcn, sigdata->conn->lchan->ts->nr, |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 766 | VTY_NEWLINE); |
| 767 | break; |
| 768 | case S_SCALL_EXPIRED: |
| 769 | vty_out(vty, "%% silent call expired paging%s", VTY_NEWLINE); |
| 770 | break; |
| 771 | } |
| 772 | return 0; |
| 773 | } |
| 774 | |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 775 | DEFUN(show_stats, |
| 776 | show_stats_cmd, |
| 777 | "show statistics", |
| 778 | SHOW_STR "Display network statistics\n") |
| 779 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 780 | struct gsm_network *net = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 781 | |
| 782 | openbsc_vty_print_statistics(vty, net); |
| 783 | vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 784 | osmo_counter_get(net->stats.loc_upd_type.attach), |
| 785 | osmo_counter_get(net->stats.loc_upd_type.normal), |
| 786 | osmo_counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 787 | vty_out(vty, "IMSI Detach Indications : %lu%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 788 | osmo_counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 789 | vty_out(vty, "Location Update Response: %lu accept, %lu reject%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 790 | osmo_counter_get(net->stats.loc_upd_resp.accept), |
| 791 | osmo_counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 792 | vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, " |
| 793 | "%lu completed, %lu failed%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 794 | osmo_counter_get(net->stats.handover.attempted), |
| 795 | osmo_counter_get(net->stats.handover.no_channel), |
| 796 | osmo_counter_get(net->stats.handover.timeout), |
| 797 | osmo_counter_get(net->stats.handover.completed), |
| 798 | osmo_counter_get(net->stats.handover.failed), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 799 | vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 800 | osmo_counter_get(net->stats.sms.submitted), |
| 801 | osmo_counter_get(net->stats.sms.no_receiver), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 802 | vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 803 | osmo_counter_get(net->stats.sms.delivered), |
| 804 | osmo_counter_get(net->stats.sms.rp_err_mem), |
| 805 | osmo_counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE); |
Harald Welte | c56006b | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 806 | vty_out(vty, "MO Calls : %lu setup, %lu connect ack%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 807 | osmo_counter_get(net->stats.call.mo_setup), |
| 808 | osmo_counter_get(net->stats.call.mo_connect_ack), VTY_NEWLINE); |
Harald Welte | c56006b | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 809 | vty_out(vty, "MT Calls : %lu setup, %lu connect%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 810 | osmo_counter_get(net->stats.call.mt_setup), |
| 811 | osmo_counter_get(net->stats.call.mt_connect), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 812 | return CMD_SUCCESS; |
| 813 | } |
| 814 | |
Holger Hans Peter Freyther | 6ec8098 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 815 | DEFUN(show_smsqueue, |
| 816 | show_smsqueue_cmd, |
| 817 | "show sms-queue", |
| 818 | SHOW_STR "Display SMSqueue statistics\n") |
| 819 | { |
| 820 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 821 | |
| 822 | sms_queue_stats(net->sms_queue, vty); |
| 823 | return CMD_SUCCESS; |
| 824 | } |
| 825 | |
Holger Hans Peter Freyther | 58fe028 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 826 | DEFUN(smsqueue_trigger, |
| 827 | smsqueue_trigger_cmd, |
| 828 | "sms-queue trigger", |
| 829 | "SMS Queue\n" "Trigger sending messages\n") |
| 830 | { |
| 831 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 832 | |
| 833 | sms_queue_trigger(net->sms_queue); |
| 834 | return CMD_SUCCESS; |
| 835 | } |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 836 | |
Holger Hans Peter Freyther | 96b4d35 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 837 | DEFUN(smsqueue_max, |
| 838 | smsqueue_max_cmd, |
| 839 | "sms-queue max-pending <1-500>", |
Holger Hans Peter Freyther | e6a500e | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 840 | "SMS Queue\n" "SMS to deliver in parallel\n" "Amount\n") |
Holger Hans Peter Freyther | 96b4d35 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 841 | { |
| 842 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 843 | |
| 844 | sms_queue_set_max_pending(net->sms_queue, atoi(argv[0])); |
| 845 | return CMD_SUCCESS; |
| 846 | } |
| 847 | |
Holger Hans Peter Freyther | 416c7de | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 848 | DEFUN(smsqueue_clear, |
| 849 | smsqueue_clear_cmd, |
| 850 | "sms-queue clear", |
| 851 | "SMS Queue\n" "Clear the queue of pending SMS\n") |
| 852 | { |
| 853 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 854 | |
| 855 | sms_queue_clear(net->sms_queue); |
| 856 | return CMD_SUCCESS; |
| 857 | } |
| 858 | |
Holger Hans Peter Freyther | 70428d9 | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 859 | DEFUN(smsqueue_fail, |
| 860 | smsqueue_fail_cmd, |
| 861 | "sms-queue max-failure <1-500>", |
Holger Hans Peter Freyther | e6a500e | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 862 | "SMS Queue\n" "Maximum amount of delivery failures\n" "Amount\n") |
Holger Hans Peter Freyther | 70428d9 | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 863 | { |
| 864 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 865 | |
| 866 | sms_queue_set_max_failure(net->sms_queue, atoi(argv[0])); |
| 867 | return CMD_SUCCESS; |
| 868 | } |
| 869 | |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 870 | |
| 871 | DEFUN(cfg_mncc_int, cfg_mncc_int_cmd, |
| 872 | "mncc-int", "Configure internal MNCC handler") |
| 873 | { |
| 874 | vty->node = MNCC_INT_NODE; |
| 875 | |
| 876 | return CMD_SUCCESS; |
| 877 | } |
| 878 | |
| 879 | static struct cmd_node mncc_int_node = { |
| 880 | MNCC_INT_NODE, |
Harald Welte | 45362bb | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 881 | "%s(config-mncc-int)# ", |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 882 | 1, |
| 883 | }; |
| 884 | |
| 885 | static const struct value_string tchf_codec_names[] = { |
| 886 | { GSM48_CMODE_SPEECH_V1, "fr" }, |
| 887 | { GSM48_CMODE_SPEECH_EFR, "efr" }, |
| 888 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 889 | { 0, NULL } |
| 890 | }; |
| 891 | |
| 892 | static const struct value_string tchh_codec_names[] = { |
| 893 | { GSM48_CMODE_SPEECH_V1, "hr" }, |
| 894 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 895 | { 0, NULL } |
| 896 | }; |
| 897 | |
| 898 | static int config_write_mncc_int(struct vty *vty) |
| 899 | { |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 900 | uint16_t meas_port; |
| 901 | char *meas_host; |
Holger Hans Peter Freyther | 65b8992 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 902 | const char *meas_scenario; |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 903 | |
| 904 | meas_feed_cfg_get(&meas_host, &meas_port); |
Holger Hans Peter Freyther | 65b8992 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 905 | meas_scenario = meas_feed_scenario_get(); |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 906 | |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 907 | vty_out(vty, "mncc-int%s", VTY_NEWLINE); |
| 908 | vty_out(vty, " default-codec tch-f %s%s", |
| 909 | get_value_string(tchf_codec_names, mncc_int.def_codec[0]), |
| 910 | VTY_NEWLINE); |
| 911 | vty_out(vty, " default-codec tch-h %s%s", |
| 912 | get_value_string(tchh_codec_names, mncc_int.def_codec[1]), |
| 913 | VTY_NEWLINE); |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 914 | if (meas_port) |
| 915 | vty_out(vty, " meas-feed destination %s %u%s", |
| 916 | meas_host, meas_port, VTY_NEWLINE); |
Holger Hans Peter Freyther | 65b8992 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 917 | if (strlen(meas_scenario) > 0) |
| 918 | vty_out(vty, " meas-feed scenario %s%s", |
| 919 | meas_scenario, VTY_NEWLINE); |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 920 | |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 921 | |
| 922 | return CMD_SUCCESS; |
| 923 | } |
| 924 | |
| 925 | DEFUN(mnccint_def_codec_f, |
| 926 | mnccint_def_codec_f_cmd, |
| 927 | "default-codec tch-f (fr|efr|amr)", |
| 928 | "Set default codec\n" "Codec for TCH/F\n" |
| 929 | "Full-Rate\n" "Enhanced Full-Rate\n" "Adaptive Multi-Rate\n") |
| 930 | { |
| 931 | mncc_int.def_codec[0] = get_string_value(tchf_codec_names, argv[0]); |
| 932 | |
| 933 | return CMD_SUCCESS; |
| 934 | } |
| 935 | |
| 936 | DEFUN(mnccint_def_codec_h, |
| 937 | mnccint_def_codec_h_cmd, |
| 938 | "default-codec tch-h (hr|amr)", |
| 939 | "Set default codec\n" "Codec for TCH/H\n" |
| 940 | "Half-Rate\n" "Adaptive Multi-Rate\n") |
| 941 | { |
| 942 | mncc_int.def_codec[1] = get_string_value(tchh_codec_names, argv[0]); |
| 943 | |
| 944 | return CMD_SUCCESS; |
| 945 | } |
| 946 | |
Holger Hans Peter Freyther | ebe3725 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 947 | #define OBSOLETE_MSG "Obsolete\n" |
Harald Welte | 3073f52 | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 948 | /* this is just for backwards compatibility as the sms code moved into |
| 949 | * libosmocore and old config files no longer parse... */ |
| 950 | DEFUN_DEPRECATED(log_level_sms, log_level_sms_cmd, |
| 951 | "logging level sms (everything|debug|info|notice|error|fatal)", |
Holger Hans Peter Freyther | ebe3725 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 952 | ".HIDDEN\n" OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG |
| 953 | OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG) |
Harald Welte | 3073f52 | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 954 | { |
| 955 | vty_out(vty, "%% 'logging level sms' is now called 'logging level " |
| 956 | "lsms', please update your config %s", VTY_NEWLINE); |
| 957 | |
| 958 | return CMD_SUCCESS; |
| 959 | } |
| 960 | |
Holger Hans Peter Freyther | 54c0124 | 2015-01-31 09:26:20 +0100 | [diff] [blame] | 961 | #define MEAS_STR "Measurement export related\n" |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 962 | DEFUN(mnccint_meas_feed, mnccint_meas_feed_cmd, |
| 963 | "meas-feed destination ADDR <0-65535>", |
Holger Hans Peter Freyther | 54c0124 | 2015-01-31 09:26:20 +0100 | [diff] [blame] | 964 | MEAS_STR "destination\n" "address or hostname\n" "port number\n") |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 965 | { |
| 966 | int rc; |
| 967 | |
| 968 | rc = meas_feed_cfg_set(argv[0], atoi(argv[1])); |
| 969 | if (rc < 0) |
| 970 | return CMD_WARNING; |
| 971 | |
| 972 | return CMD_SUCCESS; |
| 973 | } |
| 974 | |
| 975 | DEFUN(meas_feed_scenario, meas_feed_scenario_cmd, |
| 976 | "meas-feed scenario NAME", |
Holger Hans Peter Freyther | 54c0124 | 2015-01-31 09:26:20 +0100 | [diff] [blame] | 977 | MEAS_STR "scenario\n" "Name up to 31 characters included in report\n") |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 978 | { |
| 979 | meas_feed_scenario_set(argv[0]); |
| 980 | |
| 981 | return CMD_SUCCESS; |
| 982 | } |
| 983 | |
Holger Hans Peter Freyther | 75cf52a | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 984 | |
| 985 | DEFUN(logging_fltr_imsi, |
| 986 | logging_fltr_imsi_cmd, |
| 987 | "logging filter imsi IMSI", |
| 988 | LOGGING_STR FILTER_STR |
| 989 | "Filter log messages by IMSI\n" "IMSI to be used as filter\n") |
| 990 | { |
| 991 | struct gsm_subscriber *subscr; |
| 992 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 993 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 994 | |
| 995 | if (!tgt) |
| 996 | return CMD_WARNING; |
| 997 | |
| 998 | subscr = subscr_get_by_imsi(gsmnet->subscr_group, argv[0]); |
| 999 | if (!subscr) { |
| 1000 | vty_out(vty, "%%no subscriber with IMSI(%s)%s", |
| 1001 | argv[0], VTY_NEWLINE); |
| 1002 | return CMD_WARNING; |
| 1003 | } |
| 1004 | |
| 1005 | log_set_imsi_filter(tgt, subscr); |
| 1006 | return CMD_SUCCESS; |
| 1007 | } |
Holger Hans Peter Freyther | e144211 | 2015-01-27 10:58:29 +0100 | [diff] [blame] | 1008 | |
| 1009 | static struct cmd_node nitb_node = { |
| 1010 | NITB_NODE, |
| 1011 | "%s(config-nitb)# ", |
| 1012 | 1, |
| 1013 | }; |
| 1014 | |
| 1015 | DEFUN(cfg_nitb, cfg_nitb_cmd, |
| 1016 | "nitb", "Configure NITB options") |
| 1017 | { |
| 1018 | vty->node = NITB_NODE; |
| 1019 | return CMD_SUCCESS; |
| 1020 | } |
| 1021 | |
| 1022 | DEFUN(cfg_nitb_subscr_create, cfg_nitb_subscr_create_cmd, |
| 1023 | "subscriber-create-on-demand", |
| 1024 | "Make a new record when a subscriber is first seen.\n") |
| 1025 | { |
| 1026 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 1027 | gsmnet->create_subscriber = 1; |
| 1028 | return CMD_SUCCESS; |
| 1029 | } |
| 1030 | |
| 1031 | DEFUN(cfg_nitb_no_subscr_create, cfg_nitb_no_subscr_create_cmd, |
| 1032 | "no subscriber-create-on-demand", |
| 1033 | NO_STR "Make a new record when a subscriber is first seen.\n") |
| 1034 | { |
| 1035 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 1036 | gsmnet->create_subscriber = 0; |
| 1037 | return CMD_SUCCESS; |
| 1038 | } |
| 1039 | |
| 1040 | static int config_write_nitb(struct vty *vty) |
| 1041 | { |
| 1042 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 1043 | vty_out(vty, "nitb%s", VTY_NEWLINE); |
| 1044 | vty_out(vty, " %ssubscriber-create-on-demand%s", |
| 1045 | gsmnet->create_subscriber ? "" : "no ", VTY_NEWLINE); |
| 1046 | return CMD_SUCCESS; |
| 1047 | } |
| 1048 | |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 1049 | int bsc_vty_init_extra(void) |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1050 | { |
Pablo Neira Ayuso | ef717c6 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 1051 | osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL); |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 1052 | |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 1053 | install_element_ve(&show_subscr_cmd); |
| 1054 | install_element_ve(&show_subscr_cache_cmd); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1055 | |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 1056 | install_element_ve(&sms_send_pend_cmd); |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 1057 | |
Alexander Chemeris | e092dec | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 1058 | install_element_ve(&subscriber_create_cmd); |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 1059 | install_element_ve(&subscriber_send_sms_cmd); |
| 1060 | install_element_ve(&subscriber_silent_sms_cmd); |
| 1061 | install_element_ve(&subscriber_silent_call_start_cmd); |
| 1062 | install_element_ve(&subscriber_silent_call_stop_cmd); |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 1063 | install_element_ve(&subscriber_ussd_notify_cmd); |
Holger Hans Peter Freyther | 0c29e5f | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 1064 | install_element_ve(&subscriber_update_cmd); |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 1065 | install_element_ve(&show_stats_cmd); |
Holger Hans Peter Freyther | 6ec8098 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 1066 | install_element_ve(&show_smsqueue_cmd); |
Holger Hans Peter Freyther | 75cf52a | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 1067 | install_element_ve(&logging_fltr_imsi_cmd); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1068 | |
Ruben Pollan | 6af2b40 | 2014-09-24 20:50:13 -0500 | [diff] [blame] | 1069 | install_element(ENABLE_NODE, &ena_subscr_delete_cmd); |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 1070 | install_element(ENABLE_NODE, &ena_subscr_name_cmd); |
| 1071 | install_element(ENABLE_NODE, &ena_subscr_extension_cmd); |
| 1072 | install_element(ENABLE_NODE, &ena_subscr_authorized_cmd); |
| 1073 | install_element(ENABLE_NODE, &ena_subscr_a3a8_cmd); |
Holger Hans Peter Freyther | f4dfea1 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 1074 | install_element(ENABLE_NODE, &ena_subscr_handover_cmd); |
Holger Hans Peter Freyther | ed1d030 | 2010-12-22 16:33:23 +0100 | [diff] [blame] | 1075 | install_element(ENABLE_NODE, &subscriber_purge_cmd); |
Holger Hans Peter Freyther | 58fe028 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 1076 | install_element(ENABLE_NODE, &smsqueue_trigger_cmd); |
Holger Hans Peter Freyther | 96b4d35 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 1077 | install_element(ENABLE_NODE, &smsqueue_max_cmd); |
Holger Hans Peter Freyther | 416c7de | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 1078 | install_element(ENABLE_NODE, &smsqueue_clear_cmd); |
Holger Hans Peter Freyther | 70428d9 | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 1079 | install_element(ENABLE_NODE, &smsqueue_fail_cmd); |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 1080 | install_element(ENABLE_NODE, &subscriber_send_pending_sms_cmd); |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 1081 | install_element(ENABLE_NODE, &meas_feed_scenario_cmd); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1082 | |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 1083 | install_element(CONFIG_NODE, &cfg_mncc_int_cmd); |
| 1084 | install_node(&mncc_int_node, config_write_mncc_int); |
Jacob Erlbeck | f414e85 | 2013-10-29 09:30:30 +0100 | [diff] [blame] | 1085 | vty_install_default(MNCC_INT_NODE); |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 1086 | install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd); |
| 1087 | install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd); |
Harald Welte | d597317 | 2012-11-11 10:58:51 +0100 | [diff] [blame] | 1088 | install_element(MNCC_INT_NODE, &mnccint_meas_feed_cmd); |
Holger Hans Peter Freyther | 65b8992 | 2015-01-31 09:47:37 +0100 | [diff] [blame] | 1089 | install_element(MNCC_INT_NODE, &meas_feed_scenario_cmd); |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 1090 | |
Harald Welte | 3073f52 | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 1091 | install_element(CFG_LOG_NODE, &log_level_sms_cmd); |
Holger Hans Peter Freyther | 75cf52a | 2014-12-28 18:54:32 +0100 | [diff] [blame] | 1092 | install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd); |
Harald Welte | 3073f52 | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 1093 | |
Holger Hans Peter Freyther | e144211 | 2015-01-27 10:58:29 +0100 | [diff] [blame] | 1094 | |
| 1095 | install_element(CONFIG_NODE, &cfg_nitb_cmd); |
| 1096 | install_node(&nitb_node, config_write_nitb); |
| 1097 | install_element(NITB_NODE, &cfg_nitb_subscr_create_cmd); |
| 1098 | install_element(NITB_NODE, &cfg_nitb_no_subscr_create_cmd); |
| 1099 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1100 | return 0; |
| 1101 | } |