Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1 | /* MSC interface to quagga VTY */ |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2 | /* (C) 2016-2018 by sysmocom s.m.f.c. GmbH <info@sysmocom.de> |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 3 | * Based on OpenBSC interface to quagga VTY (libmsc/vty_interface_layer3.c) |
Harald Welte | 7b222aa | 2017-12-23 19:30:32 +0100 | [diff] [blame] | 4 | * (C) 2009-2017 by Harald Welte <laforge@gnumonks.org> |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 5 | * (C) 2009-2011 by Holger Hans Peter Freyther |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU Affero General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | /* NOTE: I would have liked to call this the MSC_NODE instead of the MSC_NODE, |
| 24 | * but MSC_NODE already exists to configure a remote MSC for osmo-bsc. */ |
| 25 | |
Neels Hofmeyr | 4ac8009 | 2019-03-04 02:46:37 +0100 | [diff] [blame] | 26 | #include "config.h" |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 27 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 28 | #include <inttypes.h> |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 29 | #include <limits.h> |
| 30 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 31 | #include <osmocom/core/use_count.h> |
| 32 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 33 | #include <osmocom/gsm/protocol/gsm_08_58.h> |
| 34 | #include <osmocom/gsm/protocol/gsm_04_14.h> |
Philipp Maier | 8fa2dbe | 2019-03-19 18:51:37 +0100 | [diff] [blame] | 35 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
Neels Hofmeyr | 9aac5c2 | 2020-05-27 00:04:26 +0200 | [diff] [blame] | 36 | #include <osmocom/gsm/gsm23236.h> |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 37 | |
Max | c51609a | 2018-11-09 17:13:00 +0100 | [diff] [blame] | 38 | #include <osmocom/sigtran/sccp_helpers.h> |
| 39 | |
Vadim Yanitskiy | ffc7f39 | 2020-01-18 18:39:41 +0700 | [diff] [blame] | 40 | #include <osmocom/vty/tdef_vty.h> |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 41 | #include <osmocom/vty/command.h> |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 42 | #include <osmocom/vty/logging.h> |
Stefan Sperling | 617ac80 | 2018-02-22 17:58:20 +0100 | [diff] [blame] | 43 | #include <osmocom/vty/misc.h> |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 44 | #include <osmocom/vty/stats.h> |
| 45 | |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 46 | #ifdef BUILD_IU |
| 47 | #include <osmocom/ranap/iu_client.h> |
| 48 | #endif |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 49 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 50 | #include <osmocom/msc/vty.h> |
| 51 | #include <osmocom/msc/gsm_data.h> |
| 52 | #include <osmocom/msc/gsm_subscriber.h> |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 53 | #include <osmocom/msc/msub.h> |
| 54 | #include <osmocom/msc/msc_a.h> |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 55 | #include <osmocom/msc/vlr.h> |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 56 | #include <osmocom/msc/transaction.h> |
| 57 | #include <osmocom/msc/db.h> |
| 58 | #include <osmocom/msc/sms_queue.h> |
| 59 | #include <osmocom/msc/silent_call.h> |
| 60 | #include <osmocom/msc/gsm_04_80.h> |
| 61 | #include <osmocom/msc/gsm_04_14.h> |
| 62 | #include <osmocom/msc/signal.h> |
| 63 | #include <osmocom/msc/mncc_int.h> |
Pau Espin Pedrol | 4faff9e | 2019-05-06 19:29:11 +0200 | [diff] [blame] | 64 | #include <osmocom/msc/osmux.h> |
Vadim Yanitskiy | 1b89130 | 2018-08-04 01:33:08 +0700 | [diff] [blame] | 65 | #include <osmocom/msc/rrlp.h> |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 66 | #include <osmocom/msc/vlr_sgs.h> |
| 67 | #include <osmocom/msc/sgs_vty.h> |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 68 | #include <osmocom/msc/sccp_ran.h> |
| 69 | #include <osmocom/msc/ran_peer.h> |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 70 | |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 71 | static struct gsm_network *gsmnet = NULL; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 72 | |
Vadim Yanitskiy | 9b56cd8 | 2020-01-25 06:38:44 +0700 | [diff] [blame] | 73 | static struct cmd_node net_node = { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 74 | GSMNET_NODE, |
| 75 | "%s(config-net)# ", |
| 76 | 1, |
| 77 | }; |
| 78 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 79 | #define VSUB_USE_VTY "VTY" |
| 80 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 81 | #define NETWORK_STR "Configure the GSM network\n" |
| 82 | #define CODE_CMD_STR "Code commands\n" |
| 83 | #define NAME_CMD_STR "Name Commands\n" |
| 84 | #define NAME_STR "Name to use\n" |
| 85 | |
| 86 | DEFUN(cfg_net, |
| 87 | cfg_net_cmd, |
| 88 | "network", NETWORK_STR) |
| 89 | { |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 90 | vty->index = gsmnet; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 91 | vty->node = GSMNET_NODE; |
| 92 | |
| 93 | return CMD_SUCCESS; |
| 94 | } |
| 95 | |
| 96 | DEFUN(cfg_net_ncc, |
| 97 | cfg_net_ncc_cmd, |
| 98 | "network country code <1-999>", |
| 99 | "Set the GSM network country code\n" |
| 100 | "Country commands\n" |
| 101 | CODE_CMD_STR |
| 102 | "Network Country Code to use\n") |
| 103 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 104 | gsmnet->plmn.mcc = atoi(argv[0]); |
| 105 | |
| 106 | return CMD_SUCCESS; |
| 107 | } |
| 108 | |
| 109 | DEFUN(cfg_net_mnc, |
| 110 | cfg_net_mnc_cmd, |
| 111 | "mobile network code <0-999>", |
| 112 | "Set the GSM mobile network code\n" |
| 113 | "Network Commands\n" |
| 114 | CODE_CMD_STR |
| 115 | "Mobile Network Code to use\n") |
| 116 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 117 | uint16_t mnc; |
| 118 | bool mnc_3_digits; |
| 119 | |
| 120 | if (osmo_mnc_from_str(argv[0], &mnc, &mnc_3_digits)) { |
| 121 | vty_out(vty, "%% Error decoding MNC: %s%s", argv[0], VTY_NEWLINE); |
| 122 | return CMD_WARNING; |
| 123 | } |
| 124 | |
| 125 | gsmnet->plmn.mnc = mnc; |
| 126 | gsmnet->plmn.mnc_3_digits = mnc_3_digits; |
| 127 | |
| 128 | return CMD_SUCCESS; |
| 129 | } |
| 130 | |
| 131 | DEFUN(cfg_net_name_short, |
| 132 | cfg_net_name_short_cmd, |
| 133 | "short name NAME", |
| 134 | "Set the short GSM network name\n" NAME_CMD_STR NAME_STR) |
| 135 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 136 | osmo_talloc_replace_string(gsmnet, &gsmnet->name_short, argv[0]); |
| 137 | return CMD_SUCCESS; |
| 138 | } |
| 139 | |
| 140 | DEFUN(cfg_net_name_long, |
| 141 | cfg_net_name_long_cmd, |
| 142 | "long name NAME", |
| 143 | "Set the long GSM network name\n" NAME_CMD_STR NAME_STR) |
| 144 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 145 | osmo_talloc_replace_string(gsmnet, &gsmnet->name_long, argv[0]); |
| 146 | return CMD_SUCCESS; |
| 147 | } |
| 148 | |
Neels Hofmeyr | 4dfb2ba | 2019-08-13 16:00:37 +0200 | [diff] [blame] | 149 | #define ENCRYPTION_STR "Encryption options\n" |
| 150 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 151 | DEFUN(cfg_net_encryption, |
| 152 | cfg_net_encryption_cmd, |
| 153 | "encryption a5 <0-3> [<0-3>] [<0-3>] [<0-3>]", |
Neels Hofmeyr | 4dfb2ba | 2019-08-13 16:00:37 +0200 | [diff] [blame] | 154 | ENCRYPTION_STR |
| 155 | "GSM A5 Air Interface Encryption.\n" |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 156 | "A5/n Algorithm Number\n" |
| 157 | "A5/n Algorithm Number\n" |
| 158 | "A5/n Algorithm Number\n" |
| 159 | "A5/n Algorithm Number\n") |
| 160 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 161 | unsigned int i; |
| 162 | |
| 163 | gsmnet->a5_encryption_mask = 0; |
| 164 | for (i = 0; i < argc; i++) |
| 165 | gsmnet->a5_encryption_mask |= (1 << atoi(argv[i])); |
| 166 | |
| 167 | return CMD_SUCCESS; |
| 168 | } |
| 169 | |
Neels Hofmeyr | 4dfb2ba | 2019-08-13 16:00:37 +0200 | [diff] [blame] | 170 | /* So far just a boolean switch, a future patch might add individual config for UEA1 and UEA2, see OS#4143 */ |
| 171 | DEFUN(cfg_net_encryption_uea, |
| 172 | cfg_net_encryption_uea_cmd, |
| 173 | "encryption uea <0-2> [<0-2>] [<0-2>]", |
| 174 | ENCRYPTION_STR |
| 175 | "UTRAN (3G) encryption algorithms to allow: 0 = UEA0 (no encryption), 1 = UEA1, 2 = UEA2." |
| 176 | " NOTE: the current implementation does not allow free choice of combining encryption algorithms yet." |
| 177 | " The only valid settings are either 'encryption uea 0' or 'encryption uea 1 2'.\n" |
| 178 | "UEAn Algorithm Number\n" |
| 179 | "UEAn Algorithm Number\n" |
| 180 | "UEAn Algorithm Number\n" |
| 181 | ) |
| 182 | { |
| 183 | unsigned int i; |
| 184 | uint8_t mask = 0; |
| 185 | |
| 186 | for (i = 0; i < argc; i++) |
| 187 | mask |= (1 << atoi(argv[i])); |
| 188 | |
| 189 | if (mask == (1 << 0)) { |
| 190 | /* UEA0. Disable encryption. */ |
| 191 | gsmnet->uea_encryption = false; |
| 192 | } else if (mask == ((1 << 1) | (1 << 2))) { |
| 193 | /* UEA1 and UEA2. Enable encryption. */ |
| 194 | gsmnet->uea_encryption = true; |
| 195 | } else { |
| 196 | vty_out(vty, |
| 197 | "%% Error: the current implementation does not allow free choice of combining%s" |
| 198 | "%% encryption algorithms yet. The only valid settings are either%s" |
| 199 | "%% encryption uea 0%s" |
| 200 | "%% or%s" |
| 201 | "%% encryption uea 1 2%s", |
| 202 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 203 | return CMD_WARNING; |
| 204 | } |
| 205 | |
| 206 | return CMD_SUCCESS; |
| 207 | } |
| 208 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 209 | DEFUN(cfg_net_authentication, |
| 210 | cfg_net_authentication_cmd, |
| 211 | "authentication (optional|required)", |
| 212 | "Whether to enforce MS authentication in 2G\n" |
| 213 | "Allow MS to attach via 2G BSC without authentication\n" |
| 214 | "Always do authentication\n") |
| 215 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 216 | gsmnet->authentication_required = (argv[0][0] == 'r') ? true : false; |
| 217 | |
| 218 | return CMD_SUCCESS; |
| 219 | } |
| 220 | |
| 221 | DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd, |
| 222 | "rrlp mode (none|ms-based|ms-preferred|ass-preferred)", |
| 223 | "Radio Resource Location Protocol\n" |
| 224 | "Set the Radio Resource Location Protocol Mode\n" |
| 225 | "Don't send RRLP request\n" |
| 226 | "Request MS-based location\n" |
| 227 | "Request any location, prefer MS-based\n" |
| 228 | "Request any location, prefer MS-assisted\n") |
| 229 | { |
Vadim Yanitskiy | 1b89130 | 2018-08-04 01:33:08 +0700 | [diff] [blame] | 230 | gsmnet->rrlp.mode = msc_rrlp_mode_parse(argv[0]); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 231 | |
| 232 | return CMD_SUCCESS; |
| 233 | } |
| 234 | |
| 235 | DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd, |
| 236 | "mm info (0|1)", |
| 237 | "Mobility Management\n" |
| 238 | "Send MM INFO after LOC UPD ACCEPT\n" |
| 239 | "Disable\n" "Enable\n") |
| 240 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 241 | gsmnet->send_mm_info = atoi(argv[0]); |
| 242 | |
| 243 | return CMD_SUCCESS; |
| 244 | } |
| 245 | |
| 246 | DEFUN(cfg_net_timezone, |
| 247 | cfg_net_timezone_cmd, |
| 248 | "timezone <-19-19> (0|15|30|45)", |
| 249 | "Set the Timezone Offset of the network\n" |
| 250 | "Timezone offset (hours)\n" |
| 251 | "Timezone offset (00 minutes)\n" |
| 252 | "Timezone offset (15 minutes)\n" |
| 253 | "Timezone offset (30 minutes)\n" |
| 254 | "Timezone offset (45 minutes)\n" |
| 255 | ) |
| 256 | { |
| 257 | struct gsm_network *net = vty->index; |
| 258 | int tzhr = atoi(argv[0]); |
| 259 | int tzmn = atoi(argv[1]); |
| 260 | |
| 261 | net->tz.hr = tzhr; |
| 262 | net->tz.mn = tzmn; |
| 263 | net->tz.dst = 0; |
| 264 | net->tz.override = 1; |
| 265 | |
| 266 | return CMD_SUCCESS; |
| 267 | } |
| 268 | |
| 269 | DEFUN(cfg_net_timezone_dst, |
| 270 | cfg_net_timezone_dst_cmd, |
| 271 | "timezone <-19-19> (0|15|30|45) <0-2>", |
| 272 | "Set the Timezone Offset of the network\n" |
| 273 | "Timezone offset (hours)\n" |
| 274 | "Timezone offset (00 minutes)\n" |
| 275 | "Timezone offset (15 minutes)\n" |
| 276 | "Timezone offset (30 minutes)\n" |
| 277 | "Timezone offset (45 minutes)\n" |
| 278 | "DST offset (hours)\n" |
| 279 | ) |
| 280 | { |
| 281 | struct gsm_network *net = vty->index; |
| 282 | int tzhr = atoi(argv[0]); |
| 283 | int tzmn = atoi(argv[1]); |
| 284 | int tzdst = atoi(argv[2]); |
| 285 | |
| 286 | net->tz.hr = tzhr; |
| 287 | net->tz.mn = tzmn; |
| 288 | net->tz.dst = tzdst; |
| 289 | net->tz.override = 1; |
| 290 | |
| 291 | return CMD_SUCCESS; |
| 292 | } |
| 293 | |
| 294 | DEFUN(cfg_net_no_timezone, |
| 295 | cfg_net_no_timezone_cmd, |
| 296 | "no timezone", |
| 297 | NO_STR |
| 298 | "Disable network timezone override, use system tz\n") |
| 299 | { |
| 300 | struct gsm_network *net = vty->index; |
| 301 | |
| 302 | net->tz.override = 0; |
| 303 | |
| 304 | return CMD_SUCCESS; |
| 305 | } |
| 306 | |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 307 | /* NOTE: actually this is subscriber expiration timeout */ |
| 308 | #define PER_LOC_UPD_STR "Periodic Location Updating Interval\n" |
| 309 | |
| 310 | DEFUN_DEPRECATED(cfg_net_per_loc_upd, cfg_net_per_loc_upd_cmd, |
| 311 | "periodic location update <6-1530>", |
| 312 | PER_LOC_UPD_STR PER_LOC_UPD_STR PER_LOC_UPD_STR |
| 313 | "Periodic Location Updating Interval in Minutes\n") |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 314 | { |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 315 | int minutes = atoi(argv[0]); |
| 316 | int rc; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 317 | |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 318 | vty_out(vty, "%% 'periodic location update' is now deprecated: " |
| 319 | "use 'timer T3212' to change subscriber expiration " |
| 320 | "timeout.%s", VTY_NEWLINE); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 321 | |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 322 | /* We used to double this value and add a minute when scheduling the |
| 323 | * expiration timer. Let's emulate the old behaviour here. */ |
| 324 | minutes = minutes * 2 + 1; |
| 325 | vty_out(vty, "%% Setting T3212 to %d minutes " |
| 326 | "(emulating the old behaviour).%s", |
| 327 | minutes, VTY_NEWLINE); |
| 328 | |
| 329 | rc = osmo_tdef_set(msc_tdefs_vlr, 3212, minutes, OSMO_TDEF_M); |
| 330 | return rc ? CMD_WARNING : CMD_SUCCESS; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 331 | } |
| 332 | |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 333 | DEFUN_DEPRECATED(cfg_net_no_per_loc_upd, cfg_net_no_per_loc_upd_cmd, |
| 334 | "no periodic location update", |
| 335 | NO_STR PER_LOC_UPD_STR PER_LOC_UPD_STR PER_LOC_UPD_STR) |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 336 | { |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 337 | int rc; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 338 | |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 339 | vty_out(vty, "%% 'periodic location update' is now deprecated: " |
| 340 | "use 'timer T3212' to change subscriber expiration " |
| 341 | "timeout.%s", VTY_NEWLINE); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 342 | |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 343 | rc = osmo_tdef_set(msc_tdefs_vlr, 3212, 0, OSMO_TDEF_M); |
| 344 | return rc ? CMD_WARNING : CMD_SUCCESS; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 345 | } |
| 346 | |
Keith Whyte | 991bb42 | 2019-08-08 15:43:40 +0200 | [diff] [blame] | 347 | DEFUN(cfg_net_call_wait, cfg_net_call_wait_cmd, |
| 348 | "call-waiting", |
| 349 | "Enable Call Waiting on the Network\n") |
| 350 | { |
| 351 | struct gsm_network *net = vty->index; |
| 352 | |
| 353 | net->call_waiting = true; |
| 354 | |
| 355 | return CMD_SUCCESS; |
| 356 | } |
| 357 | |
| 358 | DEFUN(cfg_net_no_call_wait, cfg_net_no_call_wait_cmd, |
| 359 | "no call-waiting", |
| 360 | NO_STR |
| 361 | "Disable Call Waiting on the Network\n") |
| 362 | { |
| 363 | struct gsm_network *net = vty->index; |
| 364 | |
| 365 | net->call_waiting = false; |
| 366 | |
| 367 | return CMD_SUCCESS; |
| 368 | } |
| 369 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 370 | static int config_write_net(struct vty *vty) |
| 371 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 372 | int i; |
| 373 | |
| 374 | vty_out(vty, "network%s", VTY_NEWLINE); |
| 375 | vty_out(vty, " network country code %s%s", osmo_mcc_name(gsmnet->plmn.mcc), VTY_NEWLINE); |
| 376 | vty_out(vty, " mobile network code %s%s", |
| 377 | osmo_mnc_name(gsmnet->plmn.mnc, gsmnet->plmn.mnc_3_digits), VTY_NEWLINE); |
| 378 | vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE); |
| 379 | vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE); |
| 380 | vty_out(vty, " encryption a5"); |
| 381 | for (i = 0; i < 8; i++) { |
| 382 | if (gsmnet->a5_encryption_mask & (1 << i)) |
| 383 | vty_out(vty, " %u", i); |
| 384 | } |
| 385 | vty_out(vty, "%s", VTY_NEWLINE); |
Neels Hofmeyr | 4dfb2ba | 2019-08-13 16:00:37 +0200 | [diff] [blame] | 386 | |
| 387 | if (!gsmnet->uea_encryption) |
| 388 | vty_out(vty, " encryption uea 0%s", VTY_NEWLINE); |
| 389 | else |
| 390 | vty_out(vty, " encryption uea 1 2%s", VTY_NEWLINE); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 391 | vty_out(vty, " authentication %s%s", |
| 392 | gsmnet->authentication_required ? "required" : "optional", VTY_NEWLINE); |
Vadim Yanitskiy | 1b89130 | 2018-08-04 01:33:08 +0700 | [diff] [blame] | 393 | vty_out(vty, " rrlp mode %s%s", msc_rrlp_mode_name(gsmnet->rrlp.mode), |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 394 | VTY_NEWLINE); |
| 395 | vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE); |
| 396 | if (gsmnet->tz.override != 0) { |
| 397 | if (gsmnet->tz.dst) |
| 398 | vty_out(vty, " timezone %d %d %d%s", |
| 399 | gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst, |
| 400 | VTY_NEWLINE); |
| 401 | else |
| 402 | vty_out(vty, " timezone %d %d%s", |
| 403 | gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE); |
| 404 | } |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 405 | |
Keith Whyte | 991bb42 | 2019-08-08 15:43:40 +0200 | [diff] [blame] | 406 | if (!gsmnet->call_waiting) |
| 407 | vty_out(vty, " no call-waiting%s", VTY_NEWLINE); |
| 408 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 409 | return CMD_SUCCESS; |
| 410 | } |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 411 | |
| 412 | static struct cmd_node msc_node = { |
| 413 | MSC_NODE, |
| 414 | "%s(config-msc)# ", |
| 415 | 1, |
| 416 | }; |
| 417 | |
| 418 | DEFUN(cfg_msc, cfg_msc_cmd, |
| 419 | "msc", "Configure MSC options") |
| 420 | { |
| 421 | vty->node = MSC_NODE; |
| 422 | return CMD_SUCCESS; |
| 423 | } |
| 424 | |
Neels Hofmeyr | 05c5680 | 2018-12-05 01:07:03 +0100 | [diff] [blame] | 425 | #define MNCC_STR "Configure Mobile Network Call Control\n" |
| 426 | #define MNCC_GUARD_TIMEOUT_STR "Set global guard timer for mncc interface activity\n" |
| 427 | #define MNCC_GUARD_TIMEOUT_VALUE_STR "guard timer value (sec.)\n" |
| 428 | |
Keith Whyte | 1587ffb | 2020-08-28 13:36:58 +0200 | [diff] [blame] | 429 | DEFUN(cfg_sms_database, cfg_sms_database_cmd, |
| 430 | "sms-database PATH", |
| 431 | "Set the path to the MSC-SMS database file\n" |
| 432 | "Relative or absolute file system path to the database file (default is '" SMS_DEFAULT_DB_FILE_PATH "')\n") |
| 433 | { |
| 434 | osmo_talloc_replace_string(gsmnet, &gsmnet->sms_db_file_path, argv[0]); |
| 435 | return CMD_SUCCESS; |
| 436 | } |
| 437 | |
Neels Hofmeyr | 80447eb | 2018-12-05 01:11:28 +0100 | [diff] [blame] | 438 | DEFUN(cfg_msc_mncc_internal, |
| 439 | cfg_msc_mncc_internal_cmd, |
| 440 | "mncc internal", |
| 441 | MNCC_STR "Use internal MNCC handler (default; changes need a program restart)\n") |
| 442 | { |
| 443 | gsm_network_set_mncc_sock_path(gsmnet, NULL); |
| 444 | return CMD_SUCCESS; |
| 445 | } |
| 446 | |
| 447 | DEFUN(cfg_msc_mncc_external, |
| 448 | cfg_msc_mncc_external_cmd, |
| 449 | "mncc external MNCC_SOCKET_PATH", |
| 450 | MNCC_STR "Use external MNCC handler (changes need a program restart)\n" |
| 451 | "File system path to create the MNCC unix domain socket at\n") |
| 452 | { |
| 453 | gsm_network_set_mncc_sock_path(gsmnet, argv[0]); |
| 454 | return CMD_SUCCESS; |
| 455 | } |
| 456 | |
Philipp Maier | 9ca7b31 | 2018-10-10 17:00:49 +0200 | [diff] [blame] | 457 | DEFUN(cfg_msc_mncc_guard_timeout, |
| 458 | cfg_msc_mncc_guard_timeout_cmd, |
Neels Hofmeyr | 05c5680 | 2018-12-05 01:07:03 +0100 | [diff] [blame] | 459 | "mncc guard-timeout <0-255>", |
| 460 | MNCC_STR |
| 461 | MNCC_GUARD_TIMEOUT_STR MNCC_GUARD_TIMEOUT_VALUE_STR) |
Philipp Maier | 9ca7b31 | 2018-10-10 17:00:49 +0200 | [diff] [blame] | 462 | { |
| 463 | gsmnet->mncc_guard_timeout = atoi(argv[0]); |
| 464 | return CMD_SUCCESS; |
| 465 | } |
| 466 | |
Neels Hofmeyr | 05c5680 | 2018-12-05 01:07:03 +0100 | [diff] [blame] | 467 | ALIAS_DEPRECATED(cfg_msc_mncc_guard_timeout, |
| 468 | cfg_msc_deprecated_mncc_guard_timeout_cmd, |
| 469 | "mncc-guard-timeout <0-255>", |
| 470 | MNCC_GUARD_TIMEOUT_STR MNCC_GUARD_TIMEOUT_VALUE_STR); |
| 471 | |
Vadim Yanitskiy | 64623e1 | 2018-11-28 23:05:51 +0700 | [diff] [blame] | 472 | #define NCSS_STR "Configure call independent Supplementary Services\n" |
| 473 | |
| 474 | DEFUN(cfg_msc_ncss_guard_timeout, |
| 475 | cfg_msc_ncss_guard_timeout_cmd, |
| 476 | "ncss guard-timeout <0-255>", |
| 477 | NCSS_STR "Set guard timer for session activity\n" |
| 478 | "guard timer value (sec.), or 0 to disable\n") |
| 479 | { |
| 480 | gsmnet->ncss_guard_timeout = atoi(argv[0]); |
| 481 | return CMD_SUCCESS; |
| 482 | } |
| 483 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 484 | DEFUN(cfg_msc_assign_tmsi, cfg_msc_assign_tmsi_cmd, |
| 485 | "assign-tmsi", |
| 486 | "Assign TMSI during Location Updating.\n") |
| 487 | { |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 488 | gsmnet->vlr->cfg.assign_tmsi = true; |
| 489 | return CMD_SUCCESS; |
| 490 | } |
| 491 | |
| 492 | DEFUN(cfg_msc_no_assign_tmsi, cfg_msc_no_assign_tmsi_cmd, |
| 493 | "no assign-tmsi", |
| 494 | NO_STR "Assign TMSI during Location Updating.\n") |
| 495 | { |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 496 | gsmnet->vlr->cfg.assign_tmsi = false; |
| 497 | return CMD_SUCCESS; |
| 498 | } |
| 499 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 500 | DEFUN(cfg_msc_cs7_instance_a, |
| 501 | cfg_msc_cs7_instance_a_cmd, |
| 502 | "cs7-instance-a <0-15>", |
| 503 | "Set SS7 to be used by the A-Interface.\n" "SS7 instance reference number\n") |
| 504 | { |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 505 | gsmnet->a.cs7_instance = atoi(argv[0]); |
| 506 | return CMD_SUCCESS; |
| 507 | } |
| 508 | |
| 509 | DEFUN(cfg_msc_cs7_instance_iu, |
| 510 | cfg_msc_cs7_instance_iu_cmd, |
| 511 | "cs7-instance-iu <0-15>", |
| 512 | "Set SS7 to be used by the Iu-Interface.\n" "SS7 instance reference number\n") |
| 513 | { |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 514 | #if BUILD_IU |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 515 | gsmnet->iu.cs7_instance = atoi(argv[0]); |
| 516 | return CMD_SUCCESS; |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 517 | #else |
| 518 | vty_out(vty, "WARNING: 'cs7-instance-iu' without effect: built without Iu support%s", |
| 519 | VTY_NEWLINE); |
| 520 | return CMD_WARNING; |
| 521 | #endif |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 522 | } |
| 523 | |
Neels Hofmeyr | 97ce015 | 2017-10-29 02:10:38 +0100 | [diff] [blame] | 524 | DEFUN(cfg_msc_auth_tuple_max_reuse_count, cfg_msc_auth_tuple_max_reuse_count_cmd, |
| 525 | "auth-tuple-max-reuse-count <-1-2147483647>", |
| 526 | "Configure authentication tuple re-use\n" |
| 527 | "0 to use each auth tuple at most once (default), >0 to limit re-use, -1 to re-use infinitely (vulnerable!).\n") |
| 528 | { |
Neels Hofmeyr | 97ce015 | 2017-10-29 02:10:38 +0100 | [diff] [blame] | 529 | gsmnet->vlr->cfg.auth_tuple_max_reuse_count = atoi(argv[0]); |
| 530 | return CMD_SUCCESS; |
| 531 | } |
| 532 | |
| 533 | DEFUN(cfg_msc_auth_tuple_reuse_on_error, cfg_msc_auth_tuple_reuse_on_error_cmd, |
| 534 | "auth-tuple-reuse-on-error (0|1)", |
| 535 | "Configure authentication tuple re-use when HLR is not responsive\n" |
Oliver Smith | d6e24fd | 2019-01-09 10:46:43 +0100 | [diff] [blame] | 536 | "Never re-use auth tuples beyond auth-tuple-max-reuse-count (default)\n" |
| 537 | "If the HLR does not deliver new tuples, do re-use already available old ones.\n") |
Neels Hofmeyr | 97ce015 | 2017-10-29 02:10:38 +0100 | [diff] [blame] | 538 | { |
Neels Hofmeyr | 97ce015 | 2017-10-29 02:10:38 +0100 | [diff] [blame] | 539 | gsmnet->vlr->cfg.auth_reuse_old_sets_on_error = atoi(argv[0]) ? true : false; |
| 540 | return CMD_SUCCESS; |
| 541 | } |
| 542 | |
Oliver Smith | 0fec28a | 2018-12-14 10:52:52 +0100 | [diff] [blame] | 543 | DEFUN(cfg_msc_check_imei_rqd, cfg_msc_check_imei_rqd_cmd, |
Oliver Smith | 03ded91 | 2019-05-02 10:40:50 +0200 | [diff] [blame] | 544 | "check-imei-rqd (0|1|early)", |
Oliver Smith | 0fec28a | 2018-12-14 10:52:52 +0100 | [diff] [blame] | 545 | "Send each IMEI to the EIR to ask if it is permitted or not. The EIR is implemented as part of OsmoHLR, " |
| 546 | "and can optionally save the IMEI in the HLR.\n" |
| 547 | "Do not send IMEIs to the EIR\n" |
Oliver Smith | 03ded91 | 2019-05-02 10:40:50 +0200 | [diff] [blame] | 548 | "Send each IMEI to the EIR\n" |
| 549 | "Send each IMEI to the EIR, and do it at the start of the location update. This allows the EIR to receive the" |
| 550 | " IMEI, even if the MS would get rejected when the MSC sends the location update request to the HLR.\n") |
Oliver Smith | 0fec28a | 2018-12-14 10:52:52 +0100 | [diff] [blame] | 551 | { |
Oliver Smith | 03ded91 | 2019-05-02 10:40:50 +0200 | [diff] [blame] | 552 | if (strcmp(argv[0], "0") == 0) { |
| 553 | gsmnet->vlr->cfg.check_imei_rqd = false; |
| 554 | gsmnet->vlr->cfg.retrieve_imeisv_early = false; |
| 555 | } else if (strcmp(argv[0], "1") == 0) { |
| 556 | gsmnet->vlr->cfg.check_imei_rqd = true; |
| 557 | gsmnet->vlr->cfg.retrieve_imeisv_early = false; |
| 558 | } else if (strcmp(argv[0], "early") == 0) { |
| 559 | gsmnet->vlr->cfg.check_imei_rqd = true; |
| 560 | gsmnet->vlr->cfg.retrieve_imeisv_early = true; |
| 561 | } |
Oliver Smith | 0fec28a | 2018-12-14 10:52:52 +0100 | [diff] [blame] | 562 | return CMD_SUCCESS; |
| 563 | } |
| 564 | |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 565 | DEFUN(cfg_msc_paging_response_timer, cfg_msc_paging_response_timer_cmd, |
| 566 | "paging response-timer (default|<1-65535>)", |
| 567 | "Configure Paging\n" |
| 568 | "Set Paging timeout, the minimum time to pass between (unsuccessful) Pagings sent towards" |
| 569 | " BSS or RNC\n" |
| 570 | "Set to default timeout (" OSMO_STRINGIFY_VAL(MSC_PAGING_RESPONSE_TIMER_DEFAULT) " seconds)\n" |
| 571 | "Set paging timeout in seconds\n") |
| 572 | { |
Pau Espin Pedrol | b08a380 | 2019-09-16 19:01:37 +0200 | [diff] [blame] | 573 | if (!strcmp(argv[0], "default")) |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 574 | gsmnet->paging_response_timer = MSC_PAGING_RESPONSE_TIMER_DEFAULT; |
| 575 | else |
| 576 | gsmnet->paging_response_timer = atoi(argv[0]); |
| 577 | return CMD_SUCCESS; |
| 578 | } |
| 579 | |
Harald Welte | 69c54a8 | 2018-02-09 20:41:14 +0100 | [diff] [blame] | 580 | DEFUN(cfg_msc_emergency_msisdn, cfg_msc_emergency_msisdn_cmd, |
| 581 | "emergency-call route-to-msisdn MSISDN", |
| 582 | "Configure Emergency Call Behaviour\n" |
| 583 | "MSISDN to which Emergency Calls are Dispatched\n" |
| 584 | "MSISDN (E.164 Phone Number)\n") |
| 585 | { |
Harald Welte | 69c54a8 | 2018-02-09 20:41:14 +0100 | [diff] [blame] | 586 | osmo_talloc_replace_string(gsmnet, &gsmnet->emergency.route_to_msisdn, argv[0]); |
| 587 | |
| 588 | return CMD_SUCCESS; |
| 589 | } |
| 590 | |
Vadim Yanitskiy | f40e46f | 2018-11-20 06:20:53 +0700 | [diff] [blame] | 591 | /* TODO: to be deprecated as soon as we rip SMS handling out (see OS#3587) */ |
| 592 | DEFUN(cfg_msc_sms_over_gsup, cfg_msc_sms_over_gsup_cmd, |
| 593 | "sms-over-gsup", |
| 594 | "Enable routing of SMS messages over GSUP\n") |
| 595 | { |
| 596 | gsmnet->sms_over_gsup = true; |
| 597 | return CMD_SUCCESS; |
| 598 | } |
| 599 | |
| 600 | /* TODO: to be deprecated as soon as we rip SMS handling out (see OS#3587) */ |
| 601 | DEFUN(cfg_msc_no_sms_over_gsup, cfg_msc_no_sms_over_gsup_cmd, |
| 602 | "no sms-over-gsup", |
| 603 | NO_STR "Disable routing of SMS messages over GSUP\n") |
| 604 | { |
| 605 | gsmnet->sms_over_gsup = false; |
| 606 | return CMD_SUCCESS; |
| 607 | } |
| 608 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 609 | /* FIXME: This should rather be in the form of |
| 610 | * handover-number range 001234xxx |
| 611 | * and |
| 612 | * handover-number range 001234xxx FIRST LAST |
| 613 | */ |
| 614 | DEFUN(cfg_msc_handover_number_range, cfg_msc_handover_number_range_cmd, |
| 615 | "handover-number range MSISDN_FIRST MSISDN_LAST", |
| 616 | "Configure a range of MSISDN to be assigned to incoming inter-MSC Handovers for call forwarding.\n" |
| 617 | "Configure a handover number range\n" |
| 618 | "First Handover Number MSISDN\n" |
| 619 | "Last Handover Number MSISDN\n") |
| 620 | { |
| 621 | char *endp; |
| 622 | uint64_t range_start; |
| 623 | uint64_t range_end; |
| 624 | |
| 625 | /* FIXME leading zeros?? */ |
| 626 | |
| 627 | errno = 0; |
| 628 | range_start = strtoull(argv[0], &endp, 10); |
| 629 | if (errno || *endp != '\0') { |
| 630 | vty_out(vty, "%% Error parsing handover-number range start: %s%s", |
| 631 | argv[0], VTY_NEWLINE); |
| 632 | return CMD_WARNING; |
| 633 | } |
| 634 | |
| 635 | errno = 0; |
| 636 | range_end = strtoull(argv[1], &endp, 10); |
| 637 | if (errno || *endp != '\0') { |
| 638 | vty_out(vty, "%% Error parsing handover-number range end: %s%s", |
| 639 | argv[1], VTY_NEWLINE); |
| 640 | return CMD_WARNING; |
| 641 | } |
| 642 | |
| 643 | if (range_start > range_end) { |
| 644 | vty_out(vty, "%% Error: handover-number range end must be > than the range start, but" |
| 645 | " %"PRIu64" > %"PRIu64"%s", range_start, range_end, VTY_NEWLINE); |
| 646 | return CMD_WARNING; |
| 647 | } |
| 648 | |
| 649 | gsmnet->handover_number.range_start = range_start; |
| 650 | gsmnet->handover_number.range_end = range_end; |
| 651 | return CMD_SUCCESS; |
| 652 | } |
| 653 | |
Pau Espin Pedrol | 4faff9e | 2019-05-06 19:29:11 +0200 | [diff] [blame] | 654 | #define OSMUX_STR "RTP multiplexing\n" |
| 655 | DEFUN(cfg_msc_osmux, |
| 656 | cfg_msc_osmux_cmd, |
| 657 | "osmux (on|off|only)", |
| 658 | OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only use OSMUX\n") |
| 659 | { |
| 660 | if (strcmp(argv[0], "off") == 0) |
| 661 | gsmnet->use_osmux = OSMUX_USAGE_OFF; |
| 662 | else if (strcmp(argv[0], "on") == 0) |
| 663 | gsmnet->use_osmux = OSMUX_USAGE_ON; |
| 664 | else if (strcmp(argv[0], "only") == 0) |
| 665 | gsmnet->use_osmux = OSMUX_USAGE_ONLY; |
| 666 | |
| 667 | return CMD_SUCCESS; |
| 668 | } |
| 669 | |
Neels Hofmeyr | 9aac5c2 | 2020-05-27 00:04:26 +0200 | [diff] [blame] | 670 | #define NRI_STR "Mapping of Network Resource Indicators to this MSC, for MSC pooling\n" |
| 671 | DEFUN(cfg_msc_nri_bitlen, cfg_msc_nri_bitlen_cmd, |
| 672 | "nri bitlen <0-15>", |
| 673 | NRI_STR |
| 674 | "Set number of NRI bits to place in TMSI identities (always starting just after the most significant octet)\n" |
| 675 | "bit count (default: " OSMO_STRINGIFY_VAL(NRI_BITLEN_DEFAULT) ")\n") |
| 676 | { |
| 677 | gsmnet->vlr->cfg.nri_bitlen = atoi(argv[0]); |
| 678 | return CMD_SUCCESS; |
| 679 | } |
| 680 | |
| 681 | #define NRI_STR "Mapping of Network Resource Indicators to this MSC, for MSC pooling\n" |
| 682 | #define NRI_ARGS_TO_STR_FMT "%s%s%s" |
| 683 | #define NRI_ARGS_TO_STR_ARGS(ARGC, ARGV) ARGV[0], (ARGC>1)? ".." : "", (ARGC>1)? ARGV[1] : "" |
| 684 | #define NRI_FIRST_LAST_STR "First value of the NRI value range, should not surpass the configured 'nri bitlen'.\n" \ |
| 685 | "Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the" \ |
| 686 | " first value; if omitted, apply only the first value.\n" |
| 687 | |
| 688 | DEFUN(cfg_msc_nri_add, cfg_msc_nri_add_cmd, |
| 689 | "nri add <0-32767> [<0-32767>]", |
| 690 | NRI_STR "Add NRI value or range to the NRI mapping for this MSC\n" |
| 691 | NRI_FIRST_LAST_STR) |
| 692 | { |
| 693 | const char *message; |
| 694 | int rc = osmo_nri_ranges_vty_add(&message, NULL, gsmnet->vlr->cfg.nri_ranges, argc, argv, gsmnet->vlr->cfg.nri_bitlen); |
| 695 | if (message) { |
| 696 | vty_out(vty, "%% %s: " NRI_ARGS_TO_STR_FMT, message, NRI_ARGS_TO_STR_ARGS(argc, argv)); |
| 697 | } |
| 698 | if (rc < 0) |
| 699 | return CMD_WARNING; |
| 700 | return CMD_SUCCESS; |
| 701 | } |
| 702 | |
| 703 | DEFUN(cfg_msc_nri_del, cfg_msc_nri_del_cmd, |
| 704 | "nri del <0-32767> [<0-32767>]", |
| 705 | NRI_STR "Remove NRI value or range from the NRI mapping for this MSC\n" |
| 706 | NRI_FIRST_LAST_STR) |
| 707 | { |
| 708 | const char *message; |
| 709 | int rc = osmo_nri_ranges_vty_del(&message, NULL, gsmnet->vlr->cfg.nri_ranges, argc, argv); |
| 710 | if (message) { |
| 711 | vty_out(vty, "%% %s: " NRI_ARGS_TO_STR_FMT, message, NRI_ARGS_TO_STR_ARGS(argc, argv)); |
| 712 | } |
| 713 | if (rc < 0) |
| 714 | return CMD_WARNING; |
| 715 | return CMD_SUCCESS; |
| 716 | } |
| 717 | |
| 718 | static void msc_write_nri(struct vty *vty) |
| 719 | { |
| 720 | struct osmo_nri_range *r; |
| 721 | |
| 722 | llist_for_each_entry(r, &gsmnet->vlr->cfg.nri_ranges->entries, entry) { |
| 723 | if (osmo_nri_range_validate(r, 255)) |
| 724 | vty_out(vty, " %% INVALID RANGE:"); |
| 725 | vty_out(vty, " nri add %d", r->first); |
| 726 | if (r->first != r->last) |
| 727 | vty_out(vty, " %d", r->last); |
| 728 | vty_out(vty, "%s", VTY_NEWLINE); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | DEFUN(show_nri, show_nri_cmd, |
| 733 | "show nri", |
| 734 | SHOW_STR NRI_STR) |
| 735 | { |
| 736 | msc_write_nri(vty); |
| 737 | return CMD_SUCCESS; |
| 738 | } |
| 739 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 740 | static int config_write_msc(struct vty *vty) |
| 741 | { |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 742 | vty_out(vty, "msc%s", VTY_NEWLINE); |
Keith Whyte | 1587ffb | 2020-08-28 13:36:58 +0200 | [diff] [blame] | 743 | if (gsmnet->sms_db_file_path && strcmp(gsmnet->sms_db_file_path, SMS_DEFAULT_DB_FILE_PATH)) |
| 744 | vty_out(vty, " sms-database %s%s", gsmnet->sms_db_file_path, VTY_NEWLINE); |
Neels Hofmeyr | 80447eb | 2018-12-05 01:11:28 +0100 | [diff] [blame] | 745 | if (gsmnet->mncc_sock_path) |
| 746 | vty_out(vty, " mncc external %s%s", gsmnet->mncc_sock_path, VTY_NEWLINE); |
Neels Hofmeyr | 05c5680 | 2018-12-05 01:07:03 +0100 | [diff] [blame] | 747 | vty_out(vty, " mncc guard-timeout %i%s", |
Philipp Maier | 9ca7b31 | 2018-10-10 17:00:49 +0200 | [diff] [blame] | 748 | gsmnet->mncc_guard_timeout, VTY_NEWLINE); |
Vadim Yanitskiy | 64623e1 | 2018-11-28 23:05:51 +0700 | [diff] [blame] | 749 | vty_out(vty, " ncss guard-timeout %i%s", |
| 750 | gsmnet->ncss_guard_timeout, VTY_NEWLINE); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 751 | vty_out(vty, " %sassign-tmsi%s", |
| 752 | gsmnet->vlr->cfg.assign_tmsi? "" : "no ", VTY_NEWLINE); |
| 753 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 754 | vty_out(vty, " cs7-instance-a %u%s", gsmnet->a.cs7_instance, |
| 755 | VTY_NEWLINE); |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 756 | #if BUILD_IU |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 757 | vty_out(vty, " cs7-instance-iu %u%s", gsmnet->iu.cs7_instance, |
| 758 | VTY_NEWLINE); |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 759 | #endif |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 760 | |
Neels Hofmeyr | 97ce015 | 2017-10-29 02:10:38 +0100 | [diff] [blame] | 761 | if (gsmnet->vlr->cfg.auth_tuple_max_reuse_count) |
| 762 | vty_out(vty, " auth-tuple-max-reuse-count %d%s", |
| 763 | OSMO_MAX(-1, gsmnet->vlr->cfg.auth_tuple_max_reuse_count), |
| 764 | VTY_NEWLINE); |
| 765 | if (gsmnet->vlr->cfg.auth_reuse_old_sets_on_error) |
| 766 | vty_out(vty, " auth-tuple-reuse-on-error 1%s", |
| 767 | VTY_NEWLINE); |
| 768 | |
Oliver Smith | 03ded91 | 2019-05-02 10:40:50 +0200 | [diff] [blame] | 769 | if (gsmnet->vlr->cfg.check_imei_rqd) { |
| 770 | if (gsmnet->vlr->cfg.retrieve_imeisv_early) |
| 771 | vty_out(vty, " check-imei-rqd early%s", VTY_NEWLINE); |
| 772 | else |
| 773 | vty_out(vty, " check-imei-rqd 1%s", VTY_NEWLINE); |
| 774 | } |
Oliver Smith | 0fec28a | 2018-12-14 10:52:52 +0100 | [diff] [blame] | 775 | |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 776 | if (gsmnet->paging_response_timer != MSC_PAGING_RESPONSE_TIMER_DEFAULT) |
| 777 | vty_out(vty, " paging response-timer %u%s", gsmnet->paging_response_timer, VTY_NEWLINE); |
| 778 | |
Harald Welte | 69c54a8 | 2018-02-09 20:41:14 +0100 | [diff] [blame] | 779 | if (gsmnet->emergency.route_to_msisdn) { |
| 780 | vty_out(vty, " emergency-call route-to-msisdn %s%s", |
| 781 | gsmnet->emergency.route_to_msisdn, VTY_NEWLINE); |
| 782 | } |
| 783 | |
Vadim Yanitskiy | f40e46f | 2018-11-20 06:20:53 +0700 | [diff] [blame] | 784 | if (gsmnet->sms_over_gsup) |
| 785 | vty_out(vty, " sms-over-gsup%s", VTY_NEWLINE); |
| 786 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 787 | if (gsmnet->handover_number.range_start || gsmnet->handover_number.range_end) |
| 788 | vty_out(vty, " handover-number range %"PRIu64" %"PRIu64"%s", |
| 789 | gsmnet->handover_number.range_start, gsmnet->handover_number.range_end, |
| 790 | VTY_NEWLINE); |
| 791 | |
Pau Espin Pedrol | 4faff9e | 2019-05-06 19:29:11 +0200 | [diff] [blame] | 792 | if (gsmnet->use_osmux != OSMUX_USAGE_OFF) { |
| 793 | vty_out(vty, " osmux %s%s", gsmnet->use_osmux == OSMUX_USAGE_ON ? "on" : "only", |
| 794 | VTY_NEWLINE); |
| 795 | } |
| 796 | |
Neels Hofmeyr | 6c8afe1 | 2017-09-04 01:03:58 +0200 | [diff] [blame] | 797 | mgcp_client_config_write(vty, " "); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 798 | #ifdef BUILD_IU |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 799 | ranap_iu_vty_config_write(vty, " "); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 800 | #endif |
| 801 | |
Neels Hofmeyr | 880b950 | 2019-05-09 02:01:55 +0200 | [diff] [blame] | 802 | neighbor_ident_vty_write(vty); |
| 803 | |
Vadim Yanitskiy | ffc7f39 | 2020-01-18 18:39:41 +0700 | [diff] [blame] | 804 | /* Timer introspection commands (generic osmo_tdef API) */ |
| 805 | osmo_tdef_vty_groups_write(vty, " "); |
| 806 | |
Neels Hofmeyr | 9aac5c2 | 2020-05-27 00:04:26 +0200 | [diff] [blame] | 807 | msc_write_nri(vty); |
| 808 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 809 | return CMD_SUCCESS; |
| 810 | } |
| 811 | |
Max | c51609a | 2018-11-09 17:13:00 +0100 | [diff] [blame] | 812 | DEFUN(show_bsc, show_bsc_cmd, |
| 813 | "show bsc", SHOW_STR "BSC\n") |
| 814 | { |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 815 | struct ran_peer *rp; |
| 816 | llist_for_each_entry(rp, &gsmnet->a.sri->ran_peers, entry) { |
| 817 | vty_out(vty, "BSC %s %s%s", |
| 818 | osmo_sccp_inst_addr_name(gsmnet->a.sri->sccp, &rp->peer_addr), |
| 819 | osmo_fsm_inst_state_name(rp->fi), |
| 820 | VTY_NEWLINE); |
Max | c51609a | 2018-11-09 17:13:00 +0100 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | return CMD_SUCCESS; |
| 824 | } |
| 825 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 826 | static const char *get_trans_proto_str(const struct gsm_trans *trans) |
| 827 | { |
| 828 | static char buf[256]; |
| 829 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 830 | switch (trans->type) { |
| 831 | case TRANS_CC: |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 832 | snprintf(buf, sizeof(buf), "%s %4u %4u", |
| 833 | gsm48_cc_state_name(trans->cc.state), |
| 834 | trans->cc.Tcurrent, |
| 835 | trans->cc.T308_second); |
| 836 | break; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 837 | case TRANS_SMS: |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 838 | snprintf(buf, sizeof(buf), "CP:%s RP:%s", |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 839 | gsm411_cp_state_name(trans->sms.smc_inst.cp_state), |
| 840 | gsm411_rp_state_name(trans->sms.smr_inst.rp_state)); |
| 841 | break; |
| 842 | default: |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 843 | return NULL; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | return buf; |
| 847 | } |
| 848 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 849 | /* Prefix a given format string with a given amount of spaces */ |
| 850 | #define MSC_VTY_DUMP(vty, offset, fmt, args...) \ |
| 851 | vty_out(vty, "%*s" fmt, offset, "", ##args) |
| 852 | |
Neels Hofmeyr | 4014e48 | 2019-06-21 02:00:58 +0200 | [diff] [blame] | 853 | /* Print value of a named flag, prefixed with a given amount of spaces */ |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 854 | #define MSC_VTY_DUMP_FLAG(vty, offset, name, flag) \ |
| 855 | MSC_VTY_DUMP(vty, offset + 2, "%s: %*s%s%s", \ |
| 856 | name, 30 - (int)strlen(name), "", \ |
| 857 | flag ? "true" : "false", \ |
| 858 | VTY_NEWLINE) |
| 859 | |
| 860 | enum msc_vty_dump_flags { |
| 861 | MSC_VTY_DUMP_F_SUBSCR = (1 << 0), |
| 862 | MSC_VTY_DUMP_F_CONNECTION = (1 << 1), |
| 863 | MSC_VTY_DUMP_F_TRANSACTION = (1 << 2), |
| 864 | }; |
| 865 | |
| 866 | static void vty_dump_one_trans(struct vty *vty, const struct gsm_trans *trans, |
| 867 | int offset, uint8_t dump_flags) |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 868 | { |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 869 | const char *proto_str; |
| 870 | |
| 871 | if (dump_flags & MSC_VTY_DUMP_F_SUBSCR) { |
| 872 | MSC_VTY_DUMP(vty, offset, "Subscriber: %s%s", |
| 873 | vlr_subscr_name(msc_a_vsub(trans->msc_a)), |
| 874 | VTY_NEWLINE); |
| 875 | } |
| 876 | |
| 877 | if (dump_flags & MSC_VTY_DUMP_F_CONNECTION) { |
Neels Hofmeyr | 4014e48 | 2019-06-21 02:00:58 +0200 | [diff] [blame] | 878 | /* (If msc_a exists, there *must* be a non-null msc_a->c.msub) */ |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 879 | MSC_VTY_DUMP(vty, offset, "RAN connection: %s%s", |
| 880 | trans->msc_a ? msub_ran_conn_name(trans->msc_a->c.msub) |
| 881 | : "(not established)", |
| 882 | VTY_NEWLINE); |
| 883 | } |
| 884 | |
| 885 | MSC_VTY_DUMP(vty, offset, "Unique (global) identifier: 0x%08x%s", |
| 886 | trans->callref, VTY_NEWLINE); |
| 887 | MSC_VTY_DUMP(vty, offset, "GSM 04.07 identifier (%s): %u%s", |
| 888 | (trans->transaction_id & 0x08) ? "MO" : "MT", |
| 889 | trans->transaction_id, |
| 890 | VTY_NEWLINE); |
| 891 | |
| 892 | MSC_VTY_DUMP(vty, offset, "Type: %s%s", |
| 893 | trans_type_name(trans->type), |
| 894 | VTY_NEWLINE); |
| 895 | |
| 896 | if ((proto_str = get_trans_proto_str(trans))) { |
| 897 | MSC_VTY_DUMP(vty, offset, "Protocol specific: %s%s", |
| 898 | proto_str, VTY_NEWLINE); |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | static void vty_dump_one_conn(struct vty *vty, const struct msub *msub, |
| 903 | int offset, uint8_t dump_flags) |
| 904 | { |
| 905 | struct vlr_subscr *vsub = msub_vsub(msub); |
| 906 | struct msc_a *msc_a = msub_msc_a(msub); |
| 907 | char buf[128]; |
| 908 | |
| 909 | if (dump_flags & MSC_VTY_DUMP_F_SUBSCR) { |
| 910 | dump_flags = dump_flags &~ MSC_VTY_DUMP_F_SUBSCR; |
| 911 | MSC_VTY_DUMP(vty, offset, "Subscriber: %s%s", |
| 912 | vlr_subscr_name(vsub), |
| 913 | VTY_NEWLINE); |
| 914 | } |
| 915 | |
| 916 | MSC_VTY_DUMP(vty, offset, "RAN connection: %s%s", |
| 917 | msub_ran_conn_name(msub), |
| 918 | VTY_NEWLINE); |
| 919 | MSC_VTY_DUMP(vty, offset, "RAN connection state: %s%s", |
| 920 | osmo_fsm_inst_state_name(msc_a->c.fi), |
| 921 | VTY_NEWLINE); |
| 922 | |
| 923 | if (vsub) { |
| 924 | MSC_VTY_DUMP(vty, offset, "LAC / cell ID: %u / %u%s", |
Neels Hofmeyr | 41c0333 | 2020-06-24 15:02:27 +0200 | [diff] [blame] | 925 | msc_a->via_cell.lai.lac, msc_a->via_cell.cell_identity, |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 926 | VTY_NEWLINE); |
| 927 | } |
| 928 | |
| 929 | MSC_VTY_DUMP(vty, offset, "Use count total: %d%s", |
| 930 | osmo_use_count_total(&msc_a->use_count), |
| 931 | VTY_NEWLINE); |
| 932 | MSC_VTY_DUMP(vty, offset, "Use count: %s%s", |
| 933 | osmo_use_count_name_buf(buf, sizeof(buf), &msc_a->use_count), |
| 934 | VTY_NEWLINE); |
| 935 | |
| 936 | /* Transactions of this connection */ |
| 937 | if (dump_flags & MSC_VTY_DUMP_F_TRANSACTION) { |
| 938 | struct gsm_trans *trans; |
| 939 | unsigned int i = 0; |
| 940 | |
| 941 | /* Both subscriber and connection info is already printed */ |
| 942 | dump_flags = dump_flags &~ MSC_VTY_DUMP_F_CONNECTION; |
| 943 | dump_flags = dump_flags &~ MSC_VTY_DUMP_F_SUBSCR; |
| 944 | |
| 945 | llist_for_each_entry(trans, &gsmnet->trans_list, entry) { |
| 946 | if (trans->msc_a != msc_a) |
| 947 | continue; |
| 948 | MSC_VTY_DUMP(vty, offset, "Transaction #%02u: %s", |
| 949 | i++, VTY_NEWLINE); |
| 950 | vty_dump_one_trans(vty, trans, offset + 2, dump_flags); |
| 951 | } |
| 952 | } |
| 953 | } |
| 954 | |
| 955 | static void vty_dump_one_subscr(struct vty *vty, struct vlr_subscr *vsub, |
| 956 | int offset, uint8_t dump_flags) |
| 957 | { |
Vadim Yanitskiy | 09ce3dc | 2019-07-09 00:34:29 +0700 | [diff] [blame] | 958 | struct timespec now; |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 959 | char buf[128]; |
| 960 | |
Vadim Yanitskiy | dcf2868 | 2019-05-29 22:34:13 +0700 | [diff] [blame] | 961 | if (vsub->name[0] != '\0') { |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 962 | MSC_VTY_DUMP(vty, offset, "Name: '%s'%s", |
| 963 | vsub->name, VTY_NEWLINE); |
| 964 | } |
Vadim Yanitskiy | dcf2868 | 2019-05-29 22:34:13 +0700 | [diff] [blame] | 965 | if (vsub->msisdn[0] != '\0') { |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 966 | MSC_VTY_DUMP(vty, offset, "MSISDN: %s%s", |
| 967 | vsub->msisdn, VTY_NEWLINE); |
| 968 | } |
| 969 | |
| 970 | MSC_VTY_DUMP(vty, offset, "LAC / cell ID: %u / %u%s", |
| 971 | vsub->cgi.lai.lac, vsub->cgi.cell_identity, |
| 972 | VTY_NEWLINE); |
| 973 | MSC_VTY_DUMP(vty, offset, "RAN type: %s%s", |
| 974 | osmo_rat_type_name(vsub->cs.attached_via_ran), |
| 975 | VTY_NEWLINE); |
| 976 | |
| 977 | MSC_VTY_DUMP(vty, offset, "IMSI: %s%s", |
| 978 | vsub->imsi, VTY_NEWLINE); |
| 979 | if (vsub->tmsi != GSM_RESERVED_TMSI) { |
| 980 | MSC_VTY_DUMP(vty, offset, "TMSI: %08X%s", |
| 981 | vsub->tmsi, VTY_NEWLINE); |
| 982 | } |
| 983 | if (vsub->tmsi_new != GSM_RESERVED_TMSI) { |
| 984 | MSC_VTY_DUMP(vty, offset, "New TMSI: %08X%s", |
| 985 | vsub->tmsi_new, VTY_NEWLINE); |
| 986 | } |
| 987 | if (vsub->imei[0] != '\0') { |
| 988 | MSC_VTY_DUMP(vty, offset, "IMEI: %s%s", |
| 989 | vsub->imei, VTY_NEWLINE); |
| 990 | } |
| 991 | if (vsub->imeisv[0] != '\0') { |
| 992 | MSC_VTY_DUMP(vty, offset, "IMEISV: %s%s", |
| 993 | vsub->imeisv, VTY_NEWLINE); |
| 994 | } |
| 995 | |
| 996 | MSC_VTY_DUMP(vty, offset, "Flags: %s", VTY_NEWLINE); |
| 997 | MSC_VTY_DUMP_FLAG(vty, offset, "IMSI detached", |
| 998 | vsub->imsi_detached_flag); |
| 999 | MSC_VTY_DUMP_FLAG(vty, offset, "Conf. by radio contact", |
| 1000 | vsub->conf_by_radio_contact_ind); |
| 1001 | MSC_VTY_DUMP_FLAG(vty, offset, "Subscr. data conf. by HLR", |
| 1002 | vsub->sub_dataconf_by_hlr_ind); |
| 1003 | MSC_VTY_DUMP_FLAG(vty, offset, "Location conf. in HLR", |
| 1004 | vsub->loc_conf_in_hlr_ind); |
| 1005 | MSC_VTY_DUMP_FLAG(vty, offset, "Subscriber dormant", |
| 1006 | vsub->dormant_ind); |
| 1007 | MSC_VTY_DUMP_FLAG(vty, offset, "Received cancel location", |
| 1008 | vsub->cancel_loc_rx); |
| 1009 | MSC_VTY_DUMP_FLAG(vty, offset, "MS not reachable", |
| 1010 | vsub->ms_not_reachable_flag); |
| 1011 | MSC_VTY_DUMP_FLAG(vty, offset, "LA allowed", |
| 1012 | vsub->la_allowed); |
| 1013 | |
| 1014 | if (vsub->last_tuple) { |
| 1015 | struct vlr_auth_tuple *t = vsub->last_tuple; |
| 1016 | MSC_VTY_DUMP(vty, offset, "A3A8 last tuple (used %d times): %s", |
| 1017 | t->use_count, VTY_NEWLINE); |
| 1018 | MSC_VTY_DUMP(vty, offset + 2, "seq # : %d%s", |
| 1019 | t->key_seq, VTY_NEWLINE); |
| 1020 | MSC_VTY_DUMP(vty, offset + 2, "RAND : %s%s", |
| 1021 | osmo_hexdump(t->vec.rand, sizeof(t->vec.rand)), |
| 1022 | VTY_NEWLINE); |
| 1023 | MSC_VTY_DUMP(vty, offset + 2, "SRES : %s%s", |
| 1024 | osmo_hexdump(t->vec.sres, sizeof(t->vec.sres)), |
| 1025 | VTY_NEWLINE); |
| 1026 | MSC_VTY_DUMP(vty, offset + 2, "Kc : %s%s", |
| 1027 | osmo_hexdump(t->vec.kc, sizeof(t->vec.kc)), |
| 1028 | VTY_NEWLINE); |
| 1029 | } |
| 1030 | |
Vadim Yanitskiy | fc2b019 | 2020-01-18 07:20:14 +0700 | [diff] [blame] | 1031 | if (!vlr_timer(vsub->vlr, 3212)) { |
Vadim Yanitskiy | 09ce3dc | 2019-07-09 00:34:29 +0700 | [diff] [blame] | 1032 | MSC_VTY_DUMP(vty, offset, "Expires: never (T3212 is disabled)%s", |
| 1033 | VTY_NEWLINE); |
| 1034 | } else if (vsub->expire_lu == VLR_SUBSCRIBER_NO_EXPIRATION) { |
| 1035 | MSC_VTY_DUMP(vty, offset, "Expires: never%s", |
| 1036 | VTY_NEWLINE); |
| 1037 | } else if (osmo_clock_gettime(CLOCK_MONOTONIC, &now) == 0) { |
| 1038 | MSC_VTY_DUMP(vty, offset, "Expires: in %ld min %ld sec%s", |
| 1039 | (vsub->expire_lu - now.tv_sec) / 60, |
| 1040 | (vsub->expire_lu - now.tv_sec) % 60, |
| 1041 | VTY_NEWLINE); |
| 1042 | } |
| 1043 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1044 | MSC_VTY_DUMP(vty, offset, "Paging: %s paging for %d requests%s", |
| 1045 | vsub->cs.is_paging ? "is" : "not", |
| 1046 | llist_count(&vsub->cs.requests), |
| 1047 | VTY_NEWLINE); |
| 1048 | |
| 1049 | /* SGs related */ |
| 1050 | MSC_VTY_DUMP(vty, offset, "SGs-state: %s%s", |
| 1051 | osmo_fsm_inst_state_name(vsub->sgs_fsm), |
| 1052 | VTY_NEWLINE); |
| 1053 | MSC_VTY_DUMP(vty, offset, "SGs-MME: %s%s", |
Vadim Yanitskiy | dcf2868 | 2019-05-29 22:34:13 +0700 | [diff] [blame] | 1054 | vsub->sgs.mme_name[0] != '\0' ? vsub->sgs.mme_name : "(none)", |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1055 | VTY_NEWLINE); |
| 1056 | |
| 1057 | MSC_VTY_DUMP(vty, offset, "Use count total: %d%s", |
| 1058 | osmo_use_count_total(&vsub->use_count), |
| 1059 | VTY_NEWLINE); |
| 1060 | MSC_VTY_DUMP(vty, offset, "Use count: %s%s", |
| 1061 | osmo_use_count_name_buf(buf, sizeof(buf), &vsub->use_count), |
| 1062 | VTY_NEWLINE); |
| 1063 | |
| 1064 | /* Connection(s) and/or transactions of this subscriber */ |
| 1065 | if (dump_flags & MSC_VTY_DUMP_F_CONNECTION) { |
| 1066 | struct msub *msub = msub_for_vsub(vsub); |
| 1067 | if (!msub) |
| 1068 | return; |
| 1069 | |
| 1070 | /* Subscriber info is already printed */ |
| 1071 | dump_flags = dump_flags &~ MSC_VTY_DUMP_F_SUBSCR; |
| 1072 | |
| 1073 | MSC_VTY_DUMP(vty, offset, "Connection: %s", VTY_NEWLINE); |
| 1074 | vty_dump_one_conn(vty, msub, offset + 2, dump_flags); |
| 1075 | } else if (dump_flags & MSC_VTY_DUMP_F_TRANSACTION) { |
| 1076 | struct gsm_trans *trans; |
| 1077 | unsigned int i = 0; |
| 1078 | |
| 1079 | /* Subscriber info is already printed */ |
| 1080 | dump_flags = dump_flags &~ MSC_VTY_DUMP_F_SUBSCR; |
| 1081 | /* Do not print connection info, but mention it */ |
| 1082 | dump_flags |= MSC_VTY_DUMP_F_CONNECTION; |
| 1083 | |
| 1084 | llist_for_each_entry(trans, &gsmnet->trans_list, entry) { |
| 1085 | if (trans->vsub != vsub) |
| 1086 | continue; |
| 1087 | MSC_VTY_DUMP(vty, offset, "Transaction #%02u: %s", |
| 1088 | i++, VTY_NEWLINE); |
| 1089 | vty_dump_one_trans(vty, trans, offset + 2, dump_flags); |
| 1090 | } |
| 1091 | } |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1092 | } |
| 1093 | |
| 1094 | DEFUN(show_msc_transaction, show_msc_transaction_cmd, |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1095 | "show transaction", |
| 1096 | SHOW_STR "Transactions\n") |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1097 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1098 | struct gsm_trans *trans; |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1099 | uint8_t flags = 0x00; |
| 1100 | unsigned int i = 0; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1101 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1102 | flags |= MSC_VTY_DUMP_F_CONNECTION; |
| 1103 | flags |= MSC_VTY_DUMP_F_SUBSCR; |
| 1104 | |
| 1105 | llist_for_each_entry(trans, &gsmnet->trans_list, entry) { |
| 1106 | vty_out(vty, " Transaction #%02u: %s", i++, VTY_NEWLINE); |
| 1107 | vty_dump_one_trans(vty, trans, 4, flags); |
| 1108 | } |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1109 | |
| 1110 | return CMD_SUCCESS; |
| 1111 | } |
| 1112 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1113 | DEFUN(show_msc_conn, show_msc_conn_cmd, |
| 1114 | "show connection [trans]", |
| 1115 | SHOW_STR "Subscriber Connections\n" |
| 1116 | "Show child transactions of each connection\n") |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1117 | { |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1118 | uint8_t flags = 0x00; |
| 1119 | unsigned int i = 0; |
| 1120 | struct msub *msub; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1121 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1122 | if (argc > 0) |
| 1123 | flags |= MSC_VTY_DUMP_F_TRANSACTION; |
| 1124 | flags |= MSC_VTY_DUMP_F_SUBSCR; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1125 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1126 | llist_for_each_entry(msub, &msub_list, entry) { |
| 1127 | vty_out(vty, " Connection #%02u: %s", i++, VTY_NEWLINE); |
| 1128 | vty_dump_one_conn(vty, msub, 4, flags); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1129 | } |
| 1130 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1131 | return CMD_SUCCESS; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1132 | } |
| 1133 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1134 | #define SUBSCR_FLAGS "[(conn|trans|conn+trans)]" |
| 1135 | #define SUBSCR_FLAGS_HELP \ |
| 1136 | "Show child connections\n" \ |
| 1137 | "Show child transactions\n" \ |
| 1138 | "Show child connections and transactions\n" |
| 1139 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1140 | /* Subscriber */ |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1141 | DEFUN(show_subscr_cache, show_subscr_cache_cmd, |
| 1142 | "show subscriber cache " SUBSCR_FLAGS, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1143 | SHOW_STR "Show information about subscribers\n" |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1144 | "Display contents of subscriber cache\n" |
| 1145 | SUBSCR_FLAGS_HELP) |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1146 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1147 | struct vlr_subscr *vsub; |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1148 | unsigned int count = 0; |
| 1149 | uint8_t flags = 0x00; |
| 1150 | unsigned int i = 0; |
| 1151 | |
| 1152 | if (argc && strcmp(argv[0], "conn") == 0) |
| 1153 | flags |= MSC_VTY_DUMP_F_CONNECTION; |
| 1154 | else if (argc && strcmp(argv[0], "trans") == 0) |
| 1155 | flags |= MSC_VTY_DUMP_F_TRANSACTION; |
| 1156 | else if (argc && strcmp(argv[0], "conn+trans") == 0) |
| 1157 | flags |= MSC_VTY_DUMP_F_CONNECTION | MSC_VTY_DUMP_F_TRANSACTION; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1158 | |
| 1159 | llist_for_each_entry(vsub, &gsmnet->vlr->subscribers, list) { |
| 1160 | if (++count > 100) { |
| 1161 | vty_out(vty, "%% More than %d subscribers in cache," |
| 1162 | " stopping here.%s", count-1, VTY_NEWLINE); |
| 1163 | break; |
| 1164 | } |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1165 | vty_out(vty, " Subscriber #%02u: %s", i++, VTY_NEWLINE); |
| 1166 | vty_dump_one_subscr(vty, vsub, 4, flags); |
Harald Welte | 69c54a8 | 2018-02-09 20:41:14 +0100 | [diff] [blame] | 1167 | } |
| 1168 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1169 | return CMD_SUCCESS; |
| 1170 | } |
| 1171 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1172 | DEFUN(sms_send_pend, |
| 1173 | sms_send_pend_cmd, |
| 1174 | "sms send pending", |
| 1175 | "SMS related commands\n" "SMS Sending related commands\n" |
| 1176 | "Send all pending SMS") |
| 1177 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1178 | struct gsm_sms *sms; |
| 1179 | unsigned long long sms_id = 0; |
| 1180 | |
| 1181 | while (1) { |
| 1182 | sms = db_sms_get_next_unsent(gsmnet, sms_id, UINT_MAX); |
| 1183 | if (!sms) |
| 1184 | break; |
| 1185 | |
| 1186 | if (sms->receiver) |
Vadim Yanitskiy | 24e025e | 2018-11-22 15:42:39 +0700 | [diff] [blame] | 1187 | gsm411_send_sms(gsmnet, sms->receiver, sms); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1188 | |
| 1189 | sms_id = sms->id + 1; |
| 1190 | } |
| 1191 | |
| 1192 | return CMD_SUCCESS; |
| 1193 | } |
| 1194 | |
| 1195 | DEFUN(sms_delete_expired, |
| 1196 | sms_delete_expired_cmd, |
| 1197 | "sms delete expired", |
| 1198 | "SMS related commands\n" "SMS Database related commands\n" |
| 1199 | "Delete all expired SMS") |
| 1200 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1201 | struct gsm_sms *sms; |
| 1202 | unsigned long long sms_id = 0; |
| 1203 | long long num_deleted = 0; |
| 1204 | |
| 1205 | while (1) { |
| 1206 | sms = db_sms_get_next_unsent(gsmnet, sms_id, UINT_MAX); |
| 1207 | if (!sms) |
| 1208 | break; |
| 1209 | |
| 1210 | /* Skip SMS which are currently queued for sending. */ |
| 1211 | if (sms_queue_sms_is_pending(gsmnet->sms_queue, sms->id)) |
| 1212 | continue; |
| 1213 | |
| 1214 | /* Expiration check is performed by the DB layer. */ |
| 1215 | if (db_sms_delete_expired_message_by_id(sms->id) == 0) |
| 1216 | num_deleted++; |
| 1217 | |
| 1218 | sms_id = sms->id + 1; |
| 1219 | } |
| 1220 | |
| 1221 | if (num_deleted == 0) { |
| 1222 | vty_out(vty, "No expired SMS in database%s", VTY_NEWLINE); |
| 1223 | return CMD_WARNING; |
| 1224 | } |
| 1225 | |
| 1226 | vty_out(vty, "Deleted %llu expired SMS from database%s", num_deleted, VTY_NEWLINE); |
| 1227 | return CMD_SUCCESS; |
| 1228 | } |
| 1229 | |
| 1230 | static int _send_sms_str(struct vlr_subscr *receiver, |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1231 | const char *sender_msisdn, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1232 | char *str, uint8_t tp_pid) |
| 1233 | { |
| 1234 | struct gsm_network *net = receiver->vlr->user_ctx; |
| 1235 | struct gsm_sms *sms; |
| 1236 | |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1237 | sms = sms_from_text(receiver, sender_msisdn, 0, str); |
Vadim Yanitskiy | db4839c | 2019-12-01 18:52:58 +0700 | [diff] [blame] | 1238 | if (!sms) { |
| 1239 | LOGP(DLSMS, LOGL_ERROR, "Failed to allocate SMS\n"); |
| 1240 | return CMD_WARNING; |
| 1241 | } |
| 1242 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1243 | sms->protocol_id = tp_pid; |
| 1244 | |
| 1245 | /* store in database for the queue */ |
| 1246 | if (db_sms_store(sms) != 0) { |
| 1247 | LOGP(DLSMS, LOGL_ERROR, "Failed to store SMS in Database\n"); |
| 1248 | sms_free(sms); |
| 1249 | return CMD_WARNING; |
| 1250 | } |
| 1251 | LOGP(DLSMS, LOGL_DEBUG, "SMS stored in DB\n"); |
| 1252 | |
| 1253 | sms_free(sms); |
| 1254 | sms_queue_trigger(net->sms_queue); |
| 1255 | return CMD_SUCCESS; |
| 1256 | } |
| 1257 | |
| 1258 | static struct vlr_subscr *get_vsub_by_argv(struct gsm_network *gsmnet, |
| 1259 | const char *type, |
| 1260 | const char *id) |
| 1261 | { |
| 1262 | if (!strcmp(type, "extension") || !strcmp(type, "msisdn")) |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1263 | return vlr_subscr_find_by_msisdn(gsmnet->vlr, id, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1264 | else if (!strcmp(type, "imsi") || !strcmp(type, "id")) |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1265 | return vlr_subscr_find_by_imsi(gsmnet->vlr, id, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1266 | else if (!strcmp(type, "tmsi")) |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1267 | return vlr_subscr_find_by_tmsi(gsmnet->vlr, atoi(id), VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1268 | |
| 1269 | return NULL; |
| 1270 | } |
| 1271 | #define SUBSCR_TYPES "(msisdn|extension|imsi|tmsi|id)" |
| 1272 | #define SUBSCR_HELP "Operations on a Subscriber\n" \ |
| 1273 | "Identify subscriber by MSISDN (phone number)\n" \ |
| 1274 | "Legacy alias for 'msisdn'\n" \ |
| 1275 | "Identify subscriber by IMSI\n" \ |
| 1276 | "Identify subscriber by TMSI\n" \ |
Vadim Yanitskiy | 3ccd823 | 2019-05-16 01:35:23 +0700 | [diff] [blame] | 1277 | "Legacy alias for 'imsi'\n" \ |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1278 | "Identifier for the subscriber\n" |
| 1279 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1280 | DEFUN(show_subscr, show_subscr_cmd, |
| 1281 | "show subscriber " SUBSCR_TYPES " ID " SUBSCR_FLAGS, |
| 1282 | SHOW_STR SUBSCR_HELP SUBSCR_FLAGS_HELP) |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1283 | { |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1284 | struct vlr_subscr *vsub; |
| 1285 | uint8_t flags = 0x00; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1286 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1287 | vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1288 | if (!vsub) { |
| 1289 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1290 | argv[0], argv[1], VTY_NEWLINE); |
| 1291 | return CMD_WARNING; |
| 1292 | } |
| 1293 | |
Neels Hofmeyr | 14c6f3e | 2018-12-12 04:02:29 +0100 | [diff] [blame] | 1294 | /* In the vty output to the user, exclude this local use count added by vlr_subscr_get() in get_vsub_by_argv(). |
| 1295 | * This works, because: for get_vsub_by_argv() to succeed, there *must* have been at least one use count before |
| 1296 | * this, and since this is not multi-threaded, this vlr_subscr_put() cannot possibly reach a count of 0. */ |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1297 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1298 | |
Vadim Yanitskiy | 8014917 | 2019-05-16 06:13:29 +0700 | [diff] [blame] | 1299 | if (argc > 2 && strcmp(argv[2], "conn") == 0) |
| 1300 | flags |= MSC_VTY_DUMP_F_CONNECTION; |
| 1301 | else if (argc > 2 && strcmp(argv[2], "trans") == 0) |
| 1302 | flags |= MSC_VTY_DUMP_F_TRANSACTION; |
| 1303 | else if (argc > 2 && strcmp(argv[2], "conn+trans") == 0) |
| 1304 | flags |= MSC_VTY_DUMP_F_CONNECTION | MSC_VTY_DUMP_F_TRANSACTION; |
| 1305 | |
| 1306 | vty_out(vty, " Subscriber: %s", VTY_NEWLINE); |
| 1307 | vty_dump_one_subscr(vty, vsub, 4, flags); |
Neels Hofmeyr | 14c6f3e | 2018-12-12 04:02:29 +0100 | [diff] [blame] | 1308 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1309 | return CMD_SUCCESS; |
| 1310 | } |
| 1311 | |
Vadim Yanitskiy | b7ddbf3 | 2020-01-20 21:30:09 +0700 | [diff] [blame] | 1312 | DEFUN_DEPRECATED(subscriber_create, subscriber_create_cmd, |
| 1313 | "subscriber create imsi ID", |
| 1314 | "Operations on a Subscriber\n" |
| 1315 | "Create new subscriber\n" |
| 1316 | "Identify the subscriber by his IMSI\n" |
| 1317 | "Identifier for the subscriber\n") |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1318 | { |
| 1319 | vty_out(vty, "%% 'subscriber create' now needs to be done at osmo-hlr%s", |
| 1320 | VTY_NEWLINE); |
| 1321 | return CMD_WARNING; |
| 1322 | } |
| 1323 | |
| 1324 | DEFUN(subscriber_send_pending_sms, |
| 1325 | subscriber_send_pending_sms_cmd, |
| 1326 | "subscriber " SUBSCR_TYPES " ID sms pending-send", |
| 1327 | SUBSCR_HELP "SMS Operations\n" "Send pending SMS\n") |
| 1328 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1329 | struct vlr_subscr *vsub; |
| 1330 | struct gsm_sms *sms; |
| 1331 | |
| 1332 | vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 1333 | if (!vsub) { |
| 1334 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1335 | argv[0], argv[1], VTY_NEWLINE); |
| 1336 | return CMD_WARNING; |
| 1337 | } |
| 1338 | |
| 1339 | sms = db_sms_get_unsent_for_subscr(vsub, UINT_MAX); |
| 1340 | if (sms) |
Vadim Yanitskiy | 24e025e | 2018-11-22 15:42:39 +0700 | [diff] [blame] | 1341 | gsm411_send_sms(gsmnet, sms->receiver, sms); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1342 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1343 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1344 | |
| 1345 | return CMD_SUCCESS; |
| 1346 | } |
| 1347 | |
Neels Hofmeyr | f90496f | 2019-03-06 16:19:50 +0100 | [diff] [blame] | 1348 | DEFUN(subscriber_sms_delete_all, |
| 1349 | subscriber_sms_delete_all_cmd, |
| 1350 | "subscriber " SUBSCR_TYPES " ID sms delete-all", |
| 1351 | SUBSCR_HELP "SMS Operations\n" |
| 1352 | "Delete all SMS to be delivered to this subscriber" |
| 1353 | " -- WARNING: the SMS data for all unsent SMS for this subscriber" |
| 1354 | " WILL BE LOST.\n") |
| 1355 | { |
| 1356 | struct vlr_subscr *vsub; |
| 1357 | |
| 1358 | vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 1359 | if (!vsub) { |
| 1360 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1361 | argv[0], argv[1], VTY_NEWLINE); |
| 1362 | return CMD_WARNING; |
| 1363 | } |
| 1364 | |
| 1365 | db_sms_delete_by_msisdn(vsub->msisdn); |
| 1366 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1367 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | f90496f | 2019-03-06 16:19:50 +0100 | [diff] [blame] | 1368 | |
| 1369 | return CMD_SUCCESS; |
| 1370 | } |
| 1371 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1372 | DEFUN(subscriber_send_sms, |
| 1373 | subscriber_send_sms_cmd, |
| 1374 | "subscriber " SUBSCR_TYPES " ID sms sender " SUBSCR_TYPES " SENDER_ID send .LINE", |
| 1375 | SUBSCR_HELP "SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS Text\n") |
| 1376 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1377 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1378 | const char *sender_msisdn; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1379 | char *str; |
| 1380 | int rc; |
| 1381 | |
| 1382 | if (!vsub) { |
| 1383 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1384 | argv[0], argv[1], VTY_NEWLINE); |
| 1385 | rc = CMD_WARNING; |
| 1386 | goto err; |
| 1387 | } |
| 1388 | |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1389 | if (!strcmp(argv[2], "msisdn")) |
| 1390 | sender_msisdn = argv[3]; |
| 1391 | else { |
| 1392 | struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]); |
| 1393 | if (!sender) { |
| 1394 | vty_out(vty, "%% No sender found for %s %s%s", argv[2], argv[3], VTY_NEWLINE); |
| 1395 | rc = CMD_WARNING; |
| 1396 | goto err; |
| 1397 | } |
| 1398 | sender_msisdn = sender->msisdn; |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1399 | vlr_subscr_put(sender, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1400 | } |
| 1401 | |
| 1402 | str = argv_concat(argv, argc, 4); |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1403 | rc = _send_sms_str(vsub, sender_msisdn, str, 0); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1404 | talloc_free(str); |
| 1405 | |
| 1406 | err: |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1407 | if (vsub) |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1408 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1409 | |
| 1410 | return rc; |
| 1411 | } |
| 1412 | |
| 1413 | DEFUN(subscriber_silent_sms, |
| 1414 | subscriber_silent_sms_cmd, |
| 1415 | |
| 1416 | "subscriber " SUBSCR_TYPES " ID silent-sms sender " SUBSCR_TYPES " SENDER_ID send .LINE", |
| 1417 | SUBSCR_HELP "Silent SMS Operations\n" SUBSCR_HELP "Send SMS\n" "Actual SMS Text\n") |
| 1418 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1419 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1420 | const char *sender_msisdn; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1421 | char *str; |
| 1422 | int rc; |
| 1423 | |
| 1424 | if (!vsub) { |
| 1425 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1426 | argv[0], argv[1], VTY_NEWLINE); |
| 1427 | rc = CMD_WARNING; |
| 1428 | goto err; |
| 1429 | } |
| 1430 | |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1431 | if (!strcmp(argv[2], "msisdn")) { |
| 1432 | sender_msisdn = argv[3]; |
| 1433 | } else { |
| 1434 | struct vlr_subscr *sender = get_vsub_by_argv(gsmnet, argv[2], argv[3]); |
| 1435 | if (!sender) { |
| 1436 | vty_out(vty, "%% No sender found for %s %s%s", argv[2], argv[3], VTY_NEWLINE); |
| 1437 | rc = CMD_WARNING; |
| 1438 | goto err; |
| 1439 | } |
| 1440 | sender_msisdn = sender->msisdn; |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1441 | vlr_subscr_put(sender, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1442 | } |
| 1443 | |
| 1444 | str = argv_concat(argv, argc, 4); |
Harald Welte | 39b5548 | 2018-04-09 19:19:33 +0200 | [diff] [blame] | 1445 | rc = _send_sms_str(vsub, sender_msisdn, str, 64); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1446 | talloc_free(str); |
| 1447 | |
| 1448 | err: |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1449 | if (vsub) |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1450 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1451 | |
| 1452 | return rc; |
| 1453 | } |
| 1454 | |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1455 | #define CHAN_TYPES "(any|tch/f|tch/h|tch/any|sdcch)" |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1456 | #define CHAN_TYPE_HELP \ |
| 1457 | "Any channel\n" \ |
| 1458 | "TCH/F channel\n" \ |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1459 | "TCH/H channel\n" \ |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1460 | "Any TCH channel\n" \ |
| 1461 | "SDCCH channel\n" |
| 1462 | |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1463 | #define CHAN_MODES "(signalling|speech-hr|speech-fr|speech-efr|speech-amr)" |
| 1464 | #define CHAN_MODE_HELP \ |
| 1465 | "Signalling only\n" \ |
| 1466 | "Speech with HR codec\n" \ |
| 1467 | "Speech with FR codec\n" \ |
| 1468 | "Speech with EFR codec\n" \ |
| 1469 | "Speech with AMR codec\n" |
| 1470 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1471 | DEFUN(subscriber_silent_call_start, |
| 1472 | subscriber_silent_call_start_cmd, |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1473 | "subscriber " SUBSCR_TYPES " ID silent-call start " CHAN_TYPES " " CHAN_MODES " [IP] [<0-65535>]", |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1474 | SUBSCR_HELP "Silent call operation\n" "Start silent call\n" |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1475 | CHAN_TYPE_HELP CHAN_MODE_HELP |
| 1476 | "Target IP for RTP traffic (default 127.0.0.1)\n" |
| 1477 | "Target port for RTP traffic (default: 4000)\n") |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1478 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1479 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1480 | struct gsm0808_channel_type ct; |
| 1481 | const char *ip; |
| 1482 | uint16_t port; |
| 1483 | int rc, speech; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1484 | |
| 1485 | if (!vsub) { |
| 1486 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1487 | argv[0], argv[1], VTY_NEWLINE); |
| 1488 | return CMD_WARNING; |
| 1489 | } |
| 1490 | |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1491 | memset(&ct, 0x00, sizeof(ct)); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1492 | |
Sylvain Munaut | 9355830 | 2019-02-14 20:13:08 +0100 | [diff] [blame] | 1493 | if (!strcmp(argv[3], "signalling")) { |
| 1494 | ct.ch_indctr = GSM0808_CHAN_SIGN; |
| 1495 | ct.perm_spch[0] = 0; /* Spare but required */ |
| 1496 | ct.perm_spch_len = 1; |
| 1497 | } else if (!strcmp(argv[3], "speech-hr")) { |
| 1498 | ct.ch_indctr = GSM0808_CHAN_SPEECH; |
| 1499 | ct.perm_spch[0] = GSM0808_PERM_HR1; |
| 1500 | ct.perm_spch_len = 1; |
| 1501 | } else if (!strcmp(argv[3], "speech-fr")) { |
| 1502 | ct.ch_indctr = GSM0808_CHAN_SPEECH; |
| 1503 | ct.perm_spch[0] = GSM0808_PERM_FR1; |
| 1504 | ct.perm_spch_len = 1; |
| 1505 | } else if (!strcmp(argv[3], "speech-efr")) { |
| 1506 | ct.ch_indctr = GSM0808_CHAN_SPEECH; |
| 1507 | ct.perm_spch[0] = GSM0808_PERM_FR2; |
| 1508 | ct.perm_spch_len = 1; |
| 1509 | } else if (!strcmp(argv[3], "speech-amr")) { |
| 1510 | ct.ch_indctr = GSM0808_CHAN_SPEECH; |
| 1511 | ct.perm_spch[0] = GSM0808_PERM_FR3; |
| 1512 | ct.perm_spch[1] = GSM0808_PERM_HR3; |
| 1513 | ct.perm_spch_len = 2; |
| 1514 | } |
| 1515 | |
| 1516 | speech = ct.ch_indctr == GSM0808_CHAN_SPEECH; |
| 1517 | |
| 1518 | if (!strcmp(argv[2], "tch/f")) |
| 1519 | ct.ch_rate_type = speech ? GSM0808_SPEECH_FULL_BM : GSM0808_SIGN_FULL_BM; |
| 1520 | else if (!strcmp(argv[2], "tch/h")) |
| 1521 | ct.ch_rate_type = speech ? GSM0808_SPEECH_HALF_LM : GSM0808_SIGN_HALF_LM; |
| 1522 | else if (!strcmp(argv[2], "tch/any")) |
| 1523 | ct.ch_rate_type = speech ? GSM0808_SPEECH_FULL_PREF : GSM0808_SIGN_FULL_PREF; |
| 1524 | else if (!strcmp(argv[2], "sdcch")) { |
| 1525 | if (speech) { |
| 1526 | vty_out(vty, "Can't request speech on SDCCH%s", VTY_NEWLINE); |
| 1527 | return CMD_WARNING; |
| 1528 | } |
| 1529 | ct.ch_rate_type = GSM0808_SIGN_SDCCH; |
| 1530 | } else |
| 1531 | ct.ch_rate_type = speech ? GSM0808_SPEECH_FULL_PREF : GSM0808_SIGN_ANY; |
| 1532 | |
| 1533 | ip = argc >= 5 ? argv[4] : "127.0.0.1"; |
| 1534 | port = argc >= 6 ? atoi(argv[5]) : 4000; |
| 1535 | |
| 1536 | rc = gsm_silent_call_start(vsub, &ct, ip, port, vty); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1537 | switch (rc) { |
| 1538 | case -ENODEV: |
| 1539 | vty_out(vty, "%% Subscriber not attached%s", VTY_NEWLINE); |
| 1540 | break; |
| 1541 | default: |
| 1542 | if (rc) |
| 1543 | vty_out(vty, "%% Cannot start silent call (rc=%d)%s", rc, VTY_NEWLINE); |
| 1544 | else |
| 1545 | vty_out(vty, "%% Silent call initiated%s", VTY_NEWLINE); |
| 1546 | break; |
| 1547 | } |
| 1548 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1549 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1550 | return rc ? CMD_WARNING : CMD_SUCCESS; |
| 1551 | } |
| 1552 | |
| 1553 | DEFUN(subscriber_silent_call_stop, |
| 1554 | subscriber_silent_call_stop_cmd, |
| 1555 | "subscriber " SUBSCR_TYPES " ID silent-call stop", |
| 1556 | SUBSCR_HELP "Silent call operation\n" "Stop silent call\n" |
| 1557 | CHAN_TYPE_HELP) |
| 1558 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1559 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 1560 | int rc; |
| 1561 | |
| 1562 | if (!vsub) { |
| 1563 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1564 | argv[0], argv[1], VTY_NEWLINE); |
| 1565 | return CMD_WARNING; |
| 1566 | } |
| 1567 | |
| 1568 | rc = gsm_silent_call_stop(vsub); |
| 1569 | switch (rc) { |
| 1570 | case -ENODEV: |
| 1571 | vty_out(vty, "%% No active connection for subscriber%s", VTY_NEWLINE); |
| 1572 | break; |
| 1573 | case -ENOENT: |
| 1574 | vty_out(vty, "%% Subscriber has no silent call active%s", |
| 1575 | VTY_NEWLINE); |
| 1576 | break; |
| 1577 | default: |
| 1578 | if (rc) |
| 1579 | vty_out(vty, "%% Cannot stop silent call (rc=%d)%s", rc, VTY_NEWLINE); |
| 1580 | else |
| 1581 | vty_out(vty, "%% Silent call stopped%s", VTY_NEWLINE); |
| 1582 | break; |
| 1583 | } |
| 1584 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1585 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1586 | return rc ? CMD_WARNING : CMD_SUCCESS; |
| 1587 | } |
| 1588 | |
| 1589 | DEFUN(subscriber_ussd_notify, |
| 1590 | subscriber_ussd_notify_cmd, |
| 1591 | "subscriber " SUBSCR_TYPES " ID ussd-notify (0|1|2) .TEXT", |
| 1592 | SUBSCR_HELP "Send a USSD notify to the subscriber\n" |
| 1593 | "Alerting Level 0\n" |
| 1594 | "Alerting Level 1\n" |
| 1595 | "Alerting Level 2\n" |
| 1596 | "Text of USSD message to send\n") |
| 1597 | { |
| 1598 | char *text; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1599 | struct msc_a *msc_a; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1600 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 1601 | int level; |
| 1602 | |
| 1603 | if (!vsub) { |
| 1604 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1605 | argv[0], argv[1], VTY_NEWLINE); |
| 1606 | return CMD_WARNING; |
| 1607 | } |
| 1608 | |
| 1609 | level = atoi(argv[2]); |
| 1610 | text = argv_concat(argv, argc, 3); |
| 1611 | if (!text) { |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1612 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1613 | return CMD_WARNING; |
| 1614 | } |
| 1615 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1616 | msc_a = msc_a_for_vsub(vsub, true); |
| 1617 | if (!msc_a || msc_a->c.remote_to) { |
| 1618 | vty_out(vty, "%% An active connection and local MSC-A role is required for %s %s%s", |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1619 | argv[0], argv[1], VTY_NEWLINE); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1620 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1621 | talloc_free(text); |
| 1622 | return CMD_WARNING; |
| 1623 | } |
| 1624 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1625 | msc_send_ussd_notify(msc_a, level, text); |
Vadim Yanitskiy | f20c6b7 | 2018-11-29 01:20:58 +0700 | [diff] [blame] | 1626 | /* FIXME: since we don't allocate a transaction here, |
| 1627 | * we use dummy GSM 04.07 transaction ID. */ |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1628 | msc_send_ussd_release_complete(msc_a, 0x00); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1629 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1630 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1631 | talloc_free(text); |
| 1632 | return CMD_SUCCESS; |
| 1633 | } |
| 1634 | |
| 1635 | DEFUN(subscriber_paging, |
| 1636 | subscriber_paging_cmd, |
| 1637 | "subscriber " SUBSCR_TYPES " ID paging", |
| 1638 | SUBSCR_HELP "Issue an empty Paging for the subscriber (for debugging)\n") |
| 1639 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1640 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1641 | struct paging_request *req; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1642 | |
| 1643 | if (!vsub) { |
| 1644 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1645 | argv[0], argv[1], VTY_NEWLINE); |
| 1646 | return CMD_WARNING; |
| 1647 | } |
| 1648 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1649 | req = paging_request_start(vsub, PAGING_CAUSE_CALL_CONVERSATIONAL, |
| 1650 | NULL, NULL, "manual Paging from VTY"); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1651 | if (req) |
| 1652 | vty_out(vty, "%% paging subscriber%s", VTY_NEWLINE); |
| 1653 | else |
| 1654 | vty_out(vty, "%% paging subscriber failed%s", VTY_NEWLINE); |
| 1655 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1656 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1657 | return req ? CMD_SUCCESS : CMD_WARNING; |
| 1658 | } |
| 1659 | |
| 1660 | static int loop_by_char(uint8_t ch) |
| 1661 | { |
| 1662 | switch (ch) { |
| 1663 | case 'a': |
| 1664 | return GSM414_LOOP_A; |
| 1665 | case 'b': |
| 1666 | return GSM414_LOOP_B; |
| 1667 | case 'c': |
| 1668 | return GSM414_LOOP_C; |
| 1669 | case 'd': |
| 1670 | return GSM414_LOOP_D; |
| 1671 | case 'e': |
| 1672 | return GSM414_LOOP_E; |
| 1673 | case 'f': |
| 1674 | return GSM414_LOOP_F; |
| 1675 | case 'i': |
| 1676 | return GSM414_LOOP_I; |
| 1677 | } |
| 1678 | return -1; |
| 1679 | } |
| 1680 | |
| 1681 | DEFUN(subscriber_mstest_close, |
| 1682 | subscriber_mstest_close_cmd, |
| 1683 | "subscriber " SUBSCR_TYPES " ID ms-test close-loop (a|b|c|d|e|f|i)", |
| 1684 | SUBSCR_HELP "Send a TS 04.14 MS Test Command to subscriber\n" |
| 1685 | "Close a TCH Loop inside the MS\n" |
| 1686 | "Loop Type A\n" |
| 1687 | "Loop Type B\n" |
| 1688 | "Loop Type C\n" |
| 1689 | "Loop Type D\n" |
| 1690 | "Loop Type E\n" |
| 1691 | "Loop Type F\n" |
| 1692 | "Loop Type I\n") |
| 1693 | { |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1694 | struct msc_a *msc_a; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1695 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 1696 | const char *loop_str; |
| 1697 | int loop_mode; |
| 1698 | |
| 1699 | if (!vsub) { |
| 1700 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1701 | argv[0], argv[1], VTY_NEWLINE); |
| 1702 | return CMD_WARNING; |
| 1703 | } |
| 1704 | |
| 1705 | loop_str = argv[2]; |
| 1706 | loop_mode = loop_by_char(loop_str[0]); |
| 1707 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1708 | msc_a = msc_a_for_vsub(vsub, true); |
| 1709 | if (!msc_a) { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1710 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 1711 | argv[0], argv[1], VTY_NEWLINE); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1712 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1713 | return CMD_WARNING; |
| 1714 | } |
| 1715 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1716 | gsm0414_tx_close_tch_loop_cmd(msc_a, loop_mode); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1717 | |
Vadim Yanitskiy | 817ad90 | 2020-07-29 05:47:01 +0700 | [diff] [blame] | 1718 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1719 | return CMD_SUCCESS; |
| 1720 | } |
| 1721 | |
| 1722 | DEFUN(subscriber_mstest_open, |
| 1723 | subscriber_mstest_open_cmd, |
| 1724 | "subscriber " SUBSCR_TYPES " ID ms-test open-loop", |
| 1725 | SUBSCR_HELP "Send a TS 04.14 MS Test Command to subscriber\n" |
| 1726 | "Open a TCH Loop inside the MS\n") |
| 1727 | { |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1728 | struct msc_a *msc_a; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1729 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], argv[1]); |
| 1730 | |
| 1731 | if (!vsub) { |
| 1732 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1733 | argv[0], argv[1], VTY_NEWLINE); |
| 1734 | return CMD_WARNING; |
| 1735 | } |
| 1736 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1737 | msc_a = msc_a_for_vsub(vsub, true); |
| 1738 | if (!msc_a) { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1739 | vty_out(vty, "%% An active connection is required for %s %s%s", |
| 1740 | argv[0], argv[1], VTY_NEWLINE); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1741 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1742 | return CMD_WARNING; |
| 1743 | } |
| 1744 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1745 | gsm0414_tx_open_loop_cmd(msc_a); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1746 | |
Vadim Yanitskiy | 817ad90 | 2020-07-29 05:47:01 +0700 | [diff] [blame] | 1747 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1748 | return CMD_SUCCESS; |
| 1749 | } |
| 1750 | |
| 1751 | DEFUN(ena_subscr_expire, |
| 1752 | ena_subscr_expire_cmd, |
| 1753 | "subscriber " SUBSCR_TYPES " ID expire", |
| 1754 | SUBSCR_HELP "Expire the subscriber Now\n") |
| 1755 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1756 | struct vlr_subscr *vsub = get_vsub_by_argv(gsmnet, argv[0], |
| 1757 | argv[1]); |
| 1758 | |
| 1759 | if (!vsub) { |
| 1760 | vty_out(vty, "%% No subscriber found for %s %s%s", |
| 1761 | argv[0], argv[1], VTY_NEWLINE); |
| 1762 | return CMD_WARNING; |
| 1763 | } |
| 1764 | |
| 1765 | if (vlr_subscr_expire(vsub)) |
| 1766 | vty_out(vty, "%% VLR released subscriber %s%s", |
| 1767 | vlr_subscr_name(vsub), VTY_NEWLINE); |
| 1768 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1769 | if (osmo_use_count_total(&vsub->use_count) > 1) |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1770 | vty_out(vty, "%% Subscriber %s is still in use," |
| 1771 | " should be released soon%s", |
| 1772 | vlr_subscr_name(vsub), VTY_NEWLINE); |
| 1773 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1774 | vlr_subscr_put(vsub, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1775 | return CMD_SUCCESS; |
| 1776 | } |
| 1777 | |
| 1778 | static int scall_cbfn(unsigned int subsys, unsigned int signal, |
| 1779 | void *handler_data, void *signal_data) |
| 1780 | { |
| 1781 | struct scall_signal_data *sigdata = signal_data; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1782 | struct vty *vty = sigdata->vty; |
| 1783 | |
| 1784 | if (!vty_is_active(vty)) |
| 1785 | return 0; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1786 | |
| 1787 | switch (signal) { |
| 1788 | case S_SCALL_SUCCESS: |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1789 | vty_out(vty, "%% Silent call success%s", VTY_NEWLINE); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1790 | break; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1791 | case S_SCALL_FAILED: |
| 1792 | vty_out(vty, "%% Silent call failed%s", VTY_NEWLINE); |
| 1793 | break; |
| 1794 | case S_SCALL_DETACHED: |
| 1795 | vty_out(vty, "%% Silent call ended%s", VTY_NEWLINE); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1796 | break; |
| 1797 | } |
| 1798 | return 0; |
| 1799 | } |
| 1800 | |
| 1801 | DEFUN(show_stats, |
| 1802 | show_stats_cmd, |
| 1803 | "show statistics", |
| 1804 | SHOW_STR "Display network statistics\n") |
| 1805 | { |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1806 | vty_out(vty, "Location Update : %" PRIu64 " attach, %" PRIu64 " normal, %" PRIu64 " periodic%s", |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1807 | gsmnet->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_ATTACH].current, |
| 1808 | gsmnet->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_NORMAL].current, |
| 1809 | gsmnet->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_PERIODIC].current, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1810 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1811 | vty_out(vty, "IMSI Detach Indications : %" PRIu64 "%s", |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1812 | gsmnet->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_TYPE_DETACH].current, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1813 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1814 | vty_out(vty, "Location Updating Results: %" PRIu64 " completed, %" PRIu64 " failed%s", |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1815 | gsmnet->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_COMPLETED].current, |
| 1816 | gsmnet->msc_ctrs->ctr[MSC_CTR_LOC_UPDATE_FAILED].current, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1817 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1818 | vty_out(vty, "SMS MO : %" PRIu64 " submitted, %" PRIu64 " no receiver%s", |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1819 | gsmnet->msc_ctrs->ctr[MSC_CTR_SMS_SUBMITTED].current, |
| 1820 | gsmnet->msc_ctrs->ctr[MSC_CTR_SMS_NO_RECEIVER].current, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1821 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1822 | vty_out(vty, "SMS MT : %" PRIu64 " delivered, %" PRIu64 " no memory, %" PRIu64 " other error%s", |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1823 | gsmnet->msc_ctrs->ctr[MSC_CTR_SMS_DELIVERED].current, |
| 1824 | gsmnet->msc_ctrs->ctr[MSC_CTR_SMS_RP_ERR_MEM].current, |
| 1825 | gsmnet->msc_ctrs->ctr[MSC_CTR_SMS_RP_ERR_OTHER].current, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1826 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1827 | vty_out(vty, "MO Calls : %" PRIu64 " setup, %" PRIu64 " connect ack%s", |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1828 | gsmnet->msc_ctrs->ctr[MSC_CTR_CALL_MO_SETUP].current, |
| 1829 | gsmnet->msc_ctrs->ctr[MSC_CTR_CALL_MO_CONNECT_ACK].current, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1830 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1831 | vty_out(vty, "MT Calls : %" PRIu64 " setup, %" PRIu64 " connect%s", |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1832 | gsmnet->msc_ctrs->ctr[MSC_CTR_CALL_MT_SETUP].current, |
| 1833 | gsmnet->msc_ctrs->ctr[MSC_CTR_CALL_MT_CONNECT].current, |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1834 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1835 | vty_out(vty, "MO NC SS/USSD : %" PRIu64 " requests, %" PRIu64 " established, %" PRIu64 " rejected%s", |
Vadim Yanitskiy | 8e25cc5 | 2018-06-23 03:32:20 +0700 | [diff] [blame] | 1836 | gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MO_REQUESTS].current, |
| 1837 | gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MO_ESTABLISHED].current, |
| 1838 | gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MO_REQUESTS].current |
| 1839 | - gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MO_ESTABLISHED].current, |
| 1840 | VTY_NEWLINE); |
Pau Espin Pedrol | 3710623 | 2018-11-19 11:10:37 +0100 | [diff] [blame] | 1841 | vty_out(vty, "MT NC SS/USSD : %" PRIu64 " requests, %" PRIu64 " established, %" PRIu64 " rejected%s", |
Vadim Yanitskiy | 8e25cc5 | 2018-06-23 03:32:20 +0700 | [diff] [blame] | 1842 | gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MT_REQUESTS].current, |
| 1843 | gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MT_ESTABLISHED].current, |
| 1844 | gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MT_REQUESTS].current |
| 1845 | - gsmnet->msc_ctrs->ctr[MSC_CTR_NC_SS_MT_ESTABLISHED].current, |
| 1846 | VTY_NEWLINE); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1847 | return CMD_SUCCESS; |
| 1848 | } |
| 1849 | |
| 1850 | DEFUN(show_smsqueue, |
| 1851 | show_smsqueue_cmd, |
| 1852 | "show sms-queue", |
| 1853 | SHOW_STR "Display SMSqueue statistics\n") |
| 1854 | { |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1855 | sms_queue_stats(gsmnet->sms_queue, vty); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1856 | return CMD_SUCCESS; |
| 1857 | } |
| 1858 | |
| 1859 | DEFUN(smsqueue_trigger, |
| 1860 | smsqueue_trigger_cmd, |
| 1861 | "sms-queue trigger", |
| 1862 | "SMS Queue\n" "Trigger sending messages\n") |
| 1863 | { |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1864 | sms_queue_trigger(gsmnet->sms_queue); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1865 | return CMD_SUCCESS; |
| 1866 | } |
| 1867 | |
| 1868 | DEFUN(smsqueue_max, |
| 1869 | smsqueue_max_cmd, |
| 1870 | "sms-queue max-pending <1-500>", |
| 1871 | "SMS Queue\n" "SMS to deliver in parallel\n" "Amount\n") |
| 1872 | { |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1873 | sms_queue_set_max_pending(gsmnet->sms_queue, atoi(argv[0])); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1874 | return CMD_SUCCESS; |
| 1875 | } |
| 1876 | |
| 1877 | DEFUN(smsqueue_clear, |
| 1878 | smsqueue_clear_cmd, |
| 1879 | "sms-queue clear", |
| 1880 | "SMS Queue\n" "Clear the queue of pending SMS\n") |
| 1881 | { |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1882 | sms_queue_clear(gsmnet->sms_queue); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1883 | return CMD_SUCCESS; |
| 1884 | } |
| 1885 | |
| 1886 | DEFUN(smsqueue_fail, |
| 1887 | smsqueue_fail_cmd, |
| 1888 | "sms-queue max-failure <1-500>", |
| 1889 | "SMS Queue\n" "Maximum amount of delivery failures\n" "Amount\n") |
| 1890 | { |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 1891 | sms_queue_set_max_failure(gsmnet->sms_queue, atoi(argv[0])); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1892 | return CMD_SUCCESS; |
| 1893 | } |
| 1894 | |
| 1895 | |
| 1896 | DEFUN(cfg_mncc_int, cfg_mncc_int_cmd, |
| 1897 | "mncc-int", "Configure internal MNCC handler") |
| 1898 | { |
| 1899 | vty->node = MNCC_INT_NODE; |
| 1900 | |
| 1901 | return CMD_SUCCESS; |
| 1902 | } |
| 1903 | |
| 1904 | static struct cmd_node mncc_int_node = { |
| 1905 | MNCC_INT_NODE, |
| 1906 | "%s(config-mncc-int)# ", |
| 1907 | 1, |
| 1908 | }; |
| 1909 | |
| 1910 | static const struct value_string tchf_codec_names[] = { |
| 1911 | { GSM48_CMODE_SPEECH_V1, "fr" }, |
| 1912 | { GSM48_CMODE_SPEECH_EFR, "efr" }, |
| 1913 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 1914 | { 0, NULL } |
| 1915 | }; |
| 1916 | |
| 1917 | static const struct value_string tchh_codec_names[] = { |
| 1918 | { GSM48_CMODE_SPEECH_V1, "hr" }, |
| 1919 | { GSM48_CMODE_SPEECH_AMR, "amr" }, |
| 1920 | { 0, NULL } |
| 1921 | }; |
| 1922 | |
| 1923 | static int config_write_mncc_int(struct vty *vty) |
| 1924 | { |
| 1925 | vty_out(vty, "mncc-int%s", VTY_NEWLINE); |
| 1926 | vty_out(vty, " default-codec tch-f %s%s", |
| 1927 | get_value_string(tchf_codec_names, mncc_int.def_codec[0]), |
| 1928 | VTY_NEWLINE); |
| 1929 | vty_out(vty, " default-codec tch-h %s%s", |
| 1930 | get_value_string(tchh_codec_names, mncc_int.def_codec[1]), |
| 1931 | VTY_NEWLINE); |
| 1932 | |
| 1933 | return CMD_SUCCESS; |
| 1934 | } |
| 1935 | |
| 1936 | DEFUN(mnccint_def_codec_f, |
| 1937 | mnccint_def_codec_f_cmd, |
| 1938 | "default-codec tch-f (fr|efr|amr)", |
| 1939 | "Set default codec\n" "Codec for TCH/F\n" |
| 1940 | "Full-Rate\n" "Enhanced Full-Rate\n" "Adaptive Multi-Rate\n") |
| 1941 | { |
| 1942 | mncc_int.def_codec[0] = get_string_value(tchf_codec_names, argv[0]); |
| 1943 | |
| 1944 | return CMD_SUCCESS; |
| 1945 | } |
| 1946 | |
| 1947 | DEFUN(mnccint_def_codec_h, |
| 1948 | mnccint_def_codec_h_cmd, |
| 1949 | "default-codec tch-h (hr|amr)", |
| 1950 | "Set default codec\n" "Codec for TCH/H\n" |
| 1951 | "Half-Rate\n" "Adaptive Multi-Rate\n") |
| 1952 | { |
| 1953 | mncc_int.def_codec[1] = get_string_value(tchh_codec_names, argv[0]); |
| 1954 | |
| 1955 | return CMD_SUCCESS; |
| 1956 | } |
| 1957 | |
| 1958 | |
| 1959 | DEFUN(logging_fltr_imsi, |
| 1960 | logging_fltr_imsi_cmd, |
| 1961 | "logging filter imsi IMSI", |
| 1962 | LOGGING_STR FILTER_STR |
| 1963 | "Filter log messages by IMSI\n" "IMSI to be used as filter\n") |
| 1964 | { |
| 1965 | struct vlr_subscr *vlr_subscr; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1966 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 1967 | const char *imsi = argv[0]; |
| 1968 | |
| 1969 | if (!tgt) |
| 1970 | return CMD_WARNING; |
| 1971 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1972 | vlr_subscr = vlr_subscr_find_by_imsi(gsmnet->vlr, imsi, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1973 | |
| 1974 | if (!vlr_subscr) { |
| 1975 | vty_out(vty, "%%no subscriber with IMSI(%s)%s", |
| 1976 | argv[0], VTY_NEWLINE); |
| 1977 | return CMD_WARNING; |
| 1978 | } |
| 1979 | |
| 1980 | log_set_filter_vlr_subscr(tgt, vlr_subscr); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 1981 | vlr_subscr_put(vlr_subscr, VSUB_USE_VTY); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 1982 | return CMD_SUCCESS; |
| 1983 | } |
| 1984 | |
| 1985 | static struct cmd_node hlr_node = { |
| 1986 | HLR_NODE, |
| 1987 | "%s(config-hlr)# ", |
| 1988 | 1, |
| 1989 | }; |
| 1990 | |
| 1991 | DEFUN(cfg_hlr, cfg_hlr_cmd, |
| 1992 | "hlr", "Configure connection to the HLR") |
| 1993 | { |
| 1994 | vty->node = HLR_NODE; |
| 1995 | return CMD_SUCCESS; |
| 1996 | } |
| 1997 | |
| 1998 | DEFUN(cfg_hlr_remote_ip, cfg_hlr_remote_ip_cmd, "remote-ip A.B.C.D", |
| 1999 | "Remote GSUP address of the HLR\n" |
| 2000 | "Remote GSUP address (default: " MSC_HLR_REMOTE_IP_DEFAULT ")") |
| 2001 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2002 | talloc_free((void*)gsmnet->gsup_server_addr_str); |
| 2003 | gsmnet->gsup_server_addr_str = talloc_strdup(gsmnet, argv[0]); |
| 2004 | return CMD_SUCCESS; |
| 2005 | } |
| 2006 | |
| 2007 | DEFUN(cfg_hlr_remote_port, cfg_hlr_remote_port_cmd, "remote-port <1-65535>", |
| 2008 | "Remote GSUP port of the HLR\n" |
| 2009 | "Remote GSUP port (default: " OSMO_STRINGIFY(MSC_HLR_REMOTE_PORT_DEFAULT) ")") |
| 2010 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2011 | gsmnet->gsup_server_port = atoi(argv[0]); |
| 2012 | return CMD_SUCCESS; |
| 2013 | } |
| 2014 | |
Neels Hofmeyr | 3a3ed9b | 2018-12-20 00:46:40 +0100 | [diff] [blame] | 2015 | DEFUN(cfg_hlr_ipa_name, |
| 2016 | cfg_hlr_ipa_name_cmd, |
| 2017 | "ipa-name NAME", |
| 2018 | "Set the IPA name of this MSC\n" |
| 2019 | "A unique name for this MSC. For example: PLMN + redundancy server number: MSC-901-70-0. " |
| 2020 | "This name is used for GSUP routing and must be set if more than one MSC is connected to the HLR. " |
| 2021 | "The default is 'MSC-00-00-00-00-00-00'.\n") |
| 2022 | { |
| 2023 | if (vty->type != VTY_FILE) { |
| 2024 | vty_out(vty, "The IPA name cannot be changed at run-time; " |
Martin Hauke | 3f07dac | 2019-11-14 17:49:08 +0100 | [diff] [blame] | 2025 | "It can only be set in the configuration file.%s", VTY_NEWLINE); |
Neels Hofmeyr | 3a3ed9b | 2018-12-20 00:46:40 +0100 | [diff] [blame] | 2026 | return CMD_WARNING; |
| 2027 | } |
| 2028 | |
| 2029 | gsmnet->msc_ipa_name = talloc_strdup(gsmnet, argv[0]); |
| 2030 | return CMD_SUCCESS; |
| 2031 | } |
| 2032 | |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2033 | static int config_write_hlr(struct vty *vty) |
| 2034 | { |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2035 | vty_out(vty, "hlr%s", VTY_NEWLINE); |
| 2036 | vty_out(vty, " remote-ip %s%s", |
| 2037 | gsmnet->gsup_server_addr_str, VTY_NEWLINE); |
| 2038 | vty_out(vty, " remote-port %u%s", |
| 2039 | gsmnet->gsup_server_port, VTY_NEWLINE); |
Neels Hofmeyr | 3a3ed9b | 2018-12-20 00:46:40 +0100 | [diff] [blame] | 2040 | if (gsmnet->msc_ipa_name) |
| 2041 | vty_out(vty, " ipa-name %s%s", gsmnet->msc_ipa_name, VTY_NEWLINE); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2042 | return CMD_SUCCESS; |
| 2043 | } |
| 2044 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 2045 | void msc_vty_init(struct gsm_network *msc_network) |
| 2046 | { |
Neels Hofmeyr | 84a1f7a | 2018-03-22 15:33:12 +0100 | [diff] [blame] | 2047 | OSMO_ASSERT(gsmnet == NULL); |
| 2048 | gsmnet = msc_network; |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2049 | |
| 2050 | osmo_stats_vty_add_cmds(); |
| 2051 | |
| 2052 | install_element(CONFIG_NODE, &cfg_net_cmd); |
| 2053 | install_node(&net_node, config_write_net); |
| 2054 | install_element(GSMNET_NODE, &cfg_net_ncc_cmd); |
| 2055 | install_element(GSMNET_NODE, &cfg_net_mnc_cmd); |
| 2056 | install_element(GSMNET_NODE, &cfg_net_name_short_cmd); |
| 2057 | install_element(GSMNET_NODE, &cfg_net_name_long_cmd); |
| 2058 | install_element(GSMNET_NODE, &cfg_net_encryption_cmd); |
Neels Hofmeyr | 4dfb2ba | 2019-08-13 16:00:37 +0200 | [diff] [blame] | 2059 | install_element(GSMNET_NODE, &cfg_net_encryption_uea_cmd); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2060 | install_element(GSMNET_NODE, &cfg_net_authentication_cmd); |
| 2061 | install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd); |
| 2062 | install_element(GSMNET_NODE, &cfg_net_mm_info_cmd); |
| 2063 | install_element(GSMNET_NODE, &cfg_net_timezone_cmd); |
| 2064 | install_element(GSMNET_NODE, &cfg_net_timezone_dst_cmd); |
| 2065 | install_element(GSMNET_NODE, &cfg_net_no_timezone_cmd); |
| 2066 | install_element(GSMNET_NODE, &cfg_net_per_loc_upd_cmd); |
| 2067 | install_element(GSMNET_NODE, &cfg_net_no_per_loc_upd_cmd); |
Keith Whyte | 991bb42 | 2019-08-08 15:43:40 +0200 | [diff] [blame] | 2068 | install_element(GSMNET_NODE, &cfg_net_call_wait_cmd); |
| 2069 | install_element(GSMNET_NODE, &cfg_net_no_call_wait_cmd); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 2070 | |
| 2071 | install_element(CONFIG_NODE, &cfg_msc_cmd); |
| 2072 | install_node(&msc_node, config_write_msc); |
Keith Whyte | 1587ffb | 2020-08-28 13:36:58 +0200 | [diff] [blame] | 2073 | install_element(MSC_NODE, &cfg_sms_database_cmd); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 2074 | install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd); |
Neels Hofmeyr | 80447eb | 2018-12-05 01:11:28 +0100 | [diff] [blame] | 2075 | install_element(MSC_NODE, &cfg_msc_mncc_internal_cmd); |
| 2076 | install_element(MSC_NODE, &cfg_msc_mncc_external_cmd); |
Philipp Maier | 9ca7b31 | 2018-10-10 17:00:49 +0200 | [diff] [blame] | 2077 | install_element(MSC_NODE, &cfg_msc_mncc_guard_timeout_cmd); |
Neels Hofmeyr | 05c5680 | 2018-12-05 01:07:03 +0100 | [diff] [blame] | 2078 | install_element(MSC_NODE, &cfg_msc_deprecated_mncc_guard_timeout_cmd); |
Vadim Yanitskiy | 64623e1 | 2018-11-28 23:05:51 +0700 | [diff] [blame] | 2079 | install_element(MSC_NODE, &cfg_msc_ncss_guard_timeout_cmd); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 2080 | install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd); |
Neels Hofmeyr | 97ce015 | 2017-10-29 02:10:38 +0100 | [diff] [blame] | 2081 | install_element(MSC_NODE, &cfg_msc_auth_tuple_max_reuse_count_cmd); |
| 2082 | install_element(MSC_NODE, &cfg_msc_auth_tuple_reuse_on_error_cmd); |
Oliver Smith | 0fec28a | 2018-12-14 10:52:52 +0100 | [diff] [blame] | 2083 | install_element(MSC_NODE, &cfg_msc_check_imei_rqd_cmd); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 2084 | install_element(MSC_NODE, &cfg_msc_cs7_instance_a_cmd); |
| 2085 | install_element(MSC_NODE, &cfg_msc_cs7_instance_iu_cmd); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 2086 | install_element(MSC_NODE, &cfg_msc_paging_response_timer_cmd); |
Harald Welte | 69c54a8 | 2018-02-09 20:41:14 +0100 | [diff] [blame] | 2087 | install_element(MSC_NODE, &cfg_msc_emergency_msisdn_cmd); |
Vadim Yanitskiy | f40e46f | 2018-11-20 06:20:53 +0700 | [diff] [blame] | 2088 | install_element(MSC_NODE, &cfg_msc_sms_over_gsup_cmd); |
| 2089 | install_element(MSC_NODE, &cfg_msc_no_sms_over_gsup_cmd); |
Pau Espin Pedrol | 4faff9e | 2019-05-06 19:29:11 +0200 | [diff] [blame] | 2090 | install_element(MSC_NODE, &cfg_msc_osmux_cmd); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 2091 | install_element(MSC_NODE, &cfg_msc_handover_number_range_cmd); |
Neels Hofmeyr | 9aac5c2 | 2020-05-27 00:04:26 +0200 | [diff] [blame] | 2092 | install_element(MSC_NODE, &cfg_msc_nri_bitlen_cmd); |
| 2093 | install_element(MSC_NODE, &cfg_msc_nri_add_cmd); |
| 2094 | install_element(MSC_NODE, &cfg_msc_nri_del_cmd); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 2095 | |
| 2096 | neighbor_ident_vty_init(msc_network); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 2097 | |
Vadim Yanitskiy | ffc7f39 | 2020-01-18 18:39:41 +0700 | [diff] [blame] | 2098 | /* Timer configuration commands (generic osmo_tdef API) */ |
| 2099 | osmo_tdef_vty_groups_init(MSC_NODE, msc_tdef_group); |
| 2100 | |
Neels Hofmeyr | 6c8afe1 | 2017-09-04 01:03:58 +0200 | [diff] [blame] | 2101 | mgcp_client_vty_init(msc_network, MSC_NODE, &msc_network->mgw.conf); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 2102 | #ifdef BUILD_IU |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 2103 | ranap_iu_vty_init(MSC_NODE, (enum ranap_nsap_addr_enc*)&msc_network->iu.rab_assign_addr_enc); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 2104 | #endif |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 2105 | sgs_vty_init(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 2106 | |
Stefan Sperling | 617ac80 | 2018-02-22 17:58:20 +0100 | [diff] [blame] | 2107 | osmo_fsm_vty_add_cmds(); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2108 | |
| 2109 | osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL); |
| 2110 | |
| 2111 | install_element_ve(&show_subscr_cmd); |
| 2112 | install_element_ve(&show_subscr_cache_cmd); |
Max | c51609a | 2018-11-09 17:13:00 +0100 | [diff] [blame] | 2113 | install_element_ve(&show_bsc_cmd); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2114 | install_element_ve(&show_msc_conn_cmd); |
| 2115 | install_element_ve(&show_msc_transaction_cmd); |
Neels Hofmeyr | 9aac5c2 | 2020-05-27 00:04:26 +0200 | [diff] [blame] | 2116 | install_element_ve(&show_nri_cmd); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2117 | |
| 2118 | install_element_ve(&sms_send_pend_cmd); |
| 2119 | install_element_ve(&sms_delete_expired_cmd); |
| 2120 | |
| 2121 | install_element_ve(&subscriber_create_cmd); |
| 2122 | install_element_ve(&subscriber_send_sms_cmd); |
| 2123 | install_element_ve(&subscriber_silent_sms_cmd); |
| 2124 | install_element_ve(&subscriber_silent_call_start_cmd); |
| 2125 | install_element_ve(&subscriber_silent_call_stop_cmd); |
| 2126 | install_element_ve(&subscriber_ussd_notify_cmd); |
| 2127 | install_element_ve(&subscriber_mstest_close_cmd); |
| 2128 | install_element_ve(&subscriber_mstest_open_cmd); |
| 2129 | install_element_ve(&subscriber_paging_cmd); |
| 2130 | install_element_ve(&show_stats_cmd); |
| 2131 | install_element_ve(&show_smsqueue_cmd); |
| 2132 | install_element_ve(&logging_fltr_imsi_cmd); |
| 2133 | |
| 2134 | install_element(ENABLE_NODE, &ena_subscr_expire_cmd); |
| 2135 | install_element(ENABLE_NODE, &smsqueue_trigger_cmd); |
| 2136 | install_element(ENABLE_NODE, &smsqueue_max_cmd); |
| 2137 | install_element(ENABLE_NODE, &smsqueue_clear_cmd); |
| 2138 | install_element(ENABLE_NODE, &smsqueue_fail_cmd); |
| 2139 | install_element(ENABLE_NODE, &subscriber_send_pending_sms_cmd); |
Neels Hofmeyr | f90496f | 2019-03-06 16:19:50 +0100 | [diff] [blame] | 2140 | install_element(ENABLE_NODE, &subscriber_sms_delete_all_cmd); |
Neels Hofmeyr | 7c075a2 | 2018-03-22 14:50:20 +0100 | [diff] [blame] | 2141 | |
| 2142 | install_element(CONFIG_NODE, &cfg_mncc_int_cmd); |
| 2143 | install_node(&mncc_int_node, config_write_mncc_int); |
| 2144 | install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd); |
| 2145 | install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd); |
| 2146 | |
| 2147 | install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd); |
| 2148 | |
| 2149 | install_element(CONFIG_NODE, &cfg_hlr_cmd); |
| 2150 | install_node(&hlr_node, config_write_hlr); |
| 2151 | install_element(HLR_NODE, &cfg_hlr_remote_ip_cmd); |
| 2152 | install_element(HLR_NODE, &cfg_hlr_remote_port_cmd); |
Neels Hofmeyr | 3a3ed9b | 2018-12-20 00:46:40 +0100 | [diff] [blame] | 2153 | install_element(HLR_NODE, &cfg_hlr_ipa_name_cmd); |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 2154 | } |