Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1 | /* OpenBSC interface to quagga VTY */ |
| 2 | /* (C) 2009 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 0e7d071 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 3 | * (C) 2009-2011 by Holger Hans Peter Freyther |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 14 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 15 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <stdlib.h> |
Holger Hans Peter Freyther | 73b878a | 2010-12-25 00:33:40 +0100 | [diff] [blame] | 22 | #include <limits.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 23 | #include <unistd.h> |
Holger Hans Peter Freyther | b970894 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 24 | #include <time.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 25 | |
Harald Welte | 4b037e4 | 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 | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 29 | |
| 30 | #include <arpa/inet.h> |
| 31 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 32 | #include <osmocom/core/linuxlist.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 33 | #include <openbsc/gsm_data.h> |
| 34 | #include <openbsc/gsm_subscriber.h> |
Harald Welte | b54d950 | 2009-11-17 06:00:23 +0100 | [diff] [blame] | 35 | #include <openbsc/silent_call.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 36 | #include <openbsc/gsm_04_11.h> |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 37 | #include <osmocom/abis/e1_input.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 38 | #include <openbsc/abis_nm.h> |
Pablo Neira Ayuso | 136f453 | 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 | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 41 | #include <openbsc/db.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 42 | #include <osmocom/core/talloc.h> |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 43 | #include <openbsc/signal.h> |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 44 | #include <openbsc/debug.h> |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 45 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | daf7534 | 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 | 81c0e25 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 48 | #include <openbsc/sms_queue.h> |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 49 | #include <openbsc/mncc_int.h> |
Holger Hans Peter Freyther | 4485321 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 50 | #include <openbsc/handover.h> |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 51 | |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 52 | extern struct gsm_network *gsmnet_from_vty(struct vty *v); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 53 | |
Holger Hans Peter Freyther | ebdd3cb | 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 | 424c4f0 | 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 | b970894 | 2013-07-27 19:42:35 +0200 | [diff] [blame] | 59 | char expire_time[200]; |
Holger Hans Peter Freyther | 424c4f0 | 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 | 3d76e44 | 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 | 5ccd015 | 2013-07-14 08:38:24 +0200 | [diff] [blame] | 70 | vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); |
Holger Hans Peter Freyther | 424c4f0 | 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 | 92b2ff5 | 2010-06-09 11:32:51 +0200 | [diff] [blame] | 75 | rc = db_get_authinfo_for_subscr(&ainfo, subscr); |
Holger Hans Peter Freyther | 424c4f0 | 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 | c0d17f2 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 80 | osmo_hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 81 | VTY_NEWLINE); |
| 82 | } |
| 83 | |
Sylvain Munaut | 92b2ff5 | 2010-06-09 11:32:51 +0200 | [diff] [blame] | 84 | rc = db_get_lastauthtuple_for_subscr(&atuple, subscr); |
Holger Hans Peter Freyther | 424c4f0 | 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 | c0d17f2 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 91 | osmo_hexdump(atuple.rand, sizeof(atuple.rand)), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 92 | VTY_NEWLINE); |
| 93 | vty_out(vty, " SRES : %s%s", |
Pablo Neira Ayuso | c0d17f2 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 94 | osmo_hexdump(atuple.sres, sizeof(atuple.sres)), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 95 | VTY_NEWLINE); |
| 96 | vty_out(vty, " Kc : %s%s", |
Pablo Neira Ayuso | c0d17f2 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 97 | osmo_hexdump(atuple.kc, sizeof(atuple.kc)), |
Holger Hans Peter Freyther | 424c4f0 | 2010-01-06 06:00:40 +0100 | [diff] [blame] | 98 | VTY_NEWLINE); |
| 99 | } |
Holger Hans Peter Freyther | b970894 | 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 | ebdd3cb | 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 | 424c4f0 | 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 | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 115 | /* Subscriber */ |
Holger Hans Peter Freyther | cfa90d4 | 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 | cfaabbb | 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 | cfa90d4 | 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 | ebdd3cb | 2010-12-28 22:12:30 +0100 | [diff] [blame] | 126 | subscr_dump_full_vty(vty, subscr, 0); |
Holger Hans Peter Freyther | cfa90d4 | 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 | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 134 | "sms send pending", |
Harald Welte | cfaabbb | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 135 | "SMS related comamnds\n" "SMS Sending related commands\n" |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 136 | "Send all pending SMS") |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 137 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 138 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 139 | struct gsm_sms *sms; |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 140 | int id = 0; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 141 | |
| 142 | while (1) { |
Holger Hans Peter Freyther | 73b878a | 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 | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 144 | if (!sms) |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 145 | break; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 146 | |
| 147 | gsm411_send_sms_subscr(sms->receiver, sms); |
Sylvain Munaut | ff1f19e | 2009-12-22 13:22:29 +0100 | [diff] [blame] | 148 | |
| 149 | id = sms->receiver->id + 1; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | return CMD_SUCCESS; |
| 153 | } |
| 154 | |
Sylvain Munaut | 01c13a3 | 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 | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 158 | { |
| 159 | struct gsm_sms *sms; |
| 160 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 161 | sms = sms_from_text(receiver, sender, 0, str); |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 162 | sms->protocol_id = tp_pid; |
Nico Golde | 5950236 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 163 | |
Holger Hans Peter Freyther | 445e615 | 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 | eff4094 | 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 | 445e615 | 2010-12-25 15:57:34 +0100 | [diff] [blame] | 167 | sms_free(sms); |
| 168 | return CMD_WARNING; |
Nico Golde | 5950236 | 2010-06-29 20:13:06 +0200 | [diff] [blame] | 169 | } |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 170 | |
Holger Hans Peter Freyther | 445e615 | 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 | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 173 | return CMD_SUCCESS; |
| 174 | } |
| 175 | |
Harald Welte | dcccb18 | 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 | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 178 | const char *id) |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 179 | { |
Harald Welte | 98f9c75 | 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 | 2832606 | 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 | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 198 | |
Harald Welte | b4a84e1 | 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 | ebdd3cb | 2010-12-28 22:12:30 +0100 | [diff] [blame] | 214 | subscr_dump_full_vty(vty, subscr, 1); |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 215 | |
| 216 | subscr_put(subscr); |
| 217 | |
| 218 | return CMD_SUCCESS; |
| 219 | } |
| 220 | |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 221 | DEFUN(subscriber_send_pending_sms, |
| 222 | subscriber_send_pending_sms_cmd, |
Holger Hans Peter Freyther | 3217fa2 | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 223 | "subscriber " SUBSCR_TYPES " ID sms pending-send", |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 224 | SUBSCR_HELP "SMS Operations\n" "Send pending SMS\n") |
| 225 | { |
| 226 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | 9feef48 | 2013-07-04 20:34:46 +0200 | [diff] [blame] | 227 | struct gsm_subscriber *subscr; |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 228 | struct gsm_sms *sms; |
| 229 | |
Holger Hans Peter Freyther | 9feef48 | 2013-07-04 20:34:46 +0200 | [diff] [blame] | 230 | subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 231 | if (!subscr) { |
| 232 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 233 | argv[0], argv[1], VTY_NEWLINE); |
| 234 | return CMD_WARNING; |
| 235 | } |
| 236 | |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 237 | sms = db_sms_get_unsent_by_subscr(gsmnet, subscr->id, UINT_MAX); |
| 238 | if (sms) |
| 239 | gsm411_send_sms_subscr(sms->receiver, sms); |
| 240 | |
| 241 | subscr_put(subscr); |
| 242 | |
| 243 | return CMD_SUCCESS; |
| 244 | } |
| 245 | |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 246 | DEFUN(subscriber_send_sms, |
| 247 | subscriber_send_sms_cmd, |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 248 | "subscriber " SUBSCR_TYPES " ID sms sender " SUBSCR_TYPES " SENDER_ID send .LINE", |
Holger Hans Peter Freyther | 63b0e44 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 249 | SUBSCR_HELP "SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS Text\n") |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 250 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 251 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 252 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 253 | struct gsm_subscriber *sender = get_subscr_by_argv(gsmnet, argv[2], argv[3]); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 254 | char *str; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 255 | int rc; |
| 256 | |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 257 | if (!subscr) { |
| 258 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 259 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 260 | rc = CMD_WARNING; |
| 261 | goto err; |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 262 | } |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 263 | |
| 264 | if (!sender) { |
| 265 | vty_out(vty, "%% No sender found for %s %s%s", |
| 266 | argv[2], argv[3], VTY_NEWLINE); |
| 267 | rc = CMD_WARNING; |
| 268 | goto err; |
| 269 | } |
| 270 | |
| 271 | str = argv_concat(argv, argc, 4); |
| 272 | rc = _send_sms_str(subscr, sender, str, 0); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 273 | talloc_free(str); |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 274 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 275 | err: |
| 276 | if (sender) |
| 277 | subscr_put(sender); |
| 278 | |
| 279 | if (subscr) |
| 280 | subscr_put(subscr); |
Harald Welte | af8c7b4 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 281 | |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 282 | return rc; |
| 283 | } |
| 284 | |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 285 | DEFUN(subscriber_silent_sms, |
| 286 | subscriber_silent_sms_cmd, |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 287 | "subscriber " SUBSCR_TYPES " ID silent-sms send .LINE", |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 288 | SUBSCR_HELP |
| 289 | "Silent SMS Operation\n" "Send Silent SMS\n" "Actual SMS text\n") |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 290 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 291 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 292 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 293 | struct gsm_subscriber *sender = get_subscr_by_argv(gsmnet, argv[2], argv[3]); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 294 | char *str; |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 295 | int rc; |
| 296 | |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 297 | if (!subscr) { |
| 298 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 299 | argv[0], argv[1], VTY_NEWLINE); |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 300 | rc = CMD_WARNING; |
| 301 | goto err; |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 302 | } |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 303 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 304 | if (!sender) { |
| 305 | vty_out(vty, "%% No sender found for %s %s%s", |
| 306 | argv[2], argv[3], VTY_NEWLINE); |
| 307 | rc = CMD_WARNING; |
| 308 | goto err; |
| 309 | } |
| 310 | |
| 311 | str = argv_concat(argv, argc, 4); |
| 312 | rc = _send_sms_str(subscr, sender, str, 64); |
Harald Welte | 20474ad | 2010-05-16 19:28:32 +0200 | [diff] [blame] | 313 | talloc_free(str); |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 314 | |
Sylvain Munaut | 01c13a3 | 2012-12-28 00:49:01 +0100 | [diff] [blame] | 315 | err: |
| 316 | if (sender) |
| 317 | subscr_put(sender); |
| 318 | |
| 319 | if (subscr) |
| 320 | subscr_put(subscr); |
Harald Welte | af8c7b4 | 2009-11-14 10:10:54 +0100 | [diff] [blame] | 321 | |
Harald Welte | 793a135 | 2009-11-05 15:51:17 +0900 | [diff] [blame] | 322 | return rc; |
| 323 | } |
| 324 | |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 325 | #define CHAN_TYPES "(any|tch/f|tch/any|sdcch)" |
| 326 | #define CHAN_TYPE_HELP \ |
| 327 | "Any channel\n" \ |
| 328 | "TCH/F channel\n" \ |
| 329 | "Any TCH channel\n" \ |
| 330 | "SDCCH channel\n" |
| 331 | |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 332 | DEFUN(subscriber_silent_call_start, |
| 333 | subscriber_silent_call_start_cmd, |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 334 | "subscriber " SUBSCR_TYPES " ID silent-call start (any|tch/f|tch/any|sdcch)", |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 335 | SUBSCR_HELP "Silent call operation\n" "Start silent call\n" |
| 336 | CHAN_TYPE_HELP) |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 337 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 338 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 339 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 340 | int rc, type; |
| 341 | |
| 342 | if (!subscr) { |
| 343 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 344 | argv[0], argv[1], VTY_NEWLINE); |
| 345 | return CMD_WARNING; |
| 346 | } |
| 347 | |
| 348 | if (!strcmp(argv[2], "tch/f")) |
| 349 | type = RSL_CHANNEED_TCH_F; |
| 350 | else if (!strcmp(argv[2], "tch/any")) |
| 351 | type = RSL_CHANNEED_TCH_ForH; |
| 352 | else if (!strcmp(argv[2], "sdcch")) |
| 353 | type = RSL_CHANNEED_SDCCH; |
| 354 | else |
| 355 | type = RSL_CHANNEED_ANY; /* Defaults to ANY */ |
| 356 | |
| 357 | rc = gsm_silent_call_start(subscr, vty, type); |
| 358 | if (rc <= 0) { |
| 359 | vty_out(vty, "%% Subscriber not attached%s", |
| 360 | VTY_NEWLINE); |
| 361 | subscr_put(subscr); |
| 362 | return CMD_WARNING; |
| 363 | } |
| 364 | |
| 365 | subscr_put(subscr); |
| 366 | |
| 367 | return CMD_SUCCESS; |
| 368 | } |
| 369 | |
| 370 | DEFUN(subscriber_silent_call_stop, |
| 371 | subscriber_silent_call_stop_cmd, |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 372 | "subscriber " SUBSCR_TYPES " ID silent-call stop", |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 373 | SUBSCR_HELP "Silent call operation\n" "Stop silent call\n" |
| 374 | CHAN_TYPE_HELP) |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 375 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 376 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 377 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 378 | int rc; |
| 379 | |
| 380 | if (!subscr) { |
| 381 | vty_out(vty, "%% No subscriber found for %s %s%s", |
Harald Welte | 20f9831 | 2009-11-14 10:11:45 +0100 | [diff] [blame] | 382 | argv[0], argv[1], VTY_NEWLINE); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 383 | return CMD_WARNING; |
| 384 | } |
| 385 | |
Sylvain Munaut | 5048070 | 2010-01-02 14:29:43 +0100 | [diff] [blame] | 386 | rc = gsm_silent_call_stop(subscr); |
| 387 | if (rc < 0) { |
| 388 | subscr_put(subscr); |
| 389 | return CMD_WARNING; |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | subscr_put(subscr); |
| 393 | |
| 394 | return CMD_SUCCESS; |
| 395 | } |
| 396 | |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 397 | DEFUN(subscriber_ussd_notify, |
| 398 | subscriber_ussd_notify_cmd, |
Holger Hans Peter Freyther | e731e1d | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 399 | "subscriber " SUBSCR_TYPES " ID ussd-notify (0|1|2) .TEXT", |
Harald Welte | cfaabbb | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 400 | SUBSCR_HELP "Send a USSD notify to the subscriber\n" |
Harald Welte | cfaabbb | 2012-08-16 23:23:50 +0200 | [diff] [blame] | 401 | "Alerting Level 0\n" |
| 402 | "Alerting Level 1\n" |
| 403 | "Alerting Level 2\n" |
| 404 | "Text of USSD message to send\n") |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 405 | { |
| 406 | char *text; |
| 407 | struct gsm_subscriber_connection *conn; |
| 408 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 409 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Holger Hans Peter Freyther | e731e1d | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 410 | int level; |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 411 | |
| 412 | if (!subscr) { |
| 413 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 414 | argv[0], argv[1], VTY_NEWLINE); |
| 415 | return CMD_WARNING; |
| 416 | } |
| 417 | |
Holger Hans Peter Freyther | e731e1d | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 418 | level = atoi(argv[2]); |
| 419 | text = argv_concat(argv, argc, 3); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 420 | if (!text) { |
| 421 | subscr_put(subscr); |
| 422 | return CMD_WARNING; |
| 423 | } |
| 424 | |
| 425 | conn = connection_for_subscr(subscr); |
| 426 | if (!conn) { |
| 427 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 428 | argv[0], argv[1], VTY_NEWLINE); |
| 429 | subscr_put(subscr); |
| 430 | talloc_free(text); |
| 431 | return CMD_WARNING; |
| 432 | } |
| 433 | |
Holger Hans Peter Freyther | e731e1d | 2010-07-27 18:27:46 +0800 | [diff] [blame] | 434 | gsm0480_send_ussdNotify(conn, level, text); |
Holger Hans Peter Freyther | 68d2679 | 2010-07-27 03:31:50 +0800 | [diff] [blame] | 435 | gsm0480_send_releaseComplete(conn); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 436 | |
| 437 | subscr_put(subscr); |
| 438 | talloc_free(text); |
| 439 | return CMD_SUCCESS; |
| 440 | } |
| 441 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 442 | DEFUN(ena_subscr_authorizde, |
| 443 | ena_subscr_authorized_cmd, |
| 444 | "subscriber " SUBSCR_TYPES " ID authorized (0|1)", |
| 445 | SUBSCR_HELP "(De-)Authorize subscriber in HLR\n" |
| 446 | "Subscriber should NOT be authorized\n" |
| 447 | "Subscriber should be authorized\n") |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 448 | { |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 449 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 450 | struct gsm_subscriber *subscr = |
| 451 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 452 | |
| 453 | if (!subscr) { |
| 454 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 455 | argv[0], argv[1], VTY_NEWLINE); |
| 456 | return CMD_WARNING; |
| 457 | } |
| 458 | |
| 459 | subscr->authorized = atoi(argv[2]); |
| 460 | db_sync_subscriber(subscr); |
| 461 | |
| 462 | subscr_put(subscr); |
| 463 | |
| 464 | return CMD_SUCCESS; |
| 465 | } |
| 466 | |
| 467 | DEFUN(ena_subscr_name, |
| 468 | ena_subscr_name_cmd, |
Harald Welte | 9d4cca7 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 469 | "subscriber " SUBSCR_TYPES " ID name .NAME", |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 470 | SUBSCR_HELP "Set the name of the subscriber\n" |
| 471 | "Name of the Subscriber\n") |
| 472 | { |
| 473 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 474 | struct gsm_subscriber *subscr = |
| 475 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | 9d4cca7 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 476 | char *name; |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 477 | |
| 478 | if (!subscr) { |
| 479 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 480 | argv[0], argv[1], VTY_NEWLINE); |
| 481 | return CMD_WARNING; |
| 482 | } |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 483 | |
Harald Welte | 9d4cca7 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 484 | name = argv_concat(argv, argc, 2); |
Holger Hans Peter Freyther | 742fc70 | 2010-07-26 19:43:54 +0800 | [diff] [blame] | 485 | if (!name) { |
| 486 | subscr_put(subscr); |
Harald Welte | 9d4cca7 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 487 | return CMD_WARNING; |
Holger Hans Peter Freyther | 742fc70 | 2010-07-26 19:43:54 +0800 | [diff] [blame] | 488 | } |
Harald Welte | 9d4cca7 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 489 | |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 490 | strncpy(subscr->name, name, sizeof(subscr->name)); |
Harald Welte | 9d4cca7 | 2010-06-24 08:06:38 +0200 | [diff] [blame] | 491 | talloc_free(name); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 492 | db_sync_subscriber(subscr); |
| 493 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 494 | subscr_put(subscr); |
| 495 | |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 496 | return CMD_SUCCESS; |
| 497 | } |
| 498 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 499 | DEFUN(ena_subscr_extension, |
| 500 | ena_subscr_extension_cmd, |
| 501 | "subscriber " SUBSCR_TYPES " ID extension EXTENSION", |
| 502 | SUBSCR_HELP "Set the extension (phone number) of the subscriber\n" |
| 503 | "Extension (phone number)\n") |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 504 | { |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 505 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 506 | struct gsm_subscriber *subscr = |
| 507 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
Holger Hans Peter Freyther | 0e7d071 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 508 | const char *ext = argv[2]; |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 509 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 510 | if (!subscr) { |
| 511 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 512 | argv[0], argv[1], VTY_NEWLINE); |
| 513 | return CMD_WARNING; |
| 514 | } |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 515 | |
Holger Hans Peter Freyther | 0e7d071 | 2011-04-18 17:15:53 +0200 | [diff] [blame] | 516 | strncpy(subscr->extension, ext, sizeof(subscr->extension)); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 517 | db_sync_subscriber(subscr); |
| 518 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 519 | subscr_put(subscr); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 520 | |
| 521 | return CMD_SUCCESS; |
| 522 | } |
| 523 | |
Holger Hans Peter Freyther | fc85741 | 2010-12-28 22:21:55 +0100 | [diff] [blame] | 524 | DEFUN(ena_subscr_clear, |
| 525 | ena_subscr_clear_cmd, |
| 526 | "subscriber " SUBSCR_TYPES " ID clear-requests", |
| 527 | SUBSCR_HELP "Clear the paging requests for this subscriber\n") |
| 528 | { |
| 529 | int del; |
| 530 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 531 | struct gsm_subscriber *subscr = |
| 532 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 533 | |
| 534 | if (!subscr) { |
| 535 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 536 | argv[0], argv[1], VTY_NEWLINE); |
| 537 | return CMD_WARNING; |
| 538 | } |
| 539 | |
| 540 | del = subscr_pending_clear(subscr); |
| 541 | vty_out(vty, "Cleared %d pending requests.%s", del, VTY_NEWLINE); |
| 542 | subscr_put(subscr); |
| 543 | |
| 544 | return CMD_SUCCESS; |
| 545 | } |
| 546 | |
Holger Hans Peter Freyther | 763b42a | 2010-12-29 11:07:22 +0100 | [diff] [blame] | 547 | DEFUN(ena_subscr_pend, |
| 548 | ena_subscr_pend_cmd, |
| 549 | "subscriber " SUBSCR_TYPES " ID show-pending", |
| 550 | SUBSCR_HELP "Clear the paging requests for this subscriber\n") |
| 551 | { |
| 552 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 553 | struct gsm_subscriber *subscr = |
| 554 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 555 | |
| 556 | if (!subscr) { |
| 557 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 558 | argv[0], argv[1], VTY_NEWLINE); |
| 559 | return CMD_WARNING; |
| 560 | } |
| 561 | |
| 562 | subscr_pending_dump(subscr, vty); |
| 563 | subscr_put(subscr); |
| 564 | |
| 565 | return CMD_SUCCESS; |
| 566 | } |
| 567 | |
Holger Hans Peter Freyther | 451eb29 | 2010-12-29 13:45:49 +0100 | [diff] [blame] | 568 | DEFUN(ena_subscr_kick, |
| 569 | ena_subscr_kick_cmd, |
| 570 | "subscriber " SUBSCR_TYPES " ID kick-pending", |
| 571 | SUBSCR_HELP "Clear the paging requests for this subscriber\n") |
| 572 | { |
| 573 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 574 | struct gsm_subscriber *subscr = |
| 575 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 576 | |
| 577 | if (!subscr) { |
| 578 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 579 | argv[0], argv[1], VTY_NEWLINE); |
| 580 | return CMD_WARNING; |
| 581 | } |
| 582 | |
| 583 | subscr_pending_kick(subscr); |
| 584 | subscr_put(subscr); |
| 585 | |
| 586 | return CMD_SUCCESS; |
| 587 | } |
| 588 | |
Holger Hans Peter Freyther | 4485321 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 589 | DEFUN(ena_subscr_handover, |
| 590 | ena_subscr_handover_cmd, |
| 591 | "subscriber " SUBSCR_TYPES " ID handover BTS_NR", |
| 592 | SUBSCR_HELP "Handover the active connection\n" |
| 593 | "Number of the BTS to handover to\n") |
| 594 | { |
| 595 | int ret; |
| 596 | struct gsm_subscriber_connection *conn; |
| 597 | struct gsm_bts *bts; |
| 598 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 599 | struct gsm_subscriber *subscr = |
| 600 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 601 | |
| 602 | if (!subscr) { |
| 603 | vty_out(vty, "%% No subscriber found for %s %s.%s", |
| 604 | argv[0], argv[1], VTY_NEWLINE); |
| 605 | return CMD_WARNING; |
| 606 | } |
| 607 | |
| 608 | conn = connection_for_subscr(subscr); |
| 609 | if (!conn) { |
| 610 | vty_out(vty, "%% No active connection for subscriber %s %s.%s", |
| 611 | argv[0], argv[1], VTY_NEWLINE); |
| 612 | subscr_put(subscr); |
| 613 | return CMD_WARNING; |
| 614 | } |
| 615 | |
| 616 | bts = gsm_bts_num(gsmnet, atoi(argv[2])); |
| 617 | if (!bts) { |
| 618 | vty_out(vty, "%% BTS with number(%d) could not be found.%s", |
| 619 | atoi(argv[2]), VTY_NEWLINE); |
| 620 | subscr_put(subscr); |
| 621 | return CMD_WARNING; |
| 622 | } |
| 623 | |
| 624 | /* now start the handover */ |
| 625 | ret = bsc_handover_start(conn->lchan, bts); |
| 626 | if (ret != 0) { |
| 627 | vty_out(vty, "%% Handover failed with errno %d.%s", |
| 628 | ret, VTY_NEWLINE); |
| 629 | } else { |
| 630 | vty_out(vty, "%% Handover started from %s", |
| 631 | gsm_lchan_name(conn->lchan)); |
| 632 | vty_out(vty, " to %s.%s", gsm_lchan_name(conn->ho_lchan), |
| 633 | VTY_NEWLINE); |
| 634 | } |
| 635 | |
| 636 | subscr_put(subscr); |
| 637 | return CMD_SUCCESS; |
| 638 | } |
| 639 | |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 640 | #define A3A8_ALG_TYPES "(none|xor|comp128v1)" |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 641 | #define A3A8_ALG_HELP \ |
| 642 | "Use No A3A8 algorithm\n" \ |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 643 | "Use XOR algorithm\n" \ |
Harald Welte | 2832606 | 2010-05-14 20:05:17 +0200 | [diff] [blame] | 644 | "Use COMP128v1 algorithm\n" |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 645 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 646 | DEFUN(ena_subscr_a3a8, |
| 647 | ena_subscr_a3a8_cmd, |
| 648 | "subscriber " SUBSCR_TYPES " ID a3a8 " A3A8_ALG_TYPES " [KI]", |
Harald Welte | d3cf85d | 2010-05-27 10:48:11 +0200 | [diff] [blame] | 649 | SUBSCR_HELP "Set a3a8 parameters for the subscriber\n" |
| 650 | A3A8_ALG_HELP "Encryption Key Ki\n") |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 651 | { |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 652 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 653 | struct gsm_subscriber *subscr = |
| 654 | get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 655 | const char *alg_str = argv[2]; |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 656 | const char *ki_str = argc == 4 ? argv[3] : NULL; |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 657 | struct gsm_auth_info ainfo; |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 658 | int rc, minlen, maxlen; |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 659 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 660 | if (!subscr) { |
| 661 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 662 | argv[0], argv[1], VTY_NEWLINE); |
| 663 | return CMD_WARNING; |
| 664 | } |
| 665 | |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 666 | if (!strcasecmp(alg_str, "none")) { |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 667 | ainfo.auth_algo = AUTH_ALGO_NONE; |
| 668 | minlen = maxlen = 0; |
| 669 | } else if (!strcasecmp(alg_str, "xor")) { |
| 670 | ainfo.auth_algo = AUTH_ALGO_XOR; |
| 671 | minlen = A38_XOR_MIN_KEY_LEN; |
| 672 | maxlen = A38_XOR_MAX_KEY_LEN; |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 673 | } else if (!strcasecmp(alg_str, "comp128v1")) { |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 674 | ainfo.auth_algo = AUTH_ALGO_COMP128v1; |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 675 | minlen = maxlen = A38_COMP128_KEY_LEN; |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 676 | } else { |
| 677 | /* Unknown method */ |
Holger Hans Peter Freyther | c02b120 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 678 | subscr_put(subscr); |
Pablo Neira Ayuso | ef1e587 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 679 | vty_out(vty, "%% Unknown auth method %s%s", |
| 680 | alg_str, VTY_NEWLINE); |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 681 | return CMD_WARNING; |
| 682 | } |
| 683 | |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 684 | if (ki_str) { |
Pablo Neira Ayuso | c0d17f2 | 2011-05-07 12:12:48 +0200 | [diff] [blame] | 685 | rc = osmo_hexparse(ki_str, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki)); |
Holger Hans Peter Freyther | c02b120 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 686 | if ((rc > maxlen) || (rc < minlen)) { |
| 687 | subscr_put(subscr); |
Pablo Neira Ayuso | ef1e587 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 688 | vty_out(vty, "%% Wrong Ki `%s'%s", |
| 689 | ki_str, VTY_NEWLINE); |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 690 | return CMD_WARNING; |
Holger Hans Peter Freyther | c02b120 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 691 | } |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 692 | ainfo.a3a8_ki_len = rc; |
| 693 | } else { |
| 694 | ainfo.a3a8_ki_len = 0; |
Holger Hans Peter Freyther | c02b120 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 695 | if (minlen) { |
| 696 | subscr_put(subscr); |
Pablo Neira Ayuso | ef1e587 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 697 | vty_out(vty, "%% Missing Ki argument%s", VTY_NEWLINE); |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 698 | return CMD_WARNING; |
Holger Hans Peter Freyther | c02b120 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 699 | } |
Sylvain Munaut | e824d9c | 2010-06-11 00:19:42 +0200 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | rc = db_sync_authinfo_for_subscr( |
| 703 | ainfo.auth_algo == AUTH_ALGO_NONE ? NULL : &ainfo, |
| 704 | subscr); |
| 705 | |
Sylvain Munaut | 0c873a0 | 2010-06-10 22:00:48 +0200 | [diff] [blame] | 706 | /* the last tuple probably invalid with the new auth settings */ |
| 707 | db_sync_lastauthtuple_for_subscr(NULL, subscr); |
Holger Hans Peter Freyther | c02b120 | 2010-12-28 22:26:34 +0100 | [diff] [blame] | 708 | subscr_put(subscr); |
Sylvain Munaut | 0c873a0 | 2010-06-10 22:00:48 +0200 | [diff] [blame] | 709 | |
Pablo Neira Ayuso | ef1e587 | 2011-05-03 22:44:39 +0200 | [diff] [blame] | 710 | if (rc) { |
| 711 | vty_out(vty, "%% Operation has failed%s", VTY_NEWLINE); |
| 712 | return CMD_WARNING; |
| 713 | } |
| 714 | return CMD_SUCCESS; |
Sylvain Munaut | 9979290 | 2009-12-27 19:30:46 +0100 | [diff] [blame] | 715 | } |
| 716 | |
Holger Hans Peter Freyther | c577ca1 | 2010-12-22 16:33:23 +0100 | [diff] [blame] | 717 | DEFUN(subscriber_purge, |
| 718 | subscriber_purge_cmd, |
| 719 | "subscriber purge-inactive", |
| 720 | "Operations on a Subscriber\n" "Purge subscribers with a zero use count.\n") |
| 721 | { |
| 722 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 723 | int purged; |
| 724 | |
| 725 | purged = subscr_purge_inactive(net); |
| 726 | vty_out(vty, "%d subscriber(s) were purged.%s", purged, VTY_NEWLINE); |
| 727 | return CMD_SUCCESS; |
| 728 | } |
| 729 | |
Holger Hans Peter Freyther | abd0cac | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 730 | DEFUN(subscriber_update, |
| 731 | subscriber_update_cmd, |
| 732 | "subscriber " SUBSCR_TYPES " ID update", |
| 733 | SUBSCR_HELP "Update the subscriber data from the dabase.\n") |
| 734 | { |
| 735 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 736 | struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); |
| 737 | |
| 738 | if (!subscr) { |
| 739 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 740 | argv[0], argv[1], VTY_NEWLINE); |
| 741 | return CMD_WARNING; |
| 742 | } |
| 743 | |
| 744 | subscr_update_from_db(subscr); |
| 745 | subscr_put(subscr); |
| 746 | return CMD_SUCCESS; |
| 747 | } |
| 748 | |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 749 | static int scall_cbfn(unsigned int subsys, unsigned int signal, |
| 750 | void *handler_data, void *signal_data) |
| 751 | { |
| 752 | struct scall_signal_data *sigdata = signal_data; |
| 753 | struct vty *vty = sigdata->data; |
| 754 | |
| 755 | switch (signal) { |
| 756 | case S_SCALL_SUCCESS: |
| 757 | vty_out(vty, "%% silent call on ARFCN %u timeslot %u%s", |
Holger Hans Peter Freyther | 86481c2 | 2010-06-17 15:05:57 +0800 | [diff] [blame] | 758 | sigdata->conn->lchan->ts->trx->arfcn, sigdata->conn->lchan->ts->nr, |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 759 | VTY_NEWLINE); |
| 760 | break; |
| 761 | case S_SCALL_EXPIRED: |
| 762 | vty_out(vty, "%% silent call expired paging%s", VTY_NEWLINE); |
| 763 | break; |
| 764 | } |
| 765 | return 0; |
| 766 | } |
| 767 | |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 768 | DEFUN(show_stats, |
| 769 | show_stats_cmd, |
| 770 | "show statistics", |
| 771 | SHOW_STR "Display network statistics\n") |
| 772 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 773 | struct gsm_network *net = gsmnet_from_vty(vty); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 774 | |
| 775 | openbsc_vty_print_statistics(vty, net); |
Harald Welte | 75e2def | 2010-12-24 15:48:09 +0100 | [diff] [blame] | 776 | vty_out(vty, "Channel Requests : %lu total, %lu no channel%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 777 | osmo_counter_get(net->stats.chreq.total), |
| 778 | osmo_counter_get(net->stats.chreq.no_channel), VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 779 | vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 780 | osmo_counter_get(net->stats.loc_upd_type.attach), |
| 781 | osmo_counter_get(net->stats.loc_upd_type.normal), |
| 782 | osmo_counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 783 | vty_out(vty, "IMSI Detach Indications : %lu%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 784 | osmo_counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 785 | vty_out(vty, "Location Update Response: %lu accept, %lu reject%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 786 | osmo_counter_get(net->stats.loc_upd_resp.accept), |
| 787 | osmo_counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 788 | vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, " |
| 789 | "%lu completed, %lu failed%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 790 | osmo_counter_get(net->stats.handover.attempted), |
| 791 | osmo_counter_get(net->stats.handover.no_channel), |
| 792 | osmo_counter_get(net->stats.handover.timeout), |
| 793 | osmo_counter_get(net->stats.handover.completed), |
| 794 | osmo_counter_get(net->stats.handover.failed), VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 795 | vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 796 | osmo_counter_get(net->stats.sms.submitted), |
| 797 | osmo_counter_get(net->stats.sms.no_receiver), VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 798 | vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 799 | osmo_counter_get(net->stats.sms.delivered), |
| 800 | osmo_counter_get(net->stats.sms.rp_err_mem), |
| 801 | osmo_counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE); |
Harald Welte | a29e43a | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 802 | vty_out(vty, "MO Calls : %lu setup, %lu connect ack%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 803 | osmo_counter_get(net->stats.call.mo_setup), |
| 804 | osmo_counter_get(net->stats.call.mo_connect_ack), VTY_NEWLINE); |
Harald Welte | a29e43a | 2010-12-24 16:06:33 +0100 | [diff] [blame] | 805 | vty_out(vty, "MT Calls : %lu setup, %lu connect%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 806 | osmo_counter_get(net->stats.call.mt_setup), |
| 807 | osmo_counter_get(net->stats.call.mt_connect), VTY_NEWLINE); |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 808 | return CMD_SUCCESS; |
| 809 | } |
| 810 | |
Holger Hans Peter Freyther | 81c0e25 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 811 | DEFUN(show_smsqueue, |
| 812 | show_smsqueue_cmd, |
| 813 | "show sms-queue", |
| 814 | SHOW_STR "Display SMSqueue statistics\n") |
| 815 | { |
| 816 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 817 | |
| 818 | sms_queue_stats(net->sms_queue, vty); |
| 819 | return CMD_SUCCESS; |
| 820 | } |
| 821 | |
Holger Hans Peter Freyther | 7a0e166 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 822 | DEFUN(smsqueue_trigger, |
| 823 | smsqueue_trigger_cmd, |
| 824 | "sms-queue trigger", |
| 825 | "SMS Queue\n" "Trigger sending messages\n") |
| 826 | { |
| 827 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 828 | |
| 829 | sms_queue_trigger(net->sms_queue); |
| 830 | return CMD_SUCCESS; |
| 831 | } |
Holger Hans Peter Freyther | e0ec326 | 2010-04-15 11:28:14 +0200 | [diff] [blame] | 832 | |
Holger Hans Peter Freyther | 3c6f6c2 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 833 | DEFUN(smsqueue_max, |
| 834 | smsqueue_max_cmd, |
| 835 | "sms-queue max-pending <1-500>", |
Holger Hans Peter Freyther | 3217fa2 | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 836 | "SMS Queue\n" "SMS to deliver in parallel\n" "Amount\n") |
Holger Hans Peter Freyther | 3c6f6c2 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 837 | { |
| 838 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 839 | |
| 840 | sms_queue_set_max_pending(net->sms_queue, atoi(argv[0])); |
| 841 | return CMD_SUCCESS; |
| 842 | } |
| 843 | |
Holger Hans Peter Freyther | 4dcc5e5 | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 844 | DEFUN(smsqueue_clear, |
| 845 | smsqueue_clear_cmd, |
| 846 | "sms-queue clear", |
| 847 | "SMS Queue\n" "Clear the queue of pending SMS\n") |
| 848 | { |
| 849 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 850 | |
| 851 | sms_queue_clear(net->sms_queue); |
| 852 | return CMD_SUCCESS; |
| 853 | } |
| 854 | |
Holger Hans Peter Freyther | 994dcbb | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 855 | DEFUN(smsqueue_fail, |
| 856 | smsqueue_fail_cmd, |
| 857 | "sms-queue max-failure <1-500>", |
Holger Hans Peter Freyther | 3217fa2 | 2012-07-20 23:55:08 +0200 | [diff] [blame] | 858 | "SMS Queue\n" "Maximum amount of delivery failures\n" "Amount\n") |
Holger Hans Peter Freyther | 994dcbb | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 859 | { |
| 860 | struct gsm_network *net = gsmnet_from_vty(vty); |
| 861 | |
| 862 | sms_queue_set_max_failure(net->sms_queue, atoi(argv[0])); |
| 863 | return CMD_SUCCESS; |
| 864 | } |
| 865 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 866 | |
| 867 | DEFUN(cfg_mncc_int, cfg_mncc_int_cmd, |
| 868 | "mncc-int", "Configure internal MNCC handler") |
| 869 | { |
| 870 | vty->node = MNCC_INT_NODE; |
| 871 | |
| 872 | return CMD_SUCCESS; |
| 873 | } |
| 874 | |
| 875 | static struct cmd_node mncc_int_node = { |
| 876 | MNCC_INT_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 877 | "%s(config-mncc-int)# ", |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 878 | 1, |
| 879 | }; |
| 880 | |
| 881 | static const struct value_string tchf_codec_names[] = { |
| 882 | { GSM48_CMODE_SPEECH_V1, "fr" }, |
| 883 | { GSM48_CMODE_SPEECH_EFR, "efr" }, |
| 884 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 885 | { 0, NULL } |
| 886 | }; |
| 887 | |
| 888 | static const struct value_string tchh_codec_names[] = { |
| 889 | { GSM48_CMODE_SPEECH_V1, "hr" }, |
| 890 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 891 | { 0, NULL } |
| 892 | }; |
| 893 | |
| 894 | static int config_write_mncc_int(struct vty *vty) |
| 895 | { |
| 896 | vty_out(vty, "mncc-int%s", VTY_NEWLINE); |
| 897 | vty_out(vty, " default-codec tch-f %s%s", |
| 898 | get_value_string(tchf_codec_names, mncc_int.def_codec[0]), |
| 899 | VTY_NEWLINE); |
| 900 | vty_out(vty, " default-codec tch-h %s%s", |
| 901 | get_value_string(tchh_codec_names, mncc_int.def_codec[1]), |
| 902 | VTY_NEWLINE); |
| 903 | |
| 904 | return CMD_SUCCESS; |
| 905 | } |
| 906 | |
| 907 | DEFUN(mnccint_def_codec_f, |
| 908 | mnccint_def_codec_f_cmd, |
| 909 | "default-codec tch-f (fr|efr|amr)", |
| 910 | "Set default codec\n" "Codec for TCH/F\n" |
| 911 | "Full-Rate\n" "Enhanced Full-Rate\n" "Adaptive Multi-Rate\n") |
| 912 | { |
| 913 | mncc_int.def_codec[0] = get_string_value(tchf_codec_names, argv[0]); |
| 914 | |
| 915 | return CMD_SUCCESS; |
| 916 | } |
| 917 | |
| 918 | DEFUN(mnccint_def_codec_h, |
| 919 | mnccint_def_codec_h_cmd, |
| 920 | "default-codec tch-h (hr|amr)", |
| 921 | "Set default codec\n" "Codec for TCH/H\n" |
| 922 | "Half-Rate\n" "Adaptive Multi-Rate\n") |
| 923 | { |
| 924 | mncc_int.def_codec[1] = get_string_value(tchh_codec_names, argv[0]); |
| 925 | |
| 926 | return CMD_SUCCESS; |
| 927 | } |
| 928 | |
Holger Hans Peter Freyther | 63b0e44 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 929 | #define OBSOLETE_MSG "Obsolete\n" |
Harald Welte | b02fc1e | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 930 | /* this is just for backwards compatibility as the sms code moved into |
| 931 | * libosmocore and old config files no longer parse... */ |
| 932 | DEFUN_DEPRECATED(log_level_sms, log_level_sms_cmd, |
| 933 | "logging level sms (everything|debug|info|notice|error|fatal)", |
Holger Hans Peter Freyther | 63b0e44 | 2013-03-03 09:32:08 +0100 | [diff] [blame] | 934 | ".HIDDEN\n" OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG |
| 935 | OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG) |
Harald Welte | b02fc1e | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 936 | { |
| 937 | vty_out(vty, "%% 'logging level sms' is now called 'logging level " |
| 938 | "lsms', please update your config %s", VTY_NEWLINE); |
| 939 | |
| 940 | return CMD_SUCCESS; |
| 941 | } |
| 942 | |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 943 | int bsc_vty_init_extra(void) |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 944 | { |
Pablo Neira Ayuso | bbc5b99 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 945 | osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL); |
Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 946 | |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 947 | install_element_ve(&show_subscr_cmd); |
| 948 | install_element_ve(&show_subscr_cache_cmd); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 949 | |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 950 | install_element_ve(&sms_send_pend_cmd); |
Harald Welte | 98f9c75 | 2009-11-14 08:00:53 +0100 | [diff] [blame] | 951 | |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 952 | install_element_ve(&subscriber_send_sms_cmd); |
| 953 | install_element_ve(&subscriber_silent_sms_cmd); |
| 954 | install_element_ve(&subscriber_silent_call_start_cmd); |
| 955 | install_element_ve(&subscriber_silent_call_stop_cmd); |
Holger Hans Peter Freyther | daf7534 | 2010-07-26 20:01:07 +0800 | [diff] [blame] | 956 | install_element_ve(&subscriber_ussd_notify_cmd); |
Holger Hans Peter Freyther | abd0cac | 2010-12-22 18:12:11 +0100 | [diff] [blame] | 957 | install_element_ve(&subscriber_update_cmd); |
Harald Welte | b4d5b17 | 2010-05-12 16:10:35 +0000 | [diff] [blame] | 958 | install_element_ve(&show_stats_cmd); |
Holger Hans Peter Freyther | 81c0e25 | 2010-12-25 14:08:00 +0100 | [diff] [blame] | 959 | install_element_ve(&show_smsqueue_cmd); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 960 | |
Harald Welte | b4a84e1 | 2010-05-27 10:44:58 +0200 | [diff] [blame] | 961 | install_element(ENABLE_NODE, &ena_subscr_name_cmd); |
| 962 | install_element(ENABLE_NODE, &ena_subscr_extension_cmd); |
| 963 | install_element(ENABLE_NODE, &ena_subscr_authorized_cmd); |
| 964 | install_element(ENABLE_NODE, &ena_subscr_a3a8_cmd); |
Holger Hans Peter Freyther | fc85741 | 2010-12-28 22:21:55 +0100 | [diff] [blame] | 965 | install_element(ENABLE_NODE, &ena_subscr_clear_cmd); |
Holger Hans Peter Freyther | 763b42a | 2010-12-29 11:07:22 +0100 | [diff] [blame] | 966 | install_element(ENABLE_NODE, &ena_subscr_pend_cmd); |
Holger Hans Peter Freyther | 451eb29 | 2010-12-29 13:45:49 +0100 | [diff] [blame] | 967 | install_element(ENABLE_NODE, &ena_subscr_kick_cmd); |
Holger Hans Peter Freyther | 4485321 | 2012-12-25 08:37:36 +0100 | [diff] [blame] | 968 | install_element(ENABLE_NODE, &ena_subscr_handover_cmd); |
Holger Hans Peter Freyther | c577ca1 | 2010-12-22 16:33:23 +0100 | [diff] [blame] | 969 | install_element(ENABLE_NODE, &subscriber_purge_cmd); |
Holger Hans Peter Freyther | 7a0e166 | 2010-12-25 14:15:32 +0100 | [diff] [blame] | 970 | install_element(ENABLE_NODE, &smsqueue_trigger_cmd); |
Holger Hans Peter Freyther | 3c6f6c2 | 2010-12-25 14:25:12 +0100 | [diff] [blame] | 971 | install_element(ENABLE_NODE, &smsqueue_max_cmd); |
Holger Hans Peter Freyther | 4dcc5e5 | 2010-12-25 14:38:30 +0100 | [diff] [blame] | 972 | install_element(ENABLE_NODE, &smsqueue_clear_cmd); |
Holger Hans Peter Freyther | 994dcbb | 2010-12-25 14:50:50 +0100 | [diff] [blame] | 973 | install_element(ENABLE_NODE, &smsqueue_fail_cmd); |
Nico Golde | b62b123 | 2011-02-22 17:54:47 +0100 | [diff] [blame] | 974 | install_element(ENABLE_NODE, &subscriber_send_pending_sms_cmd); |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 975 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 976 | install_element(CONFIG_NODE, &cfg_mncc_int_cmd); |
| 977 | install_node(&mncc_int_node, config_write_mncc_int); |
Jacob Erlbeck | 0ae92a9 | 2013-09-02 13:17:16 +0200 | [diff] [blame] | 978 | bsc_install_default(MNCC_INT_NODE); |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 979 | install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd); |
| 980 | install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd); |
| 981 | |
Harald Welte | b02fc1e | 2013-02-12 11:15:49 +0100 | [diff] [blame] | 982 | install_element(CFG_LOG_NODE, &log_level_sms_cmd); |
| 983 | |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 984 | return 0; |
| 985 | } |