blob: df8f45ca6d72c28d2db7e05c9e3628f6a80e2380 [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 Welte22229d62010-05-12 20:28:04 +020042#include <openbsc/gprs_ns.h>
Harald Welte68628e82009-03-10 12:17:57 +000043
44static struct gsm_network *gsmnet;
45
Harald Welteea4647d2010-05-12 17:19:53 +000046/* FIXME: this should go to some common file */
47static const struct value_string gprs_ns_timer_strs[] = {
Harald Welte615e9562010-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 Welteea4647d2010-05-12 17:19:53 +000058static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Welte615e9562010-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 Welte5013b2a2009-08-07 13:29:14 +020073struct cmd_node net_node = {
74 GSMNET_NODE,
75 "%s(network)#",
76 1,
77};
78
Harald Welte68628e82009-03-10 12:17:57 +000079struct 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
97static 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{
Harald Welte1bc77352009-03-10 19:47:51 +0000104 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);
Harald Welte68628e82009-03-10 12:17:57 +0000107}
108
Harald Welteb908cb72009-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 Welte68628e82009-03-10 12:17:57 +0000129static void net_dump_vty(struct vty *vty, struct gsm_network *net)
130{
Harald Welteb908cb72009-12-22 13:09:29 +0100131 struct pchan_load pl;
132
Harald Welteef235b52009-03-10 12:34:02 +0000133 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);
Harald Welte1bc77352009-03-10 19:47:51 +0000136 vty_out(vty, " Long network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000137 net->name_long, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000138 vty_out(vty, " Short network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000139 net->name_short, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200140 vty_out(vty, " Authentication policy: %s%s",
141 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100142 vty_out(vty, " Location updating reject cause: %u%s",
143 net->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900144 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
145 VTY_NEWLINE);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100146 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
147 VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100148 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
149 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100150 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
151 VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100152 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
153 VTY_NEWLINE);
Harald Welteb908cb72009-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 Welte68628e82009-03-10 12:17:57 +0000157}
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{
Harald Welteedb37782009-05-01 14:59:07 +0000170 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,
Harald Welte1bc77352009-03-10 19:47:51 +0000181 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000182 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000183 e1l->tei, e1l->sapi, VTY_NEWLINE);
184}
185
186static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
187{
Harald Welteb908cb72009-12-22 13:09:29 +0100188 struct pchan_load pl;
189
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200190 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Weltefcd24452009-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 Freytherc4a49e32009-08-21 14:44:12 +0200193 bts->cell_identity,
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +0200194 bts->location_area_code, bts->bsic, bts->tsc,
Harald Weltefcd24452009-06-20 18:15:19 +0200195 bts->num_trx, VTY_NEWLINE);
Harald Welte1d8dbc42009-12-12 15:38:16 +0100196 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100197 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte1d8dbc42009-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 Welte73225282009-12-12 18:17:25 +0100201 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut4010f1e2009-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 Welte71355012009-12-21 23:08:18 +0100207 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200208 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000209 if (is_ipaccess_bts(bts))
Harald Welte8175e952009-10-20 00:22:00 +0200210 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte4cc34222009-05-01 15:12:31 +0000211 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte8175e952009-10-20 00:22:00 +0200212 bts->oml_tei, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000213 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 Welte8175e952009-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 Welte68628e82009-03-10 12:17:57 +0000223 /* FIXME: oml_link, chan_desc */
Harald Welteb908cb72009-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 Welte68628e82009-03-10 12:17:57 +0000228}
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) {
Harald Welte1bc77352009-03-10 19:47:51 +0000241 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000242 VTY_NEWLINE);
243 return CMD_WARNING;
244 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200245 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000246 return CMD_SUCCESS;
247 }
248 /* print all BTS's */
249 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200250 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000251
252 return CMD_SUCCESS;
253}
254
Harald Welte42581822009-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 Welte67ce0732009-08-06 19:06:46 +0200283static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
284{
Harald Welte42581822009-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 Welte67ce0732009-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 Welte5013b2a2009-08-07 13:29:14 +0200296 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Holger Hans Peter Freyther2ba40af2010-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 Welte5013b2a2009-08-07 13:29:14 +0200300 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100301 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200302 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte42581822009-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 Welte67ce0732009-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 Welte615e9562010-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 Welte67ce0732009-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 Welte5013b2a2009-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 Freytherf926ed62009-11-19 16:38:49 +0100356 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200357 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200358 VTY_NEWLINE);
Harald Welte5013b2a2009-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)0e451d02009-08-13 10:14:26 +0200361 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-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 Weltea43f7892009-12-01 18:04:30 +0530366 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)efc92312009-08-14 23:09:25 +0200367 vty_out(vty, " periodic location update %u%s",
Harald Weltea43f7892009-12-01 18:04:30 +0530368 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte7a8fa412009-08-10 13:48:16 +0200369 vty_out(vty, " channel allocator %s%s",
370 bts->chan_alloc_reverse ? "descending" : "ascending",
371 VTY_NEWLINE);
Sylvain Munaut4010f1e2009-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 Freyther95c22902010-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 Welte71355012009-12-21 23:08:18 +0100384 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200385 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +0800386 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
387 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200388 if (is_ipaccess_bts(bts)) {
Harald Welte5013b2a2009-08-07 13:29:14 +0200389 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200390 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200391 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
392 } else {
Harald Welte42581822009-08-08 16:12:58 +0200393 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
394 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
395 }
Harald Welte615e9562010-05-11 23:50:21 +0200396 config_write_bts_gprs(vty, bts);
Harald Welte67ce0732009-08-06 19:06:46 +0200397
398 llist_for_each_entry(trx, &bts->trx_list, list)
399 config_write_trx_single(vty, trx);
400}
401
402static int config_write_bts(struct vty *v)
403{
404 struct gsm_bts *bts;
405
406 llist_for_each_entry(bts, &gsmnet->bts_list, list)
407 config_write_bts_single(v, bts);
408
409 return CMD_SUCCESS;
410}
411
Harald Welte5013b2a2009-08-07 13:29:14 +0200412static int config_write_net(struct vty *vty)
413{
414 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200415 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200416 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200417 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
418 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200419 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100420 vty_out(vty, " location updating reject cause %u%s",
421 gsmnet->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900422 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freytherd54c3372009-11-19 16:37:48 +0100423 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100424 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
425 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100426 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100427 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Welteb720bd32009-12-21 16:51:50 +0100428 vty_out(vty, " handover window rxlev averaging %u%s",
429 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
430 vty_out(vty, " handover window rxqual averaging %u%s",
431 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
432 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
433 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
434 vty_out(vty, " handover power budget interval %u%s",
435 gsmnet->handover.pwr_interval, VTY_NEWLINE);
436 vty_out(vty, " handover power budget hysteresis %u%s",
437 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
438 vty_out(vty, " handover maximum distance %u%s",
439 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100440 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100441 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
442 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
443 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
444 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
445 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
446 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
447 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
448 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
449 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
450 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200451
452 return CMD_SUCCESS;
453}
Harald Welte67ce0732009-08-06 19:06:46 +0200454
Harald Welte68628e82009-03-10 12:17:57 +0000455static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
456{
457 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
458 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +0200459 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte42581822009-08-08 16:12:58 +0200460 "resulting BS power: %d dBm%s",
Harald Weltefcd24452009-06-20 18:15:19 +0200461 trx->nominal_power, trx->max_power_red,
Harald Welte42581822009-08-08 16:12:58 +0200462 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000463 vty_out(vty, " NM State: ");
464 net_dump_nmstate(vty, &trx->nm_state);
465 vty_out(vty, " Baseband Transceiver NM State: ");
466 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte8175e952009-10-20 00:22:00 +0200467 if (is_ipaccess_bts(trx->bts)) {
468 vty_out(vty, " ip.access stream ID: 0x%02x%s",
469 trx->rsl_tei, VTY_NEWLINE);
470 } else {
471 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
472 e1isl_dump_vty(vty, trx->rsl_link);
473 }
Harald Welte68628e82009-03-10 12:17:57 +0000474}
475
476DEFUN(show_trx,
477 show_trx_cmd,
478 "show trx [bts_nr] [trx_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200479 SHOW_STR "Display information about a TRX\n"
480 "BTS Number\n"
481 "TRX Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000482{
483 struct gsm_network *net = gsmnet;
484 struct gsm_bts *bts = NULL;
485 struct gsm_bts_trx *trx;
486 int bts_nr, trx_nr;
487
488 if (argc >= 1) {
489 /* use the BTS number that the user has specified */
490 bts_nr = atoi(argv[0]);
491 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000492 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000493 VTY_NEWLINE);
494 return CMD_WARNING;
495 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200496 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000497 }
498 if (argc >= 2) {
499 trx_nr = atoi(argv[1]);
500 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000501 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000502 VTY_NEWLINE);
503 return CMD_WARNING;
504 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200505 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000506 trx_dump_vty(vty, trx);
507 return CMD_SUCCESS;
508 }
509 if (bts) {
510 /* print all TRX in this BTS */
511 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200512 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000513 trx_dump_vty(vty, trx);
514 }
515 return CMD_SUCCESS;
516 }
517
518 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200519 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000520 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200521 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000522 trx_dump_vty(vty, trx);
523 }
524 }
525
526 return CMD_SUCCESS;
527}
528
Harald Welte67ce0732009-08-06 19:06:46 +0200529
Harald Welte68628e82009-03-10 12:17:57 +0000530static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
531{
Harald Welte68628e82009-03-10 12:17:57 +0000532 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
533 ts->nr, ts->trx->nr, ts->trx->bts->nr,
534 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
535 vty_out(vty, " NM State: ");
536 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte2c828992009-12-02 01:56:49 +0530537 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welteef235b52009-03-10 12:34:02 +0000538 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
539 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
540 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000541}
542
543DEFUN(show_ts,
544 show_ts_cmd,
Harald Welte1bc77352009-03-10 19:47:51 +0000545 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200546 SHOW_STR "Display information about a TS\n"
547 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000548{
549 struct gsm_network *net = gsmnet;
550 struct gsm_bts *bts;
551 struct gsm_bts_trx *trx;
552 struct gsm_bts_trx_ts *ts;
553 int bts_nr, trx_nr, ts_nr;
554
555 if (argc >= 1) {
556 /* use the BTS number that the user has specified */
557 bts_nr = atoi(argv[0]);
558 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000559 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000560 VTY_NEWLINE);
561 return CMD_WARNING;
562 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200563 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000564 }
565 if (argc >= 2) {
566 trx_nr = atoi(argv[1]);
567 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000568 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000569 VTY_NEWLINE);
570 return CMD_WARNING;
571 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200572 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000573 }
574 if (argc >= 3) {
575 ts_nr = atoi(argv[2]);
576 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +0000577 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +0000578 VTY_NEWLINE);
579 return CMD_WARNING;
580 }
581 ts = &trx->ts[ts_nr];
582 ts_dump_vty(vty, ts);
583 return CMD_SUCCESS;
584 }
585 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200586 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000587 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200588 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000589 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
590 ts = &trx->ts[ts_nr];
591 ts_dump_vty(vty, ts);
592 }
593 }
594 }
595
596 return CMD_SUCCESS;
597}
598
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100599static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte68628e82009-03-10 12:17:57 +0000600{
Harald Weltefcd24452009-06-20 18:15:19 +0200601 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte40f82892009-05-23 17:31:39 +0000602 subscr->authorized, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000603 if (subscr->name)
Harald Welte1bc77352009-03-10 19:47:51 +0000604 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000605 if (subscr->extension)
606 vty_out(vty, " Extension: %s%s", subscr->extension,
607 VTY_NEWLINE);
608 if (subscr->imsi)
609 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freyther22230252009-08-19 12:53:57 +0200610 if (subscr->tmsi != GSM_RESERVED_TMSI)
611 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte731fd912009-08-15 03:24:51 +0200612 VTY_NEWLINE);
Sylvain Munautaf292642009-12-27 19:29:28 +0100613
Harald Welte (local)15920de2009-08-14 20:27:16 +0200614 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000615}
616
Harald Welte8387a492009-12-22 21:43:14 +0100617static void meas_rep_dump_uni_vty(struct vty *vty,
618 struct gsm_meas_rep_unidir *mru,
619 const char *prefix,
620 const char *dir)
621{
622 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
623 prefix, dir, rxlev2dbm(mru->full.rx_lev),
624 dir, rxlev2dbm(mru->sub.rx_lev));
625 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
626 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
627 VTY_NEWLINE);
628}
629
630static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
631 const char *prefix)
632{
633 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
634 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
635 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
636 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
637 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
638 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
639 VTY_NEWLINE);
640 if (mr->flags & MEAS_REP_F_MS_TO)
641 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
642 mr->ms_timing_offset, VTY_NEWLINE);
643 if (mr->flags & MEAS_REP_F_MS_L1)
644 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
645 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
646 if (mr->flags & MEAS_REP_F_DL_VALID)
647 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
648 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
649}
650
Harald Welte68628e82009-03-10 12:17:57 +0000651static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
652{
Harald Welte8387a492009-12-22 21:43:14 +0100653 int idx;
654
Harald Welte68628e82009-03-10 12:17:57 +0000655 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 +0200656 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
Harald Welte (local)ccd88452009-12-27 18:05:25 +0100657 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Harald Welte68628e82009-03-10 12:17:57 +0000658 VTY_NEWLINE);
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100659 vty_out(vty, " Use Count: %u, State: %s%s", lchan->conn.use_count,
Harald Welte1887f9d2009-12-29 10:52:38 +0100660 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100661 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
662 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
663 - lchan->bs_power*2,
664 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
665 VTY_NEWLINE);
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100666 if (lchan->conn.subscr) {
Harald Welte68628e82009-03-10 12:17:57 +0000667 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100668 subscr_dump_vty(vty, lchan->conn.subscr);
Harald Welte68628e82009-03-10 12:17:57 +0000669 } else
670 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte2c828992009-12-02 01:56:49 +0530671 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
672 struct in_addr ia;
Holger Hans Peter Freyther54fa7992010-04-07 15:39:16 +0200673 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte2c828992009-12-02 01:56:49 +0530674 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
675 inet_ntoa(ia), lchan->abis_ip.bound_port,
676 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
677 VTY_NEWLINE);
678 }
Harald Welte8387a492009-12-22 21:43:14 +0100679
680 /* we want to report the last measurement report */
681 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
682 lchan->meas_rep_idx, 1);
683 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte68628e82009-03-10 12:17:57 +0000684}
685
Harald Welte68628e82009-03-10 12:17:57 +0000686DEFUN(show_lchan,
687 show_lchan_cmd,
688 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200689 SHOW_STR "Display information about a logical channel\n"
690 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
691 "Logical Channel Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000692{
693 struct gsm_network *net = gsmnet;
694 struct gsm_bts *bts;
695 struct gsm_bts_trx *trx;
696 struct gsm_bts_trx_ts *ts;
697 struct gsm_lchan *lchan;
698 int bts_nr, trx_nr, ts_nr, lchan_nr;
699
700 if (argc >= 1) {
701 /* use the BTS number that the user has specified */
702 bts_nr = atoi(argv[0]);
703 if (bts_nr >= net->num_bts) {
704 vty_out(vty, "%% can't find BTS %s%s", argv[0],
705 VTY_NEWLINE);
706 return CMD_WARNING;
707 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200708 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000709 }
710 if (argc >= 2) {
711 trx_nr = atoi(argv[1]);
712 if (trx_nr >= bts->num_trx) {
713 vty_out(vty, "%% can't find TRX %s%s", argv[1],
714 VTY_NEWLINE);
715 return CMD_WARNING;
716 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200717 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000718 }
719 if (argc >= 3) {
720 ts_nr = atoi(argv[2]);
721 if (ts_nr >= TRX_NR_TS) {
722 vty_out(vty, "%% can't find TS %s%s", argv[2],
723 VTY_NEWLINE);
724 return CMD_WARNING;
725 }
726 ts = &trx->ts[ts_nr];
727 }
728 if (argc >= 4) {
729 lchan_nr = atoi(argv[3]);
730 if (lchan_nr >= TS_MAX_LCHAN) {
731 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
732 VTY_NEWLINE);
733 return CMD_WARNING;
734 }
735 lchan = &ts->lchan[lchan_nr];
736 lchan_dump_vty(vty, lchan);
737 return CMD_SUCCESS;
738 }
739 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200740 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000741 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200742 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000743 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
744 ts = &trx->ts[ts_nr];
745 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
746 lchan_nr++) {
747 lchan = &ts->lchan[lchan_nr];
Harald Welteef235b52009-03-10 12:34:02 +0000748 if (lchan->type == GSM_LCHAN_NONE)
749 continue;
Harald Welte68628e82009-03-10 12:17:57 +0000750 lchan_dump_vty(vty, lchan);
751 }
752 }
753 }
754 }
755
756 return CMD_SUCCESS;
757}
758
Harald Welte1bc77352009-03-10 19:47:51 +0000759static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
760{
761 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
762}
763
764DEFUN(show_e1drv,
765 show_e1drv_cmd,
766 "show e1_driver",
767 SHOW_STR "Display information about available E1 drivers\n")
768{
769 struct e1inp_driver *drv;
770
771 llist_for_each_entry(drv, &e1inp_driver_list, list)
772 e1drv_dump_vty(vty, drv);
773
774 return CMD_SUCCESS;
775}
776
Harald Welte68628e82009-03-10 12:17:57 +0000777static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
778{
779 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
780 line->num, line->name ? line->name : "",
781 line->driver->name, VTY_NEWLINE);
782}
783
784DEFUN(show_e1line,
785 show_e1line_cmd,
786 "show e1_line [line_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200787 SHOW_STR "Display information about a E1 line\n"
788 "E1 Line Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000789{
Harald Welte1bc77352009-03-10 19:47:51 +0000790 struct e1inp_line *line;
791
792 if (argc >= 1) {
793 int num = atoi(argv[0]);
794 llist_for_each_entry(line, &e1inp_line_list, list) {
795 if (line->num == num) {
796 e1line_dump_vty(vty, line);
797 return CMD_SUCCESS;
798 }
799 }
800 return CMD_WARNING;
801 }
802
803 llist_for_each_entry(line, &e1inp_line_list, list)
804 e1line_dump_vty(vty, line);
805
806 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000807}
808
809static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
810{
Harald Welte42581822009-08-08 16:12:58 +0200811 if (ts->type == E1INP_TS_TYPE_NONE)
812 return;
Harald Welte1bc77352009-03-10 19:47:51 +0000813 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
814 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
815 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000816}
817
818DEFUN(show_e1ts,
819 show_e1ts_cmd,
820 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200821 SHOW_STR "Display information about a E1 timeslot\n"
822 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000823{
Harald Welte986c3d72009-11-17 06:12:16 +0100824 struct e1inp_line *line = NULL;
Harald Welte1bc77352009-03-10 19:47:51 +0000825 struct e1inp_ts *ts;
826 int ts_nr;
Harald Welte68628e82009-03-10 12:17:57 +0000827
Harald Welte1bc77352009-03-10 19:47:51 +0000828 if (argc == 0) {
829 llist_for_each_entry(line, &e1inp_line_list, list) {
830 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
831 ts = &line->ts[ts_nr];
832 e1ts_dump_vty(vty, ts);
833 }
834 }
835 return CMD_SUCCESS;
836 }
837 if (argc >= 1) {
838 int num = atoi(argv[0]);
839 llist_for_each_entry(line, &e1inp_line_list, list) {
840 if (line->num == num)
841 break;
842 }
843 if (!line || line->num != num) {
844 vty_out(vty, "E1 line %s is invalid%s",
845 argv[0], VTY_NEWLINE);
846 return CMD_WARNING;
847 }
848 }
849 if (argc >= 2) {
850 ts_nr = atoi(argv[1]);
851 if (ts_nr > NUM_E1_TS) {
852 vty_out(vty, "E1 timeslot %s is invalid%s",
853 argv[1], VTY_NEWLINE);
854 return CMD_WARNING;
855 }
856 ts = &line->ts[ts_nr];
857 e1ts_dump_vty(vty, ts);
858 return CMD_SUCCESS;
859 } else {
860 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
861 ts = &line->ts[ts_nr];
862 e1ts_dump_vty(vty, ts);
863 }
864 return CMD_SUCCESS;
865 }
866 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000867}
868
Harald Weltebe4b7302009-05-23 16:59:33 +0000869static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +0000870{
871 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
872 subscr_dump_vty(vty, pag->subscr);
873}
874
Harald Weltebe4b7302009-05-23 16:59:33 +0000875static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +0000876{
877 struct gsm_paging_request *pag;
878
879 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
880 paging_dump_vty(vty, pag);
881}
882
883DEFUN(show_paging,
884 show_paging_cmd,
885 "show paging [bts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200886 SHOW_STR "Display information about paging reuqests of a BTS\n"
887 "BTS Number\n")
Harald Weltef5025b62009-03-28 16:55:11 +0000888{
889 struct gsm_network *net = gsmnet;
890 struct gsm_bts *bts;
891 int bts_nr;
892
893 if (argc >= 1) {
894 /* use the BTS number that the user has specified */
895 bts_nr = atoi(argv[0]);
896 if (bts_nr >= net->num_bts) {
897 vty_out(vty, "%% can't find BTS %s%s", argv[0],
898 VTY_NEWLINE);
899 return CMD_WARNING;
900 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200901 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000902 bts_paging_dump_vty(vty, bts);
903
904 return CMD_SUCCESS;
905 }
906 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200907 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000908 bts_paging_dump_vty(vty, bts);
909 }
910
911 return CMD_SUCCESS;
912}
913
Harald Welte8f0ed552010-05-11 21:53:49 +0200914#define NETWORK_STR "Configure the GSM network\n"
915
Harald Welte5013b2a2009-08-07 13:29:14 +0200916DEFUN(cfg_net,
917 cfg_net_cmd,
Harald Welte8f0ed552010-05-11 21:53:49 +0200918 "network", NETWORK_STR)
Harald Welte5013b2a2009-08-07 13:29:14 +0200919{
920 vty->index = gsmnet;
921 vty->node = GSMNET_NODE;
922
923 return CMD_SUCCESS;
924}
925
926
927DEFUN(cfg_net_ncc,
928 cfg_net_ncc_cmd,
929 "network country code <1-999>",
930 "Set the GSM network country code")
931{
932 gsmnet->country_code = atoi(argv[0]);
933
934 return CMD_SUCCESS;
935}
936
937DEFUN(cfg_net_mnc,
938 cfg_net_mnc_cmd,
939 "mobile network code <1-999>",
940 "Set the GSM mobile network code")
941{
942 gsmnet->network_code = atoi(argv[0]);
943
944 return CMD_SUCCESS;
945}
946
947DEFUN(cfg_net_name_short,
948 cfg_net_name_short_cmd,
949 "short name NAME",
950 "Set the short GSM network name")
951{
952 if (gsmnet->name_short)
953 talloc_free(gsmnet->name_short);
954
955 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
956
957 return CMD_SUCCESS;
958}
959
960DEFUN(cfg_net_name_long,
961 cfg_net_name_long_cmd,
962 "long name NAME",
963 "Set the long GSM network name")
964{
965 if (gsmnet->name_long)
966 talloc_free(gsmnet->name_long);
967
968 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
969
970 return CMD_SUCCESS;
971}
Harald Welte40f82892009-05-23 17:31:39 +0000972
Harald Welte (local)69de3972009-08-12 14:42:23 +0200973DEFUN(cfg_net_auth_policy,
974 cfg_net_auth_policy_cmd,
975 "auth policy (closed|accept-all|token)",
Harald Welte8f0ed552010-05-11 21:53:49 +0200976 "Authentication (not cryptographic)\n"
977 "Set the GSM network authentication policy\n"
978 "Require the MS to be activated in HLR\n"
979 "Accept all MS, whether in HLR or not\n"
980 "Use SMS-token based authentication\n")
Harald Welte (local)69de3972009-08-12 14:42:23 +0200981{
982 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
983
984 gsmnet->auth_policy = policy;
985
986 return CMD_SUCCESS;
987}
988
Harald Welte1085c092009-11-18 20:33:19 +0100989DEFUN(cfg_net_reject_cause,
990 cfg_net_reject_cause_cmd,
991 "location updating reject cause <2-111>",
992 "Set the reject cause of location updating reject\n")
993{
994 gsmnet->reject_cause = atoi(argv[0]);
995
996 return CMD_SUCCESS;
997}
998
Harald Welte4381cfe2009-08-30 15:47:06 +0900999DEFUN(cfg_net_encryption,
1000 cfg_net_encryption_cmd,
1001 "encryption a5 (0|1|2)",
1002 "Enable or disable encryption (A5) for this network\n")
1003{
Andreas.Eversberg1059deb2009-11-17 09:55:26 +01001004 gsmnet->a5_encryption= atoi(argv[0]);
Harald Welte4381cfe2009-08-30 15:47:06 +09001005
1006 return CMD_SUCCESS;
1007}
1008
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001009DEFUN(cfg_net_neci,
1010 cfg_net_neci_cmd,
1011 "neci (0|1)",
1012 "Set if NECI of cell selection is to be set")
1013{
1014 gsmnet->neci = atoi(argv[0]);
1015 return CMD_SUCCESS;
1016}
1017
Harald Welteeab84a12009-12-13 10:53:12 +01001018DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1019 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001020 "Radio Resource Location Protocol\n"
1021 "Set the Radio Resource Location Protocol Mode\n"
1022 "Don't send RRLP request\n"
1023 "Request MS-based location\n"
1024 "Request any location, prefer MS-based\n"
1025 "Request any location, prefer MS-assisted\n")
Harald Welteeab84a12009-12-13 10:53:12 +01001026{
1027 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1028
1029 return CMD_SUCCESS;
1030}
1031
Harald Welte648b6ce2009-12-14 09:00:24 +01001032DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1033 "mm info (0|1)",
1034 "Whether to send MM INFO after LOC UPD ACCEPT")
1035{
1036 gsmnet->send_mm_info = atoi(argv[0]);
1037
1038 return CMD_SUCCESS;
1039}
1040
Harald Welte8f0ed552010-05-11 21:53:49 +02001041#define HANDOVER_STR "Handover Options\n"
1042
Harald Weltebc814502009-12-19 21:41:52 +01001043DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1044 "handover (0|1)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001045 HANDOVER_STR
1046 "Don't perform in-call handover\n"
1047 "Perform in-call handover\n")
Harald Weltebc814502009-12-19 21:41:52 +01001048{
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001049 int enable = atoi(argv[0]);
1050
1051 if (enable && ipacc_rtp_direct) {
Harald Weltefe03f0d2009-12-20 13:51:01 +01001052 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1053 "is enabled by using the -P command line option%s",
1054 VTY_NEWLINE);
1055 return CMD_WARNING;
1056 }
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001057 gsmnet->handover.active = enable;
Harald Weltebc814502009-12-19 21:41:52 +01001058
1059 return CMD_SUCCESS;
1060}
1061
Harald Welte8f0ed552010-05-11 21:53:49 +02001062#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1063#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1064#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1065#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1066
Harald Welteb720bd32009-12-21 16:51:50 +01001067DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1068 "handover window rxlev averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001069 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001070 "How many RxLev measurements are used for averaging")
1071{
1072 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1073 return CMD_SUCCESS;
1074}
1075
1076DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1077 "handover window rxqual averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001078 HO_WIN_RXQUAL_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001079 "How many RxQual measurements are used for averaging")
1080{
1081 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1082 return CMD_SUCCESS;
1083}
1084
1085DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1086 "handover window rxlev neighbor averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001087 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001088 "How many RxQual measurements are used for averaging")
1089{
1090 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1091 return CMD_SUCCESS;
1092}
1093
1094DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1095 "handover power budget interval <1-99>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001096 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001097 "How often to check if we have a better cell (SACCH frames)")
1098{
1099 gsmnet->handover.pwr_interval = atoi(argv[0]);
1100 return CMD_SUCCESS;
1101}
1102
1103DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1104 "handover power budget hysteresis <0-999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001105 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001106 "How many dB does a neighbor to be stronger to become a HO candidate")
1107{
1108 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1109 return CMD_SUCCESS;
1110}
1111
1112DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1113 "handover maximum distance <0-9999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001114 HANDOVER_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001115 "How big is the maximum timing advance before HO is forced")
1116{
1117 gsmnet->handover.max_distance = atoi(argv[0]);
1118 return CMD_SUCCESS;
1119}
Harald Weltebc814502009-12-19 21:41:52 +01001120
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001121#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001122 DEFUN(cfg_net_T##number, \
1123 cfg_net_T##number##_cmd, \
1124 "timer t" #number " <0-65535>", \
Harald Welte8f0ed552010-05-11 21:53:49 +02001125 "Configure GSM Timers\n" \
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001126 doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001127{ \
1128 int value = atoi(argv[0]); \
1129 \
1130 if (value < 0 || value > 65535) { \
1131 vty_out(vty, "Timer value %s out of range.%s", \
1132 argv[0], VTY_NEWLINE); \
1133 return CMD_WARNING; \
1134 } \
1135 \
1136 gsmnet->T##number = value; \
1137 return CMD_SUCCESS; \
1138}
1139
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001140DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1141DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1142DECLARE_TIMER(3105, "Currently not used.")
1143DECLARE_TIMER(3107, "Currently not used.")
1144DECLARE_TIMER(3109, "Currently not used.")
1145DECLARE_TIMER(3111, "Currently not used.")
1146DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1147DECLARE_TIMER(3115, "Currently not used.")
1148DECLARE_TIMER(3117, "Currently not used.")
1149DECLARE_TIMER(3119, "Currently not used.")
1150DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001151
1152
Harald Welte5258fc42009-03-28 19:07:53 +00001153/* per-BTS configuration */
1154DEFUN(cfg_bts,
1155 cfg_bts_cmd,
1156 "bts BTS_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001157 "Select a BTS to configure\n"
1158 "BTS Number\n")
Harald Welte5258fc42009-03-28 19:07:53 +00001159{
1160 int bts_nr = atoi(argv[0]);
1161 struct gsm_bts *bts;
1162
Harald Weltee441d9c2009-06-21 16:17:15 +02001163 if (bts_nr > gsmnet->num_bts) {
1164 vty_out(vty, "%% The next unused BTS number is %u%s",
1165 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001166 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001167 } else if (bts_nr == gsmnet->num_bts) {
1168 /* allocate a new one */
1169 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1170 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001171 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001172 bts = gsm_bts_num(gsmnet, bts_nr);
1173
Daniel Willmannf15c2762010-01-11 13:43:07 +01001174 if (!bts) {
1175 vty_out(vty, "%% Unable to allocate BTS %u%s",
1176 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee441d9c2009-06-21 16:17:15 +02001177 return CMD_WARNING;
Daniel Willmannf15c2762010-01-11 13:43:07 +01001178 }
Harald Welte5258fc42009-03-28 19:07:53 +00001179
1180 vty->index = bts;
1181 vty->node = BTS_NODE;
1182
1183 return CMD_SUCCESS;
1184}
1185
1186DEFUN(cfg_bts_type,
1187 cfg_bts_type_cmd,
1188 "type TYPE",
1189 "Set the BTS type\n")
1190{
1191 struct gsm_bts *bts = vty->index;
Harald Welte39315c42010-01-10 18:01:52 +01001192 int rc;
Harald Welte5258fc42009-03-28 19:07:53 +00001193
Harald Welte39315c42010-01-10 18:01:52 +01001194 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1195 if (rc < 0)
1196 return CMD_WARNING;
Harald Welte8175e952009-10-20 00:22:00 +02001197
Harald Welte5258fc42009-03-28 19:07:53 +00001198 return CMD_SUCCESS;
1199}
1200
Harald Weltefcd24452009-06-20 18:15:19 +02001201DEFUN(cfg_bts_band,
1202 cfg_bts_band_cmd,
1203 "band BAND",
1204 "Set the frequency band of this BTS\n")
1205{
1206 struct gsm_bts *bts = vty->index;
Harald Welte42581822009-08-08 16:12:58 +02001207 int band = gsm_band_parse(argv[0]);
Harald Weltefcd24452009-06-20 18:15:19 +02001208
1209 if (band < 0) {
1210 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1211 band, VTY_NEWLINE);
1212 return CMD_WARNING;
1213 }
1214
1215 bts->band = band;
1216
1217 return CMD_SUCCESS;
1218}
1219
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001220DEFUN(cfg_bts_ci,
1221 cfg_bts_ci_cmd,
1222 "cell_identity <0-65535>",
1223 "Set the Cell identity of this BTS\n")
1224{
1225 struct gsm_bts *bts = vty->index;
1226 int ci = atoi(argv[0]);
1227
1228 if (ci < 0 || ci > 0xffff) {
1229 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1230 ci, VTY_NEWLINE);
1231 return CMD_WARNING;
1232 }
1233 bts->cell_identity = ci;
1234
1235 return CMD_SUCCESS;
1236}
1237
Harald Welte5258fc42009-03-28 19:07:53 +00001238DEFUN(cfg_bts_lac,
1239 cfg_bts_lac_cmd,
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001240 "location_area_code <0-65535>",
Harald Welte5258fc42009-03-28 19:07:53 +00001241 "Set the Location Area Code (LAC) of this BTS\n")
1242{
1243 struct gsm_bts *bts = vty->index;
1244 int lac = atoi(argv[0]);
1245
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001246 if (lac < 0 || lac > 0xffff) {
1247 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte5258fc42009-03-28 19:07:53 +00001248 lac, VTY_NEWLINE);
1249 return CMD_WARNING;
1250 }
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +02001251
1252 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1253 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1254 lac, VTY_NEWLINE);
1255 return CMD_WARNING;
1256 }
1257
Harald Welte5258fc42009-03-28 19:07:53 +00001258 bts->location_area_code = lac;
1259
1260 return CMD_SUCCESS;
1261}
1262
Harald Weltea43f7892009-12-01 18:04:30 +05301263
Harald Welte5258fc42009-03-28 19:07:53 +00001264DEFUN(cfg_bts_tsc,
1265 cfg_bts_tsc_cmd,
1266 "training_sequence_code <0-255>",
1267 "Set the Training Sequence Code (TSC) of this BTS\n")
1268{
1269 struct gsm_bts *bts = vty->index;
1270 int tsc = atoi(argv[0]);
1271
1272 if (tsc < 0 || tsc > 0xff) {
1273 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1274 tsc, VTY_NEWLINE);
1275 return CMD_WARNING;
1276 }
1277 bts->tsc = tsc;
1278
1279 return CMD_SUCCESS;
1280}
1281
Harald Welte78f2f502009-05-23 16:56:52 +00001282DEFUN(cfg_bts_bsic,
1283 cfg_bts_bsic_cmd,
1284 "base_station_id_code <0-63>",
1285 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1286{
1287 struct gsm_bts *bts = vty->index;
1288 int bsic = atoi(argv[0]);
1289
1290 if (bsic < 0 || bsic > 0x3f) {
Harald Welte42581822009-08-08 16:12:58 +02001291 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte78f2f502009-05-23 16:56:52 +00001292 bsic, VTY_NEWLINE);
1293 return CMD_WARNING;
1294 }
1295 bts->bsic = bsic;
1296
1297 return CMD_SUCCESS;
1298}
1299
1300
Harald Welte4cc34222009-05-01 15:12:31 +00001301DEFUN(cfg_bts_unit_id,
1302 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +02001303 "ip.access unit_id <0-65534> <0-255>",
1304 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte4cc34222009-05-01 15:12:31 +00001305{
1306 struct gsm_bts *bts = vty->index;
1307 int site_id = atoi(argv[0]);
1308 int bts_id = atoi(argv[1]);
1309
Harald Welte07dc73d2009-08-07 13:27:09 +02001310 if (!is_ipaccess_bts(bts)) {
1311 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1312 return CMD_WARNING;
1313 }
1314
Harald Welte4cc34222009-05-01 15:12:31 +00001315 bts->ip_access.site_id = site_id;
1316 bts->ip_access.bts_id = bts_id;
1317
1318 return CMD_SUCCESS;
1319}
1320
Harald Welte8f0ed552010-05-11 21:53:49 +02001321#define OML_STR "Organization & Maintenance Link\n"
1322#define IPA_STR "ip.access Specific Options\n"
1323
Harald Welte8175e952009-10-20 00:22:00 +02001324DEFUN(cfg_bts_stream_id,
1325 cfg_bts_stream_id_cmd,
1326 "oml ip.access stream_id <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001327 OML_STR IPA_STR
Harald Welte8175e952009-10-20 00:22:00 +02001328 "Set the ip.access Stream ID of the OML link of this BTS\n")
1329{
1330 struct gsm_bts *bts = vty->index;
1331 int stream_id = atoi(argv[0]);
1332
1333 if (!is_ipaccess_bts(bts)) {
1334 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1335 return CMD_WARNING;
1336 }
1337
1338 bts->oml_tei = stream_id;
1339
1340 return CMD_SUCCESS;
1341}
1342
Harald Welte8f0ed552010-05-11 21:53:49 +02001343#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte8175e952009-10-20 00:22:00 +02001344
Harald Welte42581822009-08-08 16:12:58 +02001345DEFUN(cfg_bts_oml_e1,
1346 cfg_bts_oml_e1_cmd,
1347 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001348 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001349 "E1 interface to be used for OML\n")
1350{
1351 struct gsm_bts *bts = vty->index;
1352
1353 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1354
1355 return CMD_SUCCESS;
1356}
1357
1358
1359DEFUN(cfg_bts_oml_e1_tei,
1360 cfg_bts_oml_e1_tei_cmd,
1361 "oml e1 tei <0-63>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001362 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001363 "Set the TEI to be used for OML")
1364{
1365 struct gsm_bts *bts = vty->index;
1366
1367 bts->oml_tei = atoi(argv[0]);
1368
1369 return CMD_SUCCESS;
1370}
1371
Harald Welte7a8fa412009-08-10 13:48:16 +02001372DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1373 "channel allocator (ascending|descending)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001374 "Channnel Allocator\n" "Channel Allocator\n"
1375 "Allocate Timeslots and Transceivers in ascending order\n"
1376 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte7a8fa412009-08-10 13:48:16 +02001377{
1378 struct gsm_bts *bts = vty->index;
1379
1380 if (!strcmp(argv[0], "ascending"))
1381 bts->chan_alloc_reverse = 0;
1382 else
1383 bts->chan_alloc_reverse = 1;
1384
1385 return CMD_SUCCESS;
1386}
1387
Harald Welte8f0ed552010-05-11 21:53:49 +02001388#define RACH_STR "Random Access Control Channel\n"
1389
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001390DEFUN(cfg_bts_rach_tx_integer,
1391 cfg_bts_rach_tx_integer_cmd,
1392 "rach tx integer <0-15>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001393 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001394 "Set the raw tx integer value in RACH Control parameters IE")
1395{
1396 struct gsm_bts *bts = vty->index;
1397 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1398 return CMD_SUCCESS;
1399}
1400
1401DEFUN(cfg_bts_rach_max_trans,
1402 cfg_bts_rach_max_trans_cmd,
1403 "rach max transmission (1|2|4|7)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001404 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001405 "Set the maximum number of RACH burst transmissions")
1406{
1407 struct gsm_bts *bts = vty->index;
1408 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1409 return CMD_SUCCESS;
1410}
1411
Harald Welte8f0ed552010-05-11 21:53:49 +02001412#define NM_STR "Network Management\n"
1413
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001414DEFUN(cfg_bts_rach_nm_b_thresh,
1415 cfg_bts_rach_nm_b_thresh_cmd,
1416 "rach nm busy threshold <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001417 RACH_STR NM_STR
1418 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001419{
1420 struct gsm_bts *bts = vty->index;
1421 bts->rach_b_thresh = atoi(argv[0]);
1422 return CMD_SUCCESS;
1423}
1424
1425DEFUN(cfg_bts_rach_nm_ldavg,
1426 cfg_bts_rach_nm_ldavg_cmd,
1427 "rach nm load average <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001428 RACH_STR NM_STR
1429 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001430{
1431 struct gsm_bts *bts = vty->index;
1432 bts->rach_ldavg_slots = atoi(argv[0]);
1433 return CMD_SUCCESS;
1434}
1435
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001436DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1437 "cell barred (0|1)",
1438 "Should this cell be barred from access?")
1439{
1440 struct gsm_bts *bts = vty->index;
1441
Harald Welte71355012009-12-21 23:08:18 +01001442 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001443
1444 return CMD_SUCCESS;
1445}
1446
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08001447DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1448 "rach emergency call allowed (0|1)",
1449 "Should this cell allow emergency calls?")
1450{
1451 struct gsm_bts *bts = vty->index;
1452
1453 if (atoi(argv[0]) == 0)
1454 bts->si_common.rach_control.t2 |= 0x4;
1455 else
1456 bts->si_common.rach_control.t2 &= ~0x4;
1457
1458 return CMD_SUCCESS;
1459}
1460
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001461DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1462 "ms max power <0-40>",
1463 "Maximum transmit power of the MS")
1464{
1465 struct gsm_bts *bts = vty->index;
1466
1467 bts->ms_max_power = atoi(argv[0]);
1468
1469 return CMD_SUCCESS;
1470}
1471
Harald Welte73225282009-12-12 18:17:25 +01001472DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1473 "cell reselection hysteresis <0-14>",
1474 "Cell Re-Selection Hysteresis in dB")
1475{
1476 struct gsm_bts *bts = vty->index;
1477
1478 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1479
1480 return CMD_SUCCESS;
1481}
1482
1483DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1484 "rxlev access min <0-63>",
1485 "Minimum RxLev needed for cell access (better than -110dBm)")
1486{
1487 struct gsm_bts *bts = vty->index;
1488
1489 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1490
1491 return CMD_SUCCESS;
1492}
1493
Harald Welte (local)efc92312009-08-14 23:09:25 +02001494DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1495 "periodic location update <0-1530>",
1496 "Periodic Location Updating Interval in Minutes")
1497{
1498 struct gsm_bts *bts = vty->index;
1499
Harald Weltea43f7892009-12-01 18:04:30 +05301500 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)efc92312009-08-14 23:09:25 +02001501
1502 return CMD_SUCCESS;
1503}
1504
Harald Welte8f0ed552010-05-11 21:53:49 +02001505#define GPRS_TEXT "GPRS Packet Network\n"
1506
Harald Welteaf387632010-03-14 23:30:30 +08001507DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welte57ba7e32010-04-18 14:00:26 +02001508 "gprs cell bvci <2-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001509 GPRS_TEXT
1510 "GPRS Cell Settings\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001511 "GPRS BSSGP VC Identifier")
1512{
1513 struct gsm_bts *bts = vty->index;
1514
Harald Welte4511d892010-04-18 15:51:20 +02001515 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001516 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1517 return CMD_WARNING;
1518 }
1519
Harald Welte97a282b2010-03-14 15:37:43 +08001520 bts->gprs.cell.bvci = atoi(argv[0]);
1521
1522 return CMD_SUCCESS;
1523}
1524
Harald Weltea5731cf2010-03-22 11:48:36 +08001525DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1526 "gprs nsei <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001527 GPRS_TEXT
Harald Weltea5731cf2010-03-22 11:48:36 +08001528 "GPRS NS Entity Identifier")
1529{
1530 struct gsm_bts *bts = vty->index;
1531
Harald Welte4511d892010-04-18 15:51:20 +02001532 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltea5731cf2010-03-22 11:48:36 +08001533 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1534 return CMD_WARNING;
1535 }
1536
1537 bts->gprs.nse.nsei = atoi(argv[0]);
1538
1539 return CMD_SUCCESS;
1540}
1541
Harald Welte8f0ed552010-05-11 21:53:49 +02001542#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1543 "NSVC Logical Number\n"
Harald Weltea5731cf2010-03-22 11:48:36 +08001544
Harald Welte97a282b2010-03-14 15:37:43 +08001545DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1546 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001547 GPRS_TEXT NSVC_TEXT
1548 "NS Virtual Connection Identifier\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001549 "GPRS NS VC Identifier")
1550{
1551 struct gsm_bts *bts = vty->index;
1552 int idx = atoi(argv[0]);
1553
Harald Welte4511d892010-04-18 15:51:20 +02001554 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001555 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1556 return CMD_WARNING;
1557 }
1558
Harald Welte97a282b2010-03-14 15:37:43 +08001559 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1560
1561 return CMD_SUCCESS;
1562}
1563
Harald Welteaf387632010-03-14 23:30:30 +08001564DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1565 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001566 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001567 "GPRS NS Local UDP Port")
1568{
1569 struct gsm_bts *bts = vty->index;
1570 int idx = atoi(argv[0]);
1571
Harald Welte4511d892010-04-18 15:51:20 +02001572 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001573 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1574 return CMD_WARNING;
1575 }
1576
Harald Welteaf387632010-03-14 23:30:30 +08001577 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1578
1579 return CMD_SUCCESS;
1580}
1581
1582DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1583 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001584 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001585 "GPRS NS Remote UDP Port")
1586{
1587 struct gsm_bts *bts = vty->index;
1588 int idx = atoi(argv[0]);
1589
Harald Welte4511d892010-04-18 15:51:20 +02001590 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001591 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1592 return CMD_WARNING;
1593 }
1594
Harald Welteaf387632010-03-14 23:30:30 +08001595 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1596
1597 return CMD_SUCCESS;
1598}
1599
1600DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1601 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte8f0ed552010-05-11 21:53:49 +02001602 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001603 "GPRS NS Remote IP Address")
1604{
1605 struct gsm_bts *bts = vty->index;
1606 int idx = atoi(argv[0]);
1607 struct in_addr ia;
1608
Harald Welte4511d892010-04-18 15:51:20 +02001609 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001610 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1611 return CMD_WARNING;
1612 }
1613
Harald Welteaf387632010-03-14 23:30:30 +08001614 inet_aton(argv[1], &ia);
1615 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1616
1617 return CMD_SUCCESS;
1618}
1619
Harald Welte615e9562010-05-11 23:50:21 +02001620DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1621 "gprs ns timer " NS_TIMERS " <0-255>",
1622 GPRS_TEXT "Network Service\n"
1623 "Network Service Timer\n"
1624 NS_TIMERS_HELP "Timer Value\n")
1625{
1626 struct gsm_bts *bts = vty->index;
1627 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1628 int val = atoi(argv[1]);
1629
1630 if (bts->gprs.mode == BTS_GPRS_NONE) {
1631 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1632 return CMD_WARNING;
1633 }
1634
1635 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1636 return CMD_WARNING;
1637
1638 bts->gprs.nse.timer[idx] = val;
1639
1640 return CMD_SUCCESS;
1641}
1642
1643#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)"
1644#define BSSGP_TIMERS_HELP ""
1645
1646DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1647 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1648 GPRS_TEXT "Cell / BSSGP\n"
1649 "Cell/BSSGP Timer\n"
1650 BSSGP_TIMERS_HELP "Timer Value\n")
1651{
1652 struct gsm_bts *bts = vty->index;
1653 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1654 int val = atoi(argv[1]);
1655
1656 if (bts->gprs.mode == BTS_GPRS_NONE) {
1657 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1658 return CMD_WARNING;
1659 }
1660
1661 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
1662 return CMD_WARNING;
1663
1664 bts->gprs.cell.timer[idx] = val;
1665
1666 return CMD_SUCCESS;
1667}
1668
Harald Welte97a282b2010-03-14 15:37:43 +08001669DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1670 "gprs routing area <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001671 GPRS_TEXT
Harald Welte97a282b2010-03-14 15:37:43 +08001672 "GPRS Routing Area Code")
1673{
1674 struct gsm_bts *bts = vty->index;
1675
Harald Welte4511d892010-04-18 15:51:20 +02001676 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001677 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1678 return CMD_WARNING;
1679 }
1680
Harald Welte97a282b2010-03-14 15:37:43 +08001681 bts->gprs.rac = atoi(argv[0]);
1682
1683 return CMD_SUCCESS;
1684}
1685
Harald Welte4511d892010-04-18 15:51:20 +02001686DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
1687 "gprs mode (none|gprs|egprs)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001688 GPRS_TEXT
1689 "GPRS Mode for this BTS\n"
1690 "GPRS Disabled on this BTS\n"
1691 "GPRS Enabled on this BTS\n"
1692 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welteaf387632010-03-14 23:30:30 +08001693{
1694 struct gsm_bts *bts = vty->index;
1695
Harald Welte4511d892010-04-18 15:51:20 +02001696 bts->gprs.mode = bts_gprs_mode_parse(argv[0]);
Harald Welteaf387632010-03-14 23:30:30 +08001697
1698 return CMD_SUCCESS;
1699}
1700
Harald Welte8f0ed552010-05-11 21:53:49 +02001701#define TRX_TEXT "Radio Transceiver\n"
Harald Welte7a8fa412009-08-10 13:48:16 +02001702
Harald Welte5258fc42009-03-28 19:07:53 +00001703/* per TRX configuration */
1704DEFUN(cfg_trx,
1705 cfg_trx_cmd,
1706 "trx TRX_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001707 TRX_TEXT
Harald Welte5258fc42009-03-28 19:07:53 +00001708 "Select a TRX to configure")
1709{
1710 int trx_nr = atoi(argv[0]);
1711 struct gsm_bts *bts = vty->index;
1712 struct gsm_bts_trx *trx;
1713
Harald Weltee441d9c2009-06-21 16:17:15 +02001714 if (trx_nr > bts->num_trx) {
1715 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1716 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001717 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001718 } else if (trx_nr == bts->num_trx) {
1719 /* we need to allocate a new one */
1720 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001721 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001722 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001723
Harald Weltee441d9c2009-06-21 16:17:15 +02001724 if (!trx)
1725 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00001726
1727 vty->index = trx;
1728 vty->node = TRX_NODE;
1729
1730 return CMD_SUCCESS;
1731}
1732
1733DEFUN(cfg_trx_arfcn,
1734 cfg_trx_arfcn_cmd,
1735 "arfcn <1-1024>",
1736 "Set the ARFCN for this TRX\n")
1737{
1738 int arfcn = atoi(argv[0]);
1739 struct gsm_bts_trx *trx = vty->index;
1740
1741 /* FIXME: check if this ARFCN is supported by this TRX */
1742
1743 trx->arfcn = arfcn;
1744
1745 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1746 /* FIXME: use OML layer to update the ARFCN */
1747 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
1748
1749 return CMD_SUCCESS;
1750}
1751
Harald Welte (local)7b37d972009-12-27 20:56:38 +01001752DEFUN(cfg_trx_nominal_power,
1753 cfg_trx_nominal_power_cmd,
1754 "nominal power <0-100>",
1755 "Nominal TRX RF Power in dB\n")
1756{
1757 struct gsm_bts_trx *trx = vty->index;
1758
1759 trx->nominal_power = atoi(argv[0]);
1760
1761 return CMD_SUCCESS;
1762}
1763
Harald Weltefcd24452009-06-20 18:15:19 +02001764DEFUN(cfg_trx_max_power_red,
1765 cfg_trx_max_power_red_cmd,
1766 "max_power_red <0-100>",
1767 "Reduction of maximum BS RF Power in dB\n")
1768{
1769 int maxpwr_r = atoi(argv[0]);
1770 struct gsm_bts_trx *trx = vty->index;
Harald Welte61a83b22009-11-18 09:20:22 +01001771 int upper_limit = 24; /* default 12.21 max power red. */
Harald Weltefcd24452009-06-20 18:15:19 +02001772
1773 /* FIXME: check if our BTS type supports more than 12 */
1774 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
1775 vty_out(vty, "%% Power %d dB is not in the valid range%s",
1776 maxpwr_r, VTY_NEWLINE);
1777 return CMD_WARNING;
1778 }
1779 if (maxpwr_r & 1) {
1780 vty_out(vty, "%% Power %d dB is not an even value%s",
1781 maxpwr_r, VTY_NEWLINE);
1782 return CMD_WARNING;
1783 }
1784
1785 trx->max_power_red = maxpwr_r;
1786
1787 /* FIXME: make sure we update this using OML */
1788
1789 return CMD_SUCCESS;
1790}
1791
Harald Welte42581822009-08-08 16:12:58 +02001792DEFUN(cfg_trx_rsl_e1,
1793 cfg_trx_rsl_e1_cmd,
1794 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1795 "E1 interface to be used for RSL\n")
1796{
1797 struct gsm_bts_trx *trx = vty->index;
1798
1799 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
1800
1801 return CMD_SUCCESS;
1802}
1803
1804DEFUN(cfg_trx_rsl_e1_tei,
1805 cfg_trx_rsl_e1_tei_cmd,
1806 "rsl e1 tei <0-63>",
1807 "Set the TEI to be used for RSL")
1808{
1809 struct gsm_bts_trx *trx = vty->index;
1810
1811 trx->rsl_tei = atoi(argv[0]);
1812
1813 return CMD_SUCCESS;
1814}
1815
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01001816DEFUN(cfg_trx_rf_locked,
1817 cfg_trx_rf_locked_cmd,
1818 "rf_locked (0|1)",
1819 "Turn off RF of the TRX.\n")
1820{
1821 int locked = atoi(argv[0]);
1822 struct gsm_bts_trx *trx = vty->index;
1823
1824 gsm_trx_lock_rf(trx, locked);
1825 return CMD_SUCCESS;
1826}
Harald Welte42581822009-08-08 16:12:58 +02001827
Harald Welte5258fc42009-03-28 19:07:53 +00001828/* per TS configuration */
1829DEFUN(cfg_ts,
1830 cfg_ts_cmd,
Harald Welte42581822009-08-08 16:12:58 +02001831 "timeslot <0-7>",
Harald Welte5258fc42009-03-28 19:07:53 +00001832 "Select a Timeslot to configure")
1833{
1834 int ts_nr = atoi(argv[0]);
1835 struct gsm_bts_trx *trx = vty->index;
1836 struct gsm_bts_trx_ts *ts;
1837
1838 if (ts_nr >= TRX_NR_TS) {
1839 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
1840 TRX_NR_TS, VTY_NEWLINE);
1841 return CMD_WARNING;
1842 }
1843
1844 ts = &trx->ts[ts_nr];
1845
1846 vty->index = ts;
1847 vty->node = TS_NODE;
1848
1849 return CMD_SUCCESS;
1850}
1851
Harald Weltea6fd58e2009-08-07 00:25:23 +02001852DEFUN(cfg_ts_pchan,
1853 cfg_ts_pchan_cmd,
1854 "phys_chan_config PCHAN",
1855 "Physical Channel configuration (TCH/SDCCH/...)")
1856{
1857 struct gsm_bts_trx_ts *ts = vty->index;
1858 int pchanc;
1859
1860 pchanc = gsm_pchan_parse(argv[0]);
1861 if (pchanc < 0)
1862 return CMD_WARNING;
1863
1864 ts->pchan = pchanc;
1865
1866 return CMD_SUCCESS;
1867}
1868
1869DEFUN(cfg_ts_e1_subslot,
1870 cfg_ts_e1_subslot_cmd,
Harald Welte42581822009-08-08 16:12:58 +02001871 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltea6fd58e2009-08-07 00:25:23 +02001872 "E1 sub-slot connected to this on-air timeslot")
1873{
1874 struct gsm_bts_trx_ts *ts = vty->index;
1875
Harald Welte42581822009-08-08 16:12:58 +02001876 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Weltea6fd58e2009-08-07 00:25:23 +02001877
1878 return CMD_SUCCESS;
1879}
Harald Welte5258fc42009-03-28 19:07:53 +00001880
Holger Hans Peter Freythere1ffc082010-04-10 00:08:28 +02001881extern int bsc_vty_init_extra(struct gsm_network *net);
1882
Harald Welte68628e82009-03-10 12:17:57 +00001883int bsc_vty_init(struct gsm_network *net)
1884{
1885 gsmnet = net;
1886
1887 cmd_init(1);
1888 vty_init();
1889
Harald Welteb4d5b172010-05-12 16:10:35 +00001890 install_element_ve(&show_net_cmd);
1891 install_element_ve(&show_bts_cmd);
1892 install_element_ve(&show_trx_cmd);
1893 install_element_ve(&show_ts_cmd);
1894 install_element_ve(&show_lchan_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00001895
Harald Welteb4d5b172010-05-12 16:10:35 +00001896 install_element_ve(&show_e1drv_cmd);
1897 install_element_ve(&show_e1line_cmd);
1898 install_element_ve(&show_e1ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001899
Harald Welteb4d5b172010-05-12 16:10:35 +00001900 install_element_ve(&show_paging_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001901
Holger Hans Peter Freyther3c712322010-04-06 11:55:37 +02001902 openbsc_vty_add_cmds();
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +01001903
Harald Welte5013b2a2009-08-07 13:29:14 +02001904 install_element(CONFIG_NODE, &cfg_net_cmd);
1905 install_node(&net_node, config_write_net);
1906 install_default(GSMNET_NODE);
Harald Welte42581822009-08-08 16:12:58 +02001907 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02001908 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
1909 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
1910 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)69de3972009-08-12 14:42:23 +02001911 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte1085c092009-11-18 20:33:19 +01001912 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Welte4381cfe2009-08-30 15:47:06 +09001913 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001914 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welteeab84a12009-12-13 10:53:12 +01001915 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte3d23db42009-12-14 17:49:15 +01001916 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Weltebc814502009-12-19 21:41:52 +01001917 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Welteb720bd32009-12-21 16:51:50 +01001918 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
1919 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
1920 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
1921 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
1922 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
1923 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001924 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01001925 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
1926 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
1927 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
1928 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
1929 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
1930 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
1931 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
1932 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
1933 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
1934 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02001935
1936 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02001937 install_node(&bts_node, config_write_bts);
Harald Welte68628e82009-03-10 12:17:57 +00001938 install_default(BTS_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001939 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02001940 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001941 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001942 install_element(BTS_NODE, &cfg_bts_lac_cmd);
1943 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001944 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00001945 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte8175e952009-10-20 00:22:00 +02001946 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001947 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
1948 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02001949 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001950 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
1951 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001952 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
1953 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001954 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08001955 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001956 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)efc92312009-08-14 23:09:25 +02001957 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welte73225282009-12-12 18:17:25 +01001958 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
1959 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Welte4511d892010-04-18 15:51:20 +02001960 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02001961 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08001962 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
1963 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02001964 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Weltea5731cf2010-03-22 11:48:36 +08001965 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08001966 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welteaf387632010-03-14 23:30:30 +08001967 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
1968 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
1969 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001970
Harald Welte5258fc42009-03-28 19:07:53 +00001971 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001972 install_node(&trx_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001973 install_default(TRX_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001974 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte (local)7b37d972009-12-27 20:56:38 +01001975 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02001976 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001977 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
1978 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01001979 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001980
Harald Welte5258fc42009-03-28 19:07:53 +00001981 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001982 install_node(&ts_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001983 install_default(TS_NODE);
Harald Weltea6fd58e2009-08-07 00:25:23 +02001984 install_element(TS_NODE, &cfg_ts_pchan_cmd);
1985 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001986
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +02001987 bsc_vty_init_extra(net);
Harald Welte40f82892009-05-23 17:31:39 +00001988
Harald Welte68628e82009-03-10 12:17:57 +00001989 return 0;
1990}