blob: 5863015961b7f9520b62e7f3e9f8c537df3f0996 [file] [log] [blame]
Harald Welte68628e82009-03-10 12:17:57 +00001/* OpenBSC interface to quagga VTY */
Harald Welteaf387632010-03-14 23:30:30 +08002/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welte68628e82009-03-10 12:17:57 +00003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#include <stdlib.h>
22#include <unistd.h>
23#include <sys/types.h>
24
Harald Welte4b037e42010-05-19 19:45:32 +020025#include <osmocom/vty/command.h>
26#include <osmocom/vty/buffer.h>
27#include <osmocom/vty/vty.h>
28#include <osmocom/vty/logging.h>
29#include <osmocom/vty/telnet_interface.h>
Harald Welte68628e82009-03-10 12:17:57 +000030
31#include <arpa/inet.h>
32
Harald Weltedfe6c7d2010-02-20 16:24:02 +010033#include <osmocore/linuxlist.h>
Harald Welte68628e82009-03-10 12:17:57 +000034#include <openbsc/gsm_data.h>
Harald Welte68628e82009-03-10 12:17:57 +000035#include <openbsc/e1_input.h>
Harald Welte1bc77352009-03-10 19:47:51 +000036#include <openbsc/abis_nm.h>
Harald Welte9fbff4a2010-07-30 11:50:09 +020037#include <osmocore/utils.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010038#include <osmocore/gsm_utils.h>
Harald Welteb908cb72009-12-22 13:09:29 +010039#include <openbsc/chan_alloc.h>
Harald Welte8387a492009-12-22 21:43:14 +010040#include <openbsc/meas_rep.h>
Harald Welte40f82892009-05-23 17:31:39 +000041#include <openbsc/db.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010042#include <osmocore/talloc.h>
Holger Hans Peter Freyther3c712322010-04-06 11:55:37 +020043#include <openbsc/vty.h>
Harald Welte22229d62010-05-12 20:28:04 +020044#include <openbsc/gprs_ns.h>
Harald Welte9fbff4a2010-07-30 11:50:09 +020045#include <openbsc/system_information.h>
Harald Welte5bc61dc2010-05-16 22:02:16 +020046#include <openbsc/debug.h>
Harald Welte68628e82009-03-10 12:17:57 +000047
Harald Welte1353f962010-05-16 19:20:24 +020048#include "../bscconfig.h"
49
Harald Welteea4647d2010-05-12 17:19:53 +000050/* FIXME: this should go to some common file */
51static const struct value_string gprs_ns_timer_strs[] = {
Harald Welte615e9562010-05-11 23:50:21 +020052 { 0, "tns-block" },
53 { 1, "tns-block-retries" },
54 { 2, "tns-reset" },
55 { 3, "tns-reset-retries" },
56 { 4, "tns-test" },
57 { 5, "tns-alive" },
58 { 6, "tns-alive-retries" },
59 { 0, NULL }
60};
61
Harald Welteea4647d2010-05-12 17:19:53 +000062static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Welte615e9562010-05-11 23:50:21 +020063 { 0, "blocking-timer" },
64 { 1, "blocking-retries" },
65 { 2, "unblocking-retries" },
66 { 3, "reset-timer" },
67 { 4, "reset-retries" },
68 { 5, "suspend-timer" },
69 { 6, "suspend-retries" },
70 { 7, "resume-timer" },
71 { 8, "resume-retries" },
72 { 9, "capability-update-timer" },
73 { 10, "capability-update-retries" },
74 { 0, NULL }
75};
76
Harald Welte5013b2a2009-08-07 13:29:14 +020077struct cmd_node net_node = {
78 GSMNET_NODE,
79 "%s(network)#",
80 1,
81};
82
Harald Welte68628e82009-03-10 12:17:57 +000083struct cmd_node bts_node = {
84 BTS_NODE,
85 "%s(bts)#",
86 1,
87};
88
89struct cmd_node trx_node = {
90 TRX_NODE,
91 "%s(trx)#",
92 1,
93};
94
95struct cmd_node ts_node = {
96 TS_NODE,
97 "%s(ts)#",
98 1,
99};
100
Harald Welte39231152010-05-27 13:39:40 +0200101extern struct gsm_network *bsc_gsmnet;
102
Harald Weltedcccb182010-05-16 20:52:23 +0200103struct gsm_network *gsmnet_from_vty(struct vty *v)
104{
Harald Welte39231152010-05-27 13:39:40 +0200105 /* In case we read from the config file, the vty->priv cannot
106 * point to a struct telnet_connection, and thus conn->priv
107 * will not point to the gsm_network structure */
108#if 0
Harald Weltedcccb182010-05-16 20:52:23 +0200109 struct telnet_connection *conn = v->priv;
110 return (struct gsm_network *) conn->priv;
Harald Welte39231152010-05-27 13:39:40 +0200111#else
112 return bsc_gsmnet;
113#endif
Harald Weltedcccb182010-05-16 20:52:23 +0200114}
115
Harald Welte68628e82009-03-10 12:17:57 +0000116static int dummy_config_write(struct vty *v)
117{
118 return CMD_SUCCESS;
119}
120
121static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
122{
Harald Welte1bc77352009-03-10 19:47:51 +0000123 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
124 nm_opstate_name(nms->operational), nms->administrative,
125 nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000126}
127
Harald Welteb908cb72009-12-22 13:09:29 +0100128static void dump_pchan_load_vty(struct vty *vty, char *prefix,
129 const struct pchan_load *pl)
130{
131 int i;
132
133 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
134 const struct load_counter *lc = &pl->pchan[i];
135 unsigned int percent;
136
137 if (lc->total == 0)
138 continue;
139
140 percent = (lc->used * 100) / lc->total;
141
142 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
143 gsm_pchan_name(i), percent, lc->used, lc->total,
144 VTY_NEWLINE);
145 }
146}
147
Harald Welte68628e82009-03-10 12:17:57 +0000148static void net_dump_vty(struct vty *vty, struct gsm_network *net)
149{
Harald Welteb908cb72009-12-22 13:09:29 +0100150 struct pchan_load pl;
151
Harald Welteef235b52009-03-10 12:34:02 +0000152 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
153 "and has %u BTS%s", net->country_code, net->network_code,
154 net->num_bts, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000155 vty_out(vty, " Long network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000156 net->name_long, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000157 vty_out(vty, " Short network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000158 net->name_short, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200159 vty_out(vty, " Authentication policy: %s%s",
160 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100161 vty_out(vty, " Location updating reject cause: %u%s",
162 net->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900163 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
164 VTY_NEWLINE);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100165 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
166 VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100167 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
168 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100169 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
170 VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100171 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
172 VTY_NEWLINE);
Harald Welteb908cb72009-12-22 13:09:29 +0100173 network_chan_load(&pl, net);
174 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
175 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000176}
177
178DEFUN(show_net, show_net_cmd, "show network",
179 SHOW_STR "Display information about a GSM NETWORK\n")
180{
Harald Weltedcccb182010-05-16 20:52:23 +0200181 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000182 net_dump_vty(vty, net);
183
184 return CMD_SUCCESS;
185}
186
187static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
188{
Harald Welteedb37782009-05-01 14:59:07 +0000189 struct e1inp_line *line;
190
191 if (!e1l) {
192 vty_out(vty, " None%s", VTY_NEWLINE);
193 return;
194 }
195
196 line = e1l->ts->line;
197
198 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
199 line->num, line->driver->name, e1l->ts->num,
Harald Welte1bc77352009-03-10 19:47:51 +0000200 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000201 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000202 e1l->tei, e1l->sapi, VTY_NEWLINE);
203}
204
205static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
206{
Harald Welteb908cb72009-12-22 13:09:29 +0100207 struct pchan_load pl;
208
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200209 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Weltefcd24452009-06-20 18:15:19 +0200210 "BSIC %u, TSC %u and %u TRX%s",
211 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200212 bts->cell_identity,
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +0200213 bts->location_area_code, bts->bsic, bts->tsc,
Harald Weltefcd24452009-06-20 18:15:19 +0200214 bts->num_trx, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200215 vty_out(vty, "Description: %s%s",
216 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte1d8dbc42009-12-12 15:38:16 +0100217 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100218 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte1d8dbc42009-12-12 15:38:16 +0100219 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
220 VTY_NEWLINE);
221 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welte73225282009-12-12 18:17:25 +0100222 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100223 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
224 VTY_NEWLINE);
225 vty_out(vty, "RACH Max transmissions: %u%s",
226 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
227 VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100228 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200229 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte9fbff4a2010-07-30 11:50:09 +0200230 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
231 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000232 if (is_ipaccess_bts(bts))
Harald Welte8175e952009-10-20 00:22:00 +0200233 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte4cc34222009-05-01 15:12:31 +0000234 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte8175e952009-10-20 00:22:00 +0200235 bts->oml_tei, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000236 vty_out(vty, " NM State: ");
237 net_dump_nmstate(vty, &bts->nm_state);
238 vty_out(vty, " Site Mgr NM State: ");
239 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
240 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
241 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200242 if (!is_ipaccess_bts(bts)) {
243 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
244 e1isl_dump_vty(vty, bts->oml_link);
245 }
Harald Welte68628e82009-03-10 12:17:57 +0000246 /* FIXME: oml_link, chan_desc */
Harald Welteb908cb72009-12-22 13:09:29 +0100247 memset(&pl, 0, sizeof(pl));
248 bts_chan_load(&pl, bts);
249 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
250 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000251}
252
253DEFUN(show_bts, show_bts_cmd, "show bts [number]",
254 SHOW_STR "Display information about a BTS\n"
255 "BTS number")
256{
Harald Weltedcccb182010-05-16 20:52:23 +0200257 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000258 int bts_nr;
259
260 if (argc != 0) {
261 /* use the BTS number that the user has specified */
262 bts_nr = atoi(argv[0]);
263 if (bts_nr > net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000264 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000265 VTY_NEWLINE);
266 return CMD_WARNING;
267 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200268 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000269 return CMD_SUCCESS;
270 }
271 /* print all BTS's */
272 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200273 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000274
275 return CMD_SUCCESS;
276}
277
Harald Welte42581822009-08-08 16:12:58 +0200278/* utility functions */
279static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
280 const char *ts, const char *ss)
281{
282 e1_link->e1_nr = atoi(line);
283 e1_link->e1_ts = atoi(ts);
284 if (!strcmp(ss, "full"))
285 e1_link->e1_ts_ss = 255;
286 else
287 e1_link->e1_ts_ss = atoi(ss);
288}
289
290static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
291 const char *prefix)
292{
293 if (!e1_link->e1_ts)
294 return;
295
296 if (e1_link->e1_ts_ss == 255)
297 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
298 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
299 else
300 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
301 prefix, e1_link->e1_nr, e1_link->e1_ts,
302 e1_link->e1_ts_ss, VTY_NEWLINE);
303}
304
305
Harald Welte67ce0732009-08-06 19:06:46 +0200306static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
307{
Harald Welte42581822009-08-08 16:12:58 +0200308 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
309 if (ts->pchan != GSM_PCHAN_NONE)
310 vty_out(vty, " phys_chan_config %s%s",
311 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200312 vty_out(vty, " hopping enabled %u%s",
313 ts->hopping.enabled, VTY_NEWLINE);
314 if (ts->hopping.enabled) {
315 unsigned int i;
316 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200317 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200318 vty_out(vty, " hopping maio %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200319 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200320 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
321 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
322 continue;
323 vty_out(vty, " hopping arfcn add %u%s",
324 i, VTY_NEWLINE);
325 }
326 } else
Harald Welte42581822009-08-08 16:12:58 +0200327 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte67ce0732009-08-06 19:06:46 +0200328}
329
330static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
331{
332 int i;
333
Harald Welte5013b2a2009-08-07 13:29:14 +0200334 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200335 if (trx->description)
336 vty_out(vty, " description %s%s", trx->description,
337 VTY_NEWLINE);
Holger Hans Peter Freyther2ba40af2010-04-17 06:42:07 +0200338 vty_out(vty, " rf_locked %u%s",
339 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
340 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200341 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100342 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200343 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200344 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
345 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200346
347 for (i = 0; i < TRX_NR_TS; i++)
348 config_write_ts_single(vty, &trx->ts[i]);
349}
350
Harald Welte615e9562010-05-11 23:50:21 +0200351static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
352{
353 unsigned int i;
354 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
355 VTY_NEWLINE);
356 if (bts->gprs.mode == BTS_GPRS_NONE)
357 return;
358
359 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
360 VTY_NEWLINE);
361 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
362 VTY_NEWLINE);
363 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
364 vty_out(vty, " gprs cell timer %s %u%s",
365 get_value_string(gprs_bssgp_cfg_strs, i),
366 bts->gprs.cell.timer[i], VTY_NEWLINE);
367 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
368 VTY_NEWLINE);
369 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
370 vty_out(vty, " gprs ns timer %s %u%s",
371 get_value_string(gprs_ns_timer_strs, i),
372 bts->gprs.nse.timer[i], VTY_NEWLINE);
373 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
374 struct gsm_bts_gprs_nsvc *nsvc =
375 &bts->gprs.nsvc[i];
376 struct in_addr ia;
377
378 ia.s_addr = htonl(nsvc->remote_ip);
379 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
380 nsvc->nsvci, VTY_NEWLINE);
381 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
382 nsvc->local_port, VTY_NEWLINE);
383 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
384 nsvc->remote_port, VTY_NEWLINE);
385 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
386 inet_ntoa(ia), VTY_NEWLINE);
387 }
388}
389
Harald Welte67ce0732009-08-06 19:06:46 +0200390static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
391{
392 struct gsm_bts_trx *trx;
Harald Welte9fbff4a2010-07-30 11:50:09 +0200393 int i;
Harald Welte67ce0732009-08-06 19:06:46 +0200394
Harald Welte5013b2a2009-08-07 13:29:14 +0200395 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
396 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200397 if (bts->description)
398 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200399 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freytherf926ed62009-11-19 16:38:49 +0100400 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200401 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200402 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200403 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
404 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200405 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100406 vty_out(vty, " cell reselection hysteresis %u%s",
407 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
408 vty_out(vty, " rxlev access min %u%s",
409 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Harald Weltea43f7892009-12-01 18:04:30 +0530410 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)efc92312009-08-14 23:09:25 +0200411 vty_out(vty, " periodic location update %u%s",
Harald Weltea43f7892009-12-01 18:04:30 +0530412 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte7a8fa412009-08-10 13:48:16 +0200413 vty_out(vty, " channel allocator %s%s",
414 bts->chan_alloc_reverse ? "descending" : "ascending",
415 VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100416 vty_out(vty, " rach tx integer %u%s",
417 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
418 vty_out(vty, " rach max transmission %u%s",
419 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
420 VTY_NEWLINE);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800421
422 if (bts->rach_b_thresh != -1)
423 vty_out(vty, " rach nm busy threshold %u%s",
424 bts->rach_b_thresh, VTY_NEWLINE);
425 if (bts->rach_ldavg_slots != -1)
426 vty_out(vty, " rach nm load average %u%s",
427 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100428 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200429 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +0800430 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
431 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welte9fbff4a2010-07-30 11:50:09 +0200432 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
433 if (bts->si_mode_static & (1 << i)) {
434 vty_out(vty, " system-information %s mode static%s",
435 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
436 vty_out(vty, " system-information %s static %s%s",
437 get_value_string(osmo_sitype_strs, i),
438 hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
439 VTY_NEWLINE);
440 }
441 }
Harald Welte8175e952009-10-20 00:22:00 +0200442 if (is_ipaccess_bts(bts)) {
Harald Welte5013b2a2009-08-07 13:29:14 +0200443 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200444 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200445 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
446 } else {
Harald Welte42581822009-08-08 16:12:58 +0200447 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
448 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
449 }
Harald Welte615e9562010-05-11 23:50:21 +0200450 config_write_bts_gprs(vty, bts);
Harald Welte67ce0732009-08-06 19:06:46 +0200451
452 llist_for_each_entry(trx, &bts->trx_list, list)
453 config_write_trx_single(vty, trx);
454}
455
456static int config_write_bts(struct vty *v)
457{
Harald Weltedcccb182010-05-16 20:52:23 +0200458 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte67ce0732009-08-06 19:06:46 +0200459 struct gsm_bts *bts;
460
461 llist_for_each_entry(bts, &gsmnet->bts_list, list)
462 config_write_bts_single(v, bts);
463
464 return CMD_SUCCESS;
465}
466
Harald Welte5013b2a2009-08-07 13:29:14 +0200467static int config_write_net(struct vty *vty)
468{
Harald Weltedcccb182010-05-16 20:52:23 +0200469 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
470
Harald Welte5013b2a2009-08-07 13:29:14 +0200471 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200472 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200473 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200474 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
475 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200476 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100477 vty_out(vty, " location updating reject cause %u%s",
478 gsmnet->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900479 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freytherd54c3372009-11-19 16:37:48 +0100480 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100481 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
482 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100483 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100484 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Welteb720bd32009-12-21 16:51:50 +0100485 vty_out(vty, " handover window rxlev averaging %u%s",
486 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
487 vty_out(vty, " handover window rxqual averaging %u%s",
488 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
489 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
490 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
491 vty_out(vty, " handover power budget interval %u%s",
492 gsmnet->handover.pwr_interval, VTY_NEWLINE);
493 vty_out(vty, " handover power budget hysteresis %u%s",
494 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
495 vty_out(vty, " handover maximum distance %u%s",
496 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100497 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100498 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
499 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
500 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
501 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
502 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
503 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
504 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
505 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
506 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
507 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200508
509 return CMD_SUCCESS;
510}
Harald Welte67ce0732009-08-06 19:06:46 +0200511
Harald Welte68628e82009-03-10 12:17:57 +0000512static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
513{
514 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
515 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200516 vty_out(vty, "Description: %s%s",
517 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +0200518 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte42581822009-08-08 16:12:58 +0200519 "resulting BS power: %d dBm%s",
Harald Weltefcd24452009-06-20 18:15:19 +0200520 trx->nominal_power, trx->max_power_red,
Harald Welte42581822009-08-08 16:12:58 +0200521 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000522 vty_out(vty, " NM State: ");
523 net_dump_nmstate(vty, &trx->nm_state);
524 vty_out(vty, " Baseband Transceiver NM State: ");
525 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte8175e952009-10-20 00:22:00 +0200526 if (is_ipaccess_bts(trx->bts)) {
527 vty_out(vty, " ip.access stream ID: 0x%02x%s",
528 trx->rsl_tei, VTY_NEWLINE);
529 } else {
530 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
531 e1isl_dump_vty(vty, trx->rsl_link);
532 }
Harald Welte68628e82009-03-10 12:17:57 +0000533}
534
535DEFUN(show_trx,
536 show_trx_cmd,
537 "show trx [bts_nr] [trx_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200538 SHOW_STR "Display information about a TRX\n"
539 "BTS Number\n"
540 "TRX Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000541{
Harald Weltedcccb182010-05-16 20:52:23 +0200542 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000543 struct gsm_bts *bts = NULL;
544 struct gsm_bts_trx *trx;
545 int bts_nr, trx_nr;
546
547 if (argc >= 1) {
548 /* use the BTS number that the user has specified */
549 bts_nr = atoi(argv[0]);
550 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000551 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000552 VTY_NEWLINE);
553 return CMD_WARNING;
554 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200555 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000556 }
557 if (argc >= 2) {
558 trx_nr = atoi(argv[1]);
559 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000560 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000561 VTY_NEWLINE);
562 return CMD_WARNING;
563 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200564 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000565 trx_dump_vty(vty, trx);
566 return CMD_SUCCESS;
567 }
568 if (bts) {
569 /* print all TRX in this BTS */
570 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200571 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000572 trx_dump_vty(vty, trx);
573 }
574 return CMD_SUCCESS;
575 }
576
577 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200578 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000579 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200580 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000581 trx_dump_vty(vty, trx);
582 }
583 }
584
585 return CMD_SUCCESS;
586}
587
Harald Welte67ce0732009-08-06 19:06:46 +0200588
Harald Welte68628e82009-03-10 12:17:57 +0000589static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
590{
Harald Welte68628e82009-03-10 12:17:57 +0000591 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
592 ts->nr, ts->trx->nr, ts->trx->bts->nr,
593 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
594 vty_out(vty, " NM State: ");
595 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte2c828992009-12-02 01:56:49 +0530596 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welteef235b52009-03-10 12:34:02 +0000597 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
598 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
599 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000600}
601
602DEFUN(show_ts,
603 show_ts_cmd,
Harald Welte1bc77352009-03-10 19:47:51 +0000604 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200605 SHOW_STR "Display information about a TS\n"
606 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000607{
Harald Weltedcccb182010-05-16 20:52:23 +0200608 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000609 struct gsm_bts *bts;
610 struct gsm_bts_trx *trx;
611 struct gsm_bts_trx_ts *ts;
612 int bts_nr, trx_nr, ts_nr;
613
614 if (argc >= 1) {
615 /* use the BTS number that the user has specified */
616 bts_nr = atoi(argv[0]);
617 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000618 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000619 VTY_NEWLINE);
620 return CMD_WARNING;
621 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200622 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000623 }
624 if (argc >= 2) {
625 trx_nr = atoi(argv[1]);
626 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000627 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000628 VTY_NEWLINE);
629 return CMD_WARNING;
630 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200631 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000632 }
633 if (argc >= 3) {
634 ts_nr = atoi(argv[2]);
635 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +0000636 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +0000637 VTY_NEWLINE);
638 return CMD_WARNING;
639 }
640 ts = &trx->ts[ts_nr];
641 ts_dump_vty(vty, ts);
642 return CMD_SUCCESS;
643 }
644 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200645 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000646 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200647 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000648 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
649 ts = &trx->ts[ts_nr];
650 ts_dump_vty(vty, ts);
651 }
652 }
653 }
654
655 return CMD_SUCCESS;
656}
657
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100658static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte68628e82009-03-10 12:17:57 +0000659{
Harald Weltefcd24452009-06-20 18:15:19 +0200660 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte40f82892009-05-23 17:31:39 +0000661 subscr->authorized, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000662 if (subscr->name)
Harald Welte1bc77352009-03-10 19:47:51 +0000663 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000664 if (subscr->extension)
665 vty_out(vty, " Extension: %s%s", subscr->extension,
666 VTY_NEWLINE);
667 if (subscr->imsi)
668 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freyther22230252009-08-19 12:53:57 +0200669 if (subscr->tmsi != GSM_RESERVED_TMSI)
670 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte731fd912009-08-15 03:24:51 +0200671 VTY_NEWLINE);
Sylvain Munautaf292642009-12-27 19:29:28 +0100672
Harald Welte (local)15920de2009-08-14 20:27:16 +0200673 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000674}
675
Harald Welte8387a492009-12-22 21:43:14 +0100676static void meas_rep_dump_uni_vty(struct vty *vty,
677 struct gsm_meas_rep_unidir *mru,
678 const char *prefix,
679 const char *dir)
680{
681 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
682 prefix, dir, rxlev2dbm(mru->full.rx_lev),
683 dir, rxlev2dbm(mru->sub.rx_lev));
684 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
685 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
686 VTY_NEWLINE);
687}
688
689static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
690 const char *prefix)
691{
692 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
693 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
694 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
695 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
696 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
697 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
698 VTY_NEWLINE);
699 if (mr->flags & MEAS_REP_F_MS_TO)
700 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
701 mr->ms_timing_offset, VTY_NEWLINE);
702 if (mr->flags & MEAS_REP_F_MS_L1)
703 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
704 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
705 if (mr->flags & MEAS_REP_F_DL_VALID)
706 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
707 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
708}
709
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800710static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte68628e82009-03-10 12:17:57 +0000711{
Harald Welte8387a492009-12-22 21:43:14 +0100712 int idx;
713
Harald Welte68628e82009-03-10 12:17:57 +0000714 vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s",
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +0200715 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
Harald Welte (local)ccd88452009-12-27 18:05:25 +0100716 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Harald Welte68628e82009-03-10 12:17:57 +0000717 VTY_NEWLINE);
Holger Hans Peter Freyther40494552010-06-28 17:09:29 +0800718 vty_out(vty, " Connection: %u, State: %s%s",
719 lchan->conn ? 1: 0,
Harald Welte1887f9d2009-12-29 10:52:38 +0100720 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100721 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
722 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
723 - lchan->bs_power*2,
724 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
725 VTY_NEWLINE);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800726 if (lchan->conn && lchan->conn->subscr) {
Harald Welte68628e82009-03-10 12:17:57 +0000727 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800728 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte68628e82009-03-10 12:17:57 +0000729 } else
730 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte2c828992009-12-02 01:56:49 +0530731 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
732 struct in_addr ia;
Holger Hans Peter Freyther54fa7992010-04-07 15:39:16 +0200733 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte2c828992009-12-02 01:56:49 +0530734 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
735 inet_ntoa(ia), lchan->abis_ip.bound_port,
736 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
737 VTY_NEWLINE);
738 }
Harald Welte8387a492009-12-22 21:43:14 +0100739
740 /* we want to report the last measurement report */
741 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
742 lchan->meas_rep_idx, 1);
743 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte68628e82009-03-10 12:17:57 +0000744}
745
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800746static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
747{
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +0800748 struct gsm_meas_rep *mr;
749 int idx;
750
751 /* we want to report the last measurement report */
752 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
753 lchan->meas_rep_idx, 1);
754 mr = &lchan->meas_rep[idx];
755
756 vty_out(vty, "Lchan: %u Timeslot: %u TRX: %u BTS: %u Type: %s - L1 MS Power: %u dBm "
757 "RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800758 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
759 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +0800760 mr->ms_l1.pwr,
761 rxlev2dbm(mr->dl.full.rx_lev),
762 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800763 VTY_NEWLINE);
764}
765
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800766static int lchan_summary(struct vty *vty, int argc, const char **argv,
767 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte68628e82009-03-10 12:17:57 +0000768{
Harald Weltedcccb182010-05-16 20:52:23 +0200769 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000770 struct gsm_bts *bts;
771 struct gsm_bts_trx *trx;
772 struct gsm_bts_trx_ts *ts;
773 struct gsm_lchan *lchan;
774 int bts_nr, trx_nr, ts_nr, lchan_nr;
775
776 if (argc >= 1) {
777 /* use the BTS number that the user has specified */
778 bts_nr = atoi(argv[0]);
779 if (bts_nr >= net->num_bts) {
780 vty_out(vty, "%% can't find BTS %s%s", argv[0],
781 VTY_NEWLINE);
782 return CMD_WARNING;
783 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200784 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000785 }
786 if (argc >= 2) {
787 trx_nr = atoi(argv[1]);
788 if (trx_nr >= bts->num_trx) {
789 vty_out(vty, "%% can't find TRX %s%s", argv[1],
790 VTY_NEWLINE);
791 return CMD_WARNING;
792 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200793 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000794 }
795 if (argc >= 3) {
796 ts_nr = atoi(argv[2]);
797 if (ts_nr >= TRX_NR_TS) {
798 vty_out(vty, "%% can't find TS %s%s", argv[2],
799 VTY_NEWLINE);
800 return CMD_WARNING;
801 }
802 ts = &trx->ts[ts_nr];
803 }
804 if (argc >= 4) {
805 lchan_nr = atoi(argv[3]);
806 if (lchan_nr >= TS_MAX_LCHAN) {
807 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
808 VTY_NEWLINE);
809 return CMD_WARNING;
810 }
811 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800812 dump_cb(vty, lchan);
Harald Welte68628e82009-03-10 12:17:57 +0000813 return CMD_SUCCESS;
814 }
815 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200816 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000817 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200818 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000819 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
820 ts = &trx->ts[ts_nr];
821 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
822 lchan_nr++) {
823 lchan = &ts->lchan[lchan_nr];
Harald Welteef235b52009-03-10 12:34:02 +0000824 if (lchan->type == GSM_LCHAN_NONE)
825 continue;
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800826 dump_cb(vty, lchan);
Harald Welte68628e82009-03-10 12:17:57 +0000827 }
828 }
829 }
830 }
831
832 return CMD_SUCCESS;
833}
834
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800835
836DEFUN(show_lchan,
837 show_lchan_cmd,
838 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
839 SHOW_STR "Display information about a logical channel\n"
840 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
841 "Logical Channel Number\n")
842
843{
844 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
845}
846
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800847DEFUN(show_lchan_summary,
848 show_lchan_summary_cmd,
849 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
850 SHOW_STR "Display information about a logical channel\n"
851 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
852 "Logical Channel Number\n")
853{
854 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
855}
856
Harald Welte1bc77352009-03-10 19:47:51 +0000857static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
858{
859 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
860}
861
862DEFUN(show_e1drv,
863 show_e1drv_cmd,
864 "show e1_driver",
865 SHOW_STR "Display information about available E1 drivers\n")
866{
867 struct e1inp_driver *drv;
868
869 llist_for_each_entry(drv, &e1inp_driver_list, list)
870 e1drv_dump_vty(vty, drv);
871
872 return CMD_SUCCESS;
873}
874
Harald Welte68628e82009-03-10 12:17:57 +0000875static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
876{
877 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
878 line->num, line->name ? line->name : "",
879 line->driver->name, VTY_NEWLINE);
880}
881
882DEFUN(show_e1line,
883 show_e1line_cmd,
884 "show e1_line [line_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200885 SHOW_STR "Display information about a E1 line\n"
886 "E1 Line Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000887{
Harald Welte1bc77352009-03-10 19:47:51 +0000888 struct e1inp_line *line;
889
890 if (argc >= 1) {
891 int num = atoi(argv[0]);
892 llist_for_each_entry(line, &e1inp_line_list, list) {
893 if (line->num == num) {
894 e1line_dump_vty(vty, line);
895 return CMD_SUCCESS;
896 }
897 }
898 return CMD_WARNING;
899 }
900
901 llist_for_each_entry(line, &e1inp_line_list, list)
902 e1line_dump_vty(vty, line);
903
904 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000905}
906
907static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
908{
Harald Welte42581822009-08-08 16:12:58 +0200909 if (ts->type == E1INP_TS_TYPE_NONE)
910 return;
Harald Welte1bc77352009-03-10 19:47:51 +0000911 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
912 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
913 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000914}
915
916DEFUN(show_e1ts,
917 show_e1ts_cmd,
918 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200919 SHOW_STR "Display information about a E1 timeslot\n"
920 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000921{
Harald Welte986c3d72009-11-17 06:12:16 +0100922 struct e1inp_line *line = NULL;
Harald Welte1bc77352009-03-10 19:47:51 +0000923 struct e1inp_ts *ts;
924 int ts_nr;
Harald Welte68628e82009-03-10 12:17:57 +0000925
Harald Welte1bc77352009-03-10 19:47:51 +0000926 if (argc == 0) {
927 llist_for_each_entry(line, &e1inp_line_list, list) {
928 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
929 ts = &line->ts[ts_nr];
930 e1ts_dump_vty(vty, ts);
931 }
932 }
933 return CMD_SUCCESS;
934 }
935 if (argc >= 1) {
936 int num = atoi(argv[0]);
937 llist_for_each_entry(line, &e1inp_line_list, list) {
938 if (line->num == num)
939 break;
940 }
941 if (!line || line->num != num) {
942 vty_out(vty, "E1 line %s is invalid%s",
943 argv[0], VTY_NEWLINE);
944 return CMD_WARNING;
945 }
946 }
947 if (argc >= 2) {
948 ts_nr = atoi(argv[1]);
949 if (ts_nr > NUM_E1_TS) {
950 vty_out(vty, "E1 timeslot %s is invalid%s",
951 argv[1], VTY_NEWLINE);
952 return CMD_WARNING;
953 }
954 ts = &line->ts[ts_nr];
955 e1ts_dump_vty(vty, ts);
956 return CMD_SUCCESS;
957 } else {
958 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
959 ts = &line->ts[ts_nr];
960 e1ts_dump_vty(vty, ts);
961 }
962 return CMD_SUCCESS;
963 }
964 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000965}
966
Harald Weltebe4b7302009-05-23 16:59:33 +0000967static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +0000968{
969 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
970 subscr_dump_vty(vty, pag->subscr);
971}
972
Harald Weltebe4b7302009-05-23 16:59:33 +0000973static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +0000974{
975 struct gsm_paging_request *pag;
976
977 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
978 paging_dump_vty(vty, pag);
979}
980
981DEFUN(show_paging,
982 show_paging_cmd,
983 "show paging [bts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200984 SHOW_STR "Display information about paging reuqests of a BTS\n"
985 "BTS Number\n")
Harald Weltef5025b62009-03-28 16:55:11 +0000986{
Harald Weltedcccb182010-05-16 20:52:23 +0200987 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Weltef5025b62009-03-28 16:55:11 +0000988 struct gsm_bts *bts;
989 int bts_nr;
990
991 if (argc >= 1) {
992 /* use the BTS number that the user has specified */
993 bts_nr = atoi(argv[0]);
994 if (bts_nr >= net->num_bts) {
995 vty_out(vty, "%% can't find BTS %s%s", argv[0],
996 VTY_NEWLINE);
997 return CMD_WARNING;
998 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200999 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001000 bts_paging_dump_vty(vty, bts);
1001
1002 return CMD_SUCCESS;
1003 }
1004 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +02001005 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001006 bts_paging_dump_vty(vty, bts);
1007 }
1008
1009 return CMD_SUCCESS;
1010}
1011
Harald Welte8f0ed552010-05-11 21:53:49 +02001012#define NETWORK_STR "Configure the GSM network\n"
1013
Harald Welte5013b2a2009-08-07 13:29:14 +02001014DEFUN(cfg_net,
1015 cfg_net_cmd,
Harald Welte8f0ed552010-05-11 21:53:49 +02001016 "network", NETWORK_STR)
Harald Welte5013b2a2009-08-07 13:29:14 +02001017{
Harald Weltedcccb182010-05-16 20:52:23 +02001018 vty->index = gsmnet_from_vty(vty);
Harald Welte5013b2a2009-08-07 13:29:14 +02001019 vty->node = GSMNET_NODE;
1020
1021 return CMD_SUCCESS;
1022}
1023
1024
1025DEFUN(cfg_net_ncc,
1026 cfg_net_ncc_cmd,
1027 "network country code <1-999>",
1028 "Set the GSM network country code")
1029{
Harald Weltedcccb182010-05-16 20:52:23 +02001030 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1031
Harald Welte5013b2a2009-08-07 13:29:14 +02001032 gsmnet->country_code = atoi(argv[0]);
1033
1034 return CMD_SUCCESS;
1035}
1036
1037DEFUN(cfg_net_mnc,
1038 cfg_net_mnc_cmd,
1039 "mobile network code <1-999>",
1040 "Set the GSM mobile network code")
1041{
Harald Weltedcccb182010-05-16 20:52:23 +02001042 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1043
Harald Welte5013b2a2009-08-07 13:29:14 +02001044 gsmnet->network_code = atoi(argv[0]);
1045
1046 return CMD_SUCCESS;
1047}
1048
1049DEFUN(cfg_net_name_short,
1050 cfg_net_name_short_cmd,
1051 "short name NAME",
1052 "Set the short GSM network name")
1053{
Harald Weltedcccb182010-05-16 20:52:23 +02001054 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1055
Harald Welte5013b2a2009-08-07 13:29:14 +02001056 if (gsmnet->name_short)
1057 talloc_free(gsmnet->name_short);
1058
1059 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
1060
1061 return CMD_SUCCESS;
1062}
1063
1064DEFUN(cfg_net_name_long,
1065 cfg_net_name_long_cmd,
1066 "long name NAME",
1067 "Set the long GSM network name")
1068{
Harald Weltedcccb182010-05-16 20:52:23 +02001069 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1070
Harald Welte5013b2a2009-08-07 13:29:14 +02001071 if (gsmnet->name_long)
1072 talloc_free(gsmnet->name_long);
1073
1074 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
1075
1076 return CMD_SUCCESS;
1077}
Harald Welte40f82892009-05-23 17:31:39 +00001078
Harald Welte (local)69de3972009-08-12 14:42:23 +02001079DEFUN(cfg_net_auth_policy,
1080 cfg_net_auth_policy_cmd,
1081 "auth policy (closed|accept-all|token)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001082 "Authentication (not cryptographic)\n"
1083 "Set the GSM network authentication policy\n"
1084 "Require the MS to be activated in HLR\n"
1085 "Accept all MS, whether in HLR or not\n"
1086 "Use SMS-token based authentication\n")
Harald Welte (local)69de3972009-08-12 14:42:23 +02001087{
1088 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Weltedcccb182010-05-16 20:52:23 +02001089 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)69de3972009-08-12 14:42:23 +02001090
1091 gsmnet->auth_policy = policy;
1092
1093 return CMD_SUCCESS;
1094}
1095
Harald Welte1085c092009-11-18 20:33:19 +01001096DEFUN(cfg_net_reject_cause,
1097 cfg_net_reject_cause_cmd,
1098 "location updating reject cause <2-111>",
1099 "Set the reject cause of location updating reject\n")
1100{
Harald Weltedcccb182010-05-16 20:52:23 +02001101 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1102
Harald Welte1085c092009-11-18 20:33:19 +01001103 gsmnet->reject_cause = atoi(argv[0]);
1104
1105 return CMD_SUCCESS;
1106}
1107
Harald Welte4381cfe2009-08-30 15:47:06 +09001108DEFUN(cfg_net_encryption,
1109 cfg_net_encryption_cmd,
1110 "encryption a5 (0|1|2)",
Harald Welte28326062010-05-14 20:05:17 +02001111 "Encryption options\n"
1112 "A5 encryption\n" "A5/0: No encryption\n"
1113 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Welte4381cfe2009-08-30 15:47:06 +09001114{
Harald Weltedcccb182010-05-16 20:52:23 +02001115 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1116
Andreas.Eversberg1059deb2009-11-17 09:55:26 +01001117 gsmnet->a5_encryption= atoi(argv[0]);
Harald Welte4381cfe2009-08-30 15:47:06 +09001118
1119 return CMD_SUCCESS;
1120}
1121
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001122DEFUN(cfg_net_neci,
1123 cfg_net_neci_cmd,
1124 "neci (0|1)",
Harald Welte28326062010-05-14 20:05:17 +02001125 "New Establish Cause Indication\n"
1126 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001127{
Harald Weltedcccb182010-05-16 20:52:23 +02001128 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1129
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001130 gsmnet->neci = atoi(argv[0]);
1131 return CMD_SUCCESS;
1132}
1133
Harald Welteeab84a12009-12-13 10:53:12 +01001134DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1135 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001136 "Radio Resource Location Protocol\n"
1137 "Set the Radio Resource Location Protocol Mode\n"
1138 "Don't send RRLP request\n"
1139 "Request MS-based location\n"
1140 "Request any location, prefer MS-based\n"
1141 "Request any location, prefer MS-assisted\n")
Harald Welteeab84a12009-12-13 10:53:12 +01001142{
Harald Weltedcccb182010-05-16 20:52:23 +02001143 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1144
Harald Welteeab84a12009-12-13 10:53:12 +01001145 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1146
1147 return CMD_SUCCESS;
1148}
1149
Harald Welte648b6ce2009-12-14 09:00:24 +01001150DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1151 "mm info (0|1)",
1152 "Whether to send MM INFO after LOC UPD ACCEPT")
1153{
Harald Weltedcccb182010-05-16 20:52:23 +02001154 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1155
Harald Welte648b6ce2009-12-14 09:00:24 +01001156 gsmnet->send_mm_info = atoi(argv[0]);
1157
1158 return CMD_SUCCESS;
1159}
1160
Harald Welte8f0ed552010-05-11 21:53:49 +02001161#define HANDOVER_STR "Handover Options\n"
1162
Harald Weltebc814502009-12-19 21:41:52 +01001163DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1164 "handover (0|1)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001165 HANDOVER_STR
1166 "Don't perform in-call handover\n"
1167 "Perform in-call handover\n")
Harald Weltebc814502009-12-19 21:41:52 +01001168{
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001169 int enable = atoi(argv[0]);
Harald Weltedcccb182010-05-16 20:52:23 +02001170 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001171
1172 if (enable && ipacc_rtp_direct) {
Harald Weltefe03f0d2009-12-20 13:51:01 +01001173 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1174 "is enabled by using the -P command line option%s",
1175 VTY_NEWLINE);
1176 return CMD_WARNING;
1177 }
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001178 gsmnet->handover.active = enable;
Harald Weltebc814502009-12-19 21:41:52 +01001179
1180 return CMD_SUCCESS;
1181}
1182
Harald Welte8f0ed552010-05-11 21:53:49 +02001183#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1184#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1185#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1186#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1187
Harald Welteb720bd32009-12-21 16:51:50 +01001188DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1189 "handover window rxlev averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001190 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001191 "How many RxLev measurements are used for averaging")
1192{
Harald Weltedcccb182010-05-16 20:52:23 +02001193 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001194 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1195 return CMD_SUCCESS;
1196}
1197
1198DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1199 "handover window rxqual averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001200 HO_WIN_RXQUAL_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001201 "How many RxQual measurements are used for averaging")
1202{
Harald Weltedcccb182010-05-16 20:52:23 +02001203 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001204 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1205 return CMD_SUCCESS;
1206}
1207
1208DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1209 "handover window rxlev neighbor averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001210 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001211 "How many RxQual measurements are used for averaging")
1212{
Harald Weltedcccb182010-05-16 20:52:23 +02001213 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001214 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1215 return CMD_SUCCESS;
1216}
1217
1218DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1219 "handover power budget interval <1-99>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001220 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001221 "How often to check if we have a better cell (SACCH frames)")
1222{
Harald Weltedcccb182010-05-16 20:52:23 +02001223 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001224 gsmnet->handover.pwr_interval = atoi(argv[0]);
1225 return CMD_SUCCESS;
1226}
1227
1228DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1229 "handover power budget hysteresis <0-999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001230 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001231 "How many dB does a neighbor to be stronger to become a HO candidate")
1232{
Harald Weltedcccb182010-05-16 20:52:23 +02001233 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001234 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1235 return CMD_SUCCESS;
1236}
1237
1238DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1239 "handover maximum distance <0-9999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001240 HANDOVER_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001241 "How big is the maximum timing advance before HO is forced")
1242{
Harald Weltedcccb182010-05-16 20:52:23 +02001243 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001244 gsmnet->handover.max_distance = atoi(argv[0]);
1245 return CMD_SUCCESS;
1246}
Harald Weltebc814502009-12-19 21:41:52 +01001247
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001248#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001249 DEFUN(cfg_net_T##number, \
1250 cfg_net_T##number##_cmd, \
1251 "timer t" #number " <0-65535>", \
Harald Welte8f0ed552010-05-11 21:53:49 +02001252 "Configure GSM Timers\n" \
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001253 doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001254{ \
Harald Weltedcccb182010-05-16 20:52:23 +02001255 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001256 int value = atoi(argv[0]); \
1257 \
1258 if (value < 0 || value > 65535) { \
1259 vty_out(vty, "Timer value %s out of range.%s", \
1260 argv[0], VTY_NEWLINE); \
1261 return CMD_WARNING; \
1262 } \
1263 \
1264 gsmnet->T##number = value; \
1265 return CMD_SUCCESS; \
1266}
1267
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001268DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1269DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1270DECLARE_TIMER(3105, "Currently not used.")
1271DECLARE_TIMER(3107, "Currently not used.")
1272DECLARE_TIMER(3109, "Currently not used.")
Holger Hans Peter Freytherf30c0dc2010-05-31 21:33:15 +08001273DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001274DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1275DECLARE_TIMER(3115, "Currently not used.")
1276DECLARE_TIMER(3117, "Currently not used.")
1277DECLARE_TIMER(3119, "Currently not used.")
1278DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001279
1280
Harald Welte5258fc42009-03-28 19:07:53 +00001281/* per-BTS configuration */
1282DEFUN(cfg_bts,
1283 cfg_bts_cmd,
1284 "bts BTS_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001285 "Select a BTS to configure\n"
1286 "BTS Number\n")
Harald Welte5258fc42009-03-28 19:07:53 +00001287{
Harald Weltedcccb182010-05-16 20:52:23 +02001288 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte5258fc42009-03-28 19:07:53 +00001289 int bts_nr = atoi(argv[0]);
1290 struct gsm_bts *bts;
1291
Harald Weltee441d9c2009-06-21 16:17:15 +02001292 if (bts_nr > gsmnet->num_bts) {
1293 vty_out(vty, "%% The next unused BTS number is %u%s",
1294 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001295 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001296 } else if (bts_nr == gsmnet->num_bts) {
1297 /* allocate a new one */
1298 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1299 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001300 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001301 bts = gsm_bts_num(gsmnet, bts_nr);
1302
Daniel Willmannf15c2762010-01-11 13:43:07 +01001303 if (!bts) {
1304 vty_out(vty, "%% Unable to allocate BTS %u%s",
1305 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee441d9c2009-06-21 16:17:15 +02001306 return CMD_WARNING;
Daniel Willmannf15c2762010-01-11 13:43:07 +01001307 }
Harald Welte5258fc42009-03-28 19:07:53 +00001308
1309 vty->index = bts;
Harald Welte197dea92010-05-14 17:59:53 +02001310 vty->index_sub = &bts->description;
Harald Welte5258fc42009-03-28 19:07:53 +00001311 vty->node = BTS_NODE;
1312
1313 return CMD_SUCCESS;
1314}
1315
1316DEFUN(cfg_bts_type,
1317 cfg_bts_type_cmd,
1318 "type TYPE",
1319 "Set the BTS type\n")
1320{
1321 struct gsm_bts *bts = vty->index;
Harald Welte39315c42010-01-10 18:01:52 +01001322 int rc;
Harald Welte5258fc42009-03-28 19:07:53 +00001323
Harald Welte39315c42010-01-10 18:01:52 +01001324 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1325 if (rc < 0)
1326 return CMD_WARNING;
Harald Welte8175e952009-10-20 00:22:00 +02001327
Harald Welte5258fc42009-03-28 19:07:53 +00001328 return CMD_SUCCESS;
1329}
1330
Harald Weltefcd24452009-06-20 18:15:19 +02001331DEFUN(cfg_bts_band,
1332 cfg_bts_band_cmd,
1333 "band BAND",
1334 "Set the frequency band of this BTS\n")
1335{
1336 struct gsm_bts *bts = vty->index;
Harald Welte42581822009-08-08 16:12:58 +02001337 int band = gsm_band_parse(argv[0]);
Harald Weltefcd24452009-06-20 18:15:19 +02001338
1339 if (band < 0) {
1340 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1341 band, VTY_NEWLINE);
1342 return CMD_WARNING;
1343 }
1344
1345 bts->band = band;
1346
1347 return CMD_SUCCESS;
1348}
1349
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001350DEFUN(cfg_bts_ci,
1351 cfg_bts_ci_cmd,
1352 "cell_identity <0-65535>",
1353 "Set the Cell identity of this BTS\n")
1354{
1355 struct gsm_bts *bts = vty->index;
1356 int ci = atoi(argv[0]);
1357
1358 if (ci < 0 || ci > 0xffff) {
1359 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1360 ci, VTY_NEWLINE);
1361 return CMD_WARNING;
1362 }
1363 bts->cell_identity = ci;
1364
1365 return CMD_SUCCESS;
1366}
1367
Harald Welte5258fc42009-03-28 19:07:53 +00001368DEFUN(cfg_bts_lac,
1369 cfg_bts_lac_cmd,
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001370 "location_area_code <0-65535>",
Harald Welte5258fc42009-03-28 19:07:53 +00001371 "Set the Location Area Code (LAC) of this BTS\n")
1372{
1373 struct gsm_bts *bts = vty->index;
1374 int lac = atoi(argv[0]);
1375
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001376 if (lac < 0 || lac > 0xffff) {
1377 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte5258fc42009-03-28 19:07:53 +00001378 lac, VTY_NEWLINE);
1379 return CMD_WARNING;
1380 }
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +02001381
1382 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1383 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1384 lac, VTY_NEWLINE);
1385 return CMD_WARNING;
1386 }
1387
Harald Welte5258fc42009-03-28 19:07:53 +00001388 bts->location_area_code = lac;
1389
1390 return CMD_SUCCESS;
1391}
1392
Harald Weltea43f7892009-12-01 18:04:30 +05301393
Harald Welte5258fc42009-03-28 19:07:53 +00001394DEFUN(cfg_bts_tsc,
1395 cfg_bts_tsc_cmd,
1396 "training_sequence_code <0-255>",
1397 "Set the Training Sequence Code (TSC) of this BTS\n")
1398{
1399 struct gsm_bts *bts = vty->index;
1400 int tsc = atoi(argv[0]);
1401
1402 if (tsc < 0 || tsc > 0xff) {
1403 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1404 tsc, VTY_NEWLINE);
1405 return CMD_WARNING;
1406 }
1407 bts->tsc = tsc;
1408
1409 return CMD_SUCCESS;
1410}
1411
Harald Welte78f2f502009-05-23 16:56:52 +00001412DEFUN(cfg_bts_bsic,
1413 cfg_bts_bsic_cmd,
1414 "base_station_id_code <0-63>",
1415 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1416{
1417 struct gsm_bts *bts = vty->index;
1418 int bsic = atoi(argv[0]);
1419
1420 if (bsic < 0 || bsic > 0x3f) {
Harald Welte42581822009-08-08 16:12:58 +02001421 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte78f2f502009-05-23 16:56:52 +00001422 bsic, VTY_NEWLINE);
1423 return CMD_WARNING;
1424 }
1425 bts->bsic = bsic;
1426
1427 return CMD_SUCCESS;
1428}
1429
1430
Harald Welte4cc34222009-05-01 15:12:31 +00001431DEFUN(cfg_bts_unit_id,
1432 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +02001433 "ip.access unit_id <0-65534> <0-255>",
1434 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte4cc34222009-05-01 15:12:31 +00001435{
1436 struct gsm_bts *bts = vty->index;
1437 int site_id = atoi(argv[0]);
1438 int bts_id = atoi(argv[1]);
1439
Harald Welte07dc73d2009-08-07 13:27:09 +02001440 if (!is_ipaccess_bts(bts)) {
1441 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1442 return CMD_WARNING;
1443 }
1444
Harald Welte4cc34222009-05-01 15:12:31 +00001445 bts->ip_access.site_id = site_id;
1446 bts->ip_access.bts_id = bts_id;
1447
1448 return CMD_SUCCESS;
1449}
1450
Harald Welte8f0ed552010-05-11 21:53:49 +02001451#define OML_STR "Organization & Maintenance Link\n"
1452#define IPA_STR "ip.access Specific Options\n"
1453
Harald Welte8175e952009-10-20 00:22:00 +02001454DEFUN(cfg_bts_stream_id,
1455 cfg_bts_stream_id_cmd,
1456 "oml ip.access stream_id <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001457 OML_STR IPA_STR
Harald Welte8175e952009-10-20 00:22:00 +02001458 "Set the ip.access Stream ID of the OML link of this BTS\n")
1459{
1460 struct gsm_bts *bts = vty->index;
1461 int stream_id = atoi(argv[0]);
1462
1463 if (!is_ipaccess_bts(bts)) {
1464 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1465 return CMD_WARNING;
1466 }
1467
1468 bts->oml_tei = stream_id;
1469
1470 return CMD_SUCCESS;
1471}
1472
Harald Welte8f0ed552010-05-11 21:53:49 +02001473#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte8175e952009-10-20 00:22:00 +02001474
Harald Welte42581822009-08-08 16:12:58 +02001475DEFUN(cfg_bts_oml_e1,
1476 cfg_bts_oml_e1_cmd,
1477 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001478 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001479 "E1 interface to be used for OML\n")
1480{
1481 struct gsm_bts *bts = vty->index;
1482
1483 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1484
1485 return CMD_SUCCESS;
1486}
1487
1488
1489DEFUN(cfg_bts_oml_e1_tei,
1490 cfg_bts_oml_e1_tei_cmd,
1491 "oml e1 tei <0-63>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001492 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001493 "Set the TEI to be used for OML")
1494{
1495 struct gsm_bts *bts = vty->index;
1496
1497 bts->oml_tei = atoi(argv[0]);
1498
1499 return CMD_SUCCESS;
1500}
1501
Harald Welte7a8fa412009-08-10 13:48:16 +02001502DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1503 "channel allocator (ascending|descending)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001504 "Channnel Allocator\n" "Channel Allocator\n"
1505 "Allocate Timeslots and Transceivers in ascending order\n"
1506 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte7a8fa412009-08-10 13:48:16 +02001507{
1508 struct gsm_bts *bts = vty->index;
1509
1510 if (!strcmp(argv[0], "ascending"))
1511 bts->chan_alloc_reverse = 0;
1512 else
1513 bts->chan_alloc_reverse = 1;
1514
1515 return CMD_SUCCESS;
1516}
1517
Harald Welte8f0ed552010-05-11 21:53:49 +02001518#define RACH_STR "Random Access Control Channel\n"
1519
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001520DEFUN(cfg_bts_rach_tx_integer,
1521 cfg_bts_rach_tx_integer_cmd,
1522 "rach tx integer <0-15>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001523 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001524 "Set the raw tx integer value in RACH Control parameters IE")
1525{
1526 struct gsm_bts *bts = vty->index;
1527 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1528 return CMD_SUCCESS;
1529}
1530
1531DEFUN(cfg_bts_rach_max_trans,
1532 cfg_bts_rach_max_trans_cmd,
1533 "rach max transmission (1|2|4|7)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001534 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001535 "Set the maximum number of RACH burst transmissions")
1536{
1537 struct gsm_bts *bts = vty->index;
1538 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1539 return CMD_SUCCESS;
1540}
1541
Harald Welte8f0ed552010-05-11 21:53:49 +02001542#define NM_STR "Network Management\n"
1543
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001544DEFUN(cfg_bts_rach_nm_b_thresh,
1545 cfg_bts_rach_nm_b_thresh_cmd,
1546 "rach nm busy threshold <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001547 RACH_STR NM_STR
1548 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001549{
1550 struct gsm_bts *bts = vty->index;
1551 bts->rach_b_thresh = atoi(argv[0]);
1552 return CMD_SUCCESS;
1553}
1554
1555DEFUN(cfg_bts_rach_nm_ldavg,
1556 cfg_bts_rach_nm_ldavg_cmd,
1557 "rach nm load average <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001558 RACH_STR NM_STR
1559 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001560{
1561 struct gsm_bts *bts = vty->index;
1562 bts->rach_ldavg_slots = atoi(argv[0]);
1563 return CMD_SUCCESS;
1564}
1565
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001566DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1567 "cell barred (0|1)",
1568 "Should this cell be barred from access?")
1569{
1570 struct gsm_bts *bts = vty->index;
1571
Harald Welte71355012009-12-21 23:08:18 +01001572 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001573
1574 return CMD_SUCCESS;
1575}
1576
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08001577DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1578 "rach emergency call allowed (0|1)",
1579 "Should this cell allow emergency calls?")
1580{
1581 struct gsm_bts *bts = vty->index;
1582
1583 if (atoi(argv[0]) == 0)
1584 bts->si_common.rach_control.t2 |= 0x4;
1585 else
1586 bts->si_common.rach_control.t2 &= ~0x4;
1587
1588 return CMD_SUCCESS;
1589}
1590
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001591DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1592 "ms max power <0-40>",
1593 "Maximum transmit power of the MS")
1594{
1595 struct gsm_bts *bts = vty->index;
1596
1597 bts->ms_max_power = atoi(argv[0]);
1598
1599 return CMD_SUCCESS;
1600}
1601
Harald Welte73225282009-12-12 18:17:25 +01001602DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1603 "cell reselection hysteresis <0-14>",
1604 "Cell Re-Selection Hysteresis in dB")
1605{
1606 struct gsm_bts *bts = vty->index;
1607
1608 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1609
1610 return CMD_SUCCESS;
1611}
1612
1613DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1614 "rxlev access min <0-63>",
1615 "Minimum RxLev needed for cell access (better than -110dBm)")
1616{
1617 struct gsm_bts *bts = vty->index;
1618
1619 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1620
1621 return CMD_SUCCESS;
1622}
1623
Harald Welte (local)efc92312009-08-14 23:09:25 +02001624DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1625 "periodic location update <0-1530>",
1626 "Periodic Location Updating Interval in Minutes")
1627{
1628 struct gsm_bts *bts = vty->index;
1629
Harald Weltea43f7892009-12-01 18:04:30 +05301630 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)efc92312009-08-14 23:09:25 +02001631
1632 return CMD_SUCCESS;
1633}
1634
Harald Welte8f0ed552010-05-11 21:53:49 +02001635#define GPRS_TEXT "GPRS Packet Network\n"
1636
Harald Welteaf387632010-03-14 23:30:30 +08001637DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welte57ba7e32010-04-18 14:00:26 +02001638 "gprs cell bvci <2-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001639 GPRS_TEXT
1640 "GPRS Cell Settings\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001641 "GPRS BSSGP VC Identifier")
1642{
1643 struct gsm_bts *bts = vty->index;
1644
Harald Welte4511d892010-04-18 15:51:20 +02001645 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001646 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1647 return CMD_WARNING;
1648 }
1649
Harald Welte97a282b2010-03-14 15:37:43 +08001650 bts->gprs.cell.bvci = atoi(argv[0]);
1651
1652 return CMD_SUCCESS;
1653}
1654
Harald Weltea5731cf2010-03-22 11:48:36 +08001655DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1656 "gprs nsei <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001657 GPRS_TEXT
Harald Weltea5731cf2010-03-22 11:48:36 +08001658 "GPRS NS Entity Identifier")
1659{
1660 struct gsm_bts *bts = vty->index;
1661
Harald Welte4511d892010-04-18 15:51:20 +02001662 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltea5731cf2010-03-22 11:48:36 +08001663 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1664 return CMD_WARNING;
1665 }
1666
1667 bts->gprs.nse.nsei = atoi(argv[0]);
1668
1669 return CMD_SUCCESS;
1670}
1671
Harald Welte8f0ed552010-05-11 21:53:49 +02001672#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1673 "NSVC Logical Number\n"
Harald Weltea5731cf2010-03-22 11:48:36 +08001674
Harald Welte97a282b2010-03-14 15:37:43 +08001675DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1676 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001677 GPRS_TEXT NSVC_TEXT
1678 "NS Virtual Connection Identifier\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001679 "GPRS NS VC Identifier")
1680{
1681 struct gsm_bts *bts = vty->index;
1682 int idx = atoi(argv[0]);
1683
Harald Welte4511d892010-04-18 15:51:20 +02001684 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001685 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1686 return CMD_WARNING;
1687 }
1688
Harald Welte97a282b2010-03-14 15:37:43 +08001689 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1690
1691 return CMD_SUCCESS;
1692}
1693
Harald Welteaf387632010-03-14 23:30:30 +08001694DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1695 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001696 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001697 "GPRS NS Local UDP Port")
1698{
1699 struct gsm_bts *bts = vty->index;
1700 int idx = atoi(argv[0]);
1701
Harald Welte4511d892010-04-18 15:51:20 +02001702 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001703 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1704 return CMD_WARNING;
1705 }
1706
Harald Welteaf387632010-03-14 23:30:30 +08001707 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1708
1709 return CMD_SUCCESS;
1710}
1711
1712DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1713 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001714 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001715 "GPRS NS Remote UDP Port")
1716{
1717 struct gsm_bts *bts = vty->index;
1718 int idx = atoi(argv[0]);
1719
Harald Welte4511d892010-04-18 15:51:20 +02001720 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001721 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1722 return CMD_WARNING;
1723 }
1724
Harald Welteaf387632010-03-14 23:30:30 +08001725 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1726
1727 return CMD_SUCCESS;
1728}
1729
1730DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1731 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte8f0ed552010-05-11 21:53:49 +02001732 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001733 "GPRS NS Remote IP Address")
1734{
1735 struct gsm_bts *bts = vty->index;
1736 int idx = atoi(argv[0]);
1737 struct in_addr ia;
1738
Harald Welte4511d892010-04-18 15:51:20 +02001739 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001740 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1741 return CMD_WARNING;
1742 }
1743
Harald Welteaf387632010-03-14 23:30:30 +08001744 inet_aton(argv[1], &ia);
1745 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1746
1747 return CMD_SUCCESS;
1748}
1749
Harald Welte615e9562010-05-11 23:50:21 +02001750DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1751 "gprs ns timer " NS_TIMERS " <0-255>",
1752 GPRS_TEXT "Network Service\n"
1753 "Network Service Timer\n"
1754 NS_TIMERS_HELP "Timer Value\n")
1755{
1756 struct gsm_bts *bts = vty->index;
1757 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1758 int val = atoi(argv[1]);
1759
1760 if (bts->gprs.mode == BTS_GPRS_NONE) {
1761 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1762 return CMD_WARNING;
1763 }
1764
1765 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1766 return CMD_WARNING;
1767
1768 bts->gprs.nse.timer[idx] = val;
1769
1770 return CMD_SUCCESS;
1771}
1772
1773#define BSSGP_TIMERS "(blocking-timer|blocking-retries|unblocking-retries|reset-timer|reset-retries|suspend-timer|suspend-retries|resume-timer|resume-retries|capability-update-timer|capability-update-retries)"
Harald Welte28326062010-05-14 20:05:17 +02001774#define BSSGP_TIMERS_HELP \
1775 "Tbvc-block timeout\n" \
1776 "Tbvc-block retries\n" \
1777 "Tbvc-unblock retries\n" \
1778 "Tbvcc-reset timeout\n" \
1779 "Tbvc-reset retries\n" \
1780 "Tbvc-suspend timeout\n" \
1781 "Tbvc-suspend retries\n" \
1782 "Tbvc-resume timeout\n" \
1783 "Tbvc-resume retries\n" \
1784 "Tbvc-capa-update timeout\n" \
1785 "Tbvc-capa-update retries\n"
Harald Welte615e9562010-05-11 23:50:21 +02001786
1787DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1788 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1789 GPRS_TEXT "Cell / BSSGP\n"
1790 "Cell/BSSGP Timer\n"
1791 BSSGP_TIMERS_HELP "Timer Value\n")
1792{
1793 struct gsm_bts *bts = vty->index;
1794 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1795 int val = atoi(argv[1]);
1796
1797 if (bts->gprs.mode == BTS_GPRS_NONE) {
1798 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1799 return CMD_WARNING;
1800 }
1801
1802 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
1803 return CMD_WARNING;
1804
1805 bts->gprs.cell.timer[idx] = val;
1806
1807 return CMD_SUCCESS;
1808}
1809
Harald Welte97a282b2010-03-14 15:37:43 +08001810DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1811 "gprs routing area <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001812 GPRS_TEXT
Harald Welte97a282b2010-03-14 15:37:43 +08001813 "GPRS Routing Area Code")
1814{
1815 struct gsm_bts *bts = vty->index;
1816
Harald Welte4511d892010-04-18 15:51:20 +02001817 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001818 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1819 return CMD_WARNING;
1820 }
1821
Harald Welte97a282b2010-03-14 15:37:43 +08001822 bts->gprs.rac = atoi(argv[0]);
1823
1824 return CMD_SUCCESS;
1825}
1826
Harald Welte4511d892010-04-18 15:51:20 +02001827DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
1828 "gprs mode (none|gprs|egprs)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001829 GPRS_TEXT
1830 "GPRS Mode for this BTS\n"
1831 "GPRS Disabled on this BTS\n"
1832 "GPRS Enabled on this BTS\n"
1833 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welteaf387632010-03-14 23:30:30 +08001834{
1835 struct gsm_bts *bts = vty->index;
Harald Weltef3d8e922010-06-14 22:44:42 +02001836 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welteaf387632010-03-14 23:30:30 +08001837
Harald Weltef3d8e922010-06-14 22:44:42 +02001838 if (mode != BTS_GPRS_NONE &&
1839 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
1840 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1841 VTY_NEWLINE);
1842 return CMD_WARNING;
1843 }
1844 if (mode == BTS_GPRS_EGPRS &&
1845 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
1846 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1847 VTY_NEWLINE);
1848 return CMD_WARNING;
1849 }
1850
1851 bts->gprs.mode = mode;
Harald Welteaf387632010-03-14 23:30:30 +08001852
1853 return CMD_SUCCESS;
1854}
1855
Harald Welte9fbff4a2010-07-30 11:50:09 +02001856#define SI_TEXT "System Information Messages\n"
1857#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)"
1858#define SI_TYPE_HELP "System Information Type 1\n" \
1859 "System Information Type 2\n" \
1860 "System Information Type 3\n" \
1861 "System Information Type 4\n" \
1862 "System Information Type 5\n" \
1863 "System Information Type 6\n" \
1864 "System Information Type 7\n" \
1865 "System Information Type 8\n" \
1866 "System Information Type 9\n" \
1867 "System Information Type 10\n" \
1868 "System Information Type 13\n" \
1869 "System Information Type 16\n" \
1870 "System Information Type 17\n" \
1871 "System Information Type 18\n" \
1872 "System Information Type 19\n" \
1873 "System Information Type 20\n" \
1874 "System Information Type 2bis\n" \
1875 "System Information Type 2ter\n" \
1876 "System Information Type 2quater\n" \
1877 "System Information Type 5bis\n" \
1878 "System Information Type 5ter\n"
1879
1880DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
1881 "system-information " SI_TYPE_TEXT " mode (static|computed)",
1882 SI_TEXT SI_TYPE_HELP
1883 "System Information Mode\n"
1884 "Static user-specified\n"
1885 "Dynamic, BSC-computed\n")
1886{
1887 struct gsm_bts *bts = vty->index;
1888 int type;
1889
1890 type = get_string_value(osmo_sitype_strs, argv[0]);
1891 if (type < 0) {
1892 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
1893 return CMD_WARNING;
1894 }
1895
1896 if (!strcmp(argv[1], "static"))
1897 bts->si_mode_static |= (1 << type);
1898 else
1899 bts->si_mode_static &= ~(1 << type);
1900
1901 return CMD_SUCCESS;
1902}
1903
1904DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
1905 "system-information " SI_TYPE_TEXT " static HEXSTRING",
1906 SI_TEXT SI_TYPE_HELP
1907 "Static System Information filling\n"
1908 "Static user-specified SI content in HEX notation\n")
1909{
1910 struct gsm_bts *bts = vty->index;
1911 int rc, type;
1912
1913 type = get_string_value(osmo_sitype_strs, argv[0]);
1914 if (type < 0) {
1915 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
1916 return CMD_WARNING;
1917 }
1918
1919 if (!(bts->si_mode_static & (1 << type))) {
1920 vty_out(vty, "SI Type %s is not configured in static mode%s",
1921 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
1922 return CMD_WARNING;
1923 }
1924
Harald Welte290aaed2010-07-30 11:53:18 +02001925 /* Fill buffer with padding pattern */
1926 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
1927
1928 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Harald Welte9fbff4a2010-07-30 11:50:09 +02001929 rc = hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
1930 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
1931 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
1932 return CMD_WARNING;
1933 }
1934
1935 /* Mark this SI as present */
1936 bts->si_valid |= (1 << type);
1937
1938 return CMD_SUCCESS;
1939}
1940
1941
Harald Welte8f0ed552010-05-11 21:53:49 +02001942#define TRX_TEXT "Radio Transceiver\n"
Harald Welte7a8fa412009-08-10 13:48:16 +02001943
Harald Welte5258fc42009-03-28 19:07:53 +00001944/* per TRX configuration */
1945DEFUN(cfg_trx,
1946 cfg_trx_cmd,
1947 "trx TRX_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001948 TRX_TEXT
Harald Welte5258fc42009-03-28 19:07:53 +00001949 "Select a TRX to configure")
1950{
1951 int trx_nr = atoi(argv[0]);
1952 struct gsm_bts *bts = vty->index;
1953 struct gsm_bts_trx *trx;
1954
Harald Weltee441d9c2009-06-21 16:17:15 +02001955 if (trx_nr > bts->num_trx) {
1956 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1957 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001958 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001959 } else if (trx_nr == bts->num_trx) {
1960 /* we need to allocate a new one */
1961 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001962 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001963 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001964
Harald Weltee441d9c2009-06-21 16:17:15 +02001965 if (!trx)
1966 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00001967
1968 vty->index = trx;
Harald Welte197dea92010-05-14 17:59:53 +02001969 vty->index_sub = &trx->description;
Harald Welte5258fc42009-03-28 19:07:53 +00001970 vty->node = TRX_NODE;
1971
1972 return CMD_SUCCESS;
1973}
1974
1975DEFUN(cfg_trx_arfcn,
1976 cfg_trx_arfcn_cmd,
Harald Welte93e90202010-05-14 19:00:52 +02001977 "arfcn <0-1024>",
Harald Welte5258fc42009-03-28 19:07:53 +00001978 "Set the ARFCN for this TRX\n")
1979{
1980 int arfcn = atoi(argv[0]);
1981 struct gsm_bts_trx *trx = vty->index;
1982
1983 /* FIXME: check if this ARFCN is supported by this TRX */
1984
1985 trx->arfcn = arfcn;
1986
1987 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1988 /* FIXME: use OML layer to update the ARFCN */
1989 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
1990
1991 return CMD_SUCCESS;
1992}
1993
Harald Welte (local)7b37d972009-12-27 20:56:38 +01001994DEFUN(cfg_trx_nominal_power,
1995 cfg_trx_nominal_power_cmd,
1996 "nominal power <0-100>",
1997 "Nominal TRX RF Power in dB\n")
1998{
1999 struct gsm_bts_trx *trx = vty->index;
2000
2001 trx->nominal_power = atoi(argv[0]);
2002
2003 return CMD_SUCCESS;
2004}
2005
Harald Weltefcd24452009-06-20 18:15:19 +02002006DEFUN(cfg_trx_max_power_red,
2007 cfg_trx_max_power_red_cmd,
2008 "max_power_red <0-100>",
2009 "Reduction of maximum BS RF Power in dB\n")
2010{
2011 int maxpwr_r = atoi(argv[0]);
2012 struct gsm_bts_trx *trx = vty->index;
Harald Welte61a83b22009-11-18 09:20:22 +01002013 int upper_limit = 24; /* default 12.21 max power red. */
Harald Weltefcd24452009-06-20 18:15:19 +02002014
2015 /* FIXME: check if our BTS type supports more than 12 */
2016 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2017 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2018 maxpwr_r, VTY_NEWLINE);
2019 return CMD_WARNING;
2020 }
2021 if (maxpwr_r & 1) {
2022 vty_out(vty, "%% Power %d dB is not an even value%s",
2023 maxpwr_r, VTY_NEWLINE);
2024 return CMD_WARNING;
2025 }
2026
2027 trx->max_power_red = maxpwr_r;
2028
2029 /* FIXME: make sure we update this using OML */
2030
2031 return CMD_SUCCESS;
2032}
2033
Harald Welte42581822009-08-08 16:12:58 +02002034DEFUN(cfg_trx_rsl_e1,
2035 cfg_trx_rsl_e1_cmd,
2036 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2037 "E1 interface to be used for RSL\n")
2038{
2039 struct gsm_bts_trx *trx = vty->index;
2040
2041 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2042
2043 return CMD_SUCCESS;
2044}
2045
2046DEFUN(cfg_trx_rsl_e1_tei,
2047 cfg_trx_rsl_e1_tei_cmd,
2048 "rsl e1 tei <0-63>",
2049 "Set the TEI to be used for RSL")
2050{
2051 struct gsm_bts_trx *trx = vty->index;
2052
2053 trx->rsl_tei = atoi(argv[0]);
2054
2055 return CMD_SUCCESS;
2056}
2057
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01002058DEFUN(cfg_trx_rf_locked,
2059 cfg_trx_rf_locked_cmd,
2060 "rf_locked (0|1)",
2061 "Turn off RF of the TRX.\n")
2062{
2063 int locked = atoi(argv[0]);
2064 struct gsm_bts_trx *trx = vty->index;
2065
2066 gsm_trx_lock_rf(trx, locked);
2067 return CMD_SUCCESS;
2068}
Harald Welte42581822009-08-08 16:12:58 +02002069
Harald Welte5258fc42009-03-28 19:07:53 +00002070/* per TS configuration */
2071DEFUN(cfg_ts,
2072 cfg_ts_cmd,
Harald Welte42581822009-08-08 16:12:58 +02002073 "timeslot <0-7>",
Harald Welte5258fc42009-03-28 19:07:53 +00002074 "Select a Timeslot to configure")
2075{
2076 int ts_nr = atoi(argv[0]);
2077 struct gsm_bts_trx *trx = vty->index;
2078 struct gsm_bts_trx_ts *ts;
2079
2080 if (ts_nr >= TRX_NR_TS) {
2081 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2082 TRX_NR_TS, VTY_NEWLINE);
2083 return CMD_WARNING;
2084 }
2085
2086 ts = &trx->ts[ts_nr];
2087
2088 vty->index = ts;
2089 vty->node = TS_NODE;
2090
2091 return CMD_SUCCESS;
2092}
2093
Harald Weltea6fd58e2009-08-07 00:25:23 +02002094DEFUN(cfg_ts_pchan,
2095 cfg_ts_pchan_cmd,
2096 "phys_chan_config PCHAN",
2097 "Physical Channel configuration (TCH/SDCCH/...)")
2098{
2099 struct gsm_bts_trx_ts *ts = vty->index;
2100 int pchanc;
2101
2102 pchanc = gsm_pchan_parse(argv[0]);
2103 if (pchanc < 0)
2104 return CMD_WARNING;
2105
2106 ts->pchan = pchanc;
2107
2108 return CMD_SUCCESS;
2109}
2110
Harald Weltea39b0f22010-06-14 22:26:10 +02002111#define HOPPING_STR "Configure frequency hopping\n"
2112
2113DEFUN(cfg_ts_hopping,
2114 cfg_ts_hopping_cmd,
2115 "hopping enabled (0|1)",
2116 HOPPING_STR "Enable or disable frequency hopping\n"
2117 "Disable frequency hopping\n" "Enable frequency hopping\n")
2118{
2119 struct gsm_bts_trx_ts *ts = vty->index;
Harald Weltec2fb3d02010-06-14 22:47:37 +02002120 int enabled = atoi(argv[0]);
Harald Weltea39b0f22010-06-14 22:26:10 +02002121
Harald Weltec2fb3d02010-06-14 22:47:37 +02002122 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2123 vty_out(vty, "BTS model does not support hopping%s",
2124 VTY_NEWLINE);
2125 return CMD_WARNING;
2126 }
2127
2128 ts->hopping.enabled = enabled;
Harald Weltea39b0f22010-06-14 22:26:10 +02002129
2130 return CMD_SUCCESS;
2131}
2132
Harald Welte6e0cd042009-09-12 13:05:33 +02002133DEFUN(cfg_ts_hsn,
2134 cfg_ts_hsn_cmd,
Harald Weltea39b0f22010-06-14 22:26:10 +02002135 "hopping sequence-number <0-63>",
2136 HOPPING_STR
Harald Welte6e0cd042009-09-12 13:05:33 +02002137 "Which hopping sequence to use for this channel")
2138{
2139 struct gsm_bts_trx_ts *ts = vty->index;
2140
2141 ts->hopping.hsn = atoi(argv[0]);
2142
2143 return CMD_SUCCESS;
2144}
2145
2146DEFUN(cfg_ts_maio,
2147 cfg_ts_maio_cmd,
2148 "hopping maio <0-63>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002149 HOPPING_STR
Harald Welte6e0cd042009-09-12 13:05:33 +02002150 "Which hopping MAIO to use for this channel")
2151{
2152 struct gsm_bts_trx_ts *ts = vty->index;
2153
2154 ts->hopping.maio = atoi(argv[0]);
2155
2156 return CMD_SUCCESS;
2157}
2158
2159DEFUN(cfg_ts_arfcn_add,
2160 cfg_ts_arfcn_add_cmd,
2161 "hopping arfcn add <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002162 HOPPING_STR "Configure hopping ARFCN list\n"
2163 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02002164{
2165 struct gsm_bts_trx_ts *ts = vty->index;
2166 int arfcn = atoi(argv[0]);
2167
Harald Weltea39b0f22010-06-14 22:26:10 +02002168 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2169
Harald Welte6e0cd042009-09-12 13:05:33 +02002170 return CMD_SUCCESS;
2171}
2172
2173DEFUN(cfg_ts_arfcn_del,
2174 cfg_ts_arfcn_del_cmd,
2175 "hopping arfcn del <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002176 HOPPING_STR "Configure hopping ARFCN list\n"
2177 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02002178{
2179 struct gsm_bts_trx_ts *ts = vty->index;
2180 int arfcn = atoi(argv[0]);
2181
Harald Weltea39b0f22010-06-14 22:26:10 +02002182 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2183
Harald Welte6e0cd042009-09-12 13:05:33 +02002184 return CMD_SUCCESS;
2185}
2186
Harald Weltea6fd58e2009-08-07 00:25:23 +02002187DEFUN(cfg_ts_e1_subslot,
2188 cfg_ts_e1_subslot_cmd,
Harald Welte42581822009-08-08 16:12:58 +02002189 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltea6fd58e2009-08-07 00:25:23 +02002190 "E1 sub-slot connected to this on-air timeslot")
2191{
2192 struct gsm_bts_trx_ts *ts = vty->index;
2193
Harald Welte42581822009-08-08 16:12:58 +02002194 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002195
2196 return CMD_SUCCESS;
2197}
Harald Welte5258fc42009-03-28 19:07:53 +00002198
Harald Welte4f10c252010-05-16 21:47:13 +02002199void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2200{
2201 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2202 counter_get(net->stats.chreq.total),
2203 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2204 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2205 counter_get(net->stats.chan.rf_fail),
2206 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2207 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2208 counter_get(net->stats.paging.attempted),
2209 counter_get(net->stats.paging.completed),
2210 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2211 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2212 counter_get(net->stats.bts.oml_fail),
2213 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2214}
2215
Harald Welte5bc61dc2010-05-16 22:02:16 +02002216DEFUN(logging_fltr_imsi,
2217 logging_fltr_imsi_cmd,
2218 "logging filter imsi IMSI",
2219 LOGGING_STR FILTER_STR
2220 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2221{
2222 struct telnet_connection *conn;
2223
2224 conn = (struct telnet_connection *) vty->priv;
2225 if (!conn->dbg) {
2226 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
2227 return CMD_WARNING;
2228 }
2229
2230 log_set_imsi_filter(conn->dbg, argv[0]);
2231 return CMD_SUCCESS;
2232}
2233
Harald Weltedcccb182010-05-16 20:52:23 +02002234extern int bsc_vty_init_extra(void);
Harald Welte1353f962010-05-16 19:20:24 +02002235extern const char *openbsc_copyright;
Holger Hans Peter Freythere1ffc082010-04-10 00:08:28 +02002236
Harald Weltedcccb182010-05-16 20:52:23 +02002237int bsc_vty_init(void)
Harald Welte68628e82009-03-10 12:17:57 +00002238{
Harald Welteb4d5b172010-05-12 16:10:35 +00002239 install_element_ve(&show_net_cmd);
2240 install_element_ve(&show_bts_cmd);
2241 install_element_ve(&show_trx_cmd);
2242 install_element_ve(&show_ts_cmd);
2243 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08002244 install_element_ve(&show_lchan_summary_cmd);
Harald Welte5bc61dc2010-05-16 22:02:16 +02002245 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00002246
Harald Welteb4d5b172010-05-12 16:10:35 +00002247 install_element_ve(&show_e1drv_cmd);
2248 install_element_ve(&show_e1line_cmd);
2249 install_element_ve(&show_e1ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002250
Harald Welteb4d5b172010-05-12 16:10:35 +00002251 install_element_ve(&show_paging_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002252
Harald Welte5bc61dc2010-05-16 22:02:16 +02002253 logging_vty_add_cmds();
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +01002254
Harald Welte5013b2a2009-08-07 13:29:14 +02002255 install_element(CONFIG_NODE, &cfg_net_cmd);
2256 install_node(&net_node, config_write_net);
2257 install_default(GSMNET_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002258 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002259 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002260 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02002261 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2262 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2263 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)69de3972009-08-12 14:42:23 +02002264 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte1085c092009-11-18 20:33:19 +01002265 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Welte4381cfe2009-08-30 15:47:06 +09002266 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01002267 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welteeab84a12009-12-13 10:53:12 +01002268 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte3d23db42009-12-14 17:49:15 +01002269 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Weltebc814502009-12-19 21:41:52 +01002270 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Welteb720bd32009-12-21 16:51:50 +01002271 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2272 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2273 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2274 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2275 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2276 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01002277 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01002278 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2279 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2280 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2281 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2282 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2283 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2284 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2285 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2286 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
2287 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02002288
2289 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02002290 install_node(&bts_node, config_write_bts);
Harald Welte68628e82009-03-10 12:17:57 +00002291 install_default(BTS_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002292 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002293 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002294 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02002295 install_element(BTS_NODE, &cfg_description_cmd);
2296 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02002297 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02002298 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002299 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2300 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002301 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00002302 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte8175e952009-10-20 00:22:00 +02002303 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002304 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2305 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02002306 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01002307 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2308 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08002309 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2310 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02002311 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08002312 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)0e451d02009-08-13 10:14:26 +02002313 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)efc92312009-08-14 23:09:25 +02002314 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welte73225282009-12-12 18:17:25 +01002315 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2316 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Welte4511d892010-04-18 15:51:20 +02002317 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02002318 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08002319 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2320 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02002321 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Weltea5731cf2010-03-22 11:48:36 +08002322 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08002323 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welteaf387632010-03-14 23:30:30 +08002324 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2325 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2326 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Harald Welte9fbff4a2010-07-30 11:50:09 +02002327 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2328 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002329
Harald Welte5258fc42009-03-28 19:07:53 +00002330 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002331 install_node(&trx_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00002332 install_default(TRX_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002333 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002334 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002335 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02002336 install_element(TRX_NODE, &cfg_description_cmd);
2337 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)7b37d972009-12-27 20:56:38 +01002338 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02002339 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002340 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2341 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01002342 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002343
Harald Welte5258fc42009-03-28 19:07:53 +00002344 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002345 install_node(&ts_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00002346 install_default(TS_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002347 install_element(TS_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002348 install_element(TS_NODE, &ournode_end_cmd);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002349 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Weltea39b0f22010-06-14 22:26:10 +02002350 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte6e0cd042009-09-12 13:05:33 +02002351 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2352 install_element(TS_NODE, &cfg_ts_maio_cmd);
2353 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2354 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002355 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002356
Harald Welte81c9b9c2010-05-31 16:40:40 +02002357 abis_nm_vty_init();
2358
Harald Weltedcccb182010-05-16 20:52:23 +02002359 bsc_vty_init_extra();
Harald Welte40f82892009-05-23 17:31:39 +00002360
Harald Welte68628e82009-03-10 12:17:57 +00002361 return 0;
2362}