blob: a308ec475eb53c3ca626e67e967526de5cf0e8cf [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
Harald Weltebd9591f2010-05-19 19:45:32 +020025#include <osmocom/vty/command.h>
26#include <osmocom/vty/buffer.h>
27#include <osmocom/vty/vty.h>
28#include <osmocom/vty/logging.h>
29#include <osmocom/vty/telnet_interface.h>
Harald Welte59b04682009-06-10 05:40:52 +080030
31#include <arpa/inet.h>
32
Harald Weltef4625b12010-02-20 16:24:02 +010033#include <osmocore/linuxlist.h>
Harald Welte59b04682009-06-10 05:40:52 +080034#include <openbsc/gsm_data.h>
Harald Welte59b04682009-06-10 05:40:52 +080035#include <openbsc/e1_input.h>
36#include <openbsc/abis_nm.h>
Harald Weltef4625b12010-02-20 16:24:02 +010037#include <osmocore/gsm_utils.h>
Harald Weltefe96f382009-12-22 13:09:29 +010038#include <openbsc/chan_alloc.h>
Harald Welte44007742009-12-22 21:43:14 +010039#include <openbsc/meas_rep.h>
Harald Welte59b04682009-06-10 05:40:52 +080040#include <openbsc/db.h>
Harald Weltef4625b12010-02-20 16:24:02 +010041#include <osmocore/talloc.h>
Holger Hans Peter Freytherb70d45b2010-04-06 11:55:37 +020042#include <openbsc/vty.h>
Harald Weltef45981f2010-05-12 20:28:04 +020043#include <openbsc/gprs_ns.h>
Harald Welte682ee5f2010-05-16 22:02:16 +020044#include <openbsc/debug.h>
Harald Welte59b04682009-06-10 05:40:52 +080045
Harald Welte10c29f62010-05-16 19:20:24 +020046#include "../bscconfig.h"
47
Harald Welted6b62e32010-05-12 17:19:53 +000048/* FIXME: this should go to some common file */
49static const struct value_string gprs_ns_timer_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020050 { 0, "tns-block" },
51 { 1, "tns-block-retries" },
52 { 2, "tns-reset" },
53 { 3, "tns-reset-retries" },
54 { 4, "tns-test" },
55 { 5, "tns-alive" },
56 { 6, "tns-alive-retries" },
57 { 0, NULL }
58};
59
Harald Welted6b62e32010-05-12 17:19:53 +000060static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020061 { 0, "blocking-timer" },
62 { 1, "blocking-retries" },
63 { 2, "unblocking-retries" },
64 { 3, "reset-timer" },
65 { 4, "reset-retries" },
66 { 5, "suspend-timer" },
67 { 6, "suspend-retries" },
68 { 7, "resume-timer" },
69 { 8, "resume-retries" },
70 { 9, "capability-update-timer" },
71 { 10, "capability-update-retries" },
72 { 0, NULL }
73};
74
Harald Weltee87eb462009-08-07 13:29:14 +020075struct cmd_node net_node = {
76 GSMNET_NODE,
77 "%s(network)#",
78 1,
79};
80
Harald Welte59b04682009-06-10 05:40:52 +080081struct cmd_node bts_node = {
82 BTS_NODE,
83 "%s(bts)#",
84 1,
85};
86
87struct cmd_node trx_node = {
88 TRX_NODE,
89 "%s(trx)#",
90 1,
91};
92
93struct cmd_node ts_node = {
94 TS_NODE,
95 "%s(ts)#",
96 1,
97};
98
Harald Welte61daf6d2010-05-27 13:39:40 +020099extern struct gsm_network *bsc_gsmnet;
100
Harald Welte40152872010-05-16 20:52:23 +0200101struct gsm_network *gsmnet_from_vty(struct vty *v)
102{
Harald Welte61daf6d2010-05-27 13:39:40 +0200103 /* In case we read from the config file, the vty->priv cannot
104 * point to a struct telnet_connection, and thus conn->priv
105 * will not point to the gsm_network structure */
106#if 0
Harald Welte40152872010-05-16 20:52:23 +0200107 struct telnet_connection *conn = v->priv;
108 return (struct gsm_network *) conn->priv;
Harald Welte61daf6d2010-05-27 13:39:40 +0200109#else
110 return bsc_gsmnet;
111#endif
Harald Welte40152872010-05-16 20:52:23 +0200112}
113
Harald Welte59b04682009-06-10 05:40:52 +0800114static int dummy_config_write(struct vty *v)
115{
116 return CMD_SUCCESS;
117}
118
119static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
120{
121 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
122 nm_opstate_name(nms->operational), nms->administrative,
123 nm_avail_name(nms->availability), VTY_NEWLINE);
124}
125
Harald Weltefe96f382009-12-22 13:09:29 +0100126static void dump_pchan_load_vty(struct vty *vty, char *prefix,
127 const struct pchan_load *pl)
128{
129 int i;
130
131 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
132 const struct load_counter *lc = &pl->pchan[i];
133 unsigned int percent;
134
135 if (lc->total == 0)
136 continue;
137
138 percent = (lc->used * 100) / lc->total;
139
140 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
141 gsm_pchan_name(i), percent, lc->used, lc->total,
142 VTY_NEWLINE);
143 }
144}
145
Harald Welte59b04682009-06-10 05:40:52 +0800146static void net_dump_vty(struct vty *vty, struct gsm_network *net)
147{
Harald Weltefe96f382009-12-22 13:09:29 +0100148 struct pchan_load pl;
149
Harald Welte59b04682009-06-10 05:40:52 +0800150 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
151 "and has %u BTS%s", net->country_code, net->network_code,
152 net->num_bts, VTY_NEWLINE);
153 vty_out(vty, " Long network name: '%s'%s",
154 net->name_long, VTY_NEWLINE);
155 vty_out(vty, " Short network name: '%s'%s",
156 net->name_short, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200157 vty_out(vty, " Authentication policy: %s%s",
158 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100159 vty_out(vty, " Location updating reject cause: %u%s",
160 net->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900161 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
162 VTY_NEWLINE);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +0100163 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
164 VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100165 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
166 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100167 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
168 VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100169 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
170 VTY_NEWLINE);
Harald Weltefe96f382009-12-22 13:09:29 +0100171 network_chan_load(&pl, net);
172 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
173 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800174}
175
176DEFUN(show_net, show_net_cmd, "show network",
177 SHOW_STR "Display information about a GSM NETWORK\n")
178{
Harald Welte40152872010-05-16 20:52:23 +0200179 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800180 net_dump_vty(vty, net);
181
182 return CMD_SUCCESS;
183}
184
185static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
186{
187 struct e1inp_line *line;
188
189 if (!e1l) {
190 vty_out(vty, " None%s", VTY_NEWLINE);
191 return;
192 }
193
194 line = e1l->ts->line;
195
196 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
197 line->num, line->driver->name, e1l->ts->num,
198 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
199 vty_out(vty, " E1 TEI %u, SAPI %u%s",
200 e1l->tei, e1l->sapi, VTY_NEWLINE);
201}
202
203static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
204{
Harald Weltefe96f382009-12-22 13:09:29 +0100205 struct pchan_load pl;
206
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200207 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200208 "BSIC %u, TSC %u and %u TRX%s",
209 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200210 bts->cell_identity,
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200211 bts->location_area_code, bts->bsic, bts->tsc,
Harald Welte91afe4c2009-06-20 18:15:19 +0200212 bts->num_trx, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200213 vty_out(vty, "Description: %s%s",
214 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte8e9d1792009-12-12 15:38:16 +0100215 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100216 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte8e9d1792009-12-12 15:38:16 +0100217 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
218 VTY_NEWLINE);
219 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welteb761bf82009-12-12 18:17:25 +0100220 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100221 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
222 VTY_NEWLINE);
223 vty_out(vty, "RACH Max transmissions: %u%s",
224 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
225 VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100226 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200227 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800228 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200229 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800230 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200231 bts->oml_tei, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800232 vty_out(vty, " NM State: ");
233 net_dump_nmstate(vty, &bts->nm_state);
234 vty_out(vty, " Site Mgr NM State: ");
235 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
236 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
237 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200238 if (!is_ipaccess_bts(bts)) {
239 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
240 e1isl_dump_vty(vty, bts->oml_link);
241 }
Harald Welte59b04682009-06-10 05:40:52 +0800242 /* FIXME: oml_link, chan_desc */
Harald Weltefe96f382009-12-22 13:09:29 +0100243 memset(&pl, 0, sizeof(pl));
244 bts_chan_load(&pl, bts);
245 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
246 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800247}
248
249DEFUN(show_bts, show_bts_cmd, "show bts [number]",
250 SHOW_STR "Display information about a BTS\n"
251 "BTS number")
252{
Harald Welte40152872010-05-16 20:52:23 +0200253 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800254 int bts_nr;
255
256 if (argc != 0) {
257 /* use the BTS number that the user has specified */
258 bts_nr = atoi(argv[0]);
259 if (bts_nr > net->num_bts) {
260 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
261 VTY_NEWLINE);
262 return CMD_WARNING;
263 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200264 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800265 return CMD_SUCCESS;
266 }
267 /* print all BTS's */
268 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200269 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800270
271 return CMD_SUCCESS;
272}
273
Harald Welte62868882009-08-08 16:12:58 +0200274/* utility functions */
275static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
276 const char *ts, const char *ss)
277{
278 e1_link->e1_nr = atoi(line);
279 e1_link->e1_ts = atoi(ts);
280 if (!strcmp(ss, "full"))
281 e1_link->e1_ts_ss = 255;
282 else
283 e1_link->e1_ts_ss = atoi(ss);
284}
285
286static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
287 const char *prefix)
288{
289 if (!e1_link->e1_ts)
290 return;
291
292 if (e1_link->e1_ts_ss == 255)
293 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
294 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
295 else
296 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
297 prefix, e1_link->e1_nr, e1_link->e1_ts,
298 e1_link->e1_ts_ss, VTY_NEWLINE);
299}
300
301
Harald Welte97ceef92009-08-06 19:06:46 +0200302static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
303{
Harald Welte62868882009-08-08 16:12:58 +0200304 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
305 if (ts->pchan != GSM_PCHAN_NONE)
306 vty_out(vty, " phys_chan_config %s%s",
307 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200308 vty_out(vty, " hopping enabled %u%s",
309 ts->hopping.enabled, VTY_NEWLINE);
310 if (ts->hopping.enabled) {
311 unsigned int i;
312 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200313 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200314 vty_out(vty, " hopping maio %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200315 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200316 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
317 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
318 continue;
319 vty_out(vty, " hopping arfcn add %u%s",
320 i, VTY_NEWLINE);
321 }
322 } else
Harald Welte62868882009-08-08 16:12:58 +0200323 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte97ceef92009-08-06 19:06:46 +0200324}
325
326static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
327{
328 int i;
329
Harald Weltee87eb462009-08-07 13:29:14 +0200330 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200331 if (trx->description)
332 vty_out(vty, " description %s%s", trx->description,
333 VTY_NEWLINE);
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200334 vty_out(vty, " rf_locked %u%s",
335 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
336 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200337 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +0100338 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200339 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200340 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
341 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200342
343 for (i = 0; i < TRX_NR_TS; i++)
344 config_write_ts_single(vty, &trx->ts[i]);
345}
346
Harald Weltea9251762010-05-11 23:50:21 +0200347static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
348{
349 unsigned int i;
350 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
351 VTY_NEWLINE);
352 if (bts->gprs.mode == BTS_GPRS_NONE)
353 return;
354
355 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
356 VTY_NEWLINE);
357 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
358 VTY_NEWLINE);
359 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
360 vty_out(vty, " gprs cell timer %s %u%s",
361 get_value_string(gprs_bssgp_cfg_strs, i),
362 bts->gprs.cell.timer[i], VTY_NEWLINE);
363 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
364 VTY_NEWLINE);
365 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
366 vty_out(vty, " gprs ns timer %s %u%s",
367 get_value_string(gprs_ns_timer_strs, i),
368 bts->gprs.nse.timer[i], VTY_NEWLINE);
369 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
370 struct gsm_bts_gprs_nsvc *nsvc =
371 &bts->gprs.nsvc[i];
372 struct in_addr ia;
373
374 ia.s_addr = htonl(nsvc->remote_ip);
375 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
376 nsvc->nsvci, VTY_NEWLINE);
377 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
378 nsvc->local_port, VTY_NEWLINE);
379 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
380 nsvc->remote_port, VTY_NEWLINE);
381 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
382 inet_ntoa(ia), VTY_NEWLINE);
383 }
384}
385
Harald Welte97ceef92009-08-06 19:06:46 +0200386static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
387{
388 struct gsm_bts_trx *trx;
389
Harald Weltee87eb462009-08-07 13:29:14 +0200390 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
391 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200392 if (bts->description)
393 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200394 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freyther6d82b7c2009-11-19 16:38:49 +0100395 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200396 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200397 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200398 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
399 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200400 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100401 vty_out(vty, " cell reselection hysteresis %u%s",
402 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
403 vty_out(vty, " rxlev access min %u%s",
404 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Harald Weltea54a2bb2009-12-01 18:04:30 +0530405 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200406 vty_out(vty, " periodic location update %u%s",
Harald Weltea54a2bb2009-12-01 18:04:30 +0530407 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200408 vty_out(vty, " channel allocator %s%s",
409 bts->chan_alloc_reverse ? "descending" : "ascending",
410 VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100411 vty_out(vty, " rach tx integer %u%s",
412 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
413 vty_out(vty, " rach max transmission %u%s",
414 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
415 VTY_NEWLINE);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800416
417 if (bts->rach_b_thresh != -1)
418 vty_out(vty, " rach nm busy threshold %u%s",
419 bts->rach_b_thresh, VTY_NEWLINE);
420 if (bts->rach_ldavg_slots != -1)
421 vty_out(vty, " rach nm load average %u%s",
422 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100423 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200424 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +0800425 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
426 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200427 if (is_ipaccess_bts(bts)) {
Harald Weltee87eb462009-08-07 13:29:14 +0200428 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200429 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200430 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
431 } else {
Harald Welte62868882009-08-08 16:12:58 +0200432 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
433 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
434 }
Harald Weltea9251762010-05-11 23:50:21 +0200435 config_write_bts_gprs(vty, bts);
Harald Welte97ceef92009-08-06 19:06:46 +0200436
437 llist_for_each_entry(trx, &bts->trx_list, list)
438 config_write_trx_single(vty, trx);
439}
440
441static int config_write_bts(struct vty *v)
442{
Harald Welte40152872010-05-16 20:52:23 +0200443 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte97ceef92009-08-06 19:06:46 +0200444 struct gsm_bts *bts;
445
446 llist_for_each_entry(bts, &gsmnet->bts_list, list)
447 config_write_bts_single(v, bts);
448
449 return CMD_SUCCESS;
450}
451
Harald Weltee87eb462009-08-07 13:29:14 +0200452static int config_write_net(struct vty *vty)
453{
Harald Welte40152872010-05-16 20:52:23 +0200454 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
455
Harald Weltee87eb462009-08-07 13:29:14 +0200456 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200457 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200458 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200459 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
460 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200461 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100462 vty_out(vty, " location updating reject cause %u%s",
463 gsmnet->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900464 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freyther6b4f5462009-11-19 16:37:48 +0100465 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100466 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
467 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100468 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100469 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Weltea8062f12009-12-21 16:51:50 +0100470 vty_out(vty, " handover window rxlev averaging %u%s",
471 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
472 vty_out(vty, " handover window rxqual averaging %u%s",
473 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
474 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
475 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
476 vty_out(vty, " handover power budget interval %u%s",
477 gsmnet->handover.pwr_interval, VTY_NEWLINE);
478 vty_out(vty, " handover power budget hysteresis %u%s",
479 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
480 vty_out(vty, " handover maximum distance %u%s",
481 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +0100482 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100483 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
484 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
485 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
486 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
487 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
488 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
489 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
490 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
491 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
492 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200493
494 return CMD_SUCCESS;
495}
Harald Welte97ceef92009-08-06 19:06:46 +0200496
Harald Welte59b04682009-06-10 05:40:52 +0800497static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
498{
499 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
500 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200501 vty_out(vty, "Description: %s%s",
502 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200503 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200504 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200505 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200506 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800507 vty_out(vty, " NM State: ");
508 net_dump_nmstate(vty, &trx->nm_state);
509 vty_out(vty, " Baseband Transceiver NM State: ");
510 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200511 if (is_ipaccess_bts(trx->bts)) {
512 vty_out(vty, " ip.access stream ID: 0x%02x%s",
513 trx->rsl_tei, VTY_NEWLINE);
514 } else {
515 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
516 e1isl_dump_vty(vty, trx->rsl_link);
517 }
Harald Welte59b04682009-06-10 05:40:52 +0800518}
519
520DEFUN(show_trx,
521 show_trx_cmd,
522 "show trx [bts_nr] [trx_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200523 SHOW_STR "Display information about a TRX\n"
524 "BTS Number\n"
525 "TRX Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800526{
Harald Welte40152872010-05-16 20:52:23 +0200527 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800528 struct gsm_bts *bts = NULL;
529 struct gsm_bts_trx *trx;
530 int bts_nr, trx_nr;
531
532 if (argc >= 1) {
533 /* use the BTS number that the user has specified */
534 bts_nr = atoi(argv[0]);
535 if (bts_nr >= net->num_bts) {
536 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
537 VTY_NEWLINE);
538 return CMD_WARNING;
539 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200540 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800541 }
542 if (argc >= 2) {
543 trx_nr = atoi(argv[1]);
544 if (trx_nr >= bts->num_trx) {
545 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
546 VTY_NEWLINE);
547 return CMD_WARNING;
548 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200549 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800550 trx_dump_vty(vty, trx);
551 return CMD_SUCCESS;
552 }
553 if (bts) {
554 /* print all TRX in this BTS */
555 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200556 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800557 trx_dump_vty(vty, trx);
558 }
559 return CMD_SUCCESS;
560 }
561
562 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200563 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800564 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200565 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800566 trx_dump_vty(vty, trx);
567 }
568 }
569
570 return CMD_SUCCESS;
571}
572
Harald Welte97ceef92009-08-06 19:06:46 +0200573
Harald Welte59b04682009-06-10 05:40:52 +0800574static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
575{
Harald Welte59b04682009-06-10 05:40:52 +0800576 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
577 ts->nr, ts->trx->nr, ts->trx->bts->nr,
578 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
579 vty_out(vty, " NM State: ");
580 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte87504212009-12-02 01:56:49 +0530581 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welte59b04682009-06-10 05:40:52 +0800582 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
583 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
584 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800585}
586
587DEFUN(show_ts,
588 show_ts_cmd,
589 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200590 SHOW_STR "Display information about a TS\n"
591 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800592{
Harald Welte40152872010-05-16 20:52:23 +0200593 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800594 struct gsm_bts *bts;
595 struct gsm_bts_trx *trx;
596 struct gsm_bts_trx_ts *ts;
597 int bts_nr, trx_nr, ts_nr;
598
599 if (argc >= 1) {
600 /* use the BTS number that the user has specified */
601 bts_nr = atoi(argv[0]);
602 if (bts_nr >= net->num_bts) {
603 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
604 VTY_NEWLINE);
605 return CMD_WARNING;
606 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200607 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800608 }
609 if (argc >= 2) {
610 trx_nr = atoi(argv[1]);
611 if (trx_nr >= bts->num_trx) {
612 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
613 VTY_NEWLINE);
614 return CMD_WARNING;
615 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200616 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800617 }
618 if (argc >= 3) {
619 ts_nr = atoi(argv[2]);
620 if (ts_nr >= TRX_NR_TS) {
621 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
622 VTY_NEWLINE);
623 return CMD_WARNING;
624 }
625 ts = &trx->ts[ts_nr];
626 ts_dump_vty(vty, ts);
627 return CMD_SUCCESS;
628 }
629 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200630 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800631 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200632 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800633 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
634 ts = &trx->ts[ts_nr];
635 ts_dump_vty(vty, ts);
636 }
637 }
638 }
639
640 return CMD_SUCCESS;
641}
642
Holger Hans Peter Freyther1dd0a1b2010-01-06 06:00:40 +0100643static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800644{
Harald Welte91afe4c2009-06-20 18:15:19 +0200645 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800646 subscr->authorized, VTY_NEWLINE);
647 if (subscr->name)
648 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
649 if (subscr->extension)
650 vty_out(vty, " Extension: %s%s", subscr->extension,
651 VTY_NEWLINE);
652 if (subscr->imsi)
653 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200654 if (subscr->tmsi != GSM_RESERVED_TMSI)
655 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200656 VTY_NEWLINE);
Sylvain Munaute5863a22009-12-27 19:29:28 +0100657
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200658 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800659}
660
Harald Welte44007742009-12-22 21:43:14 +0100661static void meas_rep_dump_uni_vty(struct vty *vty,
662 struct gsm_meas_rep_unidir *mru,
663 const char *prefix,
664 const char *dir)
665{
666 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
667 prefix, dir, rxlev2dbm(mru->full.rx_lev),
668 dir, rxlev2dbm(mru->sub.rx_lev));
669 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
670 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
671 VTY_NEWLINE);
672}
673
674static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
675 const char *prefix)
676{
677 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
678 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
679 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
680 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
681 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
682 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
683 VTY_NEWLINE);
684 if (mr->flags & MEAS_REP_F_MS_TO)
685 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
686 mr->ms_timing_offset, VTY_NEWLINE);
687 if (mr->flags & MEAS_REP_F_MS_L1)
688 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
689 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
690 if (mr->flags & MEAS_REP_F_DL_VALID)
691 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
692 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
693}
694
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800695static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte59b04682009-06-10 05:40:52 +0800696{
Harald Welte44007742009-12-22 21:43:14 +0100697 int idx;
698
Harald Welte59b04682009-06-10 05:40:52 +0800699 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 +0200700 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
Harald Welte (local)02204d02009-12-27 18:05:25 +0100701 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Harald Welte59b04682009-06-10 05:40:52 +0800702 VTY_NEWLINE);
Holger Hans Peter Freyther6e5c50f2010-06-28 17:09:29 +0800703 vty_out(vty, " Connection: %u, State: %s%s",
704 lchan->conn ? 1: 0,
Harald Welteab2534c2009-12-29 10:52:38 +0100705 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100706 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
707 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
708 - lchan->bs_power*2,
709 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
710 VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800711 if (lchan->conn && lchan->conn->subscr) {
Harald Welte59b04682009-06-10 05:40:52 +0800712 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800713 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte59b04682009-06-10 05:40:52 +0800714 } else
715 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte87504212009-12-02 01:56:49 +0530716 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
717 struct in_addr ia;
Holger Hans Peter Freythercec1ec52010-04-07 15:39:16 +0200718 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte87504212009-12-02 01:56:49 +0530719 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
720 inet_ntoa(ia), lchan->abis_ip.bound_port,
721 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
722 VTY_NEWLINE);
723 }
Harald Welte44007742009-12-22 21:43:14 +0100724
725 /* we want to report the last measurement report */
726 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
727 lchan->meas_rep_idx, 1);
728 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte59b04682009-06-10 05:40:52 +0800729}
730
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800731static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
732{
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800733 struct gsm_meas_rep *mr;
734 int idx;
735
736 /* we want to report the last measurement report */
737 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
738 lchan->meas_rep_idx, 1);
739 mr = &lchan->meas_rep[idx];
740
741 vty_out(vty, "Lchan: %u Timeslot: %u TRX: %u BTS: %u Type: %s - L1 MS Power: %u dBm "
742 "RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800743 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
744 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800745 mr->ms_l1.pwr,
746 rxlev2dbm(mr->dl.full.rx_lev),
747 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800748 VTY_NEWLINE);
749}
750
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800751static int lchan_summary(struct vty *vty, int argc, const char **argv,
752 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte59b04682009-06-10 05:40:52 +0800753{
Harald Welte40152872010-05-16 20:52:23 +0200754 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800755 struct gsm_bts *bts;
756 struct gsm_bts_trx *trx;
757 struct gsm_bts_trx_ts *ts;
758 struct gsm_lchan *lchan;
759 int bts_nr, trx_nr, ts_nr, lchan_nr;
760
761 if (argc >= 1) {
762 /* use the BTS number that the user has specified */
763 bts_nr = atoi(argv[0]);
764 if (bts_nr >= net->num_bts) {
765 vty_out(vty, "%% can't find BTS %s%s", argv[0],
766 VTY_NEWLINE);
767 return CMD_WARNING;
768 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200769 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800770 }
771 if (argc >= 2) {
772 trx_nr = atoi(argv[1]);
773 if (trx_nr >= bts->num_trx) {
774 vty_out(vty, "%% can't find TRX %s%s", argv[1],
775 VTY_NEWLINE);
776 return CMD_WARNING;
777 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200778 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800779 }
780 if (argc >= 3) {
781 ts_nr = atoi(argv[2]);
782 if (ts_nr >= TRX_NR_TS) {
783 vty_out(vty, "%% can't find TS %s%s", argv[2],
784 VTY_NEWLINE);
785 return CMD_WARNING;
786 }
787 ts = &trx->ts[ts_nr];
788 }
789 if (argc >= 4) {
790 lchan_nr = atoi(argv[3]);
791 if (lchan_nr >= TS_MAX_LCHAN) {
792 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
793 VTY_NEWLINE);
794 return CMD_WARNING;
795 }
796 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800797 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800798 return CMD_SUCCESS;
799 }
800 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200801 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800802 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200803 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800804 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
805 ts = &trx->ts[ts_nr];
806 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
807 lchan_nr++) {
808 lchan = &ts->lchan[lchan_nr];
809 if (lchan->type == GSM_LCHAN_NONE)
810 continue;
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800811 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800812 }
813 }
814 }
815 }
816
817 return CMD_SUCCESS;
818}
819
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800820
821DEFUN(show_lchan,
822 show_lchan_cmd,
823 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
824 SHOW_STR "Display information about a logical channel\n"
825 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
826 "Logical Channel Number\n")
827
828{
829 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
830}
831
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800832DEFUN(show_lchan_summary,
833 show_lchan_summary_cmd,
834 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
835 SHOW_STR "Display information about a logical channel\n"
836 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
837 "Logical Channel Number\n")
838{
839 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
840}
841
Harald Welte59b04682009-06-10 05:40:52 +0800842static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
843{
844 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
845}
846
847DEFUN(show_e1drv,
848 show_e1drv_cmd,
849 "show e1_driver",
850 SHOW_STR "Display information about available E1 drivers\n")
851{
852 struct e1inp_driver *drv;
853
854 llist_for_each_entry(drv, &e1inp_driver_list, list)
855 e1drv_dump_vty(vty, drv);
856
857 return CMD_SUCCESS;
858}
859
860static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
861{
862 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
863 line->num, line->name ? line->name : "",
864 line->driver->name, VTY_NEWLINE);
865}
866
867DEFUN(show_e1line,
868 show_e1line_cmd,
869 "show e1_line [line_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200870 SHOW_STR "Display information about a E1 line\n"
871 "E1 Line Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800872{
873 struct e1inp_line *line;
874
875 if (argc >= 1) {
876 int num = atoi(argv[0]);
877 llist_for_each_entry(line, &e1inp_line_list, list) {
878 if (line->num == num) {
879 e1line_dump_vty(vty, line);
880 return CMD_SUCCESS;
881 }
882 }
883 return CMD_WARNING;
884 }
885
886 llist_for_each_entry(line, &e1inp_line_list, list)
887 e1line_dump_vty(vty, line);
888
889 return CMD_SUCCESS;
890}
891
892static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
893{
Harald Welte62868882009-08-08 16:12:58 +0200894 if (ts->type == E1INP_TS_TYPE_NONE)
895 return;
Harald Welte59b04682009-06-10 05:40:52 +0800896 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
897 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
898 VTY_NEWLINE);
899}
900
901DEFUN(show_e1ts,
902 show_e1ts_cmd,
903 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200904 SHOW_STR "Display information about a E1 timeslot\n"
905 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800906{
Harald Welte49c79562009-11-17 06:12:16 +0100907 struct e1inp_line *line = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800908 struct e1inp_ts *ts;
909 int ts_nr;
910
911 if (argc == 0) {
912 llist_for_each_entry(line, &e1inp_line_list, list) {
913 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
914 ts = &line->ts[ts_nr];
915 e1ts_dump_vty(vty, ts);
916 }
917 }
918 return CMD_SUCCESS;
919 }
920 if (argc >= 1) {
921 int num = atoi(argv[0]);
922 llist_for_each_entry(line, &e1inp_line_list, list) {
923 if (line->num == num)
924 break;
925 }
926 if (!line || line->num != num) {
927 vty_out(vty, "E1 line %s is invalid%s",
928 argv[0], VTY_NEWLINE);
929 return CMD_WARNING;
930 }
931 }
932 if (argc >= 2) {
933 ts_nr = atoi(argv[1]);
934 if (ts_nr > NUM_E1_TS) {
935 vty_out(vty, "E1 timeslot %s is invalid%s",
936 argv[1], VTY_NEWLINE);
937 return CMD_WARNING;
938 }
939 ts = &line->ts[ts_nr];
940 e1ts_dump_vty(vty, ts);
941 return CMD_SUCCESS;
942 } else {
943 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
944 ts = &line->ts[ts_nr];
945 e1ts_dump_vty(vty, ts);
946 }
947 return CMD_SUCCESS;
948 }
949 return CMD_SUCCESS;
950}
951
952static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
953{
954 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
955 subscr_dump_vty(vty, pag->subscr);
956}
957
958static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
959{
960 struct gsm_paging_request *pag;
961
962 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
963 paging_dump_vty(vty, pag);
964}
965
966DEFUN(show_paging,
967 show_paging_cmd,
968 "show paging [bts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200969 SHOW_STR "Display information about paging reuqests of a BTS\n"
970 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800971{
Harald Welte40152872010-05-16 20:52:23 +0200972 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800973 struct gsm_bts *bts;
974 int bts_nr;
975
976 if (argc >= 1) {
977 /* use the BTS number that the user has specified */
978 bts_nr = atoi(argv[0]);
979 if (bts_nr >= net->num_bts) {
980 vty_out(vty, "%% can't find BTS %s%s", argv[0],
981 VTY_NEWLINE);
982 return CMD_WARNING;
983 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200984 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800985 bts_paging_dump_vty(vty, bts);
986
987 return CMD_SUCCESS;
988 }
989 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200990 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800991 bts_paging_dump_vty(vty, bts);
992 }
993
994 return CMD_SUCCESS;
995}
996
Harald Welte9e002452010-05-11 21:53:49 +0200997#define NETWORK_STR "Configure the GSM network\n"
998
Harald Weltee87eb462009-08-07 13:29:14 +0200999DEFUN(cfg_net,
1000 cfg_net_cmd,
Harald Welte9e002452010-05-11 21:53:49 +02001001 "network", NETWORK_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001002{
Harald Welte40152872010-05-16 20:52:23 +02001003 vty->index = gsmnet_from_vty(vty);
Harald Weltee87eb462009-08-07 13:29:14 +02001004 vty->node = GSMNET_NODE;
1005
1006 return CMD_SUCCESS;
1007}
1008
1009
1010DEFUN(cfg_net_ncc,
1011 cfg_net_ncc_cmd,
1012 "network country code <1-999>",
1013 "Set the GSM network country code")
1014{
Harald Welte40152872010-05-16 20:52:23 +02001015 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1016
Harald Weltee87eb462009-08-07 13:29:14 +02001017 gsmnet->country_code = atoi(argv[0]);
1018
1019 return CMD_SUCCESS;
1020}
1021
1022DEFUN(cfg_net_mnc,
1023 cfg_net_mnc_cmd,
1024 "mobile network code <1-999>",
1025 "Set the GSM mobile network code")
1026{
Harald Welte40152872010-05-16 20:52:23 +02001027 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1028
Harald Weltee87eb462009-08-07 13:29:14 +02001029 gsmnet->network_code = atoi(argv[0]);
1030
1031 return CMD_SUCCESS;
1032}
1033
1034DEFUN(cfg_net_name_short,
1035 cfg_net_name_short_cmd,
1036 "short name NAME",
1037 "Set the short GSM network name")
1038{
Harald Welte40152872010-05-16 20:52:23 +02001039 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1040
Harald Weltee87eb462009-08-07 13:29:14 +02001041 if (gsmnet->name_short)
1042 talloc_free(gsmnet->name_short);
1043
1044 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
1045
1046 return CMD_SUCCESS;
1047}
1048
1049DEFUN(cfg_net_name_long,
1050 cfg_net_name_long_cmd,
1051 "long name NAME",
1052 "Set the long GSM network name")
1053{
Harald Welte40152872010-05-16 20:52:23 +02001054 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1055
Harald Weltee87eb462009-08-07 13:29:14 +02001056 if (gsmnet->name_long)
1057 talloc_free(gsmnet->name_long);
1058
1059 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
1060
1061 return CMD_SUCCESS;
1062}
Harald Welte59b04682009-06-10 05:40:52 +08001063
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001064DEFUN(cfg_net_auth_policy,
1065 cfg_net_auth_policy_cmd,
1066 "auth policy (closed|accept-all|token)",
Harald Welte9e002452010-05-11 21:53:49 +02001067 "Authentication (not cryptographic)\n"
1068 "Set the GSM network authentication policy\n"
1069 "Require the MS to be activated in HLR\n"
1070 "Accept all MS, whether in HLR or not\n"
1071 "Use SMS-token based authentication\n")
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001072{
1073 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001074 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001075
1076 gsmnet->auth_policy = policy;
1077
1078 return CMD_SUCCESS;
1079}
1080
Harald Welte59936d72009-11-18 20:33:19 +01001081DEFUN(cfg_net_reject_cause,
1082 cfg_net_reject_cause_cmd,
1083 "location updating reject cause <2-111>",
1084 "Set the reject cause of location updating reject\n")
1085{
Harald Welte40152872010-05-16 20:52:23 +02001086 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1087
Harald Welte59936d72009-11-18 20:33:19 +01001088 gsmnet->reject_cause = atoi(argv[0]);
1089
1090 return CMD_SUCCESS;
1091}
1092
Harald Weltecca253a2009-08-30 15:47:06 +09001093DEFUN(cfg_net_encryption,
1094 cfg_net_encryption_cmd,
1095 "encryption a5 (0|1|2)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001096 "Encryption options\n"
1097 "A5 encryption\n" "A5/0: No encryption\n"
1098 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Weltecca253a2009-08-30 15:47:06 +09001099{
Harald Welte40152872010-05-16 20:52:23 +02001100 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1101
Andreas.Eversberg53293292009-11-17 09:55:26 +01001102 gsmnet->a5_encryption= atoi(argv[0]);
Harald Weltecca253a2009-08-30 15:47:06 +09001103
1104 return CMD_SUCCESS;
1105}
1106
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001107DEFUN(cfg_net_neci,
1108 cfg_net_neci_cmd,
1109 "neci (0|1)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001110 "New Establish Cause Indication\n"
1111 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001112{
Harald Welte40152872010-05-16 20:52:23 +02001113 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1114
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001115 gsmnet->neci = atoi(argv[0]);
1116 return CMD_SUCCESS;
1117}
1118
Harald Welte52af1952009-12-13 10:53:12 +01001119DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1120 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte9e002452010-05-11 21:53:49 +02001121 "Radio Resource Location Protocol\n"
1122 "Set the Radio Resource Location Protocol Mode\n"
1123 "Don't send RRLP request\n"
1124 "Request MS-based location\n"
1125 "Request any location, prefer MS-based\n"
1126 "Request any location, prefer MS-assisted\n")
Harald Welte52af1952009-12-13 10:53:12 +01001127{
Harald Welte40152872010-05-16 20:52:23 +02001128 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1129
Harald Welte52af1952009-12-13 10:53:12 +01001130 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1131
1132 return CMD_SUCCESS;
1133}
1134
Harald Weltea310f3e2009-12-14 09:00:24 +01001135DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1136 "mm info (0|1)",
1137 "Whether to send MM INFO after LOC UPD ACCEPT")
1138{
Harald Welte40152872010-05-16 20:52:23 +02001139 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1140
Harald Weltea310f3e2009-12-14 09:00:24 +01001141 gsmnet->send_mm_info = atoi(argv[0]);
1142
1143 return CMD_SUCCESS;
1144}
1145
Harald Welte9e002452010-05-11 21:53:49 +02001146#define HANDOVER_STR "Handover Options\n"
1147
Harald Welte0af9c9f2009-12-19 21:41:52 +01001148DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1149 "handover (0|1)",
Harald Welte9e002452010-05-11 21:53:49 +02001150 HANDOVER_STR
1151 "Don't perform in-call handover\n"
1152 "Perform in-call handover\n")
Harald Welte0af9c9f2009-12-19 21:41:52 +01001153{
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001154 int enable = atoi(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001155 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001156
1157 if (enable && ipacc_rtp_direct) {
Harald Welteaa2c3032009-12-20 13:51:01 +01001158 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1159 "is enabled by using the -P command line option%s",
1160 VTY_NEWLINE);
1161 return CMD_WARNING;
1162 }
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001163 gsmnet->handover.active = enable;
Harald Welte0af9c9f2009-12-19 21:41:52 +01001164
1165 return CMD_SUCCESS;
1166}
1167
Harald Welte9e002452010-05-11 21:53:49 +02001168#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1169#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1170#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1171#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1172
Harald Weltea8062f12009-12-21 16:51:50 +01001173DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1174 "handover window rxlev averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001175 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001176 "How many RxLev measurements are used for averaging")
1177{
Harald Welte40152872010-05-16 20:52:23 +02001178 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001179 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1180 return CMD_SUCCESS;
1181}
1182
1183DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1184 "handover window rxqual averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001185 HO_WIN_RXQUAL_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001186 "How many RxQual measurements are used for averaging")
1187{
Harald Welte40152872010-05-16 20:52:23 +02001188 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001189 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1190 return CMD_SUCCESS;
1191}
1192
1193DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1194 "handover window rxlev neighbor averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001195 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001196 "How many RxQual measurements are used for averaging")
1197{
Harald Welte40152872010-05-16 20:52:23 +02001198 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001199 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1200 return CMD_SUCCESS;
1201}
1202
1203DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1204 "handover power budget interval <1-99>",
Harald Welte9e002452010-05-11 21:53:49 +02001205 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001206 "How often to check if we have a better cell (SACCH frames)")
1207{
Harald Welte40152872010-05-16 20:52:23 +02001208 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001209 gsmnet->handover.pwr_interval = atoi(argv[0]);
1210 return CMD_SUCCESS;
1211}
1212
1213DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1214 "handover power budget hysteresis <0-999>",
Harald Welte9e002452010-05-11 21:53:49 +02001215 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001216 "How many dB does a neighbor to be stronger to become a HO candidate")
1217{
Harald Welte40152872010-05-16 20:52:23 +02001218 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001219 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1220 return CMD_SUCCESS;
1221}
1222
1223DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1224 "handover maximum distance <0-9999>",
Harald Welte9e002452010-05-11 21:53:49 +02001225 HANDOVER_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001226 "How big is the maximum timing advance before HO is forced")
1227{
Harald Welte40152872010-05-16 20:52:23 +02001228 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001229 gsmnet->handover.max_distance = atoi(argv[0]);
1230 return CMD_SUCCESS;
1231}
Harald Welte0af9c9f2009-12-19 21:41:52 +01001232
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001233#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001234 DEFUN(cfg_net_T##number, \
1235 cfg_net_T##number##_cmd, \
1236 "timer t" #number " <0-65535>", \
Harald Welte9e002452010-05-11 21:53:49 +02001237 "Configure GSM Timers\n" \
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001238 doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001239{ \
Harald Welte40152872010-05-16 20:52:23 +02001240 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001241 int value = atoi(argv[0]); \
1242 \
1243 if (value < 0 || value > 65535) { \
1244 vty_out(vty, "Timer value %s out of range.%s", \
1245 argv[0], VTY_NEWLINE); \
1246 return CMD_WARNING; \
1247 } \
1248 \
1249 gsmnet->T##number = value; \
1250 return CMD_SUCCESS; \
1251}
1252
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001253DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1254DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1255DECLARE_TIMER(3105, "Currently not used.")
1256DECLARE_TIMER(3107, "Currently not used.")
1257DECLARE_TIMER(3109, "Currently not used.")
Holger Hans Peter Freyther4a00c062010-05-31 21:33:15 +08001258DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001259DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1260DECLARE_TIMER(3115, "Currently not used.")
1261DECLARE_TIMER(3117, "Currently not used.")
1262DECLARE_TIMER(3119, "Currently not used.")
1263DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001264
1265
Harald Welte59b04682009-06-10 05:40:52 +08001266/* per-BTS configuration */
1267DEFUN(cfg_bts,
1268 cfg_bts_cmd,
1269 "bts BTS_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001270 "Select a BTS to configure\n"
1271 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001272{
Harald Welte40152872010-05-16 20:52:23 +02001273 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001274 int bts_nr = atoi(argv[0]);
1275 struct gsm_bts *bts;
1276
Harald Weltee712a5f2009-06-21 16:17:15 +02001277 if (bts_nr > gsmnet->num_bts) {
1278 vty_out(vty, "%% The next unused BTS number is %u%s",
1279 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001280 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001281 } else if (bts_nr == gsmnet->num_bts) {
1282 /* allocate a new one */
1283 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1284 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001285 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001286 bts = gsm_bts_num(gsmnet, bts_nr);
1287
Daniel Willmann580085f2010-01-11 13:43:07 +01001288 if (!bts) {
1289 vty_out(vty, "%% Unable to allocate BTS %u%s",
1290 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee712a5f2009-06-21 16:17:15 +02001291 return CMD_WARNING;
Daniel Willmann580085f2010-01-11 13:43:07 +01001292 }
Harald Welte59b04682009-06-10 05:40:52 +08001293
1294 vty->index = bts;
Harald Welte8791dac2010-05-14 17:59:53 +02001295 vty->index_sub = &bts->description;
Harald Welte59b04682009-06-10 05:40:52 +08001296 vty->node = BTS_NODE;
1297
1298 return CMD_SUCCESS;
1299}
1300
1301DEFUN(cfg_bts_type,
1302 cfg_bts_type_cmd,
1303 "type TYPE",
1304 "Set the BTS type\n")
1305{
1306 struct gsm_bts *bts = vty->index;
Harald Welte59698fb2010-01-10 18:01:52 +01001307 int rc;
Harald Welte59b04682009-06-10 05:40:52 +08001308
Harald Welte59698fb2010-01-10 18:01:52 +01001309 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1310 if (rc < 0)
1311 return CMD_WARNING;
Harald Welte25572872009-10-20 00:22:00 +02001312
Harald Welte59b04682009-06-10 05:40:52 +08001313 return CMD_SUCCESS;
1314}
1315
Harald Welte91afe4c2009-06-20 18:15:19 +02001316DEFUN(cfg_bts_band,
1317 cfg_bts_band_cmd,
1318 "band BAND",
1319 "Set the frequency band of this BTS\n")
1320{
1321 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +02001322 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +02001323
1324 if (band < 0) {
1325 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1326 band, VTY_NEWLINE);
1327 return CMD_WARNING;
1328 }
1329
1330 bts->band = band;
1331
1332 return CMD_SUCCESS;
1333}
1334
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001335DEFUN(cfg_bts_ci,
1336 cfg_bts_ci_cmd,
1337 "cell_identity <0-65535>",
1338 "Set the Cell identity of this BTS\n")
1339{
1340 struct gsm_bts *bts = vty->index;
1341 int ci = atoi(argv[0]);
1342
1343 if (ci < 0 || ci > 0xffff) {
1344 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1345 ci, VTY_NEWLINE);
1346 return CMD_WARNING;
1347 }
1348 bts->cell_identity = ci;
1349
1350 return CMD_SUCCESS;
1351}
1352
Harald Welte59b04682009-06-10 05:40:52 +08001353DEFUN(cfg_bts_lac,
1354 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001355 "location_area_code <0-65535>",
Harald Welte59b04682009-06-10 05:40:52 +08001356 "Set the Location Area Code (LAC) of this BTS\n")
1357{
1358 struct gsm_bts *bts = vty->index;
1359 int lac = atoi(argv[0]);
1360
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001361 if (lac < 0 || lac > 0xffff) {
1362 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001363 lac, VTY_NEWLINE);
1364 return CMD_WARNING;
1365 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +02001366
1367 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1368 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1369 lac, VTY_NEWLINE);
1370 return CMD_WARNING;
1371 }
1372
Harald Welte59b04682009-06-10 05:40:52 +08001373 bts->location_area_code = lac;
1374
1375 return CMD_SUCCESS;
1376}
1377
Harald Weltea54a2bb2009-12-01 18:04:30 +05301378
Harald Welte59b04682009-06-10 05:40:52 +08001379DEFUN(cfg_bts_tsc,
1380 cfg_bts_tsc_cmd,
1381 "training_sequence_code <0-255>",
1382 "Set the Training Sequence Code (TSC) of this BTS\n")
1383{
1384 struct gsm_bts *bts = vty->index;
1385 int tsc = atoi(argv[0]);
1386
1387 if (tsc < 0 || tsc > 0xff) {
1388 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1389 tsc, VTY_NEWLINE);
1390 return CMD_WARNING;
1391 }
1392 bts->tsc = tsc;
1393
1394 return CMD_SUCCESS;
1395}
1396
1397DEFUN(cfg_bts_bsic,
1398 cfg_bts_bsic_cmd,
1399 "base_station_id_code <0-63>",
1400 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1401{
1402 struct gsm_bts *bts = vty->index;
1403 int bsic = atoi(argv[0]);
1404
1405 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +02001406 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001407 bsic, VTY_NEWLINE);
1408 return CMD_WARNING;
1409 }
1410 bts->bsic = bsic;
1411
1412 return CMD_SUCCESS;
1413}
1414
1415
1416DEFUN(cfg_bts_unit_id,
1417 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +02001418 "ip.access unit_id <0-65534> <0-255>",
1419 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +08001420{
1421 struct gsm_bts *bts = vty->index;
1422 int site_id = atoi(argv[0]);
1423 int bts_id = atoi(argv[1]);
1424
Harald Weltef515aa02009-08-07 13:27:09 +02001425 if (!is_ipaccess_bts(bts)) {
1426 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1427 return CMD_WARNING;
1428 }
1429
Harald Welte59b04682009-06-10 05:40:52 +08001430 bts->ip_access.site_id = site_id;
1431 bts->ip_access.bts_id = bts_id;
1432
1433 return CMD_SUCCESS;
1434}
1435
Harald Welte9e002452010-05-11 21:53:49 +02001436#define OML_STR "Organization & Maintenance Link\n"
1437#define IPA_STR "ip.access Specific Options\n"
1438
Harald Welte25572872009-10-20 00:22:00 +02001439DEFUN(cfg_bts_stream_id,
1440 cfg_bts_stream_id_cmd,
1441 "oml ip.access stream_id <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001442 OML_STR IPA_STR
Harald Welte25572872009-10-20 00:22:00 +02001443 "Set the ip.access Stream ID of the OML link of this BTS\n")
1444{
1445 struct gsm_bts *bts = vty->index;
1446 int stream_id = atoi(argv[0]);
1447
1448 if (!is_ipaccess_bts(bts)) {
1449 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1450 return CMD_WARNING;
1451 }
1452
1453 bts->oml_tei = stream_id;
1454
1455 return CMD_SUCCESS;
1456}
1457
Harald Welte9e002452010-05-11 21:53:49 +02001458#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte25572872009-10-20 00:22:00 +02001459
Harald Welte62868882009-08-08 16:12:58 +02001460DEFUN(cfg_bts_oml_e1,
1461 cfg_bts_oml_e1_cmd,
1462 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte9e002452010-05-11 21:53:49 +02001463 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001464 "E1 interface to be used for OML\n")
1465{
1466 struct gsm_bts *bts = vty->index;
1467
1468 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1469
1470 return CMD_SUCCESS;
1471}
1472
1473
1474DEFUN(cfg_bts_oml_e1_tei,
1475 cfg_bts_oml_e1_tei_cmd,
1476 "oml e1 tei <0-63>",
Harald Welte9e002452010-05-11 21:53:49 +02001477 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001478 "Set the TEI to be used for OML")
1479{
1480 struct gsm_bts *bts = vty->index;
1481
1482 bts->oml_tei = atoi(argv[0]);
1483
1484 return CMD_SUCCESS;
1485}
1486
Harald Welte3e774612009-08-10 13:48:16 +02001487DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1488 "channel allocator (ascending|descending)",
Harald Welte9e002452010-05-11 21:53:49 +02001489 "Channnel Allocator\n" "Channel Allocator\n"
1490 "Allocate Timeslots and Transceivers in ascending order\n"
1491 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte3e774612009-08-10 13:48:16 +02001492{
1493 struct gsm_bts *bts = vty->index;
1494
1495 if (!strcmp(argv[0], "ascending"))
1496 bts->chan_alloc_reverse = 0;
1497 else
1498 bts->chan_alloc_reverse = 1;
1499
1500 return CMD_SUCCESS;
1501}
1502
Harald Welte9e002452010-05-11 21:53:49 +02001503#define RACH_STR "Random Access Control Channel\n"
1504
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001505DEFUN(cfg_bts_rach_tx_integer,
1506 cfg_bts_rach_tx_integer_cmd,
1507 "rach tx integer <0-15>",
Harald Welte9e002452010-05-11 21:53:49 +02001508 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001509 "Set the raw tx integer value in RACH Control parameters IE")
1510{
1511 struct gsm_bts *bts = vty->index;
1512 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1513 return CMD_SUCCESS;
1514}
1515
1516DEFUN(cfg_bts_rach_max_trans,
1517 cfg_bts_rach_max_trans_cmd,
1518 "rach max transmission (1|2|4|7)",
Harald Welte9e002452010-05-11 21:53:49 +02001519 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001520 "Set the maximum number of RACH burst transmissions")
1521{
1522 struct gsm_bts *bts = vty->index;
1523 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1524 return CMD_SUCCESS;
1525}
1526
Harald Welte9e002452010-05-11 21:53:49 +02001527#define NM_STR "Network Management\n"
1528
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001529DEFUN(cfg_bts_rach_nm_b_thresh,
1530 cfg_bts_rach_nm_b_thresh_cmd,
1531 "rach nm busy threshold <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001532 RACH_STR NM_STR
1533 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001534{
1535 struct gsm_bts *bts = vty->index;
1536 bts->rach_b_thresh = atoi(argv[0]);
1537 return CMD_SUCCESS;
1538}
1539
1540DEFUN(cfg_bts_rach_nm_ldavg,
1541 cfg_bts_rach_nm_ldavg_cmd,
1542 "rach nm load average <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001543 RACH_STR NM_STR
1544 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001545{
1546 struct gsm_bts *bts = vty->index;
1547 bts->rach_ldavg_slots = atoi(argv[0]);
1548 return CMD_SUCCESS;
1549}
1550
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001551DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1552 "cell barred (0|1)",
1553 "Should this cell be barred from access?")
1554{
1555 struct gsm_bts *bts = vty->index;
1556
Harald Welte8c973ba2009-12-21 23:08:18 +01001557 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001558
1559 return CMD_SUCCESS;
1560}
1561
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08001562DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1563 "rach emergency call allowed (0|1)",
1564 "Should this cell allow emergency calls?")
1565{
1566 struct gsm_bts *bts = vty->index;
1567
1568 if (atoi(argv[0]) == 0)
1569 bts->si_common.rach_control.t2 |= 0x4;
1570 else
1571 bts->si_common.rach_control.t2 &= ~0x4;
1572
1573 return CMD_SUCCESS;
1574}
1575
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001576DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1577 "ms max power <0-40>",
1578 "Maximum transmit power of the MS")
1579{
1580 struct gsm_bts *bts = vty->index;
1581
1582 bts->ms_max_power = atoi(argv[0]);
1583
1584 return CMD_SUCCESS;
1585}
1586
Harald Welteb761bf82009-12-12 18:17:25 +01001587DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1588 "cell reselection hysteresis <0-14>",
1589 "Cell Re-Selection Hysteresis in dB")
1590{
1591 struct gsm_bts *bts = vty->index;
1592
1593 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1594
1595 return CMD_SUCCESS;
1596}
1597
1598DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1599 "rxlev access min <0-63>",
1600 "Minimum RxLev needed for cell access (better than -110dBm)")
1601{
1602 struct gsm_bts *bts = vty->index;
1603
1604 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1605
1606 return CMD_SUCCESS;
1607}
1608
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001609DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1610 "periodic location update <0-1530>",
1611 "Periodic Location Updating Interval in Minutes")
1612{
1613 struct gsm_bts *bts = vty->index;
1614
Harald Weltea54a2bb2009-12-01 18:04:30 +05301615 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001616
1617 return CMD_SUCCESS;
1618}
1619
Harald Welte9e002452010-05-11 21:53:49 +02001620#define GPRS_TEXT "GPRS Packet Network\n"
1621
Harald Welte410575a2010-03-14 23:30:30 +08001622DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welteb42fe342010-04-18 14:00:26 +02001623 "gprs cell bvci <2-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001624 GPRS_TEXT
1625 "GPRS Cell Settings\n"
Harald Welte3055e332010-03-14 15:37:43 +08001626 "GPRS BSSGP VC Identifier")
1627{
1628 struct gsm_bts *bts = vty->index;
1629
Harald Weltecb20b7a2010-04-18 15:51:20 +02001630 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001631 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1632 return CMD_WARNING;
1633 }
1634
Harald Welte3055e332010-03-14 15:37:43 +08001635 bts->gprs.cell.bvci = atoi(argv[0]);
1636
1637 return CMD_SUCCESS;
1638}
1639
Harald Welte4a048c52010-03-22 11:48:36 +08001640DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1641 "gprs nsei <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001642 GPRS_TEXT
Harald Welte4a048c52010-03-22 11:48:36 +08001643 "GPRS NS Entity Identifier")
1644{
1645 struct gsm_bts *bts = vty->index;
1646
Harald Weltecb20b7a2010-04-18 15:51:20 +02001647 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte4a048c52010-03-22 11:48:36 +08001648 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1649 return CMD_WARNING;
1650 }
1651
1652 bts->gprs.nse.nsei = atoi(argv[0]);
1653
1654 return CMD_SUCCESS;
1655}
1656
Harald Welte9e002452010-05-11 21:53:49 +02001657#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1658 "NSVC Logical Number\n"
Harald Welte4a048c52010-03-22 11:48:36 +08001659
Harald Welte3055e332010-03-14 15:37:43 +08001660DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1661 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001662 GPRS_TEXT NSVC_TEXT
1663 "NS Virtual Connection Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08001664 "GPRS NS VC Identifier")
1665{
1666 struct gsm_bts *bts = vty->index;
1667 int idx = atoi(argv[0]);
1668
Harald Weltecb20b7a2010-04-18 15:51:20 +02001669 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001670 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1671 return CMD_WARNING;
1672 }
1673
Harald Welte3055e332010-03-14 15:37:43 +08001674 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1675
1676 return CMD_SUCCESS;
1677}
1678
Harald Welte410575a2010-03-14 23:30:30 +08001679DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1680 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001681 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001682 "GPRS NS Local UDP Port")
1683{
1684 struct gsm_bts *bts = vty->index;
1685 int idx = atoi(argv[0]);
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 Welte410575a2010-03-14 23:30:30 +08001692 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1693
1694 return CMD_SUCCESS;
1695}
1696
1697DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1698 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001699 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001700 "GPRS NS Remote UDP Port")
1701{
1702 struct gsm_bts *bts = vty->index;
1703 int idx = atoi(argv[0]);
1704
Harald Weltecb20b7a2010-04-18 15:51:20 +02001705 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001706 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1707 return CMD_WARNING;
1708 }
1709
Harald Welte410575a2010-03-14 23:30:30 +08001710 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1711
1712 return CMD_SUCCESS;
1713}
1714
1715DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1716 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte9e002452010-05-11 21:53:49 +02001717 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001718 "GPRS NS Remote IP Address")
1719{
1720 struct gsm_bts *bts = vty->index;
1721 int idx = atoi(argv[0]);
1722 struct in_addr ia;
1723
Harald Weltecb20b7a2010-04-18 15:51:20 +02001724 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001725 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1726 return CMD_WARNING;
1727 }
1728
Harald Welte410575a2010-03-14 23:30:30 +08001729 inet_aton(argv[1], &ia);
1730 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1731
1732 return CMD_SUCCESS;
1733}
1734
Harald Weltea9251762010-05-11 23:50:21 +02001735DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1736 "gprs ns timer " NS_TIMERS " <0-255>",
1737 GPRS_TEXT "Network Service\n"
1738 "Network Service Timer\n"
1739 NS_TIMERS_HELP "Timer Value\n")
1740{
1741 struct gsm_bts *bts = vty->index;
1742 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1743 int val = atoi(argv[1]);
1744
1745 if (bts->gprs.mode == BTS_GPRS_NONE) {
1746 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1747 return CMD_WARNING;
1748 }
1749
1750 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1751 return CMD_WARNING;
1752
1753 bts->gprs.nse.timer[idx] = val;
1754
1755 return CMD_SUCCESS;
1756}
1757
1758#define BSSGP_TIMERS "(blocking-timer|blocking-retries|unblocking-retries|reset-timer|reset-retries|suspend-timer|suspend-retries|resume-timer|resume-retries|capability-update-timer|capability-update-retries)"
Harald Welte18ce31c2010-05-14 20:05:17 +02001759#define BSSGP_TIMERS_HELP \
1760 "Tbvc-block timeout\n" \
1761 "Tbvc-block retries\n" \
1762 "Tbvc-unblock retries\n" \
1763 "Tbvcc-reset timeout\n" \
1764 "Tbvc-reset retries\n" \
1765 "Tbvc-suspend timeout\n" \
1766 "Tbvc-suspend retries\n" \
1767 "Tbvc-resume timeout\n" \
1768 "Tbvc-resume retries\n" \
1769 "Tbvc-capa-update timeout\n" \
1770 "Tbvc-capa-update retries\n"
Harald Weltea9251762010-05-11 23:50:21 +02001771
1772DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1773 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1774 GPRS_TEXT "Cell / BSSGP\n"
1775 "Cell/BSSGP Timer\n"
1776 BSSGP_TIMERS_HELP "Timer Value\n")
1777{
1778 struct gsm_bts *bts = vty->index;
1779 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1780 int val = atoi(argv[1]);
1781
1782 if (bts->gprs.mode == BTS_GPRS_NONE) {
1783 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1784 return CMD_WARNING;
1785 }
1786
1787 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
1788 return CMD_WARNING;
1789
1790 bts->gprs.cell.timer[idx] = val;
1791
1792 return CMD_SUCCESS;
1793}
1794
Harald Welte3055e332010-03-14 15:37:43 +08001795DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1796 "gprs routing area <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001797 GPRS_TEXT
Harald Welte3055e332010-03-14 15:37:43 +08001798 "GPRS Routing Area Code")
1799{
1800 struct gsm_bts *bts = vty->index;
1801
Harald Weltecb20b7a2010-04-18 15:51:20 +02001802 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001803 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1804 return CMD_WARNING;
1805 }
1806
Harald Welte3055e332010-03-14 15:37:43 +08001807 bts->gprs.rac = atoi(argv[0]);
1808
1809 return CMD_SUCCESS;
1810}
1811
Harald Weltecb20b7a2010-04-18 15:51:20 +02001812DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
1813 "gprs mode (none|gprs|egprs)",
Harald Welte9e002452010-05-11 21:53:49 +02001814 GPRS_TEXT
1815 "GPRS Mode for this BTS\n"
1816 "GPRS Disabled on this BTS\n"
1817 "GPRS Enabled on this BTS\n"
1818 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welte410575a2010-03-14 23:30:30 +08001819{
1820 struct gsm_bts *bts = vty->index;
Harald Welte20e275a2010-06-14 22:44:42 +02001821 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welte410575a2010-03-14 23:30:30 +08001822
Harald Welte20e275a2010-06-14 22:44:42 +02001823 if (mode != BTS_GPRS_NONE &&
1824 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
1825 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1826 VTY_NEWLINE);
1827 return CMD_WARNING;
1828 }
1829 if (mode == BTS_GPRS_EGPRS &&
1830 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
1831 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1832 VTY_NEWLINE);
1833 return CMD_WARNING;
1834 }
1835
1836 bts->gprs.mode = mode;
Harald Welte410575a2010-03-14 23:30:30 +08001837
1838 return CMD_SUCCESS;
1839}
1840
Harald Welte9e002452010-05-11 21:53:49 +02001841#define TRX_TEXT "Radio Transceiver\n"
Harald Welte3e774612009-08-10 13:48:16 +02001842
Harald Welte59b04682009-06-10 05:40:52 +08001843/* per TRX configuration */
1844DEFUN(cfg_trx,
1845 cfg_trx_cmd,
1846 "trx TRX_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001847 TRX_TEXT
Harald Welte59b04682009-06-10 05:40:52 +08001848 "Select a TRX to configure")
1849{
1850 int trx_nr = atoi(argv[0]);
1851 struct gsm_bts *bts = vty->index;
1852 struct gsm_bts_trx *trx;
1853
Harald Weltee712a5f2009-06-21 16:17:15 +02001854 if (trx_nr > bts->num_trx) {
1855 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1856 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001857 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001858 } else if (trx_nr == bts->num_trx) {
1859 /* we need to allocate a new one */
1860 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001861 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001862 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001863
Harald Weltee712a5f2009-06-21 16:17:15 +02001864 if (!trx)
1865 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08001866
1867 vty->index = trx;
Harald Welte8791dac2010-05-14 17:59:53 +02001868 vty->index_sub = &trx->description;
Harald Welte59b04682009-06-10 05:40:52 +08001869 vty->node = TRX_NODE;
1870
1871 return CMD_SUCCESS;
1872}
1873
1874DEFUN(cfg_trx_arfcn,
1875 cfg_trx_arfcn_cmd,
Harald Welte00044592010-05-14 19:00:52 +02001876 "arfcn <0-1024>",
Harald Welte59b04682009-06-10 05:40:52 +08001877 "Set the ARFCN for this TRX\n")
1878{
1879 int arfcn = atoi(argv[0]);
1880 struct gsm_bts_trx *trx = vty->index;
1881
1882 /* FIXME: check if this ARFCN is supported by this TRX */
1883
1884 trx->arfcn = arfcn;
1885
1886 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1887 /* FIXME: use OML layer to update the ARFCN */
1888 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
1889
1890 return CMD_SUCCESS;
1891}
1892
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01001893DEFUN(cfg_trx_nominal_power,
1894 cfg_trx_nominal_power_cmd,
1895 "nominal power <0-100>",
1896 "Nominal TRX RF Power in dB\n")
1897{
1898 struct gsm_bts_trx *trx = vty->index;
1899
1900 trx->nominal_power = atoi(argv[0]);
1901
1902 return CMD_SUCCESS;
1903}
1904
Harald Welte91afe4c2009-06-20 18:15:19 +02001905DEFUN(cfg_trx_max_power_red,
1906 cfg_trx_max_power_red_cmd,
1907 "max_power_red <0-100>",
1908 "Reduction of maximum BS RF Power in dB\n")
1909{
1910 int maxpwr_r = atoi(argv[0]);
1911 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01001912 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02001913
1914 /* FIXME: check if our BTS type supports more than 12 */
1915 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
1916 vty_out(vty, "%% Power %d dB is not in the valid range%s",
1917 maxpwr_r, VTY_NEWLINE);
1918 return CMD_WARNING;
1919 }
1920 if (maxpwr_r & 1) {
1921 vty_out(vty, "%% Power %d dB is not an even value%s",
1922 maxpwr_r, VTY_NEWLINE);
1923 return CMD_WARNING;
1924 }
1925
1926 trx->max_power_red = maxpwr_r;
1927
1928 /* FIXME: make sure we update this using OML */
1929
1930 return CMD_SUCCESS;
1931}
1932
Harald Welte62868882009-08-08 16:12:58 +02001933DEFUN(cfg_trx_rsl_e1,
1934 cfg_trx_rsl_e1_cmd,
1935 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1936 "E1 interface to be used for RSL\n")
1937{
1938 struct gsm_bts_trx *trx = vty->index;
1939
1940 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
1941
1942 return CMD_SUCCESS;
1943}
1944
1945DEFUN(cfg_trx_rsl_e1_tei,
1946 cfg_trx_rsl_e1_tei_cmd,
1947 "rsl e1 tei <0-63>",
1948 "Set the TEI to be used for RSL")
1949{
1950 struct gsm_bts_trx *trx = vty->index;
1951
1952 trx->rsl_tei = atoi(argv[0]);
1953
1954 return CMD_SUCCESS;
1955}
1956
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01001957DEFUN(cfg_trx_rf_locked,
1958 cfg_trx_rf_locked_cmd,
1959 "rf_locked (0|1)",
1960 "Turn off RF of the TRX.\n")
1961{
1962 int locked = atoi(argv[0]);
1963 struct gsm_bts_trx *trx = vty->index;
1964
1965 gsm_trx_lock_rf(trx, locked);
1966 return CMD_SUCCESS;
1967}
Harald Welte62868882009-08-08 16:12:58 +02001968
Harald Welte59b04682009-06-10 05:40:52 +08001969/* per TS configuration */
1970DEFUN(cfg_ts,
1971 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02001972 "timeslot <0-7>",
Harald Welte59b04682009-06-10 05:40:52 +08001973 "Select a Timeslot to configure")
1974{
1975 int ts_nr = atoi(argv[0]);
1976 struct gsm_bts_trx *trx = vty->index;
1977 struct gsm_bts_trx_ts *ts;
1978
1979 if (ts_nr >= TRX_NR_TS) {
1980 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
1981 TRX_NR_TS, VTY_NEWLINE);
1982 return CMD_WARNING;
1983 }
1984
1985 ts = &trx->ts[ts_nr];
1986
1987 vty->index = ts;
1988 vty->node = TS_NODE;
1989
1990 return CMD_SUCCESS;
1991}
1992
Harald Welte3ffe1b32009-08-07 00:25:23 +02001993DEFUN(cfg_ts_pchan,
1994 cfg_ts_pchan_cmd,
1995 "phys_chan_config PCHAN",
1996 "Physical Channel configuration (TCH/SDCCH/...)")
1997{
1998 struct gsm_bts_trx_ts *ts = vty->index;
1999 int pchanc;
2000
2001 pchanc = gsm_pchan_parse(argv[0]);
2002 if (pchanc < 0)
2003 return CMD_WARNING;
2004
2005 ts->pchan = pchanc;
2006
2007 return CMD_SUCCESS;
2008}
2009
Harald Weltea42a93f2010-06-14 22:26:10 +02002010#define HOPPING_STR "Configure frequency hopping\n"
2011
2012DEFUN(cfg_ts_hopping,
2013 cfg_ts_hopping_cmd,
2014 "hopping enabled (0|1)",
2015 HOPPING_STR "Enable or disable frequency hopping\n"
2016 "Disable frequency hopping\n" "Enable frequency hopping\n")
2017{
2018 struct gsm_bts_trx_ts *ts = vty->index;
Harald Welte059c1ef2010-06-14 22:47:37 +02002019 int enabled = atoi(argv[0]);
Harald Weltea42a93f2010-06-14 22:26:10 +02002020
Harald Welte059c1ef2010-06-14 22:47:37 +02002021 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2022 vty_out(vty, "BTS model does not support hopping%s",
2023 VTY_NEWLINE);
2024 return CMD_WARNING;
2025 }
2026
2027 ts->hopping.enabled = enabled;
Harald Weltea42a93f2010-06-14 22:26:10 +02002028
2029 return CMD_SUCCESS;
2030}
2031
Harald Welte67104d12009-09-12 13:05:33 +02002032DEFUN(cfg_ts_hsn,
2033 cfg_ts_hsn_cmd,
Harald Weltea42a93f2010-06-14 22:26:10 +02002034 "hopping sequence-number <0-63>",
2035 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002036 "Which hopping sequence to use for this channel")
2037{
2038 struct gsm_bts_trx_ts *ts = vty->index;
2039
2040 ts->hopping.hsn = atoi(argv[0]);
2041
2042 return CMD_SUCCESS;
2043}
2044
2045DEFUN(cfg_ts_maio,
2046 cfg_ts_maio_cmd,
2047 "hopping maio <0-63>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002048 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002049 "Which hopping MAIO to use for this channel")
2050{
2051 struct gsm_bts_trx_ts *ts = vty->index;
2052
2053 ts->hopping.maio = atoi(argv[0]);
2054
2055 return CMD_SUCCESS;
2056}
2057
2058DEFUN(cfg_ts_arfcn_add,
2059 cfg_ts_arfcn_add_cmd,
2060 "hopping arfcn add <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002061 HOPPING_STR "Configure hopping ARFCN list\n"
2062 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002063{
2064 struct gsm_bts_trx_ts *ts = vty->index;
2065 int arfcn = atoi(argv[0]);
2066
Harald Weltea42a93f2010-06-14 22:26:10 +02002067 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2068
Harald Welte67104d12009-09-12 13:05:33 +02002069 return CMD_SUCCESS;
2070}
2071
2072DEFUN(cfg_ts_arfcn_del,
2073 cfg_ts_arfcn_del_cmd,
2074 "hopping arfcn del <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002075 HOPPING_STR "Configure hopping ARFCN list\n"
2076 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002077{
2078 struct gsm_bts_trx_ts *ts = vty->index;
2079 int arfcn = atoi(argv[0]);
2080
Harald Weltea42a93f2010-06-14 22:26:10 +02002081 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2082
Harald Welte67104d12009-09-12 13:05:33 +02002083 return CMD_SUCCESS;
2084}
2085
Harald Welte3ffe1b32009-08-07 00:25:23 +02002086DEFUN(cfg_ts_e1_subslot,
2087 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002088 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte3ffe1b32009-08-07 00:25:23 +02002089 "E1 sub-slot connected to this on-air timeslot")
2090{
2091 struct gsm_bts_trx_ts *ts = vty->index;
2092
Harald Welte62868882009-08-08 16:12:58 +02002093 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002094
2095 return CMD_SUCCESS;
2096}
Harald Welte59b04682009-06-10 05:40:52 +08002097
Harald Weltea5b1dae2010-05-16 21:47:13 +02002098void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2099{
2100 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2101 counter_get(net->stats.chreq.total),
2102 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2103 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2104 counter_get(net->stats.chan.rf_fail),
2105 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2106 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2107 counter_get(net->stats.paging.attempted),
2108 counter_get(net->stats.paging.completed),
2109 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2110 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2111 counter_get(net->stats.bts.oml_fail),
2112 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2113}
2114
Harald Welte682ee5f2010-05-16 22:02:16 +02002115DEFUN(logging_fltr_imsi,
2116 logging_fltr_imsi_cmd,
2117 "logging filter imsi IMSI",
2118 LOGGING_STR FILTER_STR
2119 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2120{
2121 struct telnet_connection *conn;
2122
2123 conn = (struct telnet_connection *) vty->priv;
2124 if (!conn->dbg) {
2125 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
2126 return CMD_WARNING;
2127 }
2128
2129 log_set_imsi_filter(conn->dbg, argv[0]);
2130 return CMD_SUCCESS;
2131}
2132
Harald Welte40152872010-05-16 20:52:23 +02002133extern int bsc_vty_init_extra(void);
Harald Welte10c29f62010-05-16 19:20:24 +02002134extern const char *openbsc_copyright;
Holger Hans Peter Freytherc48a2a12010-04-10 00:08:28 +02002135
Harald Welte40152872010-05-16 20:52:23 +02002136int bsc_vty_init(void)
Harald Welte59b04682009-06-10 05:40:52 +08002137{
Harald Welte7bc28f62010-05-12 16:10:35 +00002138 install_element_ve(&show_net_cmd);
2139 install_element_ve(&show_bts_cmd);
2140 install_element_ve(&show_trx_cmd);
2141 install_element_ve(&show_ts_cmd);
2142 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08002143 install_element_ve(&show_lchan_summary_cmd);
Harald Welte682ee5f2010-05-16 22:02:16 +02002144 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002145
Harald Welte7bc28f62010-05-12 16:10:35 +00002146 install_element_ve(&show_e1drv_cmd);
2147 install_element_ve(&show_e1line_cmd);
2148 install_element_ve(&show_e1ts_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002149
Harald Welte7bc28f62010-05-12 16:10:35 +00002150 install_element_ve(&show_paging_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002151
Harald Welte682ee5f2010-05-16 22:02:16 +02002152 logging_vty_add_cmds();
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +01002153
Harald Weltee87eb462009-08-07 13:29:14 +02002154 install_element(CONFIG_NODE, &cfg_net_cmd);
2155 install_node(&net_node, config_write_net);
2156 install_default(GSMNET_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002157 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002158 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002159 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002160 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2161 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2162 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02002163 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte59936d72009-11-18 20:33:19 +01002164 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09002165 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01002166 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welte52af1952009-12-13 10:53:12 +01002167 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte284ddba2009-12-14 17:49:15 +01002168 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Welte0af9c9f2009-12-19 21:41:52 +01002169 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Weltea8062f12009-12-21 16:51:50 +01002170 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2171 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2172 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2173 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2174 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2175 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01002176 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002177 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2178 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2179 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2180 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2181 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2182 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2183 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2184 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2185 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
2186 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002187
2188 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02002189 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08002190 install_default(BTS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002191 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002192 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002193 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002194 install_element(BTS_NODE, &cfg_description_cmd);
2195 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02002196 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02002197 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002198 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2199 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002200 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002201 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte25572872009-10-20 00:22:00 +02002202 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002203 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2204 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02002205 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01002206 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2207 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08002208 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2209 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02002210 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08002211 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02002212 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002213 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welteb761bf82009-12-12 18:17:25 +01002214 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2215 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Weltecb20b7a2010-04-18 15:51:20 +02002216 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002217 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002218 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2219 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002220 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Welte4a048c52010-03-22 11:48:36 +08002221 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002222 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welte410575a2010-03-14 23:30:30 +08002223 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2224 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2225 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002226
2227 install_element(BTS_NODE, &cfg_trx_cmd);
2228 install_node(&trx_node, dummy_config_write);
2229 install_default(TRX_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002230 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002231 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002232 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002233 install_element(TRX_NODE, &cfg_description_cmd);
2234 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002235 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02002236 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002237 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2238 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002239 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002240
2241 install_element(TRX_NODE, &cfg_ts_cmd);
2242 install_node(&ts_node, dummy_config_write);
2243 install_default(TS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002244 install_element(TS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002245 install_element(TS_NODE, &ournode_end_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002246 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Weltea42a93f2010-06-14 22:26:10 +02002247 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte67104d12009-09-12 13:05:33 +02002248 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2249 install_element(TS_NODE, &cfg_ts_maio_cmd);
2250 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2251 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002252 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002253
Harald Welte63b964e2010-05-31 16:40:40 +02002254 abis_nm_vty_init();
2255
Harald Welte40152872010-05-16 20:52:23 +02002256 bsc_vty_init_extra();
Harald Welte59b04682009-06-10 05:40:52 +08002257
2258 return 0;
2259}