blob: 1761ebc6cedee358d8cda9cb0ec1be1d42a0a734 [file] [log] [blame]
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +02001/* OpenBSC interface to quagga VTY */
2/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther0e7d0712011-04-18 17:15:53 +02003 * (C) 2009-2011 by Holger Hans Peter Freyther
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +02004 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01007 * 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 Freythercfa90d42009-08-10 10:17:50 +02009 * (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 Welte9af6ddf2011-01-01 15:25:50 +010014 * GNU Affero General Public License for more details.
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020015 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010016 * 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 Freythercfa90d42009-08-10 10:17:50 +020018 *
19 */
20
21#include <stdlib.h>
Holger Hans Peter Freyther73b878a2010-12-25 00:33:40 +010022#include <limits.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020023#include <unistd.h>
Holger Hans Peter Freytherb9708942013-07-27 19:42:35 +020024#include <time.h>
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020025#include <inttypes.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020026
Harald Welte4b037e42010-05-19 19:45:32 +020027#include <osmocom/vty/command.h>
28#include <osmocom/vty/buffer.h>
29#include <osmocom/vty/vty.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020030
31#include <arpa/inet.h>
32
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010033#include <osmocom/core/linuxlist.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020034#include <openbsc/gsm_data.h>
35#include <openbsc/gsm_subscriber.h>
Neels Hofmeyr6d804b12017-02-18 22:20:46 +010036#include <openbsc/bsc_subscriber.h>
Harald Welteb54d9502009-11-17 06:00:23 +010037#include <openbsc/silent_call.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020038#include <openbsc/gsm_04_11.h>
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020039#include <osmocom/abis/e1_input.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020040#include <openbsc/abis_nm.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010041#include <osmocom/gsm/gsm_utils.h>
42#include <osmocom/core/utils.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020043#include <openbsc/db.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010044#include <osmocom/core/talloc.h>
Harald Weltea1482332009-11-14 10:08:40 +010045#include <openbsc/signal.h>
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010046#include <openbsc/debug.h>
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +020047#include <openbsc/vty.h>
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +080048#include <openbsc/gsm_04_80.h>
49#include <openbsc/chan_alloc.h>
Holger Hans Peter Freyther81c0e252010-12-25 14:08:00 +010050#include <openbsc/sms_queue.h>
Harald Welteab386e62011-09-01 18:18:43 +020051#include <openbsc/mncc_int.h>
Holger Hans Peter Freyther44853212012-12-25 08:37:36 +010052#include <openbsc/handover.h>
Harald Welte2483f1b2016-06-19 18:06:02 +020053#include <openbsc/vlr.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020054
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +010055#include <osmocom/vty/logging.h>
56
Harald Welte2483f1b2016-06-19 18:06:02 +020057#include <openbsc/osmo_msc.h>
58
Harald Welteb4771a62012-11-11 10:58:51 +010059#include "meas_feed.h"
60
Harald Weltedcccb182010-05-16 20:52:23 +020061extern struct gsm_network *gsmnet_from_vty(struct vty *v);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020062
Harald Welte2483f1b2016-06-19 18:06:02 +020063static void subscr_dump_full_vty(struct vty *vty, struct vlr_subscr *vsub)
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010064{
Holger Hans Peter Freytherc9dbe3c2015-08-04 13:18:47 +020065 int reqs;
Holger Hans Peter Freytherc9dbe3c2015-08-04 13:18:47 +020066 struct llist_head *entry;
Holger Hans Peter Freytherb9708942013-07-27 19:42:35 +020067 char expire_time[200];
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010068
Harald Welte2483f1b2016-06-19 18:06:02 +020069 if (strlen(vsub->name))
70 vty_out(vty, " Name: '%s'%s", vsub->name, VTY_NEWLINE);
71 if (strlen(vsub->msisdn))
72 vty_out(vty, " Extension: %s%s", vsub->msisdn,
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010073 VTY_NEWLINE);
Holger Hans Peter Freyther3d76e442010-12-25 16:40:54 +010074 vty_out(vty, " LAC: %d/0x%x%s",
Harald Welte2483f1b2016-06-19 18:06:02 +020075 vsub->lac, vsub->lac, VTY_NEWLINE);
76 vty_out(vty, " IMSI: %s%s", vsub->imsi, VTY_NEWLINE);
77 if (vsub->tmsi != GSM_RESERVED_TMSI)
78 vty_out(vty, " TMSI: %08X%s", vsub->tmsi,
79 VTY_NEWLINE);
80 if (vsub->tmsi_new != GSM_RESERVED_TMSI)
81 vty_out(vty, " new TMSI: %08X%s", vsub->tmsi_new,
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010082 VTY_NEWLINE);
83
Harald Welte2483f1b2016-06-19 18:06:02 +020084#if 0
85 /* TODO: add this to vlr_subscr? */
86 if (vsub->auth_info.auth_algo != AUTH_ALGO_NONE) {
87 struct gsm_auth_info *i = &vsub->auth_info;
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010088 vty_out(vty, " A3A8 algorithm id: %d%s",
Harald Welte2483f1b2016-06-19 18:06:02 +020089 i->auth_algo, VTY_NEWLINE);
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010090 vty_out(vty, " A3A8 Ki: %s%s",
Harald Welte2483f1b2016-06-19 18:06:02 +020091 osmo_hexdump(i->a3a8_ki, i->a3a8_ki_len),
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010092 VTY_NEWLINE);
93 }
Harald Welte2483f1b2016-06-19 18:06:02 +020094#endif
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010095
Harald Welte2483f1b2016-06-19 18:06:02 +020096 if (vsub->last_tuple) {
97 struct gsm_auth_tuple *t = vsub->last_tuple;
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010098 vty_out(vty, " A3A8 last tuple (used %d times):%s",
Harald Welte2483f1b2016-06-19 18:06:02 +020099 t->use_count, VTY_NEWLINE);
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100100 vty_out(vty, " seq # : %d%s",
Harald Welte2483f1b2016-06-19 18:06:02 +0200101 t->key_seq, VTY_NEWLINE);
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100102 vty_out(vty, " RAND : %s%s",
Harald Welte2483f1b2016-06-19 18:06:02 +0200103 osmo_hexdump(t->vec.rand, sizeof(t->vec.rand)),
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100104 VTY_NEWLINE);
105 vty_out(vty, " SRES : %s%s",
Harald Welte2483f1b2016-06-19 18:06:02 +0200106 osmo_hexdump(t->vec.sres, sizeof(t->vec.sres)),
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100107 VTY_NEWLINE);
108 vty_out(vty, " Kc : %s%s",
Harald Welte2483f1b2016-06-19 18:06:02 +0200109 osmo_hexdump(t->vec.kc, sizeof(t->vec.kc)),
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100110 VTY_NEWLINE);
111 }
Holger Hans Peter Freytherb9708942013-07-27 19:42:35 +0200112
113 /* print the expiration time of a subscriber */
114 strftime(expire_time, sizeof(expire_time),
Harald Welte2483f1b2016-06-19 18:06:02 +0200115 "%a, %d %b %Y %T %z", localtime(&vsub->expire_lu));
Holger Hans Peter Freytherb9708942013-07-27 19:42:35 +0200116 expire_time[sizeof(expire_time) - 1] = '\0';
117 vty_out(vty, " Expiration Time: %s%s", expire_time, VTY_NEWLINE);
Holger Hans Peter Freytherc9dbe3c2015-08-04 13:18:47 +0200118
119 reqs = 0;
Harald Welte2483f1b2016-06-19 18:06:02 +0200120 llist_for_each(entry, &vsub->cs.requests)
Holger Hans Peter Freytherc9dbe3c2015-08-04 13:18:47 +0200121 reqs += 1;
Harald Welte2483f1b2016-06-19 18:06:02 +0200122 vty_out(vty, " Paging: %s paging for %d requests%s",
123 vsub->cs.is_paging ? "is" : "not", reqs, VTY_NEWLINE);
124 vty_out(vty, " Use count: %u%s", vsub->use_count, VTY_NEWLINE);
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100125}
126
127
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200128/* Subscriber */
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200129DEFUN(show_subscr_cache,
130 show_subscr_cache_cmd,
131 "show subscriber cache",
Harald Weltecfaabbb2012-08-16 23:23:50 +0200132 SHOW_STR "Show information about subscribers\n"
133 "Display contents of subscriber cache\n")
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200134{
Harald Welte2483f1b2016-06-19 18:06:02 +0200135 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
136 struct vlr_subscr *vsub;
137 int count = 0;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200138
Harald Welte2483f1b2016-06-19 18:06:02 +0200139 llist_for_each_entry(vsub, &gsmnet->vlr->subscribers, list) {
140 if (++count > 100) {
141 vty_out(vty, "%% More than %d subscribers in cache,"
142 " stopping here.%s", count-1, VTY_NEWLINE);
143 break;
144 }
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200145 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Harald Welte2483f1b2016-06-19 18:06:02 +0200146 subscr_dump_full_vty(vty, vsub);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200147 }
148
149 return CMD_SUCCESS;
150}
151
152DEFUN(sms_send_pend,
153 sms_send_pend_cmd,
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100154 "sms send pending",
Neels Hofmeyrd1fdefe2016-04-01 02:17:24 +0200155 "SMS related commands\n" "SMS Sending related commands\n"
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100156 "Send all pending SMS")
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200157{
Harald Weltedcccb182010-05-16 20:52:23 +0200158 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200159 struct gsm_sms *sms;
Harald Welte2483f1b2016-06-19 18:06:02 +0200160 unsigned long long sms_id = 0;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200161
162 while (1) {
Harald Welte2483f1b2016-06-19 18:06:02 +0200163 sms = db_sms_get_next_unsent(gsmnet, sms_id, UINT_MAX);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200164 if (!sms)
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100165 break;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200166
Harald Welte2483f1b2016-06-19 18:06:02 +0200167 if (sms->receiver)
168 gsm411_send_sms_subscr(sms->receiver, sms);
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100169
Harald Welte2483f1b2016-06-19 18:06:02 +0200170 sms_id = sms->id + 1;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200171 }
172
173 return CMD_SUCCESS;
174}
175
Harald Welte2483f1b2016-06-19 18:06:02 +0200176static int _send_sms_str(struct vlr_subscr *receiver,
177 struct vlr_subscr *sender,
178 char *str, uint8_t tp_pid)
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200179{
Harald Welte2483f1b2016-06-19 18:06:02 +0200180 struct gsm_network *net = receiver->vlr->user_ctx;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200181 struct gsm_sms *sms;
182
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100183 sms = sms_from_text(receiver, sender, 0, str);
Harald Welte793a1352009-11-05 15:51:17 +0900184 sms->protocol_id = tp_pid;
Nico Golde59502362010-06-29 20:13:06 +0200185
Holger Hans Peter Freyther445e6152010-12-25 15:57:34 +0100186 /* store in database for the queue */
187 if (db_sms_store(sms) != 0) {
Holger Hans Peter Freythereff409492012-11-10 19:46:58 +0100188 LOGP(DLSMS, LOGL_ERROR, "Failed to store SMS in Database\n");
Holger Hans Peter Freyther445e6152010-12-25 15:57:34 +0100189 sms_free(sms);
190 return CMD_WARNING;
Nico Golde59502362010-06-29 20:13:06 +0200191 }
Neels Hofmeyr1e918c32016-05-09 21:48:53 +0200192 LOGP(DLSMS, LOGL_DEBUG, "SMS stored in DB\n");
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200193
Holger Hans Peter Freyther445e6152010-12-25 15:57:34 +0100194 sms_free(sms);
Harald Welte2483f1b2016-06-19 18:06:02 +0200195 sms_queue_trigger(net->sms_queue);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200196 return CMD_SUCCESS;
197}
198
Harald Welte2483f1b2016-06-19 18:06:02 +0200199static struct vlr_subscr *get_vsub_by_argv(struct gsm_network *gsmnet,
200 const char *type,
201 const char *id)
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200202{
Harald Welte2483f1b2016-06-19 18:06:02 +0200203 if (!strcmp(type, "extension") || !strcmp(type, "msisdn"))
204 return vlr_subscr_find_by_msisdn(gsmnet->vlr, id);
205 else if (!strcmp(type, "imsi") || !strcmp(type, "id"))
206 return vlr_subscr_find_by_imsi(gsmnet->vlr, id);
Harald Welte98f9c752009-11-14 08:00:53 +0100207 else if (!strcmp(type, "tmsi"))
Harald Welte2483f1b2016-06-19 18:06:02 +0200208 return vlr_subscr_find_by_tmsi(gsmnet->vlr, atoi(id));
Harald Welte98f9c752009-11-14 08:00:53 +0100209
210 return NULL;
211}
212#define SUBSCR_TYPES "(extension|imsi|tmsi|id)"
Harald Welte28326062010-05-14 20:05:17 +0200213#define SUBSCR_HELP "Operations on a Subscriber\n" \
Neels Hofmeyrd1fdefe2016-04-01 02:17:24 +0200214 "Identify subscriber by extension (phone number)\n" \
215 "Identify subscriber by IMSI\n" \
216 "Identify subscriber by TMSI\n" \
217 "Identify subscriber by database ID\n" \
Harald Welte28326062010-05-14 20:05:17 +0200218 "Identifier for the subscriber\n"
Harald Welte98f9c752009-11-14 08:00:53 +0100219
Harald Welteb4a84e12010-05-27 10:44:58 +0200220DEFUN(show_subscr,
221 show_subscr_cmd,
222 "show subscriber " SUBSCR_TYPES " ID",
223 SHOW_STR SUBSCR_HELP)
224{
225 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200226 struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0],
227 argv[1]);
Harald Welteb4a84e12010-05-27 10:44:58 +0200228
Harald Welte2483f1b2016-06-19 18:06:02 +0200229 if (!vsub) {
Harald Welteb4a84e12010-05-27 10:44:58 +0200230 vty_out(vty, "%% No subscriber found for %s %s%s",
231 argv[0], argv[1], VTY_NEWLINE);
232 return CMD_WARNING;
233 }
234
Harald Welte2483f1b2016-06-19 18:06:02 +0200235 subscr_dump_full_vty(vty, vsub);
Harald Welteb4a84e12010-05-27 10:44:58 +0200236
Harald Welte2483f1b2016-06-19 18:06:02 +0200237 vlr_subscr_put(vsub);
Harald Welteb4a84e12010-05-27 10:44:58 +0200238
239 return CMD_SUCCESS;
240}
241
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200242DEFUN(subscriber_create,
243 subscriber_create_cmd,
244 "subscriber create imsi ID",
245 "Operations on a Subscriber\n" \
246 "Create new subscriber\n" \
247 "Identify the subscriber by his IMSI\n" \
248 "Identifier for the subscriber\n")
249{
Harald Welte2483f1b2016-06-19 18:06:02 +0200250 vty_out(vty, "%% 'subscriber create' now needs to be done at osmo-hlr%s",
251 VTY_NEWLINE);
252 return CMD_WARNING;
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200253}
254
Nico Goldeb62b1232011-02-22 17:54:47 +0100255DEFUN(subscriber_send_pending_sms,
256 subscriber_send_pending_sms_cmd,
Holger Hans Peter Freyther3217fa22012-07-20 23:55:08 +0200257 "subscriber " SUBSCR_TYPES " ID sms pending-send",
Nico Goldeb62b1232011-02-22 17:54:47 +0100258 SUBSCR_HELP "SMS Operations\n" "Send pending SMS\n")
259{
260 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200261 struct vlr_subscr *vsub;
Nico Goldeb62b1232011-02-22 17:54:47 +0100262 struct gsm_sms *sms;
263
Harald Welte2483f1b2016-06-19 18:06:02 +0200264 vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
265 if (!vsub) {
Holger Hans Peter Freyther9feef482013-07-04 20:34:46 +0200266 vty_out(vty, "%% No subscriber found for %s %s%s",
267 argv[0], argv[1], VTY_NEWLINE);
268 return CMD_WARNING;
269 }
270
Harald Welte2483f1b2016-06-19 18:06:02 +0200271 sms = db_sms_get_unsent_for_subscr(vsub, UINT_MAX);
Nico Goldeb62b1232011-02-22 17:54:47 +0100272 if (sms)
273 gsm411_send_sms_subscr(sms->receiver, sms);
274
Harald Welte2483f1b2016-06-19 18:06:02 +0200275 vlr_subscr_put(vsub);
Nico Goldeb62b1232011-02-22 17:54:47 +0100276
277 return CMD_SUCCESS;
278}
279
Harald Welte98f9c752009-11-14 08:00:53 +0100280DEFUN(subscriber_send_sms,
281 subscriber_send_sms_cmd,
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100282 "subscriber " SUBSCR_TYPES " ID sms sender " SUBSCR_TYPES " SENDER_ID send .LINE",
Holger Hans Peter Freyther63b0e442013-03-03 09:32:08 +0100283 SUBSCR_HELP "SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS Text\n")
Harald Welte98f9c752009-11-14 08:00:53 +0100284{
Harald Weltedcccb182010-05-16 20:52:23 +0200285 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200286 struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
287 struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]);
Harald Welte20474ad2010-05-16 19:28:32 +0200288 char *str;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200289 int rc;
290
Harald Welte2483f1b2016-06-19 18:06:02 +0200291 if (!vsub) {
Harald Welte20f98312009-11-14 10:11:45 +0100292 vty_out(vty, "%% No subscriber found for %s %s%s",
293 argv[0], argv[1], VTY_NEWLINE);
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100294 rc = CMD_WARNING;
295 goto err;
Harald Welte20f98312009-11-14 10:11:45 +0100296 }
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100297
298 if (!sender) {
299 vty_out(vty, "%% No sender found for %s %s%s",
300 argv[2], argv[3], VTY_NEWLINE);
301 rc = CMD_WARNING;
302 goto err;
303 }
304
305 str = argv_concat(argv, argc, 4);
Harald Welte2483f1b2016-06-19 18:06:02 +0200306 rc = _send_sms_str(vsub, sender, str, 0);
Harald Welte20474ad2010-05-16 19:28:32 +0200307 talloc_free(str);
Harald Welte793a1352009-11-05 15:51:17 +0900308
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100309err:
310 if (sender)
Harald Welte2483f1b2016-06-19 18:06:02 +0200311 vlr_subscr_put(sender);
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100312
Harald Welte2483f1b2016-06-19 18:06:02 +0200313 if (vsub)
314 vlr_subscr_put(vsub);
Harald Welteaf8c7b42009-11-14 10:10:54 +0100315
Harald Welte793a1352009-11-05 15:51:17 +0900316 return rc;
317}
318
Harald Welte98f9c752009-11-14 08:00:53 +0100319DEFUN(subscriber_silent_sms,
320 subscriber_silent_sms_cmd,
Harald Welte1011d5b2014-07-10 20:19:00 +0200321
322 "subscriber " SUBSCR_TYPES " ID silent-sms sender " SUBSCR_TYPES " SENDER_ID send .LINE",
323 SUBSCR_HELP "Silent SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS Text\n")
Harald Welte793a1352009-11-05 15:51:17 +0900324{
Harald Weltedcccb182010-05-16 20:52:23 +0200325 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200326 struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
327 struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]);
Harald Welte20474ad2010-05-16 19:28:32 +0200328 char *str;
Harald Welte793a1352009-11-05 15:51:17 +0900329 int rc;
330
Harald Welte2483f1b2016-06-19 18:06:02 +0200331 if (!vsub) {
Harald Welte20f98312009-11-14 10:11:45 +0100332 vty_out(vty, "%% No subscriber found for %s %s%s",
333 argv[0], argv[1], VTY_NEWLINE);
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100334 rc = CMD_WARNING;
335 goto err;
Harald Welte20f98312009-11-14 10:11:45 +0100336 }
Harald Welte793a1352009-11-05 15:51:17 +0900337
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100338 if (!sender) {
339 vty_out(vty, "%% No sender found for %s %s%s",
340 argv[2], argv[3], VTY_NEWLINE);
341 rc = CMD_WARNING;
342 goto err;
343 }
344
345 str = argv_concat(argv, argc, 4);
Harald Welte2483f1b2016-06-19 18:06:02 +0200346 rc = _send_sms_str(vsub, sender, str, 64);
Harald Welte20474ad2010-05-16 19:28:32 +0200347 talloc_free(str);
Harald Welte793a1352009-11-05 15:51:17 +0900348
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100349err:
350 if (sender)
Harald Welte2483f1b2016-06-19 18:06:02 +0200351 vlr_subscr_put(sender);
Sylvain Munaut01c13a32012-12-28 00:49:01 +0100352
Harald Welte2483f1b2016-06-19 18:06:02 +0200353 if (vsub)
354 vlr_subscr_put(vsub);
Harald Welteaf8c7b42009-11-14 10:10:54 +0100355
Harald Welte793a1352009-11-05 15:51:17 +0900356 return rc;
357}
358
Harald Welte28326062010-05-14 20:05:17 +0200359#define CHAN_TYPES "(any|tch/f|tch/any|sdcch)"
360#define CHAN_TYPE_HELP \
361 "Any channel\n" \
362 "TCH/F channel\n" \
363 "Any TCH channel\n" \
364 "SDCCH channel\n"
365
Sylvain Munaut50480702010-01-02 14:29:43 +0100366DEFUN(subscriber_silent_call_start,
367 subscriber_silent_call_start_cmd,
Harald Welteb4a84e12010-05-27 10:44:58 +0200368 "subscriber " SUBSCR_TYPES " ID silent-call start (any|tch/f|tch/any|sdcch)",
Harald Welte28326062010-05-14 20:05:17 +0200369 SUBSCR_HELP "Silent call operation\n" "Start silent call\n"
370 CHAN_TYPE_HELP)
Sylvain Munaut50480702010-01-02 14:29:43 +0100371{
Harald Weltedcccb182010-05-16 20:52:23 +0200372 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200373 struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
Sylvain Munaut50480702010-01-02 14:29:43 +0100374 int rc, type;
375
Harald Welte2483f1b2016-06-19 18:06:02 +0200376 if (!vsub) {
Sylvain Munaut50480702010-01-02 14:29:43 +0100377 vty_out(vty, "%% No subscriber found for %s %s%s",
378 argv[0], argv[1], VTY_NEWLINE);
379 return CMD_WARNING;
380 }
381
382 if (!strcmp(argv[2], "tch/f"))
383 type = RSL_CHANNEED_TCH_F;
384 else if (!strcmp(argv[2], "tch/any"))
385 type = RSL_CHANNEED_TCH_ForH;
386 else if (!strcmp(argv[2], "sdcch"))
387 type = RSL_CHANNEED_SDCCH;
388 else
389 type = RSL_CHANNEED_ANY; /* Defaults to ANY */
390
Harald Welte2483f1b2016-06-19 18:06:02 +0200391 rc = gsm_silent_call_start(vsub, vty, type);
Sylvain Munaut50480702010-01-02 14:29:43 +0100392 if (rc <= 0) {
393 vty_out(vty, "%% Subscriber not attached%s",
394 VTY_NEWLINE);
Harald Welte2483f1b2016-06-19 18:06:02 +0200395 vlr_subscr_put(vsub);
Sylvain Munaut50480702010-01-02 14:29:43 +0100396 return CMD_WARNING;
397 }
398
Harald Welte2483f1b2016-06-19 18:06:02 +0200399 vlr_subscr_put(vsub);
Sylvain Munaut50480702010-01-02 14:29:43 +0100400
401 return CMD_SUCCESS;
402}
403
404DEFUN(subscriber_silent_call_stop,
405 subscriber_silent_call_stop_cmd,
Harald Welteb4a84e12010-05-27 10:44:58 +0200406 "subscriber " SUBSCR_TYPES " ID silent-call stop",
Harald Welte28326062010-05-14 20:05:17 +0200407 SUBSCR_HELP "Silent call operation\n" "Stop silent call\n"
408 CHAN_TYPE_HELP)
Harald Weltea1482332009-11-14 10:08:40 +0100409{
Harald Weltedcccb182010-05-16 20:52:23 +0200410 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200411 struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
Harald Weltea1482332009-11-14 10:08:40 +0100412 int rc;
413
Harald Welte2483f1b2016-06-19 18:06:02 +0200414 if (!vsub) {
Harald Weltea1482332009-11-14 10:08:40 +0100415 vty_out(vty, "%% No subscriber found for %s %s%s",
Harald Welte20f98312009-11-14 10:11:45 +0100416 argv[0], argv[1], VTY_NEWLINE);
Harald Weltea1482332009-11-14 10:08:40 +0100417 return CMD_WARNING;
418 }
419
Harald Welte2483f1b2016-06-19 18:06:02 +0200420 rc = gsm_silent_call_stop(vsub);
Sylvain Munaut50480702010-01-02 14:29:43 +0100421 if (rc < 0) {
Harald Welte2483f1b2016-06-19 18:06:02 +0200422 vlr_subscr_put(vsub);
Sylvain Munaut50480702010-01-02 14:29:43 +0100423 return CMD_WARNING;
Harald Weltea1482332009-11-14 10:08:40 +0100424 }
425
Harald Welte2483f1b2016-06-19 18:06:02 +0200426 vlr_subscr_put(vsub);
Harald Weltea1482332009-11-14 10:08:40 +0100427
428 return CMD_SUCCESS;
429}
430
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800431DEFUN(subscriber_ussd_notify,
432 subscriber_ussd_notify_cmd,
Holger Hans Peter Freythere731e1d2010-07-27 18:27:46 +0800433 "subscriber " SUBSCR_TYPES " ID ussd-notify (0|1|2) .TEXT",
Harald Weltecfaabbb2012-08-16 23:23:50 +0200434 SUBSCR_HELP "Send a USSD notify to the subscriber\n"
Harald Weltecfaabbb2012-08-16 23:23:50 +0200435 "Alerting Level 0\n"
436 "Alerting Level 1\n"
437 "Alerting Level 2\n"
438 "Text of USSD message to send\n")
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800439{
440 char *text;
441 struct gsm_subscriber_connection *conn;
442 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200443 struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]);
Holger Hans Peter Freythere731e1d2010-07-27 18:27:46 +0800444 int level;
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800445
Harald Welte2483f1b2016-06-19 18:06:02 +0200446 if (!vsub) {
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800447 vty_out(vty, "%% No subscriber found for %s %s%s",
448 argv[0], argv[1], VTY_NEWLINE);
449 return CMD_WARNING;
450 }
451
Holger Hans Peter Freythere731e1d2010-07-27 18:27:46 +0800452 level = atoi(argv[2]);
453 text = argv_concat(argv, argc, 3);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800454 if (!text) {
Harald Welte2483f1b2016-06-19 18:06:02 +0200455 vlr_subscr_put(vsub);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800456 return CMD_WARNING;
457 }
458
Harald Welte2483f1b2016-06-19 18:06:02 +0200459 conn = connection_for_subscr(vsub);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800460 if (!conn) {
461 vty_out(vty, "%% An active connection is required for %s %s%s",
462 argv[0], argv[1], VTY_NEWLINE);
Harald Welte2483f1b2016-06-19 18:06:02 +0200463 vlr_subscr_put(vsub);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800464 talloc_free(text);
465 return CMD_WARNING;
466 }
467
Neels Hofmeyr43273c62016-05-10 12:50:31 +0200468 msc_send_ussd_notify(conn, level, text);
469 msc_send_ussd_release_complete(conn);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800470
Harald Welte2483f1b2016-06-19 18:06:02 +0200471 vlr_subscr_put(vsub);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800472 talloc_free(text);
473 return CMD_SUCCESS;
474}
475
Keithd32b6d12017-01-18 17:09:33 +0100476DEFUN(ena_subscr_expire,
477 ena_subscr_expire_cmd,
478 "subscriber " SUBSCR_TYPES " ID expire",
479 SUBSCR_HELP "Expire the subscriber Now\n")
480{
Keithd32b6d12017-01-18 17:09:33 +0100481 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte2483f1b2016-06-19 18:06:02 +0200482 struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0],
483 argv[1]);
Keithd32b6d12017-01-18 17:09:33 +0100484
Harald Welte2483f1b2016-06-19 18:06:02 +0200485 if (!vsub) {
Keithd32b6d12017-01-18 17:09:33 +0100486 vty_out(vty, "%% No subscriber found for %s %s%s",
487 argv[0], argv[1], VTY_NEWLINE);
488 return CMD_WARNING;
489 }
490
Harald Welte2483f1b2016-06-19 18:06:02 +0200491 if (vsub->lu_complete) {
492 vsub->lu_complete = false;
493 vlr_subscr_put(vsub);
494 vty_out(vty, "%% VLR released subscriber %s%s",
495 vlr_subscr_name(vsub), VTY_NEWLINE);
496 }
Keithd32b6d12017-01-18 17:09:33 +0100497
Harald Welte2483f1b2016-06-19 18:06:02 +0200498 if (vsub->use_count > 1)
499 vty_out(vty, "%% Subscriber %s is still in use,"
500 " should be released soon%s",
501 vlr_subscr_name(vsub), VTY_NEWLINE);
502
503 vlr_subscr_put(vsub);
Keithd32b6d12017-01-18 17:09:33 +0100504 return CMD_SUCCESS;
505}
506
Sylvain Munaute824d9c2010-06-11 00:19:42 +0200507#define A3A8_ALG_TYPES "(none|xor|comp128v1)"
Harald Welte28326062010-05-14 20:05:17 +0200508#define A3A8_ALG_HELP \
509 "Use No A3A8 algorithm\n" \
Sylvain Munaute824d9c2010-06-11 00:19:42 +0200510 "Use XOR algorithm\n" \
Harald Welte28326062010-05-14 20:05:17 +0200511 "Use COMP128v1 algorithm\n"
Sylvain Munaut99792902009-12-27 19:30:46 +0100512
Harald Welteb4a84e12010-05-27 10:44:58 +0200513DEFUN(ena_subscr_a3a8,
514 ena_subscr_a3a8_cmd,
515 "subscriber " SUBSCR_TYPES " ID a3a8 " A3A8_ALG_TYPES " [KI]",
Harald Welted3cf85d2010-05-27 10:48:11 +0200516 SUBSCR_HELP "Set a3a8 parameters for the subscriber\n"
517 A3A8_ALG_HELP "Encryption Key Ki\n")
Sylvain Munaut99792902009-12-27 19:30:46 +0100518{
Harald Welte2483f1b2016-06-19 18:06:02 +0200519 vty_out(vty, "%% 'subscriber a3a8' is no longer supported.%s"
520 "%% This is now up to osmo-hlr.%s",
521 VTY_NEWLINE, VTY_NEWLINE);
522 return CMD_WARNING;
Sylvain Munaut99792902009-12-27 19:30:46 +0100523}
524
Holger Hans Peter Freytherabd0cac2010-12-22 18:12:11 +0100525DEFUN(subscriber_update,
526 subscriber_update_cmd,
527 "subscriber " SUBSCR_TYPES " ID update",
528 SUBSCR_HELP "Update the subscriber data from the dabase.\n")
529{
Harald Welte2483f1b2016-06-19 18:06:02 +0200530 vty_out(vty, "%% 'subscriber update' is no longer supported.%s",
531 VTY_NEWLINE);
532 return CMD_WARNING;
Holger Hans Peter Freytherabd0cac2010-12-22 18:12:11 +0100533}
534
Harald Weltea1482332009-11-14 10:08:40 +0100535static int scall_cbfn(unsigned int subsys, unsigned int signal,
536 void *handler_data, void *signal_data)
537{
538 struct scall_signal_data *sigdata = signal_data;
539 struct vty *vty = sigdata->data;
540
541 switch (signal) {
542 case S_SCALL_SUCCESS:
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200543 vty_out(vty, "%% silent call success%s", VTY_NEWLINE);
Harald Weltea1482332009-11-14 10:08:40 +0100544 break;
545 case S_SCALL_EXPIRED:
546 vty_out(vty, "%% silent call expired paging%s", VTY_NEWLINE);
547 break;
548 }
549 return 0;
550}
551
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200552DEFUN(show_stats,
553 show_stats_cmd,
554 "show statistics",
555 SHOW_STR "Display network statistics\n")
556{
Harald Weltedcccb182010-05-16 20:52:23 +0200557 struct gsm_network *net = gsmnet_from_vty(vty);
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200558
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200559 vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s",
Alexander Couzensb847a212016-08-02 11:34:11 +0200560 net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_ATTACH].current,
561 net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_NORMAL].current,
562 net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_PERIODIC].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200563 VTY_NEWLINE);
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200564 vty_out(vty, "IMSI Detach Indications : %lu%s",
Alexander Couzensb847a212016-08-02 11:34:11 +0200565 net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_DETACH].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200566 VTY_NEWLINE);
Neels Hofmeyr36891a72016-05-09 13:18:03 +0200567 vty_out(vty, "Location Updating Results: %lu completed, %lu failed%s",
568 net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_COMPLETED].current,
569 net->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_FAILED].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200570 VTY_NEWLINE);
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200571 vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, "
572 "%lu completed, %lu failed%s",
Alexander Chemerisa7388d72017-07-08 18:00:36 +0900573 net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_ATTEMPTED].current,
574 net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_NO_CHANNEL].current,
575 net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_TIMEOUT].current,
576 net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_COMPLETED].current,
577 net->bsc_ctrs->ctr[BSC_CTR_HANDOVER_FAILED].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200578 VTY_NEWLINE);
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200579 vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s",
Alexander Couzensb847a212016-08-02 11:34:11 +0200580 net->msc_ctrs->ctr[MSC_CTR_SMS_SUBMITTED].current,
581 net->msc_ctrs->ctr[MSC_CTR_SMS_NO_RECEIVER].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200582 VTY_NEWLINE);
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200583 vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s",
Alexander Couzensb847a212016-08-02 11:34:11 +0200584 net->msc_ctrs->ctr[MSC_CTR_SMS_DELIVERED].current,
585 net->msc_ctrs->ctr[MSC_CTR_SMS_RP_ERR_MEM].current,
586 net->msc_ctrs->ctr[MSC_CTR_SMS_RP_ERR_OTHER].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200587 VTY_NEWLINE);
Harald Weltea29e43a2010-12-24 16:06:33 +0100588 vty_out(vty, "MO Calls : %lu setup, %lu connect ack%s",
Alexander Couzensb847a212016-08-02 11:34:11 +0200589 net->msc_ctrs->ctr[MSC_CTR_CALL_MO_SETUP].current,
590 net->msc_ctrs->ctr[MSC_CTR_CALL_MO_CONNECT_ACK].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200591 VTY_NEWLINE);
Harald Weltea29e43a2010-12-24 16:06:33 +0100592 vty_out(vty, "MT Calls : %lu setup, %lu connect%s",
Alexander Couzensb847a212016-08-02 11:34:11 +0200593 net->msc_ctrs->ctr[MSC_CTR_CALL_MT_SETUP].current,
594 net->msc_ctrs->ctr[MSC_CTR_CALL_MT_CONNECT].current,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200595 VTY_NEWLINE);
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200596 return CMD_SUCCESS;
597}
598
Holger Hans Peter Freyther81c0e252010-12-25 14:08:00 +0100599DEFUN(show_smsqueue,
600 show_smsqueue_cmd,
601 "show sms-queue",
602 SHOW_STR "Display SMSqueue statistics\n")
603{
604 struct gsm_network *net = gsmnet_from_vty(vty);
605
606 sms_queue_stats(net->sms_queue, vty);
607 return CMD_SUCCESS;
608}
609
Holger Hans Peter Freyther7a0e1662010-12-25 14:15:32 +0100610DEFUN(smsqueue_trigger,
611 smsqueue_trigger_cmd,
612 "sms-queue trigger",
613 "SMS Queue\n" "Trigger sending messages\n")
614{
615 struct gsm_network *net = gsmnet_from_vty(vty);
616
617 sms_queue_trigger(net->sms_queue);
618 return CMD_SUCCESS;
619}
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200620
Holger Hans Peter Freyther3c6f6c22010-12-25 14:25:12 +0100621DEFUN(smsqueue_max,
622 smsqueue_max_cmd,
623 "sms-queue max-pending <1-500>",
Holger Hans Peter Freyther3217fa22012-07-20 23:55:08 +0200624 "SMS Queue\n" "SMS to deliver in parallel\n" "Amount\n")
Holger Hans Peter Freyther3c6f6c22010-12-25 14:25:12 +0100625{
626 struct gsm_network *net = gsmnet_from_vty(vty);
627
628 sms_queue_set_max_pending(net->sms_queue, atoi(argv[0]));
629 return CMD_SUCCESS;
630}
631
Holger Hans Peter Freyther4dcc5e52010-12-25 14:38:30 +0100632DEFUN(smsqueue_clear,
633 smsqueue_clear_cmd,
634 "sms-queue clear",
635 "SMS Queue\n" "Clear the queue of pending SMS\n")
636{
637 struct gsm_network *net = gsmnet_from_vty(vty);
638
639 sms_queue_clear(net->sms_queue);
640 return CMD_SUCCESS;
641}
642
Holger Hans Peter Freyther994dcbb2010-12-25 14:50:50 +0100643DEFUN(smsqueue_fail,
644 smsqueue_fail_cmd,
645 "sms-queue max-failure <1-500>",
Holger Hans Peter Freyther3217fa22012-07-20 23:55:08 +0200646 "SMS Queue\n" "Maximum amount of delivery failures\n" "Amount\n")
Holger Hans Peter Freyther994dcbb2010-12-25 14:50:50 +0100647{
648 struct gsm_network *net = gsmnet_from_vty(vty);
649
650 sms_queue_set_max_failure(net->sms_queue, atoi(argv[0]));
651 return CMD_SUCCESS;
652}
653
Harald Welteab386e62011-09-01 18:18:43 +0200654
655DEFUN(cfg_mncc_int, cfg_mncc_int_cmd,
656 "mncc-int", "Configure internal MNCC handler")
657{
658 vty->node = MNCC_INT_NODE;
659
660 return CMD_SUCCESS;
661}
662
663static struct cmd_node mncc_int_node = {
664 MNCC_INT_NODE,
Harald Welte570ce242012-08-17 13:16:10 +0200665 "%s(config-mncc-int)# ",
Harald Welteab386e62011-09-01 18:18:43 +0200666 1,
667};
668
669static const struct value_string tchf_codec_names[] = {
670 { GSM48_CMODE_SPEECH_V1, "fr" },
671 { GSM48_CMODE_SPEECH_EFR, "efr" },
672 { GSM48_CMODE_SPEECH_AMR, "amr" },
673 { 0, NULL }
674};
675
676static const struct value_string tchh_codec_names[] = {
677 { GSM48_CMODE_SPEECH_V1, "hr" },
678 { GSM48_CMODE_SPEECH_AMR, "amr" },
679 { 0, NULL }
680};
681
682static int config_write_mncc_int(struct vty *vty)
683{
Harald Welteb4771a62012-11-11 10:58:51 +0100684 uint16_t meas_port;
685 char *meas_host;
Holger Hans Peter Freyther86573262015-01-31 09:47:37 +0100686 const char *meas_scenario;
Harald Welteb4771a62012-11-11 10:58:51 +0100687
688 meas_feed_cfg_get(&meas_host, &meas_port);
Holger Hans Peter Freyther86573262015-01-31 09:47:37 +0100689 meas_scenario = meas_feed_scenario_get();
Harald Welteb4771a62012-11-11 10:58:51 +0100690
Harald Welteab386e62011-09-01 18:18:43 +0200691 vty_out(vty, "mncc-int%s", VTY_NEWLINE);
692 vty_out(vty, " default-codec tch-f %s%s",
693 get_value_string(tchf_codec_names, mncc_int.def_codec[0]),
694 VTY_NEWLINE);
695 vty_out(vty, " default-codec tch-h %s%s",
696 get_value_string(tchh_codec_names, mncc_int.def_codec[1]),
697 VTY_NEWLINE);
Harald Welteb4771a62012-11-11 10:58:51 +0100698 if (meas_port)
699 vty_out(vty, " meas-feed destination %s %u%s",
700 meas_host, meas_port, VTY_NEWLINE);
Holger Hans Peter Freyther86573262015-01-31 09:47:37 +0100701 if (strlen(meas_scenario) > 0)
702 vty_out(vty, " meas-feed scenario %s%s",
703 meas_scenario, VTY_NEWLINE);
Harald Welteb4771a62012-11-11 10:58:51 +0100704
Harald Welteab386e62011-09-01 18:18:43 +0200705
706 return CMD_SUCCESS;
707}
708
709DEFUN(mnccint_def_codec_f,
710 mnccint_def_codec_f_cmd,
711 "default-codec tch-f (fr|efr|amr)",
712 "Set default codec\n" "Codec for TCH/F\n"
713 "Full-Rate\n" "Enhanced Full-Rate\n" "Adaptive Multi-Rate\n")
714{
715 mncc_int.def_codec[0] = get_string_value(tchf_codec_names, argv[0]);
716
717 return CMD_SUCCESS;
718}
719
720DEFUN(mnccint_def_codec_h,
721 mnccint_def_codec_h_cmd,
722 "default-codec tch-h (hr|amr)",
723 "Set default codec\n" "Codec for TCH/H\n"
724 "Half-Rate\n" "Adaptive Multi-Rate\n")
725{
726 mncc_int.def_codec[1] = get_string_value(tchh_codec_names, argv[0]);
727
728 return CMD_SUCCESS;
729}
730
Holger Hans Peter Freyther63b0e442013-03-03 09:32:08 +0100731#define OBSOLETE_MSG "Obsolete\n"
Harald Welteb02fc1e2013-02-12 11:15:49 +0100732/* this is just for backwards compatibility as the sms code moved into
733 * libosmocore and old config files no longer parse... */
734DEFUN_DEPRECATED(log_level_sms, log_level_sms_cmd,
735 "logging level sms (everything|debug|info|notice|error|fatal)",
Holger Hans Peter Freyther63b0e442013-03-03 09:32:08 +0100736 ".HIDDEN\n" OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG
737 OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG OBSOLETE_MSG)
Harald Welteb02fc1e2013-02-12 11:15:49 +0100738{
739 vty_out(vty, "%% 'logging level sms' is now called 'logging level "
740 "lsms', please update your config %s", VTY_NEWLINE);
741
742 return CMD_SUCCESS;
743}
744
Holger Hans Peter Freythera07e38d2015-01-31 09:26:20 +0100745#define MEAS_STR "Measurement export related\n"
Harald Welteb4771a62012-11-11 10:58:51 +0100746DEFUN(mnccint_meas_feed, mnccint_meas_feed_cmd,
747 "meas-feed destination ADDR <0-65535>",
Holger Hans Peter Freythera07e38d2015-01-31 09:26:20 +0100748 MEAS_STR "destination\n" "address or hostname\n" "port number\n")
Harald Welteb4771a62012-11-11 10:58:51 +0100749{
750 int rc;
751
752 rc = meas_feed_cfg_set(argv[0], atoi(argv[1]));
753 if (rc < 0)
754 return CMD_WARNING;
755
756 return CMD_SUCCESS;
757}
758
759DEFUN(meas_feed_scenario, meas_feed_scenario_cmd,
760 "meas-feed scenario NAME",
Holger Hans Peter Freythera07e38d2015-01-31 09:26:20 +0100761 MEAS_STR "scenario\n" "Name up to 31 characters included in report\n")
Harald Welteb4771a62012-11-11 10:58:51 +0100762{
763 meas_feed_scenario_set(argv[0]);
764
765 return CMD_SUCCESS;
766}
767
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +0100768
769DEFUN(logging_fltr_imsi,
770 logging_fltr_imsi_cmd,
771 "logging filter imsi IMSI",
772 LOGGING_STR FILTER_STR
773 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
774{
Harald Welte2483f1b2016-06-19 18:06:02 +0200775 struct vlr_subscr *vlr_subscr;
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +0100776 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
777 struct log_target *tgt = osmo_log_vty2tgt(vty);
Neels Hofmeyr6d804b12017-02-18 22:20:46 +0100778 const char *imsi = argv[0];
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +0100779
780 if (!tgt)
781 return CMD_WARNING;
782
Harald Welte2483f1b2016-06-19 18:06:02 +0200783 vlr_subscr = vlr_subscr_find_by_imsi(gsmnet->vlr, imsi);
Neels Hofmeyr6d804b12017-02-18 22:20:46 +0100784
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200785 if (!vlr_subscr) {
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +0100786 vty_out(vty, "%%no subscriber with IMSI(%s)%s",
787 argv[0], VTY_NEWLINE);
788 return CMD_WARNING;
789 }
790
Harald Welte2483f1b2016-06-19 18:06:02 +0200791 log_set_filter_vlr_subscr(tgt, vlr_subscr);
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +0100792 return CMD_SUCCESS;
793}
Holger Hans Peter Freyther925c57f2015-01-27 10:58:29 +0100794
Harald Welte2483f1b2016-06-19 18:06:02 +0200795static struct cmd_node hlr_node = {
796 HLR_NODE,
797 "%s(config-hlr)# ",
798 1,
799};
800
801DEFUN(cfg_hlr, cfg_hlr_cmd,
802 "hlr", "Configure connection to the HLR")
803{
804 vty->node = HLR_NODE;
805 return CMD_SUCCESS;
806}
807
808DEFUN(cfg_hlr_remote_ip, cfg_hlr_remote_ip_cmd, "remote-ip A.B.C.D",
809 "Remote GSUP address of the HLR\n"
810 "Remote GSUP address (default: " MSC_HLR_REMOTE_IP_DEFAULT ")")
811{
812 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
813 talloc_free((void*)gsmnet->gsup_server_addr_str);
814 gsmnet->gsup_server_addr_str = talloc_strdup(gsmnet, argv[0]);
815 return CMD_SUCCESS;
816}
817
818DEFUN(cfg_hlr_remote_port, cfg_hlr_remote_port_cmd, "remote-port <1-65535>",
819 "Remote GSUP port of the HLR\n"
820 "Remote GSUP port (default: " OSMO_STRINGIFY(MSC_HLR_REMOTE_PORT_DEFAULT) ")")
821{
822 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
823 gsmnet->gsup_server_port = atoi(argv[0]);
824 return CMD_SUCCESS;
825}
826
827static int config_write_hlr(struct vty *vty)
828{
829 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
830
831 vty_out(vty, "hlr%s", VTY_NEWLINE);
832 vty_out(vty, " remote-ip %s%s",
833 gsmnet->gsup_server_addr_str, VTY_NEWLINE);
834 vty_out(vty, " remote-port %u%s",
835 gsmnet->gsup_server_port, VTY_NEWLINE);
836 return CMD_SUCCESS;
837}
838
Harald Weltedcccb182010-05-16 20:52:23 +0200839int bsc_vty_init_extra(void)
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200840{
Pablo Neira Ayusobbc5b992011-05-06 12:12:31 +0200841 osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL);
Harald Weltea1482332009-11-14 10:08:40 +0100842
Harald Welteb4d5b172010-05-12 16:10:35 +0000843 install_element_ve(&show_subscr_cmd);
844 install_element_ve(&show_subscr_cache_cmd);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200845
Harald Welteb4d5b172010-05-12 16:10:35 +0000846 install_element_ve(&sms_send_pend_cmd);
Harald Welte98f9c752009-11-14 08:00:53 +0100847
Alexander Chemerisbd6d40f2013-10-04 23:54:17 +0200848 install_element_ve(&subscriber_create_cmd);
Harald Welteb4d5b172010-05-12 16:10:35 +0000849 install_element_ve(&subscriber_send_sms_cmd);
850 install_element_ve(&subscriber_silent_sms_cmd);
851 install_element_ve(&subscriber_silent_call_start_cmd);
852 install_element_ve(&subscriber_silent_call_stop_cmd);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +0800853 install_element_ve(&subscriber_ussd_notify_cmd);
Holger Hans Peter Freytherabd0cac2010-12-22 18:12:11 +0100854 install_element_ve(&subscriber_update_cmd);
Harald Welteb4d5b172010-05-12 16:10:35 +0000855 install_element_ve(&show_stats_cmd);
Holger Hans Peter Freyther81c0e252010-12-25 14:08:00 +0100856 install_element_ve(&show_smsqueue_cmd);
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +0100857 install_element_ve(&logging_fltr_imsi_cmd);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200858
Keithd32b6d12017-01-18 17:09:33 +0100859 install_element(ENABLE_NODE, &ena_subscr_expire_cmd);
Harald Welteb4a84e12010-05-27 10:44:58 +0200860 install_element(ENABLE_NODE, &ena_subscr_a3a8_cmd);
Holger Hans Peter Freyther7a0e1662010-12-25 14:15:32 +0100861 install_element(ENABLE_NODE, &smsqueue_trigger_cmd);
Holger Hans Peter Freyther3c6f6c22010-12-25 14:25:12 +0100862 install_element(ENABLE_NODE, &smsqueue_max_cmd);
Holger Hans Peter Freyther4dcc5e52010-12-25 14:38:30 +0100863 install_element(ENABLE_NODE, &smsqueue_clear_cmd);
Holger Hans Peter Freyther994dcbb2010-12-25 14:50:50 +0100864 install_element(ENABLE_NODE, &smsqueue_fail_cmd);
Nico Goldeb62b1232011-02-22 17:54:47 +0100865 install_element(ENABLE_NODE, &subscriber_send_pending_sms_cmd);
Harald Welteb4771a62012-11-11 10:58:51 +0100866 install_element(ENABLE_NODE, &meas_feed_scenario_cmd);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200867
Harald Welteab386e62011-09-01 18:18:43 +0200868 install_element(CONFIG_NODE, &cfg_mncc_int_cmd);
869 install_node(&mncc_int_node, config_write_mncc_int);
Jacob Erlbeck36722e12013-10-29 09:30:30 +0100870 vty_install_default(MNCC_INT_NODE);
Harald Welteab386e62011-09-01 18:18:43 +0200871 install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd);
872 install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd);
Harald Welteb4771a62012-11-11 10:58:51 +0100873 install_element(MNCC_INT_NODE, &mnccint_meas_feed_cmd);
Holger Hans Peter Freyther86573262015-01-31 09:47:37 +0100874 install_element(MNCC_INT_NODE, &meas_feed_scenario_cmd);
Harald Welteab386e62011-09-01 18:18:43 +0200875
Harald Welteb02fc1e2013-02-12 11:15:49 +0100876 install_element(CFG_LOG_NODE, &log_level_sms_cmd);
Holger Hans Peter Freyther6995f242014-12-28 18:54:32 +0100877 install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
Harald Welteb02fc1e2013-02-12 11:15:49 +0100878
Harald Welte2483f1b2016-06-19 18:06:02 +0200879 install_element(CONFIG_NODE, &cfg_hlr_cmd);
880 install_node(&hlr_node, config_write_hlr);
881 install_element(HLR_NODE, &cfg_hlr_remote_ip_cmd);
882 install_element(HLR_NODE, &cfg_hlr_remote_port_cmd);
Holger Hans Peter Freyther925c57f2015-01-27 10:58:29 +0100883
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200884 return 0;
885}