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 | |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 52 | extern struct gsm_network *gsmnet_from_vty(struct vty *v); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 53 | |
Holger Hans Peter Freyther | 5b72b30 | 2010-12-28 22:12:30 +0100 | [diff] [blame] | 54 | static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr, int pending) |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 55 | { |
| 56 | int rc; |
| 57 | struct gsm_auth_info ainfo; |
| 58 | struct gsm_auth_tuple atuple; |
Holger Hans Peter Freyther | 2a835d8 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 59 | char expire_time[200]; |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 60 | |
| 61 | vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, |
| 62 | subscr->authorized, VTY_NEWLINE); |
| 63 | if (subscr->name) |
| 64 | vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); |
| 65 | if (subscr->extension) |
| 66 | vty_out(vty, " Extension: %s%s", subscr->extension, |
| 67 | VTY_NEWLINE); |
Holger Hans Peter Freyther | ff8dd57 | 2010-12-25 16:40:54 +0100 | [diff] [blame] | 68 | vty_out(vty, " LAC: %d/0x%x%s", |
| 69 | subscr->lac, subscr->lac, VTY_NEWLINE); |
Holger Hans Peter Freyther | b0be39b | 2013-07-14 08:38:24 +0200 | [diff] [blame] | 70 | vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 71 | if (subscr->tmsi != GSM_RESERVED_TMSI) |
| 72 | vty_out(vty, " TMSI: %08X%s", subscr->tmsi, |
| 73 | VTY_NEWLINE); |
| 74 | |
Sylvain Munaut | 48858d2 | 2010-06-09 11:32:51 +0200 | [diff] [blame] | 75 | rc = db_get_authinfo_for_subscr(&ainfo, subscr); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 76 | if (!rc) { |
| 77 | vty_out(vty, " A3A8 algorithm id: %d%s", |
| 78 | ainfo.auth_algo, VTY_NEWLINE); |
| 79 | vty_out(vty, " A3A8 Ki: %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 80 | osmo_hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 81 | VTY_NEWLINE); |
| 82 | } |
| 83 | |
Sylvain Munaut | 48858d2 | 2010-06-09 11:32:51 +0200 | [diff] [blame] | 84 | rc = db_get_lastauthtuple_for_subscr(&atuple, subscr); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 85 | if (!rc) { |
| 86 | vty_out(vty, " A3A8 last tuple (used %d times):%s", |
| 87 | atuple.use_count, VTY_NEWLINE); |
| 88 | vty_out(vty, " seq # : %d%s", |
| 89 | atuple.key_seq, VTY_NEWLINE); |
| 90 | vty_out(vty, " RAND : %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 91 | osmo_hexdump(atuple.rand, sizeof(atuple.rand)), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 92 | VTY_NEWLINE); |
| 93 | vty_out(vty, " SRES : %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 94 | osmo_hexdump(atuple.sres, sizeof(atuple.sres)), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 95 | VTY_NEWLINE); |
| 96 | vty_out(vty, " Kc : %s%s", |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 97 | osmo_hexdump(atuple.kc, sizeof(atuple.kc)), |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 98 | VTY_NEWLINE); |
| 99 | } |
Holger Hans Peter Freyther | 2a835d8 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 100 | |
| 101 | /* print the expiration time of a subscriber */ |
| 102 | strftime(expire_time, sizeof(expire_time), |
| 103 | "%a, %d %b %Y %T %z", localtime(&subscr->expire_lu)); |
| 104 | expire_time[sizeof(expire_time) - 1] = '\0'; |
| 105 | vty_out(vty, " Expiration Time: %s%s", expire_time, VTY_NEWLINE); |
| 106 | |
Holger Hans Peter Freyther | 5b72b30 | 2010-12-28 22:12:30 +0100 | [diff] [blame] | 107 | if (pending) |
| 108 | vty_out(vty, " Pending: %d%s", |
| 109 | subscr_pending_requests(subscr), VTY_NEWLINE); |
Holger Hans Peter Freyther | 1dd0a1b | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 110 | |
| 111 | vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); |
| 112 | } |
| 113 | |
| 114 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 115 | /* Subscriber */ |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 116 | DEFUN(show_subscr_cache, |
| 117 | show_subscr_cache_cmd, |
| 118 | "show subscriber cache", |
Harald Welte | 557f399 | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 119 | SHOW_STR "Show information about subscribers\n" |
| 120 | "Display contents of subscriber cache\n") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 121 | { |
| 122 | struct gsm_subscriber *subscr; |
| 123 | |
| 124 | llist_for_each_entry(subscr, &active_subscribers, entry) { |
| 125 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 5b72b30 | 2010-12-28 22:12:30 +0100 | [diff] [blame] | 126 | subscr_dump_full_vty(vty, subscr, 0); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | return CMD_SUCCESS; |
| 130 | } |
| 131 | |
| 132 | DEFUN(sms_send_pend, |
| 133 | sms_send_pend_cmd, |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 134 | "sms send pending", |
Harald Welte | 557f399 | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 135 | "SMS related comamnds\n" "SMS Sending related commands\n" |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 136 | "Send all pending SMS") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 137 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 138 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 139 | struct gsm_sms *sms; |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 140 | int id = 0; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 141 | |
| 142 | while (1) { |
Holger Hans Peter Freyther | ae9c9d9 | 2010-12-25 00:33:40 +0100 | [diff] [blame] | 143 | 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] | 144 | if (!sms) |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 145 | break; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 146 | |
| 147 | gsm411_send_sms_subscr(sms->receiver, sms); |
Sylvain Munaut | c2e0a44 | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 148 | |
| 149 | id = sms->receiver->id + 1; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | return CMD_SUCCESS; |
| 153 | } |
| 154 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 155 | static int _send_sms_str(struct gsm_subscriber *receiver, |
| 156 | struct gsm_subscriber *sender, |
| 157 | char *str, uint8_t tp_pid) |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 158 | { |
| 159 | struct gsm_sms *sms; |
| 160 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 161 | sms = sms_from_text(receiver, sender, 0, str); |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 162 | sms->protocol_id = tp_pid; |
Nico Golde | 2e6bc80 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 163 | |
Holger Hans Peter Freyther | e78b443 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 164 | /* store in database for the queue */ |
| 165 | if (db_sms_store(sms) != 0) { |
Holger Hans Peter Freyther | d0a34ed | 2012-11-10 19:46:58 +0100 | [diff] [blame] | 166 | 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] | 167 | sms_free(sms); |
| 168 | return CMD_WARNING; |
Nico Golde | 2e6bc80 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 169 | } |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 170 | |
Holger Hans Peter Freyther | e78b443 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 171 | sms_free(sms); |
| 172 | sms_queue_trigger(receiver->net->sms_queue); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 173 | return CMD_SUCCESS; |
| 174 | } |
| 175 | |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 176 | static struct gsm_subscriber *get_subscr_by_argv(struct gsm_network *gsmnet, |
| 177 | const char *type, |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 178 | const char *id) |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 179 | { |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 180 | if (!strcmp(type, "extension")) |
| 181 | return subscr_get_by_extension(gsmnet, id); |
| 182 | else if (!strcmp(type, "imsi")) |
| 183 | return subscr_get_by_imsi(gsmnet, id); |
| 184 | else if (!strcmp(type, "tmsi")) |
| 185 | return subscr_get_by_tmsi(gsmnet, atoi(id)); |
| 186 | else if (!strcmp(type, "id")) |
| 187 | return subscr_get_by_id(gsmnet, atoi(id)); |
| 188 | |
| 189 | return NULL; |
| 190 | } |
| 191 | #define SUBSCR_TYPES "(extension|imsi|tmsi|id)" |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 192 | #define SUBSCR_HELP "Operations on a Subscriber\n" \ |
| 193 | "Identify subscriber by his extension (phone number)\n" \ |
| 194 | "Identify subscriber by his IMSI\n" \ |
| 195 | "Identify subscriber by his TMSI\n" \ |
| 196 | "Identify subscriber by his database ID\n" \ |
| 197 | "Identifier for the subscriber\n" |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 198 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 199 | DEFUN(show_subscr, |
| 200 | show_subscr_cmd, |
| 201 | "show subscriber " SUBSCR_TYPES " ID", |
| 202 | SHOW_STR SUBSCR_HELP) |
| 203 | { |
| 204 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 205 | struct gsm_subscriber *subscr = |
| 206 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 207 | |
| 208 | if (!subscr) { |
| 209 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 210 | argv[0], argv[1], VTY_NEWLINE); |
| 211 | return CMD_WARNING; |
| 212 | } |
| 213 | |
Holger Hans Peter Freyther | 5b72b30 | 2010-12-28 22:12:30 +0100 | [diff] [blame] | 214 | subscr_dump_full_vty(vty, subscr, 1); |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 215 | |
| 216 | subscr_put(subscr); |
| 217 | |
| 218 | return CMD_SUCCESS; |
| 219 | } |
| 220 | |
Alexander Chemeris | e092dec | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 221 | DEFUN(subscriber_create, |
| 222 | subscriber_create_cmd, |
| 223 | "subscriber create imsi ID", |
| 224 | "Operations on a Subscriber\n" \ |
| 225 | "Create new subscriber\n" \ |
| 226 | "Identify the subscriber by his IMSI\n" \ |
| 227 | "Identifier for the subscriber\n") |
| 228 | { |
| 229 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 230 | struct gsm_subscriber *subscr; |
| 231 | |
Holger Hans Peter Freyther | abe587d | 2013-10-04 08:35:11 +0200 | [diff] [blame^] | 232 | subscr = subscr_create_subscriber(gsmnet, argv[0]); |
Alexander Chemeris | e092dec | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 233 | if (!subscr) { |
| 234 | vty_out(vty, "%% No subscriber created for IMSI %s%s", |
| 235 | argv[0], VTY_NEWLINE); |
| 236 | return CMD_WARNING; |
| 237 | } |
| 238 | |
| 239 | /* Show info about the created subscriber. */ |
| 240 | subscr_dump_full_vty(vty, subscr, 0); |
| 241 | |
| 242 | subscr_put(subscr); |
| 243 | |
| 244 | return CMD_SUCCESS; |
| 245 | } |
| 246 | |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 247 | DEFUN(subscriber_send_pending_sms, |
| 248 | subscriber_send_pending_sms_cmd, |
Holger Hans Peter Freyther | e6a500e | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 249 | "subscriber " SUBSCR_TYPES " ID sms pending-send", |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 250 | SUBSCR_HELP "SMS Operations\n" "Send pending SMS\n") |
| 251 | { |
| 252 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | e6e99e1 | 2013-07-04 20:34:46 +0200 | [diff] [blame] | 253 | struct gsm_subscriber *subscr; |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 254 | struct gsm_sms *sms; |
| 255 | |
Holger Hans Peter Freyther | e6e99e1 | 2013-07-04 20:34:46 +0200 | [diff] [blame] | 256 | subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 257 | if (!subscr) { |
| 258 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 259 | argv[0], argv[1], VTY_NEWLINE); |
| 260 | return CMD_WARNING; |
| 261 | } |
| 262 | |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 263 | sms = db_sms_get_unsent_by_subscr(gsmnet, subscr->id, UINT_MAX); |
| 264 | if (sms) |
| 265 | gsm411_send_sms_subscr(sms->receiver, sms); |
| 266 | |
| 267 | subscr_put(subscr); |
| 268 | |
| 269 | return CMD_SUCCESS; |
| 270 | } |
| 271 | |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 272 | DEFUN(subscriber_send_sms, |
| 273 | subscriber_send_sms_cmd, |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 274 | "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] | 275 | 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] | 276 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 277 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 278 | 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] | 279 | 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] | 280 | char *str; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 281 | int rc; |
| 282 | |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 283 | if (!subscr) { |
| 284 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 285 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 286 | rc = CMD_WARNING; |
| 287 | goto err; |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 288 | } |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 289 | |
| 290 | if (!sender) { |
| 291 | vty_out(vty, "%% No sender found for %s %s%s", |
| 292 | argv[2], argv[3], VTY_NEWLINE); |
| 293 | rc = CMD_WARNING; |
| 294 | goto err; |
| 295 | } |
| 296 | |
| 297 | str = argv_concat(argv, argc, 4); |
| 298 | rc = _send_sms_str(subscr, sender, str, 0); |
Harald Welte | 3699e20 | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 299 | talloc_free(str); |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 300 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 301 | err: |
| 302 | if (sender) |
| 303 | subscr_put(sender); |
| 304 | |
| 305 | if (subscr) |
| 306 | subscr_put(subscr); |
Harald Welte | bbe3172 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 307 | |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 308 | return rc; |
| 309 | } |
| 310 | |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 311 | DEFUN(subscriber_silent_sms, |
| 312 | subscriber_silent_sms_cmd, |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 313 | "subscriber " SUBSCR_TYPES " ID silent-sms send .LINE", |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 314 | SUBSCR_HELP |
| 315 | "Silent SMS Operation\n" "Send Silent SMS\n" "Actual SMS text\n") |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 316 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 317 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 318 | 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] | 319 | 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] | 320 | char *str; |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 321 | int rc; |
| 322 | |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 323 | if (!subscr) { |
| 324 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 325 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 326 | rc = CMD_WARNING; |
| 327 | goto err; |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 328 | } |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 329 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 330 | if (!sender) { |
| 331 | vty_out(vty, "%% No sender found for %s %s%s", |
| 332 | argv[2], argv[3], VTY_NEWLINE); |
| 333 | rc = CMD_WARNING; |
| 334 | goto err; |
| 335 | } |
| 336 | |
| 337 | str = argv_concat(argv, argc, 4); |
| 338 | rc = _send_sms_str(subscr, sender, str, 64); |
Harald Welte | 3699e20 | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 339 | talloc_free(str); |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 340 | |
Sylvain Munaut | 9431faa | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 341 | err: |
| 342 | if (sender) |
| 343 | subscr_put(sender); |
| 344 | |
| 345 | if (subscr) |
| 346 | subscr_put(subscr); |
Harald Welte | bbe3172 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 347 | |
Harald Welte | 9ee8ee9 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 348 | return rc; |
| 349 | } |
| 350 | |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 351 | #define CHAN_TYPES "(any|tch/f|tch/any|sdcch)" |
| 352 | #define CHAN_TYPE_HELP \ |
| 353 | "Any channel\n" \ |
| 354 | "TCH/F channel\n" \ |
| 355 | "Any TCH channel\n" \ |
| 356 | "SDCCH channel\n" |
| 357 | |
Sylvain Munaut | 1c378a7 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 358 | DEFUN(subscriber_silent_call_start, |
| 359 | subscriber_silent_call_start_cmd, |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 360 | "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] | 361 | SUBSCR_HELP "Silent call operation\n" "Start silent call\n" |
| 362 | CHAN_TYPE_HELP) |
Sylvain Munaut | 1c378a7 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 363 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 364 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 365 | 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] | 366 | int rc, type; |
| 367 | |
| 368 | if (!subscr) { |
| 369 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 370 | argv[0], argv[1], VTY_NEWLINE); |
| 371 | return CMD_WARNING; |
| 372 | } |
| 373 | |
| 374 | if (!strcmp(argv[2], "tch/f")) |
| 375 | type = RSL_CHANNEED_TCH_F; |
| 376 | else if (!strcmp(argv[2], "tch/any")) |
| 377 | type = RSL_CHANNEED_TCH_ForH; |
| 378 | else if (!strcmp(argv[2], "sdcch")) |
| 379 | type = RSL_CHANNEED_SDCCH; |
| 380 | else |
| 381 | type = RSL_CHANNEED_ANY; /* Defaults to ANY */ |
| 382 | |
| 383 | rc = gsm_silent_call_start(subscr, vty, type); |
| 384 | if (rc <= 0) { |
| 385 | vty_out(vty, "%% Subscriber not attached%s", |
| 386 | VTY_NEWLINE); |
| 387 | subscr_put(subscr); |
| 388 | return CMD_WARNING; |
| 389 | } |
| 390 | |
| 391 | subscr_put(subscr); |
| 392 | |
| 393 | return CMD_SUCCESS; |
| 394 | } |
| 395 | |
| 396 | DEFUN(subscriber_silent_call_stop, |
| 397 | subscriber_silent_call_stop_cmd, |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 398 | "subscriber " SUBSCR_TYPES " ID silent-call stop", |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 399 | SUBSCR_HELP "Silent call operation\n" "Stop silent call\n" |
| 400 | CHAN_TYPE_HELP) |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 401 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 402 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 403 | 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] | 404 | int rc; |
| 405 | |
| 406 | if (!subscr) { |
| 407 | vty_out(vty, "%% No subscriber found for %s %s%s", |
Harald Welte | 81cf198 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 408 | argv[0], argv[1], VTY_NEWLINE); |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 409 | return CMD_WARNING; |
| 410 | } |
| 411 | |
Sylvain Munaut | 1c378a7 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 412 | rc = gsm_silent_call_stop(subscr); |
| 413 | if (rc < 0) { |
| 414 | subscr_put(subscr); |
| 415 | return CMD_WARNING; |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | subscr_put(subscr); |
| 419 | |
| 420 | return CMD_SUCCESS; |
| 421 | } |
| 422 | |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 423 | DEFUN(subscriber_ussd_notify, |
| 424 | subscriber_ussd_notify_cmd, |
Holger Hans Peter Freyther | 7429476 | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 425 | "subscriber " SUBSCR_TYPES " ID ussd-notify (0|1|2) .TEXT", |
Harald Welte | 557f399 | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 426 | SUBSCR_HELP "Send a USSD notify to the subscriber\n" |
Harald Welte | 557f399 | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 427 | "Alerting Level 0\n" |
| 428 | "Alerting Level 1\n" |
| 429 | "Alerting Level 2\n" |
| 430 | "Text of USSD message to send\n") |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 431 | { |
| 432 | char *text; |
| 433 | struct gsm_subscriber_connection *conn; |
| 434 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 435 | 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] | 436 | int level; |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 437 | |
| 438 | if (!subscr) { |
| 439 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 440 | argv[0], argv[1], VTY_NEWLINE); |
| 441 | return CMD_WARNING; |
| 442 | } |
| 443 | |
Holger Hans Peter Freyther | 7429476 | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 444 | level = atoi(argv[2]); |
| 445 | text = argv_concat(argv, argc, 3); |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 446 | if (!text) { |
| 447 | subscr_put(subscr); |
| 448 | return CMD_WARNING; |
| 449 | } |
| 450 | |
| 451 | conn = connection_for_subscr(subscr); |
| 452 | if (!conn) { |
| 453 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 454 | argv[0], argv[1], VTY_NEWLINE); |
| 455 | subscr_put(subscr); |
| 456 | talloc_free(text); |
| 457 | return CMD_WARNING; |
| 458 | } |
| 459 | |
Holger Hans Peter Freyther | 7429476 | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 460 | gsm0480_send_ussdNotify(conn, level, text); |
Holger Hans Peter Freyther | 9059790 | 2010-07-27 03:31:50 +0800 | [diff] [blame] | 461 | gsm0480_send_releaseComplete(conn); |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 462 | |
| 463 | subscr_put(subscr); |
| 464 | talloc_free(text); |
| 465 | return CMD_SUCCESS; |
| 466 | } |
| 467 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 468 | DEFUN(ena_subscr_authorizde, |
| 469 | ena_subscr_authorized_cmd, |
| 470 | "subscriber " SUBSCR_TYPES " ID authorized (0|1)", |
| 471 | SUBSCR_HELP "(De-)Authorize subscriber in HLR\n" |
| 472 | "Subscriber should NOT be authorized\n" |
| 473 | "Subscriber should be authorized\n") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 474 | { |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 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 | subscr->authorized = atoi(argv[2]); |
| 486 | db_sync_subscriber(subscr); |
| 487 | |
| 488 | subscr_put(subscr); |
| 489 | |
| 490 | return CMD_SUCCESS; |
| 491 | } |
| 492 | |
| 493 | DEFUN(ena_subscr_name, |
| 494 | ena_subscr_name_cmd, |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 495 | "subscriber " SUBSCR_TYPES " ID name .NAME", |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 496 | SUBSCR_HELP "Set the name of the subscriber\n" |
| 497 | "Name of the Subscriber\n") |
| 498 | { |
| 499 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 500 | struct gsm_subscriber *subscr = |
| 501 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 502 | char *name; |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 503 | |
| 504 | if (!subscr) { |
| 505 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 506 | argv[0], argv[1], VTY_NEWLINE); |
| 507 | return CMD_WARNING; |
| 508 | } |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 509 | |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 510 | name = argv_concat(argv, argc, 2); |
Holger Hans Peter Freyther | a36df37 | 2010-07-26 19:43:54 +0800 | [diff] [blame] | 511 | if (!name) { |
| 512 | subscr_put(subscr); |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 513 | return CMD_WARNING; |
Holger Hans Peter Freyther | a36df37 | 2010-07-26 19:43:54 +0800 | [diff] [blame] | 514 | } |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 515 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 516 | strncpy(subscr->name, name, sizeof(subscr->name)); |
Harald Welte | 3368e36 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 517 | talloc_free(name); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 518 | db_sync_subscriber(subscr); |
| 519 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 520 | subscr_put(subscr); |
| 521 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 522 | return CMD_SUCCESS; |
| 523 | } |
| 524 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 525 | DEFUN(ena_subscr_extension, |
| 526 | ena_subscr_extension_cmd, |
| 527 | "subscriber " SUBSCR_TYPES " ID extension EXTENSION", |
| 528 | SUBSCR_HELP "Set the extension (phone number) of the subscriber\n" |
| 529 | "Extension (phone number)\n") |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 530 | { |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 531 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 532 | struct gsm_subscriber *subscr = |
| 533 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Holger Hans Peter Freyther | c1cf9d5 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 534 | const char *ext = argv[2]; |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 535 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 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 | |
Holger Hans Peter Freyther | c1cf9d5 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 542 | strncpy(subscr->extension, ext, sizeof(subscr->extension)); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 543 | db_sync_subscriber(subscr); |
| 544 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 545 | subscr_put(subscr); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 546 | |
| 547 | return CMD_SUCCESS; |
| 548 | } |
| 549 | |
Holger Hans Peter Freyther | ce69aec | 2010-12-28 22:21:55 +0100 | [diff] [blame] | 550 | DEFUN(ena_subscr_clear, |
| 551 | ena_subscr_clear_cmd, |
| 552 | "subscriber " SUBSCR_TYPES " ID clear-requests", |
| 553 | SUBSCR_HELP "Clear the paging requests for this subscriber\n") |
| 554 | { |
| 555 | int del; |
| 556 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 557 | struct gsm_subscriber *subscr = |
| 558 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 559 | |
| 560 | if (!subscr) { |
| 561 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 562 | argv[0], argv[1], VTY_NEWLINE); |
| 563 | return CMD_WARNING; |
| 564 | } |
| 565 | |
| 566 | del = subscr_pending_clear(subscr); |
| 567 | vty_out(vty, "Cleared %d pending requests.%s", del, VTY_NEWLINE); |
| 568 | subscr_put(subscr); |
| 569 | |
| 570 | return CMD_SUCCESS; |
| 571 | } |
| 572 | |
Holger Hans Peter Freyther | 0fe0c8c | 2010-12-29 11:07:22 +0100 | [diff] [blame] | 573 | DEFUN(ena_subscr_pend, |
| 574 | ena_subscr_pend_cmd, |
| 575 | "subscriber " SUBSCR_TYPES " ID show-pending", |
| 576 | SUBSCR_HELP "Clear the paging requests for this subscriber\n") |
| 577 | { |
| 578 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 579 | struct gsm_subscriber *subscr = |
| 580 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 581 | |
| 582 | if (!subscr) { |
| 583 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 584 | argv[0], argv[1], VTY_NEWLINE); |
| 585 | return CMD_WARNING; |
| 586 | } |
| 587 | |
| 588 | subscr_pending_dump(subscr, vty); |
| 589 | subscr_put(subscr); |
| 590 | |
| 591 | return CMD_SUCCESS; |
| 592 | } |
| 593 | |
Holger Hans Peter Freyther | e5d806e | 2010-12-29 13:45:49 +0100 | [diff] [blame] | 594 | DEFUN(ena_subscr_kick, |
| 595 | ena_subscr_kick_cmd, |
| 596 | "subscriber " SUBSCR_TYPES " ID kick-pending", |
| 597 | SUBSCR_HELP "Clear the paging requests for this subscriber\n") |
| 598 | { |
| 599 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 600 | struct gsm_subscriber *subscr = |
| 601 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 602 | |
| 603 | if (!subscr) { |
| 604 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 605 | argv[0], argv[1], VTY_NEWLINE); |
| 606 | return CMD_WARNING; |
| 607 | } |
| 608 | |
| 609 | subscr_pending_kick(subscr); |
| 610 | subscr_put(subscr); |
| 611 | |
| 612 | return CMD_SUCCESS; |
| 613 | } |
| 614 | |
Holger Hans Peter Freyther | f4dfea1 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 615 | DEFUN(ena_subscr_handover, |
| 616 | ena_subscr_handover_cmd, |
| 617 | "subscriber " SUBSCR_TYPES " ID handover BTS_NR", |
| 618 | SUBSCR_HELP "Handover the active connection\n" |
| 619 | "Number of the BTS to handover to\n") |
| 620 | { |
| 621 | int ret; |
| 622 | struct gsm_subscriber_connection *conn; |
| 623 | struct gsm_bts *bts; |
| 624 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 625 | struct gsm_subscriber *subscr = |
| 626 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 627 | |
| 628 | if (!subscr) { |
| 629 | vty_out(vty, "%% No subscriber found for %s %s.%s", |
| 630 | argv[0], argv[1], VTY_NEWLINE); |
| 631 | return CMD_WARNING; |
| 632 | } |
| 633 | |
| 634 | conn = connection_for_subscr(subscr); |
| 635 | if (!conn) { |
| 636 | vty_out(vty, "%% No active connection for subscriber %s %s.%s", |
| 637 | argv[0], argv[1], VTY_NEWLINE); |
| 638 | subscr_put(subscr); |
| 639 | return CMD_WARNING; |
| 640 | } |
| 641 | |
| 642 | bts = gsm_bts_num(gsmnet, atoi(argv[2])); |
| 643 | if (!bts) { |
| 644 | vty_out(vty, "%% BTS with number(%d) could not be found.%s", |
| 645 | atoi(argv[2]), VTY_NEWLINE); |
| 646 | subscr_put(subscr); |
| 647 | return CMD_WARNING; |
| 648 | } |
| 649 | |
| 650 | /* now start the handover */ |
| 651 | ret = bsc_handover_start(conn->lchan, bts); |
| 652 | if (ret != 0) { |
| 653 | vty_out(vty, "%% Handover failed with errno %d.%s", |
| 654 | ret, VTY_NEWLINE); |
| 655 | } else { |
| 656 | vty_out(vty, "%% Handover started from %s", |
| 657 | gsm_lchan_name(conn->lchan)); |
| 658 | vty_out(vty, " to %s.%s", gsm_lchan_name(conn->ho_lchan), |
| 659 | VTY_NEWLINE); |
| 660 | } |
| 661 | |
| 662 | subscr_put(subscr); |
| 663 | return CMD_SUCCESS; |
| 664 | } |
| 665 | |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 666 | #define A3A8_ALG_TYPES "(none|xor|comp128v1)" |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 667 | #define A3A8_ALG_HELP \ |
| 668 | "Use No A3A8 algorithm\n" \ |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 669 | "Use XOR algorithm\n" \ |
Harald Welte | 18ce31c | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 670 | "Use COMP128v1 algorithm\n" |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 671 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 672 | DEFUN(ena_subscr_a3a8, |
| 673 | ena_subscr_a3a8_cmd, |
| 674 | "subscriber " SUBSCR_TYPES " ID a3a8 " A3A8_ALG_TYPES " [KI]", |
Harald Welte | c4bf319 | 2010-05-27 10:48:11 +0200 | [diff] [blame] | 675 | SUBSCR_HELP "Set a3a8 parameters for the subscriber\n" |
| 676 | A3A8_ALG_HELP "Encryption Key Ki\n") |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 677 | { |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 678 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 679 | struct gsm_subscriber *subscr = |
| 680 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 681 | const char *alg_str = argv[2]; |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 682 | const char *ki_str = argc == 4 ? argv[3] : NULL; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 683 | struct gsm_auth_info ainfo; |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 684 | int rc, minlen, maxlen; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 685 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 686 | if (!subscr) { |
| 687 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 688 | argv[0], argv[1], VTY_NEWLINE); |
| 689 | return CMD_WARNING; |
| 690 | } |
| 691 | |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 692 | if (!strcasecmp(alg_str, "none")) { |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 693 | ainfo.auth_algo = AUTH_ALGO_NONE; |
| 694 | minlen = maxlen = 0; |
| 695 | } else if (!strcasecmp(alg_str, "xor")) { |
| 696 | ainfo.auth_algo = AUTH_ALGO_XOR; |
| 697 | minlen = A38_XOR_MIN_KEY_LEN; |
| 698 | maxlen = A38_XOR_MAX_KEY_LEN; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 699 | } else if (!strcasecmp(alg_str, "comp128v1")) { |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 700 | ainfo.auth_algo = AUTH_ALGO_COMP128v1; |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 701 | minlen = maxlen = A38_COMP128_KEY_LEN; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 702 | } else { |
| 703 | /* Unknown method */ |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 704 | subscr_put(subscr); |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 705 | vty_out(vty, "%% Unknown auth method %s%s", |
| 706 | alg_str, VTY_NEWLINE); |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 707 | return CMD_WARNING; |
| 708 | } |
| 709 | |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 710 | if (ki_str) { |
Pablo Neira Ayuso | b1d5a69 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 711 | 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] | 712 | if ((rc > maxlen) || (rc < minlen)) { |
| 713 | subscr_put(subscr); |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 714 | vty_out(vty, "%% Wrong Ki `%s'%s", |
| 715 | ki_str, VTY_NEWLINE); |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 716 | return CMD_WARNING; |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 717 | } |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 718 | ainfo.a3a8_ki_len = rc; |
| 719 | } else { |
| 720 | ainfo.a3a8_ki_len = 0; |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 721 | if (minlen) { |
| 722 | subscr_put(subscr); |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 723 | vty_out(vty, "%% Missing Ki argument%s", VTY_NEWLINE); |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 724 | return CMD_WARNING; |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 725 | } |
Sylvain Munaut | 4887644 | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | rc = db_sync_authinfo_for_subscr( |
| 729 | ainfo.auth_algo == AUTH_ALGO_NONE ? NULL : &ainfo, |
| 730 | subscr); |
| 731 | |
Sylvain Munaut | 0d7d991 | 2010-06-10 22:00:48 +0200 | [diff] [blame] | 732 | /* the last tuple probably invalid with the new auth settings */ |
| 733 | db_sync_lastauthtuple_for_subscr(NULL, subscr); |
Holger Hans Peter Freyther | 32531c4 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 734 | subscr_put(subscr); |
Sylvain Munaut | 0d7d991 | 2010-06-10 22:00:48 +0200 | [diff] [blame] | 735 | |
Pablo Neira Ayuso | 9cda7a0 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 736 | if (rc) { |
| 737 | vty_out(vty, "%% Operation has failed%s", VTY_NEWLINE); |
| 738 | return CMD_WARNING; |
| 739 | } |
| 740 | return CMD_SUCCESS; |
Sylvain Munaut | dcf8c4c | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 741 | } |
| 742 | |
Holger Hans Peter Freyther | ed1d030 | 2010-12-22 16:33:23 +0100 | [diff] [blame] | 743 | DEFUN(subscriber_purge, |
| 744 | subscriber_purge_cmd, |
| 745 | "subscriber purge-inactive", |
| 746 | "Operations on a Subscriber\n" "Purge subscribers with a zero use count.\n") |
| 747 | { |
| 748 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 749 | int purged; |
| 750 | |
| 751 | purged = subscr_purge_inactive(net); |
| 752 | vty_out(vty, "%d subscriber(s) were purged.%s", purged, VTY_NEWLINE); |
| 753 | return CMD_SUCCESS; |
| 754 | } |
| 755 | |
Holger Hans Peter Freyther | 0c29e5f | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 756 | DEFUN(subscriber_update, |
| 757 | subscriber_update_cmd, |
| 758 | "subscriber " SUBSCR_TYPES " ID update", |
| 759 | SUBSCR_HELP "Update the subscriber data from the dabase.\n") |
| 760 | { |
| 761 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 762 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 763 | |
| 764 | if (!subscr) { |
| 765 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 766 | argv[0], argv[1], VTY_NEWLINE); |
| 767 | return CMD_WARNING; |
| 768 | } |
| 769 | |
| 770 | subscr_update_from_db(subscr); |
| 771 | subscr_put(subscr); |
| 772 | return CMD_SUCCESS; |
| 773 | } |
| 774 | |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 775 | static int scall_cbfn(unsigned int subsys, unsigned int signal, |
| 776 | void *handler_data, void *signal_data) |
| 777 | { |
| 778 | struct scall_signal_data *sigdata = signal_data; |
| 779 | struct vty *vty = sigdata->data; |
| 780 | |
| 781 | switch (signal) { |
| 782 | case S_SCALL_SUCCESS: |
| 783 | 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] | 784 | sigdata->conn->lchan->ts->trx->arfcn, sigdata->conn->lchan->ts->nr, |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 785 | VTY_NEWLINE); |
| 786 | break; |
| 787 | case S_SCALL_EXPIRED: |
| 788 | vty_out(vty, "%% silent call expired paging%s", VTY_NEWLINE); |
| 789 | break; |
| 790 | } |
| 791 | return 0; |
| 792 | } |
| 793 | |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 794 | DEFUN(show_stats, |
| 795 | show_stats_cmd, |
| 796 | "show statistics", |
| 797 | SHOW_STR "Display network statistics\n") |
| 798 | { |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 799 | struct gsm_network *net = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 800 | |
| 801 | openbsc_vty_print_statistics(vty, net); |
Harald Welte | 87c0017 | 2010-12-24 15:48:09 +0100 | [diff] [blame] | 802 | vty_out(vty, "Channel Requests : %lu total, %lu no channel%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 803 | osmo_counter_get(net->stats.chreq.total), |
| 804 | osmo_counter_get(net->stats.chreq.no_channel), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 805 | 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] | 806 | osmo_counter_get(net->stats.loc_upd_type.attach), |
| 807 | osmo_counter_get(net->stats.loc_upd_type.normal), |
| 808 | 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] | 809 | vty_out(vty, "IMSI Detach Indications : %lu%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 810 | 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] | 811 | vty_out(vty, "Location Update Response: %lu accept, %lu reject%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 812 | osmo_counter_get(net->stats.loc_upd_resp.accept), |
| 813 | 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] | 814 | vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, " |
| 815 | "%lu completed, %lu failed%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 816 | osmo_counter_get(net->stats.handover.attempted), |
| 817 | osmo_counter_get(net->stats.handover.no_channel), |
| 818 | osmo_counter_get(net->stats.handover.timeout), |
| 819 | osmo_counter_get(net->stats.handover.completed), |
| 820 | osmo_counter_get(net->stats.handover.failed), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 821 | vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 822 | osmo_counter_get(net->stats.sms.submitted), |
| 823 | osmo_counter_get(net->stats.sms.no_receiver), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 824 | 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] | 825 | osmo_counter_get(net->stats.sms.delivered), |
| 826 | osmo_counter_get(net->stats.sms.rp_err_mem), |
| 827 | osmo_counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE); |
Harald Welte | c56006b | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 828 | vty_out(vty, "MO Calls : %lu setup, %lu connect ack%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 829 | osmo_counter_get(net->stats.call.mo_setup), |
| 830 | osmo_counter_get(net->stats.call.mo_connect_ack), VTY_NEWLINE); |
Harald Welte | c56006b | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 831 | vty_out(vty, "MT Calls : %lu setup, %lu connect%s", |
Pablo Neira Ayuso | 1c45074 | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 832 | osmo_counter_get(net->stats.call.mt_setup), |
| 833 | osmo_counter_get(net->stats.call.mt_connect), VTY_NEWLINE); |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 834 | return CMD_SUCCESS; |
| 835 | } |
| 836 | |
Holger Hans Peter Freyther | 6ec8098 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 837 | DEFUN(show_smsqueue, |
| 838 | show_smsqueue_cmd, |
| 839 | "show sms-queue", |
| 840 | SHOW_STR "Display SMSqueue statistics\n") |
| 841 | { |
| 842 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 843 | |
| 844 | sms_queue_stats(net->sms_queue, vty); |
| 845 | return CMD_SUCCESS; |
| 846 | } |
| 847 | |
Holger Hans Peter Freyther | 58fe028 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 848 | DEFUN(smsqueue_trigger, |
| 849 | smsqueue_trigger_cmd, |
| 850 | "sms-queue trigger", |
| 851 | "SMS Queue\n" "Trigger sending messages\n") |
| 852 | { |
| 853 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 854 | |
| 855 | sms_queue_trigger(net->sms_queue); |
| 856 | return CMD_SUCCESS; |
| 857 | } |
Holger Hans Peter Freyther | e789b21 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 858 | |
Holger Hans Peter Freyther | 96b4d35 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 859 | DEFUN(smsqueue_max, |
| 860 | smsqueue_max_cmd, |
| 861 | "sms-queue max-pending <1-500>", |
Holger Hans Peter Freyther | e6a500e | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 862 | "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] | 863 | { |
| 864 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 865 | |
| 866 | sms_queue_set_max_pending(net->sms_queue, atoi(argv[0])); |
| 867 | return CMD_SUCCESS; |
| 868 | } |
| 869 | |
Holger Hans Peter Freyther | 416c7de | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 870 | DEFUN(smsqueue_clear, |
| 871 | smsqueue_clear_cmd, |
| 872 | "sms-queue clear", |
| 873 | "SMS Queue\n" "Clear the queue of pending SMS\n") |
| 874 | { |
| 875 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 876 | |
| 877 | sms_queue_clear(net->sms_queue); |
| 878 | return CMD_SUCCESS; |
| 879 | } |
| 880 | |
Holger Hans Peter Freyther | 70428d9 | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 881 | DEFUN(smsqueue_fail, |
| 882 | smsqueue_fail_cmd, |
| 883 | "sms-queue max-failure <1-500>", |
Holger Hans Peter Freyther | e6a500e | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 884 | "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] | 885 | { |
| 886 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 887 | |
| 888 | sms_queue_set_max_failure(net->sms_queue, atoi(argv[0])); |
| 889 | return CMD_SUCCESS; |
| 890 | } |
| 891 | |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 892 | |
| 893 | DEFUN(cfg_mncc_int, cfg_mncc_int_cmd, |
| 894 | "mncc-int", "Configure internal MNCC handler") |
| 895 | { |
| 896 | vty->node = MNCC_INT_NODE; |
| 897 | |
| 898 | return CMD_SUCCESS; |
| 899 | } |
| 900 | |
| 901 | static struct cmd_node mncc_int_node = { |
| 902 | MNCC_INT_NODE, |
Harald Welte | 45362bb | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 903 | "%s(config-mncc-int)# ", |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 904 | 1, |
| 905 | }; |
| 906 | |
| 907 | static const struct value_string tchf_codec_names[] = { |
| 908 | { GSM48_CMODE_SPEECH_V1, "fr" }, |
| 909 | { GSM48_CMODE_SPEECH_EFR, "efr" }, |
| 910 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 911 | { 0, NULL } |
| 912 | }; |
| 913 | |
| 914 | static const struct value_string tchh_codec_names[] = { |
| 915 | { GSM48_CMODE_SPEECH_V1, "hr" }, |
| 916 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 917 | { 0, NULL } |
| 918 | }; |
| 919 | |
| 920 | static int config_write_mncc_int(struct vty *vty) |
| 921 | { |
| 922 | vty_out(vty, "mncc-int%s", VTY_NEWLINE); |
| 923 | vty_out(vty, " default-codec tch-f %s%s", |
| 924 | get_value_string(tchf_codec_names, mncc_int.def_codec[0]), |
| 925 | VTY_NEWLINE); |
| 926 | vty_out(vty, " default-codec tch-h %s%s", |
| 927 | get_value_string(tchh_codec_names, mncc_int.def_codec[1]), |
| 928 | VTY_NEWLINE); |
| 929 | |
| 930 | return CMD_SUCCESS; |
| 931 | } |
| 932 | |
| 933 | DEFUN(mnccint_def_codec_f, |
| 934 | mnccint_def_codec_f_cmd, |
| 935 | "default-codec tch-f (fr|efr|amr)", |
| 936 | "Set default codec\n" "Codec for TCH/F\n" |
| 937 | "Full-Rate\n" "Enhanced Full-Rate\n" "Adaptive Multi-Rate\n") |
| 938 | { |
| 939 | mncc_int.def_codec[0] = get_string_value(tchf_codec_names, argv[0]); |
| 940 | |
| 941 | return CMD_SUCCESS; |
| 942 | } |
| 943 | |
| 944 | DEFUN(mnccint_def_codec_h, |
| 945 | mnccint_def_codec_h_cmd, |
| 946 | "default-codec tch-h (hr|amr)", |
| 947 | "Set default codec\n" "Codec for TCH/H\n" |
| 948 | "Half-Rate\n" "Adaptive Multi-Rate\n") |
| 949 | { |
| 950 | mncc_int.def_codec[1] = get_string_value(tchh_codec_names, argv[0]); |
| 951 | |
| 952 | return CMD_SUCCESS; |
| 953 | } |
| 954 | |
Holger Hans Peter Freyther | ebe3725 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 955 | #define OBSOLETE_MSG "Obsolete\n" |
Harald Welte | 3073f52 | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 956 | /* this is just for backwards compatibility as the sms code moved into |
| 957 | * libosmocore and old config files no longer parse... */ |
| 958 | DEFUN_DEPRECATED(log_level_sms, log_level_sms_cmd, |
| 959 | "logging level sms (everything|debug|info|notice|error|fatal)", |
Holger Hans Peter Freyther | ebe3725 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 960 | ".HIDDEN\n" OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG |
| 961 | OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG) |
Harald Welte | 3073f52 | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 962 | { |
| 963 | vty_out(vty, "%% 'logging level sms' is now called 'logging level " |
| 964 | "lsms', please update your config %s", VTY_NEWLINE); |
| 965 | |
| 966 | return CMD_SUCCESS; |
| 967 | } |
| 968 | |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 969 | int bsc_vty_init_extra(void) |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 970 | { |
Pablo Neira Ayuso | ef717c6 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 971 | osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL); |
Harald Welte | b8678a7 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 972 | |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 973 | install_element_ve(&show_subscr_cmd); |
| 974 | install_element_ve(&show_subscr_cache_cmd); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 975 | |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 976 | install_element_ve(&sms_send_pend_cmd); |
Harald Welte | 194ef7b | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 977 | |
Alexander Chemeris | e092dec | 2013-10-04 23:54:17 +0200 | [diff] [blame] | 978 | install_element_ve(&subscriber_create_cmd); |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 979 | install_element_ve(&subscriber_send_sms_cmd); |
| 980 | install_element_ve(&subscriber_silent_sms_cmd); |
| 981 | install_element_ve(&subscriber_silent_call_start_cmd); |
| 982 | install_element_ve(&subscriber_silent_call_stop_cmd); |
Holger Hans Peter Freyther | b506d72 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 983 | install_element_ve(&subscriber_ussd_notify_cmd); |
Holger Hans Peter Freyther | 0c29e5f | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 984 | install_element_ve(&subscriber_update_cmd); |
Harald Welte | 7bc28f6 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 985 | install_element_ve(&show_stats_cmd); |
Holger Hans Peter Freyther | 6ec8098 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 986 | install_element_ve(&show_smsqueue_cmd); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 987 | |
Harald Welte | a8ca70f | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 988 | install_element(ENABLE_NODE, &ena_subscr_name_cmd); |
| 989 | install_element(ENABLE_NODE, &ena_subscr_extension_cmd); |
| 990 | install_element(ENABLE_NODE, &ena_subscr_authorized_cmd); |
| 991 | install_element(ENABLE_NODE, &ena_subscr_a3a8_cmd); |
Holger Hans Peter Freyther | ce69aec | 2010-12-28 22:21:55 +0100 | [diff] [blame] | 992 | install_element(ENABLE_NODE, &ena_subscr_clear_cmd); |
Holger Hans Peter Freyther | 0fe0c8c | 2010-12-29 11:07:22 +0100 | [diff] [blame] | 993 | install_element(ENABLE_NODE, &ena_subscr_pend_cmd); |
Holger Hans Peter Freyther | e5d806e | 2010-12-29 13:45:49 +0100 | [diff] [blame] | 994 | install_element(ENABLE_NODE, &ena_subscr_kick_cmd); |
Holger Hans Peter Freyther | f4dfea1 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 995 | install_element(ENABLE_NODE, &ena_subscr_handover_cmd); |
Holger Hans Peter Freyther | ed1d030 | 2010-12-22 16:33:23 +0100 | [diff] [blame] | 996 | install_element(ENABLE_NODE, &subscriber_purge_cmd); |
Holger Hans Peter Freyther | 58fe028 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 997 | install_element(ENABLE_NODE, &smsqueue_trigger_cmd); |
Holger Hans Peter Freyther | 96b4d35 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 998 | install_element(ENABLE_NODE, &smsqueue_max_cmd); |
Holger Hans Peter Freyther | 416c7de | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 999 | install_element(ENABLE_NODE, &smsqueue_clear_cmd); |
Holger Hans Peter Freyther | 70428d9 | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 1000 | install_element(ENABLE_NODE, &smsqueue_fail_cmd); |
Nico Golde | 55ab246 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 1001 | install_element(ENABLE_NODE, &subscriber_send_pending_sms_cmd); |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1002 | |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 1003 | install_element(CONFIG_NODE, &cfg_mncc_int_cmd); |
| 1004 | install_node(&mncc_int_node, config_write_mncc_int); |
Jacob Erlbeck | bf8eec7 | 2013-09-02 13:17:16 +0200 | [diff] [blame] | 1005 | bsc_install_default(MNCC_INT_NODE); |
Harald Welte | 1ed89d4 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 1006 | install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd); |
| 1007 | install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd); |
| 1008 | |
Harald Welte | 3073f52 | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 1009 | install_element(CFG_LOG_NODE, &log_level_sms_cmd); |
| 1010 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1011 | return 0; |
| 1012 | } |