blob: 75ef880b67c2be457e03bd3003dd276a1c048fa3 [file] [log] [blame]
Harald Welte59b04682009-06-10 05:40:52 +08001/* OpenBSC interface to quagga VTY */
Harald Welte410575a2010-03-14 23:30:30 +08002/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welte59b04682009-06-10 05:40:52 +08003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte0e3e88e2011-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 Welte59b04682009-06-10 05:40:52 +08008 * (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 Welte0e3e88e2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Harald Welte59b04682009-06-10 05:40:52 +080014 *
Harald Welte0e3e88e2011-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 Welte59b04682009-06-10 05:40:52 +080017 *
18 */
19
20#include <stdlib.h>
21#include <unistd.h>
Harald Welte59b04682009-06-10 05:40:52 +080022
Harald Weltebd9591f2010-05-19 19:45:32 +020023#include <osmocom/vty/command.h>
24#include <osmocom/vty/buffer.h>
25#include <osmocom/vty/vty.h>
26#include <osmocom/vty/logging.h>
27#include <osmocom/vty/telnet_interface.h>
Harald Welte2addf852012-08-17 12:42:06 +020028#include <osmocom/vty/misc.h>
Harald Welte59b04682009-06-10 05:40:52 +080029
30#include <arpa/inet.h>
31
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010032#include <osmocom/core/linuxlist.h>
Harald Welte59b04682009-06-10 05:40:52 +080033#include <openbsc/gsm_data.h>
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +020034#include <osmocom/abis/e1_input.h>
Harald Welte59b04682009-06-10 05:40:52 +080035#include <openbsc/abis_nm.h>
Harald Welte30f93fb2011-02-19 16:48:17 +010036#include <openbsc/abis_om2000.h>
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010037#include <osmocom/core/utils.h>
38#include <osmocom/gsm/gsm_utils.h>
Harald Welte73e69942011-05-23 20:42:26 +020039#include <osmocom/gsm/abis_nm.h>
Harald Weltefe96f382009-12-22 13:09:29 +010040#include <openbsc/chan_alloc.h>
Harald Welte44007742009-12-22 21:43:14 +010041#include <openbsc/meas_rep.h>
Harald Welte59b04682009-06-10 05:40:52 +080042#include <openbsc/db.h>
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010043#include <osmocom/core/talloc.h>
Holger Hans Peter Freytherb70d45b2010-04-06 11:55:37 +020044#include <openbsc/vty.h>
Harald Weltecfb6b282012-06-16 14:59:56 +080045#include <osmocom/gprs/gprs_ns.h>
Harald Welted8acf142010-07-30 11:50:09 +020046#include <openbsc/system_information.h>
Harald Welte682ee5f2010-05-16 22:02:16 +020047#include <openbsc/debug.h>
Holger Hans Peter Freyther25176f12010-11-09 17:00:42 +010048#include <openbsc/paging.h>
Harald Welte64fcd772011-08-20 18:25:02 +020049#include <openbsc/ipaccess.h>
Harald Welte5213e992010-12-23 13:18:07 +010050#include <openbsc/abis_rsl.h>
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +010051#include <openbsc/osmo_msc_data.h>
52#include <openbsc/osmo_bsc_rf.h>
Harald Welte59b04682009-06-10 05:40:52 +080053
Harald Welted9dea592011-03-04 13:53:51 +010054#include "../../bscconfig.h"
Harald Welte10c29f62010-05-16 19:20:24 +020055
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +020056
57#define NETWORK_STR "Configure the GSM network\n"
58#define CODE_CMD_STR "Code commands\n"
59#define NAME_CMD_STR "Name Commands\n"
60#define NAME_STR "Name to use\n"
61#define LCHAN_NR_STR "Logical Channel Number\n"
62
63
Harald Welted6b62e32010-05-12 17:19:53 +000064/* FIXME: this should go to some common file */
65static const struct value_string gprs_ns_timer_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020066 { 0, "tns-block" },
67 { 1, "tns-block-retries" },
68 { 2, "tns-reset" },
69 { 3, "tns-reset-retries" },
70 { 4, "tns-test" },
71 { 5, "tns-alive" },
72 { 6, "tns-alive-retries" },
73 { 0, NULL }
74};
75
Harald Welted6b62e32010-05-12 17:19:53 +000076static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020077 { 0, "blocking-timer" },
78 { 1, "blocking-retries" },
79 { 2, "unblocking-retries" },
80 { 3, "reset-timer" },
81 { 4, "reset-retries" },
82 { 5, "suspend-timer" },
83 { 6, "suspend-retries" },
84 { 7, "resume-timer" },
85 { 8, "resume-retries" },
86 { 9, "capability-update-timer" },
87 { 10, "capability-update-retries" },
88 { 0, NULL }
89};
90
Harald Weltef989b782011-02-15 11:43:27 +010091static const struct value_string bts_neigh_mode_strs[] = {
92 { NL_MODE_AUTOMATIC, "automatic" },
93 { NL_MODE_MANUAL, "manual" },
94 { NL_MODE_MANUAL_SI5SEP, "manual-si5" },
95 { 0, NULL }
96};
97
Harald Weltee87eb462009-08-07 13:29:14 +020098struct cmd_node net_node = {
99 GSMNET_NODE,
Harald Welte45362bb2012-08-17 13:16:10 +0200100 "%s(config-net)# ",
Harald Weltee87eb462009-08-07 13:29:14 +0200101 1,
102};
103
Harald Welte59b04682009-06-10 05:40:52 +0800104struct cmd_node bts_node = {
105 BTS_NODE,
Harald Welte45362bb2012-08-17 13:16:10 +0200106 "%s(config-net-bts)# ",
Harald Welte59b04682009-06-10 05:40:52 +0800107 1,
108};
109
110struct cmd_node trx_node = {
111 TRX_NODE,
Harald Welte45362bb2012-08-17 13:16:10 +0200112 "%s(config-net-bts-trx)# ",
Harald Welte59b04682009-06-10 05:40:52 +0800113 1,
114};
115
116struct cmd_node ts_node = {
117 TS_NODE,
Harald Welte45362bb2012-08-17 13:16:10 +0200118 "%s(config-net-bts-trx-ts)# ",
Harald Welte59b04682009-06-10 05:40:52 +0800119 1,
120};
121
Harald Welte61daf6d2010-05-27 13:39:40 +0200122extern struct gsm_network *bsc_gsmnet;
123
Harald Welte40152872010-05-16 20:52:23 +0200124struct gsm_network *gsmnet_from_vty(struct vty *v)
125{
Harald Welte61daf6d2010-05-27 13:39:40 +0200126 /* In case we read from the config file, the vty->priv cannot
127 * point to a struct telnet_connection, and thus conn->priv
128 * will not point to the gsm_network structure */
129#if 0
Harald Welte40152872010-05-16 20:52:23 +0200130 struct telnet_connection *conn = v->priv;
131 return (struct gsm_network *) conn->priv;
Harald Welte61daf6d2010-05-27 13:39:40 +0200132#else
133 return bsc_gsmnet;
134#endif
Harald Welte40152872010-05-16 20:52:23 +0200135}
136
Harald Welte59b04682009-06-10 05:40:52 +0800137static int dummy_config_write(struct vty *v)
138{
139 return CMD_SUCCESS;
140}
141
142static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
143{
144 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
Harald Welte306a8892011-05-23 20:30:39 +0200145 abis_nm_opstate_name(nms->operational), nms->administrative,
146 abis_nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800147}
148
Harald Weltefe96f382009-12-22 13:09:29 +0100149static void dump_pchan_load_vty(struct vty *vty, char *prefix,
150 const struct pchan_load *pl)
151{
152 int i;
153
154 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
155 const struct load_counter *lc = &pl->pchan[i];
156 unsigned int percent;
157
158 if (lc->total == 0)
159 continue;
160
161 percent = (lc->used * 100) / lc->total;
162
163 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
164 gsm_pchan_name(i), percent, lc->used, lc->total,
165 VTY_NEWLINE);
166 }
167}
168
Harald Welte59b04682009-06-10 05:40:52 +0800169static void net_dump_vty(struct vty *vty, struct gsm_network *net)
170{
Harald Weltefe96f382009-12-22 13:09:29 +0100171 struct pchan_load pl;
172
Harald Welte59b04682009-06-10 05:40:52 +0800173 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
174 "and has %u BTS%s", net->country_code, net->network_code,
175 net->num_bts, VTY_NEWLINE);
176 vty_out(vty, " Long network name: '%s'%s",
177 net->name_long, VTY_NEWLINE);
178 vty_out(vty, " Short network name: '%s'%s",
179 net->name_short, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200180 vty_out(vty, " Authentication policy: %s%s",
181 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100182 vty_out(vty, " Location updating reject cause: %u%s",
183 net->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900184 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
185 VTY_NEWLINE);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +0100186 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
187 VTY_NEWLINE);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800188 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
189 VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100190 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
191 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100192 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
193 VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100194 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
195 VTY_NEWLINE);
Harald Weltefe96f382009-12-22 13:09:29 +0100196 network_chan_load(&pl, net);
197 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
198 dump_pchan_load_vty(vty, " ", &pl);
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +0100199
200 /* show rf */
Holger Hans Peter Freyther4d614172011-08-15 15:53:00 +0200201 if (net->bsc_data && net->bsc_data->rf_ctrl)
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +0100202 vty_out(vty, " Last RF Command: %s%s",
Holger Hans Peter Freyther4d614172011-08-15 15:53:00 +0200203 net->bsc_data->rf_ctrl->last_state_command,
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +0100204 VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800205}
206
207DEFUN(show_net, show_net_cmd, "show network",
208 SHOW_STR "Display information about a GSM NETWORK\n")
209{
Harald Welte40152872010-05-16 20:52:23 +0200210 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800211 net_dump_vty(vty, net);
212
213 return CMD_SUCCESS;
214}
215
216static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
217{
218 struct e1inp_line *line;
219
220 if (!e1l) {
221 vty_out(vty, " None%s", VTY_NEWLINE);
222 return;
223 }
224
225 line = e1l->ts->line;
226
227 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
228 line->num, line->driver->name, e1l->ts->num,
229 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
230 vty_out(vty, " E1 TEI %u, SAPI %u%s",
231 e1l->tei, e1l->sapi, VTY_NEWLINE);
232}
233
234static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
235{
Harald Weltefe96f382009-12-22 13:09:29 +0100236 struct pchan_load pl;
237
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200238 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200239 "BSIC %u, TSC %u and %u TRX%s",
240 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200241 bts->cell_identity,
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200242 bts->location_area_code, bts->bsic, bts->tsc,
Harald Welte91afe4c2009-06-20 18:15:19 +0200243 bts->num_trx, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200244 vty_out(vty, "Description: %s%s",
245 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte8e9d1792009-12-12 15:38:16 +0100246 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100247 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte8e9d1792009-12-12 15:38:16 +0100248 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
249 VTY_NEWLINE);
250 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welteb761bf82009-12-12 18:17:25 +0100251 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100252 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
253 VTY_NEWLINE);
254 vty_out(vty, "RACH Max transmissions: %u%s",
255 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
256 VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100257 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200258 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Andreas Eversberg14e12f22012-10-13 07:27:47 +0200259 vty_out(vty, "Channel Description Attachment: %s%s",
260 (bts->si_common.chan_desc.att) ? "yes" : "no", VTY_NEWLINE);
261 vty_out(vty, "Channel Description BS-PA-MFRMS: %u%s",
262 bts->si_common.chan_desc.bs_pa_mfrms + 2, VTY_NEWLINE);
263 vty_out(vty, "Channel Description BS-AG_BLKS-RES: %u%s",
264 bts->si_common.chan_desc.bs_ag_blks_res, VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200265 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
266 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800267 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200268 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800269 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200270 bts->oml_tei, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100271 else if (bts->type == GSM_BTS_TYPE_HSL_FEMTO)
272 vty_out(vty, " Serial Number: %lu%s", bts->hsl.serno, VTY_NEWLINE);
Sylvain Munautcb8e8432011-10-17 14:04:55 +0200273 else if (bts->type == GSM_BTS_TYPE_NOKIA_SITE)
274 vty_out(vty, " Skip Reset: %d%s",
275 bts->nokia.skip_reset, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800276 vty_out(vty, " NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200277 net_dump_nmstate(vty, &bts->mo.nm_state);
Harald Welte59b04682009-06-10 05:40:52 +0800278 vty_out(vty, " Site Mgr NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200279 net_dump_nmstate(vty, &bts->site_mgr.mo.nm_state);
Holger Hans Peter Freyther914ff192011-04-26 15:52:34 +0200280 vty_out(vty, " Paging: %u pending requests, %u free slots%s",
281 paging_pending_requests_nr(bts),
Harald Welte59b04682009-06-10 05:40:52 +0800282 bts->paging.available_slots, VTY_NEWLINE);
Holger Hans Peter Freytherb5c79c92010-11-25 16:28:45 +0100283 if (is_ipaccess_bts(bts)) {
284 vty_out(vty, " OML Link state: %s.%s",
285 bts->oml_link ? "connected" : "disconnected", VTY_NEWLINE);
286 } else {
Harald Welte25572872009-10-20 00:22:00 +0200287 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
288 e1isl_dump_vty(vty, bts->oml_link);
289 }
Holger Hans Peter Freytherb5c79c92010-11-25 16:28:45 +0100290
291 /* FIXME: chan_desc */
Harald Weltefe96f382009-12-22 13:09:29 +0100292 memset(&pl, 0, sizeof(pl));
293 bts_chan_load(&pl, bts);
294 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
295 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800296}
297
Sylvain Munaut1ad96282012-12-28 12:15:11 +0100298DEFUN(show_bts, show_bts_cmd, "show bts [<0-255>]",
Harald Welte59b04682009-06-10 05:40:52 +0800299 SHOW_STR "Display information about a BTS\n"
300 "BTS number")
301{
Harald Welte40152872010-05-16 20:52:23 +0200302 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800303 int bts_nr;
304
305 if (argc != 0) {
306 /* use the BTS number that the user has specified */
307 bts_nr = atoi(argv[0]);
Harald Welteda5db862010-12-24 12:24:03 +0100308 if (bts_nr >= net->num_bts) {
Harald Welte59b04682009-06-10 05:40:52 +0800309 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
310 VTY_NEWLINE);
311 return CMD_WARNING;
312 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200313 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800314 return CMD_SUCCESS;
315 }
316 /* print all BTS's */
317 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200318 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800319
320 return CMD_SUCCESS;
321}
322
Harald Welte62868882009-08-08 16:12:58 +0200323/* utility functions */
324static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
325 const char *ts, const char *ss)
326{
327 e1_link->e1_nr = atoi(line);
328 e1_link->e1_ts = atoi(ts);
329 if (!strcmp(ss, "full"))
330 e1_link->e1_ts_ss = 255;
331 else
332 e1_link->e1_ts_ss = atoi(ss);
333}
334
335static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
336 const char *prefix)
337{
338 if (!e1_link->e1_ts)
339 return;
340
341 if (e1_link->e1_ts_ss == 255)
342 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
343 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
344 else
345 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
346 prefix, e1_link->e1_nr, e1_link->e1_ts,
347 e1_link->e1_ts_ss, VTY_NEWLINE);
348}
349
350
Harald Welte97ceef92009-08-06 19:06:46 +0200351static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
352{
Harald Welte62868882009-08-08 16:12:58 +0200353 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
Harald Welte85771a42011-05-30 12:09:13 +0200354 if (ts->tsc != -1 && ts->tsc != ts->trx->bts->tsc)
355 vty_out(vty, " training_sequence_code %u%s", ts->tsc, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200356 if (ts->pchan != GSM_PCHAN_NONE)
357 vty_out(vty, " phys_chan_config %s%s",
358 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200359 vty_out(vty, " hopping enabled %u%s",
360 ts->hopping.enabled, VTY_NEWLINE);
361 if (ts->hopping.enabled) {
362 unsigned int i;
363 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200364 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200365 vty_out(vty, " hopping maio %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200366 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200367 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
368 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
369 continue;
370 vty_out(vty, " hopping arfcn add %u%s",
371 i, VTY_NEWLINE);
372 }
Harald Welteff598092010-12-24 12:07:07 +0100373 }
Harald Welte62868882009-08-08 16:12:58 +0200374 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Weltec02789e2011-02-14 16:15:21 +0100375
376 if (ts->trx->bts->model->config_write_ts)
377 ts->trx->bts->model->config_write_ts(vty, ts);
Harald Welte97ceef92009-08-06 19:06:46 +0200378}
379
380static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
381{
382 int i;
383
Harald Weltee87eb462009-08-07 13:29:14 +0200384 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200385 if (trx->description)
386 vty_out(vty, " description %s%s", trx->description,
387 VTY_NEWLINE);
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200388 vty_out(vty, " rf_locked %u%s",
Harald Welte69f6f812011-05-30 12:07:53 +0200389 trx->mo.nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200390 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200391 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +0100392 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200393 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200394 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
395 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200396
Harald Weltec02789e2011-02-14 16:15:21 +0100397 if (trx->bts->model->config_write_trx)
398 trx->bts->model->config_write_trx(vty, trx);
399
Harald Welte97ceef92009-08-06 19:06:46 +0200400 for (i = 0; i < TRX_NR_TS; i++)
401 config_write_ts_single(vty, &trx->ts[i]);
402}
403
Harald Weltea9251762010-05-11 23:50:21 +0200404static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
405{
406 unsigned int i;
407 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
408 VTY_NEWLINE);
409 if (bts->gprs.mode == BTS_GPRS_NONE)
410 return;
411
412 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
413 VTY_NEWLINE);
414 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
415 VTY_NEWLINE);
416 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
417 vty_out(vty, " gprs cell timer %s %u%s",
418 get_value_string(gprs_bssgp_cfg_strs, i),
419 bts->gprs.cell.timer[i], VTY_NEWLINE);
420 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
421 VTY_NEWLINE);
422 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
423 vty_out(vty, " gprs ns timer %s %u%s",
424 get_value_string(gprs_ns_timer_strs, i),
425 bts->gprs.nse.timer[i], VTY_NEWLINE);
426 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
427 struct gsm_bts_gprs_nsvc *nsvc =
428 &bts->gprs.nsvc[i];
429 struct in_addr ia;
430
431 ia.s_addr = htonl(nsvc->remote_ip);
432 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
433 nsvc->nsvci, VTY_NEWLINE);
434 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
435 nsvc->local_port, VTY_NEWLINE);
436 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
437 nsvc->remote_port, VTY_NEWLINE);
438 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
439 inet_ntoa(ia), VTY_NEWLINE);
440 }
441}
442
Harald Welte97ceef92009-08-06 19:06:46 +0200443static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
444{
445 struct gsm_bts_trx *trx;
Harald Welted8acf142010-07-30 11:50:09 +0200446 int i;
Harald Welte97ceef92009-08-06 19:06:46 +0200447
Harald Weltee87eb462009-08-07 13:29:14 +0200448 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
449 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200450 if (bts->description)
451 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200452 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freyther6d82b7c2009-11-19 16:38:49 +0100453 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200454 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200455 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200456 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
457 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte5c3abf92012-07-08 16:48:11 +0200458 if (bts->tz.override != 0)
459 vty_out(vty, " timezone %d %d%s", bts->tz.hr, bts->tz.mn, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200460 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100461 vty_out(vty, " cell reselection hysteresis %u%s",
462 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
463 vty_out(vty, " rxlev access min %u%s",
464 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Sylvain Munaut00d71462010-11-28 18:17:28 +0100465
466 if (bts->si_common.cell_ro_sel_par.present) {
467 struct gsm48_si_selection_params *sp;
468 sp = &bts->si_common.cell_ro_sel_par;
469
470 if (sp->cbq)
471 vty_out(vty, " cell bar qualify %u%s",
472 sp->cbq, VTY_NEWLINE);
473
474 if (sp->cell_resel_off)
475 vty_out(vty, " cell reselection offset %u%s",
476 sp->cell_resel_off*2, VTY_NEWLINE);
477
478 if (sp->temp_offs == 7)
479 vty_out(vty, " temporary offset infinite%s",
480 VTY_NEWLINE);
481 else if (sp->temp_offs)
482 vty_out(vty, " temporary offset %u%s",
483 sp->temp_offs*10, VTY_NEWLINE);
484
485 if (sp->penalty_time == 31)
486 vty_out(vty, " penalty time reserved%s",
487 VTY_NEWLINE);
488 else if (sp->penalty_time)
489 vty_out(vty, " penalty time %u%s",
490 (sp->penalty_time*20)+20, VTY_NEWLINE);
491 }
492
Harald Weltea54a2bb2009-12-01 18:04:30 +0530493 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200494 vty_out(vty, " periodic location update %u%s",
Dieter Spaarb0f746d2010-10-05 21:10:55 +0200495 bts->si_common.chan_desc.t3212 * 6, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200496 vty_out(vty, " channel allocator %s%s",
497 bts->chan_alloc_reverse ? "descending" : "ascending",
498 VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100499 vty_out(vty, " rach tx integer %u%s",
500 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
501 vty_out(vty, " rach max transmission %u%s",
502 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
503 VTY_NEWLINE);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800504
Andreas Eversberg14e12f22012-10-13 07:27:47 +0200505 vty_out(vty, " channel-descrption attach %u%s",
506 bts->si_common.chan_desc.att, VTY_NEWLINE);
507 vty_out(vty, " channel-descrption bs-pa-mfrms %u%s",
508 bts->si_common.chan_desc.bs_pa_mfrms + 2, VTY_NEWLINE);
509 vty_out(vty, " channel-descrption bs-ag-blks-res %u%s",
510 bts->si_common.chan_desc.bs_ag_blks_res, VTY_NEWLINE);
511
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800512 if (bts->rach_b_thresh != -1)
513 vty_out(vty, " rach nm busy threshold %u%s",
514 bts->rach_b_thresh, VTY_NEWLINE);
515 if (bts->rach_ldavg_slots != -1)
516 vty_out(vty, " rach nm load average %u%s",
517 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100518 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200519 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +0800520 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
521 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200522 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
523 if (bts->si_mode_static & (1 << i)) {
524 vty_out(vty, " system-information %s mode static%s",
525 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
526 vty_out(vty, " system-information %s static %s%s",
527 get_value_string(osmo_sitype_strs, i),
Sylvain Munaut79eae142011-11-13 23:05:23 +0100528 osmo_hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
Harald Welted8acf142010-07-30 11:50:09 +0200529 VTY_NEWLINE);
530 }
531 }
Harald Welte08011e22011-03-04 13:41:31 +0100532 switch (bts->type) {
533 case GSM_BTS_TYPE_NANOBTS:
Harald Welte35ac0e42012-07-02 19:51:55 +0200534 case GSM_BTS_TYPE_OSMO_SYSMO:
Harald Weltee87eb462009-08-07 13:29:14 +0200535 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200536 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +0200537 vty_out(vty, " oml ip.access stream_id %u line %u%s",
538 bts->oml_tei, bts->oml_e1_link.e1_nr, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100539 break;
540 case GSM_BTS_TYPE_HSL_FEMTO:
541 vty_out(vty, " hsl serial-number %lu%s", bts->hsl.serno, VTY_NEWLINE);
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +0200542 vty_out(vty, " oml hsl line %u%s",
543 bts->oml_e1_link.e1_nr, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100544 break;
Sylvain Munautcb8e8432011-10-17 14:04:55 +0200545 case GSM_BTS_TYPE_NOKIA_SITE:
546 vty_out(vty, " nokia_site skip-reset %d%s", bts->nokia.skip_reset, VTY_NEWLINE);
547 break;
Harald Welte08011e22011-03-04 13:41:31 +0100548 default:
Harald Welte62868882009-08-08 16:12:58 +0200549 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
550 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100551 break;
Harald Welte62868882009-08-08 16:12:58 +0200552 }
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +0800553
554 /* if we have a limit, write it */
555 if (bts->paging.free_chans_need >= 0)
556 vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
557
Harald Welteca46eff2011-01-11 23:44:56 +0100558 vty_out(vty, " neighbor-list mode %s%s",
Harald Weltef989b782011-02-15 11:43:27 +0100559 get_value_string(bts_neigh_mode_strs, bts->neigh_list_manual_mode), VTY_NEWLINE);
560 if (bts->neigh_list_manual_mode != NL_MODE_AUTOMATIC) {
Harald Welteca46eff2011-01-11 23:44:56 +0100561 for (i = 0; i < 1024; i++) {
562 if (bitvec_get_bit_pos(&bts->si_common.neigh_list, i))
563 vty_out(vty, " neighbor-list add arfcn %u%s",
564 i, VTY_NEWLINE);
565 }
566 }
Harald Weltef989b782011-02-15 11:43:27 +0100567 if (bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) {
568 for (i = 0; i < 1024; i++) {
569 if (bitvec_get_bit_pos(&bts->si_common.si5_neigh_list, i))
570 vty_out(vty, " si5 neighbor-list add arfcn %u%s",
571 i, VTY_NEWLINE);
572 }
573 }
Harald Welteca46eff2011-01-11 23:44:56 +0100574
Harald Weltea9251762010-05-11 23:50:21 +0200575 config_write_bts_gprs(vty, bts);
Harald Welte97ceef92009-08-06 19:06:46 +0200576
Harald Weltec02789e2011-02-14 16:15:21 +0100577 if (bts->model->config_write_bts)
578 bts->model->config_write_bts(vty, bts);
579
Harald Welte97ceef92009-08-06 19:06:46 +0200580 llist_for_each_entry(trx, &bts->trx_list, list)
581 config_write_trx_single(vty, trx);
582}
583
584static int config_write_bts(struct vty *v)
585{
Harald Welte40152872010-05-16 20:52:23 +0200586 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte97ceef92009-08-06 19:06:46 +0200587 struct gsm_bts *bts;
588
589 llist_for_each_entry(bts, &gsmnet->bts_list, list)
590 config_write_bts_single(v, bts);
591
592 return CMD_SUCCESS;
593}
594
Harald Weltee87eb462009-08-07 13:29:14 +0200595static int config_write_net(struct vty *vty)
596{
Harald Welte40152872010-05-16 20:52:23 +0200597 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
598
Harald Weltee87eb462009-08-07 13:29:14 +0200599 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200600 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200601 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200602 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
603 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200604 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100605 vty_out(vty, " location updating reject cause %u%s",
606 gsmnet->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900607 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freyther6b4f5462009-11-19 16:37:48 +0100608 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800609 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100610 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
611 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100612 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100613 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Weltea8062f12009-12-21 16:51:50 +0100614 vty_out(vty, " handover window rxlev averaging %u%s",
615 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
616 vty_out(vty, " handover window rxqual averaging %u%s",
617 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
618 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
619 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
620 vty_out(vty, " handover power budget interval %u%s",
621 gsmnet->handover.pwr_interval, VTY_NEWLINE);
622 vty_out(vty, " handover power budget hysteresis %u%s",
623 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
624 vty_out(vty, " handover maximum distance %u%s",
625 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +0100626 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100627 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
628 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
629 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
630 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
631 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
632 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
633 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
634 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
635 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
Harald Weltea00fdd72010-12-23 14:39:29 +0100636 vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100637 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Weltef41bfd52010-12-15 15:34:23 +0100638 vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +0100639 vty_out(vty, " subscriber-keep-in-ram %d%s",
640 gsmnet->keep_subscr, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200641
642 return CMD_SUCCESS;
643}
Harald Welte97ceef92009-08-06 19:06:46 +0200644
Harald Welte59b04682009-06-10 05:40:52 +0800645static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
646{
647 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
648 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200649 vty_out(vty, "Description: %s%s",
650 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200651 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200652 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200653 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200654 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800655 vty_out(vty, " NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200656 net_dump_nmstate(vty, &trx->mo.nm_state);
Harald Welte59b04682009-06-10 05:40:52 +0800657 vty_out(vty, " Baseband Transceiver NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200658 net_dump_nmstate(vty, &trx->bb_transc.mo.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200659 if (is_ipaccess_bts(trx->bts)) {
660 vty_out(vty, " ip.access stream ID: 0x%02x%s",
661 trx->rsl_tei, VTY_NEWLINE);
662 } else {
663 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
664 e1isl_dump_vty(vty, trx->rsl_link);
665 }
Harald Welte59b04682009-06-10 05:40:52 +0800666}
667
668DEFUN(show_trx,
669 show_trx_cmd,
Sylvain Munaut1ad96282012-12-28 12:15:11 +0100670 "show trx [<0-255>] [<0-255>]",
Harald Welte9e002452010-05-11 21:53:49 +0200671 SHOW_STR "Display information about a TRX\n"
672 "BTS Number\n"
673 "TRX Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800674{
Harald Welte40152872010-05-16 20:52:23 +0200675 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800676 struct gsm_bts *bts = NULL;
677 struct gsm_bts_trx *trx;
678 int bts_nr, trx_nr;
679
680 if (argc >= 1) {
681 /* use the BTS number that the user has specified */
682 bts_nr = atoi(argv[0]);
683 if (bts_nr >= net->num_bts) {
684 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
685 VTY_NEWLINE);
686 return CMD_WARNING;
687 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200688 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800689 }
690 if (argc >= 2) {
691 trx_nr = atoi(argv[1]);
692 if (trx_nr >= bts->num_trx) {
693 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
694 VTY_NEWLINE);
695 return CMD_WARNING;
696 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200697 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800698 trx_dump_vty(vty, trx);
699 return CMD_SUCCESS;
700 }
701 if (bts) {
702 /* print all TRX in this BTS */
703 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200704 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800705 trx_dump_vty(vty, trx);
706 }
707 return CMD_SUCCESS;
708 }
709
710 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200711 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800712 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200713 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800714 trx_dump_vty(vty, trx);
715 }
716 }
717
718 return CMD_SUCCESS;
719}
720
Harald Welte97ceef92009-08-06 19:06:46 +0200721
Harald Welte59b04682009-06-10 05:40:52 +0800722static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
723{
Harald Welte85771a42011-05-30 12:09:13 +0200724 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s, TSC %u",
Harald Weltee3bd0c02010-12-24 12:12:10 +0100725 ts->trx->bts->nr, ts->trx->nr, ts->nr,
Harald Welte85771a42011-05-30 12:09:13 +0200726 gsm_pchan_name(ts->pchan), ts->tsc);
Harald Welte98d2bb82010-12-24 12:14:52 +0100727 if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
Harald Welte81c2ed32010-12-24 12:26:13 +0100728 vty_out(vty, " (%s mode)",
Harald Welte98d2bb82010-12-24 12:14:52 +0100729 ts->flags & TS_F_PDCH_MODE ? "PDCH" : "TCH/F");
730 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800731 vty_out(vty, " NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200732 net_dump_nmstate(vty, &ts->mo.nm_state);
Harald Welte87504212009-12-02 01:56:49 +0530733 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welte59b04682009-06-10 05:40:52 +0800734 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
735 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
736 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800737}
738
739DEFUN(show_ts,
740 show_ts_cmd,
Sylvain Munaut1ad96282012-12-28 12:15:11 +0100741 "show timeslot [<0-255>] [<0-255>] [<0-7>]",
Harald Welte9e002452010-05-11 21:53:49 +0200742 SHOW_STR "Display information about a TS\n"
743 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800744{
Harald Welte40152872010-05-16 20:52:23 +0200745 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte06868382010-12-24 12:05:03 +0100746 struct gsm_bts *bts = NULL;
747 struct gsm_bts_trx *trx = NULL;
748 struct gsm_bts_trx_ts *ts = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800749 int bts_nr, trx_nr, ts_nr;
750
751 if (argc >= 1) {
752 /* use the BTS number that the user has specified */
753 bts_nr = atoi(argv[0]);
754 if (bts_nr >= net->num_bts) {
755 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
756 VTY_NEWLINE);
757 return CMD_WARNING;
758 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200759 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800760 }
761 if (argc >= 2) {
762 trx_nr = atoi(argv[1]);
763 if (trx_nr >= bts->num_trx) {
764 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
765 VTY_NEWLINE);
766 return CMD_WARNING;
767 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200768 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800769 }
770 if (argc >= 3) {
771 ts_nr = atoi(argv[2]);
772 if (ts_nr >= TRX_NR_TS) {
773 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
774 VTY_NEWLINE);
775 return CMD_WARNING;
776 }
Harald Welte06868382010-12-24 12:05:03 +0100777 /* Fully Specified: print and exit */
Harald Welte59b04682009-06-10 05:40:52 +0800778 ts = &trx->ts[ts_nr];
779 ts_dump_vty(vty, ts);
780 return CMD_SUCCESS;
781 }
Harald Welte06868382010-12-24 12:05:03 +0100782
783 if (bts && trx) {
784 /* Iterate over all TS in this TRX */
785 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
786 ts = &trx->ts[ts_nr];
787 ts_dump_vty(vty, ts);
788 }
789 } else if (bts) {
790 /* Iterate over all TRX in this BTS, TS in each TRX */
Harald Welte59b04682009-06-10 05:40:52 +0800791 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200792 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800793 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
794 ts = &trx->ts[ts_nr];
795 ts_dump_vty(vty, ts);
796 }
797 }
Harald Welte06868382010-12-24 12:05:03 +0100798 } else {
799 /* Iterate over all BTS, TRX in each BTS, TS in each TRX */
800 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
801 bts = gsm_bts_num(net, bts_nr);
802 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
803 trx = gsm_bts_trx_num(bts, trx_nr);
804 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
805 ts = &trx->ts[ts_nr];
806 ts_dump_vty(vty, ts);
807 }
808 }
809 }
Harald Welte59b04682009-06-10 05:40:52 +0800810 }
811
812 return CMD_SUCCESS;
813}
814
Holger Hans Peter Freyther1dd0a1b2010-01-06 06:00:40 +0100815static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800816{
Harald Welte91afe4c2009-06-20 18:15:19 +0200817 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800818 subscr->authorized, VTY_NEWLINE);
819 if (subscr->name)
820 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
821 if (subscr->extension)
822 vty_out(vty, " Extension: %s%s", subscr->extension,
823 VTY_NEWLINE);
824 if (subscr->imsi)
825 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200826 if (subscr->tmsi != GSM_RESERVED_TMSI)
827 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200828 VTY_NEWLINE);
Sylvain Munaute5863a22009-12-27 19:29:28 +0100829
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200830 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800831}
832
Harald Welte44007742009-12-22 21:43:14 +0100833static void meas_rep_dump_uni_vty(struct vty *vty,
834 struct gsm_meas_rep_unidir *mru,
835 const char *prefix,
836 const char *dir)
837{
838 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
839 prefix, dir, rxlev2dbm(mru->full.rx_lev),
840 dir, rxlev2dbm(mru->sub.rx_lev));
841 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
842 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
843 VTY_NEWLINE);
844}
845
846static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
847 const char *prefix)
848{
849 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
850 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
851 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
852 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
853 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
854 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
855 VTY_NEWLINE);
856 if (mr->flags & MEAS_REP_F_MS_TO)
857 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
858 mr->ms_timing_offset, VTY_NEWLINE);
859 if (mr->flags & MEAS_REP_F_MS_L1)
860 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
861 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
862 if (mr->flags & MEAS_REP_F_DL_VALID)
863 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
864 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
865}
866
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800867static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte59b04682009-06-10 05:40:52 +0800868{
Harald Welte44007742009-12-22 21:43:14 +0100869 int idx;
870
Harald Weltef62dad62010-12-24 12:22:34 +0100871 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
872 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
873 lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
Holger Hans Peter Freyther6e5c50f2010-06-28 17:09:29 +0800874 vty_out(vty, " Connection: %u, State: %s%s",
875 lchan->conn ? 1: 0,
Harald Welteab2534c2009-12-29 10:52:38 +0100876 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100877 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
878 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
879 - lchan->bs_power*2,
880 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
881 VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800882 if (lchan->conn && lchan->conn->subscr) {
Harald Welte59b04682009-06-10 05:40:52 +0800883 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800884 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte59b04682009-06-10 05:40:52 +0800885 } else
886 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte87504212009-12-02 01:56:49 +0530887 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
888 struct in_addr ia;
Holger Hans Peter Freythercec1ec52010-04-07 15:39:16 +0200889 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte87504212009-12-02 01:56:49 +0530890 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
891 inet_ntoa(ia), lchan->abis_ip.bound_port,
892 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
893 VTY_NEWLINE);
894 }
Harald Welte44007742009-12-22 21:43:14 +0100895
896 /* we want to report the last measurement report */
897 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
898 lchan->meas_rep_idx, 1);
899 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte59b04682009-06-10 05:40:52 +0800900}
901
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800902static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
903{
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800904 struct gsm_meas_rep *mr;
905 int idx;
906
907 /* we want to report the last measurement report */
908 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
909 lchan->meas_rep_idx, 1);
910 mr = &lchan->meas_rep[idx];
911
Harald Weltef62dad62010-12-24 12:22:34 +0100912 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u, Type %s - "
913 "L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
914 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
Harald Welte81c2ed32010-12-24 12:26:13 +0100915 lchan->nr, gsm_lchant_name(lchan->type), mr->ms_l1.pwr,
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800916 rxlev2dbm(mr->dl.full.rx_lev),
917 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800918 VTY_NEWLINE);
919}
920
Holger Hans Peter Freyther86bbcbd2011-12-27 16:34:12 +0100921
922static int dump_lchan_trx_ts(struct gsm_bts_trx_ts *ts, struct vty *vty,
923 void (*dump_cb)(struct vty *, struct gsm_lchan *))
924{
925 int lchan_nr;
926 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; lchan_nr++) {
927 struct gsm_lchan *lchan = &ts->lchan[lchan_nr];
928 if ((lchan->type == GSM_LCHAN_NONE) && (lchan->state == LCHAN_S_NONE))
929 continue;
930 dump_cb(vty, lchan);
931 }
932
933 return CMD_SUCCESS;
934}
935
936static int dump_lchan_trx(struct gsm_bts_trx *trx, struct vty *vty,
937 void (*dump_cb)(struct vty *, struct gsm_lchan *))
938{
939 int ts_nr;
940
941 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
942 struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
943 dump_lchan_trx_ts(ts, vty, dump_cb);
944 }
945
946 return CMD_SUCCESS;
947}
948
949static int dump_lchan_bts(struct gsm_bts *bts, struct vty *vty,
950 void (*dump_cb)(struct vty *, struct gsm_lchan *))
951{
952 int trx_nr;
953
954 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
955 struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_nr);
956 dump_lchan_trx(trx, vty, dump_cb);
957 }
958
959 return CMD_SUCCESS;
960}
961
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800962static int lchan_summary(struct vty *vty, int argc, const char **argv,
963 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte59b04682009-06-10 05:40:52 +0800964{
Harald Welte40152872010-05-16 20:52:23 +0200965 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800966 struct gsm_bts *bts;
967 struct gsm_bts_trx *trx;
968 struct gsm_bts_trx_ts *ts;
969 struct gsm_lchan *lchan;
970 int bts_nr, trx_nr, ts_nr, lchan_nr;
971
972 if (argc >= 1) {
973 /* use the BTS number that the user has specified */
974 bts_nr = atoi(argv[0]);
975 if (bts_nr >= net->num_bts) {
976 vty_out(vty, "%% can't find BTS %s%s", argv[0],
977 VTY_NEWLINE);
978 return CMD_WARNING;
979 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200980 bts = gsm_bts_num(net, bts_nr);
Holger Hans Peter Freyther86bbcbd2011-12-27 16:34:12 +0100981
982 if (argc == 1)
983 return dump_lchan_bts(bts, vty, dump_cb);
Harald Welte59b04682009-06-10 05:40:52 +0800984 }
985 if (argc >= 2) {
986 trx_nr = atoi(argv[1]);
987 if (trx_nr >= bts->num_trx) {
988 vty_out(vty, "%% can't find TRX %s%s", argv[1],
989 VTY_NEWLINE);
990 return CMD_WARNING;
991 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200992 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther86bbcbd2011-12-27 16:34:12 +0100993
994 if (argc == 2)
995 return dump_lchan_trx(trx, vty, dump_cb);
Harald Welte59b04682009-06-10 05:40:52 +0800996 }
997 if (argc >= 3) {
998 ts_nr = atoi(argv[2]);
999 if (ts_nr >= TRX_NR_TS) {
1000 vty_out(vty, "%% can't find TS %s%s", argv[2],
1001 VTY_NEWLINE);
1002 return CMD_WARNING;
1003 }
1004 ts = &trx->ts[ts_nr];
Holger Hans Peter Freyther86bbcbd2011-12-27 16:34:12 +01001005
1006 if (argc == 3)
1007 return dump_lchan_trx_ts(ts, vty, dump_cb);
Harald Welte59b04682009-06-10 05:40:52 +08001008 }
1009 if (argc >= 4) {
1010 lchan_nr = atoi(argv[3]);
1011 if (lchan_nr >= TS_MAX_LCHAN) {
1012 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
1013 VTY_NEWLINE);
1014 return CMD_WARNING;
1015 }
1016 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +08001017 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +08001018 return CMD_SUCCESS;
1019 }
Holger Hans Peter Freyther86bbcbd2011-12-27 16:34:12 +01001020
1021
Harald Welte59b04682009-06-10 05:40:52 +08001022 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +02001023 bts = gsm_bts_num(net, bts_nr);
Holger Hans Peter Freyther86bbcbd2011-12-27 16:34:12 +01001024 dump_lchan_bts(bts, vty, dump_cb);
Harald Welte59b04682009-06-10 05:40:52 +08001025 }
1026
1027 return CMD_SUCCESS;
1028}
1029
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +08001030
1031DEFUN(show_lchan,
1032 show_lchan_cmd,
Sylvain Munaut1ad96282012-12-28 12:15:11 +01001033 "show lchan [<0-255>] [<0-255>] [<0-7>] [lchan_nr]",
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +08001034 SHOW_STR "Display information about a logical channel\n"
1035 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001036 LCHAN_NR_STR)
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +08001037
1038{
1039 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
1040}
1041
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08001042DEFUN(show_lchan_summary,
1043 show_lchan_summary_cmd,
Sylvain Munaut1ad96282012-12-28 12:15:11 +01001044 "show lchan summary [<0-255>] [<0-255>] [<0-7>] [lchan_nr]",
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08001045 SHOW_STR "Display information about a logical channel\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001046 "Short summary\n"
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08001047 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001048 LCHAN_NR_STR)
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08001049{
1050 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
1051}
1052
Harald Welte59b04682009-06-10 05:40:52 +08001053static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
1054{
1055 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
1056 subscr_dump_vty(vty, pag->subscr);
1057}
1058
1059static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
1060{
1061 struct gsm_paging_request *pag;
1062
1063 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
1064 paging_dump_vty(vty, pag);
1065}
1066
1067DEFUN(show_paging,
1068 show_paging_cmd,
Sylvain Munaut1ad96282012-12-28 12:15:11 +01001069 "show paging [<0-255>]",
Harald Welte9e002452010-05-11 21:53:49 +02001070 SHOW_STR "Display information about paging reuqests of a BTS\n"
1071 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001072{
Harald Welte40152872010-05-16 20:52:23 +02001073 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001074 struct gsm_bts *bts;
1075 int bts_nr;
1076
1077 if (argc >= 1) {
1078 /* use the BTS number that the user has specified */
1079 bts_nr = atoi(argv[0]);
1080 if (bts_nr >= net->num_bts) {
1081 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1082 VTY_NEWLINE);
1083 return CMD_WARNING;
1084 }
Harald Weltee712a5f2009-06-21 16:17:15 +02001085 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001086 bts_paging_dump_vty(vty, bts);
1087
1088 return CMD_SUCCESS;
1089 }
1090 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +02001091 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001092 bts_paging_dump_vty(vty, bts);
1093 }
1094
1095 return CMD_SUCCESS;
1096}
1097
Harald Weltee87eb462009-08-07 13:29:14 +02001098DEFUN(cfg_net,
1099 cfg_net_cmd,
Harald Welte9e002452010-05-11 21:53:49 +02001100 "network", NETWORK_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001101{
Harald Welte40152872010-05-16 20:52:23 +02001102 vty->index = gsmnet_from_vty(vty);
Harald Weltee87eb462009-08-07 13:29:14 +02001103 vty->node = GSMNET_NODE;
1104
1105 return CMD_SUCCESS;
1106}
1107
Harald Weltee87eb462009-08-07 13:29:14 +02001108DEFUN(cfg_net_ncc,
1109 cfg_net_ncc_cmd,
1110 "network country code <1-999>",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001111 "Set the GSM network country code\n"
1112 "Country commands\n"
1113 CODE_CMD_STR
1114 "Network Country Code to use\n")
Harald Weltee87eb462009-08-07 13:29:14 +02001115{
Harald Welte40152872010-05-16 20:52:23 +02001116 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1117
Harald Weltee87eb462009-08-07 13:29:14 +02001118 gsmnet->country_code = atoi(argv[0]);
1119
1120 return CMD_SUCCESS;
1121}
1122
1123DEFUN(cfg_net_mnc,
1124 cfg_net_mnc_cmd,
Dieter Spaarf1295252011-07-27 23:43:56 +02001125 "mobile network code <0-999>",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001126 "Set the GSM mobile network code\n"
1127 "Network Commands\n"
1128 CODE_CMD_STR
1129 "Mobile Network Code to use\n")
Harald Weltee87eb462009-08-07 13:29:14 +02001130{
Harald Welte40152872010-05-16 20:52:23 +02001131 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1132
Harald Weltee87eb462009-08-07 13:29:14 +02001133 gsmnet->network_code = atoi(argv[0]);
1134
1135 return CMD_SUCCESS;
1136}
1137
1138DEFUN(cfg_net_name_short,
1139 cfg_net_name_short_cmd,
1140 "short name NAME",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001141 "Set the short GSM network name\n" NAME_CMD_STR NAME_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001142{
Harald Welte40152872010-05-16 20:52:23 +02001143 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1144
Holger Hans Peter Freyther7c831f62010-10-12 23:21:54 +02001145 bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
Harald Weltee87eb462009-08-07 13:29:14 +02001146 return CMD_SUCCESS;
1147}
1148
1149DEFUN(cfg_net_name_long,
1150 cfg_net_name_long_cmd,
1151 "long name NAME",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001152 "Set the long GSM network name\n" NAME_CMD_STR NAME_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001153{
Harald Welte40152872010-05-16 20:52:23 +02001154 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1155
Holger Hans Peter Freyther7c831f62010-10-12 23:21:54 +02001156 bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
Harald Weltee87eb462009-08-07 13:29:14 +02001157 return CMD_SUCCESS;
1158}
Harald Welte59b04682009-06-10 05:40:52 +08001159
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001160DEFUN(cfg_net_auth_policy,
1161 cfg_net_auth_policy_cmd,
1162 "auth policy (closed|accept-all|token)",
Harald Welte9e002452010-05-11 21:53:49 +02001163 "Authentication (not cryptographic)\n"
1164 "Set the GSM network authentication policy\n"
1165 "Require the MS to be activated in HLR\n"
1166 "Accept all MS, whether in HLR or not\n"
1167 "Use SMS-token based authentication\n")
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001168{
1169 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001170 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001171
1172 gsmnet->auth_policy = policy;
1173
1174 return CMD_SUCCESS;
1175}
1176
Harald Welte59936d72009-11-18 20:33:19 +01001177DEFUN(cfg_net_reject_cause,
1178 cfg_net_reject_cause_cmd,
1179 "location updating reject cause <2-111>",
Harald Welte557f3992012-08-16 23:23:50 +02001180 "Set the reject cause of location updating reject\n"
1181 "Set the reject cause of location updating reject\n"
1182 "Set the reject cause of location updating reject\n"
1183 "Set the reject cause of location updating reject\n"
1184 "Cause Value as Per GSM TS 04.08\n")
Harald Welte59936d72009-11-18 20:33:19 +01001185{
Harald Welte40152872010-05-16 20:52:23 +02001186 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1187
Harald Welte59936d72009-11-18 20:33:19 +01001188 gsmnet->reject_cause = atoi(argv[0]);
1189
1190 return CMD_SUCCESS;
1191}
1192
Harald Weltecca253a2009-08-30 15:47:06 +09001193DEFUN(cfg_net_encryption,
1194 cfg_net_encryption_cmd,
Harald Welte55ff9362012-07-04 21:37:56 +02001195 "encryption a5 (0|1|2|3)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001196 "Encryption options\n"
1197 "A5 encryption\n" "A5/0: No encryption\n"
Harald Welte55ff9362012-07-04 21:37:56 +02001198 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n"
1199 "A5/3: 'New' Secure Encryption\n")
Harald Weltecca253a2009-08-30 15:47:06 +09001200{
Harald Welte40152872010-05-16 20:52:23 +02001201 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1202
Andreas.Eversberg53293292009-11-17 09:55:26 +01001203 gsmnet->a5_encryption= atoi(argv[0]);
Harald Weltecca253a2009-08-30 15:47:06 +09001204
1205 return CMD_SUCCESS;
1206}
1207
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001208DEFUN(cfg_net_neci,
1209 cfg_net_neci_cmd,
1210 "neci (0|1)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001211 "New Establish Cause Indication\n"
1212 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001213{
Harald Welte40152872010-05-16 20:52:23 +02001214 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1215
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001216 gsmnet->neci = atoi(argv[0]);
Holger Hans Peter Freytherf0f37f12010-09-06 09:36:02 +08001217 gsm_net_update_ctype(gsmnet);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001218 return CMD_SUCCESS;
1219}
1220
Harald Welte52af1952009-12-13 10:53:12 +01001221DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1222 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte9e002452010-05-11 21:53:49 +02001223 "Radio Resource Location Protocol\n"
1224 "Set the Radio Resource Location Protocol Mode\n"
1225 "Don't send RRLP request\n"
1226 "Request MS-based location\n"
1227 "Request any location, prefer MS-based\n"
1228 "Request any location, prefer MS-assisted\n")
Harald Welte52af1952009-12-13 10:53:12 +01001229{
Harald Welte40152872010-05-16 20:52:23 +02001230 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1231
Harald Welte52af1952009-12-13 10:53:12 +01001232 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1233
1234 return CMD_SUCCESS;
1235}
1236
Harald Weltea310f3e2009-12-14 09:00:24 +01001237DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1238 "mm info (0|1)",
Holger Hans Peter Freyther29844222012-07-21 00:27:10 +02001239 "Mobility Management\n"
1240 "Send MM INFO after LOC UPD ACCEPT\n"
1241 "Disable\n" "Enable\n")
Harald Weltea310f3e2009-12-14 09:00:24 +01001242{
Harald Welte40152872010-05-16 20:52:23 +02001243 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1244
Harald Weltea310f3e2009-12-14 09:00:24 +01001245 gsmnet->send_mm_info = atoi(argv[0]);
1246
1247 return CMD_SUCCESS;
1248}
1249
Harald Welte9e002452010-05-11 21:53:49 +02001250#define HANDOVER_STR "Handover Options\n"
1251
Harald Welte0af9c9f2009-12-19 21:41:52 +01001252DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1253 "handover (0|1)",
Harald Welte9e002452010-05-11 21:53:49 +02001254 HANDOVER_STR
1255 "Don't perform in-call handover\n"
1256 "Perform in-call handover\n")
Harald Welte0af9c9f2009-12-19 21:41:52 +01001257{
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001258 int enable = atoi(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001259 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001260
1261 if (enable && ipacc_rtp_direct) {
Harald Welteaa2c3032009-12-20 13:51:01 +01001262 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1263 "is enabled by using the -P command line option%s",
1264 VTY_NEWLINE);
1265 return CMD_WARNING;
1266 }
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001267 gsmnet->handover.active = enable;
Harald Welte0af9c9f2009-12-19 21:41:52 +01001268
1269 return CMD_SUCCESS;
1270}
1271
Harald Welte9e002452010-05-11 21:53:49 +02001272#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1273#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1274#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1275#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001276#define HO_AVG_COUNT_STR "Amount to use for Averaging\n"
Harald Welte9e002452010-05-11 21:53:49 +02001277
Harald Weltea8062f12009-12-21 16:51:50 +01001278DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1279 "handover window rxlev averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001280 HO_WIN_RXLEV_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001281 "How many RxLev measurements are used for averaging\n"
1282 HO_AVG_COUNT_STR)
Harald Weltea8062f12009-12-21 16:51:50 +01001283{
Harald Welte40152872010-05-16 20:52:23 +02001284 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001285 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1286 return CMD_SUCCESS;
1287}
1288
1289DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1290 "handover window rxqual averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001291 HO_WIN_RXQUAL_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001292 "How many RxQual measurements are used for averaging\n"
1293 HO_AVG_COUNT_STR)
Harald Weltea8062f12009-12-21 16:51:50 +01001294{
Harald Welte40152872010-05-16 20:52:23 +02001295 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001296 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1297 return CMD_SUCCESS;
1298}
1299
1300DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1301 "handover window rxlev neighbor averaging <1-10>",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001302 HO_WIN_RXLEV_STR "Neighbor\n"
1303 "How many RxQual measurements are used for averaging\n"
1304 HO_AVG_COUNT_STR)
Harald Weltea8062f12009-12-21 16:51:50 +01001305{
Harald Welte40152872010-05-16 20:52:23 +02001306 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001307 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1308 return CMD_SUCCESS;
1309}
1310
1311DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1312 "handover power budget interval <1-99>",
Harald Welte9e002452010-05-11 21:53:49 +02001313 HO_PBUDGET_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001314 "How often to check if we have a better cell (SACCH frames)\n"
1315 "Interval\n" "Number\n")
Harald Weltea8062f12009-12-21 16:51:50 +01001316{
Harald Welte40152872010-05-16 20:52:23 +02001317 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001318 gsmnet->handover.pwr_interval = atoi(argv[0]);
1319 return CMD_SUCCESS;
1320}
1321
1322DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1323 "handover power budget hysteresis <0-999>",
Harald Welte9e002452010-05-11 21:53:49 +02001324 HO_PBUDGET_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001325 "How many dB does a neighbor to be stronger to become a HO candidate\n"
1326 "Hysteresis\n" "Number\n")
Harald Weltea8062f12009-12-21 16:51:50 +01001327{
Harald Welte40152872010-05-16 20:52:23 +02001328 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001329 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1330 return CMD_SUCCESS;
1331}
1332
1333DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1334 "handover maximum distance <0-9999>",
Harald Welte9e002452010-05-11 21:53:49 +02001335 HANDOVER_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001336 "How big is the maximum timing advance before HO is forced\n"
1337 "Distance\n" "Number\n")
Harald Weltea8062f12009-12-21 16:51:50 +01001338{
Harald Welte40152872010-05-16 20:52:23 +02001339 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001340 gsmnet->handover.max_distance = atoi(argv[0]);
1341 return CMD_SUCCESS;
1342}
Harald Welte0af9c9f2009-12-19 21:41:52 +01001343
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001344DEFUN(cfg_net_pag_any_tch,
1345 cfg_net_pag_any_tch_cmd,
1346 "paging any use tch (0|1)",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001347 "Assign a TCH when receiving a Paging Any request\n"
1348 "Any Channel\n" "Use\n" "TCH\n"
1349 "Do not use TCH for Paging Request Any\n"
1350 "Do use TCH for Paging Request Any\n")
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001351{
Holger Hans Peter Freytherc5628882010-09-06 10:09:19 +08001352 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001353 gsmnet->pag_any_tch = atoi(argv[0]);
1354 gsm_net_update_ctype(gsmnet);
1355 return CMD_SUCCESS;
1356}
1357
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001358#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001359 DEFUN(cfg_net_T##number, \
1360 cfg_net_T##number##_cmd, \
1361 "timer t" #number " <0-65535>", \
Harald Welte9e002452010-05-11 21:53:49 +02001362 "Configure GSM Timers\n" \
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001363 doc "Timer Value\n") \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001364{ \
Harald Welte40152872010-05-16 20:52:23 +02001365 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001366 int value = atoi(argv[0]); \
1367 \
1368 if (value < 0 || value > 65535) { \
1369 vty_out(vty, "Timer value %s out of range.%s", \
1370 argv[0], VTY_NEWLINE); \
1371 return CMD_WARNING; \
1372 } \
1373 \
1374 gsmnet->T##number = value; \
1375 return CMD_SUCCESS; \
1376}
1377
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001378DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.\n")
1379DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.\n")
Harald Welte9b77f612012-06-03 13:01:47 +02001380DECLARE_TIMER(3105, "Set the timer for repetition of PHYSICAL INFORMATION.\n")
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001381DECLARE_TIMER(3107, "Currently not used.\n")
Holger Hans Peter Freyther969a4052011-12-28 16:21:05 +01001382DECLARE_TIMER(3109, "Set the RSL SACCH deactivation timeout.\n")
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001383DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.\n")
1384DECLARE_TIMER(3113, "Set the time to try paging a subscriber.\n")
1385DECLARE_TIMER(3115, "Currently not used.\n")
1386DECLARE_TIMER(3117, "Currently not used.\n")
1387DECLARE_TIMER(3119, "Currently not used.\n")
1388DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT\n")
1389DECLARE_TIMER(3141, "Currently not used.\n")
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001390
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08001391DEFUN(cfg_net_dtx,
1392 cfg_net_dtx_cmd,
1393 "dtx-used (0|1)",
1394 "Enable the usage of DTX.\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001395 "DTX is disabled\n" "DTX is enabled\n")
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08001396{
1397 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1398 gsmnet->dtx_enabled = atoi(argv[0]);
1399 return CMD_SUCCESS;
1400}
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001401
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +01001402DEFUN(cfg_net_subscr_keep,
1403 cfg_net_subscr_keep_cmd,
1404 "subscriber-keep-in-ram (0|1)",
1405 "Keep unused subscribers in RAM.\n"
1406 "Delete unused subscribers\n" "Keep unused subscribers\n")
1407{
1408 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1409 gsmnet->keep_subscr = atoi(argv[0]);
1410 return CMD_SUCCESS;
1411}
1412
Harald Welte59b04682009-06-10 05:40:52 +08001413/* per-BTS configuration */
1414DEFUN(cfg_bts,
1415 cfg_bts_cmd,
Harald Welte2af06cb2012-08-17 12:50:14 +02001416 "bts <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001417 "Select a BTS to configure\n"
1418 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001419{
Harald Welte40152872010-05-16 20:52:23 +02001420 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001421 int bts_nr = atoi(argv[0]);
1422 struct gsm_bts *bts;
1423
Harald Weltee712a5f2009-06-21 16:17:15 +02001424 if (bts_nr > gsmnet->num_bts) {
1425 vty_out(vty, "%% The next unused BTS number is %u%s",
1426 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001427 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001428 } else if (bts_nr == gsmnet->num_bts) {
1429 /* allocate a new one */
Harald Weltec7881282011-06-05 13:31:33 +02001430 bts = gsm_bts_alloc_register(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1431 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001432 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001433 bts = gsm_bts_num(gsmnet, bts_nr);
1434
Daniel Willmann580085f2010-01-11 13:43:07 +01001435 if (!bts) {
1436 vty_out(vty, "%% Unable to allocate BTS %u%s",
1437 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee712a5f2009-06-21 16:17:15 +02001438 return CMD_WARNING;
Daniel Willmann580085f2010-01-11 13:43:07 +01001439 }
Harald Welte59b04682009-06-10 05:40:52 +08001440
1441 vty->index = bts;
Harald Welte8791dac2010-05-14 17:59:53 +02001442 vty->index_sub = &bts->description;
Harald Welte59b04682009-06-10 05:40:52 +08001443 vty->node = BTS_NODE;
1444
1445 return CMD_SUCCESS;
1446}
1447
1448DEFUN(cfg_bts_type,
1449 cfg_bts_type_cmd,
Harald Welte85a77b12012-08-17 13:02:12 +02001450 "type TYPE", /* dynamically created */
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001451 "Set the BTS type\n" "Type\n")
Harald Welte59b04682009-06-10 05:40:52 +08001452{
1453 struct gsm_bts *bts = vty->index;
Harald Welte59698fb2010-01-10 18:01:52 +01001454 int rc;
Harald Welte59b04682009-06-10 05:40:52 +08001455
Harald Welte59698fb2010-01-10 18:01:52 +01001456 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1457 if (rc < 0)
1458 return CMD_WARNING;
Harald Welte25572872009-10-20 00:22:00 +02001459
Harald Welte59b04682009-06-10 05:40:52 +08001460 return CMD_SUCCESS;
1461}
1462
Harald Welte91afe4c2009-06-20 18:15:19 +02001463DEFUN(cfg_bts_band,
1464 cfg_bts_band_cmd,
1465 "band BAND",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001466 "Set the frequency band of this BTS\n" "Frequency band\n")
Harald Welte91afe4c2009-06-20 18:15:19 +02001467{
1468 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +02001469 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +02001470
1471 if (band < 0) {
1472 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1473 band, VTY_NEWLINE);
1474 return CMD_WARNING;
1475 }
1476
1477 bts->band = band;
1478
1479 return CMD_SUCCESS;
1480}
1481
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001482DEFUN(cfg_bts_ci,
1483 cfg_bts_ci_cmd,
1484 "cell_identity <0-65535>",
Holger Hans Peter Freyther29844222012-07-21 00:27:10 +02001485 "Set the Cell identity of this BTS\n" "Cell Identity\n")
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001486{
1487 struct gsm_bts *bts = vty->index;
1488 int ci = atoi(argv[0]);
1489
1490 if (ci < 0 || ci > 0xffff) {
1491 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1492 ci, VTY_NEWLINE);
1493 return CMD_WARNING;
1494 }
1495 bts->cell_identity = ci;
1496
1497 return CMD_SUCCESS;
1498}
1499
Harald Welte59b04682009-06-10 05:40:52 +08001500DEFUN(cfg_bts_lac,
1501 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001502 "location_area_code <0-65535>",
Holger Hans Peter Freyther29844222012-07-21 00:27:10 +02001503 "Set the Location Area Code (LAC) of this BTS\n" "LAC\n")
Harald Welte59b04682009-06-10 05:40:52 +08001504{
1505 struct gsm_bts *bts = vty->index;
1506 int lac = atoi(argv[0]);
1507
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001508 if (lac < 0 || lac > 0xffff) {
1509 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001510 lac, VTY_NEWLINE);
1511 return CMD_WARNING;
1512 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +02001513
1514 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1515 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1516 lac, VTY_NEWLINE);
1517 return CMD_WARNING;
1518 }
1519
Harald Welte59b04682009-06-10 05:40:52 +08001520 bts->location_area_code = lac;
1521
1522 return CMD_SUCCESS;
1523}
1524
Harald Weltea54a2bb2009-12-01 18:04:30 +05301525
Harald Welte59b04682009-06-10 05:40:52 +08001526DEFUN(cfg_bts_tsc,
1527 cfg_bts_tsc_cmd,
Harald Weltede896da2012-05-31 10:57:08 +02001528 "training_sequence_code <0-7>",
Holger Hans Peter Freyther29844222012-07-21 00:27:10 +02001529 "Set the Training Sequence Code (TSC) of this BTS\n" "TSC\n")
Harald Welte59b04682009-06-10 05:40:52 +08001530{
1531 struct gsm_bts *bts = vty->index;
1532 int tsc = atoi(argv[0]);
1533
Harald Welte59b04682009-06-10 05:40:52 +08001534 bts->tsc = tsc;
1535
1536 return CMD_SUCCESS;
1537}
1538
1539DEFUN(cfg_bts_bsic,
1540 cfg_bts_bsic_cmd,
1541 "base_station_id_code <0-63>",
Harald Welte557f3992012-08-16 23:23:50 +02001542 "Set the Base Station Identity Code (BSIC) of this BTS\n"
1543 "BSIC of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +08001544{
1545 struct gsm_bts *bts = vty->index;
1546 int bsic = atoi(argv[0]);
1547
1548 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +02001549 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001550 bsic, VTY_NEWLINE);
1551 return CMD_WARNING;
1552 }
1553 bts->bsic = bsic;
1554
1555 return CMD_SUCCESS;
1556}
1557
Gus Bourgf9dc16b2011-12-02 10:18:17 +01001558DEFUN(cfg_bts_timezone,
1559 cfg_bts_timezone_cmd,
1560 "timezone <-19-19> (0|15|30|45)",
Harald Welte557f3992012-08-16 23:23:50 +02001561 "Set the Timezone Offset of this BTS\n"
1562 "Timezone offset (hours)\n"
1563 "Timezone offset (00 minutes)\n"
1564 "Timezone offset (15 minutes)\n"
1565 "Timezone offset (30 minutes)\n"
Harald Weltefa2015f2012-08-17 09:52:03 +02001566 "Timezone offset (45 minutes)\n"
Harald Welte557f3992012-08-16 23:23:50 +02001567 )
Gus Bourgf9dc16b2011-12-02 10:18:17 +01001568{
1569 struct gsm_bts *bts = vty->index;
1570 int tzhr = atoi(argv[0]);
1571 int tzmn = atoi(argv[1]);
1572
Harald Welte5c3abf92012-07-08 16:48:11 +02001573 bts->tz.hr = tzhr;
1574 bts->tz.mn = tzmn;
1575 bts->tz.override = 1;
Gus Bourgf9dc16b2011-12-02 10:18:17 +01001576
1577 return CMD_SUCCESS;
1578}
1579
1580DEFUN(cfg_bts_no_timezone,
1581 cfg_bts_no_timezone_cmd,
1582 "no timezone",
Harald Welte557f3992012-08-16 23:23:50 +02001583 NO_STR
1584 "Disable BTS specific timezone\n")
Gus Bourgf9dc16b2011-12-02 10:18:17 +01001585{
1586 struct gsm_bts *bts = vty->index;
Harald Welte5c3abf92012-07-08 16:48:11 +02001587
1588 bts->tz.override = 0;
1589
Gus Bourgf9dc16b2011-12-02 10:18:17 +01001590 return CMD_SUCCESS;
1591}
Harald Welte59b04682009-06-10 05:40:52 +08001592
1593DEFUN(cfg_bts_unit_id,
1594 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +02001595 "ip.access unit_id <0-65534> <0-255>",
Harald Welte557f3992012-08-16 23:23:50 +02001596 "Abis/IP specific options\n"
1597 "Set the IPA BTS Unit ID\n"
1598 "Unit ID (Site)\n"
1599 "Unit ID (BTS)\n")
Harald Welte59b04682009-06-10 05:40:52 +08001600{
1601 struct gsm_bts *bts = vty->index;
1602 int site_id = atoi(argv[0]);
1603 int bts_id = atoi(argv[1]);
1604
Harald Weltef515aa02009-08-07 13:27:09 +02001605 if (!is_ipaccess_bts(bts)) {
1606 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1607 return CMD_WARNING;
1608 }
1609
Harald Welte59b04682009-06-10 05:40:52 +08001610 bts->ip_access.site_id = site_id;
1611 bts->ip_access.bts_id = bts_id;
1612
1613 return CMD_SUCCESS;
1614}
1615
Harald Welte08011e22011-03-04 13:41:31 +01001616DEFUN(cfg_bts_serno,
1617 cfg_bts_serno_cmd,
1618 "hsl serial-number STRING",
Harald Welte557f3992012-08-16 23:23:50 +02001619 "HSL BTS specific options\n"
1620 "Set the HSL Serial Number of this BTS\n"
1621 "Serial Number of this HSL BTS\n")
Harald Welte08011e22011-03-04 13:41:31 +01001622{
1623 struct gsm_bts *bts = vty->index;
1624
1625 if (bts->type != GSM_BTS_TYPE_HSL_FEMTO) {
1626 vty_out(vty, "%% BTS is not of HSL type%s", VTY_NEWLINE);
1627 return CMD_WARNING;
1628 }
1629
1630 bts->hsl.serno = strtoul(argv[0], NULL, 10);
1631
1632 return CMD_SUCCESS;
1633}
1634
Sylvain Munautcb8e8432011-10-17 14:04:55 +02001635DEFUN(cfg_bts_nokia_site_skip_reset,
1636 cfg_bts_nokia_site_skip_reset_cmd,
1637 "nokia_site skip-reset (0|1)",
Harald Welte557f3992012-08-16 23:23:50 +02001638 "Nokia *Site related commands\n"
1639 "Skip the reset step during bootstrap process of this BTS\n"
1640 "Do NOT skip the reset\n" "Skip the reset\n")
Sylvain Munautcb8e8432011-10-17 14:04:55 +02001641{
1642 struct gsm_bts *bts = vty->index;
1643
1644 if (bts->type != GSM_BTS_TYPE_NOKIA_SITE) {
1645 vty_out(vty, "%% BTS is not of Nokia *Site type%s", VTY_NEWLINE);
1646 return CMD_WARNING;
1647 }
1648
1649 bts->nokia.skip_reset = atoi(argv[0]);
1650
1651 return CMD_SUCCESS;
1652}
1653
Harald Welte9e002452010-05-11 21:53:49 +02001654#define OML_STR "Organization & Maintenance Link\n"
Harald Welte557f3992012-08-16 23:23:50 +02001655#define IPA_STR "A-bis/IP Specific Options\n"
Harald Welte9e002452010-05-11 21:53:49 +02001656
Harald Welte25572872009-10-20 00:22:00 +02001657DEFUN(cfg_bts_stream_id,
1658 cfg_bts_stream_id_cmd,
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02001659 "oml ip.access stream_id <0-255> line E1_LINE",
Harald Welte9e002452010-05-11 21:53:49 +02001660 OML_STR IPA_STR
Harald Welte557f3992012-08-16 23:23:50 +02001661 "Set the ip.access Stream ID of the OML link of this BTS\n"
1662 "Stream Identifier\n" "Virtual E1 Line Number\n" "Virtual E1 Line Number\n")
Harald Welte25572872009-10-20 00:22:00 +02001663{
1664 struct gsm_bts *bts = vty->index;
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02001665 int stream_id = atoi(argv[0]), linenr = atoi(argv[1]);
Harald Welte25572872009-10-20 00:22:00 +02001666
1667 if (!is_ipaccess_bts(bts)) {
1668 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1669 return CMD_WARNING;
1670 }
1671
1672 bts->oml_tei = stream_id;
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02001673 /* This is used by e1inp_bind_ops callback for each BTS model. */
1674 bts->oml_e1_link.e1_nr = linenr;
1675
1676 return CMD_SUCCESS;
1677}
1678
1679DEFUN(cfg_bts_hsl_oml,
1680 cfg_bts_hsl_oml_cmd,
1681 "oml hsl line E1_LINE",
Harald Welte557f3992012-08-16 23:23:50 +02001682 OML_STR "HSL femto Specific Options\n"
Harald Welte764c8e12012-08-17 09:57:25 +02001683 "Set OML link of this HSL femto BTS\n"
1684 "Virtual E1/T1 line number\n")
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02001685{
1686 struct gsm_bts *bts = vty->index;
1687 int linenr = atoi(argv[0]);
1688
1689 if (!(bts->type == GSM_BTS_TYPE_HSL_FEMTO)) {
1690 vty_out(vty, "%% BTS is not of HSL type%s", VTY_NEWLINE);
1691 return CMD_WARNING;
1692 }
1693
1694 bts->oml_e1_link.e1_nr = linenr;
Harald Welte25572872009-10-20 00:22:00 +02001695
1696 return CMD_SUCCESS;
1697}
1698
Harald Weltefa2015f2012-08-17 09:52:03 +02001699#define OML_E1_STR OML_STR "OML E1/T1 Configuration\n"
Harald Welte25572872009-10-20 00:22:00 +02001700
Harald Welte62868882009-08-08 16:12:58 +02001701DEFUN(cfg_bts_oml_e1,
1702 cfg_bts_oml_e1_cmd,
1703 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltefa2015f2012-08-17 09:52:03 +02001704 OML_E1_STR
1705 "E1/T1 line number to be used for OML\n"
Harald Welte557f3992012-08-16 23:23:50 +02001706 "E1/T1 line number to be used for OML\n"
1707 "E1/T1 timeslot to be used for OML\n"
1708 "E1/T1 timeslot to be used for OML\n"
1709 "E1/T1 sub-slot to be used for OML\n"
1710 "Use E1/T1 sub-slot 0\n"
1711 "Use E1/T1 sub-slot 1\n"
1712 "Use E1/T1 sub-slot 2\n"
1713 "Use E1/T1 sub-slot 3\n"
1714 "Use full E1 slot 3\n"
1715 )
Harald Welte62868882009-08-08 16:12:58 +02001716{
1717 struct gsm_bts *bts = vty->index;
1718
1719 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1720
1721 return CMD_SUCCESS;
1722}
1723
1724
1725DEFUN(cfg_bts_oml_e1_tei,
1726 cfg_bts_oml_e1_tei_cmd,
1727 "oml e1 tei <0-63>",
Harald Welte9e002452010-05-11 21:53:49 +02001728 OML_E1_STR
Harald Welte557f3992012-08-16 23:23:50 +02001729 "Set the TEI to be used for OML\n"
1730 "TEI Number\n")
Harald Welte62868882009-08-08 16:12:58 +02001731{
1732 struct gsm_bts *bts = vty->index;
1733
1734 bts->oml_tei = atoi(argv[0]);
1735
1736 return CMD_SUCCESS;
1737}
1738
Harald Welte3e774612009-08-10 13:48:16 +02001739DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1740 "channel allocator (ascending|descending)",
Harald Welte9e002452010-05-11 21:53:49 +02001741 "Channnel Allocator\n" "Channel Allocator\n"
1742 "Allocate Timeslots and Transceivers in ascending order\n"
1743 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte3e774612009-08-10 13:48:16 +02001744{
1745 struct gsm_bts *bts = vty->index;
1746
1747 if (!strcmp(argv[0], "ascending"))
1748 bts->chan_alloc_reverse = 0;
1749 else
1750 bts->chan_alloc_reverse = 1;
1751
1752 return CMD_SUCCESS;
1753}
1754
Harald Welte9e002452010-05-11 21:53:49 +02001755#define RACH_STR "Random Access Control Channel\n"
1756
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001757DEFUN(cfg_bts_rach_tx_integer,
1758 cfg_bts_rach_tx_integer_cmd,
1759 "rach tx integer <0-15>",
Harald Welte9e002452010-05-11 21:53:49 +02001760 RACH_STR
Harald Welte557f3992012-08-16 23:23:50 +02001761 "Set the raw tx integer value in RACH Control parameters IE\n"
1762 "Set the raw tx integer value in RACH Control parameters IE\n"
1763 "Raw tx integer value in RACH Control parameters IE\n")
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001764{
1765 struct gsm_bts *bts = vty->index;
1766 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1767 return CMD_SUCCESS;
1768}
1769
1770DEFUN(cfg_bts_rach_max_trans,
1771 cfg_bts_rach_max_trans_cmd,
1772 "rach max transmission (1|2|4|7)",
Harald Welte9e002452010-05-11 21:53:49 +02001773 RACH_STR
Harald Welte557f3992012-08-16 23:23:50 +02001774 "Set the maximum number of RACH burst transmissions\n"
1775 "Set the maximum number of RACH burst transmissions\n"
Harald Weltefa2015f2012-08-17 09:52:03 +02001776 "Maximum number of 1 RACH burst transmissions\n"
1777 "Maximum number of 2 RACH burst transmissions\n"
1778 "Maximum number of 4 RACH burst transmissions\n"
1779 "Maximum number of 7 RACH burst transmissions\n")
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001780{
1781 struct gsm_bts *bts = vty->index;
1782 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1783 return CMD_SUCCESS;
1784}
1785
Andreas Eversberg14e12f22012-10-13 07:27:47 +02001786#define CD_STR "Channel Description\n"
1787
1788DEFUN(cfg_bts_chan_desc_att,
1789 cfg_bts_chan_desc_att_cmd,
1790 "channel-descrption attach (0|1)",
1791 CD_STR
1792 "Set if attachment is required\n"
1793 "Attachment is NOT required\n"
1794 "Attachment is required (standard)\n")
1795{
1796 struct gsm_bts *bts = vty->index;
1797 bts->si_common.chan_desc.att = atoi(argv[0]);
1798 return CMD_SUCCESS;
1799}
1800
1801DEFUN(cfg_bts_chan_desc_bs_pa_mfrms,
1802 cfg_bts_chan_desc_bs_pa_mfrms_cmd,
1803 "channel-descrption bs-pa-mfrms <2-9>",
1804 CD_STR
1805 "Set number of multiframe periods for paging groups\n"
1806 "Number of multiframe periods for paging groups\n")
1807{
1808 struct gsm_bts *bts = vty->index;
1809 int bs_pa_mfrms = atoi(argv[0]);
1810
1811 bts->si_common.chan_desc.bs_pa_mfrms = bs_pa_mfrms - 2;
1812 return CMD_SUCCESS;
1813}
1814
1815DEFUN(cfg_bts_chan_desc_bs_ag_blks_res,
1816 cfg_bts_chan_desc_bs_ag_blks_res_cmd,
1817 "channel-descrption bs-ag-blks-res <0-7>",
1818 CD_STR
1819 "Set number of blocks reserved for access grant\n"
1820 "Number of blocks reserved for access grant\n")
1821{
1822 struct gsm_bts *bts = vty->index;
1823 int bs_ag_blks_res = atoi(argv[0]);
1824
1825 bts->si_common.chan_desc.bs_ag_blks_res = bs_ag_blks_res;
1826 return CMD_SUCCESS;
1827}
1828
Harald Welte9e002452010-05-11 21:53:49 +02001829#define NM_STR "Network Management\n"
1830
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001831DEFUN(cfg_bts_rach_nm_b_thresh,
1832 cfg_bts_rach_nm_b_thresh_cmd,
1833 "rach nm busy threshold <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001834 RACH_STR NM_STR
Harald Welte557f3992012-08-16 23:23:50 +02001835 "Set the NM Busy Threshold\n"
1836 "Set the NM Busy Threshold\n"
1837 "NM Busy Threshold in dB")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001838{
1839 struct gsm_bts *bts = vty->index;
1840 bts->rach_b_thresh = atoi(argv[0]);
1841 return CMD_SUCCESS;
1842}
1843
1844DEFUN(cfg_bts_rach_nm_ldavg,
1845 cfg_bts_rach_nm_ldavg_cmd,
1846 "rach nm load average <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001847 RACH_STR NM_STR
Harald Welte557f3992012-08-16 23:23:50 +02001848 "Set the NM Loadaverage Slots value\n"
1849 "Set the NM Loadaverage Slots value\n"
1850 "NM Loadaverage Slots value\n")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001851{
1852 struct gsm_bts *bts = vty->index;
1853 bts->rach_ldavg_slots = atoi(argv[0]);
1854 return CMD_SUCCESS;
1855}
1856
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001857DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1858 "cell barred (0|1)",
Harald Welte557f3992012-08-16 23:23:50 +02001859 "Should this cell be barred from access?\n"
1860 "Should this cell be barred from access?\n"
1861 "Cell should NOT be barred\n"
1862 "Cell should be barred\n")
1863
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001864{
1865 struct gsm_bts *bts = vty->index;
1866
Harald Welte8c973ba2009-12-21 23:08:18 +01001867 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001868
1869 return CMD_SUCCESS;
1870}
1871
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08001872DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1873 "rach emergency call allowed (0|1)",
Harald Welte557f3992012-08-16 23:23:50 +02001874 RACH_STR
1875 "Should this cell allow emergency calls?\n"
1876 "Should this cell allow emergency calls?\n"
1877 "Should this cell allow emergency calls?\n"
1878 "Do NOT allow emergency calls\n"
1879 "Allow emergency calls\n")
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08001880{
1881 struct gsm_bts *bts = vty->index;
1882
1883 if (atoi(argv[0]) == 0)
1884 bts->si_common.rach_control.t2 |= 0x4;
1885 else
1886 bts->si_common.rach_control.t2 &= ~0x4;
1887
1888 return CMD_SUCCESS;
1889}
1890
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001891DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1892 "ms max power <0-40>",
Harald Welte557f3992012-08-16 23:23:50 +02001893 "MS Options\n"
Harald Weltefa2015f2012-08-17 09:52:03 +02001894 "Maximum transmit power of the MS\n"
1895 "Maximum transmit power of the MS\n"
Harald Welte557f3992012-08-16 23:23:50 +02001896 "Maximum transmit power of the MS in dBm")
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001897{
1898 struct gsm_bts *bts = vty->index;
1899
1900 bts->ms_max_power = atoi(argv[0]);
1901
1902 return CMD_SUCCESS;
1903}
1904
Harald Welte557f3992012-08-16 23:23:50 +02001905#define CELL_STR "Cell Parameters\n"
1906
Harald Welteb761bf82009-12-12 18:17:25 +01001907DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1908 "cell reselection hysteresis <0-14>",
Harald Welte557f3992012-08-16 23:23:50 +02001909 CELL_STR "Cell re-selection parameters\n"
1910 "Cell Re-Selection Hysteresis in dB\n"
Harald Welteb761bf82009-12-12 18:17:25 +01001911 "Cell Re-Selection Hysteresis in dB")
1912{
1913 struct gsm_bts *bts = vty->index;
1914
1915 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1916
1917 return CMD_SUCCESS;
1918}
1919
1920DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1921 "rxlev access min <0-63>",
Harald Welte557f3992012-08-16 23:23:50 +02001922 "Minimum RxLev needed for cell access\n"
1923 "Minimum RxLev needed for cell access\n"
1924 "Minimum RxLev needed for cell access\n"
Harald Welteb761bf82009-12-12 18:17:25 +01001925 "Minimum RxLev needed for cell access (better than -110dBm)")
1926{
1927 struct gsm_bts *bts = vty->index;
1928
1929 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1930
1931 return CMD_SUCCESS;
1932}
1933
Sylvain Munaut00d71462010-11-28 18:17:28 +01001934DEFUN(cfg_bts_cell_bar_qualify, cfg_bts_cell_bar_qualify_cmd,
1935 "cell bar qualify (0|1)",
Harald Welte557f3992012-08-16 23:23:50 +02001936 CELL_STR "Cell Bar Qualify\n" "Cell Bar Qualify\n"
1937 "Set CBQ to 0\n" "Set CBQ to 1\n")
Sylvain Munaut00d71462010-11-28 18:17:28 +01001938{
1939 struct gsm_bts *bts = vty->index;
1940
1941 bts->si_common.cell_ro_sel_par.present = 1;
1942 bts->si_common.cell_ro_sel_par.cbq = atoi(argv[0]);
1943
1944 return CMD_SUCCESS;
1945}
1946
1947DEFUN(cfg_bts_cell_resel_ofs, cfg_bts_cell_resel_ofs_cmd,
1948 "cell reselection offset <0-126>",
Harald Welte557f3992012-08-16 23:23:50 +02001949 CELL_STR "Cell Re-Selection Parameters\n"
1950 "Cell Re-Selection Offset (CRO) in dB\n"
1951 "Cell Re-Selection Offset (CRO) in dB\n"
1952 )
Sylvain Munaut00d71462010-11-28 18:17:28 +01001953{
1954 struct gsm_bts *bts = vty->index;
1955
1956 bts->si_common.cell_ro_sel_par.present = 1;
1957 bts->si_common.cell_ro_sel_par.cell_resel_off = atoi(argv[0])/2;
1958
1959 return CMD_SUCCESS;
1960}
1961
1962DEFUN(cfg_bts_temp_ofs, cfg_bts_temp_ofs_cmd,
1963 "temporary offset <0-60>",
Harald Welte557f3992012-08-16 23:23:50 +02001964 "Cell selection temporary negative offset\n"
1965 "Cell selection temporary negative offset\n"
Sylvain Munaut00d71462010-11-28 18:17:28 +01001966 "Cell selection temporary negative offset in dB")
1967{
1968 struct gsm_bts *bts = vty->index;
1969
1970 bts->si_common.cell_ro_sel_par.present = 1;
1971 bts->si_common.cell_ro_sel_par.temp_offs = atoi(argv[0])/10;
1972
1973 return CMD_SUCCESS;
1974}
1975
1976DEFUN(cfg_bts_temp_ofs_inf, cfg_bts_temp_ofs_inf_cmd,
1977 "temporary offset infinite",
Harald Welte557f3992012-08-16 23:23:50 +02001978 "Cell selection temporary negative offset\n"
1979 "Cell selection temporary negative offset\n"
Sylvain Munaut00d71462010-11-28 18:17:28 +01001980 "Sets cell selection temporary negative offset to infinity")
1981{
1982 struct gsm_bts *bts = vty->index;
1983
1984 bts->si_common.cell_ro_sel_par.present = 1;
1985 bts->si_common.cell_ro_sel_par.temp_offs = 7;
1986
1987 return CMD_SUCCESS;
1988}
1989
1990DEFUN(cfg_bts_penalty_time, cfg_bts_penalty_time_cmd,
1991 "penalty time <20-620>",
Harald Welte557f3992012-08-16 23:23:50 +02001992 "Cell selection penalty time\n"
1993 "Cell selection penalty time\n"
1994 "Cell selection penalty time in seconds (by 20s increments)\n")
Sylvain Munaut00d71462010-11-28 18:17:28 +01001995{
1996 struct gsm_bts *bts = vty->index;
1997
1998 bts->si_common.cell_ro_sel_par.present = 1;
1999 bts->si_common.cell_ro_sel_par.penalty_time = (atoi(argv[0])-20)/20;
2000
2001 return CMD_SUCCESS;
2002}
2003
2004DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd,
2005 "penalty time reserved",
Harald Welte557f3992012-08-16 23:23:50 +02002006 "Cell selection penalty time\n"
2007 "Cell selection penalty time\n"
2008 "Set cell selection penalty time to reserved value 31, "
Sylvain Munaut00d71462010-11-28 18:17:28 +01002009 "(indicate that CELL_RESELECT_OFFSET is subtracted from C2 "
2010 "and TEMPORARY_OFFSET is ignored)")
2011{
2012 struct gsm_bts *bts = vty->index;
2013
2014 bts->si_common.cell_ro_sel_par.present = 1;
2015 bts->si_common.cell_ro_sel_par.penalty_time = 31;
2016
2017 return CMD_SUCCESS;
2018}
2019
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002020DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
2021 "periodic location update <0-1530>",
Harald Welte557f3992012-08-16 23:23:50 +02002022 "Periodic Location Updating Interval\n"
2023 "Periodic Location Updating Interval\n"
2024 "Periodic Location Updating Interval\n"
2025 "Periodic Location Updating Interval in Minutes\n")
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002026{
2027 struct gsm_bts *bts = vty->index;
2028
Dieter Spaarb0f746d2010-10-05 21:10:55 +02002029 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 6;
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002030
2031 return CMD_SUCCESS;
2032}
2033
Harald Welte9e002452010-05-11 21:53:49 +02002034#define GPRS_TEXT "GPRS Packet Network\n"
2035
Harald Welte410575a2010-03-14 23:30:30 +08002036DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welteb42fe342010-04-18 14:00:26 +02002037 "gprs cell bvci <2-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02002038 GPRS_TEXT
2039 "GPRS Cell Settings\n"
Harald Welte557f3992012-08-16 23:23:50 +02002040 "GPRS BSSGP VC Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08002041 "GPRS BSSGP VC Identifier")
2042{
2043 struct gsm_bts *bts = vty->index;
2044
Harald Weltecb20b7a2010-04-18 15:51:20 +02002045 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002046 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2047 return CMD_WARNING;
2048 }
2049
Harald Welte3055e332010-03-14 15:37:43 +08002050 bts->gprs.cell.bvci = atoi(argv[0]);
2051
2052 return CMD_SUCCESS;
2053}
2054
Harald Welte4a048c52010-03-22 11:48:36 +08002055DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
2056 "gprs nsei <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02002057 GPRS_TEXT
Harald Welte557f3992012-08-16 23:23:50 +02002058 "GPRS NS Entity Identifier\n"
Harald Welte4a048c52010-03-22 11:48:36 +08002059 "GPRS NS Entity Identifier")
2060{
2061 struct gsm_bts *bts = vty->index;
2062
Harald Weltecb20b7a2010-04-18 15:51:20 +02002063 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte4a048c52010-03-22 11:48:36 +08002064 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2065 return CMD_WARNING;
2066 }
2067
2068 bts->gprs.nse.nsei = atoi(argv[0]);
2069
2070 return CMD_SUCCESS;
2071}
2072
Harald Welte9e002452010-05-11 21:53:49 +02002073#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
2074 "NSVC Logical Number\n"
Harald Welte4a048c52010-03-22 11:48:36 +08002075
Harald Welte3055e332010-03-14 15:37:43 +08002076DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
2077 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02002078 GPRS_TEXT NSVC_TEXT
2079 "NS Virtual Connection Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08002080 "GPRS NS VC Identifier")
2081{
2082 struct gsm_bts *bts = vty->index;
2083 int idx = atoi(argv[0]);
2084
Harald Weltecb20b7a2010-04-18 15:51:20 +02002085 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002086 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2087 return CMD_WARNING;
2088 }
2089
Harald Welte3055e332010-03-14 15:37:43 +08002090 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
2091
2092 return CMD_SUCCESS;
2093}
2094
Harald Welte410575a2010-03-14 23:30:30 +08002095DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
2096 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02002097 GPRS_TEXT NSVC_TEXT
Harald Welte557f3992012-08-16 23:23:50 +02002098 "GPRS NS Local UDP Port\n"
2099 "GPRS NS Local UDP Port\n"
2100 "GPRS NS Local UDP Port\n"
Harald Welte764c8e12012-08-17 09:57:25 +02002101 "GPRS NS Local UDP Port Number\n")
Harald Welte410575a2010-03-14 23:30:30 +08002102{
2103 struct gsm_bts *bts = vty->index;
2104 int idx = atoi(argv[0]);
2105
Harald Weltecb20b7a2010-04-18 15:51:20 +02002106 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002107 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2108 return CMD_WARNING;
2109 }
2110
Harald Welte410575a2010-03-14 23:30:30 +08002111 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
2112
2113 return CMD_SUCCESS;
2114}
2115
2116DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
2117 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02002118 GPRS_TEXT NSVC_TEXT
Harald Welte557f3992012-08-16 23:23:50 +02002119 "GPRS NS Remote UDP Port\n"
2120 "GPRS NS Remote UDP Port\n"
Harald Welte764c8e12012-08-17 09:57:25 +02002121 "GPRS NS Remote UDP Port\n"
2122 "GPRS NS Remote UDP Port Number\n")
Harald Welte410575a2010-03-14 23:30:30 +08002123{
2124 struct gsm_bts *bts = vty->index;
2125 int idx = atoi(argv[0]);
2126
Harald Weltecb20b7a2010-04-18 15:51:20 +02002127 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002128 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2129 return CMD_WARNING;
2130 }
2131
Harald Welte410575a2010-03-14 23:30:30 +08002132 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
2133
2134 return CMD_SUCCESS;
2135}
2136
2137DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
2138 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte9e002452010-05-11 21:53:49 +02002139 GPRS_TEXT NSVC_TEXT
Harald Welte557f3992012-08-16 23:23:50 +02002140 "GPRS NS Remote IP Address\n"
2141 "GPRS NS Remote IP Address\n"
2142 "GPRS NS Remote IP Address\n")
Harald Welte410575a2010-03-14 23:30:30 +08002143{
2144 struct gsm_bts *bts = vty->index;
2145 int idx = atoi(argv[0]);
2146 struct in_addr ia;
2147
Harald Weltecb20b7a2010-04-18 15:51:20 +02002148 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002149 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2150 return CMD_WARNING;
2151 }
2152
Harald Welte410575a2010-03-14 23:30:30 +08002153 inet_aton(argv[1], &ia);
2154 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
2155
2156 return CMD_SUCCESS;
2157}
2158
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +08002159DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
Harald Welte557f3992012-08-16 23:23:50 +02002160 "paging free <-1-1024>",
2161 "Paging options\n"
2162 "Only page when having a certain amount of free slots\n"
2163 "amount of required free paging slots. -1 to disable\n")
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +08002164{
2165 struct gsm_bts *bts = vty->index;
2166
2167 bts->paging.free_chans_need = atoi(argv[0]);
2168 return CMD_SUCCESS;
2169}
2170
Harald Weltea9251762010-05-11 23:50:21 +02002171DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
2172 "gprs ns timer " NS_TIMERS " <0-255>",
2173 GPRS_TEXT "Network Service\n"
2174 "Network Service Timer\n"
2175 NS_TIMERS_HELP "Timer Value\n")
2176{
2177 struct gsm_bts *bts = vty->index;
2178 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
2179 int val = atoi(argv[1]);
2180
2181 if (bts->gprs.mode == BTS_GPRS_NONE) {
2182 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2183 return CMD_WARNING;
2184 }
2185
2186 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
2187 return CMD_WARNING;
2188
2189 bts->gprs.nse.timer[idx] = val;
2190
2191 return CMD_SUCCESS;
2192}
2193
2194#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 Welte18ce31c2010-05-14 20:05:17 +02002195#define BSSGP_TIMERS_HELP \
2196 "Tbvc-block timeout\n" \
2197 "Tbvc-block retries\n" \
2198 "Tbvc-unblock retries\n" \
2199 "Tbvcc-reset timeout\n" \
2200 "Tbvc-reset retries\n" \
2201 "Tbvc-suspend timeout\n" \
2202 "Tbvc-suspend retries\n" \
2203 "Tbvc-resume timeout\n" \
2204 "Tbvc-resume retries\n" \
2205 "Tbvc-capa-update timeout\n" \
2206 "Tbvc-capa-update retries\n"
Harald Weltea9251762010-05-11 23:50:21 +02002207
2208DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
2209 "gprs cell timer " BSSGP_TIMERS " <0-255>",
2210 GPRS_TEXT "Cell / BSSGP\n"
2211 "Cell/BSSGP Timer\n"
2212 BSSGP_TIMERS_HELP "Timer Value\n")
2213{
2214 struct gsm_bts *bts = vty->index;
2215 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
2216 int val = atoi(argv[1]);
2217
2218 if (bts->gprs.mode == BTS_GPRS_NONE) {
2219 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2220 return CMD_WARNING;
2221 }
2222
2223 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
2224 return CMD_WARNING;
2225
2226 bts->gprs.cell.timer[idx] = val;
2227
2228 return CMD_SUCCESS;
2229}
2230
Harald Welte3055e332010-03-14 15:37:43 +08002231DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
2232 "gprs routing area <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02002233 GPRS_TEXT
Harald Welte557f3992012-08-16 23:23:50 +02002234 "GPRS Routing Area Code\n"
2235 "GPRS Routing Area Code\n"
2236 "GPRS Routing Area Code\n")
Harald Welte3055e332010-03-14 15:37:43 +08002237{
2238 struct gsm_bts *bts = vty->index;
2239
Harald Weltecb20b7a2010-04-18 15:51:20 +02002240 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002241 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2242 return CMD_WARNING;
2243 }
2244
Harald Welte3055e332010-03-14 15:37:43 +08002245 bts->gprs.rac = atoi(argv[0]);
2246
2247 return CMD_SUCCESS;
2248}
2249
Harald Weltecb20b7a2010-04-18 15:51:20 +02002250DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
2251 "gprs mode (none|gprs|egprs)",
Harald Welte9e002452010-05-11 21:53:49 +02002252 GPRS_TEXT
2253 "GPRS Mode for this BTS\n"
2254 "GPRS Disabled on this BTS\n"
2255 "GPRS Enabled on this BTS\n"
2256 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welte410575a2010-03-14 23:30:30 +08002257{
2258 struct gsm_bts *bts = vty->index;
Harald Welte20e275a2010-06-14 22:44:42 +02002259 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welte410575a2010-03-14 23:30:30 +08002260
Harald Welte20e275a2010-06-14 22:44:42 +02002261 if (mode != BTS_GPRS_NONE &&
2262 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
2263 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2264 VTY_NEWLINE);
2265 return CMD_WARNING;
2266 }
2267 if (mode == BTS_GPRS_EGPRS &&
2268 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
2269 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2270 VTY_NEWLINE);
2271 return CMD_WARNING;
2272 }
2273
2274 bts->gprs.mode = mode;
Harald Welte410575a2010-03-14 23:30:30 +08002275
2276 return CMD_SUCCESS;
2277}
2278
Harald Welted8acf142010-07-30 11:50:09 +02002279#define SI_TEXT "System Information Messages\n"
2280#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)"
2281#define SI_TYPE_HELP "System Information Type 1\n" \
2282 "System Information Type 2\n" \
2283 "System Information Type 3\n" \
2284 "System Information Type 4\n" \
2285 "System Information Type 5\n" \
2286 "System Information Type 6\n" \
2287 "System Information Type 7\n" \
2288 "System Information Type 8\n" \
2289 "System Information Type 9\n" \
2290 "System Information Type 10\n" \
2291 "System Information Type 13\n" \
2292 "System Information Type 16\n" \
2293 "System Information Type 17\n" \
2294 "System Information Type 18\n" \
2295 "System Information Type 19\n" \
2296 "System Information Type 20\n" \
2297 "System Information Type 2bis\n" \
2298 "System Information Type 2ter\n" \
2299 "System Information Type 2quater\n" \
2300 "System Information Type 5bis\n" \
2301 "System Information Type 5ter\n"
2302
2303DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
2304 "system-information " SI_TYPE_TEXT " mode (static|computed)",
2305 SI_TEXT SI_TYPE_HELP
2306 "System Information Mode\n"
2307 "Static user-specified\n"
2308 "Dynamic, BSC-computed\n")
2309{
2310 struct gsm_bts *bts = vty->index;
2311 int type;
2312
2313 type = get_string_value(osmo_sitype_strs, argv[0]);
2314 if (type < 0) {
2315 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2316 return CMD_WARNING;
2317 }
2318
2319 if (!strcmp(argv[1], "static"))
2320 bts->si_mode_static |= (1 << type);
2321 else
2322 bts->si_mode_static &= ~(1 << type);
2323
2324 return CMD_SUCCESS;
2325}
2326
2327DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
2328 "system-information " SI_TYPE_TEXT " static HEXSTRING",
2329 SI_TEXT SI_TYPE_HELP
2330 "Static System Information filling\n"
2331 "Static user-specified SI content in HEX notation\n")
2332{
2333 struct gsm_bts *bts = vty->index;
2334 int rc, type;
2335
2336 type = get_string_value(osmo_sitype_strs, argv[0]);
2337 if (type < 0) {
2338 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2339 return CMD_WARNING;
2340 }
2341
2342 if (!(bts->si_mode_static & (1 << type))) {
2343 vty_out(vty, "SI Type %s is not configured in static mode%s",
2344 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
2345 return CMD_WARNING;
2346 }
2347
Harald Welte9f09ac32010-07-30 11:53:18 +02002348 /* Fill buffer with padding pattern */
2349 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
2350
2351 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Pablo Neira Ayusob1d5a692011-05-07 12:12:48 +02002352 rc = osmo_hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
Harald Welted8acf142010-07-30 11:50:09 +02002353 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
2354 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
2355 return CMD_WARNING;
2356 }
2357
2358 /* Mark this SI as present */
2359 bts->si_valid |= (1 << type);
2360
2361 return CMD_SUCCESS;
2362}
2363
Harald Welteca46eff2011-01-11 23:44:56 +01002364DEFUN(cfg_bts_neigh_mode, cfg_bts_neigh_mode_cmd,
Harald Weltef989b782011-02-15 11:43:27 +01002365 "neighbor-list mode (automatic|manual|manual-si5)",
Harald Welteca46eff2011-01-11 23:44:56 +01002366 "Neighbor List\n" "Mode of Neighbor List generation\n"
Harald Weltef989b782011-02-15 11:43:27 +01002367 "Automatically from all BTS in this OpenBSC\n" "Manual\n"
2368 "Manual with different lists for SI2 and SI5\n")
Harald Welteca46eff2011-01-11 23:44:56 +01002369{
2370 struct gsm_bts *bts = vty->index;
Harald Weltef989b782011-02-15 11:43:27 +01002371 int mode = get_string_value(bts_neigh_mode_strs, argv[0]);
Harald Welteca46eff2011-01-11 23:44:56 +01002372
Harald Weltef989b782011-02-15 11:43:27 +01002373 switch (mode) {
2374 case NL_MODE_MANUAL_SI5SEP:
2375 case NL_MODE_MANUAL:
Harald Welteca46eff2011-01-11 23:44:56 +01002376 /* make sure we clear the current list when switching to
2377 * manual mode */
2378 if (bts->neigh_list_manual_mode == 0)
2379 memset(&bts->si_common.data.neigh_list, 0,
2380 sizeof(bts->si_common.data.neigh_list));
Harald Weltef989b782011-02-15 11:43:27 +01002381 break;
2382 default:
2383 break;
2384 }
2385
2386 bts->neigh_list_manual_mode = mode;
Harald Welteca46eff2011-01-11 23:44:56 +01002387
2388 return CMD_SUCCESS;
2389}
2390
2391DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd,
Harald Welte09e4fad2012-01-29 13:24:12 +01002392 "neighbor-list (add|del) arfcn <0-1023>",
Harald Welteca46eff2011-01-11 23:44:56 +01002393 "Neighbor List\n" "Add to manual neighbor list\n"
2394 "Delete from manual neighbor list\n" "ARFCN of neighbor\n"
2395 "ARFCN of neighbor\n")
2396{
2397 struct gsm_bts *bts = vty->index;
2398 struct bitvec *bv = &bts->si_common.neigh_list;
2399 uint16_t arfcn = atoi(argv[1]);
2400
2401 if (!bts->neigh_list_manual_mode) {
2402 vty_out(vty, "%% Cannot configure neighbor list in "
2403 "automatic mode%s", VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 if (!strcmp(argv[0], "add"))
2408 bitvec_set_bit_pos(bv, arfcn, 1);
2409 else
2410 bitvec_set_bit_pos(bv, arfcn, 0);
2411
2412 return CMD_SUCCESS;
2413}
2414
Harald Weltef989b782011-02-15 11:43:27 +01002415DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd,
Harald Welte09e4fad2012-01-29 13:24:12 +01002416 "si5 neighbor-list (add|del) arfcn <0-1023>",
Harald Welte557f3992012-08-16 23:23:50 +02002417 "SI5 Neighbor List\n"
Harald Weltef989b782011-02-15 11:43:27 +01002418 "SI5 Neighbor List\n" "Add to manual SI5 neighbor list\n"
2419 "Delete from SI5 manual neighbor list\n" "ARFCN of neighbor\n"
2420 "ARFCN of neighbor\n")
2421{
2422 struct gsm_bts *bts = vty->index;
2423 struct bitvec *bv = &bts->si_common.si5_neigh_list;
2424 uint16_t arfcn = atoi(argv[1]);
2425
2426 if (!bts->neigh_list_manual_mode) {
2427 vty_out(vty, "%% Cannot configure neighbor list in "
2428 "automatic mode%s", VTY_NEWLINE);
2429 return CMD_WARNING;
2430 }
2431
2432 if (!strcmp(argv[0], "add"))
2433 bitvec_set_bit_pos(bv, arfcn, 1);
2434 else
2435 bitvec_set_bit_pos(bv, arfcn, 0);
2436
2437 return CMD_SUCCESS;
2438}
Harald Welted8acf142010-07-30 11:50:09 +02002439
Harald Welte9e002452010-05-11 21:53:49 +02002440#define TRX_TEXT "Radio Transceiver\n"
Harald Welte3e774612009-08-10 13:48:16 +02002441
Harald Welte59b04682009-06-10 05:40:52 +08002442/* per TRX configuration */
2443DEFUN(cfg_trx,
2444 cfg_trx_cmd,
Harald Welte2af06cb2012-08-17 12:50:14 +02002445 "trx <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02002446 TRX_TEXT
Harald Welte59b04682009-06-10 05:40:52 +08002447 "Select a TRX to configure")
2448{
2449 int trx_nr = atoi(argv[0]);
2450 struct gsm_bts *bts = vty->index;
2451 struct gsm_bts_trx *trx;
2452
Harald Weltee712a5f2009-06-21 16:17:15 +02002453 if (trx_nr > bts->num_trx) {
2454 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
2455 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08002456 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02002457 } else if (trx_nr == bts->num_trx) {
2458 /* we need to allocate a new one */
2459 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02002460 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02002461 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02002462
Harald Weltee712a5f2009-06-21 16:17:15 +02002463 if (!trx)
2464 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08002465
2466 vty->index = trx;
Harald Welte8791dac2010-05-14 17:59:53 +02002467 vty->index_sub = &trx->description;
Harald Welte59b04682009-06-10 05:40:52 +08002468 vty->node = TRX_NODE;
2469
2470 return CMD_SUCCESS;
2471}
2472
2473DEFUN(cfg_trx_arfcn,
2474 cfg_trx_arfcn_cmd,
Harald Welte09e4fad2012-01-29 13:24:12 +01002475 "arfcn <0-1023>",
Harald Welte764c8e12012-08-17 09:57:25 +02002476 "Set the ARFCN for this TRX\n"
2477 "Absolute Radio Frequency Channel Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08002478{
2479 int arfcn = atoi(argv[0]);
2480 struct gsm_bts_trx *trx = vty->index;
2481
2482 /* FIXME: check if this ARFCN is supported by this TRX */
2483
2484 trx->arfcn = arfcn;
2485
2486 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
2487 /* FIXME: use OML layer to update the ARFCN */
2488 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2489
2490 return CMD_SUCCESS;
2491}
2492
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002493DEFUN(cfg_trx_nominal_power,
2494 cfg_trx_nominal_power_cmd,
2495 "nominal power <0-100>",
Harald Welte557f3992012-08-16 23:23:50 +02002496 "Nominal TRX RF Power in dBm\n"
2497 "Nominal TRX RF Power in dBm\n"
2498 "Nominal TRX RF Power in dBm\n")
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002499{
2500 struct gsm_bts_trx *trx = vty->index;
2501
2502 trx->nominal_power = atoi(argv[0]);
2503
2504 return CMD_SUCCESS;
2505}
2506
Harald Welte91afe4c2009-06-20 18:15:19 +02002507DEFUN(cfg_trx_max_power_red,
2508 cfg_trx_max_power_red_cmd,
2509 "max_power_red <0-100>",
Harald Welte557f3992012-08-16 23:23:50 +02002510 "Reduction of maximum BS RF Power (relative to nominal power)\n"
Harald Welte91afe4c2009-06-20 18:15:19 +02002511 "Reduction of maximum BS RF Power in dB\n")
2512{
2513 int maxpwr_r = atoi(argv[0]);
2514 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01002515 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02002516
2517 /* FIXME: check if our BTS type supports more than 12 */
2518 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2519 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2520 maxpwr_r, VTY_NEWLINE);
2521 return CMD_WARNING;
2522 }
2523 if (maxpwr_r & 1) {
2524 vty_out(vty, "%% Power %d dB is not an even value%s",
2525 maxpwr_r, VTY_NEWLINE);
2526 return CMD_WARNING;
2527 }
2528
2529 trx->max_power_red = maxpwr_r;
2530
2531 /* FIXME: make sure we update this using OML */
2532
2533 return CMD_SUCCESS;
2534}
2535
Harald Welte62868882009-08-08 16:12:58 +02002536DEFUN(cfg_trx_rsl_e1,
2537 cfg_trx_rsl_e1_cmd,
2538 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte557f3992012-08-16 23:23:50 +02002539 "RSL Parameters\n"
2540 "E1/T1 interface to be used for RSL\n"
2541 "E1/T1 interface to be used for RSL\n"
2542 "E1/T1 Line Number to be used for RSL\n"
2543 "E1/T1 Timeslot to be used for RSL\n"
2544 "E1/T1 Timeslot to be used for RSL\n"
2545 "E1/T1 Sub-slot to be used for RSL\n"
2546 "E1/T1 Sub-slot 0 is to be used for RSL\n"
2547 "E1/T1 Sub-slot 1 is to be used for RSL\n"
2548 "E1/T1 Sub-slot 2 is to be used for RSL\n"
2549 "E1/T1 Sub-slot 3 is to be used for RSL\n"
2550 "E1/T1 full timeslot is to be used for RSL\n")
Harald Welte62868882009-08-08 16:12:58 +02002551{
2552 struct gsm_bts_trx *trx = vty->index;
2553
2554 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2555
2556 return CMD_SUCCESS;
2557}
2558
2559DEFUN(cfg_trx_rsl_e1_tei,
2560 cfg_trx_rsl_e1_tei_cmd,
2561 "rsl e1 tei <0-63>",
Harald Welte557f3992012-08-16 23:23:50 +02002562 "RSL Parameters\n"
2563 "Set the TEI to be used for RSL\n"
2564 "Set the TEI to be used for RSL\n"
2565 "TEI to be used for RSL\n")
Harald Welte62868882009-08-08 16:12:58 +02002566{
2567 struct gsm_bts_trx *trx = vty->index;
2568
2569 trx->rsl_tei = atoi(argv[0]);
2570
2571 return CMD_SUCCESS;
2572}
2573
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002574DEFUN(cfg_trx_rf_locked,
2575 cfg_trx_rf_locked_cmd,
2576 "rf_locked (0|1)",
Harald Welte557f3992012-08-16 23:23:50 +02002577 "Set or unset the RF Locking (Turn off RF of the TRX)\n"
2578 "TRX is NOT RF locked (active)\n"
2579 "TRX is RF locked (turned off)\n")
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002580{
2581 int locked = atoi(argv[0]);
2582 struct gsm_bts_trx *trx = vty->index;
2583
2584 gsm_trx_lock_rf(trx, locked);
2585 return CMD_SUCCESS;
2586}
Harald Welte62868882009-08-08 16:12:58 +02002587
Harald Welte59b04682009-06-10 05:40:52 +08002588/* per TS configuration */
2589DEFUN(cfg_ts,
2590 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002591 "timeslot <0-7>",
Harald Welte557f3992012-08-16 23:23:50 +02002592 "Select a Timeslot to configure\n"
2593 "Timeslot number\n")
Harald Welte59b04682009-06-10 05:40:52 +08002594{
2595 int ts_nr = atoi(argv[0]);
2596 struct gsm_bts_trx *trx = vty->index;
2597 struct gsm_bts_trx_ts *ts;
2598
2599 if (ts_nr >= TRX_NR_TS) {
2600 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2601 TRX_NR_TS, VTY_NEWLINE);
2602 return CMD_WARNING;
2603 }
2604
2605 ts = &trx->ts[ts_nr];
2606
2607 vty->index = ts;
2608 vty->node = TS_NODE;
2609
2610 return CMD_SUCCESS;
2611}
2612
Harald Welte3ffe1b32009-08-07 00:25:23 +02002613DEFUN(cfg_ts_pchan,
2614 cfg_ts_pchan_cmd,
Harald Welte2addf852012-08-17 12:42:06 +02002615 "phys_chan_config PCHAN", /* dynamically generated! */
2616 "Physical Channel configuration (TCH/SDCCH/...)")
2617{
2618 struct gsm_bts_trx_ts *ts = vty->index;
2619 int pchanc;
2620
2621 pchanc = gsm_pchan_parse(argv[0]);
2622 if (pchanc < 0)
2623 return CMD_WARNING;
2624
2625 ts->pchan = pchanc;
2626
2627 return CMD_SUCCESS;
2628}
2629
2630/* used for backwards compatibility with old config files that still
2631 * have uppercase pchan type names */
2632DEFUN_HIDDEN(cfg_ts_pchan_compat,
2633 cfg_ts_pchan_compat_cmd,
Harald Welte3ffe1b32009-08-07 00:25:23 +02002634 "phys_chan_config PCHAN",
2635 "Physical Channel configuration (TCH/SDCCH/...)")
2636{
2637 struct gsm_bts_trx_ts *ts = vty->index;
2638 int pchanc;
2639
2640 pchanc = gsm_pchan_parse(argv[0]);
2641 if (pchanc < 0)
2642 return CMD_WARNING;
2643
2644 ts->pchan = pchanc;
2645
2646 return CMD_SUCCESS;
2647}
2648
Harald Welte2addf852012-08-17 12:42:06 +02002649
2650
Harald Welte85771a42011-05-30 12:09:13 +02002651DEFUN(cfg_ts_tsc,
2652 cfg_ts_tsc_cmd,
2653 "training_sequence_code <0-7>",
Harald Welte557f3992012-08-16 23:23:50 +02002654 "Training Sequence Code of the Timeslot\n" "TSC\n")
Harald Welte85771a42011-05-30 12:09:13 +02002655{
2656 struct gsm_bts_trx_ts *ts = vty->index;
2657
2658 ts->tsc = atoi(argv[0]);
2659
2660 return CMD_SUCCESS;
2661}
2662
Harald Weltea42a93f2010-06-14 22:26:10 +02002663#define HOPPING_STR "Configure frequency hopping\n"
2664
2665DEFUN(cfg_ts_hopping,
2666 cfg_ts_hopping_cmd,
2667 "hopping enabled (0|1)",
2668 HOPPING_STR "Enable or disable frequency hopping\n"
2669 "Disable frequency hopping\n" "Enable frequency hopping\n")
2670{
2671 struct gsm_bts_trx_ts *ts = vty->index;
Harald Welte059c1ef2010-06-14 22:47:37 +02002672 int enabled = atoi(argv[0]);
Harald Weltea42a93f2010-06-14 22:26:10 +02002673
Harald Welte059c1ef2010-06-14 22:47:37 +02002674 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2675 vty_out(vty, "BTS model does not support hopping%s",
2676 VTY_NEWLINE);
2677 return CMD_WARNING;
2678 }
2679
2680 ts->hopping.enabled = enabled;
Harald Weltea42a93f2010-06-14 22:26:10 +02002681
2682 return CMD_SUCCESS;
2683}
2684
Harald Welte67104d12009-09-12 13:05:33 +02002685DEFUN(cfg_ts_hsn,
2686 cfg_ts_hsn_cmd,
Harald Weltea42a93f2010-06-14 22:26:10 +02002687 "hopping sequence-number <0-63>",
2688 HOPPING_STR
Harald Welte557f3992012-08-16 23:23:50 +02002689 "Which hopping sequence to use for this channel\n"
2690 "Hopping Sequence Number (HSN)\n")
Harald Welte67104d12009-09-12 13:05:33 +02002691{
2692 struct gsm_bts_trx_ts *ts = vty->index;
2693
2694 ts->hopping.hsn = atoi(argv[0]);
2695
2696 return CMD_SUCCESS;
2697}
2698
2699DEFUN(cfg_ts_maio,
2700 cfg_ts_maio_cmd,
2701 "hopping maio <0-63>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002702 HOPPING_STR
Harald Welte557f3992012-08-16 23:23:50 +02002703 "Which hopping MAIO to use for this channel\n"
2704 "Mobile Allocation Index Offset (MAIO)\n")
Harald Welte67104d12009-09-12 13:05:33 +02002705{
2706 struct gsm_bts_trx_ts *ts = vty->index;
2707
2708 ts->hopping.maio = atoi(argv[0]);
2709
2710 return CMD_SUCCESS;
2711}
2712
2713DEFUN(cfg_ts_arfcn_add,
2714 cfg_ts_arfcn_add_cmd,
2715 "hopping arfcn add <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002716 HOPPING_STR "Configure hopping ARFCN list\n"
2717 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002718{
2719 struct gsm_bts_trx_ts *ts = vty->index;
2720 int arfcn = atoi(argv[0]);
2721
Harald Weltea42a93f2010-06-14 22:26:10 +02002722 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2723
Harald Welte67104d12009-09-12 13:05:33 +02002724 return CMD_SUCCESS;
2725}
2726
2727DEFUN(cfg_ts_arfcn_del,
2728 cfg_ts_arfcn_del_cmd,
2729 "hopping arfcn del <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002730 HOPPING_STR "Configure hopping ARFCN list\n"
2731 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002732{
2733 struct gsm_bts_trx_ts *ts = vty->index;
2734 int arfcn = atoi(argv[0]);
2735
Harald Weltea42a93f2010-06-14 22:26:10 +02002736 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2737
Harald Welte67104d12009-09-12 13:05:33 +02002738 return CMD_SUCCESS;
2739}
2740
Harald Welte3ffe1b32009-08-07 00:25:23 +02002741DEFUN(cfg_ts_e1_subslot,
2742 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002743 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte557f3992012-08-16 23:23:50 +02002744 "E1/T1 channel connected to this on-air timeslot\n"
2745 "E1/T1 channel connected to this on-air timeslot\n"
2746 "E1/T1 line connected to this on-air timeslot\n"
Harald Weltefa2015f2012-08-17 09:52:03 +02002747 "E1/T1 timeslot connected to this on-air timeslot\n"
2748 "E1/T1 timeslot connected to this on-air timeslot\n"
Harald Welte557f3992012-08-16 23:23:50 +02002749 "E1/T1 sub-slot connected to this on-air timeslot\n"
2750 "E1/T1 sub-slot 0 connected to this on-air timeslot\n"
2751 "E1/T1 sub-slot 1 connected to this on-air timeslot\n"
2752 "E1/T1 sub-slot 2 connected to this on-air timeslot\n"
2753 "E1/T1 sub-slot 3 connected to this on-air timeslot\n"
2754 "Full E1/T1 timeslot connected to this on-air timeslot\n")
Harald Welte3ffe1b32009-08-07 00:25:23 +02002755{
2756 struct gsm_bts_trx_ts *ts = vty->index;
2757
Harald Welte62868882009-08-08 16:12:58 +02002758 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002759
2760 return CMD_SUCCESS;
2761}
Harald Welte59b04682009-06-10 05:40:52 +08002762
Harald Weltea5b1dae2010-05-16 21:47:13 +02002763void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2764{
2765 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002766 osmo_counter_get(net->stats.chreq.total),
2767 osmo_counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002768 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002769 osmo_counter_get(net->stats.chan.rf_fail),
2770 osmo_counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002771 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002772 osmo_counter_get(net->stats.paging.attempted),
2773 osmo_counter_get(net->stats.paging.completed),
2774 osmo_counter_get(net->stats.paging.expired), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002775 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002776 osmo_counter_get(net->stats.bts.oml_fail),
2777 osmo_counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002778}
2779
Harald Welte682ee5f2010-05-16 22:02:16 +02002780DEFUN(logging_fltr_imsi,
2781 logging_fltr_imsi_cmd,
2782 "logging filter imsi IMSI",
2783 LOGGING_STR FILTER_STR
2784 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2785{
Harald Welte58bef962011-02-18 21:10:05 +01002786 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte682ee5f2010-05-16 22:02:16 +02002787
Harald Welte58bef962011-02-18 21:10:05 +01002788 if (!tgt)
Harald Welte682ee5f2010-05-16 22:02:16 +02002789 return CMD_WARNING;
Harald Welte682ee5f2010-05-16 22:02:16 +02002790
Harald Welte58bef962011-02-18 21:10:05 +01002791 log_set_imsi_filter(tgt, argv[0]);
Harald Welte682ee5f2010-05-16 22:02:16 +02002792 return CMD_SUCCESS;
2793}
2794
Harald Welte58bef962011-02-18 21:10:05 +01002795
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002796DEFUN(drop_bts,
2797 drop_bts_cmd,
Holger Hans Peter Freythere4ac0e42010-04-11 12:46:45 +02002798 "drop bts connection <0-65535> (oml|rsl)",
Harald Welte557f3992012-08-16 23:23:50 +02002799 "Debug/Simulation command to drop Abis/IP BTS\n"
2800 "Debug/Simulation command to drop Abis/IP BTS\n"
2801 "Debug/Simulation command to drop Abis/IP BTS\n"
2802 "BTS NR\n" "Drop OML Connection\n" "Drop RSL Connection\n")
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002803{
2804 struct gsm_network *gsmnet;
2805 struct gsm_bts_trx *trx;
2806 struct gsm_bts *bts;
2807 unsigned int bts_nr;
2808
2809 gsmnet = gsmnet_from_vty(vty);
2810
2811 bts_nr = atoi(argv[0]);
2812 if (bts_nr >= gsmnet->num_bts) {
2813 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
2814 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
2815 return CMD_WARNING;
2816 }
2817
2818 bts = gsm_bts_num(gsmnet, bts_nr);
2819 if (!bts) {
2820 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
2821 return CMD_WARNING;
2822 }
2823
2824 if (!is_ipaccess_bts(bts)) {
2825 vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
2826 return CMD_WARNING;
2827 }
2828
2829
2830 /* close all connections */
2831 if (strcmp(argv[1], "oml") == 0) {
Holger Hans Peter Freyther03f17d02010-11-15 20:29:46 +01002832 ipaccess_drop_oml(bts);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002833 } else if (strcmp(argv[1], "rsl") == 0) {
2834 /* close all rsl connections */
2835 llist_for_each_entry(trx, &bts->trx_list, list) {
Holger Hans Peter Freyther03f17d02010-11-15 20:29:46 +01002836 ipaccess_drop_rsl(trx);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002837 }
2838 } else {
2839 vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
2840 return CMD_WARNING;
2841 }
2842
2843 return CMD_SUCCESS;
2844}
2845
Harald Welte5213e992010-12-23 13:18:07 +01002846DEFUN(pdch_act, pdch_act_cmd,
2847 "bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
2848 "BTS related commands\n" "BTS Number\n" "Transceiver\n" "Transceiver Number\n"
2849 "TRX Timeslot\n" "Timeslot Number\n" "Packet Data Channel\n"
2850 "Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
2851 "Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
2852{
2853 struct gsm_bts *bts;
2854 struct gsm_bts_trx *trx;
2855 struct gsm_bts_trx_ts *ts;
2856 int bts_nr = atoi(argv[0]);
2857 int trx_nr = atoi(argv[1]);
2858 int ts_nr = atoi(argv[2]);
2859 int activate;
2860
2861 bts = gsm_bts_num(bsc_gsmnet, bts_nr);
2862 if (!bts) {
2863 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
2864 return CMD_WARNING;
2865 }
2866
2867 if (!is_ipaccess_bts(bts)) {
2868 vty_out(vty, "%% This command only works for ipaccess BTS%s",
2869 VTY_NEWLINE);
2870 return CMD_WARNING;
2871 }
2872
2873 trx = gsm_bts_trx_num(bts, trx_nr);
2874 if (!trx) {
2875 vty_out(vty, "%% No such TRX (%d)%s", trx_nr, VTY_NEWLINE);
2876 return CMD_WARNING;
2877 }
2878
2879 ts = &trx->ts[ts_nr];
2880 if (ts->pchan != GSM_PCHAN_TCH_F_PDCH) {
2881 vty_out(vty, "%% Timeslot %u is not in dynamic TCH_F/PDCH "
2882 "mode%s", ts_nr, VTY_NEWLINE);
2883 return CMD_WARNING;
2884 }
2885
2886 if (!strcmp(argv[3], "activate"))
2887 activate = 1;
2888 else
2889 activate = 0;
2890
2891 rsl_ipacc_pdch_activate(ts, activate);
2892
2893 return CMD_SUCCESS;
2894
2895}
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002896
Harald Welte40152872010-05-16 20:52:23 +02002897extern int bsc_vty_init_extra(void);
Harald Welte10c29f62010-05-16 19:20:24 +02002898extern const char *openbsc_copyright;
Holger Hans Peter Freytherc48a2a12010-04-10 00:08:28 +02002899
Pablo Neira Ayuso36ad9a42011-03-09 13:36:32 +01002900int bsc_vty_init(const struct log_info *cat)
Harald Welte59b04682009-06-10 05:40:52 +08002901{
Harald Welte2addf852012-08-17 12:42:06 +02002902 cfg_ts_pchan_cmd.string =
2903 vty_cmd_string_from_valstr(tall_bsc_ctx,
2904 gsm_pchant_names,
2905 "phys_chan_config (", "|", ")",
2906 VTY_DO_LOWER);
2907 cfg_ts_pchan_cmd.doc =
2908 vty_cmd_string_from_valstr(tall_bsc_ctx,
2909 gsm_pchant_descs,
2910 "Physical Channel Combination\n",
2911 "\n", "", 0);
2912
Harald Welte85a77b12012-08-17 13:02:12 +02002913 cfg_bts_type_cmd.string =
2914 vty_cmd_string_from_valstr(tall_bsc_ctx,
2915 bts_type_names,
2916 "type (", "|", ")",
2917 VTY_DO_LOWER);
2918 cfg_bts_type_cmd.doc =
2919 vty_cmd_string_from_valstr(tall_bsc_ctx,
2920 bts_type_descs,
2921 "BTS Vendor/Type\n",
2922 "\n", "", 0);
2923
2924
Harald Welte7bc28f62010-05-12 16:10:35 +00002925 install_element_ve(&show_net_cmd);
2926 install_element_ve(&show_bts_cmd);
2927 install_element_ve(&show_trx_cmd);
2928 install_element_ve(&show_ts_cmd);
2929 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08002930 install_element_ve(&show_lchan_summary_cmd);
Harald Welte682ee5f2010-05-16 22:02:16 +02002931 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002932
Harald Welte7bc28f62010-05-12 16:10:35 +00002933 install_element_ve(&show_paging_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002934
Pablo Neira Ayuso36ad9a42011-03-09 13:36:32 +01002935 logging_vty_add_cmds(cat);
Harald Welte58bef962011-02-18 21:10:05 +01002936 install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +01002937
Harald Weltee87eb462009-08-07 13:29:14 +02002938 install_element(CONFIG_NODE, &cfg_net_cmd);
2939 install_node(&net_node, config_write_net);
2940 install_default(GSMNET_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002941 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002942 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002943 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002944 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2945 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2946 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02002947 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte59936d72009-11-18 20:33:19 +01002948 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09002949 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01002950 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welte52af1952009-12-13 10:53:12 +01002951 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte284ddba2009-12-14 17:49:15 +01002952 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Welte0af9c9f2009-12-19 21:41:52 +01002953 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Weltea8062f12009-12-21 16:51:50 +01002954 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2955 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2956 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2957 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2958 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2959 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01002960 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002961 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2962 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2963 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2964 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2965 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2966 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2967 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2968 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2969 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
Harald Weltee2aaf442010-12-23 22:53:50 +01002970 install_element(GSMNET_NODE, &cfg_net_T3122_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002971 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08002972 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +01002973 install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08002974 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002975
2976 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02002977 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08002978 install_default(BTS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002979 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002980 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002981 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002982 install_element(BTS_NODE, &cfg_description_cmd);
2983 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02002984 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02002985 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002986 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2987 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002988 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002989 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Gus Bourgf9dc16b2011-12-02 10:18:17 +01002990 install_element(BTS_NODE, &cfg_bts_timezone_cmd);
2991 install_element(BTS_NODE, &cfg_bts_no_timezone_cmd);
Harald Welte08011e22011-03-04 13:41:31 +01002992 install_element(BTS_NODE, &cfg_bts_serno_cmd);
Sylvain Munautcb8e8432011-10-17 14:04:55 +02002993 install_element(BTS_NODE, &cfg_bts_nokia_site_skip_reset_cmd);
Harald Welte25572872009-10-20 00:22:00 +02002994 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02002995 install_element(BTS_NODE, &cfg_bts_hsl_oml_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002996 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2997 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02002998 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01002999 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
3000 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Andreas Eversberg14e12f22012-10-13 07:27:47 +02003001 install_element(BTS_NODE, &cfg_bts_chan_desc_att_cmd);
3002 install_element(BTS_NODE, &cfg_bts_chan_desc_bs_pa_mfrms_cmd);
3003 install_element(BTS_NODE, &cfg_bts_chan_desc_bs_ag_blks_res_cmd);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08003004 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
3005 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02003006 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08003007 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02003008 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02003009 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welteb761bf82009-12-12 18:17:25 +01003010 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
3011 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Sylvain Munaut00d71462010-11-28 18:17:28 +01003012 install_element(BTS_NODE, &cfg_bts_cell_bar_qualify_cmd);
3013 install_element(BTS_NODE, &cfg_bts_cell_resel_ofs_cmd);
3014 install_element(BTS_NODE, &cfg_bts_temp_ofs_cmd);
3015 install_element(BTS_NODE, &cfg_bts_temp_ofs_inf_cmd);
3016 install_element(BTS_NODE, &cfg_bts_penalty_time_cmd);
3017 install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
Harald Weltecb20b7a2010-04-18 15:51:20 +02003018 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02003019 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08003020 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
3021 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02003022 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Welte4a048c52010-03-22 11:48:36 +08003023 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08003024 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welte410575a2010-03-14 23:30:30 +08003025 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
3026 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
3027 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +08003028 install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
Harald Welted8acf142010-07-30 11:50:09 +02003029 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
3030 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welteca46eff2011-01-11 23:44:56 +01003031 install_element(BTS_NODE, &cfg_bts_neigh_mode_cmd);
3032 install_element(BTS_NODE, &cfg_bts_neigh_cmd);
Harald Weltef989b782011-02-15 11:43:27 +01003033 install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08003034
3035 install_element(BTS_NODE, &cfg_trx_cmd);
3036 install_node(&trx_node, dummy_config_write);
3037 install_default(TRX_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02003038 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02003039 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08003040 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02003041 install_element(TRX_NODE, &cfg_description_cmd);
3042 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01003043 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02003044 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02003045 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
3046 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01003047 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08003048
3049 install_element(TRX_NODE, &cfg_ts_cmd);
3050 install_node(&ts_node, dummy_config_write);
3051 install_default(TS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02003052 install_element(TS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02003053 install_element(TS_NODE, &ournode_end_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02003054 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Welte2addf852012-08-17 12:42:06 +02003055 install_element(TS_NODE, &cfg_ts_pchan_compat_cmd);
Harald Welte85771a42011-05-30 12:09:13 +02003056 install_element(TS_NODE, &cfg_ts_tsc_cmd);
Harald Weltea42a93f2010-06-14 22:26:10 +02003057 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte67104d12009-09-12 13:05:33 +02003058 install_element(TS_NODE, &cfg_ts_hsn_cmd);
3059 install_element(TS_NODE, &cfg_ts_maio_cmd);
3060 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
3061 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02003062 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08003063
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02003064 install_element(ENABLE_NODE, &drop_bts_cmd);
Harald Welte5213e992010-12-23 13:18:07 +01003065 install_element(ENABLE_NODE, &pdch_act_cmd);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02003066
Harald Welte63b964e2010-05-31 16:40:40 +02003067 abis_nm_vty_init();
Harald Welte1d5a2062011-02-12 14:42:59 +01003068 abis_om2k_vty_init();
Harald Weltee76bea02011-02-05 13:54:41 +01003069 e1inp_vty_init();
Harald Welte63b964e2010-05-31 16:40:40 +02003070
Harald Welte40152872010-05-16 20:52:23 +02003071 bsc_vty_init_extra();
Harald Welte59b04682009-06-10 05:40:52 +08003072
3073 return 0;
3074}