blob: 547681ce3ff5310a7807429409d3eeb29b9ae414 [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
25#include <vty/command.h>
Harald Weltef9daefd2009-08-09 15:13:54 +020026#include <vty/buffer.h>
Harald Welte68628e82009-03-10 12:17:57 +000027#include <vty/vty.h>
28
29#include <arpa/inet.h>
30
Harald Weltedfe6c7d2010-02-20 16:24:02 +010031#include <osmocore/linuxlist.h>
Harald Welte68628e82009-03-10 12:17:57 +000032#include <openbsc/gsm_data.h>
Harald Welte68628e82009-03-10 12:17:57 +000033#include <openbsc/e1_input.h>
Harald Welte1bc77352009-03-10 19:47:51 +000034#include <openbsc/abis_nm.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010035#include <osmocore/gsm_utils.h>
Harald Welteb908cb72009-12-22 13:09:29 +010036#include <openbsc/chan_alloc.h>
Harald Welte8387a492009-12-22 21:43:14 +010037#include <openbsc/meas_rep.h>
Harald Welte40f82892009-05-23 17:31:39 +000038#include <openbsc/db.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010039#include <osmocore/talloc.h>
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +010040#include <openbsc/telnet_interface.h>
Holger Hans Peter Freyther3c712322010-04-06 11:55:37 +020041#include <openbsc/vty.h>
Harald Welte68628e82009-03-10 12:17:57 +000042
43static struct gsm_network *gsmnet;
44
Harald Welte5013b2a2009-08-07 13:29:14 +020045struct cmd_node net_node = {
46 GSMNET_NODE,
47 "%s(network)#",
48 1,
49};
50
Harald Welte68628e82009-03-10 12:17:57 +000051struct cmd_node bts_node = {
52 BTS_NODE,
53 "%s(bts)#",
54 1,
55};
56
57struct cmd_node trx_node = {
58 TRX_NODE,
59 "%s(trx)#",
60 1,
61};
62
63struct cmd_node ts_node = {
64 TS_NODE,
65 "%s(ts)#",
66 1,
67};
68
69static int dummy_config_write(struct vty *v)
70{
71 return CMD_SUCCESS;
72}
73
74static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
75{
Harald Welte1bc77352009-03-10 19:47:51 +000076 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
77 nm_opstate_name(nms->operational), nms->administrative,
78 nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +000079}
80
Harald Welteb908cb72009-12-22 13:09:29 +010081static void dump_pchan_load_vty(struct vty *vty, char *prefix,
82 const struct pchan_load *pl)
83{
84 int i;
85
86 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
87 const struct load_counter *lc = &pl->pchan[i];
88 unsigned int percent;
89
90 if (lc->total == 0)
91 continue;
92
93 percent = (lc->used * 100) / lc->total;
94
95 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
96 gsm_pchan_name(i), percent, lc->used, lc->total,
97 VTY_NEWLINE);
98 }
99}
100
Harald Welte68628e82009-03-10 12:17:57 +0000101static void net_dump_vty(struct vty *vty, struct gsm_network *net)
102{
Harald Welteb908cb72009-12-22 13:09:29 +0100103 struct pchan_load pl;
104
Harald Welteef235b52009-03-10 12:34:02 +0000105 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
106 "and has %u BTS%s", net->country_code, net->network_code,
107 net->num_bts, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000108 vty_out(vty, " Long network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000109 net->name_long, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000110 vty_out(vty, " Short network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000111 net->name_short, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200112 vty_out(vty, " Authentication policy: %s%s",
113 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100114 vty_out(vty, " Location updating reject cause: %u%s",
115 net->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900116 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
117 VTY_NEWLINE);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100118 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
119 VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100120 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
121 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100122 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
123 VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100124 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
125 VTY_NEWLINE);
Harald Welteb908cb72009-12-22 13:09:29 +0100126 network_chan_load(&pl, net);
127 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
128 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000129}
130
131DEFUN(show_net, show_net_cmd, "show network",
132 SHOW_STR "Display information about a GSM NETWORK\n")
133{
134 struct gsm_network *net = gsmnet;
135 net_dump_vty(vty, net);
136
137 return CMD_SUCCESS;
138}
139
140static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
141{
Harald Welteedb37782009-05-01 14:59:07 +0000142 struct e1inp_line *line;
143
144 if (!e1l) {
145 vty_out(vty, " None%s", VTY_NEWLINE);
146 return;
147 }
148
149 line = e1l->ts->line;
150
151 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
152 line->num, line->driver->name, e1l->ts->num,
Harald Welte1bc77352009-03-10 19:47:51 +0000153 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000154 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000155 e1l->tei, e1l->sapi, VTY_NEWLINE);
156}
157
158static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
159{
Harald Welteb908cb72009-12-22 13:09:29 +0100160 struct pchan_load pl;
161
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200162 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Weltefcd24452009-06-20 18:15:19 +0200163 "BSIC %u, TSC %u and %u TRX%s",
164 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200165 bts->cell_identity,
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +0200166 bts->location_area_code, bts->bsic, bts->tsc,
Harald Weltefcd24452009-06-20 18:15:19 +0200167 bts->num_trx, VTY_NEWLINE);
Harald Welte1d8dbc42009-12-12 15:38:16 +0100168 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100169 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte1d8dbc42009-12-12 15:38:16 +0100170 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
171 VTY_NEWLINE);
172 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welte73225282009-12-12 18:17:25 +0100173 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100174 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
175 VTY_NEWLINE);
176 vty_out(vty, "RACH Max transmissions: %u%s",
177 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
178 VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100179 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200180 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000181 if (is_ipaccess_bts(bts))
Harald Welte8175e952009-10-20 00:22:00 +0200182 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte4cc34222009-05-01 15:12:31 +0000183 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte8175e952009-10-20 00:22:00 +0200184 bts->oml_tei, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000185 vty_out(vty, " NM State: ");
186 net_dump_nmstate(vty, &bts->nm_state);
187 vty_out(vty, " Site Mgr NM State: ");
188 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
189 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
190 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200191 if (!is_ipaccess_bts(bts)) {
192 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
193 e1isl_dump_vty(vty, bts->oml_link);
194 }
Harald Welte68628e82009-03-10 12:17:57 +0000195 /* FIXME: oml_link, chan_desc */
Harald Welteb908cb72009-12-22 13:09:29 +0100196 memset(&pl, 0, sizeof(pl));
197 bts_chan_load(&pl, bts);
198 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
199 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000200}
201
202DEFUN(show_bts, show_bts_cmd, "show bts [number]",
203 SHOW_STR "Display information about a BTS\n"
204 "BTS number")
205{
206 struct gsm_network *net = gsmnet;
207 int bts_nr;
208
209 if (argc != 0) {
210 /* use the BTS number that the user has specified */
211 bts_nr = atoi(argv[0]);
212 if (bts_nr > net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000213 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000214 VTY_NEWLINE);
215 return CMD_WARNING;
216 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200217 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000218 return CMD_SUCCESS;
219 }
220 /* print all BTS's */
221 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200222 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000223
224 return CMD_SUCCESS;
225}
226
Harald Welte42581822009-08-08 16:12:58 +0200227/* utility functions */
228static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
229 const char *ts, const char *ss)
230{
231 e1_link->e1_nr = atoi(line);
232 e1_link->e1_ts = atoi(ts);
233 if (!strcmp(ss, "full"))
234 e1_link->e1_ts_ss = 255;
235 else
236 e1_link->e1_ts_ss = atoi(ss);
237}
238
239static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
240 const char *prefix)
241{
242 if (!e1_link->e1_ts)
243 return;
244
245 if (e1_link->e1_ts_ss == 255)
246 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
247 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
248 else
249 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
250 prefix, e1_link->e1_nr, e1_link->e1_ts,
251 e1_link->e1_ts_ss, VTY_NEWLINE);
252}
253
254
Harald Welte67ce0732009-08-06 19:06:46 +0200255static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
256{
Harald Welte42581822009-08-08 16:12:58 +0200257 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
258 if (ts->pchan != GSM_PCHAN_NONE)
259 vty_out(vty, " phys_chan_config %s%s",
260 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
261 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte67ce0732009-08-06 19:06:46 +0200262}
263
264static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
265{
266 int i;
267
Harald Welte5013b2a2009-08-07 13:29:14 +0200268 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Holger Hans Peter Freyther2ba40af2010-04-17 06:42:07 +0200269 vty_out(vty, " rf_locked %u%s",
270 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
271 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200272 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100273 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200274 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200275 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
276 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200277
278 for (i = 0; i < TRX_NR_TS; i++)
279 config_write_ts_single(vty, &trx->ts[i]);
280}
281
282static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
283{
284 struct gsm_bts_trx *trx;
Harald Welte97a282b2010-03-14 15:37:43 +0800285 int i;
Harald Welte67ce0732009-08-06 19:06:46 +0200286
Harald Welte5013b2a2009-08-07 13:29:14 +0200287 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
288 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
289 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freytherf926ed62009-11-19 16:38:49 +0100290 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200291 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200292 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200293 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
294 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200295 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100296 vty_out(vty, " cell reselection hysteresis %u%s",
297 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
298 vty_out(vty, " rxlev access min %u%s",
299 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Harald Weltea43f7892009-12-01 18:04:30 +0530300 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)efc92312009-08-14 23:09:25 +0200301 vty_out(vty, " periodic location update %u%s",
Harald Weltea43f7892009-12-01 18:04:30 +0530302 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte7a8fa412009-08-10 13:48:16 +0200303 vty_out(vty, " channel allocator %s%s",
304 bts->chan_alloc_reverse ? "descending" : "ascending",
305 VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100306 vty_out(vty, " rach tx integer %u%s",
307 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
308 vty_out(vty, " rach max transmission %u%s",
309 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
310 VTY_NEWLINE);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800311
312 if (bts->rach_b_thresh != -1)
313 vty_out(vty, " rach nm busy threshold %u%s",
314 bts->rach_b_thresh, VTY_NEWLINE);
315 if (bts->rach_ldavg_slots != -1)
316 vty_out(vty, " rach nm load average %u%s",
317 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100318 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200319 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200320 if (is_ipaccess_bts(bts)) {
Harald Welte5013b2a2009-08-07 13:29:14 +0200321 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200322 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200323 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
324 } else {
Harald Welte42581822009-08-08 16:12:58 +0200325 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
326 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
327 }
Harald Welte4511d892010-04-18 15:51:20 +0200328 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
329 VTY_NEWLINE);
330 if (bts->gprs.mode != BTS_GPRS_NONE) {
Harald Welteaf387632010-03-14 23:30:30 +0800331 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
332 VTY_NEWLINE);
333 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
334 VTY_NEWLINE);
Harald Weltea5731cf2010-03-22 11:48:36 +0800335 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
336 VTY_NEWLINE);
Harald Welteaf387632010-03-14 23:30:30 +0800337 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
338 struct gsm_bts_gprs_nsvc *nsvc =
339 &bts->gprs.nsvc[i];
340 struct in_addr ia;
341
342 ia.s_addr = htonl(nsvc->remote_ip);
343 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
344 nsvc->nsvci, VTY_NEWLINE);
345 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
346 nsvc->local_port, VTY_NEWLINE);
347 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
348 nsvc->remote_port, VTY_NEWLINE);
349 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
350 inet_ntoa(ia), VTY_NEWLINE);
351 }
352 }
Harald Welte67ce0732009-08-06 19:06:46 +0200353
354 llist_for_each_entry(trx, &bts->trx_list, list)
355 config_write_trx_single(vty, trx);
356}
357
358static int config_write_bts(struct vty *v)
359{
360 struct gsm_bts *bts;
361
362 llist_for_each_entry(bts, &gsmnet->bts_list, list)
363 config_write_bts_single(v, bts);
364
365 return CMD_SUCCESS;
366}
367
Harald Welte5013b2a2009-08-07 13:29:14 +0200368static int config_write_net(struct vty *vty)
369{
370 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200371 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200372 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200373 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
374 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200375 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100376 vty_out(vty, " location updating reject cause %u%s",
377 gsmnet->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900378 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freytherd54c3372009-11-19 16:37:48 +0100379 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100380 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
381 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100382 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100383 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Welteb720bd32009-12-21 16:51:50 +0100384 vty_out(vty, " handover window rxlev averaging %u%s",
385 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
386 vty_out(vty, " handover window rxqual averaging %u%s",
387 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
388 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
389 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
390 vty_out(vty, " handover power budget interval %u%s",
391 gsmnet->handover.pwr_interval, VTY_NEWLINE);
392 vty_out(vty, " handover power budget hysteresis %u%s",
393 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
394 vty_out(vty, " handover maximum distance %u%s",
395 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100396 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100397 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
398 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
399 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
400 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
401 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
402 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
403 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
404 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
405 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
406 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200407
408 return CMD_SUCCESS;
409}
Harald Welte67ce0732009-08-06 19:06:46 +0200410
Harald Welte68628e82009-03-10 12:17:57 +0000411static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
412{
413 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
414 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +0200415 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte42581822009-08-08 16:12:58 +0200416 "resulting BS power: %d dBm%s",
Harald Weltefcd24452009-06-20 18:15:19 +0200417 trx->nominal_power, trx->max_power_red,
Harald Welte42581822009-08-08 16:12:58 +0200418 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000419 vty_out(vty, " NM State: ");
420 net_dump_nmstate(vty, &trx->nm_state);
421 vty_out(vty, " Baseband Transceiver NM State: ");
422 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte8175e952009-10-20 00:22:00 +0200423 if (is_ipaccess_bts(trx->bts)) {
424 vty_out(vty, " ip.access stream ID: 0x%02x%s",
425 trx->rsl_tei, VTY_NEWLINE);
426 } else {
427 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
428 e1isl_dump_vty(vty, trx->rsl_link);
429 }
Harald Welte68628e82009-03-10 12:17:57 +0000430}
431
432DEFUN(show_trx,
433 show_trx_cmd,
434 "show trx [bts_nr] [trx_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200435 SHOW_STR "Display information about a TRX\n"
436 "BTS Number\n"
437 "TRX Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000438{
439 struct gsm_network *net = gsmnet;
440 struct gsm_bts *bts = NULL;
441 struct gsm_bts_trx *trx;
442 int bts_nr, trx_nr;
443
444 if (argc >= 1) {
445 /* use the BTS number that the user has specified */
446 bts_nr = atoi(argv[0]);
447 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000448 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000449 VTY_NEWLINE);
450 return CMD_WARNING;
451 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200452 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000453 }
454 if (argc >= 2) {
455 trx_nr = atoi(argv[1]);
456 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000457 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000458 VTY_NEWLINE);
459 return CMD_WARNING;
460 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200461 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000462 trx_dump_vty(vty, trx);
463 return CMD_SUCCESS;
464 }
465 if (bts) {
466 /* print all TRX in this BTS */
467 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200468 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000469 trx_dump_vty(vty, trx);
470 }
471 return CMD_SUCCESS;
472 }
473
474 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200475 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000476 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200477 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000478 trx_dump_vty(vty, trx);
479 }
480 }
481
482 return CMD_SUCCESS;
483}
484
Harald Welte67ce0732009-08-06 19:06:46 +0200485
Harald Welte68628e82009-03-10 12:17:57 +0000486static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
487{
Harald Welte68628e82009-03-10 12:17:57 +0000488 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
489 ts->nr, ts->trx->nr, ts->trx->bts->nr,
490 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
491 vty_out(vty, " NM State: ");
492 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte2c828992009-12-02 01:56:49 +0530493 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welteef235b52009-03-10 12:34:02 +0000494 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
495 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
496 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000497}
498
499DEFUN(show_ts,
500 show_ts_cmd,
Harald Welte1bc77352009-03-10 19:47:51 +0000501 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200502 SHOW_STR "Display information about a TS\n"
503 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000504{
505 struct gsm_network *net = gsmnet;
506 struct gsm_bts *bts;
507 struct gsm_bts_trx *trx;
508 struct gsm_bts_trx_ts *ts;
509 int bts_nr, trx_nr, ts_nr;
510
511 if (argc >= 1) {
512 /* use the BTS number that the user has specified */
513 bts_nr = atoi(argv[0]);
514 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000515 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000516 VTY_NEWLINE);
517 return CMD_WARNING;
518 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200519 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000520 }
521 if (argc >= 2) {
522 trx_nr = atoi(argv[1]);
523 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000524 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000525 VTY_NEWLINE);
526 return CMD_WARNING;
527 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200528 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000529 }
530 if (argc >= 3) {
531 ts_nr = atoi(argv[2]);
532 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +0000533 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +0000534 VTY_NEWLINE);
535 return CMD_WARNING;
536 }
537 ts = &trx->ts[ts_nr];
538 ts_dump_vty(vty, ts);
539 return CMD_SUCCESS;
540 }
541 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200542 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000543 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200544 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000545 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
546 ts = &trx->ts[ts_nr];
547 ts_dump_vty(vty, ts);
548 }
549 }
550 }
551
552 return CMD_SUCCESS;
553}
554
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100555static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte68628e82009-03-10 12:17:57 +0000556{
Harald Weltefcd24452009-06-20 18:15:19 +0200557 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte40f82892009-05-23 17:31:39 +0000558 subscr->authorized, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000559 if (subscr->name)
Harald Welte1bc77352009-03-10 19:47:51 +0000560 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000561 if (subscr->extension)
562 vty_out(vty, " Extension: %s%s", subscr->extension,
563 VTY_NEWLINE);
564 if (subscr->imsi)
565 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freyther22230252009-08-19 12:53:57 +0200566 if (subscr->tmsi != GSM_RESERVED_TMSI)
567 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte731fd912009-08-15 03:24:51 +0200568 VTY_NEWLINE);
Sylvain Munautaf292642009-12-27 19:29:28 +0100569
Harald Welte (local)15920de2009-08-14 20:27:16 +0200570 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000571}
572
Harald Welte8387a492009-12-22 21:43:14 +0100573static void meas_rep_dump_uni_vty(struct vty *vty,
574 struct gsm_meas_rep_unidir *mru,
575 const char *prefix,
576 const char *dir)
577{
578 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
579 prefix, dir, rxlev2dbm(mru->full.rx_lev),
580 dir, rxlev2dbm(mru->sub.rx_lev));
581 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
582 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
583 VTY_NEWLINE);
584}
585
586static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
587 const char *prefix)
588{
589 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
590 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
591 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
592 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
593 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
594 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
595 VTY_NEWLINE);
596 if (mr->flags & MEAS_REP_F_MS_TO)
597 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
598 mr->ms_timing_offset, VTY_NEWLINE);
599 if (mr->flags & MEAS_REP_F_MS_L1)
600 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
601 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
602 if (mr->flags & MEAS_REP_F_DL_VALID)
603 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
604 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
605}
606
Harald Welte68628e82009-03-10 12:17:57 +0000607static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
608{
Harald Welte8387a492009-12-22 21:43:14 +0100609 int idx;
610
Harald Welte68628e82009-03-10 12:17:57 +0000611 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 +0200612 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
Harald Welte (local)ccd88452009-12-27 18:05:25 +0100613 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Harald Welte68628e82009-03-10 12:17:57 +0000614 VTY_NEWLINE);
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100615 vty_out(vty, " Use Count: %u, State: %s%s", lchan->conn.use_count,
Harald Welte1887f9d2009-12-29 10:52:38 +0100616 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100617 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
618 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
619 - lchan->bs_power*2,
620 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
621 VTY_NEWLINE);
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100622 if (lchan->conn.subscr) {
Harald Welte68628e82009-03-10 12:17:57 +0000623 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100624 subscr_dump_vty(vty, lchan->conn.subscr);
Harald Welte68628e82009-03-10 12:17:57 +0000625 } else
626 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte2c828992009-12-02 01:56:49 +0530627 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
628 struct in_addr ia;
Holger Hans Peter Freyther54fa7992010-04-07 15:39:16 +0200629 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte2c828992009-12-02 01:56:49 +0530630 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
631 inet_ntoa(ia), lchan->abis_ip.bound_port,
632 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
633 VTY_NEWLINE);
634 }
Harald Welte8387a492009-12-22 21:43:14 +0100635
636 /* we want to report the last measurement report */
637 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
638 lchan->meas_rep_idx, 1);
639 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte68628e82009-03-10 12:17:57 +0000640}
641
Harald Welte4bfdfe72009-06-10 23:11:52 +0800642#if 0
643TODO: callref and remote callref of call must be resolved to get gsm_trans object
Harald Welte68628e82009-03-10 12:17:57 +0000644static void call_dump_vty(struct vty *vty, struct gsm_call *call)
645{
646 vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s",
647 call->type, call->state, call->transaction_id, VTY_NEWLINE);
648
649 if (call->local_lchan) {
650 vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE);
651 lchan_dump_vty(vty, call->local_lchan);
652 } else
653 vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE);
654
655 if (call->remote_lchan) {
656 vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE);
657 lchan_dump_vty(vty, call->remote_lchan);
658 } else
659 vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE);
660
661 if (call->called_subscr) {
662 vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE);
663 subscr_dump_vty(vty, call->called_subscr);
664 } else
665 vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE);
666}
Harald Welte4bfdfe72009-06-10 23:11:52 +0800667#endif
Harald Welte68628e82009-03-10 12:17:57 +0000668
669DEFUN(show_lchan,
670 show_lchan_cmd,
671 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200672 SHOW_STR "Display information about a logical channel\n"
673 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
674 "Logical Channel Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000675{
676 struct gsm_network *net = gsmnet;
677 struct gsm_bts *bts;
678 struct gsm_bts_trx *trx;
679 struct gsm_bts_trx_ts *ts;
680 struct gsm_lchan *lchan;
681 int bts_nr, trx_nr, ts_nr, lchan_nr;
682
683 if (argc >= 1) {
684 /* use the BTS number that the user has specified */
685 bts_nr = atoi(argv[0]);
686 if (bts_nr >= net->num_bts) {
687 vty_out(vty, "%% can't find BTS %s%s", argv[0],
688 VTY_NEWLINE);
689 return CMD_WARNING;
690 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200691 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000692 }
693 if (argc >= 2) {
694 trx_nr = atoi(argv[1]);
695 if (trx_nr >= bts->num_trx) {
696 vty_out(vty, "%% can't find TRX %s%s", argv[1],
697 VTY_NEWLINE);
698 return CMD_WARNING;
699 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200700 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000701 }
702 if (argc >= 3) {
703 ts_nr = atoi(argv[2]);
704 if (ts_nr >= TRX_NR_TS) {
705 vty_out(vty, "%% can't find TS %s%s", argv[2],
706 VTY_NEWLINE);
707 return CMD_WARNING;
708 }
709 ts = &trx->ts[ts_nr];
710 }
711 if (argc >= 4) {
712 lchan_nr = atoi(argv[3]);
713 if (lchan_nr >= TS_MAX_LCHAN) {
714 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
715 VTY_NEWLINE);
716 return CMD_WARNING;
717 }
718 lchan = &ts->lchan[lchan_nr];
719 lchan_dump_vty(vty, lchan);
720 return CMD_SUCCESS;
721 }
722 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200723 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000724 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200725 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000726 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
727 ts = &trx->ts[ts_nr];
728 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
729 lchan_nr++) {
730 lchan = &ts->lchan[lchan_nr];
Harald Welteef235b52009-03-10 12:34:02 +0000731 if (lchan->type == GSM_LCHAN_NONE)
732 continue;
Harald Welte68628e82009-03-10 12:17:57 +0000733 lchan_dump_vty(vty, lchan);
734 }
735 }
736 }
737 }
738
739 return CMD_SUCCESS;
740}
741
Harald Welte1bc77352009-03-10 19:47:51 +0000742static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
743{
744 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
745}
746
747DEFUN(show_e1drv,
748 show_e1drv_cmd,
749 "show e1_driver",
750 SHOW_STR "Display information about available E1 drivers\n")
751{
752 struct e1inp_driver *drv;
753
754 llist_for_each_entry(drv, &e1inp_driver_list, list)
755 e1drv_dump_vty(vty, drv);
756
757 return CMD_SUCCESS;
758}
759
Harald Welte68628e82009-03-10 12:17:57 +0000760static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
761{
762 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
763 line->num, line->name ? line->name : "",
764 line->driver->name, VTY_NEWLINE);
765}
766
767DEFUN(show_e1line,
768 show_e1line_cmd,
769 "show e1_line [line_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200770 SHOW_STR "Display information about a E1 line\n"
771 "E1 Line Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000772{
Harald Welte1bc77352009-03-10 19:47:51 +0000773 struct e1inp_line *line;
774
775 if (argc >= 1) {
776 int num = atoi(argv[0]);
777 llist_for_each_entry(line, &e1inp_line_list, list) {
778 if (line->num == num) {
779 e1line_dump_vty(vty, line);
780 return CMD_SUCCESS;
781 }
782 }
783 return CMD_WARNING;
784 }
785
786 llist_for_each_entry(line, &e1inp_line_list, list)
787 e1line_dump_vty(vty, line);
788
789 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000790}
791
792static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
793{
Harald Welte42581822009-08-08 16:12:58 +0200794 if (ts->type == E1INP_TS_TYPE_NONE)
795 return;
Harald Welte1bc77352009-03-10 19:47:51 +0000796 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
797 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
798 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000799}
800
801DEFUN(show_e1ts,
802 show_e1ts_cmd,
803 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200804 SHOW_STR "Display information about a E1 timeslot\n"
805 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000806{
Harald Welte986c3d72009-11-17 06:12:16 +0100807 struct e1inp_line *line = NULL;
Harald Welte1bc77352009-03-10 19:47:51 +0000808 struct e1inp_ts *ts;
809 int ts_nr;
Harald Welte68628e82009-03-10 12:17:57 +0000810
Harald Welte1bc77352009-03-10 19:47:51 +0000811 if (argc == 0) {
812 llist_for_each_entry(line, &e1inp_line_list, list) {
813 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
814 ts = &line->ts[ts_nr];
815 e1ts_dump_vty(vty, ts);
816 }
817 }
818 return CMD_SUCCESS;
819 }
820 if (argc >= 1) {
821 int num = atoi(argv[0]);
822 llist_for_each_entry(line, &e1inp_line_list, list) {
823 if (line->num == num)
824 break;
825 }
826 if (!line || line->num != num) {
827 vty_out(vty, "E1 line %s is invalid%s",
828 argv[0], VTY_NEWLINE);
829 return CMD_WARNING;
830 }
831 }
832 if (argc >= 2) {
833 ts_nr = atoi(argv[1]);
834 if (ts_nr > NUM_E1_TS) {
835 vty_out(vty, "E1 timeslot %s is invalid%s",
836 argv[1], VTY_NEWLINE);
837 return CMD_WARNING;
838 }
839 ts = &line->ts[ts_nr];
840 e1ts_dump_vty(vty, ts);
841 return CMD_SUCCESS;
842 } else {
843 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
844 ts = &line->ts[ts_nr];
845 e1ts_dump_vty(vty, ts);
846 }
847 return CMD_SUCCESS;
848 }
849 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000850}
851
Harald Weltebe4b7302009-05-23 16:59:33 +0000852static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +0000853{
854 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
855 subscr_dump_vty(vty, pag->subscr);
856}
857
Harald Weltebe4b7302009-05-23 16:59:33 +0000858static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +0000859{
860 struct gsm_paging_request *pag;
861
862 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
863 paging_dump_vty(vty, pag);
864}
865
866DEFUN(show_paging,
867 show_paging_cmd,
868 "show paging [bts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200869 SHOW_STR "Display information about paging reuqests of a BTS\n"
870 "BTS Number\n")
Harald Weltef5025b62009-03-28 16:55:11 +0000871{
872 struct gsm_network *net = gsmnet;
873 struct gsm_bts *bts;
874 int bts_nr;
875
876 if (argc >= 1) {
877 /* use the BTS number that the user has specified */
878 bts_nr = atoi(argv[0]);
879 if (bts_nr >= net->num_bts) {
880 vty_out(vty, "%% can't find BTS %s%s", argv[0],
881 VTY_NEWLINE);
882 return CMD_WARNING;
883 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200884 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000885 bts_paging_dump_vty(vty, bts);
886
887 return CMD_SUCCESS;
888 }
889 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200890 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000891 bts_paging_dump_vty(vty, bts);
892 }
893
894 return CMD_SUCCESS;
895}
896
Harald Welte8f0ed552010-05-11 21:53:49 +0200897#define NETWORK_STR "Configure the GSM network\n"
898
Harald Welte5013b2a2009-08-07 13:29:14 +0200899DEFUN(cfg_net,
900 cfg_net_cmd,
Harald Welte8f0ed552010-05-11 21:53:49 +0200901 "network", NETWORK_STR)
Harald Welte5013b2a2009-08-07 13:29:14 +0200902{
903 vty->index = gsmnet;
904 vty->node = GSMNET_NODE;
905
906 return CMD_SUCCESS;
907}
908
909
910DEFUN(cfg_net_ncc,
911 cfg_net_ncc_cmd,
912 "network country code <1-999>",
913 "Set the GSM network country code")
914{
915 gsmnet->country_code = atoi(argv[0]);
916
917 return CMD_SUCCESS;
918}
919
920DEFUN(cfg_net_mnc,
921 cfg_net_mnc_cmd,
922 "mobile network code <1-999>",
923 "Set the GSM mobile network code")
924{
925 gsmnet->network_code = atoi(argv[0]);
926
927 return CMD_SUCCESS;
928}
929
930DEFUN(cfg_net_name_short,
931 cfg_net_name_short_cmd,
932 "short name NAME",
933 "Set the short GSM network name")
934{
935 if (gsmnet->name_short)
936 talloc_free(gsmnet->name_short);
937
938 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
939
940 return CMD_SUCCESS;
941}
942
943DEFUN(cfg_net_name_long,
944 cfg_net_name_long_cmd,
945 "long name NAME",
946 "Set the long GSM network name")
947{
948 if (gsmnet->name_long)
949 talloc_free(gsmnet->name_long);
950
951 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
952
953 return CMD_SUCCESS;
954}
Harald Welte40f82892009-05-23 17:31:39 +0000955
Harald Welte (local)69de3972009-08-12 14:42:23 +0200956DEFUN(cfg_net_auth_policy,
957 cfg_net_auth_policy_cmd,
958 "auth policy (closed|accept-all|token)",
Harald Welte8f0ed552010-05-11 21:53:49 +0200959 "Authentication (not cryptographic)\n"
960 "Set the GSM network authentication policy\n"
961 "Require the MS to be activated in HLR\n"
962 "Accept all MS, whether in HLR or not\n"
963 "Use SMS-token based authentication\n")
Harald Welte (local)69de3972009-08-12 14:42:23 +0200964{
965 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
966
967 gsmnet->auth_policy = policy;
968
969 return CMD_SUCCESS;
970}
971
Harald Welte1085c092009-11-18 20:33:19 +0100972DEFUN(cfg_net_reject_cause,
973 cfg_net_reject_cause_cmd,
974 "location updating reject cause <2-111>",
975 "Set the reject cause of location updating reject\n")
976{
977 gsmnet->reject_cause = atoi(argv[0]);
978
979 return CMD_SUCCESS;
980}
981
Harald Welte4381cfe2009-08-30 15:47:06 +0900982DEFUN(cfg_net_encryption,
983 cfg_net_encryption_cmd,
984 "encryption a5 (0|1|2)",
985 "Enable or disable encryption (A5) for this network\n")
986{
Andreas.Eversberg1059deb2009-11-17 09:55:26 +0100987 gsmnet->a5_encryption= atoi(argv[0]);
Harald Welte4381cfe2009-08-30 15:47:06 +0900988
989 return CMD_SUCCESS;
990}
991
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100992DEFUN(cfg_net_neci,
993 cfg_net_neci_cmd,
994 "neci (0|1)",
995 "Set if NECI of cell selection is to be set")
996{
997 gsmnet->neci = atoi(argv[0]);
998 return CMD_SUCCESS;
999}
1000
Harald Welteeab84a12009-12-13 10:53:12 +01001001DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1002 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001003 "Radio Resource Location Protocol\n"
1004 "Set the Radio Resource Location Protocol Mode\n"
1005 "Don't send RRLP request\n"
1006 "Request MS-based location\n"
1007 "Request any location, prefer MS-based\n"
1008 "Request any location, prefer MS-assisted\n")
Harald Welteeab84a12009-12-13 10:53:12 +01001009{
1010 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1011
1012 return CMD_SUCCESS;
1013}
1014
Harald Welte648b6ce2009-12-14 09:00:24 +01001015DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1016 "mm info (0|1)",
1017 "Whether to send MM INFO after LOC UPD ACCEPT")
1018{
1019 gsmnet->send_mm_info = atoi(argv[0]);
1020
1021 return CMD_SUCCESS;
1022}
1023
Harald Welte8f0ed552010-05-11 21:53:49 +02001024#define HANDOVER_STR "Handover Options\n"
1025
Harald Weltebc814502009-12-19 21:41:52 +01001026DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1027 "handover (0|1)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001028 HANDOVER_STR
1029 "Don't perform in-call handover\n"
1030 "Perform in-call handover\n")
Harald Weltebc814502009-12-19 21:41:52 +01001031{
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001032 int enable = atoi(argv[0]);
1033
1034 if (enable && ipacc_rtp_direct) {
Harald Weltefe03f0d2009-12-20 13:51:01 +01001035 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1036 "is enabled by using the -P command line option%s",
1037 VTY_NEWLINE);
1038 return CMD_WARNING;
1039 }
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001040 gsmnet->handover.active = enable;
Harald Weltebc814502009-12-19 21:41:52 +01001041
1042 return CMD_SUCCESS;
1043}
1044
Harald Welte8f0ed552010-05-11 21:53:49 +02001045#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1046#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1047#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1048#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1049
Harald Welteb720bd32009-12-21 16:51:50 +01001050DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1051 "handover window rxlev averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001052 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001053 "How many RxLev measurements are used for averaging")
1054{
1055 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1056 return CMD_SUCCESS;
1057}
1058
1059DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1060 "handover window rxqual averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001061 HO_WIN_RXQUAL_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001062 "How many RxQual measurements are used for averaging")
1063{
1064 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1065 return CMD_SUCCESS;
1066}
1067
1068DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1069 "handover window rxlev neighbor averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001070 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001071 "How many RxQual measurements are used for averaging")
1072{
1073 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1074 return CMD_SUCCESS;
1075}
1076
1077DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1078 "handover power budget interval <1-99>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001079 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001080 "How often to check if we have a better cell (SACCH frames)")
1081{
1082 gsmnet->handover.pwr_interval = atoi(argv[0]);
1083 return CMD_SUCCESS;
1084}
1085
1086DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1087 "handover power budget hysteresis <0-999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001088 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001089 "How many dB does a neighbor to be stronger to become a HO candidate")
1090{
1091 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1092 return CMD_SUCCESS;
1093}
1094
1095DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1096 "handover maximum distance <0-9999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001097 HANDOVER_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001098 "How big is the maximum timing advance before HO is forced")
1099{
1100 gsmnet->handover.max_distance = atoi(argv[0]);
1101 return CMD_SUCCESS;
1102}
Harald Weltebc814502009-12-19 21:41:52 +01001103
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001104#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001105 DEFUN(cfg_net_T##number, \
1106 cfg_net_T##number##_cmd, \
1107 "timer t" #number " <0-65535>", \
Harald Welte8f0ed552010-05-11 21:53:49 +02001108 "Configure GSM Timers\n" \
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001109 doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001110{ \
1111 int value = atoi(argv[0]); \
1112 \
1113 if (value < 0 || value > 65535) { \
1114 vty_out(vty, "Timer value %s out of range.%s", \
1115 argv[0], VTY_NEWLINE); \
1116 return CMD_WARNING; \
1117 } \
1118 \
1119 gsmnet->T##number = value; \
1120 return CMD_SUCCESS; \
1121}
1122
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001123DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1124DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1125DECLARE_TIMER(3105, "Currently not used.")
1126DECLARE_TIMER(3107, "Currently not used.")
1127DECLARE_TIMER(3109, "Currently not used.")
1128DECLARE_TIMER(3111, "Currently not used.")
1129DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1130DECLARE_TIMER(3115, "Currently not used.")
1131DECLARE_TIMER(3117, "Currently not used.")
1132DECLARE_TIMER(3119, "Currently not used.")
1133DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001134
1135
Harald Welte5258fc42009-03-28 19:07:53 +00001136/* per-BTS configuration */
1137DEFUN(cfg_bts,
1138 cfg_bts_cmd,
1139 "bts BTS_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001140 "Select a BTS to configure\n"
1141 "BTS Number\n")
Harald Welte5258fc42009-03-28 19:07:53 +00001142{
1143 int bts_nr = atoi(argv[0]);
1144 struct gsm_bts *bts;
1145
Harald Weltee441d9c2009-06-21 16:17:15 +02001146 if (bts_nr > gsmnet->num_bts) {
1147 vty_out(vty, "%% The next unused BTS number is %u%s",
1148 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001149 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001150 } else if (bts_nr == gsmnet->num_bts) {
1151 /* allocate a new one */
1152 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1153 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001154 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001155 bts = gsm_bts_num(gsmnet, bts_nr);
1156
Daniel Willmannf15c2762010-01-11 13:43:07 +01001157 if (!bts) {
1158 vty_out(vty, "%% Unable to allocate BTS %u%s",
1159 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee441d9c2009-06-21 16:17:15 +02001160 return CMD_WARNING;
Daniel Willmannf15c2762010-01-11 13:43:07 +01001161 }
Harald Welte5258fc42009-03-28 19:07:53 +00001162
1163 vty->index = bts;
1164 vty->node = BTS_NODE;
1165
1166 return CMD_SUCCESS;
1167}
1168
1169DEFUN(cfg_bts_type,
1170 cfg_bts_type_cmd,
1171 "type TYPE",
1172 "Set the BTS type\n")
1173{
1174 struct gsm_bts *bts = vty->index;
Harald Welte39315c42010-01-10 18:01:52 +01001175 int rc;
Harald Welte5258fc42009-03-28 19:07:53 +00001176
Harald Welte39315c42010-01-10 18:01:52 +01001177 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1178 if (rc < 0)
1179 return CMD_WARNING;
Harald Welte8175e952009-10-20 00:22:00 +02001180
Harald Welte5258fc42009-03-28 19:07:53 +00001181 return CMD_SUCCESS;
1182}
1183
Harald Weltefcd24452009-06-20 18:15:19 +02001184DEFUN(cfg_bts_band,
1185 cfg_bts_band_cmd,
1186 "band BAND",
1187 "Set the frequency band of this BTS\n")
1188{
1189 struct gsm_bts *bts = vty->index;
Harald Welte42581822009-08-08 16:12:58 +02001190 int band = gsm_band_parse(argv[0]);
Harald Weltefcd24452009-06-20 18:15:19 +02001191
1192 if (band < 0) {
1193 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1194 band, VTY_NEWLINE);
1195 return CMD_WARNING;
1196 }
1197
1198 bts->band = band;
1199
1200 return CMD_SUCCESS;
1201}
1202
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001203DEFUN(cfg_bts_ci,
1204 cfg_bts_ci_cmd,
1205 "cell_identity <0-65535>",
1206 "Set the Cell identity of this BTS\n")
1207{
1208 struct gsm_bts *bts = vty->index;
1209 int ci = atoi(argv[0]);
1210
1211 if (ci < 0 || ci > 0xffff) {
1212 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1213 ci, VTY_NEWLINE);
1214 return CMD_WARNING;
1215 }
1216 bts->cell_identity = ci;
1217
1218 return CMD_SUCCESS;
1219}
1220
Harald Welte5258fc42009-03-28 19:07:53 +00001221DEFUN(cfg_bts_lac,
1222 cfg_bts_lac_cmd,
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001223 "location_area_code <0-65535>",
Harald Welte5258fc42009-03-28 19:07:53 +00001224 "Set the Location Area Code (LAC) of this BTS\n")
1225{
1226 struct gsm_bts *bts = vty->index;
1227 int lac = atoi(argv[0]);
1228
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001229 if (lac < 0 || lac > 0xffff) {
1230 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte5258fc42009-03-28 19:07:53 +00001231 lac, VTY_NEWLINE);
1232 return CMD_WARNING;
1233 }
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +02001234
1235 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1236 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1237 lac, VTY_NEWLINE);
1238 return CMD_WARNING;
1239 }
1240
Harald Welte5258fc42009-03-28 19:07:53 +00001241 bts->location_area_code = lac;
1242
1243 return CMD_SUCCESS;
1244}
1245
Harald Weltea43f7892009-12-01 18:04:30 +05301246
Harald Welte5258fc42009-03-28 19:07:53 +00001247DEFUN(cfg_bts_tsc,
1248 cfg_bts_tsc_cmd,
1249 "training_sequence_code <0-255>",
1250 "Set the Training Sequence Code (TSC) of this BTS\n")
1251{
1252 struct gsm_bts *bts = vty->index;
1253 int tsc = atoi(argv[0]);
1254
1255 if (tsc < 0 || tsc > 0xff) {
1256 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1257 tsc, VTY_NEWLINE);
1258 return CMD_WARNING;
1259 }
1260 bts->tsc = tsc;
1261
1262 return CMD_SUCCESS;
1263}
1264
Harald Welte78f2f502009-05-23 16:56:52 +00001265DEFUN(cfg_bts_bsic,
1266 cfg_bts_bsic_cmd,
1267 "base_station_id_code <0-63>",
1268 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1269{
1270 struct gsm_bts *bts = vty->index;
1271 int bsic = atoi(argv[0]);
1272
1273 if (bsic < 0 || bsic > 0x3f) {
Harald Welte42581822009-08-08 16:12:58 +02001274 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte78f2f502009-05-23 16:56:52 +00001275 bsic, VTY_NEWLINE);
1276 return CMD_WARNING;
1277 }
1278 bts->bsic = bsic;
1279
1280 return CMD_SUCCESS;
1281}
1282
1283
Harald Welte4cc34222009-05-01 15:12:31 +00001284DEFUN(cfg_bts_unit_id,
1285 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +02001286 "ip.access unit_id <0-65534> <0-255>",
1287 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte4cc34222009-05-01 15:12:31 +00001288{
1289 struct gsm_bts *bts = vty->index;
1290 int site_id = atoi(argv[0]);
1291 int bts_id = atoi(argv[1]);
1292
Harald Welte07dc73d2009-08-07 13:27:09 +02001293 if (!is_ipaccess_bts(bts)) {
1294 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1295 return CMD_WARNING;
1296 }
1297
Harald Welte4cc34222009-05-01 15:12:31 +00001298 bts->ip_access.site_id = site_id;
1299 bts->ip_access.bts_id = bts_id;
1300
1301 return CMD_SUCCESS;
1302}
1303
Harald Welte8f0ed552010-05-11 21:53:49 +02001304#define OML_STR "Organization & Maintenance Link\n"
1305#define IPA_STR "ip.access Specific Options\n"
1306
Harald Welte8175e952009-10-20 00:22:00 +02001307DEFUN(cfg_bts_stream_id,
1308 cfg_bts_stream_id_cmd,
1309 "oml ip.access stream_id <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001310 OML_STR IPA_STR
Harald Welte8175e952009-10-20 00:22:00 +02001311 "Set the ip.access Stream ID of the OML link of this BTS\n")
1312{
1313 struct gsm_bts *bts = vty->index;
1314 int stream_id = atoi(argv[0]);
1315
1316 if (!is_ipaccess_bts(bts)) {
1317 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1318 return CMD_WARNING;
1319 }
1320
1321 bts->oml_tei = stream_id;
1322
1323 return CMD_SUCCESS;
1324}
1325
Harald Welte8f0ed552010-05-11 21:53:49 +02001326#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte8175e952009-10-20 00:22:00 +02001327
Harald Welte42581822009-08-08 16:12:58 +02001328DEFUN(cfg_bts_oml_e1,
1329 cfg_bts_oml_e1_cmd,
1330 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001331 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001332 "E1 interface to be used for OML\n")
1333{
1334 struct gsm_bts *bts = vty->index;
1335
1336 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1337
1338 return CMD_SUCCESS;
1339}
1340
1341
1342DEFUN(cfg_bts_oml_e1_tei,
1343 cfg_bts_oml_e1_tei_cmd,
1344 "oml e1 tei <0-63>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001345 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001346 "Set the TEI to be used for OML")
1347{
1348 struct gsm_bts *bts = vty->index;
1349
1350 bts->oml_tei = atoi(argv[0]);
1351
1352 return CMD_SUCCESS;
1353}
1354
Harald Welte7a8fa412009-08-10 13:48:16 +02001355DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1356 "channel allocator (ascending|descending)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001357 "Channnel Allocator\n" "Channel Allocator\n"
1358 "Allocate Timeslots and Transceivers in ascending order\n"
1359 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte7a8fa412009-08-10 13:48:16 +02001360{
1361 struct gsm_bts *bts = vty->index;
1362
1363 if (!strcmp(argv[0], "ascending"))
1364 bts->chan_alloc_reverse = 0;
1365 else
1366 bts->chan_alloc_reverse = 1;
1367
1368 return CMD_SUCCESS;
1369}
1370
Harald Welte8f0ed552010-05-11 21:53:49 +02001371#define RACH_STR "Random Access Control Channel\n"
1372
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001373DEFUN(cfg_bts_rach_tx_integer,
1374 cfg_bts_rach_tx_integer_cmd,
1375 "rach tx integer <0-15>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001376 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001377 "Set the raw tx integer value in RACH Control parameters IE")
1378{
1379 struct gsm_bts *bts = vty->index;
1380 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1381 return CMD_SUCCESS;
1382}
1383
1384DEFUN(cfg_bts_rach_max_trans,
1385 cfg_bts_rach_max_trans_cmd,
1386 "rach max transmission (1|2|4|7)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001387 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001388 "Set the maximum number of RACH burst transmissions")
1389{
1390 struct gsm_bts *bts = vty->index;
1391 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1392 return CMD_SUCCESS;
1393}
1394
Harald Welte8f0ed552010-05-11 21:53:49 +02001395#define NM_STR "Network Management\n"
1396
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001397DEFUN(cfg_bts_rach_nm_b_thresh,
1398 cfg_bts_rach_nm_b_thresh_cmd,
1399 "rach nm busy threshold <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001400 RACH_STR NM_STR
1401 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001402{
1403 struct gsm_bts *bts = vty->index;
1404 bts->rach_b_thresh = atoi(argv[0]);
1405 return CMD_SUCCESS;
1406}
1407
1408DEFUN(cfg_bts_rach_nm_ldavg,
1409 cfg_bts_rach_nm_ldavg_cmd,
1410 "rach nm load average <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001411 RACH_STR NM_STR
1412 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001413{
1414 struct gsm_bts *bts = vty->index;
1415 bts->rach_ldavg_slots = atoi(argv[0]);
1416 return CMD_SUCCESS;
1417}
1418
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001419DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1420 "cell barred (0|1)",
1421 "Should this cell be barred from access?")
1422{
1423 struct gsm_bts *bts = vty->index;
1424
Harald Welte71355012009-12-21 23:08:18 +01001425 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001426
1427 return CMD_SUCCESS;
1428}
1429
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001430DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1431 "ms max power <0-40>",
1432 "Maximum transmit power of the MS")
1433{
1434 struct gsm_bts *bts = vty->index;
1435
1436 bts->ms_max_power = atoi(argv[0]);
1437
1438 return CMD_SUCCESS;
1439}
1440
Harald Welte73225282009-12-12 18:17:25 +01001441DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1442 "cell reselection hysteresis <0-14>",
1443 "Cell Re-Selection Hysteresis in dB")
1444{
1445 struct gsm_bts *bts = vty->index;
1446
1447 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1448
1449 return CMD_SUCCESS;
1450}
1451
1452DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1453 "rxlev access min <0-63>",
1454 "Minimum RxLev needed for cell access (better than -110dBm)")
1455{
1456 struct gsm_bts *bts = vty->index;
1457
1458 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1459
1460 return CMD_SUCCESS;
1461}
1462
Harald Welte (local)efc92312009-08-14 23:09:25 +02001463DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1464 "periodic location update <0-1530>",
1465 "Periodic Location Updating Interval in Minutes")
1466{
1467 struct gsm_bts *bts = vty->index;
1468
Harald Weltea43f7892009-12-01 18:04:30 +05301469 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)efc92312009-08-14 23:09:25 +02001470
1471 return CMD_SUCCESS;
1472}
1473
Harald Welte8f0ed552010-05-11 21:53:49 +02001474#define GPRS_TEXT "GPRS Packet Network\n"
1475
Harald Welteaf387632010-03-14 23:30:30 +08001476DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welte57ba7e32010-04-18 14:00:26 +02001477 "gprs cell bvci <2-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001478 GPRS_TEXT
1479 "GPRS Cell Settings\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001480 "GPRS BSSGP VC Identifier")
1481{
1482 struct gsm_bts *bts = vty->index;
1483
Harald Welte4511d892010-04-18 15:51:20 +02001484 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001485 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1486 return CMD_WARNING;
1487 }
1488
Harald Welte97a282b2010-03-14 15:37:43 +08001489 bts->gprs.cell.bvci = atoi(argv[0]);
1490
1491 return CMD_SUCCESS;
1492}
1493
Harald Weltea5731cf2010-03-22 11:48:36 +08001494DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1495 "gprs nsei <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001496 GPRS_TEXT
Harald Weltea5731cf2010-03-22 11:48:36 +08001497 "GPRS NS Entity Identifier")
1498{
1499 struct gsm_bts *bts = vty->index;
1500
Harald Welte4511d892010-04-18 15:51:20 +02001501 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltea5731cf2010-03-22 11:48:36 +08001502 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1503 return CMD_WARNING;
1504 }
1505
1506 bts->gprs.nse.nsei = atoi(argv[0]);
1507
1508 return CMD_SUCCESS;
1509}
1510
Harald Welte8f0ed552010-05-11 21:53:49 +02001511#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1512 "NSVC Logical Number\n"
Harald Weltea5731cf2010-03-22 11:48:36 +08001513
Harald Welte97a282b2010-03-14 15:37:43 +08001514DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1515 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001516 GPRS_TEXT NSVC_TEXT
1517 "NS Virtual Connection Identifier\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001518 "GPRS NS VC Identifier")
1519{
1520 struct gsm_bts *bts = vty->index;
1521 int idx = atoi(argv[0]);
1522
Harald Welte4511d892010-04-18 15:51:20 +02001523 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001524 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1525 return CMD_WARNING;
1526 }
1527
Harald Welte97a282b2010-03-14 15:37:43 +08001528 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1529
1530 return CMD_SUCCESS;
1531}
1532
Harald Welteaf387632010-03-14 23:30:30 +08001533DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1534 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001535 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001536 "GPRS NS Local UDP Port")
1537{
1538 struct gsm_bts *bts = vty->index;
1539 int idx = atoi(argv[0]);
1540
Harald Welte4511d892010-04-18 15:51:20 +02001541 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001542 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1543 return CMD_WARNING;
1544 }
1545
Harald Welteaf387632010-03-14 23:30:30 +08001546 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1547
1548 return CMD_SUCCESS;
1549}
1550
1551DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1552 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001553 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001554 "GPRS NS Remote UDP Port")
1555{
1556 struct gsm_bts *bts = vty->index;
1557 int idx = atoi(argv[0]);
1558
Harald Welte4511d892010-04-18 15:51:20 +02001559 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001560 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1561 return CMD_WARNING;
1562 }
1563
Harald Welteaf387632010-03-14 23:30:30 +08001564 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1565
1566 return CMD_SUCCESS;
1567}
1568
1569DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1570 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte8f0ed552010-05-11 21:53:49 +02001571 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001572 "GPRS NS Remote IP Address")
1573{
1574 struct gsm_bts *bts = vty->index;
1575 int idx = atoi(argv[0]);
1576 struct in_addr ia;
1577
Harald Welte4511d892010-04-18 15:51:20 +02001578 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001579 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1580 return CMD_WARNING;
1581 }
1582
Harald Welteaf387632010-03-14 23:30:30 +08001583 inet_aton(argv[1], &ia);
1584 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1585
1586 return CMD_SUCCESS;
1587}
1588
Harald Welte97a282b2010-03-14 15:37:43 +08001589DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1590 "gprs routing area <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001591 GPRS_TEXT
Harald Welte97a282b2010-03-14 15:37:43 +08001592 "GPRS Routing Area Code")
1593{
1594 struct gsm_bts *bts = vty->index;
1595
Harald Welte4511d892010-04-18 15:51:20 +02001596 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001597 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1598 return CMD_WARNING;
1599 }
1600
Harald Welte97a282b2010-03-14 15:37:43 +08001601 bts->gprs.rac = atoi(argv[0]);
1602
1603 return CMD_SUCCESS;
1604}
1605
Harald Welte4511d892010-04-18 15:51:20 +02001606DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
1607 "gprs mode (none|gprs|egprs)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001608 GPRS_TEXT
1609 "GPRS Mode for this BTS\n"
1610 "GPRS Disabled on this BTS\n"
1611 "GPRS Enabled on this BTS\n"
1612 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welteaf387632010-03-14 23:30:30 +08001613{
1614 struct gsm_bts *bts = vty->index;
1615
Harald Welte4511d892010-04-18 15:51:20 +02001616 bts->gprs.mode = bts_gprs_mode_parse(argv[0]);
Harald Welteaf387632010-03-14 23:30:30 +08001617
1618 return CMD_SUCCESS;
1619}
1620
Harald Welte8f0ed552010-05-11 21:53:49 +02001621#define TRX_TEXT "Radio Transceiver\n"
Harald Welte7a8fa412009-08-10 13:48:16 +02001622
Harald Welte5258fc42009-03-28 19:07:53 +00001623/* per TRX configuration */
1624DEFUN(cfg_trx,
1625 cfg_trx_cmd,
1626 "trx TRX_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001627 TRX_TEXT
Harald Welte5258fc42009-03-28 19:07:53 +00001628 "Select a TRX to configure")
1629{
1630 int trx_nr = atoi(argv[0]);
1631 struct gsm_bts *bts = vty->index;
1632 struct gsm_bts_trx *trx;
1633
Harald Weltee441d9c2009-06-21 16:17:15 +02001634 if (trx_nr > bts->num_trx) {
1635 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1636 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001637 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001638 } else if (trx_nr == bts->num_trx) {
1639 /* we need to allocate a new one */
1640 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001641 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001642 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001643
Harald Weltee441d9c2009-06-21 16:17:15 +02001644 if (!trx)
1645 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00001646
1647 vty->index = trx;
1648 vty->node = TRX_NODE;
1649
1650 return CMD_SUCCESS;
1651}
1652
1653DEFUN(cfg_trx_arfcn,
1654 cfg_trx_arfcn_cmd,
1655 "arfcn <1-1024>",
1656 "Set the ARFCN for this TRX\n")
1657{
1658 int arfcn = atoi(argv[0]);
1659 struct gsm_bts_trx *trx = vty->index;
1660
1661 /* FIXME: check if this ARFCN is supported by this TRX */
1662
1663 trx->arfcn = arfcn;
1664
1665 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1666 /* FIXME: use OML layer to update the ARFCN */
1667 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
1668
1669 return CMD_SUCCESS;
1670}
1671
Harald Welte (local)7b37d972009-12-27 20:56:38 +01001672DEFUN(cfg_trx_nominal_power,
1673 cfg_trx_nominal_power_cmd,
1674 "nominal power <0-100>",
1675 "Nominal TRX RF Power in dB\n")
1676{
1677 struct gsm_bts_trx *trx = vty->index;
1678
1679 trx->nominal_power = atoi(argv[0]);
1680
1681 return CMD_SUCCESS;
1682}
1683
Harald Weltefcd24452009-06-20 18:15:19 +02001684DEFUN(cfg_trx_max_power_red,
1685 cfg_trx_max_power_red_cmd,
1686 "max_power_red <0-100>",
1687 "Reduction of maximum BS RF Power in dB\n")
1688{
1689 int maxpwr_r = atoi(argv[0]);
1690 struct gsm_bts_trx *trx = vty->index;
Harald Welte61a83b22009-11-18 09:20:22 +01001691 int upper_limit = 24; /* default 12.21 max power red. */
Harald Weltefcd24452009-06-20 18:15:19 +02001692
1693 /* FIXME: check if our BTS type supports more than 12 */
1694 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
1695 vty_out(vty, "%% Power %d dB is not in the valid range%s",
1696 maxpwr_r, VTY_NEWLINE);
1697 return CMD_WARNING;
1698 }
1699 if (maxpwr_r & 1) {
1700 vty_out(vty, "%% Power %d dB is not an even value%s",
1701 maxpwr_r, VTY_NEWLINE);
1702 return CMD_WARNING;
1703 }
1704
1705 trx->max_power_red = maxpwr_r;
1706
1707 /* FIXME: make sure we update this using OML */
1708
1709 return CMD_SUCCESS;
1710}
1711
Harald Welte42581822009-08-08 16:12:58 +02001712DEFUN(cfg_trx_rsl_e1,
1713 cfg_trx_rsl_e1_cmd,
1714 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1715 "E1 interface to be used for RSL\n")
1716{
1717 struct gsm_bts_trx *trx = vty->index;
1718
1719 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
1720
1721 return CMD_SUCCESS;
1722}
1723
1724DEFUN(cfg_trx_rsl_e1_tei,
1725 cfg_trx_rsl_e1_tei_cmd,
1726 "rsl e1 tei <0-63>",
1727 "Set the TEI to be used for RSL")
1728{
1729 struct gsm_bts_trx *trx = vty->index;
1730
1731 trx->rsl_tei = atoi(argv[0]);
1732
1733 return CMD_SUCCESS;
1734}
1735
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01001736DEFUN(cfg_trx_rf_locked,
1737 cfg_trx_rf_locked_cmd,
1738 "rf_locked (0|1)",
1739 "Turn off RF of the TRX.\n")
1740{
1741 int locked = atoi(argv[0]);
1742 struct gsm_bts_trx *trx = vty->index;
1743
1744 gsm_trx_lock_rf(trx, locked);
1745 return CMD_SUCCESS;
1746}
Harald Welte42581822009-08-08 16:12:58 +02001747
Harald Welte5258fc42009-03-28 19:07:53 +00001748/* per TS configuration */
1749DEFUN(cfg_ts,
1750 cfg_ts_cmd,
Harald Welte42581822009-08-08 16:12:58 +02001751 "timeslot <0-7>",
Harald Welte5258fc42009-03-28 19:07:53 +00001752 "Select a Timeslot to configure")
1753{
1754 int ts_nr = atoi(argv[0]);
1755 struct gsm_bts_trx *trx = vty->index;
1756 struct gsm_bts_trx_ts *ts;
1757
1758 if (ts_nr >= TRX_NR_TS) {
1759 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
1760 TRX_NR_TS, VTY_NEWLINE);
1761 return CMD_WARNING;
1762 }
1763
1764 ts = &trx->ts[ts_nr];
1765
1766 vty->index = ts;
1767 vty->node = TS_NODE;
1768
1769 return CMD_SUCCESS;
1770}
1771
Harald Weltea6fd58e2009-08-07 00:25:23 +02001772DEFUN(cfg_ts_pchan,
1773 cfg_ts_pchan_cmd,
1774 "phys_chan_config PCHAN",
1775 "Physical Channel configuration (TCH/SDCCH/...)")
1776{
1777 struct gsm_bts_trx_ts *ts = vty->index;
1778 int pchanc;
1779
1780 pchanc = gsm_pchan_parse(argv[0]);
1781 if (pchanc < 0)
1782 return CMD_WARNING;
1783
1784 ts->pchan = pchanc;
1785
1786 return CMD_SUCCESS;
1787}
1788
1789DEFUN(cfg_ts_e1_subslot,
1790 cfg_ts_e1_subslot_cmd,
Harald Welte42581822009-08-08 16:12:58 +02001791 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltea6fd58e2009-08-07 00:25:23 +02001792 "E1 sub-slot connected to this on-air timeslot")
1793{
1794 struct gsm_bts_trx_ts *ts = vty->index;
1795
Harald Welte42581822009-08-08 16:12:58 +02001796 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Weltea6fd58e2009-08-07 00:25:23 +02001797
1798 return CMD_SUCCESS;
1799}
Harald Welte5258fc42009-03-28 19:07:53 +00001800
Holger Hans Peter Freythere1ffc082010-04-10 00:08:28 +02001801extern int bsc_vty_init_extra(struct gsm_network *net);
1802
Harald Welte68628e82009-03-10 12:17:57 +00001803int bsc_vty_init(struct gsm_network *net)
1804{
1805 gsmnet = net;
1806
1807 cmd_init(1);
1808 vty_init();
1809
1810 install_element(VIEW_NODE, &show_net_cmd);
1811 install_element(VIEW_NODE, &show_bts_cmd);
1812 install_element(VIEW_NODE, &show_trx_cmd);
1813 install_element(VIEW_NODE, &show_ts_cmd);
1814 install_element(VIEW_NODE, &show_lchan_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00001815
1816 install_element(VIEW_NODE, &show_e1drv_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001817 install_element(VIEW_NODE, &show_e1line_cmd);
1818 install_element(VIEW_NODE, &show_e1ts_cmd);
1819
Harald Weltef5025b62009-03-28 16:55:11 +00001820 install_element(VIEW_NODE, &show_paging_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001821
Holger Hans Peter Freyther3c712322010-04-06 11:55:37 +02001822 openbsc_vty_add_cmds();
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +01001823
Harald Welte5013b2a2009-08-07 13:29:14 +02001824 install_element(CONFIG_NODE, &cfg_net_cmd);
1825 install_node(&net_node, config_write_net);
1826 install_default(GSMNET_NODE);
Harald Welte42581822009-08-08 16:12:58 +02001827 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02001828 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
1829 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
1830 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)69de3972009-08-12 14:42:23 +02001831 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte1085c092009-11-18 20:33:19 +01001832 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Welte4381cfe2009-08-30 15:47:06 +09001833 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001834 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welteeab84a12009-12-13 10:53:12 +01001835 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte3d23db42009-12-14 17:49:15 +01001836 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Weltebc814502009-12-19 21:41:52 +01001837 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Welteb720bd32009-12-21 16:51:50 +01001838 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
1839 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
1840 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
1841 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
1842 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
1843 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001844 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01001845 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
1846 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
1847 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
1848 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
1849 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
1850 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
1851 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
1852 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
1853 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
1854 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02001855
1856 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02001857 install_node(&bts_node, config_write_bts);
Harald Welte68628e82009-03-10 12:17:57 +00001858 install_default(BTS_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001859 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02001860 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001861 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001862 install_element(BTS_NODE, &cfg_bts_lac_cmd);
1863 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001864 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00001865 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte8175e952009-10-20 00:22:00 +02001866 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001867 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
1868 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02001869 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001870 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
1871 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001872 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
1873 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001874 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001875 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)efc92312009-08-14 23:09:25 +02001876 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welte73225282009-12-12 18:17:25 +01001877 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
1878 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Welte4511d892010-04-18 15:51:20 +02001879 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08001880 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
1881 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea5731cf2010-03-22 11:48:36 +08001882 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08001883 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welteaf387632010-03-14 23:30:30 +08001884 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
1885 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
1886 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001887
Harald Welte5258fc42009-03-28 19:07:53 +00001888 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001889 install_node(&trx_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001890 install_default(TRX_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001891 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte (local)7b37d972009-12-27 20:56:38 +01001892 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02001893 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001894 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
1895 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01001896 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001897
Harald Welte5258fc42009-03-28 19:07:53 +00001898 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001899 install_node(&ts_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001900 install_default(TS_NODE);
Harald Weltea6fd58e2009-08-07 00:25:23 +02001901 install_element(TS_NODE, &cfg_ts_pchan_cmd);
1902 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001903
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +02001904 bsc_vty_init_extra(net);
Harald Welte40f82892009-05-23 17:31:39 +00001905
Harald Welte68628e82009-03-10 12:17:57 +00001906 return 0;
1907}