blob: 111c9107e217eea0b1fb37e78177b9e7e1a4a9d0 [file] [log] [blame]
Daniel Willmann2dcdf442019-04-15 16:50:46 +02001/* OsmoBSC interface to quagga VTY */
Harald Welte51e4bf32017-12-23 17:30:18 +01002/* (C) 2009-2017 by Harald Welte <laforge@gnumonks.org>
Harald Welte68628e82009-03-10 12:17:57 +00003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Harald Welte68628e82009-03-10 12:17:57 +00008 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Harald Welte68628e82009-03-10 12:17:57 +000014 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte68628e82009-03-10 12:17:57 +000017 *
18 */
19
20#include <stdlib.h>
Maxc08ee712016-05-11 12:45:13 +020021#include <stdbool.h>
Harald Welte68628e82009-03-10 12:17:57 +000022#include <unistd.h>
Maxd1f70ed2017-09-21 16:15:32 +020023#include <time.h>
Harald Welte68628e82009-03-10 12:17:57 +000024
Harald Welte4b037e42010-05-19 19:45:32 +020025#include <osmocom/vty/command.h>
26#include <osmocom/vty/buffer.h>
27#include <osmocom/vty/vty.h>
28#include <osmocom/vty/logging.h>
Jacob Erlbeck64630cc2015-10-26 16:25:37 +010029#include <osmocom/vty/stats.h>
Harald Welte4b037e42010-05-19 19:45:32 +020030#include <osmocom/vty/telnet_interface.h>
Harald Welte4ab9d7c2012-08-17 12:42:06 +020031#include <osmocom/vty/misc.h>
Neels Hofmeyra6078fe2019-01-28 03:52:14 +010032#include <osmocom/vty/tdef_vty.h>
Maxc08ee712016-05-11 12:45:13 +020033#include <osmocom/gsm/protocol/gsm_04_08.h>
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +010034#include <osmocom/gsm/gsm0502.h>
Harald Welteb71147a2017-07-18 19:11:49 +020035#include <osmocom/ctrl/control_if.h>
Neels Hofmeyr7b656882017-07-09 22:09:18 +020036#include <osmocom/gsm/gsm48.h>
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020037#include <osmocom/gsm/gsm0808.h>
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +010038
Harald Welte68628e82009-03-10 12:17:57 +000039#include <arpa/inet.h>
40
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010041#include <osmocom/core/linuxlist.h>
Oliver Smithf1051902018-10-09 15:24:06 +020042#include <osmocom/core/socket.h>
Neels Hofmeyrc0164792017-09-04 15:15:32 +020043#include <osmocom/bsc/gsm_data.h>
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020044#include <osmocom/abis/e1_input.h>
Neels Hofmeyrc0164792017-09-04 15:15:32 +020045#include <osmocom/bsc/abis_nm.h>
46#include <osmocom/bsc/abis_om2000.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010047#include <osmocom/core/utils.h>
48#include <osmocom/gsm/gsm_utils.h>
Harald Weltecdc59ff2011-05-23 20:42:26 +020049#include <osmocom/gsm/abis_nm.h>
Neels Hofmeyrc0164792017-09-04 15:15:32 +020050#include <osmocom/bsc/chan_alloc.h>
51#include <osmocom/bsc/meas_rep.h>
52#include <osmocom/bsc/vty.h>
Harald Welteea34a4e2012-06-16 14:59:56 +080053#include <osmocom/gprs/gprs_ns.h>
Neels Hofmeyrc0164792017-09-04 15:15:32 +020054#include <osmocom/bsc/system_information.h>
55#include <osmocom/bsc/debug.h>
56#include <osmocom/bsc/paging.h>
57#include <osmocom/bsc/ipaccess.h>
58#include <osmocom/bsc/abis_rsl.h>
59#include <osmocom/bsc/bsc_msc_data.h>
60#include <osmocom/bsc/osmo_bsc_rf.h>
61#include <osmocom/bsc/pcu_if.h>
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020062#include <osmocom/bsc/handover_fsm.h>
Neels Hofmeyre25018b2017-11-27 21:29:33 +010063#include <osmocom/bsc/handover_cfg.h>
64#include <osmocom/bsc/handover_vty.h>
Neels Hofmeyr62427422018-07-24 16:18:15 +020065#include <osmocom/bsc/gsm_04_08_rr.h>
Stefan Sperling6442e432018-02-06 14:44:54 +010066#include <osmocom/bsc/acc_ramp.h>
Neels Hofmeyrf28f1ef2018-04-20 15:53:53 +020067#include <osmocom/bsc/meas_feed.h>
Neels Hofmeyr19bed232018-03-22 04:54:57 +010068#include <osmocom/bsc/neighbor_ident.h>
69#include <osmocom/bsc/handover.h>
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020070#include <osmocom/bsc/timeslot_fsm.h>
71#include <osmocom/bsc/lchan_fsm.h>
Neels Hofmeyra07b6672018-07-12 05:00:55 +020072#include <osmocom/bsc/lchan_select.h>
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020073#include <osmocom/mgcp_client/mgcp_client_endpoint_fsm.h>
Neels Hofmeyr06d39fd2016-05-12 01:16:58 +020074
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +010075#include <inttypes.h>
76
Harald Weltec08e8be2011-03-04 13:53:51 +010077#include "../../bscconfig.h"
Harald Welte1353f962010-05-16 19:20:24 +020078
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +010079#define BTS_NR_STR "BTS Number\n"
80#define TRX_NR_STR "TRX Number\n"
81#define TS_NR_STR "Timeslot Number\n"
Harald Welte0bfd8d92018-02-12 18:06:53 +010082#define SS_NR_STR "Sub-slot Number\n"
Holger Hans Peter Freyther08542562011-10-03 23:42:06 +020083#define LCHAN_NR_STR "Logical Channel Number\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +010084#define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
85#define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
86#define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
Harald Welte0bfd8d92018-02-12 18:06:53 +010087#define BTS_NR_TRX_TS_STR2 \
88 "BTS for manual command\n" BTS_NR_STR \
89 "TRX for manual command\n" TRX_NR_STR \
90 "Timeslot for manual command\n" TS_NR_STR
91#define BTS_NR_TRX_TS_SS_STR2 \
92 BTS_NR_TRX_TS_STR2 \
93 "Sub-slot for manual command\n" SS_NR_STR
Holger Hans Peter Freyther08542562011-10-03 23:42:06 +020094
Harald Welteea4647d2010-05-12 17:19:53 +000095/* FIXME: this should go to some common file */
96static const struct value_string gprs_ns_timer_strs[] = {
Harald Welte615e9562010-05-11 23:50:21 +020097 { 0, "tns-block" },
98 { 1, "tns-block-retries" },
99 { 2, "tns-reset" },
100 { 3, "tns-reset-retries" },
101 { 4, "tns-test" },
102 { 5, "tns-alive" },
103 { 6, "tns-alive-retries" },
104 { 0, NULL }
105};
106
Harald Welteea4647d2010-05-12 17:19:53 +0000107static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Welte615e9562010-05-11 23:50:21 +0200108 { 0, "blocking-timer" },
109 { 1, "blocking-retries" },
110 { 2, "unblocking-retries" },
111 { 3, "reset-timer" },
112 { 4, "reset-retries" },
113 { 5, "suspend-timer" },
114 { 6, "suspend-retries" },
115 { 7, "resume-timer" },
116 { 8, "resume-retries" },
117 { 9, "capability-update-timer" },
118 { 10, "capability-update-retries" },
119 { 0, NULL }
120};
121
Harald Welte64c07d22011-02-15 11:43:27 +0100122static const struct value_string bts_neigh_mode_strs[] = {
123 { NL_MODE_AUTOMATIC, "automatic" },
124 { NL_MODE_MANUAL, "manual" },
125 { NL_MODE_MANUAL_SI5SEP, "manual-si5" },
126 { 0, NULL }
127};
128
Daniel Willmann7d109832012-05-14 18:43:23 +0200129const struct value_string bts_loc_fix_names[] = {
130 { BTS_LOC_FIX_INVALID, "invalid" },
131 { BTS_LOC_FIX_2D, "fix2d" },
132 { BTS_LOC_FIX_3D, "fix3d" },
133 { 0, NULL }
134};
135
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +0100136struct cmd_node net_node = {
137 GSMNET_NODE,
138 "%s(config-net)# ",
139 1,
140};
141
Harald Welte68628e82009-03-10 12:17:57 +0000142struct cmd_node bts_node = {
143 BTS_NODE,
Harald Welte570ce242012-08-17 13:16:10 +0200144 "%s(config-net-bts)# ",
Harald Welte68628e82009-03-10 12:17:57 +0000145 1,
146};
147
148struct cmd_node trx_node = {
149 TRX_NODE,
Harald Welte570ce242012-08-17 13:16:10 +0200150 "%s(config-net-bts-trx)# ",
Harald Welte68628e82009-03-10 12:17:57 +0000151 1,
152};
153
154struct cmd_node ts_node = {
155 TS_NODE,
Harald Welte570ce242012-08-17 13:16:10 +0200156 "%s(config-net-bts-trx-ts)# ",
Harald Welte68628e82009-03-10 12:17:57 +0000157 1,
158};
159
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +0100160static struct gsm_network *vty_global_gsm_network = NULL;
161
162struct gsm_network *gsmnet_from_vty(struct vty *v)
163{
164 /* It can't hurt to force callers to continue to pass the vty instance
165 * to this function, in case we'd like to retrieve the global
166 * gsm_network instance from the vty at some point in the future. But
167 * until then, just return the global pointer, which should have been
168 * initialized by common_cs_vty_init().
169 */
170 OSMO_ASSERT(vty_global_gsm_network);
171 return vty_global_gsm_network;
172}
173
Harald Welte68628e82009-03-10 12:17:57 +0000174static int dummy_config_write(struct vty *v)
175{
176 return CMD_SUCCESS;
177}
178
179static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
180{
Harald Welte1304b352013-03-15 16:57:33 +0100181 vty_out(vty,"Oper '%s', Admin '%s', Avail '%s'%s",
182 abis_nm_opstate_name(nms->operational),
183 get_value_string(abis_nm_adm_state_names, nms->administrative),
Harald Welte867d9f32011-05-23 20:30:39 +0200184 abis_nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000185}
186
Harald Welteb908cb72009-12-22 13:09:29 +0100187static void dump_pchan_load_vty(struct vty *vty, char *prefix,
188 const struct pchan_load *pl)
189{
190 int i;
Neels Hofmeyr9abc6522018-01-19 00:59:33 +0100191 int dumped = 0;
Harald Welteb908cb72009-12-22 13:09:29 +0100192
193 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
194 const struct load_counter *lc = &pl->pchan[i];
195 unsigned int percent;
196
197 if (lc->total == 0)
198 continue;
199
200 percent = (lc->used * 100) / lc->total;
201
202 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
203 gsm_pchan_name(i), percent, lc->used, lc->total,
204 VTY_NEWLINE);
Neels Hofmeyr9abc6522018-01-19 00:59:33 +0100205 dumped ++;
Harald Welteb908cb72009-12-22 13:09:29 +0100206 }
Neels Hofmeyr9abc6522018-01-19 00:59:33 +0100207 if (!dumped)
208 vty_out(vty, "%s(none)%s", prefix, VTY_NEWLINE);
Harald Welteb908cb72009-12-22 13:09:29 +0100209}
210
Harald Welte68628e82009-03-10 12:17:57 +0000211static void net_dump_vty(struct vty *vty, struct gsm_network *net)
212{
Harald Welteb908cb72009-12-22 13:09:29 +0100213 struct pchan_load pl;
Harald Welte51e4bf32017-12-23 17:30:18 +0100214 int i;
Harald Welteb908cb72009-12-22 13:09:29 +0100215
Neels Hofmeyrf93970b2018-03-05 02:09:40 +0100216 vty_out(vty, "BSC is on MCC-MNC %s and has %u BTS%s",
217 osmo_plmn_name(&net->plmn), net->num_bts, VTY_NEWLINE);
Maxddee01f2016-05-24 14:23:27 +0200218 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte51e4bf32017-12-23 17:30:18 +0100219 vty_out(vty, " Encryption:");
220 for (i = 0; i < 8; i++) {
221 if (net->a5_encryption_mask & (1 << i))
222 vty_out(vty, " A5/%u", i);
223 }
224 vty_out(vty, "%s", VTY_NEWLINE);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100225 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
226 VTY_NEWLINE);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800227 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
228 VTY_NEWLINE);
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100229
230 {
231 struct gsm_bts *bts;
232 unsigned int ho_active_count = 0;
233 unsigned int ho_inactive_count = 0;
234
235 llist_for_each_entry(bts, &net->bts_list, list) {
236 if (ho_get_ho_active(bts->ho))
237 ho_active_count ++;
238 else
239 ho_inactive_count ++;
240 }
241
242 if (ho_active_count && ho_inactive_count)
243 vty_out(vty, " Handover: On at %u BTS, Off at %u BTS%s",
244 ho_active_count, ho_inactive_count, VTY_NEWLINE);
245 else
246 vty_out(vty, " Handover: %s%s", ho_active_count ? "On" : "Off",
247 VTY_NEWLINE);
248 }
249
Harald Welteb908cb72009-12-22 13:09:29 +0100250 network_chan_load(&pl, net);
251 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
252 dump_pchan_load_vty(vty, " ", &pl);
Holger Hans Peter Freyther37ac4202011-02-24 14:19:14 +0100253
254 /* show rf */
Holger Hans Peter Freythera9fae1a2014-02-08 12:12:03 +0100255 if (net->bsc_data)
Holger Hans Peter Freyther37ac4202011-02-24 14:19:14 +0100256 vty_out(vty, " Last RF Command: %s%s",
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +0200257 net->bsc_data->rf_ctrl->last_state_command,
Holger Hans Peter Freyther37ac4202011-02-24 14:19:14 +0100258 VTY_NEWLINE);
Holger Hans Peter Freythera9fae1a2014-02-08 12:12:03 +0100259 if (net->bsc_data)
Jacob Erlbeck779a7282013-09-11 10:46:57 +0200260 vty_out(vty, " Last RF Lock Command: %s%s",
261 net->bsc_data->rf_ctrl->last_rf_lock_ctrl_command,
262 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000263}
264
Neels Hofmeyrea11bf82016-05-12 01:53:23 +0200265DEFUN(bsc_show_net, bsc_show_net_cmd, "show network",
Harald Welte68628e82009-03-10 12:17:57 +0000266 SHOW_STR "Display information about a GSM NETWORK\n")
267{
Harald Weltedcccb182010-05-16 20:52:23 +0200268 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000269 net_dump_vty(vty, net);
270
271 return CMD_SUCCESS;
272}
273
274static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
275{
Harald Welteedb37782009-05-01 14:59:07 +0000276 struct e1inp_line *line;
277
278 if (!e1l) {
279 vty_out(vty, " None%s", VTY_NEWLINE);
280 return;
281 }
282
283 line = e1l->ts->line;
284
285 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
286 line->num, line->driver->name, e1l->ts->num,
Harald Welte1bc77352009-03-10 19:47:51 +0000287 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000288 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000289 e1l->tei, e1l->sapi, VTY_NEWLINE);
290}
291
Oliver Smithf1051902018-10-09 15:24:06 +0200292/*! Dump the IP addresses and ports of the input signal link's timeslot.
293 * This only makes sense for links connected with ipaccess.
294 * Example output: "(r=10.1.42.1:55416<->l=10.1.42.123:3003)" */
295static void e1isl_dump_vty_tcp(struct vty *vty, const struct e1inp_sign_link *e1l)
296{
297 if (e1l) {
298 char *name = osmo_sock_get_name(NULL, e1l->ts->driver.ipaccess.fd.fd);
299 vty_out(vty, "%s", name);
300 talloc_free(name);
301 }
302 vty_out(vty, "%s", VTY_NEWLINE);
303}
304
Neels Hofmeyrc1db52f2018-01-19 00:59:33 +0100305static void vty_out_neigh_list(struct vty *vty, struct bitvec *bv)
306{
307 int count = 0;
308 int i;
309 for (i = 0; i < 1024; i++) {
310 if (!bitvec_get_bit_pos(bv, i))
311 continue;
312 vty_out(vty, " %u", i);
313 count ++;
314 }
315 if (!count)
316 vty_out(vty, " (none)");
317 else
318 vty_out(vty, " (%d)", count);
319}
320
Philipp Maierf27dbc52018-02-21 13:25:57 +0100321static void bts_dump_vty_features(struct vty *vty, struct gsm_bts *bts)
322{
323 unsigned int i;
324 bool no_features = true;
325 vty_out(vty, " Features:%s", VTY_NEWLINE);
326
327 for (i = 0; i < _NUM_BTS_FEAT; i++) {
328 if (osmo_bts_has_feature(&bts->features, i)) {
329 vty_out(vty, " %03u ", i);
330 vty_out(vty, "%-40s%s", osmo_bts_feature_name(i), VTY_NEWLINE);
331 no_features = false;
332 }
333 }
334
335 if (no_features)
336 vty_out(vty, " (not available)%s", VTY_NEWLINE);
337}
338
Harald Welte68628e82009-03-10 12:17:57 +0000339static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
340{
Harald Welteb908cb72009-12-22 13:09:29 +0100341 struct pchan_load pl;
Maxd1f70ed2017-09-21 16:15:32 +0200342 unsigned long long sec;
Neels Hofmeyr097a6e72018-01-19 00:59:33 +0100343 struct gsm_bts_trx *trx;
344 int ts_hopping_total;
345 int ts_non_hopping_total;
Harald Welteb908cb72009-12-22 13:09:29 +0100346
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200347 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte557c84e2015-11-20 10:50:24 +0100348 "BSIC %u (NCC=%u, BCC=%u) and %u TRX%s",
Harald Weltefcd24452009-06-20 18:15:19 +0200349 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200350 bts->cell_identity,
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100351 bts->location_area_code, bts->bsic,
Harald Welte557c84e2015-11-20 10:50:24 +0100352 bts->bsic >> 3, bts->bsic & 7,
Harald Weltefcd24452009-06-20 18:15:19 +0200353 bts->num_trx, VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100354 vty_out(vty, " Description: %s%s",
Harald Welte197dea92010-05-14 17:59:53 +0200355 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Neels Hofmeyr097a6e72018-01-19 00:59:33 +0100356
357 vty_out(vty, " ARFCNs:");
358 ts_hopping_total = 0;
359 ts_non_hopping_total = 0;
360 llist_for_each_entry(trx, &bts->trx_list, list) {
361 int ts_nr;
362 int ts_hopping = 0;
363 int ts_non_hopping = 0;
364 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
365 struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
366 if (ts->hopping.enabled)
367 ts_hopping++;
368 else
369 ts_non_hopping++;
370 }
371
372 if (ts_non_hopping)
373 vty_out(vty, " %u", trx->arfcn);
374 ts_hopping_total += ts_hopping;
375 ts_non_hopping_total += ts_non_hopping;
376 }
377 if (ts_hopping_total) {
378 if (ts_non_hopping_total)
379 vty_out(vty, " / Hopping on %d of %d timeslots",
380 ts_hopping_total, ts_hopping_total + ts_non_hopping_total);
381 else
382 vty_out(vty, " Hopping on all %d timeslots", ts_hopping_total);
383 }
384 vty_out(vty, "%s", VTY_NEWLINE);
385
Maxf9685c12017-03-23 12:01:07 +0100386 if (strnlen(bts->pcu_version, MAX_VERSION_LENGTH))
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100387 vty_out(vty, " PCU version %s connected%s", bts->pcu_version,
Maxf9685c12017-03-23 12:01:07 +0100388 VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100389 vty_out(vty, " MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
390 vty_out(vty, " Minimum Rx Level for Access: %i dBm%s",
Harald Welte1d8dbc42009-12-12 15:38:16 +0100391 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
392 VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100393 vty_out(vty, " Cell Reselection Hysteresis: %u dBm%s",
Harald Welte73225282009-12-12 18:17:25 +0100394 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Stefan Sperling6442e432018-02-06 14:44:54 +0100395 vty_out(vty, " Access Control Class ramping: %senabled%s",
396 acc_ramp_is_enabled(&bts->acc_ramp) ? "" : "not ", VTY_NEWLINE);
397 if (acc_ramp_is_enabled(&bts->acc_ramp)) {
398 if (!acc_ramp_step_interval_is_dynamic(&bts->acc_ramp))
399 vty_out(vty, " Access Control Class ramping step interval: %u seconds%s",
400 acc_ramp_get_step_interval(&bts->acc_ramp), VTY_NEWLINE);
401 else
402 vty_out(vty, " Access Control Class ramping step interval: dynamic%s", VTY_NEWLINE);
403 vty_out(vty, " enabling %u Access Control Class%s per ramping step%s",
404 acc_ramp_get_step_size(&bts->acc_ramp),
405 acc_ramp_get_step_size(&bts->acc_ramp) > 1 ? "es" : "", VTY_NEWLINE);
406 }
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100407 vty_out(vty, " RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100408 VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100409 vty_out(vty, " RACH Max transmissions: %u%s",
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100410 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
411 VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100412 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200413 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Maxc08ee712016-05-11 12:45:13 +0200414 if (bts->dtxu != GSM48_DTX_SHALL_NOT_BE_USED)
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100415 vty_out(vty, " Uplink DTX: %s%s",
Maxc08ee712016-05-11 12:45:13 +0200416 (bts->dtxu != GSM48_DTX_SHALL_BE_USED) ?
417 "enabled" : "forced", VTY_NEWLINE);
418 else
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100419 vty_out(vty, " Uplink DTX: not enabled%s", VTY_NEWLINE);
420 vty_out(vty, " Downlink DTX: %senabled%s", bts->dtxd ? "" : "not ",
Maxc08ee712016-05-11 12:45:13 +0200421 VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100422 vty_out(vty, " Channel Description Attachment: %s%s",
Andreas Eversberg2ee7ecd2012-10-13 07:27:47 +0200423 (bts->si_common.chan_desc.att) ? "yes" : "no", VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100424 vty_out(vty, " Channel Description BS-PA-MFRMS: %u%s",
Andreas Eversberg2ee7ecd2012-10-13 07:27:47 +0200425 bts->si_common.chan_desc.bs_pa_mfrms + 2, VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100426 vty_out(vty, " Channel Description BS-AG_BLKS-RES: %u%s",
Andreas Eversberg2ee7ecd2012-10-13 07:27:47 +0200427 bts->si_common.chan_desc.bs_ag_blks_res, VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100428 vty_out(vty, " System Information present: 0x%08x, static: 0x%08x%s",
Harald Welte9fbff4a2010-07-30 11:50:09 +0200429 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100430 vty_out(vty, " Early Classmark Sending: 2G %s, 3G %s%s%s",
Harald Welte42def722017-01-13 00:10:32 +0100431 bts->early_classmark_allowed ? "allowed" : "forbidden",
Pau Espin Pedrole8dda5f2017-11-23 19:06:09 +0100432 bts->early_classmark_allowed_3g ? "allowed" : "forbidden",
433 bts->early_classmark_allowed_3g && !bts->early_classmark_allowed ?
434 " (forbidden by 2G bit)" : "",
Harald Welte42def722017-01-13 00:10:32 +0100435 VTY_NEWLINE);
Harald Welte8254cf72017-05-29 13:42:19 +0200436 if (bts->pcu_sock_path)
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100437 vty_out(vty, " PCU Socket Path: %s%s", bts->pcu_sock_path, VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000438 if (is_ipaccess_bts(bts))
Harald Welte8175e952009-10-20 00:22:00 +0200439 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte4cc34222009-05-01 15:12:31 +0000440 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte8175e952009-10-20 00:22:00 +0200441 bts->oml_tei, VTY_NEWLINE);
Sylvain Munautc9519462011-10-17 14:04:55 +0200442 else if (bts->type == GSM_BTS_TYPE_NOKIA_SITE)
443 vty_out(vty, " Skip Reset: %d%s",
444 bts->nokia.skip_reset, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000445 vty_out(vty, " NM State: ");
Harald Welted64c0bc2011-05-30 12:07:53 +0200446 net_dump_nmstate(vty, &bts->mo.nm_state);
Harald Welte68628e82009-03-10 12:17:57 +0000447 vty_out(vty, " Site Mgr NM State: ");
Harald Welted64c0bc2011-05-30 12:07:53 +0200448 net_dump_nmstate(vty, &bts->site_mgr.mo.nm_state);
Max366f7272018-11-06 15:08:30 +0100449
450 if (bts->gprs.mode != BTS_GPRS_NONE) {
451 vty_out(vty, " GPRS NSE: ");
452 net_dump_nmstate(vty, &bts->gprs.nse.mo.nm_state);
453 vty_out(vty, " GPRS CELL: ");
454 net_dump_nmstate(vty, &bts->gprs.cell.mo.nm_state);
455 vty_out(vty, " GPRS NSVC0: ");
456 net_dump_nmstate(vty, &bts->gprs.nsvc[0].mo.nm_state);
457 vty_out(vty, " GPRS NSVC1: ");
458 net_dump_nmstate(vty, &bts->gprs.nsvc[1].mo.nm_state);
459 } else
460 vty_out(vty, " GPRS: not configured%s", VTY_NEWLINE);
461
Holger Hans Peter Freyther66e14cd2011-04-26 15:52:34 +0200462 vty_out(vty, " Paging: %u pending requests, %u free slots%s",
463 paging_pending_requests_nr(bts),
Harald Welte68628e82009-03-10 12:17:57 +0000464 bts->paging.available_slots, VTY_NEWLINE);
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100465 if (is_ipaccess_bts(bts)) {
Oliver Smithf1051902018-10-09 15:24:06 +0200466 vty_out(vty, " OML Link: ");
467 e1isl_dump_vty_tcp(vty, bts->oml_link);
Max3d049d22017-10-09 17:12:53 +0200468 vty_out(vty, " OML Link state: %s", get_model_oml_status(bts));
Max25cc4072017-10-10 14:50:35 +0200469 sec = bts_uptime(bts);
470 if (sec)
Maxff3fad12018-01-07 16:50:42 +0100471 vty_out(vty, " %llu days %llu hours %llu min. %llu sec.",
472 OSMO_SEC2DAY(sec), OSMO_SEC2HRS(sec), OSMO_SEC2MIN(sec), sec % 60);
473 vty_out(vty, "%s", VTY_NEWLINE);
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100474 } else {
Harald Welte8175e952009-10-20 00:22:00 +0200475 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
476 e1isl_dump_vty(vty, bts->oml_link);
477 }
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100478
Neels Hofmeyrc1db52f2018-01-19 00:59:33 +0100479 vty_out(vty, " Neighbor Cells: ");
480 switch (bts->neigh_list_manual_mode) {
481 default:
482 case NL_MODE_AUTOMATIC:
483 vty_out(vty, "Automatic");
484 /* generate_bcch_chan_list() should populate si_common.neigh_list */
485 break;
486 case NL_MODE_MANUAL:
487 vty_out(vty, "Manual");
488 break;
489 case NL_MODE_MANUAL_SI5SEP:
490 vty_out(vty, "Manual/separate SI5");
491 break;
492 }
493 vty_out(vty, ", ARFCNs:");
494 vty_out_neigh_list(vty, &bts->si_common.neigh_list);
495 if (bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) {
496 vty_out(vty, " SI5:");
497 vty_out_neigh_list(vty, &bts->si_common.si5_neigh_list);
498 }
499 vty_out(vty, "%s", VTY_NEWLINE);
500
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100501 /* FIXME: chan_desc */
Harald Welteb908cb72009-12-22 13:09:29 +0100502 memset(&pl, 0, sizeof(pl));
Neels Hofmeyr2afffd52016-09-25 17:01:20 +0200503 bts_chan_load(&pl, bts);
Harald Welteb908cb72009-12-22 13:09:29 +0100504 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
505 dump_pchan_load_vty(vty, " ", &pl);
Harald Welted82101e2017-12-09 23:07:38 +0100506
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100507 vty_out(vty, " Channel Requests : %"PRIu64" total, %"PRIu64" no channel%s",
Harald Welted82101e2017-12-09 23:07:38 +0100508 bts->bts_ctrs->ctr[BTS_CTR_CHREQ_TOTAL].current,
509 bts->bts_ctrs->ctr[BTS_CTR_CHREQ_NO_CHANNEL].current,
510 VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100511 vty_out(vty, " Channel Failures : %"PRIu64" rf_failures, %"PRIu64" rll failures%s",
Harald Welted82101e2017-12-09 23:07:38 +0100512 bts->bts_ctrs->ctr[BTS_CTR_CHAN_RF_FAIL].current,
513 bts->bts_ctrs->ctr[BTS_CTR_CHAN_RLL_ERR].current,
514 VTY_NEWLINE);
Neels Hofmeyr97d110e2018-01-19 00:59:33 +0100515 vty_out(vty, " BTS failures : %"PRIu64" OML, %"PRIu64" RSL%s",
Harald Welted82101e2017-12-09 23:07:38 +0100516 bts->bts_ctrs->ctr[BTS_CTR_BTS_OML_FAIL].current,
517 bts->bts_ctrs->ctr[BTS_CTR_BTS_RSL_FAIL].current,
518 VTY_NEWLINE);
Philipp Maierf27dbc52018-02-21 13:25:57 +0100519
Harald Welteaae00e42019-05-24 09:36:30 +0200520 vty_out_stat_item_group(vty, " ", bts->bts_statg);
521
Philipp Maierf27dbc52018-02-21 13:25:57 +0100522 bts_dump_vty_features(vty, bts);
Harald Welte68628e82009-03-10 12:17:57 +0000523}
524
Sylvain Munaut39c31de2012-12-28 12:15:11 +0100525DEFUN(show_bts, show_bts_cmd, "show bts [<0-255>]",
Harald Welte68628e82009-03-10 12:17:57 +0000526 SHOW_STR "Display information about a BTS\n"
527 "BTS number")
528{
Harald Weltedcccb182010-05-16 20:52:23 +0200529 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000530 int bts_nr;
531
532 if (argc != 0) {
533 /* use the BTS number that the user has specified */
534 bts_nr = atoi(argv[0]);
Harald Welte712ddbc2010-12-24 12:24:03 +0100535 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000536 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000537 VTY_NEWLINE);
538 return CMD_WARNING;
539 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200540 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000541 return CMD_SUCCESS;
542 }
543 /* print all BTS's */
544 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200545 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000546
547 return CMD_SUCCESS;
548}
549
Oliver Smith8d8d7102018-10-23 15:35:43 +0200550DEFUN(show_rejected_bts, show_rejected_bts_cmd, "show rejected-bts",
551 SHOW_STR "Display recently rejected BTS devices\n")
552{
553 struct gsm_bts_rejected *pos;
554
555 /* empty list */
556 struct llist_head *rejected = &gsmnet_from_vty(vty)->bts_rejected;
557 if (llist_empty(rejected)) {
558 vty_out(vty, "No BTS has been rejected.%s", VTY_NEWLINE);
559 return CMD_SUCCESS;
560 }
561
562 /* table head */
563 vty_out(vty, "Date Site ID BTS ID IP%s", VTY_NEWLINE);
564 vty_out(vty, "------------------- ------- ------ ---------------%s", VTY_NEWLINE);
565
566 /* table body */
567 llist_for_each_entry(pos, rejected, list) {
568 /* timestamp formatted like: "2018-10-24 15:04:52" */
569 char buf[20];
570 strftime(buf, sizeof(buf), "%F %T", localtime(&pos->time));
571
572 vty_out(vty, "%s %7u %6u %15s%s", buf, pos->site_id, pos->bts_id, pos->ip, VTY_NEWLINE);
573 }
574 return CMD_SUCCESS;
575}
576
Harald Welte42581822009-08-08 16:12:58 +0200577/* utility functions */
578static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
579 const char *ts, const char *ss)
580{
581 e1_link->e1_nr = atoi(line);
582 e1_link->e1_ts = atoi(ts);
583 if (!strcmp(ss, "full"))
584 e1_link->e1_ts_ss = 255;
585 else
586 e1_link->e1_ts_ss = atoi(ss);
587}
588
589static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
590 const char *prefix)
591{
592 if (!e1_link->e1_ts)
593 return;
594
595 if (e1_link->e1_ts_ss == 255)
596 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
597 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
598 else
599 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
600 prefix, e1_link->e1_nr, e1_link->e1_ts,
601 e1_link->e1_ts_ss, VTY_NEWLINE);
602}
603
604
Harald Welte67ce0732009-08-06 19:06:46 +0200605static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
606{
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100607 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100608 if (ts->tsc != -1)
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100609 vty_out(vty, " training_sequence_code %u%s", ts->tsc, VTY_NEWLINE);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200610 if (ts->pchan_from_config != GSM_PCHAN_NONE)
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100611 vty_out(vty, " phys_chan_config %s%s",
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200612 gsm_pchan_name(ts->pchan_from_config), VTY_NEWLINE);
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100613 vty_out(vty, " hopping enabled %u%s",
Harald Weltea39b0f22010-06-14 22:26:10 +0200614 ts->hopping.enabled, VTY_NEWLINE);
615 if (ts->hopping.enabled) {
616 unsigned int i;
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100617 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200618 ts->hopping.hsn, VTY_NEWLINE);
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100619 vty_out(vty, " hopping maio %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200620 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200621 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
622 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
623 continue;
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100624 vty_out(vty, " hopping arfcn add %u%s",
Harald Weltea39b0f22010-06-14 22:26:10 +0200625 i, VTY_NEWLINE);
626 }
Harald Welte127af342010-12-24 12:07:07 +0100627 }
Neels Hofmeyr9c4f1d62016-01-27 14:20:29 +0100628 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welteface7ed2011-02-14 16:15:21 +0100629
630 if (ts->trx->bts->model->config_write_ts)
631 ts->trx->bts->model->config_write_ts(vty, ts);
Harald Welte67ce0732009-08-06 19:06:46 +0200632}
633
634static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
635{
636 int i;
637
Harald Welte5013b2a2009-08-07 13:29:14 +0200638 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200639 if (trx->description)
640 vty_out(vty, " description %s%s", trx->description,
641 VTY_NEWLINE);
Holger Hans Peter Freyther2ba40af2010-04-17 06:42:07 +0200642 vty_out(vty, " rf_locked %u%s",
Harald Welted64c0bc2011-05-30 12:07:53 +0200643 trx->mo.nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
Holger Hans Peter Freyther2ba40af2010-04-17 06:42:07 +0200644 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200645 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100646 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200647 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200648 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
649 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200650
Harald Welteface7ed2011-02-14 16:15:21 +0100651 if (trx->bts->model->config_write_trx)
652 trx->bts->model->config_write_trx(vty, trx);
653
Harald Welte67ce0732009-08-06 19:06:46 +0200654 for (i = 0; i < TRX_NR_TS; i++)
655 config_write_ts_single(vty, &trx->ts[i]);
656}
657
Harald Welte615e9562010-05-11 23:50:21 +0200658static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
659{
660 unsigned int i;
661 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
662 VTY_NEWLINE);
663 if (bts->gprs.mode == BTS_GPRS_NONE)
664 return;
665
bhargava350533c2016-07-21 11:14:34 +0530666 vty_out(vty, " gprs 11bit_rach_support_for_egprs %u%s",
667 bts->gprs.supports_egprs_11bit_rach, VTY_NEWLINE);
668
Harald Welte615e9562010-05-11 23:50:21 +0200669 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
670 VTY_NEWLINE);
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100671 vty_out(vty, " gprs network-control-order nc%u%s",
672 bts->gprs.net_ctrl_ord, VTY_NEWLINE);
Max292ec582016-07-28 11:55:37 +0200673 if (!bts->gprs.ctrl_ack_type_use_block)
674 vty_out(vty, " gprs control-ack-type-rach%s", VTY_NEWLINE);
Harald Welte615e9562010-05-11 23:50:21 +0200675 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
676 VTY_NEWLINE);
677 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
678 vty_out(vty, " gprs cell timer %s %u%s",
679 get_value_string(gprs_bssgp_cfg_strs, i),
680 bts->gprs.cell.timer[i], VTY_NEWLINE);
681 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
682 VTY_NEWLINE);
683 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
684 vty_out(vty, " gprs ns timer %s %u%s",
685 get_value_string(gprs_ns_timer_strs, i),
686 bts->gprs.nse.timer[i], VTY_NEWLINE);
687 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
688 struct gsm_bts_gprs_nsvc *nsvc =
689 &bts->gprs.nsvc[i];
690 struct in_addr ia;
691
692 ia.s_addr = htonl(nsvc->remote_ip);
693 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
694 nsvc->nsvci, VTY_NEWLINE);
695 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
696 nsvc->local_port, VTY_NEWLINE);
697 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
698 nsvc->remote_port, VTY_NEWLINE);
699 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
700 inet_ntoa(ia), VTY_NEWLINE);
701 }
702}
703
Holger Hans Peter Freythercd40fb42013-09-15 17:23:34 +0200704/* Write the model data if there is one */
705static void config_write_bts_model(struct vty *vty, struct gsm_bts *bts)
Harald Welte67ce0732009-08-06 19:06:46 +0200706{
707 struct gsm_bts_trx *trx;
Holger Hans Peter Freythercd40fb42013-09-15 17:23:34 +0200708
709 if (!bts->model)
710 return;
711
712 if (bts->model->config_write_bts)
713 bts->model->config_write_bts(vty, bts);
714
715 llist_for_each_entry(trx, &bts->trx_list, list)
716 config_write_trx_single(vty, trx);
717}
718
Holger Hans Peter Freythera174a472015-09-24 11:39:38 +0200719static void write_amr_modes(struct vty *vty, const char *prefix,
720 const char *name, struct amr_mode *modes, int num)
721{
722 int i;
723
724 vty_out(vty, " %s threshold %s", prefix, name);
725 for (i = 0; i < num - 1; i++)
726 vty_out(vty, " %d", modes[i].threshold);
727 vty_out(vty, "%s", VTY_NEWLINE);
728 vty_out(vty, " %s hysteresis %s", prefix, name);
729 for (i = 0; i < num - 1; i++)
730 vty_out(vty, " %d", modes[i].hysteresis);
731 vty_out(vty, "%s", VTY_NEWLINE);
732}
733
Andreas Eversberg73266522014-01-19 11:47:44 +0100734static void config_write_bts_amr(struct vty *vty, struct gsm_bts *bts,
735 struct amr_multirate_conf *mr, int full)
736{
737 struct gsm48_multi_rate_conf *mr_conf;
738 const char *prefix = (full) ? "amr tch-f" : "amr tch-h";
739 int i, num;
740
741 if (!(mr->gsm48_ie[1]))
742 return;
743
744 mr_conf = (struct gsm48_multi_rate_conf *) mr->gsm48_ie;
745
746 num = 0;
747 vty_out(vty, " %s modes", prefix);
748 for (i = 0; i < ((full) ? 8 : 6); i++) {
749 if ((mr->gsm48_ie[1] & (1 << i))) {
750 vty_out(vty, " %d", i);
751 num++;
752 }
753 }
754 vty_out(vty, "%s", VTY_NEWLINE);
755 if (num > 4)
756 num = 4;
757 if (num > 1) {
Holger Hans Peter Freythera174a472015-09-24 11:39:38 +0200758 write_amr_modes(vty, prefix, "ms", mr->ms_mode, num);
759 write_amr_modes(vty, prefix, "bts", mr->bts_mode, num);
Andreas Eversberg73266522014-01-19 11:47:44 +0100760 }
761 vty_out(vty, " %s start-mode ", prefix);
762 if (mr_conf->icmi) {
763 num = 0;
764 for (i = 0; i < ((full) ? 8 : 6) && num < 4; i++) {
765 if ((mr->gsm48_ie[1] & (1 << i)))
766 num++;
767 if (mr_conf->smod == num - 1) {
768 vty_out(vty, "%d%s", num, VTY_NEWLINE);
769 break;
770 }
771 }
772 } else
773 vty_out(vty, "auto%s", VTY_NEWLINE);
774}
775
Holger Hans Peter Freythercd40fb42013-09-15 17:23:34 +0200776static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
777{
Harald Welte9fbff4a2010-07-30 11:50:09 +0200778 int i;
Max2c16bee2017-02-15 13:51:37 +0100779 uint8_t tmp;
Harald Welte67ce0732009-08-06 19:06:46 +0200780
Harald Welte5013b2a2009-08-07 13:29:14 +0200781 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
782 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200783 if (bts->description)
784 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200785 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freytherf926ed62009-11-19 16:38:49 +0100786 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200787 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200788 VTY_NEWLINE);
Maxc08ee712016-05-11 12:45:13 +0200789 if (bts->dtxu != GSM48_DTX_SHALL_NOT_BE_USED)
790 vty_out(vty, " dtx uplink%s%s",
791 (bts->dtxu != GSM48_DTX_SHALL_BE_USED) ? "" : " force",
792 VTY_NEWLINE);
793 if (bts->dtxd)
794 vty_out(vty, " dtx downlink%s", VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200795 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200796 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100797 vty_out(vty, " cell reselection hysteresis %u%s",
798 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
799 vty_out(vty, " rxlev access min %u%s",
800 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Sylvain Munaute0b06b02010-11-28 18:17:28 +0100801
802 if (bts->si_common.cell_ro_sel_par.present) {
803 struct gsm48_si_selection_params *sp;
804 sp = &bts->si_common.cell_ro_sel_par;
805
806 if (sp->cbq)
807 vty_out(vty, " cell bar qualify %u%s",
808 sp->cbq, VTY_NEWLINE);
809
810 if (sp->cell_resel_off)
811 vty_out(vty, " cell reselection offset %u%s",
812 sp->cell_resel_off*2, VTY_NEWLINE);
813
814 if (sp->temp_offs == 7)
815 vty_out(vty, " temporary offset infinite%s",
816 VTY_NEWLINE);
817 else if (sp->temp_offs)
818 vty_out(vty, " temporary offset %u%s",
819 sp->temp_offs*10, VTY_NEWLINE);
820
821 if (sp->penalty_time == 31)
822 vty_out(vty, " penalty time reserved%s",
823 VTY_NEWLINE);
824 else if (sp->penalty_time)
825 vty_out(vty, " penalty time %u%s",
826 (sp->penalty_time*20)+20, VTY_NEWLINE);
827 }
828
Harald Welte2f8b9d22017-06-18 11:12:13 +0300829 if (gsm_bts_get_radio_link_timeout(bts) < 0)
830 vty_out(vty, " radio-link-timeout infinite%s", VTY_NEWLINE);
831 else
832 vty_out(vty, " radio-link-timeout %d%s",
833 gsm_bts_get_radio_link_timeout(bts), VTY_NEWLINE);
Pau Espin Pedrolc5a84162017-11-28 15:04:26 +0100834
Harald Welte7a8fa412009-08-10 13:48:16 +0200835 vty_out(vty, " channel allocator %s%s",
836 bts->chan_alloc_reverse ? "descending" : "ascending",
837 VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100838 vty_out(vty, " rach tx integer %u%s",
839 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
840 vty_out(vty, " rach max transmission %u%s",
841 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
842 VTY_NEWLINE);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800843
Andreas Eversberg2ee7ecd2012-10-13 07:27:47 +0200844 vty_out(vty, " channel-descrption attach %u%s",
845 bts->si_common.chan_desc.att, VTY_NEWLINE);
846 vty_out(vty, " channel-descrption bs-pa-mfrms %u%s",
847 bts->si_common.chan_desc.bs_pa_mfrms + 2, VTY_NEWLINE);
848 vty_out(vty, " channel-descrption bs-ag-blks-res %u%s",
849 bts->si_common.chan_desc.bs_ag_blks_res, VTY_NEWLINE);
850
Harald Welte15400252019-05-24 11:56:23 +0200851 if (bts->ccch_load_ind_thresh != 10)
852 vty_out(vty, " ccch load-indication-threshold %u%s",
853 bts->ccch_load_ind_thresh, VTY_NEWLINE);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800854 if (bts->rach_b_thresh != -1)
855 vty_out(vty, " rach nm busy threshold %u%s",
856 bts->rach_b_thresh, VTY_NEWLINE);
857 if (bts->rach_ldavg_slots != -1)
858 vty_out(vty, " rach nm load average %u%s",
859 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100860 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200861 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +0800862 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
863 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Ivan Kluchnikov67920592013-09-16 13:13:04 +0400864 if ((bts->si_common.rach_control.t3) != 0)
865 for (i = 0; i < 8; i++)
866 if (bts->si_common.rach_control.t3 & (0x1 << i))
867 vty_out(vty, " rach access-control-class %d barred%s", i, VTY_NEWLINE);
868 if ((bts->si_common.rach_control.t2 & 0xfb) != 0)
869 for (i = 0; i < 8; i++)
870 if ((i != 2) && (bts->si_common.rach_control.t2 & (0x1 << i)))
871 vty_out(vty, " rach access-control-class %d barred%s", i+8, VTY_NEWLINE);
Stefan Sperling6442e432018-02-06 14:44:54 +0100872 vty_out(vty, " %saccess-control-class-ramping%s", acc_ramp_is_enabled(&bts->acc_ramp) ? "" : "no ", VTY_NEWLINE);
873 if (!acc_ramp_step_interval_is_dynamic(&bts->acc_ramp)) {
874 vty_out(vty, " access-control-class-ramping-step-interval %u%s",
875 acc_ramp_get_step_interval(&bts->acc_ramp), VTY_NEWLINE);
876 } else {
877 vty_out(vty, " access-control-class-ramping-step-interval dynamic%s", VTY_NEWLINE);
878 }
879 vty_out(vty, " access-control-class-ramping-step-size %u%s", acc_ramp_get_step_size(&bts->acc_ramp),
880 VTY_NEWLINE);
Pau Espin Pedrol1cf21de2018-12-05 13:38:10 +0100881 if (!bts->si_unused_send_empty)
882 vty_out(vty, " no system-information unused-send-empty%s", VTY_NEWLINE);
Harald Welte9fbff4a2010-07-30 11:50:09 +0200883 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
884 if (bts->si_mode_static & (1 << i)) {
885 vty_out(vty, " system-information %s mode static%s",
886 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
887 vty_out(vty, " system-information %s static %s%s",
888 get_value_string(osmo_sitype_strs, i),
Max6f0e50c2017-04-12 15:30:54 +0200889 osmo_hexdump_nospc(GSM_BTS_SI(bts, i), GSM_MACBLOCK_LEN),
Harald Welte9fbff4a2010-07-30 11:50:09 +0200890 VTY_NEWLINE);
891 }
892 }
Harald Welte42def722017-01-13 00:10:32 +0100893 vty_out(vty, " early-classmark-sending %s%s",
894 bts->early_classmark_allowed ? "allowed" : "forbidden", VTY_NEWLINE);
Pau Espin Pedrole8dda5f2017-11-23 19:06:09 +0100895 vty_out(vty, " early-classmark-sending-3g %s%s",
896 bts->early_classmark_allowed_3g ? "allowed" : "forbidden", VTY_NEWLINE);
Harald Weltefd355a32011-03-04 13:41:31 +0100897 switch (bts->type) {
898 case GSM_BTS_TYPE_NANOBTS:
Maxf9685c12017-03-23 12:01:07 +0100899 case GSM_BTS_TYPE_OSMOBTS:
Harald Welte5013b2a2009-08-07 13:29:14 +0200900 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200901 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte8b291802013-03-12 13:57:05 +0100902 if (bts->ip_access.rsl_ip) {
903 struct in_addr ia;
904 ia.s_addr = htonl(bts->ip_access.rsl_ip);
905 vty_out(vty, " ip.access rsl-ip %s%s", inet_ntoa(ia),
906 VTY_NEWLINE);
907 }
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200908 vty_out(vty, " oml ip.access stream_id %u line %u%s",
909 bts->oml_tei, bts->oml_e1_link.e1_nr, VTY_NEWLINE);
Harald Weltefd355a32011-03-04 13:41:31 +0100910 break;
Sylvain Munautc9519462011-10-17 14:04:55 +0200911 case GSM_BTS_TYPE_NOKIA_SITE:
912 vty_out(vty, " nokia_site skip-reset %d%s", bts->nokia.skip_reset, VTY_NEWLINE);
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100913 vty_out(vty, " nokia_site no-local-rel-conf %d%s",
914 bts->nokia.no_loc_rel_cnf, VTY_NEWLINE);
Sipos Csaba56e17662015-02-07 13:27:36 +0100915 vty_out(vty, " nokia_site bts-reset-timer %d%s", bts->nokia.bts_reset_timer_cnf, VTY_NEWLINE);
Andreas Eversbergb6f95162013-12-05 16:02:37 +0100916 /* fall through: Nokia requires "oml e1" parameters also */
Harald Weltefd355a32011-03-04 13:41:31 +0100917 default:
Harald Welte42581822009-08-08 16:12:58 +0200918 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
919 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
Harald Weltefd355a32011-03-04 13:41:31 +0100920 break;
Harald Welte42581822009-08-08 16:12:58 +0200921 }
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800922
923 /* if we have a limit, write it */
924 if (bts->paging.free_chans_need >= 0)
925 vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
926
Harald Welte32c09622011-01-11 23:44:56 +0100927 vty_out(vty, " neighbor-list mode %s%s",
Harald Welte64c07d22011-02-15 11:43:27 +0100928 get_value_string(bts_neigh_mode_strs, bts->neigh_list_manual_mode), VTY_NEWLINE);
929 if (bts->neigh_list_manual_mode != NL_MODE_AUTOMATIC) {
Harald Welte32c09622011-01-11 23:44:56 +0100930 for (i = 0; i < 1024; i++) {
931 if (bitvec_get_bit_pos(&bts->si_common.neigh_list, i))
932 vty_out(vty, " neighbor-list add arfcn %u%s",
933 i, VTY_NEWLINE);
934 }
935 }
Harald Welte64c07d22011-02-15 11:43:27 +0100936 if (bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) {
937 for (i = 0; i < 1024; i++) {
938 if (bitvec_get_bit_pos(&bts->si_common.si5_neigh_list, i))
939 vty_out(vty, " si5 neighbor-list add arfcn %u%s",
940 i, VTY_NEWLINE);
941 }
942 }
Harald Welte32c09622011-01-11 23:44:56 +0100943
Max59a1bf32016-04-15 16:04:46 +0200944 for (i = 0; i < MAX_EARFCN_LIST; i++) {
Max2c16bee2017-02-15 13:51:37 +0100945 struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;
946 if (e->arfcn[i] != OSMO_EARFCN_INVALID) {
947 vty_out(vty, " si2quater neighbor-list add earfcn %u "
948 "thresh-hi %u", e->arfcn[i], e->thresh_hi);
949
950 vty_out(vty, " thresh-lo %u",
951 e->thresh_lo_valid ? e->thresh_lo : 32);
952
953 vty_out(vty, " prio %u",
954 e->prio_valid ? e->prio : 8);
955
956 vty_out(vty, " qrxlv %u",
957 e->qrxlm_valid ? e->qrxlm : 32);
958
959 tmp = e->meas_bw[i];
960 vty_out(vty, " meas %u",
961 (tmp != OSMO_EARFCN_MEAS_INVALID) ? tmp : 8);
Max59a1bf32016-04-15 16:04:46 +0200962
963 vty_out(vty, "%s", VTY_NEWLINE);
964 }
965 }
966
Max26679e02016-04-20 15:57:13 +0200967 for (i = 0; i < bts->si_common.uarfcn_length; i++) {
968 vty_out(vty, " si2quater neighbor-list add uarfcn %u %u %u%s",
969 bts->si_common.data.uarfcn_list[i],
970 bts->si_common.data.scramble_list[i] & ~(1 << 9),
971 (bts->si_common.data.scramble_list[i] >> 9) & 1,
972 VTY_NEWLINE);
973 }
974
Neels Hofmeyr19bed232018-03-22 04:54:57 +0100975 neighbor_ident_vty_write(vty, " ", bts);
976
Andreas Eversberga83d5112013-12-07 18:32:28 +0100977 vty_out(vty, " codec-support fr");
978 if (bts->codec.hr)
979 vty_out(vty, " hr");
980 if (bts->codec.efr)
981 vty_out(vty, " efr");
982 if (bts->codec.amr)
983 vty_out(vty, " amr");
984 vty_out(vty, "%s", VTY_NEWLINE);
985
Andreas Eversberg73266522014-01-19 11:47:44 +0100986 config_write_bts_amr(vty, bts, &bts->mr_full, 1);
987 config_write_bts_amr(vty, bts, &bts->mr_half, 0);
988
Harald Welte615e9562010-05-11 23:50:21 +0200989 config_write_bts_gprs(vty, bts);
Harald Welte67ce0732009-08-06 19:06:46 +0200990
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200991 if (bts->excl_from_rf_lock)
992 vty_out(vty, " rf-lock-exclude%s", VTY_NEWLINE);
993
Pau Espin Pedrol167cb822018-11-19 17:48:17 +0100994 if (bts->force_combined_si_set)
995 vty_out(vty, " %sforce-combined-si%s",
996 bts->force_combined_si ? "" : "no ", VTY_NEWLINE);
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100997
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100998 for (i = 0; i < ARRAY_SIZE(bts->depends_on); ++i) {
999 int j;
1000
1001 if (bts->depends_on[i] == 0)
1002 continue;
1003
1004 for (j = 0; j < sizeof(bts->depends_on[i]) * 8; ++j) {
1005 int bts_nr;
1006
1007 if ((bts->depends_on[i] & (1<<j)) == 0)
1008 continue;
1009
1010 bts_nr = (i * sizeof(bts->depends_on[i]) * 8) + j;
1011 vty_out(vty, " depends-on-bts %d%s", bts_nr, VTY_NEWLINE);
1012 }
1013 }
Harald Welte8254cf72017-05-29 13:42:19 +02001014 if (bts->pcu_sock_path)
1015 vty_out(vty, " pcu-socket %s%s", bts->pcu_sock_path, VTY_NEWLINE);
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +01001016
Neels Hofmeyrdfd36da2018-02-12 16:48:45 +01001017 ho_vty_write_bts(vty, bts);
Neels Hofmeyre25018b2017-11-27 21:29:33 +01001018
Holger Hans Peter Freythercd40fb42013-09-15 17:23:34 +02001019 config_write_bts_model(vty, bts);
Harald Welte67ce0732009-08-06 19:06:46 +02001020}
1021
1022static int config_write_bts(struct vty *v)
1023{
Harald Weltedcccb182010-05-16 20:52:23 +02001024 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte67ce0732009-08-06 19:06:46 +02001025 struct gsm_bts *bts;
1026
1027 llist_for_each_entry(bts, &gsmnet->bts_list, list)
1028 config_write_bts_single(v, bts);
1029
1030 return CMD_SUCCESS;
1031}
1032
Harald Welte5013b2a2009-08-07 13:29:14 +02001033static int config_write_net(struct vty *vty)
1034{
Harald Weltedcccb182010-05-16 20:52:23 +02001035 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte51e4bf32017-12-23 17:30:18 +01001036 int i;
Harald Weltedcccb182010-05-16 20:52:23 +02001037
Harald Welte5013b2a2009-08-07 13:29:14 +02001038 vty_out(vty, "network%s", VTY_NEWLINE);
Neels Hofmeyrf93970b2018-03-05 02:09:40 +01001039 vty_out(vty, " network country code %s%s", osmo_mcc_name(gsmnet->plmn.mcc), VTY_NEWLINE);
1040 vty_out(vty, " mobile network code %s%s",
1041 osmo_mnc_name(gsmnet->plmn.mnc, gsmnet->plmn.mnc_3_digits), VTY_NEWLINE);
Harald Welte51e4bf32017-12-23 17:30:18 +01001042 vty_out(vty, " encryption a5");
1043 for (i = 0; i < 8; i++) {
1044 if (gsmnet->a5_encryption_mask & (1 << i))
1045 vty_out(vty, " %u", i);
1046 }
1047 vty_out(vty, "%s", VTY_NEWLINE);
Holger Hans Peter Freytherd54c3372009-11-19 16:37:48 +01001048 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001049 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
Neels Hofmeyre25018b2017-11-27 21:29:33 +01001050
Neels Hofmeyrdfd36da2018-02-12 16:48:45 +01001051 ho_vty_write_net(vty, gsmnet);
Neels Hofmeyre25018b2017-11-27 21:29:33 +01001052
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01001053 osmo_tdef_vty_write(vty, gsmnet->T_defs, " ");
Neels Hofmeyr0abe84e2018-05-14 18:14:29 +02001054
Neels Hofmeyr78faf702018-05-10 05:22:50 +02001055 if (!gsmnet->dyn_ts_allow_tch_f)
1056 vty_out(vty, " dyn_ts_allow_tch_f 0%s", VTY_NEWLINE);
Neels Hofmeyr73983952016-05-10 13:29:33 +02001057 if (gsmnet->tz.override != 0) {
1058 if (gsmnet->tz.dst)
1059 vty_out(vty, " timezone %d %d %d%s",
1060 gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst,
1061 VTY_NEWLINE);
1062 else
1063 vty_out(vty, " timezone %d %d%s",
1064 gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE);
1065 }
Neels Hofmeyr596c4022018-06-16 19:29:50 +02001066
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01001067 osmo_tdef_vty_write(vty, gsmnet->T_defs, " timer ");
Harald Welte5013b2a2009-08-07 13:29:14 +02001068
Neels Hofmeyrf28f1ef2018-04-20 15:53:53 +02001069 {
1070 uint16_t meas_port;
1071 char *meas_host;
1072 const char *meas_scenario;
1073
1074 meas_feed_cfg_get(&meas_host, &meas_port);
1075 meas_scenario = meas_feed_scenario_get();
1076
1077 if (meas_port)
1078 vty_out(vty, " meas-feed destination %s %u%s",
1079 meas_host, meas_port, VTY_NEWLINE);
1080 if (strlen(meas_scenario) > 0)
1081 vty_out(vty, " meas-feed scenario %s%s",
1082 meas_scenario, VTY_NEWLINE);
1083 }
1084
Harald Welte5013b2a2009-08-07 13:29:14 +02001085 return CMD_SUCCESS;
1086}
Harald Welte67ce0732009-08-06 19:06:46 +02001087
Max6f379ba2018-11-19 14:05:04 +01001088static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx, bool print_rsl, bool show_connected)
Harald Welte68628e82009-03-10 12:17:57 +00001089{
Max6f379ba2018-11-19 14:05:04 +01001090 if (show_connected && !trx->rsl_link)
1091 return;
1092
1093 if (!show_connected && trx->rsl_link)
1094 return;
1095
Harald Welte68628e82009-03-10 12:17:57 +00001096 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
1097 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +02001098 vty_out(vty, "Description: %s%s",
1099 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +02001100 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte42581822009-08-08 16:12:58 +02001101 "resulting BS power: %d dBm%s",
Harald Weltefcd24452009-06-20 18:15:19 +02001102 trx->nominal_power, trx->max_power_red,
Harald Welte42581822009-08-08 16:12:58 +02001103 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +00001104 vty_out(vty, " NM State: ");
Harald Welted64c0bc2011-05-30 12:07:53 +02001105 net_dump_nmstate(vty, &trx->mo.nm_state);
Max6f379ba2018-11-19 14:05:04 +01001106 if (print_rsl)
1107 vty_out(vty, " RSL State: %s%s", trx->rsl_link? "connected" : "disconnected", VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +00001108 vty_out(vty, " Baseband Transceiver NM State: ");
Harald Welted64c0bc2011-05-30 12:07:53 +02001109 net_dump_nmstate(vty, &trx->bb_transc.mo.nm_state);
Harald Welte8175e952009-10-20 00:22:00 +02001110 if (is_ipaccess_bts(trx->bts)) {
Oliver Smithf1051902018-10-09 15:24:06 +02001111 vty_out(vty, " ip.access stream ID: 0x%02x ", trx->rsl_tei);
1112 e1isl_dump_vty_tcp(vty, trx->rsl_link);
Harald Welte8175e952009-10-20 00:22:00 +02001113 } else {
1114 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
1115 e1isl_dump_vty(vty, trx->rsl_link);
1116 }
Harald Welte68628e82009-03-10 12:17:57 +00001117}
1118
Max6f379ba2018-11-19 14:05:04 +01001119static void trx_dump_vty_all(struct vty *vty, struct gsm_bts_trx *trx)
1120{
1121 trx_dump_vty(vty, trx, true, true);
1122 trx_dump_vty(vty, trx, true, false);
1123}
1124
Max6e4f1842018-01-07 16:45:42 +01001125static inline void print_all_trx(struct vty *vty, const struct gsm_bts *bts)
1126{
1127 uint8_t trx_nr;
1128 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++)
Max6f379ba2018-11-19 14:05:04 +01001129 trx_dump_vty_all(vty, gsm_bts_trx_num(bts, trx_nr));
Max6e4f1842018-01-07 16:45:42 +01001130}
1131
Harald Welte68628e82009-03-10 12:17:57 +00001132DEFUN(show_trx,
1133 show_trx_cmd,
Sylvain Munaut39c31de2012-12-28 12:15:11 +01001134 "show trx [<0-255>] [<0-255>]",
Harald Welte8f0ed552010-05-11 21:53:49 +02001135 SHOW_STR "Display information about a TRX\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01001136 BTS_TRX_STR)
Harald Welte68628e82009-03-10 12:17:57 +00001137{
Harald Weltedcccb182010-05-16 20:52:23 +02001138 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +00001139 struct gsm_bts *bts = NULL;
Harald Welte68628e82009-03-10 12:17:57 +00001140 int bts_nr, trx_nr;
1141
1142 if (argc >= 1) {
1143 /* use the BTS number that the user has specified */
1144 bts_nr = atoi(argv[0]);
1145 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +00001146 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +00001147 VTY_NEWLINE);
1148 return CMD_WARNING;
1149 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001150 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +00001151 }
1152 if (argc >= 2) {
1153 trx_nr = atoi(argv[1]);
1154 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +00001155 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +00001156 VTY_NEWLINE);
1157 return CMD_WARNING;
1158 }
Max6f379ba2018-11-19 14:05:04 +01001159 trx_dump_vty_all(vty, gsm_bts_trx_num(bts, trx_nr));
1160
Harald Welte68628e82009-03-10 12:17:57 +00001161 return CMD_SUCCESS;
1162 }
1163 if (bts) {
1164 /* print all TRX in this BTS */
Max6e4f1842018-01-07 16:45:42 +01001165 print_all_trx(vty, bts);
Harald Welte68628e82009-03-10 12:17:57 +00001166 return CMD_SUCCESS;
1167 }
1168
Max6e4f1842018-01-07 16:45:42 +01001169 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
1170 print_all_trx(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +00001171
1172 return CMD_SUCCESS;
1173}
1174
Stefan Sperlingc4596992018-11-13 13:59:51 +01001175/* call vty_out() to print a string like " as TCH/H" for dynamic timeslots.
1176 * Don't do anything if the ts is not dynamic. */
1177static void vty_out_dyn_ts_status(struct vty *vty, struct gsm_bts_trx_ts *ts)
1178{
1179 enum gsm_phys_chan_config target;
1180 if (ts_is_pchan_switching(ts, &target)) {
1181 vty_out(vty, " switching %s -> %s", gsm_pchan_name(ts->pchan_is),
1182 gsm_pchan_name(target));
1183 } else if (ts->pchan_is != ts->pchan_on_init) {
1184 vty_out(vty, " as %s", gsm_pchan_name(ts->pchan_is));
1185 }
1186}
1187
1188static void vty_out_dyn_ts_details(struct vty *vty, struct gsm_bts_trx_ts *ts)
1189{
1190 /* show dyn TS details, if applicable */
1191 switch (ts->pchan_on_init) {
1192 case GSM_PCHAN_TCH_F_TCH_H_PDCH:
1193 vty_out(vty, " Osmocom Dyn TS:");
1194 vty_out_dyn_ts_status(vty, ts);
1195 vty_out(vty, VTY_NEWLINE);
1196 break;
1197 case GSM_PCHAN_TCH_F_PDCH:
1198 vty_out(vty, " IPACC Dyn PDCH TS:");
1199 vty_out_dyn_ts_status(vty, ts);
1200 vty_out(vty, VTY_NEWLINE);
1201 break;
1202 default:
1203 /* no dyn ts */
1204 break;
1205 }
1206}
Harald Welte67ce0732009-08-06 19:06:46 +02001207
Harald Welte68628e82009-03-10 12:17:57 +00001208static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
1209{
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001210 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s",
Harald Welte026b4ca2010-12-24 12:12:10 +01001211 ts->trx->bts->nr, ts->trx->nr, ts->nr,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001212 gsm_pchan_name(ts->pchan_on_init));
1213 if (ts->pchan_is != ts->pchan_on_init)
1214 vty_out(vty, " (%s mode)", gsm_pchan_name(ts->pchan_is));
1215 vty_out(vty, ", TSC %u%s NM State: ", gsm_ts_tsc(ts), VTY_NEWLINE);
Stefan Sperlingc4596992018-11-13 13:59:51 +01001216 vty_out_dyn_ts_details(vty, ts);
Harald Welted64c0bc2011-05-30 12:07:53 +02001217 net_dump_nmstate(vty, &ts->mo.nm_state);
Harald Welte2c828992009-12-02 01:56:49 +05301218 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welteef235b52009-03-10 12:34:02 +00001219 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
1220 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
1221 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +00001222}
1223
1224DEFUN(show_ts,
1225 show_ts_cmd,
Sylvain Munaut39c31de2012-12-28 12:15:11 +01001226 "show timeslot [<0-255>] [<0-255>] [<0-7>]",
Harald Welte8f0ed552010-05-11 21:53:49 +02001227 SHOW_STR "Display information about a TS\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01001228 BTS_TRX_TS_STR)
Harald Welte68628e82009-03-10 12:17:57 +00001229{
Harald Weltedcccb182010-05-16 20:52:23 +02001230 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte274d0152010-12-24 12:05:03 +01001231 struct gsm_bts *bts = NULL;
1232 struct gsm_bts_trx *trx = NULL;
1233 struct gsm_bts_trx_ts *ts = NULL;
Harald Welte68628e82009-03-10 12:17:57 +00001234 int bts_nr, trx_nr, ts_nr;
1235
1236 if (argc >= 1) {
1237 /* use the BTS number that the user has specified */
1238 bts_nr = atoi(argv[0]);
1239 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +00001240 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +00001241 VTY_NEWLINE);
1242 return CMD_WARNING;
1243 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001244 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +00001245 }
1246 if (argc >= 2) {
1247 trx_nr = atoi(argv[1]);
1248 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +00001249 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +00001250 VTY_NEWLINE);
1251 return CMD_WARNING;
1252 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001253 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +00001254 }
1255 if (argc >= 3) {
1256 ts_nr = atoi(argv[2]);
1257 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +00001258 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +00001259 VTY_NEWLINE);
1260 return CMD_WARNING;
1261 }
Harald Welte274d0152010-12-24 12:05:03 +01001262 /* Fully Specified: print and exit */
Harald Welte68628e82009-03-10 12:17:57 +00001263 ts = &trx->ts[ts_nr];
1264 ts_dump_vty(vty, ts);
1265 return CMD_SUCCESS;
1266 }
Harald Welte274d0152010-12-24 12:05:03 +01001267
1268 if (bts && trx) {
1269 /* Iterate over all TS in this TRX */
1270 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
1271 ts = &trx->ts[ts_nr];
1272 ts_dump_vty(vty, ts);
1273 }
1274 } else if (bts) {
1275 /* Iterate over all TRX in this BTS, TS in each TRX */
Harald Welte68628e82009-03-10 12:17:57 +00001276 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +02001277 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +00001278 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
1279 ts = &trx->ts[ts_nr];
1280 ts_dump_vty(vty, ts);
1281 }
1282 }
Harald Welte274d0152010-12-24 12:05:03 +01001283 } else {
1284 /* Iterate over all BTS, TRX in each BTS, TS in each TRX */
1285 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
1286 bts = gsm_bts_num(net, bts_nr);
1287 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
1288 trx = gsm_bts_trx_num(bts, trx_nr);
1289 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
1290 ts = &trx->ts[ts_nr];
1291 ts_dump_vty(vty, ts);
1292 }
1293 }
1294 }
Harald Welte68628e82009-03-10 12:17:57 +00001295 }
1296
1297 return CMD_SUCCESS;
1298}
1299
Neels Hofmeyr6d804b12017-02-18 22:20:46 +01001300static void bsc_subscr_dump_vty(struct vty *vty, struct bsc_subscr *bsub)
1301{
1302 if (strlen(bsub->imsi))
1303 vty_out(vty, " IMSI: %s%s", bsub->imsi, VTY_NEWLINE);
1304 if (bsub->tmsi != GSM_RESERVED_TMSI)
1305 vty_out(vty, " TMSI: 0x%08x%s", bsub->tmsi,
1306 VTY_NEWLINE);
1307 vty_out(vty, " Use count: %d%s", bsub->use_count, VTY_NEWLINE);
1308}
1309
Harald Welte8387a492009-12-22 21:43:14 +01001310static void meas_rep_dump_uni_vty(struct vty *vty,
1311 struct gsm_meas_rep_unidir *mru,
1312 const char *prefix,
1313 const char *dir)
1314{
1315 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
1316 prefix, dir, rxlev2dbm(mru->full.rx_lev),
1317 dir, rxlev2dbm(mru->sub.rx_lev));
1318 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
1319 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
1320 VTY_NEWLINE);
1321}
1322
1323static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
1324 const char *prefix)
1325{
1326 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
1327 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
1328 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
1329 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
1330 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
1331 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
1332 VTY_NEWLINE);
1333 if (mr->flags & MEAS_REP_F_MS_TO)
Max11e4e412017-04-20 13:07:58 +02001334 vty_out(vty, "%s MS Timing Offset: %d%s", prefix, mr->ms_timing_offset, VTY_NEWLINE);
Harald Welte8387a492009-12-22 21:43:14 +01001335 if (mr->flags & MEAS_REP_F_MS_L1)
1336 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
1337 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
1338 if (mr->flags & MEAS_REP_F_DL_VALID)
1339 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
1340 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
1341}
1342
Max6f379ba2018-11-19 14:05:04 +01001343static inline void print_all_trx_ext(struct vty *vty, bool show_connected)
1344{
1345 struct gsm_network *net = gsmnet_from_vty(vty);
1346 struct gsm_bts *bts = NULL;
1347 uint8_t bts_nr;
1348 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
1349 uint8_t trx_nr;
1350 bts = gsm_bts_num(net, bts_nr);
1351 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++)
1352 trx_dump_vty(vty, gsm_bts_trx_num(bts, trx_nr), false, show_connected);
1353 }
1354}
1355
1356DEFUN(show_trx_con,
1357 show_trx_con_cmd,
1358 "show trx (connected|disconnected)",
1359 SHOW_STR "Display information about a TRX\n"
1360 "Show TRX with RSL connected\n"
1361 "Show TRX with RSL disconnected\n")
1362{
1363 if (!strcmp(argv[0], "connected"))
1364 print_all_trx_ext(vty, true);
1365 else
1366 print_all_trx_ext(vty, false);
1367
1368 return CMD_SUCCESS;
1369}
Harald Welte0a8cf322015-12-05 17:22:49 +01001370
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +08001371static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte68628e82009-03-10 12:17:57 +00001372{
Harald Welte8387a492009-12-22 21:43:14 +01001373 int idx;
1374
Harald Welte85bded82010-12-24 12:22:34 +01001375 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
1376 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
1377 lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
Stefan Sperlingc4596992018-11-13 13:59:51 +01001378 vty_out_dyn_ts_details(vty, lchan->ts);
Holger Hans Peter Freyther454140e2014-12-28 12:08:28 +01001379 vty_out(vty, " Connection: %u, State: %s%s%s%s",
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001380 lchan->conn ? 1: 0, lchan_state_name(lchan),
1381 lchan->fi && lchan->fi->state == LCHAN_ST_BORKEN ? " Error reason: " : "",
1382 lchan->fi && lchan->fi->state == LCHAN_ST_BORKEN ? lchan->last_error : "",
Holger Hans Peter Freyther454140e2014-12-28 12:08:28 +01001383 VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +01001384 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
1385 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
1386 - lchan->bs_power*2,
1387 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
1388 VTY_NEWLINE);
Harald Welte0a8cf322015-12-05 17:22:49 +01001389 vty_out(vty, " Channel Mode / Codec: %s%s",
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001390 gsm48_chan_mode_name(lchan->tch_mode),
Harald Welte0a8cf322015-12-05 17:22:49 +01001391 VTY_NEWLINE);
Neels Hofmeyr7b656882017-07-09 22:09:18 +02001392 if (lchan->conn && lchan->conn->bsub) {
Harald Welte68628e82009-03-10 12:17:57 +00001393 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Neels Hofmeyr7b656882017-07-09 22:09:18 +02001394 bsc_subscr_dump_vty(vty, lchan->conn->bsub);
Harald Welte68628e82009-03-10 12:17:57 +00001395 } else
1396 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte2c828992009-12-02 01:56:49 +05301397 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
1398 struct in_addr ia;
Harald Welte5f45a4a2018-02-05 21:33:34 +01001399 if (lchan->abis_ip.bound_ip) {
1400 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
1401 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
1402 inet_ntoa(ia), lchan->abis_ip.bound_port,
1403 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
1404 VTY_NEWLINE);
1405 }
1406 if (lchan->abis_ip.connect_ip) {
1407 ia.s_addr = htonl(lchan->abis_ip.connect_ip);
1408 vty_out(vty, " Conn. IP: %s Port %u RTP_TYPE=%u SPEECH_MODE=0x%02x%s",
1409 inet_ntoa(ia), lchan->abis_ip.connect_port,
1410 lchan->abis_ip.rtp_payload, lchan->abis_ip.speech_mode,
1411 VTY_NEWLINE);
1412 }
1413
Harald Welte2c828992009-12-02 01:56:49 +05301414 }
Harald Welte8387a492009-12-22 21:43:14 +01001415
1416 /* we want to report the last measurement report */
1417 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
1418 lchan->meas_rep_idx, 1);
1419 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte68628e82009-03-10 12:17:57 +00001420}
1421
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08001422static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
1423{
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +08001424 struct gsm_meas_rep *mr;
1425 int idx;
1426
1427 /* we want to report the last measurement report */
1428 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
1429 lchan->meas_rep_idx, 1);
1430 mr = &lchan->meas_rep[idx];
1431
Neels Hofmeyrb7480122016-11-02 14:28:15 +01001432 vty_out(vty, "BTS %u, TRX %u, Timeslot %u %s",
Harald Welte85bded82010-12-24 12:22:34 +01001433 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001434 gsm_pchan_name(lchan->ts->pchan_on_init));
Neels Hofmeyrb7480122016-11-02 14:28:15 +01001435 vty_out_dyn_ts_status(vty, lchan->ts);
1436 vty_out(vty, ", Lchan %u, Type %s, State %s - "
1437 "L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
Neels Hofmeyrefedf802016-06-14 01:31:38 +02001438 lchan->nr,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001439 gsm_lchant_name(lchan->type), lchan_state_name(lchan),
Neels Hofmeyrefedf802016-06-14 01:31:38 +02001440 mr->ms_l1.pwr,
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +08001441 rxlev2dbm(mr->dl.full.rx_lev),
1442 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08001443 VTY_NEWLINE);
1444}
1445
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001446
1447static int dump_lchan_trx_ts(struct gsm_bts_trx_ts *ts, struct vty *vty,
Philipp Maier761fa132019-01-22 10:25:05 +01001448 void (*dump_cb)(struct vty *, struct gsm_lchan *),
1449 bool all)
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001450{
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001451 struct gsm_lchan *lchan;
1452 ts_for_each_lchan(lchan, ts) {
Philipp Maier761fa132019-01-22 10:25:05 +01001453 if (lchan_state_is(lchan, LCHAN_ST_UNUSED) && all == false)
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001454 continue;
1455 dump_cb(vty, lchan);
1456 }
1457
1458 return CMD_SUCCESS;
1459}
1460
1461static int dump_lchan_trx(struct gsm_bts_trx *trx, struct vty *vty,
Philipp Maier761fa132019-01-22 10:25:05 +01001462 void (*dump_cb)(struct vty *, struct gsm_lchan *),
1463 bool all)
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001464{
1465 int ts_nr;
1466
1467 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
1468 struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
Philipp Maier761fa132019-01-22 10:25:05 +01001469 dump_lchan_trx_ts(ts, vty, dump_cb, all);
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001470 }
1471
1472 return CMD_SUCCESS;
1473}
1474
1475static int dump_lchan_bts(struct gsm_bts *bts, struct vty *vty,
Philipp Maier761fa132019-01-22 10:25:05 +01001476 void (*dump_cb)(struct vty *, struct gsm_lchan *),
1477 bool all)
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001478{
1479 int trx_nr;
1480
1481 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
1482 struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_nr);
Philipp Maier761fa132019-01-22 10:25:05 +01001483 dump_lchan_trx(trx, vty, dump_cb, all);
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001484 }
1485
1486 return CMD_SUCCESS;
1487}
1488
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +08001489static int lchan_summary(struct vty *vty, int argc, const char **argv,
Philipp Maier761fa132019-01-22 10:25:05 +01001490 void (*dump_cb)(struct vty *, struct gsm_lchan *),
1491 bool all)
Harald Welte68628e82009-03-10 12:17:57 +00001492{
Harald Weltedcccb182010-05-16 20:52:23 +02001493 struct gsm_network *net = gsmnet_from_vty(vty);
Pau Espin Pedrolcf48c542018-03-26 18:20:34 +02001494 struct gsm_bts *bts = NULL;
1495 struct gsm_bts_trx *trx = NULL;
1496 struct gsm_bts_trx_ts *ts = NULL;
Harald Welte68628e82009-03-10 12:17:57 +00001497 struct gsm_lchan *lchan;
1498 int bts_nr, trx_nr, ts_nr, lchan_nr;
1499
1500 if (argc >= 1) {
1501 /* use the BTS number that the user has specified */
1502 bts_nr = atoi(argv[0]);
1503 if (bts_nr >= net->num_bts) {
1504 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1505 VTY_NEWLINE);
1506 return CMD_WARNING;
1507 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001508 bts = gsm_bts_num(net, bts_nr);
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001509
1510 if (argc == 1)
Philipp Maier761fa132019-01-22 10:25:05 +01001511 return dump_lchan_bts(bts, vty, dump_cb, all);
Harald Welte68628e82009-03-10 12:17:57 +00001512 }
1513 if (argc >= 2) {
1514 trx_nr = atoi(argv[1]);
1515 if (trx_nr >= bts->num_trx) {
1516 vty_out(vty, "%% can't find TRX %s%s", argv[1],
1517 VTY_NEWLINE);
1518 return CMD_WARNING;
1519 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001520 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001521
1522 if (argc == 2)
Philipp Maier761fa132019-01-22 10:25:05 +01001523 return dump_lchan_trx(trx, vty, dump_cb, all);
Harald Welte68628e82009-03-10 12:17:57 +00001524 }
1525 if (argc >= 3) {
1526 ts_nr = atoi(argv[2]);
1527 if (ts_nr >= TRX_NR_TS) {
1528 vty_out(vty, "%% can't find TS %s%s", argv[2],
1529 VTY_NEWLINE);
1530 return CMD_WARNING;
1531 }
1532 ts = &trx->ts[ts_nr];
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001533
1534 if (argc == 3)
Philipp Maier761fa132019-01-22 10:25:05 +01001535 return dump_lchan_trx_ts(ts, vty, dump_cb, all);
Harald Welte68628e82009-03-10 12:17:57 +00001536 }
1537 if (argc >= 4) {
1538 lchan_nr = atoi(argv[3]);
1539 if (lchan_nr >= TS_MAX_LCHAN) {
1540 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
1541 VTY_NEWLINE);
1542 return CMD_WARNING;
1543 }
1544 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +08001545 dump_cb(vty, lchan);
Harald Welte68628e82009-03-10 12:17:57 +00001546 return CMD_SUCCESS;
1547 }
Holger Hans Peter Freyther7173f632011-12-27 16:34:12 +01001548
1549
Harald Welte68628e82009-03-10 12:17:57 +00001550 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +02001551 bts = gsm_bts_num(net, bts_nr);
Philipp Maier761fa132019-01-22 10:25:05 +01001552 dump_lchan_bts(bts, vty, dump_cb, all);
Harald Welte68628e82009-03-10 12:17:57 +00001553 }
1554
1555 return CMD_SUCCESS;
1556}
1557
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +08001558
1559DEFUN(show_lchan,
1560 show_lchan_cmd,
Neels Hofmeyre5b5a892018-01-19 15:41:24 +01001561 "show lchan [<0-255>] [<0-255>] [<0-7>] [<0-7>]",
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +08001562 SHOW_STR "Display information about a logical channel\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01001563 BTS_TRX_TS_LCHAN_STR)
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +08001564{
Philipp Maier761fa132019-01-22 10:25:05 +01001565 return lchan_summary(vty, argc, argv, lchan_dump_full_vty, true);
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +08001566}
1567
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08001568DEFUN(show_lchan_summary,
1569 show_lchan_summary_cmd,
Neels Hofmeyre5b5a892018-01-19 15:41:24 +01001570 "show lchan summary [<0-255>] [<0-255>] [<0-7>] [<0-7>]",
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08001571 SHOW_STR "Display information about a logical channel\n"
Philipp Maier761fa132019-01-22 10:25:05 +01001572 "Short summary (used lchans)\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01001573 BTS_TRX_TS_LCHAN_STR)
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08001574{
Philipp Maier761fa132019-01-22 10:25:05 +01001575 return lchan_summary(vty, argc, argv, lchan_dump_short_vty, false);
1576}
1577
1578DEFUN(show_lchan_summary_all,
1579 show_lchan_summary_all_cmd,
1580 "show lchan summary-all [<0-255>] [<0-255>] [<0-7>] [<0-7>]",
1581 SHOW_STR "Display information about a logical channel\n"
1582 "Short summary (all lchans)\n"
1583 BTS_TRX_TS_LCHAN_STR)
1584{
1585 return lchan_summary(vty, argc, argv, lchan_dump_short_vty, true);
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08001586}
1587
Harald Welte00965dc2018-05-30 23:45:53 +02001588static void dump_one_subscr_conn(struct vty *vty, const struct gsm_subscriber_connection *conn)
1589{
Philipp Maieref121b22018-09-12 16:48:53 +02001590 vty_out(vty, "conn ID=%u, MSC=%u, hodec2_fail=%d, mgw_ep=%s%s",
Harald Welte00965dc2018-05-30 23:45:53 +02001591 conn->sccp.conn_id, conn->sccp.msc->nr, conn->hodec2.failures,
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +02001592 osmo_mgcpc_ep_name(conn->user_plane.mgw_endpoint), VTY_NEWLINE);
Harald Weltec997ceb2018-05-30 01:39:43 +02001593 if (conn->lcls.global_call_ref_len) {
1594 vty_out(vty, " LCLS GCR: %s%s",
1595 osmo_hexdump_nospc(conn->lcls.global_call_ref, conn->lcls.global_call_ref_len),
1596 VTY_NEWLINE);
Maxec4de9c2018-11-16 20:36:12 +01001597 vty_out(vty, " LCLS Config: %s, LCLS Control: %s, LCLS BSS Status: %s%s",
1598 gsm0808_lcls_config_name(conn->lcls.config),
1599 gsm0808_lcls_control_name(conn->lcls.control),
1600 osmo_fsm_inst_state_name(conn->lcls.fi),
Harald Weltec997ceb2018-05-30 01:39:43 +02001601 VTY_NEWLINE);
1602 }
Harald Welte00965dc2018-05-30 23:45:53 +02001603 if (conn->lchan)
1604 lchan_dump_full_vty(vty, conn->lchan);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001605 if (conn->assignment.new_lchan)
1606 lchan_dump_full_vty(vty, conn->assignment.new_lchan);
Harald Welte00965dc2018-05-30 23:45:53 +02001607}
1608
Philipp Maier39f62bb2017-04-09 12:32:51 +02001609DEFUN(show_subscr_conn,
1610 show_subscr_conn_cmd,
1611 "show conns",
1612 SHOW_STR "Display currently active subscriber connections\n")
1613{
1614 struct gsm_subscriber_connection *conn;
1615 struct gsm_network *net = gsmnet_from_vty(vty);
1616 bool no_conns = true;
1617 unsigned int count = 0;
1618
1619 vty_out(vty, "Active subscriber connections: %s", VTY_NEWLINE);
1620
1621 llist_for_each_entry(conn, &net->subscr_conns, entry) {
Harald Welte00965dc2018-05-30 23:45:53 +02001622 dump_one_subscr_conn(vty, conn);
Philipp Maier39f62bb2017-04-09 12:32:51 +02001623 no_conns = false;
1624 count++;
1625 }
1626
1627 if (no_conns)
1628 vty_out(vty, "None%s", VTY_NEWLINE);
1629
1630 return CMD_SUCCESS;
1631}
1632
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001633static int trigger_ho_or_as(struct vty *vty, struct gsm_lchan *from_lchan, struct gsm_bts *to_bts)
1634{
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001635 if (!to_bts || from_lchan->ts->trx->bts == to_bts) {
1636 LOGP(DHO, LOGL_NOTICE, "%s Manually triggering Assignment from VTY\n",
1637 gsm_lchan_name(from_lchan));
1638 to_bts = from_lchan->ts->trx->bts;
1639 } else
1640 LOGP(DHO, LOGL_NOTICE, "%s (ARFCN %u) --> BTS %u Manually triggering Handover from VTY\n",
1641 gsm_lchan_name(from_lchan), from_lchan->ts->trx->arfcn, to_bts->nr);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001642 {
1643 struct handover_out_req req = {
1644 .from_hodec_id = HODEC_USER,
1645 .old_lchan = from_lchan,
1646 .target_nik = *bts_ident_key(to_bts),
1647 };
1648 handover_request(&req);
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001649 }
1650 return CMD_SUCCESS;
1651}
1652
1653static int ho_or_as(struct vty *vty, const char *argv[], int argc)
Philipp Maier39f62bb2017-04-09 12:32:51 +02001654{
1655 struct gsm_network *net = gsmnet_from_vty(vty);
1656 struct gsm_subscriber_connection *conn;
1657 struct gsm_bts *bts;
1658 struct gsm_bts *new_bts = NULL;
1659 unsigned int bts_nr = atoi(argv[0]);
1660 unsigned int trx_nr = atoi(argv[1]);
1661 unsigned int ts_nr = atoi(argv[2]);
1662 unsigned int ss_nr = atoi(argv[3]);
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001663 unsigned int bts_nr_new;
1664 const char *action;
Philipp Maier39f62bb2017-04-09 12:32:51 +02001665
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001666 if (argc > 4) {
1667 bts_nr_new = atoi(argv[4]);
1668
1669 /* Lookup the BTS where we want to handover to */
1670 llist_for_each_entry(bts, &net->bts_list, list) {
1671 if (bts->nr == bts_nr_new) {
1672 new_bts = bts;
1673 break;
1674 }
1675 }
1676
1677 if (!new_bts) {
1678 vty_out(vty, "Unable to trigger handover, specified bts #%u does not exist %s",
1679 bts_nr_new, VTY_NEWLINE);
1680 return CMD_WARNING;
Philipp Maier39f62bb2017-04-09 12:32:51 +02001681 }
1682 }
1683
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001684 action = new_bts ? "handover" : "assignment";
Philipp Maier39f62bb2017-04-09 12:32:51 +02001685
1686 /* Find the connection/lchan that we want to handover */
1687 llist_for_each_entry(conn, &net->subscr_conns, entry) {
Harald Welte148ee362017-12-18 18:44:25 +01001688 if (conn_get_bts(conn)->nr == bts_nr &&
Philipp Maier39f62bb2017-04-09 12:32:51 +02001689 conn->lchan->ts->trx->nr == trx_nr &&
1690 conn->lchan->ts->nr == ts_nr && conn->lchan->nr == ss_nr) {
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001691 vty_out(vty, "starting %s for lchan %s...%s", action, conn->lchan->name, VTY_NEWLINE);
Philipp Maier39f62bb2017-04-09 12:32:51 +02001692 lchan_dump_full_vty(vty, conn->lchan);
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001693 return trigger_ho_or_as(vty, conn->lchan, new_bts);
Philipp Maier39f62bb2017-04-09 12:32:51 +02001694 }
1695 }
1696
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001697 vty_out(vty, "Unable to trigger %s, specified connection (bts=%u,trx=%u,ts=%u,ss=%u) does not exist%s",
1698 action, bts_nr, trx_nr, ts_nr, ss_nr, VTY_NEWLINE);
Philipp Maier39f62bb2017-04-09 12:32:51 +02001699
1700 return CMD_WARNING;
1701}
1702
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001703#define MANUAL_HANDOVER_STR "Manually trigger handover (for debugging)\n"
1704#define MANUAL_ASSIGNMENT_STR "Manually trigger assignment (for debugging)\n"
1705
1706DEFUN(handover_subscr_conn,
1707 handover_subscr_conn_cmd,
Harald Welteb22dcb82018-02-12 17:57:57 +01001708 "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> handover <0-255>",
Harald Welte0bfd8d92018-02-12 18:06:53 +01001709 BTS_NR_TRX_TS_SS_STR2
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001710 MANUAL_HANDOVER_STR
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001711 "New " BTS_NR_STR)
1712{
1713 return ho_or_as(vty, argv, argc);
1714}
1715
1716DEFUN(assignment_subscr_conn,
1717 assignment_subscr_conn_cmd,
Harald Welteb22dcb82018-02-12 17:57:57 +01001718 "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> assignment",
Harald Welte0bfd8d92018-02-12 18:06:53 +01001719 BTS_NR_TRX_TS_SS_STR2
Harald Welteb22dcb82018-02-12 17:57:57 +01001720 MANUAL_ASSIGNMENT_STR)
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001721{
1722 return ho_or_as(vty, argv, argc);
1723}
1724
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001725static struct gsm_lchan *find_used_voice_lchan(struct vty *vty, int random_idx)
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001726{
1727 struct gsm_bts *bts;
1728 struct gsm_network *network = gsmnet_from_vty(vty);
1729
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001730 while (1) {
1731 int count = 0;
1732 llist_for_each_entry(bts, &network->bts_list, list) {
1733 struct gsm_bts_trx *trx;
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001734
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001735 llist_for_each_entry(trx, &bts->trx_list, list) {
1736 int i;
1737 for (i = 0; i < ARRAY_SIZE(trx->ts); i++) {
1738 struct gsm_bts_trx_ts *ts = &trx->ts[i];
1739 struct gsm_lchan *lchan;
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001740
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001741 if (ts->fi->state != TS_ST_IN_USE)
1742 continue;
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001743
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001744 ts_for_each_lchan(lchan, ts) {
1745 if (lchan_state_is(lchan, LCHAN_ST_ESTABLISHED)
1746 && (lchan->type == GSM_LCHAN_TCH_F
1747 || lchan->type == GSM_LCHAN_TCH_H)) {
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001748
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001749 if (count == random_idx) {
1750 vty_out(vty, "Found voice call: %s%s",
1751 gsm_lchan_name(lchan),
1752 VTY_NEWLINE);
1753 lchan_dump_full_vty(vty, lchan);
1754 return lchan;
1755 }
1756 count ++;
1757 }
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001758 }
1759 }
1760 }
1761 }
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001762
1763 if (!count)
1764 break;
1765 /* there are used lchans, but random_idx is > count. Iterate again. */
1766 random_idx %= count;
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001767 }
1768
1769 vty_out(vty, "Cannot find any ongoing voice calls%s", VTY_NEWLINE);
1770 return NULL;
1771}
1772
1773static struct gsm_bts *find_other_bts_with_free_slots(struct vty *vty, struct gsm_bts *not_this_bts,
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001774 enum gsm_chan_t free_type)
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001775{
1776 struct gsm_bts *bts;
1777 struct gsm_network *network = gsmnet_from_vty(vty);
1778
1779 llist_for_each_entry(bts, &network->bts_list, list) {
1780 struct gsm_bts_trx *trx;
1781
1782 if (bts == not_this_bts)
1783 continue;
1784
1785 llist_for_each_entry(trx, &bts->trx_list, list) {
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001786 struct gsm_lchan *lchan = lchan_select_by_type(bts, free_type);
1787 if (!lchan)
1788 continue;
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001789
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001790 vty_out(vty, "Found unused %s slot: %s%s",
1791 gsm_lchant_name(free_type), gsm_lchan_name(lchan), VTY_NEWLINE);
1792 lchan_dump_full_vty(vty, lchan);
1793 return bts;
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001794 }
1795 }
1796 vty_out(vty, "Cannot find any BTS (other than BTS %u) with free %s lchan%s",
1797 not_this_bts? not_this_bts->nr : 255, gsm_lchant_name(free_type), VTY_NEWLINE);
1798 return NULL;
1799}
1800
1801DEFUN(handover_any, handover_any_cmd,
1802 "handover any",
1803 MANUAL_HANDOVER_STR
1804 "Pick any actively used TCH/F or TCH/H lchan and handover to any other BTS."
1805 " This is likely to fail if not all BTS are guaranteed to be reachable by the MS.\n")
1806{
1807 struct gsm_lchan *from_lchan;
1808 struct gsm_bts *to_bts;
1809
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001810 from_lchan = find_used_voice_lchan(vty, random());
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001811 if (!from_lchan)
1812 return CMD_WARNING;
1813
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001814 to_bts = find_other_bts_with_free_slots(vty, from_lchan->ts->trx->bts, from_lchan->type);
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001815 if (!to_bts)
1816 return CMD_WARNING;
1817
1818 return trigger_ho_or_as(vty, from_lchan, to_bts);
1819}
1820
1821DEFUN(assignment_any, assignment_any_cmd,
1822 "assignment any",
1823 MANUAL_ASSIGNMENT_STR
1824 "Pick any actively used TCH/F or TCH/H lchan and re-assign within the same BTS."
1825 " This will fail if no lchans of the same type are available besides the used one.\n")
1826{
1827 struct gsm_lchan *from_lchan;
1828
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001829 from_lchan = find_used_voice_lchan(vty, random());
Neels Hofmeyrb99e0252017-12-05 02:10:15 +01001830 if (!from_lchan)
1831 return CMD_WARNING;
1832
1833 return trigger_ho_or_as(vty, from_lchan, NULL);
1834}
1835
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001836DEFUN(handover_any_to_arfcn_bsic, handover_any_to_arfcn_bsic_cmd,
1837 "handover any to " NEIGHBOR_IDENT_VTY_KEY_PARAMS,
1838 MANUAL_HANDOVER_STR
1839 "Pick any actively used TCH/F or TCH/H lchan to handover to another cell."
1840 " This is likely to fail outside of a lab setup where you are certain that"
1841 " all MS are able to see the target cell.\n"
1842 "'to'\n"
1843 NEIGHBOR_IDENT_VTY_KEY_DOC)
1844{
1845 struct handover_out_req req;
1846 struct gsm_lchan *from_lchan;
1847
Neels Hofmeyra07b6672018-07-12 05:00:55 +02001848 from_lchan = find_used_voice_lchan(vty, random());
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001849 if (!from_lchan)
1850 return CMD_WARNING;
1851
1852 req = (struct handover_out_req){
1853 .from_hodec_id = HODEC_USER,
1854 .old_lchan = from_lchan,
1855 };
1856
1857 if (!neighbor_ident_bts_parse_key_params(vty, from_lchan->ts->trx->bts,
1858 argv, &req.target_nik)) {
1859 vty_out(vty, "%% BTS %u does not know about this neighbor%s",
1860 from_lchan->ts->trx->bts->nr, VTY_NEWLINE);
1861 return CMD_WARNING;
1862 }
1863
1864 handover_request(&req);
1865 return CMD_SUCCESS;
1866}
1867
Harald Weltebe4b7302009-05-23 16:59:33 +00001868static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +00001869{
1870 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
Neels Hofmeyr6d804b12017-02-18 22:20:46 +01001871 bsc_subscr_dump_vty(vty, pag->bsub);
Harald Weltef5025b62009-03-28 16:55:11 +00001872}
1873
Harald Weltebe4b7302009-05-23 16:59:33 +00001874static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +00001875{
1876 struct gsm_paging_request *pag;
1877
Holger Hans Peter Freyther9b5192b2013-03-03 11:03:17 +01001878 if (!bts->paging.bts)
1879 return;
1880
Harald Weltef5025b62009-03-28 16:55:11 +00001881 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
1882 paging_dump_vty(vty, pag);
1883}
1884
1885DEFUN(show_paging,
1886 show_paging_cmd,
Sylvain Munaut39c31de2012-12-28 12:15:11 +01001887 "show paging [<0-255>]",
Martin Haukea82fc592018-09-30 20:51:43 +02001888 SHOW_STR "Display information about paging requests of a BTS\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01001889 BTS_NR_STR)
Harald Weltef5025b62009-03-28 16:55:11 +00001890{
Harald Weltedcccb182010-05-16 20:52:23 +02001891 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Weltef5025b62009-03-28 16:55:11 +00001892 struct gsm_bts *bts;
1893 int bts_nr;
1894
1895 if (argc >= 1) {
1896 /* use the BTS number that the user has specified */
1897 bts_nr = atoi(argv[0]);
1898 if (bts_nr >= net->num_bts) {
1899 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1900 VTY_NEWLINE);
1901 return CMD_WARNING;
1902 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001903 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001904 bts_paging_dump_vty(vty, bts);
Pau Espin Pedrolc5a84162017-11-28 15:04:26 +01001905
Harald Weltef5025b62009-03-28 16:55:11 +00001906 return CMD_SUCCESS;
1907 }
1908 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +02001909 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001910 bts_paging_dump_vty(vty, bts);
1911 }
1912
1913 return CMD_SUCCESS;
1914}
1915
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +01001916DEFUN(show_paging_group,
1917 show_paging_group_cmd,
1918 "show paging-group <0-255> IMSI",
1919 SHOW_STR "Display the paging group\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01001920 BTS_NR_STR "IMSI\n")
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +01001921{
1922 struct gsm_network *net = gsmnet_from_vty(vty);
1923 struct gsm_bts *bts;
1924 unsigned int page_group;
1925 int bts_nr = atoi(argv[0]);
1926
1927 if (bts_nr >= net->num_bts) {
1928 vty_out(vty, "%% can't find BTS %s%s", argv[0], VTY_NEWLINE);
1929 return CMD_WARNING;
1930 }
1931
1932 bts = gsm_bts_num(net, bts_nr);
1933 if (!bts) {
1934 vty_out(vty, "%% can't find BTS %s%s", argv[0], VTY_NEWLINE);
1935 return CMD_WARNING;
1936 }
1937
1938 page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
1939 str_to_imsi(argv[1]));
1940 vty_out(vty, "%%Paging group for IMSI %" PRIu64 " on BTS #%d is %u%s",
1941 str_to_imsi(argv[1]), bts->nr,
1942 page_group, VTY_NEWLINE);
1943 return CMD_SUCCESS;
1944}
1945
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001946DEFUN(cfg_net_neci,
1947 cfg_net_neci_cmd,
1948 "neci (0|1)",
Harald Welte28326062010-05-14 20:05:17 +02001949 "New Establish Cause Indication\n"
1950 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001951{
Harald Weltedcccb182010-05-16 20:52:23 +02001952 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1953
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001954 gsmnet->neci = atoi(argv[0]);
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +08001955 gsm_net_update_ctype(gsmnet);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001956 return CMD_SUCCESS;
1957}
1958
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001959DEFUN(cfg_net_pag_any_tch,
1960 cfg_net_pag_any_tch_cmd,
1961 "paging any use tch (0|1)",
Holger Hans Peter Freyther08542562011-10-03 23:42:06 +02001962 "Assign a TCH when receiving a Paging Any request\n"
1963 "Any Channel\n" "Use\n" "TCH\n"
1964 "Do not use TCH for Paging Request Any\n"
1965 "Do use TCH for Paging Request Any\n")
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001966{
Holger Hans Peter Freytherb0e88b82010-09-06 10:09:19 +08001967 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001968 gsmnet->pag_any_tch = atoi(argv[0]);
1969 gsm_net_update_ctype(gsmnet);
1970 return CMD_SUCCESS;
1971}
1972
Maxc08ee712016-05-11 12:45:13 +02001973DEFUN_DEPRECATED(cfg_net_dtx,
1974 cfg_net_dtx_cmd,
1975 "dtx-used (0|1)",
1976 ".HIDDEN\n""Obsolete\n""Obsolete\n")
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +08001977{
Maxc08ee712016-05-11 12:45:13 +02001978 vty_out(vty, "%% 'dtx-used' is now deprecated: use dtx * "
1979 "configuration options of BTS instead%s", VTY_NEWLINE);
1980 return CMD_SUCCESS;
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +08001981}
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001982
Harald Welte5258fc42009-03-28 19:07:53 +00001983/* per-BTS configuration */
1984DEFUN(cfg_bts,
1985 cfg_bts_cmd,
Harald Welte57e07242012-08-17 12:50:14 +02001986 "bts <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001987 "Select a BTS to configure\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01001988 BTS_NR_STR)
Harald Welte5258fc42009-03-28 19:07:53 +00001989{
Harald Weltedcccb182010-05-16 20:52:23 +02001990 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte5258fc42009-03-28 19:07:53 +00001991 int bts_nr = atoi(argv[0]);
1992 struct gsm_bts *bts;
1993
Harald Weltee441d9c2009-06-21 16:17:15 +02001994 if (bts_nr > gsmnet->num_bts) {
1995 vty_out(vty, "%% The next unused BTS number is %u%s",
1996 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001997 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001998 } else if (bts_nr == gsmnet->num_bts) {
1999 /* allocate a new one */
Neels Hofmeyr958f2592018-05-27 01:26:31 +02002000 bts = bsc_bts_alloc_register(gsmnet, GSM_BTS_TYPE_UNKNOWN,
Harald Weltea2bbc5e2015-11-20 10:43:31 +01002001 HARDCODED_BSIC);
Stefan Sperling6442e432018-02-06 14:44:54 +01002002 /*
2003 * Initalize bts->acc_ramp here. Else we could segfault while
2004 * processing a configuration file with ACC ramping settings.
2005 */
Stefan Sperlingea333412018-04-10 16:36:54 +02002006 acc_ramp_init(&bts->acc_ramp, bts);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02002007 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02002008 bts = gsm_bts_num(gsmnet, bts_nr);
2009
Daniel Willmannf15c2762010-01-11 13:43:07 +01002010 if (!bts) {
2011 vty_out(vty, "%% Unable to allocate BTS %u%s",
2012 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee441d9c2009-06-21 16:17:15 +02002013 return CMD_WARNING;
Daniel Willmannf15c2762010-01-11 13:43:07 +01002014 }
Harald Welte5258fc42009-03-28 19:07:53 +00002015
2016 vty->index = bts;
Harald Welte197dea92010-05-14 17:59:53 +02002017 vty->index_sub = &bts->description;
Harald Welte5258fc42009-03-28 19:07:53 +00002018 vty->node = BTS_NODE;
2019
2020 return CMD_SUCCESS;
2021}
2022
2023DEFUN(cfg_bts_type,
2024 cfg_bts_type_cmd,
Harald Weltee555c2b2012-08-17 13:02:12 +02002025 "type TYPE", /* dynamically created */
Holger Hans Peter Freyther08542562011-10-03 23:42:06 +02002026 "Set the BTS type\n" "Type\n")
Harald Welte5258fc42009-03-28 19:07:53 +00002027{
2028 struct gsm_bts *bts = vty->index;
Harald Welte39315c42010-01-10 18:01:52 +01002029 int rc;
Harald Welte5258fc42009-03-28 19:07:53 +00002030
Max7507aef2017-04-10 13:59:14 +02002031 rc = gsm_set_bts_type(bts, str2btstype(argv[0]));
Harald Welte39315c42010-01-10 18:01:52 +01002032 if (rc < 0)
2033 return CMD_WARNING;
Harald Welte8175e952009-10-20 00:22:00 +02002034
Harald Welte5258fc42009-03-28 19:07:53 +00002035 return CMD_SUCCESS;
2036}
2037
Harald Weltefcd24452009-06-20 18:15:19 +02002038DEFUN(cfg_bts_band,
2039 cfg_bts_band_cmd,
2040 "band BAND",
Holger Hans Peter Freyther08542562011-10-03 23:42:06 +02002041 "Set the frequency band of this BTS\n" "Frequency band\n")
Harald Weltefcd24452009-06-20 18:15:19 +02002042{
2043 struct gsm_bts *bts = vty->index;
Harald Welte42581822009-08-08 16:12:58 +02002044 int band = gsm_band_parse(argv[0]);
Harald Weltefcd24452009-06-20 18:15:19 +02002045
2046 if (band < 0) {
2047 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
2048 band, VTY_NEWLINE);
2049 return CMD_WARNING;
2050 }
2051
2052 bts->band = band;
2053
2054 return CMD_SUCCESS;
2055}
2056
Maxc08ee712016-05-11 12:45:13 +02002057DEFUN(cfg_bts_dtxu, cfg_bts_dtxu_cmd, "dtx uplink [force]",
2058 "Configure discontinuous transmission\n"
2059 "Enable Uplink DTX for this BTS\n"
2060 "MS 'shall' use DTXu instead of 'may' use (might not be supported by "
2061 "older phones).\n")
2062{
2063 struct gsm_bts *bts = vty->index;
2064
2065 bts->dtxu = (argc > 0) ? GSM48_DTX_SHALL_BE_USED : GSM48_DTX_MAY_BE_USED;
Max60795282016-06-06 11:30:57 +02002066 if (!is_ipaccess_bts(bts))
2067 vty_out(vty, "%% DTX enabled on non-IP BTS: this configuration "
2068 "neither supported nor tested!%s", VTY_NEWLINE);
Maxc08ee712016-05-11 12:45:13 +02002069 return CMD_SUCCESS;
2070}
2071
2072DEFUN(cfg_bts_no_dtxu, cfg_bts_no_dtxu_cmd, "no dtx uplink",
2073 NO_STR
2074 "Configure discontinuous transmission\n"
2075 "Disable Uplink DTX for this BTS\n")
2076{
2077 struct gsm_bts *bts = vty->index;
2078
2079 bts->dtxu = GSM48_DTX_SHALL_NOT_BE_USED;
2080
2081 return CMD_SUCCESS;
2082}
2083
2084DEFUN(cfg_bts_dtxd, cfg_bts_dtxd_cmd, "dtx downlink",
2085 "Configure discontinuous transmission\n"
2086 "Enable Downlink DTX for this BTS\n")
2087{
2088 struct gsm_bts *bts = vty->index;
2089
2090 bts->dtxd = true;
Max60795282016-06-06 11:30:57 +02002091 if (!is_ipaccess_bts(bts))
2092 vty_out(vty, "%% DTX enabled on non-IP BTS: this configuration "
2093 "neither supported nor tested!%s", VTY_NEWLINE);
Maxc08ee712016-05-11 12:45:13 +02002094 return CMD_SUCCESS;
2095}
2096
2097DEFUN(cfg_bts_no_dtxd, cfg_bts_no_dtxd_cmd, "no dtx downlink",
2098 NO_STR
2099 "Configure discontinuous transmission\n"
2100 "Disable Downlink DTX for this BTS\n")
2101{
2102 struct gsm_bts *bts = vty->index;
2103
2104 bts->dtxd = false;
2105
2106 return CMD_SUCCESS;
2107}
2108
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02002109DEFUN(cfg_bts_ci,
2110 cfg_bts_ci_cmd,
2111 "cell_identity <0-65535>",
Holger Hans Peter Freyther64c17fa2012-07-21 00:27:10 +02002112 "Set the Cell identity of this BTS\n" "Cell Identity\n")
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02002113{
2114 struct gsm_bts *bts = vty->index;
2115 int ci = atoi(argv[0]);
2116
2117 if (ci < 0 || ci > 0xffff) {
2118 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
2119 ci, VTY_NEWLINE);
2120 return CMD_WARNING;
2121 }
2122 bts->cell_identity = ci;
2123
2124 return CMD_SUCCESS;
2125}
2126
Harald Welte5258fc42009-03-28 19:07:53 +00002127DEFUN(cfg_bts_lac,
2128 cfg_bts_lac_cmd,
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02002129 "location_area_code <0-65535>",
Holger Hans Peter Freyther64c17fa2012-07-21 00:27:10 +02002130 "Set the Location Area Code (LAC) of this BTS\n" "LAC\n")
Harald Welte5258fc42009-03-28 19:07:53 +00002131{
2132 struct gsm_bts *bts = vty->index;
2133 int lac = atoi(argv[0]);
2134
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02002135 if (lac < 0 || lac > 0xffff) {
2136 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte5258fc42009-03-28 19:07:53 +00002137 lac, VTY_NEWLINE);
2138 return CMD_WARNING;
2139 }
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +02002140
2141 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
2142 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
2143 lac, VTY_NEWLINE);
2144 return CMD_WARNING;
2145 }
2146
Harald Welte5258fc42009-03-28 19:07:53 +00002147 bts->location_area_code = lac;
2148
2149 return CMD_SUCCESS;
2150}
2151
Harald Weltea43f7892009-12-01 18:04:30 +05302152
Harald Weltea2bbc5e2015-11-20 10:43:31 +01002153/* compatibility wrapper for old config files */
2154DEFUN_HIDDEN(cfg_bts_tsc,
Harald Welte5258fc42009-03-28 19:07:53 +00002155 cfg_bts_tsc_cmd,
Harald Weltec513ded2012-05-31 10:57:08 +02002156 "training_sequence_code <0-7>",
Holger Hans Peter Freyther64c17fa2012-07-21 00:27:10 +02002157 "Set the Training Sequence Code (TSC) of this BTS\n" "TSC\n")
Harald Welte5258fc42009-03-28 19:07:53 +00002158{
Harald Welte5258fc42009-03-28 19:07:53 +00002159 return CMD_SUCCESS;
2160}
2161
Harald Welte78f2f502009-05-23 16:56:52 +00002162DEFUN(cfg_bts_bsic,
2163 cfg_bts_bsic_cmd,
2164 "base_station_id_code <0-63>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002165 "Set the Base Station Identity Code (BSIC) of this BTS\n"
2166 "BSIC of this BTS\n")
Harald Welte78f2f502009-05-23 16:56:52 +00002167{
2168 struct gsm_bts *bts = vty->index;
2169 int bsic = atoi(argv[0]);
2170
2171 if (bsic < 0 || bsic > 0x3f) {
Harald Welte42581822009-08-08 16:12:58 +02002172 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte78f2f502009-05-23 16:56:52 +00002173 bsic, VTY_NEWLINE);
2174 return CMD_WARNING;
2175 }
2176 bts->bsic = bsic;
2177
2178 return CMD_SUCCESS;
2179}
2180
Harald Welte4cc34222009-05-01 15:12:31 +00002181DEFUN(cfg_bts_unit_id,
2182 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +02002183 "ip.access unit_id <0-65534> <0-255>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002184 "Abis/IP specific options\n"
2185 "Set the IPA BTS Unit ID\n"
2186 "Unit ID (Site)\n"
2187 "Unit ID (BTS)\n")
Harald Welte4cc34222009-05-01 15:12:31 +00002188{
2189 struct gsm_bts *bts = vty->index;
2190 int site_id = atoi(argv[0]);
2191 int bts_id = atoi(argv[1]);
2192
Harald Welte07dc73d2009-08-07 13:27:09 +02002193 if (!is_ipaccess_bts(bts)) {
2194 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
2195 return CMD_WARNING;
2196 }
2197
Harald Welte4cc34222009-05-01 15:12:31 +00002198 bts->ip_access.site_id = site_id;
2199 bts->ip_access.bts_id = bts_id;
2200
2201 return CMD_SUCCESS;
2202}
2203
Harald Welte8b291802013-03-12 13:57:05 +01002204DEFUN(cfg_bts_rsl_ip,
2205 cfg_bts_rsl_ip_cmd,
2206 "ip.access rsl-ip A.B.C.D",
2207 "Abis/IP specific options\n"
2208 "Set the IPA RSL IP Address of the BSC\n"
2209 "Destination IP address for RSL connection\n")
2210{
2211 struct gsm_bts *bts = vty->index;
2212 struct in_addr ia;
2213
2214 if (!is_ipaccess_bts(bts)) {
2215 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
2216 return CMD_WARNING;
2217 }
2218
2219 inet_aton(argv[0], &ia);
2220 bts->ip_access.rsl_ip = ntohl(ia.s_addr);
2221
2222 return CMD_SUCCESS;
2223}
2224
Andreas Eversberg7d8fa342013-12-05 13:25:06 +01002225#define NOKIA_STR "Nokia *Site related commands\n"
Harald Welte8b291802013-03-12 13:57:05 +01002226
Sylvain Munautc9519462011-10-17 14:04:55 +02002227DEFUN(cfg_bts_nokia_site_skip_reset,
2228 cfg_bts_nokia_site_skip_reset_cmd,
2229 "nokia_site skip-reset (0|1)",
Andreas Eversberg7d8fa342013-12-05 13:25:06 +01002230 NOKIA_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02002231 "Skip the reset step during bootstrap process of this BTS\n"
2232 "Do NOT skip the reset\n" "Skip the reset\n")
Sylvain Munautc9519462011-10-17 14:04:55 +02002233{
2234 struct gsm_bts *bts = vty->index;
2235
2236 if (bts->type != GSM_BTS_TYPE_NOKIA_SITE) {
2237 vty_out(vty, "%% BTS is not of Nokia *Site type%s", VTY_NEWLINE);
2238 return CMD_WARNING;
2239 }
2240
2241 bts->nokia.skip_reset = atoi(argv[0]);
2242
2243 return CMD_SUCCESS;
2244}
2245
Andreas Eversberg7d8fa342013-12-05 13:25:06 +01002246DEFUN(cfg_bts_nokia_site_no_loc_rel_cnf,
2247 cfg_bts_nokia_site_no_loc_rel_cnf_cmd,
2248 "nokia_site no-local-rel-conf (0|1)",
2249 NOKIA_STR
2250 "Do not wait for RELease CONFirm message when releasing channel locally\n"
2251 "Wait for RELease CONFirm\n" "Do not wait for RELease CONFirm\n")
2252{
2253 struct gsm_bts *bts = vty->index;
2254
2255 if (!is_nokia_bts(bts)) {
2256 vty_out(vty, "%% BTS is not of Nokia *Site type%s",
2257 VTY_NEWLINE);
2258 return CMD_WARNING;
2259 }
2260
2261 bts->nokia.no_loc_rel_cnf = atoi(argv[0]);
2262
2263 return CMD_SUCCESS;
2264}
2265
Sipos Csaba56e17662015-02-07 13:27:36 +01002266DEFUN(cfg_bts_nokia_site_bts_reset_timer_cnf,
2267 cfg_bts_nokia_site_bts_reset_timer_cnf_cmd,
2268 "nokia_site bts-reset-timer <15-100>",
2269 NOKIA_STR
2270 "The amount of time (in sec.) between BTS_RESET is sent,\n"
2271 "and the BTS is being bootstrapped.\n")
2272{
2273 struct gsm_bts *bts = vty->index;
2274
2275 if (!is_nokia_bts(bts)) {
2276 vty_out(vty, "%% BTS is not of Nokia *Site type%s",
2277 VTY_NEWLINE);
2278 return CMD_WARNING;
2279 }
2280
2281 bts->nokia.bts_reset_timer_cnf = atoi(argv[0]);
2282
2283 return CMD_SUCCESS;
2284}
Harald Welte8f0ed552010-05-11 21:53:49 +02002285#define OML_STR "Organization & Maintenance Link\n"
Harald Weltecfaabbb2012-08-16 23:23:50 +02002286#define IPA_STR "A-bis/IP Specific Options\n"
Harald Welte8f0ed552010-05-11 21:53:49 +02002287
Harald Welte8175e952009-10-20 00:22:00 +02002288DEFUN(cfg_bts_stream_id,
2289 cfg_bts_stream_id_cmd,
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +02002290 "oml ip.access stream_id <0-255> line E1_LINE",
Harald Welte8f0ed552010-05-11 21:53:49 +02002291 OML_STR IPA_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02002292 "Set the ip.access Stream ID of the OML link of this BTS\n"
2293 "Stream Identifier\n" "Virtual E1 Line Number\n" "Virtual E1 Line Number\n")
Harald Welte8175e952009-10-20 00:22:00 +02002294{
2295 struct gsm_bts *bts = vty->index;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +02002296 int stream_id = atoi(argv[0]), linenr = atoi(argv[1]);
Harald Welte8175e952009-10-20 00:22:00 +02002297
2298 if (!is_ipaccess_bts(bts)) {
2299 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
2300 return CMD_WARNING;
2301 }
2302
2303 bts->oml_tei = stream_id;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +02002304 /* This is used by e1inp_bind_ops callback for each BTS model. */
2305 bts->oml_e1_link.e1_nr = linenr;
2306
2307 return CMD_SUCCESS;
2308}
2309
Harald Welted13e0cd2012-08-17 09:52:03 +02002310#define OML_E1_STR OML_STR "OML E1/T1 Configuration\n"
Harald Welte8175e952009-10-20 00:22:00 +02002311
Harald Welte42581822009-08-08 16:12:58 +02002312DEFUN(cfg_bts_oml_e1,
2313 cfg_bts_oml_e1_cmd,
2314 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welted13e0cd2012-08-17 09:52:03 +02002315 OML_E1_STR
2316 "E1/T1 line number to be used for OML\n"
Harald Weltecfaabbb2012-08-16 23:23:50 +02002317 "E1/T1 line number to be used for OML\n"
2318 "E1/T1 timeslot to be used for OML\n"
2319 "E1/T1 timeslot to be used for OML\n"
2320 "E1/T1 sub-slot to be used for OML\n"
2321 "Use E1/T1 sub-slot 0\n"
2322 "Use E1/T1 sub-slot 1\n"
2323 "Use E1/T1 sub-slot 2\n"
2324 "Use E1/T1 sub-slot 3\n"
2325 "Use full E1 slot 3\n"
2326 )
Harald Welte42581822009-08-08 16:12:58 +02002327{
2328 struct gsm_bts *bts = vty->index;
2329
2330 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
2331
2332 return CMD_SUCCESS;
2333}
2334
2335
2336DEFUN(cfg_bts_oml_e1_tei,
2337 cfg_bts_oml_e1_tei_cmd,
2338 "oml e1 tei <0-63>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002339 OML_E1_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02002340 "Set the TEI to be used for OML\n"
2341 "TEI Number\n")
Harald Welte42581822009-08-08 16:12:58 +02002342{
2343 struct gsm_bts *bts = vty->index;
2344
2345 bts->oml_tei = atoi(argv[0]);
2346
2347 return CMD_SUCCESS;
2348}
2349
Harald Welte7a8fa412009-08-10 13:48:16 +02002350DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
2351 "channel allocator (ascending|descending)",
Harald Welte8f0ed552010-05-11 21:53:49 +02002352 "Channnel Allocator\n" "Channel Allocator\n"
2353 "Allocate Timeslots and Transceivers in ascending order\n"
2354 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte7a8fa412009-08-10 13:48:16 +02002355{
2356 struct gsm_bts *bts = vty->index;
2357
2358 if (!strcmp(argv[0], "ascending"))
2359 bts->chan_alloc_reverse = 0;
2360 else
2361 bts->chan_alloc_reverse = 1;
2362
2363 return CMD_SUCCESS;
2364}
2365
Harald Welte8f0ed552010-05-11 21:53:49 +02002366#define RACH_STR "Random Access Control Channel\n"
2367
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01002368DEFUN(cfg_bts_rach_tx_integer,
2369 cfg_bts_rach_tx_integer_cmd,
2370 "rach tx integer <0-15>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002371 RACH_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02002372 "Set the raw tx integer value in RACH Control parameters IE\n"
2373 "Set the raw tx integer value in RACH Control parameters IE\n"
2374 "Raw tx integer value in RACH Control parameters IE\n")
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01002375{
2376 struct gsm_bts *bts = vty->index;
2377 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
2378 return CMD_SUCCESS;
2379}
2380
2381DEFUN(cfg_bts_rach_max_trans,
2382 cfg_bts_rach_max_trans_cmd,
2383 "rach max transmission (1|2|4|7)",
Harald Welte8f0ed552010-05-11 21:53:49 +02002384 RACH_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02002385 "Set the maximum number of RACH burst transmissions\n"
2386 "Set the maximum number of RACH burst transmissions\n"
Harald Welted13e0cd2012-08-17 09:52:03 +02002387 "Maximum number of 1 RACH burst transmissions\n"
2388 "Maximum number of 2 RACH burst transmissions\n"
2389 "Maximum number of 4 RACH burst transmissions\n"
2390 "Maximum number of 7 RACH burst transmissions\n")
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01002391{
2392 struct gsm_bts *bts = vty->index;
2393 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
2394 return CMD_SUCCESS;
2395}
2396
Andreas Eversberg2ee7ecd2012-10-13 07:27:47 +02002397#define CD_STR "Channel Description\n"
2398
2399DEFUN(cfg_bts_chan_desc_att,
2400 cfg_bts_chan_desc_att_cmd,
2401 "channel-descrption attach (0|1)",
2402 CD_STR
2403 "Set if attachment is required\n"
2404 "Attachment is NOT required\n"
2405 "Attachment is required (standard)\n")
2406{
2407 struct gsm_bts *bts = vty->index;
2408 bts->si_common.chan_desc.att = atoi(argv[0]);
2409 return CMD_SUCCESS;
2410}
2411
2412DEFUN(cfg_bts_chan_desc_bs_pa_mfrms,
2413 cfg_bts_chan_desc_bs_pa_mfrms_cmd,
2414 "channel-descrption bs-pa-mfrms <2-9>",
2415 CD_STR
2416 "Set number of multiframe periods for paging groups\n"
2417 "Number of multiframe periods for paging groups\n")
2418{
2419 struct gsm_bts *bts = vty->index;
2420 int bs_pa_mfrms = atoi(argv[0]);
2421
2422 bts->si_common.chan_desc.bs_pa_mfrms = bs_pa_mfrms - 2;
2423 return CMD_SUCCESS;
2424}
2425
2426DEFUN(cfg_bts_chan_desc_bs_ag_blks_res,
2427 cfg_bts_chan_desc_bs_ag_blks_res_cmd,
2428 "channel-descrption bs-ag-blks-res <0-7>",
2429 CD_STR
2430 "Set number of blocks reserved for access grant\n"
2431 "Number of blocks reserved for access grant\n")
2432{
2433 struct gsm_bts *bts = vty->index;
2434 int bs_ag_blks_res = atoi(argv[0]);
2435
2436 bts->si_common.chan_desc.bs_ag_blks_res = bs_ag_blks_res;
2437 return CMD_SUCCESS;
2438}
2439
Harald Welte15400252019-05-24 11:56:23 +02002440#define CCCH_STR "Common Control Channel\n"
2441
2442DEFUN(cfg_bts_ccch_load_ind_thresh,
2443 cfg_bts_ccch_load_ind_thresh_cmd,
2444 "ccch load-indication-threshold <0-100>",
2445 CCCH_STR
2446 "Percentage of CCCH load at which BTS sends RSL CCCH LOAD IND\n"
2447 "CCCH Load Threshold in percent (Default: 10)")
2448{
2449 struct gsm_bts *bts = vty->index;
2450 bts->ccch_load_ind_thresh = atoi(argv[0]);
2451 return CMD_SUCCESS;
2452}
2453
Harald Welte8f0ed552010-05-11 21:53:49 +02002454#define NM_STR "Network Management\n"
2455
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08002456DEFUN(cfg_bts_rach_nm_b_thresh,
2457 cfg_bts_rach_nm_b_thresh_cmd,
2458 "rach nm busy threshold <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002459 RACH_STR NM_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02002460 "Set the NM Busy Threshold\n"
2461 "Set the NM Busy Threshold\n"
2462 "NM Busy Threshold in dB")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08002463{
2464 struct gsm_bts *bts = vty->index;
2465 bts->rach_b_thresh = atoi(argv[0]);
2466 return CMD_SUCCESS;
2467}
2468
2469DEFUN(cfg_bts_rach_nm_ldavg,
2470 cfg_bts_rach_nm_ldavg_cmd,
2471 "rach nm load average <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002472 RACH_STR NM_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02002473 "Set the NM Loadaverage Slots value\n"
2474 "Set the NM Loadaverage Slots value\n"
2475 "NM Loadaverage Slots value\n")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08002476{
2477 struct gsm_bts *bts = vty->index;
2478 bts->rach_ldavg_slots = atoi(argv[0]);
2479 return CMD_SUCCESS;
2480}
2481
Harald Welte (local)5dececf2009-08-12 13:28:23 +02002482DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
2483 "cell barred (0|1)",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002484 "Should this cell be barred from access?\n"
2485 "Should this cell be barred from access?\n"
2486 "Cell should NOT be barred\n"
2487 "Cell should be barred\n")
2488
Harald Welte (local)5dececf2009-08-12 13:28:23 +02002489{
2490 struct gsm_bts *bts = vty->index;
2491
Harald Welte71355012009-12-21 23:08:18 +01002492 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02002493
2494 return CMD_SUCCESS;
2495}
2496
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08002497DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
2498 "rach emergency call allowed (0|1)",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002499 RACH_STR
2500 "Should this cell allow emergency calls?\n"
2501 "Should this cell allow emergency calls?\n"
2502 "Should this cell allow emergency calls?\n"
2503 "Do NOT allow emergency calls\n"
2504 "Allow emergency calls\n")
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08002505{
2506 struct gsm_bts *bts = vty->index;
2507
2508 if (atoi(argv[0]) == 0)
2509 bts->si_common.rach_control.t2 |= 0x4;
2510 else
2511 bts->si_common.rach_control.t2 &= ~0x4;
2512
2513 return CMD_SUCCESS;
2514}
2515
Ivan Kluchnikov67920592013-09-16 13:13:04 +04002516DEFUN(cfg_bts_rach_ac_class, cfg_bts_rach_ac_class_cmd,
2517 "rach access-control-class (0|1|2|3|4|5|6|7|8|9|11|12|13|14|15) (barred|allowed)",
2518 RACH_STR
2519 "Set access control class\n"
2520 "Access control class 0\n"
2521 "Access control class 1\n"
2522 "Access control class 2\n"
2523 "Access control class 3\n"
2524 "Access control class 4\n"
2525 "Access control class 5\n"
2526 "Access control class 6\n"
2527 "Access control class 7\n"
2528 "Access control class 8\n"
2529 "Access control class 9\n"
2530 "Access control class 11 for PLMN use\n"
2531 "Access control class 12 for security services\n"
2532 "Access control class 13 for public utilities (e.g. water/gas suppliers)\n"
2533 "Access control class 14 for emergency services\n"
2534 "Access control class 15 for PLMN staff\n"
2535 "barred to use access control class\n"
2536 "allowed to use access control class\n")
2537{
2538 struct gsm_bts *bts = vty->index;
2539
2540 uint8_t control_class;
2541 uint8_t allowed = 0;
2542
2543 if (strcmp(argv[1], "allowed") == 0)
2544 allowed = 1;
2545
2546 control_class = atoi(argv[0]);
2547 if (control_class < 8)
2548 if (allowed)
2549 bts->si_common.rach_control.t3 &= ~(0x1 << control_class);
2550 else
2551 bts->si_common.rach_control.t3 |= (0x1 << control_class);
2552 else
2553 if (allowed)
2554 bts->si_common.rach_control.t2 &= ~(0x1 << (control_class - 8));
2555 else
2556 bts->si_common.rach_control.t2 |= (0x1 << (control_class - 8));
2557
2558 return CMD_SUCCESS;
2559}
2560
Harald Welte (local)0e451d02009-08-13 10:14:26 +02002561DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
2562 "ms max power <0-40>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002563 "MS Options\n"
Harald Welted13e0cd2012-08-17 09:52:03 +02002564 "Maximum transmit power of the MS\n"
2565 "Maximum transmit power of the MS\n"
Harald Weltecfaabbb2012-08-16 23:23:50 +02002566 "Maximum transmit power of the MS in dBm")
Harald Welte (local)0e451d02009-08-13 10:14:26 +02002567{
2568 struct gsm_bts *bts = vty->index;
2569
2570 bts->ms_max_power = atoi(argv[0]);
2571
2572 return CMD_SUCCESS;
2573}
2574
Harald Weltecfaabbb2012-08-16 23:23:50 +02002575#define CELL_STR "Cell Parameters\n"
2576
Harald Welte73225282009-12-12 18:17:25 +01002577DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
2578 "cell reselection hysteresis <0-14>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002579 CELL_STR "Cell re-selection parameters\n"
2580 "Cell Re-Selection Hysteresis in dB\n"
Harald Welte73225282009-12-12 18:17:25 +01002581 "Cell Re-Selection Hysteresis in dB")
2582{
2583 struct gsm_bts *bts = vty->index;
2584
2585 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
2586
2587 return CMD_SUCCESS;
2588}
2589
2590DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
2591 "rxlev access min <0-63>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002592 "Minimum RxLev needed for cell access\n"
2593 "Minimum RxLev needed for cell access\n"
2594 "Minimum RxLev needed for cell access\n"
Harald Welte73225282009-12-12 18:17:25 +01002595 "Minimum RxLev needed for cell access (better than -110dBm)")
2596{
2597 struct gsm_bts *bts = vty->index;
2598
2599 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
2600
2601 return CMD_SUCCESS;
2602}
2603
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002604DEFUN(cfg_bts_cell_bar_qualify, cfg_bts_cell_bar_qualify_cmd,
2605 "cell bar qualify (0|1)",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002606 CELL_STR "Cell Bar Qualify\n" "Cell Bar Qualify\n"
2607 "Set CBQ to 0\n" "Set CBQ to 1\n")
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002608{
2609 struct gsm_bts *bts = vty->index;
2610
2611 bts->si_common.cell_ro_sel_par.present = 1;
2612 bts->si_common.cell_ro_sel_par.cbq = atoi(argv[0]);
2613
2614 return CMD_SUCCESS;
2615}
2616
2617DEFUN(cfg_bts_cell_resel_ofs, cfg_bts_cell_resel_ofs_cmd,
2618 "cell reselection offset <0-126>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002619 CELL_STR "Cell Re-Selection Parameters\n"
2620 "Cell Re-Selection Offset (CRO) in dB\n"
2621 "Cell Re-Selection Offset (CRO) in dB\n"
2622 )
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002623{
2624 struct gsm_bts *bts = vty->index;
2625
2626 bts->si_common.cell_ro_sel_par.present = 1;
2627 bts->si_common.cell_ro_sel_par.cell_resel_off = atoi(argv[0])/2;
2628
2629 return CMD_SUCCESS;
2630}
2631
2632DEFUN(cfg_bts_temp_ofs, cfg_bts_temp_ofs_cmd,
2633 "temporary offset <0-60>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002634 "Cell selection temporary negative offset\n"
2635 "Cell selection temporary negative offset\n"
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002636 "Cell selection temporary negative offset in dB")
2637{
2638 struct gsm_bts *bts = vty->index;
2639
2640 bts->si_common.cell_ro_sel_par.present = 1;
2641 bts->si_common.cell_ro_sel_par.temp_offs = atoi(argv[0])/10;
2642
2643 return CMD_SUCCESS;
2644}
2645
2646DEFUN(cfg_bts_temp_ofs_inf, cfg_bts_temp_ofs_inf_cmd,
2647 "temporary offset infinite",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002648 "Cell selection temporary negative offset\n"
2649 "Cell selection temporary negative offset\n"
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002650 "Sets cell selection temporary negative offset to infinity")
2651{
2652 struct gsm_bts *bts = vty->index;
2653
2654 bts->si_common.cell_ro_sel_par.present = 1;
2655 bts->si_common.cell_ro_sel_par.temp_offs = 7;
2656
2657 return CMD_SUCCESS;
2658}
2659
2660DEFUN(cfg_bts_penalty_time, cfg_bts_penalty_time_cmd,
2661 "penalty time <20-620>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002662 "Cell selection penalty time\n"
2663 "Cell selection penalty time\n"
2664 "Cell selection penalty time in seconds (by 20s increments)\n")
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002665{
2666 struct gsm_bts *bts = vty->index;
2667
2668 bts->si_common.cell_ro_sel_par.present = 1;
2669 bts->si_common.cell_ro_sel_par.penalty_time = (atoi(argv[0])-20)/20;
2670
2671 return CMD_SUCCESS;
2672}
2673
2674DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd,
2675 "penalty time reserved",
Harald Weltecfaabbb2012-08-16 23:23:50 +02002676 "Cell selection penalty time\n"
2677 "Cell selection penalty time\n"
2678 "Set cell selection penalty time to reserved value 31, "
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002679 "(indicate that CELL_RESELECT_OFFSET is subtracted from C2 "
2680 "and TEMPORARY_OFFSET is ignored)")
2681{
2682 struct gsm_bts *bts = vty->index;
2683
2684 bts->si_common.cell_ro_sel_par.present = 1;
2685 bts->si_common.cell_ro_sel_par.penalty_time = 31;
2686
2687 return CMD_SUCCESS;
2688}
2689
Andreas Eversberg4d4944a2013-03-10 11:49:35 +01002690DEFUN(cfg_bts_radio_link_timeout, cfg_bts_radio_link_timeout_cmd,
2691 "radio-link-timeout <4-64>",
2692 "Radio link timeout criterion (BTS side)\n"
2693 "Radio link timeout value (lost SACCH block)\n")
2694{
2695 struct gsm_bts *bts = vty->index;
2696
Harald Welte2f8b9d22017-06-18 11:12:13 +03002697 gsm_bts_set_radio_link_timeout(bts, atoi(argv[0]));
2698
2699 return CMD_SUCCESS;
2700}
2701
2702DEFUN(cfg_bts_radio_link_timeout_inf, cfg_bts_radio_link_timeout_inf_cmd,
2703 "radio-link-timeout infinite",
2704 "Radio link timeout criterion (BTS side)\n"
2705 "Infinite Radio link timeout value (use only for BTS RF testing)\n")
2706{
2707 struct gsm_bts *bts = vty->index;
2708
2709 if (bts->type != GSM_BTS_TYPE_OSMOBTS) {
2710 vty_out(vty, "%% infinite radio link timeout not supported by this BTS%s", VTY_NEWLINE);
2711 return CMD_WARNING;
2712 }
2713
2714 vty_out(vty, "%% INFINITE RADIO LINK TIMEOUT, USE ONLY FOR BTS RF TESTING%s", VTY_NEWLINE);
2715 gsm_bts_set_radio_link_timeout(bts, -1);
Andreas Eversberg4d4944a2013-03-10 11:49:35 +01002716
Holger Hans Peter Freytherc63f6f12013-07-27 21:07:57 +02002717 return CMD_SUCCESS;
2718}
2719
Harald Welte8f0ed552010-05-11 21:53:49 +02002720#define GPRS_TEXT "GPRS Packet Network\n"
2721
Harald Welteaf387632010-03-14 23:30:30 +08002722DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welte57ba7e32010-04-18 14:00:26 +02002723 "gprs cell bvci <2-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002724 GPRS_TEXT
2725 "GPRS Cell Settings\n"
Harald Weltecfaabbb2012-08-16 23:23:50 +02002726 "GPRS BSSGP VC Identifier\n"
Harald Welte97a282b2010-03-14 15:37:43 +08002727 "GPRS BSSGP VC Identifier")
2728{
Pau Espin Pedrol8c209c92017-11-28 15:05:08 +01002729 /* ETSI TS 101 343: values 0 and 1 are reserved for signalling and PTM */
Harald Welte97a282b2010-03-14 15:37:43 +08002730 struct gsm_bts *bts = vty->index;
2731
Harald Welte4511d892010-04-18 15:51:20 +02002732 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002733 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte94036702010-03-14 23:56:56 +08002734 return CMD_WARNING;
2735 }
2736
Harald Welte97a282b2010-03-14 15:37:43 +08002737 bts->gprs.cell.bvci = atoi(argv[0]);
2738
2739 return CMD_SUCCESS;
2740}
2741
Harald Weltea5731cf2010-03-22 11:48:36 +08002742DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
2743 "gprs nsei <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002744 GPRS_TEXT
Harald Weltecfaabbb2012-08-16 23:23:50 +02002745 "GPRS NS Entity Identifier\n"
Harald Weltea5731cf2010-03-22 11:48:36 +08002746 "GPRS NS Entity Identifier")
2747{
2748 struct gsm_bts *bts = vty->index;
2749
Harald Welte4511d892010-04-18 15:51:20 +02002750 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002751 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Weltea5731cf2010-03-22 11:48:36 +08002752 return CMD_WARNING;
2753 }
2754
2755 bts->gprs.nse.nsei = atoi(argv[0]);
2756
2757 return CMD_SUCCESS;
2758}
2759
Harald Welte8f0ed552010-05-11 21:53:49 +02002760#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
2761 "NSVC Logical Number\n"
Harald Weltea5731cf2010-03-22 11:48:36 +08002762
Harald Welte97a282b2010-03-14 15:37:43 +08002763DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
2764 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002765 GPRS_TEXT NSVC_TEXT
2766 "NS Virtual Connection Identifier\n"
Harald Welte97a282b2010-03-14 15:37:43 +08002767 "GPRS NS VC Identifier")
2768{
2769 struct gsm_bts *bts = vty->index;
2770 int idx = atoi(argv[0]);
2771
Harald Welte4511d892010-04-18 15:51:20 +02002772 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002773 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte94036702010-03-14 23:56:56 +08002774 return CMD_WARNING;
2775 }
2776
Harald Welte97a282b2010-03-14 15:37:43 +08002777 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
2778
2779 return CMD_SUCCESS;
2780}
2781
Harald Welteaf387632010-03-14 23:30:30 +08002782DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
2783 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002784 GPRS_TEXT NSVC_TEXT
Harald Weltecfaabbb2012-08-16 23:23:50 +02002785 "GPRS NS Local UDP Port\n"
2786 "GPRS NS Local UDP Port\n"
2787 "GPRS NS Local UDP Port\n"
Harald Welte13fe2192012-08-17 09:57:25 +02002788 "GPRS NS Local UDP Port Number\n")
Harald Welteaf387632010-03-14 23:30:30 +08002789{
2790 struct gsm_bts *bts = vty->index;
2791 int idx = atoi(argv[0]);
2792
Harald Welte4511d892010-04-18 15:51:20 +02002793 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002794 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte94036702010-03-14 23:56:56 +08002795 return CMD_WARNING;
2796 }
2797
Harald Welteaf387632010-03-14 23:30:30 +08002798 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
2799
2800 return CMD_SUCCESS;
2801}
2802
2803DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
2804 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002805 GPRS_TEXT NSVC_TEXT
Harald Weltecfaabbb2012-08-16 23:23:50 +02002806 "GPRS NS Remote UDP Port\n"
2807 "GPRS NS Remote UDP Port\n"
Harald Welte13fe2192012-08-17 09:57:25 +02002808 "GPRS NS Remote UDP Port\n"
2809 "GPRS NS Remote UDP Port Number\n")
Harald Welteaf387632010-03-14 23:30:30 +08002810{
2811 struct gsm_bts *bts = vty->index;
2812 int idx = atoi(argv[0]);
2813
Harald Welte4511d892010-04-18 15:51:20 +02002814 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002815 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte94036702010-03-14 23:56:56 +08002816 return CMD_WARNING;
2817 }
2818
Harald Welteaf387632010-03-14 23:30:30 +08002819 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
2820
2821 return CMD_SUCCESS;
2822}
2823
2824DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
2825 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte8f0ed552010-05-11 21:53:49 +02002826 GPRS_TEXT NSVC_TEXT
Harald Weltecfaabbb2012-08-16 23:23:50 +02002827 "GPRS NS Remote IP Address\n"
2828 "GPRS NS Remote IP Address\n"
2829 "GPRS NS Remote IP Address\n")
Harald Welteaf387632010-03-14 23:30:30 +08002830{
2831 struct gsm_bts *bts = vty->index;
2832 int idx = atoi(argv[0]);
2833 struct in_addr ia;
2834
Harald Welte4511d892010-04-18 15:51:20 +02002835 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002836 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte94036702010-03-14 23:56:56 +08002837 return CMD_WARNING;
2838 }
2839
Harald Welteaf387632010-03-14 23:30:30 +08002840 inet_aton(argv[1], &ia);
2841 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
2842
2843 return CMD_SUCCESS;
2844}
2845
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +08002846DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
Harald Weltecfaabbb2012-08-16 23:23:50 +02002847 "paging free <-1-1024>",
2848 "Paging options\n"
2849 "Only page when having a certain amount of free slots\n"
2850 "amount of required free paging slots. -1 to disable\n")
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +08002851{
2852 struct gsm_bts *bts = vty->index;
2853
2854 bts->paging.free_chans_need = atoi(argv[0]);
2855 return CMD_SUCCESS;
2856}
2857
Harald Welte615e9562010-05-11 23:50:21 +02002858DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
2859 "gprs ns timer " NS_TIMERS " <0-255>",
2860 GPRS_TEXT "Network Service\n"
2861 "Network Service Timer\n"
2862 NS_TIMERS_HELP "Timer Value\n")
2863{
2864 struct gsm_bts *bts = vty->index;
2865 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
2866 int val = atoi(argv[1]);
2867
2868 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002869 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte615e9562010-05-11 23:50:21 +02002870 return CMD_WARNING;
2871 }
2872
2873 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
2874 return CMD_WARNING;
2875
2876 bts->gprs.nse.timer[idx] = val;
2877
2878 return CMD_SUCCESS;
2879}
2880
2881#define BSSGP_TIMERS "(blocking-timer|blocking-retries|unblocking-retries|reset-timer|reset-retries|suspend-timer|suspend-retries|resume-timer|resume-retries|capability-update-timer|capability-update-retries)"
Harald Welte28326062010-05-14 20:05:17 +02002882#define BSSGP_TIMERS_HELP \
2883 "Tbvc-block timeout\n" \
2884 "Tbvc-block retries\n" \
2885 "Tbvc-unblock retries\n" \
2886 "Tbvcc-reset timeout\n" \
2887 "Tbvc-reset retries\n" \
2888 "Tbvc-suspend timeout\n" \
2889 "Tbvc-suspend retries\n" \
2890 "Tbvc-resume timeout\n" \
2891 "Tbvc-resume retries\n" \
2892 "Tbvc-capa-update timeout\n" \
2893 "Tbvc-capa-update retries\n"
Harald Welte615e9562010-05-11 23:50:21 +02002894
2895DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
2896 "gprs cell timer " BSSGP_TIMERS " <0-255>",
2897 GPRS_TEXT "Cell / BSSGP\n"
2898 "Cell/BSSGP Timer\n"
2899 BSSGP_TIMERS_HELP "Timer Value\n")
2900{
2901 struct gsm_bts *bts = vty->index;
2902 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
2903 int val = atoi(argv[1]);
2904
2905 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002906 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte615e9562010-05-11 23:50:21 +02002907 return CMD_WARNING;
2908 }
2909
2910 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
2911 return CMD_WARNING;
2912
2913 bts->gprs.cell.timer[idx] = val;
2914
2915 return CMD_SUCCESS;
2916}
2917
Harald Welte97a282b2010-03-14 15:37:43 +08002918DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
2919 "gprs routing area <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002920 GPRS_TEXT
Harald Weltecfaabbb2012-08-16 23:23:50 +02002921 "GPRS Routing Area Code\n"
2922 "GPRS Routing Area Code\n"
2923 "GPRS Routing Area Code\n")
Harald Welte97a282b2010-03-14 15:37:43 +08002924{
2925 struct gsm_bts *bts = vty->index;
2926
Harald Welte4511d892010-04-18 15:51:20 +02002927 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002928 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Harald Welte94036702010-03-14 23:56:56 +08002929 return CMD_WARNING;
2930 }
2931
Harald Welte97a282b2010-03-14 15:37:43 +08002932 bts->gprs.rac = atoi(argv[0]);
2933
2934 return CMD_SUCCESS;
2935}
2936
Max292ec582016-07-28 11:55:37 +02002937DEFUN(cfg_bts_gprs_ctrl_ack, cfg_bts_gprs_ctrl_ack_cmd,
2938 "gprs control-ack-type-rach", GPRS_TEXT
2939 "Set GPRS Control Ack Type for PACKET CONTROL ACKNOWLEDGMENT message to "
2940 "four access bursts format instead of default RLC/MAC control block\n")
2941{
2942 struct gsm_bts *bts = vty->index;
2943
2944 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002945 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Max292ec582016-07-28 11:55:37 +02002946 return CMD_WARNING;
2947 }
2948
2949 bts->gprs.ctrl_ack_type_use_block = false;
2950
2951 return CMD_SUCCESS;
2952}
2953
2954DEFUN(cfg_no_bts_gprs_ctrl_ack, cfg_no_bts_gprs_ctrl_ack_cmd,
2955 "no gprs control-ack-type-rach", NO_STR GPRS_TEXT
2956 "Set GPRS Control Ack Type for PACKET CONTROL ACKNOWLEDGMENT message to "
2957 "four access bursts format instead of default RLC/MAC control block\n")
2958{
2959 struct gsm_bts *bts = vty->index;
2960
2961 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002962 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Max292ec582016-07-28 11:55:37 +02002963 return CMD_WARNING;
2964 }
2965
2966 bts->gprs.ctrl_ack_type_use_block = true;
2967
2968 return CMD_SUCCESS;
2969}
2970
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +01002971DEFUN(cfg_bts_gprs_net_ctrl_ord, cfg_bts_gprs_net_ctrl_ord_cmd,
2972 "gprs network-control-order (nc0|nc1|nc2)",
2973 GPRS_TEXT
2974 "GPRS Network Control Order\n"
2975 "MS controlled cell re-selection, no measurement reporting\n"
2976 "MS controlled cell re-selection, MS sends measurement reports\n"
2977 "Network controlled cell re-selection, MS sends measurement reports\n")
2978{
2979 struct gsm_bts *bts = vty->index;
2980
2981 if (bts->gprs.mode == BTS_GPRS_NONE) {
Max413846e2019-01-14 11:08:35 +01002982 vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, VTY_NEWLINE);
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +01002983 return CMD_WARNING;
2984 }
2985
2986 bts->gprs.net_ctrl_ord = atoi(argv[0] + 2);
2987
2988 return CMD_SUCCESS;
2989}
2990
Harald Welte4511d892010-04-18 15:51:20 +02002991DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
2992 "gprs mode (none|gprs|egprs)",
Harald Welte8f0ed552010-05-11 21:53:49 +02002993 GPRS_TEXT
2994 "GPRS Mode for this BTS\n"
2995 "GPRS Disabled on this BTS\n"
2996 "GPRS Enabled on this BTS\n"
2997 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welteaf387632010-03-14 23:30:30 +08002998{
2999 struct gsm_bts *bts = vty->index;
Holger Hans Peter Freyther4e13a8f2015-01-31 22:16:00 +01003000 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0], NULL);
Harald Welteaf387632010-03-14 23:30:30 +08003001
Holger Hans Peter Freyther4e13a8f2015-01-31 22:16:00 +01003002 if (!bts_gprs_mode_is_compat(bts, mode)) {
Harald Weltef3d8e922010-06-14 22:44:42 +02003003 vty_out(vty, "This BTS type does not support %s%s", argv[0],
3004 VTY_NEWLINE);
3005 return CMD_WARNING;
3006 }
3007
3008 bts->gprs.mode = mode;
Harald Welteaf387632010-03-14 23:30:30 +08003009
3010 return CMD_SUCCESS;
3011}
3012
bhargava350533c2016-07-21 11:14:34 +05303013DEFUN(cfg_bts_gprs_11bit_rach_support_for_egprs,
3014 cfg_bts_gprs_11bit_rach_support_for_egprs_cmd,
3015 "gprs 11bit_rach_support_for_egprs (0|1)",
3016 GPRS_TEXT "11 bit RACH options\n"
3017 "Disable 11 bit RACH for EGPRS\n"
3018 "Enable 11 bit RACH for EGPRS")
3019{
3020 struct gsm_bts *bts = vty->index;
3021
3022 bts->gprs.supports_egprs_11bit_rach = atoi(argv[0]);
3023
3024 if (bts->gprs.supports_egprs_11bit_rach > 1) {
3025 vty_out(vty, "Error in RACH type%s", VTY_NEWLINE);
3026 return CMD_WARNING;
3027 }
3028
3029 if ((bts->gprs.mode == BTS_GPRS_NONE) &&
3030 (bts->gprs.supports_egprs_11bit_rach == 1)) {
3031 vty_out(vty, "Error:gprs mode is none and 11bit rach is"
3032 " enabled%s", VTY_NEWLINE);
3033 return CMD_WARNING;
3034 }
3035
3036 return CMD_SUCCESS;
3037}
3038
Harald Welte9fbff4a2010-07-30 11:50:09 +02003039#define SI_TEXT "System Information Messages\n"
3040#define SI_TYPE_TEXT "(1|2|3|4|5|6|7|8|9|10|13|16|17|18|19|20|2bis|2ter|2quater|5bis|5ter)"
3041#define SI_TYPE_HELP "System Information Type 1\n" \
3042 "System Information Type 2\n" \
3043 "System Information Type 3\n" \
3044 "System Information Type 4\n" \
3045 "System Information Type 5\n" \
3046 "System Information Type 6\n" \
3047 "System Information Type 7\n" \
3048 "System Information Type 8\n" \
3049 "System Information Type 9\n" \
3050 "System Information Type 10\n" \
3051 "System Information Type 13\n" \
3052 "System Information Type 16\n" \
3053 "System Information Type 17\n" \
3054 "System Information Type 18\n" \
3055 "System Information Type 19\n" \
3056 "System Information Type 20\n" \
3057 "System Information Type 2bis\n" \
3058 "System Information Type 2ter\n" \
3059 "System Information Type 2quater\n" \
3060 "System Information Type 5bis\n" \
3061 "System Information Type 5ter\n"
3062
3063DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
3064 "system-information " SI_TYPE_TEXT " mode (static|computed)",
3065 SI_TEXT SI_TYPE_HELP
3066 "System Information Mode\n"
3067 "Static user-specified\n"
3068 "Dynamic, BSC-computed\n")
3069{
3070 struct gsm_bts *bts = vty->index;
3071 int type;
3072
3073 type = get_string_value(osmo_sitype_strs, argv[0]);
3074 if (type < 0) {
3075 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
3076 return CMD_WARNING;
3077 }
3078
3079 if (!strcmp(argv[1], "static"))
3080 bts->si_mode_static |= (1 << type);
3081 else
3082 bts->si_mode_static &= ~(1 << type);
3083
3084 return CMD_SUCCESS;
3085}
3086
3087DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
3088 "system-information " SI_TYPE_TEXT " static HEXSTRING",
3089 SI_TEXT SI_TYPE_HELP
3090 "Static System Information filling\n"
3091 "Static user-specified SI content in HEX notation\n")
3092{
3093 struct gsm_bts *bts = vty->index;
3094 int rc, type;
3095
3096 type = get_string_value(osmo_sitype_strs, argv[0]);
3097 if (type < 0) {
3098 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
3099 return CMD_WARNING;
3100 }
3101
3102 if (!(bts->si_mode_static & (1 << type))) {
3103 vty_out(vty, "SI Type %s is not configured in static mode%s",
3104 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
3105 return CMD_WARNING;
3106 }
3107
Harald Welte290aaed2010-07-30 11:53:18 +02003108 /* Fill buffer with padding pattern */
Max6f0e50c2017-04-12 15:30:54 +02003109 memset(GSM_BTS_SI(bts, type), 0x2b, GSM_MACBLOCK_LEN);
Harald Welte290aaed2010-07-30 11:53:18 +02003110
3111 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Max6f0e50c2017-04-12 15:30:54 +02003112 rc = osmo_hexparse(argv[1], GSM_BTS_SI(bts, type), GSM_MACBLOCK_LEN);
3113 if (rc < 0 || rc > GSM_MACBLOCK_LEN) {
Harald Welte9fbff4a2010-07-30 11:50:09 +02003114 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
3115 return CMD_WARNING;
3116 }
3117
3118 /* Mark this SI as present */
3119 bts->si_valid |= (1 << type);
3120
3121 return CMD_SUCCESS;
3122}
3123
Pau Espin Pedrol1cf21de2018-12-05 13:38:10 +01003124DEFUN(cfg_bts_si_unused_send_empty, cfg_bts_si_unused_send_empty_cmd,
3125 "system-information unused-send-empty",
3126 SI_TEXT
3127 "Send BCCH Info with empty 'Full BCCH Info' TLV to notify disabled SI. "
3128 "Some nanoBTS fw versions are known to fail upon receival of these messages.\n")
3129{
3130 struct gsm_bts *bts = vty->index;
3131
3132 bts->si_unused_send_empty = true;
3133
3134 return CMD_SUCCESS;
3135}
3136
3137DEFUN(cfg_bts_no_si_unused_send_empty, cfg_bts_no_si_unused_send_empty_cmd,
3138 "no system-information unused-send-empty",
3139 NO_STR SI_TEXT
3140 "Avoid sending BCCH Info with empty 'Full BCCH Info' TLV to notify disabled SI. "
3141 "Some nanoBTS fw versions are known to fail upon receival of these messages.\n")
3142{
3143 struct gsm_bts *bts = vty->index;
3144
3145 if (!is_ipaccess_bts(bts) || is_sysmobts_v2(bts)) {
3146 vty_out(vty, "This command is only intended for ipaccess nanoBTS. See OS#3707.%s",
3147 VTY_NEWLINE);
3148 return CMD_WARNING;
3149 }
3150
3151 bts->si_unused_send_empty = false;
3152
3153 return CMD_SUCCESS;
3154}
3155
Harald Welte42def722017-01-13 00:10:32 +01003156DEFUN(cfg_bts_early_cm, cfg_bts_early_cm_cmd,
3157 "early-classmark-sending (allowed|forbidden)",
3158 "Early Classmark Sending\n"
3159 "Early Classmark Sending is allowed\n"
3160 "Early Classmark Sending is forbidden\n")
3161{
3162 struct gsm_bts *bts = vty->index;
Harald Welte42def722017-01-13 00:10:32 +01003163
3164 if (!strcmp(argv[0], "allowed"))
3165 bts->early_classmark_allowed = true;
3166 else
3167 bts->early_classmark_allowed = false;
3168
3169 return CMD_SUCCESS;
3170}
3171
Pau Espin Pedrole8dda5f2017-11-23 19:06:09 +01003172DEFUN(cfg_bts_early_cm_3g, cfg_bts_early_cm_3g_cmd,
3173 "early-classmark-sending-3g (allowed|forbidden)",
3174 "3G Early Classmark Sending\n"
3175 "3G Early Classmark Sending is allowed\n"
3176 "3G Early Classmark Sending is forbidden\n")
3177{
3178 struct gsm_bts *bts = vty->index;
3179
3180 if (!strcmp(argv[0], "allowed"))
3181 bts->early_classmark_allowed_3g = true;
3182 else
3183 bts->early_classmark_allowed_3g = false;
3184
3185 return CMD_SUCCESS;
3186}
3187
Harald Welte32c09622011-01-11 23:44:56 +01003188DEFUN(cfg_bts_neigh_mode, cfg_bts_neigh_mode_cmd,
Harald Welte64c07d22011-02-15 11:43:27 +01003189 "neighbor-list mode (automatic|manual|manual-si5)",
Harald Welte32c09622011-01-11 23:44:56 +01003190 "Neighbor List\n" "Mode of Neighbor List generation\n"
Daniel Willmann2dcdf442019-04-15 16:50:46 +02003191 "Automatically from all BTS in this BSC\n" "Manual\n"
Harald Welte64c07d22011-02-15 11:43:27 +01003192 "Manual with different lists for SI2 and SI5\n")
Harald Welte32c09622011-01-11 23:44:56 +01003193{
3194 struct gsm_bts *bts = vty->index;
Harald Welte64c07d22011-02-15 11:43:27 +01003195 int mode = get_string_value(bts_neigh_mode_strs, argv[0]);
Harald Welte32c09622011-01-11 23:44:56 +01003196
Harald Welte64c07d22011-02-15 11:43:27 +01003197 switch (mode) {
3198 case NL_MODE_MANUAL_SI5SEP:
3199 case NL_MODE_MANUAL:
Harald Welte32c09622011-01-11 23:44:56 +01003200 /* make sure we clear the current list when switching to
3201 * manual mode */
3202 if (bts->neigh_list_manual_mode == 0)
3203 memset(&bts->si_common.data.neigh_list, 0,
3204 sizeof(bts->si_common.data.neigh_list));
Harald Welte64c07d22011-02-15 11:43:27 +01003205 break;
3206 default:
3207 break;
3208 }
3209
3210 bts->neigh_list_manual_mode = mode;
Harald Welte32c09622011-01-11 23:44:56 +01003211
3212 return CMD_SUCCESS;
3213}
3214
3215DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd,
Harald Welte1fe73a12012-01-29 13:24:12 +01003216 "neighbor-list (add|del) arfcn <0-1023>",
Harald Welte32c09622011-01-11 23:44:56 +01003217 "Neighbor List\n" "Add to manual neighbor list\n"
3218 "Delete from manual neighbor list\n" "ARFCN of neighbor\n"
3219 "ARFCN of neighbor\n")
3220{
3221 struct gsm_bts *bts = vty->index;
3222 struct bitvec *bv = &bts->si_common.neigh_list;
3223 uint16_t arfcn = atoi(argv[1]);
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01003224 enum gsm_band unused;
Harald Welte32c09622011-01-11 23:44:56 +01003225
Pau Espin Pedrolf1e31ca2018-11-15 12:56:36 +01003226 if (bts->neigh_list_manual_mode == NL_MODE_AUTOMATIC) {
Harald Welte32c09622011-01-11 23:44:56 +01003227 vty_out(vty, "%% Cannot configure neighbor list in "
3228 "automatic mode%s", VTY_NEWLINE);
3229 return CMD_WARNING;
3230 }
3231
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01003232 if (gsm_arfcn2band_rc(arfcn, &unused) < 0) {
3233 vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE);
3234 return CMD_WARNING;
3235 }
3236
Harald Welte32c09622011-01-11 23:44:56 +01003237 if (!strcmp(argv[0], "add"))
3238 bitvec_set_bit_pos(bv, arfcn, 1);
3239 else
3240 bitvec_set_bit_pos(bv, arfcn, 0);
3241
3242 return CMD_SUCCESS;
3243}
3244
Max70fdd242017-06-15 15:10:53 +02003245/* help text should be kept in sync with EARFCN_*_INVALID defines */
Max59a1bf32016-04-15 16:04:46 +02003246DEFUN(cfg_bts_si2quater_neigh_add, cfg_bts_si2quater_neigh_add_cmd,
Max2c16bee2017-02-15 13:51:37 +01003247 "si2quater neighbor-list add earfcn <0-65535> thresh-hi <0-31> "
3248 "thresh-lo <0-32> prio <0-8> qrxlv <0-32> meas <0-8>",
3249 "SI2quater Neighbor List\n" "SI2quater Neighbor List\n"
3250 "Add to manual SI2quater neighbor list\n"
3251 "EARFCN of neighbor\n" "EARFCN of neighbor\n"
3252 "threshold high bits\n" "threshold high bits\n"
3253 "threshold low bits\n" "threshold low bits (32 means NA)\n"
3254 "priority\n" "priority (8 means NA)\n"
3255 "QRXLEVMIN\n" "QRXLEVMIN (32 means NA)\n"
3256 "measurement bandwidth\n" "measurement bandwidth (8 means NA)\n")
Max59a1bf32016-04-15 16:04:46 +02003257{
3258 struct gsm_bts *bts = vty->index;
3259 struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;
3260 uint16_t arfcn = atoi(argv[0]);
Max2c16bee2017-02-15 13:51:37 +01003261 uint8_t thresh_hi = atoi(argv[1]), thresh_lo = atoi(argv[2]),
3262 prio = atoi(argv[3]), qrx = atoi(argv[4]), meas = atoi(argv[5]);
Max70fdd242017-06-15 15:10:53 +02003263 int r = bts_earfcn_add(bts, arfcn, thresh_hi, thresh_lo, prio, qrx, meas);
Max59a1bf32016-04-15 16:04:46 +02003264
Max70fdd242017-06-15 15:10:53 +02003265 switch (r) {
3266 case 1:
3267 vty_out(vty, "Warning: multiple threshold-high are not supported, overriding with %u%s",
3268 thresh_hi, VTY_NEWLINE);
3269 break;
3270 case EARFCN_THRESH_LOW_INVALID:
3271 vty_out(vty, "Warning: multiple threshold-low are not supported, overriding with %u%s",
3272 thresh_lo, VTY_NEWLINE);
3273 break;
3274 case EARFCN_QRXLV_INVALID + 1:
3275 vty_out(vty, "Warning: multiple QRXLEVMIN are not supported, overriding with %u%s",
3276 qrx, VTY_NEWLINE);
3277 break;
3278 case EARFCN_PRIO_INVALID:
3279 vty_out(vty, "Warning: multiple priorities are not supported, overriding with %u%s",
3280 prio, VTY_NEWLINE);
3281 break;
3282 default:
3283 if (r < 0) {
3284 vty_out(vty, "Unable to add ARFCN %u: %s%s", arfcn, strerror(-r), VTY_NEWLINE);
3285 return CMD_WARNING;
3286 }
Max59a1bf32016-04-15 16:04:46 +02003287 }
3288
Max70fdd242017-06-15 15:10:53 +02003289 if (si2q_num(bts) <= SI2Q_MAX_NUM)
Max2c16bee2017-02-15 13:51:37 +01003290 return CMD_SUCCESS;
3291
Maxf39d03a2017-05-12 17:00:30 +02003292 vty_out(vty, "Warning: not enough space in SI2quater (%u/%u used) for a given EARFCN %u%s",
Max70fdd242017-06-15 15:10:53 +02003293 bts->si2q_count, SI2Q_MAX_NUM, arfcn, VTY_NEWLINE);
Maxaafff962016-04-20 15:57:14 +02003294 osmo_earfcn_del(e, arfcn);
Max2c16bee2017-02-15 13:51:37 +01003295
Maxaafff962016-04-20 15:57:14 +02003296 return CMD_WARNING;
Max59a1bf32016-04-15 16:04:46 +02003297}
3298
3299DEFUN(cfg_bts_si2quater_neigh_del, cfg_bts_si2quater_neigh_del_cmd,
Max35697b92016-04-29 12:51:31 +02003300 "si2quater neighbor-list del earfcn <0-65535>",
Max59a1bf32016-04-15 16:04:46 +02003301 "SI2quater Neighbor List\n"
3302 "SI2quater Neighbor List\n"
3303 "Delete from SI2quater manual neighbor list\n"
Max36212f22016-04-20 12:06:05 +02003304 "EARFCN of neighbor\n"
3305 "EARFCN\n")
Max59a1bf32016-04-15 16:04:46 +02003306{
3307 struct gsm_bts *bts = vty->index;
3308 struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;
Max0c1bc262016-04-20 12:06:06 +02003309 uint16_t arfcn = atoi(argv[0]);
Max59a1bf32016-04-15 16:04:46 +02003310 int r = osmo_earfcn_del(e, arfcn);
3311 if (r < 0) {
3312 vty_out(vty, "Unable to delete arfcn %u: %s%s", arfcn,
Max0c1bc262016-04-20 12:06:06 +02003313 strerror(-r), VTY_NEWLINE);
Max59a1bf32016-04-15 16:04:46 +02003314 return CMD_WARNING;
3315 }
3316
3317 return CMD_SUCCESS;
3318}
3319
Max26679e02016-04-20 15:57:13 +02003320DEFUN(cfg_bts_si2quater_uarfcn_add, cfg_bts_si2quater_uarfcn_add_cmd,
Max35697b92016-04-29 12:51:31 +02003321 "si2quater neighbor-list add uarfcn <0-16383> <0-511> <0-1>",
Max26679e02016-04-20 15:57:13 +02003322 "SI2quater Neighbor List\n"
3323 "SI2quater Neighbor List\n" "Add to manual SI2quater neighbor list\n"
3324 "UARFCN of neighbor\n" "UARFCN of neighbor\n" "scrambling code\n"
3325 "diversity bit\n")
3326{
3327 struct gsm_bts *bts = vty->index;
3328 uint16_t arfcn = atoi(argv[0]), scramble = atoi(argv[1]);
3329
3330 switch(bts_uarfcn_add(bts, arfcn, scramble, atoi(argv[2]))) {
3331 case -ENOMEM:
Max70fdd242017-06-15 15:10:53 +02003332 vty_out(vty, "Unable to add UARFCN: max number of UARFCNs (%u) reached%s", MAX_EARFCN_LIST, VTY_NEWLINE);
Harald Weltea191dcd2016-11-26 15:06:37 +01003333 return CMD_WARNING;
Maxaafff962016-04-20 15:57:14 +02003334 case -ENOSPC:
Max70fdd242017-06-15 15:10:53 +02003335 vty_out(vty, "Warning: not enough space in SI2quater for a given UARFCN (%u, %u)%s",
3336 arfcn, scramble, VTY_NEWLINE);
Harald Weltea191dcd2016-11-26 15:06:37 +01003337 return CMD_WARNING;
Max26679e02016-04-20 15:57:13 +02003338 case -EADDRINUSE:
Max70fdd242017-06-15 15:10:53 +02003339 vty_out(vty, "Unable to add UARFCN: (%u, %u) is already added%s", arfcn, scramble, VTY_NEWLINE);
Max26679e02016-04-20 15:57:13 +02003340 return CMD_WARNING;
3341 }
3342
3343 return CMD_SUCCESS;
3344}
3345
3346DEFUN(cfg_bts_si2quater_uarfcn_del, cfg_bts_si2quater_uarfcn_del_cmd,
Max35697b92016-04-29 12:51:31 +02003347 "si2quater neighbor-list del uarfcn <0-16383> <0-511>",
Max26679e02016-04-20 15:57:13 +02003348 "SI2quater Neighbor List\n"
3349 "SI2quater Neighbor List\n"
3350 "Delete from SI2quater manual neighbor list\n"
3351 "UARFCN of neighbor\n"
3352 "UARFCN\n"
3353 "scrambling code\n")
3354{
3355 struct gsm_bts *bts = vty->index;
3356
3357 if (bts_uarfcn_del(bts, atoi(argv[0]), atoi(argv[1])) < 0) {
3358 vty_out(vty, "Unable to delete uarfcn: pair not found%s",
3359 VTY_NEWLINE);
3360 return CMD_WARNING;
3361 }
3362
3363 return CMD_SUCCESS;
3364}
3365
Harald Welte64c07d22011-02-15 11:43:27 +01003366DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd,
Harald Welte1fe73a12012-01-29 13:24:12 +01003367 "si5 neighbor-list (add|del) arfcn <0-1023>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02003368 "SI5 Neighbor List\n"
Harald Welte64c07d22011-02-15 11:43:27 +01003369 "SI5 Neighbor List\n" "Add to manual SI5 neighbor list\n"
3370 "Delete from SI5 manual neighbor list\n" "ARFCN of neighbor\n"
3371 "ARFCN of neighbor\n")
3372{
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01003373 enum gsm_band unused;
Harald Welte64c07d22011-02-15 11:43:27 +01003374 struct gsm_bts *bts = vty->index;
3375 struct bitvec *bv = &bts->si_common.si5_neigh_list;
3376 uint16_t arfcn = atoi(argv[1]);
3377
3378 if (!bts->neigh_list_manual_mode) {
3379 vty_out(vty, "%% Cannot configure neighbor list in "
3380 "automatic mode%s", VTY_NEWLINE);
3381 return CMD_WARNING;
3382 }
3383
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01003384 if (gsm_arfcn2band_rc(arfcn, &unused) < 0) {
3385 vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE);
3386 return CMD_WARNING;
3387 }
3388
Harald Welte64c07d22011-02-15 11:43:27 +01003389 if (!strcmp(argv[0], "add"))
3390 bitvec_set_bit_pos(bv, arfcn, 1);
3391 else
3392 bitvec_set_bit_pos(bv, arfcn, 0);
3393
3394 return CMD_SUCCESS;
3395}
Harald Welte9fbff4a2010-07-30 11:50:09 +02003396
Harald Welte8254cf72017-05-29 13:42:19 +02003397DEFUN(cfg_bts_pcu_sock, cfg_bts_pcu_sock_cmd,
3398 "pcu-socket PATH",
3399 "PCU Socket Path for using OsmoPCU co-located with BSC (legacy BTS)\n"
3400 "Path in the file system for the unix-domain PCU socket\n")
3401{
3402 struct gsm_bts *bts = vty->index;
3403 int rc;
3404
Harald Welte4a824ca2017-05-29 13:54:27 +02003405 osmo_talloc_replace_string(bts, &bts->pcu_sock_path, argv[0]);
Harald Welte8254cf72017-05-29 13:42:19 +02003406 pcu_sock_exit(bts);
3407 rc = pcu_sock_init(bts->pcu_sock_path, bts);
3408 if (rc < 0) {
3409 vty_out(vty, "%% Error creating PCU socket `%s' for BTS %u%s",
3410 bts->pcu_sock_path, bts->nr, VTY_NEWLINE);
3411 return CMD_WARNING;
3412 }
3413
3414 return CMD_SUCCESS;
3415}
3416
Stefan Sperling6442e432018-02-06 14:44:54 +01003417DEFUN(cfg_bts_acc_ramping,
3418 cfg_bts_acc_ramping_cmd,
3419 "access-control-class-ramping",
3420 "Enable Access Control Class ramping\n")
3421{
3422 struct gsm_bts *bts = vty->index;
3423
Stefan Sperlingea333412018-04-10 16:36:54 +02003424 if (!acc_ramp_is_enabled(&bts->acc_ramp))
3425 acc_ramp_set_enabled(&bts->acc_ramp, true);
Stefan Sperling6442e432018-02-06 14:44:54 +01003426
Stefan Sperling60ecdef2018-04-10 17:55:08 +02003427 /*
3428 * ACC ramping takes effect either when the BTS reconnects RSL,
3429 * or when RF administrative state changes to 'unlocked'.
3430 */
Stefan Sperling6442e432018-02-06 14:44:54 +01003431 return CMD_SUCCESS;
3432}
3433
3434DEFUN(cfg_bts_no_acc_ramping, cfg_bts_no_acc_ramping_cmd,
3435 "no access-control-class-ramping",
3436 NO_STR
3437 "Disable Access Control Class ramping\n")
3438{
3439 struct gsm_bts *bts = vty->index;
3440
3441 if (acc_ramp_is_enabled(&bts->acc_ramp)) {
3442 acc_ramp_abort(&bts->acc_ramp);
Stefan Sperlingea333412018-04-10 16:36:54 +02003443 acc_ramp_set_enabled(&bts->acc_ramp, false);
Stefan Sperling6442e432018-02-06 14:44:54 +01003444 gsm_bts_set_system_infos(bts);
3445 }
3446
3447 return CMD_SUCCESS;
3448}
3449
3450DEFUN(cfg_bts_acc_ramping_step_interval,
3451 cfg_bts_acc_ramping_step_interval_cmd,
3452 "access-control-class-ramping-step-interval (<"
3453 OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_INTERVAL_MIN) "-"
3454 OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_INTERVAL_MAX) ">|dynamic)",
3455 "Configure Access Control Class ramping step interval\n"
3456 "Set a fixed step interval (in seconds)\n"
3457 "Use dynamic step interval based on BTS channel load\n")
3458{
3459 struct gsm_bts *bts = vty->index;
3460 bool dynamic = (strcmp(argv[0], "dynamic") == 0);
3461 int error;
3462
3463 if (dynamic) {
3464 acc_ramp_set_step_interval_dynamic(&bts->acc_ramp);
3465 return CMD_SUCCESS;
3466 }
3467
3468 error = acc_ramp_set_step_interval(&bts->acc_ramp, atoi(argv[0]));
3469 if (error != 0) {
3470 if (error == -ERANGE)
3471 vty_out(vty, "Unable to set ACC ramp step interval: value out of range%s", VTY_NEWLINE);
3472 else
3473 vty_out(vty, "Unable to set ACC ramp step interval: unknown error%s", VTY_NEWLINE);
3474 return CMD_WARNING;
3475 }
3476
3477 return CMD_SUCCESS;
3478}
3479
3480DEFUN(cfg_bts_acc_ramping_step_size,
3481 cfg_bts_acc_ramping_step_size_cmd,
3482 "access-control-class-ramping-step-size (<"
3483 OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_SIZE_MIN) "-"
3484 OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_SIZE_MAX) ">)",
3485 "Configure Access Control Class ramping step size\n"
3486 "Set the number of Access Control Classes to enable per ramping step\n")
3487{
3488 struct gsm_bts *bts = vty->index;
3489 int error;
3490
3491 error = acc_ramp_set_step_size(&bts->acc_ramp, atoi(argv[0]));
3492 if (error != 0) {
3493 if (error == -ERANGE)
3494 vty_out(vty, "Unable to set ACC ramp step size: value out of range%s", VTY_NEWLINE);
3495 else
3496 vty_out(vty, "Unable to set ACC ramp step size: unknown error%s", VTY_NEWLINE);
3497 return CMD_WARNING;
3498 }
3499
3500 return CMD_SUCCESS;
3501}
3502
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +02003503#define EXCL_RFLOCK_STR "Exclude this BTS from the global RF Lock\n"
3504
3505DEFUN(cfg_bts_excl_rf_lock,
3506 cfg_bts_excl_rf_lock_cmd,
3507 "rf-lock-exclude",
3508 EXCL_RFLOCK_STR)
3509{
3510 struct gsm_bts *bts = vty->index;
3511 bts->excl_from_rf_lock = 1;
3512 return CMD_SUCCESS;
3513}
3514
3515DEFUN(cfg_bts_no_excl_rf_lock,
3516 cfg_bts_no_excl_rf_lock_cmd,
3517 "no rf-lock-exclude",
3518 NO_STR EXCL_RFLOCK_STR)
3519{
3520 struct gsm_bts *bts = vty->index;
3521 bts->excl_from_rf_lock = 0;
3522 return CMD_SUCCESS;
3523}
3524
Jacob Erlbeck65d114f2014-01-16 11:02:14 +01003525#define FORCE_COMB_SI_STR "Force the generation of a single SI (no ter/bis)\n"
3526
3527DEFUN(cfg_bts_force_comb_si,
3528 cfg_bts_force_comb_si_cmd,
3529 "force-combined-si",
3530 FORCE_COMB_SI_STR)
3531{
3532 struct gsm_bts *bts = vty->index;
3533 bts->force_combined_si = 1;
Pau Espin Pedrol167cb822018-11-19 17:48:17 +01003534 bts->force_combined_si_set = true;
Jacob Erlbeck65d114f2014-01-16 11:02:14 +01003535 return CMD_SUCCESS;
3536}
3537
3538DEFUN(cfg_bts_no_force_comb_si,
3539 cfg_bts_no_force_comb_si_cmd,
3540 "no force-combined-si",
3541 NO_STR FORCE_COMB_SI_STR)
3542{
3543 struct gsm_bts *bts = vty->index;
3544 bts->force_combined_si = 0;
Pau Espin Pedrol167cb822018-11-19 17:48:17 +01003545 bts->force_combined_si_set = true;
Jacob Erlbeck65d114f2014-01-16 11:02:14 +01003546 return CMD_SUCCESS;
3547}
3548
Andreas Eversberga83d5112013-12-07 18:32:28 +01003549static void _get_codec_from_arg(struct vty *vty, int argc, const char *argv[])
3550{
3551 struct gsm_bts *bts = vty->index;
3552 struct bts_codec_conf *codec = &bts->codec;
3553 int i;
3554
3555 codec->hr = 0;
3556 codec->efr = 0;
3557 codec->amr = 0;
3558 for (i = 0; i < argc; i++) {
3559 if (!strcmp(argv[i], "hr"))
3560 codec->hr = 1;
3561 if (!strcmp(argv[i], "efr"))
3562 codec->efr = 1;
3563 if (!strcmp(argv[i], "amr"))
3564 codec->amr = 1;
3565 }
3566}
3567
3568#define CODEC_PAR_STR " (hr|efr|amr)"
3569#define CODEC_HELP_STR "Half Rate\n" \
3570 "Enhanced Full Rate\nAdaptive Multirate\n"
3571
3572DEFUN(cfg_bts_codec0, cfg_bts_codec0_cmd,
3573 "codec-support fr",
3574 "Codec Support settings\nFullrate\n")
3575{
3576 _get_codec_from_arg(vty, 0, argv);
3577 return CMD_SUCCESS;
3578}
3579
3580DEFUN(cfg_bts_codec1, cfg_bts_codec1_cmd,
3581 "codec-support fr" CODEC_PAR_STR,
3582 "Codec Support settings\nFullrate\n"
3583 CODEC_HELP_STR)
3584{
3585 _get_codec_from_arg(vty, 1, argv);
3586 return CMD_SUCCESS;
3587}
3588
3589DEFUN(cfg_bts_codec2, cfg_bts_codec2_cmd,
3590 "codec-support fr" CODEC_PAR_STR CODEC_PAR_STR,
3591 "Codec Support settings\nFullrate\n"
3592 CODEC_HELP_STR CODEC_HELP_STR)
3593{
3594 _get_codec_from_arg(vty, 2, argv);
3595 return CMD_SUCCESS;
3596}
3597
3598DEFUN(cfg_bts_codec3, cfg_bts_codec3_cmd,
3599 "codec-support fr" CODEC_PAR_STR CODEC_PAR_STR CODEC_PAR_STR,
3600 "Codec Support settings\nFullrate\n"
3601 CODEC_HELP_STR CODEC_HELP_STR CODEC_HELP_STR)
3602{
3603 _get_codec_from_arg(vty, 3, argv);
3604 return CMD_SUCCESS;
3605}
3606
3607DEFUN(cfg_bts_codec4, cfg_bts_codec4_cmd,
3608 "codec-support fr" CODEC_PAR_STR CODEC_PAR_STR CODEC_PAR_STR CODEC_PAR_STR,
3609 "Codec Support settings\nFullrate\n"
3610 CODEC_HELP_STR CODEC_HELP_STR CODEC_HELP_STR CODEC_HELP_STR)
3611{
3612 _get_codec_from_arg(vty, 4, argv);
3613 return CMD_SUCCESS;
3614}
3615
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +01003616DEFUN(cfg_bts_depends_on, cfg_bts_depends_on_cmd,
3617 "depends-on-bts <0-255>",
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01003618 "This BTS can only be started if another one is up\n"
3619 BTS_NR_STR)
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +01003620{
3621 struct gsm_bts *bts = vty->index;
3622 struct gsm_bts *other_bts;
3623 int dep = atoi(argv[0]);
3624
3625
3626 if (!is_ipaccess_bts(bts)) {
3627 vty_out(vty, "This feature is only available for IP systems.%s",
3628 VTY_NEWLINE);
3629 return CMD_WARNING;
3630 }
3631
3632 other_bts = gsm_bts_num(bts->network, dep);
3633 if (!other_bts || !is_ipaccess_bts(other_bts)) {
3634 vty_out(vty, "This feature is only available for IP systems.%s",
3635 VTY_NEWLINE);
3636 return CMD_WARNING;
3637 }
3638
3639 if (dep >= bts->nr) {
3640 vty_out(vty, "%%Need to depend on an already declared unit.%s",
3641 VTY_NEWLINE);
3642 return CMD_WARNING;
3643 }
3644
3645 bts_depend_mark(bts, dep);
3646 return CMD_SUCCESS;
3647}
3648
3649DEFUN(cfg_bts_no_depends_on, cfg_bts_no_depends_on_cmd,
3650 "depeneds-on-bts <0-255>",
3651 NO_STR "This BTS can only be started if another one is up\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01003652 BTS_NR_STR)
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +01003653{
3654 struct gsm_bts *bts = vty->index;
3655 int dep = atoi(argv[0]);
3656
3657 bts_depend_clear(bts, dep);
3658 return CMD_SUCCESS;
3659}
3660
Andreas Eversberg73266522014-01-19 11:47:44 +01003661#define AMR_TEXT "Adaptive Multi Rate settings\n"
3662#define AMR_MODE_TEXT "Codec modes to use with AMR codec\n"
3663#define AMR_START_TEXT "Initial codec to use with AMR\n" \
3664 "Automatically\nFirst codec\nSecond codec\nThird codec\nFourth codec\n"
3665#define AMR_TH_TEXT "AMR threshold between codecs\nMS side\nBTS side\n"
3666#define AMR_HY_TEXT "AMR hysteresis between codecs\nMS side\nBTS side\n"
3667
3668static void get_amr_from_arg(struct vty *vty, int argc, const char *argv[], int full)
3669{
3670 struct gsm_bts *bts = vty->index;
3671 struct amr_multirate_conf *mr = (full) ? &bts->mr_full: &bts->mr_half;
3672 struct gsm48_multi_rate_conf *mr_conf =
3673 (struct gsm48_multi_rate_conf *) mr->gsm48_ie;
3674 int i;
Philipp Maiere4faf592018-10-22 14:28:00 +02003675 int mode;
3676 int mode_prev = -1;
Andreas Eversberg73266522014-01-19 11:47:44 +01003677
Philipp Maiere4faf592018-10-22 14:28:00 +02003678 /* Check if mode parameters are in order */
3679 for (i = 0; i < argc; i++) {
3680 mode = atoi(argv[i]);
3681 if (mode_prev > mode) {
3682 vty_out(vty, "Modes must be listed in order%s",
3683 VTY_NEWLINE);
3684 return;
3685 }
3686
3687 if (mode_prev == mode) {
3688 vty_out(vty, "Modes must be unique %s", VTY_NEWLINE);
3689 return;
3690 }
3691 mode_prev = mode;
3692 }
3693
3694 /* Prepare the multirate configuration IE */
Andreas Eversberg73266522014-01-19 11:47:44 +01003695 mr->gsm48_ie[1] = 0;
3696 for (i = 0; i < argc; i++)
3697 mr->gsm48_ie[1] |= 1 << atoi(argv[i]);
3698 mr_conf->icmi = 0;
Philipp Maiere4faf592018-10-22 14:28:00 +02003699
3700 /* Store actual mode identifier values */
3701 for (i = 0; i < argc; i++) {
3702 mr->ms_mode[i].mode = atoi(argv[i]);
3703 mr->bts_mode[i].mode = atoi(argv[i]);
3704 }
3705 mr->num_modes = argc;
3706
3707 /* Trim excess threshold and hysteresis values from previous config */
3708 for (i = argc - 1; i < 4; i++) {
3709 mr->ms_mode[i].threshold = 0;
3710 mr->bts_mode[i].threshold = 0;
3711 mr->ms_mode[i].hysteresis = 0;
3712 mr->bts_mode[i].hysteresis = 0;
3713 }
Andreas Eversberg73266522014-01-19 11:47:44 +01003714}
3715
3716static void get_amr_th_from_arg(struct vty *vty, int argc, const char *argv[], int full)
3717{
3718 struct gsm_bts *bts = vty->index;
3719 struct amr_multirate_conf *mr = (full) ? &bts->mr_full: &bts->mr_half;
Holger Hans Peter Freythera174a472015-09-24 11:39:38 +02003720 struct amr_mode *modes;
Andreas Eversberg73266522014-01-19 11:47:44 +01003721 int i;
3722
Holger Hans Peter Freythera174a472015-09-24 11:39:38 +02003723 modes = argv[0][0]=='m' ? mr->ms_mode : mr->bts_mode;
3724 for (i = 0; i < argc - 1; i++)
3725 modes[i].threshold = atoi(argv[i + 1]);
Andreas Eversberg73266522014-01-19 11:47:44 +01003726}
3727
3728static void get_amr_hy_from_arg(struct vty *vty, int argc, const char *argv[], int full)
3729{
3730 struct gsm_bts *bts = vty->index;
3731 struct amr_multirate_conf *mr = (full) ? &bts->mr_full: &bts->mr_half;
Holger Hans Peter Freythera174a472015-09-24 11:39:38 +02003732 struct amr_mode *modes;
Andreas Eversberg73266522014-01-19 11:47:44 +01003733 int i;
3734
Holger Hans Peter Freythera174a472015-09-24 11:39:38 +02003735 modes = argv[0][0]=='m' ? mr->ms_mode : mr->bts_mode;
3736 for (i = 0; i < argc - 1; i++)
3737 modes[i].hysteresis = atoi(argv[i + 1]);
Andreas Eversberg73266522014-01-19 11:47:44 +01003738}
3739
3740static void get_amr_start_from_arg(struct vty *vty, const char *argv[], int full)
3741{
3742 struct gsm_bts *bts = vty->index;
3743 struct amr_multirate_conf *mr = (full) ? &bts->mr_full: &bts->mr_half;
3744 struct gsm48_multi_rate_conf *mr_conf =
3745 (struct gsm48_multi_rate_conf *) mr->gsm48_ie;
3746 int num = 0, i;
3747
3748 for (i = 0; i < ((full) ? 8 : 6); i++) {
3749 if ((mr->gsm48_ie[1] & (1 << i))) {
3750 num++;
3751 }
3752 }
3753
3754 if (argv[0][0] == 'a' || num == 0)
3755 mr_conf->icmi = 0;
3756 else {
3757 mr_conf->icmi = 1;
3758 if (num < atoi(argv[0]))
3759 mr_conf->smod = num - 1;
3760 else
3761 mr_conf->smod = atoi(argv[0]) - 1;
3762 }
3763}
3764
Philipp Maiere4faf592018-10-22 14:28:00 +02003765/* Give the current amr configuration a final consistency chack by feeding the
3766 * the configuration into the gsm48 multirate IE generator function */
3767static int check_amr_config(struct vty *vty)
3768{
3769 int rc = 0;
3770 struct amr_multirate_conf *mr;
3771 const struct gsm48_multi_rate_conf *mr_conf;
3772 struct gsm_bts *bts = vty->index;
3773 int vty_rc = CMD_SUCCESS;
3774
3775 mr = &bts->mr_full;
3776 mr_conf = (struct gsm48_multi_rate_conf*) mr->gsm48_ie;
3777 rc = gsm48_multirate_config(NULL, mr_conf, mr->ms_mode, mr->num_modes);
3778 if (rc != 0) {
3779 vty_out(vty,
3780 "Invalid AMR multirate configuration (tch-f, ms) - check parameters%s",
3781 VTY_NEWLINE);
3782 vty_rc = CMD_WARNING;
3783 }
3784
3785 rc = gsm48_multirate_config(NULL, mr_conf, mr->bts_mode, mr->num_modes);
3786 if (rc != 0) {
3787 vty_out(vty,
3788 "Invalid AMR multirate configuration (tch-f, bts) - check parameters%s",
3789 VTY_NEWLINE);
3790 vty_rc = CMD_WARNING;
3791 }
3792
3793 mr = &bts->mr_half;
3794 mr_conf = (struct gsm48_multi_rate_conf*) mr->gsm48_ie;
3795 rc = gsm48_multirate_config(NULL, mr_conf, mr->ms_mode, mr->num_modes);
3796 if (rc != 0) {
3797 vty_out(vty,
3798 "Invalid AMR multirate configuration (tch-h, ms) - check parameters%s",
3799 VTY_NEWLINE);
3800 vty_rc = CMD_WARNING;
3801 }
3802
3803 rc = gsm48_multirate_config(NULL, mr_conf, mr->bts_mode, mr->num_modes);
3804 if (rc != 0) {
3805 vty_out(vty,
3806 "Invalid AMR multirate configuration (tch-h, bts) - check parameters%s",
3807 VTY_NEWLINE);
3808 vty_rc = CMD_WARNING;
3809 }
3810
3811 return vty_rc;
3812}
3813
Andreas Eversberg73266522014-01-19 11:47:44 +01003814#define AMR_TCHF_PAR_STR " (0|1|2|3|4|5|6|7)"
3815#define AMR_TCHF_HELP_STR "4,75k\n5,15k\n5,90k\n6,70k\n7,40k\n7,95k\n" \
3816 "10,2k\n12,2k\n"
3817
3818#define AMR_TCHH_PAR_STR " (0|1|2|3|4|5)"
3819#define AMR_TCHH_HELP_STR "4,75k\n5,15k\n5,90k\n6,70k\n7,40k\n7,95k\n"
3820
3821#define AMR_TH_HELP_STR "Threshold between codec 1 and 2\n"
3822#define AMR_HY_HELP_STR "Hysteresis between codec 1 and 2\n"
3823
3824DEFUN(cfg_bts_amr_fr_modes1, cfg_bts_amr_fr_modes1_cmd,
3825 "amr tch-f modes" AMR_TCHF_PAR_STR,
3826 AMR_TEXT "Full Rate\n" AMR_MODE_TEXT
3827 AMR_TCHF_HELP_STR)
3828{
3829 get_amr_from_arg(vty, 1, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003830 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003831}
3832
3833DEFUN(cfg_bts_amr_fr_modes2, cfg_bts_amr_fr_modes2_cmd,
3834 "amr tch-f modes" AMR_TCHF_PAR_STR AMR_TCHF_PAR_STR,
3835 AMR_TEXT "Full Rate\n" AMR_MODE_TEXT
3836 AMR_TCHF_HELP_STR AMR_TCHF_HELP_STR)
3837{
3838 get_amr_from_arg(vty, 2, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003839 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003840}
3841
3842DEFUN(cfg_bts_amr_fr_modes3, cfg_bts_amr_fr_modes3_cmd,
3843 "amr tch-f modes" AMR_TCHF_PAR_STR AMR_TCHF_PAR_STR AMR_TCHF_PAR_STR,
3844 AMR_TEXT "Full Rate\n" AMR_MODE_TEXT
3845 AMR_TCHF_HELP_STR AMR_TCHF_HELP_STR AMR_TCHF_HELP_STR)
3846{
3847 get_amr_from_arg(vty, 3, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003848 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003849}
3850
3851DEFUN(cfg_bts_amr_fr_modes4, cfg_bts_amr_fr_modes4_cmd,
3852 "amr tch-f modes" AMR_TCHF_PAR_STR AMR_TCHF_PAR_STR AMR_TCHF_PAR_STR AMR_TCHF_PAR_STR,
3853 AMR_TEXT "Full Rate\n" AMR_MODE_TEXT
3854 AMR_TCHF_HELP_STR AMR_TCHF_HELP_STR AMR_TCHF_HELP_STR AMR_TCHF_HELP_STR)
3855{
3856 get_amr_from_arg(vty, 4, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003857 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003858}
3859
3860DEFUN(cfg_bts_amr_fr_start_mode, cfg_bts_amr_fr_start_mode_cmd,
3861 "amr tch-f start-mode (auto|1|2|3|4)",
3862 AMR_TEXT "Full Rate\n" AMR_START_TEXT)
3863{
3864 get_amr_start_from_arg(vty, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003865 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003866}
3867
3868DEFUN(cfg_bts_amr_fr_thres1, cfg_bts_amr_fr_thres1_cmd,
3869 "amr tch-f threshold (ms|bts) <0-63>",
3870 AMR_TEXT "Full Rate\n" AMR_TH_TEXT
3871 AMR_TH_HELP_STR)
3872{
3873 get_amr_th_from_arg(vty, 2, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003874 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003875}
3876
3877DEFUN(cfg_bts_amr_fr_thres2, cfg_bts_amr_fr_thres2_cmd,
3878 "amr tch-f threshold (ms|bts) <0-63> <0-63>",
3879 AMR_TEXT "Full Rate\n" AMR_TH_TEXT
3880 AMR_TH_HELP_STR AMR_TH_HELP_STR)
3881{
3882 get_amr_th_from_arg(vty, 3, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003883 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003884}
3885
3886DEFUN(cfg_bts_amr_fr_thres3, cfg_bts_amr_fr_thres3_cmd,
3887 "amr tch-f threshold (ms|bts) <0-63> <0-63> <0-63>",
3888 AMR_TEXT "Full Rate\n" AMR_TH_TEXT
3889 AMR_TH_HELP_STR AMR_TH_HELP_STR AMR_TH_HELP_STR)
3890{
3891 get_amr_th_from_arg(vty, 4, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003892 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003893}
3894
3895DEFUN(cfg_bts_amr_fr_hyst1, cfg_bts_amr_fr_hyst1_cmd,
3896 "amr tch-f hysteresis (ms|bts) <0-15>",
3897 AMR_TEXT "Full Rate\n" AMR_HY_TEXT
3898 AMR_HY_HELP_STR)
3899{
3900 get_amr_hy_from_arg(vty, 2, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003901 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003902}
3903
3904DEFUN(cfg_bts_amr_fr_hyst2, cfg_bts_amr_fr_hyst2_cmd,
3905 "amr tch-f hysteresis (ms|bts) <0-15> <0-15>",
3906 AMR_TEXT "Full Rate\n" AMR_HY_TEXT
3907 AMR_HY_HELP_STR AMR_HY_HELP_STR)
3908{
3909 get_amr_hy_from_arg(vty, 3, argv, 1);
3910 return CMD_SUCCESS;
3911}
3912
3913DEFUN(cfg_bts_amr_fr_hyst3, cfg_bts_amr_fr_hyst3_cmd,
3914 "amr tch-f hysteresis (ms|bts) <0-15> <0-15> <0-15>",
3915 AMR_TEXT "Full Rate\n" AMR_HY_TEXT
3916 AMR_HY_HELP_STR AMR_HY_HELP_STR AMR_HY_HELP_STR)
3917{
3918 get_amr_hy_from_arg(vty, 4, argv, 1);
Philipp Maiere4faf592018-10-22 14:28:00 +02003919 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003920}
3921
3922DEFUN(cfg_bts_amr_hr_modes1, cfg_bts_amr_hr_modes1_cmd,
3923 "amr tch-h modes" AMR_TCHH_PAR_STR,
3924 AMR_TEXT "Half Rate\n" AMR_MODE_TEXT
3925 AMR_TCHH_HELP_STR)
3926{
3927 get_amr_from_arg(vty, 1, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003928 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003929}
3930
3931DEFUN(cfg_bts_amr_hr_modes2, cfg_bts_amr_hr_modes2_cmd,
3932 "amr tch-h modes" AMR_TCHH_PAR_STR AMR_TCHH_PAR_STR,
3933 AMR_TEXT "Half Rate\n" AMR_MODE_TEXT
3934 AMR_TCHH_HELP_STR AMR_TCHH_HELP_STR)
3935{
3936 get_amr_from_arg(vty, 2, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003937 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003938}
3939
3940DEFUN(cfg_bts_amr_hr_modes3, cfg_bts_amr_hr_modes3_cmd,
3941 "amr tch-h modes" AMR_TCHH_PAR_STR AMR_TCHH_PAR_STR AMR_TCHH_PAR_STR,
3942 AMR_TEXT "Half Rate\n" AMR_MODE_TEXT
3943 AMR_TCHH_HELP_STR AMR_TCHH_HELP_STR AMR_TCHH_HELP_STR)
3944{
3945 get_amr_from_arg(vty, 3, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003946 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003947}
3948
3949DEFUN(cfg_bts_amr_hr_modes4, cfg_bts_amr_hr_modes4_cmd,
3950 "amr tch-h modes" AMR_TCHH_PAR_STR AMR_TCHH_PAR_STR AMR_TCHH_PAR_STR AMR_TCHH_PAR_STR,
3951 AMR_TEXT "Half Rate\n" AMR_MODE_TEXT
3952 AMR_TCHH_HELP_STR AMR_TCHH_HELP_STR AMR_TCHH_HELP_STR AMR_TCHH_HELP_STR)
3953{
3954 get_amr_from_arg(vty, 4, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003955 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003956}
3957
3958DEFUN(cfg_bts_amr_hr_start_mode, cfg_bts_amr_hr_start_mode_cmd,
3959 "amr tch-h start-mode (auto|1|2|3|4)",
3960 AMR_TEXT "Half Rate\n" AMR_START_TEXT)
3961{
3962 get_amr_start_from_arg(vty, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003963 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003964}
3965
3966DEFUN(cfg_bts_amr_hr_thres1, cfg_bts_amr_hr_thres1_cmd,
3967 "amr tch-h threshold (ms|bts) <0-63>",
3968 AMR_TEXT "Half Rate\n" AMR_TH_TEXT
3969 AMR_TH_HELP_STR)
3970{
3971 get_amr_th_from_arg(vty, 2, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003972 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003973}
3974
3975DEFUN(cfg_bts_amr_hr_thres2, cfg_bts_amr_hr_thres2_cmd,
3976 "amr tch-h threshold (ms|bts) <0-63> <0-63>",
3977 AMR_TEXT "Half Rate\n" AMR_TH_TEXT
3978 AMR_TH_HELP_STR AMR_TH_HELP_STR)
3979{
3980 get_amr_th_from_arg(vty, 3, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003981 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003982}
3983
3984DEFUN(cfg_bts_amr_hr_thres3, cfg_bts_amr_hr_thres3_cmd,
3985 "amr tch-h threshold (ms|bts) <0-63> <0-63> <0-63>",
3986 AMR_TEXT "Half Rate\n" AMR_TH_TEXT
3987 AMR_TH_HELP_STR AMR_TH_HELP_STR AMR_TH_HELP_STR)
3988{
3989 get_amr_th_from_arg(vty, 4, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003990 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01003991}
3992
3993DEFUN(cfg_bts_amr_hr_hyst1, cfg_bts_amr_hr_hyst1_cmd,
3994 "amr tch-h hysteresis (ms|bts) <0-15>",
3995 AMR_TEXT "Half Rate\n" AMR_HY_TEXT
3996 AMR_HY_HELP_STR)
3997{
3998 get_amr_hy_from_arg(vty, 2, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02003999 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01004000}
4001
4002DEFUN(cfg_bts_amr_hr_hyst2, cfg_bts_amr_hr_hyst2_cmd,
4003 "amr tch-h hysteresis (ms|bts) <0-15> <0-15>",
4004 AMR_TEXT "Half Rate\n" AMR_HY_TEXT
4005 AMR_HY_HELP_STR AMR_HY_HELP_STR)
4006{
4007 get_amr_hy_from_arg(vty, 3, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02004008 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01004009}
4010
4011DEFUN(cfg_bts_amr_hr_hyst3, cfg_bts_amr_hr_hyst3_cmd,
4012 "amr tch-h hysteresis (ms|bts) <0-15> <0-15> <0-15>",
4013 AMR_TEXT "Half Rate\n" AMR_HY_TEXT
4014 AMR_HY_HELP_STR AMR_HY_HELP_STR AMR_HY_HELP_STR)
4015{
4016 get_amr_hy_from_arg(vty, 4, argv, 0);
Philipp Maiere4faf592018-10-22 14:28:00 +02004017 return check_amr_config(vty);
Andreas Eversberg73266522014-01-19 11:47:44 +01004018}
4019
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01004020#define TNUM_STR "T-number, optionally preceded by 't' or 'T'\n"
4021DEFUN(cfg_bts_t3113_dynamic, cfg_bts_t3113_dynamic_cmd,
4022 "timer-dynamic TNNNN",
4023 "Calculate T3113 dynamically based on channel config and load\n"
4024 TNUM_STR)
4025{
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01004026 struct osmo_tdef *d;
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01004027 struct gsm_bts *bts = vty->index;
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01004028 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01004029
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01004030 d = osmo_tdef_vty_parse_T_arg(vty, gsmnet->T_defs, argv[0]);
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01004031 if (!d)
4032 return CMD_WARNING;
4033
4034 switch (d->T) {
4035 case 3113:
4036 bts->T3113_dynamic = true;
4037 break;
4038 default:
4039 vty_out(vty, "T%d cannot be set to dynamic%s", d->T, VTY_NEWLINE);
4040 return CMD_WARNING;
4041 }
4042
4043 return CMD_SUCCESS;
4044}
4045
4046DEFUN(cfg_bts_no_t3113_dynamic, cfg_bts_no_t3113_dynamic_cmd,
4047 "no timer-dynamic TNNNN",
4048 NO_STR
4049 "Set given timer to non-dynamic and use the default or user provided fixed value\n"
4050 TNUM_STR)
4051{
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01004052 struct osmo_tdef *d;
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01004053 struct gsm_bts *bts = vty->index;
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01004054 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01004055
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01004056 d = osmo_tdef_vty_parse_T_arg(vty, gsmnet->T_defs, argv[0]);
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01004057 if (!d)
4058 return CMD_WARNING;
4059
4060 switch (d->T) {
4061 case 3113:
4062 bts->T3113_dynamic = false;
4063 break;
4064 default:
4065 vty_out(vty, "T%d already is non-dynamic%s", d->T, VTY_NEWLINE);
4066 return CMD_WARNING;
4067 }
4068
4069 return CMD_SUCCESS;
4070}
4071
Harald Welte8f0ed552010-05-11 21:53:49 +02004072#define TRX_TEXT "Radio Transceiver\n"
Harald Welte7a8fa412009-08-10 13:48:16 +02004073
Harald Welte5258fc42009-03-28 19:07:53 +00004074/* per TRX configuration */
4075DEFUN(cfg_trx,
4076 cfg_trx_cmd,
Harald Welte57e07242012-08-17 12:50:14 +02004077 "trx <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02004078 TRX_TEXT
Harald Welte5258fc42009-03-28 19:07:53 +00004079 "Select a TRX to configure")
4080{
4081 int trx_nr = atoi(argv[0]);
4082 struct gsm_bts *bts = vty->index;
4083 struct gsm_bts_trx *trx;
4084
Harald Weltee441d9c2009-06-21 16:17:15 +02004085 if (trx_nr > bts->num_trx) {
4086 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
4087 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00004088 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02004089 } else if (trx_nr == bts->num_trx) {
4090 /* we need to allocate a new one */
4091 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02004092 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02004093 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02004094
Harald Weltee441d9c2009-06-21 16:17:15 +02004095 if (!trx)
4096 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00004097
4098 vty->index = trx;
Harald Welte197dea92010-05-14 17:59:53 +02004099 vty->index_sub = &trx->description;
Harald Welte5258fc42009-03-28 19:07:53 +00004100 vty->node = TRX_NODE;
4101
4102 return CMD_SUCCESS;
4103}
4104
4105DEFUN(cfg_trx_arfcn,
4106 cfg_trx_arfcn_cmd,
Harald Welte1fe73a12012-01-29 13:24:12 +01004107 "arfcn <0-1023>",
Harald Welte13fe2192012-08-17 09:57:25 +02004108 "Set the ARFCN for this TRX\n"
4109 "Absolute Radio Frequency Channel Number\n")
Harald Welte5258fc42009-03-28 19:07:53 +00004110{
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01004111 enum gsm_band unused;
Harald Welte5258fc42009-03-28 19:07:53 +00004112 struct gsm_bts_trx *trx = vty->index;
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01004113 int arfcn = atoi(argv[0]);
4114
4115 if (gsm_arfcn2band_rc(arfcn, &unused) < 0) {
4116 vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE);
4117 return CMD_WARNING;
4118 }
Harald Welte5258fc42009-03-28 19:07:53 +00004119
4120 /* FIXME: check if this ARFCN is supported by this TRX */
4121
4122 trx->arfcn = arfcn;
4123
4124 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
4125 /* FIXME: use OML layer to update the ARFCN */
4126 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
4127
4128 return CMD_SUCCESS;
4129}
4130
Harald Welte (local)7b37d972009-12-27 20:56:38 +01004131DEFUN(cfg_trx_nominal_power,
4132 cfg_trx_nominal_power_cmd,
4133 "nominal power <0-100>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004134 "Nominal TRX RF Power in dBm\n"
4135 "Nominal TRX RF Power in dBm\n"
4136 "Nominal TRX RF Power in dBm\n")
Harald Welte (local)7b37d972009-12-27 20:56:38 +01004137{
4138 struct gsm_bts_trx *trx = vty->index;
4139
4140 trx->nominal_power = atoi(argv[0]);
4141
4142 return CMD_SUCCESS;
4143}
4144
Harald Weltefcd24452009-06-20 18:15:19 +02004145DEFUN(cfg_trx_max_power_red,
4146 cfg_trx_max_power_red_cmd,
4147 "max_power_red <0-100>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004148 "Reduction of maximum BS RF Power (relative to nominal power)\n"
Harald Weltefcd24452009-06-20 18:15:19 +02004149 "Reduction of maximum BS RF Power in dB\n")
4150{
4151 int maxpwr_r = atoi(argv[0]);
4152 struct gsm_bts_trx *trx = vty->index;
Harald Welte61a83b22009-11-18 09:20:22 +01004153 int upper_limit = 24; /* default 12.21 max power red. */
Harald Weltefcd24452009-06-20 18:15:19 +02004154
4155 /* FIXME: check if our BTS type supports more than 12 */
4156 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
4157 vty_out(vty, "%% Power %d dB is not in the valid range%s",
4158 maxpwr_r, VTY_NEWLINE);
4159 return CMD_WARNING;
4160 }
4161 if (maxpwr_r & 1) {
4162 vty_out(vty, "%% Power %d dB is not an even value%s",
4163 maxpwr_r, VTY_NEWLINE);
4164 return CMD_WARNING;
4165 }
4166
4167 trx->max_power_red = maxpwr_r;
4168
4169 /* FIXME: make sure we update this using OML */
4170
4171 return CMD_SUCCESS;
4172}
4173
Harald Welte42581822009-08-08 16:12:58 +02004174DEFUN(cfg_trx_rsl_e1,
4175 cfg_trx_rsl_e1_cmd,
4176 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004177 "RSL Parameters\n"
4178 "E1/T1 interface to be used for RSL\n"
4179 "E1/T1 interface to be used for RSL\n"
4180 "E1/T1 Line Number to be used for RSL\n"
4181 "E1/T1 Timeslot to be used for RSL\n"
4182 "E1/T1 Timeslot to be used for RSL\n"
4183 "E1/T1 Sub-slot to be used for RSL\n"
4184 "E1/T1 Sub-slot 0 is to be used for RSL\n"
4185 "E1/T1 Sub-slot 1 is to be used for RSL\n"
4186 "E1/T1 Sub-slot 2 is to be used for RSL\n"
4187 "E1/T1 Sub-slot 3 is to be used for RSL\n"
4188 "E1/T1 full timeslot is to be used for RSL\n")
Harald Welte42581822009-08-08 16:12:58 +02004189{
4190 struct gsm_bts_trx *trx = vty->index;
4191
4192 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
4193
4194 return CMD_SUCCESS;
4195}
4196
4197DEFUN(cfg_trx_rsl_e1_tei,
4198 cfg_trx_rsl_e1_tei_cmd,
4199 "rsl e1 tei <0-63>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004200 "RSL Parameters\n"
4201 "Set the TEI to be used for RSL\n"
4202 "Set the TEI to be used for RSL\n"
4203 "TEI to be used for RSL\n")
Harald Welte42581822009-08-08 16:12:58 +02004204{
4205 struct gsm_bts_trx *trx = vty->index;
4206
4207 trx->rsl_tei = atoi(argv[0]);
4208
4209 return CMD_SUCCESS;
4210}
4211
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01004212DEFUN(cfg_trx_rf_locked,
4213 cfg_trx_rf_locked_cmd,
4214 "rf_locked (0|1)",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004215 "Set or unset the RF Locking (Turn off RF of the TRX)\n"
4216 "TRX is NOT RF locked (active)\n"
4217 "TRX is RF locked (turned off)\n")
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01004218{
4219 int locked = atoi(argv[0]);
4220 struct gsm_bts_trx *trx = vty->index;
4221
Maxbe356ed2017-09-07 19:10:09 +02004222 gsm_trx_lock_rf(trx, locked, "vty");
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01004223 return CMD_SUCCESS;
4224}
Harald Welte42581822009-08-08 16:12:58 +02004225
Harald Welte5258fc42009-03-28 19:07:53 +00004226/* per TS configuration */
4227DEFUN(cfg_ts,
4228 cfg_ts_cmd,
Harald Welte42581822009-08-08 16:12:58 +02004229 "timeslot <0-7>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004230 "Select a Timeslot to configure\n"
4231 "Timeslot number\n")
Harald Welte5258fc42009-03-28 19:07:53 +00004232{
4233 int ts_nr = atoi(argv[0]);
4234 struct gsm_bts_trx *trx = vty->index;
4235 struct gsm_bts_trx_ts *ts;
4236
4237 if (ts_nr >= TRX_NR_TS) {
4238 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
4239 TRX_NR_TS, VTY_NEWLINE);
4240 return CMD_WARNING;
4241 }
4242
4243 ts = &trx->ts[ts_nr];
4244
4245 vty->index = ts;
4246 vty->node = TS_NODE;
4247
4248 return CMD_SUCCESS;
4249}
4250
Harald Weltea6fd58e2009-08-07 00:25:23 +02004251DEFUN(cfg_ts_pchan,
4252 cfg_ts_pchan_cmd,
Harald Welte4ab9d7c2012-08-17 12:42:06 +02004253 "phys_chan_config PCHAN", /* dynamically generated! */
Holger Hans Peter Freyther63b0e442013-03-03 09:32:08 +01004254 "Physical Channel configuration (TCH/SDCCH/...)\n" "Physical Channel\n")
Harald Welte4ab9d7c2012-08-17 12:42:06 +02004255{
4256 struct gsm_bts_trx_ts *ts = vty->index;
4257 int pchanc;
4258
4259 pchanc = gsm_pchan_parse(argv[0]);
4260 if (pchanc < 0)
4261 return CMD_WARNING;
4262
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004263 ts->pchan_from_config = pchanc;
Harald Welte4ab9d7c2012-08-17 12:42:06 +02004264
4265 return CMD_SUCCESS;
4266}
4267
4268/* used for backwards compatibility with old config files that still
4269 * have uppercase pchan type names */
4270DEFUN_HIDDEN(cfg_ts_pchan_compat,
4271 cfg_ts_pchan_compat_cmd,
Harald Weltea6fd58e2009-08-07 00:25:23 +02004272 "phys_chan_config PCHAN",
Holger Hans Peter Freyther63b0e442013-03-03 09:32:08 +01004273 "Physical Channel configuration (TCH/SDCCH/...)\n" "Physical Channel\n")
Harald Weltea6fd58e2009-08-07 00:25:23 +02004274{
4275 struct gsm_bts_trx_ts *ts = vty->index;
4276 int pchanc;
4277
4278 pchanc = gsm_pchan_parse(argv[0]);
Stefan Sperlinge67ebf02018-07-17 16:03:07 +02004279 if (pchanc < 0) {
4280 vty_out(vty, "Unknown physical channel name '%s'%s", argv[0], VTY_NEWLINE);
4281 return CMD_ERR_NO_MATCH;
4282 }
Harald Weltea6fd58e2009-08-07 00:25:23 +02004283
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004284 ts->pchan_from_config = pchanc;
Harald Weltea6fd58e2009-08-07 00:25:23 +02004285
4286 return CMD_SUCCESS;
4287}
4288
Harald Welte4ab9d7c2012-08-17 12:42:06 +02004289
4290
Harald Welte135a6482011-05-30 12:09:13 +02004291DEFUN(cfg_ts_tsc,
4292 cfg_ts_tsc_cmd,
4293 "training_sequence_code <0-7>",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004294 "Training Sequence Code of the Timeslot\n" "TSC\n")
Harald Welte135a6482011-05-30 12:09:13 +02004295{
4296 struct gsm_bts_trx_ts *ts = vty->index;
4297
Philipp Maier8c498fc2018-02-21 13:24:36 +01004298 if (!osmo_bts_has_feature(&ts->trx->bts->model->features, BTS_FEAT_MULTI_TSC)) {
Harald Welte903aaea2014-01-19 17:10:50 +01004299 vty_out(vty, "%% This BTS does not support a TSC != BCC, "
4300 "falling back to BCC%s", VTY_NEWLINE);
4301 ts->tsc = -1;
4302 return CMD_WARNING;
4303 }
4304
Harald Welte135a6482011-05-30 12:09:13 +02004305 ts->tsc = atoi(argv[0]);
4306
4307 return CMD_SUCCESS;
4308}
4309
Harald Weltea39b0f22010-06-14 22:26:10 +02004310#define HOPPING_STR "Configure frequency hopping\n"
4311
4312DEFUN(cfg_ts_hopping,
4313 cfg_ts_hopping_cmd,
4314 "hopping enabled (0|1)",
4315 HOPPING_STR "Enable or disable frequency hopping\n"
4316 "Disable frequency hopping\n" "Enable frequency hopping\n")
4317{
4318 struct gsm_bts_trx_ts *ts = vty->index;
Harald Weltec2fb3d02010-06-14 22:47:37 +02004319 int enabled = atoi(argv[0]);
Harald Weltea39b0f22010-06-14 22:26:10 +02004320
Philipp Maier8c498fc2018-02-21 13:24:36 +01004321 if (enabled && !osmo_bts_has_feature(&ts->trx->bts->model->features, BTS_FEAT_HOPPING)) {
Harald Weltec2fb3d02010-06-14 22:47:37 +02004322 vty_out(vty, "BTS model does not support hopping%s",
4323 VTY_NEWLINE);
4324 return CMD_WARNING;
4325 }
4326
4327 ts->hopping.enabled = enabled;
Harald Weltea39b0f22010-06-14 22:26:10 +02004328
4329 return CMD_SUCCESS;
4330}
4331
Harald Welte6e0cd042009-09-12 13:05:33 +02004332DEFUN(cfg_ts_hsn,
4333 cfg_ts_hsn_cmd,
Harald Weltea39b0f22010-06-14 22:26:10 +02004334 "hopping sequence-number <0-63>",
4335 HOPPING_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02004336 "Which hopping sequence to use for this channel\n"
4337 "Hopping Sequence Number (HSN)\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02004338{
4339 struct gsm_bts_trx_ts *ts = vty->index;
4340
4341 ts->hopping.hsn = atoi(argv[0]);
4342
4343 return CMD_SUCCESS;
4344}
4345
4346DEFUN(cfg_ts_maio,
4347 cfg_ts_maio_cmd,
4348 "hopping maio <0-63>",
Harald Weltea39b0f22010-06-14 22:26:10 +02004349 HOPPING_STR
Harald Weltecfaabbb2012-08-16 23:23:50 +02004350 "Which hopping MAIO to use for this channel\n"
4351 "Mobile Allocation Index Offset (MAIO)\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02004352{
4353 struct gsm_bts_trx_ts *ts = vty->index;
4354
4355 ts->hopping.maio = atoi(argv[0]);
4356
4357 return CMD_SUCCESS;
4358}
4359
4360DEFUN(cfg_ts_arfcn_add,
4361 cfg_ts_arfcn_add_cmd,
4362 "hopping arfcn add <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02004363 HOPPING_STR "Configure hopping ARFCN list\n"
4364 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02004365{
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01004366 enum gsm_band unused;
Harald Welte6e0cd042009-09-12 13:05:33 +02004367 struct gsm_bts_trx_ts *ts = vty->index;
4368 int arfcn = atoi(argv[0]);
4369
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01004370 if (gsm_arfcn2band_rc(arfcn, &unused) < 0) {
4371 vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE);
4372 return CMD_WARNING;
4373 }
4374
Harald Weltea39b0f22010-06-14 22:26:10 +02004375 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
4376
Harald Welte6e0cd042009-09-12 13:05:33 +02004377 return CMD_SUCCESS;
4378}
4379
4380DEFUN(cfg_ts_arfcn_del,
4381 cfg_ts_arfcn_del_cmd,
4382 "hopping arfcn del <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02004383 HOPPING_STR "Configure hopping ARFCN list\n"
4384 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02004385{
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01004386 enum gsm_band unused;
Harald Welte6e0cd042009-09-12 13:05:33 +02004387 struct gsm_bts_trx_ts *ts = vty->index;
4388 int arfcn = atoi(argv[0]);
4389
Pau Espin Pedrol33ca6132018-11-16 14:12:31 +01004390 if (gsm_arfcn2band_rc(arfcn, &unused) < 0) {
4391 vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE);
4392 return CMD_WARNING;
4393 }
4394
Harald Weltea39b0f22010-06-14 22:26:10 +02004395 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
4396
Harald Welte6e0cd042009-09-12 13:05:33 +02004397 return CMD_SUCCESS;
4398}
4399
Harald Weltea6fd58e2009-08-07 00:25:23 +02004400DEFUN(cfg_ts_e1_subslot,
4401 cfg_ts_e1_subslot_cmd,
Harald Welte42581822009-08-08 16:12:58 +02004402 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004403 "E1/T1 channel connected to this on-air timeslot\n"
4404 "E1/T1 channel connected to this on-air timeslot\n"
4405 "E1/T1 line connected to this on-air timeslot\n"
Harald Welted13e0cd2012-08-17 09:52:03 +02004406 "E1/T1 timeslot connected to this on-air timeslot\n"
4407 "E1/T1 timeslot connected to this on-air timeslot\n"
Harald Weltecfaabbb2012-08-16 23:23:50 +02004408 "E1/T1 sub-slot connected to this on-air timeslot\n"
4409 "E1/T1 sub-slot 0 connected to this on-air timeslot\n"
4410 "E1/T1 sub-slot 1 connected to this on-air timeslot\n"
4411 "E1/T1 sub-slot 2 connected to this on-air timeslot\n"
4412 "E1/T1 sub-slot 3 connected to this on-air timeslot\n"
4413 "Full E1/T1 timeslot connected to this on-air timeslot\n")
Harald Weltea6fd58e2009-08-07 00:25:23 +02004414{
4415 struct gsm_bts_trx_ts *ts = vty->index;
4416
Harald Welte42581822009-08-08 16:12:58 +02004417 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Weltea6fd58e2009-08-07 00:25:23 +02004418
4419 return CMD_SUCCESS;
4420}
Harald Welte5258fc42009-03-28 19:07:53 +00004421
Stefan Sperling71d524c2018-05-17 14:38:27 +02004422int print_counter(struct rate_ctr_group *bsc_ctrs, struct rate_ctr *ctr, const struct rate_ctr_desc *desc, void *data)
4423{
4424 struct vty *vty = data;
4425 vty_out(vty, "%25s: %10"PRIu64" %s%s", desc->name, ctr->current, desc->description, VTY_NEWLINE);
4426 return 0;
4427}
4428
Harald Welte4f10c252010-05-16 21:47:13 +02004429void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
4430{
Stefan Sperling71d524c2018-05-17 14:38:27 +02004431 rate_ctr_for_each_counter(net->bsc_ctrs, print_counter, vty);
Harald Welte4f10c252010-05-16 21:47:13 +02004432}
4433
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02004434DEFUN(drop_bts,
4435 drop_bts_cmd,
Holger Hans Peter Freyther0586b0f2010-04-11 12:46:45 +02004436 "drop bts connection <0-65535> (oml|rsl)",
Harald Weltecfaabbb2012-08-16 23:23:50 +02004437 "Debug/Simulation command to drop Abis/IP BTS\n"
4438 "Debug/Simulation command to drop Abis/IP BTS\n"
4439 "Debug/Simulation command to drop Abis/IP BTS\n"
4440 "BTS NR\n" "Drop OML Connection\n" "Drop RSL Connection\n")
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02004441{
4442 struct gsm_network *gsmnet;
4443 struct gsm_bts_trx *trx;
4444 struct gsm_bts *bts;
4445 unsigned int bts_nr;
4446
4447 gsmnet = gsmnet_from_vty(vty);
4448
4449 bts_nr = atoi(argv[0]);
4450 if (bts_nr >= gsmnet->num_bts) {
4451 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
4452 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
4453 return CMD_WARNING;
4454 }
4455
4456 bts = gsm_bts_num(gsmnet, bts_nr);
4457 if (!bts) {
4458 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
4459 return CMD_WARNING;
4460 }
4461
4462 if (!is_ipaccess_bts(bts)) {
4463 vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
4464 return CMD_WARNING;
4465 }
4466
4467
4468 /* close all connections */
4469 if (strcmp(argv[1], "oml") == 0) {
Max45867372019-01-02 15:28:17 +01004470 ipaccess_drop_oml(bts, "vty");
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02004471 } else if (strcmp(argv[1], "rsl") == 0) {
4472 /* close all rsl connections */
4473 llist_for_each_entry(trx, &bts->trx_list, list) {
Max45867372019-01-02 15:28:17 +01004474 ipaccess_drop_rsl(trx, "vty");
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02004475 }
4476 } else {
4477 vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
4478 return CMD_WARNING;
4479 }
4480
4481 return CMD_SUCCESS;
4482}
4483
Holger Hans Peter Freyther740e65f2016-03-16 13:45:23 +01004484DEFUN(restart_bts, restart_bts_cmd,
4485 "restart-bts <0-65535>",
4486 "Restart ip.access nanoBTS through OML\n"
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01004487 BTS_NR_STR)
Holger Hans Peter Freyther740e65f2016-03-16 13:45:23 +01004488{
4489 struct gsm_network *gsmnet;
4490 struct gsm_bts_trx *trx;
4491 struct gsm_bts *bts;
4492 unsigned int bts_nr;
4493
4494 gsmnet = gsmnet_from_vty(vty);
4495
4496 bts_nr = atoi(argv[0]);
4497 if (bts_nr >= gsmnet->num_bts) {
4498 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
4499 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
4500 return CMD_WARNING;
4501 }
4502
4503 bts = gsm_bts_num(gsmnet, bts_nr);
4504 if (!bts) {
4505 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
4506 return CMD_WARNING;
4507 }
4508
4509 if (!is_ipaccess_bts(bts) || is_sysmobts_v2(bts)) {
4510 vty_out(vty, "This command only works for ipaccess nanoBTS.%s",
4511 VTY_NEWLINE);
4512 return CMD_WARNING;
4513 }
4514
4515 /* go from last TRX to c0 */
4516 llist_for_each_entry_reverse(trx, &bts->trx_list, list)
4517 abis_nm_ipaccess_restart(trx);
4518
4519 return CMD_SUCCESS;
4520}
4521
Harald Welte8e2e22f2017-07-10 20:25:10 +02004522DEFUN(bts_resend, bts_resend_cmd,
4523 "bts <0-255> resend-system-information",
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01004524 "BTS Specific Commands\n" BTS_NR_STR
Harald Welte8e2e22f2017-07-10 20:25:10 +02004525 "Re-generate + re-send BCCH SYSTEM INFORMATION\n")
4526{
4527 struct gsm_network *gsmnet;
4528 struct gsm_bts_trx *trx;
4529 struct gsm_bts *bts;
4530 unsigned int bts_nr;
4531
4532 gsmnet = gsmnet_from_vty(vty);
4533
4534 bts_nr = atoi(argv[0]);
4535 if (bts_nr >= gsmnet->num_bts) {
4536 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
4537 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
4538 return CMD_WARNING;
4539 }
4540
4541 bts = gsm_bts_num(gsmnet, bts_nr);
4542 if (!bts) {
4543 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
4544 return CMD_WARNING;
4545 }
4546
4547 llist_for_each_entry_reverse(trx, &bts->trx_list, list)
4548 gsm_bts_trx_set_system_infos(trx);
4549
4550 return CMD_SUCCESS;
4551}
4552
4553
Harald Welte30f1f372014-12-28 15:00:45 +01004554DEFUN(smscb_cmd, smscb_cmd_cmd,
Harald Welte228daad2019-05-21 23:37:09 +02004555 "bts <0-255> smscb-command (normal|schedule|default) <1-4> HEXSTRING",
Neels Hofmeyr70c5fd22018-01-19 15:55:14 +01004556 "BTS related commands\n" BTS_NR_STR
Harald Welte228daad2019-05-21 23:37:09 +02004557 "SMS Cell Broadcast\n"
4558 "Normal (one-shot) SMSCB Message; sent once over Abis+Um\n"
4559 "Schedule (one-shot) SMSCB Messag; sent once over Abis+Um\n"
4560 "Default (repeating) SMSCB Message; sent once over Abis, unlimited ovrer Um\n"
4561 "Last Valid Block\n"
Harald Welte30f1f372014-12-28 15:00:45 +01004562 "Hex Encoded SMSCB message (up to 88 octets)\n")
4563{
4564 struct gsm_bts *bts;
4565 int bts_nr = atoi(argv[0]);
Harald Welte228daad2019-05-21 23:37:09 +02004566 const char *type_str = argv[1];
4567 int last_block = atoi(argv[2]);
Harald Welte30f1f372014-12-28 15:00:45 +01004568 struct rsl_ie_cb_cmd_type cb_cmd;
4569 uint8_t buf[88];
4570 int rc;
4571
Neels Hofmeyrb90eabf2016-05-11 18:48:39 +02004572 bts = gsm_bts_num(gsmnet_from_vty(vty), bts_nr);
Harald Welte30f1f372014-12-28 15:00:45 +01004573 if (!bts) {
4574 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
4575 return CMD_WARNING;
4576 }
Harald Welte0bc53652018-09-09 14:50:59 +02004577 if (!gsm_bts_get_cbch(bts)) {
4578 vty_out(vty, "%% BTS %d doesn't have a CBCH%s", bts_nr, VTY_NEWLINE);
4579 return CMD_WARNING;
4580 }
Harald Welte228daad2019-05-21 23:37:09 +02004581 rc = osmo_hexparse(argv[3], buf, sizeof(buf));
Harald Welte30f1f372014-12-28 15:00:45 +01004582 if (rc < 0 || rc > sizeof(buf)) {
4583 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
4584 return CMD_WARNING;
4585 }
4586
4587 cb_cmd.spare = 0;
4588 cb_cmd.def_bcast = 0;
Harald Welte228daad2019-05-21 23:37:09 +02004589 if (!strcmp(type_str, "normal"))
4590 cb_cmd.command = RSL_CB_CMD_TYPE_NORMAL;
4591 else if (!strcmp(type_str, "schedule"))
4592 cb_cmd.command = RSL_CB_CMD_TYPE_SCHEDULE;
4593 else if (!strcmp(type_str, "default"))
4594 cb_cmd.command = RSL_CB_CMD_TYPE_DEFAULT;
4595 else {
4596 vty_out(vty, "Error parsing type%s", VTY_NEWLINE);
4597 return CMD_WARNING;
4598 }
Harald Welte30f1f372014-12-28 15:00:45 +01004599
4600 switch (last_block) {
4601 case 1:
4602 cb_cmd.last_block = RSL_CB_CMD_LASTBLOCK_1;
4603 break;
4604 case 2:
4605 cb_cmd.last_block = RSL_CB_CMD_LASTBLOCK_2;
4606 break;
4607 case 3:
4608 cb_cmd.last_block = RSL_CB_CMD_LASTBLOCK_3;
4609 break;
4610 case 4:
4611 cb_cmd.last_block = RSL_CB_CMD_LASTBLOCK_4;
4612 break;
Vadim Yanitskiy56dec0c2018-03-06 17:18:25 +07004613 default:
4614 vty_out(vty, "Error parsing LASTBLOCK%s", VTY_NEWLINE);
4615 return CMD_WARNING;
Harald Welte30f1f372014-12-28 15:00:45 +01004616 }
4617
Harald Welteae466852019-05-21 23:25:30 +02004618 rsl_sms_cb_command(bts, RSL_CHAN_SDCCH4_ACCH, cb_cmd, false, buf, rc);
Harald Welte30f1f372014-12-28 15:00:45 +01004619
4620 return CMD_SUCCESS;
4621}
4622
Harald Welte7fe00fb2017-05-27 14:09:50 +02004623/* resolve a gsm_bts_trx_ts basd on the given numeric identifiers */
Harald Welte645eb622017-05-27 15:52:58 +02004624static struct gsm_bts_trx_ts *vty_get_ts(struct vty *vty, const char *bts_str, const char *trx_str,
4625 const char *ts_str)
Harald Welte7fe00fb2017-05-27 14:09:50 +02004626{
Harald Welte645eb622017-05-27 15:52:58 +02004627 int bts_nr = atoi(bts_str);
4628 int trx_nr = atoi(trx_str);
4629 int ts_nr = atoi(ts_str);
Harald Welte7fe00fb2017-05-27 14:09:50 +02004630 struct gsm_bts *bts;
4631 struct gsm_bts_trx *trx;
4632 struct gsm_bts_trx_ts *ts;
4633
4634 bts = gsm_bts_num(gsmnet_from_vty(vty), bts_nr);
4635 if (!bts) {
4636 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
4637 return NULL;
4638 }
4639
4640 trx = gsm_bts_trx_num(bts, trx_nr);
4641 if (!trx) {
4642 vty_out(vty, "%% No such TRX (%d)%s", trx_nr, VTY_NEWLINE);
4643 return NULL;
4644 }
4645
4646 ts = &trx->ts[ts_nr];
4647
4648 return ts;
4649}
Harald Welte30f1f372014-12-28 15:00:45 +01004650
Harald Welted0d2b0b2010-12-23 13:18:07 +01004651DEFUN(pdch_act, pdch_act_cmd,
4652 "bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
Harald Welte0bfd8d92018-02-12 18:06:53 +01004653 BTS_NR_TRX_TS_STR2
4654 "Packet Data Channel\n"
Harald Welted0d2b0b2010-12-23 13:18:07 +01004655 "Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
4656 "Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
4657{
Harald Welted0d2b0b2010-12-23 13:18:07 +01004658 struct gsm_bts_trx_ts *ts;
Harald Welted0d2b0b2010-12-23 13:18:07 +01004659 int activate;
4660
Harald Welte645eb622017-05-27 15:52:58 +02004661 ts = vty_get_ts(vty, argv[0], argv[1], argv[2]);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004662 if (!ts || !ts->fi || ts->fi->state == TS_ST_NOT_INITIALIZED || ts->fi->state == TS_ST_BORKEN) {
4663 vty_out(vty, "%% Timeslot is not usable%s", VTY_NEWLINE);
Harald Welted0d2b0b2010-12-23 13:18:07 +01004664 return CMD_WARNING;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004665 }
Harald Welted0d2b0b2010-12-23 13:18:07 +01004666
Harald Welte7fe00fb2017-05-27 14:09:50 +02004667 if (!is_ipaccess_bts(ts->trx->bts)) {
Harald Welted0d2b0b2010-12-23 13:18:07 +01004668 vty_out(vty, "%% This command only works for ipaccess BTS%s",
4669 VTY_NEWLINE);
4670 return CMD_WARNING;
4671 }
4672
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004673 if (ts->pchan_on_init != GSM_PCHAN_TCH_F_TCH_H_PDCH
4674 && ts->pchan_on_init != GSM_PCHAN_TCH_F_PDCH) {
4675 vty_out(vty, "%% Timeslot %u is not dynamic TCH/F_TCH/H_PDCH or TCH/F_PDCH%s",
4676 ts->nr, VTY_NEWLINE);
Harald Welted0d2b0b2010-12-23 13:18:07 +01004677 return CMD_WARNING;
4678 }
4679
4680 if (!strcmp(argv[3], "activate"))
4681 activate = 1;
4682 else
4683 activate = 0;
4684
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004685 if (activate && ts->fi->state != TS_ST_UNUSED) {
4686 vty_out(vty, "%% Timeslot %u is still in use%s",
4687 ts->nr, VTY_NEWLINE);
4688 return CMD_WARNING;
4689 } else if (!activate && ts->fi->state != TS_ST_PDCH) {
4690 vty_out(vty, "%% Timeslot %u is not in PDCH mode%s",
4691 ts->nr, VTY_NEWLINE);
4692 return CMD_WARNING;
4693 }
4694
4695 LOG_TS(ts, LOGL_NOTICE, "telnet VTY user asks to %s\n", activate ? "PDCH ACT" : "PDCH DEACT");
4696 ts->pdch_act_allowed = activate;
4697 osmo_fsm_inst_state_chg(ts->fi, activate ? TS_ST_WAIT_PDCH_ACT : TS_ST_WAIT_PDCH_DEACT, 4, 0);
Harald Welted0d2b0b2010-12-23 13:18:07 +01004698
4699 return CMD_SUCCESS;
4700
4701}
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02004702
Harald Welte2abd5e12017-05-27 14:10:40 +02004703/* configure the lchan for a single AMR mode (as specified) */
Stefan Sperling42f59d52018-11-06 14:24:56 +01004704static int lchan_set_single_amr_mode(struct vty *vty, struct gsm_lchan *lchan, uint8_t amr_mode)
Harald Welte2abd5e12017-05-27 14:10:40 +02004705{
4706 struct amr_multirate_conf mr;
4707 struct gsm48_multi_rate_conf *mr_conf;
Stefan Sperling42f59d52018-11-06 14:24:56 +01004708 int rc, vty_rc = CMD_SUCCESS;
Harald Welte2abd5e12017-05-27 14:10:40 +02004709 mr_conf = (struct gsm48_multi_rate_conf *) &mr.gsm48_ie;
4710
4711 if (amr_mode > 7)
4712 return -1;
4713
4714 memset(&mr, 0, sizeof(mr));
4715 mr_conf->ver = 1;
4716 /* bit-mask of supported modes, only one bit is set. Reflects
4717 * Figure 10.5.2.47a where there are no thershold and only a
4718 * single mode */
4719 mr.gsm48_ie[1] = 1 << amr_mode;
4720
4721 mr.ms_mode[0].mode = amr_mode;
4722 mr.bts_mode[0].mode = amr_mode;
Philipp Maier3b9dcb32018-10-22 14:21:57 +02004723 mr.num_modes = 1;
Harald Welte2abd5e12017-05-27 14:10:40 +02004724
4725 /* encode this configuration into the lchan for both uplink and
4726 * downlink direction */
Stefan Sperling42f59d52018-11-06 14:24:56 +01004727 rc = gsm48_multirate_config(lchan->mr_ms_lv, mr_conf, mr.ms_mode, mr.num_modes);
4728 if (rc != 0) {
4729 vty_out(vty,
4730 "Invalid AMR multirate configuration (%s, amr mode %d, ms) - check parameters%s",
4731 gsm_lchant_name(lchan->type), amr_mode, VTY_NEWLINE);
4732 vty_rc = CMD_WARNING;
4733 }
4734 rc = gsm48_multirate_config(lchan->mr_bts_lv, mr_conf, mr.bts_mode, mr.num_modes);
4735 if (rc != 0) {
4736 vty_out(vty,
4737 "Invalid AMR multirate configuration (%s, amr mode %d, bts) - check parameters%s",
4738 gsm_lchant_name(lchan->type), amr_mode, VTY_NEWLINE);
4739 vty_rc = CMD_WARNING;
4740 }
Harald Welte2abd5e12017-05-27 14:10:40 +02004741
Stefan Sperling42f59d52018-11-06 14:24:56 +01004742 return vty_rc;
Harald Welte2abd5e12017-05-27 14:10:40 +02004743}
4744
4745/* Debug/Measurement command to activate a given logical channel
4746 * manually in a given mode/codec. This is useful for receiver
4747 * performance testing (FER/RBER/...) */
4748DEFUN(lchan_act, lchan_act_cmd,
4749 "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> (activate|deactivate) (hr|fr|efr|amr) [<0-7>]",
Harald Welte0bfd8d92018-02-12 18:06:53 +01004750 BTS_NR_TRX_TS_SS_STR2
Harald Welte2abd5e12017-05-27 14:10:40 +02004751 "Manual Channel Activation (e.g. for BER test)\n"
4752 "Manual Channel Deactivation (e.g. for BER test)\n"
4753 "Half-Rate v1\n" "Full-Rate\n" "Enhanced Full Rate\n" "Adaptive Multi-Rate\n" "AMR Mode\n")
4754{
4755 struct gsm_bts_trx_ts *ts;
4756 struct gsm_lchan *lchan;
4757 int ss_nr = atoi(argv[3]);
4758 const char *act_str = argv[4];
4759 const char *codec_str = argv[5];
4760 int activate;
4761
4762 ts = vty_get_ts(vty, argv[0], argv[1], argv[2]);
4763 if (!ts)
4764 return CMD_WARNING;
4765
4766 lchan = &ts->lchan[ss_nr];
4767
4768 if (!strcmp(act_str, "activate"))
4769 activate = 1;
4770 else
4771 activate = 0;
4772
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004773 /* FIXME: allow dynamic channels with switchover, lchan_activate(lchan, FOR_VTY) */
4774 if (ss_nr >= pchan_subslots(ts->pchan_is)) {
4775 vty_out(vty, "%% subslot index %d too large for physical channel %s (%u slots)%s",
4776 ss_nr, gsm_pchan_name(ts->pchan_is), pchan_subslots(ts->pchan_is),
4777 VTY_NEWLINE);
Harald Welte2abd5e12017-05-27 14:10:40 +02004778 return CMD_WARNING;
4779 }
4780
4781 if (activate) {
4782 int lchan_t;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004783 if (lchan->fi->state != LCHAN_ST_UNUSED) {
Harald Welte2abd5e12017-05-27 14:10:40 +02004784 vty_out(vty, "%% Cannot activate: Channel busy!%s", VTY_NEWLINE);
4785 return CMD_WARNING;
4786 }
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004787 lchan_t = gsm_lchan_type_by_pchan(ts->pchan_is);
Harald Welte2abd5e12017-05-27 14:10:40 +02004788 if (lchan_t < 0)
4789 return CMD_WARNING;
4790 /* configure the lchan */
4791 lchan->type = lchan_t;
4792 lchan->rsl_cmode = RSL_CMOD_SPD_SPEECH;
4793 if (!strcmp(codec_str, "hr") || !strcmp(codec_str, "fr"))
4794 lchan->tch_mode = GSM48_CMODE_SPEECH_V1;
4795 else if (!strcmp(codec_str, "efr"))
4796 lchan->tch_mode = GSM48_CMODE_SPEECH_EFR;
4797 else if (!strcmp(codec_str, "amr")) {
Stefan Sperling42f59d52018-11-06 14:24:56 +01004798 int amr_mode, vty_rc;
Harald Welte2abd5e12017-05-27 14:10:40 +02004799 if (argc < 7) {
4800 vty_out(vty, "%% AMR requires specification of AMR mode%s", VTY_NEWLINE);
4801 return CMD_WARNING;
4802 }
4803 amr_mode = atoi(argv[6]);
4804 lchan->tch_mode = GSM48_CMODE_SPEECH_AMR;
Stefan Sperling42f59d52018-11-06 14:24:56 +01004805 vty_rc = lchan_set_single_amr_mode(vty, lchan, amr_mode);
4806 if (vty_rc != CMD_SUCCESS)
4807 return vty_rc;
Harald Welte2abd5e12017-05-27 14:10:40 +02004808 }
4809 vty_out(vty, "%% activating lchan %s%s", gsm_lchan_name(lchan), VTY_NEWLINE);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004810 rsl_tx_chan_activ(lchan, RSL_ACT_TYPE_INITIAL, 0);
4811 rsl_tx_ipacc_crcx(lchan);
Harald Welte2abd5e12017-05-27 14:10:40 +02004812 } else {
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004813 if (!lchan->fi) {
4814 vty_out(vty, "%% Cannot release: Channel not initialized%s", VTY_NEWLINE);
4815 return CMD_WARNING;
4816 }
4817 vty_out(vty, "%% Asking for release of %s in state %s%s", gsm_lchan_name(lchan),
4818 osmo_fsm_inst_state_name(lchan->fi), VTY_NEWLINE);
Neels Hofmeyr5b1a7d12018-11-06 22:24:07 +01004819 lchan_release(lchan, !!(lchan->conn), false, 0);
Harald Welte2abd5e12017-05-27 14:10:40 +02004820 }
4821
4822 return CMD_SUCCESS;
4823}
4824
Philipp Maierfad4bbc2019-01-28 16:28:42 +01004825/* Debug command to send lchans from state LCHAN_ST_UNUSED to state
4826 * LCHAN_ST_BORKEN and vice versa. */
4827DEFUN_HIDDEN(lchan_set_borken, lchan_set_borken_cmd,
4828 "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> (borken|unused)",
4829 BTS_NR_TRX_TS_SS_STR2
4830 "send lchan to state LCHAN_ST_BORKEN (for debugging)\n"
4831 "send lchan to state LCHAN_ST_UNUSED (for debugging)\n")
4832{
4833 struct gsm_bts_trx_ts *ts;
4834 struct gsm_lchan *lchan;
4835 int ss_nr = atoi(argv[3]);
4836 ts = vty_get_ts(vty, argv[0], argv[1], argv[2]);
4837 if (!ts)
4838 return CMD_WARNING;
Philipp Maierbb66d102019-01-22 11:29:06 +01004839
Philipp Maierfad4bbc2019-01-28 16:28:42 +01004840 lchan = &ts->lchan[ss_nr];
4841 if (!lchan->fi)
4842 return CMD_WARNING;
4843
4844 if (!strcmp(argv[4], "borken")) {
4845 if (lchan->fi->state == LCHAN_ST_UNUSED)
4846 osmo_fsm_inst_state_chg(lchan->fi, LCHAN_ST_BORKEN, 0, 0);
4847 else {
4848 vty_out(vty,
4849 "%% lchan is in state %s, only lchans that are in state %s may be moved to state %s manually%s",
4850 osmo_fsm_state_name(lchan->fi->fsm, lchan->fi->state),
4851 osmo_fsm_state_name(lchan->fi->fsm, LCHAN_ST_UNUSED),
4852 osmo_fsm_state_name(lchan->fi->fsm, LCHAN_ST_BORKEN), VTY_NEWLINE);
4853 return CMD_WARNING;
4854 }
4855 } else {
4856 if (lchan->fi->state == LCHAN_ST_BORKEN)
4857 osmo_fsm_inst_state_chg(lchan->fi, LCHAN_ST_UNUSED, 0, 0);
4858 else {
4859 vty_out(vty,
4860 "%% lchan is in state %s, only lchans that are in state %s may be moved to state %s manually%s",
4861 osmo_fsm_state_name(lchan->fi->fsm, lchan->fi->state),
4862 osmo_fsm_state_name(lchan->fi->fsm, LCHAN_ST_BORKEN),
4863 osmo_fsm_state_name(lchan->fi->fsm, LCHAN_ST_UNUSED), VTY_NEWLINE);
4864 return CMD_WARNING;
4865 }
4866 }
4867
4868 return CMD_SUCCESS;
4869}
4870
Harald Welte3f86c522017-05-27 15:53:28 +02004871DEFUN(lchan_mdcx, lchan_mdcx_cmd,
4872 "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> mdcx A.B.C.D <0-65535>",
Harald Welte0bfd8d92018-02-12 18:06:53 +01004873 BTS_NR_TRX_TS_SS_STR2
Harald Welte3f86c522017-05-27 15:53:28 +02004874 "Modify RTP Connection\n" "MGW IP Address\n" "MGW UDP Port\n")
4875{
4876 struct gsm_bts_trx_ts *ts;
4877 struct gsm_lchan *lchan;
4878 int ss_nr = atoi(argv[3]);
4879 int port = atoi(argv[5]);
4880 struct in_addr ia;
4881 inet_aton(argv[4], &ia);
4882
4883 ts = vty_get_ts(vty, argv[0], argv[1], argv[2]);
4884 if (!ts)
4885 return CMD_WARNING;
4886
4887 lchan = &ts->lchan[ss_nr];
4888
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004889 if (ss_nr >= pchan_subslots(ts->pchan_is)) {
4890 vty_out(vty, "%% subslot index %d too large for physical channel %s (%u slots)%s",
4891 ss_nr, gsm_pchan_name(ts->pchan_is), pchan_subslots(ts->pchan_is),
4892 VTY_NEWLINE);
Harald Welte3f86c522017-05-27 15:53:28 +02004893 return CMD_WARNING;
4894 }
4895
4896 vty_out(vty, "%% connecting RTP of %s to %s:%u%s", gsm_lchan_name(lchan),
4897 inet_ntoa(ia), port, VTY_NEWLINE);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02004898 lchan->abis_ip.connect_ip = ia.s_addr;
4899 lchan->abis_ip.connect_port = port;
4900 rsl_tx_ipacc_mdcx(lchan);
Harald Welte3f86c522017-05-27 15:53:28 +02004901 return CMD_SUCCESS;
4902}
Harald Welteb71147a2017-07-18 19:11:49 +02004903
4904DEFUN(ctrl_trap, ctrl_trap_cmd,
4905 "ctrl-interface generate-trap TRAP VALUE",
4906 "Commands related to the CTRL Interface\n"
4907 "Generate a TRAP for test purpose\n"
4908 "Identity/Name of the TRAP variable\n"
4909 "Value of the TRAP variable\n")
4910{
4911 struct gsm_network *net = gsmnet_from_vty(vty);
4912
4913 ctrl_cmd_send_trap(net->ctrl, argv[0], (char *) argv[1]);
4914 return CMD_SUCCESS;
4915}
4916
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004917#define NETWORK_STR "Configure the GSM network\n"
4918#define CODE_CMD_STR "Code commands\n"
4919#define NAME_CMD_STR "Name Commands\n"
4920#define NAME_STR "Name to use\n"
4921
4922DEFUN(cfg_net,
4923 cfg_net_cmd,
4924 "network", NETWORK_STR)
4925{
4926 vty->index = gsmnet_from_vty(vty);
4927 vty->node = GSMNET_NODE;
4928
4929 return CMD_SUCCESS;
4930}
4931
4932DEFUN(cfg_net_ncc,
4933 cfg_net_ncc_cmd,
4934 "network country code <1-999>",
4935 "Set the GSM network country code\n"
4936 "Country commands\n"
4937 CODE_CMD_STR
4938 "Network Country Code to use\n")
4939{
4940 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Neels Hofmeyrf93970b2018-03-05 02:09:40 +01004941 uint16_t mcc;
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004942
Neels Hofmeyrf93970b2018-03-05 02:09:40 +01004943 if (osmo_mcc_from_str(argv[0], &mcc)) {
4944 vty_out(vty, "%% Error decoding MCC: %s%s", argv[0], VTY_NEWLINE);
4945 return CMD_WARNING;
4946 }
4947
4948 gsmnet->plmn.mcc = mcc;
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004949
4950 return CMD_SUCCESS;
4951}
4952
4953DEFUN(cfg_net_mnc,
4954 cfg_net_mnc_cmd,
4955 "mobile network code <0-999>",
4956 "Set the GSM mobile network code\n"
4957 "Network Commands\n"
4958 CODE_CMD_STR
4959 "Mobile Network Code to use\n")
4960{
4961 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Neels Hofmeyrf93970b2018-03-05 02:09:40 +01004962 uint16_t mnc;
4963 bool mnc_3_digits;
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004964
Neels Hofmeyrf93970b2018-03-05 02:09:40 +01004965 if (osmo_mnc_from_str(argv[0], &mnc, &mnc_3_digits)) {
4966 vty_out(vty, "%% Error decoding MNC: %s%s", argv[0], VTY_NEWLINE);
4967 return CMD_WARNING;
4968 }
4969
4970 gsmnet->plmn.mnc = mnc;
4971 gsmnet->plmn.mnc_3_digits = mnc_3_digits;
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004972
4973 return CMD_SUCCESS;
4974}
4975
4976DEFUN(cfg_net_encryption,
4977 cfg_net_encryption_cmd,
Harald Welte51e4bf32017-12-23 17:30:18 +01004978 "encryption a5 <0-3> [<0-3>] [<0-3>] [<0-3>]",
4979 "Encryption options\n"
4980 "GSM A5 Air Interface Encryption\n"
4981 "A5/n Algorithm Number\n"
4982 "A5/n Algorithm Number\n"
4983 "A5/n Algorithm Number\n"
4984 "A5/n Algorithm Number\n")
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004985{
4986 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte51e4bf32017-12-23 17:30:18 +01004987 unsigned int i;
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004988
Harald Welte51e4bf32017-12-23 17:30:18 +01004989 gsmnet->a5_encryption_mask = 0;
4990 for (i = 0; i < argc; i++)
4991 gsmnet->a5_encryption_mask |= (1 << atoi(argv[i]));
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004992
4993 return CMD_SUCCESS;
4994}
4995
Neels Hofmeyr78faf702018-05-10 05:22:50 +02004996DEFUN_DEPRECATED(cfg_net_dyn_ts_allow_tch_f,
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01004997 cfg_net_dyn_ts_allow_tch_f_cmd,
4998 "dyn_ts_allow_tch_f (0|1)",
4999 "Allow or disallow allocating TCH/F on TCH_F_TCH_H_PDCH timeslots\n"
5000 "Disallow TCH/F on TCH_F_TCH_H_PDCH (default)\n"
5001 "Allow TCH/F on TCH_F_TCH_H_PDCH\n")
5002{
5003 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
5004 gsmnet->dyn_ts_allow_tch_f = atoi(argv[0]) ? true : false;
Neels Hofmeyr78faf702018-05-10 05:22:50 +02005005 vty_out(vty, "%% dyn_ts_allow_tch_f is deprecated, rather use msc/codec-list to pick codecs%s",
5006 VTY_NEWLINE);
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01005007 return CMD_SUCCESS;
5008}
5009
5010DEFUN(cfg_net_timezone,
5011 cfg_net_timezone_cmd,
5012 "timezone <-19-19> (0|15|30|45)",
5013 "Set the Timezone Offset of the network\n"
5014 "Timezone offset (hours)\n"
5015 "Timezone offset (00 minutes)\n"
5016 "Timezone offset (15 minutes)\n"
5017 "Timezone offset (30 minutes)\n"
5018 "Timezone offset (45 minutes)\n"
5019 )
5020{
5021 struct gsm_network *net = vty->index;
5022 int tzhr = atoi(argv[0]);
5023 int tzmn = atoi(argv[1]);
5024
5025 net->tz.hr = tzhr;
5026 net->tz.mn = tzmn;
5027 net->tz.dst = 0;
5028 net->tz.override = 1;
5029
5030 return CMD_SUCCESS;
5031}
5032
5033DEFUN(cfg_net_timezone_dst,
5034 cfg_net_timezone_dst_cmd,
5035 "timezone <-19-19> (0|15|30|45) <0-2>",
5036 "Set the Timezone Offset of the network\n"
5037 "Timezone offset (hours)\n"
5038 "Timezone offset (00 minutes)\n"
5039 "Timezone offset (15 minutes)\n"
5040 "Timezone offset (30 minutes)\n"
5041 "Timezone offset (45 minutes)\n"
5042 "DST offset (hours)\n"
5043 )
5044{
5045 struct gsm_network *net = vty->index;
5046 int tzhr = atoi(argv[0]);
5047 int tzmn = atoi(argv[1]);
5048 int tzdst = atoi(argv[2]);
5049
5050 net->tz.hr = tzhr;
5051 net->tz.mn = tzmn;
5052 net->tz.dst = tzdst;
5053 net->tz.override = 1;
5054
5055 return CMD_SUCCESS;
5056}
5057
5058DEFUN(cfg_net_no_timezone,
5059 cfg_net_no_timezone_cmd,
5060 "no timezone",
5061 NO_STR
5062 "Disable network timezone override, use system tz\n")
5063{
5064 struct gsm_network *net = vty->index;
5065
5066 net->tz.override = 0;
5067
5068 return CMD_SUCCESS;
5069}
5070
5071DEFUN(cfg_net_per_loc_upd, cfg_net_per_loc_upd_cmd,
5072 "periodic location update <6-1530>",
5073 "Periodic Location Updating Interval\n"
5074 "Periodic Location Updating Interval\n"
5075 "Periodic Location Updating Interval\n"
5076 "Periodic Location Updating Interval in Minutes\n")
5077{
5078 struct gsm_network *net = vty->index;
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01005079 struct osmo_tdef *d = osmo_tdef_get_entry(net->T_defs, 3212);
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01005080
Neels Hofmeyr596c4022018-06-16 19:29:50 +02005081 OSMO_ASSERT(d);
5082 d->val = atoi(argv[0]) / 6;
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01005083 vty_out(vty, "T%d = %lu %s (%s)%s", d->T, d->val, "* 6min", d->desc, VTY_NEWLINE);
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01005084 return CMD_SUCCESS;
5085}
5086
5087DEFUN(cfg_net_no_per_loc_upd, cfg_net_no_per_loc_upd_cmd,
5088 "no periodic location update",
5089 NO_STR
5090 "Periodic Location Updating Interval\n"
5091 "Periodic Location Updating Interval\n"
5092 "Periodic Location Updating Interval\n")
5093{
5094 struct gsm_network *net = vty->index;
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01005095 struct osmo_tdef *d = osmo_tdef_get_entry(net->T_defs, 3212);
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01005096
Neels Hofmeyr596c4022018-06-16 19:29:50 +02005097 OSMO_ASSERT(d);
5098 d->val = 0;
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01005099 vty_out(vty, "T%d = %lu %s (%s)%s", d->T, d->val, "* 6min", d->desc, VTY_NEWLINE);
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01005100 return CMD_SUCCESS;
5101}
5102
Neels Hofmeyrf28f1ef2018-04-20 15:53:53 +02005103#define MEAS_FEED_STR "Measurement Report export\n"
5104
5105DEFUN(cfg_net_meas_feed_dest, cfg_net_meas_feed_dest_cmd,
5106 "meas-feed destination ADDR <0-65535>",
5107 MEAS_FEED_STR "Where to forward Measurement Report feeds\n" "address or hostname\n" "port number\n")
5108{
5109 int rc;
5110 const char *host = argv[0];
5111 uint16_t port = atoi(argv[1]);
5112
5113 rc = meas_feed_cfg_set(host, port);
5114 if (rc < 0)
5115 return CMD_WARNING;
5116
5117 return CMD_SUCCESS;
5118}
5119
5120DEFUN(cfg_net_meas_feed_scenario, cfg_net_meas_feed_scenario_cmd,
5121 "meas-feed scenario NAME",
5122 MEAS_FEED_STR "Set a name to include in the Measurement Report feeds\n" "Name string, up to 31 characters\n")
5123{
5124 meas_feed_scenario_set(argv[0]);
5125
5126 return CMD_SUCCESS;
5127}
5128
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01005129DEFUN(show_timer, show_timer_cmd,
5130 "show timer " OSMO_TDEF_VTY_ARG_T_OPTIONAL,
5131 SHOW_STR "Show timers\n"
5132 OSMO_TDEF_VTY_DOC_T)
5133{
5134 struct gsm_network *net = gsmnet_from_vty(vty);
5135 const char *T_arg = argc > 0 ? argv[0] : NULL;
5136 return osmo_tdef_vty_show_cmd(vty, net->T_defs, T_arg, NULL);
5137}
5138
5139DEFUN(cfg_net_timer, cfg_net_timer_cmd,
5140 "timer " OSMO_TDEF_VTY_ARG_SET_OPTIONAL,
5141 "Configure or show timers\n"
5142 OSMO_TDEF_VTY_DOC_SET)
5143{
5144 struct gsm_network *net = gsmnet_from_vty(vty);
5145 /* If any arguments are missing, redirect to 'show' */
5146 if (argc < 2)
5147 return show_timer(self, vty, argc, argv);
5148 return osmo_tdef_vty_set_cmd(vty, net->T_defs, argv);
5149}
5150
Harald Weltedcccb182010-05-16 20:52:23 +02005151extern int bsc_vty_init_extra(void);
Holger Hans Peter Freythere1ffc082010-04-10 00:08:28 +02005152
Maxdb0e3802017-01-12 19:35:11 +01005153int bsc_vty_init(struct gsm_network *network)
Harald Welte68628e82009-03-10 12:17:57 +00005154{
Harald Welte4ab9d7c2012-08-17 12:42:06 +02005155 cfg_ts_pchan_cmd.string =
5156 vty_cmd_string_from_valstr(tall_bsc_ctx,
5157 gsm_pchant_names,
5158 "phys_chan_config (", "|", ")",
5159 VTY_DO_LOWER);
5160 cfg_ts_pchan_cmd.doc =
5161 vty_cmd_string_from_valstr(tall_bsc_ctx,
5162 gsm_pchant_descs,
5163 "Physical Channel Combination\n",
5164 "\n", "", 0);
5165
Harald Weltee555c2b2012-08-17 13:02:12 +02005166 cfg_bts_type_cmd.string =
5167 vty_cmd_string_from_valstr(tall_bsc_ctx,
5168 bts_type_names,
5169 "type (", "|", ")",
5170 VTY_DO_LOWER);
5171 cfg_bts_type_cmd.doc =
5172 vty_cmd_string_from_valstr(tall_bsc_ctx,
5173 bts_type_descs,
5174 "BTS Vendor/Type\n",
5175 "\n", "", 0);
5176
Neels Hofmeyr6dd5a9b2018-02-14 00:06:19 +01005177 OSMO_ASSERT(vty_global_gsm_network == NULL);
5178 vty_global_gsm_network = network;
5179
5180 osmo_stats_vty_add_cmds();
5181
5182 install_element(CONFIG_NODE, &cfg_net_cmd);
5183 install_node(&net_node, config_write_net);
5184 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
5185 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
5186 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
5187 install_element(GSMNET_NODE, &cfg_net_timezone_cmd);
5188 install_element(GSMNET_NODE, &cfg_net_timezone_dst_cmd);
5189 install_element(GSMNET_NODE, &cfg_net_no_timezone_cmd);
5190 install_element(GSMNET_NODE, &cfg_net_per_loc_upd_cmd);
5191 install_element(GSMNET_NODE, &cfg_net_no_per_loc_upd_cmd);
5192 install_element(GSMNET_NODE, &cfg_net_dyn_ts_allow_tch_f_cmd);
Neels Hofmeyrf28f1ef2018-04-20 15:53:53 +02005193 install_element(GSMNET_NODE, &cfg_net_meas_feed_dest_cmd);
5194 install_element(GSMNET_NODE, &cfg_net_meas_feed_scenario_cmd);
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01005195 install_element(GSMNET_NODE, &cfg_net_timer_cmd);
Harald Weltee555c2b2012-08-17 13:02:12 +02005196
Neels Hofmeyrea11bf82016-05-12 01:53:23 +02005197 install_element_ve(&bsc_show_net_cmd);
Harald Welteb4d5b172010-05-12 16:10:35 +00005198 install_element_ve(&show_bts_cmd);
Oliver Smith8d8d7102018-10-23 15:35:43 +02005199 install_element_ve(&show_rejected_bts_cmd);
Harald Welteb4d5b172010-05-12 16:10:35 +00005200 install_element_ve(&show_trx_cmd);
Max6f379ba2018-11-19 14:05:04 +01005201 install_element_ve(&show_trx_con_cmd);
Harald Welteb4d5b172010-05-12 16:10:35 +00005202 install_element_ve(&show_ts_cmd);
5203 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08005204 install_element_ve(&show_lchan_summary_cmd);
Philipp Maier761fa132019-01-22 10:25:05 +01005205 install_element_ve(&show_lchan_summary_all_cmd);
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01005206 install_element_ve(&show_timer_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00005207
Philipp Maier39f62bb2017-04-09 12:32:51 +02005208 install_element_ve(&show_subscr_conn_cmd);
Philipp Maier39f62bb2017-04-09 12:32:51 +02005209
Harald Welteb4d5b172010-05-12 16:10:35 +00005210 install_element_ve(&show_paging_cmd);
Holger Hans Peter Freytherec37bb22013-02-05 09:39:09 +01005211 install_element_ve(&show_paging_group_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00005212
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02005213 install_element(ENABLE_NODE, &handover_any_cmd);
5214 install_element(ENABLE_NODE, &assignment_any_cmd);
5215 install_element(ENABLE_NODE, &handover_any_to_arfcn_bsic_cmd);
5216
Maxdb0e3802017-01-12 19:35:11 +01005217 logging_vty_add_cmds(NULL);
Harald Welte2f4f4b82018-02-14 00:50:27 +01005218 osmo_talloc_vty_add_cmds();
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +01005219
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01005220 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +08005221 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08005222 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
Neels Hofmeyre25018b2017-11-27 21:29:33 +01005223 /* See also handover commands added on net level from handover_vty.c */
Harald Welte5013b2a2009-08-07 13:29:14 +02005224
5225 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02005226 install_node(&bts_node, config_write_bts);
Harald Welte5258fc42009-03-28 19:07:53 +00005227 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02005228 install_element(BTS_NODE, &cfg_description_cmd);
5229 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02005230 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02005231 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Maxc08ee712016-05-11 12:45:13 +02005232 install_element(BTS_NODE, &cfg_bts_dtxu_cmd);
5233 install_element(BTS_NODE, &cfg_bts_dtxd_cmd);
5234 install_element(BTS_NODE, &cfg_bts_no_dtxu_cmd);
5235 install_element(BTS_NODE, &cfg_bts_no_dtxd_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00005236 install_element(BTS_NODE, &cfg_bts_lac_cmd);
5237 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte42581822009-08-08 16:12:58 +02005238 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00005239 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte8b291802013-03-12 13:57:05 +01005240 install_element(BTS_NODE, &cfg_bts_rsl_ip_cmd);
Sylvain Munautc9519462011-10-17 14:04:55 +02005241 install_element(BTS_NODE, &cfg_bts_nokia_site_skip_reset_cmd);
Andreas Eversberg7d8fa342013-12-05 13:25:06 +01005242 install_element(BTS_NODE, &cfg_bts_nokia_site_no_loc_rel_cnf_cmd);
Sipos Csaba56e17662015-02-07 13:27:36 +01005243 install_element(BTS_NODE, &cfg_bts_nokia_site_bts_reset_timer_cnf_cmd);
Harald Welte8175e952009-10-20 00:22:00 +02005244 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte42581822009-08-08 16:12:58 +02005245 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
5246 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02005247 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01005248 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
5249 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Andreas Eversberg2ee7ecd2012-10-13 07:27:47 +02005250 install_element(BTS_NODE, &cfg_bts_chan_desc_att_cmd);
5251 install_element(BTS_NODE, &cfg_bts_chan_desc_bs_pa_mfrms_cmd);
5252 install_element(BTS_NODE, &cfg_bts_chan_desc_bs_ag_blks_res_cmd);
Harald Welte15400252019-05-24 11:56:23 +02005253 install_element(BTS_NODE, &cfg_bts_ccch_load_ind_thresh_cmd);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08005254 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
5255 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02005256 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08005257 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Ivan Kluchnikov67920592013-09-16 13:13:04 +04005258 install_element(BTS_NODE, &cfg_bts_rach_ac_class_cmd);
Harald Welte (local)0e451d02009-08-13 10:14:26 +02005259 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte73225282009-12-12 18:17:25 +01005260 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
5261 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Sylvain Munaute0b06b02010-11-28 18:17:28 +01005262 install_element(BTS_NODE, &cfg_bts_cell_bar_qualify_cmd);
5263 install_element(BTS_NODE, &cfg_bts_cell_resel_ofs_cmd);
5264 install_element(BTS_NODE, &cfg_bts_temp_ofs_cmd);
5265 install_element(BTS_NODE, &cfg_bts_temp_ofs_inf_cmd);
5266 install_element(BTS_NODE, &cfg_bts_penalty_time_cmd);
5267 install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
Andreas Eversberg4d4944a2013-03-10 11:49:35 +01005268 install_element(BTS_NODE, &cfg_bts_radio_link_timeout_cmd);
Harald Welte2f8b9d22017-06-18 11:12:13 +03005269 install_element(BTS_NODE, &cfg_bts_radio_link_timeout_inf_cmd);
Harald Welte4511d892010-04-18 15:51:20 +02005270 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
bhargava350533c2016-07-21 11:14:34 +05305271 install_element(BTS_NODE, &cfg_bts_gprs_11bit_rach_support_for_egprs_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02005272 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08005273 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +01005274 install_element(BTS_NODE, &cfg_bts_gprs_net_ctrl_ord_cmd);
Max292ec582016-07-28 11:55:37 +02005275 install_element(BTS_NODE, &cfg_bts_gprs_ctrl_ack_cmd);
5276 install_element(BTS_NODE, &cfg_no_bts_gprs_ctrl_ack_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08005277 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02005278 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Weltea5731cf2010-03-22 11:48:36 +08005279 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08005280 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welteaf387632010-03-14 23:30:30 +08005281 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
5282 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
5283 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +08005284 install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
Harald Welte9fbff4a2010-07-30 11:50:09 +02005285 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
5286 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Pau Espin Pedrol1cf21de2018-12-05 13:38:10 +01005287 install_element(BTS_NODE, &cfg_bts_si_unused_send_empty_cmd);
5288 install_element(BTS_NODE, &cfg_bts_no_si_unused_send_empty_cmd);
Harald Welte42def722017-01-13 00:10:32 +01005289 install_element(BTS_NODE, &cfg_bts_early_cm_cmd);
Pau Espin Pedrole8dda5f2017-11-23 19:06:09 +01005290 install_element(BTS_NODE, &cfg_bts_early_cm_3g_cmd);
Harald Welte32c09622011-01-11 23:44:56 +01005291 install_element(BTS_NODE, &cfg_bts_neigh_mode_cmd);
5292 install_element(BTS_NODE, &cfg_bts_neigh_cmd);
Harald Welte64c07d22011-02-15 11:43:27 +01005293 install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd);
Max59a1bf32016-04-15 16:04:46 +02005294 install_element(BTS_NODE, &cfg_bts_si2quater_neigh_add_cmd);
5295 install_element(BTS_NODE, &cfg_bts_si2quater_neigh_del_cmd);
Max26679e02016-04-20 15:57:13 +02005296 install_element(BTS_NODE, &cfg_bts_si2quater_uarfcn_add_cmd);
5297 install_element(BTS_NODE, &cfg_bts_si2quater_uarfcn_del_cmd);
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +02005298 install_element(BTS_NODE, &cfg_bts_excl_rf_lock_cmd);
5299 install_element(BTS_NODE, &cfg_bts_no_excl_rf_lock_cmd);
Jacob Erlbeck65d114f2014-01-16 11:02:14 +01005300 install_element(BTS_NODE, &cfg_bts_force_comb_si_cmd);
5301 install_element(BTS_NODE, &cfg_bts_no_force_comb_si_cmd);
Andreas Eversberga83d5112013-12-07 18:32:28 +01005302 install_element(BTS_NODE, &cfg_bts_codec0_cmd);
5303 install_element(BTS_NODE, &cfg_bts_codec1_cmd);
5304 install_element(BTS_NODE, &cfg_bts_codec2_cmd);
5305 install_element(BTS_NODE, &cfg_bts_codec3_cmd);
5306 install_element(BTS_NODE, &cfg_bts_codec4_cmd);
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +01005307 install_element(BTS_NODE, &cfg_bts_depends_on_cmd);
5308 install_element(BTS_NODE, &cfg_bts_no_depends_on_cmd);
Andreas Eversberg73266522014-01-19 11:47:44 +01005309 install_element(BTS_NODE, &cfg_bts_amr_fr_modes1_cmd);
5310 install_element(BTS_NODE, &cfg_bts_amr_fr_modes2_cmd);
5311 install_element(BTS_NODE, &cfg_bts_amr_fr_modes3_cmd);
5312 install_element(BTS_NODE, &cfg_bts_amr_fr_modes4_cmd);
5313 install_element(BTS_NODE, &cfg_bts_amr_fr_thres1_cmd);
5314 install_element(BTS_NODE, &cfg_bts_amr_fr_thres2_cmd);
5315 install_element(BTS_NODE, &cfg_bts_amr_fr_thres3_cmd);
5316 install_element(BTS_NODE, &cfg_bts_amr_fr_hyst1_cmd);
5317 install_element(BTS_NODE, &cfg_bts_amr_fr_hyst2_cmd);
5318 install_element(BTS_NODE, &cfg_bts_amr_fr_hyst3_cmd);
5319 install_element(BTS_NODE, &cfg_bts_amr_fr_start_mode_cmd);
5320 install_element(BTS_NODE, &cfg_bts_amr_hr_modes1_cmd);
5321 install_element(BTS_NODE, &cfg_bts_amr_hr_modes2_cmd);
5322 install_element(BTS_NODE, &cfg_bts_amr_hr_modes3_cmd);
5323 install_element(BTS_NODE, &cfg_bts_amr_hr_modes4_cmd);
5324 install_element(BTS_NODE, &cfg_bts_amr_hr_thres1_cmd);
5325 install_element(BTS_NODE, &cfg_bts_amr_hr_thres2_cmd);
5326 install_element(BTS_NODE, &cfg_bts_amr_hr_thres3_cmd);
5327 install_element(BTS_NODE, &cfg_bts_amr_hr_hyst1_cmd);
5328 install_element(BTS_NODE, &cfg_bts_amr_hr_hyst2_cmd);
5329 install_element(BTS_NODE, &cfg_bts_amr_hr_hyst3_cmd);
5330 install_element(BTS_NODE, &cfg_bts_amr_hr_start_mode_cmd);
Harald Welte8254cf72017-05-29 13:42:19 +02005331 install_element(BTS_NODE, &cfg_bts_pcu_sock_cmd);
Stefan Sperling6442e432018-02-06 14:44:54 +01005332 install_element(BTS_NODE, &cfg_bts_acc_ramping_cmd);
5333 install_element(BTS_NODE, &cfg_bts_no_acc_ramping_cmd);
5334 install_element(BTS_NODE, &cfg_bts_acc_ramping_step_interval_cmd);
5335 install_element(BTS_NODE, &cfg_bts_acc_ramping_step_size_cmd);
Pau Espin Pedrol1b963342018-11-07 14:19:32 +01005336 install_element(BTS_NODE, &cfg_bts_t3113_dynamic_cmd);
5337 install_element(BTS_NODE, &cfg_bts_no_t3113_dynamic_cmd);
Neels Hofmeyr19bed232018-03-22 04:54:57 +01005338 neighbor_ident_vty_init(network, network->neighbor_bss_cells);
Neels Hofmeyre25018b2017-11-27 21:29:33 +01005339 /* See also handover commands added on bts level from handover_vty.c */
Harald Welte68628e82009-03-10 12:17:57 +00005340
Harald Welte5258fc42009-03-28 19:07:53 +00005341 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00005342 install_node(&trx_node, dummy_config_write);
Harald Welte5258fc42009-03-28 19:07:53 +00005343 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02005344 install_element(TRX_NODE, &cfg_description_cmd);
5345 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)7b37d972009-12-27 20:56:38 +01005346 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02005347 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte42581822009-08-08 16:12:58 +02005348 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
5349 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01005350 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00005351
Harald Welte5258fc42009-03-28 19:07:53 +00005352 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00005353 install_node(&ts_node, dummy_config_write);
Harald Weltea6fd58e2009-08-07 00:25:23 +02005354 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Welte4ab9d7c2012-08-17 12:42:06 +02005355 install_element(TS_NODE, &cfg_ts_pchan_compat_cmd);
Harald Welte135a6482011-05-30 12:09:13 +02005356 install_element(TS_NODE, &cfg_ts_tsc_cmd);
Harald Weltea39b0f22010-06-14 22:26:10 +02005357 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte6e0cd042009-09-12 13:05:33 +02005358 install_element(TS_NODE, &cfg_ts_hsn_cmd);
5359 install_element(TS_NODE, &cfg_ts_maio_cmd);
5360 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
5361 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Weltea6fd58e2009-08-07 00:25:23 +02005362 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00005363
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02005364 install_element(ENABLE_NODE, &drop_bts_cmd);
Holger Hans Peter Freyther740e65f2016-03-16 13:45:23 +01005365 install_element(ENABLE_NODE, &restart_bts_cmd);
Harald Welte8e2e22f2017-07-10 20:25:10 +02005366 install_element(ENABLE_NODE, &bts_resend_cmd);
Harald Welted0d2b0b2010-12-23 13:18:07 +01005367 install_element(ENABLE_NODE, &pdch_act_cmd);
Harald Welte2abd5e12017-05-27 14:10:40 +02005368 install_element(ENABLE_NODE, &lchan_act_cmd);
Harald Welte3f86c522017-05-27 15:53:28 +02005369 install_element(ENABLE_NODE, &lchan_mdcx_cmd);
Philipp Maierfad4bbc2019-01-28 16:28:42 +01005370 install_element(ENABLE_NODE, &lchan_set_borken_cmd);
5371
Harald Welteb22dcb82018-02-12 17:57:57 +01005372 install_element(ENABLE_NODE, &handover_subscr_conn_cmd);
5373 install_element(ENABLE_NODE, &assignment_subscr_conn_cmd);
Harald Welte30f1f372014-12-28 15:00:45 +01005374 install_element(ENABLE_NODE, &smscb_cmd_cmd);
Harald Welteb71147a2017-07-18 19:11:49 +02005375 install_element(ENABLE_NODE, &ctrl_trap_cmd);
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02005376
Harald Welte81c9b9c2010-05-31 16:40:40 +02005377 abis_nm_vty_init();
Harald Weltee1d5eca2011-02-12 14:42:59 +01005378 abis_om2k_vty_init();
Harald Welte3016d9f2011-02-05 13:54:41 +01005379 e1inp_vty_init();
Harald Welte42def722017-01-13 00:10:32 +01005380 osmo_fsm_vty_add_cmds();
Harald Welte81c9b9c2010-05-31 16:40:40 +02005381
Neels Hofmeyre25018b2017-11-27 21:29:33 +01005382 ho_vty_init();
5383
Harald Weltedcccb182010-05-16 20:52:23 +02005384 bsc_vty_init_extra();
Harald Welte40f82892009-05-23 17:31:39 +00005385
Harald Welte68628e82009-03-10 12:17:57 +00005386 return 0;
5387}