blob: 866131613eb9dad29557337f01cf2c67ef5201d7 [file] [log] [blame]
Harald Welte59b04682009-06-10 05:40:52 +08001/* OpenBSC interface to quagga VTY */
Harald Welte410575a2010-03-14 23:30:30 +08002/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welte59b04682009-06-10 05:40:52 +08003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
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 Welte684b9752009-08-09 15:13:54 +020026#include <vty/buffer.h>
Harald Welte59b04682009-06-10 05:40:52 +080027#include <vty/vty.h>
28
29#include <arpa/inet.h>
30
Harald Weltef4625b12010-02-20 16:24:02 +010031#include <osmocore/linuxlist.h>
Harald Welte59b04682009-06-10 05:40:52 +080032#include <openbsc/gsm_data.h>
Harald Welte59b04682009-06-10 05:40:52 +080033#include <openbsc/e1_input.h>
34#include <openbsc/abis_nm.h>
Harald Weltef4625b12010-02-20 16:24:02 +010035#include <osmocore/gsm_utils.h>
Harald Weltefe96f382009-12-22 13:09:29 +010036#include <openbsc/chan_alloc.h>
Harald Welte44007742009-12-22 21:43:14 +010037#include <openbsc/meas_rep.h>
Harald Welte59b04682009-06-10 05:40:52 +080038#include <openbsc/db.h>
Harald Weltef4625b12010-02-20 16:24:02 +010039#include <osmocore/talloc.h>
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +010040#include <openbsc/telnet_interface.h>
Holger Hans Peter Freytherb70d45b2010-04-06 11:55:37 +020041#include <openbsc/vty.h>
Harald Weltef45981f2010-05-12 20:28:04 +020042#include <openbsc/gprs_ns.h>
Harald Welte59b04682009-06-10 05:40:52 +080043
44static struct gsm_network *gsmnet;
45
Harald Welted6b62e32010-05-12 17:19:53 +000046/* FIXME: this should go to some common file */
47static const struct value_string gprs_ns_timer_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020048 { 0, "tns-block" },
49 { 1, "tns-block-retries" },
50 { 2, "tns-reset" },
51 { 3, "tns-reset-retries" },
52 { 4, "tns-test" },
53 { 5, "tns-alive" },
54 { 6, "tns-alive-retries" },
55 { 0, NULL }
56};
57
Harald Welted6b62e32010-05-12 17:19:53 +000058static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020059 { 0, "blocking-timer" },
60 { 1, "blocking-retries" },
61 { 2, "unblocking-retries" },
62 { 3, "reset-timer" },
63 { 4, "reset-retries" },
64 { 5, "suspend-timer" },
65 { 6, "suspend-retries" },
66 { 7, "resume-timer" },
67 { 8, "resume-retries" },
68 { 9, "capability-update-timer" },
69 { 10, "capability-update-retries" },
70 { 0, NULL }
71};
72
Harald Weltee87eb462009-08-07 13:29:14 +020073struct cmd_node net_node = {
74 GSMNET_NODE,
75 "%s(network)#",
76 1,
77};
78
Harald Welte59b04682009-06-10 05:40:52 +080079struct cmd_node bts_node = {
80 BTS_NODE,
81 "%s(bts)#",
82 1,
83};
84
85struct cmd_node trx_node = {
86 TRX_NODE,
87 "%s(trx)#",
88 1,
89};
90
91struct cmd_node ts_node = {
92 TS_NODE,
93 "%s(ts)#",
94 1,
95};
96
Harald Welte59b04682009-06-10 05:40:52 +080097static int dummy_config_write(struct vty *v)
98{
99 return CMD_SUCCESS;
100}
101
102static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
103{
104 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
105 nm_opstate_name(nms->operational), nms->administrative,
106 nm_avail_name(nms->availability), VTY_NEWLINE);
107}
108
Harald Weltefe96f382009-12-22 13:09:29 +0100109static void dump_pchan_load_vty(struct vty *vty, char *prefix,
110 const struct pchan_load *pl)
111{
112 int i;
113
114 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
115 const struct load_counter *lc = &pl->pchan[i];
116 unsigned int percent;
117
118 if (lc->total == 0)
119 continue;
120
121 percent = (lc->used * 100) / lc->total;
122
123 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
124 gsm_pchan_name(i), percent, lc->used, lc->total,
125 VTY_NEWLINE);
126 }
127}
128
Harald Welte59b04682009-06-10 05:40:52 +0800129static void net_dump_vty(struct vty *vty, struct gsm_network *net)
130{
Harald Weltefe96f382009-12-22 13:09:29 +0100131 struct pchan_load pl;
132
Harald Welte59b04682009-06-10 05:40:52 +0800133 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
134 "and has %u BTS%s", net->country_code, net->network_code,
135 net->num_bts, VTY_NEWLINE);
136 vty_out(vty, " Long network name: '%s'%s",
137 net->name_long, VTY_NEWLINE);
138 vty_out(vty, " Short network name: '%s'%s",
139 net->name_short, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200140 vty_out(vty, " Authentication policy: %s%s",
141 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100142 vty_out(vty, " Location updating reject cause: %u%s",
143 net->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900144 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
145 VTY_NEWLINE);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +0100146 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
147 VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100148 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
149 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100150 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
151 VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100152 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
153 VTY_NEWLINE);
Harald Weltefe96f382009-12-22 13:09:29 +0100154 network_chan_load(&pl, net);
155 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
156 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800157}
158
159DEFUN(show_net, show_net_cmd, "show network",
160 SHOW_STR "Display information about a GSM NETWORK\n")
161{
162 struct gsm_network *net = gsmnet;
163 net_dump_vty(vty, net);
164
165 return CMD_SUCCESS;
166}
167
168static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
169{
170 struct e1inp_line *line;
171
172 if (!e1l) {
173 vty_out(vty, " None%s", VTY_NEWLINE);
174 return;
175 }
176
177 line = e1l->ts->line;
178
179 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
180 line->num, line->driver->name, e1l->ts->num,
181 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
182 vty_out(vty, " E1 TEI %u, SAPI %u%s",
183 e1l->tei, e1l->sapi, VTY_NEWLINE);
184}
185
186static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
187{
Harald Weltefe96f382009-12-22 13:09:29 +0100188 struct pchan_load pl;
189
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200190 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200191 "BSIC %u, TSC %u and %u TRX%s",
192 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200193 bts->cell_identity,
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200194 bts->location_area_code, bts->bsic, bts->tsc,
Harald Welte91afe4c2009-06-20 18:15:19 +0200195 bts->num_trx, VTY_NEWLINE);
Harald Welte8e9d1792009-12-12 15:38:16 +0100196 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100197 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte8e9d1792009-12-12 15:38:16 +0100198 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
199 VTY_NEWLINE);
200 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welteb761bf82009-12-12 18:17:25 +0100201 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100202 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
203 VTY_NEWLINE);
204 vty_out(vty, "RACH Max transmissions: %u%s",
205 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
206 VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100207 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200208 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800209 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200210 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800211 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200212 bts->oml_tei, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800213 vty_out(vty, " NM State: ");
214 net_dump_nmstate(vty, &bts->nm_state);
215 vty_out(vty, " Site Mgr NM State: ");
216 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
217 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
218 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200219 if (!is_ipaccess_bts(bts)) {
220 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
221 e1isl_dump_vty(vty, bts->oml_link);
222 }
Harald Welte59b04682009-06-10 05:40:52 +0800223 /* FIXME: oml_link, chan_desc */
Harald Weltefe96f382009-12-22 13:09:29 +0100224 memset(&pl, 0, sizeof(pl));
225 bts_chan_load(&pl, bts);
226 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
227 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800228}
229
230DEFUN(show_bts, show_bts_cmd, "show bts [number]",
231 SHOW_STR "Display information about a BTS\n"
232 "BTS number")
233{
234 struct gsm_network *net = gsmnet;
235 int bts_nr;
236
237 if (argc != 0) {
238 /* use the BTS number that the user has specified */
239 bts_nr = atoi(argv[0]);
240 if (bts_nr > net->num_bts) {
241 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
242 VTY_NEWLINE);
243 return CMD_WARNING;
244 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200245 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800246 return CMD_SUCCESS;
247 }
248 /* print all BTS's */
249 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200250 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800251
252 return CMD_SUCCESS;
253}
254
Harald Welte62868882009-08-08 16:12:58 +0200255/* utility functions */
256static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
257 const char *ts, const char *ss)
258{
259 e1_link->e1_nr = atoi(line);
260 e1_link->e1_ts = atoi(ts);
261 if (!strcmp(ss, "full"))
262 e1_link->e1_ts_ss = 255;
263 else
264 e1_link->e1_ts_ss = atoi(ss);
265}
266
267static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
268 const char *prefix)
269{
270 if (!e1_link->e1_ts)
271 return;
272
273 if (e1_link->e1_ts_ss == 255)
274 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
275 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
276 else
277 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
278 prefix, e1_link->e1_nr, e1_link->e1_ts,
279 e1_link->e1_ts_ss, VTY_NEWLINE);
280}
281
282
Harald Welte97ceef92009-08-06 19:06:46 +0200283static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
284{
Harald Welte62868882009-08-08 16:12:58 +0200285 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
286 if (ts->pchan != GSM_PCHAN_NONE)
287 vty_out(vty, " phys_chan_config %s%s",
288 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
289 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte97ceef92009-08-06 19:06:46 +0200290}
291
292static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
293{
294 int i;
295
Harald Weltee87eb462009-08-07 13:29:14 +0200296 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200297 vty_out(vty, " rf_locked %u%s",
298 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
299 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200300 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +0100301 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200302 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200303 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
304 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200305
306 for (i = 0; i < TRX_NR_TS; i++)
307 config_write_ts_single(vty, &trx->ts[i]);
308}
309
Harald Weltea9251762010-05-11 23:50:21 +0200310static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
311{
312 unsigned int i;
313 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
314 VTY_NEWLINE);
315 if (bts->gprs.mode == BTS_GPRS_NONE)
316 return;
317
318 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
319 VTY_NEWLINE);
320 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
321 VTY_NEWLINE);
322 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
323 vty_out(vty, " gprs cell timer %s %u%s",
324 get_value_string(gprs_bssgp_cfg_strs, i),
325 bts->gprs.cell.timer[i], VTY_NEWLINE);
326 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
327 VTY_NEWLINE);
328 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
329 vty_out(vty, " gprs ns timer %s %u%s",
330 get_value_string(gprs_ns_timer_strs, i),
331 bts->gprs.nse.timer[i], VTY_NEWLINE);
332 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
333 struct gsm_bts_gprs_nsvc *nsvc =
334 &bts->gprs.nsvc[i];
335 struct in_addr ia;
336
337 ia.s_addr = htonl(nsvc->remote_ip);
338 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
339 nsvc->nsvci, VTY_NEWLINE);
340 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
341 nsvc->local_port, VTY_NEWLINE);
342 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
343 nsvc->remote_port, VTY_NEWLINE);
344 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
345 inet_ntoa(ia), VTY_NEWLINE);
346 }
347}
348
Harald Welte97ceef92009-08-06 19:06:46 +0200349static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
350{
351 struct gsm_bts_trx *trx;
352
Harald Weltee87eb462009-08-07 13:29:14 +0200353 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
354 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
355 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freyther6d82b7c2009-11-19 16:38:49 +0100356 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200357 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200358 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200359 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
360 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200361 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100362 vty_out(vty, " cell reselection hysteresis %u%s",
363 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
364 vty_out(vty, " rxlev access min %u%s",
365 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Harald Weltea54a2bb2009-12-01 18:04:30 +0530366 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200367 vty_out(vty, " periodic location update %u%s",
Harald Weltea54a2bb2009-12-01 18:04:30 +0530368 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200369 vty_out(vty, " channel allocator %s%s",
370 bts->chan_alloc_reverse ? "descending" : "ascending",
371 VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100372 vty_out(vty, " rach tx integer %u%s",
373 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
374 vty_out(vty, " rach max transmission %u%s",
375 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
376 VTY_NEWLINE);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800377
378 if (bts->rach_b_thresh != -1)
379 vty_out(vty, " rach nm busy threshold %u%s",
380 bts->rach_b_thresh, VTY_NEWLINE);
381 if (bts->rach_ldavg_slots != -1)
382 vty_out(vty, " rach nm load average %u%s",
383 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100384 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200385 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200386 if (is_ipaccess_bts(bts)) {
Harald Weltee87eb462009-08-07 13:29:14 +0200387 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200388 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200389 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
390 } else {
Harald Welte62868882009-08-08 16:12:58 +0200391 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
392 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
393 }
Harald Weltea9251762010-05-11 23:50:21 +0200394 config_write_bts_gprs(vty, bts);
Harald Welte97ceef92009-08-06 19:06:46 +0200395
396 llist_for_each_entry(trx, &bts->trx_list, list)
397 config_write_trx_single(vty, trx);
398}
399
400static int config_write_bts(struct vty *v)
401{
402 struct gsm_bts *bts;
403
404 llist_for_each_entry(bts, &gsmnet->bts_list, list)
405 config_write_bts_single(v, bts);
406
407 return CMD_SUCCESS;
408}
409
Harald Weltee87eb462009-08-07 13:29:14 +0200410static int config_write_net(struct vty *vty)
411{
412 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200413 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200414 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200415 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
416 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200417 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100418 vty_out(vty, " location updating reject cause %u%s",
419 gsmnet->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900420 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freyther6b4f5462009-11-19 16:37:48 +0100421 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100422 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
423 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100424 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100425 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Weltea8062f12009-12-21 16:51:50 +0100426 vty_out(vty, " handover window rxlev averaging %u%s",
427 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
428 vty_out(vty, " handover window rxqual averaging %u%s",
429 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
430 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
431 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
432 vty_out(vty, " handover power budget interval %u%s",
433 gsmnet->handover.pwr_interval, VTY_NEWLINE);
434 vty_out(vty, " handover power budget hysteresis %u%s",
435 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
436 vty_out(vty, " handover maximum distance %u%s",
437 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +0100438 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100439 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
440 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
441 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
442 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
443 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
444 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
445 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
446 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
447 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
448 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200449
450 return CMD_SUCCESS;
451}
Harald Welte97ceef92009-08-06 19:06:46 +0200452
Harald Welte59b04682009-06-10 05:40:52 +0800453static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
454{
455 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
456 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200457 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200458 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200459 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200460 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800461 vty_out(vty, " NM State: ");
462 net_dump_nmstate(vty, &trx->nm_state);
463 vty_out(vty, " Baseband Transceiver NM State: ");
464 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200465 if (is_ipaccess_bts(trx->bts)) {
466 vty_out(vty, " ip.access stream ID: 0x%02x%s",
467 trx->rsl_tei, VTY_NEWLINE);
468 } else {
469 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
470 e1isl_dump_vty(vty, trx->rsl_link);
471 }
Harald Welte59b04682009-06-10 05:40:52 +0800472}
473
474DEFUN(show_trx,
475 show_trx_cmd,
476 "show trx [bts_nr] [trx_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200477 SHOW_STR "Display information about a TRX\n"
478 "BTS Number\n"
479 "TRX Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800480{
481 struct gsm_network *net = gsmnet;
482 struct gsm_bts *bts = NULL;
483 struct gsm_bts_trx *trx;
484 int bts_nr, trx_nr;
485
486 if (argc >= 1) {
487 /* use the BTS number that the user has specified */
488 bts_nr = atoi(argv[0]);
489 if (bts_nr >= net->num_bts) {
490 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
491 VTY_NEWLINE);
492 return CMD_WARNING;
493 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200494 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800495 }
496 if (argc >= 2) {
497 trx_nr = atoi(argv[1]);
498 if (trx_nr >= bts->num_trx) {
499 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
500 VTY_NEWLINE);
501 return CMD_WARNING;
502 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200503 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800504 trx_dump_vty(vty, trx);
505 return CMD_SUCCESS;
506 }
507 if (bts) {
508 /* print all TRX in this BTS */
509 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200510 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800511 trx_dump_vty(vty, trx);
512 }
513 return CMD_SUCCESS;
514 }
515
516 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200517 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800518 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200519 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800520 trx_dump_vty(vty, trx);
521 }
522 }
523
524 return CMD_SUCCESS;
525}
526
Harald Welte97ceef92009-08-06 19:06:46 +0200527
Harald Welte59b04682009-06-10 05:40:52 +0800528static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
529{
Harald Welte59b04682009-06-10 05:40:52 +0800530 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
531 ts->nr, ts->trx->nr, ts->trx->bts->nr,
532 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
533 vty_out(vty, " NM State: ");
534 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte87504212009-12-02 01:56:49 +0530535 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welte59b04682009-06-10 05:40:52 +0800536 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
537 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
538 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800539}
540
541DEFUN(show_ts,
542 show_ts_cmd,
543 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200544 SHOW_STR "Display information about a TS\n"
545 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800546{
547 struct gsm_network *net = gsmnet;
548 struct gsm_bts *bts;
549 struct gsm_bts_trx *trx;
550 struct gsm_bts_trx_ts *ts;
551 int bts_nr, trx_nr, ts_nr;
552
553 if (argc >= 1) {
554 /* use the BTS number that the user has specified */
555 bts_nr = atoi(argv[0]);
556 if (bts_nr >= net->num_bts) {
557 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
558 VTY_NEWLINE);
559 return CMD_WARNING;
560 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200561 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800562 }
563 if (argc >= 2) {
564 trx_nr = atoi(argv[1]);
565 if (trx_nr >= bts->num_trx) {
566 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
567 VTY_NEWLINE);
568 return CMD_WARNING;
569 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200570 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800571 }
572 if (argc >= 3) {
573 ts_nr = atoi(argv[2]);
574 if (ts_nr >= TRX_NR_TS) {
575 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
576 VTY_NEWLINE);
577 return CMD_WARNING;
578 }
579 ts = &trx->ts[ts_nr];
580 ts_dump_vty(vty, ts);
581 return CMD_SUCCESS;
582 }
583 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200584 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800585 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200586 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800587 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
588 ts = &trx->ts[ts_nr];
589 ts_dump_vty(vty, ts);
590 }
591 }
592 }
593
594 return CMD_SUCCESS;
595}
596
Holger Hans Peter Freyther1dd0a1b2010-01-06 06:00:40 +0100597static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800598{
Harald Welte91afe4c2009-06-20 18:15:19 +0200599 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800600 subscr->authorized, VTY_NEWLINE);
601 if (subscr->name)
602 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
603 if (subscr->extension)
604 vty_out(vty, " Extension: %s%s", subscr->extension,
605 VTY_NEWLINE);
606 if (subscr->imsi)
607 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200608 if (subscr->tmsi != GSM_RESERVED_TMSI)
609 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200610 VTY_NEWLINE);
Sylvain Munaute5863a22009-12-27 19:29:28 +0100611
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200612 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800613}
614
Harald Welte44007742009-12-22 21:43:14 +0100615static void meas_rep_dump_uni_vty(struct vty *vty,
616 struct gsm_meas_rep_unidir *mru,
617 const char *prefix,
618 const char *dir)
619{
620 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
621 prefix, dir, rxlev2dbm(mru->full.rx_lev),
622 dir, rxlev2dbm(mru->sub.rx_lev));
623 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
624 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
625 VTY_NEWLINE);
626}
627
628static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
629 const char *prefix)
630{
631 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
632 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
633 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
634 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
635 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
636 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
637 VTY_NEWLINE);
638 if (mr->flags & MEAS_REP_F_MS_TO)
639 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
640 mr->ms_timing_offset, VTY_NEWLINE);
641 if (mr->flags & MEAS_REP_F_MS_L1)
642 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
643 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
644 if (mr->flags & MEAS_REP_F_DL_VALID)
645 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
646 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
647}
648
Harald Welte59b04682009-06-10 05:40:52 +0800649static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
650{
Harald Welte44007742009-12-22 21:43:14 +0100651 int idx;
652
Harald Welte59b04682009-06-10 05:40:52 +0800653 vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s",
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200654 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
Harald Welte (local)02204d02009-12-27 18:05:25 +0100655 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Harald Welte59b04682009-06-10 05:40:52 +0800656 VTY_NEWLINE);
Holger Hans Peter Freyther065b8112010-03-23 06:41:45 +0100657 vty_out(vty, " Use Count: %u, State: %s%s", lchan->conn.use_count,
Harald Welteab2534c2009-12-29 10:52:38 +0100658 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100659 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
660 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
661 - lchan->bs_power*2,
662 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
663 VTY_NEWLINE);
Holger Hans Peter Freyther065b8112010-03-23 06:41:45 +0100664 if (lchan->conn.subscr) {
Harald Welte59b04682009-06-10 05:40:52 +0800665 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther065b8112010-03-23 06:41:45 +0100666 subscr_dump_vty(vty, lchan->conn.subscr);
Harald Welte59b04682009-06-10 05:40:52 +0800667 } else
668 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte87504212009-12-02 01:56:49 +0530669 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
670 struct in_addr ia;
Holger Hans Peter Freythercec1ec52010-04-07 15:39:16 +0200671 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte87504212009-12-02 01:56:49 +0530672 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
673 inet_ntoa(ia), lchan->abis_ip.bound_port,
674 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
675 VTY_NEWLINE);
676 }
Harald Welte44007742009-12-22 21:43:14 +0100677
678 /* we want to report the last measurement report */
679 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
680 lchan->meas_rep_idx, 1);
681 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte59b04682009-06-10 05:40:52 +0800682}
683
Harald Welte03740842009-06-10 23:11:52 +0800684#if 0
685TODO: callref and remote callref of call must be resolved to get gsm_trans object
Harald Welte59b04682009-06-10 05:40:52 +0800686static void call_dump_vty(struct vty *vty, struct gsm_call *call)
687{
688 vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s",
689 call->type, call->state, call->transaction_id, VTY_NEWLINE);
690
691 if (call->local_lchan) {
692 vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE);
693 lchan_dump_vty(vty, call->local_lchan);
694 } else
695 vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE);
696
697 if (call->remote_lchan) {
698 vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE);
699 lchan_dump_vty(vty, call->remote_lchan);
700 } else
701 vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE);
702
703 if (call->called_subscr) {
704 vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE);
705 subscr_dump_vty(vty, call->called_subscr);
706 } else
707 vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE);
708}
Harald Welte03740842009-06-10 23:11:52 +0800709#endif
Harald Welte59b04682009-06-10 05:40:52 +0800710
711DEFUN(show_lchan,
712 show_lchan_cmd,
713 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200714 SHOW_STR "Display information about a logical channel\n"
715 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
716 "Logical Channel Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800717{
718 struct gsm_network *net = gsmnet;
719 struct gsm_bts *bts;
720 struct gsm_bts_trx *trx;
721 struct gsm_bts_trx_ts *ts;
722 struct gsm_lchan *lchan;
723 int bts_nr, trx_nr, ts_nr, lchan_nr;
724
725 if (argc >= 1) {
726 /* use the BTS number that the user has specified */
727 bts_nr = atoi(argv[0]);
728 if (bts_nr >= net->num_bts) {
729 vty_out(vty, "%% can't find BTS %s%s", argv[0],
730 VTY_NEWLINE);
731 return CMD_WARNING;
732 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200733 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800734 }
735 if (argc >= 2) {
736 trx_nr = atoi(argv[1]);
737 if (trx_nr >= bts->num_trx) {
738 vty_out(vty, "%% can't find TRX %s%s", argv[1],
739 VTY_NEWLINE);
740 return CMD_WARNING;
741 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200742 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800743 }
744 if (argc >= 3) {
745 ts_nr = atoi(argv[2]);
746 if (ts_nr >= TRX_NR_TS) {
747 vty_out(vty, "%% can't find TS %s%s", argv[2],
748 VTY_NEWLINE);
749 return CMD_WARNING;
750 }
751 ts = &trx->ts[ts_nr];
752 }
753 if (argc >= 4) {
754 lchan_nr = atoi(argv[3]);
755 if (lchan_nr >= TS_MAX_LCHAN) {
756 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
757 VTY_NEWLINE);
758 return CMD_WARNING;
759 }
760 lchan = &ts->lchan[lchan_nr];
761 lchan_dump_vty(vty, lchan);
762 return CMD_SUCCESS;
763 }
764 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200765 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800766 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200767 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800768 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
769 ts = &trx->ts[ts_nr];
770 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
771 lchan_nr++) {
772 lchan = &ts->lchan[lchan_nr];
773 if (lchan->type == GSM_LCHAN_NONE)
774 continue;
775 lchan_dump_vty(vty, lchan);
776 }
777 }
778 }
779 }
780
781 return CMD_SUCCESS;
782}
783
784static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
785{
786 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
787}
788
789DEFUN(show_e1drv,
790 show_e1drv_cmd,
791 "show e1_driver",
792 SHOW_STR "Display information about available E1 drivers\n")
793{
794 struct e1inp_driver *drv;
795
796 llist_for_each_entry(drv, &e1inp_driver_list, list)
797 e1drv_dump_vty(vty, drv);
798
799 return CMD_SUCCESS;
800}
801
802static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
803{
804 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
805 line->num, line->name ? line->name : "",
806 line->driver->name, VTY_NEWLINE);
807}
808
809DEFUN(show_e1line,
810 show_e1line_cmd,
811 "show e1_line [line_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200812 SHOW_STR "Display information about a E1 line\n"
813 "E1 Line Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800814{
815 struct e1inp_line *line;
816
817 if (argc >= 1) {
818 int num = atoi(argv[0]);
819 llist_for_each_entry(line, &e1inp_line_list, list) {
820 if (line->num == num) {
821 e1line_dump_vty(vty, line);
822 return CMD_SUCCESS;
823 }
824 }
825 return CMD_WARNING;
826 }
827
828 llist_for_each_entry(line, &e1inp_line_list, list)
829 e1line_dump_vty(vty, line);
830
831 return CMD_SUCCESS;
832}
833
834static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
835{
Harald Welte62868882009-08-08 16:12:58 +0200836 if (ts->type == E1INP_TS_TYPE_NONE)
837 return;
Harald Welte59b04682009-06-10 05:40:52 +0800838 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
839 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
840 VTY_NEWLINE);
841}
842
843DEFUN(show_e1ts,
844 show_e1ts_cmd,
845 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200846 SHOW_STR "Display information about a E1 timeslot\n"
847 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800848{
Harald Welte49c79562009-11-17 06:12:16 +0100849 struct e1inp_line *line = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800850 struct e1inp_ts *ts;
851 int ts_nr;
852
853 if (argc == 0) {
854 llist_for_each_entry(line, &e1inp_line_list, list) {
855 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
856 ts = &line->ts[ts_nr];
857 e1ts_dump_vty(vty, ts);
858 }
859 }
860 return CMD_SUCCESS;
861 }
862 if (argc >= 1) {
863 int num = atoi(argv[0]);
864 llist_for_each_entry(line, &e1inp_line_list, list) {
865 if (line->num == num)
866 break;
867 }
868 if (!line || line->num != num) {
869 vty_out(vty, "E1 line %s is invalid%s",
870 argv[0], VTY_NEWLINE);
871 return CMD_WARNING;
872 }
873 }
874 if (argc >= 2) {
875 ts_nr = atoi(argv[1]);
876 if (ts_nr > NUM_E1_TS) {
877 vty_out(vty, "E1 timeslot %s is invalid%s",
878 argv[1], VTY_NEWLINE);
879 return CMD_WARNING;
880 }
881 ts = &line->ts[ts_nr];
882 e1ts_dump_vty(vty, ts);
883 return CMD_SUCCESS;
884 } else {
885 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
886 ts = &line->ts[ts_nr];
887 e1ts_dump_vty(vty, ts);
888 }
889 return CMD_SUCCESS;
890 }
891 return CMD_SUCCESS;
892}
893
894static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
895{
896 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
897 subscr_dump_vty(vty, pag->subscr);
898}
899
900static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
901{
902 struct gsm_paging_request *pag;
903
904 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
905 paging_dump_vty(vty, pag);
906}
907
908DEFUN(show_paging,
909 show_paging_cmd,
910 "show paging [bts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200911 SHOW_STR "Display information about paging reuqests of a BTS\n"
912 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800913{
914 struct gsm_network *net = gsmnet;
915 struct gsm_bts *bts;
916 int bts_nr;
917
918 if (argc >= 1) {
919 /* use the BTS number that the user has specified */
920 bts_nr = atoi(argv[0]);
921 if (bts_nr >= net->num_bts) {
922 vty_out(vty, "%% can't find BTS %s%s", argv[0],
923 VTY_NEWLINE);
924 return CMD_WARNING;
925 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200926 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800927 bts_paging_dump_vty(vty, bts);
928
929 return CMD_SUCCESS;
930 }
931 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200932 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800933 bts_paging_dump_vty(vty, bts);
934 }
935
936 return CMD_SUCCESS;
937}
938
Harald Welte9e002452010-05-11 21:53:49 +0200939#define NETWORK_STR "Configure the GSM network\n"
940
Harald Weltee87eb462009-08-07 13:29:14 +0200941DEFUN(cfg_net,
942 cfg_net_cmd,
Harald Welte9e002452010-05-11 21:53:49 +0200943 "network", NETWORK_STR)
Harald Weltee87eb462009-08-07 13:29:14 +0200944{
945 vty->index = gsmnet;
946 vty->node = GSMNET_NODE;
947
948 return CMD_SUCCESS;
949}
950
951
952DEFUN(cfg_net_ncc,
953 cfg_net_ncc_cmd,
954 "network country code <1-999>",
955 "Set the GSM network country code")
956{
957 gsmnet->country_code = atoi(argv[0]);
958
959 return CMD_SUCCESS;
960}
961
962DEFUN(cfg_net_mnc,
963 cfg_net_mnc_cmd,
964 "mobile network code <1-999>",
965 "Set the GSM mobile network code")
966{
967 gsmnet->network_code = atoi(argv[0]);
968
969 return CMD_SUCCESS;
970}
971
972DEFUN(cfg_net_name_short,
973 cfg_net_name_short_cmd,
974 "short name NAME",
975 "Set the short GSM network name")
976{
977 if (gsmnet->name_short)
978 talloc_free(gsmnet->name_short);
979
980 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
981
982 return CMD_SUCCESS;
983}
984
985DEFUN(cfg_net_name_long,
986 cfg_net_name_long_cmd,
987 "long name NAME",
988 "Set the long GSM network name")
989{
990 if (gsmnet->name_long)
991 talloc_free(gsmnet->name_long);
992
993 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
994
995 return CMD_SUCCESS;
996}
Harald Welte59b04682009-06-10 05:40:52 +0800997
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200998DEFUN(cfg_net_auth_policy,
999 cfg_net_auth_policy_cmd,
1000 "auth policy (closed|accept-all|token)",
Harald Welte9e002452010-05-11 21:53:49 +02001001 "Authentication (not cryptographic)\n"
1002 "Set the GSM network authentication policy\n"
1003 "Require the MS to be activated in HLR\n"
1004 "Accept all MS, whether in HLR or not\n"
1005 "Use SMS-token based authentication\n")
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001006{
1007 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
1008
1009 gsmnet->auth_policy = policy;
1010
1011 return CMD_SUCCESS;
1012}
1013
Harald Welte59936d72009-11-18 20:33:19 +01001014DEFUN(cfg_net_reject_cause,
1015 cfg_net_reject_cause_cmd,
1016 "location updating reject cause <2-111>",
1017 "Set the reject cause of location updating reject\n")
1018{
1019 gsmnet->reject_cause = atoi(argv[0]);
1020
1021 return CMD_SUCCESS;
1022}
1023
Harald Weltecca253a2009-08-30 15:47:06 +09001024DEFUN(cfg_net_encryption,
1025 cfg_net_encryption_cmd,
1026 "encryption a5 (0|1|2)",
1027 "Enable or disable encryption (A5) for this network\n")
1028{
Andreas.Eversberg53293292009-11-17 09:55:26 +01001029 gsmnet->a5_encryption= atoi(argv[0]);
Harald Weltecca253a2009-08-30 15:47:06 +09001030
1031 return CMD_SUCCESS;
1032}
1033
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001034DEFUN(cfg_net_neci,
1035 cfg_net_neci_cmd,
1036 "neci (0|1)",
1037 "Set if NECI of cell selection is to be set")
1038{
1039 gsmnet->neci = atoi(argv[0]);
1040 return CMD_SUCCESS;
1041}
1042
Harald Welte52af1952009-12-13 10:53:12 +01001043DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1044 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte9e002452010-05-11 21:53:49 +02001045 "Radio Resource Location Protocol\n"
1046 "Set the Radio Resource Location Protocol Mode\n"
1047 "Don't send RRLP request\n"
1048 "Request MS-based location\n"
1049 "Request any location, prefer MS-based\n"
1050 "Request any location, prefer MS-assisted\n")
Harald Welte52af1952009-12-13 10:53:12 +01001051{
1052 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1053
1054 return CMD_SUCCESS;
1055}
1056
Harald Weltea310f3e2009-12-14 09:00:24 +01001057DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1058 "mm info (0|1)",
1059 "Whether to send MM INFO after LOC UPD ACCEPT")
1060{
1061 gsmnet->send_mm_info = atoi(argv[0]);
1062
1063 return CMD_SUCCESS;
1064}
1065
Harald Welte9e002452010-05-11 21:53:49 +02001066#define HANDOVER_STR "Handover Options\n"
1067
Harald Welte0af9c9f2009-12-19 21:41:52 +01001068DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1069 "handover (0|1)",
Harald Welte9e002452010-05-11 21:53:49 +02001070 HANDOVER_STR
1071 "Don't perform in-call handover\n"
1072 "Perform in-call handover\n")
Harald Welte0af9c9f2009-12-19 21:41:52 +01001073{
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001074 int enable = atoi(argv[0]);
1075
1076 if (enable && ipacc_rtp_direct) {
Harald Welteaa2c3032009-12-20 13:51:01 +01001077 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1078 "is enabled by using the -P command line option%s",
1079 VTY_NEWLINE);
1080 return CMD_WARNING;
1081 }
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001082 gsmnet->handover.active = enable;
Harald Welte0af9c9f2009-12-19 21:41:52 +01001083
1084 return CMD_SUCCESS;
1085}
1086
Harald Welte9e002452010-05-11 21:53:49 +02001087#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1088#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1089#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1090#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1091
Harald Weltea8062f12009-12-21 16:51:50 +01001092DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1093 "handover window rxlev averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001094 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001095 "How many RxLev measurements are used for averaging")
1096{
1097 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1098 return CMD_SUCCESS;
1099}
1100
1101DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1102 "handover window rxqual averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001103 HO_WIN_RXQUAL_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001104 "How many RxQual measurements are used for averaging")
1105{
1106 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1107 return CMD_SUCCESS;
1108}
1109
1110DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1111 "handover window rxlev neighbor averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001112 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001113 "How many RxQual measurements are used for averaging")
1114{
1115 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1116 return CMD_SUCCESS;
1117}
1118
1119DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1120 "handover power budget interval <1-99>",
Harald Welte9e002452010-05-11 21:53:49 +02001121 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001122 "How often to check if we have a better cell (SACCH frames)")
1123{
1124 gsmnet->handover.pwr_interval = atoi(argv[0]);
1125 return CMD_SUCCESS;
1126}
1127
1128DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1129 "handover power budget hysteresis <0-999>",
Harald Welte9e002452010-05-11 21:53:49 +02001130 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001131 "How many dB does a neighbor to be stronger to become a HO candidate")
1132{
1133 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1134 return CMD_SUCCESS;
1135}
1136
1137DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1138 "handover maximum distance <0-9999>",
Harald Welte9e002452010-05-11 21:53:49 +02001139 HANDOVER_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001140 "How big is the maximum timing advance before HO is forced")
1141{
1142 gsmnet->handover.max_distance = atoi(argv[0]);
1143 return CMD_SUCCESS;
1144}
Harald Welte0af9c9f2009-12-19 21:41:52 +01001145
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001146#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001147 DEFUN(cfg_net_T##number, \
1148 cfg_net_T##number##_cmd, \
1149 "timer t" #number " <0-65535>", \
Harald Welte9e002452010-05-11 21:53:49 +02001150 "Configure GSM Timers\n" \
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001151 doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001152{ \
1153 int value = atoi(argv[0]); \
1154 \
1155 if (value < 0 || value > 65535) { \
1156 vty_out(vty, "Timer value %s out of range.%s", \
1157 argv[0], VTY_NEWLINE); \
1158 return CMD_WARNING; \
1159 } \
1160 \
1161 gsmnet->T##number = value; \
1162 return CMD_SUCCESS; \
1163}
1164
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001165DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1166DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1167DECLARE_TIMER(3105, "Currently not used.")
1168DECLARE_TIMER(3107, "Currently not used.")
1169DECLARE_TIMER(3109, "Currently not used.")
1170DECLARE_TIMER(3111, "Currently not used.")
1171DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1172DECLARE_TIMER(3115, "Currently not used.")
1173DECLARE_TIMER(3117, "Currently not used.")
1174DECLARE_TIMER(3119, "Currently not used.")
1175DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001176
1177
Harald Welte59b04682009-06-10 05:40:52 +08001178/* per-BTS configuration */
1179DEFUN(cfg_bts,
1180 cfg_bts_cmd,
1181 "bts BTS_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001182 "Select a BTS to configure\n"
1183 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001184{
1185 int bts_nr = atoi(argv[0]);
1186 struct gsm_bts *bts;
1187
Harald Weltee712a5f2009-06-21 16:17:15 +02001188 if (bts_nr > gsmnet->num_bts) {
1189 vty_out(vty, "%% The next unused BTS number is %u%s",
1190 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001191 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001192 } else if (bts_nr == gsmnet->num_bts) {
1193 /* allocate a new one */
1194 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1195 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001196 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001197 bts = gsm_bts_num(gsmnet, bts_nr);
1198
Daniel Willmann580085f2010-01-11 13:43:07 +01001199 if (!bts) {
1200 vty_out(vty, "%% Unable to allocate BTS %u%s",
1201 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee712a5f2009-06-21 16:17:15 +02001202 return CMD_WARNING;
Daniel Willmann580085f2010-01-11 13:43:07 +01001203 }
Harald Welte59b04682009-06-10 05:40:52 +08001204
1205 vty->index = bts;
1206 vty->node = BTS_NODE;
1207
1208 return CMD_SUCCESS;
1209}
1210
1211DEFUN(cfg_bts_type,
1212 cfg_bts_type_cmd,
1213 "type TYPE",
1214 "Set the BTS type\n")
1215{
1216 struct gsm_bts *bts = vty->index;
Harald Welte59698fb2010-01-10 18:01:52 +01001217 int rc;
Harald Welte59b04682009-06-10 05:40:52 +08001218
Harald Welte59698fb2010-01-10 18:01:52 +01001219 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1220 if (rc < 0)
1221 return CMD_WARNING;
Harald Welte25572872009-10-20 00:22:00 +02001222
Harald Welte59b04682009-06-10 05:40:52 +08001223 return CMD_SUCCESS;
1224}
1225
Harald Welte91afe4c2009-06-20 18:15:19 +02001226DEFUN(cfg_bts_band,
1227 cfg_bts_band_cmd,
1228 "band BAND",
1229 "Set the frequency band of this BTS\n")
1230{
1231 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +02001232 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +02001233
1234 if (band < 0) {
1235 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1236 band, VTY_NEWLINE);
1237 return CMD_WARNING;
1238 }
1239
1240 bts->band = band;
1241
1242 return CMD_SUCCESS;
1243}
1244
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001245DEFUN(cfg_bts_ci,
1246 cfg_bts_ci_cmd,
1247 "cell_identity <0-65535>",
1248 "Set the Cell identity of this BTS\n")
1249{
1250 struct gsm_bts *bts = vty->index;
1251 int ci = atoi(argv[0]);
1252
1253 if (ci < 0 || ci > 0xffff) {
1254 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1255 ci, VTY_NEWLINE);
1256 return CMD_WARNING;
1257 }
1258 bts->cell_identity = ci;
1259
1260 return CMD_SUCCESS;
1261}
1262
Harald Welte59b04682009-06-10 05:40:52 +08001263DEFUN(cfg_bts_lac,
1264 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001265 "location_area_code <0-65535>",
Harald Welte59b04682009-06-10 05:40:52 +08001266 "Set the Location Area Code (LAC) of this BTS\n")
1267{
1268 struct gsm_bts *bts = vty->index;
1269 int lac = atoi(argv[0]);
1270
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001271 if (lac < 0 || lac > 0xffff) {
1272 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001273 lac, VTY_NEWLINE);
1274 return CMD_WARNING;
1275 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +02001276
1277 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1278 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1279 lac, VTY_NEWLINE);
1280 return CMD_WARNING;
1281 }
1282
Harald Welte59b04682009-06-10 05:40:52 +08001283 bts->location_area_code = lac;
1284
1285 return CMD_SUCCESS;
1286}
1287
Harald Weltea54a2bb2009-12-01 18:04:30 +05301288
Harald Welte59b04682009-06-10 05:40:52 +08001289DEFUN(cfg_bts_tsc,
1290 cfg_bts_tsc_cmd,
1291 "training_sequence_code <0-255>",
1292 "Set the Training Sequence Code (TSC) of this BTS\n")
1293{
1294 struct gsm_bts *bts = vty->index;
1295 int tsc = atoi(argv[0]);
1296
1297 if (tsc < 0 || tsc > 0xff) {
1298 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1299 tsc, VTY_NEWLINE);
1300 return CMD_WARNING;
1301 }
1302 bts->tsc = tsc;
1303
1304 return CMD_SUCCESS;
1305}
1306
1307DEFUN(cfg_bts_bsic,
1308 cfg_bts_bsic_cmd,
1309 "base_station_id_code <0-63>",
1310 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1311{
1312 struct gsm_bts *bts = vty->index;
1313 int bsic = atoi(argv[0]);
1314
1315 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +02001316 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001317 bsic, VTY_NEWLINE);
1318 return CMD_WARNING;
1319 }
1320 bts->bsic = bsic;
1321
1322 return CMD_SUCCESS;
1323}
1324
1325
1326DEFUN(cfg_bts_unit_id,
1327 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +02001328 "ip.access unit_id <0-65534> <0-255>",
1329 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +08001330{
1331 struct gsm_bts *bts = vty->index;
1332 int site_id = atoi(argv[0]);
1333 int bts_id = atoi(argv[1]);
1334
Harald Weltef515aa02009-08-07 13:27:09 +02001335 if (!is_ipaccess_bts(bts)) {
1336 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1337 return CMD_WARNING;
1338 }
1339
Harald Welte59b04682009-06-10 05:40:52 +08001340 bts->ip_access.site_id = site_id;
1341 bts->ip_access.bts_id = bts_id;
1342
1343 return CMD_SUCCESS;
1344}
1345
Harald Welte9e002452010-05-11 21:53:49 +02001346#define OML_STR "Organization & Maintenance Link\n"
1347#define IPA_STR "ip.access Specific Options\n"
1348
Harald Welte25572872009-10-20 00:22:00 +02001349DEFUN(cfg_bts_stream_id,
1350 cfg_bts_stream_id_cmd,
1351 "oml ip.access stream_id <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001352 OML_STR IPA_STR
Harald Welte25572872009-10-20 00:22:00 +02001353 "Set the ip.access Stream ID of the OML link of this BTS\n")
1354{
1355 struct gsm_bts *bts = vty->index;
1356 int stream_id = atoi(argv[0]);
1357
1358 if (!is_ipaccess_bts(bts)) {
1359 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1360 return CMD_WARNING;
1361 }
1362
1363 bts->oml_tei = stream_id;
1364
1365 return CMD_SUCCESS;
1366}
1367
Harald Welte9e002452010-05-11 21:53:49 +02001368#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte25572872009-10-20 00:22:00 +02001369
Harald Welte62868882009-08-08 16:12:58 +02001370DEFUN(cfg_bts_oml_e1,
1371 cfg_bts_oml_e1_cmd,
1372 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte9e002452010-05-11 21:53:49 +02001373 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001374 "E1 interface to be used for OML\n")
1375{
1376 struct gsm_bts *bts = vty->index;
1377
1378 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1379
1380 return CMD_SUCCESS;
1381}
1382
1383
1384DEFUN(cfg_bts_oml_e1_tei,
1385 cfg_bts_oml_e1_tei_cmd,
1386 "oml e1 tei <0-63>",
Harald Welte9e002452010-05-11 21:53:49 +02001387 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001388 "Set the TEI to be used for OML")
1389{
1390 struct gsm_bts *bts = vty->index;
1391
1392 bts->oml_tei = atoi(argv[0]);
1393
1394 return CMD_SUCCESS;
1395}
1396
Harald Welte3e774612009-08-10 13:48:16 +02001397DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1398 "channel allocator (ascending|descending)",
Harald Welte9e002452010-05-11 21:53:49 +02001399 "Channnel Allocator\n" "Channel Allocator\n"
1400 "Allocate Timeslots and Transceivers in ascending order\n"
1401 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte3e774612009-08-10 13:48:16 +02001402{
1403 struct gsm_bts *bts = vty->index;
1404
1405 if (!strcmp(argv[0], "ascending"))
1406 bts->chan_alloc_reverse = 0;
1407 else
1408 bts->chan_alloc_reverse = 1;
1409
1410 return CMD_SUCCESS;
1411}
1412
Harald Welte9e002452010-05-11 21:53:49 +02001413#define RACH_STR "Random Access Control Channel\n"
1414
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001415DEFUN(cfg_bts_rach_tx_integer,
1416 cfg_bts_rach_tx_integer_cmd,
1417 "rach tx integer <0-15>",
Harald Welte9e002452010-05-11 21:53:49 +02001418 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001419 "Set the raw tx integer value in RACH Control parameters IE")
1420{
1421 struct gsm_bts *bts = vty->index;
1422 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1423 return CMD_SUCCESS;
1424}
1425
1426DEFUN(cfg_bts_rach_max_trans,
1427 cfg_bts_rach_max_trans_cmd,
1428 "rach max transmission (1|2|4|7)",
Harald Welte9e002452010-05-11 21:53:49 +02001429 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001430 "Set the maximum number of RACH burst transmissions")
1431{
1432 struct gsm_bts *bts = vty->index;
1433 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1434 return CMD_SUCCESS;
1435}
1436
Harald Welte9e002452010-05-11 21:53:49 +02001437#define NM_STR "Network Management\n"
1438
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001439DEFUN(cfg_bts_rach_nm_b_thresh,
1440 cfg_bts_rach_nm_b_thresh_cmd,
1441 "rach nm busy threshold <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001442 RACH_STR NM_STR
1443 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001444{
1445 struct gsm_bts *bts = vty->index;
1446 bts->rach_b_thresh = atoi(argv[0]);
1447 return CMD_SUCCESS;
1448}
1449
1450DEFUN(cfg_bts_rach_nm_ldavg,
1451 cfg_bts_rach_nm_ldavg_cmd,
1452 "rach nm load average <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001453 RACH_STR NM_STR
1454 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001455{
1456 struct gsm_bts *bts = vty->index;
1457 bts->rach_ldavg_slots = atoi(argv[0]);
1458 return CMD_SUCCESS;
1459}
1460
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001461DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1462 "cell barred (0|1)",
1463 "Should this cell be barred from access?")
1464{
1465 struct gsm_bts *bts = vty->index;
1466
Harald Welte8c973ba2009-12-21 23:08:18 +01001467 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001468
1469 return CMD_SUCCESS;
1470}
1471
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001472DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1473 "ms max power <0-40>",
1474 "Maximum transmit power of the MS")
1475{
1476 struct gsm_bts *bts = vty->index;
1477
1478 bts->ms_max_power = atoi(argv[0]);
1479
1480 return CMD_SUCCESS;
1481}
1482
Harald Welteb761bf82009-12-12 18:17:25 +01001483DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1484 "cell reselection hysteresis <0-14>",
1485 "Cell Re-Selection Hysteresis in dB")
1486{
1487 struct gsm_bts *bts = vty->index;
1488
1489 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1490
1491 return CMD_SUCCESS;
1492}
1493
1494DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1495 "rxlev access min <0-63>",
1496 "Minimum RxLev needed for cell access (better than -110dBm)")
1497{
1498 struct gsm_bts *bts = vty->index;
1499
1500 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1501
1502 return CMD_SUCCESS;
1503}
1504
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001505DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1506 "periodic location update <0-1530>",
1507 "Periodic Location Updating Interval in Minutes")
1508{
1509 struct gsm_bts *bts = vty->index;
1510
Harald Weltea54a2bb2009-12-01 18:04:30 +05301511 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001512
1513 return CMD_SUCCESS;
1514}
1515
Harald Welte9e002452010-05-11 21:53:49 +02001516#define GPRS_TEXT "GPRS Packet Network\n"
1517
Harald Welte410575a2010-03-14 23:30:30 +08001518DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welteb42fe342010-04-18 14:00:26 +02001519 "gprs cell bvci <2-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001520 GPRS_TEXT
1521 "GPRS Cell Settings\n"
Harald Welte3055e332010-03-14 15:37:43 +08001522 "GPRS BSSGP VC Identifier")
1523{
1524 struct gsm_bts *bts = vty->index;
1525
Harald Weltecb20b7a2010-04-18 15:51:20 +02001526 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001527 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1528 return CMD_WARNING;
1529 }
1530
Harald Welte3055e332010-03-14 15:37:43 +08001531 bts->gprs.cell.bvci = atoi(argv[0]);
1532
1533 return CMD_SUCCESS;
1534}
1535
Harald Welte4a048c52010-03-22 11:48:36 +08001536DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1537 "gprs nsei <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001538 GPRS_TEXT
Harald Welte4a048c52010-03-22 11:48:36 +08001539 "GPRS NS Entity Identifier")
1540{
1541 struct gsm_bts *bts = vty->index;
1542
Harald Weltecb20b7a2010-04-18 15:51:20 +02001543 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte4a048c52010-03-22 11:48:36 +08001544 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1545 return CMD_WARNING;
1546 }
1547
1548 bts->gprs.nse.nsei = atoi(argv[0]);
1549
1550 return CMD_SUCCESS;
1551}
1552
Harald Welte9e002452010-05-11 21:53:49 +02001553#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1554 "NSVC Logical Number\n"
Harald Welte4a048c52010-03-22 11:48:36 +08001555
Harald Welte3055e332010-03-14 15:37:43 +08001556DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1557 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001558 GPRS_TEXT NSVC_TEXT
1559 "NS Virtual Connection Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08001560 "GPRS NS VC Identifier")
1561{
1562 struct gsm_bts *bts = vty->index;
1563 int idx = atoi(argv[0]);
1564
Harald Weltecb20b7a2010-04-18 15:51:20 +02001565 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001566 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1567 return CMD_WARNING;
1568 }
1569
Harald Welte3055e332010-03-14 15:37:43 +08001570 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1571
1572 return CMD_SUCCESS;
1573}
1574
Harald Welte410575a2010-03-14 23:30:30 +08001575DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1576 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001577 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001578 "GPRS NS Local UDP Port")
1579{
1580 struct gsm_bts *bts = vty->index;
1581 int idx = atoi(argv[0]);
1582
Harald Weltecb20b7a2010-04-18 15:51:20 +02001583 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001584 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1585 return CMD_WARNING;
1586 }
1587
Harald Welte410575a2010-03-14 23:30:30 +08001588 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1589
1590 return CMD_SUCCESS;
1591}
1592
1593DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1594 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001595 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001596 "GPRS NS Remote UDP Port")
1597{
1598 struct gsm_bts *bts = vty->index;
1599 int idx = atoi(argv[0]);
1600
Harald Weltecb20b7a2010-04-18 15:51:20 +02001601 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001602 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1603 return CMD_WARNING;
1604 }
1605
Harald Welte410575a2010-03-14 23:30:30 +08001606 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1607
1608 return CMD_SUCCESS;
1609}
1610
1611DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1612 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte9e002452010-05-11 21:53:49 +02001613 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001614 "GPRS NS Remote IP Address")
1615{
1616 struct gsm_bts *bts = vty->index;
1617 int idx = atoi(argv[0]);
1618 struct in_addr ia;
1619
Harald Weltecb20b7a2010-04-18 15:51:20 +02001620 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001621 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1622 return CMD_WARNING;
1623 }
1624
Harald Welte410575a2010-03-14 23:30:30 +08001625 inet_aton(argv[1], &ia);
1626 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1627
1628 return CMD_SUCCESS;
1629}
1630
Harald Weltea9251762010-05-11 23:50:21 +02001631DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1632 "gprs ns timer " NS_TIMERS " <0-255>",
1633 GPRS_TEXT "Network Service\n"
1634 "Network Service Timer\n"
1635 NS_TIMERS_HELP "Timer Value\n")
1636{
1637 struct gsm_bts *bts = vty->index;
1638 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1639 int val = atoi(argv[1]);
1640
1641 if (bts->gprs.mode == BTS_GPRS_NONE) {
1642 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1643 return CMD_WARNING;
1644 }
1645
1646 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1647 return CMD_WARNING;
1648
1649 bts->gprs.nse.timer[idx] = val;
1650
1651 return CMD_SUCCESS;
1652}
1653
1654#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)"
1655#define BSSGP_TIMERS_HELP ""
1656
1657DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1658 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1659 GPRS_TEXT "Cell / BSSGP\n"
1660 "Cell/BSSGP Timer\n"
1661 BSSGP_TIMERS_HELP "Timer Value\n")
1662{
1663 struct gsm_bts *bts = vty->index;
1664 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1665 int val = atoi(argv[1]);
1666
1667 if (bts->gprs.mode == BTS_GPRS_NONE) {
1668 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1669 return CMD_WARNING;
1670 }
1671
1672 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
1673 return CMD_WARNING;
1674
1675 bts->gprs.cell.timer[idx] = val;
1676
1677 return CMD_SUCCESS;
1678}
1679
Harald Welte3055e332010-03-14 15:37:43 +08001680DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1681 "gprs routing area <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001682 GPRS_TEXT
Harald Welte3055e332010-03-14 15:37:43 +08001683 "GPRS Routing Area Code")
1684{
1685 struct gsm_bts *bts = vty->index;
1686
Harald Weltecb20b7a2010-04-18 15:51:20 +02001687 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001688 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1689 return CMD_WARNING;
1690 }
1691
Harald Welte3055e332010-03-14 15:37:43 +08001692 bts->gprs.rac = atoi(argv[0]);
1693
1694 return CMD_SUCCESS;
1695}
1696
Harald Weltecb20b7a2010-04-18 15:51:20 +02001697DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
1698 "gprs mode (none|gprs|egprs)",
Harald Welte9e002452010-05-11 21:53:49 +02001699 GPRS_TEXT
1700 "GPRS Mode for this BTS\n"
1701 "GPRS Disabled on this BTS\n"
1702 "GPRS Enabled on this BTS\n"
1703 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welte410575a2010-03-14 23:30:30 +08001704{
1705 struct gsm_bts *bts = vty->index;
1706
Harald Weltecb20b7a2010-04-18 15:51:20 +02001707 bts->gprs.mode = bts_gprs_mode_parse(argv[0]);
Harald Welte410575a2010-03-14 23:30:30 +08001708
1709 return CMD_SUCCESS;
1710}
1711
Harald Welte9e002452010-05-11 21:53:49 +02001712#define TRX_TEXT "Radio Transceiver\n"
Harald Welte3e774612009-08-10 13:48:16 +02001713
Harald Welte59b04682009-06-10 05:40:52 +08001714/* per TRX configuration */
1715DEFUN(cfg_trx,
1716 cfg_trx_cmd,
1717 "trx TRX_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001718 TRX_TEXT
Harald Welte59b04682009-06-10 05:40:52 +08001719 "Select a TRX to configure")
1720{
1721 int trx_nr = atoi(argv[0]);
1722 struct gsm_bts *bts = vty->index;
1723 struct gsm_bts_trx *trx;
1724
Harald Weltee712a5f2009-06-21 16:17:15 +02001725 if (trx_nr > bts->num_trx) {
1726 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1727 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001728 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001729 } else if (trx_nr == bts->num_trx) {
1730 /* we need to allocate a new one */
1731 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001732 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001733 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001734
Harald Weltee712a5f2009-06-21 16:17:15 +02001735 if (!trx)
1736 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08001737
1738 vty->index = trx;
1739 vty->node = TRX_NODE;
1740
1741 return CMD_SUCCESS;
1742}
1743
1744DEFUN(cfg_trx_arfcn,
1745 cfg_trx_arfcn_cmd,
1746 "arfcn <1-1024>",
1747 "Set the ARFCN for this TRX\n")
1748{
1749 int arfcn = atoi(argv[0]);
1750 struct gsm_bts_trx *trx = vty->index;
1751
1752 /* FIXME: check if this ARFCN is supported by this TRX */
1753
1754 trx->arfcn = arfcn;
1755
1756 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1757 /* FIXME: use OML layer to update the ARFCN */
1758 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
1759
1760 return CMD_SUCCESS;
1761}
1762
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01001763DEFUN(cfg_trx_nominal_power,
1764 cfg_trx_nominal_power_cmd,
1765 "nominal power <0-100>",
1766 "Nominal TRX RF Power in dB\n")
1767{
1768 struct gsm_bts_trx *trx = vty->index;
1769
1770 trx->nominal_power = atoi(argv[0]);
1771
1772 return CMD_SUCCESS;
1773}
1774
Harald Welte91afe4c2009-06-20 18:15:19 +02001775DEFUN(cfg_trx_max_power_red,
1776 cfg_trx_max_power_red_cmd,
1777 "max_power_red <0-100>",
1778 "Reduction of maximum BS RF Power in dB\n")
1779{
1780 int maxpwr_r = atoi(argv[0]);
1781 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01001782 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02001783
1784 /* FIXME: check if our BTS type supports more than 12 */
1785 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
1786 vty_out(vty, "%% Power %d dB is not in the valid range%s",
1787 maxpwr_r, VTY_NEWLINE);
1788 return CMD_WARNING;
1789 }
1790 if (maxpwr_r & 1) {
1791 vty_out(vty, "%% Power %d dB is not an even value%s",
1792 maxpwr_r, VTY_NEWLINE);
1793 return CMD_WARNING;
1794 }
1795
1796 trx->max_power_red = maxpwr_r;
1797
1798 /* FIXME: make sure we update this using OML */
1799
1800 return CMD_SUCCESS;
1801}
1802
Harald Welte62868882009-08-08 16:12:58 +02001803DEFUN(cfg_trx_rsl_e1,
1804 cfg_trx_rsl_e1_cmd,
1805 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1806 "E1 interface to be used for RSL\n")
1807{
1808 struct gsm_bts_trx *trx = vty->index;
1809
1810 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
1811
1812 return CMD_SUCCESS;
1813}
1814
1815DEFUN(cfg_trx_rsl_e1_tei,
1816 cfg_trx_rsl_e1_tei_cmd,
1817 "rsl e1 tei <0-63>",
1818 "Set the TEI to be used for RSL")
1819{
1820 struct gsm_bts_trx *trx = vty->index;
1821
1822 trx->rsl_tei = atoi(argv[0]);
1823
1824 return CMD_SUCCESS;
1825}
1826
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01001827DEFUN(cfg_trx_rf_locked,
1828 cfg_trx_rf_locked_cmd,
1829 "rf_locked (0|1)",
1830 "Turn off RF of the TRX.\n")
1831{
1832 int locked = atoi(argv[0]);
1833 struct gsm_bts_trx *trx = vty->index;
1834
1835 gsm_trx_lock_rf(trx, locked);
1836 return CMD_SUCCESS;
1837}
Harald Welte62868882009-08-08 16:12:58 +02001838
Harald Welte59b04682009-06-10 05:40:52 +08001839/* per TS configuration */
1840DEFUN(cfg_ts,
1841 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02001842 "timeslot <0-7>",
Harald Welte59b04682009-06-10 05:40:52 +08001843 "Select a Timeslot to configure")
1844{
1845 int ts_nr = atoi(argv[0]);
1846 struct gsm_bts_trx *trx = vty->index;
1847 struct gsm_bts_trx_ts *ts;
1848
1849 if (ts_nr >= TRX_NR_TS) {
1850 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
1851 TRX_NR_TS, VTY_NEWLINE);
1852 return CMD_WARNING;
1853 }
1854
1855 ts = &trx->ts[ts_nr];
1856
1857 vty->index = ts;
1858 vty->node = TS_NODE;
1859
1860 return CMD_SUCCESS;
1861}
1862
Harald Welte3ffe1b32009-08-07 00:25:23 +02001863DEFUN(cfg_ts_pchan,
1864 cfg_ts_pchan_cmd,
1865 "phys_chan_config PCHAN",
1866 "Physical Channel configuration (TCH/SDCCH/...)")
1867{
1868 struct gsm_bts_trx_ts *ts = vty->index;
1869 int pchanc;
1870
1871 pchanc = gsm_pchan_parse(argv[0]);
1872 if (pchanc < 0)
1873 return CMD_WARNING;
1874
1875 ts->pchan = pchanc;
1876
1877 return CMD_SUCCESS;
1878}
1879
1880DEFUN(cfg_ts_e1_subslot,
1881 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02001882 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte3ffe1b32009-08-07 00:25:23 +02001883 "E1 sub-slot connected to this on-air timeslot")
1884{
1885 struct gsm_bts_trx_ts *ts = vty->index;
1886
Harald Welte62868882009-08-08 16:12:58 +02001887 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02001888
1889 return CMD_SUCCESS;
1890}
Harald Welte59b04682009-06-10 05:40:52 +08001891
Holger Hans Peter Freytherc48a2a12010-04-10 00:08:28 +02001892extern int bsc_vty_init_extra(struct gsm_network *net);
1893
Harald Welte59b04682009-06-10 05:40:52 +08001894int bsc_vty_init(struct gsm_network *net)
1895{
1896 gsmnet = net;
1897
1898 cmd_init(1);
1899 vty_init();
1900
Harald Welte7bc28f62010-05-12 16:10:35 +00001901 install_element_ve(&show_net_cmd);
1902 install_element_ve(&show_bts_cmd);
1903 install_element_ve(&show_trx_cmd);
1904 install_element_ve(&show_ts_cmd);
1905 install_element_ve(&show_lchan_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001906
Harald Welte7bc28f62010-05-12 16:10:35 +00001907 install_element_ve(&show_e1drv_cmd);
1908 install_element_ve(&show_e1line_cmd);
1909 install_element_ve(&show_e1ts_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001910
Harald Welte7bc28f62010-05-12 16:10:35 +00001911 install_element_ve(&show_paging_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001912
Holger Hans Peter Freytherb70d45b2010-04-06 11:55:37 +02001913 openbsc_vty_add_cmds();
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +01001914
Harald Weltee87eb462009-08-07 13:29:14 +02001915 install_element(CONFIG_NODE, &cfg_net_cmd);
1916 install_node(&net_node, config_write_net);
1917 install_default(GSMNET_NODE);
Harald Welte62868882009-08-08 16:12:58 +02001918 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02001919 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
1920 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
1921 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001922 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte59936d72009-11-18 20:33:19 +01001923 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09001924 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001925 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welte52af1952009-12-13 10:53:12 +01001926 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte284ddba2009-12-14 17:49:15 +01001927 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Welte0af9c9f2009-12-19 21:41:52 +01001928 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Weltea8062f12009-12-21 16:51:50 +01001929 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
1930 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
1931 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
1932 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
1933 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
1934 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001935 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01001936 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
1937 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
1938 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
1939 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
1940 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
1941 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
1942 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
1943 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
1944 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
1945 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02001946
1947 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02001948 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08001949 install_default(BTS_NODE);
1950 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02001951 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001952 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001953 install_element(BTS_NODE, &cfg_bts_lac_cmd);
1954 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02001955 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001956 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte25572872009-10-20 00:22:00 +02001957 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte62868882009-08-08 16:12:58 +02001958 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
1959 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02001960 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001961 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
1962 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001963 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
1964 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001965 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001966 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001967 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welteb761bf82009-12-12 18:17:25 +01001968 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
1969 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Weltecb20b7a2010-04-18 15:51:20 +02001970 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02001971 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08001972 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
1973 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02001974 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Welte4a048c52010-03-22 11:48:36 +08001975 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08001976 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welte410575a2010-03-14 23:30:30 +08001977 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
1978 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
1979 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001980
1981 install_element(BTS_NODE, &cfg_trx_cmd);
1982 install_node(&trx_node, dummy_config_write);
1983 install_default(TRX_NODE);
1984 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01001985 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02001986 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02001987 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
1988 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01001989 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001990
1991 install_element(TRX_NODE, &cfg_ts_cmd);
1992 install_node(&ts_node, dummy_config_write);
1993 install_default(TS_NODE);
Harald Welte3ffe1b32009-08-07 00:25:23 +02001994 install_element(TS_NODE, &cfg_ts_pchan_cmd);
1995 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001996
Holger Hans Peter Freytherbdae6f92009-08-10 10:17:50 +02001997 bsc_vty_init_extra(net);
Harald Welte59b04682009-06-10 05:40:52 +08001998
1999 return 0;
2000}